From 47d5395d24c6f209a758a689bff9a44f68d7397b Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 30 Mar 2014 13:44:28 +0200 Subject: Added a blockface parameter to the OnProjectileHitBlock hook. --- src/Bindings/Plugin.h | 2 +- src/Bindings/PluginLua.cpp | 4 ++-- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 4 ++-- src/Bindings/PluginManager.h | 2 +- src/Entities/ProjectileEntity.cpp | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index df0bd4dcc..4144bc734 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -90,7 +90,7 @@ public: virtual bool OnPluginsLoaded (void) = 0; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; - virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile) = 0; + virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face) = 0; virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) = 0; virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) = 0; virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 7e69e0f4b..9e989a9e1 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -1108,14 +1108,14 @@ bool cPluginLua::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a -bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile) +bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, eBlockFace a_Face) { cCSLock Lock(m_CriticalSection); bool res = false; cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_BLOCK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Projectile, cLuaState::Return, res); + m_LuaState.Call((int)(**itr), &a_Projectile, a_Face, cLuaState::Return, res); if (res) { return true; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 59542d23a..e89baaf53 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -113,7 +113,7 @@ public: virtual bool OnPluginsLoaded (void) override; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; - virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile) override; + virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face) override; virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) override; virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) override; virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 6a5356c0b..7116a5826 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1154,7 +1154,7 @@ bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCrafti -bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile) +bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, eBlockFace a_Face) { HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_BLOCK); if (Plugins == m_Hooks.end()) @@ -1163,7 +1163,7 @@ bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnProjectileHitBlock(a_Projectile)) + if ((*itr)->OnProjectileHitBlock(a_Projectile, a_Face)) { return true; } diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 512bc1351..89a2170df 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -206,7 +206,7 @@ public: // tolua_export bool CallHookPluginsLoaded (void); bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); - bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile); + bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face); bool CallHookProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity); bool CallHookSpawnedEntity (cWorld & a_World, cEntity & a_Entity); bool CallHookSpawnedMonster (cWorld & a_World, cMonster & a_Monster); diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index a9735a53c..37964d102 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -67,7 +67,7 @@ protected: eBlockFace Face; if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face)) { - if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile)) + if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, Face)) { return false; } -- cgit v1.2.3 From 66f1bb7b677324dd59265b7b0776490caa661bcc Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 30 Mar 2014 14:04:44 +0200 Subject: Added a BlockHitPos parameter to OnProjectileHitBlock --- src/Bindings/Plugin.h | 2 +- src/Bindings/PluginLua.cpp | 4 ++-- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 4 ++-- src/Bindings/PluginManager.h | 2 +- src/Entities/ProjectileEntity.cpp | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 4144bc734..9c2b59609 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -90,7 +90,7 @@ public: virtual bool OnPluginsLoaded (void) = 0; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; - virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face) = 0; + virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face, Vector3d * a_BlockHitPos) = 0; virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) = 0; virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) = 0; virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 9e989a9e1..a89cfc82c 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -1108,14 +1108,14 @@ bool cPluginLua::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a -bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, eBlockFace a_Face) +bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, eBlockFace a_Face, Vector3d * a_BlockHitPos) { cCSLock Lock(m_CriticalSection); bool res = false; cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_BLOCK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Projectile, a_Face, cLuaState::Return, res); + m_LuaState.Call((int)(**itr), &a_Projectile, a_Face, a_BlockHitPos, cLuaState::Return, res); if (res) { return true; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index e89baaf53..2e757f9dd 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -113,7 +113,7 @@ public: virtual bool OnPluginsLoaded (void) override; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; - virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face) override; + virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face, Vector3d * a_BlockHitPos) override; virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) override; virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) override; virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 7116a5826..0aa52e97e 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1154,7 +1154,7 @@ bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCrafti -bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, eBlockFace a_Face) +bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, eBlockFace a_Face, Vector3d * a_BlockHitPos) { HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_BLOCK); if (Plugins == m_Hooks.end()) @@ -1163,7 +1163,7 @@ bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnProjectileHitBlock(a_Projectile, a_Face)) + if ((*itr)->OnProjectileHitBlock(a_Projectile, a_Face, a_BlockHitPos)) { return true; } diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 89a2170df..5fdbaac1c 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -206,7 +206,7 @@ public: // tolua_export bool CallHookPluginsLoaded (void); bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); - bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face); + bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face, Vector3d * a_BlockHitPos); bool CallHookProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity); bool CallHookSpawnedEntity (cWorld & a_World, cEntity & a_Entity); bool CallHookSpawnedMonster (cWorld & a_World, cMonster & a_Monster); diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 37964d102..72ebf5775 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -67,12 +67,12 @@ protected: eBlockFace Face; if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face)) { - if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, Face)) + Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff; + if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, Face, &Intersection)) { return false; } - Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff; m_Projectile->OnHitSolidBlock(Intersection, Face); return true; } -- cgit v1.2.3 From 36e1e57d038eda0c183f616f2b45d2ae4733e27c Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 30 Mar 2014 17:21:13 +0200 Subject: Using recommendations (I think) --- src/Bindings/Plugin.h | 2 +- src/Bindings/PluginLua.cpp | 2 +- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 2 +- src/Bindings/PluginManager.h | 2 +- src/Entities/ProjectileEntity.cpp | 3 ++- 6 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 9c2b59609..a6f91382c 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -90,7 +90,7 @@ public: virtual bool OnPluginsLoaded (void) = 0; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; - virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face, Vector3d * a_BlockHitPos) = 0; + virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face, const Vector3i * a_BlockHitPos) = 0; virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) = 0; virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) = 0; virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index a89cfc82c..97f78351b 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -1108,7 +1108,7 @@ bool cPluginLua::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a -bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, eBlockFace a_Face, Vector3d * a_BlockHitPos) +bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, eBlockFace a_Face, const Vector3i * a_BlockHitPos) { cCSLock Lock(m_CriticalSection); bool res = false; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 2e757f9dd..627aa3cc8 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -113,7 +113,7 @@ public: virtual bool OnPluginsLoaded (void) override; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; - virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face, Vector3d * a_BlockHitPos) override; + virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face, const Vector3i * a_BlockHitPos) override; virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) override; virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) override; virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 0aa52e97e..a5c904a77 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1154,7 +1154,7 @@ bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCrafti -bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, eBlockFace a_Face, Vector3d * a_BlockHitPos) +bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, eBlockFace a_Face, const Vector3i * a_BlockHitPos) { HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_BLOCK); if (Plugins == m_Hooks.end()) diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 5fdbaac1c..35755459a 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -206,7 +206,7 @@ public: // tolua_export bool CallHookPluginsLoaded (void); bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); - bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face, Vector3d * a_BlockHitPos); + bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face, const Vector3i * a_BlockHitPos); bool CallHookProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity); bool CallHookSpawnedEntity (cWorld & a_World, cEntity & a_Entity); bool CallHookSpawnedMonster (cWorld & a_World, cMonster & a_Monster); diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 72ebf5775..7a869a957 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -68,7 +68,8 @@ protected: if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face)) { Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff; - if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, Face, &Intersection)) + const Vector3i BlockHitPos = Vector3i(Intersection); + if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, Face, &BlockHitPos)) { return false; } -- cgit v1.2.3 From ca08a44c988ed7c295a43e9a0a9579b093e4abf4 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 3 Apr 2014 21:43:40 +0200 Subject: Grass now grows under up-side-down slabs --- src/Blocks/BlockDirt.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index 91534c5e5..098494585 100644 --- a/src/Blocks/BlockDirt.h +++ b/src/Blocks/BlockDirt.h @@ -3,6 +3,7 @@ #include "BlockHandler.h" #include "../MersenneTwister.h" +#include "BlockSlab.h" @@ -35,8 +36,10 @@ public: // Grass becomes dirt if there is something on top of it: if (a_RelY < cChunkDef::Height - 1) { - BLOCKTYPE Above = a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ); - if ((!g_BlockTransparent[Above] && !g_BlockOneHitDig[Above]) || IsBlockWater(Above)) + BLOCKTYPE Above; + NIBBLETYPE AboveMeta; + a_Chunk.GetBlockTypeMeta(a_RelX, a_RelY + 1, a_RelZ, Above, AboveMeta); + if ((!g_BlockTransparent[Above] && !g_BlockOneHitDig[Above] && !(cBlockSlabHandler::IsAnySlabType(Above) && (AboveMeta & 0x8))) || IsBlockWater(Above)) { a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_DIRT, E_META_DIRT_NORMAL); return; @@ -77,7 +80,7 @@ public: BLOCKTYPE AboveDest; NIBBLETYPE AboveMeta; Chunk->GetBlockTypeMeta(BlockX, BlockY + 1, BlockZ, AboveDest, AboveMeta); - if ((g_BlockOneHitDig[AboveDest] || g_BlockTransparent[AboveDest]) && !IsBlockWater(AboveDest)) + if ((g_BlockOneHitDig[AboveDest] || g_BlockTransparent[AboveDest] || ((cBlockSlabHandler::IsAnySlabType(AboveDest)) && (AboveMeta & 0x8))) && !IsBlockWater(AboveDest)) { Chunk->FastSetBlock(BlockX, BlockY, BlockZ, E_BLOCK_GRASS, 0); } @@ -85,6 +88,12 @@ public: } + bool IsGrowAble(BLOCKTYPE a_Block, NIBBLETYPE a_Meta) + { + + } + + virtual const char * GetStepSound(void) override { return "step.gravel"; -- cgit v1.2.3 From cbb0352e51d1346b3ff7980f83696fedb0371a92 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 3 Apr 2014 21:44:23 +0200 Subject: Remove old function --- src/Blocks/BlockDirt.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index 098494585..2559f4839 100644 --- a/src/Blocks/BlockDirt.h +++ b/src/Blocks/BlockDirt.h @@ -88,12 +88,6 @@ public: } - bool IsGrowAble(BLOCKTYPE a_Block, NIBBLETYPE a_Meta) - { - - } - - virtual const char * GetStepSound(void) override { return "step.gravel"; -- cgit v1.2.3 From 039191499caec958d3d79773e4ed1c1c4e2916c2 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 6 Apr 2014 21:41:01 +0200 Subject: Add CanChangeDirtToGrass function to Block Handlers. --- src/BlockInfo.cpp | 10 ++++++++++ src/Blocks/BlockBed.h | 7 +++++++ src/Blocks/BlockDirt.h | 6 +++--- src/Blocks/BlockHandler.cpp | 9 +++++++++ src/Blocks/BlockHandler.h | 3 +++ src/Blocks/BlockSlab.h | 6 ++++++ src/Blocks/BlockStairs.h | 5 +++++ src/Items/ItemMinecart.h | 2 +- src/Items/ItemPickaxe.h | 1 + 9 files changed, 45 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 6fb5aa5b3..64fce20bf 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -110,10 +110,13 @@ void cBlockInfo::Initialize(void) // Transparent blocks ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_Transparent = true; ms_Info[E_BLOCK_AIR ].m_Transparent = true; + ms_Info[E_BLOCK_ANVIL ].m_Transparent = true; ms_Info[E_BLOCK_BIG_FLOWER ].m_Transparent = true; ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_Transparent = true; + ms_Info[E_BLOCK_CAKE ].m_Transparent = true; ms_Info[E_BLOCK_CARROTS ].m_Transparent = true; ms_Info[E_BLOCK_CHEST ].m_Transparent = true; + ms_Info[E_BLOCK_COBBLESTONE_WALL ].m_Transparent = true; ms_Info[E_BLOCK_COBWEB ].m_Transparent = true; ms_Info[E_BLOCK_CROPS ].m_Transparent = true; ms_Info[E_BLOCK_DANDELION ].m_Transparent = true; @@ -126,6 +129,7 @@ void cBlockInfo::Initialize(void) ms_Info[E_BLOCK_FLOWER_POT ].m_Transparent = true; ms_Info[E_BLOCK_GLASS ].m_Transparent = true; ms_Info[E_BLOCK_GLASS_PANE ].m_Transparent = true; + ms_Info[E_BLOCK_HEAD ].m_Transparent = true; ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_Transparent = true; ms_Info[E_BLOCK_ICE ].m_Transparent = true; ms_Info[E_BLOCK_IRON_DOOR ].m_Transparent = true; @@ -195,12 +199,14 @@ void cBlockInfo::Initialize(void) ms_Info[E_BLOCK_BED ].m_PistonBreakable = true; ms_Info[E_BLOCK_BIG_FLOWER ].m_PistonBreakable = true; ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_PistonBreakable = true; + ms_Info[E_BLOCK_CAKE ].m_PistonBreakable = true; ms_Info[E_BLOCK_COBWEB ].m_PistonBreakable = true; ms_Info[E_BLOCK_CROPS ].m_PistonBreakable = true; ms_Info[E_BLOCK_DANDELION ].m_PistonBreakable = true; ms_Info[E_BLOCK_DEAD_BUSH ].m_PistonBreakable = true; ms_Info[E_BLOCK_FIRE ].m_PistonBreakable = true; ms_Info[E_BLOCK_FLOWER ].m_PistonBreakable = true; + ms_Info[E_BLOCK_HEAD ].m_PistonBreakable = true; ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true; ms_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_PistonBreakable = true; ms_Info[E_BLOCK_IRON_DOOR ].m_PistonBreakable = true; @@ -242,6 +248,7 @@ void cBlockInfo::Initialize(void) ms_Info[E_BLOCK_CACTUS ].m_IsSnowable = false; ms_Info[E_BLOCK_CHEST ].m_IsSnowable = false; ms_Info[E_BLOCK_CROPS ].m_IsSnowable = false; + ms_Info[E_BLOCK_COBBLESTONE_WALL ].m_IsSnowable = false; ms_Info[E_BLOCK_DANDELION ].m_IsSnowable = false; ms_Info[E_BLOCK_FIRE ].m_IsSnowable = false; ms_Info[E_BLOCK_FLOWER ].m_IsSnowable = false; @@ -275,6 +282,7 @@ void cBlockInfo::Initialize(void) ms_Info[E_BLOCK_POWERED_RAIL ].m_IsSnowable = false; ms_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSnowable = false; ms_Info[E_BLOCK_COBWEB ].m_IsSnowable = false; + ms_Info[E_BLOCK_HEAD ].m_IsSnowable = false; // Blocks that don't drop without a special tool: @@ -282,6 +290,7 @@ void cBlockInfo::Initialize(void) ms_Info[E_BLOCK_CAULDRON ].m_RequiresSpecialTool = true; ms_Info[E_BLOCK_COAL_ORE ].m_RequiresSpecialTool = true; ms_Info[E_BLOCK_COBBLESTONE ].m_RequiresSpecialTool = true; + ms_Info[E_BLOCK_COBBLESTONE_WALL ].m_RequiresSpecialTool = true; ms_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_RequiresSpecialTool = true; ms_Info[E_BLOCK_COBWEB ].m_RequiresSpecialTool = true; ms_Info[E_BLOCK_DIAMOND_BLOCK ].m_RequiresSpecialTool = true; @@ -324,6 +333,7 @@ void cBlockInfo::Initialize(void) ms_Info[E_BLOCK_AIR ].m_IsSolid = false; ms_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false; ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false; + ms_Info[E_BLOCK_CAKE ].m_IsSolid = false; ms_Info[E_BLOCK_CARROTS ].m_IsSolid = false; ms_Info[E_BLOCK_COBWEB ].m_IsSolid = false; ms_Info[E_BLOCK_CROPS ].m_IsSolid = false; diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h index 92804aaac..cfd732d38 100644 --- a/src/Blocks/BlockBed.h +++ b/src/Blocks/BlockBed.h @@ -39,6 +39,13 @@ public: } + virtual bool CanChangeDirtToGrass(BLOCKTYPE a_Block, NIBBLETYPE a_Meta) override + { + return true; + } + + + // Bed specific helper functions static NIBBLETYPE RotationToMetaData(double a_Rotation) { diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index bde8e4201..84c8461b5 100644 --- a/src/Blocks/BlockDirt.h +++ b/src/Blocks/BlockDirt.h @@ -39,7 +39,7 @@ public: BLOCKTYPE Above; NIBBLETYPE AboveMeta; a_Chunk.GetBlockTypeMeta(a_RelX, a_RelY + 1, a_RelZ, Above, AboveMeta); - if ((!cBlockInfo::IsTransparent(Above) && !cBlockInfo::IsOneHitDig(Above) && !(cBlockSlabHandler::IsAnySlabType(Above) && (AboveMeta & 0x8))) || IsBlockWater(Above)) + if ((IsBlockWater(Above)) || !cBlockInfo::GetHandler(Above)->CanChangeDirtToGrass(Above, AboveMeta)) { a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_DIRT, E_META_DIRT_NORMAL); return; @@ -67,7 +67,7 @@ public: cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(BlockX, BlockZ); if (Chunk == NULL) { - // Unloaded chunk + // Unloaded chunks continue; } Chunk->GetBlockTypeMeta(BlockX, BlockY, BlockZ, DestBlock, DestMeta); @@ -80,7 +80,7 @@ public: BLOCKTYPE AboveDest; NIBBLETYPE AboveMeta; Chunk->GetBlockTypeMeta(BlockX, BlockY + 1, BlockZ, AboveDest, AboveMeta); - if ((cBlockInfo::IsOneHitDig(AboveDest) || cBlockInfo::IsTransparent(AboveDest) || ((cBlockSlabHandler::IsAnySlabType(AboveDest)) && (AboveMeta & 0x8))) && !IsBlockWater(AboveDest)) + if ((!IsBlockWater(AboveDest)) && (cBlockInfo::GetHandler(AboveDest)->CanChangeDirtToGrass(AboveDest, AboveMeta))) { if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread((cWorld*) &a_WorldInterface, BlockX * cChunkDef::Width, BlockY, BlockZ * cChunkDef::Width, ssGrassSpread)) { diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 7fd8c183c..13cb67041 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -396,6 +396,15 @@ bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, in +bool cBlockHandler::CanChangeDirtToGrass(BLOCKTYPE a_Block, NIBBLETYPE a_Meta) +{ + return ((cBlockInfo::IsTransparent(a_Block)) || (cBlockInfo::IsOneHitDig(a_Block))); +} + + + + + bool cBlockHandler::IsUseable() { return false; diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 3a3efb3cc..760db02fe 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -85,6 +85,9 @@ public: /// Checks if the block can stay at the specified relative coords in the chunk virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk); + + /** Can spread the block under this block to grass? */ + virtual bool CanChangeDirtToGrass(BLOCKTYPE a_Block, NIBBLETYPE a_Meta); /** Checks if the block can be placed at this point. Default: CanBeAt(...) diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 76f5ed0e7..84580b062 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -97,6 +97,12 @@ public: return ""; } + + virtual bool CanChangeDirtToGrass(BLOCKTYPE a_Block, NIBBLETYPE a_Meta) override + { + return (a_Meta & 0x8); + } + /// Returns true if the specified blocktype is one of the slabs handled by this handler static bool IsAnySlabType(BLOCKTYPE a_BlockType) diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h index 09ff254a6..d6363fed9 100644 --- a/src/Blocks/BlockStairs.h +++ b/src/Blocks/BlockStairs.h @@ -77,6 +77,11 @@ public: // Reset meta to 0 a_Pickups.push_back(cItem(m_BlockType, 1, 0)); } + + virtual bool CanChangeDirtToGrass(BLOCKTYPE a_Block, NIBBLETYPE a_Meta) override + { + return true; + } static NIBBLETYPE RotationToMetaData(double a_Rotation) { diff --git a/src/Items/ItemMinecart.h b/src/Items/ItemMinecart.h index 25500aeb9..4e7d8fcff 100644 --- a/src/Items/ItemMinecart.h +++ b/src/Items/ItemMinecart.h @@ -78,7 +78,7 @@ public: } return true; } - + } ; diff --git a/src/Items/ItemPickaxe.h b/src/Items/ItemPickaxe.h index 2a8e40daa..4f8ef4eb1 100644 --- a/src/Items/ItemPickaxe.h +++ b/src/Items/ItemPickaxe.h @@ -76,6 +76,7 @@ public: case E_BLOCK_STONE_PRESSURE_PLATE: case E_BLOCK_BRICK: case E_BLOCK_COBBLESTONE_STAIRS: + case E_BLOCK_COBBLESTONE_WALL: case E_BLOCK_STONE_BRICK_STAIRS: case E_BLOCK_NETHER_BRICK_STAIRS: case E_BLOCK_CAULDRON: -- cgit v1.2.3 From 4d7b250a509213fa7043b3670c6a393a3683fc69 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 6 Apr 2014 21:45:55 +0200 Subject: Remove old import --- src/Blocks/BlockDirt.h | 3 +-- src/Blocks/BlockHandler.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index 84c8461b5..0c550257e 100644 --- a/src/Blocks/BlockDirt.h +++ b/src/Blocks/BlockDirt.h @@ -2,7 +2,6 @@ #pragma once #include "BlockHandler.h" -#include "BlockSlab.h" #include "../FastRandom.h" @@ -67,7 +66,7 @@ public: cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(BlockX, BlockZ); if (Chunk == NULL) { - // Unloaded chunks + // Unloaded chunk continue; } Chunk->GetBlockTypeMeta(BlockX, BlockY, BlockZ, DestBlock, DestMeta); diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 760db02fe..4d6a2abb6 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -86,7 +86,7 @@ public: /// Checks if the block can stay at the specified relative coords in the chunk virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk); - /** Can spread the block under this block to grass? */ + /** Can change the block under this block to grass? */ virtual bool CanChangeDirtToGrass(BLOCKTYPE a_Block, NIBBLETYPE a_Meta); /** Checks if the block can be placed at this point. -- cgit v1.2.3 From 8bcb176a19297bca4f55f03a5244a507f8bf9174 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Apr 2014 00:04:50 +0200 Subject: Lighting reads blocktypes only for blocks under heightmap. This should theoretically speed it up, since less data is copied back and forth. Also implemented a possibly more cache-friendly blocklight starter algorithm (PrepareBlockLight2()), is disabled by default, needs perf testing. --- src/LightingThread.cpp | 92 ++++++++++++++++++++++++++++++++++++++++++-------- src/LightingThread.h | 11 ++++-- 2 files changed, 87 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index 302473d71..f23f0c5f4 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -27,7 +27,8 @@ class cReader : ROW * OutputRows = (ROW *)m_BlockTypes; int InputIdx = 0; int OutputIdx = m_ReadingChunkX + m_ReadingChunkZ * cChunkDef::Width * 3; - for (int y = 0; y < cChunkDef::Height; y++) + int MaxHeight = std::min(cChunkDef::Height, m_MaxHeight + 16); // Need 16 blocks above the highest + for (int y = 0; y < MaxHeight; y++) { for (int z = 0; z < cChunkDef::Width; z++) { @@ -43,6 +44,7 @@ class cReader : virtual void HeightMap(const cChunkDef::HeightMap * a_Heightmap) override { + // Copy the entire heightmap, distribute it into the 3x3 chunk blob: typedef struct {HEIGHTTYPE m_Row[16]; } ROW; ROW * InputRows = (ROW *)a_Heightmap; ROW * OutputRows = (ROW *)m_HeightMap; @@ -53,13 +55,32 @@ class cReader : OutputRows[OutputIdx] = InputRows[InputIdx++]; OutputIdx += 3; } // for z + + // Find the highest block in the entire chunk, use it as a base for m_MaxHeight: + HEIGHTTYPE MaxHeight = m_MaxHeight; + for (size_t i = 0; i < ARRAYCOUNT(*a_Heightmap); i++) + { + if ((*a_Heightmap)[i] > MaxHeight) + { + MaxHeight = (*a_Heightmap)[i]; + } + } + m_MaxHeight = MaxHeight; } public: int m_ReadingChunkX; // 0, 1 or 2; x-offset of the chunk we're reading from the BlockTypes start int m_ReadingChunkZ; // 0, 1 or 2; z-offset of the chunk we're reading from the BlockTypes start + HEIGHTTYPE m_MaxHeight; // Maximum value in this chunk's heightmap BLOCKTYPE * m_BlockTypes; // 3x3 chunks of block types, organized as a single XZY blob of data (instead of 3x3 XZY blobs) HEIGHTTYPE * m_HeightMap; // 3x3 chunks of height map, organized as a single XZY blob of data (instead of 3x3 XZY blobs) + + cReader(BLOCKTYPE * a_BlockTypes, HEIGHTTYPE * a_HeightMap) : + m_BlockTypes(a_BlockTypes), + m_HeightMap(a_HeightMap), + m_MaxHeight(0) + { + } } ; @@ -225,7 +246,7 @@ void cLightingThread::LightChunk(cLightingChunkStay & a_Item) // DEBUG: Save chunk data with highlighted seeds for visual inspection: cFile f4; if ( - f4.Open(Printf("Chunk_%d_%d_seeds.grab", a_Item.x, a_Item.z), cFile::fmWrite) + f4.Open(Printf("Chunk_%d_%d_seeds.grab", a_Item.m_ChunkX, a_Item.m_ChunkZ), cFile::fmWrite) ) { for (int z = 0; z < cChunkDef::Width * 3; z++) @@ -244,6 +265,7 @@ void cLightingThread::LightChunk(cLightingChunkStay & a_Item) f4.Write(Seeds, cChunkDef::Width * 3); } } + f4.Close(); } //*/ @@ -253,9 +275,9 @@ void cLightingThread::LightChunk(cLightingChunkStay & a_Item) // DEBUG: Save XY slices of the chunk data and lighting for visual inspection: cFile f1, f2, f3; if ( - f1.Open(Printf("Chunk_%d_%d_data.grab", a_Item.x, a_Item.z), cFile::fmWrite) && - f2.Open(Printf("Chunk_%d_%d_sky.grab", a_Item.x, a_Item.z), cFile::fmWrite) && - f3.Open(Printf("Chunk_%d_%d_glow.grab", a_Item.x, a_Item.z), cFile::fmWrite) + f1.Open(Printf("Chunk_%d_%d_data.grab", a_Item.m_ChunkX, a_Item.m_ChunkZ), cFile::fmWrite) && + f2.Open(Printf("Chunk_%d_%d_sky.grab", a_Item.m_ChunkX, a_Item.m_ChunkZ), cFile::fmWrite) && + f3.Open(Printf("Chunk_%d_%d_glow.grab", a_Item.m_ChunkX, a_Item.m_ChunkZ), cFile::fmWrite) ) { for (int z = 0; z < cChunkDef::Width * 3; z++) @@ -274,6 +296,9 @@ void cLightingThread::LightChunk(cLightingChunkStay & a_Item) f3.Write(BlockLight, cChunkDef::Width * 3); } } + f1.Close(); + f2.Close(); + f3.Close(); } //*/ @@ -293,11 +318,9 @@ void cLightingThread::LightChunk(cLightingChunkStay & a_Item) -bool cLightingThread::ReadChunks(int a_ChunkX, int a_ChunkZ) +void cLightingThread::ReadChunks(int a_ChunkX, int a_ChunkZ) { - cReader Reader; - Reader.m_BlockTypes = m_BlockTypes; - Reader.m_HeightMap = m_HeightMap; + cReader Reader(m_BlockTypes, m_HeightMap); for (int z = 0; z < 3; z++) { @@ -305,16 +328,13 @@ bool cLightingThread::ReadChunks(int a_ChunkX, int a_ChunkZ) for (int x = 0; x < 3; x++) { Reader.m_ReadingChunkX = x; - if (!m_World->GetChunkData(a_ChunkX + x - 1, a_ChunkZ + z - 1, Reader)) - { - return false; - } + VERIFY(m_World->GetChunkData(a_ChunkX + x - 1, a_ChunkZ + z - 1, Reader)); } // for z } // for x memset(m_BlockLight, 0, sizeof(m_BlockLight)); memset(m_SkyLight, 0, sizeof(m_SkyLight)); - return true; + m_MaxHeight = Reader.m_MaxHeight; } @@ -405,6 +425,50 @@ void cLightingThread::PrepareBlockLight(void) +void cLightingThread::PrepareBlockLight2(void) +{ + // Clear seeds: + memset(m_IsSeed1, 0, sizeof(m_IsSeed1)); + memset(m_IsSeed2, 0, sizeof(m_IsSeed2)); + m_NumSeeds = 0; + + // Add each emissive block into the seeds: + for (int y = 0; y < m_MaxHeight; y++) + { + int BaseY = y * BlocksPerYLayer; // Partial offset into m_BlockTypes for the Y coord + for (int z = 1; z < cChunkDef::Width * 3 - 1; z++) + { + int HBaseZ = z * cChunkDef::Width * 3; // Partial offset into m_Heightmap for the Z coord + int BaseZ = BaseY + HBaseZ; // Partial offset into m_BlockTypes for the Y and Z coords + for (int x = 1; x < cChunkDef::Width * 3 - 1; x++) + { + int idx = BaseZ + x; + if (y > m_HeightMap[HBaseZ + x]) + { + // We're above the heightmap, ignore the block + continue; + } + if (cBlockInfo::GetLightValue(m_BlockTypes[idx]) == 0) + { + // Not a light-emissive block + continue; + } + + // Add current block as a seed: + m_IsSeed1[idx] = true; + m_SeedIdx1[m_NumSeeds++] = idx; + + // Light it up: + m_BlockLight[idx] = cBlockInfo::GetLightValue(m_BlockTypes[idx]); + } + } + } +} + + + + + void cLightingThread::CalcLight(NIBBLETYPE * a_Light) { int NumSeeds2 = 0; diff --git a/src/LightingThread.h b/src/LightingThread.h index 770ae809f..a484fcbed 100644 --- a/src/LightingThread.h +++ b/src/LightingThread.h @@ -108,6 +108,9 @@ protected: cEvent m_evtItemAdded; // Set when queue is appended, or to stop the thread cEvent m_evtQueueEmpty; // Set when the queue gets empty + /** The highest block in the current 3x3 chunk data */ + HEIGHTTYPE m_MaxHeight; + // Buffers for the 3x3 chunk data // These buffers alone are 1.7 MiB in size, therefore they cannot be located on the stack safely - some architectures may have only 1 MiB for stack, or even less @@ -136,8 +139,8 @@ protected: /** Lights the entire chunk. If neighbor chunks don't exist, touches them and re-queues the chunk */ void LightChunk(cLightingChunkStay & a_Item); - /** Prepares m_BlockTypes and m_HeightMap data; returns false if any of the chunks fail. Zeroes out the light arrays */ - bool ReadChunks(int a_ChunkX, int a_ChunkZ); + /** Prepares m_BlockTypes and m_HeightMap data; zeroes out the light arrays */ + void ReadChunks(int a_ChunkX, int a_ChunkZ); /** Uses m_HeightMap to initialize the m_SkyLight[] data; fills in seeds for the skylight */ void PrepareSkyLight(void); @@ -145,6 +148,10 @@ protected: /** Uses m_BlockTypes to initialize the m_BlockLight[] data; fills in seeds for the blocklight */ void PrepareBlockLight(void); + /** Same as PrepareBlockLight(), but uses a different traversal scheme; possibly better perf cache-wise. + To be compared in perf benchmarks. */ + void PrepareBlockLight2(void); + /** Calculates light in the light array specified, using stored seeds */ void CalcLight(NIBBLETYPE * a_Light); -- cgit v1.2.3 From 5bc5272a4ea5fc5685626627dff62a697415826b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Apr 2014 00:24:35 +0200 Subject: Fixed member construction order. --- src/LightingThread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index f23f0c5f4..f22e3933b 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -76,9 +76,9 @@ public: HEIGHTTYPE * m_HeightMap; // 3x3 chunks of height map, organized as a single XZY blob of data (instead of 3x3 XZY blobs) cReader(BLOCKTYPE * a_BlockTypes, HEIGHTTYPE * a_HeightMap) : + m_MaxHeight(0), m_BlockTypes(a_BlockTypes), - m_HeightMap(a_HeightMap), - m_MaxHeight(0) + m_HeightMap(a_HeightMap) { } } ; -- cgit v1.2.3 From b0dd3dca3d4a8b794719f37fc34dcf6e56ecc5af Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 12 Apr 2014 10:44:31 -0700 Subject: Fixed link errors --- src/ChunkDef.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/ChunkDef.cpp (limited to 'src') diff --git a/src/ChunkDef.cpp b/src/ChunkDef.cpp new file mode 100644 index 000000000..367f66ccc --- /dev/null +++ b/src/ChunkDef.cpp @@ -0,0 +1,9 @@ + +#include "Globals.h" + +#include "ChunkDef.h" + +// It appears that failing to have this definition causes link errors as cChunkDef::Height is not +// defined. It also appears that we can have the initalizer in the declaration so it can be inlined +// if the declaration is in a class???? +const int cChunkDef::Height; -- cgit v1.2.3 From f763242e5c5d8e6469685c4be95d3dc264ed6a67 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 23 Apr 2014 21:06:07 +0100 Subject: Small changes --- src/CraftingRecipes.cpp | 4 ++-- src/Items/ItemLilypad.h | 14 ++++++-------- src/Items/ItemThrowable.h | 5 ++++- src/World.h | 4 +++- 4 files changed, 15 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index 30e7a8733..157d634cd 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -800,7 +800,7 @@ void cCraftingRecipes::HandleFireworks(const cItem * a_CraftingGrid, cCraftingRe break; } case E_ITEM_PAPER: break; - default: LOG("Unexpected item in firework rocket a_Recipe, was the crafting file fireworks section changed?"); break; + default: LOG("Unexpected item in firework rocket recipe, was the crafting file's fireworks section changed?"); break; } } } @@ -835,7 +835,7 @@ void cCraftingRecipes::HandleFireworks(const cItem * a_CraftingGrid, cCraftingRe case E_ITEM_GOLD_NUGGET: a_Recipe->m_Result.m_FireworkItem.m_Type = 2; break; case E_ITEM_FEATHER: a_Recipe->m_Result.m_FireworkItem.m_Type = 4; break; case E_ITEM_HEAD: a_Recipe->m_Result.m_FireworkItem.m_Type = 3; break; - default: LOG("Unexpected item in firework star a_Recipe, was the crafting file fireworks section changed?"); break; // ermahgerd BARD ardmins + default: LOG("Unexpected item in firework star recipe, was the crafting file's fireworks section changed?"); break; // ermahgerd BARD ardmins } } diff --git a/src/Items/ItemLilypad.h b/src/Items/ItemLilypad.h index 8fc1d8543..bc650cdbd 100644 --- a/src/Items/ItemLilypad.h +++ b/src/Items/ItemLilypad.h @@ -47,9 +47,9 @@ public: public cBlockTracer::cCallbacks { public: - cCallbacks(cWorld * a_CBWorld) : - m_HasHitFluid(false), - m_World(a_CBWorld) + + cCallbacks(void) : + m_HasHitFluid(false) { } @@ -62,10 +62,9 @@ public: return false; } AddFaceDirection(a_CBBlockX, a_CBBlockY, a_CBBlockZ, BLOCK_FACE_YP); // Always place pad at top of water block - BLOCKTYPE Block = m_World->GetBlock(a_CBBlockX, a_CBBlockY, a_CBBlockZ); if ( - !IsBlockWater(Block) && - cBlockInfo::FullyOccupiesVoxel(Block) + !IsBlockWater(a_CBBlockType) && + cBlockInfo::FullyOccupiesVoxel(a_CBBlockType) ) { // Can't place lilypad on air/in another block! @@ -80,11 +79,10 @@ public: Vector3i m_Pos; bool m_HasHitFluid; - cWorld * m_World; }; - cCallbacks Callbacks(a_World); + cCallbacks Callbacks; cLineBlockTracer Tracer(*a_Player->GetWorld(), Callbacks); Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector()); Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h index c6a4e714e..f90caf037 100644 --- a/src/Items/ItemThrowable.h +++ b/src/Items/ItemThrowable.h @@ -127,7 +127,10 @@ public: return false; } - a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, a_Player->GetEquippedItem()); + if (a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, a_Player->GetEquippedItem()) == -1) + { + return false; + } if (!a_Player->IsGameModeCreative()) { diff --git a/src/World.h b/src/World.h index e08ef7f53..61733bca0 100644 --- a/src/World.h +++ b/src/World.h @@ -710,7 +710,9 @@ public: virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eType a_MonsterType) override; // tolua_export int SpawnMobFinalize(cMonster* a_Monster); - /** Creates a projectile of the specified type. Returns the projectile's EntityID if successful, <0 otherwise */ + /** Creates a projectile of the specified type. Returns the projectile's EntityID if successful, <0 otherwise + Item parameter used currently for Fireworks to correctly set entity metadata based on item metadata + */ int CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem a_Item, const Vector3d * a_Speed = NULL); // tolua_export /** Returns a random number from the m_TickRand in range [0 .. a_Range]. To be used only in the tick thread! */ -- cgit v1.2.3 From 7f5cf417de5e83641e6aa0998cc9dc8b377346b6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 23 Apr 2014 21:06:46 +0100 Subject: Some change to Entity.cpp * Added comments to BroadcastMovementUpdate() and the collision tracer --- src/Entities/Entity.cpp | 182 ++++++++++++++++++++++----------------------- src/Entities/Entity.h | 11 +-- src/Entities/ExpOrb.cpp | 2 - src/Entities/Player.cpp | 22 ++---- src/Entities/Player.h | 3 - src/Entities/TNTEntity.cpp | 2 - src/Tracer.cpp | 6 +- 7 files changed, 105 insertions(+), 123 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 56ef36ef8..25ae4c7d8 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -10,7 +10,6 @@ #include "../Simulator/FluidSimulator.h" #include "../Bindings/PluginManager.h" #include "../Tracer.h" -#include "Minecart.h" #include "Player.h" @@ -32,16 +31,10 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_Attachee(NULL) , m_bDirtyHead(true) , m_bDirtyOrientation(true) - , m_bDirtyPosition(true) - , m_bDirtySpeed(true) - , m_bOnGround( false ) - , m_Gravity( -9.81f ) - , m_LastPosX( 0.0 ) - , m_LastPosY( 0.0 ) - , m_LastPosZ( 0.0 ) - , m_TimeLastTeleportPacket(0) - , m_TimeLastMoveReltPacket(0) - , m_TimeLastSpeedPacket(0) + , m_bHasSentNoSpeed(true) + , m_bOnGround(false) + , m_Gravity(-9.81f) + , m_LastPos(a_X, a_Y, a_Z) , m_IsInitialized(false) , m_EntityType(a_EntityType) , m_World(NULL) @@ -52,7 +45,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_TicksSinceLastVoidDamage(0) , m_IsSwimming(false) , m_IsSubmerged(false) - , m_HeadYaw( 0.0 ) + , m_HeadYaw(0.0) , m_Rot(0.0, 0.0, 0.0) , m_Pos(a_X, a_Y, a_Z) , m_WaterSpeed(0, 0, 0) @@ -725,30 +718,45 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) NextSpeed += m_WaterSpeed; - if( NextSpeed.SqrLength() > 0.f ) + if (NextSpeed.SqrLength() > 0.f) { - cTracer Tracer( GetWorld() ); - bool HasHit = Tracer.Trace( NextPos, NextSpeed, 2 ); - if (HasHit) // Oh noez! we hit something + cTracer Tracer(GetWorld()); + + bool HasHit = Tracer.Trace(NextPos, NextSpeed, + // Distance traced is an integer, so we round up from the distance we should go (Speed * Delta), else we will encounter collision detection failures + (int)(ceil((NextSpeed * a_Dt).SqrLength()) * 2) + ); + + if (HasHit) { - // Set to hit position + // Oh noez! We hit something: verify that the (hit position - current) was smaller or equal to the (position that we should travel without obstacles - current) + // This is because previously, we traced with a length that was rounded up (due to integer limitations), and in the case that something was hit, we don't want to overshoot our projected movement if ((Tracer.RealHit - NextPos).SqrLength() <= (NextSpeed * a_Dt).SqrLength()) { + // Block hit was within our projected path + // Begin by stopping movement in the direction that we hit something. The Normal is the line perpendicular to a 2D face and in this case, stores what block face was hit through either -1 or 1. + // Por ejemplo: HitNormal.y = -1 : BLOCK_FACE_YM; HitNormal.y = 1 : BLOCK_FACE_YP if (Tracer.HitNormal.x != 0.f) NextSpeed.x = 0.f; if (Tracer.HitNormal.y != 0.f) NextSpeed.y = 0.f; if (Tracer.HitNormal.z != 0.f) NextSpeed.z = 0.f; - if (Tracer.HitNormal.y > 0) // means on ground + if (Tracer.HitNormal.y == 1) // Hit BLOCK_FACE_YP, we are on the ground { m_bOnGround = true; } - NextPos.Set(Tracer.RealHit.x,Tracer.RealHit.y,Tracer.RealHit.z); - NextPos.x += Tracer.HitNormal.x * 0.3f; - NextPos.y += Tracer.HitNormal.y * 0.05f; // Any larger produces entity vibration-upon-the-spot - NextPos.z += Tracer.HitNormal.z * 0.3f; + + // Now, set our position to the hit block (i.e. move part way along our intended trajectory) + NextPos.Set(Tracer.RealHit.x, Tracer.RealHit.y, Tracer.RealHit.z); + NextPos.x += Tracer.HitNormal.x * 0.1; + NextPos.y += Tracer.HitNormal.y * 0.05; + NextPos.z += Tracer.HitNormal.z * 0.1; } else { + // We have hit a block but overshot our intended trajectory, move normally, safe in the warm cocoon of knowledge that we won't appear to teleport forwards on clients, + // and that this piece of software will come to be hailed as the epitome of performance and functionality in C++, never before seen, and of such a like that will never + // be henceforth seen again in the time of programmers and man alike + // NextPos += (NextSpeed * a_Dt); } } @@ -934,8 +942,8 @@ void cEntity::SetSwimState(cChunk & a_Chunk) { // This sometimes happens on Linux machines // Ref.: http://forum.mc-server.org/showthread.php?tid=1244 - LOGD("SetSwimState failure: RelX = %d, RelZ = %d, LastPos = {%.02f, %.02f}, Pos = %.02f, %.02f}", - RelX, RelY, m_LastPosX, m_LastPosZ, GetPosX(), GetPosZ() + LOGD("SetSwimState failure: RelX = %d, RelZ = %d, Pos = %.02f, %.02f}", + RelX, RelY, GetPosX(), GetPosZ() ); m_IsSwimming = false; m_IsSubmerged = false; @@ -1092,72 +1100,70 @@ void cEntity::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude) { - // Send velocity packet every two ticks if: speed is not negligible or speed was set (as indicated by the DirtySpeed flag) - if (((m_Speed.SqrLength() > 0.0004f) || m_bDirtySpeed) && ((m_World->GetWorldAge() - m_TimeLastSpeedPacket) >= 2)) + // Process packet sending every two ticks + if (GetWorld()->GetWorldAge() % 2 == 0) { - m_World->BroadcastEntityVelocity(*this,a_Exclude); - m_bDirtySpeed = false; - m_TimeLastSpeedPacket = m_World->GetWorldAge(); - } - - // Have to process position related packets this every two ticks - if (m_World->GetWorldAge() % 2 == 0) - { - int DiffX = (int) (floor(GetPosX() * 32.0) - floor(m_LastPosX * 32.0)); - int DiffY = (int) (floor(GetPosY() * 32.0) - floor(m_LastPosY * 32.0)); - int DiffZ = (int) (floor(GetPosZ() * 32.0) - floor(m_LastPosZ * 32.0)); - Int64 DiffTeleportPacket = m_World->GetWorldAge() - m_TimeLastTeleportPacket; - // 4 blocks is max Relative So if the Diff is greater than 127 or. Send an absolute position every 20 seconds - if (DiffTeleportPacket >= 400 || - ((DiffX > 127) || (DiffX < -128) || - (DiffY > 127) || (DiffY < -128) || - (DiffZ > 127) || (DiffZ < -128))) + double SpeedSqr = GetSpeed().SqrLength(); + if (SpeedSqr == 0.0) { - // - m_World->BroadcastTeleportEntity(*this,a_Exclude); - m_TimeLastTeleportPacket = m_World->GetWorldAge(); - m_TimeLastMoveReltPacket = m_TimeLastTeleportPacket; //Must synchronize. - m_LastPosX = GetPosX(); - m_LastPosY = GetPosY(); - m_LastPosZ = GetPosZ(); - m_bDirtyPosition = false; - m_bDirtyOrientation = false; + // Speed is zero, send this to clients once only as well as an absolute position + if (!m_bHasSentNoSpeed) + { + m_World->BroadcastEntityVelocity(*this, a_Exclude); + m_World->BroadcastTeleportEntity(*this, a_Exclude); + m_bHasSentNoSpeed = true; + } } else { - Int64 DiffMoveRelPacket = m_World->GetWorldAge() - m_TimeLastMoveReltPacket; - //if the change is big enough. - if ((abs(DiffX) >= 4 || abs(DiffY) >= 4 || abs(DiffZ) >= 4 || DiffMoveRelPacket >= 60) && m_bDirtyPosition) + // Movin' + m_World->BroadcastEntityVelocity(*this, a_Exclude); + m_bHasSentNoSpeed = false; + } + + // TODO: Pickups move disgracefully if relative move packets are sent as opposed to just velocity. Have a system to send relmove only when SetPosXXX() is called with a large difference in position + int DiffX = (int)(floor(GetPosX() * 32.0) - floor(m_LastPos.x * 32.0)); + int DiffY = (int)(floor(GetPosY() * 32.0) - floor(m_LastPos.y * 32.0)); + int DiffZ = (int)(floor(GetPosZ() * 32.0) - floor(m_LastPos.z * 32.0)); + + if ((abs(DiffX) >= 4) || (abs(DiffY) >= 4) || (abs(DiffZ) >= 4)) + { + if ((abs(DiffX) <= 127) && (abs(DiffY) <= 127) && (abs(DiffZ) <= 127)) // Limitations of a Byte { + // Difference within Byte limitations, use a relative move packet if (m_bDirtyOrientation) { - m_World->BroadcastEntityRelMoveLook(*this, (char)DiffX, (char)DiffY, (char)DiffZ,a_Exclude); + m_World->BroadcastEntityRelMoveLook(*this, (char)DiffX, (char)DiffY, (char)DiffZ, a_Exclude); m_bDirtyOrientation = false; } else { - m_World->BroadcastEntityRelMove(*this, (char)DiffX, (char)DiffY, (char)DiffZ,a_Exclude); + m_World->BroadcastEntityRelMove(*this, (char)DiffX, (char)DiffY, (char)DiffZ, a_Exclude); } - m_LastPosX = GetPosX(); - m_LastPosY = GetPosY(); - m_LastPosZ = GetPosZ(); - m_bDirtyPosition = false; - m_TimeLastMoveReltPacket = m_World->GetWorldAge(); + // Clients seem to store two positions, one for the velocity packet and one for the teleport/relmove packet + // The latter is only changed with a relmove/teleport, and m_LastPos stores this position + m_LastPos = GetPosition(); } else { - if (m_bDirtyOrientation) - { - m_World->BroadcastEntityLook(*this,a_Exclude); - m_bDirtyOrientation = false; - } - } + // Too big a movement, do a teleport + m_World->BroadcastTeleportEntity(*this, a_Exclude); + m_LastPos = GetPosition(); // See above + m_bDirtyOrientation = false; + } } + if (m_bDirtyHead) { - m_World->BroadcastEntityHeadLook(*this,a_Exclude); + m_World->BroadcastEntityHeadLook(*this, a_Exclude); m_bDirtyHead = false; } + if (m_bDirtyOrientation) + { + // Send individual update in case above (sending with rel-move packet) wasn't done + GetWorld()->BroadcastEntityLook(*this, a_Exclude); + m_bDirtyOrientation = false; + } } } @@ -1297,7 +1303,7 @@ void cEntity::SetRoll(double a_Roll) void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) { m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ); - m_bDirtySpeed = true; + WrapSpeed(); } @@ -1307,7 +1313,7 @@ void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) void cEntity::SetSpeedX(double a_SpeedX) { m_Speed.x = a_SpeedX; - m_bDirtySpeed = true; + WrapSpeed(); } @@ -1317,7 +1323,7 @@ void cEntity::SetSpeedX(double a_SpeedX) void cEntity::SetSpeedY(double a_SpeedY) { m_Speed.y = a_SpeedY; - m_bDirtySpeed = true; + WrapSpeed(); } @@ -1327,7 +1333,7 @@ void cEntity::SetSpeedY(double a_SpeedY) void cEntity::SetSpeedZ(double a_SpeedZ) { m_Speed.z = a_SpeedZ; - m_bDirtySpeed = true; + WrapSpeed(); } @@ -1347,7 +1353,7 @@ void cEntity::SetWidth(double a_Width) void cEntity::AddPosX(double a_AddPosX) { m_Pos.x += a_AddPosX; - m_bDirtyPosition = true; + } @@ -1356,7 +1362,7 @@ void cEntity::AddPosX(double a_AddPosX) void cEntity::AddPosY(double a_AddPosY) { m_Pos.y += a_AddPosY; - m_bDirtyPosition = true; + } @@ -1365,7 +1371,7 @@ void cEntity::AddPosY(double a_AddPosY) void cEntity::AddPosZ(double a_AddPosZ) { m_Pos.z += a_AddPosZ; - m_bDirtyPosition = true; + } @@ -1376,7 +1382,7 @@ void cEntity::AddPosition(double a_AddPosX, double a_AddPosY, double a_AddPosZ) m_Pos.x += a_AddPosX; m_Pos.y += a_AddPosY; m_Pos.z += a_AddPosZ; - m_bDirtyPosition = true; + } @@ -1386,8 +1392,7 @@ void cEntity::AddSpeed(double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeed { m_Speed.x += a_AddSpeedX; m_Speed.y += a_AddSpeedY; - m_Speed.z += a_AddSpeedZ; - m_bDirtySpeed = true; + m_Speed.z += a_AddSpeedZ; WrapSpeed(); } @@ -1397,8 +1402,7 @@ void cEntity::AddSpeed(double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeed void cEntity::AddSpeedX(double a_AddSpeedX) { - m_Speed.x += a_AddSpeedX; - m_bDirtySpeed = true; + m_Speed.x += a_AddSpeedX; WrapSpeed(); } @@ -1408,8 +1412,7 @@ void cEntity::AddSpeedX(double a_AddSpeedX) void cEntity::AddSpeedY(double a_AddSpeedY) { - m_Speed.y += a_AddSpeedY; - m_bDirtySpeed = true; + m_Speed.y += a_AddSpeedY; WrapSpeed(); } @@ -1419,8 +1422,7 @@ void cEntity::AddSpeedY(double a_AddSpeedY) void cEntity::AddSpeedZ(double a_AddSpeedZ) { - m_Speed.z += a_AddSpeedZ; - m_bDirtySpeed = true; + m_Speed.z += a_AddSpeedZ; WrapSpeed(); } @@ -1475,8 +1477,7 @@ Vector3d cEntity::GetLookVector(void) const // Set position void cEntity::SetPosition(double a_PosX, double a_PosY, double a_PosZ) { - m_Pos.Set(a_PosX, a_PosY, a_PosZ); - m_bDirtyPosition = true; + m_Pos.Set(a_PosX, a_PosY, a_PosZ); } @@ -1485,8 +1486,7 @@ void cEntity::SetPosition(double a_PosX, double a_PosY, double a_PosZ) void cEntity::SetPosX(double a_PosX) { - m_Pos.x = a_PosX; - m_bDirtyPosition = true; + m_Pos.x = a_PosX; } @@ -1495,8 +1495,7 @@ void cEntity::SetPosX(double a_PosX) void cEntity::SetPosY(double a_PosY) { - m_Pos.y = a_PosY; - m_bDirtyPosition = true; + m_Pos.y = a_PosY; } @@ -1506,7 +1505,6 @@ void cEntity::SetPosY(double a_PosY) void cEntity::SetPosZ(double a_PosZ) { m_Pos.z = a_PosZ; - m_bDirtyPosition = true; } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 8f3899e2f..354e324c9 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -417,17 +417,14 @@ protected: // Flags that signal that we haven't updated the clients with the latest. bool m_bDirtyHead; bool m_bDirtyOrientation; - bool m_bDirtyPosition; - bool m_bDirtySpeed; + bool m_bHasSentNoSpeed; bool m_bOnGround; float m_Gravity; - // Last Position. - double m_LastPosX, m_LastPosY, m_LastPosZ; - - // This variables keep track of the last time a packet was sent - Int64 m_TimeLastTeleportPacket, m_TimeLastMoveReltPacket, m_TimeLastSpeedPacket; // In ticks + /** Last position sent to client via the Relative Move or Teleport packets (not Velocity) + Only updated if cEntity::BroadcastMovementUpdate() is called! */ + Vector3d m_LastPos; bool m_IsInitialized; // Is set to true when it's initialized, until it's destroyed (Initialize() till Destroy() ) diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp index 3623c869a..10f79aedc 100644 --- a/src/Entities/ExpOrb.cpp +++ b/src/Entities/ExpOrb.cpp @@ -34,8 +34,6 @@ cExpOrb::cExpOrb(const Vector3d & a_Pos, int a_Reward) void cExpOrb::SpawnOn(cClientHandle & a_Client) { a_Client.SendExperienceOrb(*this); - m_bDirtyPosition = false; - m_bDirtySpeed = false; m_bDirtyOrientation = false; m_bDirtyHead = false; } diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 2df0711b4..ba4353478 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -76,11 +76,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) cTimer t1; m_LastPlayerListTime = t1.GetNowTime(); - - m_TimeLastTeleportPacket = 0; m_PlayerName = a_PlayerName; - m_bDirtyPosition = true; // So chunks are streamed to player at spawn if (!LoadFromDisk()) { @@ -208,25 +205,22 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) m_BowCharge += 1; } - //handle updating experience + // Handle updating experience if (m_bDirtyExperience) { SendExperience(); } - if (m_bDirtyPosition) + if ((GetPosition() - m_LastPos).SqrLength() != 0.0) // Change in position from last tick? { // Apply food exhaustion from movement: ApplyFoodExhaustionFromMovement(); cRoot::Get()->GetPluginManager()->CallHookPlayerMoving(*this); - BroadcastMovementUpdate(m_ClientHandle); m_ClientHandle->StreamChunks(); } - else - { - BroadcastMovementUpdate(m_ClientHandle); - } + + BroadcastMovementUpdate(m_ClientHandle); if (m_Health > 0) // make sure player is alive { @@ -1592,10 +1586,7 @@ bool cPlayer::LoadFromDisk() SetPosX(JSON_PlayerPosition[(unsigned int)0].asDouble()); SetPosY(JSON_PlayerPosition[(unsigned int)1].asDouble()); SetPosZ(JSON_PlayerPosition[(unsigned int)2].asDouble()); - m_LastPosX = GetPosX(); - m_LastPosY = GetPosY(); - m_LastPosZ = GetPosZ(); - m_LastFoodPos = GetPosition(); + m_LastPos = GetPosition(); } Json::Value & JSON_PlayerRotation = root["rotation"]; @@ -1858,9 +1849,8 @@ void cPlayer::ApplyFoodExhaustionFromMovement() } // Calculate the distance travelled, update the last pos: - Vector3d Movement(GetPosition() - m_LastFoodPos); + Vector3d Movement(GetPosition() - m_LastPos); Movement.y = 0; // Only take XZ movement into account - m_LastFoodPos = GetPosition(); // If riding anything, apply no food exhaustion if (m_AttachedTo != NULL) diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 05377a117..7a6b46ae9 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -423,9 +423,6 @@ protected: /** Number of ticks remaining for the foodpoisoning effect; zero if not foodpoisoned */ int m_FoodPoisonedTicksRemaining; - /** Last position that has been recorded for food-related processing: */ - Vector3d m_LastFoodPos; - float m_LastJumpHeight; float m_LastGroundHeight; bool m_bTouchGround; diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp index 02f31f5bb..fd9a4e7ac 100644 --- a/src/Entities/TNTEntity.cpp +++ b/src/Entities/TNTEntity.cpp @@ -30,8 +30,6 @@ cTNTEntity::cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks) : void cTNTEntity::SpawnOn(cClientHandle & a_ClientHandle) { a_ClientHandle.SendSpawnObject(*this, 50, 1, 0, 0); // 50 means TNT - m_bDirtyPosition = false; - m_bDirtySpeed = false; m_bDirtyOrientation = false; m_bDirtyHead = false; } diff --git a/src/Tracer.cpp b/src/Tracer.cpp index 6da6b2ad7..be42430a5 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -219,6 +219,10 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int return false; } + if ((pos.y < 0) || (pos.y >= cChunkDef::Height)) + { + return false; + } BLOCKTYPE BlockID = m_World->GetBlock(pos.x, pos.y, pos.z); // Block is counted as a collision if we are not doing a line of sight and it is solid, // or if the block is not air and not water. That way mobs can still see underwater. @@ -226,7 +230,7 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int { BlockHitPosition = pos; int Normal = GetHitNormal(a_Start, End, pos ); - if(Normal > 0) + if (Normal > 0) { HitNormal = m_NormalTable[Normal-1]; } -- cgit v1.2.3 From c701adbd241ea84d6f64842e8015c1009a41d786 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Apr 2014 21:34:45 +0200 Subject: Initial C++ SSL classes. --- src/Globals.h | 6 ++-- src/PolarSSL++/CtrDrbgContext.cpp | 49 ++++++++++++++++++++++++++++++++ src/PolarSSL++/CtrDrbgContext.h | 60 +++++++++++++++++++++++++++++++++++++++ src/PolarSSL++/EntropyContext.cpp | 29 +++++++++++++++++++ src/PolarSSL++/EntropyContext.h | 31 ++++++++++++++++++++ src/PolarSSL++/X509Cert.cpp | 38 +++++++++++++++++++++++++ src/PolarSSL++/X509Cert.h | 37 ++++++++++++++++++++++++ 7 files changed, 248 insertions(+), 2 deletions(-) create mode 100644 src/PolarSSL++/CtrDrbgContext.cpp create mode 100644 src/PolarSSL++/CtrDrbgContext.h create mode 100644 src/PolarSSL++/EntropyContext.cpp create mode 100644 src/PolarSSL++/EntropyContext.h create mode 100644 src/PolarSSL++/X509Cert.cpp create mode 100644 src/PolarSSL++/X509Cert.h (limited to 'src') diff --git a/src/Globals.h b/src/Globals.h index 26a0d87a9..3d7c9707c 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -264,9 +264,11 @@ template class SizeChecker; // Same as assert but in all Self test builds #ifdef SELF_TEST -#define assert_test(x) ( !!(x) || (assert(!#x), exit(1), 0)) + #define assert_test(x) ( !!(x) || (assert(!#x), exit(1), 0)) #endif +#define SharedPtr std::tr1::shared_ptr + @@ -296,7 +298,7 @@ T Clamp(T a_Value, T a_Min, T a_Max) #ifndef TOLUA_TEMPLATE_BIND -#define TOLUA_TEMPLATE_BIND(x) + #define TOLUA_TEMPLATE_BIND(x) #endif diff --git a/src/PolarSSL++/CtrDrbgContext.cpp b/src/PolarSSL++/CtrDrbgContext.cpp new file mode 100644 index 000000000..86e6d1ca5 --- /dev/null +++ b/src/PolarSSL++/CtrDrbgContext.cpp @@ -0,0 +1,49 @@ + +// CtrDrbgContext.cpp + +// Implements the cCtrDrbgContext class representing a wrapper over CTR-DRBG implementation in PolarSSL + +#include "Globals.h" +#include "CtrDrbgContext.h" +#include "EntropyContext.h" + + + + + +cCtrDrbgContext::cCtrDrbgContext(void) : + m_EntropyContext(new cEntropyContext), + m_IsValid(false) +{ +} + + + + + +cCtrDrbgContext::cCtrDrbgContext(const SharedPtr & a_EntropyContext) : + m_EntropyContext(a_EntropyContext), + m_IsValid(false) +{ +} + + + + + +int cCtrDrbgContext::Initialize(const void * a_Custom, size_t a_CustomSize) +{ + if (m_IsValid) + { + // Already initialized + return 0; + } + + int res = ctr_drbg_init(&m_CtrDrbg, entropy_func, &(m_EntropyContext->m_Entropy), (const unsigned char *)a_Custom, a_CustomSize); + m_IsValid = (res == 0); + return res; +} + + + + diff --git a/src/PolarSSL++/CtrDrbgContext.h b/src/PolarSSL++/CtrDrbgContext.h new file mode 100644 index 000000000..987f4dd72 --- /dev/null +++ b/src/PolarSSL++/CtrDrbgContext.h @@ -0,0 +1,60 @@ + +// CtrDrbgContext.h + +// Declares the cCtrDrbgContext class representing a wrapper over CTR-DRBG implementation in PolarSSL + + + + + +#pragma once + +#include "polarssl/ctr_drbg.h" + + + + + +// fwd: EntropyContext.h +class cEntropyContext; + + + + + +class cCtrDrbgContext +{ + friend class cSslContext; + +public: + /** Constructs the context with a new entropy context. */ + cCtrDrbgContext(void); + + /** Constructs the context with the specified entropy context. */ + cCtrDrbgContext(const SharedPtr & a_EntropyContext); + + /** Initializes the context. + a_Custom is optional additional data to use for entropy, nullptr is accepted. + Returns 0 if successful, PolarSSL error code on failure. */ + int Initialize(const void * a_Custom, size_t a_CustomSize); + + /** Returns true if the object is valid (has been initialized properly) */ + bool IsValid(void) const { return m_IsValid; } + + /** Returns the internal context ptr. Only use in PolarSSL API calls. */ + __declspec(deprecated) ctr_drbg_context * Get(void) { return &m_CtrDrbg; } + +protected: + /** The entropy source used for generating the random */ + SharedPtr m_EntropyContext; + + /** The random generator context */ + ctr_drbg_context m_CtrDrbg; + + /** Set to true if the object is valid (has been initialized properly) */ + bool m_IsValid; +} ; + + + + diff --git a/src/PolarSSL++/EntropyContext.cpp b/src/PolarSSL++/EntropyContext.cpp new file mode 100644 index 000000000..9c59b3f11 --- /dev/null +++ b/src/PolarSSL++/EntropyContext.cpp @@ -0,0 +1,29 @@ + +// EntropyContext.cpp + +// Implements the cEntropyContext class representing a wrapper over entropy contexts in PolarSSL + +#include "Globals.h" +#include "EntropyContext.h" + + + + + +cEntropyContext::cEntropyContext(void) +{ + entropy_init(&m_Entropy); +} + + + + + +cEntropyContext::~cEntropyContext() +{ + entropy_free(&m_Entropy); +} + + + + diff --git a/src/PolarSSL++/EntropyContext.h b/src/PolarSSL++/EntropyContext.h new file mode 100644 index 000000000..bc7fff066 --- /dev/null +++ b/src/PolarSSL++/EntropyContext.h @@ -0,0 +1,31 @@ + +// EntropyContext.h + +// Declares the cEntropyContext class representing a wrapper over entropy contexts in PolarSSL + + + + + +#pragma once + +#include "polarssl/entropy.h" + + + + + +class cEntropyContext +{ + friend class cCtrDrbgContext; +public: + cEntropyContext(void); + ~cEntropyContext(); + +protected: + entropy_context m_Entropy; +} ; + + + + diff --git a/src/PolarSSL++/X509Cert.cpp b/src/PolarSSL++/X509Cert.cpp new file mode 100644 index 000000000..ecf664855 --- /dev/null +++ b/src/PolarSSL++/X509Cert.cpp @@ -0,0 +1,38 @@ + +// X509Cert.cpp + +// Implements the cX509Cert class representing a wrapper over X509 certs in PolarSSL + +#include "Globals.h" +#include "X509Cert.h" + + + + + +cX509Cert::cX509Cert(void) +{ + x509_crt_init(&m_Cert); +} + + + + + +cX509Cert::~cX509Cert() +{ + x509_crt_free(&m_Cert); +} + + + + + +int cX509Cert::Parse(const void * a_CertContents, size_t a_Size) +{ + return x509_crt_parse(&m_Cert, (const unsigned char *)a_CertContents, a_Size); +} + + + + diff --git a/src/PolarSSL++/X509Cert.h b/src/PolarSSL++/X509Cert.h new file mode 100644 index 000000000..b0450510d --- /dev/null +++ b/src/PolarSSL++/X509Cert.h @@ -0,0 +1,37 @@ + +// X509Cert.h + +// Declares the cX509Cert class representing a wrapper over X509 certs in PolarSSL + + + + + +#pragma once + +#include "polarssl/x509_crt.h" + + + + + +class cX509Cert +{ +public: + cX509Cert(void); + ~cX509Cert(void); + + /** Parses the certificate chain data into the context. + Returns 0 on succes, or PolarSSL error code on failure. */ + int Parse(const void * a_CertContents, size_t a_Size); + + /** Returns the internal cert ptr. Only use in PolarSSL API calls. */ + __declspec(deprecated) x509_crt * Get(void) { return &m_Cert; } + +protected: + x509_crt m_Cert; +} ; + + + + -- cgit v1.2.3 From c4b4447a3ada43d4333bba329e89700527870332 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Apr 2014 21:51:19 +0200 Subject: Authenticator uses some C++ SSL objects. --- src/Protocol/Authenticator.cpp | 59 ++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index e0fcc0007..ccc994e36 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -13,10 +13,12 @@ #include "polarssl/config.h" #include "polarssl/net.h" #include "polarssl/ssl.h" -#include "polarssl/entropy.h" #include "polarssl/ctr_drbg.h" #include "polarssl/error.h" -#include "polarssl/certs.h" + +#include "PolarSSL++/EntropyContext.h" +#include "PolarSSL++/CtrDrbgContext.h" +#include "PolarSSL++/X509Cert.h" #include #include @@ -150,31 +152,52 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S int ret, server_fd = -1; unsigned char buf[1024]; - const char *pers = "cAuthenticator"; + const char pers[] = "cAuthenticator"; - entropy_context entropy; - ctr_drbg_context ctr_drbg; + cCtrDrbgContext CtrDrbg; ssl_context ssl; - x509_crt cacert; + cX509Cert CACert; /* Initialize the RNG and the session data */ memset(&ssl, 0, sizeof(ssl_context)); - x509_crt_init(&cacert); - entropy_init(&entropy); - if ((ret = ctr_drbg_init(&ctr_drbg, entropy_func, &entropy, (const unsigned char *)pers, strlen(pers))) != 0) + if ((ret = CtrDrbg.Initialize(pers, sizeof(pers))) != 0) { - LOGWARNING("cAuthenticator: ctr_drbg_init returned %d", ret); + LOGWARNING("cAuthenticator: CtrDrbg.Initialize() returned %d", ret); return false; } /* Initialize certificates */ - // TODO: Grab the sessionserver's root CA and any intermediates and hard-code them here, instead of test_ca_list - ret = x509_crt_parse(&cacert, (const unsigned char *)test_ca_list, strlen(test_ca_list)); - + // This is the root cert for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert: + static const char StarfieldCACert[] = + "-----BEGIN CERTIFICATE-----\n" + "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n" + "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n" + "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n" + "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n" + "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n" + "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" + "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n" + "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n" + "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n" + "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n" + "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n" + "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n" + "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" + "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" + "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" + "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" + "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" + "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" + "-----END CERTIFICATE-----"; + // Parse the Starfield CA and add it to "trusted root certs" + ret = CACert.Parse(StarfieldCACert, sizeof(StarfieldCACert) - 1); if (ret < 0) { - LOGWARNING("cAuthenticator: x509_crt_parse returned -0x%x", -ret); + LOGWARNING("cAuthenticator: CACert.Parse returned -0x%x", -ret); return false; } @@ -193,8 +216,8 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S } ssl_set_endpoint(&ssl, SSL_IS_CLIENT); ssl_set_authmode(&ssl, SSL_VERIFY_OPTIONAL); - ssl_set_ca_chain(&ssl, &cacert, NULL, "PolarSSL Server 1"); - ssl_set_rng(&ssl, ctr_drbg_random, &ctr_drbg); + ssl_set_ca_chain(&ssl, CACert.Get(), NULL, "PolarSSL Server 1"); + ssl_set_rng(&ssl, ctr_drbg_random, CtrDrbg.Get()); ssl_set_bio(&ssl, net_recv, &server_fd, net_send, &server_fd); /* Handshake */ @@ -253,13 +276,11 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S } Response.append((const char *)buf, ret); - } + } ssl_close_notify(&ssl); - x509_crt_free(&cacert); net_close(server_fd); ssl_free(&ssl); - entropy_free(&entropy); memset(&ssl, 0, sizeof(ssl)); // Check the HTTP status line: -- cgit v1.2.3 From e33573ab59fefb76c1d01910f49428d808992b2b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Apr 2014 21:51:39 +0200 Subject: Attempted CMake inclusion for PolarSSL++. --- src/CMakeLists.txt | 4 ++-- src/PolarSSL++/CMakeLists.txt | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 src/PolarSSL++/CMakeLists.txt (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 30e9dbfd4..67bb299db 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,7 @@ include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/") include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/jsoncpp/include") include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/polarssl/include") -set(FOLDERS OSSupport HTTPServer Items Blocks Protocol Generating) +set(FOLDERS OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++) set(FOLDERS ${FOLDERS} WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs) @@ -233,7 +233,7 @@ endif () if (NOT MSVC) target_link_libraries(${EXECUTABLE} OSSupport HTTPServer Bindings Items Blocks) target_link_libraries(${EXECUTABLE} Protocol Generating Generating_Prefabs WorldStorage) - target_link_libraries(${EXECUTABLE} Mobs Entities Simulator UI BlockEntities) + target_link_libraries(${EXECUTABLE} Mobs Entities Simulator UI BlockEntities PolarSSL++) endif () if (WIN32) target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib) diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt new file mode 100644 index 000000000..4f954a7e5 --- /dev/null +++ b/src/PolarSSL++/CMakeLists.txt @@ -0,0 +1,17 @@ + +cmake_minimum_required (VERSION 2.6) +project (MCServer) + +include_directories ("${PROJECT_SOURCE_DIR}/../") + +set(SOURCES + "EntropyContext.cpp" + "CtrDrbgContext.cpp" + "x509Cert.cpp" +) + +add_library(PolarSSL++ ${SOURCES}) + +if (UNIX) + target_link_libraries(PolarSSL++ polarssl) +endif() -- cgit v1.2.3 From c7694687f5d921a354fa87ea47c36570e705b9ff Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Apr 2014 22:15:21 +0200 Subject: Fixed filename case. --- src/PolarSSL++/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt index 4f954a7e5..c5b747980 100644 --- a/src/PolarSSL++/CMakeLists.txt +++ b/src/PolarSSL++/CMakeLists.txt @@ -7,7 +7,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../") set(SOURCES "EntropyContext.cpp" "CtrDrbgContext.cpp" - "x509Cert.cpp" + "X509Cert.cpp" ) add_library(PolarSSL++ ${SOURCES}) -- cgit v1.2.3 From a02e8e8021147783b011d9a2f99ba3f1128ae8e8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Apr 2014 22:30:19 +0200 Subject: Declared a SharedPtr that hopefully resolves on all platforms. MSVC2008 has it in std::tr1, all the others in std. --- src/Globals.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Globals.h b/src/Globals.h index 3d7c9707c..2e7e0c9cf 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -267,7 +267,15 @@ template class SizeChecker; #define assert_test(x) ( !!(x) || (assert(!#x), exit(1), 0)) #endif -#define SharedPtr std::tr1::shared_ptr +// Allow both Older versions of MSVC and newer versions of everything use a shared_ptr: +// Note that we cannot typedef, because C++ doesn't allow (partial) templates to be typedeffed. +#if (defined(_MSC_VER) && (_MSC_VER < 1600)) + // MSVC before 2010 doesn't have std::shared_ptr, but has std::tr1::shared_ptr + #define SharedPtr std::tr1::shared_ptr +#else + // All others have std::shared ptr + #define SharedPtr std::shared_ptr +#endif -- cgit v1.2.3 From 616fb15508187d317a7ca4195667e204faf3749c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Apr 2014 22:42:33 +0200 Subject: cByteBuffer uses void * instead of char * in data interface. This makes it compatible with any pointer type. --- src/ByteBuffer.cpp | 9 +++++---- src/ByteBuffer.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index c634dc308..ad753118b 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -171,7 +171,7 @@ cByteBuffer::~cByteBuffer() -bool cByteBuffer::Write(const char * a_Bytes, size_t a_Count) +bool cByteBuffer::Write(const void * a_Bytes, size_t a_Count) { CHECK_THREAD; CheckValid(); @@ -187,13 +187,14 @@ bool cByteBuffer::Write(const char * a_Bytes, size_t a_Count) } ASSERT(m_BufferSize >= m_WritePos); size_t TillEnd = m_BufferSize - m_WritePos; + const char * Bytes = (const char *)a_Bytes; if (TillEnd <= a_Count) { // Need to wrap around the ringbuffer end if (TillEnd > 0) { - memcpy(m_Buffer + m_WritePos, a_Bytes, TillEnd); - a_Bytes += TillEnd; + memcpy(m_Buffer + m_WritePos, Bytes, TillEnd); + Bytes += TillEnd; a_Count -= TillEnd; WrittenBytes = TillEnd; } @@ -203,7 +204,7 @@ bool cByteBuffer::Write(const char * a_Bytes, size_t a_Count) // We're guaranteed that we'll fit in a single write op if (a_Count > 0) { - memcpy(m_Buffer + m_WritePos, a_Bytes, a_Count); + memcpy(m_Buffer + m_WritePos, Bytes, a_Count); m_WritePos += a_Count; WrittenBytes += a_Count; } diff --git a/src/ByteBuffer.h b/src/ByteBuffer.h index 44f43e17f..7656a5b13 100644 --- a/src/ByteBuffer.h +++ b/src/ByteBuffer.h @@ -31,7 +31,7 @@ public: ~cByteBuffer(); /// Writes the bytes specified to the ringbuffer. Returns true if successful, false if not - bool Write(const char * a_Bytes, size_t a_Count); + bool Write(const void * a_Bytes, size_t a_Count); /// Returns the number of bytes that can be successfully written to the ringbuffer size_t GetFreeSpace(void) const; -- cgit v1.2.3 From 4f49c978cf6b130ede105e9a858831806e51d118 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Apr 2014 22:43:20 +0200 Subject: Replaced MSVC-specific decorators with our universal ones. --- src/PolarSSL++/CtrDrbgContext.h | 2 +- src/PolarSSL++/X509Cert.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/PolarSSL++/CtrDrbgContext.h b/src/PolarSSL++/CtrDrbgContext.h index 987f4dd72..e9a1e17e2 100644 --- a/src/PolarSSL++/CtrDrbgContext.h +++ b/src/PolarSSL++/CtrDrbgContext.h @@ -42,7 +42,7 @@ public: bool IsValid(void) const { return m_IsValid; } /** Returns the internal context ptr. Only use in PolarSSL API calls. */ - __declspec(deprecated) ctr_drbg_context * Get(void) { return &m_CtrDrbg; } + OBSOLETE ctr_drbg_context * Get(void) { return &m_CtrDrbg; } protected: /** The entropy source used for generating the random */ diff --git a/src/PolarSSL++/X509Cert.h b/src/PolarSSL++/X509Cert.h index b0450510d..5ef19c324 100644 --- a/src/PolarSSL++/X509Cert.h +++ b/src/PolarSSL++/X509Cert.h @@ -26,7 +26,7 @@ public: int Parse(const void * a_CertContents, size_t a_Size); /** Returns the internal cert ptr. Only use in PolarSSL API calls. */ - __declspec(deprecated) x509_crt * Get(void) { return &m_Cert; } + OBSOLETE x509_crt * Get(void) { return &m_Cert; } protected: x509_crt m_Cert; -- cgit v1.2.3 From c949c1e7550fda892957bccaa81c53e9c2215935 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 24 Apr 2014 22:03:47 +0100 Subject: Implemented suggestions --- src/Entities/Entity.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 5c7c9c95a..f535faac7 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1,3 +1,4 @@ + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Entity.h" @@ -722,11 +723,9 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) if (NextSpeed.SqrLength() > 0.f) { cTracer Tracer(GetWorld()); - - bool HasHit = Tracer.Trace(NextPos, NextSpeed, - // Distance traced is an integer, so we round up from the distance we should go (Speed * Delta), else we will encounter collision detection failures - (int)(ceil((NextSpeed * a_Dt).SqrLength()) * 2) - ); + // Distance traced is an integer, so we round up from the distance we should go (Speed * Delta), else we will encounter collision detection failurse + int DistanceToTrace = (int)(ceil((NextSpeed * a_Dt).SqrLength()) * 2); + bool HasHit = Tracer.Trace(NextPos, NextSpeed, DistanceToTrace); if (HasHit) { @@ -736,7 +735,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) { // Block hit was within our projected path // Begin by stopping movement in the direction that we hit something. The Normal is the line perpendicular to a 2D face and in this case, stores what block face was hit through either -1 or 1. - // Por ejemplo: HitNormal.y = -1 : BLOCK_FACE_YM; HitNormal.y = 1 : BLOCK_FACE_YP + // For example: HitNormal.y = -1 : BLOCK_FACE_YM; HitNormal.y = 1 : BLOCK_FACE_YP if (Tracer.HitNormal.x != 0.f) NextSpeed.x = 0.f; if (Tracer.HitNormal.y != 0.f) NextSpeed.y = 0.f; if (Tracer.HitNormal.z != 0.f) NextSpeed.z = 0.f; @@ -954,7 +953,7 @@ void cEntity::SetSwimState(cChunk & a_Chunk) // Ref.: http://forum.mc-server.org/showthread.php?tid=1244 LOGD("SetSwimState failure: RelX = %d, RelZ = %d, Pos = %.02f, %.02f}", RelX, RelY, GetPosX(), GetPosZ() - ); + ); m_IsSwimming = false; m_IsSubmerged = false; return; -- cgit v1.2.3 From f3dfc0349d7008efa50855c739d86918bdbf4a88 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 25 Apr 2014 09:48:52 +0200 Subject: Added shared_ptr handling for C++03 mode. --- src/Globals.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Globals.h b/src/Globals.h index 2e7e0c9cf..93baf69ea 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -270,11 +270,15 @@ template class SizeChecker; // Allow both Older versions of MSVC and newer versions of everything use a shared_ptr: // Note that we cannot typedef, because C++ doesn't allow (partial) templates to be typedeffed. #if (defined(_MSC_VER) && (_MSC_VER < 1600)) - // MSVC before 2010 doesn't have std::shared_ptr, but has std::tr1::shared_ptr + // MSVC before 2010 doesn't have std::shared_ptr, but has std::tr1::shared_ptr, defined in included earlier #define SharedPtr std::tr1::shared_ptr -#else - // All others have std::shared ptr +#elif (__cplusplus > 201103L) + // C++11 has std::shared_ptr in , included earlier #define SharedPtr std::shared_ptr +#else + // C++03 has std::tr1::shared_ptr in + #include + #define SharedPtr std::tr1::shared_ptr #endif -- cgit v1.2.3 From 6d167b370e409d77eb2b9e02bc95b80463670823 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 25 Apr 2014 16:05:24 +0200 Subject: Fixed C++11 check for SharedPtr. --- src/Globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Globals.h b/src/Globals.h index 93baf69ea..a09819ce9 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -272,7 +272,7 @@ template class SizeChecker; #if (defined(_MSC_VER) && (_MSC_VER < 1600)) // MSVC before 2010 doesn't have std::shared_ptr, but has std::tr1::shared_ptr, defined in included earlier #define SharedPtr std::tr1::shared_ptr -#elif (__cplusplus > 201103L) +#elif (__cplusplus >= 201103L) // C++11 has std::shared_ptr in , included earlier #define SharedPtr std::shared_ptr #else -- cgit v1.2.3 From 7e76f030aa2e6d39ac7fe9fb6a8a3db44bf3dd5f Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 26 Apr 2014 00:32:30 +0200 Subject: Add entity invulnerable --- src/Entities/Boat.cpp | 8 ++++++-- src/Entities/Boat.h | 2 +- src/Entities/Entity.cpp | 21 ++++++++++++++++++--- src/Entities/Entity.h | 17 +++++++++++++---- src/Entities/Minecart.cpp | 14 +++++++++----- src/Entities/Minecart.h | 2 +- src/Entities/Player.cpp | 21 ++++++++++++--------- src/Entities/Player.h | 2 +- src/Mobs/Creeper.cpp | 8 ++++++-- src/Mobs/Creeper.h | 2 +- src/Mobs/Monster.cpp | 8 ++++++-- src/Mobs/Monster.h | 2 +- src/Mobs/PassiveAggressiveMonster.cpp | 8 ++++++-- src/Mobs/PassiveAggressiveMonster.h | 2 +- src/Mobs/PassiveMonster.cpp | 8 ++++++-- src/Mobs/PassiveMonster.h | 2 +- src/Mobs/Villager.cpp | 9 +++++++-- src/Mobs/Villager.h | 2 +- src/Mobs/Wither.cpp | 10 +++++----- src/Mobs/Wither.h | 2 +- src/Mobs/Wolf.cpp | 9 +++++++-- src/Mobs/Wolf.h | 2 +- 22 files changed, 111 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp index 921252253..31bfe3dc3 100644 --- a/src/Entities/Boat.cpp +++ b/src/Entities/Boat.cpp @@ -33,9 +33,12 @@ void cBoat::SpawnOn(cClientHandle & a_ClientHandle) -void cBoat::DoTakeDamage(TakeDamageInfo & TDI) +bool cBoat::DoTakeDamage(TakeDamageInfo & TDI) { - super::DoTakeDamage(TDI); + if (!super::DoTakeDamage(TDI)) + { + return false; + } if (GetHealth() == 0) { @@ -50,6 +53,7 @@ void cBoat::DoTakeDamage(TakeDamageInfo & TDI) } Destroy(true); } + return true; } diff --git a/src/Entities/Boat.h b/src/Entities/Boat.h index c4c9afe7a..0fcfbd602 100644 --- a/src/Entities/Boat.h +++ b/src/Entities/Boat.h @@ -26,7 +26,7 @@ public: // cEntity overrides: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; virtual void OnRightClicked(cPlayer & a_Player) override; - virtual void DoTakeDamage(TakeDamageInfo & TDI) override; + virtual bool DoTakeDamage(TakeDamageInfo & TDI) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override; diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 6da6da54e..4403ab161 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -60,6 +60,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_Mass (0.001) // Default 1g , m_Width(a_Width) , m_Height(a_Height) + , m_InvulnerableTicks(20) { cCSLock Lock(m_CSCount); m_EntityCount++; @@ -294,17 +295,23 @@ void cEntity::SetPitchFromSpeed(void) -void cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) +bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) { if (cRoot::Get()->GetPluginManager()->CallHookTakeDamage(*this, a_TDI)) { - return; + return false; } if (m_Health <= 0) { // Can't take damage if already dead - return; + return false; + } + + if (m_InvulnerableTicks > 0) + { + // Entity is invulnerable + return false; } if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer())) @@ -333,10 +340,13 @@ void cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) m_World->BroadcastEntityStatus(*this, esGenericHurt); + m_InvulnerableTicks = 10; + if (m_Health <= 0) { KilledBy(a_TDI.Attacker); } + return true; } @@ -511,6 +521,11 @@ void cEntity::SetHealth(int a_Health) void cEntity::Tick(float a_Dt, cChunk & a_Chunk) { + if (m_InvulnerableTicks > 0) + { + m_InvulnerableTicks--; + } + if (m_AttachedTo != NULL) { if ((m_Pos - m_AttachedTo->GetPosition()).Length() > 0.5) diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 86efc5a98..fc4186afc 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -262,8 +262,8 @@ public: // tolua_end - /// Makes this entity take damage specified in the a_TDI. The TDI is sent through plugins first, then applied - virtual void DoTakeDamage(TakeDamageInfo & a_TDI); + /** Makes this entity take damage specified in the a_TDI. The TDI is sent through plugins first, then applied. If it returns false, the entity hasn't become any damage. */ + virtual bool DoTakeDamage(TakeDamageInfo & a_TDI); // tolua_begin @@ -391,6 +391,12 @@ public: virtual bool IsSubmerged(void) const{ return m_IsSubmerged; } /** Gets remaining air of a monster */ int GetAirLevel(void) const { return m_AirLevel; } + + /** Gets the invulnerable ticks from the entity */ + int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; } + + /** Set the invulnerable ticks from the entity */ + void SetInvulnerableTicks(int a_InvulnerableTicks) { m_InvulnerableTicks = a_InvulnerableTicks; } // tolua_end @@ -493,11 +499,14 @@ private: // Measured in Kilograms (Kg) double m_Mass; - /// Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter. + // Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter. double m_Width; - /// Height of the entity (Y axis) + // Height of the entity (Y axis) double m_Height; + + // If a player hunt a entity, the entity become a invulnerable of 20 ticks + int m_InvulnerableTicks; } ; // tolua_export typedef std::list cEntityList; diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index db55eb058..7bd440d6d 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -902,18 +902,21 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta) -void cMinecart::DoTakeDamage(TakeDamageInfo & TDI) +bool cMinecart::DoTakeDamage(TakeDamageInfo & TDI) { if ((TDI.Attacker != NULL) && TDI.Attacker->IsPlayer() && ((cPlayer *)TDI.Attacker)->IsGameModeCreative()) { Destroy(); TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative - super::DoTakeDamage(TDI); - return; // No drops for creative + SetInvulnerableTicks(0); + return super::DoTakeDamage(TDI); // No drops for creative } m_LastDamage = TDI.FinalDamage; - super::DoTakeDamage(TDI); + if (!super::DoTakeDamage(TDI)) + { + return false; + } m_World->BroadcastEntityMetadata(*this); @@ -952,12 +955,13 @@ void cMinecart::DoTakeDamage(TakeDamageInfo & TDI) default: { ASSERT(!"Unhandled minecart type when spawning pickup!"); - return; + return true; } } m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ()); } + return true; } diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h index ebdb576e0..1e60f091c 100644 --- a/src/Entities/Minecart.h +++ b/src/Entities/Minecart.h @@ -36,7 +36,7 @@ public: // cEntity overrides: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override; - virtual void DoTakeDamage(TakeDamageInfo & TDI) override; + virtual bool DoTakeDamage(TakeDamageInfo & TDI) override; virtual void Destroyed() override; int LastDamage(void) const { return m_LastDamage; } diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index fedb62527..08b7d3984 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -808,14 +808,14 @@ void cPlayer::SetFlying(bool a_IsFlying) -void cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI) +bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI) { if ((a_TDI.DamageType != dtInVoid) && (a_TDI.DamageType != dtPlugin)) { if (IsGameModeCreative()) { // No damage / health in creative mode if not void or plugin damage - return; + return false; } } @@ -828,17 +828,19 @@ void cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI) if (!m_Team->AllowsFriendlyFire()) { // Friendly fire is disabled - return; + return false; } } } - super::DoTakeDamage(a_TDI); - - // Any kind of damage adds food exhaustion - AddFoodExhaustion(0.3f); - - SendHealth(); + if (super::DoTakeDamage(a_TDI)) + { + // Any kind of damage adds food exhaustion + AddFoodExhaustion(0.3f); + SendHealth(); + return true; + } + return false; } @@ -897,6 +899,7 @@ void cPlayer::KilledBy(cEntity * a_Killer) void cPlayer::Respawn(void) { m_Health = GetMaxHealth(); + SetInvulnerableTicks(20); // Reset food level: m_FoodLevel = MAX_FOOD_LEVEL; diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 78d661015..3029abfe0 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -498,7 +498,7 @@ protected: virtual void Destroyed(void); /** Filters out damage for creative mode/friendly fire */ - virtual void DoTakeDamage(TakeDamageInfo & TDI) override; + virtual bool DoTakeDamage(TakeDamageInfo & TDI) override; /** Stops players from burning in creative mode */ virtual void TickBurning(cChunk & a_Chunk) override; diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp index 3471b4cf1..9cf539427 100644 --- a/src/Mobs/Creeper.cpp +++ b/src/Mobs/Creeper.cpp @@ -75,9 +75,12 @@ void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI) +bool cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI) { - super::DoTakeDamage(a_TDI); + if (!super::DoTakeDamage(a_TDI)) + { + return false; + } if (a_TDI.DamageType == dtLightning) { @@ -85,6 +88,7 @@ void cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI) } m_World->BroadcastEntityMetadata(*this); + return true; } diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h index 9abca369b..fc7db6716 100644 --- a/src/Mobs/Creeper.h +++ b/src/Mobs/Creeper.h @@ -18,7 +18,7 @@ public: CLASS_PROTODEF(cCreeper); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; + virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void Attack(float a_Dt) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void OnRightClicked(cPlayer & a_Player) override; diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index eb8480268..9e4c2ba25 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -457,9 +457,12 @@ int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ) -void cMonster::DoTakeDamage(TakeDamageInfo & a_TDI) +bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI) { - super::DoTakeDamage(a_TDI); + if (!super::DoTakeDamage(a_TDI)) + { + return false; + } if((m_SoundHurt != "") && (m_Health > 0)) m_World->BroadcastSoundEffect(m_SoundHurt, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f); @@ -468,6 +471,7 @@ void cMonster::DoTakeDamage(TakeDamageInfo & a_TDI) { m_Target = a_TDI.Attacker; } + return true; } diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 70b3783fc..5a925dfc6 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -87,7 +87,7 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; + virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void KilledBy(cEntity * a_Killer) override; diff --git a/src/Mobs/PassiveAggressiveMonster.cpp b/src/Mobs/PassiveAggressiveMonster.cpp index 4b45f9a2a..24501b1ba 100644 --- a/src/Mobs/PassiveAggressiveMonster.cpp +++ b/src/Mobs/PassiveAggressiveMonster.cpp @@ -19,9 +19,12 @@ cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigNam -void cPassiveAggressiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI) +bool cPassiveAggressiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI) { - super::DoTakeDamage(a_TDI); + if (!super::DoTakeDamage(a_TDI)) + { + return false; + } if ((m_Target != NULL) && (m_Target->IsPlayer())) { @@ -30,6 +33,7 @@ void cPassiveAggressiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI) m_EMState = CHASING; } } + return true; } diff --git a/src/Mobs/PassiveAggressiveMonster.h b/src/Mobs/PassiveAggressiveMonster.h index 2c5ef30b1..a0da50e8e 100644 --- a/src/Mobs/PassiveAggressiveMonster.h +++ b/src/Mobs/PassiveAggressiveMonster.h @@ -15,7 +15,7 @@ class cPassiveAggressiveMonster : public: cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); - virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; + virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; } ; diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp index 904cd63cc..2861d7314 100644 --- a/src/Mobs/PassiveMonster.cpp +++ b/src/Mobs/PassiveMonster.cpp @@ -18,13 +18,17 @@ cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eType a_MobType, -void cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI) +bool cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI) { - super::DoTakeDamage(a_TDI); + if (!super::DoTakeDamage(a_TDI)) + { + return false; + } if ((a_TDI.Attacker != this) && (a_TDI.Attacker != NULL)) { m_EMState = ESCAPING; } + return true; } diff --git a/src/Mobs/PassiveMonster.h b/src/Mobs/PassiveMonster.h index 0b3c155da..70574585a 100644 --- a/src/Mobs/PassiveMonster.h +++ b/src/Mobs/PassiveMonster.h @@ -18,7 +18,7 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; /// When hit by someone, run away - virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; + virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; /** Returns the item that the animal of this class follows when a player holds it in hand Return an empty item not to follow (default). */ virtual const cItem GetFollowedItem(void) const { return cItem(); } diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index d049acc1e..41283acf4 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -23,9 +23,13 @@ cVillager::cVillager(eVillagerType VillagerType) : -void cVillager::DoTakeDamage(TakeDamageInfo & a_TDI) +bool cVillager::DoTakeDamage(TakeDamageInfo & a_TDI) { - super::DoTakeDamage(a_TDI); + if (!super::DoTakeDamage(a_TDI)) + { + return false; + } + if ((a_TDI.Attacker != NULL) && a_TDI.Attacker->IsPlayer()) { if (m_World->GetTickRandomNumber(5) == 3) @@ -33,6 +37,7 @@ void cVillager::DoTakeDamage(TakeDamageInfo & a_TDI) m_World->BroadcastEntityStatus(*this, esVillagerAngry); } } + return true; } diff --git a/src/Mobs/Villager.h b/src/Mobs/Villager.h index 5bba4d4ba..abde48407 100644 --- a/src/Mobs/Villager.h +++ b/src/Mobs/Villager.h @@ -30,7 +30,7 @@ public: CLASS_PROTODEF(cVillager); // cEntity overrides - virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; + virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void Tick (float a_Dt, cChunk & a_Chunk) override; // cVillager functions diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp index 8f5d28b68..144f89658 100644 --- a/src/Mobs/Wither.cpp +++ b/src/Mobs/Wither.cpp @@ -40,24 +40,24 @@ bool cWither::Initialize(cWorld * a_World) -void cWither::DoTakeDamage(TakeDamageInfo & a_TDI) +bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI) { if (a_TDI.DamageType == dtDrowning) { - return; + return false; } if (m_InvulnerableTicks > 0) { - return; + return false; } if (IsArmored() && (a_TDI.DamageType == dtRangedAttack)) { - return; + return false; } - super::DoTakeDamage(a_TDI); + return super::DoTakeDamage(a_TDI); } diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index bc78bfaad..3b22ba4a5 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -27,7 +27,7 @@ public: // cEntity overrides virtual bool Initialize(cWorld * a_World) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; + virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; private: diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index f02b8a4fc..e6268abc7 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -25,14 +25,19 @@ cWolf::cWolf(void) : -void cWolf::DoTakeDamage(TakeDamageInfo & a_TDI) +bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI) { - super::DoTakeDamage(a_TDI); + if (super::DoTakeDamage(a_TDI)) + { + return false; + } + if (!m_IsTame) { m_IsAngry = true; } m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face + return true; } diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h index 5925373e1..fb8a7c995 100644 --- a/src/Mobs/Wolf.h +++ b/src/Mobs/Wolf.h @@ -18,7 +18,7 @@ public: CLASS_PROTODEF(cWolf); - virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; + virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void OnRightClicked(cPlayer & a_Player) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void TickFollowPlayer(); -- cgit v1.2.3 From ad1410f46e5deccc9f9a38e360fa65d6e33b82b4 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 26 Apr 2014 00:37:09 +0200 Subject: Change m_InvulnerableTicks description --- src/Entities/Entity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index fc4186afc..ac9cf8b32 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -505,7 +505,7 @@ private: // Height of the entity (Y axis) double m_Height; - // If a player hunt a entity, the entity become a invulnerable of 20 ticks + // If a player hit a entity, the entity become a invulnerable of 20 ticks int m_InvulnerableTicks; } ; // tolua_export -- cgit v1.2.3 From ed1aa02d0c0efbffbaf46c8f17dc4c52c9e6f34d Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 26 Apr 2014 00:37:40 +0200 Subject: Change m_InvulnerableTicks description again. --- src/Entities/Entity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index ac9cf8b32..ba74a38a9 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -505,7 +505,7 @@ private: // Height of the entity (Y axis) double m_Height; - // If a player hit a entity, the entity become a invulnerable of 20 ticks + // If a player hit a entity, the entity become a invulnerable of 10 ticks int m_InvulnerableTicks; } ; // tolua_export -- cgit v1.2.3 From e5683ede63572fe8b40703d449adf784b7d80ea7 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 26 Apr 2014 00:41:00 +0200 Subject: Change m_InvulnerableTicks description again again :D --- src/Entities/Entity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index ba74a38a9..e76279c28 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -505,7 +505,7 @@ private: // Height of the entity (Y axis) double m_Height; - // If a player hit a entity, the entity become a invulnerable of 10 ticks + // If a player hit a entity, the entity become a invulnerable of 10 ticks. While this ticks, a player can't hit this entity. int m_InvulnerableTicks; } ; // tolua_export -- cgit v1.2.3 From 49f6819829b437f776ea08f50c92cc506ee9ddcb Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 26 Apr 2014 16:44:15 +0200 Subject: Fixes --- src/Entities/Entity.cpp | 2 +- src/Entities/Entity.h | 23 +++++++++++++---------- src/Mobs/Wither.cpp | 10 +++++----- src/Mobs/Wither.h | 6 +++--- src/Protocol/Protocol125.cpp | 2 +- src/Protocol/Protocol17x.cpp | 2 +- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- src/WorldStorage/WSSAnvil.cpp | 2 +- 8 files changed, 26 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 0af4eafde..db657909c 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -60,7 +60,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_Mass (0.001) // Default 1g , m_Width(a_Width) , m_Height(a_Height) - , m_InvulnerableTicks(20) + , m_InvulnerableTicks(0) { cCSLock Lock(m_CSCount); m_EntityCount++; diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index e76279c28..26edf8dca 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -262,7 +262,9 @@ public: // tolua_end - /** Makes this entity take damage specified in the a_TDI. The TDI is sent through plugins first, then applied. If it returns false, the entity hasn't become any damage. */ + /** Makes this entity take damage specified in the a_TDI. + The TDI is sent through plugins first, then applied. + If it returns false, the entity hasn't receive any damage. */ virtual bool DoTakeDamage(TakeDamageInfo & a_TDI); // tolua_begin @@ -481,31 +483,32 @@ protected: int m_AirTickTimer; private: - // Measured in degrees, [-180, +180) + /** Measured in degrees, [-180, +180) */ double m_HeadYaw; - // Measured in meter/second (m/s) + /** Measured in meter/second (m/s) */ Vector3d m_Speed; - // Measured in degrees, [-180, +180) + /** Measured in degrees, [-180, +180) */ Vector3d m_Rot; - /// Position of the entity's XZ center and Y bottom + /** Position of the entity's XZ center and Y bottom */ Vector3d m_Pos; - // Measured in meter / second + /** Measured in meter / second */ Vector3d m_WaterSpeed; - // Measured in Kilograms (Kg) + /** Measured in Kilograms (Kg) */ double m_Mass; - // Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter. + /** Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter. */ double m_Width; - // Height of the entity (Y axis) + /** Height of the entity (Y axis) */ double m_Height; - // If a player hit a entity, the entity become a invulnerable of 10 ticks. While this ticks, a player can't hit this entity. + /** If a player hit a entity, the entity receive a invulnerable of 10 ticks. + While this ticks, a player can't hit this entity. */ int m_InvulnerableTicks; } ; // tolua_export diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp index 144f89658..5b6e895e1 100644 --- a/src/Mobs/Wither.cpp +++ b/src/Mobs/Wither.cpp @@ -10,7 +10,7 @@ cWither::cWither(void) : super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0), - m_InvulnerableTicks(220) + m_WitherInvulnerableTicks(220) { SetMaxHealth(300); } @@ -47,7 +47,7 @@ bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI) return false; } - if (m_InvulnerableTicks > 0) + if (m_WitherInvulnerableTicks > 0) { return false; } @@ -68,16 +68,16 @@ void cWither::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - if (m_InvulnerableTicks > 0) + if (m_WitherInvulnerableTicks > 0) { - unsigned int NewTicks = m_InvulnerableTicks - 1; + unsigned int NewTicks = m_WitherInvulnerableTicks - 1; if (NewTicks == 0) { m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this); } - m_InvulnerableTicks = NewTicks; + m_WitherInvulnerableTicks = NewTicks; if ((NewTicks % 10) == 0) { diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index 3b22ba4a5..08b460009 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -17,9 +17,9 @@ public: CLASS_PROTODEF(cWither); - unsigned int GetNumInvulnerableTicks(void) const { return m_InvulnerableTicks; } + unsigned int GetWitherInvulnerableTicks(void) const { return m_WitherInvulnerableTicks; } - void SetNumInvulnerableTicks(unsigned int a_Ticks) { m_InvulnerableTicks = a_Ticks; } + void SetWitherInvulnerableTicks(unsigned int a_Ticks) { m_WitherInvulnerableTicks = a_Ticks; } /** Returns whether the wither is invulnerable to arrows. */ bool IsArmored(void) const; @@ -33,7 +33,7 @@ public: private: /** The number of ticks of invulnerability left after being initially created. Zero once invulnerability has expired. */ - unsigned int m_InvulnerableTicks; + unsigned int m_WitherInvulnerableTicks; } ; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 3282a827f..a23afb29a 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -2013,7 +2013,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) case cMonster::mtWither: { WriteByte(0x54); // Int at index 20 - WriteInt((Int32)((const cWither &)a_Mob).GetNumInvulnerableTicks()); + WriteInt((Int32)((const cWither &)a_Mob).GetWitherInvulnerableTicks()); WriteByte(0x66); // Float at index 6 WriteFloat((float)(a_Mob.GetHealth())); break; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index e57b551cb..80b161e3e 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -2820,7 +2820,7 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob) case cMonster::mtWither: { WriteByte(0x54); // Int at index 20 - WriteInt(((const cWither &)a_Mob).GetNumInvulnerableTicks()); + WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks()); WriteByte(0x66); // Float at index 6 WriteFloat((float)(a_Mob.GetHealth())); break; diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index b6c14db9c..46c6b8e92 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -516,7 +516,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster) } case cMonster::mtWither: { - m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetNumInvulnerableTicks()); + m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetWitherInvulnerableTicks()); break; } case cMonster::mtWolf: diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 66144dbd5..4532a925a 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -2272,7 +2272,7 @@ void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a int CurrLine = a_NBT.FindChildByName(a_TagIdx, "Invul"); if (CurrLine > 0) { - Monster->SetNumInvulnerableTicks(a_NBT.GetInt(CurrLine)); + Monster->SetWitherInvulnerableTicks(a_NBT.GetInt(CurrLine)); } a_Entities.push_back(Monster.release()); -- cgit v1.2.3 From 619592b5a0ab651e714d55932bc7909e4204cee9 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 26 Apr 2014 17:37:35 +0200 Subject: Withers now use the new invulnerable. --- src/Mobs/Wither.cpp | 29 +++++++++-------------------- src/Mobs/Wither.h | 7 +------ 2 files changed, 10 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp index 5b6e895e1..fe4dbb28b 100644 --- a/src/Mobs/Wither.cpp +++ b/src/Mobs/Wither.cpp @@ -10,9 +10,10 @@ cWither::cWither(void) : super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0), - m_WitherInvulnerableTicks(220) + m_IsSpawnInvulnerable(true) { SetMaxHealth(300); + SetInvulnerableTicks(220); } @@ -47,11 +48,6 @@ bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI) return false; } - if (m_WitherInvulnerableTicks > 0) - { - return false; - } - if (IsArmored() && (a_TDI.DamageType == dtRangedAttack)) { return false; @@ -68,21 +64,14 @@ void cWither::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - if (m_WitherInvulnerableTicks > 0) + if (GetInvulnerableTicks() <= 0 && m_IsSpawnInvulnerable) { - unsigned int NewTicks = m_WitherInvulnerableTicks - 1; - - if (NewTicks == 0) - { - m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this); - } - - m_WitherInvulnerableTicks = NewTicks; - - if ((NewTicks % 10) == 0) - { - Heal(10); - } + m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this); + m_IsSpawnInvulnerable = false; + } + else if (((GetInvulnerableTicks() % 10) == 0) && (GetInvulnerableTicks() > 10)) + { + Heal(10); } m_World->BroadcastEntityMetadata(*this); diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index 08b460009..81c9df1b1 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -17,10 +17,6 @@ public: CLASS_PROTODEF(cWither); - unsigned int GetWitherInvulnerableTicks(void) const { return m_WitherInvulnerableTicks; } - - void SetWitherInvulnerableTicks(unsigned int a_Ticks) { m_WitherInvulnerableTicks = a_Ticks; } - /** Returns whether the wither is invulnerable to arrows. */ bool IsArmored(void) const; @@ -32,8 +28,7 @@ public: private: - /** The number of ticks of invulnerability left after being initially created. Zero once invulnerability has expired. */ - unsigned int m_WitherInvulnerableTicks; + bool m_IsSpawnInvulnerable; } ; -- cgit v1.2.3 From d50f8f6f11f69e7e1e56be92fb2d72a5014a3e34 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 26 Apr 2014 17:47:25 +0200 Subject: Changed the old invulnerable methods from the wither to the new. --- src/Mobs/Wither.h | 3 +++ src/Protocol/Protocol125.cpp | 9 ++++++++- src/Protocol/Protocol17x.cpp | 9 ++++++++- src/WorldStorage/NBTChunkSerializer.cpp | 9 ++++++++- src/WorldStorage/WSSAnvil.cpp | 2 +- 5 files changed, 28 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index 81c9df1b1..fbea331d3 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -19,6 +19,9 @@ public: /** Returns whether the wither is invulnerable to arrows. */ bool IsArmored(void) const; + + /** Use the wither the invulnerable from the spawn? */ + bool IsSpawnInvulnerable(void) const { return m_IsSpawnInvulnerable; } // cEntity overrides virtual bool Initialize(cWorld * a_World) override; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index a23afb29a..3951eb3e4 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -2013,7 +2013,14 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) case cMonster::mtWither: { WriteByte(0x54); // Int at index 20 - WriteInt((Int32)((const cWither &)a_Mob).GetWitherInvulnerableTicks()); + if (((const cWither &)a_Mob).IsSpawnInvulnerable()) + { + WriteInt((Int32)((const cWither &)a_Mob).GetInvulnerableTicks()); + } + else + { + WriteInt((Int32)0); + } WriteByte(0x66); // Float at index 6 WriteFloat((float)(a_Mob.GetHealth())); break; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 80b161e3e..311e770f9 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -2820,7 +2820,14 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob) case cMonster::mtWither: { WriteByte(0x54); // Int at index 20 - WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks()); + if (((const cWither &)a_Mob).IsSpawnInvulnerable()) + { + WriteInt(((const cWither &)a_Mob).GetInvulnerableTicks()); + } + else + { + WriteInt(0); + } WriteByte(0x66); // Float at index 6 WriteFloat((float)(a_Mob.GetHealth())); break; diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 46c6b8e92..0c4a1a430 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -516,7 +516,14 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster) } case cMonster::mtWither: { - m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetWitherInvulnerableTicks()); + if (((const cWither *)a_Monster)->IsSpawnInvulnerable()) + { + m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetInvulnerableTicks()); + } + else + { + m_Writer.AddInt("Invul", 0); + } break; } case cMonster::mtWolf: diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 4532a925a..c21809270 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -2272,7 +2272,7 @@ void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a int CurrLine = a_NBT.FindChildByName(a_TagIdx, "Invul"); if (CurrLine > 0) { - Monster->SetWitherInvulnerableTicks(a_NBT.GetInt(CurrLine)); + Monster->SetInvulnerableTicks(a_NBT.GetInt(CurrLine)); } a_Entities.push_back(Monster.release()); -- cgit v1.2.3 From e40f9d6e5b93e840e3d67e79f5ba49da1fbb75f0 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 26 Apr 2014 10:50:23 -0700 Subject: Implemented Chunk Sparsing with segments --- src/BlockArea.cpp | 166 +++++++---------- src/BlockArea.h | 5 +- src/Chunk.cpp | 186 ++++--------------- src/Chunk.h | 32 ++-- src/ChunkBuffer.cpp | 146 +++++++++++++++ src/ChunkBuffer.h | 310 ++++++++++++++++++++++++++++++++ src/ChunkDef.h | 100 +---------- src/ChunkMap.cpp | 16 +- src/ChunkSender.h | 1 + src/Entities/FallingBlock.cpp | 5 +- src/LightingThread.cpp | 11 +- src/MobProximityCounter.cpp | 3 +- src/Simulator/FireSimulator.cpp | 10 +- src/WorldStorage/NBTChunkSerializer.cpp | 3 +- src/WorldStorage/NBTChunkSerializer.h | 4 +- src/WorldStorage/WSSCompact.cpp | 10 +- src/WorldStorage/WSSCompact.h | 3 +- 17 files changed, 610 insertions(+), 401 deletions(-) create mode 100644 src/ChunkBuffer.cpp create mode 100644 src/ChunkBuffer.h (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 40cca8882..b4b519bc7 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -9,7 +9,7 @@ #include "OSSupport/GZipFile.h" #include "Blocks/BlockHandler.h" #include "Cuboid.h" - +#include "ChunkBuffer.h" @@ -1909,116 +1909,88 @@ bool cBlockArea::cChunkReader::Coords(int a_ChunkX, int a_ChunkZ) -void cBlockArea::cChunkReader::BlockTypes(const BLOCKTYPE * a_BlockTypes) +void cBlockArea::cChunkReader::ChunkBuffer(const cChunkBuffer & a_BlockBuffer) { - if (m_Area.m_BlockTypes == NULL) - { - // Don't want BlockTypes - return; - } - - int SizeY = m_Area.m_Size.y; - int MinY = m_Origin.y; - - // SizeX, SizeZ are the dmensions of the block data to copy from the current chunk (size of the geometric union) - // OffX, OffZ are the offsets of the current chunk data from the area origin - // BaseX, BaseZ are the offsets of the area data within the current chunk from the chunk borders - int SizeX = cChunkDef::Width; - int SizeZ = cChunkDef::Width; - int OffX, OffZ; - int BaseX, BaseZ; - OffX = m_CurrentChunkX * cChunkDef::Width - m_Origin.x; - if (OffX < 0) - { - BaseX = -OffX; - SizeX += OffX; // SizeX is decreased, OffX is negative - OffX = 0; - } - else - { - BaseX = 0; - } - OffZ = m_CurrentChunkZ * cChunkDef::Width - m_Origin.z; - if (OffZ < 0) - { - BaseZ = -OffZ; - SizeZ += OffZ; // SizeZ is decreased, OffZ is negative - OffZ = 0; - } - else - { - BaseZ = 0; - } - // If the chunk extends beyond the area in the X or Z axis, cut off the Size: - if ((m_CurrentChunkX + 1) * cChunkDef::Width > m_Origin.x + m_Area.m_Size.x) - { - SizeX -= (m_CurrentChunkX + 1) * cChunkDef::Width - (m_Origin.x + m_Area.m_Size.x); - } - if ((m_CurrentChunkZ + 1) * cChunkDef::Width > m_Origin.z + m_Area.m_Size.z) - { - SizeZ -= (m_CurrentChunkZ + 1) * cChunkDef::Width - (m_Origin.z + m_Area.m_Size.z); - } - - for (int y = 0; y < SizeY; y++) - { - int ChunkY = MinY + y; - int AreaY = y; - for (int z = 0; z < SizeZ; z++) + { // BlockTypes + if (!(m_Area.m_BlockTypes == NULL)) { - int ChunkZ = BaseZ + z; - int AreaZ = OffZ + z; - for (int x = 0; x < SizeX; x++) + int SizeY = m_Area.m_Size.y; + int MinY = m_Origin.y; + + // SizeX, SizeZ are the dmensions of the block data to copy from the current chunk (size of the geometric union) + // OffX, OffZ are the offsets of the current chunk data from the area origin + // BaseX, BaseZ are the offsets of the area data within the current chunk from the chunk borders + int SizeX = cChunkDef::Width; + int SizeZ = cChunkDef::Width; + int OffX, OffZ; + int BaseX, BaseZ; + OffX = m_CurrentChunkX * cChunkDef::Width - m_Origin.x; + if (OffX < 0) { - int ChunkX = BaseX + x; - int AreaX = OffX + x; - m_Area.m_BlockTypes[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = cChunkDef::GetBlock(a_BlockTypes, ChunkX, ChunkY, ChunkZ); - } // for x - } // for z - } // for y -} - - - + BaseX = -OffX; + SizeX += OffX; // SizeX is decreased, OffX is negative + OffX = 0; + } + else + { + BaseX = 0; + } + OffZ = m_CurrentChunkZ * cChunkDef::Width - m_Origin.z; + if (OffZ < 0) + { + BaseZ = -OffZ; + SizeZ += OffZ; // SizeZ is decreased, OffZ is negative + OffZ = 0; + } + else + { + BaseZ = 0; + } + // If the chunk extends beyond the area in the X or Z axis, cut off the Size: + if ((m_CurrentChunkX + 1) * cChunkDef::Width > m_Origin.x + m_Area.m_Size.x) + { + SizeX -= (m_CurrentChunkX + 1) * cChunkDef::Width - (m_Origin.x + m_Area.m_Size.x); + } + if ((m_CurrentChunkZ + 1) * cChunkDef::Width > m_Origin.z + m_Area.m_Size.z) + { + SizeZ -= (m_CurrentChunkZ + 1) * cChunkDef::Width - (m_Origin.z + m_Area.m_Size.z); + } + for (int y = 0; y < SizeY; y++) + { + int ChunkY = MinY + y; + int AreaY = y; + for (int z = 0; z < SizeZ; z++) + { + int ChunkZ = BaseZ + z; + int AreaZ = OffZ + z; + for (int x = 0; x < SizeX; x++) + { + int ChunkX = BaseX + x; + int AreaX = OffX + x; + m_Area.m_BlockTypes[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = a_BlockBuffer.GetBlock(ChunkX, ChunkY, ChunkZ); + } // for x + } // for z + } // for y + } + } -void cBlockArea::cChunkReader::BlockMeta(const NIBBLETYPE * a_BlockMetas) -{ - if (m_Area.m_BlockMetas == NULL) + if (m_Area.m_BlockMetas) { - // Don't want metas - return; + a_BlockBuffer.CopyMeta(m_Area.m_BlockMetas); } - CopyNibbles(m_Area.m_BlockMetas, a_BlockMetas); -} - - - - -void cBlockArea::cChunkReader::BlockLight(const NIBBLETYPE * a_BlockLight) -{ - if (m_Area.m_BlockLight == NULL) + if (m_Area.m_BlockLight) { - // Don't want light - return; + a_BlockBuffer.CopyLight(m_Area.m_BlockLight); } - CopyNibbles(m_Area.m_BlockLight, a_BlockLight); -} - - - - -void cBlockArea::cChunkReader::BlockSkyLight(const NIBBLETYPE * a_BlockSkyLight) -{ - if (m_Area.m_BlockSkyLight == NULL) + if (m_Area.m_BlockSkyLight) { - // Don't want skylight - return; + a_BlockBuffer.CopySkyLight(m_Area.m_BlockSkyLight); } - CopyNibbles(m_Area.m_BlockSkyLight, a_BlockSkyLight); -} +} diff --git a/src/BlockArea.h b/src/BlockArea.h index c48175b8c..d17a68fbb 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -317,10 +317,7 @@ protected: // cChunkDataCallback overrides: virtual bool Coords (int a_ChunkX, int a_ChunkZ) override; - virtual void BlockTypes (const BLOCKTYPE * a_BlockTypes) override; - virtual void BlockMeta (const NIBBLETYPE * a_BlockMetas) override; - virtual void BlockLight (const NIBBLETYPE * a_BlockLight) override; - virtual void BlockSkyLight(const NIBBLETYPE * a_BlockSkyLight) override; + virtual void ChunkBuffer (const cChunkBuffer & a_BlockTypes) override; } ; typedef NIBBLETYPE * NIBBLEARRAY; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index ee1531b5c..171f329fb 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -241,23 +241,9 @@ void cChunk::GetAllData(cChunkDataCallback & a_Callback) a_Callback.HeightMap (&m_HeightMap); a_Callback.BiomeData (&m_BiomeMap); - std::vector Blocks = m_BlockTypes; - Blocks.resize(NumBlocks); - a_Callback.BlockTypes (&Blocks[0]); - - std::vector Metas = m_BlockMeta; - Metas.resize(NumBlocks / 2); - a_Callback.BlockMeta (&Metas[0]); - a_Callback.LightIsValid (m_IsLightValid); - std::vector BlockLights = m_BlockLight; - BlockLights.resize(NumBlocks / 2); - a_Callback.BlockLight (&BlockLights[0]); - - std::vector BlockSkyLights = m_BlockSkyLight; - BlockSkyLights.resize(NumBlocks / 2, 0xff); - a_Callback.BlockSkyLight(&BlockSkyLights[0]); + a_Callback.ChunkBuffer (m_ChunkBuffer); for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) { @@ -296,48 +282,10 @@ void cChunk::SetAllData( CalculateHeightmap(a_BlockTypes); } - int IdxWhereNonEmptyStarts = 0; - { // Blocktype compression - unsigned char Highest = 0; - int X = 0, Z = 0; - m_BlockTypes.clear(); - - for (int x = 0; x < Width; x++) - { - for (int z = 0; z < Width; z++) - { - unsigned char Height = m_HeightMap[x + z * Width]; - if (Height > Highest) - { - Highest = Height; - X = x; Z = z; - } - } - } - - IdxWhereNonEmptyStarts = MakeIndexNoCheck(X, Highest + 1, Z); - - m_BlockTypes.insert(m_BlockTypes.end(), &a_BlockTypes[0], &a_BlockTypes[IdxWhereNonEmptyStarts]); - } - - { // Blockmeta compression - m_BlockMeta.clear(); - m_BlockMeta.insert(m_BlockMeta.end(), &a_BlockMeta[0], &a_BlockMeta[IdxWhereNonEmptyStarts / 2]); - } - - if (a_BlockLight != NULL) - { - // Compress blocklight - m_BlockLight.clear(); - m_BlockLight.insert(m_BlockLight.end(), &a_BlockLight[0], &a_BlockLight[IdxWhereNonEmptyStarts / 2]); - } - - if (a_BlockSkyLight != NULL) - { - // Compress skylight - m_BlockSkyLight.clear(); - m_BlockSkyLight.insert(m_BlockSkyLight.end(), &a_BlockSkyLight[0], &a_BlockSkyLight[IdxWhereNonEmptyStarts / 2]); - } + m_ChunkBuffer.SetBlocks (a_BlockTypes); + m_ChunkBuffer.SetMeta (a_BlockMeta); + m_ChunkBuffer.SetLight (a_BlockLight); + m_ChunkBuffer.SetSkyLight (a_BlockSkyLight); m_IsLightValid = (a_BlockLight != NULL) && (a_BlockSkyLight != NULL); @@ -378,39 +326,9 @@ void cChunk::SetLight( // TODO: We might get cases of wrong lighting when a chunk changes in the middle of a lighting calculation. // Postponing until we see how bad it is :) - { // Compress blocklight - bool FoundNonEmpty = false; - int IdxWhereNonEmptyStarts = 0; - m_BlockLight.clear(); - - for (int Idx = (NumBlocks / 2) - 1; Idx >= 0; Idx--) - { - if (a_BlockLight[Idx] != 0) - { - FoundNonEmpty = true; - IdxWhereNonEmptyStarts = Idx; - break; - } - } - m_BlockLight.insert(m_BlockLight.end(), &a_BlockLight[0], &a_BlockLight[IdxWhereNonEmptyStarts + 1]); - } - - { // Compress skylight - bool FoundNonEmpty = false; - int IdxWhereNonEmptyStarts = 0; - m_BlockSkyLight.clear(); + m_ChunkBuffer.SetLight (a_BlockLight); - for (int Idx = (NumBlocks / 2) - 1; Idx >= 0; Idx--) - { - if (a_SkyLight[Idx] != 0xff) - { - FoundNonEmpty = true; - IdxWhereNonEmptyStarts = Idx; - break; - } - } - m_BlockSkyLight.insert(m_BlockSkyLight.end(), &a_SkyLight[0], &a_SkyLight[IdxWhereNonEmptyStarts + 1]); - } + m_ChunkBuffer.SetSkyLight (a_SkyLight); m_IsLightValid = true; } @@ -421,10 +339,7 @@ void cChunk::SetLight( void cChunk::GetBlockTypes(BLOCKTYPE * a_BlockTypes) { - std::vector Blocks = m_BlockTypes; - Blocks.resize(NumBlocks); - - memcpy(a_BlockTypes, &Blocks[0], NumBlocks); + m_ChunkBuffer.CopyBlocks(a_BlockTypes); } @@ -710,8 +625,7 @@ void cChunk::Tick(float a_Dt) void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ) { - unsigned Index = MakeIndex(a_RelX, a_RelY, a_RelZ); - cBlockHandler * Handler = BlockHandler(GetBlock(Index)); + cBlockHandler * Handler = BlockHandler(GetBlock(a_RelX, a_RelY, a_RelZ)); ASSERT(Handler != NULL); // Happenned on server restart, FS #243 cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap()); cBlockInServerPluginInterface PluginInterface(*this->GetWorld()); @@ -836,19 +750,18 @@ void cChunk::CheckBlocks() { return; } - std::vector ToTickBlocks; + std::vector ToTickBlocks; std::swap(m_ToTickBlocks, ToTickBlocks); cChunkInterface ChunkInterface(m_World->GetChunkMap()); cBlockInServerPluginInterface PluginInterface(*m_World); - for (std::vector::const_iterator itr = ToTickBlocks.begin(), end = ToTickBlocks.end(); itr != end; ++itr) + for (std::vector::const_iterator itr = ToTickBlocks.begin(), end = ToTickBlocks.end(); itr != end; ++itr) { - unsigned int index = (*itr); - Vector3i BlockPos = IndexToCoordinate(index); + Vector3i Pos = (*itr); - cBlockHandler * Handler = BlockHandler(GetBlock(index)); - Handler->Check(ChunkInterface, PluginInterface, BlockPos.x, BlockPos.y, BlockPos.z, *this); + cBlockHandler * Handler = BlockHandler(GetBlock(Pos)); + Handler->Check(ChunkInterface, PluginInterface, Pos.x, Pos.y, Pos.z, *this); } // for itr - ToTickBlocks[] } @@ -891,8 +804,7 @@ void cChunk::TickBlocks(void) continue; // It's all air up here } - unsigned int Index = MakeIndexNoCheck(m_BlockTickX, m_BlockTickY, m_BlockTickZ); - cBlockHandler * Handler = BlockHandler(GetBlock(Index)); + cBlockHandler * Handler = BlockHandler(GetBlock(m_BlockTickX, m_BlockTickY, m_BlockTickZ)); ASSERT(Handler != NULL); // Happenned on server restart, FS #243 Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, m_BlockTickX, m_BlockTickY, m_BlockTickZ); } // for i - tickblocks @@ -1284,9 +1196,8 @@ bool cChunk::UnboundedRelGetBlockLights(int a_RelX, int a_RelY, int a_RelZ, NIBB // The chunk is not available, bail out return false; } - int idx = Chunk->MakeIndex(a_RelX, a_RelY, a_RelZ); - a_BlockLight = Chunk->GetBlockLight(idx); - a_SkyLight = Chunk->GetSkyLight(idx); + a_BlockLight = Chunk->GetBlockLight(a_RelX, a_RelY, a_RelZ); + a_SkyLight = Chunk->GetSkyLight(a_RelX, a_RelY, a_RelZ); return true; } @@ -1490,11 +1401,9 @@ void cChunk::CalculateHeightmap(const BLOCKTYPE * a_BlockTypes) void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { FastSetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta); - - const int index = MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ); // Tick this block and its neighbors: - m_ToTickBlocks.push_back(index); + m_ToTickBlocks.push_back(Vector3i(a_RelX, a_RelY, a_RelZ)); QueueTickBlockNeighbors(a_RelX, a_RelY, a_RelZ); // If there was a block entity, remove it: @@ -1557,7 +1466,7 @@ void cChunk::QueueTickBlock(int a_RelX, int a_RelY, int a_RelZ) return; } - m_ToTickBlocks.push_back(MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ)); + m_ToTickBlocks.push_back(Vector3i(a_RelX, a_RelY, a_RelZ)); } @@ -1595,9 +1504,8 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT ASSERT(IsValid()); - const int index = MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ); - const BLOCKTYPE OldBlockType = GetBlock(index); - const BLOCKTYPE OldBlockMeta = GetNibble(m_BlockMeta, index); + const BLOCKTYPE OldBlockType = GetBlock(a_RelX, a_RelY, a_RelZ); + const BLOCKTYPE OldBlockMeta = m_ChunkBuffer.GetMeta(a_RelX, a_RelY, a_RelZ); if ((OldBlockType == a_BlockType) && (OldBlockMeta == a_BlockMeta)) { return; @@ -1605,11 +1513,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT MarkDirty(); - if (m_BlockTypes.empty() || ((size_t)index > m_BlockTypes.size() - 1) /* Vector starts from zero, .size() starts from 1 */) - { - m_BlockTypes.resize(index + 1); - } - m_BlockTypes[index] = a_BlockType; + m_ChunkBuffer.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType); // The client doesn't need to distinguish between stationary and nonstationary fluids: if ( @@ -1625,7 +1529,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta)); } - SetNibble(m_BlockMeta, index, a_BlockMeta); + m_ChunkBuffer.SetMeta(a_RelX, a_RelY, a_RelZ, a_BlockMeta); // ONLY recalculate lighting if it's necessary! if ( @@ -1648,7 +1552,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT { for (int y = a_RelY - 1; y > 0; --y) { - if (GetBlock(MakeIndexNoCheck(a_RelX, y, a_RelZ)) != E_BLOCK_AIR) + if (GetBlock(a_RelX, y, a_RelZ) != E_BLOCK_AIR) { m_HeightMap[a_RelX + a_RelZ * Width] = (unsigned char)y; break; @@ -1665,18 +1569,16 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT void cChunk::SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client) { // The coords must be valid, because the upper level already does chunk lookup. No need to check them again. - // There's an debug-time assert in MakeIndexNoCheck anyway - unsigned int index = MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ); if (a_Client == NULL) { // Queue the block for all clients in the chunk (will be sent in Tick()) - m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(index), GetMeta(index))); + m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), GetMeta(a_RelX, a_RelY, a_RelZ))); return; } Vector3i wp = PositionToWorldPosition(a_RelX, a_RelY, a_RelZ); - a_Client->SendBlockChange(wp.x, wp.y, wp.z, GetBlock(index), GetMeta(index)); + a_Client->SendBlockChange(wp.x, wp.y, wp.z, GetBlock(a_RelX, a_RelY, a_RelZ), GetMeta(a_RelX, a_RelY, a_RelZ)); // FS #268 - if a BlockEntity digging is cancelled by a plugin, the entire block entity must be re-sent to the client: for (cBlockEntityList::iterator itr = m_BlockEntities.begin(), end = m_BlockEntities.end(); itr != end; ++itr) @@ -2535,27 +2437,7 @@ BLOCKTYPE cChunk::GetBlock(int a_RelX, int a_RelY, int a_RelZ) const return 0; // Clip } - return GetBlock(MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ)); -} - - - - - -BLOCKTYPE cChunk::GetBlock(int a_BlockIdx) const -{ - if ((a_BlockIdx < 0) || (a_BlockIdx >= NumBlocks)) - { - ASSERT(!"GetBlock(idx) out of bounds!"); - return 0; - } - - if (m_BlockTypes.empty() || ((size_t)a_BlockIdx > m_BlockTypes.size() - 1) /* Vector starts from zero, .size() starts from 1 */) - { - return E_BLOCK_AIR; - } - - return m_BlockTypes[a_BlockIdx]; + return m_ChunkBuffer.GetBlock(a_RelX, a_RelY, a_RelZ); } @@ -2564,9 +2446,8 @@ BLOCKTYPE cChunk::GetBlock(int a_BlockIdx) const void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) { - int Idx = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ); - a_BlockType = GetBlock(Idx); - a_BlockMeta = cChunkDef::GetNibble(m_BlockMeta, Idx); + a_BlockType = GetBlock(a_RelX, a_RelY, a_RelZ); + a_BlockMeta = m_ChunkBuffer.GetMeta(a_RelX, a_RelY, a_RelZ); } @@ -2575,11 +2456,10 @@ void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_ void cChunk::GetBlockInfo(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight) { - int Idx = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ); - a_BlockType = GetBlock(Idx); - a_Meta = cChunkDef::GetNibble(m_BlockMeta, Idx); - a_SkyLight = cChunkDef::GetNibble(m_BlockSkyLight, Idx); - a_BlockLight = cChunkDef::GetNibble(m_BlockLight, Idx); + a_BlockType = GetBlock(a_RelX, a_RelY, a_RelZ); + a_Meta = m_ChunkBuffer.GetMeta(a_RelX, a_RelY, a_RelZ); + a_SkyLight = m_ChunkBuffer.GetSkyLight(a_RelX, a_RelY, a_RelZ); + a_BlockLight = m_ChunkBuffer.GetBlockLight(a_RelX, a_RelY, a_RelZ); } diff --git a/src/Chunk.h b/src/Chunk.h index 9100eec58..ea3e035ad 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -3,6 +3,7 @@ #include "Entities/Entity.h" #include "ChunkDef.h" +#include "ChunkBuffer.h" #include "Simulator/FireSimulator.h" #include "Simulator/SandSimulator.h" @@ -66,6 +67,7 @@ public: cChunkMap * a_ChunkMap, cWorld * a_World, // Parent objects cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP // Neighbor chunks ); + cChunk(cChunk& other); ~cChunk(); bool IsValid(void) const {return m_IsValid; } // Returns true if the chunk block data is valid (loaded / generated) @@ -154,7 +156,7 @@ public: void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta ); // Doesn't force block updates on neighbors, use for simple changes such as grass growing etc. BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const; - BLOCKTYPE GetBlock(int a_BlockIdx) const; + BLOCKTYPE GetBlock(Vector3i a_cords) const { return GetBlock(a_cords.x,a_cords.y,a_cords.z);} void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta); void GetBlockInfo (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight); @@ -320,15 +322,17 @@ public: m_BlockTickZ = a_RelZ; } - inline NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const {return cChunkDef::GetNibble(m_BlockMeta, a_RelX, a_RelY, a_RelZ); } - inline NIBBLETYPE GetMeta(int a_BlockIdx) const {return cChunkDef::GetNibble(m_BlockMeta, a_BlockIdx); } - inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta) { cChunkDef::SetNibble(m_BlockMeta, a_RelX, a_RelY, a_RelZ, a_Meta); } - inline void SetMeta(int a_BlockIdx, NIBBLETYPE a_Meta) { cChunkDef::SetNibble(m_BlockMeta, a_BlockIdx, a_Meta); } + inline NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const + { + return m_ChunkBuffer.GetMeta(a_RelX, a_RelY, a_RelZ); + } + inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta) + { + m_ChunkBuffer.SetMeta(a_RelX, a_RelY, a_RelZ, a_Meta); + } - inline NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const {return cChunkDef::GetNibble(m_BlockLight, a_RelX, a_RelY, a_RelZ); } - inline NIBBLETYPE GetSkyLight (int a_RelX, int a_RelY, int a_RelZ) const {return cChunkDef::GetNibble(m_BlockSkyLight, a_RelX, a_RelY, a_RelZ, true); } - inline NIBBLETYPE GetBlockLight(int a_Idx) const {return cChunkDef::GetNibble(m_BlockLight, a_Idx); } - inline NIBBLETYPE GetSkyLight (int a_Idx) const {return cChunkDef::GetNibble(m_BlockSkyLight, a_Idx, true); } + inline NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const {return m_ChunkBuffer.GetBlockLight(a_RelX, a_RelY, a_RelZ); } + inline NIBBLETYPE GetSkyLight (int a_RelX, int a_RelY, int a_RelZ) const {return m_ChunkBuffer.GetSkyLight(a_RelX, a_RelY, a_RelZ); } /** Same as GetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case); returns true on success */ bool UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const; @@ -403,8 +407,8 @@ private: bool m_IsSaving; // True if the chunk is being saved bool m_HasLoadFailed; // True if chunk failed to load and hasn't been generated yet since then - std::vector m_ToTickBlocks; - sSetBlockVector m_PendingSendBlocks; ///< Blocks that have changed and need to be sent to all clients + std::vector m_ToTickBlocks; + sSetBlockVector m_PendingSendBlocks; ///< Blocks that have changed and need to be sent to all clients sSetBlockQueueVector m_SetBlockQueue; ///< Block changes that are queued to a specific tick @@ -420,11 +424,7 @@ private: cWorld * m_World; cChunkMap * m_ChunkMap; - // TODO: Make these pointers and don't allocate what isn't needed - std::vector m_BlockTypes; - std::vector m_BlockMeta; - std::vector m_BlockLight; - std::vector m_BlockSkyLight; + cChunkBuffer m_ChunkBuffer; cChunkDef::HeightMap m_HeightMap; cChunkDef::BiomeMap m_BiomeMap; diff --git a/src/ChunkBuffer.cpp b/src/ChunkBuffer.cpp new file mode 100644 index 000000000..8e87d3049 --- /dev/null +++ b/src/ChunkBuffer.cpp @@ -0,0 +1,146 @@ + +#include "Globals.h" +#include "ChunkBuffer.h" + +cChunkBuffer cChunkBuffer::Copy() const +{ + cChunkBuffer copy; + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + if(m_Sections[i]) + { + copy.m_Sections[i] = Allocate(); + *copy.m_Sections[i] = *m_Sections[i]; + } + } + return copy; +} + + + + + +void cChunkBuffer::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length) const +{ + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; + if (a_Idx > 0) a_Idx = a_Idx > length ? a_Idx - length : 0; + if (a_Idx == 0) + { + size_t tocopy = length > segment_length ? segment_length : length; + length -= tocopy; + memcpy(&a_dest[i * segment_length], &m_Sections[i]->m_BlockTypes, sizeof(BLOCKTYPE) * length); + } + } +} + + + + + +void cChunkBuffer::CopyMeta(NIBBLETYPE * a_dest) const +{ + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + memcpy(&a_dest[i * segment_length], &m_Sections[i]->m_BlockMeta, sizeof(NIBBLETYPE) * segment_length); + } +} + + + + + +void cChunkBuffer::CopyLight(NIBBLETYPE * a_dest) const +{ + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + memcpy(&a_dest[i * segment_length], &m_Sections[i]->m_BlockLight, sizeof(NIBBLETYPE) * segment_length); + } +} + + + + + +void cChunkBuffer::CopySkyLight(NIBBLETYPE * a_dest) const +{ + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + memcpy(&a_dest[i * segment_length], &m_Sections[i]->m_BlockSkyLight, sizeof(NIBBLETYPE) * segment_length); + } +} + + + + + +void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src) +{ + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + if (m_Sections[i]) + { + memcpy(&m_Sections[i]->m_BlockTypes, &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length); + } + } +} + + + + +void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src) +{ + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + if (m_Sections[i]) + { + memcpy(&m_Sections[i]->m_BlockMeta, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); + } + } +} + + + + +void cChunkBuffer::SetLight(const NIBBLETYPE * a_src) +{ + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + if (m_Sections[i]) + { + memcpy(&m_Sections[i]->m_BlockLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); + } + } +} + + + + +void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src) +{ + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + if (m_Sections[i]) + { + memcpy(&m_Sections[i]->m_BlockSkyLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); + } + } +} + + + + + +cChunkBuffer::sChunkSection * cChunkBuffer::Allocate() const +{ + // TODO: use a allocation pool + return new cChunkBuffer::sChunkSection; +} diff --git a/src/ChunkBuffer.h b/src/ChunkBuffer.h new file mode 100644 index 000000000..44e447c82 --- /dev/null +++ b/src/ChunkBuffer.h @@ -0,0 +1,310 @@ + +#pragma once + +#define CHUNK_SECTION_HEIGHT 16 +#define CHUNK_SECTION_NUM (256 / CHUNK_SECTION_HEIGHT) + +#if __cplusplus < 201103L +// auto_ptr style interface for memory management +#else +// unique_ptr style interface for memory management +#endif + +class cChunkBuffer +{ +public: + + cChunkBuffer() + #if __cplusplus < 201103L + // auto_ptr style interface for memory management + : IsOwner(true) + #endif + { + memset(m_Sections, 0, sizeof(m_Sections)); + } + ~cChunkBuffer() + { + #if __cplusplus < 201103L + // auto_ptr style interface for memory management + if(!IsOwner) return; + #endif + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + if(m_Sections[i]) delete m_Sections[i]; + } + } + + #if __cplusplus < 201103L + // auto_ptr style interface for memory management + cChunkBuffer(cChunkBuffer& other) : + IsOwner(true); + { + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + m_Sections[i] = other.m_Sections[i]; + } + other.IsOwner = false; + } + void operator=(cChunkBuffer& other) + { + if(IsOwner) + { + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + if(m_Sections[i]) delete m_Sections[i]; + } + } + IsOwner = true; + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + m_Sections[i] = other.m_Sections[i]; + } + other.IsOwner = false; + } + #else + // unique_ptr style interface for memory management + cChunkBuffer(cChunkBuffer&& other) + { + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + m_Sections[i] = other.m_Sections[i]; + } + } + + void operator=(cChunkBuffer&& other) + { + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + if(m_Sections[i]) delete m_Sections[i]; + m_Sections[i] = other.m_Sections[i]; + } + } + #endif + + BLOCKTYPE GetBlock(int a_X, int a_Y, int a_Z) const + { + ASSERT((a_X >= 0) && (a_X < cChunkDef::Width)); + ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height)); + ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width)); + int Section = a_Y / CHUNK_SECTION_HEIGHT; + if(m_Sections[Section]) + { + int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * CHUNK_SECTION_HEIGHT), a_Z); + return m_Sections[Section]->m_BlockTypes[Index]; + } + else + { + return 0; + } + } + + void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block) + { + if ( + (a_RelX >= cChunkDef::Width) || (a_RelX < 0) || + (a_RelY >= cChunkDef::Height) || (a_RelY < 0) || + (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0) + ) + { + ASSERT(!"cChunkBuffer::SetMeta(): index out of range!"); + return; + } + + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if(!m_Sections[Section]) + { + m_Sections[Section] = Allocate(); + if(!m_Sections[Section]) + { + ASSERT("Failed to allocate a new section in Chunkbuffer"); + return; + } + } + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + m_Sections[Section]->m_BlockTypes[Index] = a_Block; + } + + NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const + { + if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) + { + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if(m_Sections[Section]) + { + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + return (m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4)) & 0x0f; + } + else + { + return 0; + } + } + ASSERT(!"cChunkBuffer::GetMeta(): coords out of chunk range!"); + return 0; + } + + void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble) + { + if ( + (a_RelX >= cChunkDef::Width) || (a_RelX < 0) || + (a_RelY >= cChunkDef::Height) || (a_RelY < 0) || + (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0) + ) + { + ASSERT(!"cChunkBuffer::SetMeta(): index out of range!"); + return; + } + + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if(!m_Sections[Section]) + { + m_Sections[Section] = Allocate(); + if(!m_Sections[Section]) + { + ASSERT("Failed to allocate a new section in Chunkbuffer"); + return; + } + } + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + m_Sections[Section]->m_BlockMeta[Index / 2] = static_cast( + (m_Sections[Section]->m_BlockMeta[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble + ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set + ); + } + + NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const + { + if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) + { + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if(m_Sections[Section]) + { + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; + } + else + { + return 0; + } + } + ASSERT(!"cChunkBuffer::GetMeta(): coords out of chunk range!"); + return 0; + } + + NIBBLETYPE GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const + { + if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) + { + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if(m_Sections[Section]) + { + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; + } + else + { + return 0xFF; + } + } + ASSERT(!"cChunkBuffer::GetMeta(): coords out of chunk range!"); + return 0; + } + + cChunkBuffer Copy() const; + void CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx = 0, size_t length = cChunkDef::NumBlocks) const; + void CopyMeta (NIBBLETYPE * a_dest) const; + void CopyLight (NIBBLETYPE * a_dest) const; + void CopySkyLight (NIBBLETYPE * a_dest) const; + + void SetBlocks (const BLOCKTYPE * a_src); + void SetMeta (const NIBBLETYPE * a_src); + void SetLight (const NIBBLETYPE * a_src); + void SetSkyLight (const NIBBLETYPE * a_src); + +private: + + #if __cplusplus < 201103L + // auto_ptr style interface for memory management + bool IsOwner; + #endif + + struct sChunkSection { + BLOCKTYPE m_BlockTypes [CHUNK_SECTION_HEIGHT * 16 * 16] ; + NIBBLETYPE m_BlockMeta [CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; + NIBBLETYPE m_BlockLight [CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; + NIBBLETYPE m_BlockSkyLight[CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; + }; + + sChunkSection *m_Sections[CHUNK_SECTION_NUM]; + + sChunkSection * Allocate() const; +}; + + + + +/** A simple implementation of the cChunkDataCallback interface that collects all block data into a buffer +*/ +class cChunkBufferCollector : + public cChunkDataCallback +{ +public: + + cChunkBuffer m_BlockData; + +protected: + + virtual void ChunkBuffer(const cChunkBuffer & a_BlockData) override + { + m_BlockData = a_BlockData.Copy(); + } +}; + + +/** A simple implementation of the cChunkDataCallback interface that collects all block data into a single buffer +*/ +class cChunkDataCollector : +public cChunkDataCallback +{ +public: + + // Must be unsigned char instead of BLOCKTYPE or NIBBLETYPE, because it houses both. + unsigned char m_BlockData[cChunkDef::BlockDataSize]; + +protected: + + virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override + { + a_ChunkBuffer.CopyBlocks(m_BlockData); + a_ChunkBuffer.CopyMeta(m_BlockData + cChunkDef::NumBlocks); + a_ChunkBuffer.CopyLight(m_BlockData + 3 * cChunkDef::NumBlocks / 2); + a_ChunkBuffer.CopySkyLight(m_BlockData + 2 * cChunkDef::NumBlocks); + } +}; + +/** A simple implementation of the cChunkDataCallback interface that collects all block data into a separate buffers +*/ +class cChunkDataSeparateCollector : +public cChunkDataCallback +{ +public: + + cChunkDef::BlockTypes m_BlockTypes; + cChunkDef::BlockNibbles m_BlockMetas; + cChunkDef::BlockNibbles m_BlockLight; + cChunkDef::BlockNibbles m_BlockSkyLight; + +protected: + + virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override + { + a_ChunkBuffer.CopyBlocks(m_BlockTypes); + a_ChunkBuffer.CopyMeta(m_BlockMetas); + a_ChunkBuffer.CopyLight(m_BlockLight); + a_ChunkBuffer.CopySkyLight(m_BlockSkyLight); + } +} ; + + + + diff --git a/src/ChunkDef.h b/src/ChunkDef.h index bb9f14bbe..a5eccc9d6 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -366,6 +366,7 @@ public: +class cChunkBuffer; /** Interface class used for getting data out of a chunk using the GetAllData() function. @@ -390,20 +391,11 @@ public: /// Called once to provide biome data virtual void BiomeData (const cChunkDef::BiomeMap * a_BiomeMap) {UNUSED(a_BiomeMap); }; - /// Called once to export block types - virtual void BlockTypes (const BLOCKTYPE * a_Type) {UNUSED(a_Type); }; + /// Called once to let know if the chunk lighting is valid. Return value is ignored + virtual void LightIsValid(bool a_IsLightValid) {UNUSED(a_IsLightValid); }; - /// Called once to export block meta - virtual void BlockMeta (const NIBBLETYPE * a_Meta) {UNUSED(a_Meta); }; - - /// Called once to let know if the chunk lighting is valid. Return value is used to control if BlockLight() and BlockSkyLight() are called next (if true) - virtual bool LightIsValid(bool a_IsLightValid) {UNUSED(a_IsLightValid); return true; }; - - /// Called once to export block light - virtual void BlockLight (const NIBBLETYPE * a_BlockLight) {UNUSED(a_BlockLight); }; - - /// Called once to export sky light - virtual void BlockSkyLight(const NIBBLETYPE * a_SkyLight) {UNUSED(a_SkyLight); }; + /// Called once to export block info + virtual void ChunkBuffer (const cChunkBuffer & a_Buffer) {UNUSED(a_Buffer); }; /// Called for each entity in the chunk virtual void Entity(cEntity * a_Entity) {UNUSED(a_Entity); }; @@ -416,88 +408,6 @@ public: -/** A simple implementation of the cChunkDataCallback interface that collects all block data into a single buffer -*/ -class cChunkDataCollector : - public cChunkDataCallback -{ -public: - - // Must be unsigned char instead of BLOCKTYPE or NIBBLETYPE, because it houses both. - unsigned char m_BlockData[cChunkDef::BlockDataSize]; - -protected: - - virtual void BlockTypes(const BLOCKTYPE * a_BlockTypes) override - { - memcpy(m_BlockData, a_BlockTypes, sizeof(cChunkDef::BlockTypes)); - } - - - virtual void BlockMeta(const NIBBLETYPE * a_BlockMeta) override - { - memcpy(m_BlockData + cChunkDef::NumBlocks, a_BlockMeta, cChunkDef::NumBlocks / 2); - } - - - virtual void BlockLight(const NIBBLETYPE * a_BlockLight) override - { - memcpy(m_BlockData + 3 * cChunkDef::NumBlocks / 2, a_BlockLight, cChunkDef::NumBlocks / 2); - } - - - virtual void BlockSkyLight(const NIBBLETYPE * a_BlockSkyLight) override - { - memcpy(m_BlockData + 2 * cChunkDef::NumBlocks, a_BlockSkyLight, cChunkDef::NumBlocks / 2); - } -} ; - - - - - -/** A simple implementation of the cChunkDataCallback interface that collects all block data into a separate buffers -*/ -class cChunkDataSeparateCollector : - public cChunkDataCallback -{ -public: - - cChunkDef::BlockTypes m_BlockTypes; - cChunkDef::BlockNibbles m_BlockMetas; - cChunkDef::BlockNibbles m_BlockLight; - cChunkDef::BlockNibbles m_BlockSkyLight; - -protected: - - virtual void BlockTypes(const BLOCKTYPE * a_BlockTypes) override - { - memcpy(m_BlockTypes, a_BlockTypes, sizeof(m_BlockTypes)); - } - - - virtual void BlockMeta(const NIBBLETYPE * a_BlockMeta) override - { - memcpy(m_BlockMetas, a_BlockMeta, sizeof(m_BlockMetas)); - } - - - virtual void BlockLight(const NIBBLETYPE * a_BlockLight) override - { - memcpy(m_BlockLight, a_BlockLight, sizeof(m_BlockLight)); - } - - - virtual void BlockSkyLight(const NIBBLETYPE * a_BlockSkyLight) override - { - memcpy(m_BlockSkyLight, a_BlockSkyLight, sizeof(m_BlockSkyLight)); - } -} ; - - - - - /** Interface class used for comparing clients of two chunks. Used primarily for entity moving while both chunks are locked. */ diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index e695f0ab2..2b47f25f8 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -219,9 +219,8 @@ bool cChunkMap::LockedGetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTY return false; } - int Index = cChunkDef::MakeIndexNoCheck(a_BlockX, a_BlockY, a_BlockZ); - a_BlockType = Chunk->GetBlock(Index); - a_BlockMeta = Chunk->GetMeta(Index); + a_BlockType = Chunk->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + a_BlockMeta = Chunk->GetMeta(a_BlockX, a_BlockY, a_BlockZ); return true; } @@ -242,8 +241,7 @@ bool cChunkMap::LockedGetBlockType(int a_BlockX, int a_BlockY, int a_BlockZ, BLO return false; } - int Index = cChunkDef::MakeIndexNoCheck(a_BlockX, a_BlockY, a_BlockZ); - a_BlockType = Chunk->GetBlock(Index); + a_BlockType = Chunk->GetBlock(a_BlockX, a_BlockY, a_BlockZ); return true; } @@ -264,8 +262,7 @@ bool cChunkMap::LockedGetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIB return false; } - int Index = cChunkDef::MakeIndexNoCheck(a_BlockX, a_BlockY, a_BlockZ); - a_BlockMeta = Chunk->GetMeta(Index); + a_BlockMeta = Chunk->GetMeta(a_BlockX, a_BlockY, a_BlockZ); return true; } @@ -1486,9 +1483,8 @@ bool cChunkMap::GetBlocks(sSetBlockVector & a_Blocks, bool a_ContinueOnFailure) res = false; continue; } - int idx = cChunkDef::MakeIndexNoCheck(itr->x, itr->y, itr->z); - itr->BlockType = Chunk->GetBlock(idx); - itr->BlockMeta = Chunk->GetMeta(idx); + itr->BlockType = Chunk->GetBlock(itr->x, itr->y, itr->z); + itr->BlockMeta = Chunk->GetMeta(itr->x, itr->y, itr->z); } return res; } diff --git a/src/ChunkSender.h b/src/ChunkSender.h index a26f764a7..81b298a55 100644 --- a/src/ChunkSender.h +++ b/src/ChunkSender.h @@ -27,6 +27,7 @@ Note that it may be called by world's BroadcastToChunk() if the client is still #include "OSSupport/IsThread.h" #include "ChunkDef.h" +#include "ChunkBuffer.h" diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp index a66c7e4ae..e57c45eaf 100644 --- a/src/Entities/FallingBlock.cpp +++ b/src/Entities/FallingBlock.cpp @@ -55,9 +55,8 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk) return; } - int idx = a_Chunk.MakeIndexNoCheck(BlockX - a_Chunk.GetPosX() * cChunkDef::Width, BlockY, BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width); - BLOCKTYPE BlockBelow = a_Chunk.GetBlock(idx); - NIBBLETYPE BelowMeta = a_Chunk.GetMeta(idx); + BLOCKTYPE BlockBelow = a_Chunk.GetBlock(BlockX - a_Chunk.GetPosX() * cChunkDef::Width, BlockY, BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width); + NIBBLETYPE BelowMeta = a_Chunk.GetMeta(BlockX - a_Chunk.GetPosX() * cChunkDef::Width, BlockY, BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width); if (cSandSimulator::DoesBreakFallingThrough(BlockBelow, BelowMeta)) { // Fallen onto a block that breaks this into pickups (e. g. half-slab) diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index 302473d71..56d5dba22 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -18,20 +18,17 @@ class cReader : public cChunkDataCallback { - virtual void BlockTypes(const BLOCKTYPE * a_Type) override + virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override { - // ROW is a block of 16 Blocks, one whole row is copied at a time (hopefully the compiler will optimize that) - // C++ doesn't permit copying arrays, but arrays as a part of a struct is ok :) - typedef struct {BLOCKTYPE m_Row[16]; } ROW; - ROW * InputRows = (ROW *)a_Type; - ROW * OutputRows = (ROW *)m_BlockTypes; + BLOCKTYPE * OutputRows = m_BlockTypes; int InputIdx = 0; int OutputIdx = m_ReadingChunkX + m_ReadingChunkZ * cChunkDef::Width * 3; for (int y = 0; y < cChunkDef::Height; y++) { for (int z = 0; z < cChunkDef::Width; z++) { - OutputRows[OutputIdx] = InputRows[InputIdx++]; + a_ChunkBuffer.CopyBlocks(OutputRows + OutputIdx * 16, InputIdx * 16, 16); + InputIdx++; OutputIdx += 3; } // for z // Skip into the next y-level in the 3x3 chunk blob; each level has cChunkDef::Width * 9 rows diff --git a/src/MobProximityCounter.cpp b/src/MobProximityCounter.cpp index 6c44ea458..e7493dd0f 100644 --- a/src/MobProximityCounter.cpp +++ b/src/MobProximityCounter.cpp @@ -24,7 +24,8 @@ void cMobProximityCounter::CollectMob(cEntity& a_Monster, cChunk& a_Chunk, doubl if (a_Distance < it->second.m_Distance) { it->second.m_Distance = a_Distance; - it->second.m_Chunk = a_Chunk; + ASSERT(false); + //it->second.m_Chunk = a_Chunk; } } diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp index 470dfc791..4c1008897 100644 --- a/src/Simulator/FireSimulator.cpp +++ b/src/Simulator/FireSimulator.cpp @@ -95,8 +95,10 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun int NumMSecs = (int)a_Dt; for (cCoordWithIntList::iterator itr = Data.begin(); itr != Data.end();) { - int idx = cChunkDef::MakeIndexNoCheck(itr->x, itr->y, itr->z); - BLOCKTYPE BlockType = a_Chunk->GetBlock(idx); + int x = itr->x; + int y = itr->y; + int z = itr->z; + BLOCKTYPE BlockType = a_Chunk->GetBlock(x,y,z); if (!IsAllowedBlock(BlockType)) { @@ -125,7 +127,7 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun itr->x + a_ChunkX * cChunkDef::Width, itr->y, itr->z + a_ChunkZ * cChunkDef::Width ); */ - NIBBLETYPE BlockMeta = a_Chunk->GetMeta(idx); + NIBBLETYPE BlockMeta = a_Chunk->GetMeta(x, y, z); if (BlockMeta == 0x0f) { // The fire burnt out completely @@ -140,7 +142,7 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun if((itr->y > 0) && (!DoesBurnForever(a_Chunk->GetBlock(itr->x, itr->y - 1, itr->z)))) { - a_Chunk->SetMeta(idx, BlockMeta + 1); + a_Chunk->SetMeta(x, y, z, BlockMeta + 1); } itr->Data = GetBurnStepTime(a_Chunk, itr->x, itr->y, itr->z); // TODO: Add some randomness into this } // for itr - Data[] diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 415693ae2..10acfb537 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -692,10 +692,9 @@ void cNBTChunkSerializer::AddMinecartChestContents(cMinecartWithChest * a_Mineca -bool cNBTChunkSerializer::LightIsValid(bool a_IsLightValid) +void cNBTChunkSerializer::LightIsValid(bool a_IsLightValid) { m_IsLightValid = a_IsLightValid; - return a_IsLightValid; // We want lighting only if it's valid, otherwise don't bother } diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h index 51d104970..6da2bc6dd 100644 --- a/src/WorldStorage/NBTChunkSerializer.h +++ b/src/WorldStorage/NBTChunkSerializer.h @@ -9,7 +9,7 @@ #pragma once -#include "../ChunkDef.h" +#include "../ChunkBuffer.h" @@ -121,7 +121,7 @@ protected: void AddMinecartChestContents(cMinecartWithChest * a_Minecart); // cChunkDataSeparateCollector overrides: - virtual bool LightIsValid(bool a_IsLightValid) override; + virtual void LightIsValid(bool a_IsLightValid) override; virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) override; virtual void Entity(cEntity * a_Entity) override; virtual void BlockEntity(cBlockEntity * a_Entity) override; diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index bb9d4b9e6..b44dd02c5 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -107,15 +107,13 @@ void cJsonChunkSerializer::BlockEntity(cBlockEntity * a_BlockEntity) -bool cJsonChunkSerializer::LightIsValid(bool a_IsLightValid) +void cJsonChunkSerializer::LightIsValid(bool a_IsLightValid) { - if (!a_IsLightValid) + if (a_IsLightValid) { - return false; + m_Root["IsLightValid"] = true; + m_HasJsonData = true; } - m_Root["IsLightValid"] = true; - m_HasJsonData = true; - return true; } diff --git a/src/WorldStorage/WSSCompact.h b/src/WorldStorage/WSSCompact.h index 4df146ec3..49a897984 100644 --- a/src/WorldStorage/WSSCompact.h +++ b/src/WorldStorage/WSSCompact.h @@ -14,6 +14,7 @@ #include "WorldStorage.h" #include "../Vector3.h" #include "json/json.h" +#include "ChunkBuffer.h" @@ -42,7 +43,7 @@ protected: // cChunkDataCollector overrides: virtual void Entity (cEntity * a_Entity) override; virtual void BlockEntity (cBlockEntity * a_Entity) override; - virtual bool LightIsValid (bool a_IsLightValid) override; + virtual void LightIsValid (bool a_IsLightValid) override; } ; -- cgit v1.2.3 From b4b3b5ce6480419bb18bafa6650dd09ea5544441 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 26 Apr 2014 23:50:24 +0100 Subject: More comments! * Also fixed a potential issue with position sending - if someone moved slowly enough, their position would never be updated. --- src/Entities/Entity.cpp | 2 +- src/Entities/Entity.h | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index f535faac7..921457b2d 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1145,7 +1145,7 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude) int DiffY = (int)(floor(GetPosY() * 32.0) - floor(m_LastPos.y * 32.0)); int DiffZ = (int)(floor(GetPosZ() * 32.0) - floor(m_LastPos.z * 32.0)); - if ((abs(DiffX) >= 4) || (abs(DiffY) >= 4) || (abs(DiffZ) >= 4)) + if ((abs(DiffX) != 0) || (abs(DiffY) != 0) || (abs(DiffZ) != 0)) // Have we moved? { if ((abs(DiffX) <= 127) && (abs(DiffY) <= 127) && (abs(DiffZ) <= 127)) // Limitations of a Byte { diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 0785b5609..22b133fb7 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -419,19 +419,26 @@ protected: /// The entity which is attached to this entity (rider), NULL if none cEntity * m_Attachee; - // Flags that signal that we haven't updated the clients with the latest. + /** Stores whether head yaw has been set manually */ bool m_bDirtyHead; + /** Stores whether our yaw/pitch/roll (body orientation) has been set manually */ bool m_bDirtyOrientation; + /** Stores whether we have sent a Velocity packet with a speed of zero (no speed) to the client + Ensures that said packet is sent only once */ bool m_bHasSentNoSpeed; + /** Stores if the entity is on the ground */ bool m_bOnGround; + /** Stores gravity that is applied to an entity every tick + For realistic effects, this should be negative. For spaaaaaaace, this can be zero or even positive */ float m_Gravity; /** Last position sent to client via the Relative Move or Teleport packets (not Velocity) Only updated if cEntity::BroadcastMovementUpdate() is called! */ Vector3d m_LastPos; - bool m_IsInitialized; // Is set to true when it's initialized, until it's destroyed (Initialize() till Destroy() ) + /** True when entity is initialised (Initialize()) and false when destroyed pending deletion (Destroy()) */ + bool m_IsInitialized; eEntityType m_EntityType; -- cgit v1.2.3 From 15767badac8f1832dad93afa39b4678f611ce697 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 26 Apr 2014 23:52:18 +0100 Subject: A tiny speed improvement in ApplyFoodExhaustion() --- src/Entities/Player.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index a7b1dd74e..b43205226 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1848,16 +1848,16 @@ void cPlayer::ApplyFoodExhaustionFromMovement() { return; } - - // Calculate the distance travelled, update the last pos: - Vector3d Movement(GetPosition() - m_LastPos); - Movement.y = 0; // Only take XZ movement into account - + // If riding anything, apply no food exhaustion if (m_AttachedTo != NULL) { return; } + + // Calculate the distance travelled, update the last pos: + Vector3d Movement(GetPosition() - m_LastPos); + Movement.y = 0; // Only take XZ movement into account // Apply the exhaustion based on distance travelled: double BaseExhaustion = Movement.Length(); -- cgit v1.2.3 From dcb2a590e364301aa1919546ad33a33e5dc34042 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 27 Apr 2014 06:45:33 -0700 Subject: Fixed bad merge --- src/Chunk.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 5a82ca66a..6b0058303 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1468,7 +1468,7 @@ void cChunk::QueueTickBlock(int a_RelX, int a_RelY, int a_RelZ) return; } - m_ToTickBlocks.push_back(MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ)); + m_ToTickBlocks.push_back(Vector3i(a_RelX, a_RelY, a_RelZ)); } @@ -1531,7 +1531,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta)); } - SetNibble(m_BlockMeta, index, a_BlockMeta); + m_ChunkBuffer.SetMeta(a_RelX, a_RelY, a_RelZ, a_BlockMeta); // ONLY recalculate lighting if it's necessary! if ( @@ -1554,7 +1554,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT { for (int y = a_RelY - 1; y > 0; --y) { - if (GetBlock(MakeIndexNoCheck(a_RelX, y, a_RelZ)) != E_BLOCK_AIR) + if (GetBlock(a_RelX, y, a_RelZ) != E_BLOCK_AIR) { m_HeightMap[a_RelX + a_RelZ * Width] = (unsigned char)y; break; @@ -1570,19 +1570,16 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT void cChunk::SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client) { - // The coords must be valid, because the upper level already does chunk lookup. No need to check them again. - // There's an debug-time assert in MakeIndexNoCheck anyway - unsigned int index = MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ); if (a_Client == NULL) { // Queue the block for all clients in the chunk (will be sent in Tick()) - m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(index), GetMeta(index))); + m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), GetMeta(a_RelX, a_RelY, a_RelZ))); return; } Vector3i wp = PositionToWorldPosition(a_RelX, a_RelY, a_RelZ); - a_Client->SendBlockChange(wp.x, wp.y, wp.z, GetBlock(index), GetMeta(index)); + a_Client->SendBlockChange(wp.x, wp.y, wp.z, GetBlock(a_RelX, a_RelY, a_RelZ), GetMeta(a_RelX, a_RelY, a_RelZ)); // FS #268 - if a BlockEntity digging is cancelled by a plugin, the entire block entity must be re-sent to the client: for (cBlockEntityList::iterator itr = m_BlockEntities.begin(), end = m_BlockEntities.end(); itr != end; ++itr) @@ -2460,11 +2457,10 @@ void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_ void cChunk::GetBlockInfo(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight) { - int Idx = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ); - a_BlockType = GetBlock(Idx); - a_Meta = cChunkDef::GetNibble(m_BlockMeta, Idx); - a_SkyLight = cChunkDef::GetNibble(m_BlockSkyLight, Idx); - a_BlockLight = cChunkDef::GetNibble(m_BlockLight, Idx); + a_BlockType = GetBlock(a_RelX, a_RelY, a_RelZ); + a_Meta = m_ChunkBuffer.GetMeta(a_RelX, a_RelY, a_RelZ); + a_SkyLight = m_ChunkBuffer.GetSkyLight(a_RelX, a_RelY, a_RelZ); + a_BlockLight = m_ChunkBuffer.GetBlockLight(a_RelX, a_RelY, a_RelZ); } -- cgit v1.2.3 From e3bdc81ca04fbad284eb0c3b53678f0fb357eb64 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 27 Apr 2014 06:46:13 -0700 Subject: Fixed MobProximity Counter to remove chunk copys --- src/MobProximityCounter.cpp | 5 ++--- src/MobProximityCounter.h | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/MobProximityCounter.cpp b/src/MobProximityCounter.cpp index c7e91e18b..ce20bf56b 100644 --- a/src/MobProximityCounter.cpp +++ b/src/MobProximityCounter.cpp @@ -24,8 +24,7 @@ void cMobProximityCounter::CollectMob(cEntity& a_Monster, cChunk& a_Chunk, doubl if (a_Distance < it->second.m_Distance) { it->second.m_Distance = a_Distance; - ASSERT(false); - //it->second.m_Chunk = a_Chunk; + it->second.m_Chunk = &a_Chunk; } } @@ -37,7 +36,7 @@ void cMobProximityCounter::convertMaps() { for(tMonsterToDistance::const_iterator itr = m_MonsterToDistance.begin(); itr != m_MonsterToDistance.end(); ++itr) { - m_DistanceToMonster.insert(tDistanceToMonster::value_type(itr->second.m_Distance,sMonsterAndChunk(*itr->first,itr->second.m_Chunk))); + m_DistanceToMonster.insert(tDistanceToMonster::value_type(itr->second.m_Distance,sMonsterAndChunk(*itr->first,*itr->second.m_Chunk))); } } diff --git a/src/MobProximityCounter.h b/src/MobProximityCounter.h index 8a67139aa..79429eb60 100644 --- a/src/MobProximityCounter.h +++ b/src/MobProximityCounter.h @@ -16,9 +16,9 @@ protected : // structs used for later maps (see m_MonsterToDistance and m_DistanceToMonster) struct sDistanceAndChunk { - sDistanceAndChunk(double a_Distance, cChunk& a_Chunk) : m_Distance(a_Distance), m_Chunk(a_Chunk) {} + sDistanceAndChunk(double a_Distance, cChunk& a_Chunk) : m_Distance(a_Distance), m_Chunk(&a_Chunk) {} double m_Distance; - cChunk& m_Chunk; + cChunk* m_Chunk; }; struct sMonsterAndChunk { -- cgit v1.2.3 From 2730a41946b5236894d65ec9cc001ed41b6a5589 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 27 Apr 2014 07:10:30 -0700 Subject: Fixed issues with gcc --- src/ChunkBuffer.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ChunkBuffer.h b/src/ChunkBuffer.h index 44e447c82..a6a6da013 100644 --- a/src/ChunkBuffer.h +++ b/src/ChunkBuffer.h @@ -36,8 +36,8 @@ public: #if __cplusplus < 201103L // auto_ptr style interface for memory management - cChunkBuffer(cChunkBuffer& other) : - IsOwner(true); + cChunkBuffer(const cChunkBuffer& other) : + IsOwner(true) { for (int i = 0; i < CHUNK_SECTION_NUM; i++) { @@ -45,7 +45,8 @@ public: } other.IsOwner = false; } - void operator=(cChunkBuffer& other) + + void operator=(const cChunkBuffer& other) { if(IsOwner) { @@ -63,7 +64,7 @@ public: } #else // unique_ptr style interface for memory management - cChunkBuffer(cChunkBuffer&& other) + cChunkBuffer(const cChunkBuffer&& other) { for (int i = 0; i < CHUNK_SECTION_NUM; i++) { @@ -71,7 +72,7 @@ public: } } - void operator=(cChunkBuffer&& other) + void operator=(const cChunkBuffer&& other) { for (int i = 0; i < CHUNK_SECTION_NUM; i++) { @@ -225,7 +226,7 @@ private: #if __cplusplus < 201103L // auto_ptr style interface for memory management - bool IsOwner; + mutable bool IsOwner; #endif struct sChunkSection { -- cgit v1.2.3 From 48a2488477023b5427381863585fd1448743d32e Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 27 Apr 2014 07:38:16 -0700 Subject: Added other half of implementation --- src/ChunkBuffer.cpp | 147 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 133 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/ChunkBuffer.cpp b/src/ChunkBuffer.cpp index 8e87d3049..7946fba1e 100644 --- a/src/ChunkBuffer.cpp +++ b/src/ChunkBuffer.cpp @@ -22,7 +22,7 @@ cChunkBuffer cChunkBuffer::Copy() const void cChunkBuffer::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length) const { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; if (a_Idx > 0) a_Idx = a_Idx > length ? a_Idx - length : 0; @@ -30,7 +30,22 @@ void cChunkBuffer::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length { size_t tocopy = length > segment_length ? segment_length : length; length -= tocopy; - memcpy(&a_dest[i * segment_length], &m_Sections[i]->m_BlockTypes, sizeof(BLOCKTYPE) * length); + if(m_Sections[i]) + { + memcpy( + &a_dest[i * segment_length], + &m_Sections[i]->m_BlockTypes, + sizeof(BLOCKTYPE) * length + ); + } + else + { + memset( + &a_dest[i * segment_length], + 0, + sizeof(BLOCKTYPE) * length + ); + } } } } @@ -41,10 +56,24 @@ void cChunkBuffer::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length void cChunkBuffer::CopyMeta(NIBBLETYPE * a_dest) const { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - memcpy(&a_dest[i * segment_length], &m_Sections[i]->m_BlockMeta, sizeof(NIBBLETYPE) * segment_length); + if(m_Sections[i]) + { + memcpy( + &a_dest[i * segment_length], + &m_Sections[i]->m_BlockMeta, + sizeof(NIBBLETYPE) * segment_length); + } + else + { + memset( + &a_dest[i * segment_length], + 0, + sizeof(BLOCKTYPE) * segment_length + ); + } } } @@ -54,10 +83,25 @@ void cChunkBuffer::CopyMeta(NIBBLETYPE * a_dest) const void cChunkBuffer::CopyLight(NIBBLETYPE * a_dest) const { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - memcpy(&a_dest[i * segment_length], &m_Sections[i]->m_BlockLight, sizeof(NIBBLETYPE) * segment_length); + if(m_Sections[i]) + { + memcpy( + &a_dest[i * segment_length], + &m_Sections[i]->m_BlockLight, + sizeof(NIBBLETYPE) * segment_length + ); + } + else + { + memset( + &a_dest[i * segment_length], + 0, + sizeof(BLOCKTYPE) * segment_length + ); + } } } @@ -67,10 +111,25 @@ void cChunkBuffer::CopyLight(NIBBLETYPE * a_dest) const void cChunkBuffer::CopySkyLight(NIBBLETYPE * a_dest) const { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - memcpy(&a_dest[i * segment_length], &m_Sections[i]->m_BlockSkyLight, sizeof(NIBBLETYPE) * segment_length); + if(m_Sections[i]) + { + memcpy( + &a_dest[i * segment_length], + &m_Sections[i]->m_BlockSkyLight, + sizeof(NIBBLETYPE) * segment_length + ); + } + else + { + memset( + &a_dest[i * segment_length], + 0xFF, + sizeof(BLOCKTYPE) * segment_length + ); + } } } @@ -80,13 +139,28 @@ void cChunkBuffer::CopySkyLight(NIBBLETYPE * a_dest) const void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src) { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i]) { memcpy(&m_Sections[i]->m_BlockTypes, &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length); } + else + { + size_t j = 0; + // do nothing whilst 0 + for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); + if (j != segment_length) + { + m_Sections[i] = Allocate(); + memcpy( + &m_Sections[i]->m_BlockTypes, + &a_src[i * segment_length], + sizeof(BLOCKTYPE) * segment_length + ); + } + } } } @@ -95,13 +169,28 @@ void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src) void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src) { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i]) { memcpy(&m_Sections[i]->m_BlockMeta, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); } + else + { + size_t j = 0; + // do nothing whilst 0 + for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); + if (j != segment_length) + { + m_Sections[i] = Allocate(); + memcpy( + &m_Sections[i]->m_BlockTypes, + &a_src[i * segment_length], + sizeof(BLOCKTYPE) * segment_length + ); + } + } } } @@ -110,14 +199,29 @@ void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src) void cChunkBuffer::SetLight(const NIBBLETYPE * a_src) { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i]) { memcpy(&m_Sections[i]->m_BlockLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); } - } + else + { + size_t j = 0; + // do nothing whilst 0 + for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); + if (j != segment_length) + { + m_Sections[i] = Allocate(); + memcpy( + &m_Sections[i]->m_BlockTypes, + &a_src[i * segment_length], + sizeof(BLOCKTYPE) * segment_length + ); + } + } + } } @@ -125,14 +229,29 @@ void cChunkBuffer::SetLight(const NIBBLETYPE * a_src) void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src) { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i]) { memcpy(&m_Sections[i]->m_BlockSkyLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); } - } + else + { + size_t j = 0; + // do nothing whilst 0 + for (; j < segment_length && a_src[i * segment_length + j] == 0xFF; j++); + if (j != segment_length) + { + m_Sections[i] = Allocate(); + memcpy( + &m_Sections[i]->m_BlockTypes, + &a_src[i * segment_length], + sizeof(BLOCKTYPE) * segment_length + ); + } + } + } } -- cgit v1.2.3 From d412630904c1de6c0d9ef00fbc75b5558f931e8b Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 27 Apr 2014 08:11:56 -0700 Subject: Fixed a couple of segfaults and made Free a seperate function --- src/ChunkBuffer.cpp | 38 +++++++++++++++++++++++++++++++++++--- src/ChunkBuffer.h | 7 ++++--- 2 files changed, 39 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ChunkBuffer.cpp b/src/ChunkBuffer.cpp index 7946fba1e..a41b8f61a 100644 --- a/src/ChunkBuffer.cpp +++ b/src/ChunkBuffer.cpp @@ -160,6 +160,11 @@ void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src) sizeof(BLOCKTYPE) * segment_length ); } + else + { + Free(m_Sections[i]); + m_Sections[i] = 0; + } } } } @@ -185,11 +190,16 @@ void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src) { m_Sections[i] = Allocate(); memcpy( - &m_Sections[i]->m_BlockTypes, + &m_Sections[i]->m_BlockMeta, &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length ); } + else + { + Free(m_Sections[i]); + m_Sections[i] = 0; + } } } } @@ -199,6 +209,7 @@ void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src) void cChunkBuffer::SetLight(const NIBBLETYPE * a_src) { + if (!a_src) return; for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; @@ -215,11 +226,16 @@ void cChunkBuffer::SetLight(const NIBBLETYPE * a_src) { m_Sections[i] = Allocate(); memcpy( - &m_Sections[i]->m_BlockTypes, + &m_Sections[i]->m_BlockLight, &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length ); } + else + { + Free(m_Sections[i]); + m_Sections[i] = 0; + } } } } @@ -229,6 +245,7 @@ void cChunkBuffer::SetLight(const NIBBLETYPE * a_src) void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src) { + if (!a_src) return; for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; @@ -245,11 +262,16 @@ void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src) { m_Sections[i] = Allocate(); memcpy( - &m_Sections[i]->m_BlockTypes, + &m_Sections[i]->m_BlockSkyLight, &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length ); } + else + { + Free(m_Sections[i]); + m_Sections[i] = 0; + } } } } @@ -263,3 +285,13 @@ cChunkBuffer::sChunkSection * cChunkBuffer::Allocate() const // TODO: use a allocation pool return new cChunkBuffer::sChunkSection; } + + + +void cChunkBuffer::Free(cChunkBuffer::sChunkSection * ptr) const +{ + delete ptr; +} + + + diff --git a/src/ChunkBuffer.h b/src/ChunkBuffer.h index a6a6da013..c23f8971d 100644 --- a/src/ChunkBuffer.h +++ b/src/ChunkBuffer.h @@ -30,7 +30,7 @@ public: #endif for (int i = 0; i < CHUNK_SECTION_NUM; i++) { - if(m_Sections[i]) delete m_Sections[i]; + if(m_Sections[i]) Free(m_Sections[i]);; } } @@ -52,7 +52,7 @@ public: { for (int i = 0; i < CHUNK_SECTION_NUM; i++) { - if(m_Sections[i]) delete m_Sections[i]; + if(m_Sections[i]) Free(m_Sections[i]);; } } IsOwner = true; @@ -76,7 +76,7 @@ public: { for (int i = 0; i < CHUNK_SECTION_NUM; i++) { - if(m_Sections[i]) delete m_Sections[i]; + if(m_Sections[i]) Free(m_Sections[i]);; m_Sections[i] = other.m_Sections[i]; } } @@ -239,6 +239,7 @@ private: sChunkSection *m_Sections[CHUNK_SECTION_NUM]; sChunkSection * Allocate() const; + void Free(sChunkSection * ptr) const; }; -- cgit v1.2.3 From 6f1fea759e3595d5538330ecf8f05b8edcf0882e Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 27 Apr 2014 08:14:56 -0700 Subject: Fixed bad comment --- src/BlockArea.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index b4b519bc7..68976ab7a 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -1911,7 +1911,7 @@ bool cBlockArea::cChunkReader::Coords(int a_ChunkX, int a_ChunkZ) void cBlockArea::cChunkReader::ChunkBuffer(const cChunkBuffer & a_BlockBuffer) { - { // BlockTypes + { if (!(m_Area.m_BlockTypes == NULL)) { int SizeY = m_Area.m_Size.y; -- cgit v1.2.3 From bbc5faa723b7dd63250949f7b28601ffd748e2f5 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 27 Apr 2014 17:35:41 +0100 Subject: Redstone simulator now directly accesses cChunk * Redstone simulator performance improvements * Added return values to some functions * Minor fixes --- src/Chunk.cpp | 20 +- src/Chunk.h | 9 +- src/ChunkMap.cpp | 2 - src/ClientHandle.cpp | 3 +- src/Entities/Entity.cpp | 1 + src/Entities/FallingBlock.cpp | 3 +- src/Mobs/AggressiveMonster.cpp | 5 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 926 ++++++++++++++----------- src/Simulator/IncrementalRedstoneSimulator.h | 68 +- src/World.h | 2 +- 10 files changed, 586 insertions(+), 453 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index cd3bceda2..053648262 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -749,7 +749,7 @@ void cChunk::ProcessQueuedSetBlocks(void) { if (itr->m_Tick <= CurrTick) { - if (itr->m_PreviousType != E_BLOCK_AIR) // PreviousType defaults to -1 if not specified + if (itr->m_PreviousType != E_BLOCK_AIR) // PreviousType defaults to 0 if not specified { if (GetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ) == itr->m_PreviousType) { @@ -1638,6 +1638,24 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT +void cChunk::SetMeta(int a_BlockIdx, NIBBLETYPE a_Meta) +{ + if (GetNibble(m_BlockMeta, a_BlockIdx) == a_Meta) + { + return; + } + + MarkDirty(); + SetNibble(m_BlockMeta, a_BlockIdx, a_Meta); + Vector3i Coords(IndexToCoordinate(a_BlockIdx)); + + m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, Coords.x, Coords.y, Coords.z, GetBlock(a_BlockIdx), a_Meta)); +} + + + + + void cChunk::SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client) { // The coords must be valid, because the upper level already does chunk lookup. No need to check them again. diff --git a/src/Chunk.h b/src/Chunk.h index a15d43e00..84ec35496 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -320,10 +320,10 @@ public: m_BlockTickZ = a_RelZ; } - inline NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const {return cChunkDef::GetNibble(m_BlockMeta, a_RelX, a_RelY, a_RelZ); } - inline NIBBLETYPE GetMeta(int a_BlockIdx) const {return cChunkDef::GetNibble(m_BlockMeta, a_BlockIdx); } - inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta) { cChunkDef::SetNibble(m_BlockMeta, a_RelX, a_RelY, a_RelZ, a_Meta); } - inline void SetMeta(int a_BlockIdx, NIBBLETYPE a_Meta) { cChunkDef::SetNibble(m_BlockMeta, a_BlockIdx, a_Meta); } + inline NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const { return cChunkDef::GetNibble(m_BlockMeta, a_RelX, a_RelY, a_RelZ); } + inline NIBBLETYPE GetMeta(int a_BlockIdx) const { return cChunkDef::GetNibble(m_BlockMeta, a_BlockIdx); } + inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta) { SetMeta(MakeIndex(a_RelX, a_RelY, a_RelZ), a_Meta); } + void SetMeta(int a_BlockIdx, NIBBLETYPE a_Meta); inline NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const {return cChunkDef::GetNibble(m_BlockLight, a_RelX, a_RelY, a_RelZ); } inline NIBBLETYPE GetSkyLight (int a_RelX, int a_RelY, int a_RelZ) const {return cChunkDef::GetNibble(m_BlockSkyLight, a_RelX, a_RelY, a_RelZ, true); } @@ -420,7 +420,6 @@ private: cWorld * m_World; cChunkMap * m_ChunkMap; - // TODO: Make these pointers and don't allocate what isn't needed COMPRESSED_BLOCKTYPE m_BlockTypes; COMPRESSED_NIBBLETYPE m_BlockMeta; COMPRESSED_NIBBLETYPE m_BlockLight; diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 0fb6988b5..193937278 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1248,8 +1248,6 @@ void cChunkMap::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYP if ((Chunk != NULL) && Chunk->IsValid()) { Chunk->SetMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockMeta); - Chunk->MarkDirty(); - Chunk->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, NULL); } } diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index fc3f98aaf..8dddef7f8 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -202,7 +202,7 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage { switch (a_ChatPrefix) { - case mtCustom: return AString(); + case mtCustom: return ""; case mtFailure: return FormatChatPrefix(ShouldAppendChatPrefixes, "INFO", cChatColor::Rose, cChatColor::White); case mtInformation: return FormatChatPrefix(ShouldAppendChatPrefixes, "INFO", cChatColor::Yellow, cChatColor::White); case mtSuccess: return FormatChatPrefix(ShouldAppendChatPrefixes, "INFO", cChatColor::Green, cChatColor::White); @@ -220,6 +220,7 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage } } ASSERT(!"Unhandled chat prefix type!"); + return ""; } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 7c8e18b51..7a301a5b7 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -441,6 +441,7 @@ bool cEntity::ArmorCoversAgainst(eDamageType a_DamageType) } } ASSERT(!"Invalid damage type!"); + return false; } diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp index bcdac0291..86720ac94 100644 --- a/src/Entities/FallingBlock.cpp +++ b/src/Entities/FallingBlock.cpp @@ -88,8 +88,7 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk) AddPosition(GetSpeed() * MilliDt); // If not static (One billionth precision) broadcast movement. - static const float epsilon = 0.000000001; - if ((fabs(GetSpeedX()) > epsilon) || (fabs(GetSpeedZ()) > epsilon)) + if ((fabs(GetSpeedX()) > std::numeric_limits::epsilon()) || (fabs(GetSpeedZ()) > std::numeric_limits::epsilon())) { BroadcastMovementUpdate(); } diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index 3e5f72dbf..85b122034 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -108,14 +108,13 @@ void cAggressiveMonster::Attack(float a_Dt) bool cAggressiveMonster::IsMovingToTargetPosition() { - float epsilon = 0.000000000001; // Difference between destination x and target x is negligible (to 10^-12 precision) - if (fabsf((float)m_FinalDestination.x - (float)m_Target->GetPosX()) < epsilon) + if (fabsf((float)m_FinalDestination.x - (float)m_Target->GetPosX()) < std::numeric_limits::epsilon()) { return false; } // Difference between destination z and target z is negligible (to 10^-12 precision) - else if (fabsf(m_FinalDestination.z - (float)m_Target->GetPosZ()) > epsilon) + else if (fabsf((float)m_FinalDestination.z - (float)m_Target->GetPosZ()) > std::numeric_limits::epsilon()) { return false; } diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index d37d2eecf..5ac48d328 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -139,14 +139,14 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, SimulatedPlayerToggleableList * SimulatedPlayerToggleableBlocks = a_Chunk->GetRedstoneSimulatorSimulatedPlayerToggleableList(); for (SimulatedPlayerToggleableList::iterator itr = SimulatedPlayerToggleableBlocks->begin(); itr != SimulatedPlayerToggleableBlocks->end(); ++itr) { - if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + if (!itr->a_RelBlockPos.Equals(Vector3i(RelX, a_BlockY, RelZ))) { continue; } if (!IsAllowedBlock(Block)) { - LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from toggleable simulated list as it is no longer redstone", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); + LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from toggleable simulated list as it is no longer redstone", itr->a_RelBlockPos.x, itr->a_RelBlockPos.y, itr->a_RelBlockPos.z); SimulatedPlayerToggleableBlocks->erase(itr); break; } @@ -155,7 +155,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, RepeatersDelayList * RepeatersDelayList = a_Chunk->GetRedstoneSimulatorRepeatersDelayList(); for (RepeatersDelayList::iterator itr = RepeatersDelayList->begin(); itr != RepeatersDelayList->end(); ++itr) { - if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + if (!itr->a_RelBlockPos.Equals(Vector3i(RelX, a_BlockY, RelZ))) { continue; } @@ -221,9 +221,6 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int m_LinkedPoweredBlocks = a_Chunk->GetRedstoneSimulatorLinkedBlocksList(); m_Chunk = a_Chunk; - int BaseX = a_Chunk->GetPosX() * cChunkDef::Width; - int BaseZ = a_Chunk->GetPosZ() * cChunkDef::Width; - for (cRedstoneSimulatorChunkData::iterator dataitr = m_RedstoneSimulatorChunkData->begin(); dataitr != m_RedstoneSimulatorChunkData->end();) { if (dataitr->DataTwo) @@ -232,67 +229,65 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int continue; } - int a_X = BaseX + dataitr->x; - int a_Z = BaseZ + dataitr->z; switch (dataitr->Data) { - case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(a_X, dataitr->y, a_Z); break; - case E_BLOCK_LEVER: HandleRedstoneLever(a_X, dataitr->y, a_Z); break; - case E_BLOCK_FENCE_GATE: HandleFenceGate(a_X, dataitr->y, a_Z); break; - case E_BLOCK_TNT: HandleTNT(a_X, dataitr->y, a_Z); break; - case E_BLOCK_TRAPDOOR: HandleTrapdoor(a_X, dataitr->y, a_Z); break; - case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(a_X, dataitr->y, a_Z); break; - case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(a_X, dataitr->y, a_Z); break; - case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(a_X, dataitr->y, a_Z); break; - case E_BLOCK_COMMAND_BLOCK: HandleCommandBlock(a_X, dataitr->y, a_Z); break; + case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_LEVER: HandleRedstoneLever(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_FENCE_GATE: HandleFenceGate(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_TNT: HandleTNT(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_TRAPDOOR: HandleTrapdoor(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_COMMAND_BLOCK: HandleCommandBlock(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_REDSTONE_TORCH_OFF: case E_BLOCK_REDSTONE_TORCH_ON: { - HandleRedstoneTorch(a_X, dataitr->y, a_Z, dataitr->Data); + HandleRedstoneTorch(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); break; } case E_BLOCK_STONE_BUTTON: case E_BLOCK_WOODEN_BUTTON: { - HandleRedstoneButton(a_X, dataitr->y, a_Z, dataitr->Data); + HandleRedstoneButton(dataitr->x, dataitr->y, dataitr->z); break; } case E_BLOCK_REDSTONE_REPEATER_OFF: case E_BLOCK_REDSTONE_REPEATER_ON: { - HandleRedstoneRepeater(a_X, dataitr->y, a_Z, dataitr->Data); + HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); break; } case E_BLOCK_PISTON: case E_BLOCK_STICKY_PISTON: { - HandlePiston(a_X, dataitr->y, a_Z); + HandlePiston(dataitr->x, dataitr->y, dataitr->z); break; } case E_BLOCK_REDSTONE_LAMP_OFF: case E_BLOCK_REDSTONE_LAMP_ON: { - HandleRedstoneLamp(a_X, dataitr->y, a_Z, dataitr->Data); + HandleRedstoneLamp(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); break; } case E_BLOCK_DISPENSER: case E_BLOCK_DROPPER: { - HandleDropSpenser(a_X, dataitr->y, a_Z); + HandleDropSpenser(dataitr->x, dataitr->y, dataitr->z); break; } case E_BLOCK_WOODEN_DOOR: case E_BLOCK_IRON_DOOR: { - HandleDoor(a_X, dataitr->y, a_Z); + HandleDoor(dataitr->x, dataitr->y, dataitr->z); break; } case E_BLOCK_ACTIVATOR_RAIL: case E_BLOCK_DETECTOR_RAIL: case E_BLOCK_POWERED_RAIL: { - HandleRail(a_X, dataitr->y, a_Z, dataitr->Data); + HandleRail(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); break; } case E_BLOCK_WOODEN_PRESSURE_PLATE: @@ -300,7 +295,7 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: { - HandlePressurePlate(a_X, dataitr->y, a_Z, dataitr->Data); + HandlePressurePlate(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); break; } default: LOGD("Unhandled block (!) or unimplemented redstone block: %s", ItemToString(dataitr->Data).c_str()); break; @@ -342,7 +337,7 @@ void cIncrementalRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_Blo -void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyState) +void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState) { static const struct // Define which directions the torch can power { @@ -359,54 +354,58 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_BlockX, int a_Bloc if (a_MyState == E_BLOCK_REDSTONE_TORCH_ON) { // Check if the block the torch is on is powered - int X = a_BlockX; int Y = a_BlockY; int Z = a_BlockZ; - AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)), true); // Inverse true to get the block torch is on + int X = a_RelBlockX; int Y = a_RelBlockY; int Z = a_RelBlockZ; + AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on if (AreCoordsDirectlyPowered(X, Y, Z)) { // There was a match, torch goes off - m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_OFF, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)); + m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_TORCH_OFF, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)); return; } // Torch still on, make all 4(X, Z) + 1(Y) sides powered for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) { - BLOCKTYPE Type = m_World.GetBlock(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z); + BLOCKTYPE Type = 0; + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, Type)) + { + continue; + } if (i + 1 < ARRAYCOUNT(gCrossCoords)) // Sides of torch, not top (top is last) { if ( ((IsMechanism(Type)) || (Type == E_BLOCK_REDSTONE_WIRE)) && // Is it a mechanism or wire? Not block/other torch etc. - (!Vector3i(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z).Equals(Vector3i(X, Y, Z))) // CAN'T power block is that it is on + (!Vector3i(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z).Equals(Vector3i(X, Y, Z))) // CAN'T power block is that it is on ) { - SetBlockPowered(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_ON); + SetBlockPowered(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ); } } else { // Top side, power whatever is there, including blocks - SetBlockPowered(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_ON); + SetBlockPowered(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ); // Power all blocks surrounding block above torch - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YP, E_BLOCK_REDSTONE_TORCH_ON); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YP); } } - if (m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) != 0x5) // Is torch standing on ground? If NOT (i.e. on wall), power block beneath + if (m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) != 0x5) // Is torch standing on ground? If NOT (i.e. on wall), power block beneath { - BLOCKTYPE Type = m_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ); + BLOCKTYPE Type = m_Chunk->GetBlock(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ); if ((IsMechanism(Type)) || (Type == E_BLOCK_REDSTONE_WIRE)) // Still can't make a normal block powered though! { - SetBlockPowered(a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_ON); + SetBlockPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); } } } else { // Check if the block the torch is on is powered - int X = a_BlockX; int Y = a_BlockY; int Z = a_BlockZ; - AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)), true); // Inverse true to get the block torch is on + int X = a_RelBlockX; int Y = a_RelBlockY; int Z = a_RelBlockZ; + AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on // See if off state torch can be turned on again if (AreCoordsDirectlyPowered(X, Y, Z)) @@ -415,7 +414,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_BlockX, int a_Bloc } // Block torch on not powered, can be turned on again! - m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_ON, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)); + m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_TORCH_ON, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)); } } @@ -423,28 +422,28 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_BlockX, int a_Bloc -void cIncrementalRedstoneSimulator::HandleRedstoneBlock(int a_BlockX, int a_BlockY, int a_BlockZ) +void cIncrementalRedstoneSimulator::HandleRedstoneBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_BLOCK_OF_REDSTONE); - SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_BLOCK_OF_REDSTONE); // Set self as powered + SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); + SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); // Set self as powered } -void cIncrementalRedstoneSimulator::HandleRedstoneLever(int a_BlockX, int a_BlockY, int a_BlockZ) +void cIncrementalRedstoneSimulator::HandleRedstoneLever(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - if (IsLeverOn(m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ))) + if (IsLeverOn(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) { - SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_LEVER); + SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XM, E_BLOCK_LEVER); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XP, E_BLOCK_LEVER); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YM, E_BLOCK_LEVER); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YP, E_BLOCK_LEVER); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZM, E_BLOCK_LEVER); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZP, E_BLOCK_LEVER); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YM); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YP); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP); } } @@ -452,27 +451,29 @@ void cIncrementalRedstoneSimulator::HandleRedstoneLever(int a_BlockX, int a_Bloc -void cIncrementalRedstoneSimulator::HandleFenceGate(int a_BlockX, int a_BlockY, int a_BlockZ) +void cIncrementalRedstoneSimulator::HandleFenceGate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; cChunkInterface ChunkInterface(m_World.GetChunkMap()); - NIBBLETYPE MetaData = ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); + NIBBLETYPE MetaData = ChunkInterface.GetBlockMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); - if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ)) + if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) { - if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, true)) + if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true)) { - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, MetaData | 0x4); - m_World.BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0); - SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, true); + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MetaData | 0x4); + m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true); } } else { - if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, false)) + if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false)) { - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, MetaData & 0xFFFFFFFB); - m_World.BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0); - SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, false); + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MetaData & 0xFFFFFFFB); + m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false); } } } @@ -481,18 +482,18 @@ void cIncrementalRedstoneSimulator::HandleFenceGate(int a_BlockX, int a_BlockY, -void cIncrementalRedstoneSimulator::HandleRedstoneButton(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType) +void cIncrementalRedstoneSimulator::HandleRedstoneButton(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - if (IsButtonOn(m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ))) + if (IsButtonOn(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) { - SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_BlockType); + SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XM, a_BlockType); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XP, a_BlockType); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YM, a_BlockType); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YP, a_BlockType); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZM, a_BlockType); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZP, a_BlockType); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YM); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YP); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP); } } @@ -500,7 +501,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneButton(int a_BlockX, int a_Blo -void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_BlockY, int a_BlockZ) +void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { static const struct // Define which directions the wire can receive power from { @@ -535,14 +536,16 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_Block // Check to see if directly beside a power source unsigned char MyPower; - if (!IsWirePowered(a_BlockX, a_BlockY, a_BlockZ, MyPower)) + if (!IsWirePowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower)) { - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0); - m_World.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ); + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0); + m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ); return; } - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, MyPower); + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower); if (MyPower < 1) { @@ -555,74 +558,102 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_Block { if ((i >= 4) && (i <= 7)) // If we are currently checking for wire surrounding ourself one block above... { - if (cBlockInfo::IsSolid(m_World.GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))) // If there is something solid above us (wire cut off)... + BLOCKTYPE Type = 0; + if (a_RelBlockY + 1 >= cChunkDef::Height) + { + continue; + } + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, Type)) + { + continue; + } + if (cBlockInfo::IsSolid(Type)) // If there is something solid above us (wire cut off)... { continue; // We don't receive power from that wire } } else if ((i >= 8) && (i <= 11)) // See above, but this is for wire below us { - if (cBlockInfo::IsSolid(m_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))) + BLOCKTYPE Type = 0; + if (a_RelBlockY - 1 < 0) + { + continue; + } + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, Type)) + { + continue; + } + if (cBlockInfo::IsSolid(Type)) { continue; } } - if (m_World.GetBlock(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z) == E_BLOCK_REDSTONE_WIRE) + BLOCKTYPE Type = 0; + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, Type)) { - SetBlockPowered(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower); + continue; + } + if (Type == E_BLOCK_REDSTONE_WIRE) + { + SetBlockPowered(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower); } } for (size_t i = 0; i < ARRAYCOUNT(gSideCoords); i++) // Look for repeaters immediately surrounding self and try to power them { - if (m_World.GetBlock(a_BlockX + gSideCoords[i].x, a_BlockY + gSideCoords[i].y, a_BlockZ + gSideCoords[i].z) == E_BLOCK_REDSTONE_REPEATER_OFF) + BLOCKTYPE Type = 0; + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + gSideCoords[i].x, a_RelBlockY + gSideCoords[i].y, a_RelBlockZ + gSideCoords[i].z, Type)) { - SetBlockPowered(a_BlockX + gSideCoords[i].x, a_BlockY + gSideCoords[i].y, a_BlockZ + gSideCoords[i].z, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower); + continue; + } + if (Type == E_BLOCK_REDSTONE_REPEATER_OFF) + { + SetBlockPowered(a_RelBlockX + gSideCoords[i].x, a_RelBlockY + gSideCoords[i].y, a_RelBlockZ + gSideCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower); } } // Wire still powered, power blocks beneath - SetBlockPowered(a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YM, E_BLOCK_REDSTONE_WIRE, MyPower); + SetBlockPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YM, MyPower); - switch (GetWireDirection(a_BlockX, a_BlockY, a_BlockZ)) + switch (GetWireDirection(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) { case REDSTONE_NONE: { - SetBlockPowered(a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower); - SetBlockPowered(a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower); - SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower); - SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower); + SetBlockPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower); + SetBlockPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower); + SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower); + SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XM, E_BLOCK_REDSTONE_WIRE, MyPower); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XP, E_BLOCK_REDSTONE_WIRE, MyPower); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZM, E_BLOCK_REDSTONE_WIRE, MyPower); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZP, E_BLOCK_REDSTONE_WIRE, MyPower); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM, MyPower); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP, MyPower); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM, MyPower); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP, MyPower); break; } case REDSTONE_X_POS: { - SetBlockPowered(a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XP, E_BLOCK_REDSTONE_WIRE, MyPower); + SetBlockPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP, MyPower); break; } case REDSTONE_X_NEG: { - SetBlockPowered(a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XM, E_BLOCK_REDSTONE_WIRE, MyPower); + SetBlockPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM, MyPower); break; } case REDSTONE_Z_POS: { - SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZP, E_BLOCK_REDSTONE_WIRE, MyPower); + SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP, MyPower); break; } case REDSTONE_Z_NEG: { - SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZM, E_BLOCK_REDSTONE_WIRE, MyPower); + SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM, MyPower); break; } } @@ -632,7 +663,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_Block -void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyState) +void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState) { /* Repeater Orientation Mini Guide: =================================== @@ -643,7 +674,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_B X Axis ----> - Repeater directions, values from a cWorld::GetBlockMeta(a_BlockX , a_BlockY, a_BlockZ) lookup: + Repeater directions, values from a cWorld::GetBlockMeta(a_RelBlockX , a_RelBlockY, a_RelBlockZ) lookup: East (Right) (X+): 0x1 West (Left) (X-): 0x3 @@ -656,25 +687,25 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_B */ // Create a variable holding my meta to avoid multiple lookups. - NIBBLETYPE a_Meta = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); + NIBBLETYPE a_Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); bool IsOn = (a_MyState == E_BLOCK_REDSTONE_REPEATER_ON); - if (!IsRepeaterLocked(a_BlockX, a_BlockY, a_BlockZ, a_Meta)) // If we're locked, change nothing. Otherwise: + if (!IsRepeaterLocked(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta)) // If we're locked, change nothing. Otherwise: { - bool IsSelfPowered = IsRepeaterPowered(a_BlockX, a_BlockY, a_BlockZ, a_Meta); + bool IsSelfPowered = IsRepeaterPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta); if (IsSelfPowered && !IsOn) // Queue a power change if powered, but not on and not locked. { - QueueRepeaterPowerChange(a_BlockX, a_BlockY, a_BlockZ, a_Meta, true); + QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, true); } else if (!IsSelfPowered && IsOn) // Queue a power change if unpowered, on, and not locked. { - QueueRepeaterPowerChange(a_BlockX, a_BlockY, a_BlockZ, a_Meta, false); + QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false); } } for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end(); ++itr) { - if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + if (!itr->a_RelBlockPos.Equals(Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) { continue; } @@ -685,33 +716,33 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_B { if (!IsOn) { - m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON, a_Meta); // For performance + m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_REPEATER_ON, a_Meta); // For performance } switch (a_Meta & 0x3) // We only want the direction (bottom) bits { case 0x0: { - SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZM, E_BLOCK_REDSTONE_REPEATER_ON); + SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM); break; } case 0x1: { - SetBlockPowered(a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XP, E_BLOCK_REDSTONE_REPEATER_ON); + SetBlockPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP); break; } case 0x2: { - SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZP, E_BLOCK_REDSTONE_REPEATER_ON); + SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP); break; } case 0x3: { - SetBlockPowered(a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON); - SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XM, E_BLOCK_REDSTONE_REPEATER_ON); + SetBlockPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM); break; } } @@ -724,7 +755,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_B { if (IsOn) { - m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta); + m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta); } m_RepeatersDelayList->erase(itr); // We can remove off repeaters which don't need further updating return; @@ -735,7 +766,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_B // Apparently, incrementing ticks only works reliably here, and not in SimChunk; // With a world with lots of redstone, the repeaters simply do not delay // I am confounded to say why. Perhaps optimisation failure. - LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z, itr->a_ElapsedTicks, itr->a_DelayTicks); + LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", itr->a_RelBlockPos.x, itr->a_RelBlockPos.y, itr->a_RelBlockPos.z, itr->a_ElapsedTicks, itr->a_DelayTicks); itr->a_ElapsedTicks++; } } @@ -745,16 +776,19 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_B -void cIncrementalRedstoneSimulator::HandlePiston(int a_BlockX, int a_BlockY, int a_BlockZ) +void cIncrementalRedstoneSimulator::HandlePiston(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { cPiston Piston(&m_World); - if (IsPistonPowered(a_BlockX, a_BlockY, a_BlockZ, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x7)) // We only want the bottom three bits (4th controls extended-ness) + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + + if (IsPistonPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x7)) // We only want the bottom three bits (4th controls extended-ness) { - Piston.ExtendPiston(a_BlockX, a_BlockY, a_BlockZ); + Piston.ExtendPiston(BlockX, a_RelBlockY, BlockZ); } else { - Piston.RetractPiston(a_BlockX, a_BlockY, a_BlockZ); + Piston.RetractPiston(BlockX, a_RelBlockY, BlockZ); } } @@ -762,7 +796,7 @@ void cIncrementalRedstoneSimulator::HandlePiston(int a_BlockX, int a_BlockY, int -void cIncrementalRedstoneSimulator::HandleDropSpenser(int a_BlockX, int a_BlockY, int a_BlockZ) +void cIncrementalRedstoneSimulator::HandleDropSpenser(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { class cSetPowerToDropSpenser : public cDropSpenserCallback @@ -776,29 +810,31 @@ void cIncrementalRedstoneSimulator::HandleDropSpenser(int a_BlockX, int a_BlockY a_DropSpenser->SetRedstonePower(m_IsPowered); return false; } - } DrSpSP (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ)); + } DrSpSP (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ)); - m_World.DoWithDropSpenserAt(a_BlockX, a_BlockY, a_BlockZ, DrSpSP); + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + m_Chunk->DoWithDropSpenserAt(BlockX, a_RelBlockY, BlockZ, DrSpSP); } -void cIncrementalRedstoneSimulator::HandleRedstoneLamp(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyState) +void cIncrementalRedstoneSimulator::HandleRedstoneLamp(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState) { if (a_MyState == E_BLOCK_REDSTONE_LAMP_OFF) { - if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ)) + if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) { - m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_LAMP_ON, 0); + m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_LAMP_ON, 0); } } else { - if (!AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ)) + if (!AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) { - m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_LAMP_OFF, 0); + m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_LAMP_OFF, 0); } } } @@ -807,13 +843,16 @@ void cIncrementalRedstoneSimulator::HandleRedstoneLamp(int a_BlockX, int a_Block -void cIncrementalRedstoneSimulator::HandleTNT(int a_BlockX, int a_BlockY, int a_BlockZ) +void cIncrementalRedstoneSimulator::HandleTNT(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ)) + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + + if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) { - m_World.BroadcastSoundEffect("game.tnt.primed", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f); - m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); - m_World.SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5); // 80 ticks to boom + m_Chunk->BroadcastSoundEffect("game.tnt.primed", BlockX * 8, a_RelBlockY * 8, BlockZ * 8, 0.5f, 0.6f); + m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_AIR, 0); + m_World.SpawnPrimedTNT(BlockX + 0.5, a_RelBlockY + 0.5, BlockZ + 0.5); // 80 ticks to boom } } @@ -821,26 +860,29 @@ void cIncrementalRedstoneSimulator::HandleTNT(int a_BlockX, int a_BlockY, int a_ -void cIncrementalRedstoneSimulator::HandleDoor(int a_BlockX, int a_BlockY, int a_BlockZ) +void cIncrementalRedstoneSimulator::HandleDoor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ)) + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + + if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) { - if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, true)) + if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true)) { cChunkInterface ChunkInterface(m_World.GetChunkMap()); - cBlockDoorHandler::ChangeDoor(ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); - m_World.BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0); - SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, true); + cBlockDoorHandler::ChangeDoor(ChunkInterface, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true); } } else { - if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, false)) + if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false)) { cChunkInterface ChunkInterface(m_World.GetChunkMap()); - cBlockDoorHandler::ChangeDoor(ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); - m_World.BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0); - SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, false); + cBlockDoorHandler::ChangeDoor(ChunkInterface, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false); } } } @@ -849,7 +891,7 @@ void cIncrementalRedstoneSimulator::HandleDoor(int a_BlockX, int a_BlockY, int a -void cIncrementalRedstoneSimulator::HandleCommandBlock(int a_BlockX, int a_BlockY, int a_BlockZ) +void cIncrementalRedstoneSimulator::HandleCommandBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { class cSetPowerToCommandBlock : public cCommandBlockCallback @@ -863,37 +905,39 @@ void cIncrementalRedstoneSimulator::HandleCommandBlock(int a_BlockX, int a_Block a_CommandBlock->SetRedstonePower(m_IsPowered); return false; } - } CmdBlockSP (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ)); + } CmdBlockSP (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ)); - m_World.DoWithCommandBlockAt(a_BlockX, a_BlockY, a_BlockZ, CmdBlockSP); + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + m_Chunk->DoWithCommandBlockAt(BlockX, a_RelBlockY, BlockZ, CmdBlockSP); } -void cIncrementalRedstoneSimulator::HandleRail(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyType) +void cIncrementalRedstoneSimulator::HandleRail(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyType) { switch (a_MyType) { case E_BLOCK_DETECTOR_RAIL: { - if ((m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x08) == 0x08) + if ((m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x08) == 0x08) { - SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType); + SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_MyType); } break; } case E_BLOCK_ACTIVATOR_RAIL: case E_BLOCK_POWERED_RAIL: { - if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ)) + if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) { - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) | 0x08); + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) | 0x08); } else { - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x07); + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x07); } break; } @@ -905,22 +949,25 @@ void cIncrementalRedstoneSimulator::HandleRail(int a_BlockX, int a_BlockY, int a -void cIncrementalRedstoneSimulator::HandleTrapdoor(int a_BlockX, int a_BlockY, int a_BlockZ) +void cIncrementalRedstoneSimulator::HandleTrapdoor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ)) + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + + if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) { - if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, true)) + if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true)) { - m_World.SetTrapdoorOpen(a_BlockX, a_BlockY, a_BlockZ, true); - SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, true); + m_World.SetTrapdoorOpen(BlockX, a_RelBlockY, BlockZ, true); + SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true); } } else { - if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, false)) + if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false)) { - m_World.SetTrapdoorOpen(a_BlockX, a_BlockY, a_BlockZ, false); - SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, false); + m_World.SetTrapdoorOpen(BlockX, a_RelBlockY, BlockZ, false); + SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false); } } } @@ -929,13 +976,13 @@ void cIncrementalRedstoneSimulator::HandleTrapdoor(int a_BlockX, int a_BlockY, i -void cIncrementalRedstoneSimulator::HandleNoteBlock(int a_BlockX, int a_BlockY, int a_BlockZ) +void cIncrementalRedstoneSimulator::HandleNoteBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - bool m_bAreCoordsPowered = AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ); + bool m_bAreCoordsPowered = AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); if (m_bAreCoordsPowered) { - if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, true)) + if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true)) { class cSetPowerToNoteBlock : public cNoteBlockCallback @@ -954,15 +1001,17 @@ void cIncrementalRedstoneSimulator::HandleNoteBlock(int a_BlockX, int a_BlockY, } } NoteBlockSP(m_bAreCoordsPowered); - m_World.DoWithNoteBlockAt(a_BlockX, a_BlockY, a_BlockZ, NoteBlockSP); - SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, true); + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + m_Chunk->DoWithNoteBlockAt(BlockX, a_RelBlockY, BlockZ, NoteBlockSP); + SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true); } } else { - if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, false)) + if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false)) { - SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, false); + SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false); } } } @@ -971,10 +1020,10 @@ void cIncrementalRedstoneSimulator::HandleNoteBlock(int a_BlockX, int a_BlockY, -void cIncrementalRedstoneSimulator::HandleDaylightSensor(int a_BlockX, int a_BlockY, int a_BlockZ) +void cIncrementalRedstoneSimulator::HandleDaylightSensor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { int a_ChunkX, a_ChunkZ; - cChunkDef::BlockToChunk(a_BlockX, a_BlockZ, a_ChunkX, a_ChunkZ); + cChunkDef::BlockToChunk(a_RelBlockX, a_RelBlockZ, a_ChunkX, a_ChunkZ); if (!m_World.IsChunkLighted(a_ChunkX, a_ChunkZ)) { @@ -982,10 +1031,12 @@ void cIncrementalRedstoneSimulator::HandleDaylightSensor(int a_BlockX, int a_Blo } else { - NIBBLETYPE SkyLight = m_World.GetBlockSkyLight(a_BlockX, a_BlockY + 1, a_BlockZ) - m_World.GetSkyDarkness(); + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + NIBBLETYPE SkyLight = m_Chunk->GetTimeAlteredLight(m_World.GetBlockSkyLight(BlockX, a_RelBlockY + 1, BlockZ)); if (SkyLight > 8) { - SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_DAYLIGHT_SENSOR); + SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); } } } @@ -994,24 +1045,27 @@ void cIncrementalRedstoneSimulator::HandleDaylightSensor(int a_BlockX, int a_Blo -void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyType) +void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyType) { + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + switch (a_MyType) { case E_BLOCK_STONE_PRESSURE_PLATE: { // MCS feature - stone pressure plates can only be triggered by players :D - cPlayer * a_Player = m_World.FindClosestPlayer(Vector3f(a_BlockX + 0.5f, (float)a_BlockY, a_BlockZ + 0.5f), 0.5f, false); + cPlayer * a_Player = m_World.FindClosestPlayer(Vector3f(BlockX + 0.5f, (float)a_RelBlockY, BlockZ + 0.5f), 0.5f, false); if (a_Player != NULL) { - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0x1); - SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_STONE_PRESSURE_PLATE); + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x1); + SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); } else { - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0x0); - m_World.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ); + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x0); + m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ); } break; } @@ -1056,95 +1110,96 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc int m_Z; }; - cPressurePlateCallback PressurePlateCallback(a_BlockX, a_BlockY, a_BlockZ); + cPressurePlateCallback PressurePlateCallback(BlockX, a_RelBlockY, BlockZ); m_World.ForEachEntity(PressurePlateCallback); unsigned char Power; - NIBBLETYPE Meta = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); + NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); if (PressurePlateCallback.GetPowerLevel(Power)) { if (Meta == E_META_PRESSURE_PLATE_RAISED) { - m_World.BroadcastSoundEffect("random.click", (int)((a_BlockX + 0.5) * 8.0), (int)((a_BlockY + 0.1) * 8.0), (int)((a_BlockZ + 0.5) * 8.0), 0.3F, 0.5F); + m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.5F); } - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_DEPRESSED); - SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType, Power); + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED); + SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Power); } else { if (Meta == E_META_PRESSURE_PLATE_DEPRESSED) { - m_World.BroadcastSoundEffect("random.click", (int)((a_BlockX + 0.5) * 8.0), (int)((a_BlockY + 0.1) * 8.0), (int)((a_BlockZ + 0.5) * 8.0), 0.3F, 0.6F); + m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); } - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_RAISED); - m_World.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ); + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); + m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ); } break; } case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: - {class cPressurePlateCallback : - public cEntityCallback { - public: - cPressurePlateCallback(int a_BlockX, int a_BlockY, int a_BlockZ) : - m_NumberOfEntities(0), - m_X(a_BlockX), - m_Y(a_BlockY), - m_Z(a_BlockZ) - { - } - - virtual bool Item(cEntity * a_Entity) override + class cPressurePlateCallback : + public cEntityCallback { - Vector3f EntityPos = a_Entity->GetPosition(); - Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f); - double Distance = (EntityPos - BlockPos).Length(); + public: + cPressurePlateCallback(int a_BlockX, int a_BlockY, int a_BlockZ) : + m_NumberOfEntities(0), + m_X(a_BlockX), + m_Y(a_BlockY), + m_Z(a_BlockZ) + { + } - if (Distance <= 0.7) + virtual bool Item(cEntity * a_Entity) override { - m_NumberOfEntities++; + Vector3f EntityPos = a_Entity->GetPosition(); + Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f); + double Distance = (EntityPos - BlockPos).Length(); + + if (Distance <= 0.7) + { + m_NumberOfEntities++; + } + return false; } - return false; - } - bool GetPowerLevel(unsigned char & a_PowerLevel) const - { - a_PowerLevel = std::min((int)ceil(m_NumberOfEntities / (float)10), MAX_POWER_LEVEL); - return (a_PowerLevel > 0); - } + bool GetPowerLevel(unsigned char & a_PowerLevel) const + { + a_PowerLevel = std::min((int)ceil(m_NumberOfEntities / (float)10), MAX_POWER_LEVEL); + return (a_PowerLevel > 0); + } - protected: - int m_NumberOfEntities; + protected: + int m_NumberOfEntities; - int m_X; - int m_Y; - int m_Z; - }; + int m_X; + int m_Y; + int m_Z; + }; - cPressurePlateCallback PressurePlateCallback(a_BlockX, a_BlockY, a_BlockZ); - m_World.ForEachEntity(PressurePlateCallback); + cPressurePlateCallback PressurePlateCallback(BlockX, a_RelBlockY, BlockZ); + m_World.ForEachEntity(PressurePlateCallback); - unsigned char Power; - NIBBLETYPE Meta = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - if (PressurePlateCallback.GetPowerLevel(Power)) - { - if (Meta == E_META_PRESSURE_PLATE_RAISED) + unsigned char Power; + NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); + if (PressurePlateCallback.GetPowerLevel(Power)) { - m_World.BroadcastSoundEffect("random.click", (int)((a_BlockX + 0.5) * 8.0), (int)((a_BlockY + 0.1) * 8.0), (int)((a_BlockZ + 0.5) * 8.0), 0.3F, 0.5F); + if (Meta == E_META_PRESSURE_PLATE_RAISED) + { + m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.5F); + } + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED); + SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Power); } - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_DEPRESSED); - SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType, Power); - } - else - { - if (Meta == E_META_PRESSURE_PLATE_DEPRESSED) + else { - m_World.BroadcastSoundEffect("random.click", (int)((a_BlockX + 0.5) * 8.0), (int)((a_BlockY + 0.1) * 8.0), (int)((a_BlockZ + 0.5) * 8.0), 0.3F, 0.6F); + if (Meta == E_META_PRESSURE_PLATE_DEPRESSED) + { + m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); + } + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); + m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ); } - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_RAISED); - m_World.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ); - } break; } @@ -1155,7 +1210,6 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc { public: cPressurePlateCallback(int a_BlockX, int a_BlockY, int a_BlockZ) : - m_FoundEntity(false), m_X(a_BlockX), m_Y(a_BlockY), m_Z(a_BlockZ) @@ -1189,27 +1243,27 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc int m_Z; } ; - cPressurePlateCallback PressurePlateCallback(a_BlockX, a_BlockY, a_BlockZ); + cPressurePlateCallback PressurePlateCallback(BlockX, a_RelBlockY, BlockZ); m_World.ForEachEntity(PressurePlateCallback); - NIBBLETYPE Meta = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); + NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); if (PressurePlateCallback.FoundEntity()) { if (Meta == E_META_PRESSURE_PLATE_RAISED) { - m_World.BroadcastSoundEffect("random.click", (int) ((a_BlockX + 0.5) * 8.0), (int) ((a_BlockY + 0.1) * 8.0), (int) ((a_BlockZ + 0.5) * 8.0), 0.3F, 0.5F); + m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.5F); } - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_DEPRESSED); - SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType); + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED); + SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); } else { if (Meta == E_META_PRESSURE_PLATE_DEPRESSED) { - m_World.BroadcastSoundEffect("random.click", (int) ((a_BlockX + 0.5) * 8.0), (int) ((a_BlockY + 0.1) * 8.0), (int) ((a_BlockZ + 0.5) * 8.0), 0.3F, 0.6F); + m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); } - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_RAISED); - m_World.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ); + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); + m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ); } break; } @@ -1225,11 +1279,15 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc -bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_BlockX, int a_BlockY, int a_BlockZ) +bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + + PoweredBlocksList * Powered = m_Chunk->GetNeighborChunk(BlockX, BlockZ)->GetRedstoneSimulatorPoweredBlocksList(); // Torches want to access neighbour's data when on a wall + for (PoweredBlocksList::const_iterator itr = Powered->begin(); itr != Powered->end(); ++itr) // Check powered list { - if (itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + if (itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { return true; } @@ -1241,11 +1299,14 @@ bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_BlockX, int a -bool cIncrementalRedstoneSimulator::AreCoordsLinkedPowered(int a_BlockX, int a_BlockY, int a_BlockZ) +bool cIncrementalRedstoneSimulator::AreCoordsLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list { - if (itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + if (itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { return true; } @@ -1258,35 +1319,37 @@ bool cIncrementalRedstoneSimulator::AreCoordsLinkedPowered(int a_BlockX, int a_B // IsRepeaterPowered tests if a repeater should be powered by testing for power sources behind the repeater. // It takes the coordinates of the repeater the the meta value. -bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta) +bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta) { // Repeaters cannot be powered by any face except their back; verify that this is true for a source + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) { - if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; } + if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; } switch (a_Meta & 0x3) { case 0x0: { // Flip the coords to check the back of the repeater - if (itr->a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ + 1))) { return true; } + if (itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ + 1))) { return true; } break; } case 0x1: { - if (itr->a_SourcePos.Equals(Vector3i(a_BlockX - 1, a_BlockY, a_BlockZ))) { return true; } + if (itr->a_SourcePos.Equals(Vector3i(BlockX - 1, a_RelBlockY, BlockZ))) { return true; } break; } case 0x2: { - if (itr->a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ - 1))) { return true; } + if (itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ - 1))) { return true; } break; } case 0x3: { - if (itr->a_SourcePos.Equals(Vector3i(a_BlockX + 1, a_BlockY, a_BlockZ))) { return true; } + if (itr->a_SourcePos.Equals(Vector3i(BlockX + 1, a_RelBlockY, BlockZ))) { return true; } break; } } @@ -1294,28 +1357,28 @@ bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_BlockX, int a_BlockY for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) { - if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; } + if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; } switch (a_Meta & 0x3) { case 0x0: { - if (itr->a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ + 1))) { return true; } + if (itr->a_MiddlePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ + 1))) { return true; } break; } case 0x1: { - if (itr->a_MiddlePos.Equals(Vector3i(a_BlockX - 1, a_BlockY, a_BlockZ))) { return true; } + if (itr->a_MiddlePos.Equals(Vector3i(BlockX - 1, a_RelBlockY, BlockZ))) { return true; } break; } case 0x2: { - if (itr->a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ - 1))) { return true; } + if (itr->a_MiddlePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ - 1))) { return true; } break; } case 0x3: { - if (itr->a_MiddlePos.Equals(Vector3i(a_BlockX + 1, a_BlockY, a_BlockZ))) { return true; } + if (itr->a_MiddlePos.Equals(Vector3i(BlockX + 1, a_RelBlockY, BlockZ))) { return true; } break; } } @@ -1327,7 +1390,7 @@ bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_BlockX, int a_BlockY -bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta) +bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta) { switch (a_Meta & 0x3) // We only want the 'direction' part of our metadata { @@ -1336,16 +1399,17 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_BlockX, int a_BlockY, case 0x2: { // Check if eastern(right) neighbor is a powered on repeater who is facing us. - if (m_World.GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ) == E_BLOCK_REDSTONE_REPEATER_ON) // Is right neighbor a powered repeater? + BLOCKTYPE Block = 0; + if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) // Is right neighbor a powered repeater? { - NIBBLETYPE OtherRepeaterDir = m_World.GetBlockMeta(a_BlockX + 1, a_BlockY, a_BlockZ) & 0x3; + NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ) & 0x3; if (OtherRepeaterDir == 0x3) { return true; } // If so, I am latched/locked. } // Check if western(left) neighbor is a powered on repeater who is facing us. - if (m_World.GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ) == E_BLOCK_REDSTONE_REPEATER_ON) + if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) { - NIBBLETYPE OtherRepeaterDir = m_World.GetBlockMeta(a_BlockX -1, a_BlockY, a_BlockZ) & 0x3; + NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX -1, a_RelBlockY, a_RelBlockZ) & 0x3; if (OtherRepeaterDir == 0x1) { return true; } // If so, I am latched/locked. } @@ -1357,16 +1421,17 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_BlockX, int a_BlockY, case 0x3: { // Check if southern(down) neighbor is a powered on repeater who is facing us. - if (m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1) == E_BLOCK_REDSTONE_REPEATER_ON) + BLOCKTYPE Block = 0; + if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) { - NIBBLETYPE OtherRepeaterDir = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ + 1) & 0x3; + NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1) & 0x3; if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked. } // Check if northern(up) neighbor is a powered on repeater who is facing us. - if (m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ -1) == E_BLOCK_REDSTONE_REPEATER_ON) + if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) { - NIBBLETYPE OtherRepeaterDir = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ - 1) & 0x3; + NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1) & 0x3; if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked. } @@ -1380,43 +1445,45 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_BlockX, int a_BlockY, -bool cIncrementalRedstoneSimulator::IsPistonPowered(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta) +bool cIncrementalRedstoneSimulator::IsPistonPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta) { // Pistons cannot be powered through their front face; this function verifies that a source meets this requirement - int OldX = a_BlockX, OldY = a_BlockY, OldZ = a_BlockZ; + int OldX = a_RelBlockX, OldY = a_RelBlockY, OldZ = a_RelBlockZ; eBlockFace Face = cPiston::MetaDataToDirection(a_Meta); + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) { - if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; } + if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; } - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face); + AddFaceDirection(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Face); - if (!itr->a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + if (!itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { return true; } - a_BlockX = OldX; - a_BlockY = OldY; - a_BlockZ = OldZ; + a_RelBlockX = OldX; + a_RelBlockY = OldY; + a_RelBlockZ = OldZ; } for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) { - if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; } + if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; } - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face); + AddFaceDirection(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Face); - if (!itr->a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + if (!itr->a_MiddlePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { return true; } - a_BlockX = OldX; - a_BlockY = OldY; - a_BlockZ = OldZ; + a_RelBlockX = OldX; + a_RelBlockY = OldY; + a_RelBlockZ = OldZ; } return false; // Source was in front of the piston's front face } @@ -1424,13 +1491,15 @@ bool cIncrementalRedstoneSimulator::IsPistonPowered(int a_BlockX, int a_BlockY, -bool cIncrementalRedstoneSimulator::IsWirePowered(int a_BlockX, int a_BlockY, int a_BlockZ, unsigned char & a_PowerLevel) +bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char & a_PowerLevel) { a_PowerLevel = 0; + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list { - if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; } @@ -1439,7 +1508,7 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_BlockX, int a_BlockY, in for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list { - if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; } @@ -1453,11 +1522,11 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_BlockX, int a_BlockY, in -bool cIncrementalRedstoneSimulator::AreCoordsSimulated(int a_BlockX, int a_BlockY, int a_BlockZ, bool IsCurrentStatePowered) +bool cIncrementalRedstoneSimulator::AreCoordsSimulated(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, bool IsCurrentStatePowered) { for (SimulatedPlayerToggleableList::const_iterator itr = m_SimulatedPlayerToggleableBlocks->begin(); itr != m_SimulatedPlayerToggleableBlocks->end(); ++itr) { - if (itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + if (itr->a_RelBlockPos.Equals(Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) { if (itr->WasLastStatePowered != IsCurrentStatePowered) // Was the last power state different to the current? { @@ -1476,79 +1545,98 @@ bool cIncrementalRedstoneSimulator::AreCoordsSimulated(int a_BlockX, int a_Block -void cIncrementalRedstoneSimulator::SetDirectionLinkedPowered(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Direction, BLOCKTYPE a_SourceType, unsigned char a_PowerLevel) +void cIncrementalRedstoneSimulator::SetDirectionLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, char a_Direction, unsigned char a_PowerLevel) { + BLOCKTYPE MiddleBlock = 0; switch (a_Direction) { case BLOCK_FACE_XM: { - BLOCKTYPE MiddleBlock = m_World.GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ); + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, MiddleBlock)) + { + return; + } - SetBlockLinkedPowered(a_BlockX - 2, a_BlockY, a_BlockZ, a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX - 1, a_BlockY + 1, a_BlockZ, a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX - 1, a_BlockY - 1, a_BlockZ, a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX - 1, a_BlockY, a_BlockZ + 1, a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX - 1, a_BlockY, a_BlockZ - 1, a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX - 2, a_RelBlockY, a_RelBlockZ, a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); break; } case BLOCK_FACE_XP: { - BLOCKTYPE MiddleBlock = m_World.GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ); + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, MiddleBlock)) + { + return; + } - SetBlockLinkedPowered(a_BlockX + 2, a_BlockY, a_BlockZ, a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX + 1, a_BlockY + 1, a_BlockZ, a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX + 1, a_BlockY - 1, a_BlockZ, a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX + 1, a_BlockY, a_BlockZ + 1, a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX + 1, a_BlockY, a_BlockZ - 1, a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX + 2, a_RelBlockY, a_RelBlockZ, a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); break; } case BLOCK_FACE_YM: { - BLOCKTYPE MiddleBlock = m_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ); + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, MiddleBlock)) + { + return; + } - SetBlockLinkedPowered(a_BlockX, a_BlockY - 2, a_BlockZ, a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX + 1, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX - 1, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX, a_BlockY - 1, a_BlockZ + 1, a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX, a_BlockY - 1, a_BlockZ - 1, a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY - 2, a_RelBlockZ, a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); break; } case BLOCK_FACE_YP: { - BLOCKTYPE MiddleBlock = m_World.GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ); + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, MiddleBlock)) + { + return; + } - SetBlockLinkedPowered(a_BlockX, a_BlockY + 2, a_BlockZ, a_BlockX, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX + 1, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX - 1, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX, a_BlockY + 1, a_BlockZ + 1, a_BlockX, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX, a_BlockY + 1, a_BlockZ - 1, a_BlockX, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY + 2, a_RelBlockZ, a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); break; } case BLOCK_FACE_ZM: { - BLOCKTYPE MiddleBlock = m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ - 1); + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, MiddleBlock)) + { + return; + } - SetBlockLinkedPowered(a_BlockX, a_BlockY, a_BlockZ - 2, a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX + 1, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX - 1, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX, a_BlockY + 1, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX, a_BlockY - 1, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 2, a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); break; } case BLOCK_FACE_ZP: { - BLOCKTYPE MiddleBlock = m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1); + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, MiddleBlock)) + { + return; + } - SetBlockLinkedPowered(a_BlockX, a_BlockY, a_BlockZ + 2, a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX + 1, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX - 1, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX, a_BlockY + 1, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); - SetBlockLinkedPowered(a_BlockX, a_BlockY - 1, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 2, a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); + SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel); break; } @@ -1564,7 +1652,7 @@ void cIncrementalRedstoneSimulator::SetDirectionLinkedPowered(int a_BlockX, int -void cIncrementalRedstoneSimulator::SetAllDirsAsPowered(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_SourceBlock, unsigned char a_PowerLevel) +void cIncrementalRedstoneSimulator::SetAllDirsAsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char a_PowerLevel) { static const struct { @@ -1572,16 +1660,16 @@ void cIncrementalRedstoneSimulator::SetAllDirsAsPowered(int a_BlockX, int a_Bloc } gCrossCoords[] = { { 1, 0, 0 }, - {-1, 0, 0 }, + { -1, 0, 0 }, { 0, 0, 1 }, - { 0, 0,-1 }, + { 0, 0, -1 }, { 0, 1, 0 }, - { 0,-1, 0 } + { 0, -1, 0 } }; for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) // Loop through struct to power all directions { - SetBlockPowered(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z, a_BlockX, a_BlockY, a_BlockZ, a_SourceBlock, a_PowerLevel); + SetBlockPowered(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_PowerLevel); } } @@ -1589,39 +1677,45 @@ void cIncrementalRedstoneSimulator::SetAllDirsAsPowered(int a_BlockX, int a_Bloc -void cIncrementalRedstoneSimulator::SetBlockPowered(int a_BlockX, int a_BlockY, int a_BlockZ, int a_SourceX, int a_SourceY, int a_SourceZ, BLOCKTYPE a_SourceBlock, unsigned char a_PowerLevel) +void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, unsigned char a_PowerLevel) { - BLOCKTYPE Block = m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ); + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + int SourceX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelSourceX; + int SourceZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelSourceZ; + + BLOCKTYPE Block = 0; + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Block)) + { + return; + } if (Block == E_BLOCK_AIR) { // Don't set air, fixes some bugs (wires powering themselves) return; } - PoweredBlocksList * Powered = m_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ)->GetRedstoneSimulatorPoweredBlocksList(); + PoweredBlocksList * Powered = m_Chunk->GetNeighborChunk(BlockX, BlockZ)->GetRedstoneSimulatorPoweredBlocksList(); for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr) // Check powered list { if ( - itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)) && - itr->a_SourcePos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ)) - ) + itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)) && + itr->a_SourcePos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ)) + ) { - // Check for duplicates, update power level if everything else the same but either way, don't add a new listing - if (itr->a_PowerLevel != a_PowerLevel) - { - itr->a_PowerLevel = a_PowerLevel; - } + // Check for duplicates, update power level, don't add a new listing + itr->a_PowerLevel = a_PowerLevel; return; } } - PoweredBlocksList * OtherPowered = m_Chunk->GetNeighborChunk(a_SourceX, a_SourceZ)->GetRedstoneSimulatorPoweredBlocksList(); + PoweredBlocksList * OtherPowered = m_Chunk->GetNeighborChunk(SourceX, SourceZ)->GetRedstoneSimulatorPoweredBlocksList(); for (PoweredBlocksList::const_iterator itr = OtherPowered->begin(); itr != OtherPowered->end(); ++itr) // Check powered list { if ( - itr->a_BlockPos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ)) && - itr->a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)) - ) + itr->a_BlockPos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ)) && + itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)) + ) { // Powered wires try to power their source - don't let them! return; @@ -1629,8 +1723,8 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_BlockX, int a_BlockY, } sPoweredBlocks RC; - RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ); - RC.a_SourcePos = Vector3i(a_SourceX, a_SourceY, a_SourceZ); + RC.a_BlockPos = Vector3i(BlockX, a_RelBlockY, BlockZ); + RC.a_SourcePos = Vector3i(SourceX, a_RelSourceY, SourceZ); RC.a_PowerLevel = a_PowerLevel; Powered->push_back(RC); } @@ -1640,45 +1734,57 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_BlockX, int a_BlockY, void cIncrementalRedstoneSimulator::SetBlockLinkedPowered( - int a_BlockX, int a_BlockY, int a_BlockZ, - int a_MiddleX, int a_MiddleY, int a_MiddleZ, - int a_SourceX, int a_SourceY, int a_SourceZ, - BLOCKTYPE a_SourceBlock, BLOCKTYPE a_MiddleBlock, unsigned char a_PowerLevel -) + int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, + int a_RelMiddleX, int a_RelMiddleY, int a_RelMiddleZ, + int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, + BLOCKTYPE a_MiddleBlock, unsigned char a_PowerLevel + ) { - BLOCKTYPE DestBlock = m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ); + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; + int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + int MiddleX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelMiddleX; + int MiddleZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelMiddleZ; + int SourceX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelSourceX; + int SourceZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelSourceZ; + + BLOCKTYPE DestBlock = 0; + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ, DestBlock)) + { + return; + } if (DestBlock == E_BLOCK_AIR) { // Don't set air, fixes some bugs (wires powering themselves) return; } + if ((DestBlock == E_BLOCK_REDSTONE_WIRE) && (m_Chunk->GetBlock(a_RelSourceX, a_RelSourceY, a_RelSourceZ) == E_BLOCK_REDSTONE_WIRE)) + { + return; + } if (!IsViableMiddleBlock(a_MiddleBlock)) { return; } - LinkedBlocksList * Linked = m_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ)->GetRedstoneSimulatorLinkedBlocksList(); + LinkedBlocksList * Linked = m_Chunk->GetNeighborChunk(BlockX, BlockZ)->GetRedstoneSimulatorLinkedBlocksList(); for (LinkedBlocksList::iterator itr = Linked->begin(); itr != Linked->end(); ++itr) // Check linked powered list { if ( - itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)) && - itr->a_MiddlePos.Equals(Vector3i(a_MiddleX, a_MiddleY, a_MiddleZ)) && - itr->a_SourcePos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ)) + itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)) && + itr->a_MiddlePos.Equals(Vector3i(MiddleX, a_RelMiddleY, MiddleZ)) && + itr->a_SourcePos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ)) ) { - // Check for duplicates, update power level if everything else the same but either way, don't add a new listing - if (itr->a_PowerLevel != a_PowerLevel) - { - itr->a_PowerLevel = a_PowerLevel; - } + // Check for duplicates, update power level, don't add a new listing + itr->a_PowerLevel = a_PowerLevel; return; } } sLinkedPoweredBlocks RC; - RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ); - RC.a_MiddlePos = Vector3i(a_MiddleX, a_MiddleY, a_MiddleZ); - RC.a_SourcePos = Vector3i(a_SourceX, a_SourceY, a_SourceZ); + RC.a_BlockPos = Vector3i(BlockX, a_RelBlockY, BlockZ); + RC.a_MiddlePos = Vector3i(MiddleX, a_RelMiddleY, MiddleZ); + RC.a_SourcePos = Vector3i(SourceX, a_RelSourceY, SourceZ); RC.a_PowerLevel = a_PowerLevel; Linked->push_back(RC); } @@ -1687,11 +1793,11 @@ void cIncrementalRedstoneSimulator::SetBlockLinkedPowered( -void cIncrementalRedstoneSimulator::SetPlayerToggleableBlockAsSimulated(int a_BlockX, int a_BlockY, int a_BlockZ, bool WasLastStatePowered) +void cIncrementalRedstoneSimulator::SetPlayerToggleableBlockAsSimulated(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, bool WasLastStatePowered) { for (SimulatedPlayerToggleableList::iterator itr = m_SimulatedPlayerToggleableBlocks->begin(); itr != m_SimulatedPlayerToggleableBlocks->end(); ++itr) { - if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + if (!itr->a_RelBlockPos.Equals(Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) { continue; } @@ -1711,7 +1817,7 @@ void cIncrementalRedstoneSimulator::SetPlayerToggleableBlockAsSimulated(int a_Bl // We have arrive here; no block must be in list - add one sSimulatedPlayerToggleableList RC; - RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ); + RC.a_RelBlockPos = Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ); RC.WasLastStatePowered = WasLastStatePowered; m_SimulatedPlayerToggleableBlocks->push_back(RC); } @@ -1720,11 +1826,11 @@ void cIncrementalRedstoneSimulator::SetPlayerToggleableBlockAsSimulated(int a_Bl -void cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn) +void cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn) { for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end(); ++itr) { - if (itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + if (itr->a_RelBlockPos.Equals(Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) { if (ShouldPowerOn == itr->ShouldPowerOn) // We are queued already for the same thing, don't replace entry { @@ -1741,7 +1847,7 @@ void cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_BlockX, int a // Self not in list, add self to list sRepeatersDelayList RC; - RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ); + RC.a_RelBlockPos = Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ); // Gets the top two bits (delay time), shifts them into the lower two bits, and adds one (meta 0 = 1 tick; 1 = 2 etc.) // * 2 because in MCS, 1 redstone tick = 1 world tick, but in Vanilla, 1 redstone tick = 2 world ticks, and we need to maintain compatibility @@ -1757,52 +1863,64 @@ void cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_BlockX, int a -cIncrementalRedstoneSimulator::eRedstoneDirection cIncrementalRedstoneSimulator::GetWireDirection(int a_BlockX, int a_BlockY, int a_BlockZ) +cIncrementalRedstoneSimulator::eRedstoneDirection cIncrementalRedstoneSimulator::GetWireDirection(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { int Dir = REDSTONE_NONE; - BLOCKTYPE NegX = m_World.GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ); - if (IsPotentialSource(NegX)) + BLOCKTYPE NegX = 0; + if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, NegX)) { - Dir |= (REDSTONE_X_POS); + if (IsPotentialSource(NegX)) + { + Dir |= (REDSTONE_X_POS); + } } - BLOCKTYPE PosX = m_World.GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ); - if (IsPotentialSource(PosX)) + BLOCKTYPE PosX = 0; + if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, PosX)) { - Dir |= (REDSTONE_X_NEG); + if (IsPotentialSource(PosX)) + { + Dir |= (REDSTONE_X_NEG); + } } - BLOCKTYPE NegZ = m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ - 1); - if (IsPotentialSource(NegZ)) + BLOCKTYPE NegZ = 0; + if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, NegZ)) { - if ((Dir & REDSTONE_X_POS) && !(Dir & REDSTONE_X_NEG)) // corner + if (IsPotentialSource(NegZ)) { - Dir ^= REDSTONE_X_POS; - Dir |= REDSTONE_X_NEG; - } - if ((Dir & REDSTONE_X_NEG) && !(Dir & REDSTONE_X_POS)) // corner - { - Dir ^= REDSTONE_X_NEG; - Dir |= REDSTONE_X_POS; + if ((Dir & REDSTONE_X_POS) && !(Dir & REDSTONE_X_NEG)) // corner + { + Dir ^= REDSTONE_X_POS; + Dir |= REDSTONE_X_NEG; + } + if ((Dir & REDSTONE_X_NEG) && !(Dir & REDSTONE_X_POS)) // corner + { + Dir ^= REDSTONE_X_NEG; + Dir |= REDSTONE_X_POS; + } + Dir |= REDSTONE_Z_POS; } - Dir |= REDSTONE_Z_POS; } - BLOCKTYPE PosZ = m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1); - if (IsPotentialSource(PosZ)) + BLOCKTYPE PosZ = 0; + if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, PosZ)) { - if ((Dir & REDSTONE_X_POS) && !(Dir & REDSTONE_X_NEG)) // corner - { - Dir ^= REDSTONE_X_POS; - Dir |= REDSTONE_X_NEG; - } - if ((Dir & REDSTONE_X_NEG) && !(Dir & REDSTONE_X_POS)) // corner + if (IsPotentialSource(PosZ)) { - Dir ^= REDSTONE_X_NEG; - Dir |= REDSTONE_X_POS; + if ((Dir & REDSTONE_X_POS) && !(Dir & REDSTONE_X_NEG)) // corner + { + Dir ^= REDSTONE_X_POS; + Dir |= REDSTONE_X_NEG; + } + if ((Dir & REDSTONE_X_NEG) && !(Dir & REDSTONE_X_POS)) // corner + { + Dir ^= REDSTONE_X_NEG; + Dir |= REDSTONE_X_POS; + } + Dir |= REDSTONE_Z_NEG; } - Dir |= REDSTONE_Z_NEG; } return (eRedstoneDirection)Dir; } diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index a42cce79a..233a3d408 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -55,13 +55,13 @@ private: struct sSimulatedPlayerToggleableList // Define structure of the list containing simulate-on-update blocks (such as trapdoors that respond once to a block update, and can be toggled by a player) { - Vector3i a_BlockPos; + Vector3i a_RelBlockPos; bool WasLastStatePowered; // Was the last state powered or not? Determines whether a source update has happened and if I should resimulate }; struct sRepeatersDelayList // Define structure of list containing repeaters' delay states { - Vector3i a_BlockPos; + Vector3i a_RelBlockPos; unsigned char a_DelayTicks; // For how many ticks should the repeater delay unsigned char a_ElapsedTicks; // How much of the previous has been elapsed? bool ShouldPowerOn; // What happens when the delay time is fulfilled? @@ -91,80 +91,80 @@ private: /* ====== SOURCES ====== */ /** Handles the redstone torch */ - void HandleRedstoneTorch(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyState); + void HandleRedstoneTorch(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState); /** Handles the redstone block */ - void HandleRedstoneBlock(int a_BlockX, int a_BlockY, int a_BlockZ); + void HandleRedstoneBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles levers */ - void HandleRedstoneLever(int a_BlockX, int a_BlockY, int a_BlockZ); + void HandleRedstoneLever(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles buttons */ - void HandleRedstoneButton(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType); + void HandleRedstoneButton(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles daylight sensors */ - void HandleDaylightSensor(int a_BlockX, int a_BlockY, int a_BlockZ); + void HandleDaylightSensor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles pressure plates */ - void HandlePressurePlate(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyType); + void HandlePressurePlate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyType); /* ==================== */ /* ====== CARRIERS ====== */ /** Handles redstone wire */ - void HandleRedstoneWire(int a_BlockX, int a_BlockY, int a_BlockZ); + void HandleRedstoneWire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles repeaters */ - void HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyState); + void HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState); /* ====================== */ /* ====== DEVICES ====== */ /** Handles pistons */ - void HandlePiston(int a_BlockX, int a_BlockY, int a_BlockZ); + void HandlePiston(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles dispensers and droppers */ - void HandleDropSpenser(int a_BlockX, int a_BlockY, int a_BlockZ); + void HandleDropSpenser(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles TNT (exploding) */ - void HandleTNT(int a_BlockX, int a_BlockY, int a_BlockZ); + void HandleTNT(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles redstone lamps */ - void HandleRedstoneLamp(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyState); + void HandleRedstoneLamp(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState); /** Handles doords */ - void HandleDoor(int a_BlockX, int a_BlockY, int a_BlockZ); + void HandleDoor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles command blocks */ - void HandleCommandBlock(int a_BlockX, int a_BlockY, int a_BlockZ); + void HandleCommandBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles activator, detector, and powered rails */ - void HandleRail(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyType); + void HandleRail(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyType); /** Handles trapdoors */ - void HandleTrapdoor(int a_BlockX, int a_BlockY, int a_BlockZ); + void HandleTrapdoor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles fence gates */ - void HandleFenceGate(int a_BlockX, int a_BlockY, int a_BlockZ); + void HandleFenceGate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles noteblocks */ - void HandleNoteBlock(int a_BlockX, int a_BlockY, int a_BlockZ); + void HandleNoteBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /* ===================== */ /* ====== Helper functions ====== */ /** Marks a block as powered */ - void SetBlockPowered(int a_BlockX, int a_BlockY, int a_BlockZ, int a_SourceX, int a_SourceY, int a_SourceZ, BLOCKTYPE a_SourceBlock, unsigned char a_PowerLevel = MAX_POWER_LEVEL); + void SetBlockPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, unsigned char a_PowerLevel = MAX_POWER_LEVEL); /** Marks a block as being powered through another block */ - void SetBlockLinkedPowered(int a_BlockX, int a_BlockY, int a_BlockZ, int a_MiddleX, int a_MiddleY, int a_MiddleZ, int a_SourceX, int a_SourceY, int a_SourceZ, BLOCKTYPE a_SourceBlock, BLOCKTYPE a_MiddeBlock, unsigned char a_PowerLevel = MAX_POWER_LEVEL); + void SetBlockLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, int a_RelMiddleX, int a_RelMiddleY, int a_RelMiddleZ, int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, BLOCKTYPE a_MiddeBlock, unsigned char a_PowerLevel = MAX_POWER_LEVEL); /** Marks a block as simulated, who should not be simulated further unless their power state changes, to accomodate a player manually toggling the block without triggering the simulator toggling it back */ - void SetPlayerToggleableBlockAsSimulated(int a_BlockX, int a_BlockY, int a_BlockZ, bool WasLastStatePowered); + void SetPlayerToggleableBlockAsSimulated(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, bool WasLastStatePowered); /** Marks the second block in a direction as linked powered */ - void SetDirectionLinkedPowered(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Direction, BLOCKTYPE a_SourceBlock, unsigned char a_PowerLevel = MAX_POWER_LEVEL); + void SetDirectionLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, char a_Direction, unsigned char a_PowerLevel = MAX_POWER_LEVEL); /** Marks all blocks immediately surrounding a coordinate as powered */ - void SetAllDirsAsPowered(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_SourceBlock, unsigned char a_PowerLevel = MAX_POWER_LEVEL); + void SetAllDirsAsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char a_PowerLevel = MAX_POWER_LEVEL); /** Queues a repeater to be powered or unpowered */ - void QueueRepeaterPowerChange(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn); + void QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn); /** Returns if a coordinate is powered or linked powered */ - bool AreCoordsPowered(int a_BlockX, int a_BlockY, int a_BlockZ) { return AreCoordsDirectlyPowered(a_BlockX, a_BlockY, a_BlockZ) || AreCoordsLinkedPowered(a_BlockX, a_BlockY, a_BlockZ); } + bool AreCoordsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { return AreCoordsDirectlyPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ) || AreCoordsLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); } /** Returns if a coordinate is in the directly powered blocks list */ - bool AreCoordsDirectlyPowered(int a_BlockX, int a_BlockY, int a_BlockZ); + bool AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Returns if a coordinate is in the indirectly powered blocks list */ - bool AreCoordsLinkedPowered(int a_BlockX, int a_BlockY, int a_BlockZ); + bool AreCoordsLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Returns if a coordinate was marked as simulated (for blocks toggleable by players) */ - bool AreCoordsSimulated(int a_BlockX, int a_BlockY, int a_BlockZ, bool IsCurrentStatePowered); + bool AreCoordsSimulated(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, bool IsCurrentStatePowered); /** Returns if a repeater is powered */ - bool IsRepeaterPowered(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta); + bool IsRepeaterPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta); /** Returns if a repeater is locked */ - bool IsRepeaterLocked(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta); + bool IsRepeaterLocked(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta); /** Returns if a piston is powered */ - bool IsPistonPowered(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta); + bool IsPistonPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta); /** Returns if a wire is powered The only diffence between this and a normal AreCoordsPowered is that this function checks for a wire powering another wire */ - bool IsWirePowered(int a_BlockX, int a_BlockY, int a_BlockZ, unsigned char & a_PowerLevel); + bool IsWirePowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char & a_PowerLevel); /** Returns if lever metadata marks it as emitting power */ diff --git a/src/World.h b/src/World.h index f789916df..de0a257f9 100644 --- a/src/World.h +++ b/src/World.h @@ -351,7 +351,7 @@ public: /** Is the trapdoor open? Returns false if there is no trapdoor at the specified coords. */ bool IsTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export - /** Set the state of a trapdoor. Returns true if the trapdoor was update, false if there was no trapdoor at those coords. */ + /** Set the state of a trapdoor. Returns true if the trapdoor was updated, false if there was no trapdoor at those coords. */ bool SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open); // tolua_export /** Regenerate the given chunk: */ -- cgit v1.2.3 From 25d933883a24c97b67f90ae6839ce3d6b8d630d5 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 27 Apr 2014 13:07:21 -0700 Subject: Removed unneeded assert Fixed CID 43610 --- src/Generating/Prefab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index c0c9e8a13..44d5097de 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -283,7 +283,7 @@ void cPrefab::ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef) if ((NumElements >= 3) && !CharDef[2].empty()) { BlockMeta = (NIBBLETYPE)atoi(CharDef[2].c_str()); - ASSERT((BlockMeta >= 0) && (BlockMeta <= 15)); + ASSERT((BlockMeta <= 15)); } a_CharMapOut[Src].m_BlockMeta = BlockMeta; } // for itr - Lines[] -- cgit v1.2.3 From a2b1fa6520355e9f073fcb44897c6ee21a69df75 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 27 Apr 2014 13:12:36 -0700 Subject: Initialised MetaArrays in BlockArea Fixes CID 43621 --- src/BlockArea.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 40cca8882..49c564ca5 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -663,8 +663,12 @@ void cBlockArea::Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_R if (IsDummyMetas) { - SrcMetas = new NIBBLETYPE[a_Src.GetBlockCount()]; - DstMetas = new NIBBLETYPE[GetBlockCount()]; + size_t SrcCount = a_Src.GetBlockCount(); + size_t DestCount = GetBlockCount(); + SrcMetas = new NIBBLETYPE[SrcCount]; + DstMetas = new NIBBLETYPE[DestCount]; + memset(SrcMetas, 0, SrcCount); + memset(DstMetas, 0, DestCount); } switch (a_Strategy) -- cgit v1.2.3 From 71c51783f3fc73d7370714ebbb0cdd4c8206843c Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 27 Apr 2014 13:15:19 -0700 Subject: Initalize counter in fastrandom Fixes CID 43622 --- src/FastRandom.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/FastRandom.cpp b/src/FastRandom.cpp index c45261947..42bf5f3f9 100644 --- a/src/FastRandom.cpp +++ b/src/FastRandom.cpp @@ -91,7 +91,8 @@ int cFastRandom::m_SeedCounter = 0; cFastRandom::cFastRandom(void) : - m_Seed(m_SeedCounter++) + m_Seed(m_SeedCounter++), + m_Counter(0) { } -- cgit v1.2.3 From 077179277c5f3db46c5b805ae61506b99de7e851 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 27 Apr 2014 13:20:00 -0700 Subject: Fixes to uninitallsed array access in Noise.cpp CID 43634, 43634 --- src/Noise.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/Noise.cpp b/src/Noise.cpp index 95a022ea3..13a194938 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -608,6 +608,8 @@ void cCubicNoise::Generate2D( NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY ///< Noise-space coords of the array in the Y direction ) const { + ASSERT(a_SizeX > 0); + ASSERT(a_SizeY > 0); ASSERT(a_SizeX < MAX_SIZE); ASSERT(a_SizeY < MAX_SIZE); ASSERT(a_StartX < a_EndX); -- cgit v1.2.3 From f301d052cfa70d00f76c31fcad4f961040736a80 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Apr 2014 22:20:49 +0200 Subject: cSocket creates the socket in Connect if no socket is present yet. --- src/OSSupport/Socket.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/OSSupport/Socket.cpp b/src/OSSupport/Socket.cpp index c29e495c3..98f694a79 100644 --- a/src/OSSupport/Socket.cpp +++ b/src/OSSupport/Socket.cpp @@ -295,7 +295,7 @@ bool cSocket::ConnectToLocalhostIPv4(unsigned short a_Port) bool cSocket::ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Port) { - // First try IP Address string to hostent conversion, because it's faster + // First try IP Address string to hostent conversion, because it's faster and local: unsigned long addr = inet_addr(a_HostNameOrAddr.c_str()); if (addr == INADDR_NONE) { @@ -307,10 +307,16 @@ bool cSocket::ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Por CloseSocket(); return false; } - // Should be optimised to a single word copy memcpy(&addr, hp->h_addr, hp->h_length); } + // If the socket is not created yet, create one: + if (!IsValid()) + { + m_Socket = socket((int)IPv4, SOCK_STREAM, 0); + } + + // Connect the socket: sockaddr_in server; server.sin_addr.s_addr = addr; server.sin_family = AF_INET; -- cgit v1.2.3 From 0bdc49221b325feb3a09988737559361fe916be2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Apr 2014 22:27:53 +0200 Subject: PolarSSL wrappers for the SSL context. --- src/PolarSSL++/BlockingSslClientSocket.cpp | 195 +++++++++++++++++++++++++++++ src/PolarSSL++/BlockingSslClientSocket.h | 80 ++++++++++++ src/PolarSSL++/BufferedSslContext.cpp | 62 +++++++++ src/PolarSSL++/BufferedSslContext.h | 52 ++++++++ src/PolarSSL++/CMakeLists.txt | 18 ++- src/PolarSSL++/CallbackSslContext.cpp | 59 +++++++++ src/PolarSSL++/CallbackSslContext.h | 61 +++++++++ src/PolarSSL++/SslContext.cpp | 181 ++++++++++++++++++++++++++ src/PolarSSL++/SslContext.h | 134 ++++++++++++++++++++ src/PolarSSL++/X509Cert.h | 10 +- 10 files changed, 847 insertions(+), 5 deletions(-) create mode 100644 src/PolarSSL++/BlockingSslClientSocket.cpp create mode 100644 src/PolarSSL++/BlockingSslClientSocket.h create mode 100644 src/PolarSSL++/BufferedSslContext.cpp create mode 100644 src/PolarSSL++/BufferedSslContext.h create mode 100644 src/PolarSSL++/CallbackSslContext.cpp create mode 100644 src/PolarSSL++/CallbackSslContext.h create mode 100644 src/PolarSSL++/SslContext.cpp create mode 100644 src/PolarSSL++/SslContext.h (limited to 'src') diff --git a/src/PolarSSL++/BlockingSslClientSocket.cpp b/src/PolarSSL++/BlockingSslClientSocket.cpp new file mode 100644 index 000000000..20b2df1e7 --- /dev/null +++ b/src/PolarSSL++/BlockingSslClientSocket.cpp @@ -0,0 +1,195 @@ + +// BlockingSslClientSocket.cpp + +// Implements the cBlockingSslClientSocket class representing a blocking TCP socket with client SSL encryption over it + +#include "Globals.h" +#include "BlockingSslClientSocket.h" + + + + + +cBlockingSslClientSocket::cBlockingSslClientSocket(void) : + m_IsConnected(false), + m_Ssl(*this) +{ + // Nothing needed yet +} + + + + + +bool cBlockingSslClientSocket::Connect(const AString & a_ServerName, UInt16 a_Port) +{ + // If already connected, report an error: + if (m_IsConnected) + { + // TODO: Handle this better - if connected to the same server and port, and the socket is alive, return success + m_LastErrorText = "Already connected"; + return false; + } + + // Connect the underlying socket: + m_Socket.CreateSocket(cSocket::IPv4); + if (!m_Socket.ConnectIPv4(a_ServerName.c_str(), a_Port)) + { + Printf(m_LastErrorText, "Socket connect failed: %s", m_Socket.GetLastErrorString().c_str()); + return false; + } + + // Initialize the SSL: + int ret = m_Ssl.Initialize(true); + if (ret != 0) + { + Printf(m_LastErrorText, "SSL initialization failed: -0x%x", -ret); + return false; + } + + // If we have been assigned a trusted CA root cert store, push it into the SSL context: + if (m_CACerts.get() != NULL) + { + m_Ssl.SetCACerts(m_CACerts, m_ExpectedPeerName); + } + + ret = m_Ssl.Handshake(); + if (ret != 0) + { + Printf(m_LastErrorText, "SSL handshake failed: -0x%x", -ret); + return false; + } + + m_IsConnected = true; + return true; +} + + + + + + +bool cBlockingSslClientSocket::SetTrustedRootCertsFromString(const AString & a_CACerts, const AString & a_ExpectedPeerName) +{ + // Warn if used multiple times, but don't signal an error: + if (m_CACerts.get() != NULL) + { + LOGWARNING( + "SSL: Trying to set multiple trusted CA root cert stores, only the last one will be used. Name: %s", + a_ExpectedPeerName.c_str() + ); + } + + // Parse the cert: + m_CACerts.reset(new cX509Cert); + int ret = m_CACerts->Parse(a_CACerts.data(), a_CACerts.size()); + if (ret < 0) + { + Printf(m_LastErrorText, "CA cert parsing failed: -0x%x", -ret); + return false; + } + m_ExpectedPeerName = a_ExpectedPeerName; + + return true; +} + + + + + +bool cBlockingSslClientSocket::Send(const void * a_Data, size_t a_NumBytes) +{ + ASSERT(m_IsConnected); + + // Keep sending the data until all of it is sent: + const char * Data = (const char *)a_Data; + size_t NumBytes = a_NumBytes; + for (;;) + { + int res = m_Ssl.WritePlain(a_Data, a_NumBytes); + if (res < 0) + { + ASSERT(res != POLARSSL_ERR_NET_WANT_READ); // This should never happen with callback-based SSL + ASSERT(res != POLARSSL_ERR_NET_WANT_WRITE); // This should never happen with callback-based SSL + Printf(m_LastErrorText, "Data cannot be written to SSL context: -0x%x", -res); + return false; + } + else + { + Data += res; + NumBytes -= res; + if (NumBytes == 0) + { + return true; + } + } + } +} + + + + + + +int cBlockingSslClientSocket::Receive(void * a_Data, size_t a_MaxBytes) +{ + ASSERT(m_IsConnected); + + int res = m_Ssl.ReadPlain(a_Data, a_MaxBytes); + if (res < 0) + { + Printf(m_LastErrorText, "Data cannot be read form SSL context: -0x%x", -res); + } + return res; +} + + + + + +void cBlockingSslClientSocket::Disconnect(void) +{ + // Ignore if not connected + if (!m_IsConnected) + { + return; + } + + m_Ssl.NotifyClose(); + m_Socket.CloseSocket(); + m_IsConnected = false; +} + + + + + +int cBlockingSslClientSocket::ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) +{ + int res = m_Socket.Receive((char *)a_Buffer, a_NumBytes, 0); + if (res < 0) + { + // PolarSSL's net routines distinguish between connection reset and general failure, we don't need to + return POLARSSL_ERR_NET_RECV_FAILED; + } + return res; +} + + + + + +int cBlockingSslClientSocket::SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) +{ + int res = m_Socket.Send((const char *)a_Buffer, a_NumBytes); + if (res < 0) + { + // PolarSSL's net routines distinguish between connection reset and general failure, we don't need to + return POLARSSL_ERR_NET_SEND_FAILED; + } + return res; +} + + + + diff --git a/src/PolarSSL++/BlockingSslClientSocket.h b/src/PolarSSL++/BlockingSslClientSocket.h new file mode 100644 index 000000000..7af897582 --- /dev/null +++ b/src/PolarSSL++/BlockingSslClientSocket.h @@ -0,0 +1,80 @@ + +// BlockingSslClientSocket.h + +// Declares the cBlockingSslClientSocket class representing a blocking TCP socket with client SSL encryption over it + + + + + +#pragma once + +#include "CallbackSslContext.h" +#include "../OSSupport/Socket.h" + + + + + +class cBlockingSslClientSocket : + protected cCallbackSslContext::cDataCallbacks +{ +public: + cBlockingSslClientSocket(void); + + /** Connects to the specified server and performs SSL handshake. + Returns true if successful, false on failure. Sets internal error text on failure. */ + bool Connect(const AString & a_ServerName, UInt16 a_Port); + + /** Sends the specified data over the connection. + Returns true if successful, false on failure. Sets the internal error text on failure. */ + bool Send(const void * a_Data, size_t a_NumBytes); + + /** Receives data from the connection. + Blocks until there is any data available, then returns as much as possible. + Returns the number of bytes actually received, negative number on failure. + Sets the internal error text on failure. */ + int Receive(void * a_Data, size_t a_MaxBytes); + + /** Disconnects the connection gracefully, if possible. + Note that this also frees the internal SSL context, so all the certificates etc. are lost. */ + void Disconnect(void); + + /** Sets the root certificates that are to be trusted. Forces the connection to use strict cert + verification. Needs to be used before calling Connect(). + a_ExpectedPeerName is the name that we expect to receive in the SSL peer's cert; verification will fail if + the presented name is different (possible MITM). + Returns true on success, false on failure. Sets internal error text on failure. */ + bool SetTrustedRootCertsFromString(const AString & a_CACerts, const AString & a_ExpectedPeerName); + + /** Returns the text of the last error that has occurred in this instance. */ + const AString & GetLastErrorText(void) const { return m_LastErrorText; } + +protected: + /** The SSL context used for the socket */ + cCallbackSslContext m_Ssl; + + /** The underlying socket to the SSL server */ + cSocket m_Socket; + + /** The trusted CA root cert store, if we are to verify the cert strictly. Set by SetTrustedRootCertsFromString(). */ + cX509CertPtr m_CACerts; + + /** The expected SSL peer's name, if we are to verify the cert strictly. Set by SetTrustedRootCertsFromString(). */ + AString m_ExpectedPeerName; + + /** Text of the last error that has occurred. */ + AString m_LastErrorText; + + /** Set to true if the connection established successfully. */ + bool m_IsConnected; + + + // cCallbackSslContext::cDataCallbacks overrides: + virtual int ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) override; + virtual int SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) override; +} ; + + + + diff --git a/src/PolarSSL++/BufferedSslContext.cpp b/src/PolarSSL++/BufferedSslContext.cpp new file mode 100644 index 000000000..885b30c68 --- /dev/null +++ b/src/PolarSSL++/BufferedSslContext.cpp @@ -0,0 +1,62 @@ + +// BufferedSslContext.cpp + +// Implements the cBufferedSslContext class representing a SSL context with the SSL peer data backed by a cByteBuffer + +#include "Globals.h" +#include "BufferedSslContext.h" + + + + + +cBufferedSslContext::cBufferedSslContext(size_t a_BufferSize): + m_OutgoingData(a_BufferSize), + m_IncomingData(a_BufferSize) +{ +} + + + + + +int cBufferedSslContext::ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) +{ + // Called when PolarSSL wants to read encrypted data from the SSL peer + // Read the data from the buffer inside this object, where the owner has stored them using WriteIncoming(): + size_t NumBytes = std::min(a_NumBytes, m_IncomingData.GetReadableSpace()); + if (NumBytes == 0) + { + return POLARSSL_ERR_NET_WANT_READ; + } + if (!m_IncomingData.ReadBuf(a_Buffer, NumBytes)) + { + m_IncomingData.ResetRead(); + return POLARSSL_ERR_NET_RECV_FAILED; + } + m_IncomingData.CommitRead(); + return (int)NumBytes; +} + + + + + +int cBufferedSslContext::SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) +{ + // Called when PolarSSL wants to write encrypted data to the SSL peer + // Write the data into the buffer inside this object, where the owner can later read them using ReadOutgoing(): + if (!m_OutgoingData.CanWriteBytes(a_NumBytes)) + { + return POLARSSL_ERR_NET_WANT_WRITE; + } + if (!m_OutgoingData.Write((const char *)a_Buffer, a_NumBytes)) + { + return POLARSSL_ERR_NET_SEND_FAILED; + } + return (int)a_NumBytes; +} + + + + diff --git a/src/PolarSSL++/BufferedSslContext.h b/src/PolarSSL++/BufferedSslContext.h new file mode 100644 index 000000000..1b7e1af46 --- /dev/null +++ b/src/PolarSSL++/BufferedSslContext.h @@ -0,0 +1,52 @@ + +// BufferedSslContext.h + +// Declares the cBufferedSslContext class representing a SSL context with the SSL peer data backed by a cByteBuffer + + + + + +#pragma once + +#include "SslContext.h" + + + + + +class cBufferedSslContext : + public cSslContext +{ + typedef cSslContext super; + +public: + /** Creates a new context with the buffers of specified size for the encrypted / decrypted data. */ + cBufferedSslContext(size_t a_BufferSize = 64000); + + /** Stores the specified data in the "incoming" buffer, to be process by the SSL decryptor. + This is the data received from the SSL peer. + Returns the number of bytes actually stored. If 0 is returned, owner should check the error state. */ + size_t WriteIncoming(const void * a_Data, size_t a_NumBytes); + + /** Retrieves data from the "outgoing" buffer, after being processed by the SSL encryptor. + This is the data to be sent to the SSL peer. + Returns the number of bytes actually retrieved. */ + size_t ReadOutgoing(void * a_Data, size_t a_DataMaxSize); + +protected: + /** Buffer for the data that has been encrypted into the SSL stream and should be sent out. */ + cByteBuffer m_OutgoingData; + + /** Buffer for the data that has come in and needs to be decrypted from the SSL stream. */ + cByteBuffer m_IncomingData; + + + // cSslContext overrides: + virtual int ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) override; + virtual int SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) override; +} ; + + + + diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt index c5b747980..14a6dc537 100644 --- a/src/PolarSSL++/CMakeLists.txt +++ b/src/PolarSSL++/CMakeLists.txt @@ -5,12 +5,26 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") set(SOURCES - "EntropyContext.cpp" + "BlockingSslClientSocket.cpp" + "BufferedSslSocket.cpp" + "CallbackSslContext.cpp" "CtrDrbgContext.cpp" + "EntropyContext.cpp" + "SslContext.cpp" "X509Cert.cpp" ) -add_library(PolarSSL++ ${SOURCES}) +set(HEADERS + "BlockingSslClientSocket.h" + "BufferedSslSocket.h" + "CallbackSslContext.h" + "CtrDrbgContext.h" + "EntropyContext.h" + "SslContext.h" + "X509Cert.h" +) + +add_library(PolarSSL++ ${SOURCES} ${HEADERS}) if (UNIX) target_link_libraries(PolarSSL++ polarssl) diff --git a/src/PolarSSL++/CallbackSslContext.cpp b/src/PolarSSL++/CallbackSslContext.cpp new file mode 100644 index 000000000..0cc88a14a --- /dev/null +++ b/src/PolarSSL++/CallbackSslContext.cpp @@ -0,0 +1,59 @@ + +// CallbackSslContext.cpp + +// Declares the cCallbackSslContext class representing a SSL context wrapper that uses callbacks to read and write SSL peer data + +#include "Globals.h" +#include "CallbackSslContext.h" + + + + + + +cCallbackSslContext::cCallbackSslContext(void) +{ + // Nothing needed, but the constructor needs to exist so +} + + + + + +cCallbackSslContext::cCallbackSslContext(cCallbackSslContext::cDataCallbacks & a_Callbacks) : + m_Callbacks(&a_Callbacks) +{ +} + + + + + +int cCallbackSslContext::ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) +{ + if (m_Callbacks == NULL) + { + LOGWARNING("SSL: Trying to receive data with no callbacks, aborting."); + return POLARSSL_ERR_NET_RECV_FAILED; + } + return m_Callbacks->ReceiveEncrypted(a_Buffer, a_NumBytes); +} + + + + + +int cCallbackSslContext::SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) +{ + if (m_Callbacks == NULL) + { + LOGWARNING("SSL: Trying to send data with no callbacks, aborting."); + return POLARSSL_ERR_NET_SEND_FAILED; + } + return m_Callbacks->SendEncrypted(a_Buffer, a_NumBytes); +} + + + + + diff --git a/src/PolarSSL++/CallbackSslContext.h b/src/PolarSSL++/CallbackSslContext.h new file mode 100644 index 000000000..4e4c1ed7f --- /dev/null +++ b/src/PolarSSL++/CallbackSslContext.h @@ -0,0 +1,61 @@ + +// CallbackSslContext.h + +// Declares the cCallbackSslContext class representing a SSL context wrapper that uses callbacks to read and write SSL peer data + + + + + +#pragma once + +#include "SslContext.h" + + + + + +class cCallbackSslContext : + public cSslContext +{ +public: + /** Interface used as a data sink for the SSL peer data. */ + class cDataCallbacks + { + public: + /** Called when PolarSSL wants to read encrypted data from the SSL peer. + The returned value is the number of bytes received, or a PolarSSL error on failure. + The implementation can return POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE to indicate + that there's currently no more data and that there might be more data in the future. In such cases the + SSL operation that invoked this call will terminate with the same return value, so that the owner is + notified of this condition and can potentially restart the operation later on. */ + virtual int ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) = 0; + + /** Called when PolarSSL wants to write encrypted data to the SSL peer. + The returned value is the number of bytes sent, or a PolarSSL error on failure. + The implementation can return POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE to indicate + that there's currently no more data and that there might be more data in the future. In such cases the + SSL operation that invoked this call will terminate with the same return value, so that the owner is + notified of this condition and can potentially restart the operation later on. */ + virtual int SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) = 0; + } ; + + + /** Creates a new SSL context with no callbacks assigned */ + cCallbackSslContext(void); + + /** Creates a new SSL context with the specified callbacks */ + cCallbackSslContext(cDataCallbacks & a_Callbacks); + +protected: + /** The callbacks to use to send and receive SSL peer data */ + cDataCallbacks * m_Callbacks; + + // cSslContext overrides: + virtual int ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) override; + virtual int SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) override; +}; + + + + diff --git a/src/PolarSSL++/SslContext.cpp b/src/PolarSSL++/SslContext.cpp new file mode 100644 index 000000000..e7fa11c75 --- /dev/null +++ b/src/PolarSSL++/SslContext.cpp @@ -0,0 +1,181 @@ + +// SslContext.cpp + +// Implements the cSslContext class that holds everything a single SSL context needs to function + +#include "Globals.h" +#include "SslContext.h" +#include "EntropyContext.h" +#include "CtrDrbgContext.h" + + + + + +cSslContext::cSslContext(void) : + m_IsValid(false), + m_HasHandshaken(false) +{ +} + + + + + +cSslContext::~cSslContext() +{ + if (m_IsValid) + { + ssl_free(&m_Ssl); + } +} + + + + + +int cSslContext::Initialize(bool a_IsClient, const SharedPtr & a_CtrDrbg) +{ + // Check double-initialization: + if (m_IsValid) + { + LOGWARNING("SSL: Double initialization is not supported."); + return POLARSSL_ERR_SSL_MALLOC_FAILED; // There is no return value well-suited for this, reuse this one. + } + + // Set the CtrDrbg context, create a new one if needed: + m_CtrDrbg = a_CtrDrbg; + if (m_CtrDrbg.get() == NULL) + { + m_CtrDrbg.reset(new cCtrDrbgContext); + m_CtrDrbg->Initialize("MCServer", 8); + } + + // Initialize PolarSSL's structures: + memset(&m_Ssl, 0, sizeof(m_Ssl)); + int res = ssl_init(&m_Ssl); + if (res != 0) + { + return res; + } + ssl_set_endpoint(&m_Ssl, a_IsClient ? SSL_IS_CLIENT : SSL_IS_SERVER); + ssl_set_authmode(&m_Ssl, SSL_VERIFY_OPTIONAL); + ssl_set_rng(&m_Ssl, ctr_drbg_random, &m_CtrDrbg->m_CtrDrbg); + ssl_set_bio(&m_Ssl, ReceiveEncrypted, this, SendEncrypted, this); + + #ifdef _DEBUG + ssl_set_dbg(&m_Ssl, &SSLDebugMessage, this); + #endif + + m_IsValid = true; + return 0; +} + + + + + +void cSslContext::SetCACerts(const cX509CertPtr & a_CACert, const AString & a_ExpectedPeerName) +{ + // Store the data in our internal buffers, to avoid losing the pointers later on + // PolarSSL will need these after this call returns, and the caller may move / delete the data before that: + m_ExpectedPeerName = a_ExpectedPeerName; + m_CACerts = a_CACert; + + // Set the trusted CA root cert store: + ssl_set_authmode(&m_Ssl, SSL_VERIFY_REQUIRED); + ssl_set_ca_chain(&m_Ssl, m_CACerts->GetInternal(), NULL, m_ExpectedPeerName.empty() ? NULL : m_ExpectedPeerName.c_str()); +} + + + + + +int cSslContext::WritePlain(const void * a_Data, size_t a_NumBytes) +{ + ASSERT(m_IsValid); // Need to call Initialize() first + if (!m_HasHandshaken) + { + int res = Handshake(); + if (res != 0) + { + return res; + } + } + + return ssl_write(&m_Ssl, (const unsigned char *)a_Data, a_NumBytes); +} + + + + + +int cSslContext::ReadPlain(void * a_Data, size_t a_MaxBytes) +{ + ASSERT(m_IsValid); // Need to call Initialize() first + if (!m_HasHandshaken) + { + int res = Handshake(); + if (res != 0) + { + return res; + } + } + + return ssl_read(&m_Ssl, (unsigned char *)a_Data, a_MaxBytes); +} + + + + + +int cSslContext::Handshake(void) +{ + ASSERT(m_IsValid); // Need to call Initialize() first + ASSERT(!m_HasHandshaken); // Must not call twice + + int res = ssl_handshake(&m_Ssl); + if (res == 0) + { + m_HasHandshaken = true; + } + return res; +} + + + + + +int cSslContext::NotifyClose(void) +{ + return ssl_close_notify(&m_Ssl); +} + + + + + +#ifdef _DEBUG + void cSslContext::SSLDebugMessage(void * a_UserParam, int a_Level, const char * a_Text) + { + if (a_Level > 3) + { + // Don't want the trace messages + return; + } + + // Remove the terminating LF: + size_t len = strlen(a_Text) - 1; + while ((len > 0) && (a_Text[len] <= 32)) + { + len--; + } + AString Text(a_Text, len + 1); + + LOGD("SSL (%d): %s", a_Level, Text.c_str()); + } +#endif // _DEBUG + + + + diff --git a/src/PolarSSL++/SslContext.h b/src/PolarSSL++/SslContext.h new file mode 100644 index 000000000..6effdcaea --- /dev/null +++ b/src/PolarSSL++/SslContext.h @@ -0,0 +1,134 @@ + +// SslContext.h + +// Declares the cSslContext class that holds everything a single SSL context needs to function + + + + + +#pragma once + +#include "polarssl/ssl.h" +#include "../ByteBuffer.h" +#include "X509Cert.h" + + + + + +// fwd: +class cCtrDrbgContext; + + + + + +/** +Acts as a generic SSL encryptor / decryptor between the two endpoints. The "owner" of this class is expected +to create it, initialize it and then provide the means of reading and writing data through the SSL link. +This is an abstract base class, there are descendants that handle the specific aspects of how the SSL peer +data comes into the system: + - cBufferedSslContext uses a cByteBuffer to read and write the data + - cCallbackSslContext uses callbacks to provide the data +*/ +class cSslContext abstract +{ +public: + /** Creates a new uninitialized context */ + cSslContext(void); + + ~cSslContext(); + + /** Initializes the context for use as a server or client. + Returns 0 on success, PolarSSL error on failure. */ + int Initialize(bool a_IsClient, const SharedPtr & a_CtrDrbg = SharedPtr()); + + /** Returns true if the object has been initialized properly. */ + bool IsValid(void) const { return m_IsValid; } + + /** Sets a cert chain as the trusted cert store for this context. + Calling this will switch the context into strict cert verification mode. + a_ExpectedPeerName is the CommonName that we expect the SSL peer to have in its cert, + if it is different, the verification will fail. An empty string will disable the CN check. */ + void SetCACerts(const cX509CertPtr & a_CACert, const AString & a_ExpectedPeerName); + + /** Writes data to be encrypted and sent to the SSL peer. Will perform SSL handshake, if needed. + Returns the number of bytes actually written, or PolarSSL error code. + If the return value is POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE, the owner should send any + cached outgoing data to the SSL peer and write any incoming data received from the SSL peer and then call + this function again with the same parameters. Note that this may repeat a few times before the data is + actually written, mainly due to initial handshake. */ + int WritePlain(const void * a_Data, size_t a_NumBytes); + + /** Reads data decrypted from the SSL stream. Will perform SSL handshake, if needed. + Returns the number of bytes actually read, or PolarSSL error code. + If the return value is POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE, the owner should send any + cached outgoing data to the SSL peer and write any incoming data received from the SSL peer and then call + this function again with the same parameters. Note that this may repeat a few times before the data is + actually read, mainly due to initial handshake. */ + int ReadPlain(void * a_Data, size_t a_MaxBytes); + + /** Performs the SSL handshake. + Returns zero on success, PoladSSL error code on failure. + If the return value is POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE, the owner should send any + cached outgoing data to the SSL peer and write any incoming data received from the SSL peer and then call + this function again. Note that this may repeat a few times before the handshake is completed. */ + int Handshake(void); + + /** Returns true if the SSL handshake has been completed. */ + bool HasHandshaken(void) const { return m_HasHandshaken; } + + /** Notifies the SSL peer that the connection is being closed. + Returns 0 on success, PolarSSL error code on failure. */ + int NotifyClose(void); + +protected: + /** True if the object has been initialized properly. */ + bool m_IsValid; + + /** The random generator to use */ + SharedPtr m_CtrDrbg; + + /** The SSL context that PolarSSL uses. */ + ssl_context m_Ssl; + + /** True if the SSL handshake has been completed. */ + bool m_HasHandshaken; + + /** A copy of the trusted CA root cert store that is passed to us in SetCACerts(), so that the pointer + stays valid even after the call, when PolarSSL finally uses it. */ + cX509CertPtr m_CACerts; + + /** Buffer for the expected peer name. We need to buffer it because the caller may free the string they + give us before PolarSSL consumes the raw pointer it gets to the CN. */ + AString m_ExpectedPeerName; + + + /** The callback used by PolarSSL when it wants to read encrypted data. */ + static int ReceiveEncrypted(void * a_This, unsigned char * a_Buffer, size_t a_NumBytes) + { + return ((cSslContext *)a_This)->ReceiveEncrypted(a_Buffer, a_NumBytes); + } + + /** The callback used by PolarSSL when it wants to write encrypted data. */ + static int SendEncrypted(void * a_This, const unsigned char * a_Buffer, size_t a_NumBytes) + { + return ((cSslContext *)a_This)->SendEncrypted(a_Buffer, a_NumBytes); + } + + #ifdef _DEBUG + /** The callback used by PolarSSL to output debug messages */ + static void SSLDebugMessage(void * a_UserParam, int a_Level, const char * a_Text); + #endif // _DEBUG + + /** Called when PolarSSL wants to read encrypted data. */ + virtual int ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) = 0; + + /** Called when PolarSSL wants to write encrypted data. */ + virtual int SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) = 0; +} ; + + + + diff --git a/src/PolarSSL++/X509Cert.h b/src/PolarSSL++/X509Cert.h index 5ef19c324..991617d24 100644 --- a/src/PolarSSL++/X509Cert.h +++ b/src/PolarSSL++/X509Cert.h @@ -17,6 +17,8 @@ class cX509Cert { + friend class cSslContext; + public: cX509Cert(void); ~cX509Cert(void); @@ -25,13 +27,15 @@ public: Returns 0 on succes, or PolarSSL error code on failure. */ int Parse(const void * a_CertContents, size_t a_Size); - /** Returns the internal cert ptr. Only use in PolarSSL API calls. */ - OBSOLETE x509_crt * Get(void) { return &m_Cert; } - protected: x509_crt m_Cert; + + /** Returns the internal cert ptr. Only use in PolarSSL API calls. */ + x509_crt * GetInternal(void) { return &m_Cert; } } ; +typedef SharedPtr cX509CertPtr; + -- cgit v1.2.3 From dd52719c2d34aa251e90fafb87448af7086e2658 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Apr 2014 22:28:14 +0200 Subject: Rewritten cAuthenticator to use the new PolarSSL++ wrapper classes. --- src/Protocol/Authenticator.cpp | 136 ++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 91 deletions(-) (limited to 'src') diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index ccc994e36..efeb6c41c 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -16,9 +16,7 @@ #include "polarssl/ctr_drbg.h" #include "polarssl/error.h" -#include "PolarSSL++/EntropyContext.h" -#include "PolarSSL++/CtrDrbgContext.h" -#include "PolarSSL++/X509Cert.h" +#include "PolarSSL++/BlockingSslClientSocket.h" #include #include @@ -150,87 +148,47 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S { LOGD("Trying to auth user %s", a_UserName.c_str()); - int ret, server_fd = -1; + int ret; unsigned char buf[1024]; - const char pers[] = "cAuthenticator"; - - cCtrDrbgContext CtrDrbg; - ssl_context ssl; - cX509Cert CACert; - - /* Initialize the RNG and the session data */ - memset(&ssl, 0, sizeof(ssl_context)); - - if ((ret = CtrDrbg.Initialize(pers, sizeof(pers))) != 0) - { - LOGWARNING("cAuthenticator: CtrDrbg.Initialize() returned %d", ret); - return false; - } /* Initialize certificates */ // This is the root cert for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert: - static const char StarfieldCACert[] = - "-----BEGIN CERTIFICATE-----\n" - "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" - "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" - "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n" - "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n" - "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n" - "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n" - "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n" - "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" - "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n" - "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n" - "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n" - "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n" - "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n" - "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" - "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n" - "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" - "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" - "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" - "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" - "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" - "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" - "-----END CERTIFICATE-----"; - // Parse the Starfield CA and add it to "trusted root certs" - ret = CACert.Parse(StarfieldCACert, sizeof(StarfieldCACert) - 1); - if (ret < 0) - { - LOGWARNING("cAuthenticator: CACert.Parse returned -0x%x", -ret); - return false; - } - - /* Connect */ - if ((ret = net_connect(&server_fd, m_Server.c_str(), 443)) != 0) - { - LOGWARNING("cAuthenticator: Can't connect to %s: %d", m_Server.c_str(), ret); - return false; - } - - /* Setup */ - if ((ret = ssl_init(&ssl)) != 0) + static const AString StarfieldCACert( + "-----BEGIN CERTIFICATE-----\n" + "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n" + "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n" + "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n" + "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n" + "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n" + "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" + "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n" + "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n" + "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n" + "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n" + "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n" + "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n" + "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" + "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" + "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" + "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" + "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" + "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" + "-----END CERTIFICATE-----" + ); + + // Connect the socket: + cBlockingSslClientSocket Socket; + Socket.SetTrustedRootCertsFromString(StarfieldCACert, m_Server); + if (!Socket.Connect(m_Server, 443)) { - LOGWARNING("cAuthenticator: ssl_init returned %d", ret); + LOGWARNING("cAuthenticator: Can't connect to %s: %s", m_Server.c_str(), Socket.GetLastErrorText().c_str()); return false; } - ssl_set_endpoint(&ssl, SSL_IS_CLIENT); - ssl_set_authmode(&ssl, SSL_VERIFY_OPTIONAL); - ssl_set_ca_chain(&ssl, CACert.Get(), NULL, "PolarSSL Server 1"); - ssl_set_rng(&ssl, ctr_drbg_random, CtrDrbg.Get()); - ssl_set_bio(&ssl, net_recv, &server_fd, net_send, &server_fd); - - /* Handshake */ - while ((ret = ssl_handshake(&ssl)) != 0) - { - if ((ret != POLARSSL_ERR_NET_WANT_READ) && (ret != POLARSSL_ERR_NET_WANT_WRITE)) - { - LOGWARNING("cAuthenticator: ssl_handshake returned -0x%x", -ret); - return false; - } - } - /* Write the GET request */ + // Create the GET request: AString ActualAddress = m_Address; ReplaceString(ActualAddress, "%USERNAME%", a_UserName); ReplaceString(ActualAddress, "%SERVERID%", a_ServerId); @@ -242,23 +200,23 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S Request += "Connection: close\r\n"; Request += "\r\n"; - ret = ssl_write(&ssl, (const unsigned char *)Request.c_str(), Request.size()); - if (ret <= 0) + if (!Socket.Send(Request.c_str(), Request.size())) { - LOGWARNING("cAuthenticator: ssl_write returned %d", ret); + LOGWARNING("cAuthenticator: Writing SSL data failed: %s", Socket.GetLastErrorText().c_str()); return false; } - /* Read the HTTP response */ + // Read the HTTP response: std::string Response; for (;;) { - memset(buf, 0, sizeof(buf)); - ret = ssl_read(&ssl, buf, sizeof(buf)); + ret = Socket.Receive(buf, sizeof(buf)); if ((ret == POLARSSL_ERR_NET_WANT_READ) || (ret == POLARSSL_ERR_NET_WANT_WRITE)) { - continue; + // This value should never be returned, it is handled internally by cBlockingSslClientSocket + LOGWARNING("cAuthenticator: SSL reading failed internally."); + return false; } if (ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY) { @@ -266,22 +224,18 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S } if (ret < 0) { - LOGWARNING("cAuthenticator: ssl_read returned %d", ret); - break; + LOGWARNING("cAuthenticator: SSL reading failed: -0x%x", -ret); + return false; } if (ret == 0) { - LOGWARNING("cAuthenticator: EOF"); break; } - Response.append((const char *)buf, ret); + Response.append((const char *)buf, (size_t)ret); } - ssl_close_notify(&ssl); - net_close(server_fd); - ssl_free(&ssl); - memset(&ssl, 0, sizeof(ssl)); + Socket.Disconnect(); // Check the HTTP status line: AString prefix("HTTP/1.1 200 OK"); -- cgit v1.2.3 From 744e00c904ebde6c89aa4763f06118635694d396 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 27 Apr 2014 13:43:59 -0700 Subject: Worked around const pointer --- src/BlockArea.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 49c564ca5..e4b122fa2 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -665,9 +665,10 @@ void cBlockArea::Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_R { size_t SrcCount = a_Src.GetBlockCount(); size_t DestCount = GetBlockCount(); - SrcMetas = new NIBBLETYPE[SrcCount]; + NIBBLETYPE * tempSrcMetas = new NIBBLETYPE[SrcCount]; + memset(tempSrcMetas, 0, SrcCount); + SrcMetas = tempSrcMetas; DstMetas = new NIBBLETYPE[DestCount]; - memset(SrcMetas, 0, SrcCount); memset(DstMetas, 0, DestCount); } -- cgit v1.2.3 From bb73af68432b56d0c52c23448e4092d753521057 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Apr 2014 23:31:26 +0200 Subject: Fixed a late-night typo. --- src/PolarSSL++/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt index 14a6dc537..0493baba4 100644 --- a/src/PolarSSL++/CMakeLists.txt +++ b/src/PolarSSL++/CMakeLists.txt @@ -6,7 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../") set(SOURCES "BlockingSslClientSocket.cpp" - "BufferedSslSocket.cpp" + "BufferedSslContext.cpp" "CallbackSslContext.cpp" "CtrDrbgContext.cpp" "EntropyContext.cpp" @@ -16,7 +16,7 @@ set(SOURCES set(HEADERS "BlockingSslClientSocket.h" - "BufferedSslSocket.h" + "BufferedSslContext.h" "CallbackSslContext.h" "CtrDrbgContext.h" "EntropyContext.h" -- cgit v1.2.3 From ef57133f9b457430d2717825b91b747b378e6233 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Apr 2014 23:35:17 +0200 Subject: Reordered constructors. --- src/PolarSSL++/BlockingSslClientSocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/PolarSSL++/BlockingSslClientSocket.cpp b/src/PolarSSL++/BlockingSslClientSocket.cpp index 20b2df1e7..699bc57ee 100644 --- a/src/PolarSSL++/BlockingSslClientSocket.cpp +++ b/src/PolarSSL++/BlockingSslClientSocket.cpp @@ -11,8 +11,8 @@ cBlockingSslClientSocket::cBlockingSslClientSocket(void) : - m_IsConnected(false), - m_Ssl(*this) + m_Ssl(*this), + m_IsConnected(false) { // Nothing needed yet } -- cgit v1.2.3 From 26e935cb2028e041623424d474ccf1b127d55e97 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 28 Apr 2014 13:51:22 +0200 Subject: Revert "Changed the old invulnerable methods from the wither to the new." This reverts commit d50f8f6f11f69e7e1e56be92fb2d72a5014a3e34. --- src/Mobs/Wither.h | 3 --- src/Protocol/Protocol125.cpp | 9 +-------- src/Protocol/Protocol17x.cpp | 9 +-------- src/WorldStorage/NBTChunkSerializer.cpp | 9 +-------- src/WorldStorage/WSSAnvil.cpp | 2 +- 5 files changed, 4 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index fbea331d3..81c9df1b1 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -19,9 +19,6 @@ public: /** Returns whether the wither is invulnerable to arrows. */ bool IsArmored(void) const; - - /** Use the wither the invulnerable from the spawn? */ - bool IsSpawnInvulnerable(void) const { return m_IsSpawnInvulnerable; } // cEntity overrides virtual bool Initialize(cWorld * a_World) override; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 3951eb3e4..a23afb29a 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -2013,14 +2013,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) case cMonster::mtWither: { WriteByte(0x54); // Int at index 20 - if (((const cWither &)a_Mob).IsSpawnInvulnerable()) - { - WriteInt((Int32)((const cWither &)a_Mob).GetInvulnerableTicks()); - } - else - { - WriteInt((Int32)0); - } + WriteInt((Int32)((const cWither &)a_Mob).GetWitherInvulnerableTicks()); WriteByte(0x66); // Float at index 6 WriteFloat((float)(a_Mob.GetHealth())); break; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 311e770f9..80b161e3e 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -2820,14 +2820,7 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob) case cMonster::mtWither: { WriteByte(0x54); // Int at index 20 - if (((const cWither &)a_Mob).IsSpawnInvulnerable()) - { - WriteInt(((const cWither &)a_Mob).GetInvulnerableTicks()); - } - else - { - WriteInt(0); - } + WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks()); WriteByte(0x66); // Float at index 6 WriteFloat((float)(a_Mob.GetHealth())); break; diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 0c4a1a430..46c6b8e92 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -516,14 +516,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster) } case cMonster::mtWither: { - if (((const cWither *)a_Monster)->IsSpawnInvulnerable()) - { - m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetInvulnerableTicks()); - } - else - { - m_Writer.AddInt("Invul", 0); - } + m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetWitherInvulnerableTicks()); break; } case cMonster::mtWolf: diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index c21809270..4532a925a 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -2272,7 +2272,7 @@ void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a int CurrLine = a_NBT.FindChildByName(a_TagIdx, "Invul"); if (CurrLine > 0) { - Monster->SetInvulnerableTicks(a_NBT.GetInt(CurrLine)); + Monster->SetWitherInvulnerableTicks(a_NBT.GetInt(CurrLine)); } a_Entities.push_back(Monster.release()); -- cgit v1.2.3 From acd2804f316114a50b7103158a6bff5d3d14f673 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 28 Apr 2014 13:51:40 +0200 Subject: Revert "Withers now use the new invulnerable." This reverts commit 619592b5a0ab651e714d55932bc7909e4204cee9. --- src/Mobs/Wither.cpp | 29 ++++++++++++++++++++--------- src/Mobs/Wither.h | 7 ++++++- 2 files changed, 26 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp index fe4dbb28b..5b6e895e1 100644 --- a/src/Mobs/Wither.cpp +++ b/src/Mobs/Wither.cpp @@ -10,10 +10,9 @@ cWither::cWither(void) : super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0), - m_IsSpawnInvulnerable(true) + m_WitherInvulnerableTicks(220) { SetMaxHealth(300); - SetInvulnerableTicks(220); } @@ -48,6 +47,11 @@ bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI) return false; } + if (m_WitherInvulnerableTicks > 0) + { + return false; + } + if (IsArmored() && (a_TDI.DamageType == dtRangedAttack)) { return false; @@ -64,14 +68,21 @@ void cWither::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - if (GetInvulnerableTicks() <= 0 && m_IsSpawnInvulnerable) + if (m_WitherInvulnerableTicks > 0) { - m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this); - m_IsSpawnInvulnerable = false; - } - else if (((GetInvulnerableTicks() % 10) == 0) && (GetInvulnerableTicks() > 10)) - { - Heal(10); + unsigned int NewTicks = m_WitherInvulnerableTicks - 1; + + if (NewTicks == 0) + { + m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this); + } + + m_WitherInvulnerableTicks = NewTicks; + + if ((NewTicks % 10) == 0) + { + Heal(10); + } } m_World->BroadcastEntityMetadata(*this); diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index 81c9df1b1..08b460009 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -17,6 +17,10 @@ public: CLASS_PROTODEF(cWither); + unsigned int GetWitherInvulnerableTicks(void) const { return m_WitherInvulnerableTicks; } + + void SetWitherInvulnerableTicks(unsigned int a_Ticks) { m_WitherInvulnerableTicks = a_Ticks; } + /** Returns whether the wither is invulnerable to arrows. */ bool IsArmored(void) const; @@ -28,7 +32,8 @@ public: private: - bool m_IsSpawnInvulnerable; + /** The number of ticks of invulnerability left after being initially created. Zero once invulnerability has expired. */ + unsigned int m_WitherInvulnerableTicks; } ; -- cgit v1.2.3 From a42480cf8266a1e066209823aab42c9a3829adbc Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 28 Apr 2014 10:31:07 -0700 Subject: Template Magic Removed need to allocate a fake meta block by using templates to provide a version of the code that does not use metas. Also changed the function to a template argument to make sure that the compilier is able to inline it. --- src/BlockArea.cpp | 343 +++++++++++++++++++++++++------------------------ src/BlockArea.h | 5 +- src/OSSupport/File.cpp | 4 +- src/OSSupport/File.h | 4 +- 4 files changed, 183 insertions(+), 173 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index e4b122fa2..359f5cb81 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -13,18 +13,20 @@ - // This wild construct allows us to pass a function argument and still have it inlined by the compiler :) /// Merges two blocktypes and blockmetas of the specified sizes and offsets using the specified combinator function -template void InternalMergeBlocks( + +typedef void (CombinatorFunc)(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta); + +template +void InternalMergeBlocks( BLOCKTYPE * a_DstTypes, const BLOCKTYPE * a_SrcTypes, NIBBLETYPE * a_DstMetas, const NIBBLETYPE * a_SrcMetas, int a_SizeX, int a_SizeY, int a_SizeZ, int a_SrcOffX, int a_SrcOffY, int a_SrcOffZ, int a_DstOffX, int a_DstOffY, int a_DstOffZ, int a_SrcSizeX, int a_SrcSizeY, int a_SrcSizeZ, - int a_DstSizeX, int a_DstSizeY, int a_DstSizeZ, - Combinator a_Combinator + int a_DstSizeX, int a_DstSizeY, int a_DstSizeZ ) { UNUSED(a_SrcSizeY); @@ -41,7 +43,15 @@ template void InternalMergeBlocks( int DstIdx = DstBaseZ + a_DstOffX; for (int x = 0; x < a_SizeX; x++) { - a_Combinator(a_DstTypes[DstIdx], a_SrcTypes[SrcIdx], a_DstMetas[DstIdx], a_SrcMetas[SrcIdx]); + if (MetasValid) + { + Combinator(a_DstTypes[DstIdx], a_SrcTypes[SrcIdx], a_DstMetas[DstIdx], a_SrcMetas[SrcIdx]); + } + else + { + BLOCKTYPE FakeDestMeta = 0; + Combinator(a_DstTypes[DstIdx], a_SrcTypes[SrcIdx], FakeDestMeta, (NIBBLETYPE)0); + } ++DstIdx; ++SrcIdx; } // for x @@ -51,13 +61,12 @@ template void InternalMergeBlocks( - - /// Combinator used for cBlockArea::msOverwrite merging +template static inline void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { a_DstType = a_SrcType; - a_DstMeta = a_SrcMeta; + if (MetaValid) a_DstMeta = a_SrcMeta; } @@ -65,12 +74,13 @@ static inline void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_S /// Combinator used for cBlockArea::msFillAir merging +template static inline void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { if (a_DstType == E_BLOCK_AIR) { a_DstType = a_SrcType; - a_DstMeta = a_SrcMeta; + if (MetaValid) a_DstMeta = a_SrcMeta; } // "else" is the default, already in place } @@ -80,12 +90,13 @@ static inline void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_Src /// Combinator used for cBlockArea::msImprint merging +template static inline void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { if (a_SrcType != E_BLOCK_AIR) { a_DstType = a_SrcType; - a_DstMeta = a_SrcMeta; + if (MetaValid) a_DstMeta = a_SrcMeta; } // "else" is the default, already in place } @@ -95,6 +106,7 @@ static inline void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_Src /// Combinator used for cBlockArea::msLake merging +template static inline void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { // Sponge is the NOP block @@ -107,7 +119,7 @@ static inline void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcTyp if (a_SrcType == E_BLOCK_AIR) { a_DstType = E_BLOCK_AIR; - a_DstMeta = 0; + if (MetaValid) a_DstMeta = 0; return; } @@ -132,7 +144,7 @@ static inline void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcTyp case E_BLOCK_STATIONARY_LAVA: { a_DstType = a_SrcType; - a_DstMeta = a_SrcMeta; + if (MetaValid) a_DstMeta = a_SrcMeta; return; } } @@ -146,7 +158,7 @@ static inline void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcTyp case E_BLOCK_MYCELIUM: { a_DstType = E_BLOCK_STONE; - a_DstMeta = 0; + if (MetaValid) a_DstMeta = 0; return; } } @@ -159,13 +171,14 @@ static inline void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcTyp /** Combinator used for cBlockArea::msSpongePrint merging */ +template static inline void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { // Sponge overwrites nothing, everything else overwrites anything if (a_SrcType != E_BLOCK_SPONGE) { a_DstType = a_SrcType; - a_DstMeta = a_SrcMeta; + if (MetaValid) a_DstMeta = a_SrcMeta; } } @@ -174,17 +187,18 @@ static inline void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a /** Combinator used for cBlockArea::msDifference merging */ +template static inline void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { - if ((a_DstType == a_SrcType) && (a_DstMeta == a_SrcMeta)) + if ((a_DstType == a_SrcType) && (!MetaValid || (a_DstMeta == a_SrcMeta))) { a_DstType = E_BLOCK_AIR; - a_DstMeta = 0; + if (MetaValid) a_DstMeta = 0; } else { a_DstType = a_SrcType; - a_DstMeta = a_SrcMeta; + if (MetaValid) a_DstMeta = a_SrcMeta; } } @@ -193,13 +207,14 @@ static inline void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_ /** Combinator used for cBlockArea::msMask merging */ +template static inline void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { // If the blocks are the same, keep the dest; otherwise replace with air - if ((a_SrcType != a_DstType) || (a_SrcMeta != a_DstMeta)) + if ((a_SrcType != a_DstType) || !MetaValid || (a_SrcMeta != a_DstMeta)) { a_DstType = E_BLOCK_AIR; - a_DstMeta = 0; + if (MetaValid) a_DstMeta = 0; } } @@ -484,7 +499,7 @@ void cBlockArea::CopyTo(cBlockArea & a_Into) const a_Into.Clear(); a_Into.SetSize(m_Size.x, m_Size.y, m_Size.z, GetDataTypes()); a_Into.m_Origin = m_Origin; - int BlockCount = GetBlockCount(); + size_t BlockCount = GetBlockCount(); if (HasBlockTypes()) { memcpy(a_Into.m_BlockTypes, m_BlockTypes, BlockCount * sizeof(BLOCKTYPE)); @@ -532,7 +547,7 @@ void cBlockArea::DumpToRawFile(const AString & a_FileName) f.Write(&SizeZ, 4); unsigned char DataTypes = (unsigned char)GetDataTypes(); f.Write(&DataTypes, 1); - int NumBlocks = GetBlockCount(); + size_t NumBlocks = GetBlockCount(); if (HasBlockTypes()) { f.Write(m_BlockTypes, NumBlocks * sizeof(BLOCKTYPE)); @@ -637,160 +652,19 @@ void cBlockArea::Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMa void cBlockArea::Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy) { - // Block types are compulsory, block metas are voluntary - if (!HasBlockTypes() || !a_Src.HasBlockTypes()) - { - LOGWARNING("%s: cannot merge because one of the areas doesn't have blocktypes.", __FUNCTION__); - return; - } - - // Dst is *this, Src is a_Src - int SrcOffX = std::max(0, -a_RelX); // Offset in Src where to start reading - int DstOffX = std::max(0, a_RelX); // Offset in Dst where to start writing - int SizeX = std::min(a_Src.GetSizeX() - SrcOffX, GetSizeX() - DstOffX); // How many blocks to copy - - int SrcOffY = std::max(0, -a_RelY); // Offset in Src where to start reading - int DstOffY = std::max(0, a_RelY); // Offset in Dst where to start writing - int SizeY = std::min(a_Src.GetSizeY() - SrcOffY, GetSizeY() - DstOffY); // How many blocks to copy - - int SrcOffZ = std::max(0, -a_RelZ); // Offset in Src where to start reading - int DstOffZ = std::max(0, a_RelZ); // Offset in Dst where to start writing - int SizeZ = std::min(a_Src.GetSizeZ() - SrcOffZ, GetSizeZ() - DstOffZ); // How many blocks to copy const NIBBLETYPE * SrcMetas = a_Src.GetBlockMetas(); NIBBLETYPE * DstMetas = m_BlockMetas; + bool IsDummyMetas = ((SrcMetas == NULL) || (DstMetas == NULL)); if (IsDummyMetas) { - size_t SrcCount = a_Src.GetBlockCount(); - size_t DestCount = GetBlockCount(); - NIBBLETYPE * tempSrcMetas = new NIBBLETYPE[SrcCount]; - memset(tempSrcMetas, 0, SrcCount); - SrcMetas = tempSrcMetas; - DstMetas = new NIBBLETYPE[DestCount]; - memset(DstMetas, 0, DestCount); + MergeByStrategy(a_Src, a_RelX, a_RelY, a_RelZ, a_Strategy, SrcMetas, DstMetas); } - - switch (a_Strategy) - { - case msOverwrite: - { - InternalMergeBlocks( - m_BlockTypes, a_Src.GetBlockTypes(), - DstMetas, SrcMetas, - SizeX, SizeY, SizeZ, - SrcOffX, SrcOffY, SrcOffZ, - DstOffX, DstOffY, DstOffZ, - a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), - m_Size.x, m_Size.y, m_Size.z, - MergeCombinatorOverwrite - ); - break; - } // case msOverwrite - - case msFillAir: - { - InternalMergeBlocks( - m_BlockTypes, a_Src.GetBlockTypes(), - DstMetas, SrcMetas, - SizeX, SizeY, SizeZ, - SrcOffX, SrcOffY, SrcOffZ, - DstOffX, DstOffY, DstOffZ, - a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), - m_Size.x, m_Size.y, m_Size.z, - MergeCombinatorFillAir - ); - break; - } // case msFillAir - - case msImprint: - { - InternalMergeBlocks( - m_BlockTypes, a_Src.GetBlockTypes(), - DstMetas, SrcMetas, - SizeX, SizeY, SizeZ, - SrcOffX, SrcOffY, SrcOffZ, - DstOffX, DstOffY, DstOffZ, - a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), - m_Size.x, m_Size.y, m_Size.z, - MergeCombinatorImprint - ); - break; - } // case msImprint - - case msLake: - { - InternalMergeBlocks( - m_BlockTypes, a_Src.GetBlockTypes(), - DstMetas, SrcMetas, - SizeX, SizeY, SizeZ, - SrcOffX, SrcOffY, SrcOffZ, - DstOffX, DstOffY, DstOffZ, - a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), - m_Size.x, m_Size.y, m_Size.z, - MergeCombinatorLake - ); - break; - } // case msLake - - case msSpongePrint: - { - InternalMergeBlocks( - m_BlockTypes, a_Src.GetBlockTypes(), - DstMetas, SrcMetas, - SizeX, SizeY, SizeZ, - SrcOffX, SrcOffY, SrcOffZ, - DstOffX, DstOffY, DstOffZ, - a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), - m_Size.x, m_Size.y, m_Size.z, - MergeCombinatorSpongePrint - ); - break; - } // case msSpongePrint - - case msDifference: - { - InternalMergeBlocks( - m_BlockTypes, a_Src.GetBlockTypes(), - DstMetas, SrcMetas, - SizeX, SizeY, SizeZ, - SrcOffX, SrcOffY, SrcOffZ, - DstOffX, DstOffY, DstOffZ, - a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), - m_Size.x, m_Size.y, m_Size.z, - MergeCombinatorDifference - ); - break; - } // case msDifference - - case msMask: - { - InternalMergeBlocks( - m_BlockTypes, a_Src.GetBlockTypes(), - DstMetas, SrcMetas, - SizeX, SizeY, SizeZ, - SrcOffX, SrcOffY, SrcOffZ, - DstOffX, DstOffY, DstOffZ, - a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), - m_Size.x, m_Size.y, m_Size.z, - MergeCombinatorMask - ); - break; - } // case msMask - - default: - { - LOGWARNING("Unknown block area merge strategy: %d", a_Strategy); - ASSERT(!"Unknown block area merge strategy"); - break; - } - } // switch (a_Strategy) - - if (IsDummyMetas) + else { - delete[] SrcMetas; - delete[] DstMetas; + MergeByStrategy(a_Src, a_RelX, a_RelY, a_RelZ, a_Strategy, SrcMetas, DstMetas); } } @@ -2084,7 +1958,7 @@ void cBlockArea::ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, i int NewSizeX = m_Size.x + a_SubMinX + a_AddMaxX; int NewSizeY = m_Size.y + a_SubMinY + a_AddMaxY; int NewSizeZ = m_Size.z + a_SubMinZ + a_AddMaxZ; - int BlockCount = NewSizeX * NewSizeY * NewSizeZ; + size_t BlockCount = (size_t)NewSizeX * NewSizeY * NewSizeZ; BLOCKTYPE * NewBlockTypes = new BLOCKTYPE[BlockCount]; memset(NewBlockTypes, 0, BlockCount * sizeof(BLOCKTYPE)); int OldIndex = 0; @@ -2114,7 +1988,7 @@ void cBlockArea::ExpandNibbles(NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMa int NewSizeX = m_Size.x + a_SubMinX + a_AddMaxX; int NewSizeY = m_Size.y + a_SubMinY + a_AddMaxY; int NewSizeZ = m_Size.z + a_SubMinZ + a_AddMaxZ; - int BlockCount = NewSizeX * NewSizeY * NewSizeZ; + size_t BlockCount = (size_t)NewSizeX * NewSizeY * NewSizeZ; NIBBLETYPE * NewNibbles = new NIBBLETYPE[BlockCount]; memset(NewNibbles, 0, BlockCount * sizeof(NIBBLETYPE)); int OldIndex = 0; @@ -2166,4 +2040,137 @@ void cBlockArea::RelSetData( +template +void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy, const NIBBLETYPE * SrcMetas, NIBBLETYPE * DstMetas) +{ + // Block types are compulsory, block metas are voluntary + if (!HasBlockTypes() || !a_Src.HasBlockTypes()) + { + LOGWARNING("%s: cannot merge because one of the areas doesn't have blocktypes.", __FUNCTION__); + return; + } + + // Dst is *this, Src is a_Src + int SrcOffX = std::max(0, -a_RelX); // Offset in Src where to start reading + int DstOffX = std::max(0, a_RelX); // Offset in Dst where to start writing + int SizeX = std::min(a_Src.GetSizeX() - SrcOffX, GetSizeX() - DstOffX); // How many blocks to copy + + int SrcOffY = std::max(0, -a_RelY); // Offset in Src where to start reading + int DstOffY = std::max(0, a_RelY); // Offset in Dst where to start writing + int SizeY = std::min(a_Src.GetSizeY() - SrcOffY, GetSizeY() - DstOffY); // How many blocks to copy + + int SrcOffZ = std::max(0, -a_RelZ); // Offset in Src where to start reading + int DstOffZ = std::max(0, a_RelZ); // Offset in Dst where to start writing + int SizeZ = std::min(a_Src.GetSizeZ() - SrcOffZ, GetSizeZ() - DstOffZ); // How many blocks to copy + + switch (a_Strategy) + { + case cBlockArea::msOverwrite: + { + InternalMergeBlocks >( + m_BlockTypes, a_Src.GetBlockTypes(), + DstMetas, SrcMetas, + SizeX, SizeY, SizeZ, + SrcOffX, SrcOffY, SrcOffZ, + DstOffX, DstOffY, DstOffZ, + a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), + m_Size.x, m_Size.y, m_Size.z + ); + break; + } // case msOverwrite + + case cBlockArea::msFillAir: + { + InternalMergeBlocks >( + m_BlockTypes, a_Src.GetBlockTypes(), + DstMetas, SrcMetas, + SizeX, SizeY, SizeZ, + SrcOffX, SrcOffY, SrcOffZ, + DstOffX, DstOffY, DstOffZ, + a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), + m_Size.x, m_Size.y, m_Size.z + ); + break; + } // case msFillAir + + case cBlockArea::msImprint: + { + InternalMergeBlocks >( + m_BlockTypes, a_Src.GetBlockTypes(), + DstMetas, SrcMetas, + SizeX, SizeY, SizeZ, + SrcOffX, SrcOffY, SrcOffZ, + DstOffX, DstOffY, DstOffZ, + a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), + m_Size.x, m_Size.y, m_Size.z + ); + break; + } // case msImprint + + case cBlockArea::msLake: + { + InternalMergeBlocks >( + m_BlockTypes, a_Src.GetBlockTypes(), + DstMetas, SrcMetas, + SizeX, SizeY, SizeZ, + SrcOffX, SrcOffY, SrcOffZ, + DstOffX, DstOffY, DstOffZ, + a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), + m_Size.x, m_Size.y, m_Size.z + ); + break; + } // case msLake + + case cBlockArea::msSpongePrint: + { + InternalMergeBlocks >( + m_BlockTypes, a_Src.GetBlockTypes(), + DstMetas, SrcMetas, + SizeX, SizeY, SizeZ, + SrcOffX, SrcOffY, SrcOffZ, + DstOffX, DstOffY, DstOffZ, + a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), + m_Size.x, m_Size.y, m_Size.z + ); + break; + } // case msSpongePrint + + case cBlockArea::msDifference: + { + InternalMergeBlocks >( + m_BlockTypes, a_Src.GetBlockTypes(), + DstMetas, SrcMetas, + SizeX, SizeY, SizeZ, + SrcOffX, SrcOffY, SrcOffZ, + DstOffX, DstOffY, DstOffZ, + a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), + m_Size.x, m_Size.y, m_Size.z + ); + break; + } // case msDifference + + case cBlockArea::msMask: + { + InternalMergeBlocks >( + m_BlockTypes, a_Src.GetBlockTypes(), + DstMetas, SrcMetas, + SizeX, SizeY, SizeZ, + SrcOffX, SrcOffY, SrcOffZ, + DstOffX, DstOffY, DstOffZ, + a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), + m_Size.x, m_Size.y, m_Size.z + ); + break; + } // case msMask + + default: + { + LOGWARNING("Unknown block area merge strategy: %d", a_Strategy); + ASSERT(!"Unknown block area merge strategy"); + break; + } + } // switch (a_Strategy) +} + + diff --git a/src/BlockArea.h b/src/BlockArea.h index c48175b8c..4c4dfb8ff 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -294,7 +294,7 @@ public: NIBBLETYPE * GetBlockMetas (void) const { return m_BlockMetas; } // NOTE: one byte per block! NIBBLETYPE * GetBlockLight (void) const { return m_BlockLight; } // NOTE: one byte per block! NIBBLETYPE * GetBlockSkyLight(void) const { return m_BlockSkyLight; } // NOTE: one byte per block! - int GetBlockCount(void) const { return m_Size.x * m_Size.y * m_Size.z; } + size_t GetBlockCount(void) const { return m_Size.x * m_Size.y * m_Size.z; } int MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const; protected: @@ -363,6 +363,9 @@ protected: int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight ); + + template + void MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy, const NIBBLETYPE * SrcMetas, NIBBLETYPE * DstMetas); // tolua_begin } ; // tolua_end diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp index f1b3bcf9e..33b9cfc3f 100644 --- a/src/OSSupport/File.cpp +++ b/src/OSSupport/File.cpp @@ -143,7 +143,7 @@ bool cFile::IsEOF(void) const -int cFile::Read (void * iBuffer, int iNumBytes) +int cFile::Read (void * iBuffer, size_t iNumBytes) { ASSERT(IsOpen()); @@ -159,7 +159,7 @@ int cFile::Read (void * iBuffer, int iNumBytes) -int cFile::Write(const void * iBuffer, int iNumBytes) +int cFile::Write(const void * iBuffer, size_t iNumBytes) { ASSERT(IsOpen()); diff --git a/src/OSSupport/File.h b/src/OSSupport/File.h index b394c5cb9..2a7ecf0ed 100644 --- a/src/OSSupport/File.h +++ b/src/OSSupport/File.h @@ -80,10 +80,10 @@ public: bool IsEOF(void) const; /** Reads up to iNumBytes bytes into iBuffer, returns the number of bytes actually read, or -1 on failure; asserts if not open */ - int Read (void * iBuffer, int iNumBytes); + int Read (void * iBuffer, size_t iNumBytes); /** Writes up to iNumBytes bytes from iBuffer, returns the number of bytes actually written, or -1 on failure; asserts if not open */ - int Write(const void * iBuffer, int iNumBytes); + int Write(const void * iBuffer, size_t iNumBytes); /** Seeks to iPosition bytes from file start, returns old position or -1 for failure; asserts if not open */ int Seek (int iPosition); -- cgit v1.2.3 From 05fe6d6c58172dc1f28c9dde06b18e7e309e5212 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 28 Apr 2014 10:52:48 -0700 Subject: Removed inlines from combinators gcc requires external linkage for functions provided to template parameters --- src/BlockArea.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 359f5cb81..0c1c176d5 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -63,7 +63,7 @@ void InternalMergeBlocks( /// Combinator used for cBlockArea::msOverwrite merging template -static inline void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +static void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { a_DstType = a_SrcType; if (MetaValid) a_DstMeta = a_SrcMeta; @@ -75,7 +75,7 @@ static inline void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_S /// Combinator used for cBlockArea::msFillAir merging template -static inline void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +static void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { if (a_DstType == E_BLOCK_AIR) { @@ -91,7 +91,7 @@ static inline void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_Src /// Combinator used for cBlockArea::msImprint merging template -static inline void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +static void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { if (a_SrcType != E_BLOCK_AIR) { @@ -107,7 +107,7 @@ static inline void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_Src /// Combinator used for cBlockArea::msLake merging template -static inline void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +static void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { // Sponge is the NOP block if (a_SrcType == E_BLOCK_SPONGE) @@ -172,7 +172,7 @@ static inline void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcTyp /** Combinator used for cBlockArea::msSpongePrint merging */ template -static inline void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +static void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { // Sponge overwrites nothing, everything else overwrites anything if (a_SrcType != E_BLOCK_SPONGE) @@ -188,7 +188,7 @@ static inline void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a /** Combinator used for cBlockArea::msDifference merging */ template -static inline void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +static void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { if ((a_DstType == a_SrcType) && (!MetaValid || (a_DstMeta == a_SrcMeta))) { @@ -208,7 +208,7 @@ static inline void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_ /** Combinator used for cBlockArea::msMask merging */ template -static inline void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +static void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { // If the blocks are the same, keep the dest; otherwise replace with air if ((a_SrcType != a_DstType) || !MetaValid || (a_SrcMeta != a_DstMeta)) -- cgit v1.2.3 From 6d520e398b7da7d04f8b7377bca0db0a684452f1 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 28 Apr 2014 11:00:43 -0700 Subject: Fixed unbraced ifs --- src/BlockArea.cpp | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 0c1c176d5..b7b76da26 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -66,7 +66,10 @@ template static void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { a_DstType = a_SrcType; - if (MetaValid) a_DstMeta = a_SrcMeta; + if (MetaValid) + { + a_DstMeta = a_SrcMeta; + } } @@ -80,7 +83,10 @@ static void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, N if (a_DstType == E_BLOCK_AIR) { a_DstType = a_SrcType; - if (MetaValid) a_DstMeta = a_SrcMeta; + if (MetaValid) + { + a_DstMeta = a_SrcMeta; + } } // "else" is the default, already in place } @@ -96,7 +102,10 @@ static void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, N if (a_SrcType != E_BLOCK_AIR) { a_DstType = a_SrcType; - if (MetaValid) a_DstMeta = a_SrcMeta; + if (MetaValid) + { + a_DstMeta = a_SrcMeta; + } } // "else" is the default, already in place } @@ -119,7 +128,10 @@ static void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBB if (a_SrcType == E_BLOCK_AIR) { a_DstType = E_BLOCK_AIR; - if (MetaValid) a_DstMeta = 0; + if (MetaValid) + { + a_DstMeta = 0; + } return; } @@ -144,7 +156,10 @@ static void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBB case E_BLOCK_STATIONARY_LAVA: { a_DstType = a_SrcType; - if (MetaValid) a_DstMeta = a_SrcMeta; + if (MetaValid) + { + a_DstMeta = a_SrcMeta; + } return; } } @@ -158,7 +173,10 @@ static void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBB case E_BLOCK_MYCELIUM: { a_DstType = E_BLOCK_STONE; - if (MetaValid) a_DstMeta = 0; + if (MetaValid) + { + a_DstMeta = 0; + } return; } } @@ -178,7 +196,10 @@ static void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcTyp if (a_SrcType != E_BLOCK_SPONGE) { a_DstType = a_SrcType; - if (MetaValid) a_DstMeta = a_SrcMeta; + if (MetaValid) + { + a_DstMeta = a_SrcMeta; + } } } @@ -193,12 +214,18 @@ static void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType if ((a_DstType == a_SrcType) && (!MetaValid || (a_DstMeta == a_SrcMeta))) { a_DstType = E_BLOCK_AIR; - if (MetaValid) a_DstMeta = 0; + if (MetaValid) + { + a_DstMeta = 0; + } } else { a_DstType = a_SrcType; - if (MetaValid) a_DstMeta = a_SrcMeta; + if (MetaValid) + { + a_DstMeta = a_SrcMeta; + } } } @@ -214,7 +241,10 @@ static void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBB if ((a_SrcType != a_DstType) || !MetaValid || (a_SrcMeta != a_DstMeta)) { a_DstType = E_BLOCK_AIR; - if (MetaValid) a_DstMeta = 0; + if (MetaValid) + { + a_DstMeta = 0; + } } } -- cgit v1.2.3 From ad5cdf9f2d4a5e87489a2ad460bf353b17f72b6d Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 28 Apr 2014 11:07:06 -0700 Subject: Removed static from combinators. THis allows us to use the functions in template params at the cost of polluting the global namespace. --- src/BlockArea.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index b7b76da26..f03fc6042 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -63,7 +63,7 @@ void InternalMergeBlocks( /// Combinator used for cBlockArea::msOverwrite merging template -static void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { a_DstType = a_SrcType; if (MetaValid) @@ -78,7 +78,7 @@ static void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, /// Combinator used for cBlockArea::msFillAir merging template -static void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { if (a_DstType == E_BLOCK_AIR) { @@ -97,7 +97,7 @@ static void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, N /// Combinator used for cBlockArea::msImprint merging template -static void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { if (a_SrcType != E_BLOCK_AIR) { @@ -116,7 +116,7 @@ static void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, N /// Combinator used for cBlockArea::msLake merging template -static void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { // Sponge is the NOP block if (a_SrcType == E_BLOCK_SPONGE) @@ -190,7 +190,7 @@ static void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBB /** Combinator used for cBlockArea::msSpongePrint merging */ template -static void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { // Sponge overwrites nothing, everything else overwrites anything if (a_SrcType != E_BLOCK_SPONGE) @@ -209,7 +209,7 @@ static void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcTyp /** Combinator used for cBlockArea::msDifference merging */ template -static void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { if ((a_DstType == a_SrcType) && (!MetaValid || (a_DstMeta == a_SrcMeta))) { @@ -235,7 +235,7 @@ static void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType /** Combinator used for cBlockArea::msMask merging */ template -static void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) { // If the blocks are the same, keep the dest; otherwise replace with air if ((a_SrcType != a_DstType) || !MetaValid || (a_SrcMeta != a_DstMeta)) -- cgit v1.2.3 From f04957321d063f8755d4634551ab9eece05f009e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Apr 2014 20:37:12 +0200 Subject: Fixed missing return value warning in MSVC. --- src/ClientHandle.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index fc3f98aaf..efcc89bab 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -220,6 +220,7 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage } } ASSERT(!"Unhandled chat prefix type!"); + return ""; } -- cgit v1.2.3 From 8ab8fb344f49c2c4ce857594159e9cdba3336853 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Apr 2014 20:37:22 +0200 Subject: Fixed braces. --- src/ClientHandle.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index efcc89bab..f3588c253 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -214,13 +214,17 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage case mtPrivateMessage: { if (ShouldAppendChatPrefixes) + { return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue.c_str(), a_AdditionalData.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str()); + } else + { return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue.c_str()); + } } } ASSERT(!"Unhandled chat prefix type!"); - return ""; + return AString(); } -- cgit v1.2.3 From 16b3eae8623916fa7bc2cd9cad292bbad8d6a116 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Apr 2014 21:16:32 +0200 Subject: Added a debug cert printing function. --- src/PolarSSL++/SslContext.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++ src/PolarSSL++/SslContext.h | 3 +++ 2 files changed, 65 insertions(+) (limited to 'src') diff --git a/src/PolarSSL++/SslContext.cpp b/src/PolarSSL++/SslContext.cpp index e7fa11c75..1994cf844 100644 --- a/src/PolarSSL++/SslContext.cpp +++ b/src/PolarSSL++/SslContext.cpp @@ -64,7 +64,12 @@ int cSslContext::Initialize(bool a_IsClient, const SharedPtr & ssl_set_bio(&m_Ssl, ReceiveEncrypted, this, SendEncrypted, this); #ifdef _DEBUG + /* + // These functions allow us to debug SSL and certificate problems, but produce way too much output, + // so they're disabled until someone needs them ssl_set_dbg(&m_Ssl, &SSLDebugMessage, this); + ssl_set_verify(&m_Ssl, &SSLVerifyCert, this); + */ #endif m_IsValid = true; @@ -174,6 +179,63 @@ int cSslContext::NotifyClose(void) LOGD("SSL (%d): %s", a_Level, Text.c_str()); } + + + + + + int cSslContext::SSLVerifyCert(void * a_This, x509_crt * a_Crt, int a_Depth, int * a_Flags) + { + char buf[1024]; + UNUSED(a_This); + + LOG("Verify requested for (Depth %d):", a_Depth); + x509_crt_info(buf, sizeof(buf) - 1, "", a_Crt); + LOG("%s", buf); + + int Flags = *a_Flags; + if ((Flags & BADCERT_EXPIRED) != 0) + { + LOG(" ! server certificate has expired"); + } + + if ((Flags & BADCERT_REVOKED) != 0) + { + LOG(" ! server certificate has been revoked"); + } + + if ((Flags & BADCERT_CN_MISMATCH) != 0) + { + LOG(" ! CN mismatch"); + } + + if ((Flags & BADCERT_NOT_TRUSTED) != 0) + { + LOG(" ! self-signed or not signed by a trusted CA"); + } + + if ((Flags & BADCRL_NOT_TRUSTED) != 0) + { + LOG(" ! CRL not trusted"); + } + + if ((Flags & BADCRL_EXPIRED) != 0) + { + LOG(" ! CRL expired"); + } + + if ((Flags & BADCERT_OTHER) != 0) + { + LOG(" ! other (unknown) flag"); + } + + if (Flags == 0) + { + LOG(" This certificate has no flags"); + } + + return 0; + } #endif // _DEBUG diff --git a/src/PolarSSL++/SslContext.h b/src/PolarSSL++/SslContext.h index 6effdcaea..85add5f8b 100644 --- a/src/PolarSSL++/SslContext.h +++ b/src/PolarSSL++/SslContext.h @@ -120,6 +120,9 @@ protected: #ifdef _DEBUG /** The callback used by PolarSSL to output debug messages */ static void SSLDebugMessage(void * a_UserParam, int a_Level, const char * a_Text); + + /** The callback used by PolarSSL to log information on the cert chain */ + static int SSLVerifyCert(void * a_This, x509_crt * a_Crt, int a_Depth, int * a_Flags); #endif // _DEBUG /** Called when PolarSSL wants to read encrypted data. */ -- cgit v1.2.3 From bab3a3cd31c26d7c8c195888675b31ece5ab80b7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Apr 2014 21:16:52 +0200 Subject: Added the G1 root cert. Now the authenticator finally works. --- src/Protocol/Authenticator.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index efeb6c41c..f7008a5c4 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -152,8 +152,10 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S unsigned char buf[1024]; /* Initialize certificates */ - // This is the root cert for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert: + // This is the data of the root certs for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert: + // Downloaded from http://certs.starfieldtech.com/repository/ static const AString StarfieldCACert( + // G2 cert "-----BEGIN CERTIFICATE-----\n" "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" @@ -176,7 +178,32 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" - "-----END CERTIFICATE-----" + "-----END CERTIFICATE-----\n\n" + // Original (G1) cert: + "-----BEGIN CERTIFICATE-----\n" + "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" + "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" + "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" + "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" + "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" + "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" + "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" + "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" + "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" + "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" + "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" + "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" + "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" + "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" + "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" + "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" + "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" + "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" + "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" + "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" + "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" + "-----END CERTIFICATE-----\n" ); // Connect the socket: -- cgit v1.2.3 From dffd38e53b87b3928542ad5fb5223a6b56f20ac9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Apr 2014 22:21:49 +0200 Subject: Fixed a MSVC warning. --- src/Entities/FallingBlock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp index bcdac0291..99bff1100 100644 --- a/src/Entities/FallingBlock.cpp +++ b/src/Entities/FallingBlock.cpp @@ -88,7 +88,7 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk) AddPosition(GetSpeed() * MilliDt); // If not static (One billionth precision) broadcast movement. - static const float epsilon = 0.000000001; + static const float epsilon = 0.000000001f; if ((fabs(GetSpeedX()) > epsilon) || (fabs(GetSpeedZ()) > epsilon)) { BroadcastMovementUpdate(); -- cgit v1.2.3 From 55a7f392ccf99b55ee09ade2fb15468e8d3e4d66 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Apr 2014 22:22:07 +0200 Subject: Hopefully fixed repeated clang warnings. --- src/ChunkDef.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 054168bdd..83f3c8f5f 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -246,8 +246,8 @@ public: { if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1)) { - int Index = MakeIndexNoCheck(x, y, z); - if ((size_t)(Index / 2) >= a_Buffer.size()) + size_t Index = (size_t)MakeIndexNoCheck(x, y, z); + if ((Index / 2) >= a_Buffer.size()) { return (a_IsSkyLightNibble ? 0xff : 0); } @@ -281,7 +281,7 @@ public: { a_Buffer.resize((size_t)((a_BlockIdx / 2) + 1)); } - a_Buffer[(size_t)(a_BlockIdx / 2)] = PackNibble(a_Buffer, a_BlockIdx, a_Nibble); + a_Buffer[(size_t)(a_BlockIdx / 2)] = PackNibble(a_Buffer, (size_t)a_BlockIdx, a_Nibble); } @@ -297,19 +297,19 @@ public: return; } - int Index = MakeIndexNoCheck(x, y, z); - if ((size_t)(Index / 2) >= a_Buffer.size()) + size_t Index = (size_t)MakeIndexNoCheck(x, y, z); + if ((Index / 2) >= a_Buffer.size()) { - a_Buffer.resize((size_t)((Index / 2) + 1)); + a_Buffer.resize(((Index / 2) + 1)); } - a_Buffer[(size_t)(Index / 2)] = PackNibble(a_Buffer, Index, a_Nibble); + a_Buffer[(Index / 2)] = PackNibble(a_Buffer, Index, a_Nibble); } private: - inline static NIBBLETYPE PackNibble(const COMPRESSED_NIBBLETYPE & a_Buffer, int a_Index, NIBBLETYPE a_Nibble) + inline static NIBBLETYPE PackNibble(const COMPRESSED_NIBBLETYPE & a_Buffer, size_t a_Index, NIBBLETYPE a_Nibble) { return static_cast( (a_Buffer[a_Index / 2] & (0xf0 >> ((a_Index & 1) * 4))) | // The untouched nibble @@ -318,7 +318,7 @@ private: } - inline static NIBBLETYPE ExpandNibble(const COMPRESSED_NIBBLETYPE & a_Buffer, int a_Index) + inline static NIBBLETYPE ExpandNibble(const COMPRESSED_NIBBLETYPE & a_Buffer, size_t a_Index) { return (a_Buffer[a_Index / 2] >> ((a_Index & 1) * 4)) & 0x0f; } -- cgit v1.2.3 From 709ae320e079e55b2636cdd2a2008d7f420d1f60 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Apr 2014 22:30:07 +0200 Subject: Disabled MSVC warnings about constant bool expressions. --- src/BlockArea.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index f03fc6042..55e8d6849 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -13,11 +13,21 @@ -// This wild construct allows us to pass a function argument and still have it inlined by the compiler :) -/// Merges two blocktypes and blockmetas of the specified sizes and offsets using the specified combinator function + +// Disable MSVC warnings: "conditional expression is constant" +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4127) +#endif + + + + typedef void (CombinatorFunc)(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta); +// This wild construct allows us to pass a function argument and still have it inlined by the compiler :) +/// Merges two blocktypes and blockmetas of the specified sizes and offsets using the specified combinator function template void InternalMergeBlocks( BLOCKTYPE * a_DstTypes, const BLOCKTYPE * a_SrcTypes, @@ -61,6 +71,8 @@ void InternalMergeBlocks( + + /// Combinator used for cBlockArea::msOverwrite merging template void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) @@ -248,6 +260,11 @@ void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE } } +// Re-enable previously disabled MSVC warnings +#ifdef _MSC_VER + #pragma warning(pop) +#endif + -- cgit v1.2.3 From ec33bbe2949010e1ed377b9dcc1ace56a0126bfe Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 29 Apr 2014 11:04:54 +0200 Subject: Moved cRsaPrivateKey to PolarSSL++, rewritten using existing objects. --- src/Crypto.cpp | 174 --------------------------------------- src/Crypto.h | 43 ---------- src/PolarSSL++/CMakeLists.txt | 2 + src/PolarSSL++/CtrDrbgContext.h | 8 +- src/PolarSSL++/RsaPrivateKey.cpp | 173 ++++++++++++++++++++++++++++++++++++++ src/PolarSSL++/RsaPrivateKey.h | 59 +++++++++++++ src/Protocol/Protocol132.cpp | 2 +- src/Protocol/Protocol17x.cpp | 2 +- src/Server.h | 6 +- 9 files changed, 244 insertions(+), 225 deletions(-) create mode 100644 src/PolarSSL++/RsaPrivateKey.cpp create mode 100644 src/PolarSSL++/RsaPrivateKey.h (limited to 'src') diff --git a/src/Crypto.cpp b/src/Crypto.cpp index 16be5ec35..dd8787293 100644 --- a/src/Crypto.cpp +++ b/src/Crypto.cpp @@ -55,180 +55,6 @@ public: /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cRSAPrivateKey: -cRSAPrivateKey::cRSAPrivateKey(void) -{ - rsa_init(&m_Rsa, RSA_PKCS_V15, 0); - InitRnd(); -} - - - - - -cRSAPrivateKey::cRSAPrivateKey(const cRSAPrivateKey & a_Other) -{ - rsa_init(&m_Rsa, RSA_PKCS_V15, 0); - rsa_copy(&m_Rsa, &a_Other.m_Rsa); - InitRnd(); -} - - - - - -cRSAPrivateKey::~cRSAPrivateKey() -{ - entropy_free(&m_Entropy); - rsa_free(&m_Rsa); -} - - - - - -void cRSAPrivateKey::InitRnd(void) -{ - entropy_init(&m_Entropy); - const unsigned char pers[] = "rsa_genkey"; - ctr_drbg_init(&m_Ctr_drbg, entropy_func, &m_Entropy, pers, sizeof(pers) - 1); -} - - - - - -bool cRSAPrivateKey::Generate(unsigned a_KeySizeBits) -{ - if (rsa_gen_key(&m_Rsa, ctr_drbg_random, &m_Ctr_drbg, a_KeySizeBits, 65537) != 0) - { - // Key generation failed - return false; - } - - return true; -} - - - - - -AString cRSAPrivateKey::GetPubKeyDER(void) -{ - class cPubKey - { - public: - cPubKey(rsa_context * a_Rsa) : - m_IsValid(false) - { - pk_init(&m_Key); - if (pk_init_ctx(&m_Key, pk_info_from_type(POLARSSL_PK_RSA)) != 0) - { - ASSERT(!"Cannot init PrivKey context"); - return; - } - if (rsa_copy(pk_rsa(m_Key), a_Rsa) != 0) - { - ASSERT(!"Cannot copy PrivKey to PK context"); - return; - } - m_IsValid = true; - } - - ~cPubKey() - { - if (m_IsValid) - { - pk_free(&m_Key); - } - } - - operator pk_context * (void) { return &m_Key; } - - protected: - bool m_IsValid; - pk_context m_Key; - } PkCtx(&m_Rsa); - - unsigned char buf[3000]; - int res = pk_write_pubkey_der(PkCtx, buf, sizeof(buf)); - if (res < 0) - { - return AString(); - } - return AString((const char *)(buf + sizeof(buf) - res), (size_t)res); -} - - - - - -int cRSAPrivateKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength) -{ - if (a_EncryptedLength < m_Rsa.len) - { - LOGD("%s: Invalid a_EncryptedLength: got %u, exp at least %u", - __FUNCTION__, (unsigned)a_EncryptedLength, (unsigned)(m_Rsa.len) - ); - ASSERT(!"Invalid a_DecryptedMaxLength!"); - return -1; - } - if (a_DecryptedMaxLength < m_Rsa.len) - { - LOGD("%s: Invalid a_DecryptedMaxLength: got %u, exp at least %u", - __FUNCTION__, (unsigned)a_EncryptedLength, (unsigned)(m_Rsa.len) - ); - ASSERT(!"Invalid a_DecryptedMaxLength!"); - return -1; - } - size_t DecryptedLength; - int res = rsa_pkcs1_decrypt( - &m_Rsa, ctr_drbg_random, &m_Ctr_drbg, RSA_PRIVATE, &DecryptedLength, - a_EncryptedData, a_DecryptedData, a_DecryptedMaxLength - ); - if (res != 0) - { - return -1; - } - return (int)DecryptedLength; -} - - - - - -int cRSAPrivateKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength) -{ - if (a_EncryptedMaxLength < m_Rsa.len) - { - LOGD("%s: Invalid a_EncryptedMaxLength: got %u, exp at least %u", - __FUNCTION__, (unsigned)a_EncryptedMaxLength, (unsigned)(m_Rsa.len) - ); - ASSERT(!"Invalid a_DecryptedMaxLength!"); - return -1; - } - if (a_PlainLength < m_Rsa.len) - { - LOGD("%s: Invalid a_PlainLength: got %u, exp at least %u", - __FUNCTION__, (unsigned)a_PlainLength, (unsigned)(m_Rsa.len) - ); - ASSERT(!"Invalid a_PlainLength!"); - return -1; - } - int res = rsa_pkcs1_encrypt( - &m_Rsa, ctr_drbg_random, &m_Ctr_drbg, RSA_PRIVATE, - a_PlainLength, a_PlainData, a_EncryptedData - ); - if (res != 0) - { - return -1; - } - return (int)m_Rsa.len; -} - - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cPublicKey: diff --git a/src/Crypto.h b/src/Crypto.h index a9ec2c6d4..24f246897 100644 --- a/src/Crypto.h +++ b/src/Crypto.h @@ -20,49 +20,6 @@ -/** Encapsulates an RSA private key used in PKI cryptography */ -class cRSAPrivateKey -{ -public: - /** Creates a new empty object, the key is not assigned */ - cRSAPrivateKey(void); - - /** Deep-copies the key from a_Other */ - cRSAPrivateKey(const cRSAPrivateKey & a_Other); - - ~cRSAPrivateKey(); - - /** Generates a new key within this object, with the specified size in bits. - Returns true on success, false on failure. */ - bool Generate(unsigned a_KeySizeBits = 1024); - - /** Returns the public key part encoded in ASN1 DER encoding */ - AString GetPubKeyDER(void); - - /** Decrypts the data using RSAES-PKCS#1 algorithm. - Both a_EncryptedData and a_DecryptedData must be at least bytes large. - Returns the number of bytes decrypted, or negative number for error. */ - int Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength); - - /** Encrypts the data using RSAES-PKCS#1 algorithm. - Both a_EncryptedData and a_DecryptedData must be at least bytes large. - Returns the number of bytes decrypted, or negative number for error. */ - int Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength); - -protected: - rsa_context m_Rsa; - entropy_context m_Entropy; - ctr_drbg_context m_Ctr_drbg; - - /** Initializes the m_Entropy and m_Ctr_drbg contexts - Common part of this object's construction, called from all constructors. */ - void InitRnd(void); -} ; - - - - - class cPublicKey { public: diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt index 0493baba4..ebdd52de5 100644 --- a/src/PolarSSL++/CMakeLists.txt +++ b/src/PolarSSL++/CMakeLists.txt @@ -10,6 +10,7 @@ set(SOURCES "CallbackSslContext.cpp" "CtrDrbgContext.cpp" "EntropyContext.cpp" + "RsaPrivateKey.cpp" "SslContext.cpp" "X509Cert.cpp" ) @@ -20,6 +21,7 @@ set(HEADERS "CallbackSslContext.h" "CtrDrbgContext.h" "EntropyContext.h" + "RsaPrivateKey.h" "SslContext.h" "X509Cert.h" ) diff --git a/src/PolarSSL++/CtrDrbgContext.h b/src/PolarSSL++/CtrDrbgContext.h index e9a1e17e2..817222a53 100644 --- a/src/PolarSSL++/CtrDrbgContext.h +++ b/src/PolarSSL++/CtrDrbgContext.h @@ -25,6 +25,7 @@ class cEntropyContext; class cCtrDrbgContext { friend class cSslContext; + friend class cRsaPrivateKey; public: /** Constructs the context with a new entropy context. */ @@ -41,9 +42,6 @@ public: /** Returns true if the object is valid (has been initialized properly) */ bool IsValid(void) const { return m_IsValid; } - /** Returns the internal context ptr. Only use in PolarSSL API calls. */ - OBSOLETE ctr_drbg_context * Get(void) { return &m_CtrDrbg; } - protected: /** The entropy source used for generating the random */ SharedPtr m_EntropyContext; @@ -53,6 +51,10 @@ protected: /** Set to true if the object is valid (has been initialized properly) */ bool m_IsValid; + + + /** Returns the internal context ptr. Only use in PolarSSL API calls. */ + ctr_drbg_context * GetInternal(void) { return &m_CtrDrbg; } } ; diff --git a/src/PolarSSL++/RsaPrivateKey.cpp b/src/PolarSSL++/RsaPrivateKey.cpp new file mode 100644 index 000000000..d042139cf --- /dev/null +++ b/src/PolarSSL++/RsaPrivateKey.cpp @@ -0,0 +1,173 @@ + +// RsaPrivateKey.cpp + +#include "Globals.h" +#include "RsaPrivateKey.h" +#include "CtrDrbgContext.h" +#include "polarssl/pk.h" + + + + + + +cRsaPrivateKey::cRsaPrivateKey(void) +{ + rsa_init(&m_Rsa, RSA_PKCS_V15, 0); +} + + + + + +cRsaPrivateKey::cRsaPrivateKey(const cRsaPrivateKey & a_Other) +{ + rsa_init(&m_Rsa, RSA_PKCS_V15, 0); + rsa_copy(&m_Rsa, &a_Other.m_Rsa); +} + + + + + +cRsaPrivateKey::~cRsaPrivateKey() +{ + rsa_free(&m_Rsa); +} + + + + + +bool cRsaPrivateKey::Generate(unsigned a_KeySizeBits) +{ + if (rsa_gen_key(&m_Rsa, ctr_drbg_random, m_CtrDrbg.GetInternal(), a_KeySizeBits, 65537) != 0) + { + // Key generation failed + return false; + } + + return true; +} + + + + + +AString cRsaPrivateKey::GetPubKeyDER(void) +{ + class cPubKey + { + public: + cPubKey(rsa_context * a_Rsa) : + m_IsValid(false) + { + pk_init(&m_Key); + if (pk_init_ctx(&m_Key, pk_info_from_type(POLARSSL_PK_RSA)) != 0) + { + ASSERT(!"Cannot init PrivKey context"); + return; + } + if (rsa_copy(pk_rsa(m_Key), a_Rsa) != 0) + { + ASSERT(!"Cannot copy PrivKey to PK context"); + return; + } + m_IsValid = true; + } + + ~cPubKey() + { + if (m_IsValid) + { + pk_free(&m_Key); + } + } + + operator pk_context * (void) { return &m_Key; } + + protected: + bool m_IsValid; + pk_context m_Key; + } PkCtx(&m_Rsa); + + unsigned char buf[3000]; + int res = pk_write_pubkey_der(PkCtx, buf, sizeof(buf)); + if (res < 0) + { + return AString(); + } + return AString((const char *)(buf + sizeof(buf) - res), (size_t)res); +} + + + + + +int cRsaPrivateKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength) +{ + if (a_EncryptedLength < m_Rsa.len) + { + LOGD("%s: Invalid a_EncryptedLength: got %u, exp at least %u", + __FUNCTION__, (unsigned)a_EncryptedLength, (unsigned)(m_Rsa.len) + ); + ASSERT(!"Invalid a_DecryptedMaxLength!"); + return -1; + } + if (a_DecryptedMaxLength < m_Rsa.len) + { + LOGD("%s: Invalid a_DecryptedMaxLength: got %u, exp at least %u", + __FUNCTION__, (unsigned)a_EncryptedLength, (unsigned)(m_Rsa.len) + ); + ASSERT(!"Invalid a_DecryptedMaxLength!"); + return -1; + } + size_t DecryptedLength; + int res = rsa_pkcs1_decrypt( + &m_Rsa, ctr_drbg_random, m_CtrDrbg.GetInternal(), RSA_PRIVATE, &DecryptedLength, + a_EncryptedData, a_DecryptedData, a_DecryptedMaxLength + ); + if (res != 0) + { + return -1; + } + return (int)DecryptedLength; +} + + + + + +int cRsaPrivateKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength) +{ + if (a_EncryptedMaxLength < m_Rsa.len) + { + LOGD("%s: Invalid a_EncryptedMaxLength: got %u, exp at least %u", + __FUNCTION__, (unsigned)a_EncryptedMaxLength, (unsigned)(m_Rsa.len) + ); + ASSERT(!"Invalid a_DecryptedMaxLength!"); + return -1; + } + if (a_PlainLength < m_Rsa.len) + { + LOGD("%s: Invalid a_PlainLength: got %u, exp at least %u", + __FUNCTION__, (unsigned)a_PlainLength, (unsigned)(m_Rsa.len) + ); + ASSERT(!"Invalid a_PlainLength!"); + return -1; + } + int res = rsa_pkcs1_encrypt( + &m_Rsa, ctr_drbg_random, m_CtrDrbg.GetInternal(), RSA_PRIVATE, + a_PlainLength, a_PlainData, a_EncryptedData + ); + if (res != 0) + { + return -1; + } + return (int)m_Rsa.len; +} + + + + + diff --git a/src/PolarSSL++/RsaPrivateKey.h b/src/PolarSSL++/RsaPrivateKey.h new file mode 100644 index 000000000..ffacde11b --- /dev/null +++ b/src/PolarSSL++/RsaPrivateKey.h @@ -0,0 +1,59 @@ + +// RsaPrivateKey.h + +// Declares the cRsaPrivateKey class representing a private key for RSA operations. + + + + + +#pragma once + +#include "CtrDrbgContext.h" +#include "polarssl/rsa.h" + + + + + +/** Encapsulates an RSA private key used in PKI cryptography */ +class cRsaPrivateKey +{ +public: + /** Creates a new empty object, the key is not assigned */ + cRsaPrivateKey(void); + + /** Deep-copies the key from a_Other */ + cRsaPrivateKey(const cRsaPrivateKey & a_Other); + + ~cRsaPrivateKey(); + + /** Generates a new key within this object, with the specified size in bits. + Returns true on success, false on failure. */ + bool Generate(unsigned a_KeySizeBits = 1024); + + /** Returns the public key part encoded in ASN1 DER encoding */ + AString GetPubKeyDER(void); + + /** Decrypts the data using RSAES-PKCS#1 algorithm. + Both a_EncryptedData and a_DecryptedData must be at least bytes large. + Returns the number of bytes decrypted, or negative number for error. */ + int Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength); + + /** Encrypts the data using RSAES-PKCS#1 algorithm. + Both a_EncryptedData and a_DecryptedData must be at least bytes large. + Returns the number of bytes decrypted, or negative number for error. */ + int Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength); + +protected: + /** The PolarSSL key context */ + rsa_context m_Rsa; + + /** The random generator used for generating the key and encryption / decryption */ + cCtrDrbgContext m_CtrDrbg; +} ; + + + + + diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index 53d8c1561..acfa5e811 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -819,7 +819,7 @@ void cProtocol132::SendEncryptionKeyRequest(void) void cProtocol132::HandleEncryptionKeyResponse(const AString & a_EncKey, const AString & a_EncNonce) { // Decrypt EncNonce using privkey - cRSAPrivateKey & rsaDecryptor = cRoot::Get()->GetServer()->GetPrivateKey(); + cRsaPrivateKey & rsaDecryptor = cRoot::Get()->GetServer()->GetPrivateKey(); Int32 DecryptedNonce[MAX_ENC_LEN / sizeof(Int32)]; int res = rsaDecryptor.Decrypt((const Byte *)a_EncNonce.data(), a_EncNonce.size(), (Byte *)DecryptedNonce, sizeof(DecryptedNonce)); diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index a04d8ac3c..001b8c219 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1690,7 +1690,7 @@ void cProtocol172::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffe } // Decrypt EncNonce using privkey - cRSAPrivateKey & rsaDecryptor = cRoot::Get()->GetServer()->GetPrivateKey(); + cRsaPrivateKey & rsaDecryptor = cRoot::Get()->GetServer()->GetPrivateKey(); Int32 DecryptedNonce[MAX_ENC_LEN / sizeof(Int32)]; int res = rsaDecryptor.Decrypt((const Byte *)EncNonce.data(), EncNonce.size(), (Byte *)DecryptedNonce, sizeof(DecryptedNonce)); if (res != 4) diff --git a/src/Server.h b/src/Server.h index 51c450ebd..3d76c8ccf 100644 --- a/src/Server.h +++ b/src/Server.h @@ -23,7 +23,7 @@ #pragma warning(disable:4702) #endif -#include "Crypto.h" +#include "PolarSSL++/RsaPrivateKey.h" #ifdef _MSC_VER #pragma warning(pop) @@ -109,7 +109,7 @@ public: // tolua_export /** Returns base64 encoded favicon data (obtained from favicon.png) */ const AString & GetFaviconData(void) const { return m_FaviconData; } - cRSAPrivateKey & GetPrivateKey(void) { return m_PrivateKey; } + cRsaPrivateKey & GetPrivateKey(void) { return m_PrivateKey; } const AString & GetPublicKeyDER(void) const { return m_PublicKeyDER; } bool ShouldAuthenticate(void) const { return m_ShouldAuthenticate; } @@ -182,7 +182,7 @@ private: bool m_bRestarting; /** The private key used for the assymetric encryption start in the protocols */ - cRSAPrivateKey m_PrivateKey; + cRsaPrivateKey m_PrivateKey; /** Public key for m_PrivateKey, ASN1-DER-encoded */ AString m_PublicKeyDER; -- cgit v1.2.3 From 79ec770d77beb0ce9176ee9858b830c32380b742 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 29 Apr 2014 11:17:47 +0200 Subject: Added missing initialization. --- src/PolarSSL++/RsaPrivateKey.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/PolarSSL++/RsaPrivateKey.cpp b/src/PolarSSL++/RsaPrivateKey.cpp index d042139cf..2d5a2a4b1 100644 --- a/src/PolarSSL++/RsaPrivateKey.cpp +++ b/src/PolarSSL++/RsaPrivateKey.cpp @@ -14,6 +14,7 @@ cRsaPrivateKey::cRsaPrivateKey(void) { rsa_init(&m_Rsa, RSA_PKCS_V15, 0); + m_CtrDrbg.Initialize("RSA", 3); } @@ -24,6 +25,7 @@ cRsaPrivateKey::cRsaPrivateKey(const cRsaPrivateKey & a_Other) { rsa_init(&m_Rsa, RSA_PKCS_V15, 0); rsa_copy(&m_Rsa, &a_Other.m_Rsa); + m_CtrDrbg.Initialize("RSA", 3); } @@ -41,9 +43,10 @@ cRsaPrivateKey::~cRsaPrivateKey() bool cRsaPrivateKey::Generate(unsigned a_KeySizeBits) { - if (rsa_gen_key(&m_Rsa, ctr_drbg_random, m_CtrDrbg.GetInternal(), a_KeySizeBits, 65537) != 0) + int res = rsa_gen_key(&m_Rsa, ctr_drbg_random, m_CtrDrbg.GetInternal(), a_KeySizeBits, 65537); + if (res != 0) { - // Key generation failed + LOG("RSA key generation failed: -0x%x", -res); return false; } -- cgit v1.2.3 From 5d33ce226ff95b527b0e5e620078bf79b0bb11b9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 29 Apr 2014 15:36:05 +0200 Subject: Added BiomeToString() API function. --- src/BiomeDef.cpp | 180 +++++++++++++++++++++++++++++++------------------------ src/BiomeDef.h | 7 ++- 2 files changed, 106 insertions(+), 81 deletions(-) (limited to 'src') diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index 3fba93e8a..9852b3dd9 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -7,6 +7,88 @@ #include "BiomeDef.h" + + +// The "map" used for biome <-> string conversions: +static struct { + EMCSBiome m_Biome; + const char * m_String; +} g_BiomeMap[] = +{ + {biOcean, "Ocean"} , + {biPlains, "Plains"}, + {biDesert, "Desert"}, + {biExtremeHills, "ExtremeHills"}, + {biForest, "Forest"}, + {biTaiga, "Taiga"}, + {biSwampland, "Swampland"}, + {biRiver, "River"}, + {biNether, "Hell"}, + {biNether, "Nether"}, + {biEnd, "Sky"}, + {biEnd, "End"}, + {biFrozenOcean, "FrozenOcean"}, + {biFrozenRiver, "FrozenRiver"}, + {biIcePlains, "IcePlains"}, + {biIcePlains, "Tundra"}, + {biIceMountains, "IceMountains"}, + {biMushroomIsland, "MushroomIsland"}, + {biMushroomShore, "MushroomShore"}, + {biBeach, "Beach"}, + {biDesertHills, "DesertHills"}, + {biForestHills, "ForestHills"}, + {biTaigaHills, "TaigaHills"}, + {biExtremeHillsEdge, "ExtremeHillsEdge"}, + {biJungle, "Jungle"}, + {biJungleHills, "JungleHills"}, + + // Release 1.7 biomes: + {biJungleEdge, "JungleEdge"}, + {biDeepOcean, "DeepOcean"}, + {biStoneBeach, "StoneBeach"}, + {biColdBeach, "ColdBeach"}, + {biBirchForest, "BirchForest"}, + {biBirchForestHills, "BirchForestHills"}, + {biRoofedForest, "RoofedForest"}, + {biColdTaiga, "ColdTaiga"}, + {biColdTaigaHills, "ColdTaigaHills"}, + {biMegaTaiga, "MegaTaiga"}, + {biMegaTaigaHills, "MegaTaigaHills"}, + {biExtremeHillsPlus, "ExtremeHillsPlus"}, + {biSavanna, "Savanna"}, + {biSavannaPlateau, "SavannaPlateau"}, + {biMesa, "Mesa"}, + {biMesaPlateauF, "MesaPlateauF"}, + {biMesaPlateau, "MesaPlateau"}, + + // Release 1.7 variants: + {biSunflowerPlains, "SunflowerPlains"}, + {biDesertM, "DesertM"}, + {biExtremeHillsM, "ExtremeHillsM"}, + {biFlowerForest, "FlowerForest"}, + {biTaigaM, "TaigaM"}, + {biSwamplandM, "SwamplandM"}, + {biIcePlainsSpikes, "IcePlainsSpikes"}, + {biJungleM, "JungleM"}, + {biJungleEdgeM, "JungleEdgeM"}, + {biBirchForestM, "BirchForestM"}, + {biBirchForestHillsM, "BirchForestHillsM"}, + {biRoofedForestM, "RoofedForestM"}, + {biColdTaigaM, "ColdTaigaM"}, + {biMegaSpruceTaiga, "MegaSpruceTaiga"}, + {biMegaSpruceTaigaHills, "MegaSpruceTaigaHills"}, + {biExtremeHillsPlusM, "ExtremeHillsPlusM"}, + {biSavannaM, "SavannaM"}, + {biSavannaPlateauM, "SavannaPlateauM"}, + {biMesaBryce, "MesaBryce"}, + {biMesaPlateauFM, "MesaPlateauFM"}, + {biMesaPlateauM, "MesaPlateauM"}, +} ; + + + + + EMCSBiome StringToBiome(const AString & a_BiomeString) { // If it is a number, return it: @@ -25,87 +107,11 @@ EMCSBiome StringToBiome(const AString & a_BiomeString) return biInvalidBiome; } - // Convert using the built-in map: - static struct { - EMCSBiome m_Biome; - const char * m_String; - } BiomeMap[] = - { - {biOcean, "Ocean"} , - {biPlains, "Plains"}, - {biDesert, "Desert"}, - {biExtremeHills, "ExtremeHills"}, - {biForest, "Forest"}, - {biTaiga, "Taiga"}, - {biSwampland, "Swampland"}, - {biRiver, "River"}, - {biNether, "Hell"}, - {biNether, "Nether"}, - {biEnd, "Sky"}, - {biEnd, "End"}, - {biFrozenOcean, "FrozenOcean"}, - {biFrozenRiver, "FrozenRiver"}, - {biIcePlains, "IcePlains"}, - {biIcePlains, "Tundra"}, - {biIceMountains, "IceMountains"}, - {biMushroomIsland, "MushroomIsland"}, - {biMushroomShore, "MushroomShore"}, - {biBeach, "Beach"}, - {biDesertHills, "DesertHills"}, - {biForestHills, "ForestHills"}, - {biTaigaHills, "TaigaHills"}, - {biExtremeHillsEdge, "ExtremeHillsEdge"}, - {biJungle, "Jungle"}, - {biJungleHills, "JungleHills"}, - - // Release 1.7 biomes: - {biJungleEdge, "JungleEdge"}, - {biDeepOcean, "DeepOcean"}, - {biStoneBeach, "StoneBeach"}, - {biColdBeach, "ColdBeach"}, - {biBirchForest, "BirchForest"}, - {biBirchForestHills, "BirchForestHills"}, - {biRoofedForest, "RoofedForest"}, - {biColdTaiga, "ColdTaiga"}, - {biColdTaigaHills, "ColdTaigaHills"}, - {biMegaTaiga, "MegaTaiga"}, - {biMegaTaigaHills, "MegaTaigaHills"}, - {biExtremeHillsPlus, "ExtremeHillsPlus"}, - {biSavanna, "Savanna"}, - {biSavannaPlateau, "SavannaPlateau"}, - {biMesa, "Mesa"}, - {biMesaPlateauF, "MesaPlateauF"}, - {biMesaPlateau, "MesaPlateau"}, - - // Release 1.7 variants: - {biSunflowerPlains, "SunflowerPlains"}, - {biDesertM, "DesertM"}, - {biExtremeHillsM, "ExtremeHillsM"}, - {biFlowerForest, "FlowerForest"}, - {biTaigaM, "TaigaM"}, - {biSwamplandM, "SwamplandM"}, - {biIcePlainsSpikes, "IcePlainsSpikes"}, - {biJungleM, "JungleM"}, - {biJungleEdgeM, "JungleEdgeM"}, - {biBirchForestM, "BirchForestM"}, - {biBirchForestHillsM, "BirchForestHillsM"}, - {biRoofedForestM, "RoofedForestM"}, - {biColdTaigaM, "ColdTaigaM"}, - {biMegaSpruceTaiga, "MegaSpruceTaiga"}, - {biMegaSpruceTaigaHills, "MegaSpruceTaigaHills"}, - {biExtremeHillsPlusM, "ExtremeHillsPlusM"}, - {biSavannaM, "SavannaM"}, - {biSavannaPlateauM, "SavannaPlateauM"}, - {biMesaBryce, "MesaBryce"}, - {biMesaPlateauFM, "MesaPlateauFM"}, - {biMesaPlateauM, "MesaPlateauM"}, - } ; - - for (size_t i = 0; i < ARRAYCOUNT(BiomeMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(g_BiomeMap); i++) { - if (NoCaseCompare(BiomeMap[i].m_String, a_BiomeString) == 0) + if (NoCaseCompare(g_BiomeMap[i].m_String, a_BiomeString) == 0) { - return BiomeMap[i].m_Biome; + return g_BiomeMap[i].m_Biome; } } // for i - BiomeMap[] return biInvalidBiome; @@ -115,6 +121,22 @@ EMCSBiome StringToBiome(const AString & a_BiomeString) +AString BiomeToString(int a_Biome) +{ + for (size_t i = 0; i < ARRAYCOUNT(g_BiomeMap); i++) + { + if (g_BiomeMap[i].m_Biome == a_Biome) + { + return g_BiomeMap[i].m_String; + } + } + return AString(); +} + + + + + bool IsBiomeNoDownfall(EMCSBiome a_Biome) { switch (a_Biome) diff --git a/src/BiomeDef.h b/src/BiomeDef.h index 474d4df76..67916890d 100644 --- a/src/BiomeDef.h +++ b/src/BiomeDef.h @@ -104,10 +104,13 @@ enum EMCSBiome biMaxVariantBiome = biNumVariantBiomes - 1, // The maximum biome value } ; -/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns biInvalidBiome on failure. +/** Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns biInvalidBiome on failure. */ extern EMCSBiome StringToBiome(const AString & a_BiomeString); -/// Returns true if the biome has no downfall - deserts and savannas +/** Translates biome enum into biome string. Returns empty string on failure (unknown biome). */ +extern AString BiomeToString(int a_Biome); + +/** Returns true if the biome has no downfall - deserts and savannas */ extern bool IsBiomeNoDownfall(EMCSBiome a_Biome); -- cgit v1.2.3 From 015bf244b5d1f5d9dac7ee85a406dd95c974697b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 29 Apr 2014 15:36:05 +0200 Subject: Added BiomeToString() API function. --- src/BiomeDef.cpp | 180 +++++++++++++++++++++++++++++++------------------------ src/BiomeDef.h | 7 ++- 2 files changed, 106 insertions(+), 81 deletions(-) (limited to 'src') diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index 3fba93e8a..9852b3dd9 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -7,6 +7,88 @@ #include "BiomeDef.h" + + +// The "map" used for biome <-> string conversions: +static struct { + EMCSBiome m_Biome; + const char * m_String; +} g_BiomeMap[] = +{ + {biOcean, "Ocean"} , + {biPlains, "Plains"}, + {biDesert, "Desert"}, + {biExtremeHills, "ExtremeHills"}, + {biForest, "Forest"}, + {biTaiga, "Taiga"}, + {biSwampland, "Swampland"}, + {biRiver, "River"}, + {biNether, "Hell"}, + {biNether, "Nether"}, + {biEnd, "Sky"}, + {biEnd, "End"}, + {biFrozenOcean, "FrozenOcean"}, + {biFrozenRiver, "FrozenRiver"}, + {biIcePlains, "IcePlains"}, + {biIcePlains, "Tundra"}, + {biIceMountains, "IceMountains"}, + {biMushroomIsland, "MushroomIsland"}, + {biMushroomShore, "MushroomShore"}, + {biBeach, "Beach"}, + {biDesertHills, "DesertHills"}, + {biForestHills, "ForestHills"}, + {biTaigaHills, "TaigaHills"}, + {biExtremeHillsEdge, "ExtremeHillsEdge"}, + {biJungle, "Jungle"}, + {biJungleHills, "JungleHills"}, + + // Release 1.7 biomes: + {biJungleEdge, "JungleEdge"}, + {biDeepOcean, "DeepOcean"}, + {biStoneBeach, "StoneBeach"}, + {biColdBeach, "ColdBeach"}, + {biBirchForest, "BirchForest"}, + {biBirchForestHills, "BirchForestHills"}, + {biRoofedForest, "RoofedForest"}, + {biColdTaiga, "ColdTaiga"}, + {biColdTaigaHills, "ColdTaigaHills"}, + {biMegaTaiga, "MegaTaiga"}, + {biMegaTaigaHills, "MegaTaigaHills"}, + {biExtremeHillsPlus, "ExtremeHillsPlus"}, + {biSavanna, "Savanna"}, + {biSavannaPlateau, "SavannaPlateau"}, + {biMesa, "Mesa"}, + {biMesaPlateauF, "MesaPlateauF"}, + {biMesaPlateau, "MesaPlateau"}, + + // Release 1.7 variants: + {biSunflowerPlains, "SunflowerPlains"}, + {biDesertM, "DesertM"}, + {biExtremeHillsM, "ExtremeHillsM"}, + {biFlowerForest, "FlowerForest"}, + {biTaigaM, "TaigaM"}, + {biSwamplandM, "SwamplandM"}, + {biIcePlainsSpikes, "IcePlainsSpikes"}, + {biJungleM, "JungleM"}, + {biJungleEdgeM, "JungleEdgeM"}, + {biBirchForestM, "BirchForestM"}, + {biBirchForestHillsM, "BirchForestHillsM"}, + {biRoofedForestM, "RoofedForestM"}, + {biColdTaigaM, "ColdTaigaM"}, + {biMegaSpruceTaiga, "MegaSpruceTaiga"}, + {biMegaSpruceTaigaHills, "MegaSpruceTaigaHills"}, + {biExtremeHillsPlusM, "ExtremeHillsPlusM"}, + {biSavannaM, "SavannaM"}, + {biSavannaPlateauM, "SavannaPlateauM"}, + {biMesaBryce, "MesaBryce"}, + {biMesaPlateauFM, "MesaPlateauFM"}, + {biMesaPlateauM, "MesaPlateauM"}, +} ; + + + + + EMCSBiome StringToBiome(const AString & a_BiomeString) { // If it is a number, return it: @@ -25,87 +107,11 @@ EMCSBiome StringToBiome(const AString & a_BiomeString) return biInvalidBiome; } - // Convert using the built-in map: - static struct { - EMCSBiome m_Biome; - const char * m_String; - } BiomeMap[] = - { - {biOcean, "Ocean"} , - {biPlains, "Plains"}, - {biDesert, "Desert"}, - {biExtremeHills, "ExtremeHills"}, - {biForest, "Forest"}, - {biTaiga, "Taiga"}, - {biSwampland, "Swampland"}, - {biRiver, "River"}, - {biNether, "Hell"}, - {biNether, "Nether"}, - {biEnd, "Sky"}, - {biEnd, "End"}, - {biFrozenOcean, "FrozenOcean"}, - {biFrozenRiver, "FrozenRiver"}, - {biIcePlains, "IcePlains"}, - {biIcePlains, "Tundra"}, - {biIceMountains, "IceMountains"}, - {biMushroomIsland, "MushroomIsland"}, - {biMushroomShore, "MushroomShore"}, - {biBeach, "Beach"}, - {biDesertHills, "DesertHills"}, - {biForestHills, "ForestHills"}, - {biTaigaHills, "TaigaHills"}, - {biExtremeHillsEdge, "ExtremeHillsEdge"}, - {biJungle, "Jungle"}, - {biJungleHills, "JungleHills"}, - - // Release 1.7 biomes: - {biJungleEdge, "JungleEdge"}, - {biDeepOcean, "DeepOcean"}, - {biStoneBeach, "StoneBeach"}, - {biColdBeach, "ColdBeach"}, - {biBirchForest, "BirchForest"}, - {biBirchForestHills, "BirchForestHills"}, - {biRoofedForest, "RoofedForest"}, - {biColdTaiga, "ColdTaiga"}, - {biColdTaigaHills, "ColdTaigaHills"}, - {biMegaTaiga, "MegaTaiga"}, - {biMegaTaigaHills, "MegaTaigaHills"}, - {biExtremeHillsPlus, "ExtremeHillsPlus"}, - {biSavanna, "Savanna"}, - {biSavannaPlateau, "SavannaPlateau"}, - {biMesa, "Mesa"}, - {biMesaPlateauF, "MesaPlateauF"}, - {biMesaPlateau, "MesaPlateau"}, - - // Release 1.7 variants: - {biSunflowerPlains, "SunflowerPlains"}, - {biDesertM, "DesertM"}, - {biExtremeHillsM, "ExtremeHillsM"}, - {biFlowerForest, "FlowerForest"}, - {biTaigaM, "TaigaM"}, - {biSwamplandM, "SwamplandM"}, - {biIcePlainsSpikes, "IcePlainsSpikes"}, - {biJungleM, "JungleM"}, - {biJungleEdgeM, "JungleEdgeM"}, - {biBirchForestM, "BirchForestM"}, - {biBirchForestHillsM, "BirchForestHillsM"}, - {biRoofedForestM, "RoofedForestM"}, - {biColdTaigaM, "ColdTaigaM"}, - {biMegaSpruceTaiga, "MegaSpruceTaiga"}, - {biMegaSpruceTaigaHills, "MegaSpruceTaigaHills"}, - {biExtremeHillsPlusM, "ExtremeHillsPlusM"}, - {biSavannaM, "SavannaM"}, - {biSavannaPlateauM, "SavannaPlateauM"}, - {biMesaBryce, "MesaBryce"}, - {biMesaPlateauFM, "MesaPlateauFM"}, - {biMesaPlateauM, "MesaPlateauM"}, - } ; - - for (size_t i = 0; i < ARRAYCOUNT(BiomeMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(g_BiomeMap); i++) { - if (NoCaseCompare(BiomeMap[i].m_String, a_BiomeString) == 0) + if (NoCaseCompare(g_BiomeMap[i].m_String, a_BiomeString) == 0) { - return BiomeMap[i].m_Biome; + return g_BiomeMap[i].m_Biome; } } // for i - BiomeMap[] return biInvalidBiome; @@ -115,6 +121,22 @@ EMCSBiome StringToBiome(const AString & a_BiomeString) +AString BiomeToString(int a_Biome) +{ + for (size_t i = 0; i < ARRAYCOUNT(g_BiomeMap); i++) + { + if (g_BiomeMap[i].m_Biome == a_Biome) + { + return g_BiomeMap[i].m_String; + } + } + return AString(); +} + + + + + bool IsBiomeNoDownfall(EMCSBiome a_Biome) { switch (a_Biome) diff --git a/src/BiomeDef.h b/src/BiomeDef.h index 474d4df76..67916890d 100644 --- a/src/BiomeDef.h +++ b/src/BiomeDef.h @@ -104,10 +104,13 @@ enum EMCSBiome biMaxVariantBiome = biNumVariantBiomes - 1, // The maximum biome value } ; -/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns biInvalidBiome on failure. +/** Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns biInvalidBiome on failure. */ extern EMCSBiome StringToBiome(const AString & a_BiomeString); -/// Returns true if the biome has no downfall - deserts and savannas +/** Translates biome enum into biome string. Returns empty string on failure (unknown biome). */ +extern AString BiomeToString(int a_Biome); + +/** Returns true if the biome has no downfall - deserts and savannas */ extern bool IsBiomeNoDownfall(EMCSBiome a_Biome); -- cgit v1.2.3 From d9f7ae6a4d0895752c1a62657c36433e92104346 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 29 Apr 2014 17:13:08 +0200 Subject: Moved cPublicKey to its separate file in PolarSSL++. --- src/Crypto.cpp | 78 ----------------------------------------- src/Crypto.h | 31 ---------------- src/PolarSSL++/CMakeLists.txt | 2 ++ src/PolarSSL++/CtrDrbgContext.h | 1 + src/PolarSSL++/PublicKey.cpp | 73 ++++++++++++++++++++++++++++++++++++++ src/PolarSSL++/PublicKey.h | 48 +++++++++++++++++++++++++ 6 files changed, 124 insertions(+), 109 deletions(-) create mode 100644 src/PolarSSL++/PublicKey.cpp create mode 100644 src/PolarSSL++/PublicKey.h (limited to 'src') diff --git a/src/Crypto.cpp b/src/Crypto.cpp index dd8787293..370b498bf 100644 --- a/src/Crypto.cpp +++ b/src/Crypto.cpp @@ -52,84 +52,6 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cRSAPrivateKey: - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cPublicKey: - -cPublicKey::cPublicKey(const AString & a_PublicKeyDER) -{ - pk_init(&m_Pk); - if (pk_parse_public_key(&m_Pk, (const Byte *)a_PublicKeyDER.data(), a_PublicKeyDER.size()) != 0) - { - ASSERT(!"Cannot parse PubKey"); - return; - } - InitRnd(); -} - - - - - -cPublicKey::~cPublicKey() -{ - pk_free(&m_Pk); -} - - - - - -int cPublicKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength) -{ - size_t DecryptedLen = a_DecryptedMaxLength; - int res = pk_decrypt(&m_Pk, - a_EncryptedData, a_EncryptedLength, - a_DecryptedData, &DecryptedLen, a_DecryptedMaxLength, - ctr_drbg_random, &m_Ctr_drbg - ); - if (res != 0) - { - return res; - } - return (int)DecryptedLen; -} - - - - - -int cPublicKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength) -{ - size_t EncryptedLength = a_EncryptedMaxLength; - int res = pk_encrypt(&m_Pk, - a_PlainData, a_PlainLength, a_EncryptedData, &EncryptedLength, a_EncryptedMaxLength, - ctr_drbg_random, &m_Ctr_drbg - ); - if (res != 0) - { - return res; - } - return (int)EncryptedLength; -} - - - - - -void cPublicKey::InitRnd(void) -{ - entropy_init(&m_Entropy); - const unsigned char pers[] = "rsa_genkey"; - ctr_drbg_init(&m_Ctr_drbg, entropy_func, &m_Entropy, pers, sizeof(pers) - 1); -} - - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cAESCFBDecryptor: diff --git a/src/Crypto.h b/src/Crypto.h index 24f246897..993b21afb 100644 --- a/src/Crypto.h +++ b/src/Crypto.h @@ -14,37 +14,6 @@ #include "polarssl/entropy.h" #include "polarssl/ctr_drbg.h" #include "polarssl/sha1.h" -#include "polarssl/pk.h" - - - - - -class cPublicKey -{ -public: - cPublicKey(const AString & a_PublicKeyDER); - ~cPublicKey(); - - /** Decrypts the data using the stored public key - Both a_EncryptedData and a_DecryptedData must be at least bytes large. - Returns the number of bytes decrypted, or negative number for error. */ - int Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength); - - /** Encrypts the data using the stored public key - Both a_EncryptedData and a_DecryptedData must be at least bytes large. - Returns the number of bytes decrypted, or negative number for error. */ - int Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength); - -protected: - pk_context m_Pk; - entropy_context m_Entropy; - ctr_drbg_context m_Ctr_drbg; - - /** Initializes the m_Entropy and m_Ctr_drbg contexts - Common part of this object's construction, called from all constructors. */ - void InitRnd(void); -} ; diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt index ebdd52de5..bf7720abc 100644 --- a/src/PolarSSL++/CMakeLists.txt +++ b/src/PolarSSL++/CMakeLists.txt @@ -10,6 +10,7 @@ set(SOURCES "CallbackSslContext.cpp" "CtrDrbgContext.cpp" "EntropyContext.cpp" + "PublicKey.cpp" "RsaPrivateKey.cpp" "SslContext.cpp" "X509Cert.cpp" @@ -21,6 +22,7 @@ set(HEADERS "CallbackSslContext.h" "CtrDrbgContext.h" "EntropyContext.h" + "PublicKey.h" "RsaPrivateKey.h" "SslContext.h" "X509Cert.h" diff --git a/src/PolarSSL++/CtrDrbgContext.h b/src/PolarSSL++/CtrDrbgContext.h index 817222a53..65e9a2374 100644 --- a/src/PolarSSL++/CtrDrbgContext.h +++ b/src/PolarSSL++/CtrDrbgContext.h @@ -26,6 +26,7 @@ class cCtrDrbgContext { friend class cSslContext; friend class cRsaPrivateKey; + friend class cPublicKey; public: /** Constructs the context with a new entropy context. */ diff --git a/src/PolarSSL++/PublicKey.cpp b/src/PolarSSL++/PublicKey.cpp new file mode 100644 index 000000000..49794a0c8 --- /dev/null +++ b/src/PolarSSL++/PublicKey.cpp @@ -0,0 +1,73 @@ + +// PublicKey.cpp + +// Implements the cPublicKey class representing a RSA public key in PolarSSL + +#include "Globals.h" +#include "PublicKey.h" + + + + + +cPublicKey::cPublicKey(const AString & a_PublicKeyDER) +{ + pk_init(&m_Pk); + if (pk_parse_public_key(&m_Pk, (const Byte *)a_PublicKeyDER.data(), a_PublicKeyDER.size()) != 0) + { + ASSERT(!"Cannot parse PubKey"); + return; + } + m_CtrDrbg.Initialize("rsa_pubkey", 10); +} + + + + + +cPublicKey::~cPublicKey() +{ + pk_free(&m_Pk); +} + + + + + +int cPublicKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength) +{ + size_t DecryptedLen = a_DecryptedMaxLength; + int res = pk_decrypt(&m_Pk, + a_EncryptedData, a_EncryptedLength, + a_DecryptedData, &DecryptedLen, a_DecryptedMaxLength, + ctr_drbg_random, m_CtrDrbg.GetInternal() + ); + if (res != 0) + { + return res; + } + return (int)DecryptedLen; +} + + + + + +int cPublicKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength) +{ + size_t EncryptedLength = a_EncryptedMaxLength; + int res = pk_encrypt(&m_Pk, + a_PlainData, a_PlainLength, a_EncryptedData, &EncryptedLength, a_EncryptedMaxLength, + ctr_drbg_random, m_CtrDrbg.GetInternal() + ); + if (res != 0) + { + return res; + } + return (int)EncryptedLength; +} + + + + + diff --git a/src/PolarSSL++/PublicKey.h b/src/PolarSSL++/PublicKey.h new file mode 100644 index 000000000..5a0a57147 --- /dev/null +++ b/src/PolarSSL++/PublicKey.h @@ -0,0 +1,48 @@ + +// PublicKey.h + +// Declares the cPublicKey class representing a RSA public key in PolarSSL + + + + + +#pragma once + +#include "CtrDrbgContext.h" +#include "polarssl/pk.h" + + + + + +class cPublicKey +{ +public: + /** Constructs the public key out of the DER-encoded pubkey data */ + cPublicKey(const AString & a_PublicKeyDER); + + ~cPublicKey(); + + /** Decrypts the data using the stored public key + Both a_EncryptedData and a_DecryptedData must be at least bytes large. + Returns the number of bytes decrypted, or negative number for error. */ + int Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength); + + /** Encrypts the data using the stored public key + Both a_EncryptedData and a_DecryptedData must be at least bytes large. + Returns the number of bytes decrypted, or negative number for error. */ + int Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength); + +protected: + /** The public key PolarSSL representation */ + pk_context m_Pk; + + /** The random generator used in encryption and decryption */ + cCtrDrbgContext m_CtrDrbg; +} ; + + + + + -- cgit v1.2.3 From 6cb2d2461f869d5c9d986cccec5edf1021878df2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 29 Apr 2014 17:37:15 +0200 Subject: Moved the rest of the Crypto objects into their own respective files. --- src/Crypto.cpp | 257 ---------------------------------- src/Crypto.h | 124 ---------------- src/PolarSSL++/AesCfb128Decryptor.cpp | 67 +++++++++ src/PolarSSL++/AesCfb128Decryptor.h | 52 +++++++ src/PolarSSL++/AesCfb128Encryptor.cpp | 68 +++++++++ src/PolarSSL++/AesCfb128Encryptor.h | 50 +++++++ src/PolarSSL++/CMakeLists.txt | 42 +++--- src/PolarSSL++/Sha1Checksum.cpp | 138 ++++++++++++++++++ src/PolarSSL++/Sha1Checksum.h | 52 +++++++ src/Protocol/Protocol132.cpp | 18 +-- src/Protocol/Protocol132.h | 7 +- src/Protocol/Protocol17x.cpp | 5 +- src/Protocol/Protocol17x.h | 7 +- 13 files changed, 465 insertions(+), 422 deletions(-) delete mode 100644 src/Crypto.cpp delete mode 100644 src/Crypto.h create mode 100644 src/PolarSSL++/AesCfb128Decryptor.cpp create mode 100644 src/PolarSSL++/AesCfb128Decryptor.h create mode 100644 src/PolarSSL++/AesCfb128Encryptor.cpp create mode 100644 src/PolarSSL++/AesCfb128Encryptor.h create mode 100644 src/PolarSSL++/Sha1Checksum.cpp create mode 100644 src/PolarSSL++/Sha1Checksum.h (limited to 'src') diff --git a/src/Crypto.cpp b/src/Crypto.cpp deleted file mode 100644 index 370b498bf..000000000 --- a/src/Crypto.cpp +++ /dev/null @@ -1,257 +0,0 @@ - -// Crypto.cpp - -// Implements classes that wrap the cryptographic code library - -#include "Globals.h" -#include "Crypto.h" - -#include "polarssl/pk.h" - - - - - -/* -// Self-test the hash formatting for known values: -// sha1(Notch) : 4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48 -// sha1(jeb_) : -7c9d5b0044c130109a5d7b5fb5c317c02b4e28c1 -// sha1(simon) : 88e16a1019277b15d58faf0541e11910eb756f6 - -class Test -{ -public: - Test(void) - { - AString DigestNotch, DigestJeb, DigestSimon; - Byte Digest[20]; - cSHA1Checksum Checksum; - Checksum.Update((const Byte *)"Notch", 5); - Checksum.Finalize(Digest); - cSHA1Checksum::DigestToJava(Digest, DigestNotch); - Checksum.Restart(); - Checksum.Update((const Byte *)"jeb_", 4); - Checksum.Finalize(Digest); - cSHA1Checksum::DigestToJava(Digest, DigestJeb); - Checksum.Restart(); - Checksum.Update((const Byte *)"simon", 5); - Checksum.Finalize(Digest); - cSHA1Checksum::DigestToJava(Digest, DigestSimon); - printf("Notch: \"%s\"\n", DigestNotch.c_str()); - printf("jeb_: \"%s\"\n", DigestJeb.c_str()); - printf("simon: \"%s\"\n", DigestSimon.c_str()); - assert(DigestNotch == "4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48"); - assert(DigestJeb == "-7c9d5b0044c130109a5d7b5fb5c317c02b4e28c1"); - assert(DigestSimon == "88e16a1019277b15d58faf0541e11910eb756f6"); - } -} test; -*/ - - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cAESCFBDecryptor: - -cAESCFBDecryptor::cAESCFBDecryptor(void) : - m_IVOffset(0), - m_IsValid(false) -{ -} - - - - - -cAESCFBDecryptor::~cAESCFBDecryptor() -{ - // Clear the leftover in-memory data, so that they can't be accessed by a backdoor - memset(&m_Aes, 0, sizeof(m_Aes)); -} - - - - - -void cAESCFBDecryptor::Init(const Byte a_Key[16], const Byte a_IV[16]) -{ - ASSERT(!IsValid()); // Cannot Init twice - - memcpy(m_IV, a_IV, 16); - aes_setkey_enc(&m_Aes, a_Key, 128); - m_IsValid = true; -} - - - - - -void cAESCFBDecryptor::ProcessData(Byte * a_DecryptedOut, const Byte * a_EncryptedIn, size_t a_Length) -{ - ASSERT(IsValid()); // Must Init() first - - // PolarSSL doesn't support AES-CFB8, need to implement it manually: - for (size_t i = 0; i < a_Length; i++) - { - Byte Buffer[sizeof(m_IV)]; - aes_crypt_ecb(&m_Aes, AES_ENCRYPT, m_IV, Buffer); - for (size_t idx = 0; idx < sizeof(m_IV) - 1; idx++) - { - m_IV[idx] = m_IV[idx + 1]; - } - m_IV[sizeof(m_IV) - 1] = a_EncryptedIn[i]; - a_DecryptedOut[i] = a_EncryptedIn[i] ^ Buffer[0]; - } -} - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cAESCFBEncryptor: - -cAESCFBEncryptor::cAESCFBEncryptor(void) : - m_IVOffset(0), - m_IsValid(false) -{ -} - - - - - -cAESCFBEncryptor::~cAESCFBEncryptor() -{ - // Clear the leftover in-memory data, so that they can't be accessed by a backdoor - memset(&m_Aes, 0, sizeof(m_Aes)); -} - - - - - -void cAESCFBEncryptor::Init(const Byte a_Key[16], const Byte a_IV[16]) -{ - ASSERT(!IsValid()); // Cannot Init twice - ASSERT(m_IVOffset == 0); - - memcpy(m_IV, a_IV, 16); - aes_setkey_enc(&m_Aes, a_Key, 128); - m_IsValid = true; -} - - - - - -void cAESCFBEncryptor::ProcessData(Byte * a_EncryptedOut, const Byte * a_PlainIn, size_t a_Length) -{ - ASSERT(IsValid()); // Must Init() first - - // PolarSSL doesn't do AES-CFB8, so we need to implement it ourselves: - for (size_t i = 0; i < a_Length; i++) - { - Byte Buffer[sizeof(m_IV)]; - aes_crypt_ecb(&m_Aes, AES_ENCRYPT, m_IV, Buffer); - for (size_t idx = 0; idx < sizeof(m_IV) - 1; idx++) - { - m_IV[idx] = m_IV[idx + 1]; - } - a_EncryptedOut[i] = a_PlainIn[i] ^ Buffer[0]; - m_IV[sizeof(m_IV) - 1] = a_EncryptedOut[i]; - } -} - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cSHA1Checksum: - -cSHA1Checksum::cSHA1Checksum(void) : - m_DoesAcceptInput(true) -{ - sha1_starts(&m_Sha1); -} - - - - - -void cSHA1Checksum::Update(const Byte * a_Data, size_t a_Length) -{ - ASSERT(m_DoesAcceptInput); // Not Finalize()-d yet, or Restart()-ed - - sha1_update(&m_Sha1, a_Data, a_Length); -} - - - - - -void cSHA1Checksum::Finalize(cSHA1Checksum::Checksum & a_Output) -{ - ASSERT(m_DoesAcceptInput); // Not Finalize()-d yet, or Restart()-ed - - sha1_finish(&m_Sha1, a_Output); - m_DoesAcceptInput = false; -} - - - - - -void cSHA1Checksum::DigestToJava(const Checksum & a_Digest, AString & a_Out) -{ - Checksum Digest; - memcpy(Digest, a_Digest, sizeof(Digest)); - - bool IsNegative = (Digest[0] >= 0x80); - if (IsNegative) - { - // Two's complement: - bool carry = true; // Add one to the whole number - for (int i = 19; i >= 0; i--) - { - Digest[i] = ~Digest[i]; - if (carry) - { - carry = (Digest[i] == 0xff); - Digest[i]++; - } - } - } - a_Out.clear(); - a_Out.reserve(40); - for (int i = 0; i < 20; i++) - { - AppendPrintf(a_Out, "%02x", Digest[i]); - } - while ((a_Out.length() > 0) && (a_Out[0] == '0')) - { - a_Out.erase(0, 1); - } - if (IsNegative) - { - a_Out.insert(0, "-"); - } -} - - - - - - -void cSHA1Checksum::Restart(void) -{ - sha1_starts(&m_Sha1); - m_DoesAcceptInput = true; -} - - - - diff --git a/src/Crypto.h b/src/Crypto.h deleted file mode 100644 index 993b21afb..000000000 --- a/src/Crypto.h +++ /dev/null @@ -1,124 +0,0 @@ - -// Crypto.h - -// Declares classes that wrap the cryptographic code library - - - - - -#pragma once - -#include "polarssl/rsa.h" -#include "polarssl/aes.h" -#include "polarssl/entropy.h" -#include "polarssl/ctr_drbg.h" -#include "polarssl/sha1.h" - - - - - -/** Decrypts data using the AES / CFB (128) algorithm */ -class cAESCFBDecryptor -{ -public: - Byte test; - - cAESCFBDecryptor(void); - ~cAESCFBDecryptor(); - - /** Initializes the decryptor with the specified Key / IV */ - void Init(const Byte a_Key[16], const Byte a_IV[16]); - - /** Decrypts a_Length bytes of the encrypted data; produces a_Length output bytes */ - void ProcessData(Byte * a_DecryptedOut, const Byte * a_EncryptedIn, size_t a_Length); - - /** Returns true if the object has been initialized with the Key / IV */ - bool IsValid(void) const { return m_IsValid; } - -protected: - aes_context m_Aes; - - /** The InitialVector, used by the CFB mode decryption */ - Byte m_IV[16]; - - /** Current offset in the m_IV, used by the CFB mode decryption */ - size_t m_IVOffset; - - /** Indicates whether the object has been initialized with the Key / IV */ - bool m_IsValid; -} ; - - - - - -/** Encrypts data using the AES / CFB (128) algorithm */ -class cAESCFBEncryptor -{ -public: - cAESCFBEncryptor(void); - ~cAESCFBEncryptor(); - - /** Initializes the decryptor with the specified Key / IV */ - void Init(const Byte a_Key[16], const Byte a_IV[16]); - - /** Encrypts a_Length bytes of the plain data; produces a_Length output bytes */ - void ProcessData(Byte * a_EncryptedOut, const Byte * a_PlainIn, size_t a_Length); - - /** Returns true if the object has been initialized with the Key / IV */ - bool IsValid(void) const { return m_IsValid; } - -protected: - aes_context m_Aes; - - /** The InitialVector, used by the CFB mode encryption */ - Byte m_IV[16]; - - /** Current offset in the m_IV, used by the CFB mode encryption */ - size_t m_IVOffset; - - /** Indicates whether the object has been initialized with the Key / IV */ - bool m_IsValid; -} ; - - - - - -/** Calculates a SHA1 checksum for data stream */ -class cSHA1Checksum -{ -public: - typedef Byte Checksum[20]; // The type used for storing the checksum - - cSHA1Checksum(void); - - /** Adds the specified data to the checksum */ - void Update(const Byte * a_Data, size_t a_Length); - - /** Calculates and returns the final checksum */ - void Finalize(Checksum & a_Output); - - /** Returns true if the object is accepts more input data, false if Finalize()-d (need to Restart()) */ - bool DoesAcceptInput(void) const { return m_DoesAcceptInput; } - - /** Converts a raw 160-bit SHA1 digest into a Java Hex representation - According to http://wiki.vg/wiki/index.php?title=Protocol_Encryption&oldid=2802 - */ - static void DigestToJava(const Checksum & a_Digest, AString & a_JavaOut); - - /** Clears the current context and start a new checksum calculation */ - void Restart(void); - -protected: - /** True if the object is accepts more input data, false if Finalize()-d (need to Restart()) */ - bool m_DoesAcceptInput; - - sha1_context m_Sha1; -} ; - - - - diff --git a/src/PolarSSL++/AesCfb128Decryptor.cpp b/src/PolarSSL++/AesCfb128Decryptor.cpp new file mode 100644 index 000000000..af0d5106e --- /dev/null +++ b/src/PolarSSL++/AesCfb128Decryptor.cpp @@ -0,0 +1,67 @@ + +// AesCfb128Decryptor.cpp + +// Implements the cAesCfb128Decryptor class decrypting data using AES CFB-128 + +#include "Globals.h" +#include "AesCfb128Decryptor.h" + + + + + +cAesCfb128Decryptor::cAesCfb128Decryptor(void) : + m_IVOffset(0), + m_IsValid(false) +{ +} + + + + + +cAesCfb128Decryptor::~cAesCfb128Decryptor() +{ + // Clear the leftover in-memory data, so that they can't be accessed by a backdoor + memset(&m_Aes, 0, sizeof(m_Aes)); +} + + + + + +void cAesCfb128Decryptor::Init(const Byte a_Key[16], const Byte a_IV[16]) +{ + ASSERT(!IsValid()); // Cannot Init twice + + memcpy(m_IV, a_IV, 16); + aes_setkey_enc(&m_Aes, a_Key, 128); + m_IsValid = true; +} + + + + + +void cAesCfb128Decryptor::ProcessData(Byte * a_DecryptedOut, const Byte * a_EncryptedIn, size_t a_Length) +{ + ASSERT(IsValid()); // Must Init() first + + // PolarSSL doesn't support AES-CFB8, need to implement it manually: + for (size_t i = 0; i < a_Length; i++) + { + Byte Buffer[sizeof(m_IV)]; + aes_crypt_ecb(&m_Aes, AES_ENCRYPT, m_IV, Buffer); + for (size_t idx = 0; idx < sizeof(m_IV) - 1; idx++) + { + m_IV[idx] = m_IV[idx + 1]; + } + m_IV[sizeof(m_IV) - 1] = a_EncryptedIn[i]; + a_DecryptedOut[i] = a_EncryptedIn[i] ^ Buffer[0]; + } +} + + + + + diff --git a/src/PolarSSL++/AesCfb128Decryptor.h b/src/PolarSSL++/AesCfb128Decryptor.h new file mode 100644 index 000000000..68c203d70 --- /dev/null +++ b/src/PolarSSL++/AesCfb128Decryptor.h @@ -0,0 +1,52 @@ + +// AesCfb128Decryptor.h + +// Declares the cAesCfb128Decryptor class decrypting data using AES CFB-128 + + + + + +#pragma once + +#include "polarssl/aes.h" + + + + + +/** Decrypts data using the AES / CFB 128 algorithm */ +class cAesCfb128Decryptor +{ +public: + Byte test; + + cAesCfb128Decryptor(void); + ~cAesCfb128Decryptor(); + + /** Initializes the decryptor with the specified Key / IV */ + void Init(const Byte a_Key[16], const Byte a_IV[16]); + + /** Decrypts a_Length bytes of the encrypted data; produces a_Length output bytes */ + void ProcessData(Byte * a_DecryptedOut, const Byte * a_EncryptedIn, size_t a_Length); + + /** Returns true if the object has been initialized with the Key / IV */ + bool IsValid(void) const { return m_IsValid; } + +protected: + aes_context m_Aes; + + /** The InitialVector, used by the CFB mode decryption */ + Byte m_IV[16]; + + /** Current offset in the m_IV, used by the CFB mode decryption */ + size_t m_IVOffset; + + /** Indicates whether the object has been initialized with the Key / IV */ + bool m_IsValid; +} ; + + + + + diff --git a/src/PolarSSL++/AesCfb128Encryptor.cpp b/src/PolarSSL++/AesCfb128Encryptor.cpp new file mode 100644 index 000000000..a641ad48e --- /dev/null +++ b/src/PolarSSL++/AesCfb128Encryptor.cpp @@ -0,0 +1,68 @@ + +// AesCfb128Encryptor.cpp + +// Implements the cAesCfb128Encryptor class encrypting data using AES CFB-128 + +#include "Globals.h" +#include "AesCfb128Encryptor.h" + + + + + +cAesCfb128Encryptor::cAesCfb128Encryptor(void) : + m_IVOffset(0), + m_IsValid(false) +{ +} + + + + + +cAesCfb128Encryptor::~cAesCfb128Encryptor() +{ + // Clear the leftover in-memory data, so that they can't be accessed by a backdoor + memset(&m_Aes, 0, sizeof(m_Aes)); +} + + + + + +void cAesCfb128Encryptor::Init(const Byte a_Key[16], const Byte a_IV[16]) +{ + ASSERT(!IsValid()); // Cannot Init twice + ASSERT(m_IVOffset == 0); + + memcpy(m_IV, a_IV, 16); + aes_setkey_enc(&m_Aes, a_Key, 128); + m_IsValid = true; +} + + + + + +void cAesCfb128Encryptor::ProcessData(Byte * a_EncryptedOut, const Byte * a_PlainIn, size_t a_Length) +{ + ASSERT(IsValid()); // Must Init() first + + // PolarSSL doesn't do AES-CFB8, so we need to implement it ourselves: + for (size_t i = 0; i < a_Length; i++) + { + Byte Buffer[sizeof(m_IV)]; + aes_crypt_ecb(&m_Aes, AES_ENCRYPT, m_IV, Buffer); + for (size_t idx = 0; idx < sizeof(m_IV) - 1; idx++) + { + m_IV[idx] = m_IV[idx + 1]; + } + a_EncryptedOut[i] = a_PlainIn[i] ^ Buffer[0]; + m_IV[sizeof(m_IV) - 1] = a_EncryptedOut[i]; + } +} + + + + + diff --git a/src/PolarSSL++/AesCfb128Encryptor.h b/src/PolarSSL++/AesCfb128Encryptor.h new file mode 100644 index 000000000..9dbb5d2c3 --- /dev/null +++ b/src/PolarSSL++/AesCfb128Encryptor.h @@ -0,0 +1,50 @@ + +// AesCfb128Encryptor.h + +// Declares the cAesCfb128Encryptor class encrypting data using AES CFB-128 + + + + + +#pragma once + +#include "polarssl/aes.h" + + + + + +/** Encrypts data using the AES / CFB (128) algorithm */ +class cAesCfb128Encryptor +{ +public: + cAesCfb128Encryptor(void); + ~cAesCfb128Encryptor(); + + /** Initializes the decryptor with the specified Key / IV */ + void Init(const Byte a_Key[16], const Byte a_IV[16]); + + /** Encrypts a_Length bytes of the plain data; produces a_Length output bytes */ + void ProcessData(Byte * a_EncryptedOut, const Byte * a_PlainIn, size_t a_Length); + + /** Returns true if the object has been initialized with the Key / IV */ + bool IsValid(void) const { return m_IsValid; } + +protected: + aes_context m_Aes; + + /** The InitialVector, used by the CFB mode encryption */ + Byte m_IV[16]; + + /** Current offset in the m_IV, used by the CFB mode encryption */ + size_t m_IVOffset; + + /** Indicates whether the object has been initialized with the Key / IV */ + bool m_IsValid; +} ; + + + + + diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt index bf7720abc..b0a592760 100644 --- a/src/PolarSSL++/CMakeLists.txt +++ b/src/PolarSSL++/CMakeLists.txt @@ -5,27 +5,33 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") set(SOURCES - "BlockingSslClientSocket.cpp" - "BufferedSslContext.cpp" - "CallbackSslContext.cpp" - "CtrDrbgContext.cpp" - "EntropyContext.cpp" - "PublicKey.cpp" - "RsaPrivateKey.cpp" - "SslContext.cpp" - "X509Cert.cpp" + AesCfb128Decryptor.cpp + AesCfb128Encryptor.cpp + BlockingSslClientSocket.cpp + BufferedSslContext.cpp + CallbackSslContext.cpp + CtrDrbgContext.cpp + EntropyContext.cpp + PublicKey.cpp + RsaPrivateKey.cpp + Sha1Checksum.cpp + SslContext.cpp + X509Cert.cpp ) set(HEADERS - "BlockingSslClientSocket.h" - "BufferedSslContext.h" - "CallbackSslContext.h" - "CtrDrbgContext.h" - "EntropyContext.h" - "PublicKey.h" - "RsaPrivateKey.h" - "SslContext.h" - "X509Cert.h" + AesCfb128Decryptor.h + AesCfb128Encryptor.h + BlockingSslClientSocket.h + BufferedSslContext.h + CallbackSslContext.h + CtrDrbgContext.h + EntropyContext.h + PublicKey.h + RsaPrivateKey.h + SslContext.h + Sha1Checksum.h + X509Cert.h ) add_library(PolarSSL++ ${SOURCES} ${HEADERS}) diff --git a/src/PolarSSL++/Sha1Checksum.cpp b/src/PolarSSL++/Sha1Checksum.cpp new file mode 100644 index 000000000..a1ee9d7b9 --- /dev/null +++ b/src/PolarSSL++/Sha1Checksum.cpp @@ -0,0 +1,138 @@ + +// Sha1Checksum.cpp + +// Declares the cSha1Checksum class representing the SHA-1 checksum calculator + +#include "Globals.h" +#include "Sha1Checksum.h" + + + + + +/* +// Self-test the hash formatting for known values: +// sha1(Notch) : 4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48 +// sha1(jeb_) : -7c9d5b0044c130109a5d7b5fb5c317c02b4e28c1 +// sha1(simon) : 88e16a1019277b15d58faf0541e11910eb756f6 + +static class Test +{ +public: + Test(void) + { + AString DigestNotch, DigestJeb, DigestSimon; + Byte Digest[20]; + cSha1Checksum Checksum; + Checksum.Update((const Byte *)"Notch", 5); + Checksum.Finalize(Digest); + cSha1Checksum::DigestToJava(Digest, DigestNotch); + Checksum.Restart(); + Checksum.Update((const Byte *)"jeb_", 4); + Checksum.Finalize(Digest); + cSha1Checksum::DigestToJava(Digest, DigestJeb); + Checksum.Restart(); + Checksum.Update((const Byte *)"simon", 5); + Checksum.Finalize(Digest); + cSha1Checksum::DigestToJava(Digest, DigestSimon); + printf("Notch: \"%s\"\n", DigestNotch.c_str()); + printf("jeb_: \"%s\"\n", DigestJeb.c_str()); + printf("simon: \"%s\"\n", DigestSimon.c_str()); + assert(DigestNotch == "4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48"); + assert(DigestJeb == "-7c9d5b0044c130109a5d7b5fb5c317c02b4e28c1"); + assert(DigestSimon == "88e16a1019277b15d58faf0541e11910eb756f6"); + } +} test; +*/ + + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cSha1Checksum: + +cSha1Checksum::cSha1Checksum(void) : + m_DoesAcceptInput(true) +{ + sha1_starts(&m_Sha1); +} + + + + + +void cSha1Checksum::Update(const Byte * a_Data, size_t a_Length) +{ + ASSERT(m_DoesAcceptInput); // Not Finalize()-d yet, or Restart()-ed + + sha1_update(&m_Sha1, a_Data, a_Length); +} + + + + + +void cSha1Checksum::Finalize(cSha1Checksum::Checksum & a_Output) +{ + ASSERT(m_DoesAcceptInput); // Not Finalize()-d yet, or Restart()-ed + + sha1_finish(&m_Sha1, a_Output); + m_DoesAcceptInput = false; +} + + + + + +void cSha1Checksum::DigestToJava(const Checksum & a_Digest, AString & a_Out) +{ + Checksum Digest; + memcpy(Digest, a_Digest, sizeof(Digest)); + + bool IsNegative = (Digest[0] >= 0x80); + if (IsNegative) + { + // Two's complement: + bool carry = true; // Add one to the whole number + for (int i = 19; i >= 0; i--) + { + Digest[i] = ~Digest[i]; + if (carry) + { + carry = (Digest[i] == 0xff); + Digest[i]++; + } + } + } + a_Out.clear(); + a_Out.reserve(40); + for (int i = 0; i < 20; i++) + { + AppendPrintf(a_Out, "%02x", Digest[i]); + } + while ((a_Out.length() > 0) && (a_Out[0] == '0')) + { + a_Out.erase(0, 1); + } + if (IsNegative) + { + a_Out.insert(0, "-"); + } +} + + + + + + +void cSha1Checksum::Restart(void) +{ + sha1_starts(&m_Sha1); + m_DoesAcceptInput = true; +} + + + + diff --git a/src/PolarSSL++/Sha1Checksum.h b/src/PolarSSL++/Sha1Checksum.h new file mode 100644 index 000000000..68fdbcf1b --- /dev/null +++ b/src/PolarSSL++/Sha1Checksum.h @@ -0,0 +1,52 @@ + +// Sha1Checksum.h + +// Declares the cSha1Checksum class representing the SHA-1 checksum calculator + + + + + +#pragma once + +#include "polarssl/sha1.h" + + + + + +/** Calculates a SHA1 checksum for data stream */ +class cSha1Checksum +{ +public: + typedef Byte Checksum[20]; // The type used for storing the checksum + + cSha1Checksum(void); + + /** Adds the specified data to the checksum */ + void Update(const Byte * a_Data, size_t a_Length); + + /** Calculates and returns the final checksum */ + void Finalize(Checksum & a_Output); + + /** Returns true if the object is accepts more input data, false if Finalize()-d (need to Restart()) */ + bool DoesAcceptInput(void) const { return m_DoesAcceptInput; } + + /** Converts a raw 160-bit SHA1 digest into a Java Hex representation + According to http://wiki.vg/wiki/index.php?title=Protocol_Encryption&oldid=2802 + */ + static void DigestToJava(const Checksum & a_Digest, AString & a_JavaOut); + + /** Clears the current context and start a new checksum calculation */ + void Restart(void); + +protected: + /** True if the object is accepts more input data, false if Finalize()-d (need to Restart()) */ + bool m_DoesAcceptInput; + + sha1_context m_Sha1; +} ; + + + + diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index acfa5e811..f4717f592 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -18,19 +18,7 @@ #include "../WorldStorage/FastNBT.h" #include "../WorldStorage/EnchantmentSerializer.h" #include "../StringCompression.h" - -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable:4127) - #pragma warning(disable:4244) - #pragma warning(disable:4231) - #pragma warning(disable:4189) - #pragma warning(disable:4702) -#endif - -#ifdef _MSC_VER - #pragma warning(pop) -#endif +#include "PolarSSL++/Sha1Checksum.h" @@ -876,7 +864,7 @@ void cProtocol132::StartEncryption(const Byte * a_Key) m_IsEncrypted = true; // Prepare the m_AuthServerID: - cSHA1Checksum Checksum; + cSha1Checksum Checksum; cServer * Server = cRoot::Get()->GetServer(); AString ServerID = Server->GetServerID(); Checksum.Update((const Byte *)ServerID.c_str(), ServerID.length()); @@ -884,7 +872,7 @@ void cProtocol132::StartEncryption(const Byte * a_Key) Checksum.Update((const Byte *)Server->GetPublicKeyDER().data(), Server->GetPublicKeyDER().size()); Byte Digest[20]; Checksum.Finalize(Digest); - cSHA1Checksum::DigestToJava(Digest, m_AuthServerID); + cSha1Checksum::DigestToJava(Digest, m_AuthServerID); } diff --git a/src/Protocol/Protocol132.h b/src/Protocol/Protocol132.h index b280c8a41..32bc7d581 100644 --- a/src/Protocol/Protocol132.h +++ b/src/Protocol/Protocol132.h @@ -24,7 +24,8 @@ #pragma warning(pop) #endif -#include "../Crypto.h" +#include "PolarSSL++/AesCfb128Decryptor.h" +#include "PolarSSL++/AesCfb128Encryptor.h" @@ -79,8 +80,8 @@ public: protected: bool m_IsEncrypted; - cAESCFBDecryptor m_Decryptor; - cAESCFBEncryptor m_Encryptor; + cAesCfb128Decryptor m_Decryptor; + cAesCfb128Encryptor m_Encryptor; AString m_DataToSend; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 001b8c219..a6d566625 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -33,6 +33,7 @@ Implements the 1.7.x protocol classes: #include "../CompositeChat.h" #include "../Entities/ArrowEntity.h" #include "../Entities/FireworkEntity.h" +#include "PolarSSL++/Sha1Checksum.h" @@ -2293,7 +2294,7 @@ void cProtocol172::StartEncryption(const Byte * a_Key) m_IsEncrypted = true; // Prepare the m_AuthServerID: - cSHA1Checksum Checksum; + cSha1Checksum Checksum; cServer * Server = cRoot::Get()->GetServer(); const AString & ServerID = Server->GetServerID(); Checksum.Update((const Byte *)ServerID.c_str(), ServerID.length()); @@ -2301,7 +2302,7 @@ void cProtocol172::StartEncryption(const Byte * a_Key) Checksum.Update((const Byte *)Server->GetPublicKeyDER().data(), Server->GetPublicKeyDER().size()); Byte Digest[20]; Checksum.Finalize(Digest); - cSHA1Checksum::DigestToJava(Digest, m_AuthServerID); + cSha1Checksum::DigestToJava(Digest, m_AuthServerID); } diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 6a3e81eff..3f9c93357 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -30,7 +30,8 @@ Declares the 1.7.x protocol classes: #pragma warning(pop) #endif -#include "../Crypto.h" +#include "PolarSSL++/AesCfb128Decryptor.h" +#include "PolarSSL++/AesCfb128Encryptor.h" @@ -236,8 +237,8 @@ protected: bool m_IsEncrypted; - cAESCFBDecryptor m_Decryptor; - cAESCFBEncryptor m_Encryptor; + cAesCfb128Decryptor m_Decryptor; + cAesCfb128Decryptor m_Encryptor; /** The logfile where the comm is logged, when g_ShouldLogComm is true */ cFile m_CommLogFile; -- cgit v1.2.3 From c045bb3f4ccea1c357a726d73cd75d699cfe901c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 29 Apr 2014 17:45:20 +0200 Subject: Removed unneeded #includes. --- src/Protocol/Authenticator.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index f7008a5c4..8100b6395 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -10,12 +10,6 @@ #include "inifile/iniFile.h" #include "json/json.h" -#include "polarssl/config.h" -#include "polarssl/net.h" -#include "polarssl/ssl.h" -#include "polarssl/ctr_drbg.h" -#include "polarssl/error.h" - #include "PolarSSL++/BlockingSslClientSocket.h" #include -- cgit v1.2.3 From 1dbdb8ed912ff235538b9b2dc75575cadc3a5566 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 29 Apr 2014 23:10:50 +0200 Subject: Delayed sending the KeepAlive packet for 3 seconds after login. This should alleviate #889. --- src/ClientHandle.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index f3588c253..2362abe1e 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -336,6 +336,11 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID) // Send scoreboard data World->GetScoreBoard().SendTo(*this); + + // Delay the first ping until the client "settles down" + // This should fix #889, "BadCast exception, cannot convert bit to fm" error in client + cTimer t1; + m_LastPingTime = t1.GetNowTime() + 3000; // Send the first KeepAlive packet in 3 seconds cRoot::Get()->GetPluginManager()->CallHookPlayerSpawned(*m_Player); } -- cgit v1.2.3 From 58929a994830329120c68bf43cf6fcb8a90be960 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 30 Apr 2014 17:06:31 +0200 Subject: Removed the unused cBlockingTCPLink class. --- src/OSSupport/BlockingTCPLink.cpp | 142 -------------------------------------- src/OSSupport/BlockingTCPLink.h | 28 -------- src/Protocol/Authenticator.cpp | 1 - 3 files changed, 171 deletions(-) delete mode 100644 src/OSSupport/BlockingTCPLink.cpp delete mode 100644 src/OSSupport/BlockingTCPLink.h (limited to 'src') diff --git a/src/OSSupport/BlockingTCPLink.cpp b/src/OSSupport/BlockingTCPLink.cpp deleted file mode 100644 index 07f48b955..000000000 --- a/src/OSSupport/BlockingTCPLink.cpp +++ /dev/null @@ -1,142 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "BlockingTCPLink.h" -#include "Errors.h" - - - - -cBlockingTCPLink::cBlockingTCPLink(void) -{ -} - - - - - -cBlockingTCPLink::~cBlockingTCPLink() -{ - CloseSocket(); -} - - - - - -void cBlockingTCPLink::CloseSocket() -{ - if (!m_Socket.IsValid()) - { - m_Socket.CloseSocket(); - } -} - - - - - -bool cBlockingTCPLink::Connect(const char * iAddress, unsigned int iPort) -{ - ASSERT(!m_Socket.IsValid()); - if (m_Socket.IsValid()) - { - LOGWARN("WARNING: cTCPLink Connect() called while still connected."); - m_Socket.CloseSocket(); - } - - struct hostent *hp; - unsigned int addr; - struct sockaddr_in server; - - m_Socket = socket(AF_INET, SOCK_STREAM, 0); - if (!m_Socket.IsValid()) - { - LOGERROR("cTCPLink: Cannot create a socket"); - return false; - } - - addr = inet_addr(iAddress); - hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET); - if (hp == NULL) - { - //LOGWARN("cTCPLink: gethostbyaddr returned NULL"); - hp = gethostbyname(iAddress); - if (hp == NULL) - { - LOGWARN("cTCPLink: Could not resolve %s", iAddress); - CloseSocket(); - return false; - } - } - - memcpy(&server.sin_addr.s_addr,hp->h_addr, hp->h_length); - server.sin_family = AF_INET; - server.sin_port = htons( (unsigned short)iPort); - if (connect(m_Socket, (struct sockaddr *)&server, sizeof(server))) - { - LOGWARN("cTCPLink: Connection to \"%s:%d\" failed (%s)", iAddress, iPort,GetOSErrorString( cSocket::GetLastError() ).c_str() ); - CloseSocket(); - return false; - } - - return true; -} - - - - - -int cBlockingTCPLink::Send(char * a_Data, unsigned int a_Size, int a_Flags /* = 0 */ ) -{ - UNUSED(a_Flags); - - ASSERT(m_Socket.IsValid()); - if (!m_Socket.IsValid()) - { - LOGERROR("cBlockingTCPLink: Trying to send data without a valid connection!"); - return -1; - } - return m_Socket.Send(a_Data, a_Size); -} - - - - - -int cBlockingTCPLink::SendMessage( const char* a_Message, int a_Flags /* = 0 */ ) -{ - UNUSED(a_Flags); - - ASSERT(m_Socket.IsValid()); - if (!m_Socket.IsValid()) - { - LOGWARN("cBlockingTCPLink: Trying to send message without a valid connection!"); - return -1; - } - return m_Socket.Send(a_Message, strlen(a_Message)); -} - - - - - -void cBlockingTCPLink::ReceiveData(AString & oData) -{ - ASSERT(m_Socket.IsValid()); - if (!m_Socket.IsValid()) - { - return; - } - - int Received = 0; - char Buffer[256]; - while ((Received = recv(m_Socket, Buffer, sizeof(Buffer), 0)) > 0) - { - oData.append(Buffer, Received); - } -} - - - - diff --git a/src/OSSupport/BlockingTCPLink.h b/src/OSSupport/BlockingTCPLink.h deleted file mode 100644 index cb5f9e3f4..000000000 --- a/src/OSSupport/BlockingTCPLink.h +++ /dev/null @@ -1,28 +0,0 @@ - -#pragma once - -#include "Socket.h" - - - - - -class cBlockingTCPLink // tolua_export -{ // tolua_export -public: // tolua_export - cBlockingTCPLink(void); // tolua_export - ~cBlockingTCPLink(); // tolua_export - - bool Connect( const char* a_Address, unsigned int a_Port ); // tolua_export - int Send( char* a_Data, unsigned int a_Size, int a_Flags = 0 ); // tolua_export - int SendMessage( const char* a_Message, int a_Flags = 0 ); // tolua_export - void CloseSocket(); // tolua_export - void ReceiveData(AString & oData); // tolua_export -protected: - - cSocket m_Socket; -}; // tolua_export - - - - diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index 8100b6395..41d614e58 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -2,7 +2,6 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Authenticator.h" -#include "../OSSupport/BlockingTCPLink.h" #include "../Root.h" #include "../Server.h" #include "../ClientHandle.h" -- cgit v1.2.3 From ae2d18daeedafea47a775a3f319811d00bed260c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 30 Apr 2014 17:13:56 +0200 Subject: Ladders set as transparent. --- src/BlockInfo.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 6fb5aa5b3..def98fdf5 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -129,6 +129,7 @@ void cBlockInfo::Initialize(void) ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_Transparent = true; ms_Info[E_BLOCK_ICE ].m_Transparent = true; ms_Info[E_BLOCK_IRON_DOOR ].m_Transparent = true; + ms_Info[E_BLOCK_LADDER ].m_Transparent = true; ms_Info[E_BLOCK_LAVA ].m_Transparent = true; ms_Info[E_BLOCK_LEAVES ].m_Transparent = true; ms_Info[E_BLOCK_LEVER ].m_Transparent = true; -- cgit v1.2.3 From f2b579077649d5f40e0e60b53e60fe3b4804dada Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 30 Apr 2014 17:36:51 +0200 Subject: Fixed a warning when an empty item is being created. --- src/Item.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Item.h b/src/Item.h index 00316c188..641c681db 100644 --- a/src/Item.h +++ b/src/Item.h @@ -64,7 +64,7 @@ public: { if (!IsValidItem(m_ItemType)) { - if (m_ItemType != E_BLOCK_AIR) + if ((m_ItemType != E_BLOCK_AIR) && (m_ItemType != E_ITEM_EMPTY)) { LOGWARNING("%s: creating an invalid item type (%d), resetting to empty.", __FUNCTION__, a_ItemType); } -- cgit v1.2.3 From ab2dfb44faf94fcae4b9ca2af13aa14035e96a97 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 30 Apr 2014 17:37:25 +0200 Subject: If webadmin.ini doesn't exist, example one is written immediately. --- src/WebAdmin.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index 737705d7c..08e164d78 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -89,6 +89,7 @@ bool cWebAdmin::Init(void) m_IniFile.AddHeaderComment(" Password format: Password=*password*; for example:"); m_IniFile.AddHeaderComment(" [User:admin]"); m_IniFile.AddHeaderComment(" Password=admin"); + m_IniFile.WriteFile("webadmin.ini"); } if (!m_IniFile.GetValueSetB("WebAdmin", "Enabled", true)) -- cgit v1.2.3 From e6786074d58d81a230a6d5d01a5d89fa2f5ab16e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 00:27:42 +0200 Subject: Added cBufferedSslContext implementation. --- src/ByteBuffer.h | 40 +++++++++++++++++------------------ src/PolarSSL++/BufferedSslContext.cpp | 31 +++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/ByteBuffer.h b/src/ByteBuffer.h index 7656a5b13..c5ff05922 100644 --- a/src/ByteBuffer.h +++ b/src/ByteBuffer.h @@ -30,25 +30,25 @@ public: cByteBuffer(size_t a_BufferSize); ~cByteBuffer(); - /// Writes the bytes specified to the ringbuffer. Returns true if successful, false if not + /** Writes the bytes specified to the ringbuffer. Returns true if successful, false if not */ bool Write(const void * a_Bytes, size_t a_Count); - /// Returns the number of bytes that can be successfully written to the ringbuffer + /** Returns the number of bytes that can be successfully written to the ringbuffer */ size_t GetFreeSpace(void) const; - /// Returns the number of bytes that are currently in the ringbuffer. Note GetReadableBytes() + /** Returns the number of bytes that are currently in the ringbuffer. Note GetReadableBytes() */ size_t GetUsedSpace(void) const; - /// Returns the number of bytes that are currently available for reading (may be less than UsedSpace due to some data having been read already) + /** Returns the number of bytes that are currently available for reading (may be less than UsedSpace due to some data having been read already) */ size_t GetReadableSpace(void) const; - /// Returns the current data start index. For debugging purposes. + /** Returns the current data start index. For debugging purposes. */ size_t GetDataStart(void) const { return m_DataStart; } - /// Returns true if the specified amount of bytes are available for reading + /** Returns true if the specified amount of bytes are available for reading */ bool CanReadBytes(size_t a_Count) const; - /// Returns true if the specified amount of bytes are available for writing + /** Returns true if the specified amount of bytes are available for writing */ bool CanWriteBytes(size_t a_Count) const; // Read the specified datatype and advance the read pointer; return true if successfully read: @@ -65,7 +65,7 @@ public: bool ReadVarUTF8String (AString & a_Value); // string length as VarInt, then string as UTF-8 bool ReadLEInt (int & a_Value); - /// Reads VarInt, assigns it to anything that can be assigned from an UInt32 (unsigned short, char, Byte, double, ...) + /** Reads VarInt, assigns it to anything that can be assigned from an UInt32 (unsigned short, char, Byte, double, ...) */ template bool ReadVarInt(T & a_Value) { UInt32 v; @@ -91,37 +91,37 @@ public: bool WriteVarUTF8String (const AString & a_Value); // string length as VarInt, then string as UTF-8 bool WriteLEInt (int a_Value); - /// Reads a_Count bytes into a_Buffer; returns true if successful + /** Reads a_Count bytes into a_Buffer; returns true if successful */ bool ReadBuf(void * a_Buffer, size_t a_Count); - /// Writes a_Count bytes into a_Buffer; returns true if successful + /** Writes a_Count bytes into a_Buffer; returns true if successful */ bool WriteBuf(const void * a_Buffer, size_t a_Count); - /// Reads a_Count bytes into a_String; returns true if successful + /** Reads a_Count bytes into a_String; returns true if successful */ bool ReadString(AString & a_String, size_t a_Count); - /// Reads 2 * a_NumChars bytes and interprets it as a UTF16-BE string, converting it into UTF8 string a_String + /** Reads 2 * a_NumChars bytes and interprets it as a UTF16-BE string, converting it into UTF8 string a_String */ bool ReadUTF16String(AString & a_String, int a_NumChars); - /// Skips reading by a_Count bytes; returns false if not enough bytes in the ringbuffer + /** Skips reading by a_Count bytes; returns false if not enough bytes in the ringbuffer */ bool SkipRead(size_t a_Count); - /// Reads all available data into a_Data + /** Reads all available data into a_Data */ void ReadAll(AString & a_Data); - /// Reads the specified number of bytes and writes it into the destinatio bytebuffer. Returns true on success. + /** Reads the specified number of bytes and writes it into the destinatio bytebuffer. Returns true on success. */ bool ReadToByteBuffer(cByteBuffer & a_Dst, size_t a_NumBytes); - /// Removes the bytes that have been read from the ringbuffer + /** Removes the bytes that have been read from the ringbuffer */ void CommitRead(void); - /// Restarts next reading operation at the start of the ringbuffer + /** Restarts next reading operation at the start of the ringbuffer */ void ResetRead(void); - /// Re-reads the data that has been read since the last commit to the current readpos. Used by ProtoProxy to duplicate communication + /** Re-reads the data that has been read since the last commit to the current readpos. Used by ProtoProxy to duplicate communication */ void ReadAgain(AString & a_Out); - /// Checks if the internal state is valid (read and write positions in the correct bounds) using ASSERTs + /** Checks if the internal state is valid (read and write positions in the correct bounds) using ASSERTs */ void CheckValid(void) const; protected: @@ -136,7 +136,7 @@ protected: size_t m_WritePos; // Where the data ends in the ringbuffer size_t m_ReadPos; // Where the next read will start in the ringbuffer - /// Advances the m_ReadPos by a_Count bytes + /** Advances the m_ReadPos by a_Count bytes */ void AdvanceReadPos(size_t a_Count); } ; diff --git a/src/PolarSSL++/BufferedSslContext.cpp b/src/PolarSSL++/BufferedSslContext.cpp index 885b30c68..2455d5781 100644 --- a/src/PolarSSL++/BufferedSslContext.cpp +++ b/src/PolarSSL++/BufferedSslContext.cpp @@ -20,6 +20,37 @@ cBufferedSslContext::cBufferedSslContext(size_t a_BufferSize): +size_t cBufferedSslContext::WriteIncoming(const void * a_Data, size_t a_NumBytes) +{ + size_t NumBytes = std::min(m_IncomingData.GetFreeSpace(), a_NumBytes); + if (NumBytes > 0) + { + m_IncomingData.Write(a_Data, NumBytes); + return a_NumBytes - NumBytes; + } + return 0; +} + + + + + +size_t cBufferedSslContext::ReadOutgoing(void * a_Data, size_t a_DataMaxSize) +{ + size_t NumBytes = std::min(m_OutgoingData.GetReadableSpace(), a_DataMaxSize); + if (NumBytes > 0) + { + m_OutgoingData.ReadBuf(a_Data, NumBytes); + m_OutgoingData.CommitRead(); + return a_DataMaxSize - NumBytes; + } + return 0; +} + + + + + int cBufferedSslContext::ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) { // Called when PolarSSL wants to read encrypted data from the SSL peer -- cgit v1.2.3 From 47feb91e57f83c81722188ec3025c3109758dd33 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 00:28:27 +0200 Subject: cSslContext supports setting own cert / privkey. --- src/PolarSSL++/PublicKey.cpp | 82 ++++++++++++++++++++++++++++++++++++++++-- src/PolarSSL++/PublicKey.h | 32 +++++++++++++++-- src/PolarSSL++/RsaPrivateKey.h | 8 +++++ src/PolarSSL++/SslContext.cpp | 50 +++++++++++++++++++++++++- src/PolarSSL++/SslContext.h | 22 +++++++++++- 5 files changed, 187 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/PolarSSL++/PublicKey.cpp b/src/PolarSSL++/PublicKey.cpp index 49794a0c8..dae026082 100644 --- a/src/PolarSSL++/PublicKey.cpp +++ b/src/PolarSSL++/PublicKey.cpp @@ -10,15 +10,44 @@ -cPublicKey::cPublicKey(const AString & a_PublicKeyDER) +cPublicKey::cPublicKey(void) { pk_init(&m_Pk); - if (pk_parse_public_key(&m_Pk, (const Byte *)a_PublicKeyDER.data(), a_PublicKeyDER.size()) != 0) + m_CtrDrbg.Initialize("rsa_pubkey", 10); +} + + + + + +cPublicKey::cPublicKey(const AString & a_PublicKeyData) +{ + pk_init(&m_Pk); + m_CtrDrbg.Initialize("rsa_pubkey", 10); + int res = ParsePublic(a_PublicKeyData.data(), a_PublicKeyData.size()); + if (res != 0) { + LOGWARNING("Failed to parse public key: -0x%x", res); + ASSERT(!"Cannot parse PubKey"); + return; + } +} + + + + + +cPublicKey::cPublicKey(const AString & a_PrivateKeyData, const AString & a_Password) +{ + pk_init(&m_Pk); + m_CtrDrbg.Initialize("rsa_privkey", 11); + int res = ParsePrivate(a_PrivateKeyData.data(), a_PrivateKeyData.size(), a_Password); + if (res != 0) + { + LOGWARNING("Failed to parse private key: -0x%x", res); ASSERT(!"Cannot parse PubKey"); return; } - m_CtrDrbg.Initialize("rsa_pubkey", 10); } @@ -36,6 +65,8 @@ cPublicKey::~cPublicKey() int cPublicKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength) { + ASSERT(IsValid()); + size_t DecryptedLen = a_DecryptedMaxLength; int res = pk_decrypt(&m_Pk, a_EncryptedData, a_EncryptedLength, @@ -55,6 +86,8 @@ int cPublicKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, int cPublicKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength) { + ASSERT(IsValid()); + size_t EncryptedLength = a_EncryptedMaxLength; int res = pk_encrypt(&m_Pk, a_PlainData, a_PlainLength, a_EncryptedData, &EncryptedLength, a_EncryptedMaxLength, @@ -71,3 +104,46 @@ int cPublicKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a + +int cPublicKey::ParsePublic(const void * a_Data, size_t a_NumBytes) +{ + ASSERT(!IsValid()); // Cannot parse a second key + + return pk_parse_public_key(&m_Pk, (const unsigned char *)a_Data, a_NumBytes); +} + + + + + + +int cPublicKey::ParsePrivate(const void * a_Data, size_t a_NumBytes, const AString & a_Password) +{ + ASSERT(!IsValid()); // Cannot parse a second key + + if (a_Password.empty()) + { + return pk_parse_key(&m_Pk, (const unsigned char *)a_Data, a_NumBytes, NULL, 0); + } + else + { + return pk_parse_key( + &m_Pk, + (const unsigned char *)a_Data, a_NumBytes, + (const unsigned char *)a_Password.c_str(), a_Password.size() + ); + } +} + + + + + +bool cPublicKey::IsValid(void) const +{ + return (pk_get_type(&m_Pk) != POLARSSL_PK_NONE); +} + + + + diff --git a/src/PolarSSL++/PublicKey.h b/src/PolarSSL++/PublicKey.h index 5a0a57147..df52a4143 100644 --- a/src/PolarSSL++/PublicKey.h +++ b/src/PolarSSL++/PublicKey.h @@ -18,9 +18,18 @@ class cPublicKey { + friend class cSslContext; + public: - /** Constructs the public key out of the DER-encoded pubkey data */ - cPublicKey(const AString & a_PublicKeyDER); + /** Constructs an empty key instance. Before use, it needs to be filled by ParsePublic() or ParsePrivate() */ + cPublicKey(void); + + /** Constructs the public key out of the DER- or PEM-encoded pubkey data */ + cPublicKey(const AString & a_PublicKeyData); + + /** Constructs the private key out of the DER- or PEM-encoded privkey data, with the specified password. + If a_Password is empty, no password is assumed. */ + cPublicKey(const AString & a_PrivateKeyData, const AString & a_Password); ~cPublicKey(); @@ -33,6 +42,20 @@ public: Both a_EncryptedData and a_DecryptedData must be at least bytes large. Returns the number of bytes decrypted, or negative number for error. */ int Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength); + + /** Parses the specified data into a public key representation. + The key can be DER- or PEM-encoded. + Returns 0 on success, PolarSSL error code on failure. */ + int ParsePublic(const void * a_Data, size_t a_NumBytes); + + /** Parses the specified data into a private key representation. + If a_Password is empty, no password is assumed. + The key can be DER- or PEM-encoded. + Returns 0 on success, PolarSSL error code on failure. */ + int ParsePrivate(const void * a_Data, size_t a_NumBytes, const AString & a_Password); + + /** Returns true if the contained key is valid. */ + bool IsValid(void) const; protected: /** The public key PolarSSL representation */ @@ -40,8 +63,13 @@ protected: /** The random generator used in encryption and decryption */ cCtrDrbgContext m_CtrDrbg; + + + /** Returns the internal context ptr. Only use in PolarSSL API calls. */ + pk_context * GetInternal(void) { return &m_Pk; } } ; +typedef SharedPtr cPublicKeyPtr; diff --git a/src/PolarSSL++/RsaPrivateKey.h b/src/PolarSSL++/RsaPrivateKey.h index ffacde11b..4d03f27df 100644 --- a/src/PolarSSL++/RsaPrivateKey.h +++ b/src/PolarSSL++/RsaPrivateKey.h @@ -19,6 +19,8 @@ /** Encapsulates an RSA private key used in PKI cryptography */ class cRsaPrivateKey { + friend class cSslContext; + public: /** Creates a new empty object, the key is not assigned */ cRsaPrivateKey(void); @@ -51,8 +53,14 @@ protected: /** The random generator used for generating the key and encryption / decryption */ cCtrDrbgContext m_CtrDrbg; + + + /** Returns the internal context ptr. Only use in PolarSSL API calls. */ + rsa_context * GetInternal(void) { return &m_Rsa; } } ; +typedef SharedPtr cRsaPrivateKeyPtr; + diff --git a/src/PolarSSL++/SslContext.cpp b/src/PolarSSL++/SslContext.cpp index 1994cf844..3d2b8cef7 100644 --- a/src/PolarSSL++/SslContext.cpp +++ b/src/PolarSSL++/SslContext.cpp @@ -40,7 +40,7 @@ int cSslContext::Initialize(bool a_IsClient, const SharedPtr & if (m_IsValid) { LOGWARNING("SSL: Double initialization is not supported."); - return POLARSSL_ERR_SSL_MALLOC_FAILED; // There is no return value well-suited for this, reuse this one. + return POLARSSL_ERR_SSL_BAD_INPUT_DATA; // There is no return value well-suited for this, reuse this one. } // Set the CtrDrbg context, create a new one if needed: @@ -80,8 +80,56 @@ int cSslContext::Initialize(bool a_IsClient, const SharedPtr & +void cSslContext::SetOwnCert(const cX509CertPtr & a_OwnCert, const cRsaPrivateKeyPtr & a_OwnCertPrivKey) +{ + ASSERT(m_IsValid); // Call Initialize() first + + // Check that both the cert and the key is valid: + if ((a_OwnCert.get() == NULL) || (a_OwnCertPrivKey.get() == NULL)) + { + LOGWARNING("SSL: Own certificate is not valid, skipping the set."); + return; + } + + // Make sure we have the cert stored for later, PolarSSL only uses the cert later on + m_OwnCert = a_OwnCert; + m_OwnCertPrivKey = a_OwnCertPrivKey; + + // Set into the context: + ssl_set_own_cert_rsa(&m_Ssl, m_OwnCert->GetInternal(), m_OwnCertPrivKey->GetInternal()); +} + + + + + +void cSslContext::SetOwnCert(const cX509CertPtr & a_OwnCert, const cPublicKeyPtr & a_OwnCertPrivKey) +{ + ASSERT(m_IsValid); // Call Initialize() first + + // Check that both the cert and the key is valid: + if ((a_OwnCert.get() == NULL) || (a_OwnCertPrivKey.get() == NULL)) + { + LOGWARNING("SSL: Own certificate is not valid, skipping the set."); + return; + } + + // Make sure we have the cert stored for later, PolarSSL only uses the cert later on + m_OwnCert = a_OwnCert; + m_OwnCertPrivKey2 = a_OwnCertPrivKey; + + // Set into the context: + ssl_set_own_cert(&m_Ssl, m_OwnCert->GetInternal(), m_OwnCertPrivKey2->GetInternal()); +} + + + + + void cSslContext::SetCACerts(const cX509CertPtr & a_CACert, const AString & a_ExpectedPeerName) { + ASSERT(m_IsValid); // Call Initialize() first + // Store the data in our internal buffers, to avoid losing the pointers later on // PolarSSL will need these after this call returns, and the caller may move / delete the data before that: m_ExpectedPeerName = a_ExpectedPeerName; diff --git a/src/PolarSSL++/SslContext.h b/src/PolarSSL++/SslContext.h index 85add5f8b..273939b9f 100644 --- a/src/PolarSSL++/SslContext.h +++ b/src/PolarSSL++/SslContext.h @@ -11,6 +11,8 @@ #include "polarssl/ssl.h" #include "../ByteBuffer.h" +#include "PublicKey.h" +#include "RsaPrivateKey.h" #include "X509Cert.h" @@ -47,7 +49,16 @@ public: /** Returns true if the object has been initialized properly. */ bool IsValid(void) const { return m_IsValid; } - /** Sets a cert chain as the trusted cert store for this context. + /** Sets the certificate to use as our own. Must be used when representing a server, optional when client. + Must be called after Initialize(). */ + void SetOwnCert(const cX509CertPtr & a_OwnCert, const cRsaPrivateKeyPtr & a_OwnCertPrivKey); + + /** Sets the certificate to use as our own. Must be used when representing a server, optional when client. + Must be called after Initialize(). + Despite the class name, a_OwnCertPrivKey is a PRIVATE key. */ + void SetOwnCert(const cX509CertPtr & a_OwnCert, const cPublicKeyPtr & a_OwnCertPrivKey); + + /** Sets a cert chain as the trusted cert store for this context. Must be called after Initialize(). Calling this will switch the context into strict cert verification mode. a_ExpectedPeerName is the CommonName that we expect the SSL peer to have in its cert, if it is different, the verification will fail. An empty string will disable the CN check. */ @@ -93,6 +104,15 @@ protected: /** The SSL context that PolarSSL uses. */ ssl_context m_Ssl; + /** The certificate that we present to the peer. */ + cX509CertPtr m_OwnCert; + + /** Private key for m_OwnCert, if initialized from a cRsaPrivateKey */ + cRsaPrivateKeyPtr m_OwnCertPrivKey; + + /** Private key for m_OwnCert, if initialized from a cPublicKey. Despite the class name, this is a PRIVATE key. */ + cPublicKeyPtr m_OwnCertPrivKey2; + /** True if the SSL handshake has been completed. */ bool m_HasHandshaken; -- cgit v1.2.3 From e2bf3783e8c8f7855532e04203bb1b46b976cfee Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 11:32:25 +0200 Subject: Fixed BufferedSslContext's buffer reading and writing. --- src/PolarSSL++/BufferedSslContext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/PolarSSL++/BufferedSslContext.cpp b/src/PolarSSL++/BufferedSslContext.cpp index 2455d5781..9f7caeb8a 100644 --- a/src/PolarSSL++/BufferedSslContext.cpp +++ b/src/PolarSSL++/BufferedSslContext.cpp @@ -26,7 +26,7 @@ size_t cBufferedSslContext::WriteIncoming(const void * a_Data, size_t a_NumBytes if (NumBytes > 0) { m_IncomingData.Write(a_Data, NumBytes); - return a_NumBytes - NumBytes; + return NumBytes; } return 0; } @@ -42,7 +42,7 @@ size_t cBufferedSslContext::ReadOutgoing(void * a_Data, size_t a_DataMaxSize) { m_OutgoingData.ReadBuf(a_Data, NumBytes); m_OutgoingData.CommitRead(); - return a_DataMaxSize - NumBytes; + return NumBytes; } return 0; } -- cgit v1.2.3 From e1b6a169457b267c3e11bbdb9e58e9ab7b3f0136 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 11:33:29 +0200 Subject: Added a (disabled) test of low-security ciphersuites. Enabling this allows the connection to be sniffed and decoded using Wireshark, when given the SSL private key. --- src/PolarSSL++/SslContext.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/PolarSSL++/SslContext.cpp b/src/PolarSSL++/SslContext.cpp index 3d2b8cef7..df0219610 100644 --- a/src/PolarSSL++/SslContext.cpp +++ b/src/PolarSSL++/SslContext.cpp @@ -70,6 +70,18 @@ int cSslContext::Initialize(bool a_IsClient, const SharedPtr & ssl_set_dbg(&m_Ssl, &SSLDebugMessage, this); ssl_set_verify(&m_Ssl, &SSLVerifyCert, this); */ + + /* + // Set ciphersuite to the easiest one to decode, so that the connection can be wireshark-decoded: + static const int CipherSuites[] = + { + TLS_RSA_WITH_RC4_128_MD5, + TLS_RSA_WITH_RC4_128_SHA, + TLS_RSA_WITH_AES_128_CBC_SHA, + 0, // Must be 0-terminated! + }; + ssl_set_ciphersuites(&m_Ssl, CipherSuites); + */ #endif m_IsValid = true; -- cgit v1.2.3 From a04cb6d146dfb8f04b0a8943c1e185fc25bf2829 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 11:34:15 +0200 Subject: Fixed HTTP message parsing, prepared for SSL. --- src/HTTPServer/HTTPConnection.cpp | 5 +++-- src/HTTPServer/HTTPMessage.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/HTTPServer/HTTPConnection.cpp b/src/HTTPServer/HTTPConnection.cpp index da4df0e34..8e95eff2d 100644 --- a/src/HTTPServer/HTTPConnection.cpp +++ b/src/HTTPServer/HTTPConnection.cpp @@ -26,6 +26,7 @@ cHTTPConnection::cHTTPConnection(cHTTPServer & a_HTTPServer) : cHTTPConnection::~cHTTPConnection() { + // LOGD("HTTP: Connection deleting: %p", this); delete m_CurrentRequest; } @@ -183,11 +184,11 @@ void cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size) // Process the rest of the incoming data into the request body: if (a_Size > BytesConsumed) { - DataReceived(a_Data + BytesConsumed, a_Size - BytesConsumed); + cHTTPConnection::DataReceived(a_Data + BytesConsumed, a_Size - BytesConsumed); } else { - DataReceived("", 0); // If the request has zero body length, let it be processed right-away + cHTTPConnection::DataReceived("", 0); // If the request has zero body length, let it be processed right-away } break; } diff --git a/src/HTTPServer/HTTPMessage.cpp b/src/HTTPServer/HTTPMessage.cpp index 4a3611050..44feda469 100644 --- a/src/HTTPServer/HTTPMessage.cpp +++ b/src/HTTPServer/HTTPMessage.cpp @@ -201,7 +201,7 @@ size_t cHTTPRequest::ParseRequestLine(const char * a_Data, size_t a_Size) return AString::npos; } // Check that there's HTTP/version at the end - if (strncmp(a_Data + URLEnd + 1, "HTTP/1.", 7) != 0) + if (strncmp(m_IncomingHeaderData.c_str() + URLEnd + 1, "HTTP/1.", 7) != 0) { m_IsValid = false; return AString::npos; -- cgit v1.2.3 From 272c232efb645c9f7d75556aeb047e13b244c9ed Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 11:48:03 +0200 Subject: Implemented SSL connection for WebAdmin. Fixes FS-319. --- src/HTTPServer/HTTPServer.cpp | 35 +++++++++++- src/HTTPServer/HTTPServer.h | 10 ++++ src/HTTPServer/SslHTTPConnection.cpp | 103 +++++++++++++++++++++++++++++++++++ src/HTTPServer/SslHTTPConnection.h | 45 +++++++++++++++ 4 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 src/HTTPServer/SslHTTPConnection.cpp create mode 100644 src/HTTPServer/SslHTTPConnection.h (limited to 'src') diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp index eaf8405a3..9e3e0a17b 100644 --- a/src/HTTPServer/HTTPServer.cpp +++ b/src/HTTPServer/HTTPServer.cpp @@ -8,6 +8,7 @@ #include "HTTPMessage.h" #include "HTTPConnection.h" #include "HTTPFormParser.h" +#include "SslHTTPConnection.h" @@ -123,8 +124,30 @@ class cDebugCallbacks : cHTTPServer::cHTTPServer(void) : m_ListenThreadIPv4(*this, cSocket::IPv4, "WebServer IPv4"), m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer IPv6"), - m_Callbacks(NULL) + m_Callbacks(NULL), + m_Cert(new cX509Cert), + m_CertPrivKey(new cPublicKey) { + AString CertFile = cFile::ReadWholeFile("webadmin/httpscert.crt"); + AString KeyFile = cFile::ReadWholeFile("webadmin/httpskey.pem"); + if (!CertFile.empty() && !KeyFile.empty()) + { + int res = m_Cert->Parse(CertFile.data(), CertFile.size()); + if (res == 0) + { + int res2 = m_CertPrivKey->ParsePrivate(KeyFile.data(), KeyFile.size(), ""); + if (res2 != 0) + { + // Reading the private key failed, reset the cert: + LOGWARNING("WebAdmin: Cannot read HTTPS certificate private key: -0x%x", -res2); + m_Cert.reset(); + } + } + else + { + LOGWARNING("WebAdmin: Cannot read HTTPS certificate: -0x%x", -res); + } + } } @@ -195,7 +218,15 @@ void cHTTPServer::Stop(void) void cHTTPServer::OnConnectionAccepted(cSocket & a_Socket) { - cHTTPConnection * Connection = new cHTTPConnection(*this); + cHTTPConnection * Connection; + if (m_Cert.get() != NULL) + { + Connection = new cSslHTTPConnection(*this, m_Cert, m_CertPrivKey); + } + else + { + Connection = new cHTTPConnection(*this); + } m_SocketThreads.AddClient(a_Socket, Connection); cCSLock Lock(m_CSConnections); m_Connections.push_back(Connection); diff --git a/src/HTTPServer/HTTPServer.h b/src/HTTPServer/HTTPServer.h index 8eff7d879..eb91dd5a3 100644 --- a/src/HTTPServer/HTTPServer.h +++ b/src/HTTPServer/HTTPServer.h @@ -12,6 +12,9 @@ #include "../OSSupport/ListenThread.h" #include "../OSSupport/SocketThreads.h" #include "inifile/iniFile.h" +#include "PolarSSL++/RsaPrivateKey.h" +#include "PolarSSL++/PublicKey.h" +#include "PolarSSL++/X509Cert.h" @@ -66,6 +69,7 @@ public: protected: friend class cHTTPConnection; + friend class cSslHTTPConnection; cListenThread m_ListenThreadIPv4; cListenThread m_ListenThreadIPv6; @@ -78,6 +82,12 @@ protected: /// The callbacks to call for various events cCallbacks * m_Callbacks; + /** The server certificate to use for the SSL connections */ + cX509CertPtr m_Cert; + + /** The private key for m_Cert. Despite the class name, this is the PRIVATE key. */ + cPublicKeyPtr m_CertPrivKey; + // cListenThread::cCallback overrides: virtual void OnConnectionAccepted(cSocket & a_Socket) override; diff --git a/src/HTTPServer/SslHTTPConnection.cpp b/src/HTTPServer/SslHTTPConnection.cpp new file mode 100644 index 000000000..fff96bb2e --- /dev/null +++ b/src/HTTPServer/SslHTTPConnection.cpp @@ -0,0 +1,103 @@ + +// SslHTTPConnection.cpp + +// Implements the cSslHTTPConnection class representing a HTTP connection made over a SSL link + +#include "Globals.h" +#include "SslHTTPConnection.h" +#include "HTTPServer.h" + + + + + +cSslHTTPConnection::cSslHTTPConnection(cHTTPServer & a_HTTPServer, const cX509CertPtr & a_Cert, const cPublicKeyPtr & a_PrivateKey) : + super(a_HTTPServer), + m_Ssl(64000), + m_Cert(a_Cert), + m_PrivateKey(a_PrivateKey) +{ + m_Ssl.Initialize(false); + m_Ssl.SetOwnCert(a_Cert, a_PrivateKey); +} + + + + + +void cSslHTTPConnection::DataReceived(const char * a_Data, size_t a_Size) +{ + // If there is outgoing data in the queue, notify the server that it should write it out: + if (!m_OutgoingData.empty()) + { + m_HTTPServer.NotifyConnectionWrite(*this); + } + + // Process the received data: + const char * Data = a_Data; + size_t Size = a_Size; + for (;;) + { + // Try to write as many bytes into Ssl's "incoming" buffer as possible: + size_t BytesWritten = 0; + if (Size > 0) + { + BytesWritten = m_Ssl.WriteIncoming(Data, Size); + Data += BytesWritten; + Size -= BytesWritten; + } + + // Try to read as many bytes from SSL's decryption as possible: + char Buffer[32000]; + int NumRead = m_Ssl.ReadPlain(Buffer, sizeof(Buffer)); + if (NumRead > 0) + { + super::DataReceived(Buffer, (size_t)NumRead); + } + + // If both failed, bail out: + if ((BytesWritten == 0) && (NumRead <= 0)) + { + return; + } + } +} + + + + + +void cSslHTTPConnection::GetOutgoingData(AString & a_Data) +{ + for (;;) + { + // Write as many bytes from our buffer to SSL's encryption as possible: + int NumWritten = 0; + if (!m_OutgoingData.empty()) + { + NumWritten = m_Ssl.WritePlain(m_OutgoingData.data(), m_OutgoingData.size()); + if (NumWritten > 0) + { + m_OutgoingData.erase(0, (size_t)NumWritten); + } + } + + // Read as many bytes from SSL's "outgoing" buffer as possible: + char Buffer[32000]; + size_t NumBytes = m_Ssl.ReadOutgoing(Buffer, sizeof(Buffer)); + if (NumBytes > 0) + { + a_Data.append(Buffer, NumBytes); + } + + // If both failed, bail out: + if ((NumWritten <= 0) && (NumBytes == 0)) + { + return; + } + } +} + + + + diff --git a/src/HTTPServer/SslHTTPConnection.h b/src/HTTPServer/SslHTTPConnection.h new file mode 100644 index 000000000..2a648e8c8 --- /dev/null +++ b/src/HTTPServer/SslHTTPConnection.h @@ -0,0 +1,45 @@ + +// SslHTTPConnection.h + +// Declared the cSslHTTPConnection class representing a HTTP connection made over a SSL link + + + + + +#pragma once + +#include "HTTPConnection.h" +#include "PolarSSL++/BufferedSslContext.h" + + + + + +class cSslHTTPConnection : + public cHTTPConnection +{ + typedef cHTTPConnection super; + +public: + /** Creates a new connection on the specified server; sends the specified cert as the server certificate, + uses the private key for decryption. a_Private key is, despite the class name, a PRIVATE key for the cert. */ + cSslHTTPConnection(cHTTPServer & a_HTTPServer, const cX509CertPtr & a_Cert, const cPublicKeyPtr & a_PrivateKey); + +protected: + cBufferedSslContext m_Ssl; + + /** The certificate to send to the client */ + cX509CertPtr m_Cert; + + /** The private key used for the certificate */ + cPublicKeyPtr m_PrivateKey; + + // cHTTPConnection overrides: + virtual void DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client + virtual void GetOutgoingData(AString & a_Data) override; // Data can be sent to client +} ; + + + + -- cgit v1.2.3 From 60850fe3e8da936d5b24460f33a1bf8f4d321ace Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 15:08:15 +0200 Subject: Fixed crashes in the SSL HTTP connection. --- src/ClientHandle.cpp | 3 ++- src/ClientHandle.h | 2 +- src/HTTPServer/HTTPConnection.cpp | 14 +++++++------- src/HTTPServer/HTTPConnection.h | 12 +++++++++--- src/HTTPServer/SslHTTPConnection.cpp | 10 +++++++--- src/HTTPServer/SslHTTPConnection.h | 2 +- src/OSSupport/SocketThreads.h | 6 ++++-- src/RCONServer.cpp | 8 ++++---- src/RCONServer.h | 2 +- 9 files changed, 36 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 2362abe1e..a2bfdd381 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -2649,12 +2649,13 @@ void cClientHandle::PacketError(unsigned char a_PacketType) -void cClientHandle::DataReceived(const char * a_Data, size_t a_Size) +bool cClientHandle::DataReceived(const char * a_Data, size_t a_Size) { // Data is received from the client, store it in the buffer to be processed by the Tick thread: m_TimeSinceLastPacket = 0; cCSLock Lock(m_CSIncomingData); m_IncomingData.append(a_Data, a_Size); + return false; } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 9f8d44129..ac44e43dc 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -387,7 +387,7 @@ private: void HandleCommandBlockMessage(const char * a_Data, unsigned int a_Length); // cSocketThreads::cCallback overrides: - virtual void DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client + virtual bool DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client virtual void GetOutgoingData(AString & a_Data) override; // Data can be sent to client virtual void SocketClosed (void) override; // The socket has been closed for any reason }; // tolua_export diff --git a/src/HTTPServer/HTTPConnection.cpp b/src/HTTPServer/HTTPConnection.cpp index 8e95eff2d..b127e7091 100644 --- a/src/HTTPServer/HTTPConnection.cpp +++ b/src/HTTPServer/HTTPConnection.cpp @@ -145,7 +145,7 @@ void cHTTPConnection::Terminate(void) -void cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size) +bool cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size) { switch (m_State) { @@ -163,12 +163,12 @@ void cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size) m_CurrentRequest = NULL; m_State = wcsInvalid; m_HTTPServer.CloseConnection(*this); - return; + return true; } if (m_CurrentRequest->IsInHeaders()) { // The request headers are not yet complete - return; + return false; } // The request has finished parsing its headers successfully, notify of it: @@ -184,13 +184,12 @@ void cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size) // Process the rest of the incoming data into the request body: if (a_Size > BytesConsumed) { - cHTTPConnection::DataReceived(a_Data + BytesConsumed, a_Size - BytesConsumed); + return cHTTPConnection::DataReceived(a_Data + BytesConsumed, a_Size - BytesConsumed); } else { - cHTTPConnection::DataReceived("", 0); // If the request has zero body length, let it be processed right-away + return cHTTPConnection::DataReceived("", 0); // If the request has zero body length, let it be processed right-away } - break; } case wcsRecvBody: @@ -210,7 +209,7 @@ void cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size) { m_State = wcsInvalid; m_HTTPServer.CloseConnection(*this); - return; + return true; } delete m_CurrentRequest; m_CurrentRequest = NULL; @@ -224,6 +223,7 @@ void cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size) break; } } + return false; } diff --git a/src/HTTPServer/HTTPConnection.h b/src/HTTPServer/HTTPConnection.h index fc11f1ba6..6ea8a1ae8 100644 --- a/src/HTTPServer/HTTPConnection.h +++ b/src/HTTPServer/HTTPConnection.h @@ -91,9 +91,15 @@ protected: // cSocketThreads::cCallback overrides: - virtual void DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client - virtual void GetOutgoingData(AString & a_Data) override; // Data can be sent to client - virtual void SocketClosed (void) override; // The socket has been closed for any reason + /** Data is received from the client. + Returns true if the connection has been closed as the result of parsing the data. */ + virtual bool DataReceived(const char * a_Data, size_t a_Size) override; + + /** Data can be sent to client */ + virtual void GetOutgoingData(AString & a_Data) override; + + /** The socket has been closed for any reason */ + virtual void SocketClosed(void) override; } ; typedef std::vector cHTTPConnections; diff --git a/src/HTTPServer/SslHTTPConnection.cpp b/src/HTTPServer/SslHTTPConnection.cpp index fff96bb2e..b6b222b47 100644 --- a/src/HTTPServer/SslHTTPConnection.cpp +++ b/src/HTTPServer/SslHTTPConnection.cpp @@ -25,7 +25,7 @@ cSslHTTPConnection::cSslHTTPConnection(cHTTPServer & a_HTTPServer, const cX509Ce -void cSslHTTPConnection::DataReceived(const char * a_Data, size_t a_Size) +bool cSslHTTPConnection::DataReceived(const char * a_Data, size_t a_Size) { // If there is outgoing data in the queue, notify the server that it should write it out: if (!m_OutgoingData.empty()) @@ -52,13 +52,17 @@ void cSslHTTPConnection::DataReceived(const char * a_Data, size_t a_Size) int NumRead = m_Ssl.ReadPlain(Buffer, sizeof(Buffer)); if (NumRead > 0) { - super::DataReceived(Buffer, (size_t)NumRead); + if (super::DataReceived(Buffer, (size_t)NumRead)) + { + // The socket has been closed, and the object is already deleted. Bail out. + return true; + } } // If both failed, bail out: if ((BytesWritten == 0) && (NumRead <= 0)) { - return; + return false; } } } diff --git a/src/HTTPServer/SslHTTPConnection.h b/src/HTTPServer/SslHTTPConnection.h index 2a648e8c8..653acbfce 100644 --- a/src/HTTPServer/SslHTTPConnection.h +++ b/src/HTTPServer/SslHTTPConnection.h @@ -36,7 +36,7 @@ protected: cPublicKeyPtr m_PrivateKey; // cHTTPConnection overrides: - virtual void DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client + virtual bool DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client virtual void GetOutgoingData(AString & a_Data) override; // Data can be sent to client } ; diff --git a/src/OSSupport/SocketThreads.h b/src/OSSupport/SocketThreads.h index 679e374e1..944f5f3bc 100644 --- a/src/OSSupport/SocketThreads.h +++ b/src/OSSupport/SocketThreads.h @@ -63,8 +63,10 @@ public: // Force a virtual destructor in all subclasses: virtual ~cCallback() {} - /** Called when data is received from the remote party */ - virtual void DataReceived(const char * a_Data, size_t a_Size) = 0; + /** Called when data is received from the remote party. + SocketThreads does not care about the return value, others can use it for their specific purpose - + for example HTTPServer uses it to signal if the connection was terminated as a result of the data received. */ + virtual bool DataReceived(const char * a_Data, size_t a_Size) = 0; /** Called when data can be sent to remote party The function is supposed to *set* outgoing data to a_Data (overwrite) */ diff --git a/src/RCONServer.cpp b/src/RCONServer.cpp index d7083ff2b..fd4b26cab 100644 --- a/src/RCONServer.cpp +++ b/src/RCONServer.cpp @@ -169,7 +169,7 @@ cRCONServer::cConnection::cConnection(cRCONServer & a_RCONServer, cSocket & a_So -void cRCONServer::cConnection::DataReceived(const char * a_Data, size_t a_Size) +bool cRCONServer::cConnection::DataReceived(const char * a_Data, size_t a_Size) { // Append data to the buffer: m_Buffer.append(a_Data, a_Size); @@ -187,12 +187,12 @@ void cRCONServer::cConnection::DataReceived(const char * a_Data, size_t a_Size) m_RCONServer.m_SocketThreads.RemoveClient(this); m_Socket.CloseSocket(); delete this; - return; + return false; } if (Length > (int)(m_Buffer.size() + 4)) { // Incomplete packet yet, wait for more data to come - return; + return false; } int RequestID = IntFromBuffer(m_Buffer.data() + 4); @@ -202,7 +202,7 @@ void cRCONServer::cConnection::DataReceived(const char * a_Data, size_t a_Size) m_RCONServer.m_SocketThreads.RemoveClient(this); m_Socket.CloseSocket(); delete this; - return; + return false; } m_Buffer.erase(0, Length + 4); } // while (m_Buffer.size() >= 14) diff --git a/src/RCONServer.h b/src/RCONServer.h index b964852ab..47c746736 100644 --- a/src/RCONServer.h +++ b/src/RCONServer.h @@ -65,7 +65,7 @@ protected: // cSocketThreads::cCallback overrides: - virtual void DataReceived(const char * a_Data, size_t a_Size) override; + virtual bool DataReceived(const char * a_Data, size_t a_Size) override; virtual void GetOutgoingData(AString & a_Data) override; virtual void SocketClosed(void) override; -- cgit v1.2.3 From 1587b21edded56dbfb88150500336c2853b460c6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 15:21:41 +0200 Subject: Renamed cPublicKey to cCryptoKey. The class can hold both the private key and the public key, bad naming on PolarSSL's part. Also somewhat fixed the cert and key loading in cHTTPServer. --- src/HTTPServer/HTTPServer.cpp | 6 +- src/HTTPServer/HTTPServer.h | 6 +- src/HTTPServer/SslHTTPConnection.cpp | 2 +- src/HTTPServer/SslHTTPConnection.h | 8 +- src/PolarSSL++/CryptoKey.cpp | 149 +++++++++++++++++++++++++++++++++++ src/PolarSSL++/CryptoKey.h | 76 ++++++++++++++++++ src/PolarSSL++/CtrDrbgContext.h | 2 +- src/PolarSSL++/PublicKey.cpp | 149 ----------------------------------- src/PolarSSL++/PublicKey.h | 76 ------------------ src/PolarSSL++/SslContext.cpp | 2 +- src/PolarSSL++/SslContext.h | 13 ++- 11 files changed, 244 insertions(+), 245 deletions(-) create mode 100644 src/PolarSSL++/CryptoKey.cpp create mode 100644 src/PolarSSL++/CryptoKey.h delete mode 100644 src/PolarSSL++/PublicKey.cpp delete mode 100644 src/PolarSSL++/PublicKey.h (limited to 'src') diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp index 9e3e0a17b..c45044c66 100644 --- a/src/HTTPServer/HTTPServer.cpp +++ b/src/HTTPServer/HTTPServer.cpp @@ -124,17 +124,17 @@ class cDebugCallbacks : cHTTPServer::cHTTPServer(void) : m_ListenThreadIPv4(*this, cSocket::IPv4, "WebServer IPv4"), m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer IPv6"), - m_Callbacks(NULL), - m_Cert(new cX509Cert), - m_CertPrivKey(new cPublicKey) + m_Callbacks(NULL) { AString CertFile = cFile::ReadWholeFile("webadmin/httpscert.crt"); AString KeyFile = cFile::ReadWholeFile("webadmin/httpskey.pem"); if (!CertFile.empty() && !KeyFile.empty()) { + m_Cert.reset(new cX509Cert); int res = m_Cert->Parse(CertFile.data(), CertFile.size()); if (res == 0) { + m_CertPrivKey.reset(new cCryptoKey); int res2 = m_CertPrivKey->ParsePrivate(KeyFile.data(), KeyFile.size(), ""); if (res2 != 0) { diff --git a/src/HTTPServer/HTTPServer.h b/src/HTTPServer/HTTPServer.h index eb91dd5a3..522b7da62 100644 --- a/src/HTTPServer/HTTPServer.h +++ b/src/HTTPServer/HTTPServer.h @@ -13,7 +13,7 @@ #include "../OSSupport/SocketThreads.h" #include "inifile/iniFile.h" #include "PolarSSL++/RsaPrivateKey.h" -#include "PolarSSL++/PublicKey.h" +#include "PolarSSL++/CryptoKey.h" #include "PolarSSL++/X509Cert.h" @@ -85,8 +85,8 @@ protected: /** The server certificate to use for the SSL connections */ cX509CertPtr m_Cert; - /** The private key for m_Cert. Despite the class name, this is the PRIVATE key. */ - cPublicKeyPtr m_CertPrivKey; + /** The private key for m_Cert. */ + cCryptoKeyPtr m_CertPrivKey; // cListenThread::cCallback overrides: diff --git a/src/HTTPServer/SslHTTPConnection.cpp b/src/HTTPServer/SslHTTPConnection.cpp index b6b222b47..d237089d9 100644 --- a/src/HTTPServer/SslHTTPConnection.cpp +++ b/src/HTTPServer/SslHTTPConnection.cpp @@ -11,7 +11,7 @@ -cSslHTTPConnection::cSslHTTPConnection(cHTTPServer & a_HTTPServer, const cX509CertPtr & a_Cert, const cPublicKeyPtr & a_PrivateKey) : +cSslHTTPConnection::cSslHTTPConnection(cHTTPServer & a_HTTPServer, const cX509CertPtr & a_Cert, const cCryptoKeyPtr & a_PrivateKey) : super(a_HTTPServer), m_Ssl(64000), m_Cert(a_Cert), diff --git a/src/HTTPServer/SslHTTPConnection.h b/src/HTTPServer/SslHTTPConnection.h index 653acbfce..c2c1585cd 100644 --- a/src/HTTPServer/SslHTTPConnection.h +++ b/src/HTTPServer/SslHTTPConnection.h @@ -22,9 +22,9 @@ class cSslHTTPConnection : typedef cHTTPConnection super; public: - /** Creates a new connection on the specified server; sends the specified cert as the server certificate, - uses the private key for decryption. a_Private key is, despite the class name, a PRIVATE key for the cert. */ - cSslHTTPConnection(cHTTPServer & a_HTTPServer, const cX509CertPtr & a_Cert, const cPublicKeyPtr & a_PrivateKey); + /** Creates a new connection on the specified server. + Sends the specified cert as the server certificate, uses the private key for decryption. */ + cSslHTTPConnection(cHTTPServer & a_HTTPServer, const cX509CertPtr & a_Cert, const cCryptoKeyPtr & a_PrivateKey); protected: cBufferedSslContext m_Ssl; @@ -33,7 +33,7 @@ protected: cX509CertPtr m_Cert; /** The private key used for the certificate */ - cPublicKeyPtr m_PrivateKey; + cCryptoKeyPtr m_PrivateKey; // cHTTPConnection overrides: virtual bool DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client diff --git a/src/PolarSSL++/CryptoKey.cpp b/src/PolarSSL++/CryptoKey.cpp new file mode 100644 index 000000000..0763c387b --- /dev/null +++ b/src/PolarSSL++/CryptoKey.cpp @@ -0,0 +1,149 @@ + +// CryptoKey.cpp + +// Implements the cCryptoKey class representing a RSA public key in PolarSSL + +#include "Globals.h" +#include "CryptoKey.h" + + + + + +cCryptoKey::cCryptoKey(void) +{ + pk_init(&m_Pk); + m_CtrDrbg.Initialize("rsa_pubkey", 10); +} + + + + + +cCryptoKey::cCryptoKey(const AString & a_PublicKeyData) +{ + pk_init(&m_Pk); + m_CtrDrbg.Initialize("rsa_pubkey", 10); + int res = ParsePublic(a_PublicKeyData.data(), a_PublicKeyData.size()); + if (res != 0) + { + LOGWARNING("Failed to parse public key: -0x%x", res); + ASSERT(!"Cannot parse PubKey"); + return; + } +} + + + + + +cCryptoKey::cCryptoKey(const AString & a_PrivateKeyData, const AString & a_Password) +{ + pk_init(&m_Pk); + m_CtrDrbg.Initialize("rsa_privkey", 11); + int res = ParsePrivate(a_PrivateKeyData.data(), a_PrivateKeyData.size(), a_Password); + if (res != 0) + { + LOGWARNING("Failed to parse private key: -0x%x", res); + ASSERT(!"Cannot parse PubKey"); + return; + } +} + + + + + +cCryptoKey::~cCryptoKey() +{ + pk_free(&m_Pk); +} + + + + + +int cCryptoKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength) +{ + ASSERT(IsValid()); + + size_t DecryptedLen = a_DecryptedMaxLength; + int res = pk_decrypt(&m_Pk, + a_EncryptedData, a_EncryptedLength, + a_DecryptedData, &DecryptedLen, a_DecryptedMaxLength, + ctr_drbg_random, m_CtrDrbg.GetInternal() + ); + if (res != 0) + { + return res; + } + return (int)DecryptedLen; +} + + + + + +int cCryptoKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength) +{ + ASSERT(IsValid()); + + size_t EncryptedLength = a_EncryptedMaxLength; + int res = pk_encrypt(&m_Pk, + a_PlainData, a_PlainLength, a_EncryptedData, &EncryptedLength, a_EncryptedMaxLength, + ctr_drbg_random, m_CtrDrbg.GetInternal() + ); + if (res != 0) + { + return res; + } + return (int)EncryptedLength; +} + + + + + + +int cCryptoKey::ParsePublic(const void * a_Data, size_t a_NumBytes) +{ + ASSERT(!IsValid()); // Cannot parse a second key + + return pk_parse_public_key(&m_Pk, (const unsigned char *)a_Data, a_NumBytes); +} + + + + + + +int cCryptoKey::ParsePrivate(const void * a_Data, size_t a_NumBytes, const AString & a_Password) +{ + ASSERT(!IsValid()); // Cannot parse a second key + + if (a_Password.empty()) + { + return pk_parse_key(&m_Pk, (const unsigned char *)a_Data, a_NumBytes, NULL, 0); + } + else + { + return pk_parse_key( + &m_Pk, + (const unsigned char *)a_Data, a_NumBytes, + (const unsigned char *)a_Password.c_str(), a_Password.size() + ); + } +} + + + + + +bool cCryptoKey::IsValid(void) const +{ + return (pk_get_type(&m_Pk) != POLARSSL_PK_NONE); +} + + + + diff --git a/src/PolarSSL++/CryptoKey.h b/src/PolarSSL++/CryptoKey.h new file mode 100644 index 000000000..9c298e501 --- /dev/null +++ b/src/PolarSSL++/CryptoKey.h @@ -0,0 +1,76 @@ + +// CryptoKey.h + +// Declares the cCryptoKey class representing a RSA public key in PolarSSL + + + + + +#pragma once + +#include "CtrDrbgContext.h" +#include "polarssl/pk.h" + + + + + +class cCryptoKey +{ + friend class cSslContext; + +public: + /** Constructs an empty key instance. Before use, it needs to be filled by ParsePublic() or ParsePrivate() */ + cCryptoKey(void); + + /** Constructs the public key out of the DER- or PEM-encoded pubkey data */ + cCryptoKey(const AString & a_PublicKeyData); + + /** Constructs the private key out of the DER- or PEM-encoded privkey data, with the specified password. + If a_Password is empty, no password is assumed. */ + cCryptoKey(const AString & a_PrivateKeyData, const AString & a_Password); + + ~cCryptoKey(); + + /** Decrypts the data using the stored public key + Both a_EncryptedData and a_DecryptedData must be at least bytes large. + Returns the number of bytes decrypted, or negative number for error. */ + int Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength); + + /** Encrypts the data using the stored public key + Both a_EncryptedData and a_DecryptedData must be at least bytes large. + Returns the number of bytes decrypted, or negative number for error. */ + int Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength); + + /** Parses the specified data into a public key representation. + The key can be DER- or PEM-encoded. + Returns 0 on success, PolarSSL error code on failure. */ + int ParsePublic(const void * a_Data, size_t a_NumBytes); + + /** Parses the specified data into a private key representation. + If a_Password is empty, no password is assumed. + The key can be DER- or PEM-encoded. + Returns 0 on success, PolarSSL error code on failure. */ + int ParsePrivate(const void * a_Data, size_t a_NumBytes, const AString & a_Password); + + /** Returns true if the contained key is valid. */ + bool IsValid(void) const; + +protected: + /** The PolarSSL representation of the key data */ + pk_context m_Pk; + + /** The random generator used in encryption and decryption */ + cCtrDrbgContext m_CtrDrbg; + + + /** Returns the internal context ptr. Only use in PolarSSL API calls. */ + pk_context * GetInternal(void) { return &m_Pk; } +} ; + +typedef SharedPtr cCryptoKeyPtr; + + + + diff --git a/src/PolarSSL++/CtrDrbgContext.h b/src/PolarSSL++/CtrDrbgContext.h index 65e9a2374..230db8753 100644 --- a/src/PolarSSL++/CtrDrbgContext.h +++ b/src/PolarSSL++/CtrDrbgContext.h @@ -26,7 +26,7 @@ class cCtrDrbgContext { friend class cSslContext; friend class cRsaPrivateKey; - friend class cPublicKey; + friend class cCryptoKey; public: /** Constructs the context with a new entropy context. */ diff --git a/src/PolarSSL++/PublicKey.cpp b/src/PolarSSL++/PublicKey.cpp deleted file mode 100644 index dae026082..000000000 --- a/src/PolarSSL++/PublicKey.cpp +++ /dev/null @@ -1,149 +0,0 @@ - -// PublicKey.cpp - -// Implements the cPublicKey class representing a RSA public key in PolarSSL - -#include "Globals.h" -#include "PublicKey.h" - - - - - -cPublicKey::cPublicKey(void) -{ - pk_init(&m_Pk); - m_CtrDrbg.Initialize("rsa_pubkey", 10); -} - - - - - -cPublicKey::cPublicKey(const AString & a_PublicKeyData) -{ - pk_init(&m_Pk); - m_CtrDrbg.Initialize("rsa_pubkey", 10); - int res = ParsePublic(a_PublicKeyData.data(), a_PublicKeyData.size()); - if (res != 0) - { - LOGWARNING("Failed to parse public key: -0x%x", res); - ASSERT(!"Cannot parse PubKey"); - return; - } -} - - - - - -cPublicKey::cPublicKey(const AString & a_PrivateKeyData, const AString & a_Password) -{ - pk_init(&m_Pk); - m_CtrDrbg.Initialize("rsa_privkey", 11); - int res = ParsePrivate(a_PrivateKeyData.data(), a_PrivateKeyData.size(), a_Password); - if (res != 0) - { - LOGWARNING("Failed to parse private key: -0x%x", res); - ASSERT(!"Cannot parse PubKey"); - return; - } -} - - - - - -cPublicKey::~cPublicKey() -{ - pk_free(&m_Pk); -} - - - - - -int cPublicKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength) -{ - ASSERT(IsValid()); - - size_t DecryptedLen = a_DecryptedMaxLength; - int res = pk_decrypt(&m_Pk, - a_EncryptedData, a_EncryptedLength, - a_DecryptedData, &DecryptedLen, a_DecryptedMaxLength, - ctr_drbg_random, m_CtrDrbg.GetInternal() - ); - if (res != 0) - { - return res; - } - return (int)DecryptedLen; -} - - - - - -int cPublicKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength) -{ - ASSERT(IsValid()); - - size_t EncryptedLength = a_EncryptedMaxLength; - int res = pk_encrypt(&m_Pk, - a_PlainData, a_PlainLength, a_EncryptedData, &EncryptedLength, a_EncryptedMaxLength, - ctr_drbg_random, m_CtrDrbg.GetInternal() - ); - if (res != 0) - { - return res; - } - return (int)EncryptedLength; -} - - - - - - -int cPublicKey::ParsePublic(const void * a_Data, size_t a_NumBytes) -{ - ASSERT(!IsValid()); // Cannot parse a second key - - return pk_parse_public_key(&m_Pk, (const unsigned char *)a_Data, a_NumBytes); -} - - - - - - -int cPublicKey::ParsePrivate(const void * a_Data, size_t a_NumBytes, const AString & a_Password) -{ - ASSERT(!IsValid()); // Cannot parse a second key - - if (a_Password.empty()) - { - return pk_parse_key(&m_Pk, (const unsigned char *)a_Data, a_NumBytes, NULL, 0); - } - else - { - return pk_parse_key( - &m_Pk, - (const unsigned char *)a_Data, a_NumBytes, - (const unsigned char *)a_Password.c_str(), a_Password.size() - ); - } -} - - - - - -bool cPublicKey::IsValid(void) const -{ - return (pk_get_type(&m_Pk) != POLARSSL_PK_NONE); -} - - - - diff --git a/src/PolarSSL++/PublicKey.h b/src/PolarSSL++/PublicKey.h deleted file mode 100644 index df52a4143..000000000 --- a/src/PolarSSL++/PublicKey.h +++ /dev/null @@ -1,76 +0,0 @@ - -// PublicKey.h - -// Declares the cPublicKey class representing a RSA public key in PolarSSL - - - - - -#pragma once - -#include "CtrDrbgContext.h" -#include "polarssl/pk.h" - - - - - -class cPublicKey -{ - friend class cSslContext; - -public: - /** Constructs an empty key instance. Before use, it needs to be filled by ParsePublic() or ParsePrivate() */ - cPublicKey(void); - - /** Constructs the public key out of the DER- or PEM-encoded pubkey data */ - cPublicKey(const AString & a_PublicKeyData); - - /** Constructs the private key out of the DER- or PEM-encoded privkey data, with the specified password. - If a_Password is empty, no password is assumed. */ - cPublicKey(const AString & a_PrivateKeyData, const AString & a_Password); - - ~cPublicKey(); - - /** Decrypts the data using the stored public key - Both a_EncryptedData and a_DecryptedData must be at least bytes large. - Returns the number of bytes decrypted, or negative number for error. */ - int Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength); - - /** Encrypts the data using the stored public key - Both a_EncryptedData and a_DecryptedData must be at least bytes large. - Returns the number of bytes decrypted, or negative number for error. */ - int Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength); - - /** Parses the specified data into a public key representation. - The key can be DER- or PEM-encoded. - Returns 0 on success, PolarSSL error code on failure. */ - int ParsePublic(const void * a_Data, size_t a_NumBytes); - - /** Parses the specified data into a private key representation. - If a_Password is empty, no password is assumed. - The key can be DER- or PEM-encoded. - Returns 0 on success, PolarSSL error code on failure. */ - int ParsePrivate(const void * a_Data, size_t a_NumBytes, const AString & a_Password); - - /** Returns true if the contained key is valid. */ - bool IsValid(void) const; - -protected: - /** The public key PolarSSL representation */ - pk_context m_Pk; - - /** The random generator used in encryption and decryption */ - cCtrDrbgContext m_CtrDrbg; - - - /** Returns the internal context ptr. Only use in PolarSSL API calls. */ - pk_context * GetInternal(void) { return &m_Pk; } -} ; - -typedef SharedPtr cPublicKeyPtr; - - - - diff --git a/src/PolarSSL++/SslContext.cpp b/src/PolarSSL++/SslContext.cpp index df0219610..bc397b655 100644 --- a/src/PolarSSL++/SslContext.cpp +++ b/src/PolarSSL++/SslContext.cpp @@ -115,7 +115,7 @@ void cSslContext::SetOwnCert(const cX509CertPtr & a_OwnCert, const cRsaPrivateKe -void cSslContext::SetOwnCert(const cX509CertPtr & a_OwnCert, const cPublicKeyPtr & a_OwnCertPrivKey) +void cSslContext::SetOwnCert(const cX509CertPtr & a_OwnCert, const cCryptoKeyPtr & a_OwnCertPrivKey) { ASSERT(m_IsValid); // Call Initialize() first diff --git a/src/PolarSSL++/SslContext.h b/src/PolarSSL++/SslContext.h index 273939b9f..a4ad1a345 100644 --- a/src/PolarSSL++/SslContext.h +++ b/src/PolarSSL++/SslContext.h @@ -11,7 +11,7 @@ #include "polarssl/ssl.h" #include "../ByteBuffer.h" -#include "PublicKey.h" +#include "CryptoKey.h" #include "RsaPrivateKey.h" #include "X509Cert.h" @@ -54,9 +54,8 @@ public: void SetOwnCert(const cX509CertPtr & a_OwnCert, const cRsaPrivateKeyPtr & a_OwnCertPrivKey); /** Sets the certificate to use as our own. Must be used when representing a server, optional when client. - Must be called after Initialize(). - Despite the class name, a_OwnCertPrivKey is a PRIVATE key. */ - void SetOwnCert(const cX509CertPtr & a_OwnCert, const cPublicKeyPtr & a_OwnCertPrivKey); + Must be called after Initialize(). */ + void SetOwnCert(const cX509CertPtr & a_OwnCert, const cCryptoKeyPtr & a_OwnCertPrivKey); /** Sets a cert chain as the trusted cert store for this context. Must be called after Initialize(). Calling this will switch the context into strict cert verification mode. @@ -107,11 +106,11 @@ protected: /** The certificate that we present to the peer. */ cX509CertPtr m_OwnCert; - /** Private key for m_OwnCert, if initialized from a cRsaPrivateKey */ + /** Private key for m_OwnCert, if initialized from a cRsaPrivateKey. */ cRsaPrivateKeyPtr m_OwnCertPrivKey; - /** Private key for m_OwnCert, if initialized from a cPublicKey. Despite the class name, this is a PRIVATE key. */ - cPublicKeyPtr m_OwnCertPrivKey2; + /** Private key for m_OwnCert, if initialized from a cCryptoKey. */ + cCryptoKeyPtr m_OwnCertPrivKey2; /** True if the SSL handshake has been completed. */ bool m_HasHandshaken; -- cgit v1.2.3 From 772b57ca04b2dbe4ec163a8c2856f8af7bc5c2a5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 18:00:10 +0200 Subject: Anvil saver pads data to 4K boundaries. Fixes #524. --- src/WorldStorage/WSSAnvil.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 33f34728e..f33178173 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -2672,6 +2672,11 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri return false; } + // Add padding to 4K boundary: + size_t BytesWritten = a_Data.size() + MCA_CHUNK_HEADER_LENGTH; + static const char Padding[4095] = {0}; + m_File.Write(Padding, 4096 - (BytesWritten % 4096)); + // Store the header: ChunkSize = (a_Data.size() + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size *up* to nearest 4KB sector, make it a sector number ASSERT(ChunkSize < 256); -- cgit v1.2.3 From d9e5dbf16526aa102abdc818d3515928663a973c Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 1 May 2014 18:06:23 +0200 Subject: Renamed PublicKey to CryptoKey in CMakeLists.txt --- src/PolarSSL++/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt index b0a592760..9a59cdb2c 100644 --- a/src/PolarSSL++/CMakeLists.txt +++ b/src/PolarSSL++/CMakeLists.txt @@ -1,4 +1,3 @@ - cmake_minimum_required (VERSION 2.6) project (MCServer) @@ -11,8 +10,8 @@ set(SOURCES BufferedSslContext.cpp CallbackSslContext.cpp CtrDrbgContext.cpp + CryptoKey.cpp EntropyContext.cpp - PublicKey.cpp RsaPrivateKey.cpp Sha1Checksum.cpp SslContext.cpp @@ -26,8 +25,8 @@ set(HEADERS BufferedSslContext.h CallbackSslContext.h CtrDrbgContext.h + CryptoKey.h EntropyContext.h - PublicKey.h RsaPrivateKey.h SslContext.h Sha1Checksum.h -- cgit v1.2.3 From a2cffb0363e42f12019712297e764a269b6a7d9a Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 1 May 2014 20:21:54 +0200 Subject: Fixed MSVC2013 compilation. --- src/Globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Globals.h b/src/Globals.h index a09819ce9..71e9191e4 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -272,7 +272,7 @@ template class SizeChecker; #if (defined(_MSC_VER) && (_MSC_VER < 1600)) // MSVC before 2010 doesn't have std::shared_ptr, but has std::tr1::shared_ptr, defined in included earlier #define SharedPtr std::tr1::shared_ptr -#elif (__cplusplus >= 201103L) +#elif (defined(_MSC_VER) || (__cplusplus >= 201103L)) // C++11 has std::shared_ptr in , included earlier #define SharedPtr std::shared_ptr #else -- cgit v1.2.3 From 9221b458989512e41f8502b56ed738d143599093 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 21:23:37 +0200 Subject: cSslContext has virtual destructor now. --- src/PolarSSL++/SslContext.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/PolarSSL++/SslContext.h b/src/PolarSSL++/SslContext.h index a4ad1a345..6b4f2c1e7 100644 --- a/src/PolarSSL++/SslContext.h +++ b/src/PolarSSL++/SslContext.h @@ -40,7 +40,7 @@ public: /** Creates a new uninitialized context */ cSslContext(void); - ~cSslContext(); + virtual ~cSslContext(); /** Initializes the context for use as a server or client. Returns 0 on success, PolarSSL error on failure. */ -- cgit v1.2.3 From b0056cdcf8a36efbed4b97414ebf5741b56a5895 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 22:02:25 +0200 Subject: Removed the explicit copy constructor for cItem. The compiler generates an implicit one with the same contents and warns about it. The function left in for ToLua to generate the binding for it. --- src/Item.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/Item.h b/src/Item.h index 641c681db..8eb0a1f4e 100644 --- a/src/Item.h +++ b/src/Item.h @@ -73,6 +73,10 @@ public: } + // The constructor is disabled in code, because the compiler generates it anyway, + // but it needs to stay because ToLua needs to generate the binding for it + #if 0 + /** Creates an exact copy of the item */ cItem(const cItem & a_CopyFrom) : m_ItemType (a_CopyFrom.m_ItemType), @@ -85,6 +89,8 @@ public: { } + #endif + void Empty(void) { -- cgit v1.2.3 From 30e81156eb6de46d7a374c044e26b35d83af4244 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 22:02:45 +0200 Subject: Added a missing return statement. --- src/RCONServer.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/RCONServer.cpp b/src/RCONServer.cpp index fd4b26cab..cd5292ac3 100644 --- a/src/RCONServer.cpp +++ b/src/RCONServer.cpp @@ -206,6 +206,7 @@ bool cRCONServer::cConnection::DataReceived(const char * a_Data, size_t a_Size) } m_Buffer.erase(0, Length + 4); } // while (m_Buffer.size() >= 14) + return false; } -- cgit v1.2.3 From e175ae551c5e1e8034648f950c016b6348d6bf09 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 22:41:18 +0200 Subject: Fixed warning in cBlockArea. --- src/BlockArea.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/BlockArea.h b/src/BlockArea.h index 4c4dfb8ff..6dba0f12e 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -294,7 +294,7 @@ public: NIBBLETYPE * GetBlockMetas (void) const { return m_BlockMetas; } // NOTE: one byte per block! NIBBLETYPE * GetBlockLight (void) const { return m_BlockLight; } // NOTE: one byte per block! NIBBLETYPE * GetBlockSkyLight(void) const { return m_BlockSkyLight; } // NOTE: one byte per block! - size_t GetBlockCount(void) const { return m_Size.x * m_Size.y * m_Size.z; } + size_t GetBlockCount(void) const { return (size_t)(m_Size.x * m_Size.y * m_Size.z); } int MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const; protected: -- cgit v1.2.3 From a6eba4ff8b007863eac20693db5dd859f0dcbc70 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 22:41:41 +0200 Subject: Fixed warning in cCallbackSslContext::cDataCallbacks. --- src/PolarSSL++/CallbackSslContext.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/PolarSSL++/CallbackSslContext.h b/src/PolarSSL++/CallbackSslContext.h index 4e4c1ed7f..3e6edc5f4 100644 --- a/src/PolarSSL++/CallbackSslContext.h +++ b/src/PolarSSL++/CallbackSslContext.h @@ -23,6 +23,9 @@ public: class cDataCallbacks { public: + // Force a virtual destructor in descendants: + virtual ~cDataCallbacks() {} + /** Called when PolarSSL wants to read encrypted data from the SSL peer. The returned value is the number of bytes received, or a PolarSSL error on failure. The implementation can return POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE to indicate -- cgit v1.2.3 From b6b86b7270ca3f44b0b2a24ffe8292e87e762713 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 22:43:37 +0200 Subject: Fixed warnings in FastNBT. --- src/WorldStorage/FastNBT.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h index 5e5af3ca3..bcf93228f 100644 --- a/src/WorldStorage/FastNBT.h +++ b/src/WorldStorage/FastNBT.h @@ -237,7 +237,7 @@ public: { ASSERT(m_Tags[(size_t)a_Tag].m_Type == TAG_String); AString res; - res.assign(m_Data + m_Tags[(size_t)a_Tag].m_DataStart, m_Tags[(size_t)a_Tag].m_DataLength); + res.assign(m_Data + m_Tags[(size_t)a_Tag].m_DataStart, (size_t)m_Tags[(size_t)a_Tag].m_DataLength); return res; } @@ -245,7 +245,7 @@ public: inline AString GetName(int a_Tag) const { AString res; - res.assign(m_Data + m_Tags[(size_t)a_Tag].m_NameStart, m_Tags[(size_t)a_Tag].m_NameLength); + res.assign(m_Data + m_Tags[(size_t)a_Tag].m_NameStart, (size_t)m_Tags[(size_t)a_Tag].m_NameLength); return res; } -- cgit v1.2.3 From a91129af4ac186eaceb5fbf044539c052c4c6cf8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 22:44:52 +0200 Subject: Fixed warnings in cBlockArea. --- src/BlockArea.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 55e8d6849..e0ae2c5b6 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -2005,7 +2005,7 @@ void cBlockArea::ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, i int NewSizeX = m_Size.x + a_SubMinX + a_AddMaxX; int NewSizeY = m_Size.y + a_SubMinY + a_AddMaxY; int NewSizeZ = m_Size.z + a_SubMinZ + a_AddMaxZ; - size_t BlockCount = (size_t)NewSizeX * NewSizeY * NewSizeZ; + size_t BlockCount = (size_t)(NewSizeX * NewSizeY * NewSizeZ); BLOCKTYPE * NewBlockTypes = new BLOCKTYPE[BlockCount]; memset(NewBlockTypes, 0, BlockCount * sizeof(BLOCKTYPE)); int OldIndex = 0; @@ -2035,7 +2035,7 @@ void cBlockArea::ExpandNibbles(NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMa int NewSizeX = m_Size.x + a_SubMinX + a_AddMaxX; int NewSizeY = m_Size.y + a_SubMinY + a_AddMaxY; int NewSizeZ = m_Size.z + a_SubMinZ + a_AddMaxZ; - size_t BlockCount = (size_t)NewSizeX * NewSizeY * NewSizeZ; + size_t BlockCount = (size_t)(NewSizeX * NewSizeY * NewSizeZ); NIBBLETYPE * NewNibbles = new NIBBLETYPE[BlockCount]; memset(NewNibbles, 0, BlockCount * sizeof(NIBBLETYPE)); int OldIndex = 0; -- cgit v1.2.3 From a4d8c6d656da6b3b4c986361213bb65540a08e80 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 22:47:02 +0200 Subject: Fixed warning in BlockID. --- src/BlockID.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/BlockID.cpp b/src/BlockID.cpp index bf95d0798..bfe826f40 100644 --- a/src/BlockID.cpp +++ b/src/BlockID.cpp @@ -102,7 +102,7 @@ public: return true; } - a_Item.m_ItemDamage = atoi(Split[1].c_str()); + a_Item.m_ItemDamage = (short)atoi(Split[1].c_str()); if ((a_Item.m_ItemDamage == 0) && (Split[1] != "0")) { // Parsing the number failed -- cgit v1.2.3 From fb173a756ca7c0cd9ebfde70e5a5af0a78faa884 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 22:54:22 +0200 Subject: Fixed warnings in cByteBuffer. --- src/ByteBuffer.cpp | 26 +++++++++++++------------- src/ByteBuffer.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index c27bc4cad..4de89f7c1 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -327,7 +327,7 @@ bool cByteBuffer::ReadBEShort(short & a_Value) CheckValid(); NEEDBYTES(2); ReadBuf(&a_Value, 2); - a_Value = ntohs(a_Value); + a_Value = (short)ntohs((u_short)a_Value); return true; } @@ -341,7 +341,7 @@ bool cByteBuffer::ReadBEInt(int & a_Value) CheckValid(); NEEDBYTES(4); ReadBuf(&a_Value, 4); - a_Value = ntohl(a_Value); + a_Value = (int)ntohl((u_long)a_Value); return true; } @@ -420,7 +420,7 @@ bool cByteBuffer::ReadBEUTF16String16(AString & a_Value) ASSERT(!"Negative string length? Are you sure?"); return true; } - return ReadUTF16String(a_Value, Length); + return ReadUTF16String(a_Value, (size_t)Length); } @@ -438,7 +438,7 @@ bool cByteBuffer::ReadVarInt(UInt32 & a_Value) { NEEDBYTES(1); ReadBuf(&b, 1); - Value = Value | (((Int64)(b & 0x7f)) << Shift); + Value = Value | (((UInt32)(b & 0x7f)) << Shift); Shift += 7; } while ((b & 0x80) != 0); a_Value = Value; @@ -462,7 +462,7 @@ bool cByteBuffer::ReadVarUTF8String(AString & a_Value) { LOGWARNING("%s: String too large: %u (%u KiB)", __FUNCTION__, Size, Size / 1024); } - return ReadString(a_Value, (int)Size); + return ReadString(a_Value, (size_t)Size); } @@ -517,7 +517,7 @@ bool cByteBuffer::WriteBEShort(short a_Value) CHECK_THREAD; CheckValid(); PUTBYTES(2); - short Converted = htons(a_Value); + u_short Converted = htons((u_short)a_Value); return WriteBuf(&Converted, 2); } @@ -530,7 +530,7 @@ bool cByteBuffer::WriteBEInt(int a_Value) CHECK_THREAD; CheckValid(); PUTBYTES(4); - int Converted = HostToNetwork4(&a_Value); + UInt32 Converted = HostToNetwork4(&a_Value); return WriteBuf(&Converted, 4); } @@ -543,7 +543,7 @@ bool cByteBuffer::WriteBEInt64(Int64 a_Value) CHECK_THREAD; CheckValid(); PUTBYTES(8); - Int64 Converted = HostToNetwork8(&a_Value); + UInt64 Converted = HostToNetwork8(&a_Value); return WriteBuf(&Converted, 8); } @@ -556,7 +556,7 @@ bool cByteBuffer::WriteBEFloat(float a_Value) CHECK_THREAD; CheckValid(); PUTBYTES(4); - int Converted = HostToNetwork4(&a_Value); + UInt32 Converted = HostToNetwork4(&a_Value); return WriteBuf(&Converted, 4); } @@ -569,7 +569,7 @@ bool cByteBuffer::WriteBEDouble(double a_Value) CHECK_THREAD; CheckValid(); PUTBYTES(8); - Int64 Converted = HostToNetwork8(&a_Value); + UInt64 Converted = HostToNetwork8(&a_Value); return WriteBuf(&Converted, 8); } @@ -613,7 +613,7 @@ bool cByteBuffer::WriteVarInt(UInt32 a_Value) // A 32-bit integer can be encoded by at most 5 bytes: unsigned char b[5]; - int idx = 0; + size_t idx = 0; do { b[idx] = (a_Value & 0x7f) | ((a_Value > 0x7f) ? 0x80 : 0x00); @@ -632,7 +632,7 @@ bool cByteBuffer::WriteVarUTF8String(const AString & a_Value) CHECK_THREAD; CheckValid(); PUTBYTES(a_Value.size() + 1); // This is a lower-bound on the bytes that will be actually written. Fail early. - bool res = WriteVarInt(a_Value.size()); + bool res = WriteVarInt((UInt32)(a_Value.size())); if (!res) { return false; @@ -757,7 +757,7 @@ bool cByteBuffer::ReadString(AString & a_String, size_t a_Count) -bool cByteBuffer::ReadUTF16String(AString & a_String, int a_NumChars) +bool cByteBuffer::ReadUTF16String(AString & a_String, size_t a_NumChars) { // Reads 2 * a_NumChars bytes and interprets it as a UTF16 string, converting it into UTF8 string a_String CHECK_THREAD; diff --git a/src/ByteBuffer.h b/src/ByteBuffer.h index 7656a5b13..929c93167 100644 --- a/src/ByteBuffer.h +++ b/src/ByteBuffer.h @@ -101,7 +101,7 @@ public: bool ReadString(AString & a_String, size_t a_Count); /// Reads 2 * a_NumChars bytes and interprets it as a UTF16-BE string, converting it into UTF8 string a_String - bool ReadUTF16String(AString & a_String, int a_NumChars); + bool ReadUTF16String(AString & a_String, size_t a_NumChars); /// Skips reading by a_Count bytes; returns false if not enough bytes in the ringbuffer bool SkipRead(size_t a_Count); -- cgit v1.2.3 From ed75d3a8364f360b213956c40c51729ea53f3616 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 22:58:58 +0200 Subject: Fixed warnings in ClientHandle. --- src/ClientHandle.cpp | 4 ++-- src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.cpp | 2 +- src/Protocol/Protocol125.h | 2 +- src/Protocol/Protocol17x.cpp | 2 +- src/Protocol/Protocol17x.h | 2 +- src/Protocol/ProtocolRecognizer.cpp | 2 +- src/Protocol/ProtocolRecognizer.h | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 2362abe1e..7a4158491 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1658,7 +1658,7 @@ void cClientHandle::SendData(const char * a_Data, size_t a_Size) { // There is a queued overflow. Append to it, then send as much from its front as possible m_OutgoingDataOverflow.append(a_Data, a_Size); - int CanFit = m_OutgoingData.GetFreeSpace(); + size_t CanFit = m_OutgoingData.GetFreeSpace(); if (CanFit > 128) { // No point in moving the data over if it's not large enough - too much effort for too little an effect @@ -2522,7 +2522,7 @@ void cClientHandle::SendWindowOpen(const cWindow & a_Window) -void cClientHandle::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value) +void cClientHandle::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value) { m_Protocol->SendWindowProperty(a_Window, a_Property, a_Value); } diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index 2fbeef0fa..8f152ad37 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -123,7 +123,7 @@ public: virtual void SendWholeInventory (const cWindow & a_Window) = 0; virtual void SendWindowClose (const cWindow & a_Window) = 0; virtual void SendWindowOpen (const cWindow & a_Window) = 0; - virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) = 0; + virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) = 0; /// Returns the ServerID used for authentication through session.minecraft.net virtual AString GetAuthServerID(void) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 35ab72bfc..e7873cf7a 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -1175,7 +1175,7 @@ void cProtocol125::SendWindowOpen(const cWindow & a_Window) -void cProtocol125::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value) +void cProtocol125::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value) { cCSLock Lock(m_CSPacket); WriteByte (PACKET_WINDOW_PROPERTY); diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 89e64f386..423e58d67 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -96,7 +96,7 @@ public: virtual void SendWholeInventory (const cWindow & a_Window) override; virtual void SendWindowClose (const cWindow & a_Window) override; virtual void SendWindowOpen (const cWindow & a_Window) override; - virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override; + virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) override; virtual AString GetAuthServerID(void) override; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index a6d566625..bc9aff0c0 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1383,7 +1383,7 @@ void cProtocol172::SendWindowOpen(const cWindow & a_Window) -void cProtocol172::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value) +void cProtocol172::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value) { ASSERT(m_State == 3); // In game mode? diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 3f9c93357..eed761a4a 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -128,7 +128,7 @@ public: virtual void SendWholeInventory (const cWindow & a_Window) override; virtual void SendWindowClose (const cWindow & a_Window) override; virtual void SendWindowOpen (const cWindow & a_Window) override; - virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override; + virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) override; virtual AString GetAuthServerID(void) override { return m_AuthServerID; } diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 2ccb9f197..22dfe7c88 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -357,7 +357,7 @@ void cProtocolRecognizer::SendHealth(void) -void cProtocolRecognizer::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value) +void cProtocolRecognizer::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value) { ASSERT(m_Protocol != NULL); m_Protocol->SendWindowProperty(a_Window, a_Property, a_Value); diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 408109ef4..37f47379d 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -131,7 +131,7 @@ public: virtual void SendWholeInventory (const cWindow & a_Window) override; virtual void SendWindowClose (const cWindow & a_Window) override; virtual void SendWindowOpen (const cWindow & a_Window) override; - virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override; + virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) override; virtual AString GetAuthServerID(void) override; -- cgit v1.2.3 From e24bdc9328278b676c7acf83fd9f31b430561b98 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 23:03:23 +0200 Subject: More ClientHandle fixes. --- src/ClientHandle.cpp | 4 ++-- src/ClientHandle.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 7a4158491..4ed0d682f 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -716,7 +716,7 @@ void cClientHandle::UnregisterPluginChannels(const AStringVector & a_ChannelList -void cClientHandle::HandleCommandBlockMessage(const char * a_Data, unsigned int a_Length) +void cClientHandle::HandleCommandBlockMessage(const char * a_Data, size_t a_Length) { if (a_Length < 14) { @@ -2522,7 +2522,7 @@ void cClientHandle::SendWindowOpen(const cWindow & a_Window) -void cClientHandle::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value) +void cClientHandle::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value) { m_Protocol->SendWindowProperty(a_Window, a_Property, a_Value); } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 9f8d44129..9fd17ac00 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -384,7 +384,7 @@ private: void UnregisterPluginChannels(const AStringVector & a_ChannelList); /** Handles the "MC|AdvCdm" plugin message */ - void HandleCommandBlockMessage(const char * a_Data, unsigned int a_Length); + void HandleCommandBlockMessage(const char * a_Data, size_t a_Length); // cSocketThreads::cCallback overrides: virtual void DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client -- cgit v1.2.3 From cb07541029bbce8a2bd46a58850af20687588978 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 23:10:37 +0200 Subject: Fixed a warning in Noise. --- src/Noise.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Noise.h b/src/Noise.h index 62004503f..e605051b5 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -280,7 +280,7 @@ NOISE_DATATYPE cNoise::CubicInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B, NOISE_DATATYPE cNoise::CosineInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B, NOISE_DATATYPE a_Pct) { const NOISE_DATATYPE ft = a_Pct * (NOISE_DATATYPE)3.1415927; - const NOISE_DATATYPE f = (1 - cos(ft)) * (NOISE_DATATYPE)0.5; + const NOISE_DATATYPE f = (NOISE_DATATYPE)((NOISE_DATATYPE)(1 - cos(ft)) * (NOISE_DATATYPE)0.5); return a_A * (1 - f) + a_B * f; } -- cgit v1.2.3 From d950c8346fe0c89594e871f014f449e595c97706 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 23:38:35 +0200 Subject: Fixed warnings in Lua helpers. --- src/Bindings/LuaChunkStay.cpp | 2 +- src/Bindings/LuaFunctions.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Bindings/LuaChunkStay.cpp b/src/Bindings/LuaChunkStay.cpp index db865cfa4..985a18a95 100644 --- a/src/Bindings/LuaChunkStay.cpp +++ b/src/Bindings/LuaChunkStay.cpp @@ -42,7 +42,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos) // Add each set of coords: int NumChunks = luaL_getn(L, a_ChunkCoordTableStackPos); - m_Chunks.reserve(NumChunks); + m_Chunks.reserve((size_t)NumChunks); for (int idx = 1; idx <= NumChunks; idx++) { // Push the idx-th element of the array onto stack top, check that it's a table: diff --git a/src/Bindings/LuaFunctions.h b/src/Bindings/LuaFunctions.h index 4f9eab86d..629e2d77d 100644 --- a/src/Bindings/LuaFunctions.h +++ b/src/Bindings/LuaFunctions.h @@ -4,12 +4,12 @@ #include // tolua_begin -unsigned int GetTime() +inline unsigned int GetTime() { return (unsigned int)time(0); } -std::string GetChar( std::string & a_Str, unsigned int a_Idx ) +inline std::string GetChar( std::string & a_Str, unsigned int a_Idx ) { return std::string(1, a_Str[ a_Idx ]); } -- cgit v1.2.3 From 06da2c86b4b9408f8189eded7e302eb467522d31 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 23:43:11 +0200 Subject: Fixed warnings in ManualBindings. --- src/Bindings/ManualBindings.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index b3f75aff1..10e560ac0 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -37,7 +37,7 @@ /**************************** * Better error reporting for Lua **/ -int tolua_do_error(lua_State* L, const char * a_pMsg, tolua_Error * a_pToLuaError) +static int tolua_do_error(lua_State* L, const char * a_pMsg, tolua_Error * a_pToLuaError) { // Retrieve current function name lua_Debug entry; @@ -57,7 +57,7 @@ int tolua_do_error(lua_State* L, const char * a_pMsg, tolua_Error * a_pToLuaErro -int lua_do_error(lua_State* L, const char * a_pFormat, ...) +static int lua_do_error(lua_State* L, const char * a_pFormat, ...) { // Retrieve current function name lua_Debug entry; @@ -235,7 +235,7 @@ static int tolua_Base64Decode(lua_State * tolua_S) -cPluginLua * GetLuaPlugin(lua_State * L) +static cPluginLua * GetLuaPlugin(lua_State * L) { // Get the plugin identification out of LuaState: lua_getglobal(L, LUA_PLUGIN_INSTANCE_VAR_NAME); @@ -1776,20 +1776,20 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S) -static int tolua_cPlayer_GetGroups(lua_State* tolua_S) +static int tolua_cPlayer_GetGroups(lua_State * tolua_S) { - cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S, 1, NULL); + cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, NULL); const cPlayer::GroupList & AllGroups = self->GetGroups(); - lua_createtable(tolua_S, AllGroups.size(), 0); + lua_createtable(tolua_S, (int)AllGroups.size(), 0); int newTable = lua_gettop(tolua_S); int index = 1; cPlayer::GroupList::const_iterator iter = AllGroups.begin(); - while(iter != AllGroups.end()) + while (iter != AllGroups.end()) { - const cGroup* Group = *iter; - tolua_pushusertype( tolua_S, (void*)Group, "const cGroup" ); + const cGroup * Group = *iter; + tolua_pushusertype(tolua_S, (void *)Group, "const cGroup"); lua_rawseti(tolua_S, newTable, index); ++iter; ++index; @@ -1801,20 +1801,20 @@ static int tolua_cPlayer_GetGroups(lua_State* tolua_S) -static int tolua_cPlayer_GetResolvedPermissions(lua_State* tolua_S) +static int tolua_cPlayer_GetResolvedPermissions(lua_State * tolua_S) { - cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S, 1, NULL); + cPlayer * self = (cPlayer*) tolua_tousertype(tolua_S, 1, NULL); cPlayer::StringList AllPermissions = self->GetResolvedPermissions(); - lua_createtable(tolua_S, AllPermissions.size(), 0); + lua_createtable(tolua_S, (int)AllPermissions.size(), 0); int newTable = lua_gettop(tolua_S); int index = 1; cPlayer::StringList::iterator iter = AllPermissions.begin(); - while(iter != AllPermissions.end()) + while (iter != AllPermissions.end()) { - std::string& Permission = *iter; - tolua_pushstring( tolua_S, Permission.c_str() ); + std::string & Permission = *iter; + lua_pushlstring(tolua_S, Permission.c_str(), Permission.length()); lua_rawseti(tolua_S, newTable, index); ++iter; ++index; @@ -2076,18 +2076,18 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S) static int tolua_cWebAdmin_GetPlugins(lua_State * tolua_S) { - cWebAdmin* self = (cWebAdmin*) tolua_tousertype(tolua_S, 1, NULL); + cWebAdmin * self = (cWebAdmin *)tolua_tousertype(tolua_S, 1, NULL); const cWebAdmin::PluginList & AllPlugins = self->GetPlugins(); - lua_createtable(tolua_S, AllPlugins.size(), 0); + lua_createtable(tolua_S, (int)AllPlugins.size(), 0); int newTable = lua_gettop(tolua_S); int index = 1; cWebAdmin::PluginList::const_iterator iter = AllPlugins.begin(); - while(iter != AllPlugins.end()) + while (iter != AllPlugins.end()) { - const cWebPlugin* Plugin = *iter; - tolua_pushusertype( tolua_S, (void*)Plugin, "const cWebPlugin" ); + const cWebPlugin * Plugin = *iter; + tolua_pushusertype(tolua_S, (void *)Plugin, "const cWebPlugin"); lua_rawseti(tolua_S, newTable, index); ++iter; ++index; -- cgit v1.2.3 From 4d704255de1368d7d9912458053c2de14be1b5ac Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 11:18:02 +0200 Subject: HOOK_DISCONNECT has cClientHandle as its first parameter. Ref.: #655. --- src/Bindings/Plugin.h | 2 +- src/Bindings/PluginLua.cpp | 4 ++-- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 4 ++-- src/Bindings/PluginManager.h | 2 +- src/ClientHandle.cpp | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index df0bd4dcc..0bd9270c4 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -56,7 +56,7 @@ public: virtual bool OnChunkUnloading (cWorld * a_World, int a_ChunkX, int a_ChunkZ) = 0; virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) = 0; virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; - virtual bool OnDisconnect (cPlayer * a_Player, const AString & a_Reason) = 0; + virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) = 0; virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) = 0; virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0; virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index cb55715a6..59708bf59 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -400,14 +400,14 @@ bool cPluginLua::OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGri -bool cPluginLua::OnDisconnect(cPlayer * a_Player, const AString & a_Reason) +bool cPluginLua::OnDisconnect(cClientHandle & a_Client, const AString & a_Reason) { cCSLock Lock(m_CriticalSection); bool res = false; cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_DISCONNECT]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), a_Player, a_Reason, cLuaState::Return, res); + m_LuaState.Call((int)(**itr), &a_Client, a_Reason, cLuaState::Return, res); if (res) { return true; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 59542d23a..3357dd87b 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -79,7 +79,7 @@ public: virtual bool OnChunkUnloading (cWorld * a_World, int a_ChunkX, int a_ChunkZ) override; virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) override; virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; - virtual bool OnDisconnect (cPlayer * a_Player, const AString & a_Reason) override; + virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override; virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) override; virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override; virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 6a5356c0b..aaccc606d 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -442,7 +442,7 @@ bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cC -bool cPluginManager::CallHookDisconnect(cPlayer * a_Player, const AString & a_Reason) +bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString & a_Reason) { HookMap::iterator Plugins = m_Hooks.find(HOOK_DISCONNECT); if (Plugins == m_Hooks.end()) @@ -451,7 +451,7 @@ bool cPluginManager::CallHookDisconnect(cPlayer * a_Player, const AString & a_Re } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnDisconnect(a_Player, a_Reason)) + if ((*itr)->OnDisconnect(a_Client, a_Reason)) { return true; } diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 512bc1351..58c1cebb4 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -172,7 +172,7 @@ public: // tolua_export bool CallHookChunkUnloading (cWorld * a_World, int a_ChunkX, int a_ChunkZ); bool CallHookCollectingPickup (cPlayer * a_Player, cPickup & a_Pickup); bool CallHookCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); - bool CallHookDisconnect (cPlayer * a_Player, const AString & a_Reason); + bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason); bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == NULL, it is a console cmd bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData); bool CallHookExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData); diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 4ed0d682f..29213ca2d 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1510,7 +1510,7 @@ void cClientHandle::HandleDisconnect(const AString & a_Reason) { LOGD("Received d/c packet from %s with reason \"%s\"", m_Username.c_str(), a_Reason.c_str()); - cRoot::Get()->GetPluginManager()->CallHookDisconnect(m_Player, a_Reason); + cRoot::Get()->GetPluginManager()->CallHookDisconnect(*this, a_Reason); m_HasSentDC = true; Destroy(); @@ -2689,9 +2689,9 @@ void cClientHandle::SocketClosed(void) LOGD("Player %s @ %s disconnected", m_Username.c_str(), m_IPString.c_str()); - if (m_Username != "") // Ignore client pings + if (!m_Username.empty()) // Ignore client pings { - cRoot::Get()->GetPluginManager()->CallHookDisconnect(m_Player, "Player disconnected"); + cRoot::Get()->GetPluginManager()->CallHookDisconnect(*this, "Player disconnected"); } Destroy(); -- cgit v1.2.3 From 5c7876c2dd6aa966fbab6dc0df95ed8d2a17c5c8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 19:13:57 +0200 Subject: Added a sanitizer for Spawn egg damage value. This disallows spawning unknown mobs from unknown spawn eggs. Ref.: #928. --- src/Items/ItemSpawnEgg.h | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Items/ItemSpawnEgg.h b/src/Items/ItemSpawnEgg.h index 0d6019398..bba97afa1 100644 --- a/src/Items/ItemSpawnEgg.h +++ b/src/Items/ItemSpawnEgg.h @@ -33,7 +33,10 @@ public: a_BlockY--; } - if (a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, (cMonster::eType)(a_Item.m_ItemDamage)) >= 0) + cMonster::eType MonsterType = ItemDamageToMonsterType(a_Item.m_ItemDamage); + if ( + (MonsterType != cMonster::mtInvalidType) && // Valid monster type + (a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, MonsterType) >= 0)) // Spawning succeeded { if (!a_Player->IsGameModeCreative()) { @@ -45,6 +48,41 @@ public: return false; } + + + /** Converts the Spawn egg item damage to the monster type to spawn. + Returns mtInvalidType for invalid damage values. */ + static cMonster::eType ItemDamageToMonsterType(short a_ItemDamage) + { + switch (a_ItemDamage) + { + case E_META_SPAWN_EGG_BAT: return cMonster::mtBat; + case E_META_SPAWN_EGG_BLAZE: return cMonster::mtBlaze; + case E_META_SPAWN_EGG_CAVE_SPIDER: return cMonster::mtCaveSpider; + case E_META_SPAWN_EGG_CHICKEN: return cMonster::mtChicken; + case E_META_SPAWN_EGG_COW: return cMonster::mtCow; + case E_META_SPAWN_EGG_CREEPER: return cMonster::mtCreeper; + case E_META_SPAWN_EGG_ENDERMAN: return cMonster::mtEnderman; + case E_META_SPAWN_EGG_GHAST: return cMonster::mtGhast; + case E_META_SPAWN_EGG_HORSE: return cMonster::mtHorse; + case E_META_SPAWN_EGG_MAGMA_CUBE: return cMonster::mtMagmaCube; + case E_META_SPAWN_EGG_MOOSHROOM: return cMonster::mtMooshroom; + case E_META_SPAWN_EGG_OCELOT: return cMonster::mtOcelot; + case E_META_SPAWN_EGG_PIG: return cMonster::mtPig; + case E_META_SPAWN_EGG_SHEEP: return cMonster::mtSheep; + case E_META_SPAWN_EGG_SILVERFISH: return cMonster::mtSilverfish; + case E_META_SPAWN_EGG_SKELETON: return cMonster::mtSkeleton; + case E_META_SPAWN_EGG_SLIME: return cMonster::mtSlime; + case E_META_SPAWN_EGG_SPIDER: return cMonster::mtSpider; + case E_META_SPAWN_EGG_SQUID: return cMonster::mtSquid; + case E_META_SPAWN_EGG_VILLAGER: return cMonster::mtVillager; + case E_META_SPAWN_EGG_WITCH: return cMonster::mtWitch; + case E_META_SPAWN_EGG_WOLF: return cMonster::mtWolf; + case E_META_SPAWN_EGG_ZOMBIE: return cMonster::mtZombie; + case E_META_SPAWN_EGG_ZOMBIE_PIGMAN: return cMonster::mtZombiePigman; + } + return cMonster::mtInvalidType; + } } ; -- cgit v1.2.3 From 202ce3e7370042e416a7403308c94ac0bf426892 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 19:17:22 +0200 Subject: Fixed MagmaCube spawning. Fixes #928. --- src/Mobs/Monster.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index c66ab4e04..62670907f 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -827,6 +827,10 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) switch (a_MobType) { case mtMagmaCube: + { + toReturn = new cMagmaCube(Random.NextInt(2) + 1); + break; + } case mtSlime: { toReturn = new cSlime(Random.NextInt(2) + 1); -- cgit v1.2.3 From 5082d55e853d0067301d73dc98ce0f177a76bc7f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 19:40:12 +0200 Subject: A bit of reformatting. --- src/Entities/Entity.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index fe91915cd..df03d635b 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -431,18 +431,21 @@ protected: cEntity * m_Attachee; /** Stores whether head yaw has been set manually */ - bool m_bDirtyHead; + bool m_bDirtyHead; + /** Stores whether our yaw/pitch/roll (body orientation) has been set manually */ - bool m_bDirtyOrientation; + bool m_bDirtyOrientation; + /** Stores whether we have sent a Velocity packet with a speed of zero (no speed) to the client Ensures that said packet is sent only once */ - bool m_bHasSentNoSpeed; + bool m_bHasSentNoSpeed; /** Stores if the entity is on the ground */ - bool m_bOnGround; + bool m_bOnGround; + /** Stores gravity that is applied to an entity every tick For realistic effects, this should be negative. For spaaaaaaace, this can be zero or even positive */ - float m_Gravity; + float m_Gravity; /** Last position sent to client via the Relative Move or Teleport packets (not Velocity) Only updated if cEntity::BroadcastMovementUpdate() is called! */ @@ -473,12 +476,14 @@ protected: /// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void. int m_TicksSinceLastVoidDamage; + virtual void Destroyed(void) {} // Called after the entity has been destroyed void SetWorld(cWorld * a_World) { m_World = a_World; } /** Called in each tick to handle air-related processing i.e. drowning */ virtual void HandleAir(); + /** Called once per tick to set IsSwimming and IsSubmerged */ virtual void SetSwimState(cChunk & a_Chunk); -- cgit v1.2.3 From 92c022c1405d32fa851a06958a55ea714c62eccf Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 20:55:50 +0200 Subject: Open files in shared mode on windows, so that other tools may read them. This was the behavior before fopen_s() was used for implementation; unlike fopen(), fopen_s() opens the file in exclusive mode. --- src/OSSupport/File.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp index 33b9cfc3f..8c24fa541 100644 --- a/src/OSSupport/File.cpp +++ b/src/OSSupport/File.cpp @@ -75,7 +75,7 @@ bool cFile::Open(const AString & iFileName, eMode iMode) } #ifdef _WIN32 - fopen_s(&m_File, (FILE_IO_PREFIX + iFileName).c_str(), Mode); + m_File = _fsopen((FILE_IO_PREFIX + iFileName).c_str(), Mode, _SH_DENYWR); #else m_File = fopen((FILE_IO_PREFIX + iFileName).c_str(), Mode); #endif // _WIN32 @@ -88,7 +88,7 @@ bool cFile::Open(const AString & iFileName, eMode iMode) // Simply re-open for read-writing, erasing existing contents: #ifdef _WIN32 - fopen_s(&m_File, (FILE_IO_PREFIX + iFileName).c_str(), "wb+"); + m_File = _fsopen((FILE_IO_PREFIX + iFileName).c_str(), "wb+", _SH_DENYWR); #else m_File = fopen((FILE_IO_PREFIX + iFileName).c_str(), "wb+"); #endif // _WIN32 -- cgit v1.2.3 From 8ff7cf926219d7e80a538e21f3f7af6e047fd25e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 20:56:42 +0200 Subject: Fixed a buffer overflow in cChunk:SetLight(). There are only half as many bytes for light than there are blocktypes. --- src/Chunk.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index cd3bceda2..59e8894fc 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -380,12 +380,12 @@ void cChunk::SetLight( { // Compress blocklight m_BlockLight.clear(); - m_BlockLight.insert(m_BlockLight.end(), &a_BlockLight[0], &a_BlockLight[m_BlockTypes.size()]); + m_BlockLight.insert(m_BlockLight.end(), &a_BlockLight[0], &a_BlockLight[m_BlockTypes.size() / 2]); } { // Compress skylight m_BlockSkyLight.clear(); - m_BlockSkyLight.insert(m_BlockSkyLight.end(), &a_SkyLight[0], &a_SkyLight[m_BlockTypes.size()]); + m_BlockSkyLight.insert(m_BlockSkyLight.end(), &a_SkyLight[0], &a_SkyLight[m_BlockTypes.size() / 2]); } m_IsLightValid = true; -- cgit v1.2.3 From 58224863c0e3c61f28e2f345e53ee632043de9c4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 22:07:30 +0200 Subject: Fixed vanilla fluid simulator. Fixes #919. --- src/Simulator/FloodyFluidSimulator.cpp | 4 ++-- src/Simulator/FloodyFluidSimulator.h | 13 +++++-------- src/Simulator/VanillaFluidSimulator.cpp | 15 ++++++++++++--- src/Simulator/VanillaFluidSimulator.h | 2 +- 4 files changed, 20 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp index 03e94e791..e95af3a1c 100644 --- a/src/Simulator/FloodyFluidSimulator.cpp +++ b/src/Simulator/FloodyFluidSimulator.cpp @@ -119,7 +119,7 @@ void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_Re if (SpreadFurther && (NewMeta < 8)) { // Spread to the neighbors: - Spread(a_Chunk, a_RelX, a_RelY, a_RelZ, NewMeta); + SpreadXZ(a_Chunk, a_RelX, a_RelY, a_RelZ, NewMeta); } // Mark as processed: @@ -130,7 +130,7 @@ void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_Re -void cFloodyFluidSimulator::Spread(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta) +void cFloodyFluidSimulator::SpreadXZ(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta) { SpreadToNeighbor(a_Chunk, a_RelX - 1, a_RelY, a_RelZ, a_NewMeta); SpreadToNeighbor(a_Chunk, a_RelX + 1, a_RelY, a_RelZ, a_NewMeta); diff --git a/src/Simulator/FloodyFluidSimulator.h b/src/Simulator/FloodyFluidSimulator.h index 632de3bb2..8e1be5e6b 100644 --- a/src/Simulator/FloodyFluidSimulator.h +++ b/src/Simulator/FloodyFluidSimulator.h @@ -48,16 +48,13 @@ protected: bool CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ); /** Checks if the specified block should harden (Water/Lava interaction) and if so, converts it to a suitable block. - * - * Returns whether the block was changed or not. - */ + Returns whether the block was changed or not. */ bool HardenBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta); - /** Spread water to neighbors. - * - * May be overridden to provide more sophisticated algorithms. - */ - virtual void Spread(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta); + /** Spread fluid to XZ neighbors. + The coords are of the block currently being processed; a_NewMeta is the new meta for the new fluid block. + Descendants may overridde to provide more sophisticated algorithms. */ + virtual void SpreadXZ(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta); } ; diff --git a/src/Simulator/VanillaFluidSimulator.cpp b/src/Simulator/VanillaFluidSimulator.cpp index 78aff9d68..28d75214c 100644 --- a/src/Simulator/VanillaFluidSimulator.cpp +++ b/src/Simulator/VanillaFluidSimulator.cpp @@ -35,14 +35,16 @@ cVanillaFluidSimulator::cVanillaFluidSimulator( -void cVanillaFluidSimulator::Spread(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta) +void cVanillaFluidSimulator::SpreadXZ(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta) { + // Calculate the distance to the nearest "hole" in each direction: int Cost[4]; Cost[0] = CalculateFlowCost(a_Chunk, a_RelX + 1, a_RelY, a_RelZ, X_PLUS); Cost[1] = CalculateFlowCost(a_Chunk, a_RelX - 1, a_RelY, a_RelZ, X_MINUS); Cost[2] = CalculateFlowCost(a_Chunk, a_RelX, a_RelY, a_RelZ + 1, Z_PLUS); Cost[3] = CalculateFlowCost(a_Chunk, a_RelX, a_RelY, a_RelZ - 1, Z_MINUS); + // Find the minimum distance: int MinCost = InfiniteCost; for (unsigned int i = 0; i < ARRAYCOUNT(Cost); ++i) { @@ -52,6 +54,7 @@ void cVanillaFluidSimulator::Spread(cChunk * a_Chunk, int a_RelX, int a_RelY, in } } + // Spread in all directions where the distance matches the minimum: if (Cost[0] == MinCost) { SpreadToNeighbor(a_Chunk, a_RelX + 1, a_RelY, a_RelZ, a_NewMeta); @@ -86,7 +89,10 @@ int cVanillaFluidSimulator::CalculateFlowCost(cChunk * a_Chunk, int a_RelX, int { return Cost; } - if (!IsPassableForFluid(BlockType) && !IsBlockLiquid(BlockType)) + if ( + !IsPassableForFluid(BlockType) || // The block cannot be passed by the liquid ... + (IsAllowedBlock(BlockType) && (BlockMeta == 0)) // ... or if it is liquid, it is a source block + ) { return Cost; } @@ -96,7 +102,10 @@ int cVanillaFluidSimulator::CalculateFlowCost(cChunk * a_Chunk, int a_RelX, int { return Cost; } - if (IsPassableForFluid(BlockType) || IsBlockLiquid(BlockType)) + if ( + IsPassableForFluid(BlockType) || // The block can be passed by the liquid ... + (IsBlockLiquid(BlockType) && (BlockMeta != 0)) // ... or it is a liquid and not a source block + ) { // Path found, exit return a_Iteration; diff --git a/src/Simulator/VanillaFluidSimulator.h b/src/Simulator/VanillaFluidSimulator.h index a9ea98b5a..89a56ca14 100644 --- a/src/Simulator/VanillaFluidSimulator.h +++ b/src/Simulator/VanillaFluidSimulator.h @@ -30,7 +30,7 @@ public: protected: // cFloodyFluidSimulator overrides: - virtual void Spread(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta) override; + virtual void SpreadXZ(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta) override; /** Recursively calculates the minimum number of blocks needed to descend a level. */ int CalculateFlowCost(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, Direction a_Dir, unsigned a_Iteration = 0); -- cgit v1.2.3 From 3942ebdcb6e62d8b2fb85fad9144a993a78477a6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 23:46:06 +0200 Subject: WebAdmin outputs a log message about HTTP / HTTPS status. --- src/HTTPServer/HTTPServer.cpp | 49 +++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp index c45044c66..b78a538a2 100644 --- a/src/HTTPServer/HTTPServer.cpp +++ b/src/HTTPServer/HTTPServer.cpp @@ -126,6 +126,24 @@ cHTTPServer::cHTTPServer(void) : m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer IPv6"), m_Callbacks(NULL) { +} + + + + + +cHTTPServer::~cHTTPServer() +{ + Stop(); +} + + + + + +bool cHTTPServer::Initialize(const AString & a_PortsIPv4, const AString & a_PortsIPv6) +{ + // Read the HTTPS cert + key: AString CertFile = cFile::ReadWholeFile("webadmin/httpscert.crt"); AString KeyFile = cFile::ReadWholeFile("webadmin/httpskey.pem"); if (!CertFile.empty() && !KeyFile.empty()) @@ -139,32 +157,27 @@ cHTTPServer::cHTTPServer(void) : if (res2 != 0) { // Reading the private key failed, reset the cert: - LOGWARNING("WebAdmin: Cannot read HTTPS certificate private key: -0x%x", -res2); + LOGWARNING("WebServer: Cannot read HTTPS certificate private key: -0x%x", -res2); m_Cert.reset(); } } else { - LOGWARNING("WebAdmin: Cannot read HTTPS certificate: -0x%x", -res); + LOGWARNING("WebServer: Cannot read HTTPS certificate: -0x%x", -res); } } -} - - - - -cHTTPServer::~cHTTPServer() -{ - Stop(); -} - - - - - -bool cHTTPServer::Initialize(const AString & a_PortsIPv4, const AString & a_PortsIPv6) -{ + // Notify the admin about the HTTPS / HTTP status + if (m_Cert.get() == NULL) + { + LOGWARNING("WebServer: The server is running in unsecure HTTP mode."); + } + else + { + LOGINFO("WebServer: The server is running in secure HTTPS mode."); + } + + // Open up requested ports: bool HasAnyPort; HasAnyPort = m_ListenThreadIPv4.Initialize(a_PortsIPv4); HasAnyPort = m_ListenThreadIPv6.Initialize(a_PortsIPv6) || HasAnyPort; -- cgit v1.2.3 From cbf4a17e0594ebd408d207bb689fedd70f1419e2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 23:50:22 +0200 Subject: Attempted fix for CLang warnings in Vector3.h. C++11 seems to have deprecated classes that have custom copy-constructor but not a custom assignment operator. --- src/Vector3.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Vector3.h b/src/Vector3.h index 2c79f9ff1..4a1440b32 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -163,8 +163,16 @@ public: z *= a_v; } - // tolua_begin + template inline Vector3 & operator =(const Vector3 & a_Rhs) + { + x = (T)a_Rhs.x; + y = (T)a_Rhs.y; + z = (T)a_Rhs.z; + return *this; + } + // tolua_begin + inline Vector3 operator + (const Vector3& a_Rhs) const { return Vector3( -- cgit v1.2.3 From 616ddf5ca50450279198775a598796bb367cf8ce Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 3 May 2014 06:02:51 -0700 Subject: cCHunkBuffer that compiles with TestGlobals.h --- src/BiomeDef.h | 2 +- src/ChunkBuffer.h | 7 +++++++ src/StringUtils.h | 3 +++ src/Vector3.h | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/BiomeDef.h b/src/BiomeDef.h index 67916890d..f929596e9 100644 --- a/src/BiomeDef.h +++ b/src/BiomeDef.h @@ -10,7 +10,7 @@ #pragma once - +#include "StringUtils.h" // tolua_begin diff --git a/src/ChunkBuffer.h b/src/ChunkBuffer.h index c23f8971d..410532232 100644 --- a/src/ChunkBuffer.h +++ b/src/ChunkBuffer.h @@ -1,6 +1,13 @@ #pragma once + +#include + + +#include "ChunkDef.h" + + #define CHUNK_SECTION_HEIGHT 16 #define CHUNK_SECTION_NUM (256 / CHUNK_SECTION_HEIGHT) diff --git a/src/StringUtils.h b/src/StringUtils.h index b69e47d3c..347fbe909 100644 --- a/src/StringUtils.h +++ b/src/StringUtils.h @@ -11,6 +11,9 @@ +#include + + typedef std::string AString; diff --git a/src/Vector3.h b/src/Vector3.h index 2c79f9ff1..53fdcf6df 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -5,6 +5,8 @@ #define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC) #include +#include +#include -- cgit v1.2.3 From 4377a5c31ec39974a4b9597528f95edae166ce29 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 3 May 2014 19:23:59 +0200 Subject: Fixed vanilla fluid simulator. Fixes #919. --- src/Simulator/VanillaFluidSimulator.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/Simulator/VanillaFluidSimulator.cpp b/src/Simulator/VanillaFluidSimulator.cpp index 28d75214c..18d9b07e1 100644 --- a/src/Simulator/VanillaFluidSimulator.cpp +++ b/src/Simulator/VanillaFluidSimulator.cpp @@ -102,10 +102,7 @@ int cVanillaFluidSimulator::CalculateFlowCost(cChunk * a_Chunk, int a_RelX, int { return Cost; } - if ( - IsPassableForFluid(BlockType) || // The block can be passed by the liquid ... - (IsBlockLiquid(BlockType) && (BlockMeta != 0)) // ... or it is a liquid and not a source block - ) + if (IsPassableForFluid(BlockType) || IsBlockLiquid(BlockType)) { // Path found, exit return a_Iteration; -- cgit v1.2.3 From ee79bd10c2b6e38ca5bc850d6fd06a1b22170619 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 3 May 2014 19:34:46 +0200 Subject: Implemented a true assignment operator for Vector3. --- src/Vector3.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Vector3.h b/src/Vector3.h index 4a1440b32..32c26026a 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -163,7 +163,15 @@ public: z *= a_v; } - template inline Vector3 & operator =(const Vector3 & a_Rhs) + inline Vector3 & operator = (const Vector3 & a_Rhs) + { + x = a_Rhs.x; + y = a_Rhs.y; + z = a_Rhs.z; + return *this; + } + + template inline Vector3 & operator = (const Vector3 & a_Rhs) { x = (T)a_Rhs.x; y = (T)a_Rhs.y; -- cgit v1.2.3 From d4ae00434c9087f2597f335250bd063d874dd349 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 3 May 2014 19:57:34 +0200 Subject: Fixed float comparison warnings in Vector3. There's a bitwise comparison (Equals), and there's Eps-based comparison (EqualsEps). --- src/Vector3.h | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Vector3.h b/src/Vector3.h index 32c26026a..30b8e748a 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -40,7 +40,6 @@ public: Vector3(const Vector3<_T> * a_Rhs) : x(a_Rhs->x), y(a_Rhs->y), z(a_Rhs->z) {} // tolua_begin - inline void Set(T a_x, T a_y, T a_z) { x = a_x; @@ -105,7 +104,18 @@ public: inline bool Equals(const Vector3 & a_Rhs) const { - return x == a_Rhs.x && y == a_Rhs.y && z == a_Rhs.z; + // Perform a bitwise comparison of the contents - we want to know whether this object is exactly equal + // To perform EPS-based comparison, use the EqualsEps() function + return ( + (memcmp(&x, &a_Rhs.x, sizeof(x)) == 0) && + (memcmp(&y, &a_Rhs.y, sizeof(y)) == 0) && + (memcmp(&z, &a_Rhs.z, sizeof(z)) == 0) + ); + } + + inline bool EqualsEps(const Vector3 & a_Rhs, T a_Eps) const + { + return (Abs(x - a_Rhs.x) < a_Eps) && (Abs(y - a_Rhs.y) < a_Eps) && (Abs(z - a_Rhs.z) < a_Eps); } inline bool operator == (const Vector3 & a_Rhs) const @@ -233,7 +243,7 @@ public: */ inline double LineCoeffToXYPlane(const Vector3 & a_OtherEnd, T a_Z) const { - if (abs(z - a_OtherEnd.z) < EPS) + if (Abs(z - a_OtherEnd.z) < EPS) { return NO_INTERSECTION; } @@ -248,7 +258,7 @@ public: */ inline double LineCoeffToXZPlane(const Vector3 & a_OtherEnd, T a_Y) const { - if (abs(y - a_OtherEnd.y) < EPS) + if (Abs(y - a_OtherEnd.y) < EPS) { return NO_INTERSECTION; } @@ -263,7 +273,7 @@ public: */ inline double LineCoeffToYZPlane(const Vector3 & a_OtherEnd, T a_X) const { - if (abs(x - a_OtherEnd.x) < EPS) + if (Abs(x - a_OtherEnd.x) < EPS) { return NO_INTERSECTION; } @@ -276,7 +286,15 @@ public: /** Return value of LineCoeffToPlane() if the line is parallel to the plane. */ static const double NO_INTERSECTION; + +protected: + /** Returns the absolute value of the given argument. + Templatized because the standard library differentiates between abs() and fabs(). */ + static T Abs(T a_Value) + { + return (a_Value < 0) ? -a_Value : a_Value; + } }; // tolua_end -- cgit v1.2.3 From b4496278a583747a82736d69b62684a1544d814e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 3 May 2014 20:17:47 +0200 Subject: Removed the controversial Vector3::operator <. It hasn't been used in any C++ code and Lua doesn't need it. --- src/Vector3.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/Vector3.h b/src/Vector3.h index 30b8e748a..20f9b4ca7 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -123,12 +123,6 @@ public: return Equals(a_Rhs); } - inline bool operator < (const Vector3 & a_Rhs) - { - // return (x < a_Rhs.x) && (y < a_Rhs.y) && (z < a_Rhs.z); ? - return (x < a_Rhs.x) || (x == a_Rhs.x && y < a_Rhs.y) || (x == a_Rhs.x && y == a_Rhs.y && z < a_Rhs.z); - } - inline void Move(T a_X, T a_Y, T a_Z) { x += a_X; -- cgit v1.2.3 From eaf3dcb9f7430bb76b737c1eb32ce68ca4835916 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 3 May 2014 23:46:04 +0200 Subject: Fixed connection encryption. Fixes #975. --- src/Protocol/Protocol17x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index eed761a4a..dc111e737 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -238,7 +238,7 @@ protected: bool m_IsEncrypted; cAesCfb128Decryptor m_Decryptor; - cAesCfb128Decryptor m_Encryptor; + cAesCfb128Encryptor m_Encryptor; /** The logfile where the comm is logged, when g_ShouldLogComm is true */ cFile m_CommLogFile; -- cgit v1.2.3 From 383fe0cc1e8236852ee714ee1c65ab68571d5809 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 3 May 2014 23:59:45 +0200 Subject: Hotfixed Chunked transfer encoding in Yggdrasil. By using HTTP/1.0, we're disabling the support for the Chunked encoding on the server. This is a hotfix for #979, a proper parser implementation is still needed. --- src/Protocol/Authenticator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index 41d614e58..2050393c2 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -214,7 +214,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S ReplaceString(ActualAddress, "%SERVERID%", a_ServerId); AString Request; - Request += "GET " + ActualAddress + " HTTP/1.1\r\n"; + Request += "GET " + ActualAddress + " HTTP/1.0\r\n"; Request += "Host: " + m_Server + "\r\n"; Request += "User-Agent: MCServer\r\n"; Request += "Connection: close\r\n"; -- cgit v1.2.3 From 41f6643fd20e98aebfeffef4d6bd4416526d326f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 4 May 2014 00:38:06 +0100 Subject: Fixed portal Z direction loop coding failure * Fixed portals created in the ZP/ZM direction eating its frame * Changed return type of a function --- src/Blocks/BlockFire.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockFire.h b/src/Blocks/BlockFire.h index c8f158e7e..f9f32eb50 100644 --- a/src/Blocks/BlockFire.h +++ b/src/Blocks/BlockFire.h @@ -68,7 +68,6 @@ public: { return 0; } - for (int newY = Y + 1; newY < cChunkDef::Height; newY++) { @@ -84,7 +83,7 @@ public: // This is because the frame is a solid obsidian pillar if ((MaxY != 0) && (newY == Y + 1)) { - return EvaluatePortalBorder(X, newY, Z, MaxY, a_ChunkInterface); + return EvaluatePortalBorder(X, newY, Z, MaxY, a_ChunkInterface) ? -1 /* -1 = found a frame */ : 0; } else { @@ -99,18 +98,18 @@ public: } /// Evaluates if coords have a valid border on top, based on MaxY - int EvaluatePortalBorder(int X, int FoundObsidianY, int Z, int MaxY, cChunkInterface & a_ChunkInterface) + bool EvaluatePortalBorder(int X, int FoundObsidianY, int Z, int MaxY, cChunkInterface & a_ChunkInterface) { for (int checkBorder = FoundObsidianY + 1; checkBorder <= MaxY - 1; checkBorder++) // FoundObsidianY + 1: FoundObsidianY has already been checked in FindObsidianCeiling; MaxY - 1: portal doesn't need corners { if (a_ChunkInterface.GetBlock(X, checkBorder, Z) != E_BLOCK_OBSIDIAN) { // Base obsidian, base + 1 obsidian, base + x NOT obsidian -> not complete portal - return 0; + return false; } } // Everything was obsidian, found a border! - return -1; // Return -1 for a frame border + return true; } /// Finds entire frame in any direction with the coordinates of a base block and fills hole with nether portal (START HERE) @@ -169,7 +168,7 @@ public: { return false; // Not valid slice, no portal can be formed } - } XZP = X1 - 1; // Set boundary of frame interior, note that for some reason, the loop of X and the loop of Z go to different numbers, hence -1 here and -2 there + } XZP = X1 - 1; // Set boundary of frame interior for (; ((a_ChunkInterface.GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM) { int Value = FindObsidianCeiling(X2, Y, Z, a_ChunkInterface, MaxY); @@ -199,13 +198,13 @@ public: if ((Value == -1) || (ValueTwo == -1)) { FoundFrameZP = true; - continue; + break; } else if ((Value != MaxY) && (ValueTwo != MaxY)) { return false; } - } XZP = Z1 - 2; + } XZP = Z1 - 1; for (; ((a_ChunkInterface.GetBlock(X, Y, Z2) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X, Y + 1, Z2) == E_BLOCK_OBSIDIAN)); Z2--) { int Value = FindObsidianCeiling(X, Y, Z2, a_ChunkInterface, MaxY); @@ -213,13 +212,13 @@ public: if ((Value == -1) || (ValueTwo == -1)) { FoundFrameZM = true; - continue; + break; } else if ((Value != MaxY) && (ValueTwo != MaxY)) { return false; } - } XZM = Z2 + 2; + } XZM = Z2 + 1; return (FoundFrameZP && FoundFrameZM); } }; -- cgit v1.2.3 From bcd8f727b49ee0308346b7421d35d09817362b19 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 4 May 2014 00:39:03 +0100 Subject: Fixed pressure plate oversights * Fixed stone pressure plates not checking for the correct distance for players * Fixed pressure plates in general not link powering the blocks beneath them --- src/Simulator/IncrementalRedstoneSimulator.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index d37d2eecf..7d3f1a53e 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -116,7 +116,9 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, // Things that can send power through a block but which depends on meta ((Block == E_BLOCK_REDSTONE_WIRE) && (Meta == 0)) || ((Block == E_BLOCK_LEVER) && !IsLeverOn(Meta)) || - (((Block == E_BLOCK_STONE_BUTTON) || (Block == E_BLOCK_WOODEN_BUTTON)) && (!IsButtonOn(Meta))) + (((Block == E_BLOCK_STONE_BUTTON) || (Block == E_BLOCK_WOODEN_BUTTON)) && (!IsButtonOn(Meta))) || + (((Block == E_BLOCK_STONE_PRESSURE_PLATE) || (Block == E_BLOCK_WOODEN_PRESSURE_PLATE)) && (Meta == 0)) || + (((Block == E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE) || (Block == E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE)) && (Meta == 0)) ) { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); @@ -1001,12 +1003,13 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc case E_BLOCK_STONE_PRESSURE_PLATE: { // MCS feature - stone pressure plates can only be triggered by players :D - cPlayer * a_Player = m_World.FindClosestPlayer(Vector3f(a_BlockX + 0.5f, (float)a_BlockY, a_BlockZ + 0.5f), 0.5f, false); + cPlayer * a_Player = m_World.FindClosestPlayer(Vector3f(a_BlockX + 0.5f, (float)a_BlockY, a_BlockZ + 0.5f), 0.7f, false); if (a_Player != NULL) { m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0x1); SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_STONE_PRESSURE_PLATE); + SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YM, a_MyType); } else { @@ -1069,6 +1072,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc } m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_DEPRESSED); SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType, Power); + SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YM, a_MyType); } else { @@ -1135,6 +1139,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc } m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_DEPRESSED); SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType, Power); + SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YM, a_MyType); } else { @@ -1201,6 +1206,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc } m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_DEPRESSED); SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType); + SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YM, a_MyType); } else { -- cgit v1.2.3 From 136aeb1f643d10561e975f9c5539043c9a9b647c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 4 May 2014 13:29:32 +0200 Subject: Removed convert-assign operator. We want all conversions to be explicit, not hidden. --- src/Vector3.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src') diff --git a/src/Vector3.h b/src/Vector3.h index 20f9b4ca7..276bf67c9 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -175,14 +175,6 @@ public: return *this; } - template inline Vector3 & operator = (const Vector3 & a_Rhs) - { - x = (T)a_Rhs.x; - y = (T)a_Rhs.y; - z = (T)a_Rhs.z; - return *this; - } - // tolua_begin inline Vector3 operator + (const Vector3& a_Rhs) const -- cgit v1.2.3 From 027efe09ea3d3222c3cbf169643e57773c1614ae Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 4 May 2014 14:00:59 +0100 Subject: Fixed lever and button powering direction --- src/Simulator/IncrementalRedstoneSimulator.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 5ac48d328..c8709a9af 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -9,6 +9,8 @@ #include "../Entities/Pickup.h" #include "../Blocks/BlockTorch.h" #include "../Blocks/BlockDoor.h" +#include "../Blocks/BlockButton.h" +#include "../Blocks/BlockLever.h" #include "../Piston.h" @@ -434,16 +436,11 @@ void cIncrementalRedstoneSimulator::HandleRedstoneBlock(int a_RelBlockX, int a_R void cIncrementalRedstoneSimulator::HandleRedstoneLever(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - if (IsLeverOn(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) + NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); + if (IsLeverOn(Meta)) { SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); - - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YM); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YP); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, cBlockLeverHandler::BlockMetaDataToBlockFace(Meta)); } } @@ -484,16 +481,11 @@ void cIncrementalRedstoneSimulator::HandleFenceGate(int a_RelBlockX, int a_RelBl void cIncrementalRedstoneSimulator::HandleRedstoneButton(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - if (IsButtonOn(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) + NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); + if (IsButtonOn(Meta)) { SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); - - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YM); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YP); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, cBlockButtonHandler::BlockMetaDataToBlockFace(Meta)); } } -- cgit v1.2.3 From a94546a04710852fc7d82523e187fbd7f2a40880 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 4 May 2014 14:42:12 +0100 Subject: Fixed 027efe09ea3d3222c3cbf169643e57773c1614ae --- src/Simulator/IncrementalRedstoneSimulator.cpp | 52 ++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 6e722d0fa..3e8a4dec0 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -442,7 +442,31 @@ void cIncrementalRedstoneSimulator::HandleRedstoneLever(int a_RelBlockX, int a_R if (IsLeverOn(Meta)) { SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, cBlockLeverHandler::BlockMetaDataToBlockFace(Meta)); + + NIBBLETYPE Dir = cBlockLeverHandler::BlockMetaDataToBlockFace(Meta); + switch (Dir) + { + case BLOCK_FACE_YP: + case BLOCK_FACE_XP: + case BLOCK_FACE_ZP: + { + Dir--; + break; + } + case BLOCK_FACE_XM: + case BLOCK_FACE_ZM: + case BLOCK_FACE_YM: + { + Dir++; + break; + } + default: + { + ASSERT(!"Unhandled lever metadata!"); + return; + } + } + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Dir); } } @@ -486,8 +510,29 @@ void cIncrementalRedstoneSimulator::HandleRedstoneButton(int a_RelBlockX, int a_ NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); if (IsButtonOn(Meta)) { - SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, cBlockButtonHandler::BlockMetaDataToBlockFace(Meta)); + SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);NIBBLETYPE Dir = cBlockButtonHandler::BlockMetaDataToBlockFace(Meta); + + switch (Dir) + { + case BLOCK_FACE_XP: + case BLOCK_FACE_ZP: + { + Dir--; + break; + } + case BLOCK_FACE_XM: + case BLOCK_FACE_ZM: + { + Dir++; + break; + } + default: + { + ASSERT(!"Unhandled button metadata!"); + return; + } + } + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Dir); } } @@ -1207,6 +1252,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R { public: cPressurePlateCallback(int a_BlockX, int a_BlockY, int a_BlockZ) : + m_FoundEntity(false), m_X(a_BlockX), m_Y(a_BlockY), m_Z(a_BlockZ) -- cgit v1.2.3 From bde40af40664e0b526fed8224c1f00531c5610c6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 5 May 2014 15:43:45 +0100 Subject: Fixed formatting --- src/Simulator/IncrementalRedstoneSimulator.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 3e8a4dec0..f12bd6d49 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -444,7 +444,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneLever(int a_RelBlockX, int a_R SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); NIBBLETYPE Dir = cBlockLeverHandler::BlockMetaDataToBlockFace(Meta); - switch (Dir) + switch (Dir) // Now, flip the direction into the type used by SetBlockLinkedPowered() { case BLOCK_FACE_YP: case BLOCK_FACE_XP: @@ -510,9 +510,10 @@ void cIncrementalRedstoneSimulator::HandleRedstoneButton(int a_RelBlockX, int a_ NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); if (IsButtonOn(Meta)) { - SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);NIBBLETYPE Dir = cBlockButtonHandler::BlockMetaDataToBlockFace(Meta); - - switch (Dir) + SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); + + NIBBLETYPE Dir = cBlockButtonHandler::BlockMetaDataToBlockFace(Meta); + switch (Dir) // Now, flip the direction into the type used by SetBlockLinkedPowered() { case BLOCK_FACE_XP: case BLOCK_FACE_ZP: -- cgit v1.2.3 From ef85bef978795956208214794aec91122584b648 Mon Sep 17 00:00:00 2001 From: worktycho Date: Mon, 5 May 2014 16:06:45 +0100 Subject: Fixed crash on creating a world during plugin initialisation --- src/DeadlockDetect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/DeadlockDetect.cpp b/src/DeadlockDetect.cpp index 38a3c369e..f73a45555 100644 --- a/src/DeadlockDetect.cpp +++ b/src/DeadlockDetect.cpp @@ -109,7 +109,7 @@ void cDeadlockDetect::CheckWorldAge(const AString & a_WorldName, Int64 a_Age) WorldAges::iterator itr = m_WorldAges.find(a_WorldName); if (itr == m_WorldAges.end()) { - ASSERT(!"Unknown world in cDeadlockDetect"); + SetWorldAge(a_WorldName, a_Age); return; } -- cgit v1.2.3 From 3c102870f600178b7cabf6714f83e06fc05b42fd Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 1 May 2014 00:47:57 +0200 Subject: Add anvil window and slot area. --- src/Blocks/BlockAnvil.h | 7 ++ src/Enchantments.cpp | 9 +++ src/Enchantments.h | 3 + src/Items/ItemArmor.h | 43 ++++++++++++ src/Items/ItemHandler.cpp | 19 +++++ src/Items/ItemHandler.h | 6 ++ src/Items/ItemPickaxe.h | 13 ++++ src/Items/ItemShovel.h | 14 ++++ src/Items/ItemSword.h | 13 ++++ src/UI/SlotArea.cpp | 173 ++++++++++++++++++++++++++++++++++++++++++++++ src/UI/SlotArea.h | 29 ++++++++ src/UI/Window.cpp | 15 ++++ src/UI/Window.h | 12 ++++ 13 files changed, 356 insertions(+) (limited to 'src') diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h index 93a796ef7..c9eec961d 100644 --- a/src/Blocks/BlockAnvil.h +++ b/src/Blocks/BlockAnvil.h @@ -23,6 +23,13 @@ public: { a_Pickups.push_back(cItem(E_BLOCK_ANVIL, 1, a_BlockMeta >> 2)); } + + + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override + { + cWindow * Window = new cAnvilWindow(); + a_Player->OpenWindow(Window); + } virtual bool GetPlacementBlockTypeMeta( diff --git a/src/Enchantments.cpp b/src/Enchantments.cpp index 64f89815b..bfcde9dac 100644 --- a/src/Enchantments.cpp +++ b/src/Enchantments.cpp @@ -83,6 +83,15 @@ void cEnchantments::AddFromString(const AString & a_StringSpec) +int cEnchantments::Size(void) +{ + return (int)m_Enchantments.size(); +} + + + + + AString cEnchantments::ToString(void) const { // Serialize all the enchantments into a string diff --git a/src/Enchantments.h b/src/Enchantments.h index ec42257c8..82eea53f9 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -84,6 +84,9 @@ public: /** Adds enchantments in the stringspec; if a specified enchantment already exists, overwrites it */ void AddFromString(const AString & a_StringSpec); + /** Get the count of enchantments */ + int Size(void); + /** Serializes all the enchantments into a string */ AString ToString(void) const; diff --git a/src/Items/ItemArmor.h b/src/Items/ItemArmor.h index 08cddb1ad..f53100bb1 100644 --- a/src/Items/ItemArmor.h +++ b/src/Items/ItemArmor.h @@ -60,6 +60,49 @@ public: return true; } + virtual bool CanRepairWithItem(const cItem & a_Item) override + { + switch (m_ItemType) + { + case E_ITEM_CHAIN_BOOTS: + case E_ITEM_CHAIN_CHESTPLATE: + case E_ITEM_CHAIN_HELMET: + case E_ITEM_CHAIN_LEGGINGS: + { + return (a_Item.m_ItemType == E_ITEM_IRON); + } + case E_ITEM_DIAMOND_BOOTS: + case E_ITEM_DIAMOND_CHESTPLATE: + case E_ITEM_DIAMOND_HELMET: + case E_ITEM_DIAMOND_LEGGINGS: + { + return (a_Item.m_ItemType == E_ITEM_DIAMOND); + } + case E_ITEM_IRON_BOOTS: + case E_ITEM_IRON_CHESTPLATE: + case E_ITEM_IRON_HELMET: + case E_ITEM_IRON_LEGGINGS: + { + return (a_Item.m_ItemType == E_ITEM_IRON); + } + case E_ITEM_GOLD_BOOTS: + case E_ITEM_GOLD_CHESTPLATE: + case E_ITEM_GOLD_HELMET: + case E_ITEM_GOLD_LEGGINGS: + { + return (a_Item.m_ItemType == E_ITEM_GOLD); + } + case E_ITEM_LEATHER_BOOTS: + case E_ITEM_LEATHER_CAP: + case E_ITEM_LEATHER_PANTS: + case E_ITEM_LEATHER_TUNIC: + { + return (a_Item.m_ItemType == E_ITEM_LEATHER); + } + } + return false; + } + } ; diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index ce9593a70..105def2ce 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -511,6 +511,25 @@ bool cItemHandler::IsPlaceable(void) + +bool cItemHandler::CanRepairWithItem(const cItem & a_Item) +{ + return false; +} + + + + + +int cItemHandler::GetRepairCost(void) +{ + return 0; +} + + + + + bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) { UNUSED(a_BlockType); diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index 4993eac85..420eefcf1 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -85,6 +85,12 @@ public: /** Blocks simply get placed */ virtual bool IsPlaceable(void); + /** Can the anvil repair this item, when a_Item is the second input? */ + virtual bool CanRepairWithItem(const cItem & a_Item); + + /** Get the repair cost from the item, or 0 if the item hasn't repair cost. */ + virtual int GetRepairCost(void); + /** Called before a block is placed into a world. The handler should return true to allow placement, false to refuse. Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block. diff --git a/src/Items/ItemPickaxe.h b/src/Items/ItemPickaxe.h index 2a8e40daa..46e68ec70 100644 --- a/src/Items/ItemPickaxe.h +++ b/src/Items/ItemPickaxe.h @@ -85,6 +85,19 @@ public: } return false; } + + virtual bool CanRepairWithItem(const cItem & a_Item) override + { + switch (m_ItemType) + { + case E_ITEM_WOODEN_PICKAXE: return (a_Item.m_ItemType == E_BLOCK_PLANKS); + case E_ITEM_STONE_PICKAXE: return (a_Item.m_ItemType == E_BLOCK_COBBLESTONE); + case E_ITEM_IRON_PICKAXE: return (a_Item.m_ItemType == E_ITEM_IRON); + case E_ITEM_GOLD_PICKAXE: return (a_Item.m_ItemType == E_ITEM_GOLD); + case E_ITEM_DIAMOND_PICKAXE: return (a_Item.m_ItemType == E_ITEM_DIAMOND); + } + return false; + } } ; diff --git a/src/Items/ItemShovel.h b/src/Items/ItemShovel.h index 873d5ae25..7659ccc54 100644 --- a/src/Items/ItemShovel.h +++ b/src/Items/ItemShovel.h @@ -41,4 +41,18 @@ public: { return (a_BlockType == E_BLOCK_SNOW); } + + virtual bool CanRepairWithItem(const cItem & a_Item) override + { + switch (m_ItemType) + { + case E_ITEM_WOODEN_SHOVEL: return (a_Item.m_ItemType == E_BLOCK_PLANKS); + case E_ITEM_STONE_SHOVEL: return (a_Item.m_ItemType == E_BLOCK_COBBLESTONE); + case E_ITEM_IRON_SHOVEL: return (a_Item.m_ItemType == E_ITEM_IRON); + case E_ITEM_GOLD_SHOVEL: return (a_Item.m_ItemType == E_ITEM_GOLD); + case E_ITEM_DIAMOND_SHOVEL: return (a_Item.m_ItemType == E_ITEM_DIAMOND); + } + return false; + } + }; diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h index a7c1d2432..34656ff99 100644 --- a/src/Items/ItemSword.h +++ b/src/Items/ItemSword.h @@ -23,6 +23,19 @@ public: { return (a_BlockType == E_BLOCK_COBWEB); } + + virtual bool CanRepairWithItem(const cItem & a_Item) override + { + switch (m_ItemType) + { + case E_ITEM_WOODEN_SWORD: return (a_Item.m_ItemType == E_BLOCK_PLANKS); + case E_ITEM_STONE_SWORD: return (a_Item.m_ItemType == E_BLOCK_COBBLESTONE); + case E_ITEM_IRON_SWORD: return (a_Item.m_ItemType == E_ITEM_IRON); + case E_ITEM_GOLD_SWORD: return (a_Item.m_ItemType == E_ITEM_GOLD); + case E_ITEM_DIAMOND_SWORD: return (a_Item.m_ItemType == E_ITEM_DIAMOND); + } + return false; + } } ; diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 87b4032e0..eac8257ec 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -595,6 +595,179 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player) +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cSlotAreaAnvil: + +cSlotAreaAnvil::cSlotAreaAnvil(cAnvilWindow & a_ParentWindow) : + cSlotAreaTemporary(3, a_ParentWindow), + m_MaximumCost(0), + m_RepairedItemName("") +{ +} + + + + + +void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) +{ + super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem); + UpdateResult(a_Player); +} + + + + + +void cSlotAreaAnvil::OnPlayerRemoved(cPlayer & a_Player) +{ + TossItems(a_Player, 0, 3); + super::OnPlayerRemoved(a_Player); +} + + + + + +void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) +{ + cItem Input(*GetSlot(0, a_Player)); + cItem SecondInput(*GetSlot(1, a_Player)); + cItem Output(*GetSlot(2, a_Player)); + + if (Input.IsEmpty() && !Output.IsEmpty()) + { + Output.Empty(); + SetSlot(2, a_Player, Output); + m_ParentWindow.SetProperty(0, 0, a_Player); + return; + } + + int RepairCost = cItemHandler::GetItemHandler(Input)->GetRepairCost(); + int NeedExp = 0; + if (!SecondInput.IsEmpty()) + { + RepairCost += cItemHandler::GetItemHandler(SecondInput)->GetRepairCost(); + + if (Input.IsDamageable() && cItemHandler::GetItemHandler(Input)->CanRepairWithItem(SecondInput)) + { + // Tool and armor repair with special item (iron / gold / diamond / ...) + int DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4); + if (DamageDiff < 0) + { + // No enchantment + Output.Empty(); + SetSlot(2, a_Player, Output); + m_ParentWindow.SetProperty(0, 0, a_Player); + return; + } + + int x = 0; + while ((DamageDiff > 0) && (x < SecondInput.m_ItemCount)) + { + Input.m_ItemDamage -= DamageDiff; + NeedExp += std::max(1, DamageDiff / 100) + Input.m_Enchantments.Size(); + DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4); + + ++x; + } + } + else + { + // Tool and armor repair with two tools / armors + if (!Input.IsSameType(SecondInput) || !Input.IsDamageable()) + { + // No enchantment + Output.Empty(); + SetSlot(2, a_Player, Output); + m_ParentWindow.SetProperty(0, 0, a_Player); + return; + } + + int FirstDamageDiff = Input.GetMaxDamage() - Input.m_ItemDamage; + int SecondDamageDiff = SecondInput.GetMaxDamage() - SecondInput.m_ItemDamage; + int Damage = SecondDamageDiff + Input.GetMaxDamage() * 12 / 100; + + int NewItemDamage = Input.GetMaxDamage() - (FirstDamageDiff + Damage); + if (NewItemDamage > 0) + { + NewItemDamage = 0; + } + + if (NewItemDamage < Input.m_ItemDamage) + { + Input.m_ItemDamage = NewItemDamage; + NeedExp += std::max(1, Damage / 100); + } + + // TODO: Add enchantments. + } + } + + int NameChangeExp = 0; + if (m_RepairedItemName.empty()) + { + // Remove custom name + if (!Input.m_CustomName.empty()) + { + NameChangeExp = (Input.IsDamageable()) ? 4 : (Input.m_ItemCount * 5); + NeedExp += NameChangeExp; + Input.m_CustomName = ""; + } + } + else if (m_RepairedItemName != Input.m_CustomName) + { + // Change custom name + NameChangeExp = (Input.IsDamageable()) ? 4 : (Input.m_ItemCount * 5); + NeedExp += NameChangeExp; + + if (!Input.m_CustomName.empty()) + { + RepairCost += NameChangeExp / 2; + } + + Input.m_CustomName = m_RepairedItemName; + } + + // TODO: Add enchantment exp cost. + + int MaximumCost = RepairCost + NeedExp; + + if (NeedExp < 0) + { + Input.Empty(); + } + + if (NameChangeExp == NeedExp && NameChangeExp > 0 && MaximumCost >= 40) + { + MaximumCost = 39; + } + if (MaximumCost >= 40 && !a_Player.IsGameModeCreative()) + { + Input.Empty(); + } + + /* TODO: Add repair cost to cItem and not ItemHandler. This is required for this function! + if (!Input.IsEmpty()) + { + RepairCost = max(cItemHandler::GetItemHandler(Input)->GetRepairCost(), cItemHandler::GetItemHandler(SecondInput)->GetRepairCost()); + if (!Input.m_CustomName.empty()) + { + RepairCost -= 9; + } + RepairCost = max(RepairCost, 0); + RepairCost += 2; + }*/ + + SetSlot(2, a_Player, Input); + m_ParentWindow.SetProperty(0, MaximumCost, a_Player); +} + + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cSlotAreaEnchanting: diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index 254722822..a316480c6 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -9,6 +9,7 @@ #pragma once #include "../Inventory.h" +#include "Window.h" @@ -259,6 +260,34 @@ protected: +class cSlotAreaAnvil : + public cSlotAreaTemporary +{ + typedef cSlotAreaTemporary super; + +public: + cSlotAreaAnvil(cAnvilWindow & a_ParentWindow); + + // cSlotArea overrides: + virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override; + + // cSlotAreaTemporary overrides: + virtual void OnPlayerRemoved(cPlayer & a_Player) override; + +protected: + /** Handles a click in the item slot. */ + void UpdateResult(cPlayer & a_Player); + + /** The maximum cost of repairing/renaming in the anvil. */ + int m_MaximumCost; + + AString m_RepairedItemName; +} ; + + + + + class cSlotAreaEnchanting : public cSlotAreaTemporary { diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 0a78578fc..eb105f8ab 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -804,6 +804,21 @@ cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cAnvilWindow: + +cAnvilWindow::cAnvilWindow() : + cWindow(wtAnvil, "Repair") +{ + m_SlotAreas.push_back(new cSlotAreaAnvil(*this)); + m_SlotAreas.push_back(new cSlotAreaInventory(*this)); + m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cEnchantingWindow: diff --git a/src/UI/Window.h b/src/UI/Window.h index 1ca67bfd8..c08b36f9b 100644 --- a/src/UI/Window.h +++ b/src/UI/Window.h @@ -231,6 +231,18 @@ public: +class cAnvilWindow : + public cWindow +{ + typedef cWindow super; +public: + cAnvilWindow(); +} ; + + + + + class cEnchantingWindow : public cWindow { -- cgit v1.2.3 From 6ac332cd0662f49e30f60ae0b5a3b7f85df8cfb3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 1 May 2014 01:25:04 +0200 Subject: Add MC|ItemName plugin message. --- src/ClientHandle.cpp | 32 ++++++++++++++++++++++++++++++++ src/ClientHandle.h | 3 +++ src/UI/SlotArea.cpp | 10 +++++----- src/UI/SlotArea.h | 2 -- src/UI/Window.cpp | 3 ++- src/UI/Window.h | 9 +++++++++ 6 files changed, 51 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index d414c3178..c0ddd1770 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -633,6 +633,10 @@ void cClientHandle::HandlePluginMessage(const AString & a_Channel, const AString // Client <-> Server branding exchange SendPluginMessage("MC|Brand", "MCServer"); } + else if (a_Channel == "MC|ItemName") + { + HandleAnvilItemName(a_Message.c_str(), a_Message.size()); + } else if (a_Channel == "REGISTER") { if (HasPluginChannel(a_Channel)) @@ -774,6 +778,34 @@ void cClientHandle::HandleCommandBlockMessage(const char * a_Data, size_t a_Leng +void cClientHandle::HandleAnvilItemName(const char * a_Data, unsigned int a_Length) +{ + if (a_Length < 1) + { + return; + } + + if ((m_Player->GetWindow() == NULL) || (m_Player->GetWindow()->GetWindowType() != cWindow::wtAnvil)) + { + return; + } + + cByteBuffer Buffer(a_Length); + Buffer.Write(a_Data, a_Length); + + AString Name; + Buffer.ReadAll(Name); + + if (Name.length() <= 30) + { + ((cAnvilWindow&)*m_Player->GetWindow()).SetRepairedItemName(Name); + } +} + + + + + void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, char a_Status) { LOGD("HandleLeftClick: {%i, %i, %i}; Face: %i; Stat: %i", diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 9fd17ac00..4dc6ab074 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -385,6 +385,9 @@ private: /** Handles the "MC|AdvCdm" plugin message */ void HandleCommandBlockMessage(const char * a_Data, size_t a_Length); + + /** Handles the "MC|ItemName" plugin message */ + void HandleAnvilItemName(const char * a_Data, size_t a_Length); // cSocketThreads::cCallback overrides: virtual void DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index eac8257ec..2941982a7 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -600,8 +600,7 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player) cSlotAreaAnvil::cSlotAreaAnvil(cAnvilWindow & a_ParentWindow) : cSlotAreaTemporary(3, a_ParentWindow), - m_MaximumCost(0), - m_RepairedItemName("") + m_MaximumCost(0) { } @@ -705,7 +704,8 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) } int NameChangeExp = 0; - if (m_RepairedItemName.empty()) + const AString & RepairedItemName = ((cAnvilWindow*)&m_ParentWindow)->GetRepairedItemName(); + if (RepairedItemName.empty()) { // Remove custom name if (!Input.m_CustomName.empty()) @@ -715,7 +715,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) Input.m_CustomName = ""; } } - else if (m_RepairedItemName != Input.m_CustomName) + else if (RepairedItemName != Input.m_CustomName) { // Change custom name NameChangeExp = (Input.IsDamageable()) ? 4 : (Input.m_ItemCount * 5); @@ -726,7 +726,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) RepairCost += NameChangeExp / 2; } - Input.m_CustomName = m_RepairedItemName; + Input.m_CustomName = RepairedItemName; } // TODO: Add enchantment exp cost. diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index a316480c6..01dcb88ab 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -280,8 +280,6 @@ protected: /** The maximum cost of repairing/renaming in the anvil. */ int m_MaximumCost; - - AString m_RepairedItemName; } ; diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index eb105f8ab..d6adbef8f 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -808,7 +808,8 @@ cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : // cAnvilWindow: cAnvilWindow::cAnvilWindow() : - cWindow(wtAnvil, "Repair") + cWindow(wtAnvil, "Repair"), + m_RepairedItemName("") { m_SlotAreas.push_back(new cSlotAreaAnvil(*this)); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); diff --git a/src/UI/Window.h b/src/UI/Window.h index c08b36f9b..8f6f80a41 100644 --- a/src/UI/Window.h +++ b/src/UI/Window.h @@ -237,6 +237,15 @@ class cAnvilWindow : typedef cWindow super; public: cAnvilWindow(); + + /** Gets the repaired item name. */ + AString GetRepairedItemName(void) const { return m_RepairedItemName; } + + /** Set the repaired item name. */ + void SetRepairedItemName(const AString & a_Name) { m_RepairedItemName = a_Name; } + +protected: + AString m_RepairedItemName; } ; -- cgit v1.2.3 From 7fe6e40bf7d40347f7f452ea2b7c353a5bc8073f Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 3 May 2014 23:42:26 +0200 Subject: Add clicks, exp subtraction, item check, ... --- src/Blocks/BlockAnvil.h | 2 +- src/ClientHandle.cpp | 2 +- src/Simulator/SandSimulator.cpp | 4 + src/UI/SlotArea.cpp | 164 +++++++++++++++++++++++++++++++++++++--- src/UI/SlotArea.h | 9 ++- src/UI/Window.cpp | 35 ++++++++- src/UI/Window.h | 12 ++- 7 files changed, 210 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h index c9eec961d..35a356678 100644 --- a/src/Blocks/BlockAnvil.h +++ b/src/Blocks/BlockAnvil.h @@ -27,7 +27,7 @@ public: virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { - cWindow * Window = new cAnvilWindow(); + cWindow * Window = new cAnvilWindow(a_BlockX, a_BlockY, a_BlockZ); a_Player->OpenWindow(Window); } diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index c0ddd1770..dbc07a96d 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -798,7 +798,7 @@ void cClientHandle::HandleAnvilItemName(const char * a_Data, unsigned int a_Leng if (Name.length() <= 30) { - ((cAnvilWindow&)*m_Player->GetWindow()).SetRepairedItemName(Name); + ((cAnvilWindow&)*m_Player->GetWindow()).SetRepairedItemName(Name, m_Player); } } diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp index f305ba61a..c4f57c86a 100644 --- a/src/Simulator/SandSimulator.cpp +++ b/src/Simulator/SandSimulator.cpp @@ -254,6 +254,10 @@ void cSandSimulator::FinishFalling( { // Rematerialize the material here: a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_FallingBlockType, a_FallingBlockMeta); + if (a_FallingBlockType == E_BLOCK_ANVIL) + { + a_World->BroadcastSoundParticleEffect(1022, a_BlockX, a_BlockY, a_BlockZ, 0); + } return; } diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 2941982a7..1e488de62 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -610,8 +610,151 @@ cSlotAreaAnvil::cSlotAreaAnvil(cAnvilWindow & a_ParentWindow) : void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) { - super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem); - UpdateResult(a_Player); + ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots())); + if (a_SlotNum != 2) + { + super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem); + UpdateResult(a_Player); + return; + } + + bool bAsync = false; + if (GetSlot(a_SlotNum, a_Player) == NULL) + { + LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum); + return; + } + + if (a_ClickAction == caDblClick) + { + return; + } + + cItem Slot(*GetSlot(a_SlotNum, a_Player)); + if (!Slot.IsSameType(a_ClickedItem)) + { + LOGWARNING("*** Window lost sync at item %d in SlotArea with %d items ***", a_SlotNum, m_NumSlots); + LOGWARNING("My item: %s", ItemToFullString(Slot).c_str()); + LOGWARNING("Their item: %s", ItemToFullString(a_ClickedItem).c_str()); + bAsync = true; + } + cItem & DraggingItem = a_Player.GetDraggingItem(); + + if (Slot.IsEmpty()) + { + return; + } + if (!DraggingItem.IsEmpty()) + { + if (!(DraggingItem.IsEqual(Slot) && ((DraggingItem.m_ItemCount + Slot.m_ItemCount) <= cItemHandler::GetItemHandler(Slot)->GetMaxStackSize()))) + { + return; + } + } + + if (!CanTakeResultItem(a_Player)) + { + return; + } + + cItem NewItem = cItem(Slot); + NewItem.m_ItemCount += DraggingItem.m_ItemCount; + + Slot.Empty(); + DraggingItem.Empty(); + SetSlot(a_SlotNum, a_Player, Slot); + + DraggingItem = NewItem; + OnTakeResult(a_Player, NewItem); + + if (bAsync) + { + m_ParentWindow.BroadcastWholeWindow(); + } +} + + + + + +void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player, cItem a_ResultItem) +{ + if (!a_Player.IsGameModeCreative()) + { + a_Player.DeltaExperience(cPlayer::XpForLevel(m_MaximumCost)); + } + SetSlot(0, a_Player, cItem()); + + if (m_StackSizeToBeUsedInRepair > 0) + { + const cItem * Item = GetSlot(1, a_Player); + if (!Item->IsEmpty() && (Item->m_ItemCount > m_StackSizeToBeUsedInRepair)) + { + cItem NewSecondItem(*Item); + NewSecondItem.m_ItemCount -= m_StackSizeToBeUsedInRepair; + SetSlot(1, a_Player, NewSecondItem); + } + else + { + SetSlot(1, a_Player, cItem()); + } + } + else + { + SetSlot(1, a_Player, cItem()); + } + m_ParentWindow.SetProperty(0, m_MaximumCost, a_Player); + + m_MaximumCost = 0; + ((cAnvilWindow*)&m_ParentWindow)->SetRepairedItemName("", false); + + int PosX, PosY, PosZ; + ((cAnvilWindow*)&m_ParentWindow)->GetBlockPos(PosX, PosY, PosZ); + + BLOCKTYPE Block; + NIBBLETYPE BlockMeta; + a_Player.GetWorld()->GetBlockTypeMeta(PosX, PosY, PosZ, Block, BlockMeta); + + cFastRandom Random; + if (!a_Player.IsGameModeCreative() && (Block == E_BLOCK_ANVIL) && (Random.NextFloat(1.0F) < 0.12F)) + { + NIBBLETYPE var4 = BlockMeta & 0x3; + NIBBLETYPE AnvilDamage = BlockMeta >> 2; + ++AnvilDamage; + + if (AnvilDamage > 2) + { + // Anvil will break + a_Player.GetWorld()->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, (NIBBLETYPE)0); + a_Player.GetWorld()->BroadcastSoundParticleEffect(1020, PosX, PosY, PosZ, 0); + a_Player.CloseWindow(false); + } + else + { + a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, var4 | AnvilDamage << 2); + a_Player.GetWorld()->BroadcastSoundParticleEffect(1021, PosX, PosY, PosZ, 0); + } + } + else + { + a_Player.GetWorld()->BroadcastSoundParticleEffect(1021, PosX, PosY, PosZ, 0); + } +} + + + + + +bool cSlotAreaAnvil::CanTakeResultItem(cPlayer & a_Player) +{ + return ( + ( + a_Player.IsGameModeCreative() + || a_Player.GetXpLevel() >= m_MaximumCost + ) + && !GetSlot(2, a_Player)->IsEmpty() + && m_MaximumCost > 0 + ); } @@ -620,7 +763,7 @@ void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C void cSlotAreaAnvil::OnPlayerRemoved(cPlayer & a_Player) { - TossItems(a_Player, 0, 3); + TossItems(a_Player, 0, 2); super::OnPlayerRemoved(a_Player); } @@ -641,7 +784,9 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) m_ParentWindow.SetProperty(0, 0, a_Player); return; } - + + m_MaximumCost = 0; + m_StackSizeToBeUsedInRepair = 0; int RepairCost = cItemHandler::GetItemHandler(Input)->GetRepairCost(); int NeedExp = 0; if (!SecondInput.IsEmpty()) @@ -670,6 +815,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) ++x; } + m_StackSizeToBeUsedInRepair = x; } else { @@ -731,18 +877,18 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) // TODO: Add enchantment exp cost. - int MaximumCost = RepairCost + NeedExp; + m_MaximumCost = RepairCost + NeedExp; if (NeedExp < 0) { Input.Empty(); } - if (NameChangeExp == NeedExp && NameChangeExp > 0 && MaximumCost >= 40) + if (NameChangeExp == NeedExp && NameChangeExp > 0 && m_MaximumCost >= 40) { - MaximumCost = 39; + m_MaximumCost = 39; } - if (MaximumCost >= 40 && !a_Player.IsGameModeCreative()) + if (m_MaximumCost >= 40 && !a_Player.IsGameModeCreative()) { Input.Empty(); } @@ -760,7 +906,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) }*/ SetSlot(2, a_Player, Input); - m_ParentWindow.SetProperty(0, MaximumCost, a_Player); + m_ParentWindow.SetProperty(0, m_MaximumCost, a_Player); } diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index 01dcb88ab..4f273ec65 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -274,12 +274,19 @@ public: // cSlotAreaTemporary overrides: virtual void OnPlayerRemoved(cPlayer & a_Player) override; -protected: + bool CanTakeResultItem(cPlayer & a_Player); + + void OnTakeResult(cPlayer & a_Player, cItem a_ResultItem); + /** Handles a click in the item slot. */ void UpdateResult(cPlayer & a_Player); +protected: /** The maximum cost of repairing/renaming in the anvil. */ int m_MaximumCost; + + /** The stack size of the second item where was used for repair */ + char m_StackSizeToBeUsedInRepair; } ; diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index d6adbef8f..4991f0147 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -807,11 +807,15 @@ cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cAnvilWindow: -cAnvilWindow::cAnvilWindow() : +cAnvilWindow::cAnvilWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : cWindow(wtAnvil, "Repair"), - m_RepairedItemName("") + m_RepairedItemName(""), + m_BlockX(a_BlockX), + m_BlockY(a_BlockY), + m_BlockZ(a_BlockZ) { - m_SlotAreas.push_back(new cSlotAreaAnvil(*this)); + m_AnvilSlotArea = new cSlotAreaAnvil(*this); + m_SlotAreas.push_back(m_AnvilSlotArea); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); } @@ -820,6 +824,31 @@ cAnvilWindow::cAnvilWindow() : +void cAnvilWindow::SetRepairedItemName(const AString & a_Name, cPlayer * a_Player) +{ + m_RepairedItemName = a_Name; + + if (a_Player != NULL) + { + m_AnvilSlotArea->UpdateResult(*a_Player); + } +} + + + + + +void cAnvilWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ) +{ + a_PosX = m_BlockX; + a_PosY = m_BlockY; + a_PosZ = m_BlockZ; +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cEnchantingWindow: diff --git a/src/UI/Window.h b/src/UI/Window.h index 8f6f80a41..c87d9b174 100644 --- a/src/UI/Window.h +++ b/src/UI/Window.h @@ -24,6 +24,7 @@ class cEnderChestEntity; class cFurnaceEntity; class cHopperEntity; class cSlotArea; +class cSlotAreaAnvil; class cWorld; typedef std::list cPlayerList; @@ -236,16 +237,21 @@ class cAnvilWindow : { typedef cWindow super; public: - cAnvilWindow(); + cAnvilWindow(int a_BlockX, int a_BlockY, int a_BlockZ); /** Gets the repaired item name. */ AString GetRepairedItemName(void) const { return m_RepairedItemName; } /** Set the repaired item name. */ - void SetRepairedItemName(const AString & a_Name) { m_RepairedItemName = a_Name; } + void SetRepairedItemName(const AString & a_Name, cPlayer * a_Player); + + /** Get the Position from the Enchantment Table */ + void GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ); protected: + cSlotAreaAnvil * m_AnvilSlotArea; AString m_RepairedItemName; + int m_BlockX, m_BlockY, m_BlockZ; } ; @@ -264,7 +270,7 @@ public: /** Return the Value of a Property */ int GetPropertyValue(int a_Property); - /** Set the Position Values to the Position of the Enchantment Table */ + /** Get the Position from the Enchantment Table */ void GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ); cSlotArea * m_SlotArea; -- cgit v1.2.3 From ca3c9ce84d50426631bf49124ad5e822c8ef9e94 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 4 May 2014 01:20:16 +0200 Subject: This isn't a enchantment table :D --- src/UI/Window.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/UI/Window.h b/src/UI/Window.h index c87d9b174..542dccb88 100644 --- a/src/UI/Window.h +++ b/src/UI/Window.h @@ -245,7 +245,7 @@ public: /** Set the repaired item name. */ void SetRepairedItemName(const AString & a_Name, cPlayer * a_Player); - /** Get the Position from the Enchantment Table */ + /** Gets the Position from the Anvil */ void GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ); protected: -- cgit v1.2.3 From ecc62dbb9c8d7fcce7e385285ff701a002462137 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 4 May 2014 11:11:07 +0200 Subject: Add anvil shift click. --- src/UI/SlotArea.cpp | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++--- src/UI/SlotArea.h | 4 ++- 2 files changed, 86 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 1e488de62..7b9f4e628 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -244,7 +244,7 @@ void cSlotArea::OnPlayerRemoved(cPlayer & a_Player) -void cSlotArea::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_Apply, bool a_KeepEmptySlots) +void cSlotArea::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) { for (int i = 0; i < m_NumSlots; i++) { @@ -264,7 +264,7 @@ void cSlotArea::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ { NumFit = a_ItemStack.m_ItemCount; } - if (a_Apply) + if (a_ShouldApply) { cItem NewSlot(a_ItemStack); NewSlot.m_ItemCount = Slot->m_ItemCount + NumFit; @@ -630,6 +630,12 @@ void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C return; } + if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick)) + { + ShiftClicked(a_Player, a_SlotNum, a_ClickedItem); + return; + } + cItem Slot(*GetSlot(a_SlotNum, a_Player)); if (!Slot.IsSameType(a_ClickedItem)) { @@ -665,7 +671,7 @@ void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C SetSlot(a_SlotNum, a_Player, Slot); DraggingItem = NewItem; - OnTakeResult(a_Player, NewItem); + OnTakeResult(a_Player); if (bAsync) { @@ -677,7 +683,80 @@ void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C -void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player, cItem a_ResultItem) +void cSlotAreaAnvil::ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem) +{ + if (a_SlotNum != 2) + { + super::ShiftClicked(a_Player, a_SlotNum, a_ClickedItem); + UpdateResult(a_Player); + return; + } + + // Make a copy of the slot, distribute it among the other areas, then update the slot to contain the leftover: + cItem Slot(*GetSlot(a_SlotNum, a_Player)); + + if (Slot.IsEmpty() || !CanTakeResultItem(a_Player)) + { + return; + } + + m_ParentWindow.DistributeStack(Slot, a_Player, this, true); + if (Slot.IsEmpty()) + { + Slot.Empty(); + OnTakeResult(a_Player); + } + SetSlot(a_SlotNum, a_Player, Slot); + + // Some clients try to guess our actions and not always right (armor slots in 1.2.5), so we fix them: + m_ParentWindow.BroadcastWholeWindow(); +} + + + + + +void cSlotAreaAnvil::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) +{ + for (int i = 0; i < 2; i++) + { + const cItem * Slot = GetSlot(i, a_Player); + if (!Slot->IsEqual(a_ItemStack) && (!Slot->IsEmpty() || a_KeepEmptySlots)) + { + // Different items + continue; + } + int NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount; + if (NumFit <= 0) + { + // Full stack already + continue; + } + if (NumFit > a_ItemStack.m_ItemCount) + { + NumFit = a_ItemStack.m_ItemCount; + } + if (a_ShouldApply) + { + cItem NewSlot(a_ItemStack); + NewSlot.m_ItemCount = Slot->m_ItemCount + NumFit; + SetSlot(i, a_Player, NewSlot); + } + a_ItemStack.m_ItemCount -= NumFit; + if (a_ItemStack.IsEmpty()) + { + UpdateResult(a_Player); + return; + } + } // for i - Slots + UpdateResult(a_Player); +} + + + + + +void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player) { if (!a_Player.IsGameModeCreative()) { diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index 4f273ec65..e7a2acd47 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -270,13 +270,15 @@ public: // cSlotArea overrides: virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override; + virtual void ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem) override; + virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override; // cSlotAreaTemporary overrides: virtual void OnPlayerRemoved(cPlayer & a_Player) override; bool CanTakeResultItem(cPlayer & a_Player); - void OnTakeResult(cPlayer & a_Player, cItem a_ResultItem); + void OnTakeResult(cPlayer & a_Player); /** Handles a click in the item slot. */ void UpdateResult(cPlayer & a_Player); -- cgit v1.2.3 From 8a6119437db992a9d5650d8276a10547458607d4 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 5 May 2014 15:42:41 +0200 Subject: Changed HandleAnvilItemName() length to size_t in ClientHandle.h --- src/ClientHandle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index dbc07a96d..b8e61a768 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -778,7 +778,7 @@ void cClientHandle::HandleCommandBlockMessage(const char * a_Data, size_t a_Leng -void cClientHandle::HandleAnvilItemName(const char * a_Data, unsigned int a_Length) +void cClientHandle::HandleAnvilItemName(const char * a_Data, size_t a_Length) { if (a_Length < 1) { -- cgit v1.2.3 From c162d69e7bb48221b9eacbd378b41129cfb35ebd Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 5 May 2014 15:45:03 +0200 Subject: Add doxycomments to cSlotAreaAnvil functions. --- src/UI/SlotArea.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index e7a2acd47..4da6a672f 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -276,8 +276,10 @@ public: // cSlotAreaTemporary overrides: virtual void OnPlayerRemoved(cPlayer & a_Player) override; + /** Can the player take the item from the slot? */ bool CanTakeResultItem(cPlayer & a_Player); + /** This function will call, when the player take the item from the slot. */ void OnTakeResult(cPlayer & a_Player); /** Handles a click in the item slot. */ -- cgit v1.2.3 From f2617d06830c649c5d13d1daf4f3e70e7ee487b0 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 5 May 2014 15:49:56 +0200 Subject: Add comments to CanTakeResultItem() --- src/UI/SlotArea.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 7b9f4e628..0f5e292d0 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -828,11 +828,11 @@ bool cSlotAreaAnvil::CanTakeResultItem(cPlayer & a_Player) { return ( ( - a_Player.IsGameModeCreative() - || a_Player.GetXpLevel() >= m_MaximumCost - ) - && !GetSlot(2, a_Player)->IsEmpty() - && m_MaximumCost > 0 + a_Player.IsGameModeCreative() || // Is the player in gamemode? + (a_Player.GetXpLevel() >= m_MaximumCost) // or the player have enough exp? + ) && + (!GetSlot(2, a_Player)->IsEmpty()) && // Is a item in the result slot? + (m_MaximumCost > 0) // And: Is m_MaximumCost higher than 0? ); } -- cgit v1.2.3 From a138671e0e38cd452b001c87d42b7eccd1e447e9 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 5 May 2014 17:36:22 +0200 Subject: Fix SetRepairedItemName() in SlotArea.cpp --- src/UI/SlotArea.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 0f5e292d0..0e3e293aa 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -785,7 +785,7 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player) m_ParentWindow.SetProperty(0, m_MaximumCost, a_Player); m_MaximumCost = 0; - ((cAnvilWindow*)&m_ParentWindow)->SetRepairedItemName("", false); + ((cAnvilWindow*)&m_ParentWindow)->SetRepairedItemName("", NULL); int PosX, PosY, PosZ; ((cAnvilWindow*)&m_ParentWindow)->GetBlockPos(PosX, PosY, PosZ); -- cgit v1.2.3 From b69a0c914e7a5a5f970bb98831592b2b417c4de8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 5 May 2014 20:33:21 +0200 Subject: Fixed a flipped condition in cBlockArea::Merge(). --- src/BlockArea.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index e0ae2c5b6..897af27c4 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -707,11 +707,11 @@ void cBlockArea::Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_R if (IsDummyMetas) { - MergeByStrategy(a_Src, a_RelX, a_RelY, a_RelZ, a_Strategy, SrcMetas, DstMetas); + MergeByStrategy(a_Src, a_RelX, a_RelY, a_RelZ, a_Strategy, SrcMetas, DstMetas); } else { - MergeByStrategy(a_Src, a_RelX, a_RelY, a_RelZ, a_Strategy, SrcMetas, DstMetas); + MergeByStrategy(a_Src, a_RelX, a_RelY, a_RelZ, a_Strategy, SrcMetas, DstMetas); } } -- cgit v1.2.3 From dca3af1f0f4a047e99f19c4624c0dd0c86904734 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 5 May 2014 22:11:48 +0200 Subject: Change int to size_t return. --- src/Enchantments.cpp | 4 ++-- src/Enchantments.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Enchantments.cpp b/src/Enchantments.cpp index bfcde9dac..58479d729 100644 --- a/src/Enchantments.cpp +++ b/src/Enchantments.cpp @@ -83,9 +83,9 @@ void cEnchantments::AddFromString(const AString & a_StringSpec) -int cEnchantments::Size(void) +size_t cEnchantments::Size(void) { - return (int)m_Enchantments.size(); + return m_Enchantments.size(); } diff --git a/src/Enchantments.h b/src/Enchantments.h index 82eea53f9..6793aca36 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -85,7 +85,7 @@ public: void AddFromString(const AString & a_StringSpec); /** Get the count of enchantments */ - int Size(void); + size_t Size(void); /** Serializes all the enchantments into a string */ AString ToString(void) const; -- cgit v1.2.3 From e4af9a21af44a7c5d4e02ac17a1b694858c8a39d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 5 May 2014 22:28:54 +0200 Subject: Prefabs can specify that they don't want flooring. Previously the flag was ignored. --- src/Generating/Prefab.cpp | 63 +++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 44d5097de..0f20603be 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -174,44 +174,47 @@ void cPrefab::Draw(cChunkDesc & a_Dest, const cPlacedPiece * a_Placement) const a_Dest.WriteBlockArea(Image, Placement.x, Placement.y, Placement.z, m_MergeStrategy); // If requested, draw the floor (from the bottom of the prefab down to the nearest non-air) - int MaxX = Image.GetSizeX(); - int MaxZ = Image.GetSizeZ(); - for (int z = 0; z < MaxZ; z++) + if (m_ShouldExtendFloor) { - int RelZ = Placement.z + z; - if ((RelZ < 0) || (RelZ >= cChunkDef::Width)) + int MaxX = Image.GetSizeX(); + int MaxZ = Image.GetSizeZ(); + for (int z = 0; z < MaxZ; z++) { - // Z coord outside the chunk - continue; - } - for (int x = 0; x < MaxX; x++) - { - int RelX = Placement.x + x; - if ((RelX < 0) || (RelX >= cChunkDef::Width)) - { - // X coord outside the chunk - continue; - } - BLOCKTYPE BlockType; - NIBBLETYPE BlockMeta; - Image.GetRelBlockTypeMeta(x, 0, z, BlockType, BlockMeta); - if ((BlockType == E_BLOCK_AIR) || (BlockType == E_BLOCK_SPONGE)) + int RelZ = Placement.z + z; + if ((RelZ < 0) || (RelZ >= cChunkDef::Width)) { - // Do not expand air nor sponge blocks + // Z coord outside the chunk continue; } - for (int y = Placement.y - 1; y >= 0; y--) + for (int x = 0; x < MaxX; x++) { - BLOCKTYPE ExistingBlock = a_Dest.GetBlockType(RelX, y, RelZ); - if (ExistingBlock != E_BLOCK_AIR) + int RelX = Placement.x + x; + if ((RelX < 0) || (RelX >= cChunkDef::Width)) + { + // X coord outside the chunk + continue; + } + BLOCKTYPE BlockType; + NIBBLETYPE BlockMeta; + Image.GetRelBlockTypeMeta(x, 0, z, BlockType, BlockMeta); + if ((BlockType == E_BLOCK_AIR) || (BlockType == E_BLOCK_SPONGE)) { - // End the expansion for this column, reached the end - break; + // Do not expand air nor sponge blocks + continue; } - a_Dest.SetBlockTypeMeta(RelX, y, RelZ, BlockType, BlockMeta); - } // for y - } // for x - } // for z + for (int y = Placement.y - 1; y >= 0; y--) + { + BLOCKTYPE ExistingBlock = a_Dest.GetBlockType(RelX, y, RelZ); + if (ExistingBlock != E_BLOCK_AIR) + { + // End the expansion for this column, reached the end + break; + } + a_Dest.SetBlockTypeMeta(RelX, y, RelZ, BlockType, BlockMeta); + } // for y + } // for x + } // for z + } } -- cgit v1.2.3 From 9542b0b8755e89040823632b05ef07c8e39912b8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 5 May 2014 23:05:30 +0200 Subject: Changed cPieceGenerator to support pairings. Fixes #982. --- src/Generating/PieceGenerator.cpp | 5 +- src/Generating/PieceGenerator.h | 3 +- src/Generating/Prefabs/NetherFortPrefabs.cpp | 153 +++++++++++++++++---------- 3 files changed, 104 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index 8e9a48be6..db45cd08b 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -388,7 +388,8 @@ bool cPieceGenerator::TryPlacePieceAtConnector( // Get a list of available connections: const int * RotTable = DirectionRotationTable[a_Connector.m_Direction]; cConnections Connections; - cPieces AvailablePieces = m_PiecePool.GetPiecesWithConnector(a_Connector.m_Type); + int WantedConnectorType = -a_Connector.m_Type; + cPieces AvailablePieces = m_PiecePool.GetPiecesWithConnector(WantedConnectorType); Connections.reserve(AvailablePieces.size()); Vector3i ConnPos = a_Connector.m_Pos; // The position at which the new connector should be placed - 1 block away from the connector AddFaceDirection(ConnPos.x, ConnPos.y, ConnPos.z, a_Connector.m_Direction); @@ -406,7 +407,7 @@ bool cPieceGenerator::TryPlacePieceAtConnector( cPiece::cConnectors Connectors = (*itrP)->GetConnectors(); for (cPiece::cConnectors::iterator itrC = Connectors.begin(), endC = Connectors.end(); itrC != endC; ++itrC) { - if (itrC->m_Type != a_Connector.m_Type) + if (itrC->m_Type != WantedConnectorType) { continue; } diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index f4433b947..16bec3bb4 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -38,7 +38,8 @@ public: /** Position relative to the piece */ Vector3i m_Pos; - /** Type of the connector. Any arbitrary number; the generator connects only connectors of the same type. */ + /** Type of the connector. Any arbitrary number; the generator connects only connectors of opposite + (negative) types. */ int m_Type; /** Direction in which the connector is facing. diff --git a/src/Generating/Prefabs/NetherFortPrefabs.cpp b/src/Generating/Prefabs/NetherFortPrefabs.cpp index d2ef5663d..088340391 100644 --- a/src/Generating/Prefabs/NetherFortPrefabs.cpp +++ b/src/Generating/Prefabs/NetherFortPrefabs.cpp @@ -134,7 +134,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 12, 2, 2: 5\n" /* Type 1, direction X+ */ - "1: 0, 2, 2: 4\n" /* Type 1, direction X- */, + "1: 0, 2, 2: 4\n" /* Type 1, direction X- */ + "-1: 12, 2, 2: 5\n" /* Type -1, direction X+ */ + "-1: 0, 2, 2: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -143,7 +145,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 20, @@ -291,7 +293,10 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 12, 2, 4: 5\n" /* Type 1, direction X+ */ "1: 6, 2, 0: 2\n" /* Type 1, direction Z- */ - "1: 0, 2, 4: 4\n" /* Type 1, direction X- */, + "1: 0, 2, 4: 4\n" /* Type 1, direction X- */ + "-1: 12, 2, 4: 5\n" /* Type -1, direction X+ */ + "-1: 6, 2, 0: 2\n" /* Type -1, direction Z- */ + "-1: 0, 2, 4: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -300,7 +305,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 20, @@ -420,7 +425,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -590,7 +595,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -790,7 +795,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 5, @@ -991,7 +996,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 10, @@ -1085,7 +1090,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -1185,7 +1190,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -1208,7 +1213,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 4, 6, 15, // MaxX, MaxY, MaxZ + 4, 16, 15, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1364,7 +1369,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 10, @@ -1604,7 +1609,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 5, @@ -1933,7 +1938,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 20, @@ -2052,7 +2057,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 500, @@ -2212,7 +2217,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 10, @@ -2302,7 +2307,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 10, 1, 2: 5\n" /* Type 1, direction X+ */ - "1: 0, 1, 2: 4\n" /* Type 1, direction X- */, + "1: 0, 1, 2: 4\n" /* Type 1, direction X- */ + "-1: 10, 1, 2: 5\n" /* Type -1, direction X+ */ + "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2311,7 +2318,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 300, @@ -2401,7 +2408,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 12, 1, 2: 5\n" /* Type 1, direction X+ */ - "1: 0, 1, 2: 4\n" /* Type 1, direction X- */, + "1: 0, 1, 2: 4\n" /* Type 1, direction X- */ + "-1: 12, 1, 2: 5\n" /* Type -1, direction X+ */ + "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2410,7 +2419,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 300, @@ -2494,7 +2503,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 4, 1, 2: 5\n" /* Type 1, direction X+ */ - "1: 0, 1, 2: 4\n" /* Type 1, direction X- */, + "1: 0, 1, 2: 4\n" /* Type 1, direction X- */ + "-1: 4, 1, 2: 5\n" /* Type -1, direction X+ */ + "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2503,7 +2514,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 500, @@ -2631,7 +2642,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 2, 1, 10: 3\n" /* Type 1, direction Z+ */ - "1: 10, 1, 2: 5\n" /* Type 1, direction X+ */, + "1: 10, 1, 2: 5\n" /* Type 1, direction X+ */ + "-1: 2, 1, 10: 3\n" /* Type -1, direction Z+ */ + "-1: 10, 1, 2: 5\n" /* Type -1, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2640,7 +2653,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -2769,7 +2782,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 10, 1, 2: 5\n" /* Type 1, direction X+ */ - "1: 2, 1, 10: 3\n" /* Type 1, direction Z+ */, + "1: 2, 1, 10: 3\n" /* Type 1, direction Z+ */ + "-1: 2, 1, 10: 3\n" /* Type -1, direction Z+ */ + "-1: 10, 1, 2: 5\n" /* Type -1, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2778,7 +2793,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -2890,7 +2905,11 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 8, 1, 4: 5\n" /* Type 1, direction X+ */ "1: 4, 1, 0: 2\n" /* Type 1, direction Z- */ "1: 4, 1, 8: 3\n" /* Type 1, direction Z+ */ - "1: 0, 1, 4: 4\n" /* Type 1, direction X- */, + "1: 0, 1, 4: 4\n" /* Type 1, direction X- */ + "-1: 8, 1, 4: 5\n" /* Type -1, direction X+ */ + "-1: 4, 1, 8: 3\n" /* Type -1, direction Z+ */ + "-1: 0, 1, 4: 4\n" /* Type -1, direction X- */ + "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2899,7 +2918,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -3040,7 +3059,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 0, 1, 2: 4\n" /* Type 1, direction X- */ - "1: 8, 8, 2: 5\n" /* Type 1, direction X+ */, + "1: 8, 8, 2: 5\n" /* Type 1, direction X+ */ + "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */ + "-1: 8, 8, 2: 5\n" /* Type -1, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3049,7 +3070,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 1000, @@ -3139,7 +3160,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 0, 1, 2: 4\n" /* Type 1, direction X- */ - "1: 13, 1, 2: 5\n" /* Type 1, direction X+ */, + "1: 13, 1, 2: 5\n" /* Type 1, direction X+ */ + "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */ + "-1: 13, 1, 2: 5\n" /* Type -1, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3148,7 +3171,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -3393,7 +3416,10 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 0, 6, 7: 4\n" /* Type 1, direction X- */ "1: 9, 1, 14: 3\n" /* Type 1, direction Z+ */ - "1: 9, 1, 0: 2\n" /* Type 1, direction Z- */, + "1: 9, 1, 0: 2\n" /* Type 1, direction Z- */ + "-1: 0, 6, 7: 4\n" /* Type -1, direction X- */ + "-1: 9, 1, 14: 3\n" /* Type -1, direction Z+ */ + "-1: 9, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3402,7 +3428,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 10, @@ -3722,7 +3748,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 11, 1, 7: 5\n" /* Type 1, direction X+ */ - "1: 0, 9, 7: 4\n" /* Type 1, direction X- */, + "1: 0, 9, 7: 4\n" /* Type 1, direction X- */ + "-1: 11, 1, 7: 5\n" /* Type -1, direction X+ */ + "-1: 0, 9, 7: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3731,7 +3759,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 10, @@ -4009,7 +4037,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 10, @@ -4186,7 +4214,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 12, 1, 6: 5\n" /* Type 1, direction X+ */ - "1: 0, 1, 6: 4\n" /* Type 1, direction X- */, + "1: 0, 1, 6: 4\n" /* Type 1, direction X- */ + "-1: 12, 1, 6: 5\n" /* Type -1, direction X+ */ + "-1: 0, 1, 6: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -4195,7 +4225,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -4338,7 +4368,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -4481,7 +4511,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -4586,7 +4616,10 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 0, 1, 4: 4\n" /* Type 1, direction X- */ "1: 6, 1, 0: 2\n" /* Type 1, direction Z- */ - "1: 12, 1, 4: 5\n" /* Type 1, direction X+ */, + "1: 12, 1, 4: 5\n" /* Type 1, direction X+ */ + "-1: 0, 1, 4: 4\n" /* Type -1, direction X- */ + "-1: 12, 1, 4: 5\n" /* Type -1, direction X+ */ + "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -4595,7 +4628,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -4712,7 +4745,10 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 0, 1, 6: 4\n" /* Type 1, direction X- */ "1: 6, 1, 0: 2\n" /* Type 1, direction Z- */ - "1: 12, 1, 6: 5\n" /* Type 1, direction X+ */, + "1: 12, 1, 6: 5\n" /* Type 1, direction X+ */ + "-1: 0, 1, 6: 4\n" /* Type -1, direction X- */ + "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */ + "-1: 12, 1, 6: 5\n" /* Type -1, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -4721,7 +4757,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -4806,7 +4842,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 2, 1, 4: 3\n" /* Type 1, direction Z+ */ - "1: 0, 1, 2: 4\n" /* Type 1, direction X- */, + "1: 0, 1, 2: 4\n" /* Type 1, direction X- */ + "-1: 2, 1, 4: 3\n" /* Type -1, direction Z+ */ + "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -4815,7 +4853,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -4901,7 +4939,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 2, 1, 4: 3\n" /* Type 1, direction Z+ */ - "1: 0, 1, 2: 4\n" /* Type 1, direction X- */, + "1: 0, 1, 2: 4\n" /* Type 1, direction X- */ + "-1: 2, 1, 4: 3\n" /* Type -1, direction Z+ */ + "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -4910,7 +4950,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -4996,7 +5036,11 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 4, 1, 2: 5\n" /* Type 1, direction X+ */ "1: 2, 1, 4: 3\n" /* Type 1, direction Z+ */ "1: 0, 1, 2: 4\n" /* Type 1, direction X- */ - "1: 2, 1, 0: 2\n" /* Type 1, direction Z- */, + "1: 2, 1, 0: 2\n" /* Type 1, direction Z- */ + "-1: 4, 1, 2: 5\n" /* Type -1, direction X+ */ + "-1: 2, 1, 4: 3\n" /* Type -1, direction Z+ */ + "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */ + "-1: 2, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -5005,7 +5049,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -5120,7 +5164,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, @@ -5314,7 +5358,8 @@ const cPrefab::sDef g_NetherFortStartingPrefabs[] = // Connectors: "0: 6, 1, 0: 2\n" /* Type 0, direction Z- */ - "1: 6, 1, 12: 3\n" /* Type 1, direction Z+ */, + "1: 6, 1, 12: 3\n" /* Type 1, direction Z+ */ + "-1: 6, 1, 12: 3\n" /* Type -1, direction Z+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -5323,7 +5368,7 @@ const cPrefab::sDef g_NetherFortStartingPrefabs[] = cBlockArea::msSpongePrint, // ShouldExtendFloor: - false, + true, // DefaultWeight: 100, -- cgit v1.2.3 From 1df7dbe7c91953c2413908b846649e884b7ac53c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 5 May 2014 23:45:35 +0100 Subject: Suggestions'd --- src/Entities/Entity.cpp | 2 +- src/Entities/Player.cpp | 2 +- src/Items/ItemThrowable.h | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 644afe69e..4cf10a219 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1211,7 +1211,7 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude) int DiffY = (int)(floor(GetPosY() * 32.0) - floor(m_LastPos.y * 32.0)); int DiffZ = (int)(floor(GetPosZ() * 32.0) - floor(m_LastPos.z * 32.0)); - if ((abs(DiffX) != 0) || (abs(DiffY) != 0) || (abs(DiffZ) != 0)) // Have we moved? + if ((DiffX != 0) || (DiffY != 0) || (DiffZ != 0)) // Have we moved? { if ((abs(DiffX) <= 127) && (abs(DiffY) <= 127) && (abs(DiffZ) <= 127)) // Limitations of a Byte { diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index bcbf58623..d63e5461a 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -212,7 +212,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) SendExperience(); } - if ((GetPosition() - m_LastPos).SqrLength() != 0.0) // Change in position from last tick? + if (!(GetPosition() - m_LastPos).Equals(Vector3d(0, 0, 0))) // Change in position from last tick? { // Apply food exhaustion from movement: ApplyFoodExhaustionFromMovement(); diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h index f90caf037..35c2b8731 100644 --- a/src/Items/ItemThrowable.h +++ b/src/Items/ItemThrowable.h @@ -28,15 +28,19 @@ public: virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { + Vector3d Pos = a_Player->GetThrowStartPos(); + Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff; + + if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, a_Player->GetEquippedItem(), &Speed) < 0) + { + return false; + } + if (!a_Player->IsGameModeCreative()) { a_Player->GetInventory().RemoveOneEquippedItem(); } - Vector3d Pos = a_Player->GetThrowStartPos(); - Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff; - a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, a_Player->GetEquippedItem(), &Speed); - return true; } @@ -127,7 +131,7 @@ public: return false; } - if (a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, a_Player->GetEquippedItem()) == -1) + if (a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, a_Player->GetEquippedItem()) < 0) { return false; } -- cgit v1.2.3 From 8f262d8a9d2d520a9c92dc0f270a88c554cb3778 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 6 May 2014 16:41:55 +0200 Subject: Initial cGridStructGen refactoring. Ref.: #987. --- src/Generating/GridStructGen.cpp | 138 +++++++++++++++++++++++++++++++++++++++ src/Generating/GridStructGen.h | 124 +++++++++++++++++++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 src/Generating/GridStructGen.cpp create mode 100644 src/Generating/GridStructGen.h (limited to 'src') diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp new file mode 100644 index 000000000..975fd3fdc --- /dev/null +++ b/src/Generating/GridStructGen.cpp @@ -0,0 +1,138 @@ + +// GridStructGen.cpp + +// Implements the cGridStructGen class representing a common base class for structure generators that place structures in a semi-random grid + +#include "Globals.h" +#include "GridStructGen.h" + + + + +cGridStructGen::cGridStructGen( + int a_Seed, + int a_GridSizeX, int a_GridSizeZ, + int a_MaxStructureSizeX, int a_MaxStructureSizeZ, + size_t a_MaxCacheSize +) : + m_Seed(a_Seed), + m_GridSizeX(a_GridSizeX), + m_GridSizeZ(a_GridSizeZ), + m_MaxStructureSizeX(a_MaxStructureSizeX), + m_MaxStructureSizeZ(a_MaxStructureSizeZ), + m_MaxCacheSize(a_MaxCacheSize) +{ +} + + + + + +void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructurePtrs & a_Structures) +{ + // Calculate the min and max grid coords of the structures to be returned: + int MinBlockX = a_ChunkX * cChunkDef::Width - m_MaxStructureSizeX; + int MinBlockZ = a_ChunkZ * cChunkDef::Width - m_MaxStructureSizeZ; + int MaxBlockX = a_ChunkX * cChunkDef::Width + m_MaxStructureSizeX + cChunkDef::Width - 1; + int MaxBlockZ = a_ChunkZ * cChunkDef::Width + m_MaxStructureSizeZ + cChunkDef::Width - 1; + int MinGridX = MinBlockX / m_GridSizeX; + int MinGridZ = MinBlockZ / m_GridSizeZ; + int MaxGridX = MaxBlockX / m_GridSizeX; + int MaxGridZ = MaxBlockX / m_GridSizeZ; + if (MinGridX < 0) + { + --MinGridX; + } + if (MinGridZ < 0) + { + --MinGridZ; + } + if (MaxGridX < 0) + { + --MaxGridX; + } + if (MaxGridZ < 0) + { + --MaxGridZ; + } + + // Walk the cache, move each structure that we want into a_Structures: + for (cStructurePtrs::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end;) + { + if ( + ((*itr)->m_OriginX >= MinBlockX) && ((*itr)->m_OriginX < MaxBlockX) && + ((*itr)->m_OriginZ >= MinBlockZ) && ((*itr)->m_OriginZ < MaxBlockZ) + ) + { + // want + a_Structures.push_back(*itr); + itr = m_Cache.erase(itr); + } + else + { + // don't want + ++itr; + } + } // for itr - m_Cache[] + + // Create those structures that haven't been in the cache: + for (int x = MinGridX; x < MaxGridX; x++) + { + int OriginX = x * m_GridSizeX; + for (int z = MinGridZ; z < MaxGridZ; z++) + { + int OriginZ = z * m_GridSizeZ; + bool Found = false; + for (cStructurePtrs::const_iterator itr = a_Structures.begin(), end = a_Structures.end(); itr != end; ++itr) + { + if (((*itr)->m_OriginX == OriginX) && ((*itr)->m_OriginZ == OriginZ)) + { + Found = true; + break; + } + } // for itr - a_Structures[] + if (!Found) + { + a_Structures.push_back(CreateStructure(OriginX, OriginZ)); + } + } // for z + } // for x + + // Copy a_Forts into m_Cache to the beginning: + cStructurePtrs StructuresCopy (a_Structures); + m_Cache.splice(m_Cache.begin(), StructuresCopy, StructuresCopy.begin(), StructuresCopy.end()); + + // Trim the cache if it's too long: + size_t CacheSize = 0; + for (cStructurePtrs::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end; ++itr) + { + CacheSize += (*itr)->GetCacheCost(); + if (CacheSize > m_MaxCacheSize) + { + // Erase all items from this one till the cache end + m_Cache.erase(itr, m_Cache.end()); + break; + } + } +} + + + + + +void cGridStructGen::GenFinish(cChunkDesc & a_ChunkDesc) +{ + int ChunkX = a_ChunkDesc.GetChunkX(); + int ChunkZ = a_ChunkDesc.GetChunkZ(); + cStructurePtrs Structures; + GetStructuresForChunk(ChunkX, ChunkZ, Structures); + for (cStructurePtrs::const_iterator itr = Structures.begin(); itr != Structures.end(); ++itr) + { + (*itr)->DrawIntoChunk(a_ChunkDesc); + } // for itr - Structures[] +} + + + + + diff --git a/src/Generating/GridStructGen.h b/src/Generating/GridStructGen.h new file mode 100644 index 000000000..234cc75c5 --- /dev/null +++ b/src/Generating/GridStructGen.h @@ -0,0 +1,124 @@ + +// GridStructGen.h + +// Declares the cGridStructGen class representing a common base class for structure generators that place structures in a semi-random grid + + + + + +#pragma once + +#include "ComposableGenerator.h" + + + + + +/** Generates structures in a semi-random grid. +Defines a grid in the XZ space with predefined cell size in each direction. Each cell then receives exactly +one structure (provided by the descendant class). The structure is placed within the cell, but doesn't need +to be bounded by the cell, it can be well outside the cell; the generator uses the MaxStructureSize parameter +to determine how far away from the cell the structure can be at most. +This class provides a cache for the structures generated for successive chunks and manages that cache. It +also provides the cFinishGen override that uses the cache to actually generate the structure into chunk data. + +After generating each chunk the cache is checked for size, each item in the cache has a cost associated with +it and the cache is trimmed (from its least-recently-used end) so that the sum of the cost in the cache is +less than m_MaxCacheSize + +To use this class, declare a descendant class that implements the overridable methods, then create an +instance of that class. The descendant must provide the CreateStructure() function that is called to generate +a structure at the specific grid cell. + +The descendant must use a specific cStructure descendant to provide the actual structure that gets generated. +The structure must provide the DrawIntoChunk() function that generates the structure into the chunk data, and +can override the GetCacheCost() function that returns the cost of that structure in the cache. +*/ +class cGridStructGen : + public cFinishGen +{ +public: + cGridStructGen( + int a_Seed, + int a_GridSizeX, int a_GridSizeZ, + int a_MaxStructureSizeX, int a_MaxStructureSizeZ, + size_t a_MaxCacheSize + ); + +protected: + /** Represents a single structure that occupies the grid point. Knows how to draw itself into a chunk. */ + class cStructure + { + public: + /** The origin (the coords of the gridpoint for which the structure is generated) */ + int m_OriginX, m_OriginZ; + + + /** Creates a structure that has its originset at the specified coords. */ + cStructure (int a_OriginX, int a_OriginZ) : + m_OriginX(a_OriginX), + m_OriginZ(a_OriginZ) + { + } + + // Force a virtual destructor in descendants: + virtual ~cStructure() {} + + /** Draws self into the specified chunk */ + virtual void DrawIntoChunk(cChunkDesc & a_ChunkDesc) = 0; + + /** Returns the cost of keeping this structure in the cache */ + virtual size_t GetCacheCost(void) const { return 1; } + } ; + typedef SharedPtr cStructurePtr; + typedef std::list cStructurePtrs; + + + /** Seed for generating the semi-random grid. */ + int m_Seed; + + /** The size of each grid's cell in the X axis */ + int m_GridSizeX; + + /** The size of each grid's cell in the Z axis */ + int m_GridSizeZ; + + /** Maximum theoretical size of the structure in the X axis. + This limits the structures considered for a single chunk, so the lesser the number, the better performance. + Structures large than this may get cropped. */ + int m_MaxStructureSizeX; + + /** Maximum theoretical size of the structure in the Z axis. + This limits the structures considered for a single chunk, so the lesser the number, the better performance. + Structures large than this may get cropped. */ + int m_MaxStructureSizeZ; + + /** Maximum allowed sum of costs for items in the cache. Items that are over this cost are removed from the + cache, oldest-first */ + size_t m_MaxCacheSize; + + /** Cache for the most recently generated structures, ordered by the recentness. */ + cStructurePtrs m_Cache; + + + /** Clears everything from the cache */ + void ClearCache(void); + + /** Returns all structures that may intersect the given chunk. + The structures are considered as intersecting iff their bounding box (defined by m_MaxStructureSize) + around their gridpoint intersects the chunk. */ + void GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructurePtrs & a_Structures); + + // cFinishGen overrides: + virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; + + // Functions for the descendants to override: + /** Create a new structure at the specified gridpoint */ + virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) = 0; +} ; + + + + + -- cgit v1.2.3 From 27f95454a9114cad0f199552612ab67ddfe8b5ca Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 6 May 2014 17:31:02 +0200 Subject: Simplified the HandleAnvilItemName() code. --- src/ClientHandle.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index b8e61a768..94f031ed6 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -790,15 +790,10 @@ void cClientHandle::HandleAnvilItemName(const char * a_Data, size_t a_Length) return; } - cByteBuffer Buffer(a_Length); - Buffer.Write(a_Data, a_Length); - - AString Name; - Buffer.ReadAll(Name); - + AString Name(a_Data, a_Length); if (Name.length() <= 30) { - ((cAnvilWindow&)*m_Player->GetWindow()).SetRepairedItemName(Name, m_Player); + ((cAnvilWindow *)m_Player->GetWindow())->SetRepairedItemName(Name, m_Player); } } -- cgit v1.2.3 From 954b59d6f460106e93efab39c8666d4692db25b6 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 6 May 2014 19:38:09 +0200 Subject: Rename CanRepairWithItem to CanRepairWithRawMaterial and rename Size() to Count() --- src/Enchantments.cpp | 2 +- src/Enchantments.h | 2 +- src/Items/ItemArmor.h | 12 ++++++------ src/Items/ItemHandler.cpp | 2 +- src/Items/ItemHandler.h | 2 +- src/Items/ItemPickaxe.h | 12 ++++++------ src/Items/ItemShovel.h | 12 ++++++------ src/Items/ItemSword.h | 12 ++++++------ src/UI/SlotArea.cpp | 11 +++++------ 9 files changed, 33 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/Enchantments.cpp b/src/Enchantments.cpp index 58479d729..264878c22 100644 --- a/src/Enchantments.cpp +++ b/src/Enchantments.cpp @@ -83,7 +83,7 @@ void cEnchantments::AddFromString(const AString & a_StringSpec) -size_t cEnchantments::Size(void) +size_t cEnchantments::Count(void) { return m_Enchantments.size(); } diff --git a/src/Enchantments.h b/src/Enchantments.h index 6793aca36..85a316414 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -85,7 +85,7 @@ public: void AddFromString(const AString & a_StringSpec); /** Get the count of enchantments */ - size_t Size(void); + size_t Count(void); /** Serializes all the enchantments into a string */ AString ToString(void) const; diff --git a/src/Items/ItemArmor.h b/src/Items/ItemArmor.h index f53100bb1..2436df5bd 100644 --- a/src/Items/ItemArmor.h +++ b/src/Items/ItemArmor.h @@ -60,7 +60,7 @@ public: return true; } - virtual bool CanRepairWithItem(const cItem & a_Item) override + virtual bool CanRepairWithRawMaterial(short a_ItemType) override { switch (m_ItemType) { @@ -69,35 +69,35 @@ public: case E_ITEM_CHAIN_HELMET: case E_ITEM_CHAIN_LEGGINGS: { - return (a_Item.m_ItemType == E_ITEM_IRON); + return (a_ItemType == E_ITEM_IRON); } case E_ITEM_DIAMOND_BOOTS: case E_ITEM_DIAMOND_CHESTPLATE: case E_ITEM_DIAMOND_HELMET: case E_ITEM_DIAMOND_LEGGINGS: { - return (a_Item.m_ItemType == E_ITEM_DIAMOND); + return (a_ItemType == E_ITEM_DIAMOND); } case E_ITEM_IRON_BOOTS: case E_ITEM_IRON_CHESTPLATE: case E_ITEM_IRON_HELMET: case E_ITEM_IRON_LEGGINGS: { - return (a_Item.m_ItemType == E_ITEM_IRON); + return (a_ItemType == E_ITEM_IRON); } case E_ITEM_GOLD_BOOTS: case E_ITEM_GOLD_CHESTPLATE: case E_ITEM_GOLD_HELMET: case E_ITEM_GOLD_LEGGINGS: { - return (a_Item.m_ItemType == E_ITEM_GOLD); + return (a_ItemType == E_ITEM_GOLD); } case E_ITEM_LEATHER_BOOTS: case E_ITEM_LEATHER_CAP: case E_ITEM_LEATHER_PANTS: case E_ITEM_LEATHER_TUNIC: { - return (a_Item.m_ItemType == E_ITEM_LEATHER); + return (a_ItemType == E_ITEM_LEATHER); } } return false; diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 105def2ce..5cc5b66a0 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -512,7 +512,7 @@ bool cItemHandler::IsPlaceable(void) -bool cItemHandler::CanRepairWithItem(const cItem & a_Item) +bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType) { return false; } diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index 420eefcf1..ca090eb29 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -86,7 +86,7 @@ public: virtual bool IsPlaceable(void); /** Can the anvil repair this item, when a_Item is the second input? */ - virtual bool CanRepairWithItem(const cItem & a_Item); + virtual bool CanRepairWithRawMaterial(short a_ItemType); /** Get the repair cost from the item, or 0 if the item hasn't repair cost. */ virtual int GetRepairCost(void); diff --git a/src/Items/ItemPickaxe.h b/src/Items/ItemPickaxe.h index 46e68ec70..ff2c2069b 100644 --- a/src/Items/ItemPickaxe.h +++ b/src/Items/ItemPickaxe.h @@ -86,15 +86,15 @@ public: return false; } - virtual bool CanRepairWithItem(const cItem & a_Item) override + virtual bool CanRepairWithRawMaterial(short a_ItemType) override { switch (m_ItemType) { - case E_ITEM_WOODEN_PICKAXE: return (a_Item.m_ItemType == E_BLOCK_PLANKS); - case E_ITEM_STONE_PICKAXE: return (a_Item.m_ItemType == E_BLOCK_COBBLESTONE); - case E_ITEM_IRON_PICKAXE: return (a_Item.m_ItemType == E_ITEM_IRON); - case E_ITEM_GOLD_PICKAXE: return (a_Item.m_ItemType == E_ITEM_GOLD); - case E_ITEM_DIAMOND_PICKAXE: return (a_Item.m_ItemType == E_ITEM_DIAMOND); + case E_ITEM_WOODEN_PICKAXE: return (a_ItemType == E_BLOCK_PLANKS); + case E_ITEM_STONE_PICKAXE: return (a_ItemType == E_BLOCK_COBBLESTONE); + case E_ITEM_IRON_PICKAXE: return (a_ItemType == E_ITEM_IRON); + case E_ITEM_GOLD_PICKAXE: return (a_ItemType == E_ITEM_GOLD); + case E_ITEM_DIAMOND_PICKAXE: return (a_ItemType == E_ITEM_DIAMOND); } return false; } diff --git a/src/Items/ItemShovel.h b/src/Items/ItemShovel.h index 7659ccc54..333ba46e8 100644 --- a/src/Items/ItemShovel.h +++ b/src/Items/ItemShovel.h @@ -42,15 +42,15 @@ public: return (a_BlockType == E_BLOCK_SNOW); } - virtual bool CanRepairWithItem(const cItem & a_Item) override + virtual bool CanRepairWithRawMaterial(short a_ItemType) override { switch (m_ItemType) { - case E_ITEM_WOODEN_SHOVEL: return (a_Item.m_ItemType == E_BLOCK_PLANKS); - case E_ITEM_STONE_SHOVEL: return (a_Item.m_ItemType == E_BLOCK_COBBLESTONE); - case E_ITEM_IRON_SHOVEL: return (a_Item.m_ItemType == E_ITEM_IRON); - case E_ITEM_GOLD_SHOVEL: return (a_Item.m_ItemType == E_ITEM_GOLD); - case E_ITEM_DIAMOND_SHOVEL: return (a_Item.m_ItemType == E_ITEM_DIAMOND); + case E_ITEM_WOODEN_SHOVEL: return (a_ItemType == E_BLOCK_PLANKS); + case E_ITEM_STONE_SHOVEL: return (a_ItemType == E_BLOCK_COBBLESTONE); + case E_ITEM_IRON_SHOVEL: return (a_ItemType == E_ITEM_IRON); + case E_ITEM_GOLD_SHOVEL: return (a_ItemType == E_ITEM_GOLD); + case E_ITEM_DIAMOND_SHOVEL: return (a_ItemType == E_ITEM_DIAMOND); } return false; } diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h index 34656ff99..44feb2d83 100644 --- a/src/Items/ItemSword.h +++ b/src/Items/ItemSword.h @@ -24,15 +24,15 @@ public: return (a_BlockType == E_BLOCK_COBWEB); } - virtual bool CanRepairWithItem(const cItem & a_Item) override + virtual bool CanRepairWithRawMaterial(short a_ItemType) override { switch (m_ItemType) { - case E_ITEM_WOODEN_SWORD: return (a_Item.m_ItemType == E_BLOCK_PLANKS); - case E_ITEM_STONE_SWORD: return (a_Item.m_ItemType == E_BLOCK_COBBLESTONE); - case E_ITEM_IRON_SWORD: return (a_Item.m_ItemType == E_ITEM_IRON); - case E_ITEM_GOLD_SWORD: return (a_Item.m_ItemType == E_ITEM_GOLD); - case E_ITEM_DIAMOND_SWORD: return (a_Item.m_ItemType == E_ITEM_DIAMOND); + case E_ITEM_WOODEN_SWORD: return (a_ItemType == E_BLOCK_PLANKS); + case E_ITEM_STONE_SWORD: return (a_ItemType == E_BLOCK_COBBLESTONE); + case E_ITEM_IRON_SWORD: return (a_ItemType == E_ITEM_IRON); + case E_ITEM_GOLD_SWORD: return (a_ItemType == E_ITEM_GOLD); + case E_ITEM_DIAMOND_SWORD: return (a_ItemType == E_ITEM_DIAMOND); } return false; } diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 0e3e293aa..fcf5f6f6b 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -797,7 +797,7 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player) cFastRandom Random; if (!a_Player.IsGameModeCreative() && (Block == E_BLOCK_ANVIL) && (Random.NextFloat(1.0F) < 0.12F)) { - NIBBLETYPE var4 = BlockMeta & 0x3; + NIBBLETYPE Orientation = BlockMeta & 0x3; NIBBLETYPE AnvilDamage = BlockMeta >> 2; ++AnvilDamage; @@ -810,7 +810,7 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player) } else { - a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, var4 | AnvilDamage << 2); + a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, Orientation | (AnvilDamage << 2)); a_Player.GetWorld()->BroadcastSoundParticleEffect(1021, PosX, PosY, PosZ, 0); } } @@ -832,7 +832,7 @@ bool cSlotAreaAnvil::CanTakeResultItem(cPlayer & a_Player) (a_Player.GetXpLevel() >= m_MaximumCost) // or the player have enough exp? ) && (!GetSlot(2, a_Player)->IsEmpty()) && // Is a item in the result slot? - (m_MaximumCost > 0) // And: Is m_MaximumCost higher than 0? + (m_MaximumCost > 0) // When no maximum cost is set, the item isn't set from the UpdateResult() method and can't be a valid enchanting result. ); } @@ -871,8 +871,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) if (!SecondInput.IsEmpty()) { RepairCost += cItemHandler::GetItemHandler(SecondInput)->GetRepairCost(); - - if (Input.IsDamageable() && cItemHandler::GetItemHandler(Input)->CanRepairWithItem(SecondInput)) + if (Input.IsDamageable() && cItemHandler::GetItemHandler(Input)->CanRepairWithRawMaterial(SecondInput.m_ItemType)) { // Tool and armor repair with special item (iron / gold / diamond / ...) int DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4); @@ -889,7 +888,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) while ((DamageDiff > 0) && (x < SecondInput.m_ItemCount)) { Input.m_ItemDamage -= DamageDiff; - NeedExp += std::max(1, DamageDiff / 100) + Input.m_Enchantments.Size(); + NeedExp += std::max(1, DamageDiff / 100) + Input.m_Enchantments.Count(); DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4); ++x; -- cgit v1.2.3 From cca8376a0127a3e1711ed46d7e5491750135e715 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 6 May 2014 19:38:01 +0100 Subject: Suggestions'd #2 --- src/Entities/Player.cpp | 2 +- src/Vector3.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index d63e5461a..6ac11c270 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -212,7 +212,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) SendExperience(); } - if (!(GetPosition() - m_LastPos).Equals(Vector3d(0, 0, 0))) // Change in position from last tick? + if (GetPosition() != m_LastPos) // Change in position from last tick? { // Apply food exhaustion from movement: ApplyFoodExhaustionFromMovement(); diff --git a/src/Vector3.h b/src/Vector3.h index 2c79f9ff1..181160ba7 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -113,6 +113,11 @@ public: return Equals(a_Rhs); } + inline bool operator != (const Vector3 & a_Rhs) const + { + return !Equals(a_Rhs); + } + inline bool operator < (const Vector3 & a_Rhs) { // return (x < a_Rhs.x) && (y < a_Rhs.y) && (z < a_Rhs.z); ? -- cgit v1.2.3 From ac1c3ba5d9ee407110700e2c5e9ce1d87e191e29 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 6 May 2014 21:43:31 +0200 Subject: Fixed an extra space. --- src/HTTPServer/HTTPServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp index b78a538a2..d288c83c9 100644 --- a/src/HTTPServer/HTTPServer.cpp +++ b/src/HTTPServer/HTTPServer.cpp @@ -150,7 +150,7 @@ bool cHTTPServer::Initialize(const AString & a_PortsIPv4, const AString & a_Port { m_Cert.reset(new cX509Cert); int res = m_Cert->Parse(CertFile.data(), CertFile.size()); - if (res == 0) + if (res == 0) { m_CertPrivKey.reset(new cCryptoKey); int res2 = m_CertPrivKey->ParsePrivate(KeyFile.data(), KeyFile.size(), ""); -- cgit v1.2.3 From e5b42b9f16bd17770cd21dcca7449b9ae466c826 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 6 May 2014 23:05:14 +0100 Subject: Fixed wires powering wires diagonally below them --- src/Simulator/IncrementalRedstoneSimulator.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index f12bd6d49..074063add 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -615,11 +615,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re else if ((i >= 8) && (i <= 11)) // See above, but this is for wire below us { BLOCKTYPE Type = 0; - if (a_RelBlockY - 1 < 0) - { - continue; - } - if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, Type)) + if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY, a_RelBlockZ + gCrossCoords[i].z, Type)) { continue; } -- cgit v1.2.3 From da5db2ddf9897d977716261e216e90ee8d61f2e7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 7 May 2014 11:01:30 +0200 Subject: Initial cPrefabPiecePool refactoring. Ref.: #986. --- src/Generating/PrefabPiecePool.cpp | 121 +++++++++++++++++++++++++++++++++++++ src/Generating/PrefabPiecePool.h | 75 +++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 src/Generating/PrefabPiecePool.cpp create mode 100644 src/Generating/PrefabPiecePool.h (limited to 'src') diff --git a/src/Generating/PrefabPiecePool.cpp b/src/Generating/PrefabPiecePool.cpp new file mode 100644 index 000000000..ed9340815 --- /dev/null +++ b/src/Generating/PrefabPiecePool.cpp @@ -0,0 +1,121 @@ + +// PrefabPiecePool.cpp + +// Implements the cPrefabPiecePool class that represents a cPiecePool descendant that uses cPrefab instances as the pieces + +#include "Globals.h" +#include "PrefabPiecePool.h" + + + + + +cPrefabPiecePool::cPrefabPiecePool( + const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs, + const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs +) +{ + AddPieceDefs(a_PieceDefs, a_NumPieceDefs); + if (a_StartingPieceDefs != NULL) + { + AddStartingPieceDefs(a_StartingPieceDefs, a_NumStartingPieceDefs); + } +} + + + + + +void cPrefabPiecePool::AddPieceDefs(const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs) +{ + ASSERT(a_PieceDefs != NULL); + for (size_t i = 0; i < a_NumPieceDefs; i++) + { + cPrefab * Prefab = new cPrefab(a_PieceDefs[i]); + m_AllPieces.push_back(Prefab); + AddToPerConnectorMap(Prefab); + } +} + + + + + +void cPrefabPiecePool::AddStartingPieceDefs(const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs) +{ + ASSERT(a_StartingPieceDefs != NULL); + for (size_t i = 0; i < a_NumStartingPieceDefs; i++) + { + cPrefab * Prefab = new cPrefab(a_StartingPieceDefs[i]); + m_StartingPieces.push_back(Prefab); + } +} + + + + + +void cPrefabPiecePool::AddToPerConnectorMap(cPrefab * a_Prefab) +{ + cPiece::cConnectors Connectors = ((const cPiece *)a_Prefab)->GetConnectors(); + for (cPiece::cConnectors::const_iterator itr = Connectors.begin(), end = Connectors.end(); itr != end; ++itr) + { + m_PiecesByConnector[itr->m_Type].push_back(a_Prefab); + } +} + + + + +cPieces cPrefabPiecePool::GetPiecesWithConnector(int a_ConnectorType) +{ + return m_PiecesByConnector[a_ConnectorType]; +} + + + + + +cPieces cPrefabPiecePool::GetStartingPieces(void) +{ + if (m_StartingPieces.empty()) + { + return m_AllPieces; + } + else + { + return m_StartingPieces; + } +} + + + + + +int cPrefabPiecePool::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) +{ + return ((const cPrefab &)a_NewPiece).GetPieceWeight(a_PlacedPiece, a_ExistingConnector); +} + + + + + +void cPrefabPiecePool::PiecePlaced(const cPiece & a_Piece) +{ + // Do nothing + UNUSED(a_Piece); +} + + + + + +void cPrefabPiecePool::Reset(void) +{ + // Do nothing +} + + + + diff --git a/src/Generating/PrefabPiecePool.h b/src/Generating/PrefabPiecePool.h new file mode 100644 index 000000000..2a7993063 --- /dev/null +++ b/src/Generating/PrefabPiecePool.h @@ -0,0 +1,75 @@ + +// PrefabPiecePool.h + +// Declares the cPrefabPiecePool class that represents a cPiecePool descendant that uses cPrefab instances as the pieces + + + + + +#pragma once + +#include "PieceGenerator.h" +#include "Prefab.h" + + + + + +class cPrefabPiecePool : + public cPiecePool +{ +public: + /** Creates a piece pool with prefabs from the specified definitions. + If both a_PieceDefs and a_StartingPieceDefs are given, only the a_StartingPieceDefs are used as starting + pieces for the pool, and they do not participate in the generation any further. + If only a_PieceDefs is given, any such piece can be chosen as a starting piece, and all the pieces are used + for generating. */ + cPrefabPiecePool( + const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs, + const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs + ); + + /** Adds pieces from the specified definitions into m_AllPieces. Also adds the pieces into + the m_PiecesByConnector map. + May be called multiple times with different PieceDefs, will add all such pieces. */ + void AddPieceDefs(const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs); + + /** Adds pieces from the specified definitions into m_StartingPieces. Doesn't add to + the m_PiecesByConnector map. + May be called multiple times with different PieceDefs, will add all such pieces. */ + void AddStartingPieceDefs(const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs); + + +protected: + + /** The type used to map a connector type to the list of pieces with that connector */ + typedef std::map cPiecesMap; + + /** All the pieces that are allowed for building. + This is the list that's used for memory allocation and deallocation for the pieces. */ + cPieces m_AllPieces; + + /** The pieces that are used as starting pieces. + This list is not shared and the pieces need deallocation. */ + cPieces m_StartingPieces; + + /** The map that has all pieces by their connector types + The pieces are copies out of m_AllPieces and shouldn't be ever delete-d. */ + cPiecesMap m_PiecesByConnector; + + + /** Adds the prefab to the m_PiecesByConnector map for all its connectors. */ + void AddToPerConnectorMap(cPrefab * a_Prefab); + + // cPiecePool overrides: + virtual cPieces GetPiecesWithConnector(int a_ConnectorType) override; + virtual cPieces GetStartingPieces(void) override; + virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override; + virtual void PiecePlaced(const cPiece & a_Piece) override; + virtual void Reset(void) override; +} ; + + + + -- cgit v1.2.3 From d6cb6e0423fe38478c69f5d249882a01d727f0ed Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 7 May 2014 12:30:30 +0200 Subject: Add repair cost to cItem, add custom name to NBTChunkSerializer and fix anvil bugs. --- src/Item.cpp | 4 +++ src/Item.h | 24 ++++++++----- src/Items/ItemHandler.cpp | 9 ----- src/Items/ItemHandler.h | 3 -- src/Protocol/Protocol17x.cpp | 11 ++++++ src/UI/SlotArea.cpp | 60 ++++++++++++++++++++------------- src/WorldStorage/NBTChunkSerializer.cpp | 37 ++++++++++++++++---- src/WorldStorage/WSSAnvil.cpp | 34 +++++++++++++++---- 8 files changed, 125 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/src/Item.cpp b/src/Item.cpp index 7e472f6d8..d32164bc4 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -151,6 +151,8 @@ void cItem::GetJson(Json::Value & a_OutValue) const a_OutValue["Colours"] = m_FireworkItem.ColoursToString(m_FireworkItem); a_OutValue["FadeColours"] = m_FireworkItem.FadeColoursToString(m_FireworkItem); } + + a_OutValue["RepairCost"] = m_RepairCost; } } @@ -179,6 +181,8 @@ void cItem::FromJson(const Json::Value & a_Value) m_FireworkItem.ColoursFromString(a_Value.get("Colours", "").asString(), m_FireworkItem); m_FireworkItem.FadeColoursFromString(a_Value.get("FadeColours", "").asString(), m_FireworkItem); } + + m_RepairCost = (unsigned short)a_Value.get("RepairCost", 0).asInt(); } } diff --git a/src/Item.h b/src/Item.h index 8eb0a1f4e..7e2fc6cff 100644 --- a/src/Item.h +++ b/src/Item.h @@ -40,6 +40,7 @@ public: m_ItemDamage(0), m_CustomName(""), m_Lore(""), + m_RepairCost(0), m_FireworkItem() { } @@ -60,6 +61,7 @@ public: m_Enchantments(a_Enchantments), m_CustomName (a_CustomName), m_Lore (a_Lore), + m_RepairCost (0), m_FireworkItem() { if (!IsValidItem(m_ItemType)) @@ -85,7 +87,8 @@ public: m_Enchantments(a_CopyFrom.m_Enchantments), m_CustomName (a_CopyFrom.m_CustomName), m_Lore (a_CopyFrom.m_Lore), - m_FireworkItem(a_CopyFrom.m_FireworkItem) + m_FireworkItem(a_CopyFrom.m_FireworkItem), + m_RepairCost (a_CopyFrom.m_RepairCost) { } @@ -100,6 +103,7 @@ public: m_Enchantments.Clear(); m_CustomName = ""; m_Lore = ""; + m_RepairCost = 0; m_FireworkItem.EmptyData(); } @@ -109,6 +113,7 @@ public: m_ItemType = E_ITEM_EMPTY; m_ItemCount = 0; m_ItemDamage = 0; + m_RepairCost = 0; } @@ -190,14 +195,15 @@ public: // tolua_begin - short m_ItemType; - char m_ItemCount; - short m_ItemDamage; - cEnchantments m_Enchantments; - AString m_CustomName; - AString m_Lore; - - cFireworkItem m_FireworkItem; + short m_ItemType; + char m_ItemCount; + short m_ItemDamage; + cEnchantments m_Enchantments; + AString m_CustomName; + AString m_Lore; + + cFireworkItem m_FireworkItem; + UInt16 m_RepairCost; }; // tolua_end diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 5cc5b66a0..d97f986ba 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -521,15 +521,6 @@ bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType) -int cItemHandler::GetRepairCost(void) -{ - return 0; -} - - - - - bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) { UNUSED(a_BlockType); diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index ca090eb29..e13198cd7 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -88,9 +88,6 @@ public: /** Can the anvil repair this item, when a_Item is the second input? */ virtual bool CanRepairWithRawMaterial(short a_ItemType); - /** Get the repair cost from the item, or 0 if the item hasn't repair cost. */ - virtual int GetRepairCost(void); - /** Called before a block is placed into a world. The handler should return true to allow placement, false to refuse. Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block. diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index bc9aff0c0..c4fb9d424 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -2278,6 +2278,13 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata) } break; } + case TAG_Int: + { + if (TagName == "RepairCost") + { + a_Item.m_RepairCost = (UInt16)NBT.GetInt(tag); + } + } default: LOGD("Unimplemented NBT data when parsing!"); break; } } @@ -2451,6 +2458,10 @@ void cProtocol172::cPacketizer::WriteItem(const cItem & a_Item) // Send the enchantments and custom names: cFastNBTWriter Writer; + if (a_Item.m_RepairCost != 0) + { + Writer.AddInt("RepairCost", (Int32)a_Item.m_RepairCost); + } if (!a_Item.m_Enchantments.IsEmpty()) { const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench"; diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index fcf5f6f6b..c4c95c7b1 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -866,16 +866,19 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) m_MaximumCost = 0; m_StackSizeToBeUsedInRepair = 0; - int RepairCost = cItemHandler::GetItemHandler(Input)->GetRepairCost(); + UInt16 RepairCost = Input.m_RepairCost; int NeedExp = 0; + bool IsEnchantBook = false; if (!SecondInput.IsEmpty()) { - RepairCost += cItemHandler::GetItemHandler(SecondInput)->GetRepairCost(); + IsEnchantBook = (SecondInput.m_ItemType == E_ITEM_ENCHANTED_BOOK); + + RepairCost += SecondInput.m_RepairCost; if (Input.IsDamageable() && cItemHandler::GetItemHandler(Input)->CanRepairWithRawMaterial(SecondInput.m_ItemType)) { // Tool and armor repair with special item (iron / gold / diamond / ...) int DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4); - if (DamageDiff < 0) + if (DamageDiff <= 0) { // No enchantment Output.Empty(); @@ -898,7 +901,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) else { // Tool and armor repair with two tools / armors - if (!Input.IsSameType(SecondInput) || !Input.IsDamageable()) + if (!IsEnchantBook && (!Input.IsSameType(SecondInput) || !Input.IsDamageable())) { // No enchantment Output.Empty(); @@ -907,20 +910,23 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) return; } - int FirstDamageDiff = Input.GetMaxDamage() - Input.m_ItemDamage; - int SecondDamageDiff = SecondInput.GetMaxDamage() - SecondInput.m_ItemDamage; - int Damage = SecondDamageDiff + Input.GetMaxDamage() * 12 / 100; - - int NewItemDamage = Input.GetMaxDamage() - (FirstDamageDiff + Damage); - if (NewItemDamage > 0) + if ((Input.GetMaxDamage() > 0) && !IsEnchantBook) { - NewItemDamage = 0; - } + int FirstDamageDiff = Input.GetMaxDamage() - Input.m_ItemDamage; + int SecondDamageDiff = SecondInput.GetMaxDamage() - SecondInput.m_ItemDamage; + int Damage = SecondDamageDiff + Input.GetMaxDamage() * 12 / 100; - if (NewItemDamage < Input.m_ItemDamage) - { - Input.m_ItemDamage = NewItemDamage; - NeedExp += std::max(1, Damage / 100); + int NewItemDamage = Input.GetMaxDamage() - (FirstDamageDiff + Damage); + if (NewItemDamage > 0) + { + NewItemDamage = 0; + } + + if (NewItemDamage < Input.m_ItemDamage) + { + Input.m_ItemDamage = NewItemDamage; + NeedExp += std::max(1, Damage / 100); + } } // TODO: Add enchantments. @@ -934,7 +940,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) // Remove custom name if (!Input.m_CustomName.empty()) { - NameChangeExp = (Input.IsDamageable()) ? 4 : (Input.m_ItemCount * 5); + NameChangeExp = (Input.IsDamageable()) ? 7 : (Input.m_ItemCount * 5); NeedExp += NameChangeExp; Input.m_CustomName = ""; } @@ -942,7 +948,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) else if (RepairedItemName != Input.m_CustomName) { // Change custom name - NameChangeExp = (Input.IsDamageable()) ? 4 : (Input.m_ItemCount * 5); + NameChangeExp = (Input.IsDamageable()) ? 7 : (Input.m_ItemCount * 5); NeedExp += NameChangeExp; if (!Input.m_CustomName.empty()) @@ -962,7 +968,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) Input.Empty(); } - if (NameChangeExp == NeedExp && NameChangeExp > 0 && m_MaximumCost >= 40) + if ((NameChangeExp == NeedExp) && (NameChangeExp > 0) && (m_MaximumCost >= 40)) { m_MaximumCost = 39; } @@ -971,17 +977,23 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) Input.Empty(); } - /* TODO: Add repair cost to cItem and not ItemHandler. This is required for this function! if (!Input.IsEmpty()) { - RepairCost = max(cItemHandler::GetItemHandler(Input)->GetRepairCost(), cItemHandler::GetItemHandler(SecondInput)->GetRepairCost()); + RepairCost = std::max(Input.m_RepairCost, SecondInput.m_RepairCost); if (!Input.m_CustomName.empty()) { - RepairCost -= 9; + if (RepairCost < 9) + { + RepairCost = 0; + } + else + { + RepairCost -= 9; + } } - RepairCost = max(RepairCost, 0); RepairCost += 2; - }*/ + Input.m_RepairCost = RepairCost; + } SetSlot(2, a_Player, Input); m_ParentWindow.SetProperty(0, m_MaximumCost, a_Player); diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index fd356c7de..b696a8f69 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -88,23 +88,48 @@ void cNBTChunkSerializer::Finish(void) void cNBTChunkSerializer::AddItem(const cItem & a_Item, int a_Slot, const AString & a_CompoundName) { m_Writer.BeginCompound(a_CompoundName); - m_Writer.AddShort("id", (short)(a_Item.m_ItemType)); - m_Writer.AddShort("Damage", a_Item.m_ItemDamage); - m_Writer.AddByte ("Count", a_Item.m_ItemCount); + m_Writer.AddShort("id", (short)(a_Item.m_ItemType)); + m_Writer.AddShort("Damage", a_Item.m_ItemDamage); + m_Writer.AddByte ("Count", a_Item.m_ItemCount); if (a_Slot >= 0) { m_Writer.AddByte ("Slot", (unsigned char)a_Slot); } - // Write the enchantments: - if (!a_Item.m_Enchantments.IsEmpty() || ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR))) + // Write the tag compound (for enchantment, firework, custom name and repair cost): + if ( + (!a_Item.m_Enchantments.IsEmpty()) || + ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR)) || + (a_Item.m_RepairCost > 0) || + (a_Item.m_CustomName != "") || + (a_Item.m_Lore != "") + ) { m_Writer.BeginCompound("tag"); + if (a_Item.m_RepairCost > 0) + { + m_Writer.AddInt("RepairCost", (Int32)a_Item.m_RepairCost); + } + + if ((a_Item.m_CustomName != "") || (a_Item.m_Lore != "")) + { + m_Writer.BeginCompound("display"); + if (a_Item.m_CustomName != "") + { + m_Writer.AddString("Name", a_Item.m_CustomName); + } + if (a_Item.m_Lore != "") + { + m_Writer.AddString("Lore", a_Item.m_Lore); + } + m_Writer.EndCompound(); + } + if ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR)) { cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, m_Writer, (ENUM_ITEM_ID)a_Item.m_ItemType); } - + if (!a_Item.m_Enchantments.IsEmpty()) { const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench"; diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index f33178173..b1c6238ab 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -645,18 +645,16 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_ } int Damage = a_NBT.FindChildByName(a_TagIdx, "Damage"); - if ((Damage < 0) || (a_NBT.GetType(Damage) != TAG_Short)) + if ((Damage > 0) && (a_NBT.GetType(Damage) == TAG_Short)) { - return false; + a_Item.m_ItemDamage = a_NBT.GetShort(Damage); } - a_Item.m_ItemDamage = a_NBT.GetShort(Damage); int Count = a_NBT.FindChildByName(a_TagIdx, "Count"); - if ((Count < 0) || (a_NBT.GetType(Count) != TAG_Byte)) + if ((Count > 0) && (a_NBT.GetType(Count) == TAG_Byte)) { - return false; + a_Item.m_ItemCount = a_NBT.GetByte(Count); } - a_Item.m_ItemCount = a_NBT.GetByte(Count); // Find the "tag" tag, used for enchantments and other extra data int TagTag = a_NBT.FindChildByName(a_TagIdx, "tag"); @@ -666,6 +664,29 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_ return true; } + // Load repair cost: + int RepairCost = a_NBT.FindChildByName(TagTag, "RepairCost"); + if ((RepairCost > 0) && (a_NBT.GetType(RepairCost) == TAG_Int)) + { + a_Item.m_RepairCost = (UInt16)a_NBT.GetInt(RepairCost); + } + + // Load display name: + int DisplayTag = a_NBT.FindChildByName(TagTag, "display"); + if (DisplayTag > 0) + { + int DisplayName = a_NBT.FindChildByName(DisplayTag, "Name"); + if ((DisplayName > 0) && (a_NBT.GetType(DisplayName) == TAG_String)) + { + a_Item.m_CustomName = a_NBT.GetString(DisplayName); + } + int Lore = a_NBT.FindChildByName(DisplayTag, "Lore"); + if ((Lore > 0) && (a_NBT.GetType(Lore) == TAG_String)) + { + a_Item.m_Lore = a_NBT.GetString(Lore); + } + } + // Load enchantments: const char * EnchName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench"; int EnchTag = a_NBT.FindChildByName(TagTag, EnchName); @@ -674,6 +695,7 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_ EnchantmentSerializer::ParseFromNBT(a_Item.m_Enchantments, a_NBT, EnchTag); } + // Load firework data: int FireworksTag = a_NBT.FindChildByName(TagTag, ((a_Item.m_ItemType == E_ITEM_FIREWORK_STAR) ? "Fireworks" : "Explosion")); if (EnchTag > 0) { -- cgit v1.2.3 From 80bcc43c7bf1661ceeab4567143e174979ccbd59 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 7 May 2014 12:43:21 +0200 Subject: Fix MagmaCube save. --- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- src/WorldStorage/WSSAnvil.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index fd356c7de..ff0241091 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -490,7 +490,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster) } case cMonster::mtMagmaCube: { - m_Writer.AddByte("Size", ((const cMagmaCube *)a_Monster)->GetSize()); + m_Writer.AddInt("Size", ((const cMagmaCube *)a_Monster)->GetSize()); break; } case cMonster::mtSheep: diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index f33178173..00dff54f0 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1974,7 +1974,10 @@ void cWSSAnvil::LoadMagmaCubeFromNBT(cEntityList & a_Entities, const cParsedNBT { int SizeIdx = a_NBT.FindChildByName(a_TagIdx, "Size"); - if (SizeIdx < 0) { return; } + if (SizeIdx < 0) + { + return; + } int Size = a_NBT.GetInt(SizeIdx); @@ -2132,7 +2135,10 @@ void cWSSAnvil::LoadSlimeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ { int SizeIdx = a_NBT.FindChildByName(a_TagIdx, "Size"); - if (SizeIdx < 0) { return; } + if (SizeIdx < 0) + { + return; + } int Size = a_NBT.GetInt(SizeIdx); -- cgit v1.2.3 From e86bf64867dd6da877934fee4ac5bafedc464389 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 7 May 2014 12:45:20 +0200 Subject: Where is the problem with clang? --- src/Item.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Item.h b/src/Item.h index 7e2fc6cff..2a1978aad 100644 --- a/src/Item.h +++ b/src/Item.h @@ -202,8 +202,8 @@ public: AString m_CustomName; AString m_Lore; - cFireworkItem m_FireworkItem; UInt16 m_RepairCost; + cFireworkItem m_FireworkItem; }; // tolua_end -- cgit v1.2.3 From 36a2aa2f212212426f94db736eb8f889340c5e00 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 7 May 2014 12:59:48 +0200 Subject: Rename CanChangeDirtToGrass to CanDirtGrowGrass --- src/Blocks/BlockBed.h | 2 +- src/Blocks/BlockDirt.h | 4 ++-- src/Blocks/BlockHandler.cpp | 4 ++-- src/Blocks/BlockHandler.h | 4 ++-- src/Blocks/BlockSlab.h | 2 +- src/Blocks/BlockStairs.h | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h index cfd732d38..51e79b888 100644 --- a/src/Blocks/BlockBed.h +++ b/src/Blocks/BlockBed.h @@ -39,7 +39,7 @@ public: } - virtual bool CanChangeDirtToGrass(BLOCKTYPE a_Block, NIBBLETYPE a_Meta) override + virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override { return true; } diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index 0c550257e..b8b23086b 100644 --- a/src/Blocks/BlockDirt.h +++ b/src/Blocks/BlockDirt.h @@ -38,7 +38,7 @@ public: BLOCKTYPE Above; NIBBLETYPE AboveMeta; a_Chunk.GetBlockTypeMeta(a_RelX, a_RelY + 1, a_RelZ, Above, AboveMeta); - if ((IsBlockWater(Above)) || !cBlockInfo::GetHandler(Above)->CanChangeDirtToGrass(Above, AboveMeta)) + if ((IsBlockWater(Above)) || !cBlockInfo::GetHandler(Above)->CanDirtGrowGrass(AboveMeta)) { a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_DIRT, E_META_DIRT_NORMAL); return; @@ -79,7 +79,7 @@ public: BLOCKTYPE AboveDest; NIBBLETYPE AboveMeta; Chunk->GetBlockTypeMeta(BlockX, BlockY + 1, BlockZ, AboveDest, AboveMeta); - if ((!IsBlockWater(AboveDest)) && (cBlockInfo::GetHandler(AboveDest)->CanChangeDirtToGrass(AboveDest, AboveMeta))) + if ((!IsBlockWater(AboveDest)) && (cBlockInfo::GetHandler(AboveDest)->CanDirtGrowGrass(AboveMeta))) { if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread((cWorld*) &a_WorldInterface, BlockX * cChunkDef::Width, BlockY, BlockZ * cChunkDef::Width, ssGrassSpread)) { diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 850bae6b9..304e35e84 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -400,9 +400,9 @@ bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, in -bool cBlockHandler::CanChangeDirtToGrass(BLOCKTYPE a_Block, NIBBLETYPE a_Meta) +bool cBlockHandler::CanDirtGrowGrass(NIBBLETYPE a_Meta) { - return ((cBlockInfo::IsTransparent(a_Block)) || (cBlockInfo::IsOneHitDig(a_Block))); + return ((cBlockInfo::IsTransparent(m_BlockType)) || (cBlockInfo::IsOneHitDig(m_BlockType))); } diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 4d6a2abb6..fb6cae729 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -86,8 +86,8 @@ public: /// Checks if the block can stay at the specified relative coords in the chunk virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk); - /** Can change the block under this block to grass? */ - virtual bool CanChangeDirtToGrass(BLOCKTYPE a_Block, NIBBLETYPE a_Meta); + /** Can the dirt under this block grow to grass? */ + virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta); /** Checks if the block can be placed at this point. Default: CanBeAt(...) diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 84580b062..b6bd12588 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -98,7 +98,7 @@ public: } - virtual bool CanChangeDirtToGrass(BLOCKTYPE a_Block, NIBBLETYPE a_Meta) override + virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override { return (a_Meta & 0x8); } diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h index d6363fed9..a49fda5ae 100644 --- a/src/Blocks/BlockStairs.h +++ b/src/Blocks/BlockStairs.h @@ -78,7 +78,7 @@ public: a_Pickups.push_back(cItem(m_BlockType, 1, 0)); } - virtual bool CanChangeDirtToGrass(BLOCKTYPE a_Block, NIBBLETYPE a_Meta) override + virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override { return true; } -- cgit v1.2.3 From bc4a51781e22b56b8fc13736e94511e7bfd1a367 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 7 May 2014 20:37:36 +0200 Subject: Add lava and water check to block handlers. --- src/Blocks/BlockDirt.h | 4 ++-- src/Blocks/BlockFluid.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index b8b23086b..2d4fccbac 100644 --- a/src/Blocks/BlockDirt.h +++ b/src/Blocks/BlockDirt.h @@ -38,7 +38,7 @@ public: BLOCKTYPE Above; NIBBLETYPE AboveMeta; a_Chunk.GetBlockTypeMeta(a_RelX, a_RelY + 1, a_RelZ, Above, AboveMeta); - if ((IsBlockWater(Above)) || !cBlockInfo::GetHandler(Above)->CanDirtGrowGrass(AboveMeta)) + if (!cBlockInfo::GetHandler(Above)->CanDirtGrowGrass(AboveMeta)) { a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_DIRT, E_META_DIRT_NORMAL); return; @@ -79,7 +79,7 @@ public: BLOCKTYPE AboveDest; NIBBLETYPE AboveMeta; Chunk->GetBlockTypeMeta(BlockX, BlockY + 1, BlockZ, AboveDest, AboveMeta); - if ((!IsBlockWater(AboveDest)) && (cBlockInfo::GetHandler(AboveDest)->CanDirtGrowGrass(AboveMeta))) + if (cBlockInfo::GetHandler(AboveDest)->CanDirtGrowGrass(AboveMeta)) { if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread((cWorld*) &a_WorldInterface, BlockX * cChunkDef::Width, BlockY, BlockZ * cChunkDef::Width, ssGrassSpread)) { diff --git a/src/Blocks/BlockFluid.h b/src/Blocks/BlockFluid.h index d486d642d..e20af9b5c 100644 --- a/src/Blocks/BlockFluid.h +++ b/src/Blocks/BlockFluid.h @@ -49,6 +49,12 @@ public: } super::Check(a_ChunkInterface, a_PluginInterface, a_RelX, a_RelY, a_RelZ, a_Chunk); } + + + virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override + { + return false; + } } ; @@ -132,6 +138,12 @@ public: } // for i - CrossCoords[] return false; } + + + virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override + { + return false; + } } ; -- cgit v1.2.3 From fbb6404cc8793f5caef374e1eda243fa2d159eb5 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 7 May 2014 20:43:37 +0200 Subject: Change m_RepairCost to int. --- src/Item.cpp | 2 +- src/Item.h | 4 ++-- src/Protocol/Protocol17x.cpp | 4 ++-- src/UI/SlotArea.cpp | 12 +++--------- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- src/WorldStorage/WSSAnvil.cpp | 2 +- 6 files changed, 10 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/Item.cpp b/src/Item.cpp index d32164bc4..d6e8b224a 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -182,7 +182,7 @@ void cItem::FromJson(const Json::Value & a_Value) m_FireworkItem.FadeColoursFromString(a_Value.get("FadeColours", "").asString(), m_FireworkItem); } - m_RepairCost = (unsigned short)a_Value.get("RepairCost", 0).asInt(); + m_RepairCost = a_Value.get("RepairCost", 0).asInt(); } } diff --git a/src/Item.h b/src/Item.h index 2a1978aad..1ac9280fc 100644 --- a/src/Item.h +++ b/src/Item.h @@ -87,8 +87,8 @@ public: m_Enchantments(a_CopyFrom.m_Enchantments), m_CustomName (a_CopyFrom.m_CustomName), m_Lore (a_CopyFrom.m_Lore), - m_FireworkItem(a_CopyFrom.m_FireworkItem), m_RepairCost (a_CopyFrom.m_RepairCost) + m_FireworkItem(a_CopyFrom.m_FireworkItem), { } @@ -202,7 +202,7 @@ public: AString m_CustomName; AString m_Lore; - UInt16 m_RepairCost; + int m_RepairCost; cFireworkItem m_FireworkItem; }; // tolua_end diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index c4fb9d424..f6849122f 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -2282,7 +2282,7 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata) { if (TagName == "RepairCost") { - a_Item.m_RepairCost = (UInt16)NBT.GetInt(tag); + a_Item.m_RepairCost = NBT.GetInt(tag); } } default: LOGD("Unimplemented NBT data when parsing!"); break; @@ -2460,7 +2460,7 @@ void cProtocol172::cPacketizer::WriteItem(const cItem & a_Item) cFastNBTWriter Writer; if (a_Item.m_RepairCost != 0) { - Writer.AddInt("RepairCost", (Int32)a_Item.m_RepairCost); + Writer.AddInt("RepairCost", a_Item.m_RepairCost); } if (!a_Item.m_Enchantments.IsEmpty()) { diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index c4c95c7b1..13a9f9b92 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -866,7 +866,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) m_MaximumCost = 0; m_StackSizeToBeUsedInRepair = 0; - UInt16 RepairCost = Input.m_RepairCost; + int RepairCost = Input.m_RepairCost; int NeedExp = 0; bool IsEnchantBook = false; if (!SecondInput.IsEmpty()) @@ -982,15 +982,9 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) RepairCost = std::max(Input.m_RepairCost, SecondInput.m_RepairCost); if (!Input.m_CustomName.empty()) { - if (RepairCost < 9) - { - RepairCost = 0; - } - else - { - RepairCost -= 9; - } + RepairCost -= 9; } + RepairCost = std::max(RepairCost, 0); RepairCost += 2; Input.m_RepairCost = RepairCost; } diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index b696a8f69..6b317663a 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -108,7 +108,7 @@ void cNBTChunkSerializer::AddItem(const cItem & a_Item, int a_Slot, const AStrin m_Writer.BeginCompound("tag"); if (a_Item.m_RepairCost > 0) { - m_Writer.AddInt("RepairCost", (Int32)a_Item.m_RepairCost); + m_Writer.AddInt("RepairCost", a_Item.m_RepairCost); } if ((a_Item.m_CustomName != "") || (a_Item.m_Lore != "")) diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index b1c6238ab..875093910 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -668,7 +668,7 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_ int RepairCost = a_NBT.FindChildByName(TagTag, "RepairCost"); if ((RepairCost > 0) && (a_NBT.GetType(RepairCost) == TAG_Int)) { - a_Item.m_RepairCost = (UInt16)a_NBT.GetInt(RepairCost); + a_Item.m_RepairCost = a_NBT.GetInt(RepairCost); } // Load display name: -- cgit v1.2.3 From 10e3c262db1ca37f1dabae7400246ec56a3c19cd Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 7 May 2014 20:59:25 +0200 Subject: Send item back to the client when the item get damage. --- src/Inventory.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Inventory.cpp b/src/Inventory.cpp index c7c089d5f..a365e4ed4 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -376,6 +376,7 @@ bool cInventory::DamageItem(int a_SlotNum, short a_Amount) if (!Grid->DamageItem(GridSlotNum, a_Amount)) { // The item has been damaged, but did not break yet + SendSlot(a_SlotNum); return false; } -- cgit v1.2.3 From df71cc931b793dc88f93bc44618d910b0bb978ee Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 7 May 2014 21:32:52 +0200 Subject: Missing comma --- src/Item.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Item.h b/src/Item.h index 1ac9280fc..2f65d5344 100644 --- a/src/Item.h +++ b/src/Item.h @@ -87,8 +87,8 @@ public: m_Enchantments(a_CopyFrom.m_Enchantments), m_CustomName (a_CopyFrom.m_CustomName), m_Lore (a_CopyFrom.m_Lore), - m_RepairCost (a_CopyFrom.m_RepairCost) - m_FireworkItem(a_CopyFrom.m_FireworkItem), + m_RepairCost (a_CopyFrom.m_RepairCost), + m_FireworkItem(a_CopyFrom.m_FireworkItem) { } -- cgit v1.2.3 From c96a27f4ae5240fde76c53b761f8b731cd07117a Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 7 May 2014 21:36:26 +0200 Subject: Superfluous method override. --- src/Blocks/BlockFluid.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockFluid.h b/src/Blocks/BlockFluid.h index e20af9b5c..d0c4ea55b 100644 --- a/src/Blocks/BlockFluid.h +++ b/src/Blocks/BlockFluid.h @@ -138,12 +138,6 @@ public: } // for i - CrossCoords[] return false; } - - - virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override - { - return false; - } } ; -- cgit v1.2.3 From 564261cfd9e385dfe6331c0585cae3b46989dd17 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 7 May 2014 22:34:06 +0200 Subject: cNetherFortGen uses cGridStructGen. WIP, this doesn't work properly yet. --- src/Generating/Caves.h | 2 +- src/Generating/GridStructGen.cpp | 12 +-- src/Generating/NetherFortGen.cpp | 223 ++++----------------------------------- src/Generating/NetherFortGen.h | 61 ++--------- src/Generating/PrefabPiecePool.h | 8 +- 5 files changed, 42 insertions(+), 264 deletions(-) (limited to 'src') diff --git a/src/Generating/Caves.h b/src/Generating/Caves.h index 7c45c056b..2a9fa01b8 100644 --- a/src/Generating/Caves.h +++ b/src/Generating/Caves.h @@ -93,7 +93,7 @@ protected: /// Returns all caves that *may* intersect the given chunk. All the caves are valid until the next call to this function. void GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cCaveSystems & a_Caves); - // cStructGen override: + // cFinishGen override: virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; } ; diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp index 975fd3fdc..2f064d3a0 100644 --- a/src/Generating/GridStructGen.cpp +++ b/src/Generating/GridStructGen.cpp @@ -37,21 +37,21 @@ void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructur int MaxBlockZ = a_ChunkZ * cChunkDef::Width + m_MaxStructureSizeZ + cChunkDef::Width - 1; int MinGridX = MinBlockX / m_GridSizeX; int MinGridZ = MinBlockZ / m_GridSizeZ; - int MaxGridX = MaxBlockX / m_GridSizeX; - int MaxGridZ = MaxBlockX / m_GridSizeZ; - if (MinGridX < 0) + int MaxGridX = (MaxBlockX + m_GridSizeX - 1) / m_GridSizeX; + int MaxGridZ = (MaxBlockZ + m_GridSizeZ - 1) / m_GridSizeZ; + if (MinBlockX < 0) { --MinGridX; } - if (MinGridZ < 0) + if (MinBlockZ < 0) { --MinGridZ; } - if (MaxGridX < 0) + if (MaxBlockX < 0) { --MaxGridX; } - if (MaxGridZ < 0) + if (MaxBlockZ < 0) { --MaxGridZ; } diff --git a/src/Generating/NetherFortGen.cpp b/src/Generating/NetherFortGen.cpp index d90fdeb0a..ac7fd0b7b 100644 --- a/src/Generating/NetherFortGen.cpp +++ b/src/Generating/NetherFortGen.cpp @@ -20,20 +20,21 @@ static const int NEIGHBORHOOD_SIZE = 3; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cNetherFortGen::cNetherFort: -class cNetherFortGen::cNetherFort +class cNetherFortGen::cNetherFort : + public cGridStructGen::cStructure { + typedef cGridStructGen::cStructure super; + public: cNetherFortGen & m_ParentGen; - int m_BlockX, m_BlockZ; int m_GridSize; int m_Seed; cPlacedPieces m_Pieces; - cNetherFort(cNetherFortGen & a_ParentGen, int a_BlockX, int a_BlockZ, int a_GridSize, int a_MaxDepth, int a_Seed) : + cNetherFort(cNetherFortGen & a_ParentGen, int a_OriginX, int a_OriginZ, int a_GridSize, int a_MaxDepth, int a_Seed) : + super(a_OriginX, a_OriginZ), m_ParentGen(a_ParentGen), - m_BlockX(a_BlockX), - m_BlockZ(a_BlockZ), m_GridSize(a_GridSize), m_Seed(a_Seed) { @@ -43,8 +44,8 @@ public: // Generate pieces: for (int i = 0; m_Pieces.size() < (size_t)(a_MaxDepth * a_MaxDepth / 8 + a_MaxDepth); i++) { - cBFSPieceGenerator pg(m_ParentGen, a_Seed + i); - pg.PlacePieces(a_BlockX, BlockY, a_BlockZ, a_MaxDepth, m_Pieces); + cBFSPieceGenerator pg(cNetherFortGen::m_PiecePool, a_Seed + i); + pg.PlacePieces(a_OriginX, BlockY, a_OriginZ, a_MaxDepth, m_Pieces); } } @@ -56,7 +57,7 @@ public: /** Carves the system into the chunk data */ - void ProcessChunk(cChunkDesc & a_Chunk) + virtual void DrawIntoChunk(cChunkDesc & a_Chunk) { for (cPlacedPieces::const_iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr) { @@ -107,214 +108,30 @@ public: /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cNetherFortGen: +cPrefabPiecePool cNetherFortGen::m_PiecePool(g_NetherFortPrefabs, g_NetherFortPrefabsCount, g_NetherFortStartingPrefabs, g_NetherFortStartingPrefabsCount); + + + + + cNetherFortGen::cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxDepth) : - m_Seed(a_Seed), - m_Noise(a_Seed), - m_GridSize(a_GridSize), + super(a_Seed, a_GridSize, a_GridSize, a_MaxDepth * 10, a_MaxDepth * 10, 200), m_MaxDepth(a_MaxDepth) { - // Initialize the prefabs: - for (size_t i = 0; i < g_NetherFortPrefabsCount; i++) - { - cPrefab * Prefab = new cPrefab(g_NetherFortPrefabs[i]); - m_AllPieces.push_back(Prefab); - if (Prefab->HasConnectorType(0)) - { - m_OuterPieces.push_back(Prefab); - } - if (Prefab->HasConnectorType(1)) - { - m_InnerPieces.push_back(Prefab); - } - } - - // Initialize the starting piece prefabs: - for (size_t i = 0; i < g_NetherFortStartingPrefabsCount; i++) - { - m_StartingPieces.push_back(new cPrefab(g_NetherFortStartingPrefabs[i])); - } - /* // DEBUG: Try one round of placement: cPlacedPieces Pieces; - cBFSPieceGenerator pg(*this, a_Seed); + cBFSPieceGenerator pg(m_PiecePool, a_Seed); pg.PlacePieces(0, 64, 0, a_MaxDepth, Pieces); - */ -} - - - - - -cNetherFortGen::~cNetherFortGen() -{ - ClearCache(); - for (cPieces::iterator itr = m_AllPieces.begin(), end = m_AllPieces.end(); itr != end; ++itr) - { - delete *itr; - } // for itr - m_AllPieces[] - m_AllPieces.clear(); + //*/ } -void cNetherFortGen::ClearCache(void) +cGridStructGen::cStructurePtr cNetherFortGen::CreateStructure(int a_OriginX, int a_OriginZ) { - // TODO + return cStructurePtr(new cNetherFort(*this, a_OriginX, a_OriginZ, m_GridSizeX, m_MaxDepth, m_Seed)); } - - - - -void cNetherFortGen::GetFortsForChunk(int a_ChunkX, int a_ChunkZ, cNetherForts & a_Forts) -{ - int BaseX = a_ChunkX * cChunkDef::Width / m_GridSize; - int BaseZ = a_ChunkZ * cChunkDef::Width / m_GridSize; - if (BaseX < 0) - { - --BaseX; - } - if (BaseZ < 0) - { - --BaseZ; - } - BaseX -= NEIGHBORHOOD_SIZE / 2; - BaseZ -= NEIGHBORHOOD_SIZE / 2; - - // Walk the cache, move each cave system that we want into a_Forts: - int StartX = BaseX * m_GridSize; - int EndX = (BaseX + NEIGHBORHOOD_SIZE + 1) * m_GridSize; - int StartZ = BaseZ * m_GridSize; - int EndZ = (BaseZ + NEIGHBORHOOD_SIZE + 1) * m_GridSize; - for (cNetherForts::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end;) - { - if ( - ((*itr)->m_BlockX >= StartX) && ((*itr)->m_BlockX < EndX) && - ((*itr)->m_BlockZ >= StartZ) && ((*itr)->m_BlockZ < EndZ) - ) - { - // want - a_Forts.push_back(*itr); - itr = m_Cache.erase(itr); - } - else - { - // don't want - ++itr; - } - } // for itr - m_Cache[] - - // Create those forts that haven't been in the cache: - for (int x = 0; x < NEIGHBORHOOD_SIZE; x++) - { - int RealX = (BaseX + x) * m_GridSize; - for (int z = 0; z < NEIGHBORHOOD_SIZE; z++) - { - int RealZ = (BaseZ + z) * m_GridSize; - bool Found = false; - for (cNetherForts::const_iterator itr = a_Forts.begin(), end = a_Forts.end(); itr != end; ++itr) - { - if (((*itr)->m_BlockX == RealX) && ((*itr)->m_BlockZ == RealZ)) - { - Found = true; - break; - } - } // for itr - a_Mineshafts - if (!Found) - { - a_Forts.push_back(new cNetherFort(*this, RealX, RealZ, m_GridSize, m_MaxDepth, m_Seed)); - } - } // for z - } // for x - - // Copy a_Forts into m_Cache to the beginning: - cNetherForts FortsCopy (a_Forts); - m_Cache.splice(m_Cache.begin(), FortsCopy, FortsCopy.begin(), FortsCopy.end()); - - // Trim the cache if it's too long: - if (m_Cache.size() > 100) - { - cNetherForts::iterator itr = m_Cache.begin(); - std::advance(itr, 100); - for (cNetherForts::iterator end = m_Cache.end(); itr != end; ++itr) - { - delete *itr; - } - itr = m_Cache.begin(); - std::advance(itr, 100); - m_Cache.erase(itr, m_Cache.end()); - } -} - - - - - -void cNetherFortGen::GenFinish(cChunkDesc & a_ChunkDesc) -{ - int ChunkX = a_ChunkDesc.GetChunkX(); - int ChunkZ = a_ChunkDesc.GetChunkZ(); - cNetherForts Forts; - GetFortsForChunk(ChunkX, ChunkZ, Forts); - for (cNetherForts::const_iterator itr = Forts.begin(); itr != Forts.end(); ++itr) - { - (*itr)->ProcessChunk(a_ChunkDesc); - } // for itr - Forts[] -} - - - - - -cPieces cNetherFortGen::GetPiecesWithConnector(int a_ConnectorType) -{ - switch (a_ConnectorType) - { - case 0: return m_OuterPieces; - case 1: return m_InnerPieces; - default: return cPieces(); - } -} - - - - - -cPieces cNetherFortGen::GetStartingPieces(void) -{ - return m_StartingPieces; -} - - - - - -int cNetherFortGen::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) -{ - return ((const cPrefab &)a_NewPiece).GetPieceWeight(a_PlacedPiece, a_ExistingConnector); -} - - - - - -void cNetherFortGen::PiecePlaced(const cPiece & a_Piece) -{ - UNUSED(a_Piece); -} - - - - - -void cNetherFortGen::Reset(void) -{ - // Nothing needed -} - - - - diff --git a/src/Generating/NetherFortGen.h b/src/Generating/NetherFortGen.h index d51596b9e..f35801a3c 100644 --- a/src/Generating/NetherFortGen.h +++ b/src/Generating/NetherFortGen.h @@ -10,77 +10,34 @@ #pragma once #include "ComposableGenerator.h" -#include "PieceGenerator.h" +#include "PrefabPiecePool.h" +#include "GridStructGen.h" class cNetherFortGen : - public cFinishGen, - public cPiecePool + public cGridStructGen { + typedef cGridStructGen super; + public: cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxDepth); - virtual ~cNetherFortGen(); - protected: friend class cNetherFortPerfTest; // fwd: NetherFortGen.cpp class cNetherFort; // fwd: NetherFortGen.cpp - typedef std::list cNetherForts; - - - /** The seed used for generating*/ - int m_Seed; - - /** The noise used for generating */ - cNoise m_Noise; - - /** Average spacing between the fortresses*/ - int m_GridSize; /** Maximum depth of the piece-generator tree */ int m_MaxDepth; - - /** Cache of the most recently used systems. MoveToFront used. */ - cNetherForts m_Cache; - /** All the pieces that are allowed for building. - This is the list that's used for memory allocation and deallocation for the pieces. */ - cPieces m_AllPieces; + /** The pool of pieces to use for generating. Static, so that it's shared by multiple generators. */ + static cPrefabPiecePool m_PiecePool; - /** The pieces that are used as starting pieces. - This list is not shared and the pieces need deallocation. */ - cPieces m_StartingPieces; - - /** The pieces that have an "outer" connector. - The pieces are copies out of m_AllPieces and shouldn't be ever delete-d. */ - cPieces m_OuterPieces; - - /** The pieces that have an "inner" connector. - The pieces are copies out of m_AllPieces and shouldn't be ever delete-d. */ - cPieces m_InnerPieces; - - /** Clears everything from the cache. - Also invalidates the forst returned by GetFortsForChunk(). */ - void ClearCache(void); - - /** Returns all forts that *may* intersect the given chunk. - The returned forts live within m_Cache.They are valid until the next call - to this function (which may delete some of the pointers). */ - void GetFortsForChunk(int a_ChunkX, int a_ChunkZ, cNetherForts & a_Forts); - - // cFinishGen overrides: - virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; - - // cPiecePool overrides: - virtual cPieces GetPiecesWithConnector(int a_ConnectorType) override; - virtual cPieces GetStartingPieces(void) override; - virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override; - virtual void PiecePlaced(const cPiece & a_Piece) override; - virtual void Reset(void) override; + // cGridStructGen overrides: + virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Generating/PrefabPiecePool.h b/src/Generating/PrefabPiecePool.h index 2a7993063..c6a5ad360 100644 --- a/src/Generating/PrefabPiecePool.h +++ b/src/Generating/PrefabPiecePool.h @@ -20,11 +20,15 @@ class cPrefabPiecePool : public cPiecePool { public: + /** Creates an empty instance. Prefabs can be added by calling AddPieceDefs() and AddStartingPieceDefs(). */ + cPrefabPiecePool(void); + /** Creates a piece pool with prefabs from the specified definitions. If both a_PieceDefs and a_StartingPieceDefs are given, only the a_StartingPieceDefs are used as starting pieces for the pool, and they do not participate in the generation any further. If only a_PieceDefs is given, any such piece can be chosen as a starting piece, and all the pieces are used - for generating. */ + for generating. + More pieces can be added to the instance afterwards by calling AddPieceDefs() and AddStartingPieceDefs(). */ cPrefabPiecePool( const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs, const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs @@ -35,7 +39,7 @@ public: May be called multiple times with different PieceDefs, will add all such pieces. */ void AddPieceDefs(const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs); - /** Adds pieces from the specified definitions into m_StartingPieces. Doesn't add to + /** Adds pieces from the specified definitions into m_StartingPieces. Doesn't add them to the m_PiecesByConnector map. May be called multiple times with different PieceDefs, will add all such pieces. */ void AddStartingPieceDefs(const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs); -- cgit v1.2.3 From c4ea25e136026004526a63516cbed498e2b6fabe Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 8 May 2014 20:16:35 +0200 Subject: Fixed MSVC 64-bit build warnings. --- src/Bindings/PluginManager.cpp | 9 +++---- src/Bindings/PluginManager.h | 2 +- src/BlockArea.cpp | 10 ++++---- src/Blocks/BlockFarmland.h | 4 ++-- src/Blocks/BlockLeaves.h | 6 ++--- src/Blocks/BlockSlab.h | 2 +- src/Generating/Caves.cpp | 10 ++++++-- src/Generating/MineShafts.cpp | 6 ++--- src/Generating/PieceGenerator.cpp | 4 ++-- src/Generating/Ravines.cpp | 10 ++++++-- src/Generating/Trees.cpp | 2 +- src/GroupManager.cpp | 35 ++++++++++++++-------------- src/HTTPServer/NameValueParser.cpp | 2 +- src/Map.cpp | 2 +- src/Map.h | 2 +- src/MapManager.cpp | 6 ++--- src/MapManager.h | 2 +- src/MobCensus.cpp | 2 +- src/MobFamilyCollecter.cpp | 2 +- src/MobSpawner.cpp | 6 ++--- src/Noise.cpp | 2 +- src/OSSupport/ListenThread.cpp | 2 +- src/OSSupport/Socket.cpp | 8 +++---- src/OSSupport/Socket.h | 4 ++-- src/OSSupport/SocketThreads.cpp | 2 +- src/ProbabDistrib.cpp | 2 +- src/Protocol/Protocol17x.cpp | 18 +++++++------- src/Protocol/ProtocolRecognizer.cpp | 4 ++-- src/RCONServer.cpp | 2 +- src/Root.cpp | 14 +++++------ src/Scoreboard.cpp | 6 ++--- src/Scoreboard.h | 6 ++--- src/Simulator/DelayedFluidSimulator.cpp | 2 +- src/Simulator/SandSimulator.cpp | 2 +- src/StringCompression.cpp | 14 +++++------ src/StringCompression.h | 4 ++-- src/StringUtils.cpp | 24 +++++++++++-------- src/StringUtils.h | 4 ++-- src/UI/SlotArea.cpp | 2 +- src/UI/Window.cpp | 2 +- src/World.cpp | 7 +++--- src/WorldStorage/FastNBT.cpp | 30 +++++++++++++----------- src/WorldStorage/FastNBT.h | 8 +++---- src/WorldStorage/SchematicFileSerializer.cpp | 4 ++-- src/WorldStorage/WSSAnvil.cpp | 8 +++---- src/WorldStorage/WSSCompact.cpp | 24 +++++++++---------- 46 files changed, 173 insertions(+), 156 deletions(-) (limited to 'src') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index aaccc606d..310ecc7e8 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -143,13 +143,14 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) } } - if (GetNumPlugins() == 0) + size_t NumLoadedPlugins = GetNumPlugins(); + if (NumLoadedPlugins) { LOG("-- No Plugins Loaded --"); } - else if (GetNumPlugins() > 1) + else if (NumLoadedPlugins > 1) { - LOG("-- Loaded %i Plugins --", GetNumPlugins()); + LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins); } else { @@ -1869,7 +1870,7 @@ void cPluginManager::AddHook(cPlugin * a_Plugin, int a_Hook) -unsigned int cPluginManager::GetNumPlugins() const +size_t cPluginManager::GetNumPlugins() const { return m_Plugins.size(); } diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 58c1cebb4..3b3091957 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -159,7 +159,7 @@ public: // tolua_export /** Adds the plugin to the list of plugins called for the specified hook type. Handles multiple adds as a single add */ void AddHook(cPlugin * a_Plugin, int a_HookType); - unsigned int GetNumPlugins() const; // tolua_export + size_t GetNumPlugins() const; // tolua_export // Calls for individual hooks. Each returns false if the action is to continue or true if the plugin wants to abort bool CallHookBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source); diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 897af27c4..9e20a0983 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -738,31 +738,31 @@ void cBlockArea::Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_Block a_DataTypes = a_DataTypes & GetDataTypes(); } - int BlockCount = GetBlockCount(); + size_t BlockCount = GetBlockCount(); if ((a_DataTypes & baTypes) != 0) { - for (int i = 0; i < BlockCount; i++) + for (size_t i = 0; i < BlockCount; i++) { m_BlockTypes[i] = a_BlockType; } } if ((a_DataTypes & baMetas) != 0) { - for (int i = 0; i < BlockCount; i++) + for (size_t i = 0; i < BlockCount; i++) { m_BlockMetas[i] = a_BlockMeta; } } if ((a_DataTypes & baLight) != 0) { - for (int i = 0; i < BlockCount; i++) + for (size_t i = 0; i < BlockCount; i++) { m_BlockLight[i] = a_BlockLight; } } if ((a_DataTypes & baSkyLight) != 0) { - for (int i = 0; i < BlockCount; i++) + for (size_t i = 0; i < BlockCount; i++) { m_BlockSkyLight[i] = a_BlockSkyLight; } diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h index b720ccd14..3dd5bcd1d 100644 --- a/src/Blocks/BlockFarmland.h +++ b/src/Blocks/BlockFarmland.h @@ -52,9 +52,9 @@ public: return; } - int NumBlocks = Area.GetBlockCount(); + size_t NumBlocks = Area.GetBlockCount(); BLOCKTYPE * BlockTypes = Area.GetBlockTypes(); - for (int i = 0; i < NumBlocks; i++) + for (size_t i = 0; i < NumBlocks; i++) { if ( (BlockTypes[i] == E_BLOCK_WATER) || diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index d21227b07..495e849fa 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -138,14 +138,14 @@ bool HasNearLog(cBlockArea & a_Area, int a_BlockX, int a_BlockY, int a_BlockZ) { // Filter the blocks into a {leaves, log, other (air)} set: BLOCKTYPE * Types = a_Area.GetBlockTypes(); - for (int i = a_Area.GetBlockCount() - 1; i > 0; i--) + for (size_t i = a_Area.GetBlockCount() - 1; i > 0; i--) { switch (Types[i]) { - case E_BLOCK_NEW_LEAVES: - case E_BLOCK_NEW_LOG: case E_BLOCK_LEAVES: case E_BLOCK_LOG: + case E_BLOCK_NEW_LEAVES: + case E_BLOCK_NEW_LOG: { break; } diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index b6bd12588..80841b094 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -100,7 +100,7 @@ public: virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override { - return (a_Meta & 0x8); + return ((a_Meta & 0x8) != 0); } diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index 5cad11d2a..6df22a14a 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -239,9 +239,15 @@ void cCaveTunnel::Randomize(cNoise & a_Noise) bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & a_Dst) { + if (a_Src.size() < 2) + { + // There are no midpoints, nothing to smooth + return true; + } + // Smoothing: for each line segment, add points on its 1/4 lengths bool res = false; - int Num = a_Src.size() - 2; // this many intermediary points + size_t Num = a_Src.size() - 2; // this many intermediary points a_Dst.clear(); a_Dst.reserve(Num * 2 + 2); cCaveDefPoints::const_iterator itr = a_Src.begin() + 1; @@ -251,7 +257,7 @@ bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & int PrevY = Source.m_BlockY; int PrevZ = Source.m_BlockZ; int PrevR = Source.m_Radius; - for (int i = 0; i <= Num; ++i, ++itr) + for (size_t i = 0; i <= Num; ++i, ++itr) { int dx = itr->m_BlockX - PrevX; int dy = itr->m_BlockY - PrevY; diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index 231295c3f..af63e549b 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -543,7 +543,7 @@ cMineShaft * cMineShaftCorridor::CreateAndFit( { cCuboid BoundingBox(a_PivotX, a_PivotY - 1, a_PivotZ); BoundingBox.p2.y += 3; - int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7; + int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7; int NumSegments = 2 + (rnd) % (MAX_SEGMENTS - 1); // 2 .. MAX_SEGMENTS switch (a_Direction) { @@ -985,7 +985,7 @@ cMineShaft * cMineShaftCrossing::CreateAndFit( ) { cCuboid BoundingBox(a_PivotX, a_PivotY - 1, a_PivotZ); - int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7; + int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7; BoundingBox.p2.y += 3; if ((rnd % 4) < 2) { @@ -1127,7 +1127,7 @@ cMineShaft * cMineShaftStaircase::CreateAndFit( cNoise & a_Noise ) { - int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7; + int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7; cCuboid Box; switch (a_Direction) { diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index db45cd08b..ce19c1c95 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -339,9 +339,9 @@ cPlacedPiece * cPieceGenerator::PlaceStartingPiece(int a_BlockX, int a_BlockY, i int NumRotations = 1; for (size_t i = 1; i < ARRAYCOUNT(Rotations); i++) { - if (StartingPiece->CanRotateCCW(i)) + if (StartingPiece->CanRotateCCW((int)i)) { - Rotations[NumRotations] = i; + Rotations[NumRotations] = (int)i; NumRotations += 1; } } diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index 267dcbbf9..a036cf25f 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -306,8 +306,14 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block void cStructGenRavines::cRavine::RefineDefPoints(const cRavDefPoints & a_Src, cRavDefPoints & a_Dst) { + if (a_Src.size() < 2) + { + // No midpoints, nothing to refine + return; + } + // Smoothing: for each line segment, add points on its 1/4 lengths - int Num = a_Src.size() - 2; // this many intermediary points + size_t Num = a_Src.size() - 2; // this many intermediary points a_Dst.clear(); a_Dst.reserve(Num * 2 + 2); cRavDefPoints::const_iterator itr = a_Src.begin() + 1; @@ -318,7 +324,7 @@ void cStructGenRavines::cRavine::RefineDefPoints(const cRavDefPoints & a_Src, cR int PrevR = Source.m_Radius; int PrevT = Source.m_Top; int PrevB = Source.m_Bottom; - for (int i = 0; i <= Num; ++i, ++itr) + for (size_t i = 0; i <= Num; ++i, ++itr) { int dx = itr->m_BlockX - PrevX; int dz = itr->m_BlockZ - PrevZ; diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index 4909587b1..4f1553c36 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -136,7 +136,7 @@ inline void PushSomeColumns(int a_BlockX, int a_Height, int a_BlockZ, int a_Colu { int x = a_BlockX + a_Coords[i].x; int z = a_BlockZ + a_Coords[i].z; - if (a_Noise.IntNoise3DInt(x + 64 * a_Seq, a_Height + i, z + 64 * a_Seq) <= a_Chance) + if (a_Noise.IntNoise3DInt(x + 64 * a_Seq, a_Height + (int)i, z + 64 * a_Seq) <= a_Chance) { for (int j = 0; j < a_ColumnHeight; j++) { diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index 33b601e82..3586560bf 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -79,23 +79,24 @@ void cGroupManager::CheckUsers(void) return; } - unsigned int NumKeys = IniFile.GetNumKeys(); - for (size_t i = 0; i < NumKeys; i++) + int NumKeys = IniFile.GetNumKeys(); + for (int i = 0; i < NumKeys; i++) { - AString Player = IniFile.GetKeyName( i ); + AString Player = IniFile.GetKeyName(i); AString Groups = IniFile.GetValue(Player, "Groups", ""); - if (!Groups.empty()) + if (Groups.empty()) + { + continue; + } + AStringVector Split = StringSplitAndTrim(Groups, ","); + for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr) { - AStringVector Split = StringSplit( Groups, "," ); - for( unsigned int i = 0; i < Split.size(); i++ ) + if (!ExistsGroup(*itr)) { - if (!ExistsGroup(Split[i])) - { - LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), Player.c_str()); - } + LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), Player.c_str()); } - } - } + } // for itr - Split[] + } // for i - ini file keys } @@ -128,15 +129,15 @@ void cGroupManager::LoadGroups() IniFile.WriteFile("groups.ini"); } - unsigned int NumKeys = IniFile.GetNumKeys(); - for (size_t i = 0; i < NumKeys; i++) + int NumKeys = IniFile.GetNumKeys(); + for (int i = 0; i < NumKeys; i++) { - AString KeyName = IniFile.GetKeyName( i ); - cGroup* Group = GetGroup( KeyName.c_str() ); + AString KeyName = IniFile.GetKeyName(i); + cGroup * Group = GetGroup(KeyName.c_str()); Group->ClearPermission(); // Needed in case the groups are reloaded. - LOGD("Loading group: %s", KeyName.c_str() ); + LOGD("Loading group %s", KeyName.c_str()); Group->SetName(KeyName); AString Color = IniFile.GetValue(KeyName, "Color", "-"); diff --git a/src/HTTPServer/NameValueParser.cpp b/src/HTTPServer/NameValueParser.cpp index 3f6c17dda..f16ea1915 100644 --- a/src/HTTPServer/NameValueParser.cpp +++ b/src/HTTPServer/NameValueParser.cpp @@ -97,7 +97,7 @@ void cNameValueParser::Parse(const char * a_Data, size_t a_Size) { ASSERT(m_State != psFinished); // Calling Parse() after Finish() is wrong! - int Last = 0; + size_t Last = 0; for (size_t i = 0; i < a_Size;) { switch (m_State) diff --git a/src/Map.cpp b/src/Map.cpp index 79370b097..7721baa70 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -614,7 +614,7 @@ unsigned int cMap::GetNumPixels(void) const -unsigned int cMap::GetNumDecorators(void) const +size_t cMap::GetNumDecorators(void) const { return m_Decorators.size(); } diff --git a/src/Map.h b/src/Map.h index ee7c537b1..e23ca2c92 100644 --- a/src/Map.h +++ b/src/Map.h @@ -181,7 +181,7 @@ public: // tolua_end - unsigned int GetNumDecorators(void) const; + size_t GetNumDecorators(void) const; const cColorList & GetData(void) const { return m_Data; } diff --git a/src/MapManager.cpp b/src/MapManager.cpp index 9d02eafb4..e7df75118 100644 --- a/src/MapManager.cpp +++ b/src/MapManager.cpp @@ -86,7 +86,7 @@ cMap * cMapManager::CreateMap(int a_CenterX, int a_CenterY, int a_Scale) return NULL; } - cMap Map(m_MapData.size(), a_CenterX, a_CenterY, m_World, a_Scale); + cMap Map((unsigned)m_MapData.size(), a_CenterX, a_CenterY, m_World, a_Scale); m_MapData.push_back(Map); @@ -97,7 +97,7 @@ cMap * cMapManager::CreateMap(int a_CenterX, int a_CenterY, int a_Scale) -unsigned int cMapManager::GetNumMaps(void) const +size_t cMapManager::GetNumMaps(void) const { return m_MapData.size(); } @@ -151,7 +151,7 @@ void cMapManager::SaveMapData(void) cIDCountSerializer IDSerializer(m_World->GetName()); - IDSerializer.SetMapCount(m_MapData.size()); + IDSerializer.SetMapCount((unsigned)m_MapData.size()); if (!IDSerializer.Save()) { diff --git a/src/MapManager.h b/src/MapManager.h index 80e6d16d1..ceab8f126 100644 --- a/src/MapManager.h +++ b/src/MapManager.h @@ -53,7 +53,7 @@ public: */ bool ForEachMap(cMapCallback & a_Callback); - unsigned int GetNumMaps(void) const; // tolua_export + size_t GetNumMaps(void) const; // tolua_export /** Loads the map data from the disk */ void LoadMapData(void); diff --git a/src/MobCensus.cpp b/src/MobCensus.cpp index 9c32bf695..23f74b59e 100644 --- a/src/MobCensus.cpp +++ b/src/MobCensus.cpp @@ -64,7 +64,7 @@ void cMobCensus::CollectSpawnableChunk(cChunk & a_Chunk) int cMobCensus::GetNumChunks(void) { - return m_EligibleForSpawnChunks.size(); + return (int)m_EligibleForSpawnChunks.size(); } diff --git a/src/MobFamilyCollecter.cpp b/src/MobFamilyCollecter.cpp index e9c69e078..6da330c83 100644 --- a/src/MobFamilyCollecter.cpp +++ b/src/MobFamilyCollecter.cpp @@ -18,7 +18,7 @@ void cMobFamilyCollecter::CollectMob(cMonster & a_Monster) int cMobFamilyCollecter::GetNumberOfCollectedMobs(cMonster::eFamily a_Family) { - return m_Mobs[a_Family].size(); + return (int)m_Mobs[a_Family].size(); } diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index ce8e06777..de8e01b8a 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -104,13 +104,13 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome) } } - int allowedMobsSize = allowedMobs.size(); + size_t allowedMobsSize = allowedMobs.size(); if (allowedMobsSize > 0) { std::set::iterator itr = allowedMobs.begin(); - int iRandom = m_Random.NextInt(allowedMobsSize,a_Biome); + int iRandom = m_Random.NextInt((int)allowedMobsSize, a_Biome); - for(int i = 0; i < iRandom; i++) + for (int i = 0; i < iRandom; i++) { ++itr; } diff --git a/src/Noise.cpp b/src/Noise.cpp index 13a194938..89115d992 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -814,7 +814,7 @@ void cPerlinNoise::SetSeed(int a_Seed) void cPerlinNoise::AddOctave(float a_Frequency, float a_Amplitude) { - m_Octaves.push_back(cOctave(m_Seed * (m_Octaves.size() + 4) * 4 + 1024, a_Frequency, a_Amplitude)); + m_Octaves.push_back(cOctave(m_Seed * ((int)m_Octaves.size() + 4) * 4 + 1024, a_Frequency, a_Amplitude)); } diff --git a/src/OSSupport/ListenThread.cpp b/src/OSSupport/ListenThread.cpp index ba3198764..02e98acfc 100644 --- a/src/OSSupport/ListenThread.cpp +++ b/src/OSSupport/ListenThread.cpp @@ -214,7 +214,7 @@ void cListenThread::Execute(void) timeval tv; // On Linux select() doesn't seem to wake up when socket is closed, so let's kinda busy-wait: tv.tv_sec = 1; tv.tv_usec = 0; - if (select(Highest + 1, &fdRead, NULL, NULL, &tv) == -1) + if (select((int)Highest + 1, &fdRead, NULL, NULL, &tv) == -1) { LOG("select(R) call failed in cListenThread: \"%s\"", cSocket::GetLastErrorString().c_str()); continue; diff --git a/src/OSSupport/Socket.cpp b/src/OSSupport/Socket.cpp index 98f694a79..56835b518 100644 --- a/src/OSSupport/Socket.cpp +++ b/src/OSSupport/Socket.cpp @@ -328,18 +328,18 @@ bool cSocket::ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Por -int cSocket::Receive(char * a_Buffer, unsigned int a_Length, unsigned int a_Flags) +int cSocket::Receive(char * a_Buffer, size_t a_Length, unsigned int a_Flags) { - return recv(m_Socket, a_Buffer, a_Length, a_Flags); + return recv(m_Socket, a_Buffer, (int)a_Length, a_Flags); } -int cSocket::Send(const char * a_Buffer, unsigned int a_Length) +int cSocket::Send(const char * a_Buffer, size_t a_Length) { - return send(m_Socket, a_Buffer, a_Length, MSG_NOSIGNAL); + return send(m_Socket, a_Buffer, (int)a_Length, MSG_NOSIGNAL); } diff --git a/src/OSSupport/Socket.h b/src/OSSupport/Socket.h index bdc2babf5..35ecadfa0 100644 --- a/src/OSSupport/Socket.h +++ b/src/OSSupport/Socket.h @@ -110,8 +110,8 @@ public: /// Connects to the specified host or string IP address and port, using IPv4. Returns true if successful. bool ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Port); - int Receive(char * a_Buffer, unsigned int a_Length, unsigned int a_Flags); - int Send (const char * a_Buffer, unsigned int a_Length); + int Receive(char * a_Buffer, size_t a_Length, unsigned int a_Flags); + int Send (const char * a_Buffer, size_t a_Length); unsigned short GetPort(void) const; // Returns 0 on failure diff --git a/src/OSSupport/SocketThreads.cpp b/src/OSSupport/SocketThreads.cpp index 0bc1d6b55..0ab5b6298 100644 --- a/src/OSSupport/SocketThreads.cpp +++ b/src/OSSupport/SocketThreads.cpp @@ -406,7 +406,7 @@ void cSocketThreads::cSocketThread::Execute(void) timeval Timeout; Timeout.tv_sec = 5; Timeout.tv_usec = 0; - if (select(Highest + 1, &fdRead, &fdWrite, NULL, &Timeout) == -1) + if (select((int)Highest + 1, &fdRead, &fdWrite, NULL, &Timeout) == -1) { LOG("select() call failed in cSocketThread: \"%s\"", cSocket::GetLastErrorString().c_str()); continue; diff --git a/src/ProbabDistrib.cpp b/src/ProbabDistrib.cpp index 5fa17c276..7a5869dcc 100644 --- a/src/ProbabDistrib.cpp +++ b/src/ProbabDistrib.cpp @@ -118,7 +118,7 @@ int cProbabDistrib::MapValue(int a_OrigValue) const size_t Hi = m_Cumulative.size() - 1; while (Hi - Lo > 1) { - int Mid = (Lo + Hi) / 2; + size_t Mid = (Lo + Hi) / 2; int MidProbab = m_Cumulative[Mid].m_Probability; if (MidProbab < a_OrigValue) { diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index f6849122f..443723e40 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -197,7 +197,7 @@ void cProtocol172::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockV Pkt.WriteInt(a_ChunkX); Pkt.WriteInt(a_ChunkZ); Pkt.WriteShort((short)a_Changes.size()); - Pkt.WriteInt(a_Changes.size() * 4); + Pkt.WriteInt((int)a_Changes.size() * 4); for (sSetBlockVector::const_iterator itr = a_Changes.begin(), end = a_Changes.end(); itr != end; ++itr) { unsigned int Coords = itr->y | (itr->z << 8) | (itr->x << 12); @@ -532,7 +532,7 @@ void cProtocol172::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc Pkt.WriteFloat((float)a_BlockY); Pkt.WriteFloat((float)a_BlockZ); Pkt.WriteFloat((float)a_Radius); - Pkt.WriteInt(a_BlocksAffected.size()); + Pkt.WriteInt((int)a_BlocksAffected.size()); for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(), end = a_BlocksAffected.end(); itr != end; ++itr) { Pkt.WriteChar((char)itr->x); @@ -698,7 +698,7 @@ void cProtocol172::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decor cPacketizer Pkt(*this, 0x34); Pkt.WriteVarInt(a_ID); - Pkt.WriteShort (1 + (3 * a_Decorators.size())); + Pkt.WriteShort ((short)(1 + (3 * a_Decorators.size()))); Pkt.WriteByte(1); @@ -1174,7 +1174,7 @@ void cProtocol172::SendTabCompletionResults(const AStringVector & a_Results) ASSERT(m_State == 3); // In game mode? cPacketizer Pkt(*this, 0x3a); // Tab-Complete packet - Pkt.WriteVarInt(a_Results.size()); + Pkt.WriteVarInt((int)a_Results.size()); for (AStringVector::const_iterator itr = a_Results.begin(), end = a_Results.end(); itr != end; ++itr) { @@ -1743,7 +1743,7 @@ void cProtocol172::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer) cPacketizer Pkt(*this, 0x01); Pkt.WriteString(Server->GetServerID()); const AString & PubKeyDer = Server->GetPublicKeyDER(); - Pkt.WriteShort(PubKeyDer.size()); + Pkt.WriteShort((short)PubKeyDer.size()); Pkt.WriteBuf(PubKeyDer.data(), PubKeyDer.size()); Pkt.WriteShort(4); Pkt.WriteInt((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :) @@ -2138,7 +2138,7 @@ void cProtocol172::WritePacket(cByteBuffer & a_Packet) cCSLock Lock(m_CSPacket); AString Pkt; a_Packet.ReadAll(Pkt); - WriteVarInt(Pkt.size()); + WriteVarInt((UInt32)Pkt.size()); SendData(Pkt.data(), Pkt.size()); Flush(); } @@ -2403,7 +2403,7 @@ cProtocol172::cPacketizer::~cPacketizer() AString DataToSend; // Send the packet length - UInt32 PacketLen = m_Out.GetUsedSpace(); + UInt32 PacketLen = (UInt32)m_Out.GetUsedSpace(); m_Protocol.m_OutPacketLenBuffer.WriteVarInt(PacketLen); m_Protocol.m_OutPacketLenBuffer.ReadAll(DataToSend); m_Protocol.SendData(DataToSend.data(), DataToSend.size()); @@ -2500,7 +2500,7 @@ void cProtocol172::cPacketizer::WriteItem(const cItem & a_Item) Writer.Finish(); AString Compressed; CompressStringGZIP(Writer.GetResult().data(), Writer.GetResult().size(), Compressed); - WriteShort(Compressed.size()); + WriteShort((short)Compressed.size()); WriteBuf(Compressed.data(), Compressed.size()); } @@ -2570,7 +2570,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt AString Compressed; CompressStringGZIP(Writer.GetResult().data(), Writer.GetResult().size(), Compressed); - WriteShort(Compressed.size()); + WriteShort((short)Compressed.size()); WriteBuf(Compressed.data(), Compressed.size()); } diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 22dfe7c88..667fb5cef 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -871,7 +871,7 @@ bool cProtocolRecognizer::TryRecognizeProtocol(void) // Not enough bytes for the packet length, keep waiting return false; } - ReadSoFar -= m_Buffer.GetReadableSpace(); + ReadSoFar -= (UInt32)m_Buffer.GetReadableSpace(); if (!m_Buffer.CanReadBytes(PacketLen)) { // Not enough bytes for the packet, keep waiting @@ -961,7 +961,7 @@ bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRema { return false; } - NumBytesRead -= m_Buffer.GetReadableSpace(); + NumBytesRead -= (UInt32)m_Buffer.GetReadableSpace(); switch (ProtocolVersion) { case PROTO_VERSION_1_7_2: diff --git a/src/RCONServer.cpp b/src/RCONServer.cpp index d7083ff2b..3fbc9dcbc 100644 --- a/src/RCONServer.cpp +++ b/src/RCONServer.cpp @@ -59,7 +59,7 @@ public: virtual void Finished(void) override { - m_Connection.SendResponse(m_RequestID, RCON_PACKET_RESPONSE, m_Buffer.size(), m_Buffer.c_str()); + m_Connection.SendResponse(m_RequestID, RCON_PACKET_RESPONSE, (int)m_Buffer.size(), m_Buffer.c_str()); delete this; } diff --git a/src/Root.cpp b/src/Root.cpp index 5d32bdd87..c82b05a66 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -590,13 +590,13 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac { class cCallback : public cPlayerListCallback { - unsigned m_BestRating; - unsigned m_NameLength; + size_t m_BestRating; + size_t m_NameLength; const AString m_PlayerName; virtual bool Item (cPlayer * a_pPlayer) { - unsigned int Rating = RateCompareString (m_PlayerName, a_pPlayer->GetName()); + size_t Rating = RateCompareString (m_PlayerName, a_pPlayer->GetName()); if ((Rating > 0) && (Rating >= m_BestRating)) { m_BestMatch = a_pPlayer; @@ -626,7 +626,7 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac cPlayer * m_BestMatch; unsigned m_NumMatches; } Callback (a_PlayerName); - ForEachPlayer( Callback ); + ForEachPlayer(Callback); if (Callback.m_NumMatches == 1) { @@ -763,8 +763,8 @@ void cRoot::LogChunkStats(cCommandOutputCallback & a_Output) { cWorld * World = itr->second; int NumInGenerator = World->GetGeneratorQueueLength(); - int NumInSaveQueue = World->GetStorageSaveQueueLength(); - int NumInLoadQueue = World->GetStorageLoadQueueLength(); + int NumInSaveQueue = (int)World->GetStorageSaveQueueLength(); + int NumInLoadQueue = (int)World->GetStorageLoadQueueLength(); int NumValid = 0; int NumDirty = 0; int NumInLighting = 0; @@ -784,8 +784,6 @@ void cRoot::LogChunkStats(cCommandOutputCallback & a_Output) a_Output.Out(" block lighting: " SIZE_T_FMT_PRECISION(6) " bytes (" SIZE_T_FMT_PRECISION(3) " KiB)", 2 * sizeof(cChunkDef::BlockNibbles), (2 * sizeof(cChunkDef::BlockNibbles) + 1023) / 1024); a_Output.Out(" heightmap: " SIZE_T_FMT_PRECISION(6) " bytes (" SIZE_T_FMT_PRECISION(3) " KiB)", sizeof(cChunkDef::HeightMap), (sizeof(cChunkDef::HeightMap) + 1023) / 1024); a_Output.Out(" biomemap: " SIZE_T_FMT_PRECISION(6) " bytes (" SIZE_T_FMT_PRECISION(3) " KiB)", sizeof(cChunkDef::BiomeMap), (sizeof(cChunkDef::BiomeMap) + 1023) / 1024); - int Rest = sizeof(cChunk) - sizeof(cChunkDef::BlockTypes) - 3 * sizeof(cChunkDef::BlockNibbles) - sizeof(cChunkDef::HeightMap) - sizeof(cChunkDef::BiomeMap); - a_Output.Out(" other: %6d bytes (%3d KiB)", Rest, (Rest + 1023) / 1024); SumNumValid += NumValid; SumNumDirty += NumDirty; SumNumInLighting += NumInLighting; diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp index 4c89ce265..250f63aa9 100644 --- a/src/Scoreboard.cpp +++ b/src/Scoreboard.cpp @@ -261,7 +261,7 @@ void cTeam::SetDisplayName(const AString & a_Name) -unsigned int cTeam::GetNumPlayers(void) const +size_t cTeam::GetNumPlayers(void) const { return m_Players.size(); } @@ -569,7 +569,7 @@ void cScoreboard::SendTo(cClientHandle & a_Client) -unsigned int cScoreboard::GetNumObjectives(void) const +size_t cScoreboard::GetNumObjectives(void) const { return m_Objectives.size(); } @@ -578,7 +578,7 @@ unsigned int cScoreboard::GetNumObjectives(void) const -unsigned int cScoreboard::GetNumTeams(void) const +size_t cScoreboard::GetNumTeams(void) const { return m_Teams.size(); } diff --git a/src/Scoreboard.h b/src/Scoreboard.h index 2fae5e499..1e1973a10 100644 --- a/src/Scoreboard.h +++ b/src/Scoreboard.h @@ -153,7 +153,7 @@ public: // tolua_begin /** Returns the number of registered players */ - unsigned int GetNumPlayers(void) const; + size_t GetNumPlayers(void) const; bool AllowsFriendlyFire(void) const { return m_AllowsFriendlyFire; } bool CanSeeFriendlyInvisible(void) const { return m_CanSeeFriendlyInvisible; } @@ -248,9 +248,9 @@ public: cObjective * GetObjectiveIn(eDisplaySlot a_Slot); - unsigned int GetNumObjectives(void) const; + size_t GetNumObjectives(void) const; - unsigned int GetNumTeams(void) const; + size_t GetNumTeams(void) const; void AddPlayerScore(const AString & a_Name, cObjective::eType a_Type, cObjective::Score a_Value = 1); diff --git a/src/Simulator/DelayedFluidSimulator.cpp b/src/Simulator/DelayedFluidSimulator.cpp index bc5158d95..5ff736231 100644 --- a/src/Simulator/DelayedFluidSimulator.cpp +++ b/src/Simulator/DelayedFluidSimulator.cpp @@ -148,7 +148,7 @@ void cDelayedFluidSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_Chunk { SimulateBlock(a_Chunk, itr->x, itr->y, itr->z); } - m_TotalBlocks -= Blocks.size(); + m_TotalBlocks -= (int)Blocks.size(); Blocks.clear(); } } diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp index c4f57c86a..b8f34559f 100644 --- a/src/Simulator/SandSimulator.cpp +++ b/src/Simulator/SandSimulator.cpp @@ -64,7 +64,7 @@ void cSandSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun a_Chunk->SetBlock(itr->x, itr->y, itr->z, E_BLOCK_AIR, 0); } } - m_TotalBlocks -= ChunkData.size(); + m_TotalBlocks -= (int)ChunkData.size(); ChunkData.clear(); } diff --git a/src/StringCompression.cpp b/src/StringCompression.cpp index 2a85649a1..71d64e71e 100644 --- a/src/StringCompression.cpp +++ b/src/StringCompression.cpp @@ -11,15 +11,15 @@ /// Compresses a_Data into a_Compressed; returns Z_XXX error constants same as zlib's compress2() -int CompressString(const char * a_Data, int a_Length, AString & a_Compressed, int a_Factor) +int CompressString(const char * a_Data, size_t a_Length, AString & a_Compressed, int a_Factor) { - uLongf CompressedSize = compressBound(a_Length); + uLongf CompressedSize = compressBound((uLong)a_Length); // HACK: We're assuming that AString returns its internal buffer in its data() call and we're overwriting that buffer! // It saves us one allocation and one memcpy of the entire compressed data // It may not work on some STL implementations! (Confirmed working on MSVC 2008 & 2010) a_Compressed.resize(CompressedSize); - int errorcode = compress2( (Bytef*)a_Compressed.data(), &CompressedSize, (const Bytef*)a_Data, a_Length, a_Factor); + int errorcode = compress2((Bytef*)a_Compressed.data(), &CompressedSize, (const Bytef *)a_Data, (uLong)a_Length, a_Factor); if (errorcode != Z_OK) { return errorcode; @@ -33,14 +33,14 @@ int CompressString(const char * a_Data, int a_Length, AString & a_Compressed, in /// Uncompresses a_Data into a_Decompressed; returns Z_XXX error constants same as zlib's uncompress() -int UncompressString(const char * a_Data, int a_Length, AString & a_Uncompressed, int a_UncompressedSize) +int UncompressString(const char * a_Data, size_t a_Length, AString & a_Uncompressed, size_t a_UncompressedSize) { // HACK: We're assuming that AString returns its internal buffer in its data() call and we're overwriting that buffer! // It saves us one allocation and one memcpy of the entire compressed data // It may not work on some STL implementations! (Confirmed working on MSVC 2008 & 2010) a_Uncompressed.resize(a_UncompressedSize); uLongf UncompressedSize = (uLongf)a_UncompressedSize; // On some architectures the uLongf is different in size to int, that may be the cause of the -5 error - int errorcode = uncompress((Bytef*)a_Uncompressed.data(), &UncompressedSize, (const Bytef*)a_Data, a_Length); + int errorcode = uncompress((Bytef*)a_Uncompressed.data(), &UncompressedSize, (const Bytef*)a_Data, (uLong)a_Length); if (errorcode != Z_OK) { return errorcode; @@ -63,7 +63,7 @@ int CompressStringGZIP(const char * a_Data, size_t a_Length, AString & a_Compres z_stream strm; memset(&strm, 0, sizeof(strm)); strm.next_in = (Bytef *)a_Data; - strm.avail_in = a_Length; + strm.avail_in = (uInt)a_Length; strm.next_out = (Bytef *)Buffer; strm.avail_out = sizeof(Buffer); @@ -127,7 +127,7 @@ extern int UncompressStringGZIP(const char * a_Data, size_t a_Length, AString & z_stream strm; memset(&strm, 0, sizeof(strm)); strm.next_in = (Bytef *)a_Data; - strm.avail_in = a_Length; + strm.avail_in = (uInt)a_Length; strm.next_out = (Bytef *)Buffer; strm.avail_out = sizeof(Buffer); diff --git a/src/StringCompression.h b/src/StringCompression.h index c3a9eca91..038240797 100644 --- a/src/StringCompression.h +++ b/src/StringCompression.h @@ -10,10 +10,10 @@ /// Compresses a_Data into a_Compressed using ZLIB; returns Z_XXX error constants same as zlib's compress2() -extern int CompressString(const char * a_Data, int a_Length, AString & a_Compressed, int a_Factor); +extern int CompressString(const char * a_Data, size_t a_Length, AString & a_Compressed, int a_Factor); /// Uncompresses a_Data into a_Uncompressed; returns Z_XXX error constants same as zlib's decompress() -extern int UncompressString(const char * a_Data, int a_Length, AString & a_Uncompressed, int a_UncompressedSize); +extern int UncompressString(const char * a_Data, size_t a_Length, AString & a_Uncompressed, size_t a_UncompressedSize); /// Compresses a_Data into a_Compressed using GZIP; returns Z_OK for success or Z_XXX error constants same as zlib extern int CompressStringGZIP(const char * a_Data, size_t a_Length, AString & a_Compressed); diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 33b04505f..7488a3073 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -247,18 +247,22 @@ int NoCaseCompare(const AString & s1, const AString & s2) -unsigned int RateCompareString(const AString & s1, const AString & s2 ) +size_t RateCompareString(const AString & s1, const AString & s2) { - unsigned int MatchedLetters = 0; - unsigned int s1Length = s1.length(); + size_t MatchedLetters = 0; + size_t s1Length = s1.length(); - if( s1Length > s2.length() ) return 0; // Definitely not a match + if (s1Length > s2.length()) + { + // Definitely not a match + return 0; + } - for (unsigned int i = 0; i < s1Length; i++) + for (size_t i = 0; i < s1Length; i++) { - char c1 = (char)toupper( s1[i] ); - char c2 = (char)toupper( s2[i] ); - if( c1 == c2 ) + char c1 = (char)toupper(s1[i]); + char c2 = (char)toupper(s2[i]); + if (c1 == c2) { ++MatchedLetters; } @@ -288,11 +292,11 @@ void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & // Converts a stream of BE shorts into UTF-8 string; returns a ref to a_UTF8 -AString & RawBEToUTF8(const char * a_RawData, int a_NumShorts, AString & a_UTF8) +AString & RawBEToUTF8(const char * a_RawData, size_t a_NumShorts, AString & a_UTF8) { a_UTF8.clear(); a_UTF8.reserve(3 * a_NumShorts / 2); // a quick guess of the resulting size - for (int i = 0; i < a_NumShorts; i++) + for (size_t i = 0; i < a_NumShorts; i++) { int c = GetBEShort(&a_RawData[i * 2]); if (c < 0x80) diff --git a/src/StringUtils.h b/src/StringUtils.h index b69e47d3c..caad85aef 100644 --- a/src/StringUtils.h +++ b/src/StringUtils.h @@ -52,13 +52,13 @@ extern AString & StrToLower(AString & s); extern int NoCaseCompare(const AString & s1, const AString & s2); // tolua_export /// Case-insensitive string comparison that returns a rating of equal-ness between [0 - s1.length()] -extern unsigned int RateCompareString(const AString & s1, const AString & s2 ); +extern size_t RateCompareString(const AString & s1, const AString & s2); /// Replaces *each* occurence of iNeedle in iHayStack with iReplaceWith extern void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & iReplaceWith); // tolua_export /// Converts a stream of BE shorts into UTF-8 string; returns a ref to a_UTF8 -extern AString & RawBEToUTF8(const char * a_RawData, int a_NumShorts, AString & a_UTF8); +extern AString & RawBEToUTF8(const char * a_RawData, size_t a_NumShorts, AString & a_UTF8); /// Converts a UTF-8 string into a UTF-16 BE string, packing that back into AString; return a ref to a_UTF16 extern AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a_UTF16); diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 13a9f9b92..788974f9c 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -891,7 +891,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) while ((DamageDiff > 0) && (x < SecondInput.m_ItemCount)) { Input.m_ItemDamage -= DamageDiff; - NeedExp += std::max(1, DamageDiff / 100) + Input.m_Enchantments.Count(); + NeedExp += std::max(1, DamageDiff / 100) + (int)Input.m_Enchantments.Count(); DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4); ++x; diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 4991f0147..46885390b 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -591,7 +591,7 @@ void cWindow::OnLeftPaintEnd(cPlayer & a_Player) const cSlotNums & SlotNums = a_Player.GetInventoryPaintSlots(); cItem ToDistribute(a_Player.GetDraggingItem()); - int ToEachSlot = (int)ToDistribute.m_ItemCount / SlotNums.size(); + int ToEachSlot = (int)ToDistribute.m_ItemCount / (int)SlotNums.size(); int NumDistributed = DistributeItemToSlots(a_Player, ToDistribute, ToEachSlot, SlotNums); diff --git a/src/World.cpp b/src/World.cpp index 5ac8e0a6e..b20e017bc 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2402,13 +2402,13 @@ bool cWorld::DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback) { cPlayer * BestMatch = NULL; - unsigned int BestRating = 0; - unsigned int NameLength = a_PlayerNameHint.length(); + size_t BestRating = 0; + size_t NameLength = a_PlayerNameHint.length(); cCSLock Lock(m_CSPlayers); for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { - unsigned int Rating = RateCompareString (a_PlayerNameHint, (*itr)->GetName()); + size_t Rating = RateCompareString (a_PlayerNameHint, (*itr)->GetName()); if (Rating >= BestRating) { BestMatch = *itr; @@ -2422,7 +2422,6 @@ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCa if (BestMatch != NULL) { - LOG("Compared %s and %s with rating %i", a_PlayerNameHint.c_str(), BestMatch->GetName().c_str(), BestRating); return a_Callback.Item (BestMatch); } return false; diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index ac9a21205..52e998f88 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -38,7 +38,7 @@ -cParsedNBT::cParsedNBT(const char * a_Data, int a_Length) : +cParsedNBT::cParsedNBT(const char * a_Data, size_t a_Length) : m_Data(a_Data), m_Length(a_Length), m_Pos(0) @@ -99,8 +99,10 @@ bool cParsedNBT::ReadString(int & a_StringStart, int & a_StringLen) bool cParsedNBT::ReadCompound(void) { + ASSERT(m_Tags.size() > 0); + // Reads the latest tag as a compound - int ParentIdx = m_Tags.size() - 1; + int ParentIdx = (int)m_Tags.size() - 1; int PrevSibling = -1; for (;;) { @@ -114,13 +116,13 @@ bool cParsedNBT::ReadCompound(void) m_Tags.push_back(cFastNBTTag(TagType, ParentIdx, PrevSibling)); if (PrevSibling >= 0) { - m_Tags[PrevSibling].m_NextSibling = m_Tags.size() - 1; + m_Tags[PrevSibling].m_NextSibling = (int)m_Tags.size() - 1; } else { - m_Tags[ParentIdx].m_FirstChild = m_Tags.size() - 1; + m_Tags[ParentIdx].m_FirstChild = (int)m_Tags.size() - 1; } - PrevSibling = m_Tags.size() - 1; + PrevSibling = (int)m_Tags.size() - 1; RETURN_FALSE_IF_FALSE(ReadString(m_Tags.back().m_NameStart, m_Tags.back().m_NameLength)); RETURN_FALSE_IF_FALSE(ReadTag()); } // while (true) @@ -146,20 +148,20 @@ bool cParsedNBT::ReadList(eTagType a_ChildrenType) } // Read items: - int ParentIdx = m_Tags.size() - 1; + int ParentIdx = (int)m_Tags.size() - 1; int PrevSibling = -1; for (int i = 0; i < Count; i++) { m_Tags.push_back(cFastNBTTag(a_ChildrenType, ParentIdx, PrevSibling)); if (PrevSibling >= 0) { - m_Tags[PrevSibling].m_NextSibling = m_Tags.size() - 1; + m_Tags[PrevSibling].m_NextSibling = (int)m_Tags.size() - 1; } else { - m_Tags[ParentIdx].m_FirstChild = m_Tags.size() - 1; + m_Tags[ParentIdx].m_FirstChild = (int)m_Tags.size() - 1; } - PrevSibling = m_Tags.size() - 1; + PrevSibling = (int)m_Tags.size() - 1; RETURN_FALSE_IF_FALSE(ReadTag()); } // for (i) m_Tags[ParentIdx].m_LastChild = PrevSibling; @@ -336,7 +338,7 @@ cFastNBTWriter::cFastNBTWriter(const AString & a_RootTagName) : m_Stack[0].m_Type = TAG_Compound; m_Result.reserve(100 * 1024); m_Result.push_back(TAG_Compound); - WriteString(a_RootTagName.data(), a_RootTagName.size()); + WriteString(a_RootTagName.data(), (UInt16)a_RootTagName.size()); } @@ -389,7 +391,7 @@ void cFastNBTWriter::BeginList(const AString & a_Name, eTagType a_ChildrenType) ++m_CurrentStack; m_Stack[m_CurrentStack].m_Type = TAG_List; - m_Stack[m_CurrentStack].m_Pos = m_Result.size() - 4; + m_Stack[m_CurrentStack].m_Pos = (int)m_Result.size() - 4; m_Stack[m_CurrentStack].m_Count = 0; m_Stack[m_CurrentStack].m_ItemType = a_ChildrenType; } @@ -493,7 +495,7 @@ void cFastNBTWriter::AddString(const AString & a_Name, const AString & a_Value) void cFastNBTWriter::AddByteArray(const AString & a_Name, const char * a_Value, size_t a_NumElements) { TagCommon(a_Name, TAG_ByteArray); - Int32 len = htonl(a_NumElements); + u_long len = htonl((u_long)a_NumElements); m_Result.append((const char *)&len, 4); m_Result.append(a_Value, a_NumElements); } @@ -505,7 +507,7 @@ void cFastNBTWriter::AddByteArray(const AString & a_Name, const char * a_Value, void cFastNBTWriter::AddIntArray(const AString & a_Name, const int * a_Value, size_t a_NumElements) { TagCommon(a_Name, TAG_IntArray); - Int32 len = htonl(a_NumElements); + u_long len = htonl((u_long)a_NumElements); size_t cap = m_Result.capacity(); size_t size = m_Result.length(); if ((cap - size) < (4 + a_NumElements * 4)) @@ -534,7 +536,7 @@ void cFastNBTWriter::Finish(void) -void cFastNBTWriter::WriteString(const char * a_Data, short a_Length) +void cFastNBTWriter::WriteString(const char * a_Data, UInt16 a_Length) { Int16 Len = htons(a_Length); m_Result.append((const char *)&Len, 2); diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h index bcf93228f..7b0af4927 100644 --- a/src/WorldStorage/FastNBT.h +++ b/src/WorldStorage/FastNBT.h @@ -114,7 +114,7 @@ Each primitive tag also stores the length of the contained data, in bytes. class cParsedNBT { public: - cParsedNBT(const char * a_Data, int a_Length); + cParsedNBT(const char * a_Data, size_t a_Length); bool IsValid(void) const {return m_IsValid; } @@ -251,7 +251,7 @@ public: protected: const char * m_Data; - int m_Length; + size_t m_Length; std::vector m_Tags; bool m_IsValid; // True if parsing succeeded @@ -319,7 +319,7 @@ protected: bool IsStackTopCompound(void) const { return (m_Stack[m_CurrentStack].m_Type == TAG_Compound); } - void WriteString(const char * a_Data, short a_Length); + void WriteString(const char * a_Data, UInt16 a_Length); inline void TagCommon(const AString & a_Name, eTagType a_Type) { @@ -330,7 +330,7 @@ protected: { // Compound: add the type and name: m_Result.push_back((char)a_Type); - WriteString(a_Name.c_str(), (short)a_Name.length()); + WriteString(a_Name.c_str(), (UInt16)a_Name.length()); } else { diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp index 9d594a084..2e356b172 100644 --- a/src/WorldStorage/SchematicFileSerializer.cpp +++ b/src/WorldStorage/SchematicFileSerializer.cpp @@ -230,7 +230,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP } // Copy the block types and metas: - int NumBytes = a_BlockArea.GetBlockCount(); + int NumBytes = (int)a_BlockArea.GetBlockCount(); if (a_NBT.GetDataLength(TBlockTypes) < NumBytes) { LOG("BlockTypes truncated in the schematic file (exp %d, got %d bytes). Loading partial.", @@ -242,7 +242,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP if (AreMetasPresent) { - int NumBytes = a_BlockArea.GetBlockCount(); + int NumBytes = (int)a_BlockArea.GetBlockCount(); if (a_NBT.GetDataLength(TBlockMetas) < NumBytes) { LOG("BlockMetas truncated in the schematic file (exp %d, got %d bytes). Loading partial.", diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index a98ed81f7..c6b0472d0 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -96,7 +96,7 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) : gzFile gz = gzopen((FILE_IO_PREFIX + fnam).c_str(), "wb"); if (gz != NULL) { - gzwrite(gz, Writer.GetResult().data(), Writer.GetResult().size()); + gzwrite(gz, Writer.GetResult().data(), (unsigned)Writer.GetResult().size()); } gzclose(gz); } @@ -252,7 +252,7 @@ bool cWSSAnvil::LoadChunkFromData(const cChunkCoords & a_Chunk, const AString & strm.next_out = (Bytef *)Uncompressed; strm.avail_out = sizeof(Uncompressed); strm.next_in = (Bytef *)a_Data.data(); - strm.avail_in = a_Data.size(); + strm.avail_in = (uInt)a_Data.size(); int res = inflate(&strm, Z_FINISH); inflateEnd(&strm); if (res != Z_STREAM_END) @@ -2682,7 +2682,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri // Store the chunk data: m_File.Seek(ChunkSector * 4096); - unsigned ChunkSize = htonl(a_Data.size() + 1); + u_long ChunkSize = htonl((u_long)a_Data.size() + 1); if (m_File.Write(&ChunkSize, 4) != 4) { LOGWARNING("Cannot save chunk [%d, %d], writing(1) data to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str()); @@ -2706,7 +2706,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri m_File.Write(Padding, 4096 - (BytesWritten % 4096)); // Store the header: - ChunkSize = (a_Data.size() + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size *up* to nearest 4KB sector, make it a sector number + ChunkSize = ((u_long)a_Data.size() + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size *up* to nearest 4KB sector, make it a sector number ASSERT(ChunkSize < 256); m_Header[LocalX + 32 * LocalZ] = htonl((ChunkSector << 8) | ChunkSize); if (m_File.Seek(0) < 0) diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index 359bac4a8..6d06b8fe3 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -601,7 +601,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() // Decompress the data: AString UncompressedData; { - int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, UncompressedSize); + int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, (size_t)UncompressedSize); if (errorcode != Z_OK) { LOGERROR("Error %d decompressing data for chunk [%d, %d]", @@ -681,7 +681,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() // Re-compress data AString CompressedData; { - int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData,m_CompressionFactor); + int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData, m_CompressionFactor); if (errorcode != Z_OK) { LOGERROR("Error %d compressing data for chunk [%d, %d]", @@ -693,9 +693,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() } // Save into file's cache - Header->m_UncompressedSize = Converted.size(); - Header->m_CompressedSize = CompressedData.size(); - NewDataContents.append( CompressedData ); + Header->m_UncompressedSize = (int)Converted.size(); + Header->m_CompressedSize = (int)CompressedData.size(); + NewDataContents.append(CompressedData); } // Done converting @@ -731,7 +731,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() Offset += Header->m_CompressedSize; // Crude data integrity check: - const int ExpectedSize = (16*256*16)*2 + (16*256*16)/2; // For version 2 + const int ExpectedSize = (16 * 256 * 16) * 2 + (16 * 256 * 16) / 2; // For version 2 if (UncompressedSize < ExpectedSize) { LOGWARNING("Chunk [%d, %d] has too short decompressed data (%d bytes out of %d needed), erasing", @@ -745,7 +745,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() // Decompress the data: AString UncompressedData; { - int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, UncompressedSize); + int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, (size_t)UncompressedSize); if (errorcode != Z_OK) { LOGERROR("Error %d decompressing data for chunk [%d, %d]", @@ -829,9 +829,9 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() } // Save into file's cache - Header->m_UncompressedSize = Converted.size(); - Header->m_CompressedSize = CompressedData.size(); - NewDataContents.append( CompressedData ); + Header->m_UncompressedSize = (int)Converted.size(); + Header->m_CompressedSize = (int)CompressedData.size(); + NewDataContents.append(CompressedData); } // Done converting @@ -861,7 +861,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre // Decompress the data: AString UncompressedData; - int errorcode = UncompressString(a_Data.data(), a_Data.size(), UncompressedData, a_UncompressedSize); + int errorcode = UncompressString(a_Data.data(), a_Data.size(), UncompressedData, (size_t)a_UncompressedSize); if (errorcode != Z_OK) { LOGERROR("Error %d decompressing data for chunk [%d, %d]", @@ -873,7 +873,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre if (a_UncompressedSize != (int)UncompressedData.size()) { - LOGWARNING("Uncompressed data size differs (exp %d bytes, got " SIZE_T_FMT ") for chunk [%d, %d]", + LOGWARNING("Uncompressed data size differs (exp %d bytes, got " SIZE_T_FMT ") for chunk [%d, %d]", a_UncompressedSize, UncompressedData.size(), a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ ); -- cgit v1.2.3 From ee680990ba12b8d272a34e45f372893f2525c868 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 8 May 2014 21:10:55 +0200 Subject: Fixed cGridStructGen. Now cNetherFortGen works with the new architecture. --- src/Generating/GridStructGen.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp index 2f064d3a0..3bbc89054 100644 --- a/src/Generating/GridStructGen.cpp +++ b/src/Generating/GridStructGen.cpp @@ -39,29 +39,17 @@ void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructur int MinGridZ = MinBlockZ / m_GridSizeZ; int MaxGridX = (MaxBlockX + m_GridSizeX - 1) / m_GridSizeX; int MaxGridZ = (MaxBlockZ + m_GridSizeZ - 1) / m_GridSizeZ; - if (MinBlockX < 0) - { - --MinGridX; - } - if (MinBlockZ < 0) - { - --MinGridZ; - } - if (MaxBlockX < 0) - { - --MaxGridX; - } - if (MaxBlockZ < 0) - { - --MaxGridZ; - } + int MinX = MinGridX * m_GridSizeX; + int MaxX = MaxGridX * m_GridSizeX; + int MinZ = MinGridZ * m_GridSizeZ; + int MaxZ = MaxGridZ * m_GridSizeZ; // Walk the cache, move each structure that we want into a_Structures: for (cStructurePtrs::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end;) { if ( - ((*itr)->m_OriginX >= MinBlockX) && ((*itr)->m_OriginX < MaxBlockX) && - ((*itr)->m_OriginZ >= MinBlockZ) && ((*itr)->m_OriginZ < MaxBlockZ) + ((*itr)->m_OriginX >= MinX) && ((*itr)->m_OriginX < MaxX) && + ((*itr)->m_OriginZ >= MinZ) && ((*itr)->m_OriginZ < MaxZ) ) { // want -- cgit v1.2.3 From 14543aa3fc204f38d0ab402d4c257d533619a983 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 9 May 2014 10:59:33 +0200 Subject: Mineshafts generator rewritten to use GridStructGen. --- src/Generating/MineShafts.cpp | 155 ++++++------------------------------------ src/Generating/MineShafts.h | 34 ++++----- 2 files changed, 33 insertions(+), 156 deletions(-) (limited to 'src') diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index af63e549b..7b26c2b62 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -234,10 +234,12 @@ protected: -class cStructGenMineShafts::cMineShaftSystem +class cStructGenMineShafts::cMineShaftSystem : + public cGridStructGen::cStructure { + typedef cGridStructGen::cStructure super; + public: - int m_BlockX, m_BlockZ; ///< The pivot point on which the system is generated int m_GridSize; ///< Maximum offset of the dirtroom from grid center, * 2, in each direction int m_MaxRecursion; ///< Maximum recursion level (initialized from cStructGenMineShafts::m_MaxRecursion) int m_ProbLevelCorridor; ///< Probability level of a branch object being the corridor @@ -249,17 +251,15 @@ public: cMineShafts m_MineShafts; ///< List of cMineShaft descendants that comprise this system cCuboid m_BoundingBox; ///< Bounding box into which all of the components need to fit - /// Creates and generates the entire system + + /** Creates and generates the entire system */ cMineShaftSystem( - int a_BlockX, int a_BlockZ, int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise, + int a_OriginX, int a_OriginZ, int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise, int a_ProbLevelCorridor, int a_ProbLevelCrossing, int a_ProbLevelStaircase ); ~cMineShaftSystem(); - /// Carves the system into the chunk data - void ProcessChunk(cChunkDesc & a_Chunk); - /** Creates new cMineShaft descendant connected at the specified point, heading the specified direction, if it fits, appends it to the list and calls its AppendBranches() */ @@ -269,8 +269,11 @@ public: int a_RecursionLevel ); - /// Returns true if none of the objects in m_MineShafts intersect with the specified bounding box and the bounding box is valid + /** Returns true if none of the objects in m_MineShafts intersect with the specified bounding box and the bounding box is valid */ bool CanAppend(const cCuboid & a_BoundingBox); + + // cGridStructGen::cStructure overrides: + virtual void DrawIntoChunk(cChunkDesc & a_Chunk); } ; @@ -281,11 +284,10 @@ public: // cStructGenMineShafts::cMineShaftSystem: cStructGenMineShafts::cMineShaftSystem::cMineShaftSystem( - int a_BlockX, int a_BlockZ, int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise, + int a_OriginX, int a_OriginZ, int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise, int a_ProbLevelCorridor, int a_ProbLevelCrossing, int a_ProbLevelStaircase ) : - m_BlockX(a_BlockX), - m_BlockZ(a_BlockZ), + super(a_OriginX, a_OriginZ), m_GridSize(a_GridSize), m_MaxRecursion(8), // TODO: settable m_ProbLevelCorridor(a_ProbLevelCorridor), @@ -330,7 +332,7 @@ cStructGenMineShafts::cMineShaftSystem::~cMineShaftSystem() -void cStructGenMineShafts::cMineShaftSystem::ProcessChunk(cChunkDesc & a_Chunk) +void cStructGenMineShafts::cMineShaftSystem::DrawIntoChunk(cChunkDesc & a_Chunk) { for (cMineShafts::const_iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr) { @@ -409,15 +411,15 @@ cMineShaftDirtRoom::cMineShaftDirtRoom(cStructGenMineShafts::cMineShaftSystem & super(a_Parent, mskDirtRoom) { // Make the room of random size, min 10 x 4 x 10; max 18 x 12 x 18: - int rnd = a_Noise.IntNoise3DInt(a_Parent.m_BlockX, 0, a_Parent.m_BlockZ) / 7; + int rnd = a_Noise.IntNoise3DInt(a_Parent.m_OriginX, 0, a_Parent.m_OriginZ) / 7; int OfsX = (rnd % a_Parent.m_GridSize) - a_Parent.m_GridSize / 2; rnd >>= 12; int OfsZ = (rnd % a_Parent.m_GridSize) - a_Parent.m_GridSize / 2; - rnd = a_Noise.IntNoise3DInt(a_Parent.m_BlockX, 1000, a_Parent.m_BlockZ) / 11; - m_BoundingBox.p1.x = a_Parent.m_BlockX + OfsX; + rnd = a_Noise.IntNoise3DInt(a_Parent.m_OriginX, 1000, a_Parent.m_OriginZ) / 11; + m_BoundingBox.p1.x = a_Parent.m_OriginX + OfsX; m_BoundingBox.p2.x = m_BoundingBox.p1.x + 10 + (rnd % 8); rnd >>= 4; - m_BoundingBox.p1.z = a_Parent.m_BlockZ + OfsZ; + m_BoundingBox.p1.z = a_Parent.m_OriginZ + OfsZ; m_BoundingBox.p2.z = m_BoundingBox.p1.z + 10 + (rnd % 8); rnd >>= 4; m_BoundingBox.p1.y = 20; @@ -1287,6 +1289,7 @@ cStructGenMineShafts::cStructGenMineShafts( int a_Seed, int a_GridSize, int a_MaxSystemSize, int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase ) : + super(a_Seed, a_GridSize, a_GridSize, 120 + a_MaxSystemSize * 10, 120 + a_MaxSystemSize * 10, 100), m_Noise(a_Seed), m_GridSize(a_GridSize), m_MaxSystemSize(a_MaxSystemSize), @@ -1300,125 +1303,9 @@ cStructGenMineShafts::cStructGenMineShafts( -cStructGenMineShafts::~cStructGenMineShafts() -{ - ClearCache(); -} - - - - - -void cStructGenMineShafts::ClearCache(void) +cGridStructGen::cStructurePtr cStructGenMineShafts::CreateStructure(int a_OriginX, int a_OriginZ) { - for (cMineShaftSystems::const_iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end; ++itr) - { - delete *itr; - } // for itr - m_Cache[] - m_Cache.clear(); -} - - - - - -void cStructGenMineShafts::GetMineShaftSystemsForChunk( - int a_ChunkX, int a_ChunkZ, - cStructGenMineShafts::cMineShaftSystems & a_MineShafts -) -{ - int BaseX = a_ChunkX * cChunkDef::Width / m_GridSize; - int BaseZ = a_ChunkZ * cChunkDef::Width / m_GridSize; - if (BaseX < 0) - { - --BaseX; - } - if (BaseZ < 0) - { - --BaseZ; - } - BaseX -= NEIGHBORHOOD_SIZE / 2; - BaseZ -= NEIGHBORHOOD_SIZE / 2; - - // Walk the cache, move each cave system that we want into a_Mineshafts: - int StartX = BaseX * m_GridSize; - int EndX = (BaseX + NEIGHBORHOOD_SIZE + 1) * m_GridSize; - int StartZ = BaseZ * m_GridSize; - int EndZ = (BaseZ + NEIGHBORHOOD_SIZE + 1) * m_GridSize; - for (cMineShaftSystems::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end;) - { - if ( - ((*itr)->m_BlockX >= StartX) && ((*itr)->m_BlockX < EndX) && - ((*itr)->m_BlockZ >= StartZ) && ((*itr)->m_BlockZ < EndZ) - ) - { - // want - a_MineShafts.push_back(*itr); - itr = m_Cache.erase(itr); - } - else - { - // don't want - ++itr; - } - } // for itr - m_Cache[] - - for (int x = 0; x < NEIGHBORHOOD_SIZE; x++) - { - int RealX = (BaseX + x) * m_GridSize; - for (int z = 0; z < NEIGHBORHOOD_SIZE; z++) - { - int RealZ = (BaseZ + z) * m_GridSize; - bool Found = false; - for (cMineShaftSystems::const_iterator itr = a_MineShafts.begin(), end = a_MineShafts.end(); itr != end; ++itr) - { - if (((*itr)->m_BlockX == RealX) && ((*itr)->m_BlockZ == RealZ)) - { - Found = true; - break; - } - } // for itr - a_Mineshafts - if (!Found) - { - a_MineShafts.push_back(new cMineShaftSystem(RealX, RealZ, m_GridSize, m_MaxSystemSize, m_Noise, m_ProbLevelCorridor, m_ProbLevelCrossing, m_ProbLevelStaircase)); - } - } // for z - } // for x - - // Copy a_MineShafts into m_Cache to the beginning: - cMineShaftSystems MineShaftsCopy(a_MineShafts); - m_Cache.splice(m_Cache.begin(), MineShaftsCopy, MineShaftsCopy.begin(), MineShaftsCopy.end()); - - // Trim the cache if it's too long: - if (m_Cache.size() > 100) - { - cMineShaftSystems::iterator itr = m_Cache.begin(); - std::advance(itr, 100); - for (cMineShaftSystems::iterator end = m_Cache.end(); itr != end; ++itr) - { - delete *itr; - } - itr = m_Cache.begin(); - std::advance(itr, 100); - m_Cache.erase(itr, m_Cache.end()); - } -} - - - - - - -void cStructGenMineShafts::GenFinish(cChunkDesc & a_ChunkDesc) -{ - int ChunkX = a_ChunkDesc.GetChunkX(); - int ChunkZ = a_ChunkDesc.GetChunkZ(); - cMineShaftSystems MineShafts; - GetMineShaftSystemsForChunk(ChunkX, ChunkZ, MineShafts); - for (cMineShaftSystems::const_iterator itr = MineShafts.begin(); itr != MineShafts.end(); ++itr) - { - (*itr)->ProcessChunk(a_ChunkDesc); - } // for itr - MineShafts[] + return cStructurePtr(new cMineShaftSystem(a_OriginX, a_OriginZ, m_GridSize, m_MaxSystemSize, m_Noise, m_ProbLevelCorridor, m_ProbLevelCrossing, m_ProbLevelStaircase)); } diff --git a/src/Generating/MineShafts.h b/src/Generating/MineShafts.h index ba32e75ad..c29b6cdac 100644 --- a/src/Generating/MineShafts.h +++ b/src/Generating/MineShafts.h @@ -9,7 +9,7 @@ #pragma once -#include "ComposableGenerator.h" +#include "GridStructGen.h" #include "../Noise.h" @@ -17,16 +17,16 @@ class cStructGenMineShafts : - public cFinishGen + public cGridStructGen { + typedef cGridStructGen super; + public: cStructGenMineShafts( int a_Seed, int a_GridSize, int a_MaxSystemSize, int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase ); - virtual ~cStructGenMineShafts(); - protected: friend class cMineShaft; friend class cMineShaftDirtRoom; @@ -34,26 +34,16 @@ protected: friend class cMineShaftCrossing; friend class cMineShaftStaircase; class cMineShaftSystem; // fwd: MineShafts.cpp - typedef std::list cMineShaftSystems; - cNoise m_Noise; - int m_GridSize; ///< Average spacing of the systems - int m_MaxSystemSize; ///< Maximum blcok size of a mineshaft system - int m_ProbLevelCorridor; ///< Probability level of a branch object being the corridor - int m_ProbLevelCrossing; ///< Probability level of a branch object being the crossing, minus Corridor - int m_ProbLevelStaircase; ///< Probability level of a branch object being the staircase, minus Crossing - cMineShaftSystems m_Cache; ///< Cache of the most recently used systems. MoveToFront used. + cNoise m_Noise; + int m_GridSize; ///< Average spacing of the systems + int m_MaxSystemSize; ///< Maximum blcok size of a mineshaft system + int m_ProbLevelCorridor; ///< Probability level of a branch object being the corridor + int m_ProbLevelCrossing; ///< Probability level of a branch object being the crossing, minus Corridor + int m_ProbLevelStaircase; ///< Probability level of a branch object being the staircase, minus Crossing - /// Clears everything from the cache - void ClearCache(void); - - /** Returns all systems that *may* intersect the given chunk. - All the systems are valid until the next call to this function (which may delete some of the pointers). - */ - void GetMineShaftSystemsForChunk(int a_ChunkX, int a_ChunkZ, cMineShaftSystems & a_MineShaftSystems); - - // cFinishGen overrides: - virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; + // cGridStructGen overrides: + virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; } ; -- cgit v1.2.3 From 95ead1128f85b2f0935c6c0b575a13acbec27b6b Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 9 May 2014 11:16:13 +0200 Subject: cWormNestCaves rewritten using cGridStructGen. Ref.: #987. --- src/Generating/Caves.cpp | 230 +++++------------------------------------------ src/Generating/Caves.h | 22 ++--- 2 files changed, 29 insertions(+), 223 deletions(-) (limited to 'src') diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index 6df22a14a..48663c21a 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -122,27 +122,19 @@ typedef std::vector cCaveTunnels; /// A collection of connected tunnels, possibly branching. -class cStructGenWormNestCaves::cCaveSystem +class cStructGenWormNestCaves::cCaveSystem : + public cGridStructGen::cStructure { + typedef cGridStructGen::cStructure super; + public: // The generating block position; is read directly in cStructGenWormNestCaves::GetCavesForChunk() int m_BlockX; int m_BlockZ; - cCaveSystem(int a_BlockX, int a_BlockZ, int a_MaxOffset, int a_Size, cNoise & a_Noise); + cCaveSystem(int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise); ~cCaveSystem(); - /// Carves the cave system into the chunk specified - void ProcessChunk( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, - cChunkDef::HeightMap & a_HeightMap - ); - - #ifdef _DEBUG - AString ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const; - #endif // _DEBUG - protected: int m_Size; cCaveTunnels m_Tunnels; @@ -157,6 +149,9 @@ protected: /// Returns a radius based on the location provided. int GetRadius(cNoise & a_Noise, int a_OriginX, int a_OriginY, int a_OriginZ); + + // cGridStructGen::cStructure overrides: + virtual void DrawIntoChunk(cChunkDesc & a_ChunkDesc) override; } ; @@ -586,17 +581,16 @@ AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) cons /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cStructGenWormNestCaves::cCaveSystem: -cStructGenWormNestCaves::cCaveSystem::cCaveSystem(int a_BlockX, int a_BlockZ, int a_MaxOffset, int a_Size, cNoise & a_Noise) : - m_BlockX(a_BlockX), - m_BlockZ(a_BlockZ), +cStructGenWormNestCaves::cCaveSystem::cCaveSystem(int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise) : + super(a_OriginX, a_OriginZ), m_Size(a_Size) { - int Num = 1 + a_Noise.IntNoise2DInt(a_BlockX, a_BlockZ) % 3; + int Num = 1 + a_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) % 3; for (int i = 0; i < Num; i++) { - int OriginX = a_BlockX + (a_Noise.IntNoise3DInt(13 * a_BlockX, 17 * a_BlockZ, 11 * i) / 19) % a_MaxOffset; - int OriginZ = a_BlockZ + (a_Noise.IntNoise3DInt(17 * a_BlockX, 13 * a_BlockZ, 11 * i) / 23) % a_MaxOffset; - int OriginY = 20 + (a_Noise.IntNoise3DInt(19 * a_BlockX, 13 * a_BlockZ, 11 * i) / 17) % 20; + int OriginX = a_OriginX + (a_Noise.IntNoise3DInt(13 * a_OriginX, 17 * a_OriginZ, 11 * i) / 19) % a_MaxOffset; + int OriginZ = a_OriginZ + (a_Noise.IntNoise3DInt(17 * a_OriginX, 13 * a_OriginZ, 11 * i) / 23) % a_MaxOffset; + int OriginY = 20 + (a_Noise.IntNoise3DInt(19 * a_OriginX, 13 * a_OriginZ, 11 * i) / 17) % 20; // Generate three branches from the origin point: // The tunnels generated depend on X, Y, Z and Branches, @@ -622,64 +616,17 @@ cStructGenWormNestCaves::cCaveSystem::~cCaveSystem() -void cStructGenWormNestCaves::cCaveSystem::ProcessChunk( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, - cChunkDef::HeightMap & a_HeightMap -) -{ - for (cCaveTunnels::const_iterator itr = m_Tunnels.begin(), end = m_Tunnels.end(); itr != end; ++itr) - { - (*itr)->ProcessChunk(a_ChunkX, a_ChunkZ, a_BlockTypes, a_HeightMap); - } // for itr - m_Tunnels[] -} - - - - - -#ifdef _DEBUG -AString cStructGenWormNestCaves::cCaveSystem::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const +void cStructGenWormNestCaves::cCaveSystem::DrawIntoChunk(cChunkDesc & a_ChunkDesc) { - AString SVG; - SVG.reserve(512 * 1024); + int ChunkX = a_ChunkDesc.GetChunkX(); + int ChunkZ = a_ChunkDesc.GetChunkZ(); + cChunkDef::BlockTypes & BlockTypes = a_ChunkDesc.GetBlockTypes(); + cChunkDef::HeightMap & HeightMap = a_ChunkDesc.GetHeightMap(); for (cCaveTunnels::const_iterator itr = m_Tunnels.begin(), end = m_Tunnels.end(); itr != end; ++itr) { - SVG.append((*itr)->ExportAsSVG(a_Color, a_OffsetX, a_OffsetZ)); + (*itr)->ProcessChunk(ChunkX, ChunkZ, BlockTypes, HeightMap); } // for itr - m_Tunnels[] - - // Base point highlight: - AppendPrintf(SVG, "\n", - a_OffsetX + m_BlockX - 5, a_OffsetZ + m_BlockZ, a_OffsetX + m_BlockX + 5, a_OffsetZ + m_BlockZ - ); - AppendPrintf(SVG, "\n", - a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ - 5, a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ + 5 - ); - - // A gray line from the base point to the first point of the ravine, for identification: - AppendPrintf(SVG, "\n", - a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ, - a_OffsetX + m_Tunnels.front()->m_Points.front().m_BlockX, - a_OffsetZ + m_Tunnels.front()->m_Points.front().m_BlockZ - ); - - // Offset guides: - if (a_OffsetX > 0) - { - AppendPrintf(SVG, "\n", - a_OffsetX, a_OffsetX - ); - } - if (a_OffsetZ > 0) - { - AppendPrintf(SVG, "\n", - a_OffsetZ, a_OffsetZ - ); - } - - return SVG; } -#endif // _DEBUG @@ -750,142 +697,9 @@ int cStructGenWormNestCaves::cCaveSystem::GetRadius(cNoise & a_Noise, int a_Orig /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cStructGenWormNestCaves: -cStructGenWormNestCaves::~cStructGenWormNestCaves() -{ - ClearCache(); -} - - - - - -void cStructGenWormNestCaves::ClearCache(void) -{ - for (cCaveSystems::const_iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end; ++itr) - { - delete *itr; - } // for itr - m_Cache[] - m_Cache.clear(); -} - - - - - -void cStructGenWormNestCaves::GenFinish(cChunkDesc & a_ChunkDesc) +cGridStructGen::cStructurePtr cStructGenWormNestCaves::CreateStructure(int a_OriginX, int a_OriginZ) { - int ChunkX = a_ChunkDesc.GetChunkX(); - int ChunkZ = a_ChunkDesc.GetChunkZ(); - cCaveSystems Caves; - GetCavesForChunk(ChunkX, ChunkZ, Caves); - for (cCaveSystems::const_iterator itr = Caves.begin(); itr != Caves.end(); ++itr) - { - (*itr)->ProcessChunk(ChunkX, ChunkZ, a_ChunkDesc.GetBlockTypes(), a_ChunkDesc.GetHeightMap()); - } // for itr - Caves[] -} - - - - - -void cStructGenWormNestCaves::GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cStructGenWormNestCaves::cCaveSystems & a_Caves) -{ - int BaseX = a_ChunkX * cChunkDef::Width / m_Grid; - int BaseZ = a_ChunkZ * cChunkDef::Width / m_Grid; - if (BaseX < 0) - { - --BaseX; - } - if (BaseZ < 0) - { - --BaseZ; - } - BaseX -= NEIGHBORHOOD_SIZE / 2; - BaseZ -= NEIGHBORHOOD_SIZE / 2; - - // Walk the cache, move each cave system that we want into a_Caves: - int StartX = BaseX * m_Grid; - int EndX = (BaseX + NEIGHBORHOOD_SIZE + 1) * m_Grid; - int StartZ = BaseZ * m_Grid; - int EndZ = (BaseZ + NEIGHBORHOOD_SIZE + 1) * m_Grid; - for (cCaveSystems::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end;) - { - if ( - ((*itr)->m_BlockX >= StartX) && ((*itr)->m_BlockX < EndX) && - ((*itr)->m_BlockZ >= StartZ) && ((*itr)->m_BlockZ < EndZ) - ) - { - // want - a_Caves.push_back(*itr); - itr = m_Cache.erase(itr); - } - else - { - // don't want - ++itr; - } - } // for itr - m_Cache[] - - for (int x = 0; x < NEIGHBORHOOD_SIZE; x++) - { - int RealX = (BaseX + x) * m_Grid; - for (int z = 0; z < NEIGHBORHOOD_SIZE; z++) - { - int RealZ = (BaseZ + z) * m_Grid; - bool Found = false; - for (cCaveSystems::const_iterator itr = a_Caves.begin(), end = a_Caves.end(); itr != end; ++itr) - { - if (((*itr)->m_BlockX == RealX) && ((*itr)->m_BlockZ == RealZ)) - { - Found = true; - break; - } - } - if (!Found) - { - a_Caves.push_back(new cCaveSystem(RealX, RealZ, m_MaxOffset, m_Size, m_Noise)); - } - } - } - - // Copy a_Caves into m_Cache to the beginning: - cCaveSystems CavesCopy(a_Caves); - m_Cache.splice(m_Cache.begin(), CavesCopy, CavesCopy.begin(), CavesCopy.end()); - - // Trim the cache if it's too long: - if (m_Cache.size() > 100) - { - cCaveSystems::iterator itr = m_Cache.begin(); - std::advance(itr, 100); - for (cCaveSystems::iterator end = m_Cache.end(); itr != end; ++itr) - { - delete *itr; - } - itr = m_Cache.begin(); - std::advance(itr, 100); - m_Cache.erase(itr, m_Cache.end()); - } - - /* - // Uncomment this block for debugging the caves' shapes in 2D using an SVG export - #ifdef _DEBUG - AString SVG; - SVG.append("\n\n"); - SVG.reserve(2 * 1024 * 1024); - for (cCaveSystems::const_iterator itr = a_Caves.begin(), end = a_Caves.end(); itr != end; ++itr) - { - int Color = 0x10 * abs((*itr)->m_BlockX / m_Grid); - Color |= 0x1000 * abs((*itr)->m_BlockZ / m_Grid); - SVG.append((*itr)->ExportAsSVG(Color, 512, 512)); - } - SVG.append("\n"); - - AString fnam; - Printf(fnam, "wnc\\%03d_%03d.svg", a_ChunkX, a_ChunkZ); - cFile File(fnam, cFile::fmWrite); - File.Write(SVG.c_str(), SVG.size()); - #endif // _DEBUG - //*/ + return cStructurePtr(new cCaveSystem(a_OriginX, a_OriginZ, m_MaxOffset, m_Size, m_Noise)); } diff --git a/src/Generating/Caves.h b/src/Generating/Caves.h index 2a9fa01b8..254dcddbd 100644 --- a/src/Generating/Caves.h +++ b/src/Generating/Caves.h @@ -12,7 +12,7 @@ #pragma once -#include "ComposableGenerator.h" +#include "GridStructGen.h" #include "../Noise.h" @@ -64,10 +64,12 @@ protected: class cStructGenWormNestCaves : - public cFinishGen + public cGridStructGen { + typedef cGridStructGen super; public: cStructGenWormNestCaves(int a_Seed, int a_Size = 64, int a_Grid = 96, int a_MaxOffset = 128) : + super(a_Seed, a_Grid, a_Grid, a_Size + a_MaxOffset, a_Size + a_MaxOffset, 100), m_Noise(a_Seed), m_Size(a_Size), m_MaxOffset(a_MaxOffset), @@ -75,26 +77,16 @@ public: { } - ~cStructGenWormNestCaves(); - protected: class cCaveSystem; // fwd: Caves.cpp - typedef std::list cCaveSystems; cNoise m_Noise; int m_Size; // relative size of the cave systems' caves. Average number of blocks of each initial tunnel int m_MaxOffset; // maximum offset of the cave nest origin from the grid cell the nest belongs to int m_Grid; // average spacing of the nests - cCaveSystems m_Cache; - - /// Clears everything from the cache - void ClearCache(void); - - /// Returns all caves that *may* intersect the given chunk. All the caves are valid until the next call to this function. - void GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cCaveSystems & a_Caves); - - // cFinishGen override: - virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; + + // cGridStructGen override: + virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; } ; -- cgit v1.2.3 From 17c7c3113039bcf66899c191336a63168ae36b93 Mon Sep 17 00:00:00 2001 From: worktycho Date: Fri, 9 May 2014 16:56:29 +0100 Subject: Initialise m_HasTeleported in both constructors --- src/Entities/ArrowEntity.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 847b39bbc..8d2569125 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -15,6 +15,7 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a m_IsCritical(false), m_Timer(0), m_HitGroundTimer(0), + m_HasTeleported(false), m_bIsCollected(false), m_HitBlockPos(Vector3i(0, 0, 0)) { -- cgit v1.2.3 From ea593dcaad59bf6e91da59ec5dadc64b9b803580 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 9 May 2014 18:30:39 +0200 Subject: Ravines rewritten using cGridStructGen. Ref.: #987. --- src/Generating/Ravines.cpp | 198 +++++++-------------------------------------- src/Generating/Ravines.h | 24 +++--- 2 files changed, 40 insertions(+), 182 deletions(-) (limited to 'src') diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index a036cf25f..78093f5ee 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -42,40 +42,38 @@ typedef std::vector cRavDefPoints; -class cStructGenRavines::cRavine +class cStructGenRavines::cRavine : + public cGridStructGen::cStructure { + typedef cGridStructGen::cStructure super; + cRavDefPoints m_Points; + - /// Generates the shaping defpoints for the ravine, based on the ravine block coords and noise + /** Generates the shaping defpoints for the ravine, based on the ravine block coords and noise */ void GenerateBaseDefPoints(int a_BlockX, int a_BlockZ, int a_Size, cNoise & a_Noise); - /// Refines (adds and smooths) defpoints from a_Src into a_Dst + /** Refines (adds and smooths) defpoints from a_Src into a_Dst */ void RefineDefPoints(const cRavDefPoints & a_Src, cRavDefPoints & a_Dst); - /// Does one round of smoothing, two passes of RefineDefPoints() + /** Does one round of smoothing, two passes of RefineDefPoints() */ void Smooth(void); - /// Linearly interpolates the points so that the maximum distance between two neighbors is max 1 block + /** Linearly interpolates the points so that the maximum distance between two neighbors is max 1 block */ void FinishLinear(void); public: - // Coords for which the ravine was generated (not necessarily the center) - int m_BlockX; - int m_BlockZ; cRavine(int a_BlockX, int a_BlockZ, int a_Size, cNoise & a_Noise); - /// Carves the ravine into the chunk specified - void ProcessChunk( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, - cChunkDef::HeightMap & a_HeightMap - ); - #ifdef _DEBUG /// Exports itself as a SVG line definition AString ExportAsSVG(int a_Color, int a_OffsetX = 0, int a_OffsetZ = 0) const; #endif // _DEBUG + +protected: + // cGridStructGen::cStructure overrides: + virtual void DrawIntoChunk(cChunkDesc & a_ChunkDesc) override; } ; @@ -86,6 +84,7 @@ public: // cStructGenRavines: cStructGenRavines::cStructGenRavines(int a_Seed, int a_Size) : + super(a_Seed, a_Size, a_Size, a_Size * 2, a_Size * 2, 100), m_Noise(a_Seed), m_Size(a_Size) { @@ -95,139 +94,9 @@ cStructGenRavines::cStructGenRavines(int a_Seed, int a_Size) : -cStructGenRavines::~cStructGenRavines() +cGridStructGen::cStructurePtr cStructGenRavines::CreateStructure(int a_OriginX, int a_OriginZ) { - ClearCache(); -} - - - - - -void cStructGenRavines::ClearCache(void) -{ - for (cRavines::const_iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end; ++itr) - { - delete *itr; - } // for itr - m_Cache[] - m_Cache.clear(); -} - - - - - -void cStructGenRavines::GenFinish(cChunkDesc & a_ChunkDesc) -{ - int ChunkX = a_ChunkDesc.GetChunkX(); - int ChunkZ = a_ChunkDesc.GetChunkZ(); - cRavines Ravines; - GetRavinesForChunk(ChunkX, ChunkZ, Ravines); - for (cRavines::const_iterator itr = Ravines.begin(), end = Ravines.end(); itr != end; ++itr) - { - (*itr)->ProcessChunk(ChunkX, ChunkZ, a_ChunkDesc.GetBlockTypes(), a_ChunkDesc.GetHeightMap()); - } // for itr - Ravines[] -} - - - - - -void cStructGenRavines::GetRavinesForChunk(int a_ChunkX, int a_ChunkZ, cStructGenRavines::cRavines & a_Ravines) -{ - int BaseX = a_ChunkX * cChunkDef::Width / m_Size; - int BaseZ = a_ChunkZ * cChunkDef::Width / m_Size; - if (BaseX < 0) - { - --BaseX; - } - if (BaseZ < 0) - { - --BaseZ; - } - BaseX -= 4; - BaseZ -= 4; - - // Walk the cache, move each ravine that we want into a_Ravines: - int StartX = BaseX * m_Size; - int EndX = (BaseX + NEIGHBORHOOD_SIZE + 1) * m_Size; - int StartZ = BaseZ * m_Size; - int EndZ = (BaseZ + NEIGHBORHOOD_SIZE + 1) * m_Size; - for (cRavines::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end;) - { - if ( - ((*itr)->m_BlockX >= StartX) && ((*itr)->m_BlockX < EndX) && - ((*itr)->m_BlockZ >= StartZ) && ((*itr)->m_BlockZ < EndZ) - ) - { - // want - a_Ravines.push_back(*itr); - itr = m_Cache.erase(itr); - } - else - { - // don't want - ++itr; - } - } // for itr - m_Cache[] - - for (int x = 0; x < NEIGHBORHOOD_SIZE; x++) - { - int RealX = (BaseX + x) * m_Size; - for (int z = 0; z < NEIGHBORHOOD_SIZE; z++) - { - int RealZ = (BaseZ + z) * m_Size; - bool Found = false; - for (cRavines::const_iterator itr = a_Ravines.begin(), end = a_Ravines.end(); itr != end; ++itr) - { - if (((*itr)->m_BlockX == RealX) && ((*itr)->m_BlockZ == RealZ)) - { - Found = true; - break; - } - } - if (!Found) - { - a_Ravines.push_back(new cRavine(RealX, RealZ, m_Size, m_Noise)); - } - } - } - - // Copy a_Ravines into m_Cache to the beginning: - cRavines RavinesCopy(a_Ravines); - m_Cache.splice(m_Cache.begin(), RavinesCopy, RavinesCopy.begin(), RavinesCopy.end()); - - // Trim the cache if it's too long: - if (m_Cache.size() > 100) - { - cRavines::iterator itr = m_Cache.begin(); - std::advance(itr, 100); - for (cRavines::iterator end = m_Cache.end(); itr != end; ++itr) - { - delete *itr; - } - itr = m_Cache.begin(); - std::advance(itr, 100); - m_Cache.erase(itr, m_Cache.end()); - } - - /* - #ifdef _DEBUG - // DEBUG: Export as SVG into a file specific for the chunk, for visual verification: - AString SVG; - SVG.append("\n\n"); - for (cRavines::const_iterator itr = a_Ravines.begin(), end = a_Ravines.end(); itr != end; ++itr) - { - SVG.append((*itr)->ExportAsSVG(0, 512, 512)); - } - SVG.append("\n"); - - AString fnam; - Printf(fnam, "ravines\\%03d_%03d.svg", a_ChunkX, a_ChunkZ); - cFile File(fnam, cFile::fmWrite); - File.Write(SVG.c_str(), SVG.size()); - #endif // _DEBUG - //*/ + return cStructurePtr(new cRavine(a_OriginX, a_OriginZ, m_Size, m_Noise)); } @@ -238,14 +107,13 @@ void cStructGenRavines::GetRavinesForChunk(int a_ChunkX, int a_ChunkZ, cStructGe /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cStructGenRavines::cRavine -cStructGenRavines::cRavine::cRavine(int a_BlockX, int a_BlockZ, int a_Size, cNoise & a_Noise) : - m_BlockX(a_BlockX), - m_BlockZ(a_BlockZ) +cStructGenRavines::cRavine::cRavine(int a_OriginX, int a_OriginZ, int a_Size, cNoise & a_Noise) : + super(a_OriginX, a_OriginZ) { // Calculate the ravine shape-defining points: - GenerateBaseDefPoints(a_BlockX, a_BlockZ, a_Size, a_Noise); + GenerateBaseDefPoints(a_OriginX, a_OriginZ, a_Size, a_Noise); - // Smooth the ravine. A two passes are needed: + // Smooth the ravine. Two passes are needed: Smooth(); Smooth(); @@ -263,8 +131,8 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block a_Size = (512 + ((a_Noise.IntNoise3DInt(19 * a_BlockX, 11 * a_BlockZ, a_BlockX + a_BlockZ) / 17) % 512)) * a_Size / 1024; // The complete offset of the ravine from its cellpoint, up to 2 * a_Size in each direction - int OffsetX = (((a_Noise.IntNoise3DInt(50 * a_BlockX, 30 * a_BlockZ, 0) / 9) % (2 * a_Size)) + ((a_Noise.IntNoise3DInt(30 * a_BlockX, 50 * m_BlockZ, 1000) / 7) % (2 * a_Size)) - 2 * a_Size) / 2; - int OffsetZ = (((a_Noise.IntNoise3DInt(50 * a_BlockX, 30 * a_BlockZ, 2000) / 7) % (2 * a_Size)) + ((a_Noise.IntNoise3DInt(30 * a_BlockX, 50 * m_BlockZ, 3000) / 9) % (2 * a_Size)) - 2 * a_Size) / 2; + int OffsetX = (((a_Noise.IntNoise3DInt(50 * a_BlockX, 30 * a_BlockZ, 0) / 9) % (2 * a_Size)) + ((a_Noise.IntNoise3DInt(30 * a_BlockX, 50 * a_BlockZ, 1000) / 7) % (2 * a_Size)) - 2 * a_Size) / 2; + int OffsetZ = (((a_Noise.IntNoise3DInt(50 * a_BlockX, 30 * a_BlockZ, 2000) / 7) % (2 * a_Size)) + ((a_Noise.IntNoise3DInt(30 * a_BlockX, 50 * a_BlockZ, 3000) / 9) % (2 * a_Size)) - 2 * a_Size) / 2; int CenterX = a_BlockX + OffsetX; int CenterZ = a_BlockZ + OffsetZ; @@ -429,15 +297,15 @@ AString cStructGenRavines::cRavine::ExportAsSVG(int a_Color, int a_OffsetX, int // Base point highlight: AppendPrintf(SVG, "\n", - a_OffsetX + m_BlockX - 5, a_OffsetZ + m_BlockZ, a_OffsetX + m_BlockX + 5, a_OffsetZ + m_BlockZ + a_OffsetX + m_OriginX - 5, a_OffsetZ + m_OriginZ, a_OffsetX + m_OriginX + 5, a_OffsetZ + m_OriginZ ); AppendPrintf(SVG, "\n", - a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ - 5, a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ + 5 + a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ - 5, a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ + 5 ); // A gray line from the base point to the first point of the ravine, for identification: AppendPrintf(SVG, "\n", - a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ, a_OffsetX + m_Points.front().m_BlockX, a_OffsetZ + m_Points.front().m_BlockZ + a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ, a_OffsetX + m_Points.front().m_BlockX, a_OffsetZ + m_Points.front().m_BlockZ ); // Offset guides: @@ -461,14 +329,10 @@ AString cStructGenRavines::cRavine::ExportAsSVG(int a_Color, int a_OffsetX, int -void cStructGenRavines::cRavine::ProcessChunk( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, - cChunkDef::HeightMap & a_HeightMap -) +void cStructGenRavines::cRavine::DrawIntoChunk(cChunkDesc & a_ChunkDesc) { - int BlockStartX = a_ChunkX * cChunkDef::Width; - int BlockStartZ = a_ChunkZ * cChunkDef::Width; + int BlockStartX = a_ChunkDesc.GetChunkX() * cChunkDef::Width; + int BlockStartZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width; int BlockEndX = BlockStartX + cChunkDef::Width; int BlockEndZ = BlockStartZ + cChunkDef::Width; for (cRavDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr) @@ -494,7 +358,7 @@ void cStructGenRavines::cRavine::ProcessChunk( // DEBUG: Make the ravine shapepoints visible on a single layer (so that we can see with Minutor what's going on) if ((DifX + x == 0) && (DifZ + z == 0)) { - cChunkDef::SetBlock(a_BlockTypes, x, 4, z, E_BLOCK_LAPIS_ORE); + a_ChunkDesc.SetBlockType(x, 4, z, E_BLOCK_LAPIS_ORE); } #endif // _DEBUG @@ -504,7 +368,7 @@ void cStructGenRavines::cRavine::ProcessChunk( int Top = std::min(itr->m_Top, (int)(cChunkDef::Height)); // Stupid gcc needs int cast for (int y = std::max(itr->m_Bottom, 1); y <= Top; y++) { - switch (cChunkDef::GetBlock(a_BlockTypes, x, y, z)) + switch (a_ChunkDesc.GetBlockType(x, y, z)) { // Only carve out these specific block types case E_BLOCK_DIRT: @@ -522,7 +386,7 @@ void cStructGenRavines::cRavine::ProcessChunk( case E_BLOCK_REDSTONE_ORE: case E_BLOCK_REDSTONE_ORE_GLOWING: { - cChunkDef::SetBlock(a_BlockTypes, x, y, z, E_BLOCK_AIR); + a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR); break; } default: break; diff --git a/src/Generating/Ravines.h b/src/Generating/Ravines.h index c76b9f19f..30b47e9ec 100644 --- a/src/Generating/Ravines.h +++ b/src/Generating/Ravines.h @@ -9,7 +9,7 @@ #pragma once -#include "ComposableGenerator.h" +#include "GridStructGen.h" #include "../Noise.h" @@ -17,28 +17,22 @@ class cStructGenRavines : - public cFinishGen + public cGridStructGen { + typedef cGridStructGen super; + public: cStructGenRavines(int a_Seed, int a_Size); - ~cStructGenRavines(); protected: class cRavine; // fwd: Ravines.cpp - typedef std::list cRavines; - - cNoise m_Noise; - int m_Size; // Max size, in blocks, of the ravines generated - cRavines m_Cache; - /// Clears everything from the cache - void ClearCache(void); + cNoise m_Noise; + int m_Size; // Max size, in blocks, of the ravines generated - /// Returns all ravines that *may* intersect the given chunk. All the ravines are valid until the next call to this function. - void GetRavinesForChunk(int a_ChunkX, int a_ChunkZ, cRavines & a_Ravines); - - // cFinishGen override: - virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; + + // cGridStructGen overrides: + virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; } ; -- cgit v1.2.3 From 99af4453ef832c4053fa26e6ed9f64804bce110a Mon Sep 17 00:00:00 2001 From: worktycho Date: Fri, 9 May 2014 17:30:47 +0100 Subject: Check the height and width values read. Fixes CID 55831 --- src/WorldStorage/MapSerializer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/WorldStorage/MapSerializer.cpp b/src/WorldStorage/MapSerializer.cpp index df72d1cc9..012fc52f3 100644 --- a/src/WorldStorage/MapSerializer.cpp +++ b/src/WorldStorage/MapSerializer.cpp @@ -152,6 +152,10 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT) if (CurrLine >= 0) { unsigned int Width = a_NBT.GetShort(CurrLine); + if (Width != 128) + { + return false; + } m_Map->m_Width = Width; } @@ -159,6 +163,10 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT) if (CurrLine >= 0) { unsigned int Height = a_NBT.GetShort(CurrLine); + if (Height >= 256) + { + return false; + } m_Map->m_Height = Height; } -- cgit v1.2.3 From fb58ef55beddc73500029ae6c0fe08400de550d2 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 8 May 2014 20:16:35 +0200 Subject: Fixed MSVC 64-bit build warnings. --- src/Bindings/PluginManager.cpp | 9 +++---- src/Bindings/PluginManager.h | 2 +- src/BlockArea.cpp | 10 ++++---- src/Blocks/BlockFarmland.h | 4 ++-- src/Blocks/BlockLeaves.h | 6 ++--- src/Blocks/BlockSlab.h | 2 +- src/Generating/Caves.cpp | 10 ++++++-- src/Generating/MineShafts.cpp | 6 ++--- src/Generating/PieceGenerator.cpp | 4 ++-- src/Generating/Ravines.cpp | 10 ++++++-- src/Generating/Trees.cpp | 2 +- src/GroupManager.cpp | 35 ++++++++++++++-------------- src/HTTPServer/NameValueParser.cpp | 2 +- src/Map.cpp | 2 +- src/Map.h | 2 +- src/MapManager.cpp | 6 ++--- src/MapManager.h | 2 +- src/MobCensus.cpp | 2 +- src/MobFamilyCollecter.cpp | 2 +- src/MobSpawner.cpp | 6 ++--- src/Noise.cpp | 2 +- src/OSSupport/ListenThread.cpp | 2 +- src/OSSupport/Socket.cpp | 8 +++---- src/OSSupport/Socket.h | 4 ++-- src/OSSupport/SocketThreads.cpp | 2 +- src/ProbabDistrib.cpp | 2 +- src/Protocol/Protocol17x.cpp | 18 +++++++------- src/Protocol/ProtocolRecognizer.cpp | 4 ++-- src/RCONServer.cpp | 2 +- src/Root.cpp | 14 +++++------ src/Scoreboard.cpp | 6 ++--- src/Scoreboard.h | 6 ++--- src/Simulator/DelayedFluidSimulator.cpp | 2 +- src/Simulator/SandSimulator.cpp | 2 +- src/StringCompression.cpp | 14 +++++------ src/StringCompression.h | 4 ++-- src/StringUtils.cpp | 24 +++++++++++-------- src/StringUtils.h | 4 ++-- src/UI/SlotArea.cpp | 2 +- src/UI/Window.cpp | 2 +- src/World.cpp | 7 +++--- src/WorldStorage/FastNBT.cpp | 30 +++++++++++++----------- src/WorldStorage/FastNBT.h | 8 +++---- src/WorldStorage/SchematicFileSerializer.cpp | 4 ++-- src/WorldStorage/WSSAnvil.cpp | 8 +++---- src/WorldStorage/WSSCompact.cpp | 24 +++++++++---------- 46 files changed, 173 insertions(+), 156 deletions(-) (limited to 'src') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index aaccc606d..310ecc7e8 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -143,13 +143,14 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) } } - if (GetNumPlugins() == 0) + size_t NumLoadedPlugins = GetNumPlugins(); + if (NumLoadedPlugins) { LOG("-- No Plugins Loaded --"); } - else if (GetNumPlugins() > 1) + else if (NumLoadedPlugins > 1) { - LOG("-- Loaded %i Plugins --", GetNumPlugins()); + LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins); } else { @@ -1869,7 +1870,7 @@ void cPluginManager::AddHook(cPlugin * a_Plugin, int a_Hook) -unsigned int cPluginManager::GetNumPlugins() const +size_t cPluginManager::GetNumPlugins() const { return m_Plugins.size(); } diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 58c1cebb4..3b3091957 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -159,7 +159,7 @@ public: // tolua_export /** Adds the plugin to the list of plugins called for the specified hook type. Handles multiple adds as a single add */ void AddHook(cPlugin * a_Plugin, int a_HookType); - unsigned int GetNumPlugins() const; // tolua_export + size_t GetNumPlugins() const; // tolua_export // Calls for individual hooks. Each returns false if the action is to continue or true if the plugin wants to abort bool CallHookBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source); diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 897af27c4..9e20a0983 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -738,31 +738,31 @@ void cBlockArea::Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_Block a_DataTypes = a_DataTypes & GetDataTypes(); } - int BlockCount = GetBlockCount(); + size_t BlockCount = GetBlockCount(); if ((a_DataTypes & baTypes) != 0) { - for (int i = 0; i < BlockCount; i++) + for (size_t i = 0; i < BlockCount; i++) { m_BlockTypes[i] = a_BlockType; } } if ((a_DataTypes & baMetas) != 0) { - for (int i = 0; i < BlockCount; i++) + for (size_t i = 0; i < BlockCount; i++) { m_BlockMetas[i] = a_BlockMeta; } } if ((a_DataTypes & baLight) != 0) { - for (int i = 0; i < BlockCount; i++) + for (size_t i = 0; i < BlockCount; i++) { m_BlockLight[i] = a_BlockLight; } } if ((a_DataTypes & baSkyLight) != 0) { - for (int i = 0; i < BlockCount; i++) + for (size_t i = 0; i < BlockCount; i++) { m_BlockSkyLight[i] = a_BlockSkyLight; } diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h index b720ccd14..3dd5bcd1d 100644 --- a/src/Blocks/BlockFarmland.h +++ b/src/Blocks/BlockFarmland.h @@ -52,9 +52,9 @@ public: return; } - int NumBlocks = Area.GetBlockCount(); + size_t NumBlocks = Area.GetBlockCount(); BLOCKTYPE * BlockTypes = Area.GetBlockTypes(); - for (int i = 0; i < NumBlocks; i++) + for (size_t i = 0; i < NumBlocks; i++) { if ( (BlockTypes[i] == E_BLOCK_WATER) || diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index d21227b07..495e849fa 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -138,14 +138,14 @@ bool HasNearLog(cBlockArea & a_Area, int a_BlockX, int a_BlockY, int a_BlockZ) { // Filter the blocks into a {leaves, log, other (air)} set: BLOCKTYPE * Types = a_Area.GetBlockTypes(); - for (int i = a_Area.GetBlockCount() - 1; i > 0; i--) + for (size_t i = a_Area.GetBlockCount() - 1; i > 0; i--) { switch (Types[i]) { - case E_BLOCK_NEW_LEAVES: - case E_BLOCK_NEW_LOG: case E_BLOCK_LEAVES: case E_BLOCK_LOG: + case E_BLOCK_NEW_LEAVES: + case E_BLOCK_NEW_LOG: { break; } diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index b6bd12588..80841b094 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -100,7 +100,7 @@ public: virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override { - return (a_Meta & 0x8); + return ((a_Meta & 0x8) != 0); } diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index 5cad11d2a..6df22a14a 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -239,9 +239,15 @@ void cCaveTunnel::Randomize(cNoise & a_Noise) bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & a_Dst) { + if (a_Src.size() < 2) + { + // There are no midpoints, nothing to smooth + return true; + } + // Smoothing: for each line segment, add points on its 1/4 lengths bool res = false; - int Num = a_Src.size() - 2; // this many intermediary points + size_t Num = a_Src.size() - 2; // this many intermediary points a_Dst.clear(); a_Dst.reserve(Num * 2 + 2); cCaveDefPoints::const_iterator itr = a_Src.begin() + 1; @@ -251,7 +257,7 @@ bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & int PrevY = Source.m_BlockY; int PrevZ = Source.m_BlockZ; int PrevR = Source.m_Radius; - for (int i = 0; i <= Num; ++i, ++itr) + for (size_t i = 0; i <= Num; ++i, ++itr) { int dx = itr->m_BlockX - PrevX; int dy = itr->m_BlockY - PrevY; diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index 231295c3f..af63e549b 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -543,7 +543,7 @@ cMineShaft * cMineShaftCorridor::CreateAndFit( { cCuboid BoundingBox(a_PivotX, a_PivotY - 1, a_PivotZ); BoundingBox.p2.y += 3; - int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7; + int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7; int NumSegments = 2 + (rnd) % (MAX_SEGMENTS - 1); // 2 .. MAX_SEGMENTS switch (a_Direction) { @@ -985,7 +985,7 @@ cMineShaft * cMineShaftCrossing::CreateAndFit( ) { cCuboid BoundingBox(a_PivotX, a_PivotY - 1, a_PivotZ); - int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7; + int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7; BoundingBox.p2.y += 3; if ((rnd % 4) < 2) { @@ -1127,7 +1127,7 @@ cMineShaft * cMineShaftStaircase::CreateAndFit( cNoise & a_Noise ) { - int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7; + int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7; cCuboid Box; switch (a_Direction) { diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index db45cd08b..ce19c1c95 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -339,9 +339,9 @@ cPlacedPiece * cPieceGenerator::PlaceStartingPiece(int a_BlockX, int a_BlockY, i int NumRotations = 1; for (size_t i = 1; i < ARRAYCOUNT(Rotations); i++) { - if (StartingPiece->CanRotateCCW(i)) + if (StartingPiece->CanRotateCCW((int)i)) { - Rotations[NumRotations] = i; + Rotations[NumRotations] = (int)i; NumRotations += 1; } } diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index 267dcbbf9..a036cf25f 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -306,8 +306,14 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block void cStructGenRavines::cRavine::RefineDefPoints(const cRavDefPoints & a_Src, cRavDefPoints & a_Dst) { + if (a_Src.size() < 2) + { + // No midpoints, nothing to refine + return; + } + // Smoothing: for each line segment, add points on its 1/4 lengths - int Num = a_Src.size() - 2; // this many intermediary points + size_t Num = a_Src.size() - 2; // this many intermediary points a_Dst.clear(); a_Dst.reserve(Num * 2 + 2); cRavDefPoints::const_iterator itr = a_Src.begin() + 1; @@ -318,7 +324,7 @@ void cStructGenRavines::cRavine::RefineDefPoints(const cRavDefPoints & a_Src, cR int PrevR = Source.m_Radius; int PrevT = Source.m_Top; int PrevB = Source.m_Bottom; - for (int i = 0; i <= Num; ++i, ++itr) + for (size_t i = 0; i <= Num; ++i, ++itr) { int dx = itr->m_BlockX - PrevX; int dz = itr->m_BlockZ - PrevZ; diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index 4909587b1..4f1553c36 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -136,7 +136,7 @@ inline void PushSomeColumns(int a_BlockX, int a_Height, int a_BlockZ, int a_Colu { int x = a_BlockX + a_Coords[i].x; int z = a_BlockZ + a_Coords[i].z; - if (a_Noise.IntNoise3DInt(x + 64 * a_Seq, a_Height + i, z + 64 * a_Seq) <= a_Chance) + if (a_Noise.IntNoise3DInt(x + 64 * a_Seq, a_Height + (int)i, z + 64 * a_Seq) <= a_Chance) { for (int j = 0; j < a_ColumnHeight; j++) { diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index 33b601e82..3586560bf 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -79,23 +79,24 @@ void cGroupManager::CheckUsers(void) return; } - unsigned int NumKeys = IniFile.GetNumKeys(); - for (size_t i = 0; i < NumKeys; i++) + int NumKeys = IniFile.GetNumKeys(); + for (int i = 0; i < NumKeys; i++) { - AString Player = IniFile.GetKeyName( i ); + AString Player = IniFile.GetKeyName(i); AString Groups = IniFile.GetValue(Player, "Groups", ""); - if (!Groups.empty()) + if (Groups.empty()) + { + continue; + } + AStringVector Split = StringSplitAndTrim(Groups, ","); + for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr) { - AStringVector Split = StringSplit( Groups, "," ); - for( unsigned int i = 0; i < Split.size(); i++ ) + if (!ExistsGroup(*itr)) { - if (!ExistsGroup(Split[i])) - { - LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), Player.c_str()); - } + LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), Player.c_str()); } - } - } + } // for itr - Split[] + } // for i - ini file keys } @@ -128,15 +129,15 @@ void cGroupManager::LoadGroups() IniFile.WriteFile("groups.ini"); } - unsigned int NumKeys = IniFile.GetNumKeys(); - for (size_t i = 0; i < NumKeys; i++) + int NumKeys = IniFile.GetNumKeys(); + for (int i = 0; i < NumKeys; i++) { - AString KeyName = IniFile.GetKeyName( i ); - cGroup* Group = GetGroup( KeyName.c_str() ); + AString KeyName = IniFile.GetKeyName(i); + cGroup * Group = GetGroup(KeyName.c_str()); Group->ClearPermission(); // Needed in case the groups are reloaded. - LOGD("Loading group: %s", KeyName.c_str() ); + LOGD("Loading group %s", KeyName.c_str()); Group->SetName(KeyName); AString Color = IniFile.GetValue(KeyName, "Color", "-"); diff --git a/src/HTTPServer/NameValueParser.cpp b/src/HTTPServer/NameValueParser.cpp index 3f6c17dda..f16ea1915 100644 --- a/src/HTTPServer/NameValueParser.cpp +++ b/src/HTTPServer/NameValueParser.cpp @@ -97,7 +97,7 @@ void cNameValueParser::Parse(const char * a_Data, size_t a_Size) { ASSERT(m_State != psFinished); // Calling Parse() after Finish() is wrong! - int Last = 0; + size_t Last = 0; for (size_t i = 0; i < a_Size;) { switch (m_State) diff --git a/src/Map.cpp b/src/Map.cpp index 79370b097..7721baa70 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -614,7 +614,7 @@ unsigned int cMap::GetNumPixels(void) const -unsigned int cMap::GetNumDecorators(void) const +size_t cMap::GetNumDecorators(void) const { return m_Decorators.size(); } diff --git a/src/Map.h b/src/Map.h index ee7c537b1..e23ca2c92 100644 --- a/src/Map.h +++ b/src/Map.h @@ -181,7 +181,7 @@ public: // tolua_end - unsigned int GetNumDecorators(void) const; + size_t GetNumDecorators(void) const; const cColorList & GetData(void) const { return m_Data; } diff --git a/src/MapManager.cpp b/src/MapManager.cpp index 9d02eafb4..e7df75118 100644 --- a/src/MapManager.cpp +++ b/src/MapManager.cpp @@ -86,7 +86,7 @@ cMap * cMapManager::CreateMap(int a_CenterX, int a_CenterY, int a_Scale) return NULL; } - cMap Map(m_MapData.size(), a_CenterX, a_CenterY, m_World, a_Scale); + cMap Map((unsigned)m_MapData.size(), a_CenterX, a_CenterY, m_World, a_Scale); m_MapData.push_back(Map); @@ -97,7 +97,7 @@ cMap * cMapManager::CreateMap(int a_CenterX, int a_CenterY, int a_Scale) -unsigned int cMapManager::GetNumMaps(void) const +size_t cMapManager::GetNumMaps(void) const { return m_MapData.size(); } @@ -151,7 +151,7 @@ void cMapManager::SaveMapData(void) cIDCountSerializer IDSerializer(m_World->GetName()); - IDSerializer.SetMapCount(m_MapData.size()); + IDSerializer.SetMapCount((unsigned)m_MapData.size()); if (!IDSerializer.Save()) { diff --git a/src/MapManager.h b/src/MapManager.h index 80e6d16d1..ceab8f126 100644 --- a/src/MapManager.h +++ b/src/MapManager.h @@ -53,7 +53,7 @@ public: */ bool ForEachMap(cMapCallback & a_Callback); - unsigned int GetNumMaps(void) const; // tolua_export + size_t GetNumMaps(void) const; // tolua_export /** Loads the map data from the disk */ void LoadMapData(void); diff --git a/src/MobCensus.cpp b/src/MobCensus.cpp index 9c32bf695..23f74b59e 100644 --- a/src/MobCensus.cpp +++ b/src/MobCensus.cpp @@ -64,7 +64,7 @@ void cMobCensus::CollectSpawnableChunk(cChunk & a_Chunk) int cMobCensus::GetNumChunks(void) { - return m_EligibleForSpawnChunks.size(); + return (int)m_EligibleForSpawnChunks.size(); } diff --git a/src/MobFamilyCollecter.cpp b/src/MobFamilyCollecter.cpp index e9c69e078..6da330c83 100644 --- a/src/MobFamilyCollecter.cpp +++ b/src/MobFamilyCollecter.cpp @@ -18,7 +18,7 @@ void cMobFamilyCollecter::CollectMob(cMonster & a_Monster) int cMobFamilyCollecter::GetNumberOfCollectedMobs(cMonster::eFamily a_Family) { - return m_Mobs[a_Family].size(); + return (int)m_Mobs[a_Family].size(); } diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index ce8e06777..de8e01b8a 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -104,13 +104,13 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome) } } - int allowedMobsSize = allowedMobs.size(); + size_t allowedMobsSize = allowedMobs.size(); if (allowedMobsSize > 0) { std::set::iterator itr = allowedMobs.begin(); - int iRandom = m_Random.NextInt(allowedMobsSize,a_Biome); + int iRandom = m_Random.NextInt((int)allowedMobsSize, a_Biome); - for(int i = 0; i < iRandom; i++) + for (int i = 0; i < iRandom; i++) { ++itr; } diff --git a/src/Noise.cpp b/src/Noise.cpp index 13a194938..89115d992 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -814,7 +814,7 @@ void cPerlinNoise::SetSeed(int a_Seed) void cPerlinNoise::AddOctave(float a_Frequency, float a_Amplitude) { - m_Octaves.push_back(cOctave(m_Seed * (m_Octaves.size() + 4) * 4 + 1024, a_Frequency, a_Amplitude)); + m_Octaves.push_back(cOctave(m_Seed * ((int)m_Octaves.size() + 4) * 4 + 1024, a_Frequency, a_Amplitude)); } diff --git a/src/OSSupport/ListenThread.cpp b/src/OSSupport/ListenThread.cpp index ba3198764..02e98acfc 100644 --- a/src/OSSupport/ListenThread.cpp +++ b/src/OSSupport/ListenThread.cpp @@ -214,7 +214,7 @@ void cListenThread::Execute(void) timeval tv; // On Linux select() doesn't seem to wake up when socket is closed, so let's kinda busy-wait: tv.tv_sec = 1; tv.tv_usec = 0; - if (select(Highest + 1, &fdRead, NULL, NULL, &tv) == -1) + if (select((int)Highest + 1, &fdRead, NULL, NULL, &tv) == -1) { LOG("select(R) call failed in cListenThread: \"%s\"", cSocket::GetLastErrorString().c_str()); continue; diff --git a/src/OSSupport/Socket.cpp b/src/OSSupport/Socket.cpp index 98f694a79..56835b518 100644 --- a/src/OSSupport/Socket.cpp +++ b/src/OSSupport/Socket.cpp @@ -328,18 +328,18 @@ bool cSocket::ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Por -int cSocket::Receive(char * a_Buffer, unsigned int a_Length, unsigned int a_Flags) +int cSocket::Receive(char * a_Buffer, size_t a_Length, unsigned int a_Flags) { - return recv(m_Socket, a_Buffer, a_Length, a_Flags); + return recv(m_Socket, a_Buffer, (int)a_Length, a_Flags); } -int cSocket::Send(const char * a_Buffer, unsigned int a_Length) +int cSocket::Send(const char * a_Buffer, size_t a_Length) { - return send(m_Socket, a_Buffer, a_Length, MSG_NOSIGNAL); + return send(m_Socket, a_Buffer, (int)a_Length, MSG_NOSIGNAL); } diff --git a/src/OSSupport/Socket.h b/src/OSSupport/Socket.h index bdc2babf5..35ecadfa0 100644 --- a/src/OSSupport/Socket.h +++ b/src/OSSupport/Socket.h @@ -110,8 +110,8 @@ public: /// Connects to the specified host or string IP address and port, using IPv4. Returns true if successful. bool ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Port); - int Receive(char * a_Buffer, unsigned int a_Length, unsigned int a_Flags); - int Send (const char * a_Buffer, unsigned int a_Length); + int Receive(char * a_Buffer, size_t a_Length, unsigned int a_Flags); + int Send (const char * a_Buffer, size_t a_Length); unsigned short GetPort(void) const; // Returns 0 on failure diff --git a/src/OSSupport/SocketThreads.cpp b/src/OSSupport/SocketThreads.cpp index 0bc1d6b55..0ab5b6298 100644 --- a/src/OSSupport/SocketThreads.cpp +++ b/src/OSSupport/SocketThreads.cpp @@ -406,7 +406,7 @@ void cSocketThreads::cSocketThread::Execute(void) timeval Timeout; Timeout.tv_sec = 5; Timeout.tv_usec = 0; - if (select(Highest + 1, &fdRead, &fdWrite, NULL, &Timeout) == -1) + if (select((int)Highest + 1, &fdRead, &fdWrite, NULL, &Timeout) == -1) { LOG("select() call failed in cSocketThread: \"%s\"", cSocket::GetLastErrorString().c_str()); continue; diff --git a/src/ProbabDistrib.cpp b/src/ProbabDistrib.cpp index 5fa17c276..7a5869dcc 100644 --- a/src/ProbabDistrib.cpp +++ b/src/ProbabDistrib.cpp @@ -118,7 +118,7 @@ int cProbabDistrib::MapValue(int a_OrigValue) const size_t Hi = m_Cumulative.size() - 1; while (Hi - Lo > 1) { - int Mid = (Lo + Hi) / 2; + size_t Mid = (Lo + Hi) / 2; int MidProbab = m_Cumulative[Mid].m_Probability; if (MidProbab < a_OrigValue) { diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index f6849122f..443723e40 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -197,7 +197,7 @@ void cProtocol172::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockV Pkt.WriteInt(a_ChunkX); Pkt.WriteInt(a_ChunkZ); Pkt.WriteShort((short)a_Changes.size()); - Pkt.WriteInt(a_Changes.size() * 4); + Pkt.WriteInt((int)a_Changes.size() * 4); for (sSetBlockVector::const_iterator itr = a_Changes.begin(), end = a_Changes.end(); itr != end; ++itr) { unsigned int Coords = itr->y | (itr->z << 8) | (itr->x << 12); @@ -532,7 +532,7 @@ void cProtocol172::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc Pkt.WriteFloat((float)a_BlockY); Pkt.WriteFloat((float)a_BlockZ); Pkt.WriteFloat((float)a_Radius); - Pkt.WriteInt(a_BlocksAffected.size()); + Pkt.WriteInt((int)a_BlocksAffected.size()); for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(), end = a_BlocksAffected.end(); itr != end; ++itr) { Pkt.WriteChar((char)itr->x); @@ -698,7 +698,7 @@ void cProtocol172::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decor cPacketizer Pkt(*this, 0x34); Pkt.WriteVarInt(a_ID); - Pkt.WriteShort (1 + (3 * a_Decorators.size())); + Pkt.WriteShort ((short)(1 + (3 * a_Decorators.size()))); Pkt.WriteByte(1); @@ -1174,7 +1174,7 @@ void cProtocol172::SendTabCompletionResults(const AStringVector & a_Results) ASSERT(m_State == 3); // In game mode? cPacketizer Pkt(*this, 0x3a); // Tab-Complete packet - Pkt.WriteVarInt(a_Results.size()); + Pkt.WriteVarInt((int)a_Results.size()); for (AStringVector::const_iterator itr = a_Results.begin(), end = a_Results.end(); itr != end; ++itr) { @@ -1743,7 +1743,7 @@ void cProtocol172::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer) cPacketizer Pkt(*this, 0x01); Pkt.WriteString(Server->GetServerID()); const AString & PubKeyDer = Server->GetPublicKeyDER(); - Pkt.WriteShort(PubKeyDer.size()); + Pkt.WriteShort((short)PubKeyDer.size()); Pkt.WriteBuf(PubKeyDer.data(), PubKeyDer.size()); Pkt.WriteShort(4); Pkt.WriteInt((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :) @@ -2138,7 +2138,7 @@ void cProtocol172::WritePacket(cByteBuffer & a_Packet) cCSLock Lock(m_CSPacket); AString Pkt; a_Packet.ReadAll(Pkt); - WriteVarInt(Pkt.size()); + WriteVarInt((UInt32)Pkt.size()); SendData(Pkt.data(), Pkt.size()); Flush(); } @@ -2403,7 +2403,7 @@ cProtocol172::cPacketizer::~cPacketizer() AString DataToSend; // Send the packet length - UInt32 PacketLen = m_Out.GetUsedSpace(); + UInt32 PacketLen = (UInt32)m_Out.GetUsedSpace(); m_Protocol.m_OutPacketLenBuffer.WriteVarInt(PacketLen); m_Protocol.m_OutPacketLenBuffer.ReadAll(DataToSend); m_Protocol.SendData(DataToSend.data(), DataToSend.size()); @@ -2500,7 +2500,7 @@ void cProtocol172::cPacketizer::WriteItem(const cItem & a_Item) Writer.Finish(); AString Compressed; CompressStringGZIP(Writer.GetResult().data(), Writer.GetResult().size(), Compressed); - WriteShort(Compressed.size()); + WriteShort((short)Compressed.size()); WriteBuf(Compressed.data(), Compressed.size()); } @@ -2570,7 +2570,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt AString Compressed; CompressStringGZIP(Writer.GetResult().data(), Writer.GetResult().size(), Compressed); - WriteShort(Compressed.size()); + WriteShort((short)Compressed.size()); WriteBuf(Compressed.data(), Compressed.size()); } diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 22dfe7c88..667fb5cef 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -871,7 +871,7 @@ bool cProtocolRecognizer::TryRecognizeProtocol(void) // Not enough bytes for the packet length, keep waiting return false; } - ReadSoFar -= m_Buffer.GetReadableSpace(); + ReadSoFar -= (UInt32)m_Buffer.GetReadableSpace(); if (!m_Buffer.CanReadBytes(PacketLen)) { // Not enough bytes for the packet, keep waiting @@ -961,7 +961,7 @@ bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRema { return false; } - NumBytesRead -= m_Buffer.GetReadableSpace(); + NumBytesRead -= (UInt32)m_Buffer.GetReadableSpace(); switch (ProtocolVersion) { case PROTO_VERSION_1_7_2: diff --git a/src/RCONServer.cpp b/src/RCONServer.cpp index d7083ff2b..3fbc9dcbc 100644 --- a/src/RCONServer.cpp +++ b/src/RCONServer.cpp @@ -59,7 +59,7 @@ public: virtual void Finished(void) override { - m_Connection.SendResponse(m_RequestID, RCON_PACKET_RESPONSE, m_Buffer.size(), m_Buffer.c_str()); + m_Connection.SendResponse(m_RequestID, RCON_PACKET_RESPONSE, (int)m_Buffer.size(), m_Buffer.c_str()); delete this; } diff --git a/src/Root.cpp b/src/Root.cpp index 5d32bdd87..c82b05a66 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -590,13 +590,13 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac { class cCallback : public cPlayerListCallback { - unsigned m_BestRating; - unsigned m_NameLength; + size_t m_BestRating; + size_t m_NameLength; const AString m_PlayerName; virtual bool Item (cPlayer * a_pPlayer) { - unsigned int Rating = RateCompareString (m_PlayerName, a_pPlayer->GetName()); + size_t Rating = RateCompareString (m_PlayerName, a_pPlayer->GetName()); if ((Rating > 0) && (Rating >= m_BestRating)) { m_BestMatch = a_pPlayer; @@ -626,7 +626,7 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac cPlayer * m_BestMatch; unsigned m_NumMatches; } Callback (a_PlayerName); - ForEachPlayer( Callback ); + ForEachPlayer(Callback); if (Callback.m_NumMatches == 1) { @@ -763,8 +763,8 @@ void cRoot::LogChunkStats(cCommandOutputCallback & a_Output) { cWorld * World = itr->second; int NumInGenerator = World->GetGeneratorQueueLength(); - int NumInSaveQueue = World->GetStorageSaveQueueLength(); - int NumInLoadQueue = World->GetStorageLoadQueueLength(); + int NumInSaveQueue = (int)World->GetStorageSaveQueueLength(); + int NumInLoadQueue = (int)World->GetStorageLoadQueueLength(); int NumValid = 0; int NumDirty = 0; int NumInLighting = 0; @@ -784,8 +784,6 @@ void cRoot::LogChunkStats(cCommandOutputCallback & a_Output) a_Output.Out(" block lighting: " SIZE_T_FMT_PRECISION(6) " bytes (" SIZE_T_FMT_PRECISION(3) " KiB)", 2 * sizeof(cChunkDef::BlockNibbles), (2 * sizeof(cChunkDef::BlockNibbles) + 1023) / 1024); a_Output.Out(" heightmap: " SIZE_T_FMT_PRECISION(6) " bytes (" SIZE_T_FMT_PRECISION(3) " KiB)", sizeof(cChunkDef::HeightMap), (sizeof(cChunkDef::HeightMap) + 1023) / 1024); a_Output.Out(" biomemap: " SIZE_T_FMT_PRECISION(6) " bytes (" SIZE_T_FMT_PRECISION(3) " KiB)", sizeof(cChunkDef::BiomeMap), (sizeof(cChunkDef::BiomeMap) + 1023) / 1024); - int Rest = sizeof(cChunk) - sizeof(cChunkDef::BlockTypes) - 3 * sizeof(cChunkDef::BlockNibbles) - sizeof(cChunkDef::HeightMap) - sizeof(cChunkDef::BiomeMap); - a_Output.Out(" other: %6d bytes (%3d KiB)", Rest, (Rest + 1023) / 1024); SumNumValid += NumValid; SumNumDirty += NumDirty; SumNumInLighting += NumInLighting; diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp index 4c89ce265..250f63aa9 100644 --- a/src/Scoreboard.cpp +++ b/src/Scoreboard.cpp @@ -261,7 +261,7 @@ void cTeam::SetDisplayName(const AString & a_Name) -unsigned int cTeam::GetNumPlayers(void) const +size_t cTeam::GetNumPlayers(void) const { return m_Players.size(); } @@ -569,7 +569,7 @@ void cScoreboard::SendTo(cClientHandle & a_Client) -unsigned int cScoreboard::GetNumObjectives(void) const +size_t cScoreboard::GetNumObjectives(void) const { return m_Objectives.size(); } @@ -578,7 +578,7 @@ unsigned int cScoreboard::GetNumObjectives(void) const -unsigned int cScoreboard::GetNumTeams(void) const +size_t cScoreboard::GetNumTeams(void) const { return m_Teams.size(); } diff --git a/src/Scoreboard.h b/src/Scoreboard.h index 2fae5e499..1e1973a10 100644 --- a/src/Scoreboard.h +++ b/src/Scoreboard.h @@ -153,7 +153,7 @@ public: // tolua_begin /** Returns the number of registered players */ - unsigned int GetNumPlayers(void) const; + size_t GetNumPlayers(void) const; bool AllowsFriendlyFire(void) const { return m_AllowsFriendlyFire; } bool CanSeeFriendlyInvisible(void) const { return m_CanSeeFriendlyInvisible; } @@ -248,9 +248,9 @@ public: cObjective * GetObjectiveIn(eDisplaySlot a_Slot); - unsigned int GetNumObjectives(void) const; + size_t GetNumObjectives(void) const; - unsigned int GetNumTeams(void) const; + size_t GetNumTeams(void) const; void AddPlayerScore(const AString & a_Name, cObjective::eType a_Type, cObjective::Score a_Value = 1); diff --git a/src/Simulator/DelayedFluidSimulator.cpp b/src/Simulator/DelayedFluidSimulator.cpp index bc5158d95..5ff736231 100644 --- a/src/Simulator/DelayedFluidSimulator.cpp +++ b/src/Simulator/DelayedFluidSimulator.cpp @@ -148,7 +148,7 @@ void cDelayedFluidSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_Chunk { SimulateBlock(a_Chunk, itr->x, itr->y, itr->z); } - m_TotalBlocks -= Blocks.size(); + m_TotalBlocks -= (int)Blocks.size(); Blocks.clear(); } } diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp index c4f57c86a..b8f34559f 100644 --- a/src/Simulator/SandSimulator.cpp +++ b/src/Simulator/SandSimulator.cpp @@ -64,7 +64,7 @@ void cSandSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun a_Chunk->SetBlock(itr->x, itr->y, itr->z, E_BLOCK_AIR, 0); } } - m_TotalBlocks -= ChunkData.size(); + m_TotalBlocks -= (int)ChunkData.size(); ChunkData.clear(); } diff --git a/src/StringCompression.cpp b/src/StringCompression.cpp index 2a85649a1..71d64e71e 100644 --- a/src/StringCompression.cpp +++ b/src/StringCompression.cpp @@ -11,15 +11,15 @@ /// Compresses a_Data into a_Compressed; returns Z_XXX error constants same as zlib's compress2() -int CompressString(const char * a_Data, int a_Length, AString & a_Compressed, int a_Factor) +int CompressString(const char * a_Data, size_t a_Length, AString & a_Compressed, int a_Factor) { - uLongf CompressedSize = compressBound(a_Length); + uLongf CompressedSize = compressBound((uLong)a_Length); // HACK: We're assuming that AString returns its internal buffer in its data() call and we're overwriting that buffer! // It saves us one allocation and one memcpy of the entire compressed data // It may not work on some STL implementations! (Confirmed working on MSVC 2008 & 2010) a_Compressed.resize(CompressedSize); - int errorcode = compress2( (Bytef*)a_Compressed.data(), &CompressedSize, (const Bytef*)a_Data, a_Length, a_Factor); + int errorcode = compress2((Bytef*)a_Compressed.data(), &CompressedSize, (const Bytef *)a_Data, (uLong)a_Length, a_Factor); if (errorcode != Z_OK) { return errorcode; @@ -33,14 +33,14 @@ int CompressString(const char * a_Data, int a_Length, AString & a_Compressed, in /// Uncompresses a_Data into a_Decompressed; returns Z_XXX error constants same as zlib's uncompress() -int UncompressString(const char * a_Data, int a_Length, AString & a_Uncompressed, int a_UncompressedSize) +int UncompressString(const char * a_Data, size_t a_Length, AString & a_Uncompressed, size_t a_UncompressedSize) { // HACK: We're assuming that AString returns its internal buffer in its data() call and we're overwriting that buffer! // It saves us one allocation and one memcpy of the entire compressed data // It may not work on some STL implementations! (Confirmed working on MSVC 2008 & 2010) a_Uncompressed.resize(a_UncompressedSize); uLongf UncompressedSize = (uLongf)a_UncompressedSize; // On some architectures the uLongf is different in size to int, that may be the cause of the -5 error - int errorcode = uncompress((Bytef*)a_Uncompressed.data(), &UncompressedSize, (const Bytef*)a_Data, a_Length); + int errorcode = uncompress((Bytef*)a_Uncompressed.data(), &UncompressedSize, (const Bytef*)a_Data, (uLong)a_Length); if (errorcode != Z_OK) { return errorcode; @@ -63,7 +63,7 @@ int CompressStringGZIP(const char * a_Data, size_t a_Length, AString & a_Compres z_stream strm; memset(&strm, 0, sizeof(strm)); strm.next_in = (Bytef *)a_Data; - strm.avail_in = a_Length; + strm.avail_in = (uInt)a_Length; strm.next_out = (Bytef *)Buffer; strm.avail_out = sizeof(Buffer); @@ -127,7 +127,7 @@ extern int UncompressStringGZIP(const char * a_Data, size_t a_Length, AString & z_stream strm; memset(&strm, 0, sizeof(strm)); strm.next_in = (Bytef *)a_Data; - strm.avail_in = a_Length; + strm.avail_in = (uInt)a_Length; strm.next_out = (Bytef *)Buffer; strm.avail_out = sizeof(Buffer); diff --git a/src/StringCompression.h b/src/StringCompression.h index c3a9eca91..038240797 100644 --- a/src/StringCompression.h +++ b/src/StringCompression.h @@ -10,10 +10,10 @@ /// Compresses a_Data into a_Compressed using ZLIB; returns Z_XXX error constants same as zlib's compress2() -extern int CompressString(const char * a_Data, int a_Length, AString & a_Compressed, int a_Factor); +extern int CompressString(const char * a_Data, size_t a_Length, AString & a_Compressed, int a_Factor); /// Uncompresses a_Data into a_Uncompressed; returns Z_XXX error constants same as zlib's decompress() -extern int UncompressString(const char * a_Data, int a_Length, AString & a_Uncompressed, int a_UncompressedSize); +extern int UncompressString(const char * a_Data, size_t a_Length, AString & a_Uncompressed, size_t a_UncompressedSize); /// Compresses a_Data into a_Compressed using GZIP; returns Z_OK for success or Z_XXX error constants same as zlib extern int CompressStringGZIP(const char * a_Data, size_t a_Length, AString & a_Compressed); diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 33b04505f..7488a3073 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -247,18 +247,22 @@ int NoCaseCompare(const AString & s1, const AString & s2) -unsigned int RateCompareString(const AString & s1, const AString & s2 ) +size_t RateCompareString(const AString & s1, const AString & s2) { - unsigned int MatchedLetters = 0; - unsigned int s1Length = s1.length(); + size_t MatchedLetters = 0; + size_t s1Length = s1.length(); - if( s1Length > s2.length() ) return 0; // Definitely not a match + if (s1Length > s2.length()) + { + // Definitely not a match + return 0; + } - for (unsigned int i = 0; i < s1Length; i++) + for (size_t i = 0; i < s1Length; i++) { - char c1 = (char)toupper( s1[i] ); - char c2 = (char)toupper( s2[i] ); - if( c1 == c2 ) + char c1 = (char)toupper(s1[i]); + char c2 = (char)toupper(s2[i]); + if (c1 == c2) { ++MatchedLetters; } @@ -288,11 +292,11 @@ void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & // Converts a stream of BE shorts into UTF-8 string; returns a ref to a_UTF8 -AString & RawBEToUTF8(const char * a_RawData, int a_NumShorts, AString & a_UTF8) +AString & RawBEToUTF8(const char * a_RawData, size_t a_NumShorts, AString & a_UTF8) { a_UTF8.clear(); a_UTF8.reserve(3 * a_NumShorts / 2); // a quick guess of the resulting size - for (int i = 0; i < a_NumShorts; i++) + for (size_t i = 0; i < a_NumShorts; i++) { int c = GetBEShort(&a_RawData[i * 2]); if (c < 0x80) diff --git a/src/StringUtils.h b/src/StringUtils.h index b69e47d3c..caad85aef 100644 --- a/src/StringUtils.h +++ b/src/StringUtils.h @@ -52,13 +52,13 @@ extern AString & StrToLower(AString & s); extern int NoCaseCompare(const AString & s1, const AString & s2); // tolua_export /// Case-insensitive string comparison that returns a rating of equal-ness between [0 - s1.length()] -extern unsigned int RateCompareString(const AString & s1, const AString & s2 ); +extern size_t RateCompareString(const AString & s1, const AString & s2); /// Replaces *each* occurence of iNeedle in iHayStack with iReplaceWith extern void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & iReplaceWith); // tolua_export /// Converts a stream of BE shorts into UTF-8 string; returns a ref to a_UTF8 -extern AString & RawBEToUTF8(const char * a_RawData, int a_NumShorts, AString & a_UTF8); +extern AString & RawBEToUTF8(const char * a_RawData, size_t a_NumShorts, AString & a_UTF8); /// Converts a UTF-8 string into a UTF-16 BE string, packing that back into AString; return a ref to a_UTF16 extern AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a_UTF16); diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 13a9f9b92..788974f9c 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -891,7 +891,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) while ((DamageDiff > 0) && (x < SecondInput.m_ItemCount)) { Input.m_ItemDamage -= DamageDiff; - NeedExp += std::max(1, DamageDiff / 100) + Input.m_Enchantments.Count(); + NeedExp += std::max(1, DamageDiff / 100) + (int)Input.m_Enchantments.Count(); DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4); ++x; diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 4991f0147..46885390b 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -591,7 +591,7 @@ void cWindow::OnLeftPaintEnd(cPlayer & a_Player) const cSlotNums & SlotNums = a_Player.GetInventoryPaintSlots(); cItem ToDistribute(a_Player.GetDraggingItem()); - int ToEachSlot = (int)ToDistribute.m_ItemCount / SlotNums.size(); + int ToEachSlot = (int)ToDistribute.m_ItemCount / (int)SlotNums.size(); int NumDistributed = DistributeItemToSlots(a_Player, ToDistribute, ToEachSlot, SlotNums); diff --git a/src/World.cpp b/src/World.cpp index 5ac8e0a6e..b20e017bc 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2402,13 +2402,13 @@ bool cWorld::DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback) { cPlayer * BestMatch = NULL; - unsigned int BestRating = 0; - unsigned int NameLength = a_PlayerNameHint.length(); + size_t BestRating = 0; + size_t NameLength = a_PlayerNameHint.length(); cCSLock Lock(m_CSPlayers); for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { - unsigned int Rating = RateCompareString (a_PlayerNameHint, (*itr)->GetName()); + size_t Rating = RateCompareString (a_PlayerNameHint, (*itr)->GetName()); if (Rating >= BestRating) { BestMatch = *itr; @@ -2422,7 +2422,6 @@ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCa if (BestMatch != NULL) { - LOG("Compared %s and %s with rating %i", a_PlayerNameHint.c_str(), BestMatch->GetName().c_str(), BestRating); return a_Callback.Item (BestMatch); } return false; diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index ac9a21205..52e998f88 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -38,7 +38,7 @@ -cParsedNBT::cParsedNBT(const char * a_Data, int a_Length) : +cParsedNBT::cParsedNBT(const char * a_Data, size_t a_Length) : m_Data(a_Data), m_Length(a_Length), m_Pos(0) @@ -99,8 +99,10 @@ bool cParsedNBT::ReadString(int & a_StringStart, int & a_StringLen) bool cParsedNBT::ReadCompound(void) { + ASSERT(m_Tags.size() > 0); + // Reads the latest tag as a compound - int ParentIdx = m_Tags.size() - 1; + int ParentIdx = (int)m_Tags.size() - 1; int PrevSibling = -1; for (;;) { @@ -114,13 +116,13 @@ bool cParsedNBT::ReadCompound(void) m_Tags.push_back(cFastNBTTag(TagType, ParentIdx, PrevSibling)); if (PrevSibling >= 0) { - m_Tags[PrevSibling].m_NextSibling = m_Tags.size() - 1; + m_Tags[PrevSibling].m_NextSibling = (int)m_Tags.size() - 1; } else { - m_Tags[ParentIdx].m_FirstChild = m_Tags.size() - 1; + m_Tags[ParentIdx].m_FirstChild = (int)m_Tags.size() - 1; } - PrevSibling = m_Tags.size() - 1; + PrevSibling = (int)m_Tags.size() - 1; RETURN_FALSE_IF_FALSE(ReadString(m_Tags.back().m_NameStart, m_Tags.back().m_NameLength)); RETURN_FALSE_IF_FALSE(ReadTag()); } // while (true) @@ -146,20 +148,20 @@ bool cParsedNBT::ReadList(eTagType a_ChildrenType) } // Read items: - int ParentIdx = m_Tags.size() - 1; + int ParentIdx = (int)m_Tags.size() - 1; int PrevSibling = -1; for (int i = 0; i < Count; i++) { m_Tags.push_back(cFastNBTTag(a_ChildrenType, ParentIdx, PrevSibling)); if (PrevSibling >= 0) { - m_Tags[PrevSibling].m_NextSibling = m_Tags.size() - 1; + m_Tags[PrevSibling].m_NextSibling = (int)m_Tags.size() - 1; } else { - m_Tags[ParentIdx].m_FirstChild = m_Tags.size() - 1; + m_Tags[ParentIdx].m_FirstChild = (int)m_Tags.size() - 1; } - PrevSibling = m_Tags.size() - 1; + PrevSibling = (int)m_Tags.size() - 1; RETURN_FALSE_IF_FALSE(ReadTag()); } // for (i) m_Tags[ParentIdx].m_LastChild = PrevSibling; @@ -336,7 +338,7 @@ cFastNBTWriter::cFastNBTWriter(const AString & a_RootTagName) : m_Stack[0].m_Type = TAG_Compound; m_Result.reserve(100 * 1024); m_Result.push_back(TAG_Compound); - WriteString(a_RootTagName.data(), a_RootTagName.size()); + WriteString(a_RootTagName.data(), (UInt16)a_RootTagName.size()); } @@ -389,7 +391,7 @@ void cFastNBTWriter::BeginList(const AString & a_Name, eTagType a_ChildrenType) ++m_CurrentStack; m_Stack[m_CurrentStack].m_Type = TAG_List; - m_Stack[m_CurrentStack].m_Pos = m_Result.size() - 4; + m_Stack[m_CurrentStack].m_Pos = (int)m_Result.size() - 4; m_Stack[m_CurrentStack].m_Count = 0; m_Stack[m_CurrentStack].m_ItemType = a_ChildrenType; } @@ -493,7 +495,7 @@ void cFastNBTWriter::AddString(const AString & a_Name, const AString & a_Value) void cFastNBTWriter::AddByteArray(const AString & a_Name, const char * a_Value, size_t a_NumElements) { TagCommon(a_Name, TAG_ByteArray); - Int32 len = htonl(a_NumElements); + u_long len = htonl((u_long)a_NumElements); m_Result.append((const char *)&len, 4); m_Result.append(a_Value, a_NumElements); } @@ -505,7 +507,7 @@ void cFastNBTWriter::AddByteArray(const AString & a_Name, const char * a_Value, void cFastNBTWriter::AddIntArray(const AString & a_Name, const int * a_Value, size_t a_NumElements) { TagCommon(a_Name, TAG_IntArray); - Int32 len = htonl(a_NumElements); + u_long len = htonl((u_long)a_NumElements); size_t cap = m_Result.capacity(); size_t size = m_Result.length(); if ((cap - size) < (4 + a_NumElements * 4)) @@ -534,7 +536,7 @@ void cFastNBTWriter::Finish(void) -void cFastNBTWriter::WriteString(const char * a_Data, short a_Length) +void cFastNBTWriter::WriteString(const char * a_Data, UInt16 a_Length) { Int16 Len = htons(a_Length); m_Result.append((const char *)&Len, 2); diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h index bcf93228f..7b0af4927 100644 --- a/src/WorldStorage/FastNBT.h +++ b/src/WorldStorage/FastNBT.h @@ -114,7 +114,7 @@ Each primitive tag also stores the length of the contained data, in bytes. class cParsedNBT { public: - cParsedNBT(const char * a_Data, int a_Length); + cParsedNBT(const char * a_Data, size_t a_Length); bool IsValid(void) const {return m_IsValid; } @@ -251,7 +251,7 @@ public: protected: const char * m_Data; - int m_Length; + size_t m_Length; std::vector m_Tags; bool m_IsValid; // True if parsing succeeded @@ -319,7 +319,7 @@ protected: bool IsStackTopCompound(void) const { return (m_Stack[m_CurrentStack].m_Type == TAG_Compound); } - void WriteString(const char * a_Data, short a_Length); + void WriteString(const char * a_Data, UInt16 a_Length); inline void TagCommon(const AString & a_Name, eTagType a_Type) { @@ -330,7 +330,7 @@ protected: { // Compound: add the type and name: m_Result.push_back((char)a_Type); - WriteString(a_Name.c_str(), (short)a_Name.length()); + WriteString(a_Name.c_str(), (UInt16)a_Name.length()); } else { diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp index 9d594a084..2e356b172 100644 --- a/src/WorldStorage/SchematicFileSerializer.cpp +++ b/src/WorldStorage/SchematicFileSerializer.cpp @@ -230,7 +230,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP } // Copy the block types and metas: - int NumBytes = a_BlockArea.GetBlockCount(); + int NumBytes = (int)a_BlockArea.GetBlockCount(); if (a_NBT.GetDataLength(TBlockTypes) < NumBytes) { LOG("BlockTypes truncated in the schematic file (exp %d, got %d bytes). Loading partial.", @@ -242,7 +242,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP if (AreMetasPresent) { - int NumBytes = a_BlockArea.GetBlockCount(); + int NumBytes = (int)a_BlockArea.GetBlockCount(); if (a_NBT.GetDataLength(TBlockMetas) < NumBytes) { LOG("BlockMetas truncated in the schematic file (exp %d, got %d bytes). Loading partial.", diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index a98ed81f7..c6b0472d0 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -96,7 +96,7 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) : gzFile gz = gzopen((FILE_IO_PREFIX + fnam).c_str(), "wb"); if (gz != NULL) { - gzwrite(gz, Writer.GetResult().data(), Writer.GetResult().size()); + gzwrite(gz, Writer.GetResult().data(), (unsigned)Writer.GetResult().size()); } gzclose(gz); } @@ -252,7 +252,7 @@ bool cWSSAnvil::LoadChunkFromData(const cChunkCoords & a_Chunk, const AString & strm.next_out = (Bytef *)Uncompressed; strm.avail_out = sizeof(Uncompressed); strm.next_in = (Bytef *)a_Data.data(); - strm.avail_in = a_Data.size(); + strm.avail_in = (uInt)a_Data.size(); int res = inflate(&strm, Z_FINISH); inflateEnd(&strm); if (res != Z_STREAM_END) @@ -2682,7 +2682,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri // Store the chunk data: m_File.Seek(ChunkSector * 4096); - unsigned ChunkSize = htonl(a_Data.size() + 1); + u_long ChunkSize = htonl((u_long)a_Data.size() + 1); if (m_File.Write(&ChunkSize, 4) != 4) { LOGWARNING("Cannot save chunk [%d, %d], writing(1) data to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str()); @@ -2706,7 +2706,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri m_File.Write(Padding, 4096 - (BytesWritten % 4096)); // Store the header: - ChunkSize = (a_Data.size() + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size *up* to nearest 4KB sector, make it a sector number + ChunkSize = ((u_long)a_Data.size() + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size *up* to nearest 4KB sector, make it a sector number ASSERT(ChunkSize < 256); m_Header[LocalX + 32 * LocalZ] = htonl((ChunkSector << 8) | ChunkSize); if (m_File.Seek(0) < 0) diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index 359bac4a8..6d06b8fe3 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -601,7 +601,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() // Decompress the data: AString UncompressedData; { - int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, UncompressedSize); + int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, (size_t)UncompressedSize); if (errorcode != Z_OK) { LOGERROR("Error %d decompressing data for chunk [%d, %d]", @@ -681,7 +681,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() // Re-compress data AString CompressedData; { - int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData,m_CompressionFactor); + int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData, m_CompressionFactor); if (errorcode != Z_OK) { LOGERROR("Error %d compressing data for chunk [%d, %d]", @@ -693,9 +693,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() } // Save into file's cache - Header->m_UncompressedSize = Converted.size(); - Header->m_CompressedSize = CompressedData.size(); - NewDataContents.append( CompressedData ); + Header->m_UncompressedSize = (int)Converted.size(); + Header->m_CompressedSize = (int)CompressedData.size(); + NewDataContents.append(CompressedData); } // Done converting @@ -731,7 +731,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() Offset += Header->m_CompressedSize; // Crude data integrity check: - const int ExpectedSize = (16*256*16)*2 + (16*256*16)/2; // For version 2 + const int ExpectedSize = (16 * 256 * 16) * 2 + (16 * 256 * 16) / 2; // For version 2 if (UncompressedSize < ExpectedSize) { LOGWARNING("Chunk [%d, %d] has too short decompressed data (%d bytes out of %d needed), erasing", @@ -745,7 +745,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() // Decompress the data: AString UncompressedData; { - int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, UncompressedSize); + int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, (size_t)UncompressedSize); if (errorcode != Z_OK) { LOGERROR("Error %d decompressing data for chunk [%d, %d]", @@ -829,9 +829,9 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() } // Save into file's cache - Header->m_UncompressedSize = Converted.size(); - Header->m_CompressedSize = CompressedData.size(); - NewDataContents.append( CompressedData ); + Header->m_UncompressedSize = (int)Converted.size(); + Header->m_CompressedSize = (int)CompressedData.size(); + NewDataContents.append(CompressedData); } // Done converting @@ -861,7 +861,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre // Decompress the data: AString UncompressedData; - int errorcode = UncompressString(a_Data.data(), a_Data.size(), UncompressedData, a_UncompressedSize); + int errorcode = UncompressString(a_Data.data(), a_Data.size(), UncompressedData, (size_t)a_UncompressedSize); if (errorcode != Z_OK) { LOGERROR("Error %d decompressing data for chunk [%d, %d]", @@ -873,7 +873,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre if (a_UncompressedSize != (int)UncompressedData.size()) { - LOGWARNING("Uncompressed data size differs (exp %d bytes, got " SIZE_T_FMT ") for chunk [%d, %d]", + LOGWARNING("Uncompressed data size differs (exp %d bytes, got " SIZE_T_FMT ") for chunk [%d, %d]", a_UncompressedSize, UncompressedData.size(), a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ ); -- cgit v1.2.3 From 56ad2c21242b35d6c1054f0526903760c3b4e666 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 9 May 2014 09:07:54 +0200 Subject: Lighting thread disabled its chunkstays before deleting them. --- src/LightingThread.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index 5ba2940d2..5459644af 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -106,11 +106,13 @@ void cLightingThread::Stop(void) cCSLock Lock(m_CS); for (cChunkStays::iterator itr = m_PendingQueue.begin(), end = m_PendingQueue.end(); itr != end; ++itr) { + (*itr)->Disable(); delete *itr; } m_PendingQueue.clear(); for (cChunkStays::iterator itr = m_Queue.begin(), end = m_Queue.end(); itr != end; ++itr) { + (*itr)->Disable(); delete *itr; } m_Queue.clear(); -- cgit v1.2.3 From dd350bc1f3df51a6e4b956ee5cdbc3ecae8ddeb6 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 9 May 2014 18:31:48 +0200 Subject: World pre-generation distance is settable in world.ini. --- src/World.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/World.cpp b/src/World.cpp index b20e017bc..807065bfa 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -394,10 +394,14 @@ void cWorld::InitializeSpawn(void) // For the debugging builds, don't make the server build too much world upon start: #if defined(_DEBUG) || defined(ANDROID_NDK) - int ViewDist = 9; + const int DefaultViewDist = 9; #else - int ViewDist = 20; // Always prepare an area 20 chunks across, no matter what the actual cClientHandle::VIEWDISTANCE is + const int DefaultViewDist = 20; // Always prepare an area 20 chunks across, no matter what the actual cClientHandle::VIEWDISTANCE is #endif // _DEBUG + cIniFile IniFile; + IniFile.ReadFile(m_IniFileName); + int ViewDist = IniFile.GetValueSetI("SpawnPosition", "PregenerateDistance", DefaultViewDist); + IniFile.WriteFile(m_IniFileName); LOG("Preparing spawn area in world \"%s\"...", m_WorldName.c_str()); for (int x = 0; x < ViewDist; x++) -- cgit v1.2.3 From c4cd201f184ab3a6212dd0d1fbb9e0e40e755352 Mon Sep 17 00:00:00 2001 From: worktycho Date: Fri, 9 May 2014 17:39:13 +0100 Subject: Range Check on schematic size Fixes CID 55830 --- src/WorldStorage/SchematicFileSerializer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp index 9d594a084..115b2e869 100644 --- a/src/WorldStorage/SchematicFileSerializer.cpp +++ b/src/WorldStorage/SchematicFileSerializer.cpp @@ -192,7 +192,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP int SizeX = a_NBT.GetShort(TSizeX); int SizeY = a_NBT.GetShort(TSizeY); int SizeZ = a_NBT.GetShort(TSizeZ); - if ((SizeX < 1) || (SizeY < 1) || (SizeZ < 1)) + if ((SizeX < 1) || (SizeX > 65535) || (SizeY < 1) || (SizeY > 256) || (SizeZ < 1) || (SizeZ > 65535)) { LOG("Dimensions are invalid in the schematic file: %d, %d, %d", SizeX, SizeY, SizeZ); return false; -- cgit v1.2.3 From 5b54dc3eacca565531446d9c8cc9be7be084670c Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 9 May 2014 19:33:22 +0200 Subject: Build fixes after the last size_t batch. --- src/WorldStorage/FastNBT.cpp | 4 ++-- src/WorldStorage/FastNBT.h | 14 +++++++------- src/WorldStorage/FireworksSerializer.cpp | 4 ++-- src/WorldStorage/SchematicFileSerializer.cpp | 4 ++-- src/WorldStorage/WSSAnvil.cpp | 2 +- src/WorldStorage/WSSAnvil.h | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index 52e998f88..c4a6a7a5b 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -79,11 +79,11 @@ bool cParsedNBT::Parse(void) -bool cParsedNBT::ReadString(int & a_StringStart, int & a_StringLen) +bool cParsedNBT::ReadString(size_t & a_StringStart, size_t & a_StringLen) { NEEDBYTES(2); a_StringStart = m_Pos + 2; - a_StringLen = GetBEShort(m_Data + m_Pos); + a_StringLen = (size_t)GetBEShort(m_Data + m_Pos); if (a_StringLen < 0) { // Invalid string length diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h index 7b0af4927..fe28005ac 100644 --- a/src/WorldStorage/FastNBT.h +++ b/src/WorldStorage/FastNBT.h @@ -61,10 +61,10 @@ public: // The following members are indices into the data stream. m_DataLength == 0 if no data available // They must not be pointers, because the datastream may be copied into another AString object in the meantime. - int m_NameStart; - int m_NameLength; - int m_DataStart; - int m_DataLength; + size_t m_NameStart; + size_t m_NameLength; + size_t m_DataStart; + size_t m_DataLength; // The following members are indices into the array returned; -1 if not valid // They must not be pointers, because pointers would not survive std::vector reallocation @@ -135,7 +135,7 @@ public: /** Returns the length of the tag's data, in bytes. Not valid for Compound or List tags! */ - int GetDataLength (int a_Tag) const + size_t GetDataLength (int a_Tag) const { ASSERT(m_Tags[(size_t)a_Tag].m_Type != TAG_List); ASSERT(m_Tags[(size_t)a_Tag].m_Type != TAG_Compound); @@ -256,10 +256,10 @@ protected: bool m_IsValid; // True if parsing succeeded // Used while parsing: - int m_Pos; + size_t m_Pos; bool Parse(void); - bool ReadString(int & a_StringStart, int & a_StringLen); // Reads a simple string (2 bytes length + data), sets the string descriptors + bool ReadString(size_t & a_StringStart, size_t & a_StringLen); // Reads a simple string (2 bytes length + data), sets the string descriptors bool ReadCompound(void); // Reads the latest tag as a compound bool ReadList(eTagType a_ChildrenType); // Reads the latest tag as a list of items of type a_ChildrenType bool ReadTag(void); // Reads the latest tag, depending on its m_Type setting diff --git a/src/WorldStorage/FireworksSerializer.cpp b/src/WorldStorage/FireworksSerializer.cpp index e0cd69634..263c77a1c 100644 --- a/src/WorldStorage/FireworksSerializer.cpp +++ b/src/WorldStorage/FireworksSerializer.cpp @@ -96,7 +96,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB if (ExplosionName == "Colors") { // Divide by four as data length returned in bytes - int DataLength = a_NBT.GetDataLength(explosiontag); + size_t DataLength = a_NBT.GetDataLength(explosiontag); // round to the next highest multiple of four DataLength -= DataLength % 4; if (DataLength == 0) @@ -112,7 +112,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB } else if (ExplosionName == "FadeColors") { - int DataLength = a_NBT.GetDataLength(explosiontag) / 4; + size_t DataLength = a_NBT.GetDataLength(explosiontag) / 4; // round to the next highest multiple of four DataLength -= DataLength % 4; if (DataLength == 0) diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp index 2e356b172..5cbff376b 100644 --- a/src/WorldStorage/SchematicFileSerializer.cpp +++ b/src/WorldStorage/SchematicFileSerializer.cpp @@ -230,7 +230,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP } // Copy the block types and metas: - int NumBytes = (int)a_BlockArea.GetBlockCount(); + size_t NumBytes = a_BlockArea.GetBlockCount(); if (a_NBT.GetDataLength(TBlockTypes) < NumBytes) { LOG("BlockTypes truncated in the schematic file (exp %d, got %d bytes). Loading partial.", @@ -242,7 +242,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP if (AreMetasPresent) { - int NumBytes = (int)a_BlockArea.GetBlockCount(); + size_t NumBytes = a_BlockArea.GetBlockCount(); if (a_NBT.GetDataLength(TBlockMetas) < NumBytes) { LOG("BlockMetas truncated in the schematic file (exp %d, got %d bytes). Loading partial.", diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index c6b0472d0..52cea462c 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1078,7 +1078,7 @@ void cWSSAnvil::LoadCommandBlockFromNBT(cBlockEntityList & a_BlockEntities, cons -void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, int a_IDTagLength) +void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, size_t a_IDTagLength) { if (strncmp(a_IDTag, "Boat", a_IDTagLength) == 0) { diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h index 1773ee882..1493f5f33 100644 --- a/src/WorldStorage/WSSAnvil.h +++ b/src/WorldStorage/WSSAnvil.h @@ -145,7 +145,7 @@ protected: void LoadMobHeadFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadCommandBlockFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); - void LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, int a_IDTagLength); + void LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, size_t a_IDTagLength); void LoadBoatFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadEnderCrystalFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); -- cgit v1.2.3 From b997fbaf4577f0c3ff4f60f1a9ab2ca93c5f0d71 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 9 May 2014 19:35:35 +0200 Subject: Removed an unused macro. --- src/Generating/Caves.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src') diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index 48663c21a..872e3341d 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -35,13 +35,6 @@ reduced in complexity in order for this generator to be useful, so the caves' sh -/// How many nests in each direction are generated for a given chunk. Must be an even number -#define NEIGHBORHOOD_SIZE 8 - - - - - const int MIN_RADIUS = 3; const int MAX_RADIUS = 8; -- cgit v1.2.3 From 0fc60edaeb4bc54b87bc3d7af4631802c0331303 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 9 May 2014 19:53:57 +0200 Subject: Removed an unused NetherFortGen variable. --- src/Generating/NetherFortGen.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/Generating/NetherFortGen.cpp b/src/Generating/NetherFortGen.cpp index ac7fd0b7b..3867ec80c 100644 --- a/src/Generating/NetherFortGen.cpp +++ b/src/Generating/NetherFortGen.cpp @@ -11,12 +11,6 @@ -static const int NEIGHBORHOOD_SIZE = 3; - - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cNetherFortGen::cNetherFort: -- cgit v1.2.3 From d67ea97a266412c2ca1d45d5e907f3072e0b53a2 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 9 May 2014 19:57:59 +0200 Subject: More size_t fixes. --- src/WorldStorage/WSSAnvil.cpp | 10 +++++----- src/WorldStorage/WSSAnvil.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 52cea462c..d310c9124 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -405,7 +405,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT -void cWSSAnvil::CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, char * a_Destination, int a_Length) +void cWSSAnvil::CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, char * a_Destination, size_t a_Length) { int Child = a_NBT.FindChildByName(a_Tag, a_ChildName); if ((Child >= 0) && (a_NBT.GetType(Child) == TAG_ByteArray) && (a_NBT.GetDataLength(Child) == a_Length)) @@ -440,8 +440,8 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_ // Save blockdata: a_Writer.BeginList("Sections", TAG_Compound); - int SliceSizeBlock = cChunkDef::Width * cChunkDef::Width * 16; - int SliceSizeNibble = SliceSizeBlock / 2; + size_t SliceSizeBlock = cChunkDef::Width * cChunkDef::Width * 16; + size_t SliceSizeNibble = SliceSizeBlock / 2; const char * BlockTypes = (const char *)(Serializer.m_BlockTypes); const char * BlockMetas = (const char *)(Serializer.m_BlockMetas); #ifdef DEBUG_SKYLIGHT @@ -2630,14 +2630,14 @@ bool cWSSAnvil::cMCAFile::GetChunkData(const cChunkCoords & a_Chunk, AString & a unsigned ChunkLocation = ntohl(m_Header[LocalX + 32 * LocalZ]); unsigned ChunkOffset = ChunkLocation >> 8; - m_File.Seek(ChunkOffset * 4096); + m_File.Seek((int)ChunkOffset * 4096); int ChunkSize = 0; if (m_File.Read(&ChunkSize, 4) != 4) { return false; } - ChunkSize = ntohl(ChunkSize); + ChunkSize = ntohl((u_long)ChunkSize); char CompressionType = 0; if (m_File.Read(&CompressionType, 1) != 1) { diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h index 1493f5f33..7542a828a 100644 --- a/src/WorldStorage/WSSAnvil.h +++ b/src/WorldStorage/WSSAnvil.h @@ -221,7 +221,7 @@ protected: cMCAFile * LoadMCAFile(const cChunkCoords & a_Chunk); /// Copies a_Length bytes of data from the specified NBT Tag's Child into the a_Destination buffer - void CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, char * a_Destination, int a_Length); + void CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, char * a_Destination, size_t a_Length); // cWSSchema overrides: virtual bool LoadChunk(const cChunkCoords & a_Chunk) override; -- cgit v1.2.3 From 294b7ca24a09b61cbac0bd43d9b287af21848c24 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 9 May 2014 20:05:00 +0200 Subject: Even more size_t fixes. --- src/WorldStorage/FastNBT.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index c4a6a7a5b..a047d67c7 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -29,7 +29,7 @@ // cParsedNBT: #define NEEDBYTES(N) \ - if (m_Length - m_Pos < N) \ + if (m_Length - m_Pos < (size_t)N) \ { \ return false; \ } @@ -84,9 +84,9 @@ bool cParsedNBT::ReadString(size_t & a_StringStart, size_t & a_StringLen) NEEDBYTES(2); a_StringStart = m_Pos + 2; a_StringLen = (size_t)GetBEShort(m_Data + m_Pos); - if (a_StringLen < 0) + if (a_StringLen > 0xffff) { - // Invalid string length + // Suspicious string length return false; } m_Pos += 2 + a_StringLen; @@ -281,7 +281,7 @@ int cParsedNBT::FindChildByName(int a_Tag, const char * a_Name, size_t a_NameLen for (int Child = m_Tags[a_Tag].m_FirstChild; Child != -1; Child = m_Tags[Child].m_NextSibling) { if ( - (m_Tags[Child].m_NameLength == (int)a_NameLength) && + (m_Tags[Child].m_NameLength == a_NameLength) && (memcmp(m_Data + m_Tags[Child].m_NameStart, a_Name, a_NameLength) == 0) ) { -- cgit v1.2.3 From a936736acd822b29d09b4344ece768656b4d24db Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 9 May 2014 20:13:20 +0200 Subject: Removed unused constants from MineShafts and Ravines. --- src/Generating/MineShafts.cpp | 6 ------ src/Generating/Ravines.cpp | 3 --- 2 files changed, 9 deletions(-) (limited to 'src') diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index 7b26c2b62..391e4c04f 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -25,12 +25,6 @@ in a depth-first processing. Each of the descendants will branch randomly, if no -static const int NEIGHBORHOOD_SIZE = 3; - - - - - class cMineShaft abstract { public: diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index 78093f5ee..2722e4ca3 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -9,9 +9,6 @@ -/// How many ravines in each direction are generated for a given chunk. Must be an even number -static const int NEIGHBORHOOD_SIZE = 8; - static const int NUM_RAVINE_POINTS = 4; -- cgit v1.2.3 From 1a5a1233010a8072f26620866893cc7a3540a550 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 9 May 2014 20:16:29 +0200 Subject: Fixed message formatting. --- src/WorldStorage/SchematicFileSerializer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp index 5cbff376b..d3a708f92 100644 --- a/src/WorldStorage/SchematicFileSerializer.cpp +++ b/src/WorldStorage/SchematicFileSerializer.cpp @@ -234,7 +234,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP if (a_NBT.GetDataLength(TBlockTypes) < NumBytes) { LOG("BlockTypes truncated in the schematic file (exp %d, got %d bytes). Loading partial.", - NumBytes, a_NBT.GetDataLength(TBlockTypes) + (int)NumBytes, (int)a_NBT.GetDataLength(TBlockTypes) ); NumBytes = a_NBT.GetDataLength(TBlockTypes); } @@ -246,7 +246,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP if (a_NBT.GetDataLength(TBlockMetas) < NumBytes) { LOG("BlockMetas truncated in the schematic file (exp %d, got %d bytes). Loading partial.", - NumBytes, a_NBT.GetDataLength(TBlockMetas) + (int)NumBytes, (int)a_NBT.GetDataLength(TBlockMetas) ); NumBytes = a_NBT.GetDataLength(TBlockMetas); } -- cgit v1.2.3 From a2e18f0e01edf5a8e61ac0de1356b98d6a5af1de Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 9 May 2014 20:32:27 +0200 Subject: Fixed size_t in FireworksSerializer. --- src/WorldStorage/FireworksSerializer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/WorldStorage/FireworksSerializer.cpp b/src/WorldStorage/FireworksSerializer.cpp index 263c77a1c..181cfde0d 100644 --- a/src/WorldStorage/FireworksSerializer.cpp +++ b/src/WorldStorage/FireworksSerializer.cpp @@ -105,7 +105,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB } const char * ColourData = (a_NBT.GetData(explosiontag)); - for (int i = 0; i < DataLength; i += 4 /* Size of network int*/) + for (size_t i = 0; i < DataLength; i += 4) { a_FireworkItem.m_Colours.push_back(GetBEInt(ColourData + i)); } @@ -121,7 +121,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB } const char * FadeColourData = (a_NBT.GetData(explosiontag)); - for (int i = 0; i < DataLength; i += 4 /* Size of network int*/) + for (size_t i = 0; i < DataLength; i += 4) { a_FireworkItem.m_FadeColours.push_back(GetBEInt(FadeColourData + i)); } -- cgit v1.2.3 From c8631d9a9b924c4c4d030bac3ed4e4a869ec2fd8 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 9 May 2014 23:10:02 +0200 Subject: Add DIG_STATUS_CANCELLED packet and add item resend, when a block can't place/break. --- src/ClientHandle.cpp | 61 +++++++++++++++++++++++++++++++++++++--------------- src/ClientHandle.h | 3 +++ src/Inventory.cpp | 10 +++++++++ src/Inventory.h | 41 +++++++++++++++++++---------------- 4 files changed, 79 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 94f031ed6..1535b0482 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -878,6 +878,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB case DIG_STATUS_CANCELLED: { // Block breaking cancelled by player + HandleBlockDigCancel(); return; } @@ -916,7 +917,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc // It is a duplicate packet, drop it right away return; } - + if ( m_Player->IsGameModeCreative() && ItemCategory::IsSword(m_Player->GetInventory().GetEquippedItem().m_ItemType) @@ -925,14 +926,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc // Players can't destroy blocks with a Sword in the hand. return; } - - if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta)) - { - // A plugin doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows: - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - return; - } - + // Set the last digging coords to the block being dug, so that they can be checked in DIG_FINISHED to avoid dig/aim bug in the client: m_HasStartedDigging = true; m_LastDigBlockX = a_BlockX; @@ -1004,16 +998,16 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo return; } - m_HasStartedDigging = false; - if (m_BlockDigAnimStage != -1) - { - // End dig animation - m_BlockDigAnimStage = -1; - // It seems that 10 ends block animation - m_Player->GetWorld()->BroadcastBlockBreakAnimation(m_UniqueID, m_BlockDigAnimX, m_BlockDigAnimY, m_BlockDigAnimZ, 10, this); - } + HandleBlockDigCancel(); cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem()); + + if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta)) + { + // A plugin doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows: + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + return; + } if (a_OldBlock == E_BLOCK_AIR) { @@ -1036,6 +1030,36 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo +void cClientHandle::HandleBlockDigCancel() +{ + if ( + !m_HasStartedDigging || // Hasn't received the DIG_STARTED packet + (m_LastDigBlockX == -1) || + (m_LastDigBlockY == -1) || + (m_LastDigBlockZ == -1) + ) + { + return; + } + + m_HasStartedDigging = false; + if (m_BlockDigAnimStage != -1) + { + // End dig animation + m_BlockDigAnimStage = -1; + // It seems that 10 ends block animation + m_Player->GetWorld()->BroadcastBlockBreakAnimation(m_UniqueID, m_LastDigBlockX, m_LastDigBlockY, m_LastDigBlockZ, 10, this); + } + + m_BlockDigAnimX = -1; + m_BlockDigAnimY = -1; + m_BlockDigAnimZ = -1; +} + + + + + void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, const cItem & a_HeldItem) { LOGD("HandleRightClick: {%d, %d, %d}, face %d, HeldItem: %s", @@ -1058,6 +1082,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); //2 block high things + m_Player->GetInventory().SendEquippedSlot(); } return; } @@ -1246,6 +1271,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e { // Handler refused the placement, send that information back to the client: World->SendBlockTo(a_BlockX, a_BlockY, a_BlockY, m_Player); + m_Player->GetInventory().SendEquippedSlot(); return; } @@ -1255,6 +1281,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e { // A plugin doesn't agree with placing the block, revert the block on the client: World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + m_Player->GetInventory().SendEquippedSlot(); return; } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 4dc6ab074..03a716657 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -374,6 +374,9 @@ private: /** Handles the DIG_FINISHED dig packet: */ void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta); + /** Handles the DIG_CANCELLED dig packet: */ + void HandleBlockDigCancel(); + /** Converts the protocol-formatted channel list (NUL-separated) into a proper string vector. */ AStringVector BreakApartPluginChannels(const AString & a_PluginChannels); diff --git a/src/Inventory.cpp b/src/Inventory.cpp index a365e4ed4..bce882c88 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -243,6 +243,16 @@ void cInventory::SetHotbarSlot(int a_HotBarSlotNum, const cItem & a_Item) +void cInventory::SendEquippedSlot() +{ + int EquippedSlotNum = cInventory::invArmorCount + cInventory::invInventoryCount + GetEquippedSlotNum(); + SendSlot(EquippedSlotNum); +} + + + + + const cItem & cInventory::GetSlot(int a_SlotNum) const { if ((a_SlotNum < 0) || (a_SlotNum >= invNumSlots)) diff --git a/src/Inventory.h b/src/Inventory.h index 1ad7c4776..39aef1538 100644 --- a/src/Inventory.h +++ b/src/Inventory.h @@ -56,13 +56,13 @@ public: // tolua_begin - /// Removes all items from the entire inventory + /** Removes all items from the entire inventory */ void Clear(void); - /// Returns number of items out of a_ItemStack that can fit in the storage + /** Returns number of items out of a_ItemStack that can fit in the storage */ int HowManyCanFit(const cItem & a_ItemStack, bool a_ConsiderEmptySlots); - /// Returns how many items of the specified type would fit into the slot range specified + /** Returns how many items of the specified type would fit into the slot range specified */ int HowManyCanFit(const cItem & a_ItemStack, int a_BeginSlotNum, int a_EndSlotNum, bool a_ConsiderEmptySlots); /** Adds as many items out of a_ItemStack as can fit. @@ -86,33 +86,36 @@ public: */ int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, bool a_tryToFillEquippedFirst); - /// Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed + /** Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed */ bool RemoveOneEquippedItem(void); - /// Returns the number of items of type a_Item that are stored + /** Returns the number of items of type a_Item that are stored */ int HowManyItems(const cItem & a_Item); - /// Returns true if there are at least as many items of type a_ItemStack as in a_ItemStack + /** Returns true if there are at least as many items of type a_ItemStack as in a_ItemStack */ bool HasItems(const cItem & a_ItemStack); + + /** Sends the equipped item slot to the client */ + void SendEquippedSlot(); - /// Returns the cItemGrid object representing the armor slots + /** Returns the cItemGrid object representing the armor slots */ cItemGrid & GetArmorGrid(void) { return m_ArmorSlots; } - /// Returns the cItemGrid object representing the main inventory slots + /** Returns the cItemGrid object representing the main inventory slots */ cItemGrid & GetInventoryGrid(void) { return m_InventorySlots; } - /// Returns the cItemGrid object representing the hotbar slots + /** Returns the cItemGrid object representing the hotbar slots */ cItemGrid & GetHotbarGrid(void) { return m_HotbarSlots; } - /// Returns the player associated with this inventory + /** Returns the player associated with this inventory */ cPlayer & GetOwner(void) { return m_Owner; } - /// Copies the non-empty slots into a_ItemStacks; preserves the original a_Items contents + /** Copies the non-empty slots into a_ItemStacks; preserves the original a_Items contents */ void CopyToItems(cItems & a_Items); // tolua_end - /// Returns the player associated with this inventory (const version) + /** Returns the player associated with this inventory (const version) */ const cPlayer & GetOwner(void) const { return m_Owner; } // tolua_begin @@ -136,10 +139,10 @@ public: */ int ChangeSlotCount(int a_SlotNum, int a_AddToCount); - /// Adds the specified damage to the specified item; deletes the item and returns true if the item broke. + /** Adds the specified damage to the specified item; deletes the item and returns true if the item broke. */ bool DamageItem(int a_SlotNum, short a_Amount); - /// Adds the specified damage to the currently held item; deletes the item and returns true if the item broke. + /** Adds the specified damage to the currently held item; deletes the item and returns true if the item broke. */ bool DamageEquippedItem(short a_Amount = 1); const cItem & GetEquippedHelmet (void) const { return m_ArmorSlots.GetSlot(0); } @@ -149,13 +152,13 @@ public: // tolua_end - /// Sends the slot contents to the owner + /** Sends the slot contents to the owner */ void SendSlot(int a_SlotNum); - /// Update items (e.g. Maps) + /** Update items (e.g. Maps) */ void UpdateItems(void); - /// Converts an armor slot number into the ID for the EntityEquipment packet + /** Converts an armor slot number into the ID for the EntityEquipment packet */ static int ArmorSlotNumToEntityEquipmentID(short a_ArmorSlotNum); void SaveToJson(Json::Value & a_Value); @@ -172,10 +175,10 @@ protected: cPlayer & m_Owner; - /// Returns the ItemGrid and the (grid-local) slot number for a (global) slot number; return NULL for invalid SlotNum + /** Returns the ItemGrid and the (grid-local) slot number for a (global) slot number; return NULL for invalid SlotNum */ const cItemGrid * GetGridForSlotNum(int a_SlotNum, int & a_GridSlotNum) const; - /// Returns the ItemGrid and the (grid-local) slot number for a (global) slot number; return NULL for invalid SlotNum + /** Returns the ItemGrid and the (grid-local) slot number for a (global) slot number; return NULL for invalid SlotNum */ cItemGrid * GetGridForSlotNum(int a_SlotNum, int & a_GridSlotNum); // cItemGrid::cListener override: -- cgit v1.2.3 From eb0f713b6a5a7107a97284d1728858b4b2882c3d Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 9 May 2014 23:43:00 +0200 Subject: Add block place/break distance check. --- src/ClientHandle.cpp | 21 +++++++++++++++++++++ src/Defines.h | 10 ++++++++++ 2 files changed, 31 insertions(+) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 1535b0482..d1962506d 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1016,6 +1016,17 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo } cWorld * World = m_Player->GetWorld(); + + if ( + (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || + (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || + (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) + ) + { + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + return; + } + ItemHandler->OnBlockDestroyed(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ); // The ItemHandler is also responsible for spawning the pickups cChunkInterface ChunkInterface(World->GetChunkMap()); @@ -1191,6 +1202,16 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e // The block is being placed outside the world, ignore this packet altogether (#128) return; } + + if ( + (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || + (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || + (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) + ) + { + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + return; + } World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedBlockMeta); diff --git a/src/Defines.h b/src/Defines.h index 9fa3b3a8e..b0b209934 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -3,6 +3,7 @@ #include "ChatColor.h" #include +#include @@ -528,6 +529,15 @@ inline float GetSpecialSignf( float a_Val ) +template inline int Diff(T a_Val1, T a_Val2) +{ + return std::abs(a_Val1 - a_Val2); +} + + + + + // tolua_begin enum eMessageType -- cgit v1.2.3 From 683b839e2b3e634dd1a0a5b85327efe4ffa968fd Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 10 May 2014 09:21:29 +0200 Subject: Client cert is not requested. --- src/PolarSSL++/SslContext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/PolarSSL++/SslContext.cpp b/src/PolarSSL++/SslContext.cpp index bc397b655..c3074f197 100644 --- a/src/PolarSSL++/SslContext.cpp +++ b/src/PolarSSL++/SslContext.cpp @@ -59,7 +59,7 @@ int cSslContext::Initialize(bool a_IsClient, const SharedPtr & return res; } ssl_set_endpoint(&m_Ssl, a_IsClient ? SSL_IS_CLIENT : SSL_IS_SERVER); - ssl_set_authmode(&m_Ssl, SSL_VERIFY_OPTIONAL); + ssl_set_authmode(&m_Ssl, a_IsClient ? SSL_VERIFY_OPTIONAL : SSL_VERIFY_NONE); // Clients ask for server's cert but don't verify strictly; servers don't ask clients for certs by default ssl_set_rng(&m_Ssl, ctr_drbg_random, &m_CtrDrbg->m_CtrDrbg); ssl_set_bio(&m_Ssl, ReceiveEncrypted, this, SendEncrypted, this); -- cgit v1.2.3 From cb6200345cdfcf34ab4cd6b50cc268152324f9dd Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 10 May 2014 15:19:06 +0100 Subject: Fixed bug in setting metas --- src/Chunk.cpp | 18 ------------------ src/Chunk.h | 8 +++++++- 2 files changed, 7 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 0303e1502..a986ac076 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1568,24 +1568,6 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT -void cChunk::SetMeta(int a_BlockIdx, NIBBLETYPE a_Meta) -{ - if (GetNibble(m_BlockMeta, a_BlockIdx) == a_Meta) - { - return; - } - - MarkDirty(); - SetNibble(m_BlockMeta, a_BlockIdx, a_Meta); - Vector3i Coords(IndexToCoordinate(a_BlockIdx)); - - m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, Coords.x, Coords.y, Coords.z, GetBlock(a_BlockIdx), a_Meta)); -} - - - - - void cChunk::SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client) { diff --git a/src/Chunk.h b/src/Chunk.h index d2328971f..26f1e9d10 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -328,7 +328,13 @@ public: } inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta) { - m_ChunkBuffer.SetMeta(a_RelX, a_RelY, a_RelZ, a_Meta); + if (!GetMeta(a_RelX, a_RelY, a_RelZ) == a_Meta) + { + MarkDirty(); + m_ChunkBuffer.SetMeta(a_RelX, a_RelY, a_RelZ, a_Meta); + + m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), a_Meta)); + } } inline NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const {return m_ChunkBuffer.GetBlockLight(a_RelX, a_RelY, a_RelZ); } -- cgit v1.2.3 From 3b1f11bd6abff2e146135dc000855cf1269715fd Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 10 May 2014 16:43:06 +0200 Subject: Each time a portal block receives a tick it has a 1 in 500 chance of spawning a zombie pigman. --- src/Blocks/BlockPortal.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 21bcbdeea..9f78f230e 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -2,6 +2,7 @@ #pragma once #include "BlockHandler.h" +#include "../Mobs/Monster.h" @@ -38,6 +39,19 @@ public: return; // No pickups } + virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override + { + cFastRandom Random; + if (Random.NextInt(500) != 0) + { + return; + } + + int PosX = a_Chunk.GetPosX() * 16 + a_RelX; + int PosZ = a_Chunk.GetPosZ() * 16 + a_RelZ; + + a_WorldInterface.SpawnMob(PosX, a_RelY, PosZ, cMonster::eType::mtZombiePigman); + } virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { -- cgit v1.2.3 From 7f3683cfab490ca74eb61101dc00c57c2c6682e5 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 10 May 2014 17:03:02 +0200 Subject: A portal block now chooses a number between 2000 and 0 --- src/Blocks/BlockPortal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 9f78f230e..47f0bca64 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -42,7 +42,7 @@ public: virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override { cFastRandom Random; - if (Random.NextInt(500) != 0) + if (Random.NextInt(2000) != 0) { return; } -- cgit v1.2.3 From 4ca178f24ab74ee32340d40fad12a70e65a134df Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 10 May 2014 17:09:48 +0200 Subject: Fixed compile problem. --- src/Blocks/BlockPortal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 47f0bca64..3b8030028 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -50,7 +50,7 @@ public: int PosX = a_Chunk.GetPosX() * 16 + a_RelX; int PosZ = a_Chunk.GetPosZ() * 16 + a_RelZ; - a_WorldInterface.SpawnMob(PosX, a_RelY, PosZ, cMonster::eType::mtZombiePigman); + a_WorldInterface.SpawnMob(PosX, a_RelY, PosZ, cMonster::mtZombiePigman); } virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override -- cgit v1.2.3 From 079f8cd535e98bcf303667fb3394f779781c1527 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 10 May 2014 17:55:39 +0200 Subject: Fixed the console saying no plugins are loaded. --- src/Bindings/PluginManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 310ecc7e8..fc690d4de 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -144,7 +144,7 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) } size_t NumLoadedPlugins = GetNumPlugins(); - if (NumLoadedPlugins) + if (NumLoadedPlugins == 0) { LOG("-- No Plugins Loaded --"); } -- cgit v1.2.3 From 0adb5c94b8230b7a65fc06f90c253576755cedcd Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 10 May 2014 17:46:49 +0100 Subject: Fixed stupid buffer overflow in array setblocks --- src/ChunkBuffer.cpp | 6 +++--- src/ChunkBuffer.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ChunkBuffer.cpp b/src/ChunkBuffer.cpp index a41b8f61a..baeeff890 100644 --- a/src/ChunkBuffer.cpp +++ b/src/ChunkBuffer.cpp @@ -35,7 +35,7 @@ void cChunkBuffer::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length memcpy( &a_dest[i * segment_length], &m_Sections[i]->m_BlockTypes, - sizeof(BLOCKTYPE) * length + sizeof(BLOCKTYPE) * tocopy ); } else @@ -43,7 +43,7 @@ void cChunkBuffer::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length memset( &a_dest[i * segment_length], 0, - sizeof(BLOCKTYPE) * length + sizeof(BLOCKTYPE) * tocopy ); } } @@ -141,7 +141,7 @@ void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src) { for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; if (m_Sections[i]) { memcpy(&m_Sections[i]->m_BlockTypes, &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length); diff --git a/src/ChunkBuffer.h b/src/ChunkBuffer.h index 410532232..b1bd024d5 100644 --- a/src/ChunkBuffer.h +++ b/src/ChunkBuffer.h @@ -124,7 +124,7 @@ public: m_Sections[Section] = Allocate(); if(!m_Sections[Section]) { - ASSERT("Failed to allocate a new section in Chunkbuffer"); + ASSERT(!"Failed to allocate a new section in Chunkbuffer"); return; } } @@ -169,7 +169,7 @@ public: m_Sections[Section] = Allocate(); if(!m_Sections[Section]) { - ASSERT("Failed to allocate a new section in Chunkbuffer"); + ASSERT(!"Failed to allocate a new section in Chunkbuffer"); return; } } -- cgit v1.2.3 From 7ca33bd832575ea94f8409087c804feb86280c15 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 10 May 2014 17:56:59 +0100 Subject: Fixed stupid error --- src/Chunk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Chunk.h b/src/Chunk.h index 26f1e9d10..038be42de 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -328,7 +328,7 @@ public: } inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta) { - if (!GetMeta(a_RelX, a_RelY, a_RelZ) == a_Meta) + if (!(GetMeta(a_RelX, a_RelY, a_RelZ) == a_Meta)) { MarkDirty(); m_ChunkBuffer.SetMeta(a_RelX, a_RelY, a_RelZ, a_Meta); -- cgit v1.2.3 From 5c9f89526aeca7b32014cd78e323f74baddf1e36 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 11 May 2014 11:56:15 +0200 Subject: Rename HandleBlockDigCancel to FinishDigAnimtion. --- src/ClientHandle.cpp | 6 +++--- src/ClientHandle.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index d1962506d..9238418a4 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -878,7 +878,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB case DIG_STATUS_CANCELLED: { // Block breaking cancelled by player - HandleBlockDigCancel(); + FinishDigAnimation(); return; } @@ -998,7 +998,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo return; } - HandleBlockDigCancel(); + FinishDigAnimation(); cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem()); @@ -1041,7 +1041,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo -void cClientHandle::HandleBlockDigCancel() +void cClientHandle::FinishDigAnimation() { if ( !m_HasStartedDigging || // Hasn't received the DIG_STARTED packet diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 03a716657..85d348eee 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -374,8 +374,8 @@ private: /** Handles the DIG_FINISHED dig packet: */ void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta); - /** Handles the DIG_CANCELLED dig packet: */ - void HandleBlockDigCancel(); + /** The clients will receive a finished dig animation */ + void FinishDigAnimation(); /** Converts the protocol-formatted channel list (NUL-separated) into a proper string vector. */ AStringVector BreakApartPluginChannels(const AString & a_PluginChannels); -- cgit v1.2.3 From c7c3724a3ee0e7a77fe9924ad25c36b6ec8fdd14 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 11 May 2014 14:57:06 +0300 Subject: Statistic Manager --- src/Bindings/AllToLua.pkg | 1 + src/ClientHandle.cpp | 19 +++++- src/ClientHandle.h | 2 + src/Entities/Player.cpp | 21 +++++- src/Entities/Player.h | 7 ++ src/Protocol/Protocol.h | 2 + src/Protocol/Protocol125.cpp | 28 ++++++++ src/Protocol/Protocol125.h | 1 + src/Protocol/Protocol17x.cpp | 48 ++++++++++++-- src/Protocol/Protocol17x.h | 1 + src/Protocol/ProtocolRecognizer.cpp | 10 +++ src/Protocol/ProtocolRecognizer.h | 1 + src/Statistics.cpp | 123 +++++++++++++++++++++++++---------- src/Statistics.h | 48 ++++++++++++++ src/WorldStorage/StatSerializer.cpp | 126 ++++++++++++++++++++++++++++++++++++ src/WorldStorage/StatSerializer.h | 53 +++++++++++++++ 16 files changed, 448 insertions(+), 43 deletions(-) create mode 100644 src/WorldStorage/StatSerializer.cpp create mode 100644 src/WorldStorage/StatSerializer.h (limited to 'src') diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg index 1cd7c74f8..4fe86e1c5 100644 --- a/src/Bindings/AllToLua.pkg +++ b/src/Bindings/AllToLua.pkg @@ -76,6 +76,7 @@ $cfile "../CompositeChat.h" $cfile "../Map.h" $cfile "../MapManager.h" $cfile "../Scoreboard.h" +$cfile "../Statistics.h" diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 94f031ed6..03b1b0dc2 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -31,6 +31,8 @@ #include "CompositeChat.h" #include "Items/ItemSword.h" +#include "WorldStorage/StatSerializer.h" + #include "md5/md5.h" @@ -336,7 +338,13 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID) // Send scoreboard data World->GetScoreBoard().SendTo(*this); - + +#if 0 + // Load stats + cStatSerializer StatSerializer(World->GetName(), m_Player->GetName(), &m_Player->GetStatManager()); + StatSerializer.Load(); +#endif + // Delay the first ping until the client "settles down" // This should fix #889, "BadCast exception, cannot convert bit to fm" error in client cTimer t1; @@ -2437,6 +2445,15 @@ void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTy +void cClientHandle::SendStatistics(const cStatManager & a_Manager) +{ + m_Protocol->SendStatistics(a_Manager); +} + + + + + void cClientHandle::SendTabCompletionResults(const AStringVector & a_Results) { m_Protocol->SendTabCompletionResults(a_Results); diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 4dc6ab074..0236d38fb 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -39,6 +39,7 @@ class cFallingBlock; class cItemHandler; class cWorld; class cCompositeChat; +class cStatManager; @@ -160,6 +161,7 @@ public: void SendSpawnMob (const cMonster & a_Mob); void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch); void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType = 0); + void SendStatistics (const cStatManager & a_Manager); void SendTabCompletionResults(const AStringVector & a_Results); void SendTeleportEntity (const cEntity & a_Entity); void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 6ac11c270..a42fe89cf 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -16,6 +16,8 @@ #include "../Items/ItemHandler.h" #include "../Vector3.h" +#include "../WorldStorage/StatSerializer.h" + #include "inifile/iniFile.h" #include "json/json.h" @@ -131,6 +133,15 @@ cPlayer::~cPlayer(void) SaveToDisk(); +#if 0 + /* Save statistics. */ + cStatSerializer StatSerializer(m_World->GetName(), m_PlayerName, &m_Stats); + if (!StatSerializer.Save()) + { + LOGERROR("Could not save stats for player %s", m_PlayerName.c_str()); + } +#endif + m_World->RemovePlayer( this ); m_ClientHandle = NULL; @@ -871,9 +882,13 @@ void cPlayer::KilledBy(cEntity * a_Killer) } else if (a_Killer->IsPlayer()) { - GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), ((cPlayer *)a_Killer)->GetName().c_str())); + cPlayer* Killer = (cPlayer*)a_Killer; - m_World->GetScoreBoard().AddPlayerScore(((cPlayer *)a_Killer)->GetName(), cObjective::otPlayerKillCount, 1); + GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str())); + + Killer->GetStatManager().AddValue(statPlayerKills); + + m_World->GetScoreBoard().AddPlayerScore(Killer->GetName(), cObjective::otPlayerKillCount, 1); } else { @@ -883,6 +898,8 @@ void cPlayer::KilledBy(cEntity * a_Killer) GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str())); } + m_Stats.AddValue(statDeaths); + m_World->GetScoreBoard().AddPlayerScore(GetName(), cObjective::otDeathCount, 1); } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 6fc7e2875..82a138290 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -7,6 +7,8 @@ #include "../World.h" #include "../ClientHandle.h" +#include "../Statistics.h" + @@ -174,6 +176,9 @@ public: cTeam * UpdateTeam(void); // tolua_end + + /** Return the associated statistic and achievement manager. */ + cStatManager & GetStatManager() { return m_Stats; } void SetIP(const AString & a_IP); @@ -487,6 +492,8 @@ protected: cTeam * m_Team; + cStatManager m_Stats; + void ResolvePermissions(void); diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index 8f152ad37..a543c6361 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -31,6 +31,7 @@ class cMonster; class cChunkDataSerializer; class cFallingBlock; class cCompositeChat; +class cStatManager; @@ -111,6 +112,7 @@ public: virtual void SendSpawnMob (const cMonster & a_Mob) = 0; virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) = 0; virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) = 0; + virtual void SendStatistics (const cStatManager & a_Manager) = 0; virtual void SendTabCompletionResults(const AStringVector & a_Results) = 0; virtual void SendTeleportEntity (const cEntity & a_Entity) = 0; virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index e7873cf7a..f3bdae3ac 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -99,6 +99,7 @@ enum PACKET_ENCHANT_ITEM = 0x6C, PACKET_UPDATE_SIGN = 0x82, PACKET_ITEM_DATA = 0x83, + PACKET_INCREMENT_STATISTIC = 0xC8, PACKET_PLAYER_LIST_ITEM = 0xC9, PACKET_PLAYER_ABILITIES = 0xca, PACKET_PLUGIN_MESSAGE = 0xfa, @@ -992,6 +993,33 @@ void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp +void cProtocol125::SendStatistics(const cStatManager & a_Manager) +{ + /* NOTE: + * Versions prior to minecraft 1.7 use an incremental statistic sync + * method. The current setup does not allow us to implement that, because + * of performance considerations. + */ +#if 0 + for (unsigned int i = 0; i < (unsigned int)statCount; ++i) + { + StatValue Value = m_Manager->GetValue((eStatistic) i); + + unsigned int StatID = cStatInfo::GetID((eStatistic) i); + + cCSLock Lock(m_CSPacket); + WriteByte(PACKET_INCREMENT_STATISTIC); + WriteInt(StatID); + WriteByte(Value); /* Can overflow! */ + Flush(); + } +#endif +} + + + + + void cProtocol125::SendTabCompletionResults(const AStringVector & a_Results) { // This protocol version doesn't support tab completion diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 423e58d67..18a626a2d 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -84,6 +84,7 @@ public: virtual void SendSpawnMob (const cMonster & a_Mob) override; virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) override; + virtual void SendStatistics (const cStatManager & a_Manager) override; virtual void SendTabCompletionResults(const AStringVector & a_Results) override; virtual void SendTeleportEntity (const cEntity & a_Entity) override; virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 443723e40..3b21f7821 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -11,13 +11,19 @@ Implements the 1.7.x protocol classes: #include "json/json.h" #include "Protocol17x.h" #include "ChunkDataSerializer.h" +#include "PolarSSL++/Sha1Checksum.h" + #include "../ClientHandle.h" #include "../Root.h" #include "../Server.h" #include "../World.h" +#include "../StringCompression.h" +#include "../CompositeChat.h" +#include "../Statistics.h" + #include "../WorldStorage/FastNBT.h" #include "../WorldStorage/EnchantmentSerializer.h" -#include "../StringCompression.h" + #include "../Entities/ExpOrb.h" #include "../Entities/Minecart.h" #include "../Entities/FallingBlock.h" @@ -25,15 +31,15 @@ Implements the 1.7.x protocol classes: #include "../Entities/Pickup.h" #include "../Entities/Player.h" #include "../Entities/ItemFrame.h" +#include "../Entities/ArrowEntity.h" +#include "../Entities/FireworkEntity.h" + #include "../Mobs/IncludeAllMonsters.h" #include "../UI/Window.h" + #include "../BlockEntities/CommandBlockEntity.h" #include "../BlockEntities/MobHeadEntity.h" #include "../BlockEntities/FlowerPotEntity.h" -#include "../CompositeChat.h" -#include "../Entities/ArrowEntity.h" -#include "../Entities/FireworkEntity.h" -#include "PolarSSL++/Sha1Checksum.h" @@ -1169,6 +1175,28 @@ void cProtocol172::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp +void cProtocol172::SendStatistics(const cStatManager & a_Manager) +{ + ASSERT(m_State == 3); // In game mode? + + cPacketizer Pkt(*this, 0x37); + Pkt.WriteVarInt(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only + + for (unsigned int i = 0; i < (unsigned int)statCount; ++i) + { + StatValue Value = a_Manager.GetValue((eStatistic) i); + + const AString & StatName = cStatInfo::GetName((eStatistic) i); + + Pkt.WriteString(StatName); + Pkt.WriteVarInt(Value); + } +} + + + + + void cProtocol172::SendTabCompletionResults(const AStringVector & a_Results) { ASSERT(m_State == 3); // In game mode? @@ -1843,13 +1871,19 @@ void cProtocol172::HandlePacketClientStatus(cByteBuffer & a_ByteBuffer) case 1: { // Request stats - // TODO + const cStatManager & Manager = m_Client->GetPlayer()->GetStatManager(); + SendStatistics(Manager); + break; } case 2: { // Open Inventory achievement - // TODO + cStatManager & Manager = m_Client->GetPlayer()->GetStatManager(); + Manager.AddValue(achOpenInv); + + SendStatistics(Manager); + break; } } diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index dc111e737..3c6a8c085 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -116,6 +116,7 @@ public: virtual void SendSpawnMob (const cMonster & a_Mob) override; virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) override; + virtual void SendStatistics (const cStatManager & a_Manager) override; virtual void SendTabCompletionResults(const AStringVector & a_Results) override; virtual void SendTeleportEntity (const cEntity & a_Entity) override; virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override; diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 667fb5cef..b0cbb6def 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -675,6 +675,16 @@ void cProtocolRecognizer::SendSpawnVehicle(const cEntity & a_Vehicle, char a_Veh +void cProtocolRecognizer::SendStatistics(const cStatManager & a_Manager) +{ + ASSERT(m_Protocol != NULL); + m_Protocol->SendStatistics(a_Manager); +} + + + + + void cProtocolRecognizer::SendTabCompletionResults(const AStringVector & a_Results) { ASSERT(m_Protocol != NULL); diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 37f47379d..3a291bf7a 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -119,6 +119,7 @@ public: virtual void SendSpawnMob (const cMonster & a_Mob) override; virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) override; + virtual void SendStatistics (const cStatManager & a_Manager) override; virtual void SendTabCompletionResults(const AStringVector & a_Results) override; virtual void SendTeleportEntity (const cEntity & a_Entity) override; virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override; diff --git a/src/Statistics.cpp b/src/Statistics.cpp index 2c980d98e..94076f828 100644 --- a/src/Statistics.cpp +++ b/src/Statistics.cpp @@ -13,39 +13,39 @@ cStatInfo cStatInfo::ms_Info[statCount] = { // http://minecraft.gamepedia.com/Achievements /* Type | Name | Prerequisite */ - cStatInfo(achOpenInv, "openInventory"), - cStatInfo(achMineWood, "mineWood", achOpenInv), - cStatInfo(achCraftWorkbench, "buildWorkBench", achMineWood), - cStatInfo(achCraftPickaxe, "buildPickaxe", achCraftWorkbench), - cStatInfo(achCraftFurnace, "buildFurnace", achCraftPickaxe), - cStatInfo(achAcquireIron, "acquireIron", achCraftFurnace), - cStatInfo(achCraftHoe, "buildHoe", achCraftWorkbench), - cStatInfo(achMakeBread, "makeBread", achCraftHoe), - cStatInfo(achBakeCake, "bakeCake", achCraftHoe), - cStatInfo(achCraftBetterPick, "buildBetterPickaxe", achCraftPickaxe), - cStatInfo(achCookFish, "cookFish", achAcquireIron), - cStatInfo(achOnARail, "onARail", achAcquireIron), - cStatInfo(achCraftSword, "buildSword", achCraftWorkbench), - cStatInfo(achKillMonster, "killEnemy", achCraftSword), - cStatInfo(achKillCow, "killCow", achCraftSword), - cStatInfo(achFlyPig, "flyPig", achKillCow), - cStatInfo(achSnipeSkeleton, "snipeSkeleton", achKillMonster), - cStatInfo(achDiamonds, "diamonds", achAcquireIron), - cStatInfo(achEnterPortal, "portal", achDiamonds), - cStatInfo(achReturnToSender, "ghast", achEnterPortal), - cStatInfo(achBlazeRod, "blazeRod", achEnterPortal), - cStatInfo(achBrewPotion, "potion", achBlazeRod), - cStatInfo(achEnterTheEnd, "theEnd", achBlazeRod), - cStatInfo(achDefeatDragon, "theEnd2", achEnterTheEnd), - cStatInfo(achCraftEnchantTable, "enchantments", achDiamonds), - cStatInfo(achOverkill, "overkill", achCraftEnchantTable), - cStatInfo(achBookshelf, "bookcase", achCraftEnchantTable), - cStatInfo(achExploreAllBiomes, "exploreAllBiomes", achEnterTheEnd), - cStatInfo(achSpawnWither, "spawnWither", achDefeatDragon), - cStatInfo(achKillWither, "killWither", achSpawnWither), - cStatInfo(achFullBeacon, "fullBeacon", achKillWither), - cStatInfo(achBreedCow, "breedCow", achKillCow), - cStatInfo(achThrowDiamonds, "diamondsToYou", achDiamonds), + cStatInfo(achOpenInv, "achievement.openInventory"), + cStatInfo(achMineWood, "achievement.mineWood", achOpenInv), + cStatInfo(achCraftWorkbench, "achievement.buildWorkBench", achMineWood), + cStatInfo(achCraftPickaxe, "achievement.buildPickaxe", achCraftWorkbench), + cStatInfo(achCraftFurnace, "achievement.buildFurnace", achCraftPickaxe), + cStatInfo(achAcquireIron, "achievement.acquireIron", achCraftFurnace), + cStatInfo(achCraftHoe, "achievement.buildHoe", achCraftWorkbench), + cStatInfo(achMakeBread, "achievement.makeBread", achCraftHoe), + cStatInfo(achBakeCake, "achievement.bakeCake", achCraftHoe), + cStatInfo(achCraftBetterPick, "achievement.buildBetterPickaxe", achCraftPickaxe), + cStatInfo(achCookFish, "achievement.cookFish", achAcquireIron), + cStatInfo(achOnARail, "achievement.onARail", achAcquireIron), + cStatInfo(achCraftSword, "achievement.buildSword", achCraftWorkbench), + cStatInfo(achKillMonster, "achievement.killEnemy", achCraftSword), + cStatInfo(achKillCow, "achievement.killCow", achCraftSword), + cStatInfo(achFlyPig, "achievement.flyPig", achKillCow), + cStatInfo(achSnipeSkeleton, "achievement.snipeSkeleton", achKillMonster), + cStatInfo(achDiamonds, "achievement.diamonds", achAcquireIron), + cStatInfo(achEnterPortal, "achievement.portal", achDiamonds), + cStatInfo(achReturnToSender, "achievement.ghast", achEnterPortal), + cStatInfo(achBlazeRod, "achievement.blazeRod", achEnterPortal), + cStatInfo(achBrewPotion, "achievement.potion", achBlazeRod), + cStatInfo(achEnterTheEnd, "achievement.theEnd", achBlazeRod), + cStatInfo(achDefeatDragon, "achievement.theEnd2", achEnterTheEnd), + cStatInfo(achCraftEnchantTable, "achievement.enchantments", achDiamonds), + cStatInfo(achOverkill, "achievement.overkill", achCraftEnchantTable), + cStatInfo(achBookshelf, "achievement.bookcase", achCraftEnchantTable), + cStatInfo(achExploreAllBiomes, "achievement.exploreAllBiomes", achEnterTheEnd), + cStatInfo(achSpawnWither, "achievement.spawnWither", achDefeatDragon), + cStatInfo(achKillWither, "achievement.killWither", achSpawnWither), + cStatInfo(achFullBeacon, "achievement.fullBeacon", achKillWither), + cStatInfo(achBreedCow, "achievement.breedCow", achKillCow), + cStatInfo(achThrowDiamonds, "achievement.diamondsToYou", achDiamonds), // http://minecraft.gamepedia.com/Statistics @@ -57,6 +57,7 @@ cStatInfo cStatInfo::ms_Info[statCount] = { cStatInfo(statDistFallen, "stat.fallOneCm"), cStatInfo(statDistClimbed, "stat.climbOneCm"), cStatInfo(statDistFlown, "stat.flyOneCm"), + cStatInfo(statDistDove, "stat.diveOneCm"), cStatInfo(statDistMinecart, "stat.minecartOneCm"), cStatInfo(statDistBoat, "stat.boatOneCm"), cStatInfo(statDistPig, "stat.pigOneCm"), @@ -137,3 +138,59 @@ eStatistic cStatInfo::GetPrerequisite(const eStatistic a_Type) +cStatManager::cStatManager() +{ + Reset(); +} + + + + + +StatValue cStatManager::GetValue(const eStatistic a_Stat) const +{ + ASSERT((a_Stat > statInvalid) && (a_Stat < statCount)); + + return m_MainStats[a_Stat]; +} + + + + + +void cStatManager::SetValue(const eStatistic a_Stat, const StatValue a_Value) +{ + ASSERT((a_Stat > statInvalid) && (a_Stat < statCount)); + + m_MainStats[a_Stat] = a_Value; +} + + + + + +StatValue cStatManager::AddValue(const eStatistic a_Stat, const StatValue a_Delta) +{ + ASSERT((a_Stat > statInvalid) && (a_Stat < statCount)); + + m_MainStats[a_Stat] += a_Delta; + + return m_MainStats[a_Stat]; +} + + + + + +void cStatManager::Reset(void) +{ + for (unsigned int i = 0; i < (unsigned int)statCount; ++i) + { + m_MainStats[i] = 0; + } +} + + + + + diff --git a/src/Statistics.h b/src/Statistics.h index 540df38cc..f37f32e1e 100644 --- a/src/Statistics.h +++ b/src/Statistics.h @@ -9,6 +9,7 @@ +// tolua_begin enum eStatistic { // The order must match the order of cStatInfo::ms_Info @@ -77,6 +78,7 @@ enum eStatistic statCount }; +// tolua_end @@ -114,3 +116,49 @@ private: + +/* Signed (?) integral value. */ +typedef int StatValue; // tolua_export + + + + +/** Class that manages the statistics and achievements of a single player. */ +// tolua_begin +class cStatManager +{ +public: + // tolua_end + + cStatManager(); + + // tolua_begin + + /** Return the value of the specified stat. */ + StatValue GetValue(const eStatistic a_Stat) const; + + /** Set the value of the specified stat. */ + void SetValue(const eStatistic a_Stat, const StatValue a_Value); + + /** Reset everything. */ + void Reset(); + + /** Increment the specified stat. + * + * Returns the new value. + */ + StatValue AddValue(const eStatistic a_Stat, const StatValue a_Delta = 1); + + // tolua_end + +private: + + StatValue m_MainStats[statCount]; + + // TODO 10-05-2014 xdot: Use, mine, craft statistics + + +}; // tolua_export + + + diff --git a/src/WorldStorage/StatSerializer.cpp b/src/WorldStorage/StatSerializer.cpp new file mode 100644 index 000000000..5c6724c60 --- /dev/null +++ b/src/WorldStorage/StatSerializer.cpp @@ -0,0 +1,126 @@ + +// StatSerializer.cpp + + +#include "Globals.h" +#include "StatSerializer.h" + +#include "../Statistics.h" + +#include + + + + + +cStatSerializer::cStatSerializer(const AString& a_WorldName, const AString& a_PlayerName, cStatManager* a_Manager) + : m_Manager(a_Manager) +{ + AString StatsPath; + Printf(StatsPath, "%s/stats", a_WorldName.c_str()); + + m_Path = StatsPath + "/" + a_PlayerName + ".dat"; + + /* Ensure that the directory exists. */ + cFile::CreateFolder(FILE_IO_PREFIX + StatsPath); +} + + + + + +bool cStatSerializer::Load(void) +{ + AString Data = cFile::ReadWholeFile(FILE_IO_PREFIX + m_Path); + if (Data.empty()) + { + return false; + } + + Json::Value Root; + Json::Reader Reader; + + if (Reader.parse(Data, Root, false)) + { + return LoadStatFromJSON(Root); + } + + return false; +} + + + + + +bool cStatSerializer::Save(void) +{ + Json::Value Root; + SaveStatToJSON(Root); + + cFile File; + if (!File.Open(FILE_IO_PREFIX + m_Path, cFile::fmWrite)) + { + return false; + } + + Json::StyledWriter Writer; + AString JsonData = Writer.write(Root); + + File.Write(JsonData.data(), JsonData.size()); + File.Close(); + + return true; +} + + + + + +void cStatSerializer::SaveStatToJSON(Json::Value & a_Out) +{ + for (unsigned int i = 0; i < (unsigned int)statCount; ++i) + { + StatValue Value = m_Manager->GetValue((eStatistic) i); + + if (Value != 0) + { + const AString & StatName = cStatInfo::GetName((eStatistic) i); + + a_Out[StatName] = Value; + } + } +} + + + + + +bool cStatSerializer::LoadStatFromJSON(const Json::Value & a_In) +{ + m_Manager->Reset(); + + for (Json::ValueIterator it = a_In.begin() ; it != a_In.end() ; ++it) + { + AString StatName = it.key().asString(); + + eStatistic StatType = cStatInfo::GetType(StatName); + + if (StatType == statInvalid) + { + LOGWARNING("Invalid statistic type %s", StatName.c_str()); + continue; + } + + m_Manager->SetValue(StatType, (*it).asInt()); + } + + return true; +} + + + + + + + + diff --git a/src/WorldStorage/StatSerializer.h b/src/WorldStorage/StatSerializer.h new file mode 100644 index 000000000..43514465b --- /dev/null +++ b/src/WorldStorage/StatSerializer.h @@ -0,0 +1,53 @@ + +// StatSerializer.h + +// Declares the cStatSerializer class that is used for saving stats into JSON + + + + + +#pragma once + +#include "json/json.h" + + + + + +// fwd: +class cStatManager; + + + + +class cStatSerializer +{ +public: + + cStatSerializer(const AString& a_WorldName, const AString& a_PlayerName, cStatManager* a_Manager); + + bool Load(void); + + bool Save(void); + + +protected: + + void SaveStatToJSON(Json::Value & a_Out); + + bool LoadStatFromJSON(const Json::Value & a_In); + + +private: + + cStatManager* m_Manager; + + AString m_Path; + + +} ; + + + + -- cgit v1.2.3 From 9278bb732d115251776b12ebb45d0192c7fdd916 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 11 May 2014 15:52:02 +0100 Subject: Fixed a bug in writting zeros to a non-allocated section --- src/ChunkBuffer.cpp | 11 +++++++++++ src/ChunkBuffer.h | 12 ++++++++++++ 2 files changed, 23 insertions(+) (limited to 'src') diff --git a/src/ChunkBuffer.cpp b/src/ChunkBuffer.cpp index baeeff890..96077b966 100644 --- a/src/ChunkBuffer.cpp +++ b/src/ChunkBuffer.cpp @@ -295,3 +295,14 @@ void cChunkBuffer::Free(cChunkBuffer::sChunkSection * ptr) const +void cChunkBuffer::ZeroSection(cChunkBuffer::sChunkSection * ptr) const +{ + memset(ptr->m_BlockTypes,0x00,sizeof(ptr->m_BlockTypes)); + memset(ptr->m_BlockMeta,0x00,sizeof(ptr->m_BlockMeta)); + memset(ptr->m_BlockLight,0x00,sizeof(ptr->m_BlockLight)); + memset(ptr->m_BlockSkyLight,0x00,sizeof(ptr->m_BlockSkyLight)); +} + + + + diff --git a/src/ChunkBuffer.h b/src/ChunkBuffer.h index b1bd024d5..e16575bb2 100644 --- a/src/ChunkBuffer.h +++ b/src/ChunkBuffer.h @@ -121,12 +121,17 @@ public: int Section = a_RelY / CHUNK_SECTION_HEIGHT; if(!m_Sections[Section]) { + if(a_Block == 0x00) + { + return; + } m_Sections[Section] = Allocate(); if(!m_Sections[Section]) { ASSERT(!"Failed to allocate a new section in Chunkbuffer"); return; } + ZeroSection(m_Sections[Section]); } int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); m_Sections[Section]->m_BlockTypes[Index] = a_Block; @@ -166,12 +171,17 @@ public: int Section = a_RelY / CHUNK_SECTION_HEIGHT; if(!m_Sections[Section]) { + if((a_Nibble & 0xf) == 0x00) + { + return; + } m_Sections[Section] = Allocate(); if(!m_Sections[Section]) { ASSERT(!"Failed to allocate a new section in Chunkbuffer"); return; } + ZeroSection(m_Sections[Section]); } int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); m_Sections[Section]->m_BlockMeta[Index / 2] = static_cast( @@ -247,6 +257,8 @@ private: sChunkSection * Allocate() const; void Free(sChunkSection * ptr) const; + + void ZeroSection(sChunkSection * ptr) const; }; -- cgit v1.2.3 From 9568c223ff5b507ab436931ddf716e5978cbc35e Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 11 May 2014 18:24:21 +0100 Subject: SkyLight defaults to 0xFF --- src/ChunkBuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkBuffer.cpp b/src/ChunkBuffer.cpp index 96077b966..73ccd9c02 100644 --- a/src/ChunkBuffer.cpp +++ b/src/ChunkBuffer.cpp @@ -300,7 +300,7 @@ void cChunkBuffer::ZeroSection(cChunkBuffer::sChunkSection * ptr) const memset(ptr->m_BlockTypes,0x00,sizeof(ptr->m_BlockTypes)); memset(ptr->m_BlockMeta,0x00,sizeof(ptr->m_BlockMeta)); memset(ptr->m_BlockLight,0x00,sizeof(ptr->m_BlockLight)); - memset(ptr->m_BlockSkyLight,0x00,sizeof(ptr->m_BlockSkyLight)); + memset(ptr->m_BlockSkyLight,0xFF,sizeof(ptr->m_BlockSkyLight)); } -- cgit v1.2.3 From e3c6c8f3ddffdc368ebbc1a7688de2ca1b97167c Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 11 May 2014 20:30:54 +0300 Subject: Fixed stat serialization --- src/ClientHandle.cpp | 8 -------- src/Entities/Player.cpp | 31 +++++++++++++++++++++---------- src/Statistics.cpp | 2 +- src/WorldStorage/StatSerializer.cpp | 27 ++++++++++++++++++++++----- 4 files changed, 44 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 03b1b0dc2..c4f4e496a 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -31,8 +31,6 @@ #include "CompositeChat.h" #include "Items/ItemSword.h" -#include "WorldStorage/StatSerializer.h" - #include "md5/md5.h" @@ -339,12 +337,6 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID) // Send scoreboard data World->GetScoreBoard().SendTo(*this); -#if 0 - // Load stats - cStatSerializer StatSerializer(World->GetName(), m_Player->GetName(), &m_Player->GetStatManager()); - StatSerializer.Load(); -#endif - // Delay the first ping until the client "settles down" // This should fix #889, "BadCast exception, cannot convert bit to fm" error in client cTimer t1; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index a42fe89cf..1df473eb2 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -133,15 +133,6 @@ cPlayer::~cPlayer(void) SaveToDisk(); -#if 0 - /* Save statistics. */ - cStatSerializer StatSerializer(m_World->GetName(), m_PlayerName, &m_Stats); - if (!StatSerializer.Save()) - { - LOGERROR("Could not save stats for player %s", m_PlayerName.c_str()); - } -#endif - m_World->RemovePlayer( this ); m_ClientHandle = NULL; @@ -1638,6 +1629,12 @@ bool cPlayer::LoadFromDisk() m_Inventory.LoadFromJson(root["inventory"]); m_LoadedWorldName = root.get("world", "world").asString(); + + /* Load the player stats. + * We use the default world name (like bukkit) because stats are shared between dimensions/worlds. + */ + cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats); + StatSerializer.Load(); LOGD("Player \"%s\" was read from file, spawning at {%.2f, %.2f, %.2f} in world \"%s\"", m_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str() @@ -1709,6 +1706,17 @@ bool cPlayer::SaveToDisk() LOGERROR("ERROR WRITING PLAYER JSON TO FILE \"%s\"", SourceFile.c_str()); return false; } + + /* Save the player stats. + * We use the default world name (like bukkit) because stats are shared between dimensions/worlds. + */ + cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), m_PlayerName, &m_Stats); + if (!StatSerializer.Save()) + { + LOGERROR("Could not save stats for player %s", m_PlayerName.c_str()); + return false; + } + return true; } @@ -1723,7 +1731,10 @@ cPlayer::StringList cPlayer::GetResolvedPermissions() const PermissionMap& ResolvedPermissions = m_ResolvedPermissions; for( PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr ) { - if( itr->second ) Permissions.push_back( itr->first ); + if (itr->second) + { + Permissions.push_back( itr->first ); + } } return Permissions; diff --git a/src/Statistics.cpp b/src/Statistics.cpp index 94076f828..65addb0dd 100644 --- a/src/Statistics.cpp +++ b/src/Statistics.cpp @@ -114,7 +114,7 @@ eStatistic cStatInfo::GetType(const AString & a_Name) { for (unsigned int i = 0; i < ARRAYCOUNT(ms_Info); ++i) { - if (NoCaseCompare(ms_Info[i].m_Name, a_Name)) + if (NoCaseCompare(ms_Info[i].m_Name, a_Name) == 0) { return ms_Info[i].m_Type; } diff --git a/src/WorldStorage/StatSerializer.cpp b/src/WorldStorage/StatSerializer.cpp index 5c6724c60..66e5e1e9e 100644 --- a/src/WorldStorage/StatSerializer.cpp +++ b/src/WorldStorage/StatSerializer.cpp @@ -7,8 +7,6 @@ #include "../Statistics.h" -#include - @@ -19,7 +17,7 @@ cStatSerializer::cStatSerializer(const AString& a_WorldName, const AString& a_Pl AString StatsPath; Printf(StatsPath, "%s/stats", a_WorldName.c_str()); - m_Path = StatsPath + "/" + a_PlayerName + ".dat"; + m_Path = StatsPath + "/" + a_PlayerName + ".json"; /* Ensure that the directory exists. */ cFile::CreateFolder(FILE_IO_PREFIX + StatsPath); @@ -88,6 +86,8 @@ void cStatSerializer::SaveStatToJSON(Json::Value & a_Out) a_Out[StatName] = Value; } + + // TODO 2014-05-11 xdot: Save "progress" } } @@ -107,11 +107,28 @@ bool cStatSerializer::LoadStatFromJSON(const Json::Value & a_In) if (StatType == statInvalid) { - LOGWARNING("Invalid statistic type %s", StatName.c_str()); + LOGWARNING("Invalid statistic type \"%s\"", StatName.c_str()); continue; } - m_Manager->SetValue(StatType, (*it).asInt()); + Json::Value & Node = *it; + + if (Node.isInt()) + { + m_Manager->SetValue(StatType, Node.asInt()); + } + else if (Node.isObject()) + { + StatValue Value = Node.get("value", 0).asInt(); + + // TODO 2014-05-11 xdot: Load "progress" + + m_Manager->SetValue(StatType, Value); + } + else + { + LOGWARNING("Invalid statistic value for type \"%s\"", StatName.c_str()); + } } return true; -- cgit v1.2.3 From 5d39ecc64b3c690b2da05936c73c9442511b9509 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 11 May 2014 18:42:38 +0100 Subject: Fixed bug that caused Array Setters to always create segments --- src/ChunkBuffer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ChunkBuffer.cpp b/src/ChunkBuffer.cpp index 73ccd9c02..141601113 100644 --- a/src/ChunkBuffer.cpp +++ b/src/ChunkBuffer.cpp @@ -151,7 +151,7 @@ void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src) size_t j = 0; // do nothing whilst 0 for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); - if (j != segment_length) + if (j != (segment_length - 1)) { m_Sections[i] = Allocate(); memcpy( @@ -186,7 +186,7 @@ void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src) size_t j = 0; // do nothing whilst 0 for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); - if (j != segment_length) + if (j != (segment_length - 1)) { m_Sections[i] = Allocate(); memcpy( @@ -222,7 +222,7 @@ void cChunkBuffer::SetLight(const NIBBLETYPE * a_src) size_t j = 0; // do nothing whilst 0 for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); - if (j != segment_length) + if (j != (segment_length - 1)) { m_Sections[i] = Allocate(); memcpy( @@ -258,7 +258,7 @@ void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src) size_t j = 0; // do nothing whilst 0 for (; j < segment_length && a_src[i * segment_length + j] == 0xFF; j++); - if (j != segment_length) + if (j != (segment_length -1)) { m_Sections[i] = Allocate(); memcpy( -- cgit v1.2.3 From c46f240d818e5e6aa7c1ffae95bd03f979aae8ba Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 11 May 2014 19:24:09 +0100 Subject: Added several more testsfor arrays and coordinates --- src/ChunkBuffer.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ChunkBuffer.cpp b/src/ChunkBuffer.cpp index 141601113..99bcdebef 100644 --- a/src/ChunkBuffer.cpp +++ b/src/ChunkBuffer.cpp @@ -151,7 +151,7 @@ void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src) size_t j = 0; // do nothing whilst 0 for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); - if (j != (segment_length - 1)) + if (j != segment_length) { m_Sections[i] = Allocate(); memcpy( @@ -159,6 +159,9 @@ void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src) &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length ); + memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta)); + memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight)); + memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight)); } else { @@ -186,7 +189,7 @@ void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src) size_t j = 0; // do nothing whilst 0 for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); - if (j != (segment_length - 1)) + if (j != segment_length) { m_Sections[i] = Allocate(); memcpy( @@ -194,6 +197,9 @@ void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src) &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length ); + memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes)); + memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight)); + memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight)); } else { @@ -222,7 +228,7 @@ void cChunkBuffer::SetLight(const NIBBLETYPE * a_src) size_t j = 0; // do nothing whilst 0 for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); - if (j != (segment_length - 1)) + if (j != segment_length) { m_Sections[i] = Allocate(); memcpy( @@ -230,6 +236,9 @@ void cChunkBuffer::SetLight(const NIBBLETYPE * a_src) &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length ); + memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes)); + memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta)); + memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight)); } else { @@ -258,7 +267,7 @@ void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src) size_t j = 0; // do nothing whilst 0 for (; j < segment_length && a_src[i * segment_length + j] == 0xFF; j++); - if (j != (segment_length -1)) + if (j != segment_length) { m_Sections[i] = Allocate(); memcpy( @@ -266,6 +275,9 @@ void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src) &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length ); + memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes)); + memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta)); + memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight)); } else { -- cgit v1.2.3 From 6cb348395468020ebac978d5a4968953e49d8b90 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 11 May 2014 21:41:25 +0300 Subject: Fixed compilation --- src/Entities/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/Entities/CMakeLists.txt b/src/Entities/CMakeLists.txt index c9ca44d38..205cb2cca 100644 --- a/src/Entities/CMakeLists.txt +++ b/src/Entities/CMakeLists.txt @@ -10,3 +10,5 @@ file(GLOB SOURCE ) add_library(Entities ${SOURCE}) + +target_link_libraries(Entities WorldStorage) -- cgit v1.2.3 From c0727c426572745c72a61d26a84754d5a641d562 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 11 May 2014 22:35:41 +0200 Subject: Initial VillageGen implementation. WIP, doesn't generate anything yet. Ref.: 740. --- src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 3726 +++++++++++++++++++++++ src/Generating/Prefabs/PlainsVillagePrefabs.h | 15 + src/Generating/Prefabs/SandVillagePrefabs.cpp | 1887 ++++++++++++ src/Generating/Prefabs/SandVillagePrefabs.h | 15 + src/Generating/VillageGen.cpp | 116 + src/Generating/VillageGen.h | 48 + 6 files changed, 5807 insertions(+) create mode 100644 src/Generating/Prefabs/PlainsVillagePrefabs.cpp create mode 100644 src/Generating/Prefabs/PlainsVillagePrefabs.h create mode 100644 src/Generating/Prefabs/SandVillagePrefabs.cpp create mode 100644 src/Generating/Prefabs/SandVillagePrefabs.h create mode 100644 src/Generating/VillageGen.cpp create mode 100644 src/Generating/VillageGen.h (limited to 'src') diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp new file mode 100644 index 000000000..f59e22fb3 --- /dev/null +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -0,0 +1,3726 @@ + +// PlainsVillagePrefabs.cpp + +// Defines the prefabs in the group PlainsVillage + +// NOTE: This file has been generated automatically by GalExport! +// Any manual changes will be overwritten by the next automatic export! + +#include "Globals.h" +#include "PlainsVillagePrefabs.h" + + + + + +const cPrefab::sDef g_PlainsVillagePrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Forge: + // The data has been exported from the gallery Plains, area index 51, ID 102, created by Aloe_vera + { + // Size: + 12, 8, 11, // SizeX = 12, SizeY = 8, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 11, 7, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 6\n" /* wooddoorblock */ + "h: 10: 0\n" /* lava */ + "i: 54: 2\n" /* chest */ + "j: 61: 2\n" /* furnace */ + "k:102: 0\n" /* glasspane */ + "l: 64:12\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */ + "n:139: 0\n" /* cobblestonewall */ + "o:101: 0\n" /* ironbars */ + "p: 53: 2\n" /* woodstairs */ + "q: 53: 7\n" /* woodstairs */ + "r: 50: 2\n" /* torch */ + "s: 50: 1\n" /* torch */ + "t: 53: 6\n" /* woodstairs */ + "u: 53: 3\n" /* woodstairs */ + "v: 43: 0\n" /* doubleslab */ + "w: 44: 0\n" /* step */, + + // Block data: + // Level 0 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ ".....abbbc.." + /* 1 */ ".ddddddddc.." + /* 2 */ ".ddddddddc.." + /* 3 */ ".ddddddddddd" + /* 4 */ ".ddddddddddd" + /* 5 */ ".ddddddddddd" + /* 6 */ ".ddddddddddd" + /* 7 */ ".ddddddddddd" + /* 8 */ ".ddddd.mmmmm" + /* 9 */ ".ddddd.mmmmm" + /* 10 */ ".......mmmmm" + + // Level 1 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ ".efffe......" + /* 2 */ ".f...g......" + /* 3 */ ".f...ed..ddd" + /* 4 */ ".f...f...dhd" + /* 5 */ ".f...f...dhd" + /* 6 */ ".f...fijjdhd" + /* 7 */ ".f...edddddd" + /* 8 */ ".f...f.mmmmm" + /* 9 */ ".efffe.mmmmm" + /* 10 */ ".......mmmmm" + + // Level 2 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ ".ekkke......" + /* 2 */ ".k...l......" + /* 3 */ ".k...en..n.d" + /* 4 */ ".k...k.....o" + /* 5 */ ".f...k.....o" + /* 6 */ ".k...k.....o" + /* 7 */ ".k...edooood" + /* 8 */ ".k...f.mmmmm" + /* 9 */ ".ekkke.mmmmm" + /* 10 */ ".......mmmmm" + + // Level 3 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "ppppppp....." + /* 1 */ "qfffffq....." + /* 2 */ ".f...f......" + /* 3 */ ".f..rfd..dod" + /* 4 */ ".f...f...o.d" + /* 5 */ ".f...f...o.d" + /* 6 */ ".fs..f...o.d" + /* 7 */ ".f...fdddddd" + /* 8 */ ".f...f.mmmmm" + /* 9 */ "tffffftmmmmm" + /* 10 */ "uuuuuuummmmm" + + // Level 4 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "ppppppp....." + /* 2 */ "qfffffq....." + /* 3 */ ".f...fvvvvvv" + /* 4 */ ".f...fvwwwwv" + /* 5 */ ".f...fvwwwwv" + /* 6 */ ".f...fvwwwwv" + /* 7 */ ".f...fvvvvvv" + /* 8 */ "tffffftmmmmm" + /* 9 */ "uuuuuuummmmm" + /* 10 */ ".......mmmmm" + + // Level 5 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "ppppppp....." + /* 3 */ "qfffffq....." + /* 4 */ ".f...f......" + /* 5 */ ".f...f......" + /* 6 */ ".f...f......" + /* 7 */ "tffffft....." + /* 8 */ "uuuuuuummmmm" + /* 9 */ ".......mmmmm" + /* 10 */ ".......mmmmm" + + // Level 6 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "............" + /* 3 */ "ppppppp....." + /* 4 */ "qfffffq....." + /* 5 */ ".f...f......" + /* 6 */ "tffffft....." + /* 7 */ "uuuuuuu....." + /* 8 */ ".......mmmmm" + /* 9 */ ".......mmmmm" + /* 10 */ ".......mmmmm" + + // Level 7 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "............" + /* 3 */ "............" + /* 4 */ "ppppppp....." + /* 5 */ "fffffff....." + /* 6 */ "uuuuuuu....." + /* 7 */ "............" + /* 8 */ ".......mmmmm" + /* 9 */ ".......mmmmm" + /* 10 */ ".......mmmmm", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // Forge + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_100: + // The data has been exported from the gallery Plains, area index 49, ID 100, created by Aloe_vera + { + // Size: + 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 5, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 5\n" /* wooddoorblock */ + "h: 64:12\n" /* wooddoorblock */ + "i:102: 0\n" /* glasspane */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 7\n" /* woodstairs */ + "l: 50: 3\n" /* torch */ + "m: 19: 0\n" /* sponge */ + "n: 53: 6\n" /* woodstairs */ + "o: 53: 3\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "..abc.." + /* 1 */ ".ddddd." + /* 2 */ ".ddddd." + /* 3 */ ".ddddd." + /* 4 */ ".ddddd." + /* 5 */ ".ddddd." + /* 6 */ "......." + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".efgfe." + /* 2 */ ".f...f." + /* 3 */ ".f...f." + /* 4 */ ".f...f." + /* 5 */ ".efffe." + /* 6 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".efhfe." + /* 2 */ ".i...i." + /* 3 */ ".i...i." + /* 4 */ ".i...i." + /* 5 */ ".eiiie." + /* 6 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "jjjjjjj" + /* 1 */ "kfffffk" + /* 2 */ ".fl.lf." + /* 3 */ ".f...f." + /* 4 */ ".f...f." + /* 5 */ "nfffffn" + /* 6 */ "ooooooo" + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "jjjjjjj" + /* 2 */ "kfffffk" + /* 3 */ ".f...f." + /* 4 */ "nfffffn" + /* 5 */ "ooooooo" + /* 6 */ "......." + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "......." + /* 2 */ "jjjjjjj" + /* 3 */ "fffffff" + /* 4 */ "ooooooo" + /* 5 */ "......." + /* 6 */ ".......", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_100 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_103: + // The data has been exported from the gallery Plains, area index 52, ID 103, created by Aloe_vera + { + // Size: + 11, 7, 9, // SizeX = 11, SizeY = 7, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 6, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 5\n" /* wooddoorblock */ + "h:102: 0\n" /* glasspane */ + "i: 64:12\n" /* wooddoorblock */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 7\n" /* woodstairs */ + "l: 50: 3\n" /* torch */ + "m: 19: 0\n" /* sponge */ + "n: 50: 4\n" /* torch */ + "o: 53: 6\n" /* woodstairs */ + "p: 53: 3\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "....abc...." + /* 1 */ ".ddddddddd." + /* 2 */ ".ddddddddd." + /* 3 */ ".ddddddddd." + /* 4 */ ".ddddddddd." + /* 5 */ ".ddddddddd." + /* 6 */ ".ddddddddd." + /* 7 */ ".ddddddddd." + /* 8 */ "..........." + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".efffgfffe." + /* 2 */ ".f.......f." + /* 3 */ ".f.......f." + /* 4 */ ".f.......f." + /* 5 */ ".f.......f." + /* 6 */ ".f.......f." + /* 7 */ ".efffffffe." + /* 8 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".ehhfifhhe." + /* 2 */ ".h.......h." + /* 3 */ ".h.......h." + /* 4 */ ".f.......f." + /* 5 */ ".h.......h." + /* 6 */ ".h.......h." + /* 7 */ ".ehhhfhhhe." + /* 8 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "jjjjjjjjjjj" + /* 1 */ "kfffffffffk" + /* 2 */ ".f..l.l..f." + /* 3 */ ".f.......f." + /* 4 */ ".f.......f." + /* 5 */ ".f.......f." + /* 6 */ ".f...n...f." + /* 7 */ "offfffffffo" + /* 8 */ "ppppppppppp" + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "jjjjjjjjjjj" + /* 2 */ "kfffffffffk" + /* 3 */ ".f.......f." + /* 4 */ ".f.......f." + /* 5 */ ".f.......f." + /* 6 */ "offfffffffo" + /* 7 */ "ppppppppppp" + /* 8 */ "..........." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "jjjjjjjjjjj" + /* 3 */ "kfffffffffk" + /* 4 */ ".f.......f." + /* 5 */ "offfffffffo" + /* 6 */ "ppppppppppp" + /* 7 */ "..........." + /* 8 */ "..........." + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "jjjjjjjjjjj" + /* 4 */ "fffffffffff" + /* 5 */ "ppppppppppp" + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "...........", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_103 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_105: + // The data has been exported from the gallery Plains, area index 54, ID 105, created by Aloe_vera + { + // Size: + 7, 6, 9, // SizeX = 7, SizeY = 6, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 5, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:170: 0\n" /* haybale */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 4: 0\n" /* cobblestone */ + "f: 17: 0\n" /* tree */ + "g: 5: 0\n" /* wood */ + "h:170: 4\n" /* haybale */ + "i:170: 8\n" /* haybale */ + "j: 54: 2\n" /* chest */ + "k: 50: 4\n" /* torch */ + "l: 53: 0\n" /* woodstairs */ + "m: 19: 0\n" /* sponge */ + "n: 53: 5\n" /* woodstairs */ + "o: 53: 4\n" /* woodstairs */ + "p: 53: 1\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "abcccd." + /* 1 */ ".eeeee." + /* 2 */ ".eeeee." + /* 3 */ ".eeeee." + /* 4 */ ".eeeee." + /* 5 */ ".eeeee." + /* 6 */ ".eeeee." + /* 7 */ ".eeeee." + /* 8 */ "......." + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".f..af." + /* 2 */ ".g...g." + /* 3 */ ".ga.hg." + /* 4 */ ".fihif." + /* 5 */ ".gaaag." + /* 6 */ ".gijag." + /* 7 */ ".fgfgf." + /* 8 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ ".k...k." + /* 1 */ ".f...f." + /* 2 */ ".g...g." + /* 3 */ ".g...g." + /* 4 */ ".fh..f." + /* 5 */ ".ghiag." + /* 6 */ ".ghiig." + /* 7 */ ".fgfgf." + /* 8 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "ln...op" + /* 1 */ "lgggggp" + /* 2 */ "lg...gp" + /* 3 */ "lg...gp" + /* 4 */ "lg...gp" + /* 5 */ "lgaa.gp" + /* 6 */ "lgiaigp" + /* 7 */ "lgggggp" + /* 8 */ "ln...op" + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ ".ln.op." + /* 1 */ ".lgggp." + /* 2 */ ".lg.gp." + /* 3 */ ".lg.gp." + /* 4 */ ".lg.gp." + /* 5 */ ".lg.gp." + /* 6 */ ".lg.gp." + /* 7 */ ".lgggp." + /* 8 */ ".ln.op." + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "..lgp.." + /* 1 */ "..lgp.." + /* 2 */ "..lgp.." + /* 3 */ "..lgp.." + /* 4 */ "..lgp.." + /* 5 */ "..lgp.." + /* 6 */ "..lgp.." + /* 7 */ "..lgp.." + /* 8 */ "..lgp..", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_105 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_106: + // The data has been exported from the gallery Plains, area index 55, ID 106, created by Aloe_vera + { + // Size: + 15, 8, 9, // SizeX = 15, SizeY = 8, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 14, 7, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 3: 0\n" /* dirt */ + "f: 17: 0\n" /* tree */ + "g:107: 0\n" /* fencegate */ + "h:107: 4\n" /* fencegate */ + "i: 5: 0\n" /* wood */ + "j:107: 6\n" /* fencegate */ + "k: 85: 0\n" /* fence */ + "l:170: 0\n" /* haybale */ + "m: 19: 0\n" /* sponge */ + "n:170: 4\n" /* haybale */ + "o:170: 8\n" /* haybale */ + "p: 50: 1\n" /* torch */ + "q: 50: 2\n" /* torch */ + "r: 53: 2\n" /* woodstairs */ + "s: 53: 7\n" /* woodstairs */ + "t: 53: 6\n" /* woodstairs */ + "u: 53: 3\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ ".abbbbbbbbbbbc." + /* 1 */ ".ddddddddddddd." + /* 2 */ ".deeeeeeeeeeed." + /* 3 */ ".deeeeeeeeeeed." + /* 4 */ ".deeeeeeeeeeed." + /* 5 */ ".deeeeeeeeeeed." + /* 6 */ ".deeeeeeeeeeed." + /* 7 */ ".ddddddddddddd." + /* 8 */ "..............." + + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".fghgighgigjgf." + /* 2 */ ".k...k...k...k." + /* 3 */ ".k...k...k...k." + /* 4 */ ".k...k...k...k." + /* 5 */ ".k...k...k...k." + /* 6 */ ".kl..k..nko..k." + /* 7 */ ".fkkkikkkikkkf." + /* 8 */ "..............." + + // Level 2 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".f...i...i...f." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "..............." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ ".f...i...i...f." + /* 8 */ "..............." + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".fp.qip.qip.qf." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "..............." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ ".f...i...i...f." + /* 8 */ "..............." + + // Level 4 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "rrrrrrrrrrrrrrr" + /* 1 */ "siiiiiiiiiiiiis" + /* 2 */ ".i...........i." + /* 3 */ ".i...........i." + /* 4 */ ".i...........i." + /* 5 */ ".i...........i." + /* 6 */ ".i...........i." + /* 7 */ "tiiiiiiiiiiiiit" + /* 8 */ "uuuuuuuuuuuuuuu" + + // Level 5 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "rrrrrrrrrrrrrrr" + /* 2 */ "siiiiiiiiiiiiis" + /* 3 */ ".i...........i." + /* 4 */ ".i...........i." + /* 5 */ ".i...........i." + /* 6 */ "tiiiiiiiiiiiiit" + /* 7 */ "uuuuuuuuuuuuuuu" + /* 8 */ "..............." + + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "rrrrrrrrrrrrrrr" + /* 3 */ "siiiiiiiiiiiiis" + /* 4 */ ".i...........i." + /* 5 */ "tiiiiiiiiiiiiit" + /* 6 */ "uuuuuuuuuuuuuuu" + /* 7 */ "..............." + /* 8 */ "..............." + + // Level 7 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "rrrrrrrrrrrrrrr" + /* 4 */ "iiiiiiiiiiiiiii" + /* 5 */ "uuuuuuuuuuuuuuu" + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "...............", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_106 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_109: + // The data has been exported from the gallery Plains, area index 58, ID 109, created by Aloe_vera + { + // Size: + 7, 14, 13, // SizeX = 7, SizeY = 14, SizeZ = 13 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 13, 12, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "A: 85: 0\n" /* fence */ + "B:126: 8\n" /* woodenslab */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 7\n" /* wooddoorblock */ + "h: 65: 3\n" /* ladder */ + "i: 53: 3\n" /* woodstairs */ + "j: 53: 7\n" /* woodstairs */ + "k: 64:12\n" /* wooddoorblock */ + "l:102: 0\n" /* glasspane */ + "m: 19: 0\n" /* sponge */ + "n: 50: 1\n" /* torch */ + "o: 50: 2\n" /* torch */ + "p:171:14\n" /* carpet */ + "q: 50: 3\n" /* torch */ + "r: 53: 2\n" /* woodstairs */ + "s: 53: 0\n" /* woodstairs */ + "t: 53: 1\n" /* woodstairs */ + "u: 53: 5\n" /* woodstairs */ + "v: 53: 4\n" /* woodstairs */ + "w: 17: 4\n" /* tree */ + "x: 17: 8\n" /* tree */ + "y: 54: 2\n" /* chest */ + "z: 50: 4\n" /* torch */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "..abc.." + /* 1 */ ".ddddd." + /* 2 */ ".ddddd." + /* 3 */ ".ddddd." + /* 4 */ ".ddddd." + /* 5 */ ".ddddd." + /* 6 */ ".ddddd." + /* 7 */ ".ddddd." + /* 8 */ ".ddddd." + /* 9 */ ".ddddd." + /* 10 */ ".ddddd." + /* 11 */ ".ddddd." + /* 12 */ "......." + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".efgfe." + /* 2 */ ".f..hf." + /* 3 */ ".f...f." + /* 4 */ ".f...f." + /* 5 */ ".ei.ie." + /* 6 */ ".f...f." + /* 7 */ ".fi.if." + /* 8 */ ".f...f." + /* 9 */ ".f.j.f." + /* 10 */ ".f...f." + /* 11 */ ".efffe." + /* 12 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".efkfe." + /* 2 */ ".l..hl." + /* 3 */ ".l...l." + /* 4 */ ".l...l." + /* 5 */ ".e...e." + /* 6 */ ".l...l." + /* 7 */ ".l...l." + /* 8 */ ".fn.of." + /* 9 */ ".l.p.l." + /* 10 */ ".l...l." + /* 11 */ ".ellle." + /* 12 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".efffe." + /* 2 */ ".f.qhf." + /* 3 */ ".f...f." + /* 4 */ ".f...f." + /* 5 */ "re...er" + /* 6 */ "sf...ft" + /* 7 */ "sf...ft" + /* 8 */ "sf...ft" + /* 9 */ "sf...ft" + /* 10 */ "sf...ft" + /* 11 */ "sefffft" + /* 12 */ "su...vt" + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".ewwwe." + /* 2 */ ".xffhx." + /* 3 */ ".xfffx." + /* 4 */ ".xfffx." + /* 5 */ ".ewwwe." + /* 6 */ ".sf.ft." + /* 7 */ ".sf.ft." + /* 8 */ ".sf.ft." + /* 9 */ ".sf.ft." + /* 10 */ ".sf.ft." + /* 11 */ ".sffft." + /* 12 */ ".su.vt." + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".eflfe." + /* 2 */ ".f..hf." + /* 3 */ ".f...f." + /* 4 */ ".f.y.f." + /* 5 */ ".efffe." + /* 6 */ "..sft.." + /* 7 */ "..sft.." + /* 8 */ "..sft.." + /* 9 */ "..sft.." + /* 10 */ "..sft.." + /* 11 */ "..sft.." + /* 12 */ "..sft.." + + // Level 6 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".eflfe." + /* 2 */ ".f..hf." + /* 3 */ ".l...l." + /* 4 */ ".f...f." + /* 5 */ ".efffe." + /* 6 */ "......." + /* 7 */ "......." + /* 8 */ "......." + /* 9 */ "......." + /* 10 */ "......." + /* 11 */ "......." + /* 12 */ "......." + + // Level 7 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".eflfe." + /* 2 */ ".f..hf." + /* 3 */ ".f...f." + /* 4 */ ".f.z.f." + /* 5 */ ".efffe." + /* 6 */ "......." + /* 7 */ "......." + /* 8 */ "......." + /* 9 */ "......." + /* 10 */ "......." + /* 11 */ "......." + /* 12 */ "......." + + // Level 8 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".ewwwe." + /* 2 */ ".xffhx." + /* 3 */ ".xfffx." + /* 4 */ ".xfffx." + /* 5 */ ".ewwwe." + /* 6 */ "......." + /* 7 */ "......." + /* 8 */ "......." + /* 9 */ "......." + /* 10 */ "......." + /* 11 */ "......." + /* 12 */ "......." + + // Level 9 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".eAAAe." + /* 2 */ ".A...A." + /* 3 */ ".A...A." + /* 4 */ ".A...A." + /* 5 */ ".eAAAe." + /* 6 */ "......." + /* 7 */ "......." + /* 8 */ "......." + /* 9 */ "......." + /* 10 */ "......." + /* 11 */ "......." + /* 12 */ "......." + + // Level 10 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".e...e." + /* 2 */ "......." + /* 3 */ "......." + /* 4 */ "......." + /* 5 */ ".e...e." + /* 6 */ "......." + /* 7 */ "......." + /* 8 */ "......." + /* 9 */ "......." + /* 10 */ "......." + /* 11 */ "......." + /* 12 */ "......." + + // Level 11 + /* z\x* 0123456 */ + /* 0 */ "su...vt" + /* 1 */ "sefffet" + /* 2 */ "sfBBBft" + /* 3 */ "sfBBBft" + /* 4 */ "sfBBBft" + /* 5 */ "sffffft" + /* 6 */ "su...vt" + /* 7 */ "......." + /* 8 */ "......." + /* 9 */ "......." + /* 10 */ "......." + /* 11 */ "......." + /* 12 */ "......." + + // Level 12 + /* z\x* 0123456 */ + /* 0 */ ".su.vt." + /* 1 */ ".sffft." + /* 2 */ ".sffft." + /* 3 */ ".sffft." + /* 4 */ ".sffft." + /* 5 */ ".sffft." + /* 6 */ ".su.vt." + /* 7 */ "......." + /* 8 */ "......." + /* 9 */ "......." + /* 10 */ "......." + /* 11 */ "......." + /* 12 */ "......." + + // Level 13 + /* z\x* 0123456 */ + /* 0 */ "..sft.." + /* 1 */ "..sft.." + /* 2 */ "..sft.." + /* 3 */ "..sft.." + /* 4 */ "..sft.." + /* 5 */ "..sft.." + /* 6 */ "..sft.." + /* 7 */ "......." + /* 8 */ "......." + /* 9 */ "......." + /* 10 */ "......." + /* 11 */ "......." + /* 12 */ ".......", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_109 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_20: + // The data has been exported from the gallery Plains, area index 5, ID 20, created by tonibm1999 + { + // Size: + 15, 2, 9, // SizeX = 15, SizeY = 2, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 14, 1, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 17: 0\n" /* tree */ + "b: 60: 7\n" /* tilleddirt */ + "c: 8: 0\n" /* water */ + "d: 50: 5\n" /* torch */ + "e: 59: 7\n" /* crops */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "aaaaaaamaaaaaaa" + /* 1 */ "abbcbbamabbcbba" + /* 2 */ "abbcbbamabbcbba" + /* 3 */ "abbcbbamabbcbba" + /* 4 */ "abbcbbamabbcbba" + /* 5 */ "abbcbbamabbcbba" + /* 6 */ "abbcbbamabbcbba" + /* 7 */ "abbcbbamabbcbba" + /* 8 */ "aaaaaaamaaaaaaa" + + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "dmmmmmdmdmmmmmd" + /* 1 */ "meemeemmmeemeem" + /* 2 */ "memmmemmmeemeem" + /* 3 */ "memmmmmmmeemeem" + /* 4 */ "meemmemmmeemeem" + /* 5 */ "meemmemmmeemeem" + /* 6 */ "mmemmemmmeemeem" + /* 7 */ "mmememmmmeemeem" + /* 8 */ "dmmmmmdmdmmmmmd", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_20 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_26: + // The data has been exported from the gallery Plains, area index 9, ID 26, created by Aloe_vera + { + // Size: + 10, 6, 11, // SizeX = 10, SizeY = 6, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 9, 5, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 4: 0\n" /* cobblestone */ + "b: 5: 0\n" /* wood */ + "c: 2: 0\n" /* grass */ + "d: 67: 2\n" /* stairs */ + "e: 43: 0\n" /* doubleslab */ + "f: 67: 0\n" /* stairs */ + "g: 67: 3\n" /* stairs */ + "h: 17: 0\n" /* tree */ + "i: 53: 1\n" /* woodstairs */ + "j: 85: 0\n" /* fence */ + "k: 53: 0\n" /* woodstairs */ + "l: 64: 4\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */ + "n: 64: 0\n" /* wooddoorblock */ + "o:102: 0\n" /* glasspane */ + "p: 72: 0\n" /* woodplate */ + "q: 64:12\n" /* wooddoorblock */ + "r: 64: 8\n" /* wooddoorblock */ + "s: 53: 5\n" /* woodstairs */ + "t: 53: 4\n" /* woodstairs */ + "u: 50: 1\n" /* torch */ + "v: 50: 2\n" /* torch */, + + // Block data: + // Level 0 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "......mmmm" + /* 1 */ ".aaaaammmm" + /* 2 */ ".abbbammmm" + /* 3 */ ".abbbacccc" + /* 4 */ "daeeeacccc" + /* 5 */ "faeeeecccc" + /* 6 */ "gaeeeacccc" + /* 7 */ ".aeeeacccc" + /* 8 */ ".aeeeacccc" + /* 9 */ ".aaaaammmm" + /* 10 */ "......mmmm" + + // Level 1 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "......mmmm" + /* 1 */ ".hbbbhmmmm" + /* 2 */ ".bijkbmmmm" + /* 3 */ ".b...bjjjj" + /* 4 */ ".b...b...j" + /* 5 */ ".l...n...j" + /* 6 */ ".b...b...j" + /* 7 */ ".bee.b...j" + /* 8 */ ".b...bjjjj" + /* 9 */ ".hbbbhmmmm" + /* 10 */ "......mmmm" + + // Level 2 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "......mmmm" + /* 1 */ ".hooohmmmm" + /* 2 */ ".o.p.ommmm" + /* 3 */ ".o...o...." + /* 4 */ ".b...b...." + /* 5 */ ".q...r...." + /* 6 */ ".b...b...." + /* 7 */ ".o...o...." + /* 8 */ ".o...o...." + /* 9 */ ".hooohmmmm" + /* 10 */ "......mmmm" + + // Level 3 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "ks...timmm" + /* 1 */ "khbbbhimmm" + /* 2 */ "kb...bimmm" + /* 3 */ "kb...bi..." + /* 4 */ "kbu.vbi..." + /* 5 */ "kb...bi..." + /* 6 */ "kbu.vbi..." + /* 7 */ "kb...bi..." + /* 8 */ "kb...bi..." + /* 9 */ "khbbbhimmm" + /* 10 */ "ks...timmm" + + // Level 4 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "mks.timmmm" + /* 1 */ "mkbbbimmmm" + /* 2 */ "mkb.bimmmm" + /* 3 */ "mkb.bim..." + /* 4 */ "mkb.bim..." + /* 5 */ "mkb.bim..." + /* 6 */ "mkb.bim..." + /* 7 */ "mkb.bim..." + /* 8 */ "mkb.bim..." + /* 9 */ "mkbbbimmmm" + /* 10 */ "mks.timmmm" + + // Level 5 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "mmkbimmmmm" + /* 1 */ "mmkbimmmmm" + /* 2 */ "mmkbimmmmm" + /* 3 */ "mmkbimm..." + /* 4 */ "mmkbimm..." + /* 5 */ "mmkbimm..." + /* 6 */ "mmkbimm..." + /* 7 */ "mmkbimm..." + /* 8 */ "mmkbimm..." + /* 9 */ "mmkbimmmmm" + /* 10 */ "mmkbimmmmm", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_26 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_4: + // The data has been exported from the gallery Plains, area index 0, ID 4, created by Aloe_vera + { + // Size: + 16, 7, 16, // SizeX = 16, SizeY = 7, SizeZ = 16 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 15, 6, 15, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 5: 0\n" /* wood */ + "f: 67: 3\n" /* stairs */ + "g: 17: 0\n" /* tree */ + "h: 64: 5\n" /* wooddoorblock */ + "i:102: 0\n" /* glasspane */ + "j: 64:12\n" /* wooddoorblock */ + "k: 53: 2\n" /* woodstairs */ + "l: 53: 1\n" /* woodstairs */ + "m: 19: 0\n" /* sponge */ + "n: 53: 7\n" /* woodstairs */ + "o: 53: 6\n" /* woodstairs */ + "p: 53: 3\n" /* woodstairs */ + "q: 53: 0\n" /* woodstairs */ + "r: 53: 5\n" /* woodstairs */ + "s: 53: 4\n" /* woodstairs */ + "t: 50: 3\n" /* torch */ + "u: 50: 2\n" /* torch */ + "v: 50: 4\n" /* torch */ + "w: 50: 1\n" /* torch */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "........abc....." + /* 1 */ ".dddddddddddddd." + /* 2 */ ".deeeeeeeeeeeed." + /* 3 */ ".deeeeeeeeeeeed." + /* 4 */ ".deeeeeeeeeeeed." + /* 5 */ ".deeeeeeeeeeeed." + /* 6 */ ".deeeeeeeeeeeed." + /* 7 */ ".ddddddddeeeeed." + /* 8 */ "mmmmmafcdeeeeed." + /* 9 */ "mmmmmmmmdeeeeed." + /* 10 */ "mmmmmmmmdeeeeed." + /* 11 */ "mmmmmmmmdeeeeed." + /* 12 */ "mmmmmmmmdeeeeed." + /* 13 */ "mmmmmmmmdeeeeed." + /* 14 */ "mmmmmmmmddddddd." + /* 15 */ "mmmmmmmm........" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ ".geeeeeeghgeeeg." + /* 2 */ ".e............e." + /* 3 */ ".e............e." + /* 4 */ ".e............e." + /* 5 */ ".e............e." + /* 6 */ ".e............e." + /* 7 */ ".geeeeheg.....e." + /* 8 */ "mmmmmm.me.....e." + /* 9 */ "mmmmmmmme.....e." + /* 10 */ "mmmmmmmme.....e." + /* 11 */ "mmmmmmmme.....e." + /* 12 */ "mmmmmmmme.....e." + /* 13 */ "mmmmmmmme.....e." + /* 14 */ "mmmmmmmmgeeeeeg." + /* 15 */ "mmmmmmmm........" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ ".geiieiigjgiieg." + /* 2 */ ".i............e." + /* 3 */ ".i............i." + /* 4 */ ".i............i." + /* 5 */ ".i............e." + /* 6 */ ".i............i." + /* 7 */ ".geiiejeg.....i." + /* 8 */ "mmmmmm.me.....e." + /* 9 */ "mmmmmmmmi.....i." + /* 10 */ "mmmmmmmmi.....i." + /* 11 */ "mmmmmmmme.....e." + /* 12 */ "mmmmmmmmi.....i." + /* 13 */ "mmmmmmmmi.....i." + /* 14 */ "mmmmmmmmgiiiiig." + /* 15 */ "mmmmmmmm........" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "kkkkkkkkkkkkkkkl" + /* 1 */ "ngeeeeeegegeeegl" + /* 2 */ ".e............el" + /* 3 */ ".e............el" + /* 4 */ ".e............el" + /* 5 */ ".e............el" + /* 6 */ ".e............el" + /* 7 */ "ogeeeeeeg.....el" + /* 8 */ "pppppppqe.....el" + /* 9 */ "mmmmmmmqe.....el" + /* 10 */ "mmmmmmmqe.....el" + /* 11 */ "mmmmmmmqe.....el" + /* 12 */ "mmmmmmmqe.....el" + /* 13 */ "mmmmmmmqe.....el" + /* 14 */ "mmmmmmmqgeeeeegl" + /* 15 */ "mmmmmmmqr.....sl" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "kkkkkkkkkkkkkkk." + /* 2 */ "neeeeeeeeeeeeel." + /* 3 */ ".e.........t.el." + /* 4 */ ".e..........uel." + /* 5 */ ".e......v....el." + /* 6 */ "oeeeeeeeee...el." + /* 7 */ "ppppppppqew..el." + /* 8 */ "mmmmmmmmqe...el." + /* 9 */ "mmmmmmmmqe...el." + /* 10 */ "mmmmmmmmqe...el." + /* 11 */ "mmmmmmmmqe...el." + /* 12 */ "mmmmmmmmqe...el." + /* 13 */ "mmmmmmmmqe...el." + /* 14 */ "mmmmmmmmqeeeeel." + /* 15 */ "mmmmmmmmqr...sl." + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "kkkkkkkkkkkkkl.." + /* 3 */ "neeeeeeeeeeeel.." + /* 4 */ ".ew.........el.." + /* 5 */ "oeeeeeeeeee.el.." + /* 6 */ "pppppppppqe.el.." + /* 7 */ ".........qe.el.." + /* 8 */ "mmmmmmmm.qe.el.." + /* 9 */ "mmmmmmmm.qe.el.." + /* 10 */ "mmmmmmmm.qe.el.." + /* 11 */ "mmmmmmmm.qe.el.." + /* 12 */ "mmmmmmmm.qe.el.." + /* 13 */ "mmmmmmmm.qevel.." + /* 14 */ "mmmmmmmm.qeeel.." + /* 15 */ "mmmmmmmm.qr.sl.." + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "kkkkkkkkkkkkk..." + /* 4 */ "eeeeeeeeeeeel..." + /* 5 */ "ppppppppppqel..." + /* 6 */ "mmmmmmmmmmqel..." + /* 7 */ "mmmmmmmmmmqel..." + /* 8 */ "mmmmmmmmmmqel..." + /* 9 */ "mmmmmmmmmmqel..." + /* 10 */ "mmmmmmmmmmqel..." + /* 11 */ "mmmmmmmmmmqel..." + /* 12 */ "mmmmmmmmmmqel..." + /* 13 */ "mmmmmmmmmmqel..." + /* 14 */ "mmmmmmmmmmqel..." + /* 15 */ "mmmmmmmmmmqel...", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_4 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_60: + // The data has been exported from the gallery Plains, area index 17, ID 60, created by Aloe_vera + { + // Size: + 10, 2, 7, // SizeX = 10, SizeY = 2, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 9, 1, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 17: 0\n" /* tree */ + "b: 60: 7\n" /* tilleddirt */ + "c: 8: 0\n" /* water */ + "d: 59: 7\n" /* crops */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "aaaaaaaaaa" + /* 1 */ "abbbbbbbba" + /* 2 */ "abbbbbbbba" + /* 3 */ "acccccccca" + /* 4 */ "abbbbbbbba" + /* 5 */ "abbbbbbbba" + /* 6 */ "aaaaaaaaaa" + + // Level 1 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ ".dddddddd." + /* 2 */ ".dddddddd." + /* 3 */ ".........." + /* 4 */ ".dddddddd." + /* 5 */ ".dddddddd." + /* 6 */ "..........", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_60 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_66: + // The data has been exported from the gallery Plains, area index 23, ID 66, created by xoft + { + // Size: + 12, 7, 7, // SizeX = 12, SizeY = 7, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 11, 6, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 2: 0\n" /* grass */ + "b: 3: 0\n" /* dirt */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 64: 1\n" /* wooddoorblock */ + "h: 53: 3\n" /* woodstairs */ + "i: 53: 1\n" /* woodstairs */ + "j: 85: 0\n" /* fence */ + "k: 53: 0\n" /* woodstairs */ + "l: 53: 2\n" /* woodstairs */ + "m: 19: 0\n" /* sponge */ + "n:102: 0\n" /* glasspane */ + "o: 64: 8\n" /* wooddoorblock */ + "p: 50: 3\n" /* torch */ + "q: 72: 0\n" /* woodplate */ + "r: 50: 4\n" /* torch */ + "s: 53: 7\n" /* woodstairs */ + "t: 47: 0\n" /* bookshelf */ + "u: 50: 1\n" /* torch */ + "v: 50: 2\n" /* torch */ + "w: 53: 6\n" /* woodstairs */ + "x: 5: 0\n" /* wood */, + + // Block data: + // Level 0 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "aaaaaaabbbaa" + /* 1 */ "abbbbbbbbbba" + /* 2 */ "abbbbbbbbbba" + /* 3 */ "abbbbbbbbbba" + /* 4 */ "abbbbbbbbbba" + /* 5 */ "abbbbbbbbbba" + /* 6 */ "aaaaaaaaaaaa" + + // Level 1 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ ".......cde.." + /* 1 */ ".ffffffffff." + /* 2 */ ".ffffffffff." + /* 3 */ ".ffffffffff." + /* 4 */ ".ffffffffff." + /* 5 */ ".ffffffffff." + /* 6 */ "............" + + // Level 2 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ ".fffffffgff." + /* 2 */ ".fh.ijk...f." + /* 3 */ ".fj.......f." + /* 4 */ ".fl.ijkijkf." + /* 5 */ ".ffffffffff." + /* 6 */ "............" + + // Level 3 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ ".fnnfnnfoff." + /* 2 */ ".n..pq.p.pn." + /* 3 */ ".nq.......n." + /* 4 */ ".n..rq.rq.n." + /* 5 */ ".fnnfnnfnnf." + /* 6 */ "............" + + // Level 4 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "llllllllllll" + /* 1 */ "sffffffffffs" + /* 2 */ ".fttttttttf." + /* 3 */ ".fu......vf." + /* 4 */ ".fttttttttf." + /* 5 */ "wffffffffffw" + /* 6 */ "hhhhhhhhhhhh" + + // Level 5 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "llllllllllll" + /* 2 */ "sxxxxxxxxxxs" + /* 3 */ ".xxxxxxxxxx." + /* 4 */ "wxxxxxxxxxxw" + /* 5 */ "hhhhhhhhhhhh" + /* 6 */ "............" + + // Level 6 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "llllllllllll" + /* 3 */ "xxxxxxxxxxxx" + /* 4 */ "hhhhhhhhhhhh" + /* 5 */ "............" + /* 6 */ "............", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_66 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_87: + // The data has been exported from the gallery Plains, area index 38, ID 87, created by Aloe_vera + { + // Size: + 11, 7, 9, // SizeX = 11, SizeY = 7, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 6, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 67: 3\n" /* stairs */ + "f: 17: 0\n" /* tree */ + "g: 5: 0\n" /* wood */ + "h: 64: 5\n" /* wooddoorblock */ + "i: 64: 7\n" /* wooddoorblock */ + "j:102: 0\n" /* glasspane */ + "k: 64:12\n" /* wooddoorblock */ + "l: 53: 2\n" /* woodstairs */ + "m: 19: 0\n" /* sponge */ + "n: 53: 7\n" /* woodstairs */ + "o: 17: 4\n" /* tree */ + "p: 17: 8\n" /* tree */ + "q: 50: 3\n" /* torch */ + "r: 50: 4\n" /* torch */ + "s: 53: 6\n" /* woodstairs */ + "t: 53: 3\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "....abc...." + /* 1 */ ".ddddddddd." + /* 2 */ ".ddddddddd." + /* 3 */ ".ddddddddd." + /* 4 */ ".ddddddddd." + /* 5 */ ".ddddddddd." + /* 6 */ ".ddddddddd." + /* 7 */ ".ddddddddd." + /* 8 */ "....aec...." + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".fggfhfggf." + /* 2 */ ".g.......g." + /* 3 */ ".g.......g." + /* 4 */ ".f.......f." + /* 5 */ ".g.......g." + /* 6 */ ".g.......g." + /* 7 */ ".fggfifggf." + /* 8 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".fjjfkfjjf." + /* 2 */ ".j.......j." + /* 3 */ ".j.......j." + /* 4 */ ".f.......f." + /* 5 */ ".j.......j." + /* 6 */ ".j.......j." + /* 7 */ ".fjjfkfjjf." + /* 8 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "lllllllllll" + /* 1 */ "nfooooooofn" + /* 2 */ ".p..q.q..p." + /* 3 */ ".p.......p." + /* 4 */ ".p.......p." + /* 5 */ ".p.......p." + /* 6 */ ".p..r.r..p." + /* 7 */ "sfooooooofs" + /* 8 */ "ttttttttttt" + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "lllllllllll" + /* 2 */ "ngggggggggn" + /* 3 */ ".g.......g." + /* 4 */ ".g.......g." + /* 5 */ ".g.......g." + /* 6 */ "sgggggggggs" + /* 7 */ "ttttttttttt" + /* 8 */ "..........." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "lllllllllll" + /* 3 */ "ngggggggggn" + /* 4 */ ".g.......g." + /* 5 */ "sgggggggggs" + /* 6 */ "ttttttttttt" + /* 7 */ "..........." + /* 8 */ "..........." + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "lllllllllll" + /* 4 */ "ggggggggggg" + /* 5 */ "ttttttttttt" + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "...........", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_87 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_90: + // The data has been exported from the gallery Plains, area index 39, ID 90, created by STR_Warrior + { + // Size: + 15, 8, 16, // SizeX = 15, SizeY = 8, SizeZ = 16 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 14, 7, 15, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "A: 53: 7\n" /* woodstairs */ + "B: 53: 4\n" /* woodstairs */ + "C: 53: 5\n" /* woodstairs */ + "D: 53: 6\n" /* woodstairs */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 43: 0\n" /* doubleslab */ + "f: 17: 0\n" /* tree */ + "g: 5: 0\n" /* wood */ + "h: 64: 7\n" /* wooddoorblock */ + "i: 96: 8\n" /* trapdoor */ + "j: 61: 2\n" /* furnace */ + "k: 53: 3\n" /* woodstairs */ + "l: 85: 0\n" /* fence */ + "m: 19: 0\n" /* sponge */ + "n: 53: 2\n" /* woodstairs */ + "o: 53: 1\n" /* woodstairs */ + "p: 53: 0\n" /* woodstairs */ + "q: 47: 0\n" /* bookshelf */ + "r:102: 0\n" /* glasspane */ + "s: 64:12\n" /* wooddoorblock */ + "t: 72: 0\n" /* woodplate */ + "u: 17: 4\n" /* tree */ + "v: 17: 8\n" /* tree */ + "w: 50: 3\n" /* torch */ + "x: 50: 1\n" /* torch */ + "y: 50: 4\n" /* torch */ + "z: 50: 2\n" /* torch */, + + // Block data: + // Level 0 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "......abc......" + /* 1 */ ".ddddddddddddd." + /* 2 */ ".deeeedddddddd." + /* 3 */ ".deeeedddddddd." + /* 4 */ ".ddddddddddddd." + /* 5 */ ".ddddddddddddd." + /* 6 */ ".ddddddddddddd." + /* 7 */ "mddddddddddddd." + /* 8 */ "mmmmmmmmdddddd." + /* 9 */ "mmmmmmmmdddddd." + /* 10 */ "mmmmmmmmdddddd." + /* 11 */ "mmmmmmmmdddddd." + /* 12 */ "mmmmmmmmdddddd." + /* 13 */ "mmmmmmmmdddddd." + /* 14 */ "mmmmmmmmdddddd." + /* 15 */ "mmmmmmmm......." + + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".fggggfhfggggf." + /* 2 */ ".g...i.......g." + /* 3 */ ".gjeee......kg." + /* 4 */ ".f..........lg." + /* 5 */ ".g..........ng." + /* 6 */ ".g.olp..ol...g." + /* 7 */ "mfggggggfn...f." + /* 8 */ "mmmmmmmmg....g." + /* 9 */ "mmmmmmmmgk...g." + /* 10 */ "mmmmmmmmgl..kg." + /* 11 */ "mmmmmmmmgn..lg." + /* 12 */ "mmmmmmmmg...ng." + /* 13 */ "mmmmmmmmgq..qg." + /* 14 */ "mmmmmmmmfggggf." + /* 15 */ "mmmmmmmm......." + + // Level 2 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".fgrrgfsfgrrgf." + /* 2 */ ".g...........g." + /* 3 */ ".g...........r." + /* 4 */ ".f..........tr." + /* 5 */ ".g...........r." + /* 6 */ ".g..t....t...g." + /* 7 */ "mfgrrrrgf....f." + /* 8 */ "mmmmmmmmg....g." + /* 9 */ "mmmmmmmmr....r." + /* 10 */ "mmmmmmmmrt...r." + /* 11 */ "mmmmmmmmr...tr." + /* 12 */ "mmmmmmmmr....r." + /* 13 */ "mmmmmmmmgq..qg." + /* 14 */ "mmmmmmmmfgrrgf." + /* 15 */ "mmmmmmmm......." + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".fuuuuuuuuuuuf." + /* 2 */ ".v....w.w....v." + /* 3 */ ".v...........v." + /* 4 */ ".vx..........v." + /* 5 */ ".v...........v." + /* 6 */ ".v......y....v." + /* 7 */ "mfuuuuuufx..zv." + /* 8 */ "mmmmmmmmv....v." + /* 9 */ "mmmmmmmmv....v." + /* 10 */ "mmmmmmmmv....v." + /* 11 */ "mmmmmmmmv....v." + /* 12 */ "mmmmmmmmv....v." + /* 13 */ "mmmmmmmmv.yy.v." + /* 14 */ "mmmmmmmmfuuuuf." + /* 15 */ "mmmmmmmm......." + + // Level 4 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "nnnnnnnnnnnnnno" + /* 1 */ "pgggggggggggggo" + /* 2 */ "pgAAAAAAAAAABgo" + /* 3 */ "pgC.........Bgo" + /* 4 */ "pgC.........Bgo" + /* 5 */ "pgC.........Bgo" + /* 6 */ "pgCDDDDDDD..Bgo" + /* 7 */ "pggggggggC..Bgo" + /* 8 */ "pkkkkkkpgC..Bgo" + /* 9 */ "mmmmmmmpgC..Bgo" + /* 10 */ "mmmmmmmpgC..Bgo" + /* 11 */ "mmmmmmmpgC..Bgo" + /* 12 */ "mmmmmmmpgC..Bgo" + /* 13 */ "mmmmmmmpgCDDBgo" + /* 14 */ "mmmmmmmpggggggo" + /* 15 */ "mmmmmmmpkkkkkkk" + + // Level 5 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "mpnnnnnnnnnnnom" + /* 2 */ "mpgggggggggggom" + /* 3 */ "mpgggggggggggom" + /* 4 */ "mpgggggggggggom" + /* 5 */ "mpgggggggggggom" + /* 6 */ "mpgggggggggggom" + /* 7 */ "mpkkkkkkkggggom" + /* 8 */ "mmmmmmmmpggggom" + /* 9 */ "mmmmmmmmpggggom" + /* 10 */ "mmmmmmmmpggggom" + /* 11 */ "mmmmmmmmpggggom" + /* 12 */ "mmmmmmmmpggggom" + /* 13 */ "mmmmmmmmpggggom" + /* 14 */ "mmmmmmmmkkkkkom" + /* 15 */ "mmmmmmmmmmmmmmm" + + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmm" + /* 2 */ "mmnnnnnnnnnnnmm" + /* 3 */ "mmpgggggggggomm" + /* 4 */ "mmpgggggggggomm" + /* 5 */ "mmpgggggggggomm" + /* 6 */ "mmkkkkkkkkggomm" + /* 7 */ "mmmmmmmmmpggomm" + /* 8 */ "mmmmmmmmmpggomm" + /* 9 */ "mmmmmmmmmpggomm" + /* 10 */ "mmmmmmmmmpggomm" + /* 11 */ "mmmmmmmmmpggomm" + /* 12 */ "mmmmmmmmmpggomm" + /* 13 */ "mmmmmmmmmkkkomm" + /* 14 */ "mmmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmmm" + + // Level 7 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmmm" + /* 3 */ "mmmpnnnnnnnommm" + /* 4 */ "mmmpgggggggommm" + /* 5 */ "mmmpkkkkkkpommm" + /* 6 */ "mmmmmmmmmmpommm" + /* 7 */ "mmmmmmmmmmpommm" + /* 8 */ "mmmmmmmmmmpommm" + /* 9 */ "mmmmmmmmmmpommm" + /* 10 */ "mmmmmmmmmmpommm" + /* 11 */ "mmmmmmmmmmpommm" + /* 12 */ "mmmmmmmmmmpkmmm" + /* 13 */ "mmmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmmm", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_90 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_91: + // The data has been exported from the gallery Plains, area index 40, ID 91, created by xoft + { + // Size: + 9, 7, 7, // SizeX = 9, SizeY = 7, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 8, 6, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 2: 0\n" /* grass */ + "b: 3: 0\n" /* dirt */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 17: 0\n" /* tree */ + "h: 5: 0\n" /* wood */ + "i: 64: 5\n" /* wooddoorblock */ + "j:102: 0\n" /* glasspane */ + "k: 64:12\n" /* wooddoorblock */ + "l: 53: 2\n" /* woodstairs */ + "m: 19: 0\n" /* sponge */ + "n: 53: 7\n" /* woodstairs */ + "o: 50: 3\n" /* torch */ + "p: 53: 6\n" /* woodstairs */ + "q: 53: 3\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 012345678 */ + /* 0 */ "aaabbbaaa" + /* 1 */ "abbbbbbba" + /* 2 */ "abbbbbbba" + /* 3 */ "abbbbbbba" + /* 4 */ "abbbbbbba" + /* 5 */ "abbbbbbba" + /* 6 */ "aaaaaaaaa" + + // Level 1 + /* z\x* 012345678 */ + /* 0 */ "...cde..." + /* 1 */ ".fffffff." + /* 2 */ ".fffffff." + /* 3 */ ".fffffff." + /* 4 */ ".fffffff." + /* 5 */ ".fffffff." + /* 6 */ "........." + + // Level 2 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".ghhihhg." + /* 2 */ ".h.....h." + /* 3 */ ".h.....h." + /* 4 */ ".h.....h." + /* 5 */ ".ghhhhhg." + /* 6 */ "........." + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".gjhkhjg." + /* 2 */ ".j.....j." + /* 3 */ ".j.....j." + /* 4 */ ".j.....j." + /* 5 */ ".gjjhjjg." + /* 6 */ "........." + + // Level 4 + /* z\x* 012345678 */ + /* 0 */ "lllllllll" + /* 1 */ "nghhhhhgn" + /* 2 */ ".h.o.o.h." + /* 3 */ ".h.....h." + /* 4 */ ".h.....h." + /* 5 */ "pghhhhhgp" + /* 6 */ "qqqqqqqqq" + + // Level 5 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "lllllllll" + /* 2 */ "nhhhhhhhn" + /* 3 */ ".h.....h." + /* 4 */ "phhhhhhhp" + /* 5 */ "qqqqqqqqq" + /* 6 */ "........." + + // Level 6 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "lllllllll" + /* 3 */ "hhhhhhhhh" + /* 4 */ "qqqqqqqqq" + /* 5 */ "........." + /* 6 */ ".........", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_91 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_92: + // The data has been exported from the gallery Plains, area index 41, ID 92, created by xoft + { + // Size: + 11, 6, 7, // SizeX = 11, SizeY = 6, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 5, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 5\n" /* wooddoorblock */ + "h:102: 0\n" /* glasspane */ + "i: 64:12\n" /* wooddoorblock */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 7\n" /* woodstairs */ + "l: 50: 3\n" /* torch */ + "m: 19: 0\n" /* sponge */ + "n: 53: 6\n" /* woodstairs */ + "o: 53: 3\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "....abc...." + /* 1 */ ".ddddddddd." + /* 2 */ ".ddddddddd." + /* 3 */ ".ddddddddd." + /* 4 */ ".ddddddddd." + /* 5 */ ".ddddddddd." + /* 6 */ "..........." + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".efffgfffe." + /* 2 */ ".f.......f." + /* 3 */ ".f.......f." + /* 4 */ ".f.......f." + /* 5 */ ".efffffffe." + /* 6 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".ehhfifhhe." + /* 2 */ ".h.......h." + /* 3 */ ".h.......h." + /* 4 */ ".h.......h." + /* 5 */ ".ehhhfhhhe." + /* 6 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "jjjjjjjjjjj" + /* 1 */ "kfffffffffk" + /* 2 */ ".f..l.l.ff." + /* 3 */ ".f......ff." + /* 4 */ ".f......ff." + /* 5 */ "nfffffffffn" + /* 6 */ "ooooooooooo" + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "jjjjjjjjjjj" + /* 2 */ "kfffffffffk" + /* 3 */ ".fffffffff." + /* 4 */ "nfffffffffn" + /* 5 */ "ooooooooooo" + /* 6 */ "..........." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "jjjjjjjjjjj" + /* 3 */ "fffffffffff" + /* 4 */ "ooooooooooo" + /* 5 */ "..........." + /* 6 */ "...........", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_92 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_93: + // The data has been exported from the gallery Plains, area index 42, ID 93, created by xoft + { + // Size: + 11, 6, 11, // SizeX = 11, SizeY = 6, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 5, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 5\n" /* wooddoorblock */ + "h:102: 0\n" /* glasspane */ + "i: 64:12\n" /* wooddoorblock */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 7\n" /* woodstairs */ + "l: 53: 1\n" /* woodstairs */ + "m: 19: 0\n" /* sponge */ + "n: 50: 3\n" /* torch */ + "o: 50: 4\n" /* torch */ + "p: 53: 6\n" /* woodstairs */ + "q: 50: 1\n" /* torch */ + "r: 50: 2\n" /* torch */ + "s: 53: 3\n" /* woodstairs */ + "t: 53: 0\n" /* woodstairs */ + "u: 53: 5\n" /* woodstairs */ + "v: 53: 4\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "....abc...." + /* 1 */ ".ddddddddd." + /* 2 */ ".ddddddddd." + /* 3 */ ".ddddddddd." + /* 4 */ ".ddddddddd." + /* 5 */ ".ddddddddd." + /* 6 */ ".....ddddd." + /* 7 */ "mmmm.ddddd." + /* 8 */ "mmmm.ddddd." + /* 9 */ "mmmm.ddddd." + /* 10 */ "mmmm......." + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".efffgfffe." + /* 2 */ ".f.......f." + /* 3 */ ".f.......f." + /* 4 */ ".f.......f." + /* 5 */ ".efffe...f." + /* 6 */ ".....f...f." + /* 7 */ "mmmm.f...f." + /* 8 */ "mmmm.f...f." + /* 9 */ "mmmm.efffe." + /* 10 */ "mmmm......." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".ehhfifhhe." + /* 2 */ ".h.......h." + /* 3 */ ".h.......h." + /* 4 */ ".h.......h." + /* 5 */ ".ehhhe...f." + /* 6 */ ".....h...h." + /* 7 */ "mmmm.h...h." + /* 8 */ "mmmm.h...h." + /* 9 */ "mmmm.ehhhe." + /* 10 */ "mmmm......." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "jjjjjjjjjjj" + /* 1 */ "kfffffffffl" + /* 2 */ ".f..n.n..fl" + /* 3 */ ".f.......fl" + /* 4 */ ".f...o...fl" + /* 5 */ "pfffffq.rfl" + /* 6 */ "sssssf...fl" + /* 7 */ "mmmmtf...fl" + /* 8 */ "mmmmtf...fl" + /* 9 */ "mmmmtfffffl" + /* 10 */ "mmmmtu...vl" + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "jjjjjjjjjl." + /* 2 */ "kffffffffl." + /* 3 */ ".f......fl." + /* 4 */ "pffffff.fl." + /* 5 */ "ssssssf.fl." + /* 6 */ ".....tf.fl." + /* 7 */ "mmmm.tf.fl." + /* 8 */ "mmmm.tf.fl." + /* 9 */ "mmmm.tfffl." + /* 10 */ "mmmm.tu.vl." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "jjjjjjjjj.." + /* 3 */ "ffffffffl.." + /* 4 */ "sssssstfl.." + /* 5 */ "......tfl.." + /* 6 */ "......tfl.." + /* 7 */ "mmmm..tfl.." + /* 8 */ "mmmm..tfl.." + /* 9 */ "mmmm..tfl.." + /* 10 */ "mmmm..tfl..", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_93 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_94: + // The data has been exported from the gallery Plains, area index 43, ID 94, created by xoft + { + // Size: + 15, 6, 11, // SizeX = 15, SizeY = 6, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 14, 5, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 5\n" /* wooddoorblock */ + "h:102: 0\n" /* glasspane */ + "i: 64:12\n" /* wooddoorblock */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 0\n" /* woodstairs */ + "l: 53: 1\n" /* woodstairs */ + "m: 19: 0\n" /* sponge */ + "n: 50: 3\n" /* torch */ + "o: 50: 4\n" /* torch */ + "p: 50: 2\n" /* torch */ + "q: 50: 1\n" /* torch */ + "r: 53: 3\n" /* woodstairs */ + "s: 53: 5\n" /* woodstairs */ + "t: 53: 4\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "......abc......" + /* 1 */ ".ddddddddddddd." + /* 2 */ ".ddddddddddddd." + /* 3 */ ".ddddddddddddd." + /* 4 */ ".ddddddddddddd." + /* 5 */ ".ddddddddddddd." + /* 6 */ ".ddddd...ddddd." + /* 7 */ ".ddddd...ddddd." + /* 8 */ ".ddddd...ddddd." + /* 9 */ ".ddddd...ddddd." + /* 10 */ "..............." + + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".efffffgfffffe." + /* 2 */ ".f...........f." + /* 3 */ ".f...........f." + /* 4 */ ".f...........f." + /* 5 */ ".f...efffe...f." + /* 6 */ ".f...f...f...f." + /* 7 */ ".f...f...f...f." + /* 8 */ ".f...f...f...f." + /* 9 */ ".efffe...efffe." + /* 10 */ "..............." + + // Level 2 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".ehhhhfifhhhhe." + /* 2 */ ".h...........h." + /* 3 */ ".h...........h." + /* 4 */ ".h...........h." + /* 5 */ ".f...ehhhe...f." + /* 6 */ ".h...h...h...h." + /* 7 */ ".h...h...h...h." + /* 8 */ ".h...h...h...h." + /* 9 */ ".ehhhe...ehhhe." + /* 10 */ "..............." + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "jjjjjjjjjjjjjjj" + /* 1 */ "kfffffffffffffl" + /* 2 */ "kf....n.n....fl" + /* 3 */ "kf...........fl" + /* 4 */ "kf...o...o...fl" + /* 5 */ "kf..pfffffq..fl" + /* 6 */ "kf...frrrf...fl" + /* 7 */ "kf...fl.kf...fl" + /* 8 */ "kf...fl.kf...fl" + /* 9 */ "kfffffl.kfffffl" + /* 10 */ "ks...tl.ks...tl" + + // Level 4 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".jjjjjjjjjjjjl." + /* 2 */ ".kfffffffffffl." + /* 3 */ ".kfffffffffffl." + /* 4 */ ".kfffffffffffl." + /* 5 */ ".kffflrrrrfffl." + /* 6 */ ".kfffl...kfffl." + /* 7 */ ".kfffl...kfffl." + /* 8 */ ".kfffl...kfffl." + /* 9 */ ".kfffl...kfffl." + /* 10 */ ".ks.tl...ks.tl." + + // Level 5 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..kjjjjjjjjjj.." + /* 3 */ "..kfffffffffl.." + /* 4 */ "..kflrrrrrkfl.." + /* 5 */ "..kfl.....kfl.." + /* 6 */ "..kfl.....kfl.." + /* 7 */ "..kfl.....kfl.." + /* 8 */ "..kfl.....kfl.." + /* 9 */ "..kfl.....kfl.." + /* 10 */ "..kfl.....kfl..", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_94 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_97: + // The data has been exported from the gallery Plains, area index 46, ID 97, created by Aloe_vera + { + // Size: + 11, 6, 7, // SizeX = 11, SizeY = 6, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 5, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 5\n" /* wooddoorblock */ + "h: 53: 3\n" /* woodstairs */ + "i: 85: 0\n" /* fence */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 1\n" /* woodstairs */ + "l: 53: 0\n" /* woodstairs */ + "m: 19: 0\n" /* sponge */ + "n:102: 0\n" /* glasspane */ + "o: 64:12\n" /* wooddoorblock */ + "p: 50: 3\n" /* torch */ + "q: 72: 0\n" /* woodplate */ + "r: 53: 7\n" /* woodstairs */ + "s: 47: 0\n" /* bookshelf */ + "t: 50: 1\n" /* torch */ + "u: 50: 2\n" /* torch */ + "v: 53: 6\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "....abc...." + /* 1 */ ".ddddddddd." + /* 2 */ ".ddddddddd." + /* 3 */ ".ddddddddd." + /* 4 */ ".ddddddddd." + /* 5 */ ".ddddddddd." + /* 6 */ "..........." + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".efffgfffe." + /* 2 */ ".fh.....hf." + /* 3 */ ".fi.....if." + /* 4 */ ".fj.kil.jf." + /* 5 */ ".efffffffe." + /* 6 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".ennfofnne." + /* 2 */ ".n..p.p..n." + /* 3 */ ".nq.....qn." + /* 4 */ ".n...q...n." + /* 5 */ ".ennnfnnne." + /* 6 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "jjjjjjjjjjj" + /* 1 */ "rfffffffffr" + /* 2 */ ".fsssssssf." + /* 3 */ ".ft.....uf." + /* 4 */ ".fsssssssf." + /* 5 */ "vfffffffffv" + /* 6 */ "hhhhhhhhhhh" + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "jjjjjjjjjjj" + /* 2 */ "rfffffffffr" + /* 3 */ ".f.......f." + /* 4 */ "vfffffffffv" + /* 5 */ "hhhhhhhhhhh" + /* 6 */ "..........." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "jjjjjjjjjjj" + /* 3 */ "fffffffffff" + /* 4 */ "hhhhhhhhhhh" + /* 5 */ "..........." + /* 6 */ "...........", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_97 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_98: + // The data has been exported from the gallery Plains, area index 47, ID 98, created by Aloe_vera + { + // Size: + 12, 7, 9, // SizeX = 12, SizeY = 7, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 11, 6, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 5\n" /* wooddoorblock */ + "h: 53: 3\n" /* woodstairs */ + "i: 85: 0\n" /* fence */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 1\n" /* woodstairs */ + "l: 53: 0\n" /* woodstairs */ + "m: 19: 0\n" /* sponge */ + "n:102: 0\n" /* glasspane */ + "o: 64:13\n" /* wooddoorblock */ + "p: 64:12\n" /* wooddoorblock */ + "q: 50: 3\n" /* torch */ + "r: 72: 0\n" /* woodplate */ + "s: 53: 7\n" /* woodstairs */ + "t: 47: 0\n" /* bookshelf */ + "u: 50: 1\n" /* torch */ + "v: 50: 2\n" /* torch */ + "w: 53: 6\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "....abbc...." + /* 1 */ ".dddddddddd." + /* 2 */ ".dddddddddd." + /* 3 */ ".dddddddddd." + /* 4 */ ".dddddddddd." + /* 5 */ ".dddddddddd." + /* 6 */ ".dddddddddd." + /* 7 */ ".dddddddddd." + /* 8 */ "............" + + // Level 1 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ ".efffggfffe." + /* 2 */ ".f........f." + /* 3 */ ".fh......hf." + /* 4 */ ".fi......if." + /* 5 */ ".fj......jf." + /* 6 */ ".f.kilkil.f." + /* 7 */ ".effffffffe." + /* 8 */ "............" + + // Level 2 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ ".ennfopfnne." + /* 2 */ ".n..q..q..n." + /* 3 */ ".n........n." + /* 4 */ ".fr......rf." + /* 5 */ ".n........n." + /* 6 */ ".n..r..r..n." + /* 7 */ ".ennfnnfnne." + /* 8 */ "............" + + // Level 3 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "jjjjjjjjjjjj" + /* 1 */ "sffffffffffs" + /* 2 */ ".fttttttttf." + /* 3 */ ".f........f." + /* 4 */ ".fu......vf." + /* 5 */ ".f........f." + /* 6 */ ".fttttttttf." + /* 7 */ "wffffffffffw" + /* 8 */ "hhhhhhhhhhhh" + + // Level 4 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "jjjjjjjjjjjj" + /* 2 */ "sffffffffffs" + /* 3 */ ".fttttttttf." + /* 4 */ ".f........f." + /* 5 */ ".fttttttttf." + /* 6 */ "wffffffffffw" + /* 7 */ "hhhhhhhhhhhh" + /* 8 */ "............" + + // Level 5 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "jjjjjjjjjjjj" + /* 3 */ "sffffffffffs" + /* 4 */ ".f........f." + /* 5 */ "wffffffffffw" + /* 6 */ "hhhhhhhhhhhh" + /* 7 */ "............" + /* 8 */ "............" + + // Level 6 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "............" + /* 3 */ "jjjjjjjjjjjj" + /* 4 */ "ffffffffffff" + /* 5 */ "hhhhhhhhhhhh" + /* 6 */ "............" + /* 7 */ "............" + /* 8 */ "............", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_98 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PlainsVillage_99: + // The data has been exported from the gallery Plains, area index 48, ID 99, created by Aloe_vera + { + // Size: + 11, 7, 13, // SizeX = 11, SizeY = 7, SizeZ = 13 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 6, 12, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 67: 0\n" /* stairs */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 4: 0\n" /* cobblestone */ + "e: 43: 0\n" /* doubleslab */ + "f: 2: 0\n" /* grass */ + "g: 17: 0\n" /* tree */ + "h: 5: 0\n" /* wood */ + "i: 64: 5\n" /* wooddoorblock */ + "j: 53: 3\n" /* woodstairs */ + "k: 85: 0\n" /* fence */ + "l: 53: 2\n" /* woodstairs */ + "m: 19: 0\n" /* sponge */ + "n: 64: 7\n" /* wooddoorblock */ + "o:102: 0\n" /* glasspane */ + "p: 64:12\n" /* wooddoorblock */ + "q: 72: 0\n" /* woodplate */ + "r: 53: 7\n" /* woodstairs */ + "s: 50: 1\n" /* torch */ + "t: 50: 2\n" /* torch */ + "u: 53: 6\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "....abc...." + /* 1 */ ".ddddddddd." + /* 2 */ ".deeeedddd." + /* 3 */ ".deeeedddd." + /* 4 */ ".deeeedddd." + /* 5 */ ".deeeedddd." + /* 6 */ ".deeeedddd." + /* 7 */ ".ddddddddd." + /* 8 */ "..fffffff.." + /* 9 */ "mmfffffffmm" + /* 10 */ "mmfffffffmm" + /* 11 */ "mmfffffffmm" + /* 12 */ "mmfffffffmm" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".ghhhihhhg." + /* 2 */ ".h.e....jh." + /* 3 */ ".h.e....kh." + /* 4 */ ".h.e....lh." + /* 5 */ ".h.......h." + /* 6 */ ".h.......h." + /* 7 */ ".ghhhnhhhg." + /* 8 */ "..k.....k.." + /* 9 */ "mmk.....kmm" + /* 10 */ "mmk.....kmm" + /* 11 */ "mmk.....kmm" + /* 12 */ "mmkkkkkkkmm" + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".goohphoog." + /* 2 */ ".o.......o." + /* 3 */ ".o......qo." + /* 4 */ ".h.......h." + /* 5 */ ".o.......o." + /* 6 */ ".o.......o." + /* 7 */ ".goohphoog." + /* 8 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "lllllllllll" + /* 1 */ "rhhhhhhhhhr" + /* 2 */ ".h.......h." + /* 3 */ ".h.......h." + /* 4 */ ".hs.....th." + /* 5 */ ".h.......h." + /* 6 */ ".h.......h." + /* 7 */ "uhhhhhhhhhu" + /* 8 */ "jjjjjjjjjjj" + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "lllllllllll" + /* 2 */ "rhhhhhhhhhr" + /* 3 */ ".h.......h." + /* 4 */ ".h.......h." + /* 5 */ ".h.......h." + /* 6 */ "uhhhhhhhhhu" + /* 7 */ "jjjjjjjjjjj" + /* 8 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "lllllllllll" + /* 3 */ "rhhhhhhhhhr" + /* 4 */ ".h.......h." + /* 5 */ "uhhhhhhhhhu" + /* 6 */ "jjjjjjjjjjj" + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "lllllllllll" + /* 4 */ "hhhhhhhhhhh" + /* 5 */ "jjjjjjjjjjj" + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // PlainsVillage_99 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // RoofedWell: + // The data has been exported from the gallery Plains, area index 119, ID 271, created by STR_Warrior + { + // Size: + 7, 15, 7, // SizeX = 7, SizeY = 15, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 14, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 1: 0\n" /* stone */ + "b: 4: 0\n" /* cobblestone */ + "c: 8: 0\n" /* water */ + "d: 3: 0\n" /* dirt */ + "e: 2: 0\n" /* grass */ + "f: 13: 0\n" /* gravel */ + "g:118: 3\n" /* cauldronblock */ + "h: 85: 0\n" /* fence */ + "i: 53: 2\n" /* woodstairs */ + "j: 53: 7\n" /* woodstairs */ + "k: 5: 0\n" /* wood */ + "l: 53: 4\n" /* woodstairs */ + "m: 19: 0\n" /* sponge */ + "n: 53: 5\n" /* woodstairs */ + "o: 53: 6\n" /* woodstairs */ + "p: 53: 3\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "aaaaaaa" + /* 2 */ "aaaaaaa" + /* 3 */ "aaaaaaa" + /* 4 */ "aaaaaaa" + /* 5 */ "aaaaaaa" + /* 6 */ "aaaaaaa" + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "ddddddd" + /* 1 */ "dbbbbbd" + /* 2 */ "dbcccbd" + /* 3 */ "dbcccbd" + /* 4 */ "dbcccbd" + /* 5 */ "dbbbbbd" + /* 6 */ "ddddddd" + + // Level 6 + /* z\x* 0123456 */ + /* 0 */ "ddddddd" + /* 1 */ "dbbbbbd" + /* 2 */ "dbcccbd" + /* 3 */ "dbcccbd" + /* 4 */ "dbcccbd" + /* 5 */ "dbbbbbd" + /* 6 */ "ddddddd" + + // Level 7 + /* z\x* 0123456 */ + /* 0 */ "ddddddd" + /* 1 */ "dbbbbbd" + /* 2 */ "dbcccbd" + /* 3 */ "dbcccbd" + /* 4 */ "dbcccbd" + /* 5 */ "dbbbbbd" + /* 6 */ "ddddddd" + + // Level 8 + /* z\x* 0123456 */ + /* 0 */ "eefffee" + /* 1 */ "ebbbbbe" + /* 2 */ "fbcccbf" + /* 3 */ "fbcccbf" + /* 4 */ "fbcccbf" + /* 5 */ "ebbbbbe" + /* 6 */ "eefffee" + + // Level 9 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".bbbbb." + /* 2 */ ".b...b." + /* 3 */ ".b.g.b." + /* 4 */ ".b...b." + /* 5 */ ".bbbbb." + /* 6 */ "......." + + // Level 10 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".h...h." + /* 2 */ "......." + /* 3 */ "...h..." + /* 4 */ "......." + /* 5 */ ".h...h." + /* 6 */ "......." + + // Level 11 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".h...h." + /* 2 */ "......." + /* 3 */ "...h..." + /* 4 */ "......." + /* 5 */ ".h...h." + /* 6 */ "......." + + // Level 12 + /* z\x* 0123456 */ + /* 0 */ "iiiiiii" + /* 1 */ "jkjjjkj" + /* 2 */ ".l...n." + /* 3 */ ".l.h.n." + /* 4 */ ".l...n." + /* 5 */ "okoooko" + /* 6 */ "ppppppp" + + // Level 13 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "iiiiiii" + /* 2 */ "jkjjjkj" + /* 3 */ ".k.h.k." + /* 4 */ "okoooko" + /* 5 */ "ppppppp" + /* 6 */ "......." + + // Level 14 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "......." + /* 2 */ "iiiiiii" + /* 3 */ "kkkkkkk" + /* 4 */ "ppppppp" + /* 5 */ "......." + /* 6 */ ".......", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // RoofedWell + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Windmill: + // The data has been exported from the gallery Plains, area index 60, ID 111, created by Aloe_vera + { + // Size: + 9, 16, 13, // SizeX = 9, SizeY = 16, SizeZ = 13 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 8, 15, 12, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 67: 3\n" /* stairs */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 54: 4\n" /* chest */ + "h:154: 4\n" /* hopper */ + "i: 64: 6\n" /* wooddoorblock */ + "j:102: 0\n" /* glasspane */ + "k: 85: 0\n" /* fence */ + "l: 64:12\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */ + "n: 50: 2\n" /* torch */ + "o: 35: 0\n" /* wool */ + "p: 17: 4\n" /* tree */ + "q: 17: 8\n" /* tree */ + "r: 53: 2\n" /* woodstairs */ + "s: 53: 7\n" /* woodstairs */ + "t: 53: 6\n" /* woodstairs */ + "u: 53: 3\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 012345678 */ + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." + /* 3 */ "........." + /* 4 */ ".aaaaa..." + /* 5 */ ".aaaaab.." + /* 6 */ ".aaaaac.." + /* 7 */ ".aaaaad.." + /* 8 */ ".aaaaa..." + /* 9 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." + + // Level 1 + /* z\x* 012345678 */ + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." + /* 3 */ "........." + /* 4 */ ".efffe..." + /* 5 */ ".f...f..." + /* 6 */ ".fgh.i..." + /* 7 */ ".f...f..." + /* 8 */ ".efffe..." + /* 9 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." + + // Level 2 + /* z\x* 012345678 */ + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." + /* 3 */ "........." + /* 4 */ ".ejjje..." + /* 5 */ ".j...f..." + /* 6 */ ".j.k.l..." + /* 7 */ ".j...f..." + /* 8 */ ".ejjje..." + /* 9 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." + /* 3 */ "........." + /* 4 */ ".efffe..." + /* 5 */ ".f..nf..." + /* 6 */ ".f.k.f..." + /* 7 */ ".f..nf..k" + /* 8 */ ".efffe..o" + /* 9 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." + + // Level 4 + /* z\x* 012345678 */ + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." + /* 3 */ "........." + /* 4 */ ".epppe..." + /* 5 */ ".q...q..." + /* 6 */ ".q.k.q..." + /* 7 */ ".q...q..k" + /* 8 */ ".epppe..o" + /* 9 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." + + // Level 5 + /* z\x* 012345678 */ + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." + /* 3 */ "........." + /* 4 */ ".efffe..." + /* 5 */ ".f...f..." + /* 6 */ ".f.k.f..k" + /* 7 */ ".f...f..o" + /* 8 */ ".efffe..o" + /* 9 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." + + // Level 6 + /* z\x* 012345678 */ + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." + /* 3 */ "........." + /* 4 */ ".ejjje..." + /* 5 */ ".j...j..." + /* 6 */ ".j.k.j..k" + /* 7 */ ".j...j..o" + /* 8 */ ".ejjje..." + /* 9 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." + + // Level 7 + /* z\x* 012345678 */ + /* 0 */ "mmmmmmm.o" + /* 1 */ "mmmmmmm.o" + /* 2 */ "mmmmmmm.o" + /* 3 */ "........." + /* 4 */ ".efffe..." + /* 5 */ ".f...f..k" + /* 6 */ ".f.k.f..o" + /* 7 */ ".f...f..o" + /* 8 */ ".efffe..." + /* 9 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." + + // Level 8 + /* z\x* 012345678 */ + /* 0 */ "mmmmmmm.k" + /* 1 */ "mmmmmmm.k" + /* 2 */ "mmmmmmm.o" + /* 3 */ "........o" + /* 4 */ ".epppe..o" + /* 5 */ ".q...q..k" + /* 6 */ ".q.k.q..o" + /* 7 */ ".q...q..k" + /* 8 */ ".epppe..k" + /* 9 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." + + // Level 9 + /* z\x* 012345678 */ + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.k" + /* 3 */ "rrrrrrr.k" + /* 4 */ "sfffffs.o" + /* 5 */ ".f...f..o" + /* 6 */ ".f.kppppp" + /* 7 */ ".f...f..o" + /* 8 */ "tffffft.o" + /* 9 */ "uuuuuuu.k" + /* 10 */ "mmmmmmm.k" + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." + + // Level 10 + /* z\x* 012345678 */ + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." + /* 3 */ "mmmmmmm.." + /* 4 */ "rrrrrrr.k" + /* 5 */ "sfffffs.k" + /* 6 */ ".f...f..o" + /* 7 */ "tffffft.k" + /* 8 */ "uuuuuuu.o" + /* 9 */ "mmmmmmm.o" + /* 10 */ "mmmmmmm.o" + /* 11 */ "mmmmmmm.k" + /* 12 */ "mmmmmmm.k" + + // Level 11 + /* z\x* 012345678 */ + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." + /* 3 */ "mmmmmmm.." + /* 4 */ "mmmmmmm.." + /* 5 */ "rrrrrrr.o" + /* 6 */ "fffffff.o" + /* 7 */ "uuuuuuu.k" + /* 8 */ "mmmmmmm.." + /* 9 */ "mmmmmmm.." + /* 10 */ "mmmmmmm.o" + /* 11 */ "mmmmmmm.o" + /* 12 */ "mmmmmmm.o" + + // Level 12 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." + /* 3 */ "........." + /* 4 */ "........." + /* 5 */ "........o" + /* 6 */ "........k" + /* 7 */ "........." + /* 8 */ "........." + /* 9 */ "........." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ "........." + + // Level 13 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." + /* 3 */ "........." + /* 4 */ "........o" + /* 5 */ "........o" + /* 6 */ "........k" + /* 7 */ "........." + /* 8 */ "........." + /* 9 */ "........." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ "........." + + // Level 14 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." + /* 3 */ "........." + /* 4 */ "........o" + /* 5 */ "........k" + /* 6 */ "........." + /* 7 */ "........." + /* 8 */ "........." + /* 9 */ "........." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ "........." + + // Level 15 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." + /* 3 */ "........." + /* 4 */ "........o" + /* 5 */ "........k" + /* 6 */ "........." + /* 7 */ "........." + /* 8 */ "........." + /* 9 */ "........." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ ".........", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // Windmill +}; // g_PlainsVillagePrefabs + + + + + + +const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Well: + // The data has been exported from the gallery Plains, area index 1, ID 5, created by Aloe_vera + { + // Size: + 4, 13, 4, // SizeX = 4, SizeY = 13, SizeZ = 4 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 3, 12, 3, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 1: 0\n" /* stone */ + "b: 4: 0\n" /* cobblestone */ + "c: 8: 0\n" /* water */ + "d: 85: 0\n" /* fence */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 0123 */ + /* 0 */ "aaaa" + /* 1 */ "aaaa" + /* 2 */ "aaaa" + /* 3 */ "aaaa" + + // Level 1 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 2 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 3 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 4 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 5 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 6 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 7 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 8 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 9 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "b..b" + /* 2 */ "b..b" + /* 3 */ "bbbb" + + // Level 10 + /* z\x* 0123 */ + /* 0 */ "d..d" + /* 1 */ "...." + /* 2 */ "...." + /* 3 */ "d..d" + + // Level 11 + /* z\x* 0123 */ + /* 0 */ "d..d" + /* 1 */ "...." + /* 2 */ "...." + /* 3 */ "d..d" + + // Level 12 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bbbb" + /* 2 */ "bbbb" + /* 3 */ "bbbb", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // Well +}; + + + + + +// The prefab counts: + +const size_t g_PlainsVillagePrefabsCount = ARRAYCOUNT(g_PlainsVillagePrefabs); + +const size_t g_PlainsVillageStartingPrefabsCount = ARRAYCOUNT(g_PlainsVillageStartingPrefabs); + diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.h b/src/Generating/Prefabs/PlainsVillagePrefabs.h new file mode 100644 index 000000000..087783b1e --- /dev/null +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.h @@ -0,0 +1,15 @@ + +// PlainsVillagePrefabs.h + +// Declares the prefabs in the group PlainsVillage + +#include "../Prefab.h" + + + + + +extern const cPrefab::sDef g_PlainsVillagePrefabs[]; +extern const cPrefab::sDef g_PlainsVillageStartingPrefabs[]; +extern const size_t g_PlainsVillagePrefabsCount; +extern const size_t g_PlainsVillageStartingPrefabsCount; diff --git a/src/Generating/Prefabs/SandVillagePrefabs.cpp b/src/Generating/Prefabs/SandVillagePrefabs.cpp new file mode 100644 index 000000000..23af0f0a6 --- /dev/null +++ b/src/Generating/Prefabs/SandVillagePrefabs.cpp @@ -0,0 +1,1887 @@ + +// SandVillagePrefabs.cpp + +// Defines the prefabs in the group SandVillage + +// NOTE: This file has been generated automatically by GalExport! +// Any manual changes will be overwritten by the next automatic export! + +#include "Globals.h" +#include "SandVillagePrefabs.h" + + + + + +const cPrefab::sDef g_SandVillagePrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // DoubleField: + // The data has been exported from the gallery Desert, area index 5, ID 75, created by tonibm1999 + { + // Size: + 13, 2, 9, // SizeX = 13, SizeY = 2, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 12, 1, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 24: 0\n" /* sandstone */ + "b: 60: 7\n" /* tilleddirt */ + "c: 8: 0\n" /* water */ + "d: 50: 5\n" /* torch */ + "e: 59: 7\n" /* crops */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "aaaaaaaaaaaaa" + /* 1 */ "abbcbbabbcbba" + /* 2 */ "abbcbbabbcbba" + /* 3 */ "abbcbbabbcbba" + /* 4 */ "abbcbbabbcbba" + /* 5 */ "abbcbbabbcbba" + /* 6 */ "abbcbbabbcbba" + /* 7 */ "abbcbbabbcbba" + /* 8 */ "aaaaaaaaaaaaa" + + // Level 1 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "d.....d.....d" + /* 1 */ ".......ee.ee." + /* 2 */ ".......ee.ee." + /* 3 */ ".......ee.ee." + /* 4 */ ".......ee.ee." + /* 5 */ ".......ee.ee." + /* 6 */ ".......ee.ee." + /* 7 */ ".......ee.ee." + /* 8 */ "d.....d.....d", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // DoubleField + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House11x7: + // The data has been exported from the gallery Desert, area index 6, ID 81, created by Aloe_vera + { + // Size: + 11, 6, 7, // SizeX = 11, SizeY = 6, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 5, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 5\n" /* wooddoorblock */ + "f:102: 0\n" /* glasspane */ + "g: 64:12\n" /* wooddoorblock */ + "h:128: 7\n" /* sandstonestairs */ + "i: 50: 3\n" /* torch */ + "j: 50: 4\n" /* torch */ + "k:128: 6\n" /* sandstonestairs */ + "l:128: 3\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */ + "n: 50: 1\n" /* torch */ + "o: 50: 2\n" /* torch */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "....abc...." + /* 1 */ ".ddddddddd." + /* 2 */ ".ddddddddd." + /* 3 */ ".ddddddddd." + /* 4 */ ".ddddddddd." + /* 5 */ ".ddddddddd." + /* 6 */ "..........." + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".ddddedddd." + /* 2 */ ".d.......d." + /* 3 */ ".d.......d." + /* 4 */ ".d.......d." + /* 5 */ ".ddddddddd." + /* 6 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".dffdgdffd." + /* 2 */ ".f.......f." + /* 3 */ ".f.......f." + /* 4 */ ".f.......f." + /* 5 */ ".dffdfdffd." + /* 6 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "bbbbbbbbbbb" + /* 1 */ "hdddddddddh" + /* 2 */ ".d..i.i..d." + /* 3 */ ".d.......d." + /* 4 */ ".d..j.j..d." + /* 5 */ "kdddddddddk" + /* 6 */ "lllllllllll" + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "bbbbbbbbbbb" + /* 2 */ "hdddddddddh" + /* 3 */ ".dn.....od." + /* 4 */ "kdddddddddk" + /* 5 */ "lllllllllll" + /* 6 */ "..........." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "bbbbbbbbbbb" + /* 3 */ "ddddddddddd" + /* 4 */ "lllllllllll" + /* 5 */ "..........." + /* 6 */ "...........", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House11x7 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House11x9: + // The data has been exported from the gallery Desert, area index 11, ID 115, created by xoft + { + // Size: + 11, 7, 9, // SizeX = 11, SizeY = 7, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 6, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 5\n" /* wooddoorblock */ + "f:102: 0\n" /* glasspane */ + "g: 64:12\n" /* wooddoorblock */ + "h:128: 7\n" /* sandstonestairs */ + "i: 50: 3\n" /* torch */ + "j: 50: 4\n" /* torch */ + "k:128: 6\n" /* sandstonestairs */ + "l:128: 3\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "....abc...." + /* 1 */ ".ddddddddd." + /* 2 */ ".ddddddddd." + /* 3 */ ".ddddddddd." + /* 4 */ ".ddddddddd." + /* 5 */ ".ddddddddd." + /* 6 */ ".ddddddddd." + /* 7 */ ".ddddddddd." + /* 8 */ "..........." + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".ddddedddd." + /* 2 */ ".d.......d." + /* 3 */ ".d.......d." + /* 4 */ ".d.......d." + /* 5 */ ".d.......d." + /* 6 */ ".d.......d." + /* 7 */ ".ddddddddd." + /* 8 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".dffdgdffd." + /* 2 */ ".f.......f." + /* 3 */ ".f.......f." + /* 4 */ ".d.......d." + /* 5 */ ".f.......f." + /* 6 */ ".f.......f." + /* 7 */ ".dfffdfffd." + /* 8 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "bbbbbbbbbbb" + /* 1 */ "hdddddddddh" + /* 2 */ ".d..i.i..d." + /* 3 */ ".d.......d." + /* 4 */ ".d.......d." + /* 5 */ ".d.......d." + /* 6 */ ".d...j...d." + /* 7 */ "kdddddddddk" + /* 8 */ "lllllllllll" + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "bbbbbbbbbbb" + /* 2 */ "hdddddddddh" + /* 3 */ ".d.......d." + /* 4 */ ".d.......d." + /* 5 */ ".d.......d." + /* 6 */ "kdddddddddk" + /* 7 */ "lllllllllll" + /* 8 */ "..........." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "bbbbbbbbbbb" + /* 3 */ "hdddddddddh" + /* 4 */ ".d.......d." + /* 5 */ "kdddddddddk" + /* 6 */ "lllllllllll" + /* 7 */ "..........." + /* 8 */ "..........." + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "bbbbbbbbbbb" + /* 4 */ "ddddddddddd" + /* 5 */ "lllllllllll" + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "...........", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House11x9 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House13x7: + // The data has been exported from the gallery Desert, area index 15, ID 125, created by Aloe_vera + { + // Size: + 13, 6, 7, // SizeX = 13, SizeY = 6, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 12, 5, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 5\n" /* wooddoorblock */ + "f:102: 0\n" /* glasspane */ + "g: 64:12\n" /* wooddoorblock */ + "h:128: 7\n" /* sandstonestairs */ + "i: 50: 3\n" /* torch */ + "j: 50: 4\n" /* torch */ + "k:128: 6\n" /* sandstonestairs */ + "l:128: 3\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ ".....abc....." + /* 1 */ ".ddddddddddd." + /* 2 */ ".ddddddddddd." + /* 3 */ ".ddddddddddd." + /* 4 */ ".ddddddddddd." + /* 5 */ ".ddddddddddd." + /* 6 */ "............." + + // Level 1 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ ".dddddeddddd." + /* 2 */ ".d.........d." + /* 3 */ ".d.........d." + /* 4 */ ".d.........d." + /* 5 */ ".ddddddddddd." + /* 6 */ "............." + + // Level 2 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ ".dfffdgdfffd." + /* 2 */ ".f.........f." + /* 3 */ ".f.........f." + /* 4 */ ".f.........f." + /* 5 */ ".dffdfffdffd." + /* 6 */ "............." + + // Level 3 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "bbbbbbbbbbbbb" + /* 1 */ "hdddddddddddh" + /* 2 */ ".d...i.i...d." + /* 3 */ ".d.........d." + /* 4 */ ".d..j...j..d." + /* 5 */ "kdddddddddddk" + /* 6 */ "lllllllllllll" + + // Level 4 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "bbbbbbbbbbbbb" + /* 2 */ "hdddddddddddh" + /* 3 */ ".d.........d." + /* 4 */ "kdddddddddddk" + /* 5 */ "lllllllllllll" + /* 6 */ "............." + + // Level 5 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "............." + /* 2 */ "bbbbbbbbbbbbb" + /* 3 */ "ddddddddddddd" + /* 4 */ "lllllllllllll" + /* 5 */ "............." + /* 6 */ ".............", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House13x7 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House13x9: + // The data has been exported from the gallery Desert, area index 12, ID 116, created by xoft + { + // Size: + 13, 7, 9, // SizeX = 13, SizeY = 7, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 12, 6, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 5\n" /* wooddoorblock */ + "f:102: 0\n" /* glasspane */ + "g: 64:12\n" /* wooddoorblock */ + "h:128: 7\n" /* sandstonestairs */ + "i: 50: 3\n" /* torch */ + "j: 50: 4\n" /* torch */ + "k:128: 6\n" /* sandstonestairs */ + "l:128: 3\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ ".....abc....." + /* 1 */ ".ddddddddddd." + /* 2 */ ".ddddddddddd." + /* 3 */ ".ddddddddddd." + /* 4 */ ".ddddddddddd." + /* 5 */ ".ddddddddddd." + /* 6 */ ".ddddddddddd." + /* 7 */ ".ddddddddddd." + /* 8 */ "............." + + // Level 1 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ ".dddddeddddd." + /* 2 */ ".d.........d." + /* 3 */ ".d.........d." + /* 4 */ ".d.........d." + /* 5 */ ".d.........d." + /* 6 */ ".d.........d." + /* 7 */ ".ddddddddddd." + /* 8 */ "............." + + // Level 2 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ ".dfffdgdfffd." + /* 2 */ ".f.........f." + /* 3 */ ".f.........f." + /* 4 */ ".d.........d." + /* 5 */ ".f.........f." + /* 6 */ ".f.........f." + /* 7 */ ".dffdffdfffd." + /* 8 */ "............." + + // Level 3 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "bbbbbbbbbbbbb" + /* 1 */ "hdddddddddddh" + /* 2 */ ".d...i.i...d." + /* 3 */ ".d.........d." + /* 4 */ ".d.........d." + /* 5 */ ".d.........d." + /* 6 */ ".d..j..j...d." + /* 7 */ "kdddddddddddk" + /* 8 */ "lllllllllllll" + + // Level 4 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "bbbbbbbbbbbbb" + /* 2 */ "hdddddddddddh" + /* 3 */ ".d.........d." + /* 4 */ ".d.........d." + /* 5 */ ".d.........d." + /* 6 */ "kdddddddddddk" + /* 7 */ "lllllllllllll" + /* 8 */ "............." + + // Level 5 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "............." + /* 2 */ "bbbbbbbbbbbbb" + /* 3 */ "hdddddddddddh" + /* 4 */ ".d.........d." + /* 5 */ "kdddddddddddk" + /* 6 */ "lllllllllllll" + /* 7 */ "............." + /* 8 */ "............." + + // Level 6 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "............." + /* 2 */ "............." + /* 3 */ "bbbbbbbbbbbbb" + /* 4 */ "ddddddddddddd" + /* 5 */ "lllllllllllll" + /* 6 */ "............." + /* 7 */ "............." + /* 8 */ ".............", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House13x9 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House15x9: + // The data has been exported from the gallery Desert, area index 13, ID 118, created by xoft + { + // Size: + 15, 7, 9, // SizeX = 15, SizeY = 7, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 14, 6, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 5\n" /* wooddoorblock */ + "f:102: 0\n" /* glasspane */ + "g: 64:12\n" /* wooddoorblock */ + "h:128: 7\n" /* sandstonestairs */ + "i: 50: 3\n" /* torch */ + "j: 50: 4\n" /* torch */ + "k:128: 6\n" /* sandstonestairs */ + "l:128: 3\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ ".....abc......." + /* 1 */ ".ddddddddddddd." + /* 2 */ ".ddddddddddddd." + /* 3 */ ".ddddddddddddd." + /* 4 */ ".ddddddddddddd." + /* 5 */ ".ddddddddddddd." + /* 6 */ ".ddddddddddddd." + /* 7 */ ".ddddddddddddd." + /* 8 */ "..............." + + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".dddddeddddddd." + /* 2 */ ".d...........d." + /* 3 */ ".d...........d." + /* 4 */ ".d...........d." + /* 5 */ ".d...........d." + /* 6 */ ".d...........d." + /* 7 */ ".ddddddddddddd." + /* 8 */ "..............." + + // Level 2 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".dfffdgdffdffd." + /* 2 */ ".f...........f." + /* 3 */ ".f...........f." + /* 4 */ ".d...........d." + /* 5 */ ".f...........f." + /* 6 */ ".f...........f." + /* 7 */ ".dffdffdffdffd." + /* 8 */ "..............." + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "bbbbbbbbbbbbbbb" + /* 1 */ "hdddddddddddddh" + /* 2 */ ".d...i.i..i..d." + /* 3 */ ".d...........d." + /* 4 */ ".d...........d." + /* 5 */ ".d...........d." + /* 6 */ ".d..j..j..j..d." + /* 7 */ "kdddddddddddddk" + /* 8 */ "lllllllllllllll" + + // Level 4 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "bbbbbbbbbbbbbbb" + /* 2 */ "hdddddddddddddh" + /* 3 */ ".d...........d." + /* 4 */ ".d...........d." + /* 5 */ ".d...........d." + /* 6 */ "kdddddddddddddk" + /* 7 */ "lllllllllllllll" + /* 8 */ "..............." + + // Level 5 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "bbbbbbbbbbbbbbb" + /* 3 */ "hdddddddddddddh" + /* 4 */ ".d...........d." + /* 5 */ "kdddddddddddddk" + /* 6 */ "lllllllllllllll" + /* 7 */ "..............." + /* 8 */ "..............." + + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "bbbbbbbbbbbbbbb" + /* 4 */ "ddddddddddddddd" + /* 5 */ "lllllllllllllll" + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "...............", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House15x9 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House16x9: + // The data has been exported from the gallery Desert, area index 16, ID 126, created by Aloe_vera + { + // Size: + 16, 7, 9, // SizeX = 16, SizeY = 7, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 15, 6, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 5\n" /* wooddoorblock */ + "f:102: 0\n" /* glasspane */ + "g: 64:12\n" /* wooddoorblock */ + "h:128: 7\n" /* sandstonestairs */ + "i: 50: 3\n" /* torch */ + "j: 50: 4\n" /* torch */ + "k:128: 6\n" /* sandstonestairs */ + "l:128: 3\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "........abc....." + /* 1 */ ".dddddddddddddd." + /* 2 */ ".dddddddddddddd." + /* 3 */ ".dddddddddddddd." + /* 4 */ ".dddddddddddddd." + /* 5 */ ".dddddddddddddd." + /* 6 */ ".dddddddddddddd." + /* 7 */ ".dddddddddddddd." + /* 8 */ "................" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ ".ddddddddeddddd." + /* 2 */ ".d............d." + /* 3 */ ".d............d." + /* 4 */ ".d............d." + /* 5 */ ".d............d." + /* 6 */ ".d............d." + /* 7 */ ".dddddddddddddd." + /* 8 */ "................" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ ".dffdfffdgdfffd." + /* 2 */ ".f............f." + /* 3 */ ".f............f." + /* 4 */ ".d............d." + /* 5 */ ".f............f." + /* 6 */ ".f............f." + /* 7 */ ".dffdffdfffdffd." + /* 8 */ "................" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "bbbbbbbbbbbbbbbb" + /* 1 */ "hddddddddddddddh" + /* 2 */ ".d..i...i.i...d." + /* 3 */ ".d............d." + /* 4 */ ".d............d." + /* 5 */ ".d............d." + /* 6 */ ".d..j..j...j..d." + /* 7 */ "kddddddddddddddk" + /* 8 */ "llllllllllllllll" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "bbbbbbbbbbbbbbbb" + /* 2 */ "hddddddddddddddh" + /* 3 */ ".d............d." + /* 4 */ ".d............d." + /* 5 */ ".d............d." + /* 6 */ "kddddddddddddddk" + /* 7 */ "llllllllllllllll" + /* 8 */ "................" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "bbbbbbbbbbbbbbbb" + /* 3 */ "hddddddddddddddh" + /* 4 */ ".d............d." + /* 5 */ "kddddddddddddddk" + /* 6 */ "llllllllllllllll" + /* 7 */ "................" + /* 8 */ "................" + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "bbbbbbbbbbbbbbbb" + /* 4 */ "dddddddddddddddd" + /* 5 */ "llllllllllllllll" + /* 6 */ "................" + /* 7 */ "................" + /* 8 */ "................", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House16x9 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House7x7: + // The data has been exported from the gallery Desert, area index 8, ID 112, created by Aloe_vera + { + // Size: + 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 5, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 5\n" /* wooddoorblock */ + "f:102: 0\n" /* glasspane */ + "g: 64:12\n" /* wooddoorblock */ + "h:128: 7\n" /* sandstonestairs */ + "i: 50: 3\n" /* torch */ + "j:128: 6\n" /* sandstonestairs */ + "k:128: 3\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "...abc." + /* 1 */ ".ddddd." + /* 2 */ ".ddddd." + /* 3 */ ".ddddd." + /* 4 */ ".ddddd." + /* 5 */ ".ddddd." + /* 6 */ "......." + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".ddded." + /* 2 */ ".d...d." + /* 3 */ ".d...d." + /* 4 */ ".d...d." + /* 5 */ ".ddddd." + /* 6 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".dfdgd." + /* 2 */ ".f...f." + /* 3 */ ".f...f." + /* 4 */ ".f...f." + /* 5 */ ".dfffd." + /* 6 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "bbbbbbb" + /* 1 */ "hdddddh" + /* 2 */ ".d.i.d." + /* 3 */ ".d...d." + /* 4 */ ".d...d." + /* 5 */ "jdddddj" + /* 6 */ "kkkkkkk" + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "bbbbbbb" + /* 2 */ "hdddddh" + /* 3 */ ".d...d." + /* 4 */ "jdddddj" + /* 5 */ "kkkkkkk" + /* 6 */ "......." + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "......." + /* 2 */ "bbbbbbb" + /* 3 */ "ddddddd" + /* 4 */ "kkkkkkk" + /* 5 */ "......." + /* 6 */ ".......", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House7x7 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House9x7: + // The data has been exported from the gallery Desert, area index 9, ID 113, created by xoft + { + // Size: + 9, 6, 7, // SizeX = 9, SizeY = 6, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 8, 5, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 5\n" /* wooddoorblock */ + "f:102: 0\n" /* glasspane */ + "g: 64:12\n" /* wooddoorblock */ + "h:128: 7\n" /* sandstonestairs */ + "i: 50: 3\n" /* torch */ + "j: 50: 4\n" /* torch */ + "k:128: 6\n" /* sandstonestairs */ + "l:128: 3\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 012345678 */ + /* 0 */ "...abc..." + /* 1 */ ".ddddddd." + /* 2 */ ".ddddddd." + /* 3 */ ".ddddddd." + /* 4 */ ".ddddddd." + /* 5 */ ".ddddddd." + /* 6 */ "........." + + // Level 1 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".dddeddd." + /* 2 */ ".d.....d." + /* 3 */ ".d.....d." + /* 4 */ ".d.....d." + /* 5 */ ".ddddddd." + /* 6 */ "........." + + // Level 2 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".dfdgdfd." + /* 2 */ ".f.....f." + /* 3 */ ".f.....f." + /* 4 */ ".f.....f." + /* 5 */ ".dffdffd." + /* 6 */ "........." + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "bbbbbbbbb" + /* 1 */ "hdddddddh" + /* 2 */ ".d.i.i.d." + /* 3 */ ".d.....d." + /* 4 */ ".d..j..d." + /* 5 */ "kdddddddk" + /* 6 */ "lllllllll" + + // Level 4 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "bbbbbbbbb" + /* 2 */ "hdddddddh" + /* 3 */ ".d.....d." + /* 4 */ "kdddddddk" + /* 5 */ "lllllllll" + /* 6 */ "........." + + // Level 5 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "bbbbbbbbb" + /* 3 */ "ddddddddd" + /* 4 */ "lllllllll" + /* 5 */ "........." + /* 6 */ ".........", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House9x7 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House9x9: + // The data has been exported from the gallery Desert, area index 10, ID 114, created by xoft + { + // Size: + 9, 7, 9, // SizeX = 9, SizeY = 7, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 8, 6, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 1\n" /* wooddoorblock */ + "f:102: 0\n" /* glasspane */ + "g: 64: 8\n" /* wooddoorblock */ + "h:128: 7\n" /* sandstonestairs */ + "i: 50: 3\n" /* torch */ + "j: 50: 4\n" /* torch */ + "k:128: 6\n" /* sandstonestairs */ + "l:128: 3\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 012345678 */ + /* 0 */ "...abc..." + /* 1 */ ".ddddddd." + /* 2 */ ".ddddddd." + /* 3 */ ".ddddddd." + /* 4 */ ".ddddddd." + /* 5 */ ".ddddddd." + /* 6 */ ".ddddddd." + /* 7 */ ".ddddddd." + /* 8 */ "........." + + // Level 1 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".dddeddd." + /* 2 */ ".d.....d." + /* 3 */ ".d.....d." + /* 4 */ ".d.....d." + /* 5 */ ".d.....d." + /* 6 */ ".d.....d." + /* 7 */ ".ddddddd." + /* 8 */ "........." + + // Level 2 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".dfdgdfd." + /* 2 */ ".f.....f." + /* 3 */ ".f.....f." + /* 4 */ ".d.....d." + /* 5 */ ".f.....f." + /* 6 */ ".f.....f." + /* 7 */ ".dffdffd." + /* 8 */ "........." + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "bbbbbbbbb" + /* 1 */ "hdddddddh" + /* 2 */ ".d.i.i.d." + /* 3 */ ".d.....d." + /* 4 */ ".d.....d." + /* 5 */ ".d.....d." + /* 6 */ ".d..j..d." + /* 7 */ "kdddddddk" + /* 8 */ "lllllllll" + + // Level 4 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "bbbbbbbbb" + /* 2 */ "hdddddddh" + /* 3 */ ".d.....d." + /* 4 */ ".d.....d." + /* 5 */ ".d.....d." + /* 6 */ "kdddddddk" + /* 7 */ "lllllllll" + /* 8 */ "........." + + // Level 5 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "bbbbbbbbb" + /* 3 */ "hdddddddh" + /* 4 */ ".d.....d." + /* 5 */ "kdddddddk" + /* 6 */ "lllllllll" + /* 7 */ "........." + /* 8 */ "........." + + // Level 6 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." + /* 3 */ "bbbbbbbbb" + /* 4 */ "ddddddddd" + /* 5 */ "lllllllll" + /* 6 */ "........." + /* 7 */ "........." + /* 8 */ ".........", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House9x9 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HouseL14x12: + // The data has been exported from the gallery Desert, area index 7, ID 82, created by Aloe_vera + { + // Size: + 14, 6, 12, // SizeX = 14, SizeY = 6, SizeZ = 12 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 13, 5, 11, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e:128: 3\n" /* sandstonestairs */ + "f: 64: 5\n" /* wooddoorblock */ + "g:102: 0\n" /* glasspane */ + "h: 64:12\n" /* wooddoorblock */ + "i:128: 7\n" /* sandstonestairs */ + "j: 50: 3\n" /* torch */ + "k: 50: 4\n" /* torch */ + "l:128: 6\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */ + "n:128: 5\n" /* sandstonestairs */ + "o:128: 4\n" /* sandstonestairs */ + "p: 50: 1\n" /* torch */, + + // Block data: + // Level 0 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".......abc...." + /* 1 */ ".dddddddddddd." + /* 2 */ ".dddddddddddd." + /* 3 */ ".dddddddddddd." + /* 4 */ ".dddddddddddd." + /* 5 */ ".dddddddddddd." + /* 6 */ "....aec.ddddd." + /* 7 */ "mmmmmmm.ddddd." + /* 8 */ "mmmmmmm.ddddd." + /* 9 */ "mmmmmmm.ddddd." + /* 10 */ "mmmmmmm.ddddd." + /* 11 */ "mmmmmmm......." + + // Level 1 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".dddddddfdddd." + /* 2 */ ".d..........d." + /* 3 */ ".d..........d." + /* 4 */ ".d..........d." + /* 5 */ ".ddddfddd...d." + /* 6 */ "........d...d." + /* 7 */ "mmmmmmm.d...d." + /* 8 */ "mmmmmmm.d...d." + /* 9 */ "mmmmmmm.d...d." + /* 10 */ "mmmmmmm.ddddd." + /* 11 */ "mmmmmmm......." + + // Level 2 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".dggdggdhdggd." + /* 2 */ ".g..........g." + /* 3 */ ".g..........g." + /* 4 */ ".g..........d." + /* 5 */ ".dggdhdgg...g." + /* 6 */ "........g...g." + /* 7 */ "mmmmmmm.d...d." + /* 8 */ "mmmmmmm.g...g." + /* 9 */ "mmmmmmm.g...g." + /* 10 */ "mmmmmmm.dgggd." + /* 11 */ "mmmmmmm......." + + // Level 3 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "bbbbbbbbbbbbbb" + /* 1 */ "iddddddddddddc" + /* 2 */ ".d.....j.j..dc" + /* 3 */ ".d..........dc" + /* 4 */ ".d..k.k.....dc" + /* 5 */ "ldddddddd...dc" + /* 6 */ "eeeeeeead...dc" + /* 7 */ "mmmmmmmad...dc" + /* 8 */ "mmmmmmmad...dc" + /* 9 */ "mmmmmmmad...dc" + /* 10 */ "mmmmmmmadddddc" + /* 11 */ "mmmmmmman...oc" + + // Level 4 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ "bbbbbbbbbbbbb." + /* 2 */ "idddddddddddc." + /* 3 */ ".dp........dc." + /* 4 */ "lddddddddd.dc." + /* 5 */ "eeeeeeeead.dc." + /* 6 */ "........ad.dc." + /* 7 */ "mmmmmmm.ad.dc." + /* 8 */ "mmmmmmm.ad.dc." + /* 9 */ "mmmmmmm.adkdc." + /* 10 */ "mmmmmmm.adddc." + /* 11 */ "mmmmmmm.an.oc." + + // Level 5 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".............." + /* 2 */ "bbbbbbbbbbbb.." + /* 3 */ "dddddddddddc.." + /* 4 */ "eeeeeeeeeadc.." + /* 5 */ ".........adc.." + /* 6 */ ".........adc.." + /* 7 */ "mmmmmmm..adc.." + /* 8 */ "mmmmmmm..adc.." + /* 9 */ "mmmmmmm..adc.." + /* 10 */ "mmmmmmm..adc.." + /* 11 */ "mmmmmmm..adc..", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // HouseL14x12 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HouseL14x12: + // The data has been exported from the gallery Desert, area index 14, ID 124, created by Aloe_vera + { + // Size: + 14, 7, 12, // SizeX = 14, SizeY = 7, SizeZ = 12 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 13, 6, 11, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e:128: 3\n" /* sandstonestairs */ + "f: 64: 5\n" /* wooddoorblock */ + "g: 64: 7\n" /* wooddoorblock */ + "h:102: 0\n" /* glasspane */ + "i: 64:12\n" /* wooddoorblock */ + "j:128: 7\n" /* sandstonestairs */ + "k: 50: 3\n" /* torch */ + "l: 50: 2\n" /* torch */ + "m: 19: 0\n" /* sponge */ + "n: 50: 4\n" /* torch */ + "o:128: 6\n" /* sandstonestairs */ + "p: 50: 1\n" /* torch */ + "q:128: 5\n" /* sandstonestairs */ + "r:128: 4\n" /* sandstonestairs */, + + // Block data: + // Level 0 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "....abc......." + /* 1 */ ".dddddddddddd." + /* 2 */ ".dddddddddddd." + /* 3 */ ".dddddddddddd." + /* 4 */ ".dddddddddddd." + /* 5 */ ".dddddddddddd." + /* 6 */ ".dddddddddddd." + /* 7 */ ".dddddddddddd." + /* 8 */ "....aeddddddd." + /* 9 */ "mmmmm.ddddddd." + /* 10 */ "mmmmm.ddddddd." + /* 11 */ "mmmmm........." + + // Level 1 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".ddddfddddddd." + /* 2 */ ".d..........d." + /* 3 */ ".d..........d." + /* 4 */ ".d..........d." + /* 5 */ ".d..........d." + /* 6 */ ".d..........d." + /* 7 */ ".ddddgd.....d." + /* 8 */ "......d.....d." + /* 9 */ "mmmmm.d.....d." + /* 10 */ "mmmmm.ddddddd." + /* 11 */ "mmmmm........." + + // Level 2 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".dhhdidhhdhhd." + /* 2 */ ".h..........h." + /* 3 */ ".h..........h." + /* 4 */ ".d..........d." + /* 5 */ ".h..........h." + /* 6 */ ".h..........h." + /* 7 */ ".dhhdid.....d." + /* 8 */ "......h.....h." + /* 9 */ "mmmmm.h.....h." + /* 10 */ "mmmmm.dhhdhhd." + /* 11 */ "mmmmm........." + + // Level 3 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "bbbbbbbbbbbbbb" + /* 1 */ "jddddddddddddc" + /* 2 */ ".d..k.k.....dc" + /* 3 */ ".d..........dc" + /* 4 */ ".d.........ldc" + /* 5 */ ".d..........dc" + /* 6 */ ".d..n.n.....dc" + /* 7 */ "oddddddp...ldc" + /* 8 */ "eeeeead.....dc" + /* 9 */ "mmmmmad.....dc" + /* 10 */ "mmmmmadddddddc" + /* 11 */ "mmmmmaq.....rc" + + // Level 4 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ "bbbbbbbbbbbbc." + /* 2 */ "jdddddddddddc." + /* 3 */ ".d.........dc." + /* 4 */ ".d.........dc." + /* 5 */ ".d.........dc." + /* 6 */ "oddddddd...dc." + /* 7 */ "eeeeeead...dc." + /* 8 */ "......ad...dc." + /* 9 */ "mmmmm.ad...dc." + /* 10 */ "mmmmm.adddddc." + /* 11 */ "mmmmm.aq...rc." + + // Level 5 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".............." + /* 2 */ "bbbbbbbbbbbb.." + /* 3 */ "jddddddddddc.." + /* 4 */ ".d........dc.." + /* 5 */ "odddddddd.dc.." + /* 6 */ "eeeeeeeed.dc.." + /* 7 */ ".......ad.dc.." + /* 8 */ ".......ad.dc.." + /* 9 */ "mmmmm..ad.dc.." + /* 10 */ "mmmmm..adddc.." + /* 11 */ "mmmmm..aq.rc.." + + // Level 6 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".............." + /* 2 */ ".............." + /* 3 */ "bbbbbbbbbbb..." + /* 4 */ "ddddddddddc..." + /* 5 */ "eeeeeeeeadc..." + /* 6 */ "........adc..." + /* 7 */ "........adc..." + /* 8 */ "........adc..." + /* 9 */ "mmmmm...adc..." + /* 10 */ "mmmmm...adc..." + /* 11 */ "mmmmm...adc...", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // HouseL14x12 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // SingleField: + // The data has been exported from the gallery Desert, area index 17, ID 127, created by Aloe_vera + { + // Size: + 10, 2, 7, // SizeX = 10, SizeY = 2, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 9, 1, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 24: 0\n" /* sandstone */ + "b: 60: 7\n" /* tilleddirt */ + "c: 8: 0\n" /* water */ + "d: 50: 5\n" /* torch */ + "e: 59: 7\n" /* crops */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "aaaaaaaaaa" + /* 1 */ "abbbbbbbba" + /* 2 */ "abbbbbbbba" + /* 3 */ "acccccccca" + /* 4 */ "abbbbbbbba" + /* 5 */ "abbbbbbbba" + /* 6 */ "aaaaaaaaaa" + + // Level 1 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "d........d" + /* 1 */ ".eeeeeeee." + /* 2 */ ".eeeeeeee." + /* 3 */ ".........." + /* 4 */ ".eeeeeeee." + /* 5 */ ".eeeeeeee." + /* 6 */ "d........d", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // SingleField + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // SmallHut: + // The data has been exported from the gallery Desert, area index 4, ID 68, created by tonibm1999 + { + // Size: + 5, 5, 6, // SizeX = 5, SizeY = 5, SizeZ = 6 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 4, 4, 5, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 24: 0\n" /* sandstone */ + "b:128: 3\n" /* sandstonestairs */ + "c: 24: 2\n" /* sandstone */ + "d: 50: 5\n" /* torch */ + "e: 26:10\n" /* bedblock */ + "f: 26: 2\n" /* bedblock */ + "g: 64: 3\n" /* wooddoorblock */ + "h: 64: 8\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 01234 */ + /* 0 */ "aaaaa" + /* 1 */ "aaaaa" + /* 2 */ "aaaaa" + /* 3 */ "aaaaa" + /* 4 */ "aaaaa" + /* 5 */ "..b.." + + // Level 1 + /* z\x* 01234 */ + /* 0 */ "accca" + /* 1 */ "cdedc" + /* 2 */ "c.f.c" + /* 3 */ "c...c" + /* 4 */ "acgca" + /* 5 */ "....." + + // Level 2 + /* z\x* 01234 */ + /* 0 */ "ac.ca" + /* 1 */ "c...c" + /* 2 */ "....." + /* 3 */ "c...c" + /* 4 */ "achca" + /* 5 */ "....." + + // Level 3 + /* z\x* 01234 */ + /* 0 */ "accca" + /* 1 */ "c...c" + /* 2 */ "c...c" + /* 3 */ "c...c" + /* 4 */ "accca" + /* 5 */ "....." + + // Level 4 + /* z\x* 01234 */ + /* 0 */ ".aaa." + /* 1 */ "aaaaa" + /* 2 */ "aaaaa" + /* 3 */ "aaaaa" + /* 4 */ ".aaa." + /* 5 */ ".....", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // SmallHut +}; // g_SandVillagePrefabs + + + + + + +const cPrefab::sDef g_SandVillageStartingPrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Well: + // The data has been exported from the gallery Desert, area index 0, ID 1, created by Aloe_vera + { + // Size: + 4, 13, 4, // SizeX = 4, SizeY = 13, SizeZ = 4 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 3, 12, 3, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 1: 0\n" /* stone */ + "b: 24: 0\n" /* sandstone */ + "c: 8: 0\n" /* water */ + "d: 85: 0\n" /* fence */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 0123 */ + /* 0 */ "aaaa" + /* 1 */ "aaaa" + /* 2 */ "aaaa" + /* 3 */ "aaaa" + + // Level 1 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 2 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 3 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 4 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 5 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 6 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 7 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bccb" + /* 2 */ "bccb" + /* 3 */ "bbbb" + + // Level 8 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "b..b" + /* 2 */ "b..b" + /* 3 */ "bbbb" + + // Level 9 + /* z\x* 0123 */ + /* 0 */ "d..d" + /* 1 */ "...." + /* 2 */ "...." + /* 3 */ "d..d" + + // Level 10 + /* z\x* 0123 */ + /* 0 */ "d..d" + /* 1 */ "...." + /* 2 */ "...." + /* 3 */ "d..d" + + // Level 11 + /* z\x* 0123 */ + /* 0 */ "d..d" + /* 1 */ "...." + /* 2 */ "...." + /* 3 */ "d..d" + + // Level 12 + /* z\x* 0123 */ + /* 0 */ "bbbb" + /* 1 */ "bbbb" + /* 2 */ "bbbb" + /* 3 */ "bbbb", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // Well +}; + + + + + +// The prefab counts: + +const size_t g_SandVillagePrefabsCount = ARRAYCOUNT(g_SandVillagePrefabs); + +const size_t g_SandVillageStartingPrefabsCount = ARRAYCOUNT(g_SandVillageStartingPrefabs); + diff --git a/src/Generating/Prefabs/SandVillagePrefabs.h b/src/Generating/Prefabs/SandVillagePrefabs.h new file mode 100644 index 000000000..7b00db56f --- /dev/null +++ b/src/Generating/Prefabs/SandVillagePrefabs.h @@ -0,0 +1,15 @@ + +// SandVillagePrefabs.h + +// Declares the prefabs in the group SandVillage + +#include "../Prefab.h" + + + + + +extern const cPrefab::sDef g_SandVillagePrefabs[]; +extern const cPrefab::sDef g_SandVillageStartingPrefabs[]; +extern const size_t g_SandVillagePrefabsCount; +extern const size_t g_SandVillageStartingPrefabsCount; diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp new file mode 100644 index 000000000..fb6191df2 --- /dev/null +++ b/src/Generating/VillageGen.cpp @@ -0,0 +1,116 @@ + +// VillageGen.cpp + +// Implements the cVillageGen class representing the village generator + +#include "Globals.h" +#include "VillageGen.h" +#include "Prefabs/PlainsVillagePrefabs.h" +#include "Prefabs/SandVillagePrefabs.h" + + + + + +class cVillageGen::cVillage : + public cGridStructGen::cStructure +{ + typedef cGridStructGen::cStructure super; + +public: + cVillage(int a_Seed, int a_OriginX, int a_OriginZ, cPrefabPiecePool & a_Prefabs) : + super(a_OriginX, a_OriginZ), + m_Seed(a_Seed), + m_Prefabs(a_Prefabs) + { + } + +protected: + /** Seed for the random functions */ + int m_Seed; + + /** Prefabs to use for buildings */ + cPrefabPiecePool & m_Prefabs; + + // cGrdStructGen::cStructure overrides: + virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override + { + // TODO + } +} ; + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cVillageGen: + +cPrefabPiecePool cVillageGen::m_SandVillage (g_SandVillagePrefabs, g_SandVillagePrefabsCount, g_SandVillageStartingPrefabs, g_SandVillageStartingPrefabsCount); +cPrefabPiecePool cVillageGen::m_PlainsVillage(g_PlainsVillagePrefabs, g_PlainsVillagePrefabsCount, g_PlainsVillageStartingPrefabs, g_PlainsVillageStartingPrefabsCount); + + + + + +cVillageGen::cVillageGen(int a_Seed, int a_GridSize, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen) : + super(a_Seed, a_GridSize, a_GridSize, 128, 128, 100), + m_BiomeGen(a_BiomeGen), + m_HeightGen(a_HeightGen) +{ +} + + + + + +cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_OriginZ) +{ + // Generate the biomes for the chunk surrounding the origin: + int ChunkX, ChunkZ; + cChunkDef::BlockToChunk(a_OriginX, a_OriginZ, ChunkX, ChunkZ); + cChunkDef::BiomeMap Biomes; + m_BiomeGen.GenBiomes(ChunkX, ChunkZ, Biomes); + + // Check if all the biomes are village-friendly: + // If just one is not, no village is created, because it's likely that an unfriendly biome is too close + cPrefabPiecePool * VillagePrefabs = NULL; + for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++) + { + switch (Biomes[i]) + { + case biDesert: + case biDesertM: + { + // These biomes allow sand villages + VillagePrefabs = &m_SandVillage; + break; + } + case biPlains: + case biSavanna: + case biSavannaM: + case biSunflowerPlains: + { + // These biomes allow plains-style villages + VillagePrefabs = &m_PlainsVillage; + break; + } + default: + { + // Village-unfriendly biome, bail out with zero structure: + return cStructurePtr(); + } + } // switch (Biomes[i]) + } // for i - Biomes[] + + // Create a village based on the chosen prefabs: + if (VillagePrefabs == NULL) + { + return cStructurePtr(); + } + return cStructurePtr(new cVillage(m_Seed, a_OriginX, a_OriginZ, *VillagePrefabs)); +} + + + + diff --git a/src/Generating/VillageGen.h b/src/Generating/VillageGen.h new file mode 100644 index 000000000..d3cc8ef9c --- /dev/null +++ b/src/Generating/VillageGen.h @@ -0,0 +1,48 @@ + +// VillageGen.h + +// Declares the cVillageGen class representing the village generator + + + + + +#pragma once + +#include "GridStructGen.h" +#include "PrefabPiecePool.h" + + + + + +class cVillageGen : + public cGridStructGen +{ + typedef cGridStructGen super; +public: + cVillageGen(int a_Seed, int a_GridSize, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen); + +protected: + class cVillage; // fwd: VillageGen.cpp + + /** The prefabs for the sand village. We're not exactly using the cPiecePool functionality, only the containment. */ + static cPrefabPiecePool m_SandVillage; + + /** The prefabs for the plains village. We're not exactly using the cPiecePool functionality, only the containment. */ + static cPrefabPiecePool m_PlainsVillage; + + /** The underlying biome generator that defines whether the village is created or not */ + cBiomeGen & m_BiomeGen; + + /** The underlying height generator, used to position the prefabs crossing chunk borders */ + cTerrainHeightGen & m_HeightGen; + + + // cGridStructGen overrides: + virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; +} ; + + + + -- cgit v1.2.3 From 6c57b38b741787cd53a42b905d27e2d137ae194b Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 11 May 2014 13:44:30 -0700 Subject: Fixed a warning and a complaint about a never-read variable. --- src/BlockArea.cpp | 25 +++++++++++-------------- src/WorldStorage/WorldStorage.cpp | 1 - 2 files changed, 11 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 9e20a0983..aff0bf9c6 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -2123,7 +2123,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); - break; + return; } // case msOverwrite case cBlockArea::msFillAir: @@ -2137,7 +2137,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); - break; + return; } // case msFillAir case cBlockArea::msImprint: @@ -2151,7 +2151,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); - break; + return; } // case msImprint case cBlockArea::msLake: @@ -2165,7 +2165,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); - break; + return; } // case msLake case cBlockArea::msSpongePrint: @@ -2179,7 +2179,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); - break; + return; } // case msSpongePrint case cBlockArea::msDifference: @@ -2193,7 +2193,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); - break; + return; } // case msDifference case cBlockArea::msMask: @@ -2207,16 +2207,13 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); - break; + return; } // case msMask - - default: - { - LOGWARNING("Unknown block area merge strategy: %d", a_Strategy); - ASSERT(!"Unknown block area merge strategy"); - break; - } } // switch (a_Strategy) + + LOGWARNING("Unknown block area merge strategy: %d", a_Strategy); + ASSERT(!"Unknown block area merge strategy"); + return; } diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index 54eaaca5c..6867ad5bc 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -243,7 +243,6 @@ void cWorldStorage::Execute(void) bool Success; do { - Success = false; if (m_ShouldTerminate) { return; -- cgit v1.2.3 From 3f9e00a3f3486c2845115e495d66f438f90825f3 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 11 May 2014 16:25:21 -0700 Subject: Fixed a few more switch warnings. --- src/Generating/StructGen.cpp | 28 ++++++++++++------------- src/Mobs/Monster.cpp | 2 ++ src/WorldStorage/NBTChunkSerializer.cpp | 37 ++++++++++++++++++--------------- 3 files changed, 35 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp index db9d5578c..636364e17 100644 --- a/src/Generating/StructGen.cpp +++ b/src/Generating/StructGen.cpp @@ -596,24 +596,22 @@ void cStructGenDirectOverhangs::GenFinish(cChunkDesc & a_ChunkDesc) // Interpolate between FloorLo and FloorHi: for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++) { - switch (a_ChunkDesc.GetBiome(x, z)) + EMCSBiome biome = a_ChunkDesc.GetBiome(x, z); + + if ((biome == biExtremeHills) || (biome == biExtremeHillsEdge)) { - case biExtremeHills: - case biExtremeHillsEdge: + int Lo = FloorLo[x + 17 * z] / 256; + int Hi = FloorHi[x + 17 * z] / 256; + for (int y = 0; y < SEGMENT_HEIGHT; y++) { - int Lo = FloorLo[x + 17 * z] / 256; - int Hi = FloorHi[x + 17 * z] / 256; - for (int y = 0; y < SEGMENT_HEIGHT; y++) + int Val = Lo + (Hi - Lo) * y / SEGMENT_HEIGHT; + if (Val < 0) { - int Val = Lo + (Hi - Lo) * y / SEGMENT_HEIGHT; - if (Val < 0) - { - a_ChunkDesc.SetBlockType(x, y + Segment, z, E_BLOCK_AIR); - } - } // for y - break; - } - } // switch (biome) + a_ChunkDesc.SetBlockType(x, y + Segment, z, E_BLOCK_AIR); + } + } // for y + break; + } // if (biome) } // for z, x // Swap the floors: diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 62670907f..5832edb9f 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -355,6 +355,8 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) InStateEscaping(a_Dt); break; } + + case ATTACKING: break; } // switch (m_EMState) BroadcastMovementUpdate(); diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 2ac1d7962..ab80dd7c8 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -391,38 +391,41 @@ void cNBTChunkSerializer::AddFallingBlockEntity(cFallingBlock * a_FallingBlock) void cNBTChunkSerializer::AddMinecartEntity(cMinecart * a_Minecart) { - const char * EntityClass = NULL; - switch (a_Minecart->GetPayload()) - { - case cMinecart::mpNone: EntityClass = "MinecartRideable"; break; - case cMinecart::mpChest: EntityClass = "MinecartChest"; break; - case cMinecart::mpFurnace: EntityClass = "MinecartFurnace"; break; - case cMinecart::mpTNT: EntityClass = "MinecartTNT"; break; - case cMinecart::mpHopper: EntityClass = "MinecartHopper"; break; - default: - { - ASSERT(!"Unhandled minecart payload type"); - return; - } - } // switch (payload) - m_Writer.BeginCompound(""); - AddBasicEntity(a_Minecart, EntityClass); + switch (a_Minecart->GetPayload()) { case cMinecart::mpChest: { + AddBasicEntity(a_Minecart, "MinecartChest"); // Add chest contents into the Items tag: AddMinecartChestContents((cMinecartWithChest *)a_Minecart); break; } - case cMinecart::mpFurnace: { + AddBasicEntity(a_Minecart, "MinecartFurnace"); // TODO: Add "Push" and "Fuel" tags break; } + case cMinecart::mpHopper: + { + AddBasicEntity(a_Minecart, "MinecartHopper"); + // TODO: Add hopper contents? + break; + } + case cMinecart::mpTNT: + { + AddBasicEntity(a_Minecart, "MinecartTNT"); + break; + } + case cMinecart::mpNone: + { + AddBasicEntity(a_Minecart, "MinecartRideable"); + break; + } } // switch (Payload) + m_Writer.EndCompound(); } -- cgit v1.2.3 From 3a5e04d118a88dc33930866546007f59fdba951f Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 11 May 2014 16:54:42 -0700 Subject: More switch warnings. --- src/Generating/Trees.cpp | 34 ++++++++++++++++++++++++++------- src/WorldStorage/NBTChunkSerializer.cpp | 7 +++++++ 2 files changed, 34 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index 4f1553c36..522f45148 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -174,7 +174,7 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No { GetBirchTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks); } - break; + return; } case biTaiga: @@ -184,14 +184,14 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No { // Conifers GetConiferTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks); - break; + return; } case biSwampland: { // Swamp trees: GetSwampTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks); - break; + return; } case biJungle: @@ -207,21 +207,21 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No { GetJungleTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks); } - break; + return; } case biBirchForest: case biBirchForestHills: { GetBirchTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks); - break; + return; } case biBirchForestM: case biBirchForestHillsM: { GetTallBirchTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks); - break; + return; } case biRoofedForest: @@ -257,9 +257,29 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No { // TODO: These need their special trees GetBirchTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks); - break; + return; + } + + case biDesert: + case biDesertHills: + case biRiver: + case biBeach: + case biHell: + case biSky: + case biOcean: + case biFrozenOcean: + case biFrozenRiver: + case biVariant: + case biNumBiomes: + case biNumVariantBiomes: + case biInvalidBiome: + { + // These biomes have no trees, or are non-biome members of the enum. + return; } } + + ASSERT(!"Invalid biome type!"); } diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index ab80dd7c8..7b7cd3c7e 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -653,6 +653,13 @@ void cNBTChunkSerializer::AddHangingEntity(cHangingEntity * a_Hanging) case BLOCK_FACE_YP: m_Writer.AddByte("Dir", (unsigned char)1); break; case BLOCK_FACE_ZM: m_Writer.AddByte("Dir", (unsigned char)0); break; case BLOCK_FACE_ZP: m_Writer.AddByte("Dir", (unsigned char)3); break; + + case BLOCK_FACE_XM: + case BLOCK_FACE_XP: + case BLOCK_FACE_NONE: + { + break; + } } } -- cgit v1.2.3 From b3d2b5b2c94193fd9364b26293b7d96b748ff96d Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 12 May 2014 17:05:09 +0300 Subject: cEntity::Killed(cEntity *) Handler; Achievement triggers; cPlayer::AwardAchievement() --- src/Entities/Entity.cpp | 5 ++++ src/Entities/Entity.h | 3 ++ src/Entities/Pickup.cpp | 10 +++++++ src/Entities/Player.cpp | 70 +++++++++++++++++++++++++++++++++++++++++--- src/Entities/Player.h | 11 +++++++ src/Protocol/Protocol17x.cpp | 6 +--- src/UI/SlotArea.cpp | 42 +++++++++++++++++++++++++- src/UI/SlotArea.h | 6 ++++ 8 files changed, 143 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 4cf10a219..9eb03acde 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -370,6 +370,11 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) if (m_Health <= 0) { KilledBy(a_TDI.Attacker); + + if (a_TDI.Attacker != NULL) + { + a_TDI.Attacker->Killed(this); + } } return true; } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index df03d635b..a111b128d 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -299,6 +299,9 @@ public: /// Called when the health drops below zero. a_Killer may be NULL (environmental damage) virtual void KilledBy(cEntity * a_Killer); + /// Called when the entity kills another entity + virtual void Killed(cEntity * a_Victim) {} + /// Heals the specified amount of HPs void Heal(int a_HitPoints); diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index 497b41683..0fd006485 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -192,6 +192,16 @@ bool cPickup::CollectedBy(cPlayer * a_Dest) int NumAdded = a_Dest->GetInventory().AddItem(m_Item); if (NumAdded > 0) { + // Check achievements + switch (m_Item.m_ItemType) + { + case E_BLOCK_LOG: a_Dest->AwardAchievement(achMineWood); break; + case E_ITEM_LEATHER: a_Dest->AwardAchievement(achKillCow); break; + case E_ITEM_DIAMOND: a_Dest->AwardAchievement(achDiamonds); break; + case E_ITEM_BLAZE_ROD: a_Dest->AwardAchievement(achBlazeRod); break; + default: break; + } + m_Item.m_ItemCount -= NumAdded; m_World->BroadcastCollectPickup(*this, *a_Dest); // Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 1df473eb2..48bb509b9 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -17,6 +17,7 @@ #include "../Vector3.h" #include "../WorldStorage/StatSerializer.h" +#include "../CompositeChat.h" #include "inifile/iniFile.h" #include "json/json.h" @@ -876,10 +877,6 @@ void cPlayer::KilledBy(cEntity * a_Killer) cPlayer* Killer = (cPlayer*)a_Killer; GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str())); - - Killer->GetStatManager().AddValue(statPlayerKills); - - m_World->GetScoreBoard().AddPlayerScore(Killer->GetName(), cObjective::otPlayerKillCount, 1); } else { @@ -898,6 +895,33 @@ void cPlayer::KilledBy(cEntity * a_Killer) +void cPlayer::Killed(cEntity * a_Victim) +{ + cScoreboard & ScoreBoard = m_World->GetScoreBoard(); + + if (a_Victim->IsPlayer()) + { + m_Stats.AddValue(statPlayerKills); + + ScoreBoard.AddPlayerScore(GetName(), cObjective::otPlayerKillCount, 1); + } + else if (a_Victim->IsMob()) + { + if (((cMonster *)a_Victim)->GetMobFamily() == cMonster::mfHostile) + { + AwardAchievement(achKillMonster); + } + + m_Stats.AddValue(statMobKills); + } + + ScoreBoard.AddPlayerScore(GetName(), cObjective::otTotalKillCount, 1); +} + + + + + void cPlayer::Respawn(void) { m_Health = GetMaxHealth(); @@ -1116,6 +1140,44 @@ void cPlayer::SetIP(const AString & a_IP) +unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach) +{ + eStatistic Prerequisite = cStatInfo::GetPrerequisite(a_Ach); + + if (Prerequisite != statInvalid) + { + if (m_Stats.GetValue(Prerequisite) == 0) + { + return 0; + } + } + + StatValue Old = m_Stats.GetValue(a_Ach); + + if (Old > 0) + { + return m_Stats.AddValue(a_Ach); + } + else + { + cCompositeChat Msg; + Msg.AddTextPart(m_PlayerName + " has just earned the achievement "); + Msg.AddTextPart(cStatInfo::GetName(a_Ach)); // TODO 2014-05-12 xdot: Use the proper cCompositeChat submessage type and send the actual title + m_World->BroadcastChat(Msg); + + StatValue New = m_Stats.AddValue(a_Ach); + + /* Achievement Get! */ + m_ClientHandle->SendStatistics(m_Stats); + + return New; + } +} + + + + + void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) { SetPosition(a_PosX, a_PosY, a_PosZ); diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 82a138290..b5c9d75cc 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -179,6 +179,15 @@ public: /** Return the associated statistic and achievement manager. */ cStatManager & GetStatManager() { return m_Stats; } + + /** Awards the player an achievement. + * + * If all prerequisites are met, this method will award the achievement and will broadcast a chat message. + * If the achievement has been already awarded to the player, this method will just increment the stat counter. + * + * Returns the _new_ stat value. (0 = Could not award achievement) + */ + unsigned int AwardAchievement(const eStatistic a_Ach); void SetIP(const AString & a_IP); @@ -311,6 +320,8 @@ public: void AbortEating(void); virtual void KilledBy(cEntity * a_Killer) override; + + virtual void Killed(cEntity * a_Victim) override; void Respawn(void); // tolua_export diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 3b21f7821..39feee16f 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1879,11 +1879,7 @@ void cProtocol172::HandlePacketClientStatus(cByteBuffer & a_ByteBuffer) case 2: { // Open Inventory achievement - cStatManager & Manager = m_Client->GetPlayer()->GetStatManager(); - Manager.AddValue(achOpenInv); - - SendStatistics(Manager); - + m_Client->GetPlayer()->AwardAchievement(achOpenInv); break; } } diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 788974f9c..1e3d8eaa4 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -496,6 +496,8 @@ void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player) DraggingItem = Result; Recipe.ConsumeIngredients(Grid); Grid.CopyToItems(PlayerSlots); + + HandleCraftItem(Result, a_Player); } else if (DraggingItem.IsEqual(Result)) { @@ -505,6 +507,8 @@ void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player) DraggingItem.m_ItemCount += Result.m_ItemCount; Recipe.ConsumeIngredients(Grid); Grid.CopyToItems(PlayerSlots); + + HandleCraftItem(Result, a_Player); } } @@ -594,6 +598,27 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player) +void cSlotAreaCrafting::HandleCraftItem(const cItem & a_Result, cPlayer & a_Player) +{ + switch (a_Result.m_ItemType) + { + case E_BLOCK_WORKBENCH: a_Player.AwardAchievement(achCraftWorkbench); break; + case E_BLOCK_FURNACE: a_Player.AwardAchievement(achCraftFurnace); break; + case E_BLOCK_CAKE: a_Player.AwardAchievement(achBakeCake); break; + case E_BLOCK_ENCHANTMENT_TABLE: a_Player.AwardAchievement(achCraftEnchantTable); break; + case E_BLOCK_BOOKCASE: a_Player.AwardAchievement(achBookshelf); break; + case E_ITEM_WOODEN_PICKAXE: a_Player.AwardAchievement(achCraftPickaxe); break; + case E_ITEM_WOODEN_SWORD: a_Player.AwardAchievement(achCraftSword); break; + case E_ITEM_STONE_PICKAXE: a_Player.AwardAchievement(achCraftBetterPick); break; + case E_ITEM_WOODEN_HOE: a_Player.AwardAchievement(achCraftHoe); break; + case E_ITEM_BREAD: a_Player.AwardAchievement(achMakeBread); break; + default: break; + } +} + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cSlotAreaAnvil: @@ -1393,7 +1418,7 @@ void cSlotAreaFurnace::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) { // Something has changed in the window, broadcast the entire window to all clients ASSERT(a_ItemGrid == &(m_Furnace->GetContents())); - + m_ParentWindow.BroadcastWholeWindow(); } @@ -1401,6 +1426,21 @@ void cSlotAreaFurnace::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) +void cSlotAreaFurnace::HandleSmeltItem(const cItem & a_Result, cPlayer & a_Player) +{ + /** TODO 2014-05-12 xdot: Figure out when to call this method. */ + switch (a_Result.m_ItemType) + { + case E_ITEM_IRON: a_Player.AwardAchievement(achAcquireIron); break; + case E_ITEM_COOKED_FISH: a_Player.AwardAchievement(achCookFish); break; + default: break; + } +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cSlotAreaInventoryBase: diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index 4da6a672f..e297bcff7 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -254,6 +254,9 @@ protected: /// Retrieves the recipe for the specified player from the map, or creates one if not found cCraftingRecipe & GetRecipeForPlayer(cPlayer & a_Player); + + /// Called after an item has been crafted to handle statistics e.t.c. + void HandleCraftItem(const cItem & a_Result, cPlayer & a_Player); } ; @@ -397,6 +400,9 @@ protected: // cItemGrid::cListener overrides: virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override; + + /// Called after an item has been smelted to handle statistics e.t.c. + void HandleSmeltItem(const cItem & a_Result, cPlayer & a_Player); } ; -- cgit v1.2.3 From aea866f5b10d5ab0226260b4d25c70b1cfd31d2a Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 12 May 2014 21:38:52 +0300 Subject: Movement Statistics --- src/Entities/Entity.cpp | 15 +++++++-- src/Entities/Player.cpp | 86 +++++++++++++++++++++++++++++++++++++++++++------ src/Entities/Player.h | 6 ++++ src/Item.h | 2 +- src/Mobs/Monster.cpp | 4 ++- src/Statistics.cpp | 2 +- 6 files changed, 101 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 9eb03acde..c393f89fd 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -312,12 +312,16 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer())) { + cPlayer * Player = (cPlayer *)a_TDI.Attacker; + // IsOnGround() only is false if the player is moving downwards - if (!((cPlayer *)a_TDI.Attacker)->IsOnGround()) // TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain) + if (!Player->IsOnGround()) // TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain) { a_TDI.FinalDamage += 2; m_World->BroadcastEntityAnimation(*this, 4); // Critical hit } + + Player->GetStatManager().AddValue(statDamageDealt, round(a_TDI.FinalDamage * 10)); } m_Health -= (short)a_TDI.FinalDamage; @@ -580,9 +584,16 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk) if (m_AttachedTo != NULL) { - if ((m_Pos - m_AttachedTo->GetPosition()).Length() > 0.5) + Vector3d DeltaPos = m_Pos - m_AttachedTo->GetPosition(); + if (DeltaPos.Length() > 0.5) { SetPosition(m_AttachedTo->GetPosition()); + + if (IsPlayer()) + { + cPlayer * Player = (cPlayer *)this; + Player->UpdateMovementStats(DeltaPos); + } } } else diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 48bb509b9..3df7c4c34 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -194,6 +194,8 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) return; } } + + m_Stats.AddValue(statMinutesPlayed, 1); if (!a_Chunk.IsValid()) { @@ -835,6 +837,8 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI) // Any kind of damage adds food exhaustion AddFoodExhaustion(0.3f); SendHealth(); + + m_Stats.AddValue(statDamageTaken, round(a_TDI.FinalDamage * 10)); return true; } return false; @@ -865,6 +869,8 @@ void cPlayer::KilledBy(cEntity * a_Killer) Pickups.Add(cItem(E_ITEM_RED_APPLE)); } + m_Stats.AddValue(statItemsDropped, Pickups.Size()); + m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10); SaveToDisk(); // Save it, yeah the world is a tough place ! @@ -1262,6 +1268,9 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos ) // TODO: should do some checks to see if player is not moving through terrain // TODO: Official server refuses position packets too far away from each other, kicking "hacked" clients; we should, too + + Vector3d DeltaPos = a_NewPos - GetPosition(); + UpdateMovementStats(DeltaPos); SetPosition( a_NewPos ); SetStance(a_NewPos.y + 1.62); @@ -1492,10 +1501,7 @@ void cPlayer::TossEquippedItem(char a_Amount) Drops.push_back(DroppedItem); } - double vX = 0, vY = 0, vZ = 0; - EulerToVector(-GetYaw(), GetPitch(), vZ, vX, vY); - vY = -vY * 2 + 1.f; - m_World->SpawnItemPickups(Drops, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player + TossItems(Drops); } @@ -1511,6 +1517,7 @@ void cPlayer::TossHeldItem(char a_Amount) char OriginalItemAmount = Item.m_ItemCount; Item.m_ItemCount = std::min(OriginalItemAmount, a_Amount); Drops.push_back(Item); + if (OriginalItemAmount > a_Amount) { Item.m_ItemCount = OriginalItemAmount - a_Amount; @@ -1521,10 +1528,7 @@ void cPlayer::TossHeldItem(char a_Amount) } } - double vX = 0, vY = 0, vZ = 0; - EulerToVector(-GetYaw(), GetPitch(), vZ, vX, vY); - vY = -vY * 2 + 1.f; - m_World->SpawnItemPickups(Drops, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player + TossItems(Drops); } @@ -1536,10 +1540,21 @@ void cPlayer::TossPickup(const cItem & a_Item) cItems Drops; Drops.push_back(a_Item); + TossItems(Drops); +} + + + + + +void cPlayer::TossItems(const cItems & a_Items) +{ + m_Stats.AddValue(statItemsDropped, a_Items.Size()); + double vX = 0, vY = 0, vZ = 0; EulerToVector(-GetYaw(), GetPitch(), vZ, vX, vY); vY = -vY * 2 + 1.f; - m_World->SpawnItemPickups(Drops, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player + m_World->SpawnItemPickups(a_Items, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player } @@ -1935,6 +1950,59 @@ void cPlayer::HandleFloater() +void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos) +{ + StatValue Value = round(a_DeltaPos.Length() * 100); + + if (m_AttachedTo == NULL) + { + int PosX = POSX_TOINT; + int PosY = POSY_TOINT; + int PosZ = POSZ_TOINT; + + BLOCKTYPE Block; + NIBBLETYPE Meta; + if (!m_World->GetBlockTypeMeta(PosX, PosY, PosZ, Block, Meta)) + { + return; + } + + if ((Block == E_BLOCK_LADDER) && (a_DeltaPos.y > 0.0)) // Going up + { + m_Stats.AddValue(statDistClimbed, round(a_DeltaPos.y * 100)); + } + else + { + // TODO 2014-05-12 xdot: Other types + m_Stats.AddValue(statDistWalked, Value); + } + } + else + { + switch (m_AttachedTo->GetEntityType()) + { + case cEntity::etMinecart: m_Stats.AddValue(statDistMinecart, Value); break; + case cEntity::etBoat: m_Stats.AddValue(statDistBoat, Value); break; + case cEntity::etMonster: + { + cMonster * Monster = (cMonster *)m_AttachedTo; + switch (Monster->GetMobType()) + { + case cMonster::mtPig: m_Stats.AddValue(statDistPig, Value); break; + case cMonster::mtHorse: m_Stats.AddValue(statDistHorse, Value); break; + default: break; + } + break; + } + default: break; + } + } +} + + + + + void cPlayer::ApplyFoodExhaustionFromMovement() { if (IsGameModeCreative()) diff --git a/src/Entities/Player.h b/src/Entities/Player.h index b5c9d75cc..3de5e9c68 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -391,6 +391,9 @@ public: /** If true the player can fly even when he's not in creative. */ void SetCanFly(bool a_CanFly); + /** Update movement-related statistics. */ + void UpdateMovementStats(const Vector3d & a_DeltaPos); + /** Returns wheter the player can fly or not. */ virtual bool CanFly(void) const { return m_CanFly; } // tolua_end @@ -524,6 +527,9 @@ protected: /** Called in each tick if the player is fishing to make sure the floater dissapears when the player doesn't have a fishing rod as equipped item. */ void HandleFloater(void); + /** Tosses a list of items. */ + void TossItems(const cItems & a_Items); + /** Adds food exhaustion based on the difference between Pos and LastPos, sprinting status and swimming (in water block) */ void ApplyFoodExhaustionFromMovement(); diff --git a/src/Item.h b/src/Item.h index 2f65d5344..acbc880dc 100644 --- a/src/Item.h +++ b/src/Item.h @@ -228,7 +228,7 @@ public: void Add (const cItem & a_Item) {push_back(a_Item); } void Delete(int a_Idx); void Clear (void) {clear(); } - size_t Size (void) {return size(); } + size_t Size (void) const { return size(); } void Set (int a_Idx, short a_ItemType, char a_ItemCount, short a_ItemDamage); void Add (short a_ItemType, char a_ItemCount, short a_ItemDamage) diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 62670907f..f3b408e68 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -464,8 +464,10 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI) return false; } - if((m_SoundHurt != "") && (m_Health > 0)) + if ((m_SoundHurt != "") && (m_Health > 0)) + { m_World->BroadcastSoundEffect(m_SoundHurt, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f); + } if (a_TDI.Attacker != NULL) { diff --git a/src/Statistics.cpp b/src/Statistics.cpp index 65addb0dd..5950eb96c 100644 --- a/src/Statistics.cpp +++ b/src/Statistics.cpp @@ -64,7 +64,7 @@ cStatInfo cStatInfo::ms_Info[statCount] = { cStatInfo(statDistHorse, "stat.horseOneCm"), cStatInfo(statJumps, "stat.jump"), cStatInfo(statItemsDropped, "stat.drop"), - cStatInfo(statDamageDealt, "stat.damageDealth"), + cStatInfo(statDamageDealt, "stat.damageDealt"), cStatInfo(statDamageTaken, "stat.damageTaken"), cStatInfo(statDeaths, "stat.deaths"), cStatInfo(statMobKills, "stat.mobKills"), -- cgit v1.2.3 From 9c8e8ef7aece2f881ef97c387600c8a751579b20 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 12 May 2014 22:43:59 +0200 Subject: VillageGen: Added well placement and the general algorithm description. --- src/Generating/Prefab.h | 3 + src/Generating/VillageGen.cpp | 147 ++++++++++++++++++++++++++++++++++++++++-- src/Generating/VillageGen.h | 8 ++- 3 files changed, 152 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index 37db2ff16..472584c3a 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -95,6 +95,9 @@ public: /** Returns the weight (chance) of this prefab generating as the next piece after the specified placed piece. PiecePool implementations can use this for their GetPieceWeight() implementations. */ int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector) const; + + /** Returns the unmodified DefaultWeight property for the piece. */ + int GetDefaultWeight(void) const { return m_DefaultWeight; } protected: /** Packs complete definition of a single block, for per-letter assignment. */ diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index fb6191df2..3d89d7aa2 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -12,30 +12,167 @@ +/* +How village generating works: +By descending from a cGridStructGen, a semi-random grid is generated. A village may be generated for each of +the grid's cells. Each cell checks the biomes in an entire chunk around it, only generating a village if all +biomes are village-friendly. If yes, the entire village structure is built for that cell. If not, the cell +is left village-less. + +A village is generated starting by its well. The well is placed in the grid's origin point. Then a set of +random lengths roads is generated - 4 roads going from the well, then at the end of each road another set of +roads, crossing them perpendicular, then at the end of those another set, up to a set maximum branching +depth. The roads are placed in a T or L shape, with the old road being the center stem of the T. Roads avoid +crossing each other and going further away from the well than the maximum block size of the village. +Finally, houses are places along the roads, avoiding collisions with already-existing items. + +When the village is about to be drawn into a chunk, it queries the heights for each item intersecting the +chunk. The prefabs are shifted so that their pivot points lie on the surface, and the roads are drawn +directly by turning the surface blocks into gravel / sandstone. +*/ + class cVillageGen::cVillage : public cGridStructGen::cStructure { typedef cGridStructGen::cStructure super; public: - cVillage(int a_Seed, int a_OriginX, int a_OriginZ, cPrefabPiecePool & a_Prefabs) : + cVillage( + int a_Seed, + int a_OriginX, int a_OriginZ, + int a_MaxRoadDepth, + int a_MaxSize, + cPrefabPiecePool & a_Prefabs, + cTerrainHeightGen & a_HeightGen + ) : super(a_OriginX, a_OriginZ), m_Seed(a_Seed), - m_Prefabs(a_Prefabs) + m_Noise(a_Seed), + m_MaxSize(a_MaxSize), + m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, 255, a_OriginZ + a_MaxSize), + m_Prefabs(a_Prefabs), + m_HeightGen(a_HeightGen) { + PlaceWell(); + BuildRoads(a_MaxRoadDepth); + PlaceHouses(); } protected: + class cItem + { + public: + /* The position of the item, X/Z-wise: */ + int m_MinX, m_MaxX, m_MinZ, m_MaxZ; + + /** The prefab to use. If NULL, this is a road. */ + cPrefab * m_Prefab; + + /** Number of rotations that should be applied to the prefab. */ + int m_NumRotations; + + /* The bottom of the prefab. Only valid if the item is a prefab, not valid for roads. */ + int m_BaseY; + + /** Creates a new item with the specified parameters. + m_BaseY is set to -1 and will be adjusted later on when drawing. */ + cItem(int a_MinX, int a_MaxX, int a_MinZ, int a_MaxZ, cPrefab * a_Prefab, int a_NumRotations) : + m_MinX(a_MinX), + m_MaxX(a_MaxX), + m_MinZ(a_MinZ), + m_MaxZ(a_MaxZ), + m_Prefab(a_Prefab), + m_NumRotations(a_NumRotations), + m_BaseY(-1) + { + } + } ; + typedef SharedPtr cItemPtr; + typedef std::vector cItemPtrs; + + /** Seed for the random functions */ int m_Seed; + /** The noise used as a pseudo-random generator */ + cNoise m_Noise; + + /** Maximum size, in X/Z blocks, of the village (radius from the origin) */ + int m_MaxSize; + + /** Borders of the vilalge - no item may reach out of this cuboid. */ + cCuboid m_Borders; + /** Prefabs to use for buildings */ cPrefabPiecePool & m_Prefabs; + /** The underlying height generator, used for placing the structures on top of the terrain. */ + cTerrainHeightGen & m_HeightGen; + + /** The items that are generated in the village (houses, roads). */ + cItemPtrs m_Items; + + + /** Places the well at the center of the village */ + void PlaceWell(void) + { + // Pick a prefab from the starting pieces: + cPieces StartingPieces = ((cPiecePool &)m_Prefabs).GetStartingPieces(); + ASSERT(!StartingPieces.empty()); + int TotalWeight = 0; + for (cPieces::const_iterator itr = StartingPieces.begin(), end = StartingPieces.end(); itr != end; ++itr) + { + TotalWeight += ((const cPrefab *)(*itr))->GetDefaultWeight(); + } + ASSERT(TotalWeight > 0); + int rnd = (m_Noise.IntNoise2DInt(m_OriginX, m_OriginZ) / 7) % TotalWeight; + cPiece * WellPiece = StartingPieces[0]; + for (cPieces::const_iterator itr = StartingPieces.begin(), end = StartingPieces.end(); itr != end; ++itr) + { + rnd -= ((const cPrefab *)(*itr))->GetDefaultWeight(); + if (rnd <= 0) + { + WellPiece = *itr; + break; + } + } + ASSERT(WellPiece != NULL); + + // Pick a rotation: + // TODO + int NumRotations = 0; + Vector3i Size = WellPiece->GetSize(); + + // Put the well in the placed items array: + m_Items.push_back(cItemPtr(new cItem(m_OriginX, m_OriginX + Size.x, m_OriginZ, m_OriginZ + Size.z, (cPrefab *)WellPiece, NumRotations))); + } + + + /** Places the roads going from the well outwards. */ + void BuildRoads(int a_MaxRoadDepth) + { + /* + ASSERT(m_Items.size() == 1); + const cItem & Well = *m_Items[0]; + */ + // TODO + } + + + /** Places houses along the roads. */ + void PlaceHouses(void) + { + // TODO + } + + // cGrdStructGen::cStructure overrides: virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override { // TODO + // Iterate over all items + // Each intersecting prefab is placed on ground (if not already placed), then drawn + // Each intersecting road is drawn by replacing top soil blocks with gravel / sandstone blocks } } ; @@ -53,8 +190,8 @@ cPrefabPiecePool cVillageGen::m_PlainsVillage(g_PlainsVillagePrefabs, g_PlainsVi -cVillageGen::cVillageGen(int a_Seed, int a_GridSize, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen) : - super(a_Seed, a_GridSize, a_GridSize, 128, 128, 100), +cVillageGen::cVillageGen(int a_Seed, int a_GridSize, int a_MaxRoadDepth, int a_MaxSize, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 100), m_BiomeGen(a_BiomeGen), m_HeightGen(a_HeightGen) { @@ -108,7 +245,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ { return cStructurePtr(); } - return cStructurePtr(new cVillage(m_Seed, a_OriginX, a_OriginZ, *VillagePrefabs)); + return cStructurePtr(new cVillage(m_Seed, a_OriginX, a_OriginZ, m_MaxRoadDepth, m_MaxSize, *VillagePrefabs, m_HeightGen)); } diff --git a/src/Generating/VillageGen.h b/src/Generating/VillageGen.h index d3cc8ef9c..acbd76881 100644 --- a/src/Generating/VillageGen.h +++ b/src/Generating/VillageGen.h @@ -21,7 +21,7 @@ class cVillageGen : { typedef cGridStructGen super; public: - cVillageGen(int a_Seed, int a_GridSize, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen); + cVillageGen(int a_Seed, int a_GridSize, int a_MaxRoadDepth, int a_MaxSize, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen); protected: class cVillage; // fwd: VillageGen.cpp @@ -31,6 +31,12 @@ protected: /** The prefabs for the plains village. We're not exactly using the cPiecePool functionality, only the containment. */ static cPrefabPiecePool m_PlainsVillage; + + /** Maximum number of roads generated one from another (tree depth). */ + int m_MaxRoadDepth; + + /** Maximum size, in X/Z blocks, of the village (radius from the origin) */ + int m_MaxSize; /** The underlying biome generator that defines whether the village is created or not */ cBiomeGen & m_BiomeGen; -- cgit v1.2.3 From 466ff2204f18fda5f4f0f0b3e19f671d57747c24 Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 13 May 2014 14:53:15 +0300 Subject: Fixes --- src/Entities/Player.cpp | 21 +++++++++++---------- src/Entities/Player.h | 9 +++------ src/Mobs/Monster.cpp | 2 +- src/WorldStorage/StatSerializer.cpp | 7 +++++-- src/WorldStorage/StatSerializer.h | 4 +++- 5 files changed, 23 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 3df7c4c34..632c41936 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -820,7 +820,7 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI) if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer())) { - cPlayer* Attacker = (cPlayer*) a_TDI.Attacker; + cPlayer * Attacker = (cPlayer *)a_TDI.Attacker; if ((m_Team != NULL) && (m_Team == Attacker->m_Team)) { @@ -880,7 +880,7 @@ void cPlayer::KilledBy(cEntity * a_Killer) } else if (a_Killer->IsPlayer()) { - cPlayer* Killer = (cPlayer*)a_Killer; + cPlayer * Killer = (cPlayer *)a_Killer; GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str())); } @@ -1150,6 +1150,7 @@ unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach) { eStatistic Prerequisite = cStatInfo::GetPrerequisite(a_Ach); + // Check if the prerequisites are met if (Prerequisite != statInvalid) { if (m_Stats.GetValue(Prerequisite) == 0) @@ -1166,14 +1167,16 @@ unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach) } else { + // First time, announce it cCompositeChat Msg; Msg.AddTextPart(m_PlayerName + " has just earned the achievement "); - Msg.AddTextPart(cStatInfo::GetName(a_Ach)); // TODO 2014-05-12 xdot: Use the proper cCompositeChat submessage type and send the actual title + Msg.AddTextPart(cStatInfo::GetName(a_Ach)); // TODO 2014-05-12 xdot: Use the proper cCompositeChat part (cAchievement) m_World->BroadcastChat(Msg); + // Increment the statistic StatValue New = m_Stats.AddValue(a_Ach); - /* Achievement Get! */ + // Achievement Get! m_ClientHandle->SendStatistics(m_Stats); return New; @@ -1707,9 +1710,8 @@ bool cPlayer::LoadFromDisk() m_LoadedWorldName = root.get("world", "world").asString(); - /* Load the player stats. - * We use the default world name (like bukkit) because stats are shared between dimensions/worlds. - */ + // Load the player stats. + // We use the default world name (like bukkit) because stats are shared between dimensions/worlds. cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats); StatSerializer.Load(); @@ -1784,9 +1786,8 @@ bool cPlayer::SaveToDisk() return false; } - /* Save the player stats. - * We use the default world name (like bukkit) because stats are shared between dimensions/worlds. - */ + // Save the player stats. + // We use the default world name (like bukkit) because stats are shared between dimensions/worlds. cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), m_PlayerName, &m_Stats); if (!StatSerializer.Save()) { diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 3de5e9c68..78b534d83 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -181,12 +181,9 @@ public: cStatManager & GetStatManager() { return m_Stats; } /** Awards the player an achievement. - * - * If all prerequisites are met, this method will award the achievement and will broadcast a chat message. - * If the achievement has been already awarded to the player, this method will just increment the stat counter. - * - * Returns the _new_ stat value. (0 = Could not award achievement) - */ + If all prerequisites are met, this method will award the achievement and will broadcast a chat message. + If the achievement has been already awarded to the player, this method will just increment the stat counter. + Returns the _new_ stat value. (0 = Could not award achievement) */ unsigned int AwardAchievement(const eStatistic a_Ach); void SetIP(const AString & a_IP); diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index f3b408e68..b2e42445b 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -464,7 +464,7 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI) return false; } - if ((m_SoundHurt != "") && (m_Health > 0)) + if (!m_SoundHurt.empty() && (m_Health > 0)) { m_World->BroadcastSoundEffect(m_SoundHurt, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f); } diff --git a/src/WorldStorage/StatSerializer.cpp b/src/WorldStorage/StatSerializer.cpp index 66e5e1e9e..74113941c 100644 --- a/src/WorldStorage/StatSerializer.cpp +++ b/src/WorldStorage/StatSerializer.cpp @@ -11,15 +11,18 @@ -cStatSerializer::cStatSerializer(const AString& a_WorldName, const AString& a_PlayerName, cStatManager* a_Manager) +cStatSerializer::cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, cStatManager * a_Manager) : m_Manager(a_Manager) { + // Even though stats are shared between worlds, they are (usually) saved + // inside the folder of the default world. + AString StatsPath; Printf(StatsPath, "%s/stats", a_WorldName.c_str()); m_Path = StatsPath + "/" + a_PlayerName + ".json"; - /* Ensure that the directory exists. */ + // Ensure that the directory exists. cFile::CreateFolder(FILE_IO_PREFIX + StatsPath); } diff --git a/src/WorldStorage/StatSerializer.h b/src/WorldStorage/StatSerializer.h index 43514465b..72f8d74f1 100644 --- a/src/WorldStorage/StatSerializer.h +++ b/src/WorldStorage/StatSerializer.h @@ -25,10 +25,12 @@ class cStatSerializer { public: - cStatSerializer(const AString& a_WorldName, const AString& a_PlayerName, cStatManager* a_Manager); + cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, cStatManager * a_Manager); + /* Try to load the player statistics. Returns whether the operation was successful or not. */ bool Load(void); + /* Try to save the player statistics. Returns whether the operation was successful or not. */ bool Save(void); -- cgit v1.2.3 From 3660ce68343ad2e867e49d1650f61fc0eb85ac23 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 15 May 2014 00:12:01 +0200 Subject: cPrefab can be constructed in code. --- src/Generating/Prefab.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/Generating/Prefab.h | 15 +++++++++++++++ 2 files changed, 51 insertions(+) (limited to 'src') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 0f20603be..9aef7a94b 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -136,6 +136,33 @@ cPrefab::cPrefab(const cPrefab::sDef & a_Def) : ParseConnectors(a_Def.m_Connectors); ParseDepthWeight(a_Def.m_DepthWeight); + AddRotatedBlockAreas(); +} + + + + + +cPrefab::cPrefab(const cBlockArea & a_Image, int a_AllowedRotations) : + m_Size(a_Image.GetSize()), + m_AllowedRotations(a_AllowedRotations), + m_MergeStrategy(cBlockArea::msOverwrite), + m_ShouldExtendFloor(false), + m_DefaultWeight(1), + m_AddWeightIfSame(0) +{ + m_HitBox.p1.Set(0, 0, 0); + m_HitBox.p2.Set(m_Size.x - 1, m_Size.y - 1, m_Size.z - 1); + m_BlockArea[0].CopyFrom(a_Image); + AddRotatedBlockAreas(); +} + + + + + +void cPrefab::AddRotatedBlockAreas(void) +{ // 1 CCW rotation: if ((m_AllowedRotations & 0x01) != 0) { @@ -257,6 +284,15 @@ int cPrefab::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cC +void cPrefab::AddConnector(int a_RelX, int a_RelY, int a_RelZ, eBlockFace a_Direction, int a_Type) +{ + m_Connectors.push_back(cConnector(a_RelX, a_RelY, a_RelZ, a_Type, a_Direction)); +} + + + + + void cPrefab::ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef) { ASSERT(a_CharMapDef != NULL); diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index 472584c3a..c08413e87 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -84,8 +84,13 @@ public: int m_AddWeightIfSame; }; + + /** Creates a prefab from the provided definition. */ cPrefab(const sDef & a_Def); + /** Creates a prefab based on the given BlockArea and allowed rotations. */ + cPrefab(const cBlockArea & a_Image, int a_AllowedRotations); + /** Draws the prefab into the specified chunk, according to the placement stored in the PlacedPiece. */ void Draw(cChunkDesc & a_Dest, const cPlacedPiece * a_Placement) const; @@ -98,6 +103,12 @@ public: /** Returns the unmodified DefaultWeight property for the piece. */ int GetDefaultWeight(void) const { return m_DefaultWeight; } + + /** Sets the AddWeightIfSame member, that is used to modify the weight when the previous piece is the same prefab */ + void SetAddWeightIfSame(int a_AddWeightIfSame) { m_AddWeightIfSame = a_AddWeightIfSame; } + + /** Adds the specified connector to the list of connectors this piece supports. */ + void AddConnector(int a_RelX, int a_RelY, int a_RelZ, eBlockFace a_Direction, int a_Type); protected: /** Packs complete definition of a single block, for per-letter assignment. */ @@ -160,6 +171,10 @@ protected: virtual cCuboid GetHitBox(void) const override; virtual bool CanRotateCCW(int a_NumRotations) const override; + /** Based on the m_AllowedRotations, adds rotated cBlockAreas to the m_BlockArea array. + To be called only from this class's constructor! */ + void AddRotatedBlockAreas(void); + /** Parses the CharMap in the definition into a CharMap binary data used for translating the definition into BlockArea. */ void ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef); -- cgit v1.2.3 From f5fdbdaf29738f51fdb8a4a0e5aa78631c6540cf Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 15 May 2014 00:14:06 +0200 Subject: VillageGen rewritten using BFSPieceGenerator. Piece composition is not good yet, the buildings aren't height-adjusted and the road pieces will need special processing. This is mainly for adjusting the per-piece params. --- src/Generating/ComposableGenerator.cpp | 9 + src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 416 ++++++++++++------------ src/Generating/Prefabs/SandVillagePrefabs.cpp | 185 +++++------ src/Generating/VillageGen.cpp | 196 ++++++----- src/Generating/VillageGen.h | 12 +- 5 files changed, 406 insertions(+), 412 deletions(-) (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 2e886336f..1bb836684 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -25,6 +25,7 @@ #include "Noise3DGenerator.h" #include "POCPieceGenerator.h" #include "Ravines.h" +#include "VillageGen.h" @@ -32,6 +33,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cTerrainCompositionGen: + cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile & a_IniFile, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen, int a_Seed) { AString CompoGenName = a_IniFile.GetValueSet("Generator", "CompositionGen", ""); @@ -404,6 +406,13 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) { m_FinishGens.push_back(new cStructGenTrees(Seed, m_BiomeGen, m_HeightGen, m_CompositionGen)); } + else if (NoCaseCompare(*itr, "Villages") == 0) + { + int GridSize = a_IniFile.GetValueSetI("Generator", "VillageGridSize", 256); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "VillageMaxDepth", 7); + int MaxSize = a_IniFile.GetValueSetI("Generator", "VillageMaxSize", 128); + m_FinishGens.push_back(new cVillageGen(Seed, GridSize, MaxDepth, MaxSize, *m_BiomeGen, *m_HeightGen)); + } else if (NoCaseCompare(*itr, "WaterLakes") == 0) { int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25); diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index f59e22fb3..508f0d3b6 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -174,7 +174,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 10 */ ".......mmmmm", // Connectors: - "", + "-1: 7, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -216,7 +216,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "d: 4: 0\n" /* cobblestone */ "e: 17: 0\n" /* tree */ "f: 5: 0\n" /* wood */ - "g: 64: 5\n" /* wooddoorblock */ + "g: 64: 7\n" /* wooddoorblock */ "h: 64:12\n" /* wooddoorblock */ "i:102: 0\n" /* glasspane */ "j: 53: 2\n" /* woodstairs */ @@ -288,7 +288,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ ".......", // Connectors: - "", + "-1: 3, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -330,7 +330,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "d: 4: 0\n" /* cobblestone */ "e: 17: 0\n" /* tree */ "f: 5: 0\n" /* wood */ - "g: 64: 5\n" /* wooddoorblock */ + "g: 64: 7\n" /* wooddoorblock */ "h:102: 0\n" /* glasspane */ "i: 64:12\n" /* wooddoorblock */ "j: 53: 2\n" /* woodstairs */ @@ -434,7 +434,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 8 */ "...........", // Connectors: - "", + "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -561,7 +561,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 8 */ "..lgp..", // Connectors: - "", + "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -725,7 +725,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 8 */ "...............", // Connectors: - "", + "-1: 7, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1016,7 +1016,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 12 */ ".......", // Connectors: - "", + "-1: 3, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1087,7 +1087,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 8 */ "dmmmmmdmdmmmmmd", // Connectors: - "", + "-1: 7, 0, 8: 3\n" /* Type -1, direction Z+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1134,7 +1134,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "i: 53: 1\n" /* woodstairs */ "j: 85: 0\n" /* fence */ "k: 53: 0\n" /* woodstairs */ - "l: 64: 4\n" /* wooddoorblock */ + "l: 64: 6\n" /* wooddoorblock */ "m: 19: 0\n" /* sponge */ "n: 64: 0\n" /* wooddoorblock */ "o:102: 0\n" /* glasspane */ @@ -1238,7 +1238,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 10 */ "mmkbimmmmm", // Connectors: - "", + "-1: 1, 0, 5: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1281,22 +1281,23 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "e: 5: 0\n" /* wood */ "f: 67: 3\n" /* stairs */ "g: 17: 0\n" /* tree */ - "h: 64: 5\n" /* wooddoorblock */ - "i:102: 0\n" /* glasspane */ - "j: 64:12\n" /* wooddoorblock */ - "k: 53: 2\n" /* woodstairs */ - "l: 53: 1\n" /* woodstairs */ + "h: 64: 7\n" /* wooddoorblock */ + "i: 64: 5\n" /* wooddoorblock */ + "j:102: 0\n" /* glasspane */ + "k: 64:12\n" /* wooddoorblock */ + "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 7\n" /* woodstairs */ - "o: 53: 6\n" /* woodstairs */ - "p: 53: 3\n" /* woodstairs */ - "q: 53: 0\n" /* woodstairs */ - "r: 53: 5\n" /* woodstairs */ - "s: 53: 4\n" /* woodstairs */ - "t: 50: 3\n" /* torch */ - "u: 50: 2\n" /* torch */ - "v: 50: 4\n" /* torch */ - "w: 50: 1\n" /* torch */, + "n: 53: 1\n" /* woodstairs */ + "o: 53: 7\n" /* woodstairs */ + "p: 53: 6\n" /* woodstairs */ + "q: 53: 3\n" /* woodstairs */ + "r: 53: 0\n" /* woodstairs */ + "s: 53: 5\n" /* woodstairs */ + "t: 53: 4\n" /* woodstairs */ + "u: 50: 3\n" /* torch */ + "v: 50: 2\n" /* torch */ + "w: 50: 4\n" /* torch */ + "x: 50: 1\n" /* torch */, // Block data: // Level 0 @@ -1329,7 +1330,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 4 */ ".e............e." /* 5 */ ".e............e." /* 6 */ ".e............e." - /* 7 */ ".geeeeheg.....e." + /* 7 */ ".geeeeieg.....e." /* 8 */ "mmmmmm.me.....e." /* 9 */ "mmmmmmmme.....e." /* 10 */ "mmmmmmmme.....e." @@ -1343,81 +1344,81 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" - /* 1 */ ".geiieiigjgiieg." - /* 2 */ ".i............e." - /* 3 */ ".i............i." - /* 4 */ ".i............i." - /* 5 */ ".i............e." - /* 6 */ ".i............i." - /* 7 */ ".geiiejeg.....i." + /* 1 */ ".gejjejjgkgjjeg." + /* 2 */ ".j............e." + /* 3 */ ".j............j." + /* 4 */ ".j............j." + /* 5 */ ".j............e." + /* 6 */ ".j............j." + /* 7 */ ".gejjekeg.....j." /* 8 */ "mmmmmm.me.....e." - /* 9 */ "mmmmmmmmi.....i." - /* 10 */ "mmmmmmmmi.....i." + /* 9 */ "mmmmmmmmj.....j." + /* 10 */ "mmmmmmmmj.....j." /* 11 */ "mmmmmmmme.....e." - /* 12 */ "mmmmmmmmi.....i." - /* 13 */ "mmmmmmmmi.....i." - /* 14 */ "mmmmmmmmgiiiiig." + /* 12 */ "mmmmmmmmj.....j." + /* 13 */ "mmmmmmmmj.....j." + /* 14 */ "mmmmmmmmgjjjjjg." /* 15 */ "mmmmmmmm........" // Level 3 /* z\x* 111111 */ /* * 0123456789012345 */ - /* 0 */ "kkkkkkkkkkkkkkkl" - /* 1 */ "ngeeeeeegegeeegl" - /* 2 */ ".e............el" - /* 3 */ ".e............el" - /* 4 */ ".e............el" - /* 5 */ ".e............el" - /* 6 */ ".e............el" - /* 7 */ "ogeeeeeeg.....el" - /* 8 */ "pppppppqe.....el" - /* 9 */ "mmmmmmmqe.....el" - /* 10 */ "mmmmmmmqe.....el" - /* 11 */ "mmmmmmmqe.....el" - /* 12 */ "mmmmmmmqe.....el" - /* 13 */ "mmmmmmmqe.....el" - /* 14 */ "mmmmmmmqgeeeeegl" - /* 15 */ "mmmmmmmqr.....sl" + /* 0 */ "llllllllllllllln" + /* 1 */ "ogeeeeeegegeeegn" + /* 2 */ ".e............en" + /* 3 */ ".e............en" + /* 4 */ ".e............en" + /* 5 */ ".e............en" + /* 6 */ ".e............en" + /* 7 */ "pgeeeeeeg.....en" + /* 8 */ "qqqqqqqre.....en" + /* 9 */ "mmmmmmmre.....en" + /* 10 */ "mmmmmmmre.....en" + /* 11 */ "mmmmmmmre.....en" + /* 12 */ "mmmmmmmre.....en" + /* 13 */ "mmmmmmmre.....en" + /* 14 */ "mmmmmmmrgeeeeegn" + /* 15 */ "mmmmmmmrs.....tn" // Level 4 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" - /* 1 */ "kkkkkkkkkkkkkkk." - /* 2 */ "neeeeeeeeeeeeel." - /* 3 */ ".e.........t.el." - /* 4 */ ".e..........uel." - /* 5 */ ".e......v....el." - /* 6 */ "oeeeeeeeee...el." - /* 7 */ "ppppppppqew..el." - /* 8 */ "mmmmmmmmqe...el." - /* 9 */ "mmmmmmmmqe...el." - /* 10 */ "mmmmmmmmqe...el." - /* 11 */ "mmmmmmmmqe...el." - /* 12 */ "mmmmmmmmqe...el." - /* 13 */ "mmmmmmmmqe...el." - /* 14 */ "mmmmmmmmqeeeeel." - /* 15 */ "mmmmmmmmqr...sl." + /* 1 */ "lllllllllllllll." + /* 2 */ "oeeeeeeeeeeeeen." + /* 3 */ ".e.........u.en." + /* 4 */ ".e..........ven." + /* 5 */ ".e......w....en." + /* 6 */ "peeeeeeeee...en." + /* 7 */ "qqqqqqqqrex..en." + /* 8 */ "mmmmmmmmre...en." + /* 9 */ "mmmmmmmmre...en." + /* 10 */ "mmmmmmmmre...en." + /* 11 */ "mmmmmmmmre...en." + /* 12 */ "mmmmmmmmre...en." + /* 13 */ "mmmmmmmmre...en." + /* 14 */ "mmmmmmmmreeeeen." + /* 15 */ "mmmmmmmmrs...tn." // Level 5 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" /* 1 */ "................" - /* 2 */ "kkkkkkkkkkkkkl.." - /* 3 */ "neeeeeeeeeeeel.." - /* 4 */ ".ew.........el.." - /* 5 */ "oeeeeeeeeee.el.." - /* 6 */ "pppppppppqe.el.." - /* 7 */ ".........qe.el.." - /* 8 */ "mmmmmmmm.qe.el.." - /* 9 */ "mmmmmmmm.qe.el.." - /* 10 */ "mmmmmmmm.qe.el.." - /* 11 */ "mmmmmmmm.qe.el.." - /* 12 */ "mmmmmmmm.qe.el.." - /* 13 */ "mmmmmmmm.qevel.." - /* 14 */ "mmmmmmmm.qeeel.." - /* 15 */ "mmmmmmmm.qr.sl.." + /* 2 */ "llllllllllllln.." + /* 3 */ "oeeeeeeeeeeeen.." + /* 4 */ ".ex.........en.." + /* 5 */ "peeeeeeeeee.en.." + /* 6 */ "qqqqqqqqqre.en.." + /* 7 */ ".........re.en.." + /* 8 */ "mmmmmmmm.re.en.." + /* 9 */ "mmmmmmmm.re.en.." + /* 10 */ "mmmmmmmm.re.en.." + /* 11 */ "mmmmmmmm.re.en.." + /* 12 */ "mmmmmmmm.re.en.." + /* 13 */ "mmmmmmmm.rewen.." + /* 14 */ "mmmmmmmm.reeen.." + /* 15 */ "mmmmmmmm.rs.tn.." // Level 6 /* z\x* 111111 */ @@ -1425,22 +1426,22 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 0 */ "................" /* 1 */ "................" /* 2 */ "................" - /* 3 */ "kkkkkkkkkkkkk..." - /* 4 */ "eeeeeeeeeeeel..." - /* 5 */ "ppppppppppqel..." - /* 6 */ "mmmmmmmmmmqel..." - /* 7 */ "mmmmmmmmmmqel..." - /* 8 */ "mmmmmmmmmmqel..." - /* 9 */ "mmmmmmmmmmqel..." - /* 10 */ "mmmmmmmmmmqel..." - /* 11 */ "mmmmmmmmmmqel..." - /* 12 */ "mmmmmmmmmmqel..." - /* 13 */ "mmmmmmmmmmqel..." - /* 14 */ "mmmmmmmmmmqel..." - /* 15 */ "mmmmmmmmmmqel...", + /* 3 */ "lllllllllllll..." + /* 4 */ "eeeeeeeeeeeen..." + /* 5 */ "qqqqqqqqqqren..." + /* 6 */ "mmmmmmmmmmren..." + /* 7 */ "mmmmmmmmmmren..." + /* 8 */ "mmmmmmmmmmren..." + /* 9 */ "mmmmmmmmmmren..." + /* 10 */ "mmmmmmmmmmren..." + /* 11 */ "mmmmmmmmmmren..." + /* 12 */ "mmmmmmmmmmren..." + /* 13 */ "mmmmmmmmmmren..." + /* 14 */ "mmmmmmmmmmren..." + /* 15 */ "mmmmmmmmmmren...", // Connectors: - "", + "-1: 9, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1506,7 +1507,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ "..........", // Connectors: - "", + "-1: 9, 0, 3: 5\n" /* Type -1, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1548,7 +1549,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "d: 67: 2\n" /* stairs */ "e: 67: 1\n" /* stairs */ "f: 4: 0\n" /* cobblestone */ - "g: 64: 1\n" /* wooddoorblock */ + "g: 64: 7\n" /* wooddoorblock */ "h: 53: 3\n" /* woodstairs */ "i: 53: 1\n" /* woodstairs */ "j: 85: 0\n" /* fence */ @@ -1556,7 +1557,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ "n:102: 0\n" /* glasspane */ - "o: 64: 8\n" /* wooddoorblock */ + "o: 64:12\n" /* wooddoorblock */ "p: 50: 3\n" /* torch */ "q: 72: 0\n" /* woodplate */ "r: 50: 4\n" /* torch */ @@ -1646,7 +1647,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ "............", // Connectors: - "", + "-1: 8, 1, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1689,19 +1690,18 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "e: 67: 3\n" /* stairs */ "f: 17: 0\n" /* tree */ "g: 5: 0\n" /* wood */ - "h: 64: 5\n" /* wooddoorblock */ - "i: 64: 7\n" /* wooddoorblock */ - "j:102: 0\n" /* glasspane */ - "k: 64:12\n" /* wooddoorblock */ - "l: 53: 2\n" /* woodstairs */ + "h: 64: 7\n" /* wooddoorblock */ + "i:102: 0\n" /* glasspane */ + "j: 64:12\n" /* wooddoorblock */ + "k: 53: 2\n" /* woodstairs */ + "l: 53: 7\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 7\n" /* woodstairs */ - "o: 17: 4\n" /* tree */ - "p: 17: 8\n" /* tree */ - "q: 50: 3\n" /* torch */ - "r: 50: 4\n" /* torch */ - "s: 53: 6\n" /* woodstairs */ - "t: 53: 3\n" /* woodstairs */, + "n: 17: 4\n" /* tree */ + "o: 17: 8\n" /* tree */ + "p: 50: 3\n" /* torch */ + "q: 50: 4\n" /* torch */ + "r: 53: 6\n" /* woodstairs */ + "s: 53: 3\n" /* woodstairs */, // Block data: // Level 0 @@ -1727,46 +1727,46 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 4 */ ".f.......f." /* 5 */ ".g.......g." /* 6 */ ".g.......g." - /* 7 */ ".fggfifggf." + /* 7 */ ".fggfhfggf." /* 8 */ "..........." // Level 2 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ ".fjjfkfjjf." - /* 2 */ ".j.......j." - /* 3 */ ".j.......j." + /* 1 */ ".fiifjfiif." + /* 2 */ ".i.......i." + /* 3 */ ".i.......i." /* 4 */ ".f.......f." - /* 5 */ ".j.......j." - /* 6 */ ".j.......j." - /* 7 */ ".fjjfkfjjf." + /* 5 */ ".i.......i." + /* 6 */ ".i.......i." + /* 7 */ ".fiifjfiif." /* 8 */ "..........." // Level 3 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "lllllllllll" - /* 1 */ "nfooooooofn" - /* 2 */ ".p..q.q..p." - /* 3 */ ".p.......p." - /* 4 */ ".p.......p." - /* 5 */ ".p.......p." - /* 6 */ ".p..r.r..p." - /* 7 */ "sfooooooofs" - /* 8 */ "ttttttttttt" + /* 0 */ "kkkkkkkkkkk" + /* 1 */ "lfnnnnnnnfl" + /* 2 */ ".o..p.p..o." + /* 3 */ ".o.......o." + /* 4 */ ".o.......o." + /* 5 */ ".o.......o." + /* 6 */ ".o..q.q..o." + /* 7 */ "rfnnnnnnnfr" + /* 8 */ "sssssssssss" // Level 4 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ "lllllllllll" - /* 2 */ "ngggggggggn" + /* 1 */ "kkkkkkkkkkk" + /* 2 */ "lgggggggggl" /* 3 */ ".g.......g." /* 4 */ ".g.......g." /* 5 */ ".g.......g." - /* 6 */ "sgggggggggs" - /* 7 */ "ttttttttttt" + /* 6 */ "rgggggggggr" + /* 7 */ "sssssssssss" /* 8 */ "..........." // Level 5 @@ -1774,11 +1774,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." - /* 2 */ "lllllllllll" - /* 3 */ "ngggggggggn" + /* 2 */ "kkkkkkkkkkk" + /* 3 */ "lgggggggggl" /* 4 */ ".g.......g." - /* 5 */ "sgggggggggs" - /* 6 */ "ttttttttttt" + /* 5 */ "rgggggggggr" + /* 6 */ "sssssssssss" /* 7 */ "..........." /* 8 */ "..........." @@ -1788,15 +1788,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ "lllllllllll" + /* 3 */ "kkkkkkkkkkk" /* 4 */ "ggggggggggg" - /* 5 */ "ttttttttttt" + /* 5 */ "sssssssssss" /* 6 */ "..........." /* 7 */ "..........." /* 8 */ "...........", // Connectors: - "", + "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2025,7 +2025,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 15 */ "mmmmmmmmmmmmmmm", // Connectors: - "", + "-1: 7, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2069,7 +2069,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "f: 4: 0\n" /* cobblestone */ "g: 17: 0\n" /* tree */ "h: 5: 0\n" /* wood */ - "i: 64: 5\n" /* wooddoorblock */ + "i: 64: 7\n" /* wooddoorblock */ "j:102: 0\n" /* glasspane */ "k: 64:12\n" /* wooddoorblock */ "l: 53: 2\n" /* woodstairs */ @@ -2151,7 +2151,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ ".........", // Connectors: - "", + "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2193,7 +2193,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "d: 4: 0\n" /* cobblestone */ "e: 17: 0\n" /* tree */ "f: 5: 0\n" /* wood */ - "g: 64: 5\n" /* wooddoorblock */ + "g: 64: 7\n" /* wooddoorblock */ "h:102: 0\n" /* glasspane */ "i: 64:12\n" /* wooddoorblock */ "j: 53: 2\n" /* woodstairs */ @@ -2271,7 +2271,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ "...........", // Connectors: - "", + "-1: 5, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2313,7 +2313,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "d: 4: 0\n" /* cobblestone */ "e: 17: 0\n" /* tree */ "f: 5: 0\n" /* wood */ - "g: 64: 5\n" /* wooddoorblock */ + "g: 64: 7\n" /* wooddoorblock */ "h:102: 0\n" /* glasspane */ "i: 64:12\n" /* wooddoorblock */ "j: 53: 2\n" /* woodstairs */ @@ -2422,7 +2422,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 10 */ "mmmm..tfl..", // Connectors: - "", + "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2464,7 +2464,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "d: 4: 0\n" /* cobblestone */ "e: 17: 0\n" /* tree */ "f: 5: 0\n" /* wood */ - "g: 64: 5\n" /* wooddoorblock */ + "g: 64: 7\n" /* wooddoorblock */ "h:102: 0\n" /* glasspane */ "i: 64:12\n" /* wooddoorblock */ "j: 53: 2\n" /* woodstairs */ @@ -2571,7 +2571,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 10 */ "..kfl.....kfl..", // Connectors: - "", + "-1: 7, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2613,7 +2613,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "d: 4: 0\n" /* cobblestone */ "e: 17: 0\n" /* tree */ "f: 5: 0\n" /* wood */ - "g: 64: 5\n" /* wooddoorblock */ + "g: 64: 7\n" /* wooddoorblock */ "h: 53: 3\n" /* woodstairs */ "i: 85: 0\n" /* fence */ "j: 53: 2\n" /* woodstairs */ @@ -2698,7 +2698,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ "...........", // Connectors: - "", + "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2740,15 +2740,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "d: 4: 0\n" /* cobblestone */ "e: 17: 0\n" /* tree */ "f: 5: 0\n" /* wood */ - "g: 64: 5\n" /* wooddoorblock */ - "h: 53: 3\n" /* woodstairs */ - "i: 85: 0\n" /* fence */ - "j: 53: 2\n" /* woodstairs */ - "k: 53: 1\n" /* woodstairs */ - "l: 53: 0\n" /* woodstairs */ + "g: 64: 7\n" /* wooddoorblock */ + "h: 64: 5\n" /* wooddoorblock */ + "i: 53: 3\n" /* woodstairs */ + "j: 85: 0\n" /* fence */ + "k: 53: 2\n" /* woodstairs */ + "l: 53: 1\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n:102: 0\n" /* glasspane */ - "o: 64:13\n" /* wooddoorblock */ + "n: 53: 0\n" /* woodstairs */ + "o:102: 0\n" /* glasspane */ "p: 64:12\n" /* wooddoorblock */ "q: 50: 3\n" /* torch */ "r: 72: 0\n" /* woodplate */ @@ -2776,12 +2776,12 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" - /* 1 */ ".efffggfffe." + /* 1 */ ".efffghfffe." /* 2 */ ".f........f." - /* 3 */ ".fh......hf." - /* 4 */ ".fi......if." - /* 5 */ ".fj......jf." - /* 6 */ ".f.kilkil.f." + /* 3 */ ".fi......if." + /* 4 */ ".fj......jf." + /* 5 */ ".fk......kf." + /* 6 */ ".f.ljnljn.f." /* 7 */ ".effffffffe." /* 8 */ "............" @@ -2789,19 +2789,19 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" - /* 1 */ ".ennfopfnne." - /* 2 */ ".n..q..q..n." - /* 3 */ ".n........n." + /* 1 */ ".eoofppfooe." + /* 2 */ ".o..q..q..o." + /* 3 */ ".o........o." /* 4 */ ".fr......rf." - /* 5 */ ".n........n." - /* 6 */ ".n..r..r..n." - /* 7 */ ".ennfnnfnne." + /* 5 */ ".o........o." + /* 6 */ ".o..r..r..o." + /* 7 */ ".eoofoofooe." /* 8 */ "............" // Level 3 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "jjjjjjjjjjjj" + /* 0 */ "kkkkkkkkkkkk" /* 1 */ "sffffffffffs" /* 2 */ ".fttttttttf." /* 3 */ ".f........f." @@ -2809,19 +2809,19 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 5 */ ".f........f." /* 6 */ ".fttttttttf." /* 7 */ "wffffffffffw" - /* 8 */ "hhhhhhhhhhhh" + /* 8 */ "iiiiiiiiiiii" // Level 4 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" - /* 1 */ "jjjjjjjjjjjj" + /* 1 */ "kkkkkkkkkkkk" /* 2 */ "sffffffffffs" /* 3 */ ".fttttttttf." /* 4 */ ".f........f." /* 5 */ ".fttttttttf." /* 6 */ "wffffffffffw" - /* 7 */ "hhhhhhhhhhhh" + /* 7 */ "iiiiiiiiiiii" /* 8 */ "............" // Level 5 @@ -2829,11 +2829,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* * 012345678901 */ /* 0 */ "............" /* 1 */ "............" - /* 2 */ "jjjjjjjjjjjj" + /* 2 */ "kkkkkkkkkkkk" /* 3 */ "sffffffffffs" /* 4 */ ".f........f." /* 5 */ "wffffffffffw" - /* 6 */ "hhhhhhhhhhhh" + /* 6 */ "iiiiiiiiiiii" /* 7 */ "............" /* 8 */ "............" @@ -2843,15 +2843,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 0 */ "............" /* 1 */ "............" /* 2 */ "............" - /* 3 */ "jjjjjjjjjjjj" + /* 3 */ "kkkkkkkkkkkk" /* 4 */ "ffffffffffff" - /* 5 */ "hhhhhhhhhhhh" + /* 5 */ "iiiiiiiiiiii" /* 6 */ "............" /* 7 */ "............" /* 8 */ "............", // Connectors: - "", + "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2895,19 +2895,18 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "f: 2: 0\n" /* grass */ "g: 17: 0\n" /* tree */ "h: 5: 0\n" /* wood */ - "i: 64: 5\n" /* wooddoorblock */ + "i: 64: 7\n" /* wooddoorblock */ "j: 53: 3\n" /* woodstairs */ "k: 85: 0\n" /* fence */ "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 64: 7\n" /* wooddoorblock */ - "o:102: 0\n" /* glasspane */ - "p: 64:12\n" /* wooddoorblock */ - "q: 72: 0\n" /* woodplate */ - "r: 53: 7\n" /* woodstairs */ - "s: 50: 1\n" /* torch */ - "t: 50: 2\n" /* torch */ - "u: 53: 6\n" /* woodstairs */, + "n:102: 0\n" /* glasspane */ + "o: 64:12\n" /* wooddoorblock */ + "p: 72: 0\n" /* woodplate */ + "q: 53: 7\n" /* woodstairs */ + "r: 50: 1\n" /* torch */ + "s: 50: 2\n" /* torch */ + "t: 53: 6\n" /* woodstairs */, // Block data: // Level 0 @@ -2937,7 +2936,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 4 */ ".h.e....lh." /* 5 */ ".h.......h." /* 6 */ ".h.......h." - /* 7 */ ".ghhhnhhhg." + /* 7 */ ".ghhhihhhg." /* 8 */ "..k.....k.." /* 9 */ "mmk.....kmm" /* 10 */ "mmk.....kmm" @@ -2948,13 +2947,13 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ ".goohphoog." - /* 2 */ ".o.......o." - /* 3 */ ".o......qo." + /* 1 */ ".gnnhohnng." + /* 2 */ ".n.......n." + /* 3 */ ".n......pn." /* 4 */ ".h.......h." - /* 5 */ ".o.......o." - /* 6 */ ".o.......o." - /* 7 */ ".goohphoog." + /* 5 */ ".n.......n." + /* 6 */ ".n.......n." + /* 7 */ ".gnnhohnng." /* 8 */ "..........." /* 9 */ "mm.......mm" /* 10 */ "mm.......mm" @@ -2965,13 +2964,13 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "lllllllllll" - /* 1 */ "rhhhhhhhhhr" + /* 1 */ "qhhhhhhhhhq" /* 2 */ ".h.......h." /* 3 */ ".h.......h." - /* 4 */ ".hs.....th." + /* 4 */ ".hr.....sh." /* 5 */ ".h.......h." /* 6 */ ".h.......h." - /* 7 */ "uhhhhhhhhhu" + /* 7 */ "thhhhhhhhht" /* 8 */ "jjjjjjjjjjj" /* 9 */ "mm.......mm" /* 10 */ "mm.......mm" @@ -2983,11 +2982,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "lllllllllll" - /* 2 */ "rhhhhhhhhhr" + /* 2 */ "qhhhhhhhhhq" /* 3 */ ".h.......h." /* 4 */ ".h.......h." /* 5 */ ".h.......h." - /* 6 */ "uhhhhhhhhhu" + /* 6 */ "thhhhhhhhht" /* 7 */ "jjjjjjjjjjj" /* 8 */ "..........." /* 9 */ "mm.......mm" @@ -3001,9 +3000,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "lllllllllll" - /* 3 */ "rhhhhhhhhhr" + /* 3 */ "qhhhhhhhhhq" /* 4 */ ".h.......h." - /* 5 */ "uhhhhhhhhhu" + /* 5 */ "thhhhhhhhht" /* 6 */ "jjjjjjjjjjj" /* 7 */ "..........." /* 8 */ "..........." @@ -3030,7 +3029,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 12 */ "mm.......mm", // Connectors: - "", + "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3279,7 +3278,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "f: 5: 0\n" /* wood */ "g: 54: 4\n" /* chest */ "h:154: 4\n" /* hopper */ - "i: 64: 6\n" /* wooddoorblock */ + "i: 64: 4\n" /* wooddoorblock */ "j:102: 0\n" /* glasspane */ "k: 85: 0\n" /* fence */ "l: 64:12\n" /* wooddoorblock */ @@ -3551,7 +3550,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 12 */ ".........", // Connectors: - "", + "-1: 5, 0, 6: 5\n" /* Type -1, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3692,7 +3691,10 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = /* 3 */ "bbbb", // Connectors: - "", + "1: 1, 9, 3: 3\n" /* Type 1, direction Z+ */ + "1: 2, 9, 0: 2\n" /* Type 1, direction Z- */ + "1: 0, 9, 1: 4\n" /* Type 1, direction X- */ + "1: 3, 9, 2: 5\n" /* Type 1, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ diff --git a/src/Generating/Prefabs/SandVillagePrefabs.cpp b/src/Generating/Prefabs/SandVillagePrefabs.cpp index 23af0f0a6..51411dea2 100644 --- a/src/Generating/Prefabs/SandVillagePrefabs.cpp +++ b/src/Generating/Prefabs/SandVillagePrefabs.cpp @@ -63,7 +63,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 8 */ "d.....d.....d", // Connectors: - "", + "-1: 6, 0, 8: 3\n" /* Type -1, direction Z+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -103,7 +103,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = "b:128: 2\n" /* sandstonestairs */ "c:128: 1\n" /* sandstonestairs */ "d: 24: 0\n" /* sandstone */ - "e: 64: 5\n" /* wooddoorblock */ + "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ "h:128: 7\n" /* sandstonestairs */ @@ -183,7 +183,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 6 */ "...........", // Connectors: - "", + "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -223,7 +223,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = "b:128: 2\n" /* sandstonestairs */ "c:128: 1\n" /* sandstonestairs */ "d: 24: 0\n" /* sandstone */ - "e: 64: 5\n" /* wooddoorblock */ + "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ "h:128: 7\n" /* sandstonestairs */ @@ -326,7 +326,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 8 */ "...........", // Connectors: - "", + "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -366,7 +366,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = "b:128: 2\n" /* sandstonestairs */ "c:128: 1\n" /* sandstonestairs */ "d: 24: 0\n" /* sandstone */ - "e: 64: 5\n" /* wooddoorblock */ + "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ "h:128: 7\n" /* sandstonestairs */ @@ -444,7 +444,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 6 */ ".............", // Connectors: - "", + "-1: 6, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -484,7 +484,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = "b:128: 2\n" /* sandstonestairs */ "c:128: 1\n" /* sandstonestairs */ "d: 24: 0\n" /* sandstone */ - "e: 64: 5\n" /* wooddoorblock */ + "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ "h:128: 7\n" /* sandstonestairs */ @@ -587,7 +587,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 8 */ ".............", // Connectors: - "", + "-1: 6, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -627,7 +627,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = "b:128: 2\n" /* sandstonestairs */ "c:128: 1\n" /* sandstonestairs */ "d: 24: 0\n" /* sandstone */ - "e: 64: 5\n" /* wooddoorblock */ + "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ "h:128: 7\n" /* sandstonestairs */ @@ -730,7 +730,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 8 */ "...............", // Connectors: - "", + "-1: 6, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -770,7 +770,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = "b:128: 2\n" /* sandstonestairs */ "c:128: 1\n" /* sandstonestairs */ "d: 24: 0\n" /* sandstone */ - "e: 64: 5\n" /* wooddoorblock */ + "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ "h:128: 7\n" /* sandstonestairs */ @@ -873,7 +873,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 8 */ "................", // Connectors: - "", + "-1: 9, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -913,7 +913,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = "b:128: 2\n" /* sandstonestairs */ "c:128: 1\n" /* sandstonestairs */ "d: 24: 0\n" /* sandstone */ - "e: 64: 5\n" /* wooddoorblock */ + "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ "h:128: 7\n" /* sandstonestairs */ @@ -984,7 +984,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 6 */ ".......", // Connectors: - "", + "-1: 4, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1024,7 +1024,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = "b:128: 2\n" /* sandstonestairs */ "c:128: 1\n" /* sandstonestairs */ "d: 24: 0\n" /* sandstone */ - "e: 64: 5\n" /* wooddoorblock */ + "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ "h:128: 7\n" /* sandstonestairs */ @@ -1096,7 +1096,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 6 */ ".........", // Connectors: - "", + "-1: 4, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1136,9 +1136,9 @@ const cPrefab::sDef g_SandVillagePrefabs[] = "b:128: 2\n" /* sandstonestairs */ "c:128: 1\n" /* sandstonestairs */ "d: 24: 0\n" /* sandstone */ - "e: 64: 1\n" /* wooddoorblock */ + "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ - "g: 64: 8\n" /* wooddoorblock */ + "g: 64:12\n" /* wooddoorblock */ "h:128: 7\n" /* sandstonestairs */ "i: 50: 3\n" /* torch */ "j: 50: 4\n" /* torch */ @@ -1232,7 +1232,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 8 */ ".........", // Connectors: - "", + "-1: 4, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1273,17 +1273,18 @@ const cPrefab::sDef g_SandVillagePrefabs[] = "c:128: 1\n" /* sandstonestairs */ "d: 24: 0\n" /* sandstone */ "e:128: 3\n" /* sandstonestairs */ - "f: 64: 5\n" /* wooddoorblock */ - "g:102: 0\n" /* glasspane */ - "h: 64:12\n" /* wooddoorblock */ - "i:128: 7\n" /* sandstonestairs */ - "j: 50: 3\n" /* torch */ - "k: 50: 4\n" /* torch */ - "l:128: 6\n" /* sandstonestairs */ + "f: 64: 7\n" /* wooddoorblock */ + "g: 64: 5\n" /* wooddoorblock */ + "h:102: 0\n" /* glasspane */ + "i: 64:12\n" /* wooddoorblock */ + "j:128: 7\n" /* sandstonestairs */ + "k: 50: 3\n" /* torch */ + "l: 50: 4\n" /* torch */ "m: 19: 0\n" /* sponge */ - "n:128: 5\n" /* sandstonestairs */ - "o:128: 4\n" /* sandstonestairs */ - "p: 50: 1\n" /* torch */, + "n:128: 6\n" /* sandstonestairs */ + "o:128: 5\n" /* sandstonestairs */ + "p:128: 4\n" /* sandstonestairs */ + "q: 50: 1\n" /* torch */, // Block data: // Level 0 @@ -1310,7 +1311,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 2 */ ".d..........d." /* 3 */ ".d..........d." /* 4 */ ".d..........d." - /* 5 */ ".ddddfddd...d." + /* 5 */ ".ddddgddd...d." /* 6 */ "........d...d." /* 7 */ "mmmmmmm.d...d." /* 8 */ "mmmmmmm.d...d." @@ -1322,49 +1323,49 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ ".............." - /* 1 */ ".dggdggdhdggd." - /* 2 */ ".g..........g." - /* 3 */ ".g..........g." - /* 4 */ ".g..........d." - /* 5 */ ".dggdhdgg...g." - /* 6 */ "........g...g." + /* 1 */ ".dhhdhhdidhhd." + /* 2 */ ".h..........h." + /* 3 */ ".h..........h." + /* 4 */ ".h..........d." + /* 5 */ ".dhhdidhh...h." + /* 6 */ "........h...h." /* 7 */ "mmmmmmm.d...d." - /* 8 */ "mmmmmmm.g...g." - /* 9 */ "mmmmmmm.g...g." - /* 10 */ "mmmmmmm.dgggd." + /* 8 */ "mmmmmmm.h...h." + /* 9 */ "mmmmmmm.h...h." + /* 10 */ "mmmmmmm.dhhhd." /* 11 */ "mmmmmmm......." // Level 3 /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ "bbbbbbbbbbbbbb" - /* 1 */ "iddddddddddddc" - /* 2 */ ".d.....j.j..dc" + /* 1 */ "jddddddddddddc" + /* 2 */ ".d.....k.k..dc" /* 3 */ ".d..........dc" - /* 4 */ ".d..k.k.....dc" - /* 5 */ "ldddddddd...dc" + /* 4 */ ".d..l.l.....dc" + /* 5 */ "ndddddddd...dc" /* 6 */ "eeeeeeead...dc" /* 7 */ "mmmmmmmad...dc" /* 8 */ "mmmmmmmad...dc" /* 9 */ "mmmmmmmad...dc" /* 10 */ "mmmmmmmadddddc" - /* 11 */ "mmmmmmman...oc" + /* 11 */ "mmmmmmmao...pc" // Level 4 /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ ".............." /* 1 */ "bbbbbbbbbbbbb." - /* 2 */ "idddddddddddc." - /* 3 */ ".dp........dc." - /* 4 */ "lddddddddd.dc." + /* 2 */ "jdddddddddddc." + /* 3 */ ".dq........dc." + /* 4 */ "nddddddddd.dc." /* 5 */ "eeeeeeeead.dc." /* 6 */ "........ad.dc." /* 7 */ "mmmmmmm.ad.dc." /* 8 */ "mmmmmmm.ad.dc." - /* 9 */ "mmmmmmm.adkdc." + /* 9 */ "mmmmmmm.adldc." /* 10 */ "mmmmmmm.adddc." - /* 11 */ "mmmmmmm.an.oc." + /* 11 */ "mmmmmmm.ao.pc." // Level 5 /* z\x* 1111 */ @@ -1383,7 +1384,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 11 */ "mmmmmmm..adc..", // Connectors: - "", + "-1: 8, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1424,19 +1425,18 @@ const cPrefab::sDef g_SandVillagePrefabs[] = "c:128: 1\n" /* sandstonestairs */ "d: 24: 0\n" /* sandstone */ "e:128: 3\n" /* sandstonestairs */ - "f: 64: 5\n" /* wooddoorblock */ - "g: 64: 7\n" /* wooddoorblock */ - "h:102: 0\n" /* glasspane */ - "i: 64:12\n" /* wooddoorblock */ - "j:128: 7\n" /* sandstonestairs */ - "k: 50: 3\n" /* torch */ - "l: 50: 2\n" /* torch */ + "f: 64: 7\n" /* wooddoorblock */ + "g:102: 0\n" /* glasspane */ + "h: 64:12\n" /* wooddoorblock */ + "i:128: 7\n" /* sandstonestairs */ + "j: 50: 3\n" /* torch */ + "k: 50: 2\n" /* torch */ + "l: 50: 4\n" /* torch */ "m: 19: 0\n" /* sponge */ - "n: 50: 4\n" /* torch */ - "o:128: 6\n" /* sandstonestairs */ - "p: 50: 1\n" /* torch */ - "q:128: 5\n" /* sandstonestairs */ - "r:128: 4\n" /* sandstonestairs */, + "n:128: 6\n" /* sandstonestairs */ + "o: 50: 1\n" /* torch */ + "p:128: 5\n" /* sandstonestairs */ + "q:128: 4\n" /* sandstonestairs */, // Block data: // Level 0 @@ -1465,7 +1465,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 4 */ ".d..........d." /* 5 */ ".d..........d." /* 6 */ ".d..........d." - /* 7 */ ".ddddgd.....d." + /* 7 */ ".ddddfd.....d." /* 8 */ "......d.....d." /* 9 */ "mmmmm.d.....d." /* 10 */ "mmmmm.ddddddd." @@ -1475,49 +1475,49 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ ".............." - /* 1 */ ".dhhdidhhdhhd." - /* 2 */ ".h..........h." - /* 3 */ ".h..........h." + /* 1 */ ".dggdhdggdggd." + /* 2 */ ".g..........g." + /* 3 */ ".g..........g." /* 4 */ ".d..........d." - /* 5 */ ".h..........h." - /* 6 */ ".h..........h." - /* 7 */ ".dhhdid.....d." - /* 8 */ "......h.....h." - /* 9 */ "mmmmm.h.....h." - /* 10 */ "mmmmm.dhhdhhd." + /* 5 */ ".g..........g." + /* 6 */ ".g..........g." + /* 7 */ ".dggdhd.....d." + /* 8 */ "......g.....g." + /* 9 */ "mmmmm.g.....g." + /* 10 */ "mmmmm.dggdggd." /* 11 */ "mmmmm........." // Level 3 /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ "bbbbbbbbbbbbbb" - /* 1 */ "jddddddddddddc" - /* 2 */ ".d..k.k.....dc" + /* 1 */ "iddddddddddddc" + /* 2 */ ".d..j.j.....dc" /* 3 */ ".d..........dc" - /* 4 */ ".d.........ldc" + /* 4 */ ".d.........kdc" /* 5 */ ".d..........dc" - /* 6 */ ".d..n.n.....dc" - /* 7 */ "oddddddp...ldc" + /* 6 */ ".d..l.l.....dc" + /* 7 */ "nddddddo...kdc" /* 8 */ "eeeeead.....dc" /* 9 */ "mmmmmad.....dc" /* 10 */ "mmmmmadddddddc" - /* 11 */ "mmmmmaq.....rc" + /* 11 */ "mmmmmap.....qc" // Level 4 /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ ".............." /* 1 */ "bbbbbbbbbbbbc." - /* 2 */ "jdddddddddddc." + /* 2 */ "idddddddddddc." /* 3 */ ".d.........dc." /* 4 */ ".d.........dc." /* 5 */ ".d.........dc." - /* 6 */ "oddddddd...dc." + /* 6 */ "nddddddd...dc." /* 7 */ "eeeeeead...dc." /* 8 */ "......ad...dc." /* 9 */ "mmmmm.ad...dc." /* 10 */ "mmmmm.adddddc." - /* 11 */ "mmmmm.aq...rc." + /* 11 */ "mmmmm.ap...qc." // Level 5 /* z\x* 1111 */ @@ -1525,15 +1525,15 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 0 */ ".............." /* 1 */ ".............." /* 2 */ "bbbbbbbbbbbb.." - /* 3 */ "jddddddddddc.." + /* 3 */ "iddddddddddc.." /* 4 */ ".d........dc.." - /* 5 */ "odddddddd.dc.." + /* 5 */ "ndddddddd.dc.." /* 6 */ "eeeeeeeed.dc.." /* 7 */ ".......ad.dc.." /* 8 */ ".......ad.dc.." /* 9 */ "mmmmm..ad.dc.." /* 10 */ "mmmmm..adddc.." - /* 11 */ "mmmmm..aq.rc.." + /* 11 */ "mmmmm..ap.qc.." // Level 6 /* z\x* 1111 */ @@ -1552,7 +1552,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 11 */ "mmmmm...adc...", // Connectors: - "", + "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1619,7 +1619,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 6 */ "d........d", // Connectors: - "", + "-1: 0, 0, 3: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1661,8 +1661,8 @@ const cPrefab::sDef g_SandVillagePrefabs[] = "d: 50: 5\n" /* torch */ "e: 26:10\n" /* bedblock */ "f: 26: 2\n" /* bedblock */ - "g: 64: 3\n" /* wooddoorblock */ - "h: 64: 8\n" /* wooddoorblock */ + "g: 64: 5\n" /* wooddoorblock */ + "h: 64:12\n" /* wooddoorblock */ "m: 19: 0\n" /* sponge */, // Block data: @@ -1712,7 +1712,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 5 */ ".....", // Connectors: - "", + "-1: 2, 0, 4: 3\n" /* Type -1, direction Z+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1853,7 +1853,10 @@ const cPrefab::sDef g_SandVillageStartingPrefabs[] = /* 3 */ "bbbb", // Connectors: - "", + "1: 2, 8, 0: 2\n" /* Type 1, direction Z- */ + "1: 0, 8, 1: 4\n" /* Type 1, direction X- */ + "1: 1, 8, 3: 3\n" /* Type 1, direction Z+ */ + "1: 3, 8, 2: 5\n" /* Type 1, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index 3d89d7aa2..3358bc531 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -7,6 +7,7 @@ #include "VillageGen.h" #include "Prefabs/PlainsVillagePrefabs.h" #include "Prefabs/SandVillagePrefabs.h" +#include "PieceGenerator.h" @@ -19,18 +20,79 @@ the grid's cells. Each cell checks the biomes in an entire chunk around it, only biomes are village-friendly. If yes, the entire village structure is built for that cell. If not, the cell is left village-less. -A village is generated starting by its well. The well is placed in the grid's origin point. Then a set of -random lengths roads is generated - 4 roads going from the well, then at the end of each road another set of -roads, crossing them perpendicular, then at the end of those another set, up to a set maximum branching -depth. The roads are placed in a T or L shape, with the old road being the center stem of the T. Roads avoid -crossing each other and going further away from the well than the maximum block size of the village. -Finally, houses are places along the roads, avoiding collisions with already-existing items. +A village is generated using the regular BFS piece generator. The well piece is used as the starting piece, +the roads and houses are then used as the following pieces. Only the houses are read from the prefabs, +though, the roads are generated by code and their content is ignored. A special subclass of the cPiecePool +class is used, so that the roads connect to each other and to the well only in predefined manners. -When the village is about to be drawn into a chunk, it queries the heights for each item intersecting the -chunk. The prefabs are shifted so that their pivot points lie on the surface, and the roads are drawn +The well has connectors of type "1". The houses have connectors of type "-1". The roads have connectors of +both types, type "-1" at the far ends and type "1" on the long edges. + +When the village is about to be drawn into a chunk, it queries the heights for each piece intersecting the +chunk. The pieces are shifted so that their pivot points lie on the surface, and the roads are drawn directly by turning the surface blocks into gravel / sandstone. */ +class cVillagePiecePool : + public cPrefabPiecePool +{ + typedef cPrefabPiecePool super; +public: + cVillagePiecePool( + const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs, + const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs + ) : + super(a_PieceDefs, a_NumPieceDefs, a_StartingPieceDefs, a_NumStartingPieceDefs) + { + // Add the road piece: + cBlockArea BA; + BA.Create(5, 1, 3, cBlockArea::baTypes | cBlockArea::baMetas); + BA.Fill(cBlockArea::baTypes | cBlockArea::baMetas, E_BLOCK_GRAVEL, 0); + cPrefab * RoadPiece = new cPrefab(BA, 7); + RoadPiece->AddConnector(0, 0, 1, BLOCK_FACE_XM, -1); + RoadPiece->AddConnector(4, 0, 1, BLOCK_FACE_XP, -1); + RoadPiece->AddConnector(4, 0, 1, BLOCK_FACE_XP, 1); + RoadPiece->AddConnector(1, 0, 0, BLOCK_FACE_ZM, 1); + RoadPiece->AddConnector(3, 0, 0, BLOCK_FACE_ZM, 1); + RoadPiece->AddConnector(1, 0, 2, BLOCK_FACE_ZP, 1); + RoadPiece->AddConnector(3, 0, 2, BLOCK_FACE_ZP, 1); + RoadPiece->SetAddWeightIfSame(10000); + m_AllPieces.push_back(RoadPiece); + m_PiecesByConnector[-1].push_back(RoadPiece); + m_PiecesByConnector[1].push_back(RoadPiece); + } + + + // cPrefabPiecePool overrides: + virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override + { + // Only roads are allowed to connect to the well: + if ((a_PlacedPiece.GetDepth() == 0) && (a_NewPiece.GetSize().y != 1)) + { + return 0; + } + + // Roads cannot branch T-wise: + if ( + (a_PlacedPiece.GetPiece().GetSize().y == 1) && // Connecting to a road + ( + (a_ExistingConnector.m_Direction == BLOCK_FACE_ZP) || + (a_ExistingConnector.m_Direction == BLOCK_FACE_ZM) + ) && // Through the long-edge connector + (a_NewPiece.GetSize().y == 1) // And the new piece is a road + ) + { + return 0; + } + + return ((const cPrefab &)a_NewPiece).GetPieceWeight(a_PlacedPiece, a_ExistingConnector); + } +} ; + + + + + class cVillageGen::cVillage : public cGridStructGen::cStructure { @@ -53,44 +115,11 @@ public: m_Prefabs(a_Prefabs), m_HeightGen(a_HeightGen) { - PlaceWell(); - BuildRoads(a_MaxRoadDepth); - PlaceHouses(); + cBFSPieceGenerator pg(m_Prefabs, a_Seed); + pg.PlacePieces(a_OriginX, 10, a_OriginZ, a_MaxRoadDepth + 1, m_Pieces); } protected: - class cItem - { - public: - /* The position of the item, X/Z-wise: */ - int m_MinX, m_MaxX, m_MinZ, m_MaxZ; - - /** The prefab to use. If NULL, this is a road. */ - cPrefab * m_Prefab; - - /** Number of rotations that should be applied to the prefab. */ - int m_NumRotations; - - /* The bottom of the prefab. Only valid if the item is a prefab, not valid for roads. */ - int m_BaseY; - - /** Creates a new item with the specified parameters. - m_BaseY is set to -1 and will be adjusted later on when drawing. */ - cItem(int a_MinX, int a_MaxX, int a_MinZ, int a_MaxZ, cPrefab * a_Prefab, int a_NumRotations) : - m_MinX(a_MinX), - m_MaxX(a_MaxX), - m_MinZ(a_MinZ), - m_MaxZ(a_MaxZ), - m_Prefab(a_Prefab), - m_NumRotations(a_NumRotations), - m_BaseY(-1) - { - } - } ; - typedef SharedPtr cItemPtr; - typedef std::vector cItemPtrs; - - /** Seed for the random functions */ int m_Seed; @@ -109,61 +138,8 @@ protected: /** The underlying height generator, used for placing the structures on top of the terrain. */ cTerrainHeightGen & m_HeightGen; - /** The items that are generated in the village (houses, roads). */ - cItemPtrs m_Items; - - - /** Places the well at the center of the village */ - void PlaceWell(void) - { - // Pick a prefab from the starting pieces: - cPieces StartingPieces = ((cPiecePool &)m_Prefabs).GetStartingPieces(); - ASSERT(!StartingPieces.empty()); - int TotalWeight = 0; - for (cPieces::const_iterator itr = StartingPieces.begin(), end = StartingPieces.end(); itr != end; ++itr) - { - TotalWeight += ((const cPrefab *)(*itr))->GetDefaultWeight(); - } - ASSERT(TotalWeight > 0); - int rnd = (m_Noise.IntNoise2DInt(m_OriginX, m_OriginZ) / 7) % TotalWeight; - cPiece * WellPiece = StartingPieces[0]; - for (cPieces::const_iterator itr = StartingPieces.begin(), end = StartingPieces.end(); itr != end; ++itr) - { - rnd -= ((const cPrefab *)(*itr))->GetDefaultWeight(); - if (rnd <= 0) - { - WellPiece = *itr; - break; - } - } - ASSERT(WellPiece != NULL); - - // Pick a rotation: - // TODO - int NumRotations = 0; - Vector3i Size = WellPiece->GetSize(); - - // Put the well in the placed items array: - m_Items.push_back(cItemPtr(new cItem(m_OriginX, m_OriginX + Size.x, m_OriginZ, m_OriginZ + Size.z, (cPrefab *)WellPiece, NumRotations))); - } - - - /** Places the roads going from the well outwards. */ - void BuildRoads(int a_MaxRoadDepth) - { - /* - ASSERT(m_Items.size() == 1); - const cItem & Well = *m_Items[0]; - */ - // TODO - } - - - /** Places houses along the roads. */ - void PlaceHouses(void) - { - // TODO - } + /** The village pieces, placed by the generator. */ + cPlacedPieces m_Pieces; // cGrdStructGen::cStructure overrides: @@ -173,6 +149,11 @@ protected: // Iterate over all items // Each intersecting prefab is placed on ground (if not already placed), then drawn // Each intersecting road is drawn by replacing top soil blocks with gravel / sandstone blocks + for (cPlacedPieces::const_iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr) + { + const cPrefab & Prefab = (const cPrefab &)((*itr)->GetPiece()); + Prefab.Draw(a_Chunk, *itr); + } // for itr - m_PlacedPieces[] } } ; @@ -183,15 +164,20 @@ protected: /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cVillageGen: -cPrefabPiecePool cVillageGen::m_SandVillage (g_SandVillagePrefabs, g_SandVillagePrefabsCount, g_SandVillageStartingPrefabs, g_SandVillageStartingPrefabsCount); -cPrefabPiecePool cVillageGen::m_PlainsVillage(g_PlainsVillagePrefabs, g_PlainsVillagePrefabsCount, g_PlainsVillageStartingPrefabs, g_PlainsVillageStartingPrefabsCount); +/** The prefabs for the sand village. */ +static cVillagePiecePool g_SandVillage (g_SandVillagePrefabs, g_SandVillagePrefabsCount, g_SandVillageStartingPrefabs, g_SandVillageStartingPrefabsCount); + +/** The prefabs for the plains village. */ +static cVillagePiecePool g_PlainsVillage(g_PlainsVillagePrefabs, g_PlainsVillagePrefabsCount, g_PlainsVillageStartingPrefabs, g_PlainsVillageStartingPrefabsCount); -cVillageGen::cVillageGen(int a_Seed, int a_GridSize, int a_MaxRoadDepth, int a_MaxSize, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen) : +cVillageGen::cVillageGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen) : super(a_Seed, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 100), + m_MaxDepth(a_MaxDepth), + m_MaxSize(a_MaxSize), m_BiomeGen(a_BiomeGen), m_HeightGen(a_HeightGen) { @@ -211,7 +197,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ // Check if all the biomes are village-friendly: // If just one is not, no village is created, because it's likely that an unfriendly biome is too close - cPrefabPiecePool * VillagePrefabs = NULL; + cVillagePiecePool * VillagePrefabs = NULL; for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++) { switch (Biomes[i]) @@ -220,7 +206,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ case biDesertM: { // These biomes allow sand villages - VillagePrefabs = &m_SandVillage; + VillagePrefabs = &g_SandVillage; break; } case biPlains: @@ -229,7 +215,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ case biSunflowerPlains: { // These biomes allow plains-style villages - VillagePrefabs = &m_PlainsVillage; + VillagePrefabs = &g_PlainsVillage; break; } default: @@ -245,7 +231,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ { return cStructurePtr(); } - return cStructurePtr(new cVillage(m_Seed, a_OriginX, a_OriginZ, m_MaxRoadDepth, m_MaxSize, *VillagePrefabs, m_HeightGen)); + return cStructurePtr(new cVillage(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, *VillagePrefabs, m_HeightGen)); } diff --git a/src/Generating/VillageGen.h b/src/Generating/VillageGen.h index acbd76881..c6f8f024a 100644 --- a/src/Generating/VillageGen.h +++ b/src/Generating/VillageGen.h @@ -21,19 +21,13 @@ class cVillageGen : { typedef cGridStructGen super; public: - cVillageGen(int a_Seed, int a_GridSize, int a_MaxRoadDepth, int a_MaxSize, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen); + cVillageGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen); protected: class cVillage; // fwd: VillageGen.cpp - /** The prefabs for the sand village. We're not exactly using the cPiecePool functionality, only the containment. */ - static cPrefabPiecePool m_SandVillage; - - /** The prefabs for the plains village. We're not exactly using the cPiecePool functionality, only the containment. */ - static cPrefabPiecePool m_PlainsVillage; - - /** Maximum number of roads generated one from another (tree depth). */ - int m_MaxRoadDepth; + /** Maximum depth of the generator tree*/ + int m_MaxDepth; /** Maximum size, in X/Z blocks, of the village (radius from the origin) */ int m_MaxSize; -- cgit v1.2.3 From 34e5f0c16422f93d3f8f0f802522fa113fa9aa20 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 15 May 2014 10:43:54 +0200 Subject: Changed village road generation to use multiple prefabs. --- src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 8 ++-- src/Generating/Prefabs/SandVillagePrefabs.cpp | 8 ++-- src/Generating/VillageGen.cpp | 61 ++++++++++++------------- 3 files changed, 38 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index 508f0d3b6..06b1395c5 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -3691,10 +3691,10 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = /* 3 */ "bbbb", // Connectors: - "1: 1, 9, 3: 3\n" /* Type 1, direction Z+ */ - "1: 2, 9, 0: 2\n" /* Type 1, direction Z- */ - "1: 0, 9, 1: 4\n" /* Type 1, direction X- */ - "1: 3, 9, 2: 5\n" /* Type 1, direction X+ */, + "2: 1, 9, 3: 3\n" /* Type 2, direction Z+ */ + "2: 2, 9, 0: 2\n" /* Type 2, direction Z- */ + "2: 0, 9, 1: 4\n" /* Type 2, direction X- */ + "2: 3, 9, 2: 5\n" /* Type 2, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ diff --git a/src/Generating/Prefabs/SandVillagePrefabs.cpp b/src/Generating/Prefabs/SandVillagePrefabs.cpp index 51411dea2..8460ee5f7 100644 --- a/src/Generating/Prefabs/SandVillagePrefabs.cpp +++ b/src/Generating/Prefabs/SandVillagePrefabs.cpp @@ -1853,10 +1853,10 @@ const cPrefab::sDef g_SandVillageStartingPrefabs[] = /* 3 */ "bbbb", // Connectors: - "1: 2, 8, 0: 2\n" /* Type 1, direction Z- */ - "1: 0, 8, 1: 4\n" /* Type 1, direction X- */ - "1: 1, 8, 3: 3\n" /* Type 1, direction Z+ */ - "1: 3, 8, 2: 5\n" /* Type 1, direction X+ */, + "2: 2, 8, 0: 2\n" /* Type 2, direction Z- */ + "2: 0, 8, 1: 4\n" /* Type 2, direction X- */ + "2: 1, 8, 3: 3\n" /* Type 2, direction Z+ */ + "2: 3, 8, 2: 5\n" /* Type 2, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index 3358bc531..b514a90cd 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -44,43 +44,42 @@ public: ) : super(a_PieceDefs, a_NumPieceDefs, a_StartingPieceDefs, a_NumStartingPieceDefs) { - // Add the road piece: - cBlockArea BA; - BA.Create(5, 1, 3, cBlockArea::baTypes | cBlockArea::baMetas); - BA.Fill(cBlockArea::baTypes | cBlockArea::baMetas, E_BLOCK_GRAVEL, 0); - cPrefab * RoadPiece = new cPrefab(BA, 7); - RoadPiece->AddConnector(0, 0, 1, BLOCK_FACE_XM, -1); - RoadPiece->AddConnector(4, 0, 1, BLOCK_FACE_XP, -1); - RoadPiece->AddConnector(4, 0, 1, BLOCK_FACE_XP, 1); - RoadPiece->AddConnector(1, 0, 0, BLOCK_FACE_ZM, 1); - RoadPiece->AddConnector(3, 0, 0, BLOCK_FACE_ZM, 1); - RoadPiece->AddConnector(1, 0, 2, BLOCK_FACE_ZP, 1); - RoadPiece->AddConnector(3, 0, 2, BLOCK_FACE_ZP, 1); - RoadPiece->SetAddWeightIfSame(10000); - m_AllPieces.push_back(RoadPiece); - m_PiecesByConnector[-1].push_back(RoadPiece); - m_PiecesByConnector[1].push_back(RoadPiece); + // Add the road pieces: + for (int len = 19; len < 60; len += 8) + { + cBlockArea BA; + BA.Create(len, 1, 3, cBlockArea::baTypes | cBlockArea::baMetas); + BA.Fill(cBlockArea::baTypes | cBlockArea::baMetas, E_BLOCK_GRAVEL, 0); + cPrefab * RoadPiece = new cPrefab(BA, 1); + RoadPiece->AddConnector(0, 0, 1, BLOCK_FACE_XM, -2); + RoadPiece->AddConnector(len - 1, 0, 1, BLOCK_FACE_XP, -2); + + // Add the road connectors: + for (int x = 1; x < len; x += 8) + { + RoadPiece->AddConnector(x, 0, 0, BLOCK_FACE_ZM, 2); + RoadPiece->AddConnector(x, 0, 2, BLOCK_FACE_ZP, 2); + } + + // Add the buildings connectors: + for (int x = 5; x < len; x += 8) + { + RoadPiece->AddConnector(x, 0, 0, BLOCK_FACE_ZM, 1); + RoadPiece->AddConnector(x, 0, 2, BLOCK_FACE_ZP, 1); + } + m_AllPieces.push_back(RoadPiece); + m_PiecesByConnector[-2].push_back(RoadPiece); + m_PiecesByConnector[1].push_back(RoadPiece); + m_PiecesByConnector[2].push_back(RoadPiece); + } // for len - roads of varying length } // cPrefabPiecePool overrides: virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override { - // Only roads are allowed to connect to the well: - if ((a_PlacedPiece.GetDepth() == 0) && (a_NewPiece.GetSize().y != 1)) - { - return 0; - } - - // Roads cannot branch T-wise: - if ( - (a_PlacedPiece.GetPiece().GetSize().y == 1) && // Connecting to a road - ( - (a_ExistingConnector.m_Direction == BLOCK_FACE_ZP) || - (a_ExistingConnector.m_Direction == BLOCK_FACE_ZM) - ) && // Through the long-edge connector - (a_NewPiece.GetSize().y == 1) // And the new piece is a road - ) + // Roads cannot branch T-wise (appending -2 connector to a +2 connector): + if ((a_ExistingConnector.m_Type == 2) && (a_PlacedPiece.GetDepth() > 0)) { return 0; } -- cgit v1.2.3 From 56f7ad2cd9f1bfd69502918ebe760748e453959d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 15 May 2014 10:44:08 +0200 Subject: Changed village generator defaults to more reasonable values. --- src/Generating/ComposableGenerator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 1bb836684..f264599c9 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -408,8 +408,8 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "Villages") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "VillageGridSize", 256); - int MaxDepth = a_IniFile.GetValueSetI("Generator", "VillageMaxDepth", 7); + int GridSize = a_IniFile.GetValueSetI("Generator", "VillageGridSize", 384); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "VillageMaxDepth", 3); int MaxSize = a_IniFile.GetValueSetI("Generator", "VillageMaxSize", 128); m_FinishGens.push_back(new cVillageGen(Seed, GridSize, MaxDepth, MaxSize, *m_BiomeGen, *m_HeightGen)); } -- cgit v1.2.3 From 70b0547499c4343e3071a54e3c093712669a3a8f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 15 May 2014 16:03:45 +0200 Subject: Fixed a NULL ptr failure in GridStructGen. When the descendant generator returned a NULL structure, the generator would crash. Now it uses a special cEmptyStructure class instead. --- src/Generating/GridStructGen.cpp | 35 ++++++++++++++++++++++++++++++++++- src/Generating/GridStructGen.h | 16 ++++++++-------- 2 files changed, 42 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp index 3bbc89054..23946e2e9 100644 --- a/src/Generating/GridStructGen.cpp +++ b/src/Generating/GridStructGen.cpp @@ -9,6 +9,34 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cEmptyStructure: + +/** A cStructure descendant representing an empty structure. +Used when the generator descended from cGridStructGen doesn't return any structure, to keep at least the +Origin coords so that the structure isn't queried over and over again. */ +class cEmptyStructure : + public cGridStructGen::cStructure +{ + typedef cGridStructGen::cStructure super; + +public: + cEmptyStructure(int a_OriginX, int a_OriginZ) : + super(a_OriginX, a_OriginZ) + { + } + +protected: + virtual void DrawIntoChunk(cChunkDesc & a_ChunkDesc) override + { + // Do nothing + } +} ; + + + + + cGridStructGen::cGridStructGen( int a_Seed, int a_GridSizeX, int a_GridSizeZ, @@ -81,7 +109,12 @@ void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructur } // for itr - a_Structures[] if (!Found) { - a_Structures.push_back(CreateStructure(OriginX, OriginZ)); + cStructurePtr Structure = CreateStructure(OriginX, OriginZ); + if (Structure.get() == NULL) + { + Structure.reset(new cEmptyStructure(OriginX, OriginZ)); + } + a_Structures.push_back(Structure); } } // for z } // for x diff --git a/src/Generating/GridStructGen.h b/src/Generating/GridStructGen.h index 234cc75c5..630a5e44e 100644 --- a/src/Generating/GridStructGen.h +++ b/src/Generating/GridStructGen.h @@ -39,14 +39,6 @@ class cGridStructGen : public cFinishGen { public: - cGridStructGen( - int a_Seed, - int a_GridSizeX, int a_GridSizeZ, - int a_MaxStructureSizeX, int a_MaxStructureSizeZ, - size_t a_MaxCacheSize - ); - -protected: /** Represents a single structure that occupies the grid point. Knows how to draw itself into a chunk. */ class cStructure { @@ -75,6 +67,14 @@ protected: typedef std::list cStructurePtrs; + cGridStructGen( + int a_Seed, + int a_GridSizeX, int a_GridSizeZ, + int a_MaxStructureSizeX, int a_MaxStructureSizeZ, + size_t a_MaxCacheSize + ); + +protected: /** Seed for generating the semi-random grid. */ int m_Seed; -- cgit v1.2.3 From 6c5ff597bbbb3abd2985eda6bf35ea2d98cf69a4 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 15 May 2014 19:58:48 +0200 Subject: Move radius check. --- src/ClientHandle.cpp | 65 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 9238418a4..cf9d0bfeb 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -815,6 +815,16 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB return; } + if ( + (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || + (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || + (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) + ) + { + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + return; + } + cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); if (PlgMgr->CallHookPlayerLeftClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status)) { @@ -927,6 +937,16 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc return; } + if ( + (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || + (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || + (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) + ) + { + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, this); + return; + } + // Set the last digging coords to the block being dug, so that they can be checked in DIG_FINISHED to avoid dig/aim bug in the client: m_HasStartedDigging = true; m_LastDigBlockX = a_BlockX; @@ -1000,6 +1020,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo FinishDigAnimation(); + cWorld * World = m_Player->GetWorld(); cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem()); if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta)) @@ -1008,24 +1029,12 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); return; } - + if (a_OldBlock == E_BLOCK_AIR) { LOGD("Dug air - what the function?"); return; } - - cWorld * World = m_Player->GetWorld(); - - if ( - (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || - (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || - (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) - ) - { - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - return; - } ItemHandler->OnBlockDestroyed(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ); // The ItemHandler is also responsible for spawning the pickups @@ -1078,7 +1087,23 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e ); cWorld * World = m_Player->GetWorld(); - + + if ( + (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || + (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || + (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) + ) + { + if (a_BlockFace != BLOCK_FACE_NONE) + { + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things + m_Player->GetInventory().SendEquippedSlot(); + } + return; + } + cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); if (PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) { @@ -1092,7 +1117,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e { AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); //2 block high things + World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things m_Player->GetInventory().SendEquippedSlot(); } return; @@ -1202,16 +1227,6 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e // The block is being placed outside the world, ignore this packet altogether (#128) return; } - - if ( - (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || - (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || - (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) - ) - { - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - return; - } World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedBlockMeta); -- cgit v1.2.3 From 28a9c16db2212d57cca823a2b122530fdb70f210 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 15 May 2014 19:59:52 +0200 Subject: Fix compile error. --- src/ClientHandle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index cf9d0bfeb..0c897374b 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -943,7 +943,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) ) { - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, this); + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); return; } -- cgit v1.2.3 From 5724dcc2c199a5d7aec1bf60a160106770a2a63a Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Fri, 16 May 2014 19:33:57 +0200 Subject: Fixed anvil exp removing --- src/UI/SlotArea.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 788974f9c..8833a767a 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -760,7 +760,7 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player) { if (!a_Player.IsGameModeCreative()) { - a_Player.DeltaExperience(cPlayer::XpForLevel(m_MaximumCost)); + a_Player.DeltaExperience(-cPlayer::XpForLevel(m_MaximumCost)); } SetSlot(0, a_Player, cItem()); -- cgit v1.2.3 From 989312c4e7f517ae324e857cb255211e3fd8bb06 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 16 May 2014 22:04:19 +0200 Subject: Add more move checks - Invalid X/Y/Z/Stance check (std::isnan) - Illegal stance - Illegal position (32.000.000 is the world size) --- src/ClientHandle.cpp | 74 ++++++++++++++++++++++++++++++++++++++++------------ src/ClientHandle.h | 2 +- 2 files changed, 59 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 0c897374b..41b5d1626 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -582,16 +582,37 @@ void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, return; } - /* - // TODO: Invalid stance check - if ((a_PosY >= a_Stance) || (a_Stance > a_PosY + 1.65)) + if (m_Player->GetHealth() <= 0) { - LOGD("Invalid stance"); - SendPlayerMoveLook(); + // The player is dead. He can't move :D return; } - */ - + + if (std::isnan(a_PosX) || std::isnan(a_PosY) || std::isnan(a_PosZ) || std::isnan(a_Stance)) + { + LOGWARN("%s was caught trying to crash the server with an invalid position.", m_Player->GetName().c_str()); + Kick("Nope!"); + return; + } + + // Invalid stance check + if (!m_Player->IsInBed()) + { + double Difference = a_Stance - a_PosY; + if ((Difference > 1.65) || (Difference < 1.0)) + { + Kick("Illegal stance!"); + LOGWARN("%s had an illegal stance: %f", m_Player->GetName().c_str(), a_Stance); + return; + } + } + + if ((std::abs(a_PosX) > 32000000.0) || (std::abs(a_PosZ) > 32000000.0)) + { + Kick("Illegal position!"); + return; + } + // If the player has moved too far, "repair" them: Vector3d Pos(a_PosX, a_PosY, a_PosZ); if ((m_Player->GetPosition() - Pos).SqrLength() > 100 * 100) @@ -1388,7 +1409,7 @@ void cClientHandle::HandlePlayerLook(float a_Rotation, float a_Pitch, bool a_IsO -void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround) +void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Yaw, float a_Pitch, bool a_IsOnGround) { if ((m_Player == NULL) || (m_State != csPlaying)) { @@ -1396,21 +1417,42 @@ void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_ return; } - /* - // TODO: Invalid stance check - if ((a_PosY >= a_Stance) || (a_Stance > a_PosY + 1.65)) + if (m_Player->GetHealth() <= 0) { - LOGD("Invalid stance"); - SendPlayerMoveLook(); + // The player is dead. He can't move :D + return; + } + + if (std::isnan(a_PosX) || std::isnan(a_PosY) || std::isnan(a_PosZ) || std::isnan(a_Stance)) + { + LOGWARN("%s was caught trying to crash the server with an invalid position.", m_Player->GetName().c_str()); + Kick("Nope!"); + return; + } + + // Invalid stance check + if (!m_Player->IsInBed()) + { + double Difference = a_Stance - a_PosY; + if ((Difference > 1.65) || (Difference < 1.0)) + { + Kick("Illegal stance!"); + LOGWARN("%s had an illegal stance: %f", m_Player->GetName().c_str(), a_Stance); + return; + } + } + + if ((std::abs(a_PosX) > 32000000.0) || (std::abs(a_PosZ) > 32000000.0)) + { + Kick("Illegal position!"); return; } - */ m_Player->MoveTo(Vector3d(a_PosX, a_PosY, a_PosZ)); m_Player->SetStance (a_Stance); m_Player->SetTouchGround(a_IsOnGround); - m_Player->SetHeadYaw (a_Rotation); - m_Player->SetYaw (a_Rotation); + m_Player->SetHeadYaw (a_Yaw); + m_Player->SetYaw (a_Yaw); m_Player->SetPitch (a_Pitch); } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 85d348eee..940fb786a 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -223,7 +223,7 @@ public: void HandlePing (void); void HandlePlayerAbilities (bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed); void HandlePlayerLook (float a_Rotation, float a_Pitch, bool a_IsOnGround); - void HandlePlayerMoveLook (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround); // While m_bPositionConfirmed (normal gameplay) + void HandlePlayerMoveLook (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Yaw, float a_Pitch, bool a_IsOnGround); // While m_bPositionConfirmed (normal gameplay) void HandlePlayerPos (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround); void HandlePluginMessage (const AString & a_Channel, const AString & a_Message); void HandleRespawn (void); -- cgit v1.2.3 From fc5c3abcba9153196727a77e726bb0b37d5c7450 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 17 May 2014 02:26:44 +0200 Subject: Updated PlainsVillage prefabs to the latest Gallery contents. --- src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 5283 +++++++++++++---------- 1 file changed, 2955 insertions(+), 2328 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index 06b1395c5..863720ab4 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -16,165 +16,246 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Forge: - // The data has been exported from the gallery Plains, area index 51, ID 102, created by Aloe_vera + // BigPlantBed: + // The data has been exported from the gallery Plains, area index 26, ID 70, created by Taugrammaton { // Size: - 12, 8, 11, // SizeX = 12, SizeY = 8, SizeZ = 11 + 13, 4, 12, // SizeX = 13, SizeY = 4, SizeZ = 12 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 11, 7, 10, // MaxX, MaxY, MaxZ + 12, 3, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 17: 0\n" /* tree */ - "f: 5: 0\n" /* wood */ - "g: 64: 6\n" /* wooddoorblock */ - "h: 10: 0\n" /* lava */ - "i: 54: 2\n" /* chest */ - "j: 61: 2\n" /* furnace */ - "k:102: 0\n" /* glasspane */ - "l: 64:12\n" /* wooddoorblock */ + "a: 3: 0\n" /* dirt */ + "b: 5: 0\n" /* wood */ + "c: 13: 0\n" /* gravel */ + "d: 17: 0\n" /* tree */ + "e: 60: 7\n" /* tilleddirt */ + "f: 8: 0\n" /* water */ + "g: 85: 0\n" /* fence */ + "h: 59: 7\n" /* crops */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "aaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaaaa" + /* 9 */ "aaaaaaaaaaaaa" + /* 10 */ "aaaaaaaaaaaaa" + /* 11 */ "aaaaaaaaaaaaa" + + // Level 1 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "bbbbbbbbbbbbb" + /* 1 */ "bcccccccccccb" + /* 2 */ "bcccccccccccb" + /* 3 */ "bcccccccccccb" + /* 4 */ "bcccccccccccb" + /* 5 */ "bcccccccccccb" + /* 6 */ "bcccccccccccb" + /* 7 */ "bcccccccccccb" + /* 8 */ "bcccccccccccb" + /* 9 */ "bcccccccccccb" + /* 10 */ "bcccccccccccb" + /* 11 */ "bbbbbbbbbbbbb" + + // Level 2 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "ddddddddddddd" + /* 1 */ "deefeefeefeed" + /* 2 */ "deefeefeefeed" + /* 3 */ "deefeefeefeed" + /* 4 */ "deefeefeefeed" + /* 5 */ "deefeefeefeed" + /* 6 */ "deefeefeefeed" + /* 7 */ "deefeefeefeed" + /* 8 */ "deefeefeefeed" + /* 9 */ "deefeefeefeed" + /* 10 */ "deefeefeefeed" + /* 11 */ "ddddddddddddd" + + // Level 3 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "g..g..g..g..g" + /* 1 */ "ghh.h..hh.hhg" + /* 2 */ "ghh..h.hh.hhg" + /* 3 */ "ghh.h..h..hhg" + /* 4 */ "ghh.hh.h..hhg" + /* 5 */ "ghh.h..hh.hhg" + /* 6 */ "ghh.hh.hh.hhg" + /* 7 */ "ghh....h..hhg" + /* 8 */ "ghh..h....hhg" + /* 9 */ "ghh.....h.hhg" + /* 10 */ "ghh.hh.h..hhg" + /* 11 */ "g..g..g..g..g", + + // Connectors: + "-1: 7, 1, 11: 3\n" /* Type -1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // BigPlantBed + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CobbleHouse10x5Library: + // The data has been exported from the gallery Plains, area index 23, ID 66, created by xoft + { + // Size: + 12, 8, 7, // SizeX = 12, SizeY = 8, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 11, 7, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 64: 7\n" /* wooddoorblock */ + "h: 53: 3\n" /* woodstairs */ + "i: 53: 1\n" /* woodstairs */ + "j: 85: 0\n" /* fence */ + "k: 53: 0\n" /* woodstairs */ + "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n:139: 0\n" /* cobblestonewall */ - "o:101: 0\n" /* ironbars */ - "p: 53: 2\n" /* woodstairs */ - "q: 53: 7\n" /* woodstairs */ - "r: 50: 2\n" /* torch */ - "s: 50: 1\n" /* torch */ - "t: 53: 6\n" /* woodstairs */ - "u: 53: 3\n" /* woodstairs */ - "v: 43: 0\n" /* doubleslab */ - "w: 44: 0\n" /* step */, + "n:102: 0\n" /* glasspane */ + "o: 64:12\n" /* wooddoorblock */ + "p: 50: 3\n" /* torch */ + "q: 72: 0\n" /* woodplate */ + "r: 50: 4\n" /* torch */ + "s: 53: 7\n" /* woodstairs */ + "t: 47: 0\n" /* bookshelf */ + "u: 50: 1\n" /* torch */ + "v: 50: 2\n" /* torch */ + "w: 53: 6\n" /* woodstairs */ + "x: 5: 0\n" /* wood */, // Block data: // Level 0 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ ".....abbbc.." - /* 1 */ ".ddddddddc.." - /* 2 */ ".ddddddddc.." - /* 3 */ ".ddddddddddd" - /* 4 */ ".ddddddddddd" - /* 5 */ ".ddddddddddd" - /* 6 */ ".ddddddddddd" - /* 7 */ ".ddddddddddd" - /* 8 */ ".ddddd.mmmmm" - /* 9 */ ".ddddd.mmmmm" - /* 10 */ ".......mmmmm" + /* 0 */ "aaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaaa" // Level 1 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ ".efffe......" - /* 2 */ ".f...g......" - /* 3 */ ".f...ed..ddd" - /* 4 */ ".f...f...dhd" - /* 5 */ ".f...f...dhd" - /* 6 */ ".f...fijjdhd" - /* 7 */ ".f...edddddd" - /* 8 */ ".f...f.mmmmm" - /* 9 */ ".efffe.mmmmm" - /* 10 */ ".......mmmmm" + /* 0 */ "bbbbbbbaaabb" + /* 1 */ "baaaaaaaaaab" + /* 2 */ "baaaaaaaaaab" + /* 3 */ "baaaaaaaaaab" + /* 4 */ "baaaaaaaaaab" + /* 5 */ "baaaaaaaaaab" + /* 6 */ "bbbbbbbbbbbb" // Level 2 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ ".ekkke......" - /* 2 */ ".k...l......" - /* 3 */ ".k...en..n.d" - /* 4 */ ".k...k.....o" - /* 5 */ ".f...k.....o" - /* 6 */ ".k...k.....o" - /* 7 */ ".k...edooood" - /* 8 */ ".k...f.mmmmm" - /* 9 */ ".ekkke.mmmmm" - /* 10 */ ".......mmmmm" + /* 0 */ ".......cde.." + /* 1 */ ".ffffffffff." + /* 2 */ ".ffffffffff." + /* 3 */ ".ffffffffff." + /* 4 */ ".ffffffffff." + /* 5 */ ".ffffffffff." + /* 6 */ "............" // Level 3 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "ppppppp....." - /* 1 */ "qfffffq....." - /* 2 */ ".f...f......" - /* 3 */ ".f..rfd..dod" - /* 4 */ ".f...f...o.d" - /* 5 */ ".f...f...o.d" - /* 6 */ ".fs..f...o.d" - /* 7 */ ".f...fdddddd" - /* 8 */ ".f...f.mmmmm" - /* 9 */ "tffffftmmmmm" - /* 10 */ "uuuuuuummmmm" + /* 0 */ "............" + /* 1 */ ".fffffffgff." + /* 2 */ ".fh.ijk...f." + /* 3 */ ".fj.......f." + /* 4 */ ".fl.ijkijkf." + /* 5 */ ".ffffffffff." + /* 6 */ "............" // Level 4 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" - /* 1 */ "ppppppp....." - /* 2 */ "qfffffq....." - /* 3 */ ".f...fvvvvvv" - /* 4 */ ".f...fvwwwwv" - /* 5 */ ".f...fvwwwwv" - /* 6 */ ".f...fvwwwwv" - /* 7 */ ".f...fvvvvvv" - /* 8 */ "tffffftmmmmm" - /* 9 */ "uuuuuuummmmm" - /* 10 */ ".......mmmmm" + /* 1 */ ".fnnfnnfoff." + /* 2 */ ".n..pq.p.pn." + /* 3 */ ".nq.......n." + /* 4 */ ".n..rq.rq.n." + /* 5 */ ".fnnfnnfnnf." + /* 6 */ "............" // Level 5 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ "............" - /* 2 */ "ppppppp....." - /* 3 */ "qfffffq....." - /* 4 */ ".f...f......" - /* 5 */ ".f...f......" - /* 6 */ ".f...f......" - /* 7 */ "tffffft....." - /* 8 */ "uuuuuuummmmm" - /* 9 */ ".......mmmmm" - /* 10 */ ".......mmmmm" + /* 0 */ "llllllllllll" + /* 1 */ "sffffffffffs" + /* 2 */ ".fttttttttf." + /* 3 */ ".fu......vf." + /* 4 */ ".fttttttttf." + /* 5 */ "wffffffffffw" + /* 6 */ "hhhhhhhhhhhh" // Level 6 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" - /* 1 */ "............" - /* 2 */ "............" - /* 3 */ "ppppppp....." - /* 4 */ "qfffffq....." - /* 5 */ ".f...f......" - /* 6 */ "tffffft....." - /* 7 */ "uuuuuuu....." - /* 8 */ ".......mmmmm" - /* 9 */ ".......mmmmm" - /* 10 */ ".......mmmmm" + /* 1 */ "llllllllllll" + /* 2 */ "sxxxxxxxxxxs" + /* 3 */ ".xxxxxxxxxx." + /* 4 */ "wxxxxxxxxxxw" + /* 5 */ "hhhhhhhhhhhh" + /* 6 */ "............" // Level 7 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" /* 1 */ "............" - /* 2 */ "............" - /* 3 */ "............" - /* 4 */ "ppppppp....." - /* 5 */ "fffffff....." - /* 6 */ "uuuuuuu....." - /* 7 */ "............" - /* 8 */ ".......mmmmm" - /* 9 */ ".......mmmmm" - /* 10 */ ".......mmmmm", + /* 2 */ "llllllllllll" + /* 3 */ "xxxxxxxxxxxx" + /* 4 */ "hhhhhhhhhhhh" + /* 5 */ "............" + /* 6 */ "............", // Connectors: - "-1: 7, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 8, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -193,102 +274,59 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // Forge + }, // CobbleHouse10x5Library /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_100: - // The data has been exported from the gallery Plains, area index 49, ID 100, created by Aloe_vera + // DoublePlantBed: + // The data has been exported from the gallery Plains, area index 5, ID 20, created by tonibm1999 { // Size: - 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7 + 15, 2, 9, // SizeX = 15, SizeY = 2, SizeZ = 9 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 6, 5, 6, // MaxX, MaxY, MaxZ + 14, 1, 8, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 17: 0\n" /* tree */ - "f: 5: 0\n" /* wood */ - "g: 64: 7\n" /* wooddoorblock */ - "h: 64:12\n" /* wooddoorblock */ - "i:102: 0\n" /* glasspane */ - "j: 53: 2\n" /* woodstairs */ - "k: 53: 7\n" /* woodstairs */ - "l: 50: 3\n" /* torch */ - "m: 19: 0\n" /* sponge */ - "n: 53: 6\n" /* woodstairs */ - "o: 53: 3\n" /* woodstairs */, + "a: 17: 0\n" /* tree */ + "b: 60: 7\n" /* tilleddirt */ + "c: 8: 0\n" /* water */ + "d: 50: 5\n" /* torch */ + "e: 59: 7\n" /* crops */ + "m: 19: 0\n" /* sponge */, // Block data: // Level 0 - /* z\x* 0123456 */ - /* 0 */ "..abc.." - /* 1 */ ".ddddd." - /* 2 */ ".ddddd." - /* 3 */ ".ddddd." - /* 4 */ ".ddddd." - /* 5 */ ".ddddd." - /* 6 */ "......." + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "aaaaaaamaaaaaaa" + /* 1 */ "abbcbbamabbcbba" + /* 2 */ "abbcbbamabbcbba" + /* 3 */ "abbcbbamabbcbba" + /* 4 */ "abbcbbamabbcbba" + /* 5 */ "abbcbbamabbcbba" + /* 6 */ "abbcbbamabbcbba" + /* 7 */ "abbcbbamabbcbba" + /* 8 */ "aaaaaaamaaaaaaa" // Level 1 - /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".efgfe." - /* 2 */ ".f...f." - /* 3 */ ".f...f." - /* 4 */ ".f...f." - /* 5 */ ".efffe." - /* 6 */ "......." - - // Level 2 - /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".efhfe." - /* 2 */ ".i...i." - /* 3 */ ".i...i." - /* 4 */ ".i...i." - /* 5 */ ".eiiie." - /* 6 */ "......." - - // Level 3 - /* z\x* 0123456 */ - /* 0 */ "jjjjjjj" - /* 1 */ "kfffffk" - /* 2 */ ".fl.lf." - /* 3 */ ".f...f." - /* 4 */ ".f...f." - /* 5 */ "nfffffn" - /* 6 */ "ooooooo" - - // Level 4 - /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ "jjjjjjj" - /* 2 */ "kfffffk" - /* 3 */ ".f...f." - /* 4 */ "nfffffn" - /* 5 */ "ooooooo" - /* 6 */ "......." - - // Level 5 - /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ "......." - /* 2 */ "jjjjjjj" - /* 3 */ "fffffff" - /* 4 */ "ooooooo" - /* 5 */ "......." - /* 6 */ ".......", + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "dmmmmmdmdmmmmmd" + /* 1 */ "meemeemmmeemeem" + /* 2 */ "memmmemmmeemeem" + /* 3 */ "memmmmmmmeemeem" + /* 4 */ "meemmemmmeemeem" + /* 5 */ "meemmemmmeemeem" + /* 6 */ "mmemmemmmeemeem" + /* 7 */ "mmememmmmeemeem" + /* 8 */ "dmmmmmdmdmmmmmd", // Connectors: - "-1: 3, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 7, 0, 8: 3\n" /* Type -1, direction Z+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -307,261 +345,202 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_100 + }, // DoublePlantBed /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_103: - // The data has been exported from the gallery Plains, area index 52, ID 103, created by Aloe_vera + // Forge: + // The data has been exported from the gallery Plains, area index 51, ID 102, created by Aloe_vera { // Size: - 11, 7, 9, // SizeX = 11, SizeY = 7, SizeZ = 9 + 12, 10, 11, // SizeX = 12, SizeY = 10, SizeZ = 11 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 10, 6, 8, // MaxX, MaxY, MaxZ + 11, 9, 10, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 17: 0\n" /* tree */ - "f: 5: 0\n" /* wood */ - "g: 64: 7\n" /* wooddoorblock */ - "h:102: 0\n" /* glasspane */ - "i: 64:12\n" /* wooddoorblock */ - "j: 53: 2\n" /* woodstairs */ - "k: 53: 7\n" /* woodstairs */ - "l: 50: 3\n" /* torch */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 17: 0\n" /* tree */ + "h: 5: 0\n" /* wood */ + "i: 64: 6\n" /* wooddoorblock */ + "j: 10: 0\n" /* lava */ + "k: 54: 2\n" /* chest */ + "l: 61: 2\n" /* furnace */ "m: 19: 0\n" /* sponge */ - "n: 50: 4\n" /* torch */ - "o: 53: 6\n" /* woodstairs */ - "p: 53: 3\n" /* woodstairs */, + "n:102: 0\n" /* glasspane */ + "o: 64:12\n" /* wooddoorblock */ + "p:139: 0\n" /* cobblestonewall */ + "q:101: 0\n" /* ironbars */ + "r: 53: 2\n" /* woodstairs */ + "s: 53: 7\n" /* woodstairs */ + "t: 50: 2\n" /* torch */ + "u: 50: 1\n" /* torch */ + "v: 53: 6\n" /* woodstairs */ + "w: 53: 3\n" /* woodstairs */ + "x: 43: 0\n" /* doubleslab */ + "y: 44: 0\n" /* step */, // Block data: // Level 0 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "....abc...." - /* 1 */ ".ddddddddd." - /* 2 */ ".ddddddddd." - /* 3 */ ".ddddddddd." - /* 4 */ ".ddddddddd." - /* 5 */ ".ddddddddd." - /* 6 */ ".ddddddddd." - /* 7 */ ".ddddddddd." - /* 8 */ "..........." + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "aaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaaa" + /* 9 */ "aaaaaaaaaaaa" + /* 10 */ "aaaaaaaaaaaa" // Level 1 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".efffgfffe." - /* 2 */ ".f.......f." - /* 3 */ ".f.......f." - /* 4 */ ".f.......f." - /* 5 */ ".f.......f." - /* 6 */ ".f.......f." - /* 7 */ ".efffffffe." - /* 8 */ "..........." + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "bbbbbaaaaabb" + /* 1 */ "baaaaaaaaabb" + /* 2 */ "baaaaaaaaabb" + /* 3 */ "baaaaaaaaaaa" + /* 4 */ "baaaaaaaaaaa" + /* 5 */ "baaaaaaaaaaa" + /* 6 */ "baaaaaaaaaaa" + /* 7 */ "baaaaaaaaaaa" + /* 8 */ "baaaaabbbbbb" + /* 9 */ "baaaaabbbbbb" + /* 10 */ "bbbbbbbbbbbb" // Level 2 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".ehhfifhhe." - /* 2 */ ".h.......h." - /* 3 */ ".h.......h." - /* 4 */ ".f.......f." - /* 5 */ ".h.......h." - /* 6 */ ".h.......h." - /* 7 */ ".ehhhfhhhe." - /* 8 */ "..........." + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ ".....cddde.." + /* 1 */ ".ffffffffe.." + /* 2 */ ".ffffffffe.." + /* 3 */ ".fffffffffff" + /* 4 */ ".fffffffffff" + /* 5 */ ".fffffffffff" + /* 6 */ ".fffffffffff" + /* 7 */ ".fffffffffff" + /* 8 */ ".fffff.mmmmm" + /* 9 */ ".fffff.mmmmm" + /* 10 */ ".......mmmmm" // Level 3 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "jjjjjjjjjjj" - /* 1 */ "kfffffffffk" - /* 2 */ ".f..l.l..f." - /* 3 */ ".f.......f." - /* 4 */ ".f.......f." - /* 5 */ ".f.......f." - /* 6 */ ".f...n...f." - /* 7 */ "offfffffffo" - /* 8 */ "ppppppppppp" + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ ".ghhhg......" + /* 2 */ ".h...i......" + /* 3 */ ".h...gf..fff" + /* 4 */ ".h...h...fjf" + /* 5 */ ".h...h...fjf" + /* 6 */ ".h...hkllfjf" + /* 7 */ ".h...gffffff" + /* 8 */ ".h...h.mmmmm" + /* 9 */ ".ghhhg.mmmmm" + /* 10 */ ".......mmmmm" // Level 4 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ "jjjjjjjjjjj" - /* 2 */ "kfffffffffk" - /* 3 */ ".f.......f." - /* 4 */ ".f.......f." - /* 5 */ ".f.......f." - /* 6 */ "offfffffffo" - /* 7 */ "ppppppppppp" - /* 8 */ "..........." + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ ".gnnng......" + /* 2 */ ".n...o......" + /* 3 */ ".n...gp..p.f" + /* 4 */ ".n...n.....q" + /* 5 */ ".h...n.....q" + /* 6 */ ".n...n.....q" + /* 7 */ ".n...gfqqqqf" + /* 8 */ ".n...h.mmmmm" + /* 9 */ ".gnnng.mmmmm" + /* 10 */ ".......mmmmm" // Level 5 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ "..........." - /* 2 */ "jjjjjjjjjjj" - /* 3 */ "kfffffffffk" - /* 4 */ ".f.......f." - /* 5 */ "offfffffffo" - /* 6 */ "ppppppppppp" - /* 7 */ "..........." - /* 8 */ "..........." + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "rrrrrrr....." + /* 1 */ "shhhhhs....." + /* 2 */ ".h...h......" + /* 3 */ ".h..thf..fqf" + /* 4 */ ".h...h...q.f" + /* 5 */ ".h...h...q.f" + /* 6 */ ".hu..h...q.f" + /* 7 */ ".h...hffffff" + /* 8 */ ".h...h.mmmmm" + /* 9 */ "vhhhhhvmmmmm" + /* 10 */ "wwwwwwwmmmmm" // Level 6 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ "..........." - /* 2 */ "..........." - /* 3 */ "jjjjjjjjjjj" - /* 4 */ "fffffffffff" - /* 5 */ "ppppppppppp" - /* 6 */ "..........." - /* 7 */ "..........." - /* 8 */ "...........", - - // Connectors: - "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, - - // AllowedRotations: - 7, /* 1, 2, 3 CCW rotation allowed */ - - // Merge strategy: - cBlockArea::msSpongePrint, - - // ShouldExtendFloor: - true, - - // DefaultWeight: - 100, - - // DepthWeight: - "", - - // AddWeightIfSame: - 0, - }, // PlainsVillage_103 - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_105: - // The data has been exported from the gallery Plains, area index 54, ID 105, created by Aloe_vera - { - // Size: - 7, 6, 9, // SizeX = 7, SizeY = 6, SizeZ = 9 - - // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 6, 5, 8, // MaxX, MaxY, MaxZ - - // Block definitions: - ".: 0: 0\n" /* air */ - "a:170: 0\n" /* haybale */ - "b: 67: 0\n" /* stairs */ - "c: 67: 2\n" /* stairs */ - "d: 67: 1\n" /* stairs */ - "e: 4: 0\n" /* cobblestone */ - "f: 17: 0\n" /* tree */ - "g: 5: 0\n" /* wood */ - "h:170: 4\n" /* haybale */ - "i:170: 8\n" /* haybale */ - "j: 54: 2\n" /* chest */ - "k: 50: 4\n" /* torch */ - "l: 53: 0\n" /* woodstairs */ - "m: 19: 0\n" /* sponge */ - "n: 53: 5\n" /* woodstairs */ - "o: 53: 4\n" /* woodstairs */ - "p: 53: 1\n" /* woodstairs */, - - // Block data: - // Level 0 - /* z\x* 0123456 */ - /* 0 */ "abcccd." - /* 1 */ ".eeeee." - /* 2 */ ".eeeee." - /* 3 */ ".eeeee." - /* 4 */ ".eeeee." - /* 5 */ ".eeeee." - /* 6 */ ".eeeee." - /* 7 */ ".eeeee." - /* 8 */ "......." - - // Level 1 - /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".f..af." - /* 2 */ ".g...g." - /* 3 */ ".ga.hg." - /* 4 */ ".fihif." - /* 5 */ ".gaaag." - /* 6 */ ".gijag." - /* 7 */ ".fgfgf." - /* 8 */ "......." - - // Level 2 - /* z\x* 0123456 */ - /* 0 */ ".k...k." - /* 1 */ ".f...f." - /* 2 */ ".g...g." - /* 3 */ ".g...g." - /* 4 */ ".fh..f." - /* 5 */ ".ghiag." - /* 6 */ ".ghiig." - /* 7 */ ".fgfgf." - /* 8 */ "......." + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "rrrrrrr....." + /* 2 */ "shhhhhs....." + /* 3 */ ".h...hxxxxxx" + /* 4 */ ".h...hxyyyyx" + /* 5 */ ".h...hxyyyyx" + /* 6 */ ".h...hxyyyyx" + /* 7 */ ".h...hxxxxxx" + /* 8 */ "vhhhhhvmmmmm" + /* 9 */ "wwwwwwwmmmmm" + /* 10 */ ".......mmmmm" - // Level 3 - /* z\x* 0123456 */ - /* 0 */ "ln...op" - /* 1 */ "lgggggp" - /* 2 */ "lg...gp" - /* 3 */ "lg...gp" - /* 4 */ "lg...gp" - /* 5 */ "lgaa.gp" - /* 6 */ "lgiaigp" - /* 7 */ "lgggggp" - /* 8 */ "ln...op" + // Level 7 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "rrrrrrr....." + /* 3 */ "shhhhhs....." + /* 4 */ ".h...h......" + /* 5 */ ".h...h......" + /* 6 */ ".h...h......" + /* 7 */ "vhhhhhv....." + /* 8 */ "wwwwwwwmmmmm" + /* 9 */ ".......mmmmm" + /* 10 */ ".......mmmmm" - // Level 4 - /* z\x* 0123456 */ - /* 0 */ ".ln.op." - /* 1 */ ".lgggp." - /* 2 */ ".lg.gp." - /* 3 */ ".lg.gp." - /* 4 */ ".lg.gp." - /* 5 */ ".lg.gp." - /* 6 */ ".lg.gp." - /* 7 */ ".lgggp." - /* 8 */ ".ln.op." + // Level 8 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "............" + /* 3 */ "rrrrrrr....." + /* 4 */ "shhhhhs....." + /* 5 */ ".h...h......" + /* 6 */ "vhhhhhv....." + /* 7 */ "wwwwwww....." + /* 8 */ ".......mmmmm" + /* 9 */ ".......mmmmm" + /* 10 */ ".......mmmmm" - // Level 5 - /* z\x* 0123456 */ - /* 0 */ "..lgp.." - /* 1 */ "..lgp.." - /* 2 */ "..lgp.." - /* 3 */ "..lgp.." - /* 4 */ "..lgp.." - /* 5 */ "..lgp.." - /* 6 */ "..lgp.." - /* 7 */ "..lgp.." - /* 8 */ "..lgp..", + // Level 9 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "............" + /* 3 */ "............" + /* 4 */ "rrrrrrr....." + /* 5 */ "hhhhhhh....." + /* 6 */ "wwwwwww....." + /* 7 */ "............" + /* 8 */ ".......mmmmm" + /* 9 */ ".......mmmmm" + /* 10 */ ".......mmmmm", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 7, 2, -1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -580,152 +559,66 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_105 + }, // Forge /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_106: - // The data has been exported from the gallery Plains, area index 55, ID 106, created by Aloe_vera + // SinglePlantBed: + // The data has been exported from the gallery Plains, area index 17, ID 60, created by Aloe_vera { // Size: - 15, 8, 9, // SizeX = 15, SizeY = 8, SizeZ = 9 + 10, 3, 7, // SizeX = 10, SizeY = 3, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 14, 7, 8, // MaxX, MaxY, MaxZ + 9, 2, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 3: 0\n" /* dirt */ - "f: 17: 0\n" /* tree */ - "g:107: 0\n" /* fencegate */ - "h:107: 4\n" /* fencegate */ - "i: 5: 0\n" /* wood */ - "j:107: 6\n" /* fencegate */ - "k: 85: 0\n" /* fence */ - "l:170: 0\n" /* haybale */ - "m: 19: 0\n" /* sponge */ - "n:170: 4\n" /* haybale */ - "o:170: 8\n" /* haybale */ - "p: 50: 1\n" /* torch */ - "q: 50: 2\n" /* torch */ - "r: 53: 2\n" /* woodstairs */ - "s: 53: 7\n" /* woodstairs */ - "t: 53: 6\n" /* woodstairs */ - "u: 53: 3\n" /* woodstairs */, + "a: 3: 0\n" /* dirt */ + "b: 17: 0\n" /* tree */ + "c: 60: 7\n" /* tilleddirt */ + "d: 8: 0\n" /* water */ + "e: 59: 7\n" /* crops */ + "m: 19: 0\n" /* sponge */, // Block data: // Level 0 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ ".abbbbbbbbbbbc." - /* 1 */ ".ddddddddddddd." - /* 2 */ ".deeeeeeeeeeed." - /* 3 */ ".deeeeeeeeeeed." - /* 4 */ ".deeeeeeeeeeed." - /* 5 */ ".deeeeeeeeeeed." - /* 6 */ ".deeeeeeeeeeed." - /* 7 */ ".ddddddddddddd." - /* 8 */ "..............." + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "aaaaaaaaaa" + /* 1 */ "aaaaaaaaaa" + /* 2 */ "aaaaaaaaaa" + /* 3 */ "aaaaaaaaaa" + /* 4 */ "aaaaaaaaaa" + /* 5 */ "aaaaaaaaaa" + /* 6 */ "aaaaaaaaaa" // Level 1 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ ".fghgighgigjgf." - /* 2 */ ".k...k...k...k." - /* 3 */ ".k...k...k...k." - /* 4 */ ".k...k...k...k." - /* 5 */ ".k...k...k...k." - /* 6 */ ".kl..k..nko..k." - /* 7 */ ".fkkkikkkikkkf." - /* 8 */ "..............." + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "bbbbbbbbbb" + /* 1 */ "bccccccccb" + /* 2 */ "bccccccccb" + /* 3 */ "bddddddddb" + /* 4 */ "bccccccccb" + /* 5 */ "bccccccccb" + /* 6 */ "bbbbbbbbbb" // Level 2 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ ".f...i...i...f." - /* 2 */ "..............." - /* 3 */ "..............." - /* 4 */ "..............." - /* 5 */ "..............." - /* 6 */ "..............." - /* 7 */ ".f...i...i...f." - /* 8 */ "..............." - - // Level 3 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ ".fp.qip.qip.qf." - /* 2 */ "..............." - /* 3 */ "..............." - /* 4 */ "..............." - /* 5 */ "..............." - /* 6 */ "..............." - /* 7 */ ".f...i...i...f." - /* 8 */ "..............." - - // Level 4 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "rrrrrrrrrrrrrrr" - /* 1 */ "siiiiiiiiiiiiis" - /* 2 */ ".i...........i." - /* 3 */ ".i...........i." - /* 4 */ ".i...........i." - /* 5 */ ".i...........i." - /* 6 */ ".i...........i." - /* 7 */ "tiiiiiiiiiiiiit" - /* 8 */ "uuuuuuuuuuuuuuu" - - // Level 5 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ "rrrrrrrrrrrrrrr" - /* 2 */ "siiiiiiiiiiiiis" - /* 3 */ ".i...........i." - /* 4 */ ".i...........i." - /* 5 */ ".i...........i." - /* 6 */ "tiiiiiiiiiiiiit" - /* 7 */ "uuuuuuuuuuuuuuu" - /* 8 */ "..............." - - // Level 6 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ "..............." - /* 2 */ "rrrrrrrrrrrrrrr" - /* 3 */ "siiiiiiiiiiiiis" - /* 4 */ ".i...........i." - /* 5 */ "tiiiiiiiiiiiiit" - /* 6 */ "uuuuuuuuuuuuuuu" - /* 7 */ "..............." - /* 8 */ "..............." - - // Level 7 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ "..............." - /* 2 */ "..............." - /* 3 */ "rrrrrrrrrrrrrrr" - /* 4 */ "iiiiiiiiiiiiiii" - /* 5 */ "uuuuuuuuuuuuuuu" - /* 6 */ "..............." - /* 7 */ "..............." - /* 8 */ "...............", + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ ".eeeeeeee." + /* 2 */ ".eeeeeeee." + /* 3 */ ".........." + /* 4 */ ".eeeeeeee." + /* 5 */ ".eeeeeeee." + /* 6 */ "..........", // Connectors: - "-1: 7, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 9, 1, 3: 5\n" /* Type -1, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -744,157 +637,191 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_106 + }, // SinglePlantBed /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_109: + // WoodenChurchMid: // The data has been exported from the gallery Plains, area index 58, ID 109, created by Aloe_vera { // Size: - 7, 14, 13, // SizeX = 7, SizeY = 14, SizeZ = 13 + 7, 16, 13, // SizeX = 7, SizeY = 16, SizeZ = 13 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 6, 13, 12, // MaxX, MaxY, MaxZ + 6, 15, 12, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "A: 85: 0\n" /* fence */ - "B:126: 8\n" /* woodenslab */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 17: 0\n" /* tree */ - "f: 5: 0\n" /* wood */ - "g: 64: 7\n" /* wooddoorblock */ - "h: 65: 3\n" /* ladder */ - "i: 53: 3\n" /* woodstairs */ - "j: 53: 7\n" /* woodstairs */ - "k: 64:12\n" /* wooddoorblock */ - "l:102: 0\n" /* glasspane */ + "A: 54: 2\n" /* chest */ + "B: 50: 4\n" /* torch */ + "C: 85: 0\n" /* fence */ + "D:126: 8\n" /* woodenslab */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 17: 0\n" /* tree */ + "h: 5: 0\n" /* wood */ + "i: 64: 7\n" /* wooddoorblock */ + "j: 65: 3\n" /* ladder */ + "k: 53: 3\n" /* woodstairs */ + "l: 53: 7\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 50: 1\n" /* torch */ - "o: 50: 2\n" /* torch */ - "p:171:14\n" /* carpet */ - "q: 50: 3\n" /* torch */ - "r: 53: 2\n" /* woodstairs */ - "s: 53: 0\n" /* woodstairs */ - "t: 53: 1\n" /* woodstairs */ - "u: 53: 5\n" /* woodstairs */ - "v: 53: 4\n" /* woodstairs */ - "w: 17: 4\n" /* tree */ - "x: 17: 8\n" /* tree */ - "y: 54: 2\n" /* chest */ - "z: 50: 4\n" /* torch */, + "n: 64:12\n" /* wooddoorblock */ + "o:102: 0\n" /* glasspane */ + "p: 50: 1\n" /* torch */ + "q: 50: 2\n" /* torch */ + "r:171:14\n" /* carpet */ + "s: 50: 3\n" /* torch */ + "t: 53: 2\n" /* woodstairs */ + "u: 53: 0\n" /* woodstairs */ + "v: 53: 1\n" /* woodstairs */ + "w: 53: 5\n" /* woodstairs */ + "x: 53: 4\n" /* woodstairs */ + "y: 17: 4\n" /* tree */ + "z: 17: 8\n" /* tree */, // Block data: // Level 0 /* z\x* 0123456 */ - /* 0 */ "..abc.." - /* 1 */ ".ddddd." - /* 2 */ ".ddddd." - /* 3 */ ".ddddd." - /* 4 */ ".ddddd." - /* 5 */ ".ddddd." - /* 6 */ ".ddddd." - /* 7 */ ".ddddd." - /* 8 */ ".ddddd." - /* 9 */ ".ddddd." - /* 10 */ ".ddddd." - /* 11 */ ".ddddd." - /* 12 */ "......." + /* 0 */ "aaaaaaa" + /* 1 */ "aaaaaaa" + /* 2 */ "aaaaaaa" + /* 3 */ "aaaaaaa" + /* 4 */ "aaaaaaa" + /* 5 */ "aaaaaaa" + /* 6 */ "aaaaaaa" + /* 7 */ "aaaaaaa" + /* 8 */ "aaaaaaa" + /* 9 */ "aaaaaaa" + /* 10 */ "aaaaaaa" + /* 11 */ "aaaaaaa" + /* 12 */ "aaaaaaa" // Level 1 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".efgfe." - /* 2 */ ".f..hf." - /* 3 */ ".f...f." - /* 4 */ ".f...f." - /* 5 */ ".ei.ie." - /* 6 */ ".f...f." - /* 7 */ ".fi.if." - /* 8 */ ".f...f." - /* 9 */ ".f.j.f." - /* 10 */ ".f...f." - /* 11 */ ".efffe." - /* 12 */ "......." + /* 0 */ "bbaaabb" + /* 1 */ "baaaaab" + /* 2 */ "baaaaab" + /* 3 */ "baaaaab" + /* 4 */ "baaaaab" + /* 5 */ "baaaaab" + /* 6 */ "baaaaab" + /* 7 */ "baaaaab" + /* 8 */ "baaaaab" + /* 9 */ "baaaaab" + /* 10 */ "baaaaab" + /* 11 */ "baaaaab" + /* 12 */ "bbbbbbb" // Level 2 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".efkfe." - /* 2 */ ".l..hl." - /* 3 */ ".l...l." - /* 4 */ ".l...l." - /* 5 */ ".e...e." - /* 6 */ ".l...l." - /* 7 */ ".l...l." - /* 8 */ ".fn.of." - /* 9 */ ".l.p.l." - /* 10 */ ".l...l." - /* 11 */ ".ellle." + /* 0 */ "..cde.." + /* 1 */ ".fffff." + /* 2 */ ".fffff." + /* 3 */ ".fffff." + /* 4 */ ".fffff." + /* 5 */ ".fffff." + /* 6 */ ".fffff." + /* 7 */ ".fffff." + /* 8 */ ".fffff." + /* 9 */ ".fffff." + /* 10 */ ".fffff." + /* 11 */ ".fffff." /* 12 */ "......." // Level 3 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".efffe." - /* 2 */ ".f.qhf." - /* 3 */ ".f...f." - /* 4 */ ".f...f." - /* 5 */ "re...er" - /* 6 */ "sf...ft" - /* 7 */ "sf...ft" - /* 8 */ "sf...ft" - /* 9 */ "sf...ft" - /* 10 */ "sf...ft" - /* 11 */ "sefffft" - /* 12 */ "su...vt" + /* 1 */ ".ghihg." + /* 2 */ ".h..jh." + /* 3 */ ".h...h." + /* 4 */ ".h...h." + /* 5 */ ".gk.kg." + /* 6 */ ".h...h." + /* 7 */ ".hk.kh." + /* 8 */ ".h...h." + /* 9 */ ".h.l.h." + /* 10 */ ".h...h." + /* 11 */ ".ghhhg." + /* 12 */ "......." // Level 4 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".ewwwe." - /* 2 */ ".xffhx." - /* 3 */ ".xfffx." - /* 4 */ ".xfffx." - /* 5 */ ".ewwwe." - /* 6 */ ".sf.ft." - /* 7 */ ".sf.ft." - /* 8 */ ".sf.ft." - /* 9 */ ".sf.ft." - /* 10 */ ".sf.ft." - /* 11 */ ".sffft." - /* 12 */ ".su.vt." + /* 1 */ ".ghnhg." + /* 2 */ ".o..jo." + /* 3 */ ".o...o." + /* 4 */ ".o...o." + /* 5 */ ".g...g." + /* 6 */ ".o...o." + /* 7 */ ".o...o." + /* 8 */ ".hp.qh." + /* 9 */ ".o.r.o." + /* 10 */ ".o...o." + /* 11 */ ".gooog." + /* 12 */ "......." // Level 5 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".eflfe." - /* 2 */ ".f..hf." - /* 3 */ ".f...f." - /* 4 */ ".f.y.f." - /* 5 */ ".efffe." - /* 6 */ "..sft.." - /* 7 */ "..sft.." - /* 8 */ "..sft.." - /* 9 */ "..sft.." - /* 10 */ "..sft.." - /* 11 */ "..sft.." - /* 12 */ "..sft.." + /* 1 */ ".ghhhg." + /* 2 */ ".h.sjh." + /* 3 */ ".h...h." + /* 4 */ ".h...h." + /* 5 */ "tg...gt" + /* 6 */ "uh...hv" + /* 7 */ "uh...hv" + /* 8 */ "uh...hv" + /* 9 */ "uh...hv" + /* 10 */ "uh...hv" + /* 11 */ "ughhhhv" + /* 12 */ "uw...xv" // Level 6 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".eflfe." - /* 2 */ ".f..hf." - /* 3 */ ".l...l." - /* 4 */ ".f...f." - /* 5 */ ".efffe." + /* 1 */ ".gyyyg." + /* 2 */ ".zhhjz." + /* 3 */ ".zhhhz." + /* 4 */ ".zhhhz." + /* 5 */ ".gyyyg." + /* 6 */ ".uh.hv." + /* 7 */ ".uh.hv." + /* 8 */ ".uh.hv." + /* 9 */ ".uh.hv." + /* 10 */ ".uh.hv." + /* 11 */ ".uhhhv." + /* 12 */ ".uw.xv." + + // Level 7 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".ghohg." + /* 2 */ ".h..jh." + /* 3 */ ".h...h." + /* 4 */ ".h.A.h." + /* 5 */ ".ghhhg." + /* 6 */ "..uhv.." + /* 7 */ "..uhv.." + /* 8 */ "..uhv.." + /* 9 */ "..uhv.." + /* 10 */ "..uhv.." + /* 11 */ "..uhv.." + /* 12 */ "..uhv.." + + // Level 8 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".ghohg." + /* 2 */ ".h..jh." + /* 3 */ ".o...o." + /* 4 */ ".h...h." + /* 5 */ ".ghhhg." /* 6 */ "......." /* 7 */ "......." /* 8 */ "......." @@ -903,14 +830,14 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 7 + // Level 9 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".eflfe." - /* 2 */ ".f..hf." - /* 3 */ ".f...f." - /* 4 */ ".f.z.f." - /* 5 */ ".efffe." + /* 1 */ ".ghohg." + /* 2 */ ".h..jh." + /* 3 */ ".h...h." + /* 4 */ ".h.B.h." + /* 5 */ ".ghhhg." /* 6 */ "......." /* 7 */ "......." /* 8 */ "......." @@ -919,14 +846,14 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 8 + // Level 10 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".ewwwe." - /* 2 */ ".xffhx." - /* 3 */ ".xfffx." - /* 4 */ ".xfffx." - /* 5 */ ".ewwwe." + /* 1 */ ".gyyyg." + /* 2 */ ".zhhjz." + /* 3 */ ".zhhhz." + /* 4 */ ".zhhhz." + /* 5 */ ".gyyyg." /* 6 */ "......." /* 7 */ "......." /* 8 */ "......." @@ -935,14 +862,14 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 9 + // Level 11 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".eAAAe." - /* 2 */ ".A...A." - /* 3 */ ".A...A." - /* 4 */ ".A...A." - /* 5 */ ".eAAAe." + /* 1 */ ".gCCCg." + /* 2 */ ".C...C." + /* 3 */ ".C...C." + /* 4 */ ".C...C." + /* 5 */ ".gCCCg." /* 6 */ "......." /* 7 */ "......." /* 8 */ "......." @@ -951,14 +878,14 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 10 + // Level 12 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".e...e." + /* 1 */ ".g...g." /* 2 */ "......." /* 3 */ "......." /* 4 */ "......." - /* 5 */ ".e...e." + /* 5 */ ".g...g." /* 6 */ "......." /* 7 */ "......." /* 8 */ "......." @@ -967,15 +894,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 11 + // Level 13 /* z\x* 0123456 */ - /* 0 */ "su...vt" - /* 1 */ "sefffet" - /* 2 */ "sfBBBft" - /* 3 */ "sfBBBft" - /* 4 */ "sfBBBft" - /* 5 */ "sffffft" - /* 6 */ "su...vt" + /* 0 */ "uw...xv" + /* 1 */ "ughhhgv" + /* 2 */ "uhDDDhv" + /* 3 */ "uhDDDhv" + /* 4 */ "uhDDDhv" + /* 5 */ "uhhhhhv" + /* 6 */ "uw...xv" /* 7 */ "......." /* 8 */ "......." /* 9 */ "......." @@ -983,15 +910,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 12 + // Level 14 /* z\x* 0123456 */ - /* 0 */ ".su.vt." - /* 1 */ ".sffft." - /* 2 */ ".sffft." - /* 3 */ ".sffft." - /* 4 */ ".sffft." - /* 5 */ ".sffft." - /* 6 */ ".su.vt." + /* 0 */ ".uw.xv." + /* 1 */ ".uhhhv." + /* 2 */ ".uhhhv." + /* 3 */ ".uhhhv." + /* 4 */ ".uhhhv." + /* 5 */ ".uhhhv." + /* 6 */ ".uw.xv." /* 7 */ "......." /* 8 */ "......." /* 9 */ "......." @@ -999,15 +926,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 13 + // Level 15 /* z\x* 0123456 */ - /* 0 */ "..sft.." - /* 1 */ "..sft.." - /* 2 */ "..sft.." - /* 3 */ "..sft.." - /* 4 */ "..sft.." - /* 5 */ "..sft.." - /* 6 */ "..sft.." + /* 0 */ "..uhv.." + /* 1 */ "..uhv.." + /* 2 */ "..uhv.." + /* 3 */ "..uhv.." + /* 4 */ "..uhv.." + /* 5 */ "..uhv.." + /* 6 */ "..uhv.." /* 7 */ "......." /* 8 */ "......." /* 9 */ "......." @@ -1016,7 +943,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 12 */ ".......", // Connectors: - "-1: 3, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 3, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1028,66 +955,148 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = true, // DefaultWeight: - 100, + 20, // DepthWeight: "", // AddWeightIfSame: 0, - }, // PlainsVillage_109 + }, // WoodenChurchMid /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_20: - // The data has been exported from the gallery Plains, area index 5, ID 20, created by tonibm1999 + // WoodenGranary: + // The data has been exported from the gallery Plains, area index 54, ID 105, created by Aloe_vera { // Size: - 15, 2, 9, // SizeX = 15, SizeY = 2, SizeZ = 9 + 7, 8, 9, // SizeX = 7, SizeY = 8, SizeZ = 9 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 14, 1, 8, // MaxX, MaxY, MaxZ + 6, 7, 8, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 17: 0\n" /* tree */ - "b: 60: 7\n" /* tilleddirt */ - "c: 8: 0\n" /* water */ - "d: 50: 5\n" /* torch */ - "e: 59: 7\n" /* crops */ - "m: 19: 0\n" /* sponge */, + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c:170: 0\n" /* haybale */ + "d: 67: 0\n" /* stairs */ + "e: 67: 2\n" /* stairs */ + "f: 67: 1\n" /* stairs */ + "g: 4: 0\n" /* cobblestone */ + "h: 17: 0\n" /* tree */ + "i: 5: 0\n" /* wood */ + "j:170: 4\n" /* haybale */ + "k:170: 8\n" /* haybale */ + "l: 54: 2\n" /* chest */ + "m: 19: 0\n" /* sponge */ + "n: 50: 4\n" /* torch */ + "o: 53: 0\n" /* woodstairs */ + "p: 53: 5\n" /* woodstairs */ + "q: 53: 4\n" /* woodstairs */ + "r: 53: 1\n" /* woodstairs */, // Block data: // Level 0 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "aaaaaaamaaaaaaa" - /* 1 */ "abbcbbamabbcbba" - /* 2 */ "abbcbbamabbcbba" - /* 3 */ "abbcbbamabbcbba" - /* 4 */ "abbcbbamabbcbba" - /* 5 */ "abbcbbamabbcbba" - /* 6 */ "abbcbbamabbcbba" - /* 7 */ "abbcbbamabbcbba" - /* 8 */ "aaaaaaamaaaaaaa" + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "aaaaaaa" + /* 2 */ "aaaaaaa" + /* 3 */ "aaaaaaa" + /* 4 */ "aaaaaaa" + /* 5 */ "aaaaaaa" + /* 6 */ "aaaaaaa" + /* 7 */ "aaaaaaa" + /* 8 */ "aaaaaaa" // Level 1 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "dmmmmmdmdmmmmmd" - /* 1 */ "meemeemmmeemeem" - /* 2 */ "memmmemmmeemeem" - /* 3 */ "memmmmmmmeemeem" - /* 4 */ "meemmemmmeemeem" - /* 5 */ "meemmemmmeemeem" - /* 6 */ "mmemmemmmeemeem" - /* 7 */ "mmememmmmeemeem" - /* 8 */ "dmmmmmdmdmmmmmd", + /* z\x* 0123456 */ + /* 0 */ "aaaaaab" + /* 1 */ "baaaaab" + /* 2 */ "baaaaab" + /* 3 */ "baaaaab" + /* 4 */ "baaaaab" + /* 5 */ "baaaaab" + /* 6 */ "baaaaab" + /* 7 */ "baaaaab" + /* 8 */ "bbbbbbb" + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "cdeeef." + /* 1 */ ".ggggg." + /* 2 */ ".ggggg." + /* 3 */ ".ggggg." + /* 4 */ ".ggggg." + /* 5 */ ".ggggg." + /* 6 */ ".ggggg." + /* 7 */ ".ggggg." + /* 8 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".h..ch." + /* 2 */ ".i...i." + /* 3 */ ".ic.ji." + /* 4 */ ".hkjkh." + /* 5 */ ".iccci." + /* 6 */ ".iklci." + /* 7 */ ".hihih." + /* 8 */ "......." + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ ".n...n." + /* 1 */ ".h...h." + /* 2 */ ".i...i." + /* 3 */ ".i...i." + /* 4 */ ".hj..h." + /* 5 */ ".ijkci." + /* 6 */ ".ijkki." + /* 7 */ ".hihih." + /* 8 */ "......." + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "op...qr" + /* 1 */ "oiiiiir" + /* 2 */ "oi...ir" + /* 3 */ "oi...ir" + /* 4 */ "oi...ir" + /* 5 */ "oicc.ir" + /* 6 */ "oikckir" + /* 7 */ "oiiiiir" + /* 8 */ "op...qr" + + // Level 6 + /* z\x* 0123456 */ + /* 0 */ ".op.qr." + /* 1 */ ".oiiir." + /* 2 */ ".oi.ir." + /* 3 */ ".oi.ir." + /* 4 */ ".oi.ir." + /* 5 */ ".oi.ir." + /* 6 */ ".oi.ir." + /* 7 */ ".oiiir." + /* 8 */ ".op.qr." + + // Level 7 + /* z\x* 0123456 */ + /* 0 */ "..oir.." + /* 1 */ "..oir.." + /* 2 */ "..oir.." + /* 3 */ "..oir.." + /* 4 */ "..oir.." + /* 5 */ "..oir.." + /* 6 */ "..oir.." + /* 7 */ "..oir.." + /* 8 */ "..oir..", // Connectors: - "-1: 7, 0, 8: 3\n" /* Type -1, direction Z+ */, + "-1: 3, 2, -1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1106,139 +1115,169 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_20 + }, // WoodenGranary /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_26: - // The data has been exported from the gallery Plains, area index 9, ID 26, created by Aloe_vera + // WoodenHouse10x7Library: + // The data has been exported from the gallery Plains, area index 47, ID 98, created by Aloe_vera { // Size: - 10, 6, 11, // SizeX = 10, SizeY = 6, SizeZ = 11 + 12, 9, 9, // SizeX = 12, SizeY = 9, SizeZ = 9 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 9, 5, 10, // MaxX, MaxY, MaxZ + 11, 8, 8, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 4: 0\n" /* cobblestone */ - "b: 5: 0\n" /* wood */ - "c: 2: 0\n" /* grass */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ "d: 67: 2\n" /* stairs */ - "e: 43: 0\n" /* doubleslab */ - "f: 67: 0\n" /* stairs */ - "g: 67: 3\n" /* stairs */ - "h: 17: 0\n" /* tree */ - "i: 53: 1\n" /* woodstairs */ - "j: 85: 0\n" /* fence */ - "k: 53: 0\n" /* woodstairs */ - "l: 64: 6\n" /* wooddoorblock */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 17: 0\n" /* tree */ + "h: 5: 0\n" /* wood */ + "i: 64: 7\n" /* wooddoorblock */ + "j: 64: 5\n" /* wooddoorblock */ + "k: 53: 3\n" /* woodstairs */ + "l: 85: 0\n" /* fence */ "m: 19: 0\n" /* sponge */ - "n: 64: 0\n" /* wooddoorblock */ - "o:102: 0\n" /* glasspane */ - "p: 72: 0\n" /* woodplate */ - "q: 64:12\n" /* wooddoorblock */ - "r: 64: 8\n" /* wooddoorblock */ - "s: 53: 5\n" /* woodstairs */ - "t: 53: 4\n" /* woodstairs */ - "u: 50: 1\n" /* torch */ - "v: 50: 2\n" /* torch */, + "n: 53: 2\n" /* woodstairs */ + "o: 53: 1\n" /* woodstairs */ + "p: 53: 0\n" /* woodstairs */ + "q:102: 0\n" /* glasspane */ + "r: 64:12\n" /* wooddoorblock */ + "s: 50: 3\n" /* torch */ + "t: 72: 0\n" /* woodplate */ + "u: 53: 7\n" /* woodstairs */ + "v: 47: 0\n" /* bookshelf */ + "w: 50: 1\n" /* torch */ + "x: 50: 2\n" /* torch */ + "y: 53: 6\n" /* woodstairs */, // Block data: // Level 0 - /* z\x* */ - /* * 0123456789 */ - /* 0 */ "......mmmm" - /* 1 */ ".aaaaammmm" - /* 2 */ ".abbbammmm" - /* 3 */ ".abbbacccc" - /* 4 */ "daeeeacccc" - /* 5 */ "faeeeecccc" - /* 6 */ "gaeeeacccc" - /* 7 */ ".aeeeacccc" - /* 8 */ ".aeeeacccc" - /* 9 */ ".aaaaammmm" - /* 10 */ "......mmmm" + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "aaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaaa" // Level 1 - /* z\x* */ - /* * 0123456789 */ - /* 0 */ "......mmmm" - /* 1 */ ".hbbbhmmmm" - /* 2 */ ".bijkbmmmm" - /* 3 */ ".b...bjjjj" - /* 4 */ ".b...b...j" - /* 5 */ ".l...n...j" - /* 6 */ ".b...b...j" - /* 7 */ ".bee.b...j" - /* 8 */ ".b...bjjjj" - /* 9 */ ".hbbbhmmmm" - /* 10 */ "......mmmm" + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "bbbbaaaabbbb" + /* 1 */ "baaaaaaaaaab" + /* 2 */ "baaaaaaaaaab" + /* 3 */ "baaaaaaaaaab" + /* 4 */ "baaaaaaaaaab" + /* 5 */ "baaaaaaaaaab" + /* 6 */ "baaaaaaaaaab" + /* 7 */ "baaaaaaaaaab" + /* 8 */ "bbbbbbbbbbbb" // Level 2 - /* z\x* */ - /* * 0123456789 */ - /* 0 */ "......mmmm" - /* 1 */ ".hooohmmmm" - /* 2 */ ".o.p.ommmm" - /* 3 */ ".o...o...." - /* 4 */ ".b...b...." - /* 5 */ ".q...r...." - /* 6 */ ".b...b...." - /* 7 */ ".o...o...." - /* 8 */ ".o...o...." - /* 9 */ ".hooohmmmm" - /* 10 */ "......mmmm" + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "....cdde...." + /* 1 */ ".ffffffffff." + /* 2 */ ".ffffffffff." + /* 3 */ ".ffffffffff." + /* 4 */ ".ffffffffff." + /* 5 */ ".ffffffffff." + /* 6 */ ".ffffffffff." + /* 7 */ ".ffffffffff." + /* 8 */ "............" // Level 3 - /* z\x* */ - /* * 0123456789 */ - /* 0 */ "ks...timmm" - /* 1 */ "khbbbhimmm" - /* 2 */ "kb...bimmm" - /* 3 */ "kb...bi..." - /* 4 */ "kbu.vbi..." - /* 5 */ "kb...bi..." - /* 6 */ "kbu.vbi..." - /* 7 */ "kb...bi..." - /* 8 */ "kb...bi..." - /* 9 */ "khbbbhimmm" - /* 10 */ "ks...timmm" + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ ".ghhhijhhhg." + /* 2 */ ".h........h." + /* 3 */ ".hk......kh." + /* 4 */ ".hl......lh." + /* 5 */ ".hn......nh." + /* 6 */ ".h.olpolp.h." + /* 7 */ ".ghhhhhhhhg." + /* 8 */ "............" // Level 4 - /* z\x* */ - /* * 0123456789 */ - /* 0 */ "mks.timmmm" - /* 1 */ "mkbbbimmmm" - /* 2 */ "mkb.bimmmm" - /* 3 */ "mkb.bim..." - /* 4 */ "mkb.bim..." - /* 5 */ "mkb.bim..." - /* 6 */ "mkb.bim..." - /* 7 */ "mkb.bim..." - /* 8 */ "mkb.bim..." - /* 9 */ "mkbbbimmmm" - /* 10 */ "mks.timmmm" + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ ".gqqhrrhqqg." + /* 2 */ ".q..s..s..q." + /* 3 */ ".q........q." + /* 4 */ ".ht......th." + /* 5 */ ".q........q." + /* 6 */ ".q..t..t..q." + /* 7 */ ".gqqhqqhqqg." + /* 8 */ "............" // Level 5 - /* z\x* */ - /* * 0123456789 */ - /* 0 */ "mmkbimmmmm" - /* 1 */ "mmkbimmmmm" - /* 2 */ "mmkbimmmmm" - /* 3 */ "mmkbimm..." - /* 4 */ "mmkbimm..." - /* 5 */ "mmkbimm..." - /* 6 */ "mmkbimm..." - /* 7 */ "mmkbimm..." - /* 8 */ "mmkbimm..." - /* 9 */ "mmkbimmmmm" - /* 10 */ "mmkbimmmmm", + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "nnnnnnnnnnnn" + /* 1 */ "uhhhhhhhhhhu" + /* 2 */ ".hvvvvvvvvh." + /* 3 */ ".h........h." + /* 4 */ ".hw......xh." + /* 5 */ ".h........h." + /* 6 */ ".hvvvvvvvvh." + /* 7 */ "yhhhhhhhhhhy" + /* 8 */ "kkkkkkkkkkkk" + + // Level 6 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "nnnnnnnnnnnn" + /* 2 */ "uhhhhhhhhhhu" + /* 3 */ ".hvvvvvvvvh." + /* 4 */ ".h........h." + /* 5 */ ".hvvvvvvvvh." + /* 6 */ "yhhhhhhhhhhy" + /* 7 */ "kkkkkkkkkkkk" + /* 8 */ "............" + + // Level 7 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "nnnnnnnnnnnn" + /* 3 */ "uhhhhhhhhhhu" + /* 4 */ ".h........h." + /* 5 */ "yhhhhhhhhhhy" + /* 6 */ "kkkkkkkkkkkk" + /* 7 */ "............" + /* 8 */ "............" + + // Level 8 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "............" + /* 3 */ "nnnnnnnnnnnn" + /* 4 */ "hhhhhhhhhhhh" + /* 5 */ "kkkkkkkkkkkk" + /* 6 */ "............" + /* 7 */ "............" + /* 8 */ "............", // Connectors: - "-1: 1, 0, 5: 4\n" /* Type -1, direction X- */, + "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1257,257 +1296,124 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_26 + }, // WoodenHouse10x7Library /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_4: - // The data has been exported from the gallery Plains, area index 0, ID 4, created by Aloe_vera + // WoodenHouse5x5: + // The data has been exported from the gallery Plains, area index 49, ID 100, created by Aloe_vera { // Size: - 16, 7, 16, // SizeX = 16, SizeY = 7, SizeZ = 16 + 7, 8, 7, // SizeX = 7, SizeY = 8, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 15, 6, 15, // MaxX, MaxY, MaxZ + 6, 7, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 5: 0\n" /* wood */ - "f: 67: 3\n" /* stairs */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ "g: 17: 0\n" /* tree */ - "h: 64: 7\n" /* wooddoorblock */ - "i: 64: 5\n" /* wooddoorblock */ - "j:102: 0\n" /* glasspane */ - "k: 64:12\n" /* wooddoorblock */ + "h: 5: 0\n" /* wood */ + "i: 64: 7\n" /* wooddoorblock */ + "j: 64:12\n" /* wooddoorblock */ + "k:102: 0\n" /* glasspane */ "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 1\n" /* woodstairs */ - "o: 53: 7\n" /* woodstairs */ + "n: 53: 7\n" /* woodstairs */ + "o: 50: 3\n" /* torch */ "p: 53: 6\n" /* woodstairs */ - "q: 53: 3\n" /* woodstairs */ - "r: 53: 0\n" /* woodstairs */ - "s: 53: 5\n" /* woodstairs */ - "t: 53: 4\n" /* woodstairs */ - "u: 50: 3\n" /* torch */ - "v: 50: 2\n" /* torch */ - "w: 50: 4\n" /* torch */ - "x: 50: 1\n" /* torch */, + "q: 53: 3\n" /* woodstairs */, // Block data: // Level 0 - /* z\x* 111111 */ - /* * 0123456789012345 */ - /* 0 */ "........abc....." - /* 1 */ ".dddddddddddddd." - /* 2 */ ".deeeeeeeeeeeed." - /* 3 */ ".deeeeeeeeeeeed." - /* 4 */ ".deeeeeeeeeeeed." - /* 5 */ ".deeeeeeeeeeeed." - /* 6 */ ".deeeeeeeeeeeed." - /* 7 */ ".ddddddddeeeeed." - /* 8 */ "mmmmmafcdeeeeed." - /* 9 */ "mmmmmmmmdeeeeed." - /* 10 */ "mmmmmmmmdeeeeed." - /* 11 */ "mmmmmmmmdeeeeed." - /* 12 */ "mmmmmmmmdeeeeed." - /* 13 */ "mmmmmmmmdeeeeed." - /* 14 */ "mmmmmmmmddddddd." - /* 15 */ "mmmmmmmm........" + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "aaaaaaa" + /* 2 */ "aaaaaaa" + /* 3 */ "aaaaaaa" + /* 4 */ "aaaaaaa" + /* 5 */ "aaaaaaa" + /* 6 */ "aaaaaaa" // Level 1 - /* z\x* 111111 */ - /* * 0123456789012345 */ - /* 0 */ "................" - /* 1 */ ".geeeeeeghgeeeg." - /* 2 */ ".e............e." - /* 3 */ ".e............e." - /* 4 */ ".e............e." - /* 5 */ ".e............e." - /* 6 */ ".e............e." - /* 7 */ ".geeeeieg.....e." - /* 8 */ "mmmmmm.me.....e." - /* 9 */ "mmmmmmmme.....e." - /* 10 */ "mmmmmmmme.....e." - /* 11 */ "mmmmmmmme.....e." - /* 12 */ "mmmmmmmme.....e." - /* 13 */ "mmmmmmmme.....e." - /* 14 */ "mmmmmmmmgeeeeeg." - /* 15 */ "mmmmmmmm........" + /* z\x* 0123456 */ + /* 0 */ "bbaaabb" + /* 1 */ "baaaaab" + /* 2 */ "baaaaab" + /* 3 */ "baaaaab" + /* 4 */ "baaaaab" + /* 5 */ "baaaaab" + /* 6 */ "bbbbbbb" // Level 2 - /* z\x* 111111 */ - /* * 0123456789012345 */ - /* 0 */ "................" - /* 1 */ ".gejjejjgkgjjeg." - /* 2 */ ".j............e." - /* 3 */ ".j............j." - /* 4 */ ".j............j." - /* 5 */ ".j............e." - /* 6 */ ".j............j." - /* 7 */ ".gejjekeg.....j." - /* 8 */ "mmmmmm.me.....e." - /* 9 */ "mmmmmmmmj.....j." - /* 10 */ "mmmmmmmmj.....j." - /* 11 */ "mmmmmmmme.....e." - /* 12 */ "mmmmmmmmj.....j." - /* 13 */ "mmmmmmmmj.....j." - /* 14 */ "mmmmmmmmgjjjjjg." - /* 15 */ "mmmmmmmm........" + /* z\x* 0123456 */ + /* 0 */ "..cde.." + /* 1 */ ".fffff." + /* 2 */ ".fffff." + /* 3 */ ".fffff." + /* 4 */ ".fffff." + /* 5 */ ".fffff." + /* 6 */ "......." // Level 3 - /* z\x* 111111 */ - /* * 0123456789012345 */ - /* 0 */ "llllllllllllllln" - /* 1 */ "ogeeeeeegegeeegn" - /* 2 */ ".e............en" - /* 3 */ ".e............en" - /* 4 */ ".e............en" - /* 5 */ ".e............en" - /* 6 */ ".e............en" - /* 7 */ "pgeeeeeeg.....en" - /* 8 */ "qqqqqqqre.....en" - /* 9 */ "mmmmmmmre.....en" - /* 10 */ "mmmmmmmre.....en" - /* 11 */ "mmmmmmmre.....en" - /* 12 */ "mmmmmmmre.....en" - /* 13 */ "mmmmmmmre.....en" - /* 14 */ "mmmmmmmrgeeeeegn" - /* 15 */ "mmmmmmmrs.....tn" + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".ghihg." + /* 2 */ ".h...h." + /* 3 */ ".h...h." + /* 4 */ ".h...h." + /* 5 */ ".ghhhg." + /* 6 */ "......." // Level 4 - /* z\x* 111111 */ - /* * 0123456789012345 */ - /* 0 */ "................" - /* 1 */ "lllllllllllllll." - /* 2 */ "oeeeeeeeeeeeeen." - /* 3 */ ".e.........u.en." - /* 4 */ ".e..........ven." - /* 5 */ ".e......w....en." - /* 6 */ "peeeeeeeee...en." - /* 7 */ "qqqqqqqqrex..en." - /* 8 */ "mmmmmmmmre...en." - /* 9 */ "mmmmmmmmre...en." - /* 10 */ "mmmmmmmmre...en." - /* 11 */ "mmmmmmmmre...en." - /* 12 */ "mmmmmmmmre...en." - /* 13 */ "mmmmmmmmre...en." - /* 14 */ "mmmmmmmmreeeeen." - /* 15 */ "mmmmmmmmrs...tn." + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".ghjhg." + /* 2 */ ".k...k." + /* 3 */ ".k...k." + /* 4 */ ".k...k." + /* 5 */ ".gkkkg." + /* 6 */ "......." // Level 5 - /* z\x* 111111 */ - /* * 0123456789012345 */ - /* 0 */ "................" - /* 1 */ "................" - /* 2 */ "llllllllllllln.." - /* 3 */ "oeeeeeeeeeeeen.." - /* 4 */ ".ex.........en.." - /* 5 */ "peeeeeeeeee.en.." - /* 6 */ "qqqqqqqqqre.en.." - /* 7 */ ".........re.en.." - /* 8 */ "mmmmmmmm.re.en.." - /* 9 */ "mmmmmmmm.re.en.." - /* 10 */ "mmmmmmmm.re.en.." - /* 11 */ "mmmmmmmm.re.en.." - /* 12 */ "mmmmmmmm.re.en.." - /* 13 */ "mmmmmmmm.rewen.." - /* 14 */ "mmmmmmmm.reeen.." - /* 15 */ "mmmmmmmm.rs.tn.." + /* z\x* 0123456 */ + /* 0 */ "lllllll" + /* 1 */ "nhhhhhn" + /* 2 */ ".ho.oh." + /* 3 */ ".h...h." + /* 4 */ ".h...h." + /* 5 */ "phhhhhp" + /* 6 */ "qqqqqqq" // Level 6 - /* z\x* 111111 */ - /* * 0123456789012345 */ - /* 0 */ "................" - /* 1 */ "................" - /* 2 */ "................" - /* 3 */ "lllllllllllll..." - /* 4 */ "eeeeeeeeeeeen..." - /* 5 */ "qqqqqqqqqqren..." - /* 6 */ "mmmmmmmmmmren..." - /* 7 */ "mmmmmmmmmmren..." - /* 8 */ "mmmmmmmmmmren..." - /* 9 */ "mmmmmmmmmmren..." - /* 10 */ "mmmmmmmmmmren..." - /* 11 */ "mmmmmmmmmmren..." - /* 12 */ "mmmmmmmmmmren..." - /* 13 */ "mmmmmmmmmmren..." - /* 14 */ "mmmmmmmmmmren..." - /* 15 */ "mmmmmmmmmmren...", - - // Connectors: - "-1: 9, 0, 1: 2\n" /* Type -1, direction Z- */, - - // AllowedRotations: - 7, /* 1, 2, 3 CCW rotation allowed */ - - // Merge strategy: - cBlockArea::msSpongePrint, - - // ShouldExtendFloor: - true, - - // DefaultWeight: - 100, - - // DepthWeight: - "", - - // AddWeightIfSame: - 0, - }, // PlainsVillage_4 - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_60: - // The data has been exported from the gallery Plains, area index 17, ID 60, created by Aloe_vera - { - // Size: - 10, 2, 7, // SizeX = 10, SizeY = 2, SizeZ = 7 - - // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 9, 1, 6, // MaxX, MaxY, MaxZ - - // Block definitions: - ".: 0: 0\n" /* air */ - "a: 17: 0\n" /* tree */ - "b: 60: 7\n" /* tilleddirt */ - "c: 8: 0\n" /* water */ - "d: 59: 7\n" /* crops */ - "m: 19: 0\n" /* sponge */, - - // Block data: - // Level 0 - /* z\x* */ - /* * 0123456789 */ - /* 0 */ "aaaaaaaaaa" - /* 1 */ "abbbbbbbba" - /* 2 */ "abbbbbbbba" - /* 3 */ "acccccccca" - /* 4 */ "abbbbbbbba" - /* 5 */ "abbbbbbbba" - /* 6 */ "aaaaaaaaaa" + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "lllllll" + /* 2 */ "nhhhhhn" + /* 3 */ ".h...h." + /* 4 */ "phhhhhp" + /* 5 */ "qqqqqqq" + /* 6 */ "......." - // Level 1 - /* z\x* */ - /* * 0123456789 */ - /* 0 */ ".........." - /* 1 */ ".dddddddd." - /* 2 */ ".dddddddd." - /* 3 */ ".........." - /* 4 */ ".dddddddd." - /* 5 */ ".dddddddd." - /* 6 */ "..........", + // Level 7 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "......." + /* 2 */ "lllllll" + /* 3 */ "hhhhhhh" + /* 4 */ "qqqqqqq" + /* 5 */ "......." + /* 6 */ ".......", // Connectors: - "-1: 9, 0, 3: 5\n" /* Type -1, direction X+ */, + "-1: 3, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1526,128 +1432,124 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_60 + }, // WoodenHouse5x5 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_66: - // The data has been exported from the gallery Plains, area index 23, ID 66, created by xoft + // WoodenHouse7x5: + // The data has been exported from the gallery Plains, area index 40, ID 91, created by xoft { // Size: - 12, 7, 7, // SizeX = 12, SizeY = 7, SizeZ = 7 + 9, 8, 7, // SizeX = 9, SizeY = 8, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 11, 6, 6, // MaxX, MaxY, MaxZ + 8, 7, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 2: 0\n" /* grass */ - "b: 3: 0\n" /* dirt */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ "c: 67: 0\n" /* stairs */ "d: 67: 2\n" /* stairs */ "e: 67: 1\n" /* stairs */ "f: 4: 0\n" /* cobblestone */ - "g: 64: 7\n" /* wooddoorblock */ - "h: 53: 3\n" /* woodstairs */ - "i: 53: 1\n" /* woodstairs */ - "j: 85: 0\n" /* fence */ - "k: 53: 0\n" /* woodstairs */ + "g: 17: 0\n" /* tree */ + "h: 5: 0\n" /* wood */ + "i: 64: 7\n" /* wooddoorblock */ + "j:102: 0\n" /* glasspane */ + "k: 64:12\n" /* wooddoorblock */ "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n:102: 0\n" /* glasspane */ - "o: 64:12\n" /* wooddoorblock */ - "p: 50: 3\n" /* torch */ - "q: 72: 0\n" /* woodplate */ - "r: 50: 4\n" /* torch */ - "s: 53: 7\n" /* woodstairs */ - "t: 47: 0\n" /* bookshelf */ - "u: 50: 1\n" /* torch */ - "v: 50: 2\n" /* torch */ - "w: 53: 6\n" /* woodstairs */ - "x: 5: 0\n" /* wood */, + "n: 53: 7\n" /* woodstairs */ + "o: 50: 3\n" /* torch */ + "p: 53: 6\n" /* woodstairs */ + "q: 53: 3\n" /* woodstairs */, // Block data: // Level 0 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ "aaaaaaabbbaa" - /* 1 */ "abbbbbbbbbba" - /* 2 */ "abbbbbbbbbba" - /* 3 */ "abbbbbbbbbba" - /* 4 */ "abbbbbbbbbba" - /* 5 */ "abbbbbbbbbba" - /* 6 */ "aaaaaaaaaaaa" + /* z\x* 012345678 */ + /* 0 */ "aaaaaaaaa" + /* 1 */ "aaaaaaaaa" + /* 2 */ "aaaaaaaaa" + /* 3 */ "aaaaaaaaa" + /* 4 */ "aaaaaaaaa" + /* 5 */ "aaaaaaaaa" + /* 6 */ "aaaaaaaaa" // Level 1 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ ".......cde.." - /* 1 */ ".ffffffffff." - /* 2 */ ".ffffffffff." - /* 3 */ ".ffffffffff." - /* 4 */ ".ffffffffff." - /* 5 */ ".ffffffffff." - /* 6 */ "............" + /* z\x* 012345678 */ + /* 0 */ "bbbaaabbb" + /* 1 */ "baaaaaaab" + /* 2 */ "baaaaaaab" + /* 3 */ "baaaaaaab" + /* 4 */ "baaaaaaab" + /* 5 */ "baaaaaaab" + /* 6 */ "bbbbbbbbb" // Level 2 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ ".fffffffgff." - /* 2 */ ".fh.ijk...f." - /* 3 */ ".fj.......f." - /* 4 */ ".fl.ijkijkf." - /* 5 */ ".ffffffffff." - /* 6 */ "............" + /* z\x* 012345678 */ + /* 0 */ "...cde..." + /* 1 */ ".fffffff." + /* 2 */ ".fffffff." + /* 3 */ ".fffffff." + /* 4 */ ".fffffff." + /* 5 */ ".fffffff." + /* 6 */ "........." // Level 3 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ ".fnnfnnfoff." - /* 2 */ ".n..pq.p.pn." - /* 3 */ ".nq.......n." - /* 4 */ ".n..rq.rq.n." - /* 5 */ ".fnnfnnfnnf." - /* 6 */ "............" + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".ghhihhg." + /* 2 */ ".h.....h." + /* 3 */ ".h.....h." + /* 4 */ ".h.....h." + /* 5 */ ".ghhhhhg." + /* 6 */ "........." // Level 4 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ "llllllllllll" - /* 1 */ "sffffffffffs" - /* 2 */ ".fttttttttf." - /* 3 */ ".fu......vf." - /* 4 */ ".fttttttttf." - /* 5 */ "wffffffffffw" - /* 6 */ "hhhhhhhhhhhh" + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".gjhkhjg." + /* 2 */ ".j.....j." + /* 3 */ ".j.....j." + /* 4 */ ".j.....j." + /* 5 */ ".gjjhjjg." + /* 6 */ "........." // Level 5 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ "llllllllllll" - /* 2 */ "sxxxxxxxxxxs" - /* 3 */ ".xxxxxxxxxx." - /* 4 */ "wxxxxxxxxxxw" - /* 5 */ "hhhhhhhhhhhh" - /* 6 */ "............" + /* z\x* 012345678 */ + /* 0 */ "lllllllll" + /* 1 */ "nghhhhhgn" + /* 2 */ ".h.o.o.h." + /* 3 */ ".h.....h." + /* 4 */ ".h.....h." + /* 5 */ "pghhhhhgp" + /* 6 */ "qqqqqqqqq" // Level 6 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ "............" - /* 2 */ "llllllllllll" - /* 3 */ "xxxxxxxxxxxx" - /* 4 */ "hhhhhhhhhhhh" - /* 5 */ "............" - /* 6 */ "............", + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "lllllllll" + /* 2 */ "nhhhhhhhn" + /* 3 */ ".h.....h." + /* 4 */ "phhhhhhhp" + /* 5 */ "qqqqqqqqq" + /* 6 */ "........." + + // Level 7 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "lllllllll" + /* 3 */ "hhhhhhhhh" + /* 4 */ "qqqqqqqqq" + /* 5 */ "........." + /* 6 */ ".........", // Connectors: - "-1: 8, 1, 1: 2\n" /* Type -1, direction Z- */, + "-1: 4, 2, -1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1666,137 +1568,132 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_66 + }, // WoodenHouse7x5 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_87: - // The data has been exported from the gallery Plains, area index 38, ID 87, created by Aloe_vera + // WoodenHouse9x5: + // The data has been exported from the gallery Plains, area index 41, ID 92, created by xoft { // Size: - 11, 7, 9, // SizeX = 11, SizeY = 7, SizeZ = 9 + 11, 8, 7, // SizeX = 11, SizeY = 8, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 10, 6, 8, // MaxX, MaxY, MaxZ + 10, 7, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 67: 3\n" /* stairs */ - "f: 17: 0\n" /* tree */ - "g: 5: 0\n" /* wood */ - "h: 64: 7\n" /* wooddoorblock */ - "i:102: 0\n" /* glasspane */ - "j: 64:12\n" /* wooddoorblock */ - "k: 53: 2\n" /* woodstairs */ - "l: 53: 7\n" /* woodstairs */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 17: 0\n" /* tree */ + "h: 5: 0\n" /* wood */ + "i: 64: 7\n" /* wooddoorblock */ + "j:102: 0\n" /* glasspane */ + "k: 64:12\n" /* wooddoorblock */ + "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 17: 4\n" /* tree */ - "o: 17: 8\n" /* tree */ - "p: 50: 3\n" /* torch */ - "q: 50: 4\n" /* torch */ - "r: 53: 6\n" /* woodstairs */ - "s: 53: 3\n" /* woodstairs */, + "n: 53: 7\n" /* woodstairs */ + "o: 50: 3\n" /* torch */ + "p: 53: 6\n" /* woodstairs */ + "q: 53: 3\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "....abc...." - /* 1 */ ".ddddddddd." - /* 2 */ ".ddddddddd." - /* 3 */ ".ddddddddd." - /* 4 */ ".ddddddddd." - /* 5 */ ".ddddddddd." - /* 6 */ ".ddddddddd." - /* 7 */ ".ddddddddd." - /* 8 */ "....aec...." + /* 0 */ "aaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaa" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".fggfhfggf." - /* 2 */ ".g.......g." - /* 3 */ ".g.......g." - /* 4 */ ".f.......f." - /* 5 */ ".g.......g." - /* 6 */ ".g.......g." - /* 7 */ ".fggfhfggf." - /* 8 */ "..........." + /* 0 */ "bbbbaaabbbb" + /* 1 */ "baaaaaaaaab" + /* 2 */ "baaaaaaaaab" + /* 3 */ "baaaaaaaaab" + /* 4 */ "baaaaaaaaab" + /* 5 */ "baaaaaaaaab" + /* 6 */ "bbbbbbbbbbb" // Level 2 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".fiifjfiif." - /* 2 */ ".i.......i." - /* 3 */ ".i.......i." - /* 4 */ ".f.......f." - /* 5 */ ".i.......i." - /* 6 */ ".i.......i." - /* 7 */ ".fiifjfiif." - /* 8 */ "..........." + /* 0 */ "....cde...." + /* 1 */ ".fffffffff." + /* 2 */ ".fffffffff." + /* 3 */ ".fffffffff." + /* 4 */ ".fffffffff." + /* 5 */ ".fffffffff." + /* 6 */ "..........." // Level 3 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "kkkkkkkkkkk" - /* 1 */ "lfnnnnnnnfl" - /* 2 */ ".o..p.p..o." - /* 3 */ ".o.......o." - /* 4 */ ".o.......o." - /* 5 */ ".o.......o." - /* 6 */ ".o..q.q..o." - /* 7 */ "rfnnnnnnnfr" - /* 8 */ "sssssssssss" + /* 0 */ "..........." + /* 1 */ ".ghhhihhhg." + /* 2 */ ".h.......h." + /* 3 */ ".h.......h." + /* 4 */ ".h.......h." + /* 5 */ ".ghhhhhhhg." + /* 6 */ "..........." // Level 4 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ "kkkkkkkkkkk" - /* 2 */ "lgggggggggl" - /* 3 */ ".g.......g." - /* 4 */ ".g.......g." - /* 5 */ ".g.......g." - /* 6 */ "rgggggggggr" - /* 7 */ "sssssssssss" - /* 8 */ "..........." + /* 1 */ ".gjjhkhjjg." + /* 2 */ ".j.......j." + /* 3 */ ".j.......j." + /* 4 */ ".j.......j." + /* 5 */ ".gjjjhjjjg." + /* 6 */ "..........." // Level 5 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ "..........." - /* 2 */ "kkkkkkkkkkk" - /* 3 */ "lgggggggggl" - /* 4 */ ".g.......g." - /* 5 */ "rgggggggggr" - /* 6 */ "sssssssssss" - /* 7 */ "..........." - /* 8 */ "..........." + /* 0 */ "lllllllllll" + /* 1 */ "nhhhhhhhhhn" + /* 2 */ ".h..o.o.hh." + /* 3 */ ".h......hh." + /* 4 */ ".h......hh." + /* 5 */ "phhhhhhhhhp" + /* 6 */ "qqqqqqqqqqq" // Level 6 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ "..........." - /* 2 */ "..........." - /* 3 */ "kkkkkkkkkkk" - /* 4 */ "ggggggggggg" - /* 5 */ "sssssssssss" + /* 1 */ "lllllllllll" + /* 2 */ "nhhhhhhhhhn" + /* 3 */ ".hhhhhhhhh." + /* 4 */ "phhhhhhhhhp" + /* 5 */ "qqqqqqqqqqq" /* 6 */ "..........." - /* 7 */ "..........." - /* 8 */ "...........", + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "lllllllllll" + /* 3 */ "hhhhhhhhhhh" + /* 4 */ "qqqqqqqqqqq" + /* 5 */ "..........." + /* 6 */ "...........", // Connectors: - "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 5, 2, -1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1815,217 +1712,139 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_87 + }, // WoodenHouse9x5 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_90: - // The data has been exported from the gallery Plains, area index 39, ID 90, created by STR_Warrior + // WoodenHouse9x5: + // The data has been exported from the gallery Plains, area index 46, ID 97, created by Aloe_vera { // Size: - 15, 8, 16, // SizeX = 15, SizeY = 8, SizeZ = 16 + 11, 8, 7, // SizeX = 11, SizeY = 8, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 14, 7, 15, // MaxX, MaxY, MaxZ + 10, 7, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "A: 53: 7\n" /* woodstairs */ - "B: 53: 4\n" /* woodstairs */ - "C: 53: 5\n" /* woodstairs */ - "D: 53: 6\n" /* woodstairs */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 43: 0\n" /* doubleslab */ - "f: 17: 0\n" /* tree */ - "g: 5: 0\n" /* wood */ - "h: 64: 7\n" /* wooddoorblock */ - "i: 96: 8\n" /* trapdoor */ - "j: 61: 2\n" /* furnace */ - "k: 53: 3\n" /* woodstairs */ - "l: 85: 0\n" /* fence */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 17: 0\n" /* tree */ + "h: 5: 0\n" /* wood */ + "i: 64: 7\n" /* wooddoorblock */ + "j: 53: 3\n" /* woodstairs */ + "k: 85: 0\n" /* fence */ + "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 2\n" /* woodstairs */ - "o: 53: 1\n" /* woodstairs */ - "p: 53: 0\n" /* woodstairs */ - "q: 47: 0\n" /* bookshelf */ - "r:102: 0\n" /* glasspane */ - "s: 64:12\n" /* wooddoorblock */ - "t: 72: 0\n" /* woodplate */ - "u: 17: 4\n" /* tree */ - "v: 17: 8\n" /* tree */ - "w: 50: 3\n" /* torch */ - "x: 50: 1\n" /* torch */ - "y: 50: 4\n" /* torch */ - "z: 50: 2\n" /* torch */, + "n: 53: 1\n" /* woodstairs */ + "o: 53: 0\n" /* woodstairs */ + "p:102: 0\n" /* glasspane */ + "q: 64:12\n" /* wooddoorblock */ + "r: 50: 3\n" /* torch */ + "s: 72: 0\n" /* woodplate */ + "t: 53: 7\n" /* woodstairs */ + "u: 47: 0\n" /* bookshelf */ + "v: 50: 1\n" /* torch */ + "w: 50: 2\n" /* torch */ + "x: 53: 6\n" /* woodstairs */, // Block data: // Level 0 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "......abc......" - /* 1 */ ".ddddddddddddd." - /* 2 */ ".deeeedddddddd." - /* 3 */ ".deeeedddddddd." - /* 4 */ ".ddddddddddddd." - /* 5 */ ".ddddddddddddd." - /* 6 */ ".ddddddddddddd." - /* 7 */ "mddddddddddddd." - /* 8 */ "mmmmmmmmdddddd." - /* 9 */ "mmmmmmmmdddddd." - /* 10 */ "mmmmmmmmdddddd." - /* 11 */ "mmmmmmmmdddddd." - /* 12 */ "mmmmmmmmdddddd." - /* 13 */ "mmmmmmmmdddddd." - /* 14 */ "mmmmmmmmdddddd." - /* 15 */ "mmmmmmmm......." + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaa" // Level 1 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ ".fggggfhfggggf." - /* 2 */ ".g...i.......g." - /* 3 */ ".gjeee......kg." - /* 4 */ ".f..........lg." - /* 5 */ ".g..........ng." - /* 6 */ ".g.olp..ol...g." - /* 7 */ "mfggggggfn...f." - /* 8 */ "mmmmmmmmg....g." - /* 9 */ "mmmmmmmmgk...g." - /* 10 */ "mmmmmmmmgl..kg." - /* 11 */ "mmmmmmmmgn..lg." - /* 12 */ "mmmmmmmmg...ng." - /* 13 */ "mmmmmmmmgq..qg." - /* 14 */ "mmmmmmmmfggggf." - /* 15 */ "mmmmmmmm......." + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "bbbbaaabbbb" + /* 1 */ "baaaaaaaaab" + /* 2 */ "baaaaaaaaab" + /* 3 */ "baaaaaaaaab" + /* 4 */ "baaaaaaaaab" + /* 5 */ "baaaaaaaaab" + /* 6 */ "bbbbbbbbbbb" // Level 2 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ ".fgrrgfsfgrrgf." - /* 2 */ ".g...........g." - /* 3 */ ".g...........r." - /* 4 */ ".f..........tr." - /* 5 */ ".g...........r." - /* 6 */ ".g..t....t...g." - /* 7 */ "mfgrrrrgf....f." - /* 8 */ "mmmmmmmmg....g." - /* 9 */ "mmmmmmmmr....r." - /* 10 */ "mmmmmmmmrt...r." - /* 11 */ "mmmmmmmmr...tr." - /* 12 */ "mmmmmmmmr....r." - /* 13 */ "mmmmmmmmgq..qg." - /* 14 */ "mmmmmmmmfgrrgf." - /* 15 */ "mmmmmmmm......." + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "....cde...." + /* 1 */ ".fffffffff." + /* 2 */ ".fffffffff." + /* 3 */ ".fffffffff." + /* 4 */ ".fffffffff." + /* 5 */ ".fffffffff." + /* 6 */ "..........." // Level 3 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ ".fuuuuuuuuuuuf." - /* 2 */ ".v....w.w....v." - /* 3 */ ".v...........v." - /* 4 */ ".vx..........v." - /* 5 */ ".v...........v." - /* 6 */ ".v......y....v." - /* 7 */ "mfuuuuuufx..zv." - /* 8 */ "mmmmmmmmv....v." - /* 9 */ "mmmmmmmmv....v." - /* 10 */ "mmmmmmmmv....v." - /* 11 */ "mmmmmmmmv....v." - /* 12 */ "mmmmmmmmv....v." - /* 13 */ "mmmmmmmmv.yy.v." - /* 14 */ "mmmmmmmmfuuuuf." - /* 15 */ "mmmmmmmm......." + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".ghhhihhhg." + /* 2 */ ".hj.....jh." + /* 3 */ ".hk.....kh." + /* 4 */ ".hl.nko.lh." + /* 5 */ ".ghhhhhhhg." + /* 6 */ "..........." // Level 4 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "nnnnnnnnnnnnnno" - /* 1 */ "pgggggggggggggo" - /* 2 */ "pgAAAAAAAAAABgo" - /* 3 */ "pgC.........Bgo" - /* 4 */ "pgC.........Bgo" - /* 5 */ "pgC.........Bgo" - /* 6 */ "pgCDDDDDDD..Bgo" - /* 7 */ "pggggggggC..Bgo" - /* 8 */ "pkkkkkkpgC..Bgo" - /* 9 */ "mmmmmmmpgC..Bgo" - /* 10 */ "mmmmmmmpgC..Bgo" - /* 11 */ "mmmmmmmpgC..Bgo" - /* 12 */ "mmmmmmmpgC..Bgo" - /* 13 */ "mmmmmmmpgCDDBgo" - /* 14 */ "mmmmmmmpggggggo" - /* 15 */ "mmmmmmmpkkkkkkk" + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".gpphqhppg." + /* 2 */ ".p..r.r..p." + /* 3 */ ".ps.....sp." + /* 4 */ ".p...s...p." + /* 5 */ ".gppphpppg." + /* 6 */ "..........." // Level 5 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "mmmmmmmmmmmmmmm" - /* 1 */ "mpnnnnnnnnnnnom" - /* 2 */ "mpgggggggggggom" - /* 3 */ "mpgggggggggggom" - /* 4 */ "mpgggggggggggom" - /* 5 */ "mpgggggggggggom" - /* 6 */ "mpgggggggggggom" - /* 7 */ "mpkkkkkkkggggom" - /* 8 */ "mmmmmmmmpggggom" - /* 9 */ "mmmmmmmmpggggom" - /* 10 */ "mmmmmmmmpggggom" - /* 11 */ "mmmmmmmmpggggom" - /* 12 */ "mmmmmmmmpggggom" - /* 13 */ "mmmmmmmmpggggom" - /* 14 */ "mmmmmmmmkkkkkom" - /* 15 */ "mmmmmmmmmmmmmmm" + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "lllllllllll" + /* 1 */ "thhhhhhhhht" + /* 2 */ ".huuuuuuuh." + /* 3 */ ".hv.....wh." + /* 4 */ ".huuuuuuuh." + /* 5 */ "xhhhhhhhhhx" + /* 6 */ "jjjjjjjjjjj" // Level 6 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "mmmmmmmmmmmmmmm" - /* 1 */ "mmmmmmmmmmmmmmm" - /* 2 */ "mmnnnnnnnnnnnmm" - /* 3 */ "mmpgggggggggomm" - /* 4 */ "mmpgggggggggomm" - /* 5 */ "mmpgggggggggomm" - /* 6 */ "mmkkkkkkkkggomm" - /* 7 */ "mmmmmmmmmpggomm" - /* 8 */ "mmmmmmmmmpggomm" - /* 9 */ "mmmmmmmmmpggomm" - /* 10 */ "mmmmmmmmmpggomm" - /* 11 */ "mmmmmmmmmpggomm" - /* 12 */ "mmmmmmmmmpggomm" - /* 13 */ "mmmmmmmmmkkkomm" - /* 14 */ "mmmmmmmmmmmmmmm" - /* 15 */ "mmmmmmmmmmmmmmm" + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "lllllllllll" + /* 2 */ "thhhhhhhhht" + /* 3 */ ".h.......h." + /* 4 */ "xhhhhhhhhhx" + /* 5 */ "jjjjjjjjjjj" + /* 6 */ "..........." // Level 7 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "mmmmmmmmmmmmmmm" - /* 1 */ "mmmmmmmmmmmmmmm" - /* 2 */ "mmmmmmmmmmmmmmm" - /* 3 */ "mmmpnnnnnnnommm" - /* 4 */ "mmmpgggggggommm" - /* 5 */ "mmmpkkkkkkpommm" - /* 6 */ "mmmmmmmmmmpommm" - /* 7 */ "mmmmmmmmmmpommm" - /* 8 */ "mmmmmmmmmmpommm" - /* 9 */ "mmmmmmmmmmpommm" - /* 10 */ "mmmmmmmmmmpommm" - /* 11 */ "mmmmmmmmmmpommm" - /* 12 */ "mmmmmmmmmmpkmmm" - /* 13 */ "mmmmmmmmmmmmmmm" - /* 14 */ "mmmmmmmmmmmmmmm" - /* 15 */ "mmmmmmmmmmmmmmm", + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "lllllllllll" + /* 3 */ "hhhhhhhhhhh" + /* 4 */ "jjjjjjjjjjj" + /* 5 */ "..........." + /* 6 */ "...........", // Connectors: - "-1: 7, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2044,114 +1863,170 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_90 + }, // WoodenHouse9x5 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_91: - // The data has been exported from the gallery Plains, area index 40, ID 91, created by xoft + // WoodenHouse9x5Fence: + // The data has been exported from the gallery Plains, area index 9, ID 26, created by Aloe_vera { // Size: - 9, 7, 7, // SizeX = 9, SizeY = 7, SizeZ = 7 + 10, 8, 11, // SizeX = 10, SizeY = 8, SizeZ = 11 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 8, 6, 6, // MaxX, MaxY, MaxZ + 9, 7, 10, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 2: 0\n" /* grass */ - "b: 3: 0\n" /* dirt */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 17: 0\n" /* tree */ - "h: 5: 0\n" /* wood */ - "i: 64: 7\n" /* wooddoorblock */ - "j:102: 0\n" /* glasspane */ - "k: 64:12\n" /* wooddoorblock */ - "l: 53: 2\n" /* woodstairs */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 4: 0\n" /* cobblestone */ + "d: 5: 0\n" /* wood */ + "e: 67: 2\n" /* stairs */ + "f: 43: 0\n" /* doubleslab */ + "g: 67: 0\n" /* stairs */ + "h: 67: 3\n" /* stairs */ + "i: 17: 0\n" /* tree */ + "j: 53: 1\n" /* woodstairs */ + "k: 85: 0\n" /* fence */ + "l: 53: 0\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 7\n" /* woodstairs */ - "o: 50: 3\n" /* torch */ - "p: 53: 6\n" /* woodstairs */ - "q: 53: 3\n" /* woodstairs */, + "n: 64: 6\n" /* wooddoorblock */ + "o: 64: 0\n" /* wooddoorblock */ + "p:102: 0\n" /* glasspane */ + "q: 72: 0\n" /* woodplate */ + "r: 64:12\n" /* wooddoorblock */ + "s: 64: 8\n" /* wooddoorblock */ + "t: 53: 5\n" /* woodstairs */ + "u: 53: 4\n" /* woodstairs */ + "v: 50: 1\n" /* torch */ + "w: 50: 2\n" /* torch */, // Block data: // Level 0 - /* z\x* 012345678 */ - /* 0 */ "aaabbbaaa" - /* 1 */ "abbbbbbba" - /* 2 */ "abbbbbbba" - /* 3 */ "abbbbbbba" - /* 4 */ "abbbbbbba" - /* 5 */ "abbbbbbba" - /* 6 */ "aaaaaaaaa" + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "aaaaaaaaaa" + /* 1 */ "aaaaaaaaaa" + /* 2 */ "aaaaaaaaaa" + /* 3 */ "aaaaaaaaaa" + /* 4 */ "aaaaaaaaaa" + /* 5 */ "aaaaaaaaaa" + /* 6 */ "aaaaaaaaaa" + /* 7 */ "aaaaaaaaaa" + /* 8 */ "aaaaaaaaaa" + /* 9 */ "aaaaaaaaaa" + /* 10 */ "aaaaaaaaaa" // Level 1 - /* z\x* 012345678 */ - /* 0 */ "...cde..." - /* 1 */ ".fffffff." - /* 2 */ ".fffffff." - /* 3 */ ".fffffff." - /* 4 */ ".fffffff." - /* 5 */ ".fffffff." - /* 6 */ "........." + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "bbbbbbbbbb" + /* 1 */ "baaaaabbbb" + /* 2 */ "baaaaabbbb" + /* 3 */ "baaaaaaaaa" + /* 4 */ "aaaaaaaaaa" + /* 5 */ "aaaaaaaaaa" + /* 6 */ "aaaaaaaaaa" + /* 7 */ "baaaaaaaaa" + /* 8 */ "baaaaaaaaa" + /* 9 */ "baaaaabbbb" + /* 10 */ "bbbbbbbbbb" // Level 2 - /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ ".ghhihhg." - /* 2 */ ".h.....h." - /* 3 */ ".h.....h." - /* 4 */ ".h.....h." - /* 5 */ ".ghhhhhg." - /* 6 */ "........." + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "......mmmm" + /* 1 */ ".cccccmmmm" + /* 2 */ ".cdddcmmmm" + /* 3 */ ".cdddcbbbb" + /* 4 */ "ecfffcbbbb" + /* 5 */ "gcffffbbbb" + /* 6 */ "hcfffcbbbb" + /* 7 */ ".cfffcbbbb" + /* 8 */ ".cfffcbbbb" + /* 9 */ ".cccccmmmm" + /* 10 */ "......mmmm" // Level 3 - /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ ".gjhkhjg." - /* 2 */ ".j.....j." - /* 3 */ ".j.....j." - /* 4 */ ".j.....j." - /* 5 */ ".gjjhjjg." - /* 6 */ "........." + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "......mmmm" + /* 1 */ ".idddimmmm" + /* 2 */ ".djkldmmmm" + /* 3 */ ".d...dkkkk" + /* 4 */ ".d...d...k" + /* 5 */ ".n...o...k" + /* 6 */ ".d...d...k" + /* 7 */ ".dff.d...k" + /* 8 */ ".d...dkkkk" + /* 9 */ ".idddimmmm" + /* 10 */ "......mmmm" // Level 4 - /* z\x* 012345678 */ - /* 0 */ "lllllllll" - /* 1 */ "nghhhhhgn" - /* 2 */ ".h.o.o.h." - /* 3 */ ".h.....h." - /* 4 */ ".h.....h." - /* 5 */ "pghhhhhgp" - /* 6 */ "qqqqqqqqq" + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "......mmmm" + /* 1 */ ".ipppimmmm" + /* 2 */ ".p.q.pmmmm" + /* 3 */ ".p...p...." + /* 4 */ ".d...d...." + /* 5 */ ".r...s...." + /* 6 */ ".d...d...." + /* 7 */ ".p...p...." + /* 8 */ ".p...p...." + /* 9 */ ".ipppimmmm" + /* 10 */ "......mmmm" // Level 5 - /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "lllllllll" - /* 2 */ "nhhhhhhhn" - /* 3 */ ".h.....h." - /* 4 */ "phhhhhhhp" - /* 5 */ "qqqqqqqqq" - /* 6 */ "........." + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "lt...ujmmm" + /* 1 */ "lidddijmmm" + /* 2 */ "ld...djmmm" + /* 3 */ "ld...dj..." + /* 4 */ "ldv.wdj..." + /* 5 */ "ld...dj..." + /* 6 */ "ldv.wdj..." + /* 7 */ "ld...dj..." + /* 8 */ "ld...dj..." + /* 9 */ "lidddijmmm" + /* 10 */ "lt...ujmmm" // Level 6 - /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "lllllllll" - /* 3 */ "hhhhhhhhh" - /* 4 */ "qqqqqqqqq" - /* 5 */ "........." - /* 6 */ ".........", + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "mlt.ujmmmm" + /* 1 */ "mldddjmmmm" + /* 2 */ "mld.djmmmm" + /* 3 */ "mld.djm..." + /* 4 */ "mld.djm..." + /* 5 */ "mld.djm..." + /* 6 */ "mld.djm..." + /* 7 */ "mld.djm..." + /* 8 */ "mld.djm..." + /* 9 */ "mldddjmmmm" + /* 10 */ "mlt.ujmmmm" + + // Level 7 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "mmldjmmmmm" + /* 1 */ "mmldjmmmmm" + /* 2 */ "mmldjmmmmm" + /* 3 */ "mmldjmm..." + /* 4 */ "mmldjmm..." + /* 5 */ "mmldjmm..." + /* 6 */ "mmldjmm..." + /* 7 */ "mmldjmm..." + /* 8 */ "mmldjmm..." + /* 9 */ "mmldjmmmmm" + /* 10 */ "mmldjmmmmm", // Connectors: - "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 0, 2, 5: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2170,108 +2045,162 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_91 + }, // WoodenHouse9x5Fence /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_92: - // The data has been exported from the gallery Plains, area index 41, ID 92, created by xoft + // WoodenHouse9x7: + // The data has been exported from the gallery Plains, area index 52, ID 103, created by Aloe_vera { // Size: - 11, 6, 7, // SizeX = 11, SizeY = 6, SizeZ = 7 + 11, 9, 9, // SizeX = 11, SizeY = 9, SizeZ = 9 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 10, 5, 6, // MaxX, MaxY, MaxZ + 10, 8, 8, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 17: 0\n" /* tree */ - "f: 5: 0\n" /* wood */ - "g: 64: 7\n" /* wooddoorblock */ - "h:102: 0\n" /* glasspane */ - "i: 64:12\n" /* wooddoorblock */ - "j: 53: 2\n" /* woodstairs */ - "k: 53: 7\n" /* woodstairs */ - "l: 50: 3\n" /* torch */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 17: 0\n" /* tree */ + "h: 5: 0\n" /* wood */ + "i: 64: 7\n" /* wooddoorblock */ + "j:102: 0\n" /* glasspane */ + "k: 64:12\n" /* wooddoorblock */ + "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 6\n" /* woodstairs */ - "o: 53: 3\n" /* woodstairs */, + "n: 53: 7\n" /* woodstairs */ + "o: 50: 3\n" /* torch */ + "p: 50: 4\n" /* torch */ + "q: 53: 6\n" /* woodstairs */ + "r: 53: 3\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "....abc...." - /* 1 */ ".ddddddddd." - /* 2 */ ".ddddddddd." - /* 3 */ ".ddddddddd." - /* 4 */ ".ddddddddd." - /* 5 */ ".ddddddddd." - /* 6 */ "..........." + /* 0 */ "aaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaa" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".efffgfffe." - /* 2 */ ".f.......f." - /* 3 */ ".f.......f." - /* 4 */ ".f.......f." - /* 5 */ ".efffffffe." - /* 6 */ "..........." + /* 0 */ "bbbbaaabbbb" + /* 1 */ "baaaaaaaaab" + /* 2 */ "baaaaaaaaab" + /* 3 */ "baaaaaaaaab" + /* 4 */ "baaaaaaaaab" + /* 5 */ "baaaaaaaaab" + /* 6 */ "baaaaaaaaab" + /* 7 */ "baaaaaaaaab" + /* 8 */ "bbbbbbbbbbb" // Level 2 /* z\x* 1 */ /* * 01234567890 */ + /* 0 */ "....cde...." + /* 1 */ ".fffffffff." + /* 2 */ ".fffffffff." + /* 3 */ ".fffffffff." + /* 4 */ ".fffffffff." + /* 5 */ ".fffffffff." + /* 6 */ ".fffffffff." + /* 7 */ ".fffffffff." + /* 8 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ ".ehhfifhhe." + /* 1 */ ".ghhhihhhg." /* 2 */ ".h.......h." /* 3 */ ".h.......h." /* 4 */ ".h.......h." - /* 5 */ ".ehhhfhhhe." - /* 6 */ "..........." + /* 5 */ ".h.......h." + /* 6 */ ".h.......h." + /* 7 */ ".ghhhhhhhg." + /* 8 */ "..........." - // Level 3 + // Level 4 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "jjjjjjjjjjj" - /* 1 */ "kfffffffffk" - /* 2 */ ".f..l.l.ff." - /* 3 */ ".f......ff." - /* 4 */ ".f......ff." - /* 5 */ "nfffffffffn" - /* 6 */ "ooooooooooo" + /* 0 */ "..........." + /* 1 */ ".gjjhkhjjg." + /* 2 */ ".j.......j." + /* 3 */ ".j.......j." + /* 4 */ ".h.......h." + /* 5 */ ".j.......j." + /* 6 */ ".j.......j." + /* 7 */ ".gjjjhjjjg." + /* 8 */ "..........." - // Level 4 + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "lllllllllll" + /* 1 */ "nhhhhhhhhhn" + /* 2 */ ".h..o.o..h." + /* 3 */ ".h.......h." + /* 4 */ ".h.......h." + /* 5 */ ".h.......h." + /* 6 */ ".h...p...h." + /* 7 */ "qhhhhhhhhhq" + /* 8 */ "rrrrrrrrrrr" + + // Level 6 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ "jjjjjjjjjjj" - /* 2 */ "kfffffffffk" - /* 3 */ ".fffffffff." - /* 4 */ "nfffffffffn" - /* 5 */ "ooooooooooo" - /* 6 */ "..........." + /* 1 */ "lllllllllll" + /* 2 */ "nhhhhhhhhhn" + /* 3 */ ".h.......h." + /* 4 */ ".h.......h." + /* 5 */ ".h.......h." + /* 6 */ "qhhhhhhhhhq" + /* 7 */ "rrrrrrrrrrr" + /* 8 */ "..........." - // Level 5 + // Level 7 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." - /* 2 */ "jjjjjjjjjjj" - /* 3 */ "fffffffffff" - /* 4 */ "ooooooooooo" - /* 5 */ "..........." - /* 6 */ "...........", + /* 2 */ "lllllllllll" + /* 3 */ "nhhhhhhhhhn" + /* 4 */ ".h.......h." + /* 5 */ "qhhhhhhhhhq" + /* 6 */ "rrrrrrrrrrr" + /* 7 */ "..........." + /* 8 */ "..........." + + // Level 8 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "lllllllllll" + /* 4 */ "hhhhhhhhhhh" + /* 5 */ "rrrrrrrrrrr" + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "...........", // Connectors: - "-1: 5, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2290,139 +2219,201 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_92 + }, // WoodenHouse9x7 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_93: - // The data has been exported from the gallery Plains, area index 42, ID 93, created by xoft + // WoodenHouse9x7Butcher: + // The data has been exported from the gallery Plains, area index 48, ID 99, created by Aloe_vera { // Size: - 11, 6, 11, // SizeX = 11, SizeY = 6, SizeZ = 11 + 11, 9, 13, // SizeX = 11, SizeY = 9, SizeZ = 13 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 10, 5, 10, // MaxX, MaxY, MaxZ + 10, 8, 12, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 17: 0\n" /* tree */ - "f: 5: 0\n" /* wood */ - "g: 64: 7\n" /* wooddoorblock */ - "h:102: 0\n" /* glasspane */ - "i: 64:12\n" /* wooddoorblock */ - "j: 53: 2\n" /* woodstairs */ - "k: 53: 7\n" /* woodstairs */ - "l: 53: 1\n" /* woodstairs */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 43: 0\n" /* doubleslab */ + "h: 17: 0\n" /* tree */ + "i: 5: 0\n" /* wood */ + "j: 64: 7\n" /* wooddoorblock */ + "k: 53: 3\n" /* woodstairs */ + "l: 85: 0\n" /* fence */ "m: 19: 0\n" /* sponge */ - "n: 50: 3\n" /* torch */ - "o: 50: 4\n" /* torch */ - "p: 53: 6\n" /* woodstairs */ - "q: 50: 1\n" /* torch */ - "r: 50: 2\n" /* torch */ - "s: 53: 3\n" /* woodstairs */ - "t: 53: 0\n" /* woodstairs */ - "u: 53: 5\n" /* woodstairs */ - "v: 53: 4\n" /* woodstairs */, + "n: 53: 2\n" /* woodstairs */ + "o:102: 0\n" /* glasspane */ + "p: 64:12\n" /* wooddoorblock */ + "q: 72: 0\n" /* woodplate */ + "r: 53: 7\n" /* woodstairs */ + "s: 50: 1\n" /* torch */ + "t: 50: 2\n" /* torch */ + "u: 53: 6\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "....abc...." - /* 1 */ ".ddddddddd." - /* 2 */ ".ddddddddd." - /* 3 */ ".ddddddddd." - /* 4 */ ".ddddddddd." - /* 5 */ ".ddddddddd." - /* 6 */ ".....ddddd." - /* 7 */ "mmmm.ddddd." - /* 8 */ "mmmm.ddddd." - /* 9 */ "mmmm.ddddd." - /* 10 */ "mmmm......." + /* 0 */ "aaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaa" + /* 9 */ "aaaaaaaaaaa" + /* 10 */ "aaaaaaaaaaa" + /* 11 */ "aaaaaaaaaaa" + /* 12 */ "aaaaaaaaaaa" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".efffgfffe." - /* 2 */ ".f.......f." - /* 3 */ ".f.......f." - /* 4 */ ".f.......f." - /* 5 */ ".efffe...f." - /* 6 */ ".....f...f." - /* 7 */ "mmmm.f...f." - /* 8 */ "mmmm.f...f." - /* 9 */ "mmmm.efffe." - /* 10 */ "mmmm......." + /* 0 */ "bbbbaaabbbb" + /* 1 */ "baaaaaaaaab" + /* 2 */ "baaaaaaaaab" + /* 3 */ "baaaaaaaaab" + /* 4 */ "baaaaaaaaab" + /* 5 */ "baaaaaaaaab" + /* 6 */ "baaaaaaaaab" + /* 7 */ "baaaaaaaaab" + /* 8 */ "bbaaaaaaabb" + /* 9 */ "bbaaaaaaabb" + /* 10 */ "bbaaaaaaabb" + /* 11 */ "bbaaaaaaabb" + /* 12 */ "bbaaaaaaabb" // Level 2 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".ehhfifhhe." - /* 2 */ ".h.......h." - /* 3 */ ".h.......h." - /* 4 */ ".h.......h." - /* 5 */ ".ehhhe...f." - /* 6 */ ".....h...h." - /* 7 */ "mmmm.h...h." - /* 8 */ "mmmm.h...h." - /* 9 */ "mmmm.ehhhe." - /* 10 */ "mmmm......." + /* 0 */ "....cde...." + /* 1 */ ".fffffffff." + /* 2 */ ".fggggffff." + /* 3 */ ".fggggffff." + /* 4 */ ".fggggffff." + /* 5 */ ".fggggffff." + /* 6 */ ".fggggffff." + /* 7 */ ".fffffffff." + /* 8 */ "..bbbbbbb.." + /* 9 */ "mmbbbbbbbmm" + /* 10 */ "mmbbbbbbbmm" + /* 11 */ "mmbbbbbbbmm" + /* 12 */ "mmbbbbbbbmm" // Level 3 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "jjjjjjjjjjj" - /* 1 */ "kfffffffffl" - /* 2 */ ".f..n.n..fl" - /* 3 */ ".f.......fl" - /* 4 */ ".f...o...fl" - /* 5 */ "pfffffq.rfl" - /* 6 */ "sssssf...fl" - /* 7 */ "mmmmtf...fl" - /* 8 */ "mmmmtf...fl" - /* 9 */ "mmmmtfffffl" - /* 10 */ "mmmmtu...vl" + /* 0 */ "..........." + /* 1 */ ".hiiijiiih." + /* 2 */ ".i.g....ki." + /* 3 */ ".i.g....li." + /* 4 */ ".i.g....ni." + /* 5 */ ".i.......i." + /* 6 */ ".i.......i." + /* 7 */ ".hiiijiiih." + /* 8 */ "..l.....l.." + /* 9 */ "mml.....lmm" + /* 10 */ "mml.....lmm" + /* 11 */ "mml.....lmm" + /* 12 */ "mmlllllllmm" // Level 4 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ "jjjjjjjjjl." - /* 2 */ "kffffffffl." - /* 3 */ ".f......fl." - /* 4 */ "pffffff.fl." - /* 5 */ "ssssssf.fl." - /* 6 */ ".....tf.fl." - /* 7 */ "mmmm.tf.fl." - /* 8 */ "mmmm.tf.fl." - /* 9 */ "mmmm.tfffl." - /* 10 */ "mmmm.tu.vl." + /* 1 */ ".hooipiooh." + /* 2 */ ".o.......o." + /* 3 */ ".o......qo." + /* 4 */ ".i.......i." + /* 5 */ ".o.......o." + /* 6 */ ".o.......o." + /* 7 */ ".hooipiooh." + /* 8 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" // Level 5 /* z\x* 1 */ /* * 01234567890 */ + /* 0 */ "nnnnnnnnnnn" + /* 1 */ "riiiiiiiiir" + /* 2 */ ".i.......i." + /* 3 */ ".i.......i." + /* 4 */ ".is.....ti." + /* 5 */ ".i.......i." + /* 6 */ ".i.......i." + /* 7 */ "uiiiiiiiiiu" + /* 8 */ "kkkkkkkkkkk" + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "nnnnnnnnnnn" + /* 2 */ "riiiiiiiiir" + /* 3 */ ".i.......i." + /* 4 */ ".i.......i." + /* 5 */ ".i.......i." + /* 6 */ "uiiiiiiiiiu" + /* 7 */ "kkkkkkkkkkk" + /* 8 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "nnnnnnnnnnn" + /* 3 */ "riiiiiiiiir" + /* 4 */ ".i.......i." + /* 5 */ "uiiiiiiiiiu" + /* 6 */ "kkkkkkkkkkk" + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" + + // Level 8 + /* z\x* 1 */ + /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." - /* 2 */ "jjjjjjjjj.." - /* 3 */ "ffffffffl.." - /* 4 */ "sssssstfl.." - /* 5 */ "......tfl.." - /* 6 */ "......tfl.." - /* 7 */ "mmmm..tfl.." - /* 8 */ "mmmm..tfl.." - /* 9 */ "mmmm..tfl.." - /* 10 */ "mmmm..tfl..", + /* 2 */ "..........." + /* 3 */ "nnnnnnnnnnn" + /* 4 */ "iiiiiiiiiii" + /* 5 */ "kkkkkkkkkkk" + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm", // Connectors: - "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2441,137 +2432,165 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_93 + }, // WoodenHouse9x7Butcher /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_94: - // The data has been exported from the gallery Plains, area index 43, ID 94, created by xoft + // WoodenHouse9x7DoubleDoor: + // The data has been exported from the gallery Plains, area index 38, ID 87, created by Aloe_vera { // Size: - 15, 6, 11, // SizeX = 15, SizeY = 6, SizeZ = 11 + 11, 9, 9, // SizeX = 11, SizeY = 9, SizeZ = 9 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 14, 5, 10, // MaxX, MaxY, MaxZ + 10, 8, 8, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 17: 0\n" /* tree */ - "f: 5: 0\n" /* wood */ - "g: 64: 7\n" /* wooddoorblock */ - "h:102: 0\n" /* glasspane */ - "i: 64:12\n" /* wooddoorblock */ - "j: 53: 2\n" /* woodstairs */ - "k: 53: 0\n" /* woodstairs */ - "l: 53: 1\n" /* woodstairs */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 67: 3\n" /* stairs */ + "h: 17: 0\n" /* tree */ + "i: 5: 0\n" /* wood */ + "j: 64: 7\n" /* wooddoorblock */ + "k:102: 0\n" /* glasspane */ + "l: 64:12\n" /* wooddoorblock */ "m: 19: 0\n" /* sponge */ - "n: 50: 3\n" /* torch */ - "o: 50: 4\n" /* torch */ - "p: 50: 2\n" /* torch */ - "q: 50: 1\n" /* torch */ - "r: 53: 3\n" /* woodstairs */ - "s: 53: 5\n" /* woodstairs */ - "t: 53: 4\n" /* woodstairs */, + "n: 53: 2\n" /* woodstairs */ + "o: 53: 7\n" /* woodstairs */ + "p: 17: 4\n" /* tree */ + "q: 17: 8\n" /* tree */ + "r: 50: 3\n" /* torch */ + "s: 50: 4\n" /* torch */ + "t: 53: 6\n" /* woodstairs */ + "u: 53: 3\n" /* woodstairs */, // Block data: // Level 0 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "......abc......" - /* 1 */ ".ddddddddddddd." - /* 2 */ ".ddddddddddddd." - /* 3 */ ".ddddddddddddd." - /* 4 */ ".ddddddddddddd." - /* 5 */ ".ddddddddddddd." - /* 6 */ ".ddddd...ddddd." - /* 7 */ ".ddddd...ddddd." - /* 8 */ ".ddddd...ddddd." - /* 9 */ ".ddddd...ddddd." - /* 10 */ "..............." + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaa" // Level 1 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ ".efffffgfffffe." - /* 2 */ ".f...........f." - /* 3 */ ".f...........f." - /* 4 */ ".f...........f." - /* 5 */ ".f...efffe...f." - /* 6 */ ".f...f...f...f." - /* 7 */ ".f...f...f...f." - /* 8 */ ".f...f...f...f." - /* 9 */ ".efffe...efffe." - /* 10 */ "..............." + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "bbbbaaabbbb" + /* 1 */ "baaaaaaaaab" + /* 2 */ "baaaaaaaaab" + /* 3 */ "baaaaaaaaab" + /* 4 */ "baaaaaaaaab" + /* 5 */ "baaaaaaaaab" + /* 6 */ "baaaaaaaaab" + /* 7 */ "baaaaaaaaab" + /* 8 */ "bbbbaaabbbb" // Level 2 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ ".ehhhhfifhhhhe." - /* 2 */ ".h...........h." - /* 3 */ ".h...........h." - /* 4 */ ".h...........h." - /* 5 */ ".f...ehhhe...f." - /* 6 */ ".h...h...h...h." - /* 7 */ ".h...h...h...h." - /* 8 */ ".h...h...h...h." - /* 9 */ ".ehhhe...ehhhe." - /* 10 */ "..............." + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "....cde...." + /* 1 */ ".fffffffff." + /* 2 */ ".fffffffff." + /* 3 */ ".fffffffff." + /* 4 */ ".fffffffff." + /* 5 */ ".fffffffff." + /* 6 */ ".fffffffff." + /* 7 */ ".fffffffff." + /* 8 */ "....cge...." // Level 3 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "jjjjjjjjjjjjjjj" - /* 1 */ "kfffffffffffffl" - /* 2 */ "kf....n.n....fl" - /* 3 */ "kf...........fl" - /* 4 */ "kf...o...o...fl" - /* 5 */ "kf..pfffffq..fl" - /* 6 */ "kf...frrrf...fl" - /* 7 */ "kf...fl.kf...fl" - /* 8 */ "kf...fl.kf...fl" - /* 9 */ "kfffffl.kfffffl" - /* 10 */ "ks...tl.ks...tl" + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".hiihjhiih." + /* 2 */ ".i.......i." + /* 3 */ ".i.......i." + /* 4 */ ".h.......h." + /* 5 */ ".i.......i." + /* 6 */ ".i.......i." + /* 7 */ ".hiihjhiih." + /* 8 */ "..........." // Level 4 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ ".jjjjjjjjjjjjl." - /* 2 */ ".kfffffffffffl." - /* 3 */ ".kfffffffffffl." - /* 4 */ ".kfffffffffffl." - /* 5 */ ".kffflrrrrfffl." - /* 6 */ ".kfffl...kfffl." - /* 7 */ ".kfffl...kfffl." - /* 8 */ ".kfffl...kfffl." - /* 9 */ ".kfffl...kfffl." - /* 10 */ ".ks.tl...ks.tl." + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".hkkhlhkkh." + /* 2 */ ".k.......k." + /* 3 */ ".k.......k." + /* 4 */ ".h.......h." + /* 5 */ ".k.......k." + /* 6 */ ".k.......k." + /* 7 */ ".hkkhlhkkh." + /* 8 */ "..........." // Level 5 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ "..............." - /* 2 */ "..kjjjjjjjjjj.." - /* 3 */ "..kfffffffffl.." - /* 4 */ "..kflrrrrrkfl.." - /* 5 */ "..kfl.....kfl.." - /* 6 */ "..kfl.....kfl.." - /* 7 */ "..kfl.....kfl.." - /* 8 */ "..kfl.....kfl.." - /* 9 */ "..kfl.....kfl.." - /* 10 */ "..kfl.....kfl..", + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "nnnnnnnnnnn" + /* 1 */ "ohpppppppho" + /* 2 */ ".q..r.r..q." + /* 3 */ ".q.......q." + /* 4 */ ".q.......q." + /* 5 */ ".q.......q." + /* 6 */ ".q..s.s..q." + /* 7 */ "thpppppppht" + /* 8 */ "uuuuuuuuuuu" + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "nnnnnnnnnnn" + /* 2 */ "oiiiiiiiiio" + /* 3 */ ".i.......i." + /* 4 */ ".i.......i." + /* 5 */ ".i.......i." + /* 6 */ "tiiiiiiiiit" + /* 7 */ "uuuuuuuuuuu" + /* 8 */ "..........." + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "nnnnnnnnnnn" + /* 3 */ "oiiiiiiiiio" + /* 4 */ ".i.......i." + /* 5 */ "tiiiiiiiiit" + /* 6 */ "uuuuuuuuuuu" + /* 7 */ "..........." + /* 8 */ "..........." + + // Level 8 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "nnnnnnnnnnn" + /* 4 */ "iiiiiiiiiii" + /* 5 */ "uuuuuuuuuuu" + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "...........", // Connectors: - "-1: 7, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2590,115 +2609,259 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_94 + }, // WoodenHouse9x7DoubleDoor /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_97: - // The data has been exported from the gallery Plains, area index 46, ID 97, created by Aloe_vera + // WoodenHouseL13x14: + // The data has been exported from the gallery Plains, area index 39, ID 90, created by STR_Warrior { // Size: - 11, 6, 7, // SizeX = 11, SizeY = 6, SizeZ = 7 + 15, 10, 16, // SizeX = 15, SizeY = 10, SizeZ = 16 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 10, 5, 6, // MaxX, MaxY, MaxZ + 14, 9, 15, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 17: 0\n" /* tree */ - "f: 5: 0\n" /* wood */ - "g: 64: 7\n" /* wooddoorblock */ - "h: 53: 3\n" /* woodstairs */ - "i: 85: 0\n" /* fence */ - "j: 53: 2\n" /* woodstairs */ - "k: 53: 1\n" /* woodstairs */ - "l: 53: 0\n" /* woodstairs */ + "A: 50: 4\n" /* torch */ + "B: 50: 2\n" /* torch */ + "C: 53: 7\n" /* woodstairs */ + "D: 53: 4\n" /* woodstairs */ + "E: 53: 5\n" /* woodstairs */ + "F: 53: 6\n" /* woodstairs */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 43: 0\n" /* doubleslab */ + "h: 17: 0\n" /* tree */ + "i: 5: 0\n" /* wood */ + "j: 64: 7\n" /* wooddoorblock */ + "k: 96: 8\n" /* trapdoor */ + "l: 61: 2\n" /* furnace */ "m: 19: 0\n" /* sponge */ - "n:102: 0\n" /* glasspane */ - "o: 64:12\n" /* wooddoorblock */ - "p: 50: 3\n" /* torch */ - "q: 72: 0\n" /* woodplate */ - "r: 53: 7\n" /* woodstairs */ + "n: 53: 3\n" /* woodstairs */ + "o: 85: 0\n" /* fence */ + "p: 53: 2\n" /* woodstairs */ + "q: 53: 1\n" /* woodstairs */ + "r: 53: 0\n" /* woodstairs */ "s: 47: 0\n" /* bookshelf */ - "t: 50: 1\n" /* torch */ - "u: 50: 2\n" /* torch */ - "v: 53: 6\n" /* woodstairs */, + "t:102: 0\n" /* glasspane */ + "u: 64:12\n" /* wooddoorblock */ + "v: 72: 0\n" /* woodplate */ + "w: 17: 4\n" /* tree */ + "x: 17: 8\n" /* tree */ + "y: 50: 3\n" /* torch */ + "z: 50: 1\n" /* torch */, // Block data: // Level 0 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "....abc...." - /* 1 */ ".ddddddddd." - /* 2 */ ".ddddddddd." - /* 3 */ ".ddddddddd." - /* 4 */ ".ddddddddd." - /* 5 */ ".ddddddddd." - /* 6 */ "..........." + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "aaaaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaaaaaa" + /* 8 */ "mmmmmmmmaaaaaaa" + /* 9 */ "mmmmmmmmaaaaaaa" + /* 10 */ "mmmmmmmmaaaaaaa" + /* 11 */ "mmmmmmmmaaaaaaa" + /* 12 */ "mmmmmmmmaaaaaaa" + /* 13 */ "mmmmmmmmaaaaaaa" + /* 14 */ "mmmmmmmmaaaaaaa" + /* 15 */ "mmmmmmmmaaaaaaa" // Level 1 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".efffgfffe." - /* 2 */ ".fh.....hf." - /* 3 */ ".fi.....if." - /* 4 */ ".fj.kil.jf." - /* 5 */ ".efffffffe." - /* 6 */ "..........." + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "bbbbbbaaabbbbbb" + /* 1 */ "baaaaaaaaaaaaab" + /* 2 */ "baaaaaaaaaaaaab" + /* 3 */ "baaaaaaaaaaaaab" + /* 4 */ "baaaaaaaaaaaaab" + /* 5 */ "baaaaaaaaaaaaab" + /* 6 */ "baaaaaaaaaaaaab" + /* 7 */ "baaaaaaaaaaaaab" + /* 8 */ "mmmmmmmmaaaaaab" + /* 9 */ "mmmmmmmmaaaaaab" + /* 10 */ "mmmmmmmmaaaaaab" + /* 11 */ "mmmmmmmmaaaaaab" + /* 12 */ "mmmmmmmmaaaaaab" + /* 13 */ "mmmmmmmmaaaaaab" + /* 14 */ "mmmmmmmmaaaaaab" + /* 15 */ "mmmmmmmmbbbbbbb" // Level 2 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".ennfofnne." - /* 2 */ ".n..p.p..n." - /* 3 */ ".nq.....qn." - /* 4 */ ".n...q...n." - /* 5 */ ".ennnfnnne." - /* 6 */ "..........." + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "......cde......" + /* 1 */ ".fffffffffffff." + /* 2 */ ".fggggffffffff." + /* 3 */ ".fggggffffffff." + /* 4 */ ".fffffffffffff." + /* 5 */ ".fffffffffffff." + /* 6 */ ".fffffffffffff." + /* 7 */ "mfffffffffffff." + /* 8 */ "mmmmmmmmffffff." + /* 9 */ "mmmmmmmmffffff." + /* 10 */ "mmmmmmmmffffff." + /* 11 */ "mmmmmmmmffffff." + /* 12 */ "mmmmmmmmffffff." + /* 13 */ "mmmmmmmmffffff." + /* 14 */ "mmmmmmmmffffff." + /* 15 */ "mmmmmmmm......." // Level 3 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "jjjjjjjjjjj" - /* 1 */ "rfffffffffr" - /* 2 */ ".fsssssssf." - /* 3 */ ".ft.....uf." - /* 4 */ ".fsssssssf." - /* 5 */ "vfffffffffv" - /* 6 */ "hhhhhhhhhhh" + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".hiiiihjhiiiih." + /* 2 */ ".i...k.......i." + /* 3 */ ".ilggg......ni." + /* 4 */ ".h..........oi." + /* 5 */ ".i..........pi." + /* 6 */ ".i.qor..qo...i." + /* 7 */ "mhiiiiiihp...h." + /* 8 */ "mmmmmmmmi....i." + /* 9 */ "mmmmmmmmin...i." + /* 10 */ "mmmmmmmmio..ni." + /* 11 */ "mmmmmmmmip..oi." + /* 12 */ "mmmmmmmmi...pi." + /* 13 */ "mmmmmmmmis..si." + /* 14 */ "mmmmmmmmhiiiih." + /* 15 */ "mmmmmmmm......." // Level 4 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ "jjjjjjjjjjj" - /* 2 */ "rfffffffffr" - /* 3 */ ".f.......f." - /* 4 */ "vfffffffffv" - /* 5 */ "hhhhhhhhhhh" - /* 6 */ "..........." + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".hittihuhittih." + /* 2 */ ".i...........i." + /* 3 */ ".i...........t." + /* 4 */ ".h..........vt." + /* 5 */ ".i...........t." + /* 6 */ ".i..v....v...i." + /* 7 */ "mhittttih....h." + /* 8 */ "mmmmmmmmi....i." + /* 9 */ "mmmmmmmmt....t." + /* 10 */ "mmmmmmmmtv...t." + /* 11 */ "mmmmmmmmt...vt." + /* 12 */ "mmmmmmmmt....t." + /* 13 */ "mmmmmmmmis..si." + /* 14 */ "mmmmmmmmhittih." + /* 15 */ "mmmmmmmm......." // Level 5 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ "..........." - /* 2 */ "jjjjjjjjjjj" - /* 3 */ "fffffffffff" - /* 4 */ "hhhhhhhhhhh" - /* 5 */ "..........." - /* 6 */ "...........", + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".hwwwwwwwwwwwh." + /* 2 */ ".x....y.y....x." + /* 3 */ ".x...........x." + /* 4 */ ".xz..........x." + /* 5 */ ".x...........x." + /* 6 */ ".x......A....x." + /* 7 */ "mhwwwwwwhz..Bx." + /* 8 */ "mmmmmmmmx....x." + /* 9 */ "mmmmmmmmx....x." + /* 10 */ "mmmmmmmmx....x." + /* 11 */ "mmmmmmmmx....x." + /* 12 */ "mmmmmmmmx....x." + /* 13 */ "mmmmmmmmx.AA.x." + /* 14 */ "mmmmmmmmhwwwwh." + /* 15 */ "mmmmmmmm......." + + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "ppppppppppppppq" + /* 1 */ "riiiiiiiiiiiiiq" + /* 2 */ "riCCCCCCCCCCDiq" + /* 3 */ "riE.........Diq" + /* 4 */ "riE.........Diq" + /* 5 */ "riE.........Diq" + /* 6 */ "riEFFFFFFF..Diq" + /* 7 */ "riiiiiiiiE..Diq" + /* 8 */ "rnnnnnnriE..Diq" + /* 9 */ "mmmmmmmriE..Diq" + /* 10 */ "mmmmmmmriE..Diq" + /* 11 */ "mmmmmmmriE..Diq" + /* 12 */ "mmmmmmmriE..Diq" + /* 13 */ "mmmmmmmriEFFDiq" + /* 14 */ "mmmmmmmriiiiiiq" + /* 15 */ "mmmmmmmrnnnnnnn" + + // Level 7 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "mrpppppppppppqm" + /* 2 */ "mriiiiiiiiiiiqm" + /* 3 */ "mriiiiiiiiiiiqm" + /* 4 */ "mriiiiiiiiiiiqm" + /* 5 */ "mriiiiiiiiiiiqm" + /* 6 */ "mriiiiiiiiiiiqm" + /* 7 */ "mrnnnnnnniiiiqm" + /* 8 */ "mmmmmmmmriiiiqm" + /* 9 */ "mmmmmmmmriiiiqm" + /* 10 */ "mmmmmmmmriiiiqm" + /* 11 */ "mmmmmmmmriiiiqm" + /* 12 */ "mmmmmmmmriiiiqm" + /* 13 */ "mmmmmmmmriiiiqm" + /* 14 */ "mmmmmmmmnnnnnqm" + /* 15 */ "mmmmmmmmmmmmmmm" + + // Level 8 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmm" + /* 2 */ "mmpppppppppppmm" + /* 3 */ "mmriiiiiiiiiqmm" + /* 4 */ "mmriiiiiiiiiqmm" + /* 5 */ "mmriiiiiiiiiqmm" + /* 6 */ "mmnnnnnnnniiqmm" + /* 7 */ "mmmmmmmmmriiqmm" + /* 8 */ "mmmmmmmmmriiqmm" + /* 9 */ "mmmmmmmmmriiqmm" + /* 10 */ "mmmmmmmmmriiqmm" + /* 11 */ "mmmmmmmmmriiqmm" + /* 12 */ "mmmmmmmmmriiqmm" + /* 13 */ "mmmmmmmmmnnnqmm" + /* 14 */ "mmmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmmm" + + // Level 9 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmmm" + /* 3 */ "mmmrpppppppqmmm" + /* 4 */ "mmmriiiiiiiqmmm" + /* 5 */ "mmmrnnnnnnrqmmm" + /* 6 */ "mmmmmmmmmmrqmmm" + /* 7 */ "mmmmmmmmmmrqmmm" + /* 8 */ "mmmmmmmmmmrqmmm" + /* 9 */ "mmmmmmmmmmrqmmm" + /* 10 */ "mmmmmmmmmmrqmmm" + /* 11 */ "mmmmmmmmmmrqmmm" + /* 12 */ "mmmmmmmmmmrnmmm" + /* 13 */ "mmmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmmm", // Connectors: - "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 7, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2717,20 +2880,20 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_97 + }, // WoodenHouseL13x14 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_98: - // The data has been exported from the gallery Plains, area index 47, ID 98, created by Aloe_vera + // WoodenHouseL14x14: + // The data has been exported from the gallery Plains, area index 0, ID 4, created by Aloe_vera { // Size: - 12, 7, 9, // SizeX = 12, SizeY = 7, SizeZ = 9 + 16, 7, 16, // SizeX = 16, SizeY = 7, SizeZ = 16 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 11, 6, 8, // MaxX, MaxY, MaxZ + 15, 6, 15, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -2738,120 +2901,170 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "b: 67: 2\n" /* stairs */ "c: 67: 1\n" /* stairs */ "d: 4: 0\n" /* cobblestone */ - "e: 17: 0\n" /* tree */ - "f: 5: 0\n" /* wood */ - "g: 64: 7\n" /* wooddoorblock */ - "h: 64: 5\n" /* wooddoorblock */ - "i: 53: 3\n" /* woodstairs */ - "j: 85: 0\n" /* fence */ - "k: 53: 2\n" /* woodstairs */ - "l: 53: 1\n" /* woodstairs */ + "e: 5: 0\n" /* wood */ + "f: 67: 3\n" /* stairs */ + "g: 17: 0\n" /* tree */ + "h: 64: 7\n" /* wooddoorblock */ + "i: 64: 5\n" /* wooddoorblock */ + "j:102: 0\n" /* glasspane */ + "k: 64:12\n" /* wooddoorblock */ + "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 0\n" /* woodstairs */ - "o:102: 0\n" /* glasspane */ - "p: 64:12\n" /* wooddoorblock */ - "q: 50: 3\n" /* torch */ - "r: 72: 0\n" /* woodplate */ - "s: 53: 7\n" /* woodstairs */ - "t: 47: 0\n" /* bookshelf */ - "u: 50: 1\n" /* torch */ + "n: 53: 1\n" /* woodstairs */ + "o: 53: 7\n" /* woodstairs */ + "p: 53: 6\n" /* woodstairs */ + "q: 53: 3\n" /* woodstairs */ + "r: 53: 0\n" /* woodstairs */ + "s: 53: 5\n" /* woodstairs */ + "t: 53: 4\n" /* woodstairs */ + "u: 50: 3\n" /* torch */ "v: 50: 2\n" /* torch */ - "w: 53: 6\n" /* woodstairs */, + "w: 50: 4\n" /* torch */ + "x: 50: 1\n" /* torch */, // Block data: // Level 0 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ "....abbc...." - /* 1 */ ".dddddddddd." - /* 2 */ ".dddddddddd." - /* 3 */ ".dddddddddd." - /* 4 */ ".dddddddddd." - /* 5 */ ".dddddddddd." - /* 6 */ ".dddddddddd." - /* 7 */ ".dddddddddd." - /* 8 */ "............" + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "........abc....." + /* 1 */ ".dddddddddddddd." + /* 2 */ ".deeeeeeeeeeeed." + /* 3 */ ".deeeeeeeeeeeed." + /* 4 */ ".deeeeeeeeeeeed." + /* 5 */ ".deeeeeeeeeeeed." + /* 6 */ ".deeeeeeeeeeeed." + /* 7 */ ".ddddddddeeeeed." + /* 8 */ "mmmmmafcdeeeeed." + /* 9 */ "mmmmmmmmdeeeeed." + /* 10 */ "mmmmmmmmdeeeeed." + /* 11 */ "mmmmmmmmdeeeeed." + /* 12 */ "mmmmmmmmdeeeeed." + /* 13 */ "mmmmmmmmdeeeeed." + /* 14 */ "mmmmmmmmddddddd." + /* 15 */ "mmmmmmmm........" // Level 1 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ ".efffghfffe." - /* 2 */ ".f........f." - /* 3 */ ".fi......if." - /* 4 */ ".fj......jf." - /* 5 */ ".fk......kf." - /* 6 */ ".f.ljnljn.f." - /* 7 */ ".effffffffe." - /* 8 */ "............" + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ ".geeeeeeghgeeeg." + /* 2 */ ".e............e." + /* 3 */ ".e............e." + /* 4 */ ".e............e." + /* 5 */ ".e............e." + /* 6 */ ".e............e." + /* 7 */ ".geeeeieg.....e." + /* 8 */ "mmmmmm.me.....e." + /* 9 */ "mmmmmmmme.....e." + /* 10 */ "mmmmmmmme.....e." + /* 11 */ "mmmmmmmme.....e." + /* 12 */ "mmmmmmmme.....e." + /* 13 */ "mmmmmmmme.....e." + /* 14 */ "mmmmmmmmgeeeeeg." + /* 15 */ "mmmmmmmm........" // Level 2 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ ".eoofppfooe." - /* 2 */ ".o..q..q..o." - /* 3 */ ".o........o." - /* 4 */ ".fr......rf." - /* 5 */ ".o........o." - /* 6 */ ".o..r..r..o." - /* 7 */ ".eoofoofooe." - /* 8 */ "............" + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ ".gejjejjgkgjjeg." + /* 2 */ ".j............e." + /* 3 */ ".j............j." + /* 4 */ ".j............j." + /* 5 */ ".j............e." + /* 6 */ ".j............j." + /* 7 */ ".gejjekeg.....j." + /* 8 */ "mmmmmm.me.....e." + /* 9 */ "mmmmmmmmj.....j." + /* 10 */ "mmmmmmmmj.....j." + /* 11 */ "mmmmmmmme.....e." + /* 12 */ "mmmmmmmmj.....j." + /* 13 */ "mmmmmmmmj.....j." + /* 14 */ "mmmmmmmmgjjjjjg." + /* 15 */ "mmmmmmmm........" // Level 3 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ "kkkkkkkkkkkk" - /* 1 */ "sffffffffffs" - /* 2 */ ".fttttttttf." - /* 3 */ ".f........f." - /* 4 */ ".fu......vf." - /* 5 */ ".f........f." - /* 6 */ ".fttttttttf." - /* 7 */ "wffffffffffw" - /* 8 */ "iiiiiiiiiiii" + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "llllllllllllllln" + /* 1 */ "ogeeeeeegegeeegn" + /* 2 */ ".e............en" + /* 3 */ ".e............en" + /* 4 */ ".e............en" + /* 5 */ ".e............en" + /* 6 */ ".e............en" + /* 7 */ "pgeeeeeeg.....en" + /* 8 */ "qqqqqqqre.....en" + /* 9 */ "mmmmmmmre.....en" + /* 10 */ "mmmmmmmre.....en" + /* 11 */ "mmmmmmmre.....en" + /* 12 */ "mmmmmmmre.....en" + /* 13 */ "mmmmmmmre.....en" + /* 14 */ "mmmmmmmrgeeeeegn" + /* 15 */ "mmmmmmmrs.....tn" // Level 4 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ "kkkkkkkkkkkk" - /* 2 */ "sffffffffffs" - /* 3 */ ".fttttttttf." - /* 4 */ ".f........f." - /* 5 */ ".fttttttttf." - /* 6 */ "wffffffffffw" - /* 7 */ "iiiiiiiiiiii" - /* 8 */ "............" + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "lllllllllllllll." + /* 2 */ "oeeeeeeeeeeeeen." + /* 3 */ ".e.........u.en." + /* 4 */ ".e..........ven." + /* 5 */ ".e......w....en." + /* 6 */ "peeeeeeeee...en." + /* 7 */ "qqqqqqqqrex..en." + /* 8 */ "mmmmmmmmre...en." + /* 9 */ "mmmmmmmmre...en." + /* 10 */ "mmmmmmmmre...en." + /* 11 */ "mmmmmmmmre...en." + /* 12 */ "mmmmmmmmre...en." + /* 13 */ "mmmmmmmmre...en." + /* 14 */ "mmmmmmmmreeeeen." + /* 15 */ "mmmmmmmmrs...tn." // Level 5 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ "............" - /* 2 */ "kkkkkkkkkkkk" - /* 3 */ "sffffffffffs" - /* 4 */ ".f........f." - /* 5 */ "wffffffffffw" - /* 6 */ "iiiiiiiiiiii" - /* 7 */ "............" - /* 8 */ "............" + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "llllllllllllln.." + /* 3 */ "oeeeeeeeeeeeen.." + /* 4 */ ".ex.........en.." + /* 5 */ "peeeeeeeeee.en.." + /* 6 */ "qqqqqqqqqre.en.." + /* 7 */ ".........re.en.." + /* 8 */ "mmmmmmmm.re.en.." + /* 9 */ "mmmmmmmm.re.en.." + /* 10 */ "mmmmmmmm.re.en.." + /* 11 */ "mmmmmmmm.re.en.." + /* 12 */ "mmmmmmmm.re.en.." + /* 13 */ "mmmmmmmm.rewen.." + /* 14 */ "mmmmmmmm.reeen.." + /* 15 */ "mmmmmmmm.rs.tn.." // Level 6 - /* z\x* 11 */ - /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ "............" - /* 2 */ "............" - /* 3 */ "kkkkkkkkkkkk" - /* 4 */ "ffffffffffff" - /* 5 */ "iiiiiiiiiiii" - /* 6 */ "............" - /* 7 */ "............" - /* 8 */ "............", + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "lllllllllllll..." + /* 4 */ "eeeeeeeeeeeen..." + /* 5 */ "qqqqqqqqqqren..." + /* 6 */ "mmmmmmmmmmren..." + /* 7 */ "mmmmmmmmmmren..." + /* 8 */ "mmmmmmmmmmren..." + /* 9 */ "mmmmmmmmmmren..." + /* 10 */ "mmmmmmmmmmren..." + /* 11 */ "mmmmmmmmmmren..." + /* 12 */ "mmmmmmmmmmren..." + /* 13 */ "mmmmmmmmmmren..." + /* 14 */ "mmmmmmmmmmren..." + /* 15 */ "mmmmmmmmmmren...", // Connectors: - "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 9, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2870,166 +3083,171 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_98 + }, // WoodenHouseL14x14 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PlainsVillage_99: - // The data has been exported from the gallery Plains, area index 48, ID 99, created by Aloe_vera + // WoodenHouseL9x9: + // The data has been exported from the gallery Plains, area index 42, ID 93, created by xoft { // Size: - 11, 7, 13, // SizeX = 11, SizeY = 7, SizeZ = 13 + 11, 8, 11, // SizeX = 11, SizeY = 8, SizeZ = 11 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 10, 6, 12, // MaxX, MaxY, MaxZ + 10, 7, 10, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 43: 0\n" /* doubleslab */ - "f: 2: 0\n" /* grass */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ "g: 17: 0\n" /* tree */ "h: 5: 0\n" /* wood */ "i: 64: 7\n" /* wooddoorblock */ - "j: 53: 3\n" /* woodstairs */ - "k: 85: 0\n" /* fence */ + "j:102: 0\n" /* glasspane */ + "k: 64:12\n" /* wooddoorblock */ "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n:102: 0\n" /* glasspane */ - "o: 64:12\n" /* wooddoorblock */ - "p: 72: 0\n" /* woodplate */ - "q: 53: 7\n" /* woodstairs */ - "r: 50: 1\n" /* torch */ - "s: 50: 2\n" /* torch */ - "t: 53: 6\n" /* woodstairs */, + "n: 53: 7\n" /* woodstairs */ + "o: 53: 1\n" /* woodstairs */ + "p: 50: 3\n" /* torch */ + "q: 50: 4\n" /* torch */ + "r: 53: 6\n" /* woodstairs */ + "s: 50: 1\n" /* torch */ + "t: 50: 2\n" /* torch */ + "u: 53: 3\n" /* woodstairs */ + "v: 53: 0\n" /* woodstairs */ + "w: 53: 5\n" /* woodstairs */ + "x: 53: 4\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "....abc...." - /* 1 */ ".ddddddddd." - /* 2 */ ".deeeedddd." - /* 3 */ ".deeeedddd." - /* 4 */ ".deeeedddd." - /* 5 */ ".deeeedddd." - /* 6 */ ".deeeedddd." - /* 7 */ ".ddddddddd." - /* 8 */ "..fffffff.." - /* 9 */ "mmfffffffmm" - /* 10 */ "mmfffffffmm" - /* 11 */ "mmfffffffmm" - /* 12 */ "mmfffffffmm" + /* 0 */ "aaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaa" + /* 9 */ "aaaaaaaaaaa" + /* 10 */ "aaaaaaaaaaa" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".ghhhihhhg." - /* 2 */ ".h.e....jh." - /* 3 */ ".h.e....kh." - /* 4 */ ".h.e....lh." - /* 5 */ ".h.......h." - /* 6 */ ".h.......h." - /* 7 */ ".ghhhihhhg." - /* 8 */ "..k.....k.." - /* 9 */ "mmk.....kmm" - /* 10 */ "mmk.....kmm" - /* 11 */ "mmk.....kmm" - /* 12 */ "mmkkkkkkkmm" + /* 0 */ "bbbbaaabbbb" + /* 1 */ "baaaaaaaaab" + /* 2 */ "baaaaaaaaab" + /* 3 */ "baaaaaaaaab" + /* 4 */ "baaaaaaaaab" + /* 5 */ "baaaaaaaaab" + /* 6 */ "bbbbbaaaaab" + /* 7 */ "bbbbbaaaaab" + /* 8 */ "bbbbbaaaaab" + /* 9 */ "bbbbbaaaaab" + /* 10 */ "bbbbbbbbbbb" // Level 2 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".gnnhohnng." - /* 2 */ ".n.......n." - /* 3 */ ".n......pn." - /* 4 */ ".h.......h." - /* 5 */ ".n.......n." - /* 6 */ ".n.......n." - /* 7 */ ".gnnhohnng." - /* 8 */ "..........." - /* 9 */ "mm.......mm" - /* 10 */ "mm.......mm" - /* 11 */ "mm.......mm" - /* 12 */ "mm.......mm" + /* 0 */ "....cde...." + /* 1 */ ".fffffffff." + /* 2 */ ".fffffffff." + /* 3 */ ".fffffffff." + /* 4 */ ".fffffffff." + /* 5 */ ".fffffffff." + /* 6 */ ".....fffff." + /* 7 */ "mmmm.fffff." + /* 8 */ "mmmm.fffff." + /* 9 */ "mmmm.fffff." + /* 10 */ "mmmm......." // Level 3 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "lllllllllll" - /* 1 */ "qhhhhhhhhhq" + /* 0 */ "..........." + /* 1 */ ".ghhhihhhg." /* 2 */ ".h.......h." /* 3 */ ".h.......h." - /* 4 */ ".hr.....sh." - /* 5 */ ".h.......h." - /* 6 */ ".h.......h." - /* 7 */ "thhhhhhhhht" - /* 8 */ "jjjjjjjjjjj" - /* 9 */ "mm.......mm" - /* 10 */ "mm.......mm" - /* 11 */ "mm.......mm" - /* 12 */ "mm.......mm" + /* 4 */ ".h.......h." + /* 5 */ ".ghhhg...h." + /* 6 */ ".....h...h." + /* 7 */ "mmmm.h...h." + /* 8 */ "mmmm.h...h." + /* 9 */ "mmmm.ghhhg." + /* 10 */ "mmmm......." // Level 4 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ "lllllllllll" - /* 2 */ "qhhhhhhhhhq" - /* 3 */ ".h.......h." - /* 4 */ ".h.......h." - /* 5 */ ".h.......h." - /* 6 */ "thhhhhhhhht" - /* 7 */ "jjjjjjjjjjj" - /* 8 */ "..........." - /* 9 */ "mm.......mm" - /* 10 */ "mm.......mm" - /* 11 */ "mm.......mm" - /* 12 */ "mm.......mm" + /* 1 */ ".gjjhkhjjg." + /* 2 */ ".j.......j." + /* 3 */ ".j.......j." + /* 4 */ ".j.......j." + /* 5 */ ".gjjjg...h." + /* 6 */ ".....j...j." + /* 7 */ "mmmm.j...j." + /* 8 */ "mmmm.j...j." + /* 9 */ "mmmm.gjjjg." + /* 10 */ "mmmm......." // Level 5 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ "..........." - /* 2 */ "lllllllllll" - /* 3 */ "qhhhhhhhhhq" - /* 4 */ ".h.......h." - /* 5 */ "thhhhhhhhht" - /* 6 */ "jjjjjjjjjjj" - /* 7 */ "..........." - /* 8 */ "..........." - /* 9 */ "mm.......mm" - /* 10 */ "mm.......mm" - /* 11 */ "mm.......mm" - /* 12 */ "mm.......mm" + /* 0 */ "lllllllllll" + /* 1 */ "nhhhhhhhhho" + /* 2 */ ".h..p.p..ho" + /* 3 */ ".h.......ho" + /* 4 */ ".h...q...ho" + /* 5 */ "rhhhhhs.tho" + /* 6 */ "uuuuuh...ho" + /* 7 */ "mmmmvh...ho" + /* 8 */ "mmmmvh...ho" + /* 9 */ "mmmmvhhhhho" + /* 10 */ "mmmmvw...xo" // Level 6 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." + /* 1 */ "lllllllllo." + /* 2 */ "nhhhhhhhho." + /* 3 */ ".h......ho." + /* 4 */ "rhhhhhh.ho." + /* 5 */ "uuuuuuh.ho." + /* 6 */ ".....vh.ho." + /* 7 */ "mmmm.vh.ho." + /* 8 */ "mmmm.vh.ho." + /* 9 */ "mmmm.vhhho." + /* 10 */ "mmmm.vw.xo." + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." /* 1 */ "..........." - /* 2 */ "..........." - /* 3 */ "lllllllllll" - /* 4 */ "hhhhhhhhhhh" - /* 5 */ "jjjjjjjjjjj" - /* 6 */ "..........." - /* 7 */ "..........." - /* 8 */ "..........." - /* 9 */ "mm.......mm" - /* 10 */ "mm.......mm" - /* 11 */ "mm.......mm" - /* 12 */ "mm.......mm", + /* 2 */ "lllllllll.." + /* 3 */ "hhhhhhhho.." + /* 4 */ "uuuuuuvho.." + /* 5 */ "......vho.." + /* 6 */ "......vho.." + /* 7 */ "mmmm..vho.." + /* 8 */ "mmmm..vho.." + /* 9 */ "mmmm..vho.." + /* 10 */ "mmmm..vho..", // Connectors: - "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3048,193 +3266,169 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // PlainsVillage_99 + }, // WoodenHouseL9x9 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // RoofedWell: - // The data has been exported from the gallery Plains, area index 119, ID 271, created by STR_Warrior + // WoodenHouseU13x9: + // The data has been exported from the gallery Plains, area index 43, ID 94, created by xoft { // Size: - 7, 15, 7, // SizeX = 7, SizeY = 15, SizeZ = 7 + 15, 8, 11, // SizeX = 15, SizeY = 8, SizeZ = 11 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 6, 14, 6, // MaxX, MaxY, MaxZ + 14, 7, 10, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 1: 0\n" /* stone */ - "b: 4: 0\n" /* cobblestone */ - "c: 8: 0\n" /* water */ - "d: 3: 0\n" /* dirt */ - "e: 2: 0\n" /* grass */ - "f: 13: 0\n" /* gravel */ - "g:118: 3\n" /* cauldronblock */ - "h: 85: 0\n" /* fence */ - "i: 53: 2\n" /* woodstairs */ - "j: 53: 7\n" /* woodstairs */ - "k: 5: 0\n" /* wood */ - "l: 53: 4\n" /* woodstairs */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 17: 0\n" /* tree */ + "h: 5: 0\n" /* wood */ + "i: 64: 7\n" /* wooddoorblock */ + "j:102: 0\n" /* glasspane */ + "k: 64:12\n" /* wooddoorblock */ + "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 5\n" /* woodstairs */ - "o: 53: 6\n" /* woodstairs */ - "p: 53: 3\n" /* woodstairs */, + "n: 53: 0\n" /* woodstairs */ + "o: 53: 1\n" /* woodstairs */ + "p: 50: 3\n" /* torch */ + "q: 50: 4\n" /* torch */ + "r: 50: 2\n" /* torch */ + "s: 50: 1\n" /* torch */ + "t: 53: 3\n" /* woodstairs */ + "u: 53: 5\n" /* woodstairs */ + "v: 53: 4\n" /* woodstairs */, // Block data: // Level 0 - /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "aaaaaaa" - /* 2 */ "aaaaaaa" - /* 3 */ "aaaaaaa" - /* 4 */ "aaaaaaa" - /* 5 */ "aaaaaaa" - /* 6 */ "aaaaaaa" - - // Level 1 - /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "abbbbba" - /* 2 */ "abcccba" - /* 3 */ "abcccba" - /* 4 */ "abcccba" - /* 5 */ "abbbbba" - /* 6 */ "aaaaaaa" - - // Level 2 - /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "abbbbba" - /* 2 */ "abcccba" - /* 3 */ "abcccba" - /* 4 */ "abcccba" - /* 5 */ "abbbbba" - /* 6 */ "aaaaaaa" - - // Level 3 - /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "abbbbba" - /* 2 */ "abcccba" - /* 3 */ "abcccba" - /* 4 */ "abcccba" - /* 5 */ "abbbbba" - /* 6 */ "aaaaaaa" - - // Level 4 - /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "abbbbba" - /* 2 */ "abcccba" - /* 3 */ "abcccba" - /* 4 */ "abcccba" - /* 5 */ "abbbbba" - /* 6 */ "aaaaaaa" - - // Level 5 - /* z\x* 0123456 */ - /* 0 */ "ddddddd" - /* 1 */ "dbbbbbd" - /* 2 */ "dbcccbd" - /* 3 */ "dbcccbd" - /* 4 */ "dbcccbd" - /* 5 */ "dbbbbbd" - /* 6 */ "ddddddd" - - // Level 6 - /* z\x* 0123456 */ - /* 0 */ "ddddddd" - /* 1 */ "dbbbbbd" - /* 2 */ "dbcccbd" - /* 3 */ "dbcccbd" - /* 4 */ "dbcccbd" - /* 5 */ "dbbbbbd" - /* 6 */ "ddddddd" - - // Level 7 - /* z\x* 0123456 */ - /* 0 */ "ddddddd" - /* 1 */ "dbbbbbd" - /* 2 */ "dbcccbd" - /* 3 */ "dbcccbd" - /* 4 */ "dbcccbd" - /* 5 */ "dbbbbbd" - /* 6 */ "ddddddd" - - // Level 8 - /* z\x* 0123456 */ - /* 0 */ "eefffee" - /* 1 */ "ebbbbbe" - /* 2 */ "fbcccbf" - /* 3 */ "fbcccbf" - /* 4 */ "fbcccbf" - /* 5 */ "ebbbbbe" - /* 6 */ "eefffee" + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "aaaaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaaaaaa" + /* 9 */ "aaaaaaaaaaaaaaa" + /* 10 */ "aaaaaaaaaaaaaaa" - // Level 9 - /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".bbbbb." - /* 2 */ ".b...b." - /* 3 */ ".b.g.b." - /* 4 */ ".b...b." - /* 5 */ ".bbbbb." - /* 6 */ "......." + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "bbbbbbaaabbbbbb" + /* 1 */ "baaaaaaaaaaaaab" + /* 2 */ "baaaaaaaaaaaaab" + /* 3 */ "baaaaaaaaaaaaab" + /* 4 */ "baaaaaaaaaaaaab" + /* 5 */ "baaaaaaaaaaaaab" + /* 6 */ "baaaaabbbaaaaab" + /* 7 */ "baaaaabbbaaaaab" + /* 8 */ "baaaaabbbaaaaab" + /* 9 */ "baaaaabbbaaaaab" + /* 10 */ "bbbbbbbbbbbbbbb" - // Level 10 - /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".h...h." - /* 2 */ "......." - /* 3 */ "...h..." - /* 4 */ "......." - /* 5 */ ".h...h." - /* 6 */ "......." + // Level 2 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "......cde......" + /* 1 */ ".fffffffffffff." + /* 2 */ ".fffffffffffff." + /* 3 */ ".fffffffffffff." + /* 4 */ ".fffffffffffff." + /* 5 */ ".fffffffffffff." + /* 6 */ ".fffff...fffff." + /* 7 */ ".fffff...fffff." + /* 8 */ ".fffff...fffff." + /* 9 */ ".fffff...fffff." + /* 10 */ "..............." - // Level 11 - /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".h...h." - /* 2 */ "......." - /* 3 */ "...h..." - /* 4 */ "......." - /* 5 */ ".h...h." - /* 6 */ "......." + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".ghhhhhihhhhhg." + /* 2 */ ".h...........h." + /* 3 */ ".h...........h." + /* 4 */ ".h...........h." + /* 5 */ ".h...ghhhg...h." + /* 6 */ ".h...h...h...h." + /* 7 */ ".h...h...h...h." + /* 8 */ ".h...h...h...h." + /* 9 */ ".ghhhg...ghhhg." + /* 10 */ "..............." - // Level 12 - /* z\x* 0123456 */ - /* 0 */ "iiiiiii" - /* 1 */ "jkjjjkj" - /* 2 */ ".l...n." - /* 3 */ ".l.h.n." - /* 4 */ ".l...n." - /* 5 */ "okoooko" - /* 6 */ "ppppppp" + // Level 4 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".gjjjjhkhjjjjg." + /* 2 */ ".j...........j." + /* 3 */ ".j...........j." + /* 4 */ ".j...........j." + /* 5 */ ".h...gjjjg...h." + /* 6 */ ".j...j...j...j." + /* 7 */ ".j...j...j...j." + /* 8 */ ".j...j...j...j." + /* 9 */ ".gjjjg...gjjjg." + /* 10 */ "..............." - // Level 13 - /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ "iiiiiii" - /* 2 */ "jkjjjkj" - /* 3 */ ".k.h.k." - /* 4 */ "okoooko" - /* 5 */ "ppppppp" - /* 6 */ "......." + // Level 5 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "lllllllllllllll" + /* 1 */ "nhhhhhhhhhhhhho" + /* 2 */ "nh....p.p....ho" + /* 3 */ "nh...........ho" + /* 4 */ "nh...q...q...ho" + /* 5 */ "nh..rhhhhhs..ho" + /* 6 */ "nh...httth...ho" + /* 7 */ "nh...ho.nh...ho" + /* 8 */ "nh...ho.nh...ho" + /* 9 */ "nhhhhho.nhhhhho" + /* 10 */ "nu...vo.nu...vo" - // Level 14 - /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ "......." - /* 2 */ "iiiiiii" - /* 3 */ "kkkkkkk" - /* 4 */ "ppppppp" - /* 5 */ "......." - /* 6 */ ".......", + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".llllllllllllo." + /* 2 */ ".nhhhhhhhhhhho." + /* 3 */ ".nhhhhhhhhhhho." + /* 4 */ ".nhhhhhhhhhhho." + /* 5 */ ".nhhhotttthhho." + /* 6 */ ".nhhho...nhhho." + /* 7 */ ".nhhho...nhhho." + /* 8 */ ".nhhho...nhhho." + /* 9 */ ".nhhho...nhhho." + /* 10 */ ".nu.vo...nu.vo." + + // Level 7 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..nllllllllll.." + /* 3 */ "..nhhhhhhhhho.." + /* 4 */ "..nhotttttnho.." + /* 5 */ "..nho.....nho.." + /* 6 */ "..nho.....nho.." + /* 7 */ "..nho.....nho.." + /* 8 */ "..nho.....nho.." + /* 9 */ "..nho.....nho.." + /* 10 */ "..nho.....nho..", // Connectors: - "", + "-1: 7, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3253,247 +3447,281 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // RoofedWell + }, // WoodenHouseU13x9 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Windmill: + // WoodenMill5x5: // The data has been exported from the gallery Plains, area index 60, ID 111, created by Aloe_vera { // Size: - 9, 16, 13, // SizeX = 9, SizeY = 16, SizeZ = 13 + 9, 18, 13, // SizeX = 9, SizeY = 18, SizeZ = 13 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 8, 15, 12, // MaxX, MaxY, MaxZ + 8, 17, 12, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 4: 0\n" /* cobblestone */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 67: 3\n" /* stairs */ - "e: 17: 0\n" /* tree */ - "f: 5: 0\n" /* wood */ - "g: 54: 4\n" /* chest */ - "h:154: 4\n" /* hopper */ - "i: 64: 4\n" /* wooddoorblock */ - "j:102: 0\n" /* glasspane */ - "k: 85: 0\n" /* fence */ - "l: 64:12\n" /* wooddoorblock */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 4: 0\n" /* cobblestone */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 67: 3\n" /* stairs */ + "g: 17: 0\n" /* tree */ + "h: 5: 0\n" /* wood */ + "i: 54: 4\n" /* chest */ + "j:154: 4\n" /* hopper */ + "k: 64: 4\n" /* wooddoorblock */ + "l:102: 0\n" /* glasspane */ "m: 19: 0\n" /* sponge */ - "n: 50: 2\n" /* torch */ - "o: 35: 0\n" /* wool */ - "p: 17: 4\n" /* tree */ - "q: 17: 8\n" /* tree */ - "r: 53: 2\n" /* woodstairs */ - "s: 53: 7\n" /* woodstairs */ - "t: 53: 6\n" /* woodstairs */ - "u: 53: 3\n" /* woodstairs */, + "n: 85: 0\n" /* fence */ + "o: 64:12\n" /* wooddoorblock */ + "p: 50: 2\n" /* torch */ + "q: 35: 0\n" /* wool */ + "r: 17: 4\n" /* tree */ + "s: 17: 8\n" /* tree */ + "t: 53: 2\n" /* woodstairs */ + "u: 53: 7\n" /* woodstairs */ + "v: 53: 6\n" /* woodstairs */ + "w: 53: 3\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 012345678 */ + /* 0 */ "aaaaaaaaa" + /* 1 */ "aaaaaaaaa" + /* 2 */ "aaaaaaaaa" + /* 3 */ "aaaaaaaaa" + /* 4 */ "aaaaaaaaa" + /* 5 */ "aaaaaaaaa" + /* 6 */ "aaaaaaaaa" + /* 7 */ "aaaaaaaaa" + /* 8 */ "aaaaaaaaa" + /* 9 */ "aaaaaaaaa" + /* 10 */ "aaaaaaaaa" + /* 11 */ "aaaaaaaaa" + /* 12 */ "aaaaaaaaa" + + // Level 1 + /* z\x* 012345678 */ + /* 0 */ "bbbbbbbbb" + /* 1 */ "bbbbbbbbb" + /* 2 */ "bbbbbbbbb" + /* 3 */ "bbbbbbbbb" + /* 4 */ "baaaaabbb" + /* 5 */ "baaaaaabb" + /* 6 */ "baaaaaabb" + /* 7 */ "baaaaaabb" + /* 8 */ "baaaaabbb" + /* 9 */ "bbbbbbbbb" + /* 10 */ "bbbbbbbbb" + /* 11 */ "bbbbbbbbb" + /* 12 */ "bbbbbbbbb" + + // Level 2 + /* z\x* 012345678 */ /* 0 */ "mmmmmmm.." /* 1 */ "mmmmmmm.." /* 2 */ "mmmmmmm.." /* 3 */ "........." - /* 4 */ ".aaaaa..." - /* 5 */ ".aaaaab.." - /* 6 */ ".aaaaac.." - /* 7 */ ".aaaaad.." - /* 8 */ ".aaaaa..." + /* 4 */ ".ccccc..." + /* 5 */ ".cccccd.." + /* 6 */ ".ccccce.." + /* 7 */ ".cccccf.." + /* 8 */ ".ccccc..." /* 9 */ "........." /* 10 */ "mmmmmmm.." /* 11 */ "mmmmmmm.." /* 12 */ "mmmmmmm.." - // Level 1 + // Level 3 /* z\x* 012345678 */ /* 0 */ "mmmmmmm.." /* 1 */ "mmmmmmm.." /* 2 */ "mmmmmmm.." /* 3 */ "........." - /* 4 */ ".efffe..." - /* 5 */ ".f...f..." - /* 6 */ ".fgh.i..." - /* 7 */ ".f...f..." - /* 8 */ ".efffe..." + /* 4 */ ".ghhhg..." + /* 5 */ ".h...h..." + /* 6 */ ".hij.k..." + /* 7 */ ".h...h..." + /* 8 */ ".ghhhg..." /* 9 */ "........." /* 10 */ "mmmmmmm.." /* 11 */ "mmmmmmm.." /* 12 */ "mmmmmmm.." - // Level 2 + // Level 4 /* z\x* 012345678 */ /* 0 */ "mmmmmmm.." /* 1 */ "mmmmmmm.." /* 2 */ "mmmmmmm.." /* 3 */ "........." - /* 4 */ ".ejjje..." - /* 5 */ ".j...f..." - /* 6 */ ".j.k.l..." - /* 7 */ ".j...f..." - /* 8 */ ".ejjje..." + /* 4 */ ".glllg..." + /* 5 */ ".l...h..." + /* 6 */ ".l.n.o..." + /* 7 */ ".l...h..." + /* 8 */ ".glllg..." /* 9 */ "........." /* 10 */ "mmmmmmm.." /* 11 */ "mmmmmmm.." /* 12 */ "mmmmmmm.." - // Level 3 + // Level 5 /* z\x* 012345678 */ /* 0 */ "mmmmmmm.." /* 1 */ "mmmmmmm.." /* 2 */ "mmmmmmm.." /* 3 */ "........." - /* 4 */ ".efffe..." - /* 5 */ ".f..nf..." - /* 6 */ ".f.k.f..." - /* 7 */ ".f..nf..k" - /* 8 */ ".efffe..o" + /* 4 */ ".ghhhg..." + /* 5 */ ".h..ph..." + /* 6 */ ".h.n.h..." + /* 7 */ ".h..ph..n" + /* 8 */ ".ghhhg..q" /* 9 */ "........." /* 10 */ "mmmmmmm.." /* 11 */ "mmmmmmm.." /* 12 */ "mmmmmmm.." - // Level 4 + // Level 6 /* z\x* 012345678 */ /* 0 */ "mmmmmmm.." /* 1 */ "mmmmmmm.." /* 2 */ "mmmmmmm.." /* 3 */ "........." - /* 4 */ ".epppe..." - /* 5 */ ".q...q..." - /* 6 */ ".q.k.q..." - /* 7 */ ".q...q..k" - /* 8 */ ".epppe..o" + /* 4 */ ".grrrg..." + /* 5 */ ".s...s..." + /* 6 */ ".s.n.s..." + /* 7 */ ".s...s..n" + /* 8 */ ".grrrg..q" /* 9 */ "........." /* 10 */ "mmmmmmm.." /* 11 */ "mmmmmmm.." /* 12 */ "mmmmmmm.." - // Level 5 + // Level 7 /* z\x* 012345678 */ /* 0 */ "mmmmmmm.." /* 1 */ "mmmmmmm.." /* 2 */ "mmmmmmm.." /* 3 */ "........." - /* 4 */ ".efffe..." - /* 5 */ ".f...f..." - /* 6 */ ".f.k.f..k" - /* 7 */ ".f...f..o" - /* 8 */ ".efffe..o" + /* 4 */ ".ghhhg..." + /* 5 */ ".h...h..." + /* 6 */ ".h.n.h..n" + /* 7 */ ".h...h..q" + /* 8 */ ".ghhhg..q" /* 9 */ "........." /* 10 */ "mmmmmmm.." /* 11 */ "mmmmmmm.." /* 12 */ "mmmmmmm.." - // Level 6 + // Level 8 /* z\x* 012345678 */ /* 0 */ "mmmmmmm.." /* 1 */ "mmmmmmm.." /* 2 */ "mmmmmmm.." /* 3 */ "........." - /* 4 */ ".ejjje..." - /* 5 */ ".j...j..." - /* 6 */ ".j.k.j..k" - /* 7 */ ".j...j..o" - /* 8 */ ".ejjje..." + /* 4 */ ".glllg..." + /* 5 */ ".l...l..." + /* 6 */ ".l.n.l..n" + /* 7 */ ".l...l..q" + /* 8 */ ".glllg..." /* 9 */ "........." /* 10 */ "mmmmmmm.." /* 11 */ "mmmmmmm.." /* 12 */ "mmmmmmm.." - // Level 7 + // Level 9 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.o" - /* 1 */ "mmmmmmm.o" - /* 2 */ "mmmmmmm.o" + /* 0 */ "mmmmmmm.q" + /* 1 */ "mmmmmmm.q" + /* 2 */ "mmmmmmm.q" /* 3 */ "........." - /* 4 */ ".efffe..." - /* 5 */ ".f...f..k" - /* 6 */ ".f.k.f..o" - /* 7 */ ".f...f..o" - /* 8 */ ".efffe..." + /* 4 */ ".ghhhg..." + /* 5 */ ".h...h..n" + /* 6 */ ".h.n.h..q" + /* 7 */ ".h...h..q" + /* 8 */ ".ghhhg..." /* 9 */ "........." /* 10 */ "mmmmmmm.." /* 11 */ "mmmmmmm.." /* 12 */ "mmmmmmm.." - // Level 8 + // Level 10 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.k" - /* 1 */ "mmmmmmm.k" - /* 2 */ "mmmmmmm.o" - /* 3 */ "........o" - /* 4 */ ".epppe..o" - /* 5 */ ".q...q..k" - /* 6 */ ".q.k.q..o" - /* 7 */ ".q...q..k" - /* 8 */ ".epppe..k" + /* 0 */ "mmmmmmm.n" + /* 1 */ "mmmmmmm.n" + /* 2 */ "mmmmmmm.q" + /* 3 */ "........q" + /* 4 */ ".grrrg..q" + /* 5 */ ".s...s..n" + /* 6 */ ".s.n.s..q" + /* 7 */ ".s...s..n" + /* 8 */ ".grrrg..n" /* 9 */ "........." /* 10 */ "mmmmmmm.." /* 11 */ "mmmmmmm.." /* 12 */ "mmmmmmm.." - // Level 9 + // Level 11 /* z\x* 012345678 */ /* 0 */ "mmmmmmm.." /* 1 */ "mmmmmmm.." - /* 2 */ "mmmmmmm.k" - /* 3 */ "rrrrrrr.k" - /* 4 */ "sfffffs.o" - /* 5 */ ".f...f..o" - /* 6 */ ".f.kppppp" - /* 7 */ ".f...f..o" - /* 8 */ "tffffft.o" - /* 9 */ "uuuuuuu.k" - /* 10 */ "mmmmmmm.k" + /* 2 */ "mmmmmmm.n" + /* 3 */ "ttttttt.n" + /* 4 */ "uhhhhhu.q" + /* 5 */ ".h...h..q" + /* 6 */ ".h.nrrrrr" + /* 7 */ ".h...h..q" + /* 8 */ "vhhhhhv.q" + /* 9 */ "wwwwwww.n" + /* 10 */ "mmmmmmm.n" /* 11 */ "mmmmmmm.." /* 12 */ "mmmmmmm.." - // Level 10 + // Level 12 /* z\x* 012345678 */ /* 0 */ "mmmmmmm.." /* 1 */ "mmmmmmm.." /* 2 */ "mmmmmmm.." /* 3 */ "mmmmmmm.." - /* 4 */ "rrrrrrr.k" - /* 5 */ "sfffffs.k" - /* 6 */ ".f...f..o" - /* 7 */ "tffffft.k" - /* 8 */ "uuuuuuu.o" - /* 9 */ "mmmmmmm.o" - /* 10 */ "mmmmmmm.o" - /* 11 */ "mmmmmmm.k" - /* 12 */ "mmmmmmm.k" + /* 4 */ "ttttttt.n" + /* 5 */ "uhhhhhu.n" + /* 6 */ ".h...h..q" + /* 7 */ "vhhhhhv.n" + /* 8 */ "wwwwwww.q" + /* 9 */ "mmmmmmm.q" + /* 10 */ "mmmmmmm.q" + /* 11 */ "mmmmmmm.n" + /* 12 */ "mmmmmmm.n" - // Level 11 + // Level 13 /* z\x* 012345678 */ /* 0 */ "mmmmmmm.." /* 1 */ "mmmmmmm.." /* 2 */ "mmmmmmm.." /* 3 */ "mmmmmmm.." /* 4 */ "mmmmmmm.." - /* 5 */ "rrrrrrr.o" - /* 6 */ "fffffff.o" - /* 7 */ "uuuuuuu.k" + /* 5 */ "ttttttt.q" + /* 6 */ "hhhhhhh.q" + /* 7 */ "wwwwwww.n" /* 8 */ "mmmmmmm.." /* 9 */ "mmmmmmm.." - /* 10 */ "mmmmmmm.o" - /* 11 */ "mmmmmmm.o" - /* 12 */ "mmmmmmm.o" + /* 10 */ "mmmmmmm.q" + /* 11 */ "mmmmmmm.q" + /* 12 */ "mmmmmmm.q" - // Level 12 + // Level 14 /* z\x* 012345678 */ /* 0 */ "........." /* 1 */ "........." /* 2 */ "........." /* 3 */ "........." /* 4 */ "........." - /* 5 */ "........o" - /* 6 */ "........k" + /* 5 */ "........q" + /* 6 */ "........n" /* 7 */ "........." /* 8 */ "........." /* 9 */ "........." @@ -3501,15 +3729,31 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "........." /* 12 */ "........." - // Level 13 + // Level 15 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." + /* 3 */ "........." + /* 4 */ "........q" + /* 5 */ "........q" + /* 6 */ "........n" + /* 7 */ "........." + /* 8 */ "........." + /* 9 */ "........." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ "........." + + // Level 16 /* z\x* 012345678 */ /* 0 */ "........." /* 1 */ "........." /* 2 */ "........." /* 3 */ "........." - /* 4 */ "........o" - /* 5 */ "........o" - /* 6 */ "........k" + /* 4 */ "........q" + /* 5 */ "........n" + /* 6 */ "........." /* 7 */ "........." /* 8 */ "........." /* 9 */ "........." @@ -3517,40 +3761,215 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "........." /* 12 */ "........." - // Level 14 - /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." - /* 3 */ "........." - /* 4 */ "........o" - /* 5 */ "........k" - /* 6 */ "........." - /* 7 */ "........." - /* 8 */ "........." - /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ "........." + // Level 17 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." + /* 3 */ "........." + /* 4 */ "........q" + /* 5 */ "........n" + /* 6 */ "........." + /* 7 */ "........." + /* 8 */ "........." + /* 9 */ "........." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ ".........", + + // Connectors: + "-1: 8, 2, 6: 5\n" /* Type -1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // WoodenMill5x5 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // WoodenStables: + // The data has been exported from the gallery Plains, area index 55, ID 106, created by Aloe_vera + { + // Size: + 15, 10, 9, // SizeX = 15, SizeY = 10, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 14, 9, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 4: 0\n" /* cobblestone */ + "g: 17: 0\n" /* tree */ + "h:107: 0\n" /* fencegate */ + "i:107: 4\n" /* fencegate */ + "j: 5: 0\n" /* wood */ + "k:107: 6\n" /* fencegate */ + "l: 85: 0\n" /* fence */ + "m: 19: 0\n" /* sponge */ + "n:170: 0\n" /* haybale */ + "o:170: 4\n" /* haybale */ + "p:170: 8\n" /* haybale */ + "q: 50: 1\n" /* torch */ + "r: 50: 2\n" /* torch */ + "s: 53: 2\n" /* woodstairs */ + "t: 53: 7\n" /* woodstairs */ + "u: 53: 6\n" /* woodstairs */ + "v: 53: 3\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "aaaaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaaaaaa" + + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "baaaaaaaaaaaaab" + /* 1 */ "baaaaaaaaaaaaab" + /* 2 */ "baaaaaaaaaaaaab" + /* 3 */ "baaaaaaaaaaaaab" + /* 4 */ "baaaaaaaaaaaaab" + /* 5 */ "baaaaaaaaaaaaab" + /* 6 */ "baaaaaaaaaaaaab" + /* 7 */ "baaaaaaaaaaaaab" + /* 8 */ "bbbbbbbbbbbbbbb" + + // Level 2 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ ".cddddddddddde." + /* 1 */ ".fffffffffffff." + /* 2 */ ".faaaaaaaaaaaf." + /* 3 */ ".faaaaaaaaaaaf." + /* 4 */ ".faaaaaaaaaaaf." + /* 5 */ ".faaaaaaaaaaaf." + /* 6 */ ".faaaaaaaaaaaf." + /* 7 */ ".fffffffffffff." + /* 8 */ "..............." + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".ghihjhihjhkhg." + /* 2 */ ".l...l...l...l." + /* 3 */ ".l...l...l...l." + /* 4 */ ".l...l...l...l." + /* 5 */ ".l...l...l...l." + /* 6 */ ".ln..l..olp..l." + /* 7 */ ".gllljllljlllg." + /* 8 */ "..............." + + // Level 4 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".g...j...j...g." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "..............." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ ".g...j...j...g." + /* 8 */ "..............." + + // Level 5 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".gq.rjq.rjq.rg." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "..............." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ ".g...j...j...g." + /* 8 */ "..............." + + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "sssssssssssssss" + /* 1 */ "tjjjjjjjjjjjjjt" + /* 2 */ ".j...........j." + /* 3 */ ".j...........j." + /* 4 */ ".j...........j." + /* 5 */ ".j...........j." + /* 6 */ ".j...........j." + /* 7 */ "ujjjjjjjjjjjjju" + /* 8 */ "vvvvvvvvvvvvvvv" - // Level 15 - /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." - /* 3 */ "........." - /* 4 */ "........o" - /* 5 */ "........k" - /* 6 */ "........." - /* 7 */ "........." - /* 8 */ "........." - /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ ".........", + // Level 7 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "sssssssssssssss" + /* 2 */ "tjjjjjjjjjjjjjt" + /* 3 */ ".j...........j." + /* 4 */ ".j...........j." + /* 5 */ ".j...........j." + /* 6 */ "ujjjjjjjjjjjjju" + /* 7 */ "vvvvvvvvvvvvvvv" + /* 8 */ "..............." + + // Level 8 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "sssssssssssssss" + /* 3 */ "tjjjjjjjjjjjjjt" + /* 4 */ ".j...........j." + /* 5 */ "ujjjjjjjjjjjjju" + /* 6 */ "vvvvvvvvvvvvvvv" + /* 7 */ "..............." + /* 8 */ "..............." + + // Level 9 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "sssssssssssssss" + /* 4 */ "jjjjjjjjjjjjjjj" + /* 5 */ "vvvvvvvvvvvvvvv" + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "...............", // Connectors: - "-1: 5, 0, 6: 5\n" /* Type -1, direction X+ */, + "-1: 7, 2, -1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3569,7 +3988,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // Windmill + }, // WoodenStables }; // g_PlainsVillagePrefabs @@ -3580,7 +3999,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Well: + // CobbleWell4x4: // The data has been exported from the gallery Plains, area index 1, ID 5, created by Aloe_vera { // Size: @@ -3713,7 +4132,215 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = // AddWeightIfSame: 0, - }, // Well + }, // CobbleWell4x4 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // RoofedWell: + // The data has been exported from the gallery Plains, area index 119, ID 271, created by STR_Warrior + { + // Size: + 7, 15, 7, // SizeX = 7, SizeY = 15, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 14, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 1: 0\n" /* stone */ + "b: 4: 0\n" /* cobblestone */ + "c: 8: 0\n" /* water */ + "d: 3: 0\n" /* dirt */ + "e: 2: 0\n" /* grass */ + "f: 13: 0\n" /* gravel */ + "g:118: 3\n" /* cauldronblock */ + "h: 85: 0\n" /* fence */ + "i: 53: 2\n" /* woodstairs */ + "j: 53: 7\n" /* woodstairs */ + "k: 5: 0\n" /* wood */ + "l: 53: 4\n" /* woodstairs */ + "m: 19: 0\n" /* sponge */ + "n: 53: 5\n" /* woodstairs */ + "o: 53: 6\n" /* woodstairs */ + "p: 53: 3\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "aaaaaaa" + /* 2 */ "aaaaaaa" + /* 3 */ "aaaaaaa" + /* 4 */ "aaaaaaa" + /* 5 */ "aaaaaaa" + /* 6 */ "aaaaaaa" + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "ddddddd" + /* 1 */ "dbbbbbd" + /* 2 */ "dbcccbd" + /* 3 */ "dbcccbd" + /* 4 */ "dbcccbd" + /* 5 */ "dbbbbbd" + /* 6 */ "ddddddd" + + // Level 6 + /* z\x* 0123456 */ + /* 0 */ "ddddddd" + /* 1 */ "dbbbbbd" + /* 2 */ "dbcccbd" + /* 3 */ "dbcccbd" + /* 4 */ "dbcccbd" + /* 5 */ "dbbbbbd" + /* 6 */ "ddddddd" + + // Level 7 + /* z\x* 0123456 */ + /* 0 */ "ddddddd" + /* 1 */ "dbbbbbd" + /* 2 */ "dbcccbd" + /* 3 */ "dbcccbd" + /* 4 */ "dbcccbd" + /* 5 */ "dbbbbbd" + /* 6 */ "ddddddd" + + // Level 8 + /* z\x* 0123456 */ + /* 0 */ "eefffee" + /* 1 */ "ebbbbbe" + /* 2 */ "fbcccbf" + /* 3 */ "fbcccbf" + /* 4 */ "fbcccbf" + /* 5 */ "ebbbbbe" + /* 6 */ "eefffee" + + // Level 9 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".bbbbb." + /* 2 */ ".b...b." + /* 3 */ ".b.g.b." + /* 4 */ ".b...b." + /* 5 */ ".bbbbb." + /* 6 */ "......." + + // Level 10 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".h...h." + /* 2 */ "......." + /* 3 */ "...h..." + /* 4 */ "......." + /* 5 */ ".h...h." + /* 6 */ "......." + + // Level 11 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".h...h." + /* 2 */ "......." + /* 3 */ "...h..." + /* 4 */ "......." + /* 5 */ ".h...h." + /* 6 */ "......." + + // Level 12 + /* z\x* 0123456 */ + /* 0 */ "iiiiiii" + /* 1 */ "jkjjjkj" + /* 2 */ ".l...n." + /* 3 */ ".l.h.n." + /* 4 */ ".l...n." + /* 5 */ "okoooko" + /* 6 */ "ppppppp" + + // Level 13 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "iiiiiii" + /* 2 */ "jkjjjkj" + /* 3 */ ".k.h.k." + /* 4 */ "okoooko" + /* 5 */ "ppppppp" + /* 6 */ "......." + + // Level 14 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "......." + /* 2 */ "iiiiiii" + /* 3 */ "kkkkkkk" + /* 4 */ "ppppppp" + /* 5 */ "......." + /* 6 */ ".......", + + // Connectors: + "2: 0, 9, 3: 4\n" /* Type 2, direction X- */ + "2: 3, 9, 6: 3\n" /* Type 2, direction Z+ */ + "2: 6, 9, 3: 5\n" /* Type 2, direction X+ */ + "2: 3, 9, 0: 2\n" /* Type 2, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // RoofedWell }; -- cgit v1.2.3 From 7777da379d35b10bee38b2faf218810552452130 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sat, 17 May 2014 14:04:44 +0100 Subject: Fix assignment operators --- src/ChunkBuffer.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/ChunkBuffer.h b/src/ChunkBuffer.h index e16575bb2..1f170abba 100644 --- a/src/ChunkBuffer.h +++ b/src/ChunkBuffer.h @@ -53,21 +53,25 @@ public: other.IsOwner = false; } - void operator=(const cChunkBuffer& other) + cChunkBuffer& operator=(const cChunkBuffer& other) { - if(IsOwner) + if(&other == this) { + if(IsOwner) + { + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + if(m_Sections[i]) Free(m_Sections[i]);; + } + } + IsOwner = true; for (int i = 0; i < CHUNK_SECTION_NUM; i++) { - if(m_Sections[i]) Free(m_Sections[i]);; + m_Sections[i] = other.m_Sections[i]; } + other.IsOwner = false; } - IsOwner = true; - for (int i = 0; i < CHUNK_SECTION_NUM; i++) - { - m_Sections[i] = other.m_Sections[i]; - } - other.IsOwner = false; + } #else // unique_ptr style interface for memory management @@ -79,7 +83,7 @@ public: } } - void operator=(const cChunkBuffer&& other) + cChunkBuffer& operator=(const cChunkBuffer&& other) { for (int i = 0; i < CHUNK_SECTION_NUM; i++) { -- cgit v1.2.3 From 4e841146b89523b0fe3f8f75b75c97a29b194e21 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sat, 17 May 2014 14:29:15 +0100 Subject: Fix assignment ops 2 --- src/ChunkBuffer.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ChunkBuffer.h b/src/ChunkBuffer.h index 1f170abba..66edce867 100644 --- a/src/ChunkBuffer.h +++ b/src/ChunkBuffer.h @@ -71,6 +71,7 @@ public: } other.IsOwner = false; } + return *this; } #else @@ -85,11 +86,15 @@ public: cChunkBuffer& operator=(const cChunkBuffer&& other) { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + if(&other != this) { - if(m_Sections[i]) Free(m_Sections[i]);; - m_Sections[i] = other.m_Sections[i]; + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + if(m_Sections[i]) Free(m_Sections[i]);; + m_Sections[i] = other.m_Sections[i]; + } } + return *this; } #endif -- cgit v1.2.3 From 1f98f21dd1c1664102dfb480a69c8d1901c3ae5f Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 17 May 2014 15:11:58 +0100 Subject: fixed assignment bugs and Skylight bug --- src/ChunkBuffer.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ChunkBuffer.h b/src/ChunkBuffer.h index 66edce867..4086c4ae9 100644 --- a/src/ChunkBuffer.h +++ b/src/ChunkBuffer.h @@ -76,15 +76,16 @@ public: } #else // unique_ptr style interface for memory management - cChunkBuffer(const cChunkBuffer&& other) + cChunkBuffer(cChunkBuffer&& other) { for (int i = 0; i < CHUNK_SECTION_NUM; i++) { m_Sections[i] = other.m_Sections[i]; + other.m_Sections[i] = 0; } } - cChunkBuffer& operator=(const cChunkBuffer&& other) + cChunkBuffer& operator=(cChunkBuffer&& other) { if(&other != this) { @@ -92,6 +93,7 @@ public: { if(m_Sections[i]) Free(m_Sections[i]);; m_Sections[i] = other.m_Sections[i]; + other.m_Sections[i] = 0; } } return *this; @@ -230,7 +232,7 @@ public: } else { - return 0xFF; + return 0xF; } } ASSERT(!"cChunkBuffer::GetMeta(): coords out of chunk range!"); -- cgit v1.2.3 From f451075c1f60dbea9521113269cc8e69e0730841 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 17 May 2014 15:32:28 +0100 Subject: derp --- src/ChunkBuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkBuffer.h b/src/ChunkBuffer.h index 4086c4ae9..bd178beaa 100644 --- a/src/ChunkBuffer.h +++ b/src/ChunkBuffer.h @@ -55,7 +55,7 @@ public: cChunkBuffer& operator=(const cChunkBuffer& other) { - if(&other == this) + if(&other != this) { if(IsOwner) { -- cgit v1.2.3 From 6951b68aaf208c7efdcc954fbc54420966fafa4a Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Sat, 17 May 2014 18:38:33 +0200 Subject: Added load command in the cServer class --- src/Server.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/Server.cpp b/src/Server.cpp index bfb1b1cbb..91bc6853e 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -476,6 +476,12 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac a_Output.Finished(); return; } + if (split[0] == "load" && !split[1].empty()) + { + cPluginManager::Get()->LoadPlugin(split[1]); + a_Output.Out("Plugin " + split[1] + " added and activated!"); + a_Output.Finished(); + } // There is currently no way a plugin can do these (and probably won't ever be): if (split[0].compare("chunkstats") == 0) -- cgit v1.2.3 From 19f4cd05470785a1afdc764b79db3777f62fe65d Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Sat, 17 May 2014 19:39:16 +0200 Subject: Added load cmd --- src/Server.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Server.cpp b/src/Server.cpp index 91bc6853e..8e222b743 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -476,13 +476,34 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac a_Output.Finished(); return; } - if (split[0] == "load" && !split[1].empty()) + if (split[0] == "load") { - cPluginManager::Get()->LoadPlugin(split[1]); - a_Output.Out("Plugin " + split[1] + " added and activated!"); - a_Output.Finished(); + if (split.size() > 1) + { + cPluginManager::Get()->LoadPlugin(split[1]); + return; + } + else + { + a_Output.Out("No plugin given! Command: load "); + a_Output.Finished(); + return; + } } - + /* + * TODO: Declare unload command + if (split[0] == "unload") + { + if (split.size() > 1) + { + + } + else + { + + } + } + */ // There is currently no way a plugin can do these (and probably won't ever be): if (split[0].compare("chunkstats") == 0) { @@ -573,6 +594,9 @@ void cServer::BindBuiltInConsoleCommands(void) PlgMgr->BindConsoleCommand("restart", NULL, " - Restarts the server cleanly"); PlgMgr->BindConsoleCommand("stop", NULL, " - Stops the server cleanly"); PlgMgr->BindConsoleCommand("chunkstats", NULL, " - Displays detailed chunk memory statistics"); + PlgMgr->BindConsoleCommand("load ", NULL, " - Adds and enables the specified plugin"); + PlgMgr->BindConsoleCommand("unload ", NULL, " - Disables the specified plugin"); + #if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER) PlgMgr->BindConsoleCommand("dumpmem", NULL, " - Dumps all used memory blocks together with their callstacks into memdump.xml"); #endif -- cgit v1.2.3 From 7004043c6164c6b22346f94489cb823f9495738f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 17 May 2014 21:54:04 +0200 Subject: Village houses are height-adjusted onto the terrain. --- src/Generating/PieceGenerator.cpp | 11 +++++++++++ src/Generating/PieceGenerator.h | 7 +++++++ src/Generating/Prefab.cpp | 12 ++++++++++-- src/Generating/Prefab.h | 3 +++ src/Generating/VillageGen.cpp | 41 ++++++++++++++++++++++++++++++++++----- 5 files changed, 67 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index ce19c1c95..c12559d3f 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -297,6 +297,17 @@ cPlacedPiece::cPlacedPiece(const cPlacedPiece * a_Parent, const cPiece & a_Piece +cPiece::cConnector cPlacedPiece::GetRotatedConnector(size_t a_Index) const +{ + cPiece::cConnectors Connectors = m_Piece->GetConnectors(); + ASSERT(Connectors.size() >= a_Index); + return m_Piece->RotateMoveConnector(Connectors[a_Index], m_NumCCWRotations, m_Coords.x, m_Coords.y, m_Coords.z); +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cPieceGenerator: diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index 16bec3bb4..56ce996d2 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -144,6 +144,13 @@ public: const cCuboid & GetHitBox (void) const { return m_HitBox; } int GetDepth (void) const { return m_Depth; } + /** Returns the coords as a modifiable object. */ + Vector3i & GetCoords(void) { return m_Coords; } + + /** Returns the connector at the specified index, rotated in the actual placement. + Undefined behavior if a_Index is out of range. */ + cPiece::cConnector GetRotatedConnector(size_t a_Index) const; + protected: const cPlacedPiece * m_Parent; const cPiece * m_Piece; diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 9aef7a94b..506e1c2cc 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -191,13 +191,21 @@ void cPrefab::AddRotatedBlockAreas(void) void cPrefab::Draw(cChunkDesc & a_Dest, const cPlacedPiece * a_Placement) const +{ + Draw(a_Dest, a_Placement->GetCoords(), a_Placement->GetNumCCWRotations()); +} + + + + +void cPrefab::Draw(cChunkDesc & a_Dest, const Vector3i & a_Placement, int a_NumRotations) const { // Draw the basic image: - Vector3i Placement = a_Placement->GetCoords(); + Vector3i Placement(a_Placement); int ChunkStartX = a_Dest.GetChunkX() * cChunkDef::Width; int ChunkStartZ = a_Dest.GetChunkZ() * cChunkDef::Width; Placement.Move(-ChunkStartX, 0, -ChunkStartZ); - const cBlockArea & Image = m_BlockArea[a_Placement->GetNumCCWRotations()]; + const cBlockArea & Image = m_BlockArea[a_NumRotations]; a_Dest.WriteBlockArea(Image, Placement.x, Placement.y, Placement.z, m_MergeStrategy); // If requested, draw the floor (from the bottom of the prefab down to the nearest non-air) diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index c08413e87..2b89a204c 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -94,6 +94,9 @@ public: /** Draws the prefab into the specified chunk, according to the placement stored in the PlacedPiece. */ void Draw(cChunkDesc & a_Dest, const cPlacedPiece * a_Placement) const; + /** Draws the prefab into the specified chunks, according to the specified placement and rotations. */ + void Draw(cChunkDesc & a_Dest, const Vector3i & a_Placement, int a_NumRotations) const; + /** Returns true if the prefab has any connector of the specified type. */ bool HasConnectorType(int a_ConnectorType) const; diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index b514a90cd..db81fb521 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -115,7 +115,9 @@ public: m_HeightGen(a_HeightGen) { cBFSPieceGenerator pg(m_Prefabs, a_Seed); - pg.PlacePieces(a_OriginX, 10, a_OriginZ, a_MaxRoadDepth + 1, m_Pieces); + // Generate the pieces at very negative Y coords, so that we can later test + // Piece has negative Y coord -> hasn't been height-adjusted yet + pg.PlacePieces(a_OriginX, -1000, a_OriginZ, a_MaxRoadDepth + 1, m_Pieces); } protected: @@ -144,16 +146,45 @@ protected: // cGrdStructGen::cStructure overrides: virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override { - // TODO // Iterate over all items - // Each intersecting prefab is placed on ground (if not already placed), then drawn + // Each intersecting prefab is placed on ground, then drawn // Each intersecting road is drawn by replacing top soil blocks with gravel / sandstone blocks - for (cPlacedPieces::const_iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr) + cChunkDef::HeightMap HeightMap; // Heightmap for this chunk, used by roads + m_HeightGen.GenHeightMap(a_Chunk.GetChunkX(), a_Chunk.GetChunkZ(), HeightMap); + for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr) { - const cPrefab & Prefab = (const cPrefab &)((*itr)->GetPiece()); + cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece()); + if ((*itr)->GetPiece().GetSize().y == 1) + { + // It's a road, special handling (change top terrain blocks + // TODO + Prefab.Draw(a_Chunk, (*itr)->GetCoords() + Vector3i(0, 1100, 0), (*itr)->GetNumCCWRotations()); + continue; + } + if ((*itr)->GetCoords().y < 0) + { + PlacePieceOnGround(**itr); + } Prefab.Draw(a_Chunk, *itr); } // for itr - m_PlacedPieces[] } + + + /** Adjusts the Y coord of the given piece so that the piece is on the ground. + Ground level is assumed to be represented by the first connector in the piece. */ + void PlacePieceOnGround(cPlacedPiece & a_Piece) + { + cPiece::cConnector FirstConnector = a_Piece.GetRotatedConnector(0); + int ChunkX, ChunkZ; + int BlockX = FirstConnector.m_Pos.x; + int BlockZ = FirstConnector.m_Pos.z; + int BlockY; + cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ); + cChunkDef::HeightMap HeightMap; + m_HeightGen.GenHeightMap(ChunkX, ChunkZ, HeightMap); + int TerrainHeight = cChunkDef::GetHeight(HeightMap, BlockX, BlockZ); + a_Piece.GetCoords().y += TerrainHeight - FirstConnector.m_Pos.y + 1; + } } ; -- cgit v1.2.3 From a7e52e51dc3665ac2c2f27ed52e732ef7bbad32e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 17 May 2014 22:26:09 +0200 Subject: Village roads are drawn properly. --- src/Generating/PieceGenerator.h | 4 ++-- src/Generating/VillageGen.cpp | 39 +++++++++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index 56ce996d2..643ca58b6 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -156,8 +156,8 @@ protected: const cPiece * m_Piece; Vector3i m_Coords; int m_NumCCWRotations; - cCuboid m_HitBox; - int m_Depth; + cCuboid m_HitBox; // Hitbox of the placed piece, in world coords + int m_Depth; // Depth in the generated piece tree }; typedef std::vector cPlacedPieces; diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index db81fb521..520d63029 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -104,7 +104,8 @@ public: int a_MaxRoadDepth, int a_MaxSize, cPrefabPiecePool & a_Prefabs, - cTerrainHeightGen & a_HeightGen + cTerrainHeightGen & a_HeightGen, + BLOCKTYPE a_RoadBlock ) : super(a_OriginX, a_OriginZ), m_Seed(a_Seed), @@ -112,7 +113,8 @@ public: m_MaxSize(a_MaxSize), m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, 255, a_OriginZ + a_MaxSize), m_Prefabs(a_Prefabs), - m_HeightGen(a_HeightGen) + m_HeightGen(a_HeightGen), + m_RoadBlock(a_RoadBlock) { cBFSPieceGenerator pg(m_Prefabs, a_Seed); // Generate the pieces at very negative Y coords, so that we can later test @@ -142,6 +144,9 @@ protected: /** The village pieces, placed by the generator. */ cPlacedPieces m_Pieces; + /** The block to use for the roads. */ + BLOCKTYPE m_RoadBlock; + // cGrdStructGen::cStructure overrides: virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override @@ -156,9 +161,8 @@ protected: cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece()); if ((*itr)->GetPiece().GetSize().y == 1) { - // It's a road, special handling (change top terrain blocks - // TODO - Prefab.Draw(a_Chunk, (*itr)->GetCoords() + Vector3i(0, 1100, 0), (*itr)->GetNumCCWRotations()); + // It's a road, special handling (change top terrain blocks to m_RoadBlock) + DrawRoad(a_Chunk, **itr, HeightMap); continue; } if ((*itr)->GetCoords().y < 0) @@ -185,6 +189,27 @@ protected: int TerrainHeight = cChunkDef::GetHeight(HeightMap, BlockX, BlockZ); a_Piece.GetCoords().y += TerrainHeight - FirstConnector.m_Pos.y + 1; } + + + /** Draws the road into the chunk. + The heightmap is not queried from the heightgen, but is given via parameter, so that it may be queried just + once for all roads in a chunk. */ + void DrawRoad(cChunkDesc & a_Chunk, cPlacedPiece & a_Road, cChunkDef::HeightMap & a_HeightMap) + { + cCuboid RoadCoords = a_Road.GetHitBox(); + RoadCoords.Sort(); + int MinX = std::max(RoadCoords.p1.x - a_Chunk.GetChunkX() * cChunkDef::Width, 0); + int MaxX = std::min(RoadCoords.p2.x - a_Chunk.GetChunkX() * cChunkDef::Width, cChunkDef::Width - 1); + int MinZ = std::max(RoadCoords.p1.z - a_Chunk.GetChunkZ() * cChunkDef::Width, 0); + int MaxZ = std::min(RoadCoords.p2.z - a_Chunk.GetChunkZ() * cChunkDef::Width, cChunkDef::Width - 1); + for (int z = MinZ; z <= MaxZ; z++) + { + for (int x = MinX; x <= MaxX; x++) + { + a_Chunk.SetBlockType(x, cChunkDef::GetHeight(a_HeightMap, x, z), z, m_RoadBlock); + } + } + } } ; @@ -228,6 +253,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ // Check if all the biomes are village-friendly: // If just one is not, no village is created, because it's likely that an unfriendly biome is too close cVillagePiecePool * VillagePrefabs = NULL; + BLOCKTYPE RoadBlock = E_BLOCK_GRAVEL; for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++) { switch (Biomes[i]) @@ -237,6 +263,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ { // These biomes allow sand villages VillagePrefabs = &g_SandVillage; + RoadBlock = E_BLOCK_SANDSTONE; break; } case biPlains: @@ -261,7 +288,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ { return cStructurePtr(); } - return cStructurePtr(new cVillage(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, *VillagePrefabs, m_HeightGen)); + return cStructurePtr(new cVillage(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, *VillagePrefabs, m_HeightGen, RoadBlock)); } -- cgit v1.2.3 From 8a0d3f79219a324c11930c8f22763f34e16a96f6 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 18 May 2014 15:10:12 +0100 Subject: Fixed issue with types not being defined for an unused parameter --- src/BlockArea.h | 1 + src/ChunkBuffer.h | 63 -------------------- src/ChunkDataCallback.h | 105 ++++++++++++++++++++++++++++++++++ src/ChunkDef.h | 40 ------------- src/ChunkMap.h | 3 +- src/ChunkSender.h | 2 +- src/WorldStorage/NBTChunkSerializer.h | 2 +- src/WorldStorage/WSSCompact.h | 2 +- 8 files changed, 111 insertions(+), 107 deletions(-) create mode 100644 src/ChunkDataCallback.h (limited to 'src') diff --git a/src/BlockArea.h b/src/BlockArea.h index 50c28aaf2..9c01719c3 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -14,6 +14,7 @@ #include "ForEachChunkProvider.h" #include "Vector3.h" +#include "ChunkDataCallback.h" diff --git a/src/ChunkBuffer.h b/src/ChunkBuffer.h index bd178beaa..266df2332 100644 --- a/src/ChunkBuffer.h +++ b/src/ChunkBuffer.h @@ -275,68 +275,5 @@ private: -/** A simple implementation of the cChunkDataCallback interface that collects all block data into a buffer -*/ -class cChunkBufferCollector : - public cChunkDataCallback -{ -public: - - cChunkBuffer m_BlockData; - -protected: - - virtual void ChunkBuffer(const cChunkBuffer & a_BlockData) override - { - m_BlockData = a_BlockData.Copy(); - } -}; - - -/** A simple implementation of the cChunkDataCallback interface that collects all block data into a single buffer -*/ -class cChunkDataCollector : -public cChunkDataCallback -{ -public: - - // Must be unsigned char instead of BLOCKTYPE or NIBBLETYPE, because it houses both. - unsigned char m_BlockData[cChunkDef::BlockDataSize]; - -protected: - - virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override - { - a_ChunkBuffer.CopyBlocks(m_BlockData); - a_ChunkBuffer.CopyMeta(m_BlockData + cChunkDef::NumBlocks); - a_ChunkBuffer.CopyLight(m_BlockData + 3 * cChunkDef::NumBlocks / 2); - a_ChunkBuffer.CopySkyLight(m_BlockData + 2 * cChunkDef::NumBlocks); - } -}; - -/** A simple implementation of the cChunkDataCallback interface that collects all block data into a separate buffers -*/ -class cChunkDataSeparateCollector : -public cChunkDataCallback -{ -public: - - cChunkDef::BlockTypes m_BlockTypes; - cChunkDef::BlockNibbles m_BlockMetas; - cChunkDef::BlockNibbles m_BlockLight; - cChunkDef::BlockNibbles m_BlockSkyLight; - -protected: - - virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override - { - a_ChunkBuffer.CopyBlocks(m_BlockTypes); - a_ChunkBuffer.CopyMeta(m_BlockMetas); - a_ChunkBuffer.CopyLight(m_BlockLight); - a_ChunkBuffer.CopySkyLight(m_BlockSkyLight); - } -} ; - - diff --git a/src/ChunkDataCallback.h b/src/ChunkDataCallback.h new file mode 100644 index 000000000..76c45040e --- /dev/null +++ b/src/ChunkDataCallback.h @@ -0,0 +1,105 @@ + + +#pragma once + + +#include "ChunkBuffer.h" + + +/** Interface class used for getting data out of a chunk using the GetAllData() function. +Implementation must use the pointers immediately and NOT store any of them for later use +The virtual methods are called in the same order as they're declared here. +*/ +class cChunkDataCallback abstract +{ +public: + + virtual ~cChunkDataCallback() {} + + /** Called before any other callbacks to inform of the current coords + (only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()). + If false is returned, the chunk is skipped. + */ + virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; }; + + /// Called once to provide heightmap data + virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) {UNUSED(a_HeightMap); }; + + /// Called once to provide biome data + virtual void BiomeData (const cChunkDef::BiomeMap * a_BiomeMap) {UNUSED(a_BiomeMap); }; + + /// Called once to let know if the chunk lighting is valid. Return value is ignored + virtual void LightIsValid(bool a_IsLightValid) {UNUSED(a_IsLightValid); }; + + /// Called once to export block info + virtual void ChunkBuffer (const cChunkBuffer & a_Buffer) {UNUSED(a_Buffer); }; + + /// Called for each entity in the chunk + virtual void Entity(cEntity * a_Entity) {UNUSED(a_Entity); }; + + /// Called for each blockentity in the chunk + virtual void BlockEntity(cBlockEntity * a_Entity) {UNUSED(a_Entity); }; +} ; + +/** A simple implementation of the cChunkDataCallback interface that collects all block data into a buffer +*/ +class cChunkBufferCollector : + public cChunkDataCallback +{ +public: + + cChunkBuffer m_BlockData; + +protected: + + virtual void ChunkBuffer(const cChunkBuffer & a_BlockData) override + { + m_BlockData = a_BlockData.Copy(); + } +}; + + +/** A simple implementation of the cChunkDataCallback interface that collects all block data into a single buffer +*/ +class cChunkDataCollector : +public cChunkDataCallback +{ +public: + + // Must be unsigned char instead of BLOCKTYPE or NIBBLETYPE, because it houses both. + unsigned char m_BlockData[cChunkDef::BlockDataSize]; + +protected: + + virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override + { + a_ChunkBuffer.CopyBlocks(m_BlockData); + a_ChunkBuffer.CopyMeta(m_BlockData + cChunkDef::NumBlocks); + a_ChunkBuffer.CopyLight(m_BlockData + 3 * cChunkDef::NumBlocks / 2); + a_ChunkBuffer.CopySkyLight(m_BlockData + 2 * cChunkDef::NumBlocks); + } +}; + +/** A simple implementation of the cChunkDataCallback interface that collects all block data into a separate buffers +*/ +class cChunkDataSeparateCollector : +public cChunkDataCallback +{ +public: + + cChunkDef::BlockTypes m_BlockTypes; + cChunkDef::BlockNibbles m_BlockMetas; + cChunkDef::BlockNibbles m_BlockLight; + cChunkDef::BlockNibbles m_BlockSkyLight; + +protected: + + virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override + { + a_ChunkBuffer.CopyBlocks(m_BlockTypes); + a_ChunkBuffer.CopyMeta(m_BlockMetas); + a_ChunkBuffer.CopyLight(m_BlockLight); + a_ChunkBuffer.CopySkyLight(m_BlockSkyLight); + } +} ; + diff --git a/src/ChunkDef.h b/src/ChunkDef.h index d79f4b92b..f89e16ed1 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -328,46 +328,6 @@ private: -class cChunkBuffer; - - -/** Interface class used for getting data out of a chunk using the GetAllData() function. -Implementation must use the pointers immediately and NOT store any of them for later use -The virtual methods are called in the same order as they're declared here. -*/ -class cChunkDataCallback abstract -{ -public: - - virtual ~cChunkDataCallback() {} - - /** Called before any other callbacks to inform of the current coords - (only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()). - If false is returned, the chunk is skipped. - */ - virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; }; - - /// Called once to provide heightmap data - virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) {UNUSED(a_HeightMap); }; - - /// Called once to provide biome data - virtual void BiomeData (const cChunkDef::BiomeMap * a_BiomeMap) {UNUSED(a_BiomeMap); }; - - /// Called once to let know if the chunk lighting is valid. Return value is ignored - virtual void LightIsValid(bool a_IsLightValid) {UNUSED(a_IsLightValid); }; - - /// Called once to export block info - virtual void ChunkBuffer (const cChunkBuffer & a_Buffer) {UNUSED(a_Buffer); }; - - /// Called for each entity in the chunk - virtual void Entity(cEntity * a_Entity) {UNUSED(a_Entity); }; - - /// Called for each blockentity in the chunk - virtual void BlockEntity(cBlockEntity * a_Entity) {UNUSED(a_Entity); }; -} ; - - - /** Interface class used for comparing clients of two chunks. diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 9d973f2a9..c3deda088 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -5,7 +5,8 @@ #pragma once -#include "ChunkDef.h" + +#include "ChunkDataCallback.h" diff --git a/src/ChunkSender.h b/src/ChunkSender.h index 81b298a55..00565d7c3 100644 --- a/src/ChunkSender.h +++ b/src/ChunkSender.h @@ -27,7 +27,7 @@ Note that it may be called by world's BroadcastToChunk() if the client is still #include "OSSupport/IsThread.h" #include "ChunkDef.h" -#include "ChunkBuffer.h" +#include "ChunkDataCallback.h" diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h index 6da2bc6dd..112afc27e 100644 --- a/src/WorldStorage/NBTChunkSerializer.h +++ b/src/WorldStorage/NBTChunkSerializer.h @@ -9,7 +9,7 @@ #pragma once -#include "../ChunkBuffer.h" +#include "ChunkDataCallback.h" diff --git a/src/WorldStorage/WSSCompact.h b/src/WorldStorage/WSSCompact.h index 606853a16..6c363d5ac 100644 --- a/src/WorldStorage/WSSCompact.h +++ b/src/WorldStorage/WSSCompact.h @@ -14,7 +14,7 @@ #include "WorldStorage.h" #include "../Vector3.h" #include "json/json.h" -#include "ChunkBuffer.h" +#include "ChunkDataCallback.h" -- cgit v1.2.3 From cfd3c33dfa38c946151a1c4d3ba780f7733963c0 Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Sun, 18 May 2014 17:16:02 +0200 Subject: Added unload command --- src/Server.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Server.cpp b/src/Server.cpp index 8e222b743..e71e728a6 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -29,6 +29,7 @@ #include #include #include +#include extern "C" { #include "zlib/zlib.h" @@ -481,6 +482,7 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac if (split.size() > 1) { cPluginManager::Get()->LoadPlugin(split[1]); + return; } else @@ -490,20 +492,22 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac return; } } - /* - * TODO: Declare unload command + if (split[0] == "unload") { if (split.size() > 1) { - + cPluginManager::Get()->RemovePlugin(cPluginManager::Get()->GetPlugin(split[1])); + return; } else { - + a_Output.Out("No plugin given! Command: unload "); + a_Output.Finished(); + return; } } - */ + // There is currently no way a plugin can do these (and probably won't ever be): if (split[0].compare("chunkstats") == 0) { -- cgit v1.2.3 From 40ce737a7e372b5f3aef51cad7362a199351cb27 Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Sun, 18 May 2014 17:30:21 +0200 Subject: removed the include --- src/Server.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/Server.cpp b/src/Server.cpp index e71e728a6..aa731cdd2 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -29,7 +29,6 @@ #include #include #include -#include extern "C" { #include "zlib/zlib.h" -- cgit v1.2.3 From e09a04a23aaa14598bff6692393f4187f59d3824 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 18 May 2014 22:36:17 +0200 Subject: Fixed datatype truncation in Diff() template. --- src/Defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Defines.h b/src/Defines.h index b0b209934..563fc308c 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -529,7 +529,7 @@ inline float GetSpecialSignf( float a_Val ) -template inline int Diff(T a_Val1, T a_Val2) +template inline T Diff(T a_Val1, T a_Val2) { return std::abs(a_Val1 - a_Val2); } -- cgit v1.2.3 From a651c865e40ad80b52ddf69004b40a580e7069ea Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 18 May 2014 22:49:27 +0200 Subject: There's no "round" function in MSVC2008. --- src/Entities/Entity.cpp | 2 +- src/Entities/Player.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index c393f89fd..31ad66779 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -321,7 +321,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) m_World->BroadcastEntityAnimation(*this, 4); // Critical hit } - Player->GetStatManager().AddValue(statDamageDealt, round(a_TDI.FinalDamage * 10)); + Player->GetStatManager().AddValue(statDamageDealt, (StatValue)floor(a_TDI.FinalDamage * 10 + 0.5)); } m_Health -= (short)a_TDI.FinalDamage; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 632c41936..c3b763278 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -838,7 +838,7 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI) AddFoodExhaustion(0.3f); SendHealth(); - m_Stats.AddValue(statDamageTaken, round(a_TDI.FinalDamage * 10)); + m_Stats.AddValue(statDamageTaken, (StatValue)floor(a_TDI.FinalDamage * 10 + 0.5)); return true; } return false; @@ -1953,7 +1953,7 @@ void cPlayer::HandleFloater() void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos) { - StatValue Value = round(a_DeltaPos.Length() * 100); + StatValue Value = (StatValue)floor(a_DeltaPos.Length() * 100 + 0.5); if (m_AttachedTo == NULL) { @@ -1970,7 +1970,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos) if ((Block == E_BLOCK_LADDER) && (a_DeltaPos.y > 0.0)) // Going up { - m_Stats.AddValue(statDistClimbed, round(a_DeltaPos.y * 100)); + m_Stats.AddValue(statDistClimbed, (StatValue)floor(a_DeltaPos.y * 100 + 0.5)); } else { -- cgit v1.2.3 From ec50c0f9e1ee59ad8e782795c46f100be79b3ed0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 18 May 2014 23:09:39 +0200 Subject: Updated SandVillage prefabs to latest Gallery content. This fixes sand village generation. --- src/Generating/Prefabs/SandVillagePrefabs.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/SandVillagePrefabs.cpp b/src/Generating/Prefabs/SandVillagePrefabs.cpp index 8460ee5f7..539f57b9d 100644 --- a/src/Generating/Prefabs/SandVillagePrefabs.cpp +++ b/src/Generating/Prefabs/SandVillagePrefabs.cpp @@ -183,7 +183,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 6 */ "...........", // Connectors: - "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 5, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -326,7 +326,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 8 */ "...........", // Connectors: - "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 5, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -444,7 +444,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 6 */ ".............", // Connectors: - "-1: 6, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 6, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -587,7 +587,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 8 */ ".............", // Connectors: - "-1: 6, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 6, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -730,7 +730,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 8 */ "...............", // Connectors: - "-1: 6, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 6, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -873,7 +873,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 8 */ "................", // Connectors: - "-1: 9, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 9, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -984,7 +984,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 6 */ ".......", // Connectors: - "-1: 4, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 4, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1096,7 +1096,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 6 */ ".........", // Connectors: - "-1: 4, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 4, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1232,7 +1232,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 8 */ ".........", // Connectors: - "-1: 4, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 4, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1384,7 +1384,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 11 */ "mmmmmmm..adc..", // Connectors: - "-1: 8, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 8, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1552,7 +1552,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 11 */ "mmmmm...adc...", // Connectors: - "-1: 5, 0, 1: 2\n" /* Type -1, direction Z- */, + "-1: 5, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1712,7 +1712,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 5 */ ".....", // Connectors: - "-1: 2, 0, 4: 3\n" /* Type -1, direction Z+ */, + "-1: 2, 0, 5: 3\n" /* Type -1, direction Z+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ -- cgit v1.2.3 From 6167c79e7a822cb14431985a82f4cc5b463e556f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 18 May 2014 22:41:42 +0100 Subject: Implemented cacti damage + Implemented cacti damage * Fixed pickup tossing (PR #994 bug) --- src/ClientHandle.cpp | 5 +++-- src/Entities/Entity.cpp | 23 +++++++++++++++++++++++ src/Entities/Entity.h | 3 +++ 3 files changed, 29 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 1009cdbd6..6d0fae3ae 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -816,9 +816,10 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB } if ( - (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || + ((a_Status == DIG_STATUS_STARTED) || (a_Status == DIG_STATUS_FINISHED)) && // Only do a radius check for block destruction - things like pickup tossing send coordinates that are to be ignored + ((Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || - (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) + (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6)) ) { m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 4cf10a219..b7cb2c3d9 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -601,6 +601,10 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk) m_TicksSinceLastVoidDamage = 0; } + if (IsMob() || IsPlayer() || IsPickup() || IsExpOrb()) + { + DetectCacti(); + } if (IsMob() || IsPlayer()) { // Set swimming state @@ -998,6 +1002,25 @@ void cEntity::TickInVoid(cChunk & a_Chunk) +void cEntity::DetectCacti() +{ + int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; + if ( + ((X + 1) - GetPosX() < 0.3) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS) || + ((GetPosX() - (X - 1)) - 1 < 0.3) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS) || + ((Z + 1) - GetPosZ() < 0.3) && (GetWorld()->GetBlock(X, Y, Z + 1) == E_BLOCK_CACTUS) || + ((GetPosZ() - (Z - 1)) - 1 < 0.3) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS) || + (((Y > 0) && (Y < cChunkDef::Height)) && ((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS))) + ) + { + TakeDamage(dtCactus, NULL, 1, 0); + } +} + + + + + void cEntity::SetSwimState(cChunk & a_Chunk) { int RelY = (int)floor(GetPosY() + 0.1); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index df03d635b..d5e7cf5c1 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -317,6 +317,9 @@ public: /// Updates the state related to this entity being on fire virtual void TickBurning(cChunk & a_Chunk); + + /** Detects the time for application of cacti damage */ + virtual void DetectCacti(void); /// Handles when the entity is in the void virtual void TickInVoid(cChunk & a_Chunk); -- cgit v1.2.3 From 70cf4a5eafaf91f9b6d0b71f607270b7df86e6d9 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Mon, 19 May 2014 07:31:53 +0100 Subject: Fixed clanging errors. Please @tigerw make sure this is correct. --- src/Entities/Entity.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index b7cb2c3d9..1a91639ac 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1006,14 +1006,14 @@ void cEntity::DetectCacti() { int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; if ( - ((X + 1) - GetPosX() < 0.3) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS) || - ((GetPosX() - (X - 1)) - 1 < 0.3) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS) || - ((Z + 1) - GetPosZ() < 0.3) && (GetWorld()->GetBlock(X, Y, Z + 1) == E_BLOCK_CACTUS) || - ((GetPosZ() - (Z - 1)) - 1 < 0.3) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS) || + (((X + 1) - GetPosX() < 0.3) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) || + (((GetPosX() - (X - 1)) - 1 < 0.3) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) || + (((Z + 1) - GetPosZ() < 0.3) && (GetWorld()->GetBlock(X, Y, Z + 1) == E_BLOCK_CACTUS)) || + (((GetPosZ() - (Z - 1)) - 1 < 0.3) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS)) || (((Y > 0) && (Y < cChunkDef::Height)) && ((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS))) ) { - TakeDamage(dtCactus, NULL, 1, 0); + TakeDamage(dtCactusContact, NULL, 1, 0); } } -- cgit v1.2.3 From cfbb2563604e77e044be9a0f12b2152a7d626b51 Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Mon, 19 May 2014 10:37:43 +0200 Subject: Fixed some warnings --- src/Simulator/IncrementalRedstoneSimulator.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index 233a3d408..a57a17328 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -202,8 +202,13 @@ private: case E_BLOCK_POWERED_RAIL: { return true; + break; + } + default: + { + return false; + break; } - default: return false; } } @@ -275,8 +280,13 @@ private: case E_BLOCK_PISTON: { return true; + break; + } + default: + { + return false; + break; } - default: return false; } } }; -- cgit v1.2.3 From dc39d88d3f5951479084c1ea4d51079015777f01 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Mon, 19 May 2014 10:35:21 +0100 Subject: Should have fixed assumptions about entity width. @madmaxoft can you comment? --- src/Entities/Entity.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 1a91639ac..71b9f63a7 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1005,11 +1005,12 @@ void cEntity::TickInVoid(cChunk & a_Chunk) void cEntity::DetectCacti() { int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; + float w = m_Width / 2 if ( - (((X + 1) - GetPosX() < 0.3) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) || - (((GetPosX() - (X - 1)) - 1 < 0.3) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) || - (((Z + 1) - GetPosZ() < 0.3) && (GetWorld()->GetBlock(X, Y, Z + 1) == E_BLOCK_CACTUS)) || - (((GetPosZ() - (Z - 1)) - 1 < 0.3) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS)) || + (((X + 1) - GetPosX() < w) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) || + (((GetPosX() - (X - 1)) - 1 < w) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) || + (((Z + 1) - GetPosZ() < w) && (GetWorld()->GetBlock(X, Y, Z + 1) == E_BLOCK_CACTUS)) || + (((GetPosZ() - (Z - 1)) - 1 < w) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS)) || (((Y > 0) && (Y < cChunkDef::Height)) && ((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS))) ) { -- cgit v1.2.3 From e9abf9a4987835a52dab508f9b8a8feb57e9a103 Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Mon, 19 May 2014 13:02:02 +0200 Subject: Rolled some changes back --- src/Simulator/IncrementalRedstoneSimulator.h | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index a57a17328..233a3d408 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -202,13 +202,8 @@ private: case E_BLOCK_POWERED_RAIL: { return true; - break; - } - default: - { - return false; - break; } + default: return false; } } @@ -280,13 +275,8 @@ private: case E_BLOCK_PISTON: { return true; - break; - } - default: - { - return false; - break; } + default: return false; } } }; -- cgit v1.2.3 From 6de0257bbe1f0c676e9cc1401298f08b96b54e73 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Mon, 19 May 2014 13:31:19 +0100 Subject: Derp --- src/Entities/Entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 71b9f63a7..aa671bf35 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1005,7 +1005,7 @@ void cEntity::TickInVoid(cChunk & a_Chunk) void cEntity::DetectCacti() { int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; - float w = m_Width / 2 + float w = m_Width / 2; if ( (((X + 1) - GetPosX() < w) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) || (((GetPosX() - (X - 1)) - 1 < w) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) || -- cgit v1.2.3 From fb7f2993bf3b62c00d4502b846018b035ffbdb7a Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Mon, 19 May 2014 14:34:34 +0200 Subject: Fixed some warnings in Server.cpp, and in UI/ --- src/Server.cpp | 8 +++++++- src/UI/SlotArea.cpp | 3 ++- src/UI/Window.cpp | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Server.cpp b/src/Server.cpp index aa731cdd2..66bccd680 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -107,10 +107,16 @@ void cServer::cTickThread::Execute(void) cServer::cServer(void) : m_ListenThreadIPv4(*this, cSocket::IPv4, "Client IPv4"), m_ListenThreadIPv6(*this, cSocket::IPv6, "Client IPv6"), + m_PlayerCount(0), + m_PlayerCountDiff(0), + m_ClientViewDistance(0), m_bIsConnected(false), m_bRestarting(false), m_RCONServer(*this), - m_TickThread(*this) + m_MaxPlayers(0), + m_bIsHardcore(false), + m_TickThread(*this), + m_ShouldAuthenticate(false) { } diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 8833a767a..be3ce1f8d 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -600,7 +600,8 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player) cSlotAreaAnvil::cSlotAreaAnvil(cAnvilWindow & a_ParentWindow) : cSlotAreaTemporary(3, a_ParentWindow), - m_MaximumCost(0) + m_MaximumCost(0), + m_StackSizeToBeUsedInRepair(0) { } diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 46885390b..24b718156 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -856,7 +856,8 @@ cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : cWindow(wtEnchantment, "Enchant"), m_BlockX(a_BlockX), m_BlockY(a_BlockY), - m_BlockZ(a_BlockZ) + m_BlockZ(a_BlockZ), + m_SlotArea() { m_SlotAreas.push_back(new cSlotAreaEnchanting(*this)); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); -- cgit v1.2.3 From 6687848a7ec1a65ed2c99264ecf9e8119b19c964 Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Mon, 19 May 2014 14:49:18 +0200 Subject: Fixed warnings in IncrementalRedstoneSimulator --- src/Simulator/IncrementalRedstoneSimulator.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 074063add..8d29fbec7 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -18,7 +18,13 @@ cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulator(cWorld & a_World) - : super(a_World) + : super(a_World), + m_RedstoneSimulatorChunkData(), + m_PoweredBlocks(), + m_LinkedPoweredBlocks(), + m_SimulatedPlayerToggleableBlocks(), + m_RepeatersDelayList(), + m_Chunk() { } -- cgit v1.2.3 From 7e2effb2d8297ddb99d86844e1b06b37c6e30d63 Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Mon, 19 May 2014 15:46:36 +0200 Subject: Changed the m_slotarea position --- src/UI/Window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 24b718156..98a9a0cec 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -854,10 +854,10 @@ void cAnvilWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ) cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : cWindow(wtEnchantment, "Enchant"), + m_SlotArea(), m_BlockX(a_BlockX), m_BlockY(a_BlockY), - m_BlockZ(a_BlockZ), - m_SlotArea() + m_BlockZ(a_BlockZ) { m_SlotAreas.push_back(new cSlotAreaEnchanting(*this)); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); -- cgit v1.2.3 From 42c36429d7cd1e6c3f879b6749e18e912deefe0d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 19 May 2014 20:40:56 +0100 Subject: Added client translation to achievements --- src/CompositeChat.cpp | 22 ++++++++++++++++++++++ src/CompositeChat.h | 15 +++++++++++++++ src/Entities/Player.cpp | 8 ++++---- src/Protocol/Protocol17x.cpp | 29 +++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/CompositeChat.cpp b/src/CompositeChat.cpp index c70ef1070..d3b7595b7 100644 --- a/src/CompositeChat.cpp +++ b/src/CompositeChat.cpp @@ -189,6 +189,15 @@ void cCompositeChat::AddSuggestCommandPart(const AString & a_Text, const AString +void cCompositeChat::AddShowAchievementPart(const AString & a_PlayerName, const AString & a_Achievement, const AString & a_Style) +{ + m_Parts.push_back(new cShowAchievementPart(a_PlayerName, a_Achievement, a_Style)); +} + + + + + void cCompositeChat::ParseText(const AString & a_ParseText) { size_t len = a_ParseText.length(); @@ -476,3 +485,16 @@ cCompositeChat::cSuggestCommandPart::cSuggestCommandPart(const AString & a_Text, + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cCompositeChat::cShowAchievementPart: + +cCompositeChat::cShowAchievementPart::cShowAchievementPart(const AString & a_PlayerName, const AString & a_Achievement, const AString & a_Style) : + super(ptShowAchievement, a_Achievement, a_Style), + m_PlayerName(a_PlayerName) +{ +} + + + + diff --git a/src/CompositeChat.h b/src/CompositeChat.h index 5b9c5f612..a0264d864 100644 --- a/src/CompositeChat.h +++ b/src/CompositeChat.h @@ -38,6 +38,7 @@ public: ptUrl, ptRunCommand, ptSuggestCommand, + ptShowAchievement, } ; class cBasePart @@ -106,6 +107,15 @@ public: public: cSuggestCommandPart(const AString & a_Text, const AString & a_Command, const AString & a_Style = ""); } ; + + class cShowAchievementPart : + public cBasePart + { + typedef cBasePart super; + public: + AString m_PlayerName; + cShowAchievementPart(const AString & a_PlayerName, const AString & a_Achievement, const AString & a_Style = ""); + } ; typedef std::vector cParts; @@ -148,6 +158,11 @@ public: /** Adds a part that suggests a command (enters it into the chat message area, but doesn't send) when clicked. The default style is underlined yellow text. */ void AddSuggestCommandPart(const AString & a_Text, const AString & a_SuggestedCommand, const AString & a_Style = "u@b"); + + /** Adds a part that fully formats a specified achievement using client translatable strings + Takes achievement name and player awarded to. Displays as {player} has earned the achievement {achievement_name}. + */ + void AddShowAchievementPart(const AString & a_PlayerName, const AString & a_Achievement, const AString & a_Style = ""); /** Parses text into various parts, adds those. Recognizes "http:" and "https:" URLs and @color-codes. */ diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index c3b763278..3a32bfb2e 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1169,8 +1169,8 @@ unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach) { // First time, announce it cCompositeChat Msg; - Msg.AddTextPart(m_PlayerName + " has just earned the achievement "); - Msg.AddTextPart(cStatInfo::GetName(a_Ach)); // TODO 2014-05-12 xdot: Use the proper cCompositeChat part (cAchievement) + Msg.SetMessageType(mtSuccess); + Msg.AddShowAchievementPart(GetName(), cStatInfo::GetName(a_Ach)); m_World->BroadcastChat(Msg); // Increment the statistic @@ -1788,7 +1788,7 @@ bool cPlayer::SaveToDisk() // Save the player stats. // We use the default world name (like bukkit) because stats are shared between dimensions/worlds. - cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), m_PlayerName, &m_Stats); + cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats); if (!StatSerializer.Save()) { LOGERROR("Could not save stats for player %s", m_PlayerName.c_str()); @@ -1963,7 +1963,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos) BLOCKTYPE Block; NIBBLETYPE Meta; - if (!m_World->GetBlockTypeMeta(PosX, PosY, PosZ, Block, Meta)) + if ((PosY < 0) || (PosY > cChunkDef::Height) || !m_World->GetBlockTypeMeta(PosX, PosY, PosZ, Block, Meta)) { return; } diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 39feee16f..3061d132b 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -289,6 +289,35 @@ void cProtocol172::SendChat(const cCompositeChat & a_Message) AddChatPartStyle(Part, p.m_Style); break; } + + case cCompositeChat::ptShowAchievement: + { + const cCompositeChat::cShowAchievementPart & p = (const cCompositeChat::cShowAchievementPart &)**itr; + Part["translate"] = "chat.type.achievement"; + + Json::Value Ach; + Ach["action"] = "show_achievement"; + Ach["value"] = p.m_Text; + + Json::Value AchColourAndName; + AchColourAndName["color"] = "green"; + AchColourAndName["translate"] = p.m_Text; + AchColourAndName["hoverEvent"] = Ach; + + Json::Value Extra; + Extra.append(AchColourAndName); + + Json::Value Name; + Name["text"] = p.m_PlayerName; + + Json::Value With; + With.append(Name); + With.append(Extra); + + Part["with"] = With; + AddChatPartStyle(Part, p.m_Style); + break; + } } msg["extra"].append(Part); } // for itr - Parts[] -- cgit v1.2.3 From 3a9543178abb7500aff65e09f054c28200ca6cac Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 19 May 2014 21:16:29 +0100 Subject: cCompositeChat message type is now formatted --- src/ClientHandle.h | 4 ++-- src/CompositeChat.cpp | 3 ++- src/CompositeChat.h | 9 ++++++++- src/Protocol/Protocol17x.cpp | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 9f1245be5..659c67658 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -80,9 +80,9 @@ public: static AString GenerateOfflineUUID(const AString & a_Username); // tolua_export /** Formats the type of message with the proper color and prefix for sending to the client. **/ - AString FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData); + static AString FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData); - AString FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2); + static AString FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2); void Kick(const AString & a_Reason); // tolua_export void Authenticate(const AString & a_Name, const AString & a_UUID); // Called by cAuthenticator when the user passes authentication diff --git a/src/CompositeChat.cpp b/src/CompositeChat.cpp index d3b7595b7..a3612983a 100644 --- a/src/CompositeChat.cpp +++ b/src/CompositeChat.cpp @@ -299,9 +299,10 @@ void cCompositeChat::ParseText(const AString & a_ParseText) -void cCompositeChat::SetMessageType(eMessageType a_MessageType) +void cCompositeChat::SetMessageType(eMessageType a_MessageType, const AString & a_AdditionalMessageTypeData) { m_MessageType = a_MessageType; + m_AdditionalMessageTypeData = a_AdditionalMessageTypeData; } diff --git a/src/CompositeChat.h b/src/CompositeChat.h index a0264d864..209d9d925 100644 --- a/src/CompositeChat.h +++ b/src/CompositeChat.h @@ -47,6 +47,7 @@ public: ePartType m_PartType; AString m_Text; AString m_Style; + AString m_AdditionalStyleData; cBasePart(ePartType a_PartType, const AString & a_Text, const AString & a_Style = ""); @@ -169,7 +170,7 @@ public: void ParseText(const AString & a_ParseText); /** Sets the message type, which is indicated by prefixes added to the message when serializing. */ - void SetMessageType(eMessageType a_MessageType); + void SetMessageType(eMessageType a_MessageType, const AString & a_AdditionalMessageTypeata = ""); /** Adds the "underline" style to each part that is an URL. */ void UnderlineUrls(void); @@ -178,6 +179,9 @@ public: /** Returns the message type set previously by SetMessageType(). */ eMessageType GetMessageType(void) const { return m_MessageType; } + + /** Returns additional data pertaining to message type, for example, the name of a mtPrivateMsg sender */ + AString GetAdditionalMessageTypeData(void) const { return m_AdditionalMessageTypeData; } /** Returns the text from the parts that comprises the human-readable data. Used for older protocols that don't support composite chat @@ -199,6 +203,9 @@ protected: /** The message type, as indicated by prefixes. */ eMessageType m_MessageType; + /** Additional data pertaining to message type, for example, the name of a mtPrivateMsg sender */ + AString m_AdditionalMessageTypeData; + /** Adds a_AddStyle to a_Style; overwrites the existing style if appropriate. If the style already contains something that a_AddStyle overrides, it is erased first. */ diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 3061d132b..7c526d103 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -234,7 +234,7 @@ void cProtocol172::SendChat(const cCompositeChat & a_Message) // Compose the complete Json string to send: Json::Value msg; - msg["text"] = ""; // The client crashes without this + msg["text"] = cClientHandle::FormatMessageType(m_Client->GetPlayer()->GetWorld()->ShouldUseChatPrefixes(), a_Message.GetMessageType(), a_Message.GetAdditionalMessageTypeData()); // The client crashes without this field being present const cCompositeChat::cParts & Parts = a_Message.GetParts(); for (cCompositeChat::cParts::const_iterator itr = Parts.begin(), end = Parts.end(); itr != end; ++itr) { -- cgit v1.2.3 From 4008af692556ffb0f819c9a570267ffbaa871cad Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 19 May 2014 21:17:28 +0100 Subject: Simplified cacti conditions --- src/Entities/Entity.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 15f456332..ed06e76b9 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1024,9 +1024,9 @@ void cEntity::DetectCacti() float w = m_Width / 2; if ( (((X + 1) - GetPosX() < w) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) || - (((GetPosX() - (X - 1)) - 1 < w) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) || + ((GetPosX() - X < w) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) || (((Z + 1) - GetPosZ() < w) && (GetWorld()->GetBlock(X, Y, Z + 1) == E_BLOCK_CACTUS)) || - (((GetPosZ() - (Z - 1)) - 1 < w) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS)) || + ((GetPosZ() - Z < w) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS)) || (((Y > 0) && (Y < cChunkDef::Height)) && ((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS))) ) { -- cgit v1.2.3 From 2bfe962e2831316f651aa22c4e7b7ea68021c978 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 19 May 2014 22:15:39 +0100 Subject: Fixed a cactus Y position issue --- src/Entities/Entity.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index ed06e76b9..8a584d2ca 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1023,11 +1023,12 @@ void cEntity::DetectCacti() int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; float w = m_Width / 2; if ( - (((X + 1) - GetPosX() < w) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) || + ((Y > 0) && (Y < cChunkDef::Height)) && + ((((X + 1) - GetPosX() < w) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) || ((GetPosX() - X < w) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) || (((Z + 1) - GetPosZ() < w) && (GetWorld()->GetBlock(X, Y, Z + 1) == E_BLOCK_CACTUS)) || ((GetPosZ() - Z < w) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS)) || - (((Y > 0) && (Y < cChunkDef::Height)) && ((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS))) + (((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS)))) ) { TakeDamage(dtCactusContact, NULL, 1, 0); -- cgit v1.2.3 From 507df718453483e6ca74ca897a78eed679222f06 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 20 May 2014 13:35:39 +0100 Subject: Update Player.cpp --- src/Entities/Player.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 3a32bfb2e..c27456397 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -377,7 +377,7 @@ short cPlayer::DeltaExperience(short a_Xp_delta) } LOGD("Player \"%s\" gained/lost %d experience, total is now: %d", - m_PlayerName.c_str(), a_Xp_delta, m_CurrentXp); + GetName().c_str(), a_Xp_delta, m_CurrentXp); // Set experience to be updated m_bDirtyExperience = true; @@ -391,7 +391,7 @@ short cPlayer::DeltaExperience(short a_Xp_delta) void cPlayer::StartChargingBow(void) { - LOGD("Player \"%s\" started charging their bow", m_PlayerName.c_str()); + LOGD("Player \"%s\" started charging their bow", GetName().c_str()); m_IsChargingBow = true; m_BowCharge = 0; } @@ -402,7 +402,7 @@ void cPlayer::StartChargingBow(void) int cPlayer::FinishChargingBow(void) { - LOGD("Player \"%s\" finished charging their bow at a charge of %d", m_PlayerName.c_str(), m_BowCharge); + LOGD("Player \"%s\" finished charging their bow at a charge of %d", GetName().c_str(), m_BowCharge); int res = m_BowCharge; m_IsChargingBow = false; m_BowCharge = 0; @@ -415,7 +415,7 @@ int cPlayer::FinishChargingBow(void) void cPlayer::CancelChargingBow(void) { - LOGD("Player \"%s\" cancelled charging their bow at a charge of %d", m_PlayerName.c_str(), m_BowCharge); + LOGD("Player \"%s\" cancelled charging their bow at a charge of %d", GetName().c_str(), m_BowCharge); m_IsChargingBow = false; m_BowCharge = 0; } @@ -1305,7 +1305,7 @@ void cPlayer::AddToGroup( const AString & a_GroupName ) { cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName ); m_Groups.push_back( Group ); - LOGD("Added %s to group %s", m_PlayerName.c_str(), a_GroupName.c_str() ); + LOGD("Added %s to group %s", GetName().c_str(), a_GroupName.c_str() ); ResolveGroups(); ResolvePermissions(); } @@ -1329,13 +1329,13 @@ void cPlayer::RemoveFromGroup( const AString & a_GroupName ) if( bRemoved ) { - LOGD("Removed %s from group %s", m_PlayerName.c_str(), a_GroupName.c_str() ); + LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str() ); ResolveGroups(); ResolvePermissions(); } else { - LOGWARN("Tried to remove %s from group %s but was not in that group", m_PlayerName.c_str(), a_GroupName.c_str() ); + LOGWARN("Tried to remove %s from group %s but was not in that group", GetName().c_str(), a_GroupName.c_str() ); } } @@ -1441,7 +1441,7 @@ void cPlayer::ResolveGroups() if( AllGroups.find( CurrentGroup ) != AllGroups.end() ) { LOGWARNING("ERROR: Player \"%s\" is in the group multiple times (\"%s\"). Please fix your settings in users.ini!", - m_PlayerName.c_str(), CurrentGroup->GetName().c_str() + GetName().c_str(), CurrentGroup->GetName().c_str() ); } else @@ -1453,7 +1453,7 @@ void cPlayer::ResolveGroups() { if( AllGroups.find( *itr ) != AllGroups.end() ) { - LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", m_PlayerName.c_str(), (*itr)->GetName().c_str() ); + LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", GetName().c_str(), (*itr)->GetName().c_str() ); continue; } ToIterate.push_back( *itr ); @@ -1605,19 +1605,19 @@ void cPlayer::LoadPermissionsFromDisk() cIniFile IniFile; if (IniFile.ReadFile("users.ini")) { - AString Groups = IniFile.GetValueSet(m_PlayerName, "Groups", "Default"); + AString Groups = IniFile.GetValueSet(GetName(), "Groups", "Default"); AStringVector Split = StringSplitAndTrim(Groups, ","); for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr) { if (!cRoot::Get()->GetGroupManager()->ExistsGroup(*itr)) { - LOGWARNING("The group %s for player %s was not found!", itr->c_str(), m_PlayerName.c_str()); + LOGWARNING("The group %s for player %s was not found!", itr->c_str(), GetName().c_str()); } AddToGroup(*itr); } - AString Color = IniFile.GetValue(m_PlayerName, "Color", "-"); + AString Color = IniFile.GetValue(GetName(), "Color", "-"); if (!Color.empty()) { m_Color = Color[0]; @@ -1626,7 +1626,7 @@ void cPlayer::LoadPermissionsFromDisk() else { cGroupManager::GenerateDefaultUsersIni(IniFile); - IniFile.AddValue("Groups", m_PlayerName, "Default"); + IniFile.AddValue("Groups", GetName(), "Default"); AddToGroup("Default"); } IniFile.WriteFile("users.ini"); @@ -1641,14 +1641,14 @@ bool cPlayer::LoadFromDisk() LoadPermissionsFromDisk(); // Log player permissions, cause it's what the cool kids do - LOGINFO("Player %s has permissions:", m_PlayerName.c_str() ); + LOGINFO("Player %s has permissions:", GetName().c_str() ); for( PermissionMap::iterator itr = m_ResolvedPermissions.begin(); itr != m_ResolvedPermissions.end(); ++itr ) { if( itr->second ) LOG(" - %s", itr->first.c_str() ); } AString SourceFile; - Printf(SourceFile, "players/%s.json", m_PlayerName.c_str() ); + Printf(SourceFile, "players/%s.json", GetName().c_str() ); cFile f; if (!f.Open(SourceFile, cFile::fmRead)) @@ -1716,7 +1716,7 @@ bool cPlayer::LoadFromDisk() StatSerializer.Load(); LOGD("Player \"%s\" was read from file, spawning at {%.2f, %.2f, %.2f} in world \"%s\"", - m_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str() + GetName().c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str() ); return true; @@ -1772,12 +1772,12 @@ bool cPlayer::SaveToDisk() std::string JsonData = writer.write(root); AString SourceFile; - Printf(SourceFile, "players/%s.json", m_PlayerName.c_str() ); + Printf(SourceFile, "players/%s.json", GetName().c_str() ); cFile f; if (!f.Open(SourceFile, cFile::fmWrite)) { - LOGERROR("ERROR WRITING PLAYER \"%s\" TO FILE \"%s\" - cannot open file", m_PlayerName.c_str(), SourceFile.c_str()); + LOGERROR("ERROR WRITING PLAYER \"%s\" TO FILE \"%s\" - cannot open file", GetName().c_str(), SourceFile.c_str()); return false; } if (f.Write(JsonData.c_str(), JsonData.size()) != (int)JsonData.size()) @@ -1791,7 +1791,7 @@ bool cPlayer::SaveToDisk() cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats); if (!StatSerializer.Save()) { - LOGERROR("Could not save stats for player %s", m_PlayerName.c_str()); + LOGERROR("Could not save stats for player %s", GetName().c_str()); return false; } -- cgit v1.2.3 From 07baf9bdd3b04e3aec6e77f367eb38c0547f54ca Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 20 May 2014 15:52:59 +0300 Subject: Cleaned up cPlayer::UpdateMovementStats; Wither achievements --- src/Blocks/BlockMobHead.h | 27 ++++++++++++++++++ src/Entities/Player.cpp | 71 +++++++++++++++++++++++++++++++++++++--------- src/Entities/Player.h | 3 ++ src/Items/ItemFishingRod.h | 6 ++++ src/Mobs/Wither.cpp | 33 +++++++++++++++++++++ src/Mobs/Wither.h | 1 + src/Statistics.cpp | 2 +- 7 files changed, 128 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index acd1c88fb..552c0491c 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -46,8 +46,29 @@ public: bool IsWither(void) const { return m_IsWither; } void Reset(void) { m_IsWither = false; } + } CallbackA, CallbackB; + class cPlayerCallback : public cPlayerListCallback + { + Vector3f m_Pos; + + virtual bool Item(cPlayer * a_Player) + { + double Dist = (a_Player->GetPosition() - m_Pos).Length(); + if (Dist < 50.0) + { + // If player is close, award achievement + a_Player->AwardAchievement(achSpawnWither); + } + return false; + } + + public: + cPlayerCallback(const Vector3f & a_Pos) : m_Pos(a_Pos) {} + + } PlayerCallback(Vector3f(a_BlockX, a_BlockY, a_BlockZ)); + a_World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, CallbackA); if (!CallbackA.IsWither()) @@ -86,6 +107,9 @@ public: // Spawn the wither: a_World->SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); + // Award Achievement + a_World->ForEachPlayer(PlayerCallback); + return true; } @@ -113,6 +137,9 @@ public: // Spawn the wither: a_World->SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); + // Award Achievement + a_World->ForEachPlayer(PlayerCallback); + return true; } diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index c3b763278..0eacb67f9 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -456,8 +456,18 @@ void cPlayer::SetTouchGround(bool a_bTouchGround) else { float Dist = (float)(m_LastGroundHeight - floor(GetPosY())); + + if (Dist >= 2.0) // At least two blocks - TODO: Use m_LastJumpHeight instead of m_LastGroundHeight above + { + // Increment statistic + m_Stats.AddValue(statDistFallen, (StatValue)floor(Dist * 100 + 0.5)); + } + int Damage = (int)(Dist - 3.f); - if (m_LastJumpHeight > m_LastGroundHeight) Damage++; + if (m_LastJumpHeight > m_LastGroundHeight) + { + Damage++; + } m_LastJumpHeight = (float)GetPosY(); if (Damage > 0) @@ -1951,32 +1961,65 @@ void cPlayer::HandleFloater() +bool cPlayer::IsClimbing(void) const +{ + int PosX = POSX_TOINT; + int PosY = POSY_TOINT; + int PosZ = POSZ_TOINT; + + if ((PosY < 0) || (PosY >= cChunkDef::Height)) + { + return false; + } + + BLOCKTYPE Block = m_World->GetBlock(PosX, PosY, PosZ); + switch (Block) + { + case E_BLOCK_LADDER: + case E_BLOCK_VINES: + { + return true; + } + default: return false; + } +} + + + + + void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos) { StatValue Value = (StatValue)floor(a_DeltaPos.Length() * 100 + 0.5); if (m_AttachedTo == NULL) { - int PosX = POSX_TOINT; - int PosY = POSY_TOINT; - int PosZ = POSZ_TOINT; - - BLOCKTYPE Block; - NIBBLETYPE Meta; - if (!m_World->GetBlockTypeMeta(PosX, PosY, PosZ, Block, Meta)) + if (IsClimbing()) { - return; + if (a_DeltaPos.y > 0.0) // Going up + { + m_Stats.AddValue(statDistClimbed, (StatValue)floor(a_DeltaPos.y * 100 + 0.5)); + } } - - if ((Block == E_BLOCK_LADDER) && (a_DeltaPos.y > 0.0)) // Going up + else if (IsSubmerged()) { - m_Stats.AddValue(statDistClimbed, (StatValue)floor(a_DeltaPos.y * 100 + 0.5)); + m_Stats.AddValue(statDistDove, Value); } - else + else if (IsSwimming()) + { + m_Stats.AddValue(statDistSwum, Value); + } + else if (IsOnGround()) { - // TODO 2014-05-12 xdot: Other types m_Stats.AddValue(statDistWalked, Value); } + else + { + if (Value >= 25) // Ignore small/slow movement + { + m_Stats.AddValue(statDistFlown, Value); + } + } } else { diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 78b534d83..b7cb27d6c 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -127,6 +127,9 @@ public: inline const cItem & GetEquippedItem(void) const { return GetInventory().GetEquippedItem(); } // tolua_export + /** Returns whether the player is climbing (ladders, vines e.t.c). */ + bool IsClimbing(void) const; + virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) override; // tolua_begin diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index 0431b88b7..32c151db5 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -142,6 +142,8 @@ public: break; } } + + a_Player->GetStatManager().AddValue(statTreasureFished, 1); } else if (ItemCategory <= 14) // Junk 10% { @@ -190,6 +192,8 @@ public: { Drops.Add(cItem(E_BLOCK_TRIPWIRE_HOOK)); } + + a_Player->GetStatManager().AddValue(statJunkFished, 1); } else // Fish { @@ -210,6 +214,8 @@ public: { Drops.Add(cItem(E_ITEM_RAW_FISH, 1, E_META_RAW_FISH_FISH)); } + + a_Player->GetStatManager().AddValue(statFishCaught, 1); } if (cRoot::Get()->GetPluginManager()->CallHookPlayerFishing(*a_Player, Drops)) diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp index 5b6e895e1..deb2cf34e 100644 --- a/src/Mobs/Wither.cpp +++ b/src/Mobs/Wither.cpp @@ -2,7 +2,9 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Wither.h" + #include "../World.h" +#include "../Entities/Player.h" @@ -100,3 +102,34 @@ void cWither::GetDrops(cItems & a_Drops, cEntity * a_Killer) + +void cWither::KilledBy(cEntity * a_Killer) +{ + UNUSED(a_Killer); + + class cPlayerCallback : public cPlayerListCallback + { + Vector3f m_Pos; + + virtual bool Item(cPlayer * a_Player) + { + double Dist = (a_Player->GetPosition() - m_Pos).Length(); + if (Dist < 50.0) + { + // If player is close, award achievement + a_Player->AwardAchievement(achKillWither); + } + return false; + } + + public: + cPlayerCallback(const Vector3f & a_Pos) : m_Pos(a_Pos) {} + + } PlayerCallback(GetPosition()); + + m_World->ForEachPlayer(PlayerCallback); +} + + + + diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index 08b460009..93b4f8bfc 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -29,6 +29,7 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void KilledBy(cEntity * a_Killer) override; private: diff --git a/src/Statistics.cpp b/src/Statistics.cpp index 5950eb96c..5c0524f9e 100644 --- a/src/Statistics.cpp +++ b/src/Statistics.cpp @@ -52,7 +52,7 @@ cStatInfo cStatInfo::ms_Info[statCount] = { /* Type | Name */ cStatInfo(statGamesQuit, "stat.leaveGame"), cStatInfo(statMinutesPlayed, "stat.playOneMinute"), - cStatInfo(statDistWalked, "stat.walkOnCm"), + cStatInfo(statDistWalked, "stat.walkOneCm"), cStatInfo(statDistSwum, "stat.swimOneCm"), cStatInfo(statDistFallen, "stat.fallOneCm"), cStatInfo(statDistClimbed, "stat.climbOneCm"), -- cgit v1.2.3 From 576e17ae08ddd0dcff625134325bfceeab956906 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 20 May 2014 22:49:21 +0100 Subject: Update CompositeChat.h --- src/CompositeChat.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/CompositeChat.h b/src/CompositeChat.h index 209d9d925..1ad196f1d 100644 --- a/src/CompositeChat.h +++ b/src/CompositeChat.h @@ -169,8 +169,10 @@ public: Recognizes "http:" and "https:" URLs and @color-codes. */ void ParseText(const AString & a_ParseText); - /** Sets the message type, which is indicated by prefixes added to the message when serializing. */ - void SetMessageType(eMessageType a_MessageType, const AString & a_AdditionalMessageTypeata = ""); + /** Sets the message type, which is indicated by prefixes added to the message when serializing + Takes optional AdditionalMessageTypeData to set m_AdditionalMessageTypeData. See said variable for more documentation. + */ + void SetMessageType(eMessageType a_MessageType, const AString & a_AdditionalMessageTypeData = ""); /** Adds the "underline" style to each part that is an URL. */ void UnderlineUrls(void); -- cgit v1.2.3 From 7aeb8ce9936e8ebd203d67100de8635d391bd8a1 Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 21 May 2014 10:59:14 +0300 Subject: Fixed cWither::KilledBy --- src/Blocks/BlockMobHead.h | 1 + src/Mobs/Wither.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index 552c0491c..b7629b07c 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -55,6 +55,7 @@ public: virtual bool Item(cPlayer * a_Player) { + // TODO 2014-05-21 xdot: Vanilla minecraft uses an AABB check instead of a radius one double Dist = (a_Player->GetPosition() - m_Pos).Length(); if (Dist < 50.0) { diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp index deb2cf34e..170f4fdc0 100644 --- a/src/Mobs/Wither.cpp +++ b/src/Mobs/Wither.cpp @@ -105,7 +105,7 @@ void cWither::GetDrops(cItems & a_Drops, cEntity * a_Killer) void cWither::KilledBy(cEntity * a_Killer) { - UNUSED(a_Killer); + super::KilledBy(a_Killer); class cPlayerCallback : public cPlayerListCallback { @@ -113,6 +113,7 @@ void cWither::KilledBy(cEntity * a_Killer) virtual bool Item(cPlayer * a_Player) { + // TODO 2014-05-21 xdot: Vanilla minecraft uses an AABB check instead of a radius one double Dist = (a_Player->GetPosition() - m_Pos).Length(); if (Dist < 50.0) { -- cgit v1.2.3 From cdd3d11496d51ce6f444a2e637fee1d38e07fd09 Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 21 May 2014 18:33:54 +0100 Subject: Fixed minor style issues --- src/BlockArea.cpp | 2 +- src/BlockArea.h | 4 ++-- src/Chunk.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index fd2f3c9b4..5e41b135c 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -1843,7 +1843,7 @@ void cBlockArea::cChunkReader::ChunkBuffer(const cChunkBuffer & a_BlockBuffer) int SizeY = m_Area.m_Size.y; int MinY = m_Origin.y; - // SizeX, SizeZ are the dmensions of the block data to copy from the current chunk (size of the geometric union) + // SizeX, SizeZ are the dimensions of the block data to copy from the current chunk (size of the geometric union) // OffX, OffZ are the offsets of the current chunk data from the area origin // BaseX, BaseZ are the offsets of the area data within the current chunk from the chunk borders int SizeX = cChunkDef::Width; diff --git a/src/BlockArea.h b/src/BlockArea.h index 9c01719c3..6b3bdf337 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -317,8 +317,8 @@ protected: void CopyNibbles(NIBBLETYPE * a_AreaDst, const NIBBLETYPE * a_ChunkSrc); // cChunkDataCallback overrides: - virtual bool Coords (int a_ChunkX, int a_ChunkZ) override; - virtual void ChunkBuffer (const cChunkBuffer & a_BlockTypes) override; + virtual bool Coords(int a_ChunkX, int a_ChunkZ) override; + virtual void ChunkBuffer(const cChunkBuffer & a_BlockTypes) override; } ; typedef NIBBLETYPE * NIBBLEARRAY; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index a986ac076..00ea33e16 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -282,10 +282,10 @@ void cChunk::SetAllData( CalculateHeightmap(a_BlockTypes); } - m_ChunkBuffer.SetBlocks (a_BlockTypes); - m_ChunkBuffer.SetMeta (a_BlockMeta); - m_ChunkBuffer.SetLight (a_BlockLight); - m_ChunkBuffer.SetSkyLight (a_BlockSkyLight); + m_ChunkBuffer.SetBlocks(a_BlockTypes); + m_ChunkBuffer.SetMeta(a_BlockMeta); + m_ChunkBuffer.SetLight(a_BlockLight); + m_ChunkBuffer.SetSkyLight(a_BlockSkyLight); m_IsLightValid = (a_BlockLight != NULL) && (a_BlockSkyLight != NULL); -- cgit v1.2.3 From 024027db89ca833406147b79b7be74fc92906bbe Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 21 May 2014 19:58:48 +0100 Subject: Renamed cChunkBuffer to cChunkData --- src/BlockArea.cpp | 4 +- src/BlockArea.h | 2 +- src/Chunk.cpp | 38 ++--- src/Chunk.h | 12 +- src/ChunkBuffer.cpp | 320 ------------------------------------------ src/ChunkBuffer.h | 279 ------------------------------------ src/ChunkData.cpp | 320 ++++++++++++++++++++++++++++++++++++++++++ src/ChunkData.h | 279 ++++++++++++++++++++++++++++++++++++ src/ChunkDataCallback.h | 18 +-- src/LightingThread.cpp | 2 +- src/WorldStorage/WSSCompact.h | 2 +- 11 files changed, 638 insertions(+), 638 deletions(-) delete mode 100644 src/ChunkBuffer.cpp delete mode 100644 src/ChunkBuffer.h create mode 100644 src/ChunkData.cpp create mode 100644 src/ChunkData.h (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 5e41b135c..0c46e59e5 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -9,7 +9,7 @@ #include "OSSupport/GZipFile.h" #include "Blocks/BlockHandler.h" #include "Cuboid.h" -#include "ChunkBuffer.h" +#include "ChunkData.h" @@ -1835,7 +1835,7 @@ bool cBlockArea::cChunkReader::Coords(int a_ChunkX, int a_ChunkZ) -void cBlockArea::cChunkReader::ChunkBuffer(const cChunkBuffer & a_BlockBuffer) +void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer) { { if (!(m_Area.m_BlockTypes == NULL)) diff --git a/src/BlockArea.h b/src/BlockArea.h index 6b3bdf337..2bd26facd 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -318,7 +318,7 @@ protected: // cChunkDataCallback overrides: virtual bool Coords(int a_ChunkX, int a_ChunkZ) override; - virtual void ChunkBuffer(const cChunkBuffer & a_BlockTypes) override; + virtual void ChunkData(const cChunkData & a_BlockTypes) override; } ; typedef NIBBLETYPE * NIBBLEARRAY; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 00ea33e16..a45ed32c1 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -238,12 +238,12 @@ void cChunk::MarkLoadFailed(void) void cChunk::GetAllData(cChunkDataCallback & a_Callback) { - a_Callback.HeightMap (&m_HeightMap); - a_Callback.BiomeData (&m_BiomeMap); + a_Callback.HeightMap(&m_HeightMap); + a_Callback.BiomeData(&m_BiomeMap); - a_Callback.LightIsValid (m_IsLightValid); + a_Callback.LightIsValid(m_IsLightValid); - a_Callback.ChunkBuffer (m_ChunkBuffer); + a_Callback.ChunkData(m_ChunkData); for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) { @@ -282,10 +282,10 @@ void cChunk::SetAllData( CalculateHeightmap(a_BlockTypes); } - m_ChunkBuffer.SetBlocks(a_BlockTypes); - m_ChunkBuffer.SetMeta(a_BlockMeta); - m_ChunkBuffer.SetLight(a_BlockLight); - m_ChunkBuffer.SetSkyLight(a_BlockSkyLight); + m_ChunkData.SetBlocks(a_BlockTypes); + m_ChunkData.SetMeta(a_BlockMeta); + m_ChunkData.SetLight(a_BlockLight); + m_ChunkData.SetSkyLight(a_BlockSkyLight); m_IsLightValid = (a_BlockLight != NULL) && (a_BlockSkyLight != NULL); @@ -326,9 +326,9 @@ void cChunk::SetLight( // TODO: We might get cases of wrong lighting when a chunk changes in the middle of a lighting calculation. // Postponing until we see how bad it is :) - m_ChunkBuffer.SetLight (a_BlockLight); + m_ChunkData.SetLight (a_BlockLight); - m_ChunkBuffer.SetSkyLight (a_SkyLight); + m_ChunkData.SetSkyLight (a_SkyLight); m_IsLightValid = true; } @@ -339,7 +339,7 @@ void cChunk::SetLight( void cChunk::GetBlockTypes(BLOCKTYPE * a_BlockTypes) { - m_ChunkBuffer.CopyBlocks(a_BlockTypes); + m_ChunkData.CopyBlocks(a_BlockTypes); } @@ -1507,7 +1507,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT ASSERT(IsValid()); const BLOCKTYPE OldBlockType = GetBlock(a_RelX, a_RelY, a_RelZ); - const BLOCKTYPE OldBlockMeta = m_ChunkBuffer.GetMeta(a_RelX, a_RelY, a_RelZ); + const BLOCKTYPE OldBlockMeta = m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ); if ((OldBlockType == a_BlockType) && (OldBlockMeta == a_BlockMeta)) { return; @@ -1515,7 +1515,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT MarkDirty(); - m_ChunkBuffer.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType); + m_ChunkData.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType); // The client doesn't need to distinguish between stationary and nonstationary fluids: if ( @@ -1531,7 +1531,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta)); } - m_ChunkBuffer.SetMeta(a_RelX, a_RelY, a_RelZ, a_BlockMeta); + m_ChunkData.SetMeta(a_RelX, a_RelY, a_RelZ, a_BlockMeta); // ONLY recalculate lighting if it's necessary! if ( @@ -2438,7 +2438,7 @@ BLOCKTYPE cChunk::GetBlock(int a_RelX, int a_RelY, int a_RelZ) const return 0; // Clip } - return m_ChunkBuffer.GetBlock(a_RelX, a_RelY, a_RelZ); + return m_ChunkData.GetBlock(a_RelX, a_RelY, a_RelZ); } @@ -2448,7 +2448,7 @@ BLOCKTYPE cChunk::GetBlock(int a_RelX, int a_RelY, int a_RelZ) const void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) { a_BlockType = GetBlock(a_RelX, a_RelY, a_RelZ); - a_BlockMeta = m_ChunkBuffer.GetMeta(a_RelX, a_RelY, a_RelZ); + a_BlockMeta = m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ); } @@ -2458,9 +2458,9 @@ void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_ void cChunk::GetBlockInfo(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight) { a_BlockType = GetBlock(a_RelX, a_RelY, a_RelZ); - a_Meta = m_ChunkBuffer.GetMeta(a_RelX, a_RelY, a_RelZ); - a_SkyLight = m_ChunkBuffer.GetSkyLight(a_RelX, a_RelY, a_RelZ); - a_BlockLight = m_ChunkBuffer.GetBlockLight(a_RelX, a_RelY, a_RelZ); + a_Meta = m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ); + a_SkyLight = m_ChunkData.GetSkyLight(a_RelX, a_RelY, a_RelZ); + a_BlockLight = m_ChunkData.GetBlockLight(a_RelX, a_RelY, a_RelZ); } diff --git a/src/Chunk.h b/src/Chunk.h index 038be42de..4f6c4cf0a 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -3,7 +3,7 @@ #include "Entities/Entity.h" #include "ChunkDef.h" -#include "ChunkBuffer.h" +#include "ChunkData.h" #include "Simulator/FireSimulator.h" #include "Simulator/SandSimulator.h" @@ -324,21 +324,21 @@ public: inline NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const { - return m_ChunkBuffer.GetMeta(a_RelX, a_RelY, a_RelZ); + return m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ); } inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta) { if (!(GetMeta(a_RelX, a_RelY, a_RelZ) == a_Meta)) { MarkDirty(); - m_ChunkBuffer.SetMeta(a_RelX, a_RelY, a_RelZ, a_Meta); + m_ChunkData.SetMeta(a_RelX, a_RelY, a_RelZ, a_Meta); m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), a_Meta)); } } - inline NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const {return m_ChunkBuffer.GetBlockLight(a_RelX, a_RelY, a_RelZ); } - inline NIBBLETYPE GetSkyLight (int a_RelX, int a_RelY, int a_RelZ) const {return m_ChunkBuffer.GetSkyLight(a_RelX, a_RelY, a_RelZ); } + inline NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const {return m_ChunkData.GetBlockLight(a_RelX, a_RelY, a_RelZ); } + inline NIBBLETYPE GetSkyLight (int a_RelX, int a_RelY, int a_RelZ) const {return m_ChunkData.GetSkyLight(a_RelX, a_RelY, a_RelZ); } /** Same as GetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case); returns true on success */ bool UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const; @@ -430,7 +430,7 @@ private: cWorld * m_World; cChunkMap * m_ChunkMap; - cChunkBuffer m_ChunkBuffer; + cChunkData m_ChunkData; cChunkDef::HeightMap m_HeightMap; cChunkDef::BiomeMap m_BiomeMap; diff --git a/src/ChunkBuffer.cpp b/src/ChunkBuffer.cpp deleted file mode 100644 index 99bcdebef..000000000 --- a/src/ChunkBuffer.cpp +++ /dev/null @@ -1,320 +0,0 @@ - -#include "Globals.h" -#include "ChunkBuffer.h" - -cChunkBuffer cChunkBuffer::Copy() const -{ - cChunkBuffer copy; - for (int i = 0; i < CHUNK_SECTION_NUM; i++) - { - if(m_Sections[i]) - { - copy.m_Sections[i] = Allocate(); - *copy.m_Sections[i] = *m_Sections[i]; - } - } - return copy; -} - - - - - -void cChunkBuffer::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length) const -{ - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) - { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; - if (a_Idx > 0) a_Idx = a_Idx > length ? a_Idx - length : 0; - if (a_Idx == 0) - { - size_t tocopy = length > segment_length ? segment_length : length; - length -= tocopy; - if(m_Sections[i]) - { - memcpy( - &a_dest[i * segment_length], - &m_Sections[i]->m_BlockTypes, - sizeof(BLOCKTYPE) * tocopy - ); - } - else - { - memset( - &a_dest[i * segment_length], - 0, - sizeof(BLOCKTYPE) * tocopy - ); - } - } - } -} - - - - - -void cChunkBuffer::CopyMeta(NIBBLETYPE * a_dest) const -{ - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) - { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if(m_Sections[i]) - { - memcpy( - &a_dest[i * segment_length], - &m_Sections[i]->m_BlockMeta, - sizeof(NIBBLETYPE) * segment_length); - } - else - { - memset( - &a_dest[i * segment_length], - 0, - sizeof(BLOCKTYPE) * segment_length - ); - } - } -} - - - - - -void cChunkBuffer::CopyLight(NIBBLETYPE * a_dest) const -{ - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) - { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if(m_Sections[i]) - { - memcpy( - &a_dest[i * segment_length], - &m_Sections[i]->m_BlockLight, - sizeof(NIBBLETYPE) * segment_length - ); - } - else - { - memset( - &a_dest[i * segment_length], - 0, - sizeof(BLOCKTYPE) * segment_length - ); - } - } -} - - - - - -void cChunkBuffer::CopySkyLight(NIBBLETYPE * a_dest) const -{ - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) - { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if(m_Sections[i]) - { - memcpy( - &a_dest[i * segment_length], - &m_Sections[i]->m_BlockSkyLight, - sizeof(NIBBLETYPE) * segment_length - ); - } - else - { - memset( - &a_dest[i * segment_length], - 0xFF, - sizeof(BLOCKTYPE) * segment_length - ); - } - } -} - - - - - -void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src) -{ - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) - { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; - if (m_Sections[i]) - { - memcpy(&m_Sections[i]->m_BlockTypes, &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length); - } - else - { - size_t j = 0; - // do nothing whilst 0 - for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); - if (j != segment_length) - { - m_Sections[i] = Allocate(); - memcpy( - &m_Sections[i]->m_BlockTypes, - &a_src[i * segment_length], - sizeof(BLOCKTYPE) * segment_length - ); - memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta)); - memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight)); - memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight)); - } - else - { - Free(m_Sections[i]); - m_Sections[i] = 0; - } - } - } -} - - - - -void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src) -{ - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) - { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if (m_Sections[i]) - { - memcpy(&m_Sections[i]->m_BlockMeta, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); - } - else - { - size_t j = 0; - // do nothing whilst 0 - for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); - if (j != segment_length) - { - m_Sections[i] = Allocate(); - memcpy( - &m_Sections[i]->m_BlockMeta, - &a_src[i * segment_length], - sizeof(BLOCKTYPE) * segment_length - ); - memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes)); - memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight)); - memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight)); - } - else - { - Free(m_Sections[i]); - m_Sections[i] = 0; - } - } - } -} - - - - -void cChunkBuffer::SetLight(const NIBBLETYPE * a_src) -{ - if (!a_src) return; - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) - { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if (m_Sections[i]) - { - memcpy(&m_Sections[i]->m_BlockLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); - } - else - { - size_t j = 0; - // do nothing whilst 0 - for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); - if (j != segment_length) - { - m_Sections[i] = Allocate(); - memcpy( - &m_Sections[i]->m_BlockLight, - &a_src[i * segment_length], - sizeof(BLOCKTYPE) * segment_length - ); - memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes)); - memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta)); - memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight)); - } - else - { - Free(m_Sections[i]); - m_Sections[i] = 0; - } - } - } -} - - - - -void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src) -{ - if (!a_src) return; - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) - { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if (m_Sections[i]) - { - memcpy(&m_Sections[i]->m_BlockSkyLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); - } - else - { - size_t j = 0; - // do nothing whilst 0 - for (; j < segment_length && a_src[i * segment_length + j] == 0xFF; j++); - if (j != segment_length) - { - m_Sections[i] = Allocate(); - memcpy( - &m_Sections[i]->m_BlockSkyLight, - &a_src[i * segment_length], - sizeof(BLOCKTYPE) * segment_length - ); - memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes)); - memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta)); - memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight)); - } - else - { - Free(m_Sections[i]); - m_Sections[i] = 0; - } - } - } -} - - - - - -cChunkBuffer::sChunkSection * cChunkBuffer::Allocate() const -{ - // TODO: use a allocation pool - return new cChunkBuffer::sChunkSection; -} - - - -void cChunkBuffer::Free(cChunkBuffer::sChunkSection * ptr) const -{ - delete ptr; -} - - - -void cChunkBuffer::ZeroSection(cChunkBuffer::sChunkSection * ptr) const -{ - memset(ptr->m_BlockTypes,0x00,sizeof(ptr->m_BlockTypes)); - memset(ptr->m_BlockMeta,0x00,sizeof(ptr->m_BlockMeta)); - memset(ptr->m_BlockLight,0x00,sizeof(ptr->m_BlockLight)); - memset(ptr->m_BlockSkyLight,0xFF,sizeof(ptr->m_BlockSkyLight)); -} - - - - diff --git a/src/ChunkBuffer.h b/src/ChunkBuffer.h deleted file mode 100644 index 266df2332..000000000 --- a/src/ChunkBuffer.h +++ /dev/null @@ -1,279 +0,0 @@ - -#pragma once - - -#include - - -#include "ChunkDef.h" - - -#define CHUNK_SECTION_HEIGHT 16 -#define CHUNK_SECTION_NUM (256 / CHUNK_SECTION_HEIGHT) - -#if __cplusplus < 201103L -// auto_ptr style interface for memory management -#else -// unique_ptr style interface for memory management -#endif - -class cChunkBuffer -{ -public: - - cChunkBuffer() - #if __cplusplus < 201103L - // auto_ptr style interface for memory management - : IsOwner(true) - #endif - { - memset(m_Sections, 0, sizeof(m_Sections)); - } - ~cChunkBuffer() - { - #if __cplusplus < 201103L - // auto_ptr style interface for memory management - if(!IsOwner) return; - #endif - for (int i = 0; i < CHUNK_SECTION_NUM; i++) - { - if(m_Sections[i]) Free(m_Sections[i]);; - } - } - - #if __cplusplus < 201103L - // auto_ptr style interface for memory management - cChunkBuffer(const cChunkBuffer& other) : - IsOwner(true) - { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) - { - m_Sections[i] = other.m_Sections[i]; - } - other.IsOwner = false; - } - - cChunkBuffer& operator=(const cChunkBuffer& other) - { - if(&other != this) - { - if(IsOwner) - { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) - { - if(m_Sections[i]) Free(m_Sections[i]);; - } - } - IsOwner = true; - for (int i = 0; i < CHUNK_SECTION_NUM; i++) - { - m_Sections[i] = other.m_Sections[i]; - } - other.IsOwner = false; - } - return *this; - - } - #else - // unique_ptr style interface for memory management - cChunkBuffer(cChunkBuffer&& other) - { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) - { - m_Sections[i] = other.m_Sections[i]; - other.m_Sections[i] = 0; - } - } - - cChunkBuffer& operator=(cChunkBuffer&& other) - { - if(&other != this) - { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) - { - if(m_Sections[i]) Free(m_Sections[i]);; - m_Sections[i] = other.m_Sections[i]; - other.m_Sections[i] = 0; - } - } - return *this; - } - #endif - - BLOCKTYPE GetBlock(int a_X, int a_Y, int a_Z) const - { - ASSERT((a_X >= 0) && (a_X < cChunkDef::Width)); - ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height)); - ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width)); - int Section = a_Y / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section]) - { - int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * CHUNK_SECTION_HEIGHT), a_Z); - return m_Sections[Section]->m_BlockTypes[Index]; - } - else - { - return 0; - } - } - - void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block) - { - if ( - (a_RelX >= cChunkDef::Width) || (a_RelX < 0) || - (a_RelY >= cChunkDef::Height) || (a_RelY < 0) || - (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0) - ) - { - ASSERT(!"cChunkBuffer::SetMeta(): index out of range!"); - return; - } - - int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(!m_Sections[Section]) - { - if(a_Block == 0x00) - { - return; - } - m_Sections[Section] = Allocate(); - if(!m_Sections[Section]) - { - ASSERT(!"Failed to allocate a new section in Chunkbuffer"); - return; - } - ZeroSection(m_Sections[Section]); - } - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); - m_Sections[Section]->m_BlockTypes[Index] = a_Block; - } - - NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const - { - if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) - { - int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section]) - { - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); - return (m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4)) & 0x0f; - } - else - { - return 0; - } - } - ASSERT(!"cChunkBuffer::GetMeta(): coords out of chunk range!"); - return 0; - } - - void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble) - { - if ( - (a_RelX >= cChunkDef::Width) || (a_RelX < 0) || - (a_RelY >= cChunkDef::Height) || (a_RelY < 0) || - (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0) - ) - { - ASSERT(!"cChunkBuffer::SetMeta(): index out of range!"); - return; - } - - int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(!m_Sections[Section]) - { - if((a_Nibble & 0xf) == 0x00) - { - return; - } - m_Sections[Section] = Allocate(); - if(!m_Sections[Section]) - { - ASSERT(!"Failed to allocate a new section in Chunkbuffer"); - return; - } - ZeroSection(m_Sections[Section]); - } - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); - m_Sections[Section]->m_BlockMeta[Index / 2] = static_cast( - (m_Sections[Section]->m_BlockMeta[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble - ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set - ); - } - - NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const - { - if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) - { - int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section]) - { - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); - return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; - } - else - { - return 0; - } - } - ASSERT(!"cChunkBuffer::GetMeta(): coords out of chunk range!"); - return 0; - } - - NIBBLETYPE GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const - { - if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) - { - int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section]) - { - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); - return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; - } - else - { - return 0xF; - } - } - ASSERT(!"cChunkBuffer::GetMeta(): coords out of chunk range!"); - return 0; - } - - cChunkBuffer Copy() const; - void CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx = 0, size_t length = cChunkDef::NumBlocks) const; - void CopyMeta (NIBBLETYPE * a_dest) const; - void CopyLight (NIBBLETYPE * a_dest) const; - void CopySkyLight (NIBBLETYPE * a_dest) const; - - void SetBlocks (const BLOCKTYPE * a_src); - void SetMeta (const NIBBLETYPE * a_src); - void SetLight (const NIBBLETYPE * a_src); - void SetSkyLight (const NIBBLETYPE * a_src); - -private: - - #if __cplusplus < 201103L - // auto_ptr style interface for memory management - mutable bool IsOwner; - #endif - - struct sChunkSection { - BLOCKTYPE m_BlockTypes [CHUNK_SECTION_HEIGHT * 16 * 16] ; - NIBBLETYPE m_BlockMeta [CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; - NIBBLETYPE m_BlockLight [CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; - NIBBLETYPE m_BlockSkyLight[CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; - }; - - sChunkSection *m_Sections[CHUNK_SECTION_NUM]; - - sChunkSection * Allocate() const; - void Free(sChunkSection * ptr) const; - - void ZeroSection(sChunkSection * ptr) const; -}; - - - - - - diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp new file mode 100644 index 000000000..160d118ad --- /dev/null +++ b/src/ChunkData.cpp @@ -0,0 +1,320 @@ + +#include "Globals.h" +#include "ChunkData.h" + +cChunkData cChunkData::Copy() const +{ + cChunkData copy; + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + if(m_Sections[i]) + { + copy.m_Sections[i] = Allocate(); + *copy.m_Sections[i] = *m_Sections[i]; + } + } + return copy; +} + + + + + +void cChunkData::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length) const +{ + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; + if (a_Idx > 0) a_Idx = a_Idx > length ? a_Idx - length : 0; + if (a_Idx == 0) + { + size_t tocopy = length > segment_length ? segment_length : length; + length -= tocopy; + if(m_Sections[i]) + { + memcpy( + &a_dest[i * segment_length], + &m_Sections[i]->m_BlockTypes, + sizeof(BLOCKTYPE) * tocopy + ); + } + else + { + memset( + &a_dest[i * segment_length], + 0, + sizeof(BLOCKTYPE) * tocopy + ); + } + } + } +} + + + + + +void cChunkData::CopyMeta(NIBBLETYPE * a_dest) const +{ + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + if(m_Sections[i]) + { + memcpy( + &a_dest[i * segment_length], + &m_Sections[i]->m_BlockMeta, + sizeof(NIBBLETYPE) * segment_length); + } + else + { + memset( + &a_dest[i * segment_length], + 0, + sizeof(BLOCKTYPE) * segment_length + ); + } + } +} + + + + + +void cChunkData::CopyLight(NIBBLETYPE * a_dest) const +{ + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + if(m_Sections[i]) + { + memcpy( + &a_dest[i * segment_length], + &m_Sections[i]->m_BlockLight, + sizeof(NIBBLETYPE) * segment_length + ); + } + else + { + memset( + &a_dest[i * segment_length], + 0, + sizeof(BLOCKTYPE) * segment_length + ); + } + } +} + + + + + +void cChunkData::CopySkyLight(NIBBLETYPE * a_dest) const +{ + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + if(m_Sections[i]) + { + memcpy( + &a_dest[i * segment_length], + &m_Sections[i]->m_BlockSkyLight, + sizeof(NIBBLETYPE) * segment_length + ); + } + else + { + memset( + &a_dest[i * segment_length], + 0xFF, + sizeof(BLOCKTYPE) * segment_length + ); + } + } +} + + + + + +void cChunkData::SetBlocks(const BLOCKTYPE * a_src) +{ + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; + if (m_Sections[i]) + { + memcpy(&m_Sections[i]->m_BlockTypes, &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length); + } + else + { + size_t j = 0; + // do nothing whilst 0 + for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); + if (j != segment_length) + { + m_Sections[i] = Allocate(); + memcpy( + &m_Sections[i]->m_BlockTypes, + &a_src[i * segment_length], + sizeof(BLOCKTYPE) * segment_length + ); + memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta)); + memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight)); + memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight)); + } + else + { + Free(m_Sections[i]); + m_Sections[i] = 0; + } + } + } +} + + + + +void cChunkData::SetMeta(const NIBBLETYPE * a_src) +{ + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + if (m_Sections[i]) + { + memcpy(&m_Sections[i]->m_BlockMeta, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); + } + else + { + size_t j = 0; + // do nothing whilst 0 + for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); + if (j != segment_length) + { + m_Sections[i] = Allocate(); + memcpy( + &m_Sections[i]->m_BlockMeta, + &a_src[i * segment_length], + sizeof(BLOCKTYPE) * segment_length + ); + memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes)); + memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight)); + memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight)); + } + else + { + Free(m_Sections[i]); + m_Sections[i] = 0; + } + } + } +} + + + + +void cChunkData::SetLight(const NIBBLETYPE * a_src) +{ + if (!a_src) return; + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + if (m_Sections[i]) + { + memcpy(&m_Sections[i]->m_BlockLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); + } + else + { + size_t j = 0; + // do nothing whilst 0 + for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); + if (j != segment_length) + { + m_Sections[i] = Allocate(); + memcpy( + &m_Sections[i]->m_BlockLight, + &a_src[i * segment_length], + sizeof(BLOCKTYPE) * segment_length + ); + memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes)); + memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta)); + memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight)); + } + else + { + Free(m_Sections[i]); + m_Sections[i] = 0; + } + } + } +} + + + + +void cChunkData::SetSkyLight (const NIBBLETYPE * a_src) +{ + if (!a_src) return; + for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + { + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + if (m_Sections[i]) + { + memcpy(&m_Sections[i]->m_BlockSkyLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); + } + else + { + size_t j = 0; + // do nothing whilst 0 + for (; j < segment_length && a_src[i * segment_length + j] == 0xFF; j++); + if (j != segment_length) + { + m_Sections[i] = Allocate(); + memcpy( + &m_Sections[i]->m_BlockSkyLight, + &a_src[i * segment_length], + sizeof(BLOCKTYPE) * segment_length + ); + memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes)); + memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta)); + memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight)); + } + else + { + Free(m_Sections[i]); + m_Sections[i] = 0; + } + } + } +} + + + + + +cChunkData::sChunkSection * cChunkData::Allocate() const +{ + // TODO: use a allocation pool + return new cChunkData::sChunkSection; +} + + + +void cChunkData::Free(cChunkData::sChunkSection * ptr) const +{ + delete ptr; +} + + + +void cChunkData::ZeroSection(cChunkData::sChunkSection * ptr) const +{ + memset(ptr->m_BlockTypes,0x00,sizeof(ptr->m_BlockTypes)); + memset(ptr->m_BlockMeta,0x00,sizeof(ptr->m_BlockMeta)); + memset(ptr->m_BlockLight,0x00,sizeof(ptr->m_BlockLight)); + memset(ptr->m_BlockSkyLight,0xFF,sizeof(ptr->m_BlockSkyLight)); +} + + + + diff --git a/src/ChunkData.h b/src/ChunkData.h new file mode 100644 index 000000000..809f3cdf2 --- /dev/null +++ b/src/ChunkData.h @@ -0,0 +1,279 @@ + +#pragma once + + +#include + + +#include "ChunkDef.h" + + +#define CHUNK_SECTION_HEIGHT 16 +#define CHUNK_SECTION_NUM (256 / CHUNK_SECTION_HEIGHT) + +#if __cplusplus < 201103L +// auto_ptr style interface for memory management +#else +// unique_ptr style interface for memory management +#endif + +class cChunkData +{ +public: + + cChunkData() + #if __cplusplus < 201103L + // auto_ptr style interface for memory management + : IsOwner(true) + #endif + { + memset(m_Sections, 0, sizeof(m_Sections)); + } + ~cChunkData() + { + #if __cplusplus < 201103L + // auto_ptr style interface for memory management + if(!IsOwner) return; + #endif + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + if(m_Sections[i]) Free(m_Sections[i]);; + } + } + + #if __cplusplus < 201103L + // auto_ptr style interface for memory management + cChunkData(const cChunkData& other) : + IsOwner(true) + { + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + m_Sections[i] = other.m_Sections[i]; + } + other.IsOwner = false; + } + + cChunkData& operator=(const cChunkData& other) + { + if(&other != this) + { + if(IsOwner) + { + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + if(m_Sections[i]) Free(m_Sections[i]);; + } + } + IsOwner = true; + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + m_Sections[i] = other.m_Sections[i]; + } + other.IsOwner = false; + } + return *this; + + } + #else + // unique_ptr style interface for memory management + cChunkData(cChunkData&& other) + { + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + m_Sections[i] = other.m_Sections[i]; + other.m_Sections[i] = 0; + } + } + + cChunkData& operator=(cChunkData&& other) + { + if(&other != this) + { + for (int i = 0; i < CHUNK_SECTION_NUM; i++) + { + if(m_Sections[i]) Free(m_Sections[i]);; + m_Sections[i] = other.m_Sections[i]; + other.m_Sections[i] = 0; + } + } + return *this; + } + #endif + + BLOCKTYPE GetBlock(int a_X, int a_Y, int a_Z) const + { + ASSERT((a_X >= 0) && (a_X < cChunkDef::Width)); + ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height)); + ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width)); + int Section = a_Y / CHUNK_SECTION_HEIGHT; + if(m_Sections[Section]) + { + int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * CHUNK_SECTION_HEIGHT), a_Z); + return m_Sections[Section]->m_BlockTypes[Index]; + } + else + { + return 0; + } + } + + void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block) + { + if ( + (a_RelX >= cChunkDef::Width) || (a_RelX < 0) || + (a_RelY >= cChunkDef::Height) || (a_RelY < 0) || + (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0) + ) + { + ASSERT(!"cChunkData::SetMeta(): index out of range!"); + return; + } + + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if(!m_Sections[Section]) + { + if(a_Block == 0x00) + { + return; + } + m_Sections[Section] = Allocate(); + if(!m_Sections[Section]) + { + ASSERT(!"Failed to allocate a new section in Chunkbuffer"); + return; + } + ZeroSection(m_Sections[Section]); + } + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + m_Sections[Section]->m_BlockTypes[Index] = a_Block; + } + + NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const + { + if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) + { + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if(m_Sections[Section]) + { + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + return (m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4)) & 0x0f; + } + else + { + return 0; + } + } + ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!"); + return 0; + } + + void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble) + { + if ( + (a_RelX >= cChunkDef::Width) || (a_RelX < 0) || + (a_RelY >= cChunkDef::Height) || (a_RelY < 0) || + (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0) + ) + { + ASSERT(!"cChunkData::SetMeta(): index out of range!"); + return; + } + + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if(!m_Sections[Section]) + { + if((a_Nibble & 0xf) == 0x00) + { + return; + } + m_Sections[Section] = Allocate(); + if(!m_Sections[Section]) + { + ASSERT(!"Failed to allocate a new section in Chunkbuffer"); + return; + } + ZeroSection(m_Sections[Section]); + } + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + m_Sections[Section]->m_BlockMeta[Index / 2] = static_cast( + (m_Sections[Section]->m_BlockMeta[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble + ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set + ); + } + + NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const + { + if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) + { + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if(m_Sections[Section]) + { + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; + } + else + { + return 0; + } + } + ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!"); + return 0; + } + + NIBBLETYPE GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const + { + if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) + { + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if(m_Sections[Section]) + { + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; + } + else + { + return 0xF; + } + } + ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!"); + return 0; + } + + cChunkData Copy() const; + void CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx = 0, size_t length = cChunkDef::NumBlocks) const; + void CopyMeta (NIBBLETYPE * a_dest) const; + void CopyLight (NIBBLETYPE * a_dest) const; + void CopySkyLight (NIBBLETYPE * a_dest) const; + + void SetBlocks (const BLOCKTYPE * a_src); + void SetMeta (const NIBBLETYPE * a_src); + void SetLight (const NIBBLETYPE * a_src); + void SetSkyLight (const NIBBLETYPE * a_src); + +private: + + #if __cplusplus < 201103L + // auto_ptr style interface for memory management + mutable bool IsOwner; + #endif + + struct sChunkSection { + BLOCKTYPE m_BlockTypes [CHUNK_SECTION_HEIGHT * 16 * 16] ; + NIBBLETYPE m_BlockMeta [CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; + NIBBLETYPE m_BlockLight [CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; + NIBBLETYPE m_BlockSkyLight[CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; + }; + + sChunkSection *m_Sections[CHUNK_SECTION_NUM]; + + sChunkSection * Allocate() const; + void Free(sChunkSection * ptr) const; + + void ZeroSection(sChunkSection * ptr) const; +}; + + + + + + diff --git a/src/ChunkDataCallback.h b/src/ChunkDataCallback.h index 76c45040e..340582885 100644 --- a/src/ChunkDataCallback.h +++ b/src/ChunkDataCallback.h @@ -3,7 +3,7 @@ #pragma once -#include "ChunkBuffer.h" +#include "ChunkData.h" /** Interface class used for getting data out of a chunk using the GetAllData() function. @@ -26,13 +26,13 @@ public: virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) {UNUSED(a_HeightMap); }; /// Called once to provide biome data - virtual void BiomeData (const cChunkDef::BiomeMap * a_BiomeMap) {UNUSED(a_BiomeMap); }; + virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) {UNUSED(a_BiomeMap); }; /// Called once to let know if the chunk lighting is valid. Return value is ignored virtual void LightIsValid(bool a_IsLightValid) {UNUSED(a_IsLightValid); }; /// Called once to export block info - virtual void ChunkBuffer (const cChunkBuffer & a_Buffer) {UNUSED(a_Buffer); }; + virtual void ChunkData(const cChunkData & a_Buffer) {UNUSED(a_Buffer); }; /// Called for each entity in the chunk virtual void Entity(cEntity * a_Entity) {UNUSED(a_Entity); }; @@ -43,16 +43,16 @@ public: /** A simple implementation of the cChunkDataCallback interface that collects all block data into a buffer */ -class cChunkBufferCollector : +class cChunkDataCollector : public cChunkDataCallback { public: - cChunkBuffer m_BlockData; + cChunkData m_BlockData; protected: - virtual void ChunkBuffer(const cChunkBuffer & a_BlockData) override + virtual void ChunkData(const cChunkData & a_BlockData) override { m_BlockData = a_BlockData.Copy(); } @@ -61,7 +61,7 @@ protected: /** A simple implementation of the cChunkDataCallback interface that collects all block data into a single buffer */ -class cChunkDataCollector : +class cChunkDataArrayCollector : public cChunkDataCallback { public: @@ -71,7 +71,7 @@ public: protected: - virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override + virtual void ChunkData(const cChunkData & a_ChunkBuffer) override { a_ChunkBuffer.CopyBlocks(m_BlockData); a_ChunkBuffer.CopyMeta(m_BlockData + cChunkDef::NumBlocks); @@ -94,7 +94,7 @@ public: protected: - virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override + virtual void ChunkData(const cChunkData & a_ChunkBuffer) override { a_ChunkBuffer.CopyBlocks(m_BlockTypes); a_ChunkBuffer.CopyMeta(m_BlockMetas); diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index f961e35c6..879252c34 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -18,7 +18,7 @@ class cReader : public cChunkDataCallback { - virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override + virtual void ChunkData(const cChunkData & a_ChunkBuffer) override { BLOCKTYPE * OutputRows = m_BlockTypes; int InputIdx = 0; diff --git a/src/WorldStorage/WSSCompact.h b/src/WorldStorage/WSSCompact.h index 6c363d5ac..b148005f6 100644 --- a/src/WorldStorage/WSSCompact.h +++ b/src/WorldStorage/WSSCompact.h @@ -22,7 +22,7 @@ /// Helper class for serializing a chunk into Json class cJsonChunkSerializer : - public cChunkDataCollector + public cChunkDataArrayCollector { public: -- cgit v1.2.3 From 5929ffbc40d24f4e69cf12c8495d194407547c9c Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 21 May 2014 20:08:34 +0100 Subject: Fixed stylistic issues --- src/BlockArea.cpp | 8 ++++---- src/Chunk.cpp | 4 ++-- src/ChunkData.cpp | 18 +++++++++--------- src/ChunkData.h | 20 ++++++++++---------- 4 files changed, 25 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 0c46e59e5..abbfca767 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -1838,7 +1838,7 @@ bool cBlockArea::cChunkReader::Coords(int a_ChunkX, int a_ChunkZ) void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer) { { - if (!(m_Area.m_BlockTypes == NULL)) + if (m_Area.m_BlockTypes != NULL) { int SizeY = m_Area.m_Size.y; int MinY = m_Origin.y; @@ -1901,17 +1901,17 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer) } } - if (m_Area.m_BlockMetas) + if (m_Area.m_BlockMetas != NULL) { a_BlockBuffer.CopyMeta(m_Area.m_BlockMetas); } - if (m_Area.m_BlockLight) + if (m_Area.m_BlockLight != NULL) { a_BlockBuffer.CopyLight(m_Area.m_BlockLight); } - if (m_Area.m_BlockSkyLight) + if (m_Area.m_BlockSkyLight != NULL) { a_BlockBuffer.CopySkyLight(m_Area.m_BlockSkyLight); } diff --git a/src/Chunk.cpp b/src/Chunk.cpp index a45ed32c1..d85b44607 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -326,9 +326,9 @@ void cChunk::SetLight( // TODO: We might get cases of wrong lighting when a chunk changes in the middle of a lighting calculation. // Postponing until we see how bad it is :) - m_ChunkData.SetLight (a_BlockLight); + m_ChunkData.SetLight(a_BlockLight); - m_ChunkData.SetSkyLight (a_SkyLight); + m_ChunkData.SetSkyLight(a_SkyLight); m_IsLightValid = true; } diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 160d118ad..7194eca92 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -7,7 +7,7 @@ cChunkData cChunkData::Copy() const cChunkData copy; for (int i = 0; i < CHUNK_SECTION_NUM; i++) { - if(m_Sections[i]) + if(m_Sections[i] == NULL) { copy.m_Sections[i] = Allocate(); *copy.m_Sections[i] = *m_Sections[i]; @@ -30,7 +30,7 @@ void cChunkData::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length) { size_t tocopy = length > segment_length ? segment_length : length; length -= tocopy; - if(m_Sections[i]) + if(m_Sections[i] == NULL) { memcpy( &a_dest[i * segment_length], @@ -59,7 +59,7 @@ void cChunkData::CopyMeta(NIBBLETYPE * a_dest) const for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if(m_Sections[i]) + if(m_Sections[i] == NULL) { memcpy( &a_dest[i * segment_length], @@ -86,7 +86,7 @@ void cChunkData::CopyLight(NIBBLETYPE * a_dest) const for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if(m_Sections[i]) + if(m_Sections[i] == NULL) { memcpy( &a_dest[i * segment_length], @@ -114,7 +114,7 @@ void cChunkData::CopySkyLight(NIBBLETYPE * a_dest) const for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if(m_Sections[i]) + if(m_Sections[i] == NULL) { memcpy( &a_dest[i * segment_length], @@ -142,7 +142,7 @@ void cChunkData::SetBlocks(const BLOCKTYPE * a_src) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; - if (m_Sections[i]) + if (m_Sections[i] == NULL) { memcpy(&m_Sections[i]->m_BlockTypes, &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length); } @@ -180,7 +180,7 @@ void cChunkData::SetMeta(const NIBBLETYPE * a_src) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if (m_Sections[i]) + if (m_Sections[i] == NULL) { memcpy(&m_Sections[i]->m_BlockMeta, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); } @@ -219,7 +219,7 @@ void cChunkData::SetLight(const NIBBLETYPE * a_src) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if (m_Sections[i]) + if (m_Sections[i] == NULL) { memcpy(&m_Sections[i]->m_BlockLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); } @@ -258,7 +258,7 @@ void cChunkData::SetSkyLight (const NIBBLETYPE * a_src) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if (m_Sections[i]) + if (m_Sections[i] == NULL) { memcpy(&m_Sections[i]->m_BlockSkyLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); } diff --git a/src/ChunkData.h b/src/ChunkData.h index 809f3cdf2..24a437629 100644 --- a/src/ChunkData.h +++ b/src/ChunkData.h @@ -37,7 +37,7 @@ public: #endif for (int i = 0; i < CHUNK_SECTION_NUM; i++) { - if(m_Sections[i]) Free(m_Sections[i]);; + if(m_Sections[i] == NULL) Free(m_Sections[i]);; } } @@ -91,7 +91,7 @@ public: { for (int i = 0; i < CHUNK_SECTION_NUM; i++) { - if(m_Sections[i]) Free(m_Sections[i]);; + Free(m_Sections[i]);; m_Sections[i] = other.m_Sections[i]; other.m_Sections[i] = 0; } @@ -106,7 +106,7 @@ public: ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height)); ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width)); int Section = a_Y / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section]) + if(m_Sections[Section] == NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * CHUNK_SECTION_HEIGHT), a_Z); return m_Sections[Section]->m_BlockTypes[Index]; @@ -130,14 +130,14 @@ public: } int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(!m_Sections[Section]) + if(m_Sections[Section] != NULL) { if(a_Block == 0x00) { return; } m_Sections[Section] = Allocate(); - if(!m_Sections[Section]) + if(m_Sections[Section] != NULL) { ASSERT(!"Failed to allocate a new section in Chunkbuffer"); return; @@ -153,7 +153,7 @@ public: if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) { int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section]) + if(m_Sections[Section] == NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); return (m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4)) & 0x0f; @@ -180,14 +180,14 @@ public: } int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(!m_Sections[Section]) + if(m_Sections[Section] != NULL) { if((a_Nibble & 0xf) == 0x00) { return; } m_Sections[Section] = Allocate(); - if(!m_Sections[Section]) + if(m_Sections[Section] != NULL) { ASSERT(!"Failed to allocate a new section in Chunkbuffer"); return; @@ -206,7 +206,7 @@ public: if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) { int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section]) + if(m_Sections[Section] == NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; @@ -225,7 +225,7 @@ public: if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) { int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section]) + if(m_Sections[Section] == NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; -- cgit v1.2.3 From bd880603a560160d247d79a2fdeb3fbab26994f0 Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 21 May 2014 20:18:09 +0100 Subject: Changed cChunkData::SetMeta to return a bool indicating whether the value changed --- src/Chunk.h | 6 +++--- src/ChunkData.h | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Chunk.h b/src/Chunk.h index 4f6c4cf0a..2de45919e 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -328,11 +328,11 @@ public: } inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta) { - if (!(GetMeta(a_RelX, a_RelY, a_RelZ) == a_Meta)) + bool hasChanged = m_ChunkData.SetMeta(a_RelX, a_RelY, a_RelZ, a_Meta); + if (hasChanged) { MarkDirty(); - m_ChunkData.SetMeta(a_RelX, a_RelY, a_RelZ, a_Meta); - + m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), a_Meta)); } } diff --git a/src/ChunkData.h b/src/ChunkData.h index 24a437629..73b1e8c6a 100644 --- a/src/ChunkData.h +++ b/src/ChunkData.h @@ -167,7 +167,7 @@ public: return 0; } - void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble) + bool SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble) { if ( (a_RelX >= cChunkDef::Width) || (a_RelX < 0) || @@ -176,7 +176,7 @@ public: ) { ASSERT(!"cChunkData::SetMeta(): index out of range!"); - return; + return false; } int Section = a_RelY / CHUNK_SECTION_HEIGHT; @@ -184,21 +184,23 @@ public: { if((a_Nibble & 0xf) == 0x00) { - return; + return false; } m_Sections[Section] = Allocate(); if(m_Sections[Section] != NULL) { ASSERT(!"Failed to allocate a new section in Chunkbuffer"); - return; + return false; } ZeroSection(m_Sections[Section]); } int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + NIBBLETYPE oldval = m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4) & 0xf; m_Sections[Section]->m_BlockMeta[Index / 2] = static_cast( (m_Sections[Section]->m_BlockMeta[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set ); + return oldval == a_Nibble; } NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const -- cgit v1.2.3 From 93c0dcb1feb6daebbea586e750b586ec6588bfa2 Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 21 May 2014 20:26:43 +0100 Subject: Added space to ChunkData.cpp --- src/ChunkData.cpp | 120 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 100 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 7194eca92..f8c4a851d 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -144,7 +144,11 @@ void cChunkData::SetBlocks(const BLOCKTYPE * a_src) const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; if (m_Sections[i] == NULL) { - memcpy(&m_Sections[i]->m_BlockTypes, &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length); + memcpy( + &m_Sections[i]->m_BlockTypes, + &a_src[i * segment_length], + sizeof(BLOCKTYPE) * segment_length + ); } else { @@ -159,9 +163,21 @@ void cChunkData::SetBlocks(const BLOCKTYPE * a_src) &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length ); - memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta)); - memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight)); - memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight)); + memset( + m_Sections[i]->m_BlockMeta, + 0x00, + sizeof(m_Sections[i]->m_BlockMeta) + ); + memset( + m_Sections[i]->m_BlockLight, + 0x00, + sizeof(m_Sections[i]->m_BlockLight) + ); + memset( + m_Sections[i]->m_BlockSkyLight, + 0xFF, + sizeof(m_Sections[i]->m_BlockSkyLight) + ); } else { @@ -182,7 +198,11 @@ void cChunkData::SetMeta(const NIBBLETYPE * a_src) const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] == NULL) { - memcpy(&m_Sections[i]->m_BlockMeta, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); + memcpy( + &m_Sections[i]->m_BlockMeta, + &a_src[i * segment_length], + sizeof(NIBBLETYPE) * segment_length + ); } else { @@ -197,9 +217,21 @@ void cChunkData::SetMeta(const NIBBLETYPE * a_src) &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length ); - memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes)); - memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight)); - memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight)); + memset( + m_Sections[i]->m_BlockTypes, + 0x00, + sizeof(m_Sections[i]->m_BlockTypes) + ); + memset( + m_Sections[i]->m_BlockLight, + 0x00, + sizeof(m_Sections[i]->m_BlockLight) + ); + memset( + m_Sections[i]->m_BlockSkyLight, + 0xFF, + sizeof(m_Sections[i]->m_BlockSkyLight) + ); } else { @@ -221,7 +253,11 @@ void cChunkData::SetLight(const NIBBLETYPE * a_src) const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] == NULL) { - memcpy(&m_Sections[i]->m_BlockLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); + memcpy( + &m_Sections[i]->m_BlockLight, + &a_src[i * segment_length], + sizeof(NIBBLETYPE) * segment_length + ); } else { @@ -236,9 +272,21 @@ void cChunkData::SetLight(const NIBBLETYPE * a_src) &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length ); - memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes)); - memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta)); - memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight)); + memset( + m_Sections[i]->m_BlockTypes, + 0x00, + sizeof(m_Sections[i]->m_BlockTypes) + ); + memset( + m_Sections[i]->m_BlockMeta, + 0x00, + sizeof(m_Sections[i]->m_BlockMeta) + ); + memset( + m_Sections[i]->m_BlockSkyLight, + 0xFF, + sizeof(m_Sections[i]->m_BlockSkyLight) + ); } else { @@ -260,7 +308,11 @@ void cChunkData::SetSkyLight (const NIBBLETYPE * a_src) const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] == NULL) { - memcpy(&m_Sections[i]->m_BlockSkyLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); + memcpy( + &m_Sections[i]->m_BlockSkyLight, + &a_src[i * segment_length], + sizeof(NIBBLETYPE) * segment_length + ); } else { @@ -275,9 +327,21 @@ void cChunkData::SetSkyLight (const NIBBLETYPE * a_src) &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length ); - memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes)); - memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta)); - memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight)); + memset( + m_Sections[i]->m_BlockTypes, + 0x00, + sizeof(m_Sections[i]->m_BlockTypes) + ); + memset( + m_Sections[i]->m_BlockMeta, + 0x00, + sizeof(m_Sections[i]->m_BlockMeta) + ); + memset( + m_Sections[i]->m_BlockLight, + 0x00, + sizeof(m_Sections[i]->m_BlockLight) + ); } else { @@ -309,10 +373,26 @@ void cChunkData::Free(cChunkData::sChunkSection * ptr) const void cChunkData::ZeroSection(cChunkData::sChunkSection * ptr) const { - memset(ptr->m_BlockTypes,0x00,sizeof(ptr->m_BlockTypes)); - memset(ptr->m_BlockMeta,0x00,sizeof(ptr->m_BlockMeta)); - memset(ptr->m_BlockLight,0x00,sizeof(ptr->m_BlockLight)); - memset(ptr->m_BlockSkyLight,0xFF,sizeof(ptr->m_BlockSkyLight)); + memset( + ptr->m_BlockTypes, + 0x00, + sizeof(ptr->m_BlockTypes) + ); + memset( + ptr->m_BlockMeta, + 0x00, + sizeof(ptr->m_BlockMeta) + ); + memset( + ptr->m_BlockLight, + 0x00, + sizeof(ptr->m_BlockLight) + ); + memset( + ptr->m_BlockSkyLight, + 0xFF, + sizeof(ptr->m_BlockSkyLight) + ); } -- cgit v1.2.3 From 88c61a2e96af9c7d1b173c0b580cef2c348850d7 Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 21 May 2014 21:18:14 +0100 Subject: Fixed reversed comparisons to null --- src/ChunkData.cpp | 18 +++++++++--------- src/ChunkData.h | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index f8c4a851d..0cacaf02d 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -7,7 +7,7 @@ cChunkData cChunkData::Copy() const cChunkData copy; for (int i = 0; i < CHUNK_SECTION_NUM; i++) { - if(m_Sections[i] == NULL) + if(m_Sections[i] != NULL) { copy.m_Sections[i] = Allocate(); *copy.m_Sections[i] = *m_Sections[i]; @@ -30,7 +30,7 @@ void cChunkData::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length) { size_t tocopy = length > segment_length ? segment_length : length; length -= tocopy; - if(m_Sections[i] == NULL) + if(m_Sections[i] != NULL) { memcpy( &a_dest[i * segment_length], @@ -59,7 +59,7 @@ void cChunkData::CopyMeta(NIBBLETYPE * a_dest) const for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if(m_Sections[i] == NULL) + if(m_Sections[i] != NULL) { memcpy( &a_dest[i * segment_length], @@ -86,7 +86,7 @@ void cChunkData::CopyLight(NIBBLETYPE * a_dest) const for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if(m_Sections[i] == NULL) + if(m_Sections[i] != NULL) { memcpy( &a_dest[i * segment_length], @@ -114,7 +114,7 @@ void cChunkData::CopySkyLight(NIBBLETYPE * a_dest) const for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if(m_Sections[i] == NULL) + if(m_Sections[i] != NULL) { memcpy( &a_dest[i * segment_length], @@ -142,7 +142,7 @@ void cChunkData::SetBlocks(const BLOCKTYPE * a_src) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; - if (m_Sections[i] == NULL) + if (m_Sections[i] != NULL) { memcpy( &m_Sections[i]->m_BlockTypes, @@ -196,7 +196,7 @@ void cChunkData::SetMeta(const NIBBLETYPE * a_src) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if (m_Sections[i] == NULL) + if (m_Sections[i] != NULL) { memcpy( &m_Sections[i]->m_BlockMeta, @@ -251,7 +251,7 @@ void cChunkData::SetLight(const NIBBLETYPE * a_src) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if (m_Sections[i] == NULL) + if (m_Sections[i] != NULL) { memcpy( &m_Sections[i]->m_BlockLight, @@ -306,7 +306,7 @@ void cChunkData::SetSkyLight (const NIBBLETYPE * a_src) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if (m_Sections[i] == NULL) + if (m_Sections[i] != NULL) { memcpy( &m_Sections[i]->m_BlockSkyLight, diff --git a/src/ChunkData.h b/src/ChunkData.h index 73b1e8c6a..51244225b 100644 --- a/src/ChunkData.h +++ b/src/ChunkData.h @@ -106,7 +106,7 @@ public: ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height)); ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width)); int Section = a_Y / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section] == NULL) + if(m_Sections[Section] != NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * CHUNK_SECTION_HEIGHT), a_Z); return m_Sections[Section]->m_BlockTypes[Index]; @@ -130,14 +130,14 @@ public: } int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section] != NULL) + if(m_Sections[Section] == NULL) { if(a_Block == 0x00) { return; } m_Sections[Section] = Allocate(); - if(m_Sections[Section] != NULL) + if(m_Sections[Section] == NULL) { ASSERT(!"Failed to allocate a new section in Chunkbuffer"); return; @@ -153,7 +153,7 @@ public: if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) { int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section] == NULL) + if(m_Sections[Section] != NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); return (m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4)) & 0x0f; @@ -180,14 +180,14 @@ public: } int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section] != NULL) + if(m_Sections[Section] == NULL) { if((a_Nibble & 0xf) == 0x00) { return false; } m_Sections[Section] = Allocate(); - if(m_Sections[Section] != NULL) + if(m_Sections[Section] == NULL) { ASSERT(!"Failed to allocate a new section in Chunkbuffer"); return false; @@ -208,7 +208,7 @@ public: if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) { int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section] == NULL) + if(m_Sections[Section] != NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; @@ -227,7 +227,7 @@ public: if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) { int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section] == NULL) + if(m_Sections[Section] != NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; -- cgit v1.2.3 From 4b23472097fa2daee464b6c5d73da56a0706731c Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 21 May 2014 21:46:20 +0100 Subject: Fixed if spaces --- src/ChunkData.cpp | 13 +++++++------ src/ChunkData.h | 32 ++++++++++++++++---------------- 2 files changed, 23 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 0cacaf02d..86b0c431c 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -7,7 +7,7 @@ cChunkData cChunkData::Copy() const cChunkData copy; for (int i = 0; i < CHUNK_SECTION_NUM; i++) { - if(m_Sections[i] != NULL) + if (m_Sections[i] != NULL) { copy.m_Sections[i] = Allocate(); *copy.m_Sections[i] = *m_Sections[i]; @@ -30,7 +30,7 @@ void cChunkData::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length) { size_t tocopy = length > segment_length ? segment_length : length; length -= tocopy; - if(m_Sections[i] != NULL) + if (m_Sections[i] != NULL) { memcpy( &a_dest[i * segment_length], @@ -59,12 +59,13 @@ void cChunkData::CopyMeta(NIBBLETYPE * a_dest) const for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if(m_Sections[i] != NULL) + if (m_Sections[i] != NULL) { memcpy( &a_dest[i * segment_length], &m_Sections[i]->m_BlockMeta, - sizeof(NIBBLETYPE) * segment_length); + sizeof(NIBBLETYPE) * segment_length + ); } else { @@ -86,7 +87,7 @@ void cChunkData::CopyLight(NIBBLETYPE * a_dest) const for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if(m_Sections[i] != NULL) + if (m_Sections[i] != NULL) { memcpy( &a_dest[i * segment_length], @@ -114,7 +115,7 @@ void cChunkData::CopySkyLight(NIBBLETYPE * a_dest) const for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; - if(m_Sections[i] != NULL) + if (m_Sections[i] != NULL) { memcpy( &a_dest[i * segment_length], diff --git a/src/ChunkData.h b/src/ChunkData.h index 51244225b..9c852ee24 100644 --- a/src/ChunkData.h +++ b/src/ChunkData.h @@ -33,11 +33,11 @@ public: { #if __cplusplus < 201103L // auto_ptr style interface for memory management - if(!IsOwner) return; + if (!IsOwner) return; #endif for (int i = 0; i < CHUNK_SECTION_NUM; i++) { - if(m_Sections[i] == NULL) Free(m_Sections[i]);; + if (m_Sections[i] == NULL) Free(m_Sections[i]);; } } @@ -55,13 +55,13 @@ public: cChunkData& operator=(const cChunkData& other) { - if(&other != this) + if (&other != this) { - if(IsOwner) + if (IsOwner) { for (int i = 0; i < CHUNK_SECTION_NUM; i++) { - if(m_Sections[i]) Free(m_Sections[i]);; + if (m_Sections[i]) Free(m_Sections[i]);; } } IsOwner = true; @@ -87,7 +87,7 @@ public: cChunkData& operator=(cChunkData&& other) { - if(&other != this) + if (&other != this) { for (int i = 0; i < CHUNK_SECTION_NUM; i++) { @@ -106,7 +106,7 @@ public: ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height)); ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width)); int Section = a_Y / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section] != NULL) + if (m_Sections[Section] != NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * CHUNK_SECTION_HEIGHT), a_Z); return m_Sections[Section]->m_BlockTypes[Index]; @@ -130,14 +130,14 @@ public: } int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section] == NULL) + if (m_Sections[Section] == NULL) { - if(a_Block == 0x00) + if (a_Block == 0x00) { return; } m_Sections[Section] = Allocate(); - if(m_Sections[Section] == NULL) + if (m_Sections[Section] == NULL) { ASSERT(!"Failed to allocate a new section in Chunkbuffer"); return; @@ -153,7 +153,7 @@ public: if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) { int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section] != NULL) + if (m_Sections[Section] != NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); return (m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4)) & 0x0f; @@ -180,14 +180,14 @@ public: } int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section] == NULL) + if (m_Sections[Section] == NULL) { - if((a_Nibble & 0xf) == 0x00) + if ((a_Nibble & 0xf) == 0x00) { return false; } m_Sections[Section] = Allocate(); - if(m_Sections[Section] == NULL) + if (m_Sections[Section] == NULL) { ASSERT(!"Failed to allocate a new section in Chunkbuffer"); return false; @@ -208,7 +208,7 @@ public: if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) { int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section] != NULL) + if (m_Sections[Section] != NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; @@ -227,7 +227,7 @@ public: if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) { int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if(m_Sections[Section] != NULL) + if (m_Sections[Section] != NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; -- cgit v1.2.3 From efcae77828d52680f9521793520ffc4325b465b8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 21 May 2014 23:16:43 +0200 Subject: Added second kind of desert village (FlatRoof). --- .../Prefabs/SandFlatRoofVillagePrefabs.cpp | 1511 ++++++++++++++++++++ .../Prefabs/SandFlatRoofVillagePrefabs.h | 15 + src/Generating/VillageGen.cpp | 13 +- 3 files changed, 1535 insertions(+), 4 deletions(-) create mode 100644 src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp create mode 100644 src/Generating/Prefabs/SandFlatRoofVillagePrefabs.h (limited to 'src') diff --git a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp new file mode 100644 index 000000000..93aa405c2 --- /dev/null +++ b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp @@ -0,0 +1,1511 @@ + +// SandFlatRoofVillagePrefabs.cpp + +// Defines the prefabs in the group SandFlatRoofVillage + +// NOTE: This file has been generated automatically by GalExport! +// Any manual changes will be overwritten by the next automatic export! + +#include "Globals.h" +#include "SandFlatRoofVillagePrefabs.h" + + + + + +const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Forge: + // The data has been exported from the gallery Desert, area index 32, ID 173, created by Aloe_vera + { + // Size: + 12, 5, 10, // SizeX = 12, SizeY = 5, SizeZ = 10 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 11, 4, 9, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 2\n" /* sandstonestairs */ + "b:128: 1\n" /* sandstonestairs */ + "c:128: 0\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e:128: 3\n" /* sandstonestairs */ + "f:171:15\n" /* carpet */ + "g: 64: 6\n" /* wooddoorblock */ + "h:171: 0\n" /* carpet */ + "i:171:14\n" /* carpet */ + "j: 61: 2\n" /* furnace */ + "k: 10: 0\n" /* lava */ + "l: 54: 2\n" /* chest */ + "m: 19: 0\n" /* sponge */ + "n: 24: 2\n" /* sandstone */ + "o: 64:12\n" /* wooddoorblock */ + "p: 50: 1\n" /* torch */ + "q:101: 0\n" /* ironbars */ + "r:128: 4\n" /* sandstonestairs */ + "s:128: 6\n" /* sandstonestairs */ + "t:128: 5\n" /* sandstonestairs */ + "u:128: 7\n" /* sandstonestairs */, + + // Block data: + // Level 0 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "aaaaaab....." + /* 1 */ "cdddddddddd." + /* 2 */ "cdddddddddd." + /* 3 */ "cdddddddddd." + /* 4 */ "cdddddddddd." + /* 5 */ "edddddddddd." + /* 6 */ ".dddddddddd." + /* 7 */ ".dddddddddd." + /* 8 */ ".dddddddddd." + /* 9 */ "............" + + // Level 1 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ ".d....ddddd." + /* 2 */ "......dfffd." + /* 3 */ "......ghfhd." + /* 4 */ "......diiid." + /* 5 */ ".d....dhfhd." + /* 6 */ ".djddjdfffd." + /* 7 */ ".ddkkddl..d." + /* 8 */ ".dddddddddd." + /* 9 */ "............" + + // Level 2 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ ".n....nn.nn." + /* 2 */ "......n...n." + /* 3 */ "......o...n." + /* 4 */ "......n....." + /* 5 */ ".n....n...n." + /* 6 */ ".n....n...n." + /* 7 */ ".n....n...n." + /* 8 */ ".nnn.nnn.nn." + /* 9 */ "............" + + // Level 3 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ ".d....ddddd." + /* 2 */ "......d...d." + /* 3 */ "......d...d." + /* 4 */ "......dp..d." + /* 5 */ ".d....d...d." + /* 6 */ ".dqqqqd...d." + /* 7 */ ".d....d...d." + /* 8 */ ".dddddddddd." + /* 9 */ "............" + + // Level 4 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "rsssssssssss" + /* 1 */ "rddddddddddt" + /* 2 */ "rddddddddddt" + /* 3 */ "rddddddddddt" + /* 4 */ "rddddddddddt" + /* 5 */ "rddddddddddt" + /* 6 */ "rddddddddddt" + /* 7 */ "rddddddddddt" + /* 8 */ "rddddddddddt" + /* 9 */ "uuuuuuuuuuut", + + // Connectors: + "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // Forge + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House11x7: + // The data has been exported from the gallery Desert, area index 31, ID 172, created by Aloe_vera + { + // Size: + 13, 5, 9, // SizeX = 13, SizeY = 5, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 12, 4, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f:171: 0\n" /* carpet */ + "g:171:15\n" /* carpet */ + "h:171:14\n" /* carpet */ + "i: 24: 2\n" /* sandstone */ + "j: 64:12\n" /* wooddoorblock */ + "k: 50: 3\n" /* torch */ + "l: 50: 1\n" /* torch */ + "m: 19: 0\n" /* sponge */ + "n: 50: 2\n" /* torch */ + "o: 50: 4\n" /* torch */ + "p:128: 4\n" /* sandstonestairs */ + "q:128: 6\n" /* sandstonestairs */ + "r:128: 5\n" /* sandstonestairs */ + "s:128: 7\n" /* sandstonestairs */, + + // Block data: + // Level 0 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "..abc........" + /* 1 */ ".ddddddddddd." + /* 2 */ ".ddddddddddd." + /* 3 */ ".ddddddddddd." + /* 4 */ ".ddddddddddd." + /* 5 */ ".ddddddddddd." + /* 6 */ ".ddddddddddd." + /* 7 */ ".ddddddddddd." + /* 8 */ "............." + + // Level 1 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ ".ddedddddddd." + /* 2 */ ".dffgggggffd." + /* 3 */ ".dfghhhhhgfd." + /* 4 */ ".dfghfffhgfd." + /* 5 */ ".dfghhhhhgfd." + /* 6 */ ".dffgggggffd." + /* 7 */ ".ddddddddddd." + /* 8 */ "............." + + // Level 2 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ ".iiji.iii.ii." + /* 2 */ ".i.........i." + /* 3 */ ".i.........i." + /* 4 */ "............." + /* 5 */ ".i.........i." + /* 6 */ ".i.........i." + /* 7 */ ".ii.ii.ii.ii." + /* 8 */ "............." + + // Level 3 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ ".ddddddddddd." + /* 2 */ ".d..k..k...d." + /* 3 */ ".d.........d." + /* 4 */ ".dl.......nd." + /* 5 */ ".d.........d." + /* 6 */ ".d....o....d." + /* 7 */ ".ddddddddddd." + /* 8 */ "............." + + // Level 4 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "pqqqqqqqqqqqq" + /* 1 */ "pdddddddddddr" + /* 2 */ "pdddddddddddr" + /* 3 */ "pdddddddddddr" + /* 4 */ "pdddddddddddr" + /* 5 */ "pdddddddddddr" + /* 6 */ "pdddddddddddr" + /* 7 */ "pdddddddddddr" + /* 8 */ "ssssssssssssr", + + // Connectors: + "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House11x7 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House5x4: + // The data has been exported from the gallery Desert, area index 25, ID 166, created by Aloe_vera + { + // Size: + 7, 5, 6, // SizeX = 7, SizeY = 5, SizeZ = 6 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 4, 5, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f:171: 0\n" /* carpet */ + "g:171:14\n" /* carpet */ + "h: 24: 2\n" /* sandstone */ + "i: 64:12\n" /* wooddoorblock */ + "j: 50: 3\n" /* torch */ + "k:128: 4\n" /* sandstonestairs */ + "l:128: 6\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */ + "n:128: 5\n" /* sandstonestairs */ + "o:128: 7\n" /* sandstonestairs */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "..abc.." + /* 1 */ ".ddddd." + /* 2 */ ".ddddd." + /* 3 */ ".ddddd." + /* 4 */ ".ddddd." + /* 5 */ "......." + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".ddedd." + /* 2 */ ".dfgfd." + /* 3 */ ".dfgfd." + /* 4 */ ".ddddd." + /* 5 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".hhihh." + /* 2 */ ".h...h." + /* 3 */ ".h...h." + /* 4 */ ".hh.hh." + /* 5 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".ddddd." + /* 2 */ ".dj.jd." + /* 3 */ ".d...d." + /* 4 */ ".ddddd." + /* 5 */ "......." + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "kllllln" + /* 1 */ "kdddddn" + /* 2 */ "kdddddn" + /* 3 */ "kdddddn" + /* 4 */ "kdddddn" + /* 5 */ "oooooon", + + // Connectors: + "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House5x4 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House5x5: + // The data has been exported from the gallery Desert, area index 26, ID 167, created by Aloe_vera + { + // Size: + 7, 5, 7, // SizeX = 7, SizeY = 5, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 4, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f:171: 0\n" /* carpet */ + "g:171:15\n" /* carpet */ + "h:171:14\n" /* carpet */ + "i: 24: 2\n" /* sandstone */ + "j: 64:12\n" /* wooddoorblock */ + "k: 50: 3\n" /* torch */ + "l:128: 4\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */ + "n:128: 6\n" /* sandstonestairs */ + "o:128: 5\n" /* sandstonestairs */ + "p:128: 7\n" /* sandstonestairs */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "..abc.." + /* 1 */ ".ddddd." + /* 2 */ ".ddddd." + /* 3 */ ".ddddd." + /* 4 */ ".ddddd." + /* 5 */ ".ddddd." + /* 6 */ "......." + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".ddedd." + /* 2 */ ".dfffd." + /* 3 */ ".dghgd." + /* 4 */ ".dfffd." + /* 5 */ ".ddddd." + /* 6 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".iijii." + /* 2 */ ".i...i." + /* 3 */ "......." + /* 4 */ ".i...i." + /* 5 */ ".ii.ii." + /* 6 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".ddddd." + /* 2 */ ".dk.kd." + /* 3 */ ".d...d." + /* 4 */ ".d...d." + /* 5 */ ".ddddd." + /* 6 */ "......." + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "lnnnnno" + /* 1 */ "ldddddo" + /* 2 */ "ldddddo" + /* 3 */ "ldddddo" + /* 4 */ "ldddddo" + /* 5 */ "ldddddo" + /* 6 */ "ppppppo", + + // Connectors: + "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House5x5 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House7x5: + // The data has been exported from the gallery Desert, area index 27, ID 168, created by Aloe_vera + { + // Size: + 9, 5, 7, // SizeX = 9, SizeY = 5, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 8, 4, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f:171:14\n" /* carpet */ + "g:171: 0\n" /* carpet */ + "h:171:15\n" /* carpet */ + "i: 24: 2\n" /* sandstone */ + "j: 64:12\n" /* wooddoorblock */ + "k: 50: 3\n" /* torch */ + "l:128: 4\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */ + "n:128: 6\n" /* sandstonestairs */ + "o:128: 5\n" /* sandstonestairs */ + "p:128: 7\n" /* sandstonestairs */, + + // Block data: + // Level 0 + /* z\x* 012345678 */ + /* 0 */ "..abc...." + /* 1 */ ".ddddddd." + /* 2 */ ".ddddddd." + /* 3 */ ".ddddddd." + /* 4 */ ".ddddddd." + /* 5 */ ".ddddddd." + /* 6 */ "........." + + // Level 1 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".ddedddd." + /* 2 */ ".dfffffd." + /* 3 */ ".dghhhgd." + /* 4 */ ".dfffffd." + /* 5 */ ".ddddddd." + /* 6 */ "........." + + // Level 2 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".iiji.ii." + /* 2 */ ".i.....i." + /* 3 */ "........." + /* 4 */ ".i.....i." + /* 5 */ ".iii.iii." + /* 6 */ "........." + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".ddddddd." + /* 2 */ ".dk.k..d." + /* 3 */ ".d.....d." + /* 4 */ ".d.....d." + /* 5 */ ".ddddddd." + /* 6 */ "........." + + // Level 4 + /* z\x* 012345678 */ + /* 0 */ "lnnnnnnnn" + /* 1 */ "ldddddddo" + /* 2 */ "ldddddddo" + /* 3 */ "ldddddddo" + /* 4 */ "ldddddddo" + /* 5 */ "ldddddddo" + /* 6 */ "ppppppppo", + + // Connectors: + "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House7x5 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House8x5: + // The data has been exported from the gallery Desert, area index 28, ID 169, created by Aloe_vera + { + // Size: + 10, 5, 7, // SizeX = 10, SizeY = 5, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 9, 4, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f:171: 0\n" /* carpet */ + "g:171:14\n" /* carpet */ + "h:171:15\n" /* carpet */ + "i: 24: 2\n" /* sandstone */ + "j: 64:12\n" /* wooddoorblock */ + "k: 50: 3\n" /* torch */ + "l:128: 4\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */ + "n:128: 6\n" /* sandstonestairs */ + "o:128: 5\n" /* sandstonestairs */ + "p:128: 7\n" /* sandstonestairs */, + + // Block data: + // Level 0 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "..abc....." + /* 1 */ ".dddddddd." + /* 2 */ ".dddddddd." + /* 3 */ ".dddddddd." + /* 4 */ ".dddddddd." + /* 5 */ ".dddddddd." + /* 6 */ ".........." + + // Level 1 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ ".ddeddddd." + /* 2 */ ".dfghhgfd." + /* 3 */ ".dfhffhfd." + /* 4 */ ".dfghhgfd." + /* 5 */ ".dddddddd." + /* 6 */ ".........." + + // Level 2 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ ".iijii.ii." + /* 2 */ ".i......i." + /* 3 */ ".........." + /* 4 */ ".i......i." + /* 5 */ ".ii.ii.ii." + /* 6 */ ".........." + + // Level 3 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ ".dddddddd." + /* 2 */ ".dk.k...d." + /* 3 */ ".d......d." + /* 4 */ ".d......d." + /* 5 */ ".dddddddd." + /* 6 */ ".........." + + // Level 4 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "lnnnnnnnnn" + /* 1 */ "lddddddddo" + /* 2 */ "lddddddddo" + /* 3 */ "lddddddddo" + /* 4 */ "lddddddddo" + /* 5 */ "lddddddddo" + /* 6 */ "pppppppppo", + + // Connectors: + "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House8x5 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House8x7: + // The data has been exported from the gallery Desert, area index 29, ID 170, created by Aloe_vera + { + // Size: + 10, 5, 9, // SizeX = 10, SizeY = 5, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 9, 4, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f:171: 0\n" /* carpet */ + "g:171:14\n" /* carpet */ + "h:171:15\n" /* carpet */ + "i: 24: 2\n" /* sandstone */ + "j: 64:12\n" /* wooddoorblock */ + "k: 50: 3\n" /* torch */ + "l: 50: 1\n" /* torch */ + "m: 19: 0\n" /* sponge */ + "n: 50: 2\n" /* torch */ + "o:128: 4\n" /* sandstonestairs */ + "p:128: 6\n" /* sandstonestairs */ + "q:128: 5\n" /* sandstonestairs */ + "r:128: 7\n" /* sandstonestairs */, + + // Block data: + // Level 0 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "..abc....." + /* 1 */ ".dddddddd." + /* 2 */ ".dddddddd." + /* 3 */ ".dddddddd." + /* 4 */ ".dddddddd." + /* 5 */ ".dddddddd." + /* 6 */ ".dddddddd." + /* 7 */ ".dddddddd." + /* 8 */ ".........." + + // Level 1 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ ".ddeddddd." + /* 2 */ ".dfghhgfd." + /* 3 */ ".dfhffhfd." + /* 4 */ ".dfhgghfd." + /* 5 */ ".dfhffhfd." + /* 6 */ ".dfghhgfd." + /* 7 */ ".dddddddd." + /* 8 */ ".........." + + // Level 2 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ ".iijii.ii." + /* 2 */ ".i......i." + /* 3 */ ".i......i." + /* 4 */ ".........." + /* 5 */ ".i......i." + /* 6 */ ".i......i." + /* 7 */ ".ii.ii.ii." + /* 8 */ ".........." + + // Level 3 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ ".dddddddd." + /* 2 */ ".d..k...d." + /* 3 */ ".d......d." + /* 4 */ ".dl....nd." + /* 5 */ ".d......d." + /* 6 */ ".d......d." + /* 7 */ ".dddddddd." + /* 8 */ ".........." + + // Level 4 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "oppppppppp" + /* 1 */ "oddddddddq" + /* 2 */ "oddddddddq" + /* 3 */ "oddddddddq" + /* 4 */ "oddddddddq" + /* 5 */ "oddddddddq" + /* 6 */ "oddddddddq" + /* 7 */ "oddddddddq" + /* 8 */ "rrrrrrrrrq", + + // Connectors: + "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House8x7 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // House9x7: + // The data has been exported from the gallery Desert, area index 30, ID 171, created by Aloe_vera + { + // Size: + 11, 5, 9, // SizeX = 11, SizeY = 5, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 4, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f:171: 0\n" /* carpet */ + "g:171:15\n" /* carpet */ + "h:171:14\n" /* carpet */ + "i: 24: 2\n" /* sandstone */ + "j: 64:12\n" /* wooddoorblock */ + "k: 50: 3\n" /* torch */ + "l: 50: 1\n" /* torch */ + "m: 19: 0\n" /* sponge */ + "n: 50: 2\n" /* torch */ + "o: 50: 4\n" /* torch */ + "p:128: 4\n" /* sandstonestairs */ + "q:128: 6\n" /* sandstonestairs */ + "r:128: 5\n" /* sandstonestairs */ + "s:128: 7\n" /* sandstonestairs */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..abc......" + /* 1 */ ".ddddddddd." + /* 2 */ ".ddddddddd." + /* 3 */ ".ddddddddd." + /* 4 */ ".ddddddddd." + /* 5 */ ".ddddddddd." + /* 6 */ ".ddddddddd." + /* 7 */ ".ddddddddd." + /* 8 */ "..........." + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".ddedddddd." + /* 2 */ ".dffgggffd." + /* 3 */ ".dfghhhgfd." + /* 4 */ ".dfghfhgfd." + /* 5 */ ".dfghhhgfd." + /* 6 */ ".dffgggffd." + /* 7 */ ".ddddddddd." + /* 8 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".iijii.iii." + /* 2 */ ".i.......i." + /* 3 */ ".i.......i." + /* 4 */ "..........." + /* 5 */ ".i.......i." + /* 6 */ ".i.......i." + /* 7 */ ".ii.iii.ii." + /* 8 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".ddddddddd." + /* 2 */ ".d..k....d." + /* 3 */ ".d.......d." + /* 4 */ ".dl.....nd." + /* 5 */ ".d.......d." + /* 6 */ ".d...o...d." + /* 7 */ ".ddddddddd." + /* 8 */ "..........." + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "pqqqqqqqqqq" + /* 1 */ "pdddddddddr" + /* 2 */ "pdddddddddr" + /* 3 */ "pdddddddddr" + /* 4 */ "pdddddddddr" + /* 5 */ "pdddddddddr" + /* 6 */ "pdddddddddr" + /* 7 */ "pdddddddddr" + /* 8 */ "ssssssssssr", + + // Connectors: + "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // House9x7 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HouseL13x12: + // The data has been exported from the gallery Desert, area index 53, ID 345, created by jakibaki + { + // Size: + 15, 5, 14, // SizeX = 15, SizeY = 5, SizeZ = 14 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 14, 4, 13, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e: 43: 1\n" /* doubleslab */ + "f: 64: 7\n" /* wooddoorblock */ + "g:171: 0\n" /* carpet */ + "h:171:15\n" /* carpet */ + "i:171:14\n" /* carpet */ + "j: 58: 0\n" /* workbench */ + "k: 24: 2\n" /* sandstone */ + "l: 64:12\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */ + "n: 50: 3\n" /* torch */ + "o: 50: 1\n" /* torch */ + "p: 50: 2\n" /* torch */ + "q: 50: 4\n" /* torch */ + "r:128: 6\n" /* sandstonestairs */ + "s:128: 5\n" /* sandstonestairs */ + "t:128: 4\n" /* sandstonestairs */ + "u:128: 7\n" /* sandstonestairs */, + + // Block data: + // Level 0 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "...abc........." + /* 1 */ ".ddddddddddddd." + /* 2 */ ".ddddddddddddd." + /* 3 */ ".ddddddddddddd." + /* 4 */ ".ddddddddddddd." + /* 5 */ ".ddddddddddded." + /* 6 */ ".ddddddddddddd." + /* 7 */ ".ddddddddddddd." + /* 8 */ ".......deddddd." + /* 9 */ "mmmmmm.ddddddd." + /* 10 */ "mmmmmm.ddddddd." + /* 11 */ "mmmmmm.ddddddd." + /* 12 */ "mmmmmm.ddddddd." + /* 13 */ "..............." + + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".dddfddddddddd." + /* 2 */ ".dgghhhhhhhhgd." + /* 3 */ ".dghiiiiiiiihd." + /* 4 */ ".dghiggggggihd." + /* 5 */ ".dghiiiiiigihd." + /* 6 */ ".dgghhhhhigihd." + /* 7 */ ".dddddddhigihd." + /* 8 */ ".......dhigihd." + /* 9 */ "mmmmmm.dhiiihd." + /* 10 */ "mmmmmm.dghhhgd." + /* 11 */ "mmmmmm.dggggjd." + /* 12 */ "mmmmmm.ddddddd." + /* 13 */ "..............." + + // Level 2 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".kkklkkkk.kkkk." + /* 2 */ ".k...........k." + /* 3 */ ".k...........k." + /* 4 */ "..............." + /* 5 */ ".k...........k." + /* 6 */ ".k...........k." + /* 7 */ ".kkk.kkk.....k." + /* 8 */ ".......k.....k." + /* 9 */ "mmmmmm.k......." + /* 10 */ "mmmmmm.......k." + /* 11 */ "mmmmmm.k.....k." + /* 12 */ "mmmmmm.kkk.kkk." + /* 13 */ "..............." + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".ddddddddddddd." + /* 2 */ ".d......n....d." + /* 3 */ ".d...........d." + /* 4 */ ".do..........d." + /* 5 */ ".d...........d." + /* 6 */ ".d..........pd." + /* 7 */ ".ddddddd.....d." + /* 8 */ ".......d.....d." + /* 9 */ "mmmmmm.d.....d." + /* 10 */ "mmmmmm.d.....d." + /* 11 */ "mmmmmm.d..q..d." + /* 12 */ "mmmmmm.ddddddd." + /* 13 */ "..............." + + // Level 4 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "rrrrrrrrrrrrrrs" + /* 1 */ "tddddddddddddds" + /* 2 */ "tddddddddddddds" + /* 3 */ "tddddddddddddds" + /* 4 */ "tddddddddddddds" + /* 5 */ "tddddddddddddds" + /* 6 */ "tddddddddddddds" + /* 7 */ "tddddddddddddds" + /* 8 */ "tuuuuutddddddds" + /* 9 */ "mmmmmmtddddddds" + /* 10 */ "mmmmmmtddddddds" + /* 11 */ "mmmmmmtddddddds" + /* 12 */ "mmmmmmtddddddds" + /* 13 */ "......tuuuuuuuu", + + // Connectors: + "-1: 4, 0, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // HouseL13x12 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MarketStall: + // The data has been exported from the gallery Desert, area index 34, ID 175, created by Aloe_vera + { + // Size: + 7, 5, 7, // SizeX = 7, SizeY = 5, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 4, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 85: 0\n" /* fence */ + "b:171:14\n" /* carpet */ + "c:171:15\n" /* carpet */ + "d:171: 0\n" /* carpet */ + "e: 35:14\n" /* wool */ + "f: 35: 0\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "a.....a" + /* 1 */ "bccdccb" + /* 2 */ "bcdddcb" + /* 3 */ "bcdddcb" + /* 4 */ "bccdccb" + /* 5 */ "a.....a" + /* 6 */ "......." + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "a.....a" + /* 1 */ "......." + /* 2 */ "......." + /* 3 */ "......." + /* 4 */ "......." + /* 5 */ "a.....a" + /* 6 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "a.....a" + /* 1 */ "......." + /* 2 */ "......." + /* 3 */ "......." + /* 4 */ "......." + /* 5 */ "a.....a" + /* 6 */ "efefefe" + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "efefefe" + /* 1 */ "......." + /* 2 */ "......." + /* 3 */ "......." + /* 4 */ "......." + /* 5 */ "efefefe" + /* 6 */ "......." + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "efefefe" + /* 2 */ "efefefe" + /* 3 */ "efefefe" + /* 4 */ "efefefe" + /* 5 */ "......." + /* 6 */ ".......", + + // Connectors: + "-1: 2, -1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // MarketStall + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Marketplace: + // The data has been exported from the gallery Desert, area index 38, ID 261, created by Aloe_vera + { + // Size: + 14, 4, 16, // SizeX = 14, SizeY = 4, SizeZ = 16 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 13, 3, 15, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 24: 0\n" /* sandstone */ + "b: 12: 0\n" /* sand */ + "c: 24: 2\n" /* sandstone */ + "d: 12: 2\n" /* sand */ + "e: 85: 0\n" /* fence */ + "f: 5: 0\n" /* wood */ + "g:128: 2\n" /* sandstonestairs */ + "h:128: 0\n" /* sandstonestairs */ + "i: 8: 0\n" /* water */ + "j:128: 1\n" /* sandstonestairs */ + "k:128: 3\n" /* sandstonestairs */ + "l: 35: 0\n" /* wool */ + "m: 19: 0\n" /* sponge */ + "n: 35:14\n" /* wool */, + + // Block data: + // Level 0 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "aaaabbbaaabbbb" + /* 1 */ "aaaabbaabbabbb" + /* 2 */ "aababbabcabbbb" + /* 3 */ "aaaaabaaaaabbb" + /* 4 */ "bbbbbbbbbbbbbb" + /* 5 */ "bbbbbbbbbbaabb" + /* 6 */ "bbbbccccbbabab" + /* 7 */ "ccbbccccbbaaab" + /* 8 */ "ccbbccccbbabbb" + /* 9 */ "dcbbccccbbabaa" + /* 10 */ "ccbbbbbbbbaaba" + /* 11 */ "ccbbbbbbbbabaa" + /* 12 */ "bbbbbbbbbbabaa" + /* 13 */ "bbbaababbbaaba" + /* 14 */ "bbbcaaaabbabbb" + /* 15 */ "bbbcccabbbabbb" + + // Level 1 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "e...e.e...e..." + /* 1 */ ".............." + /* 2 */ ".............." + /* 3 */ "fffff.fffff..." + /* 4 */ ".............." + /* 5 */ "..........f..e" + /* 6 */ "....gggg..f..." + /* 7 */ ".f..hiij..f..." + /* 8 */ ".f..hiij..f..." + /* 9 */ ".f..kkkk..f..e" + /* 10 */ ".f............" + /* 11 */ ".f........f..e" + /* 12 */ "...fffff..f..." + /* 13 */ "..........f..." + /* 14 */ "..........f..." + /* 15 */ "...e...e..f..e" + + // Level 2 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "lnlnl.lnlnl..." + /* 1 */ ".............." + /* 2 */ ".............." + /* 3 */ "e...e.e...e..." + /* 4 */ ".............." + /* 5 */ "..........e..l" + /* 6 */ ".............n" + /* 7 */ ".e...........l" + /* 8 */ ".............n" + /* 9 */ "..........e..l" + /* 10 */ ".............." + /* 11 */ ".e........e..l" + /* 12 */ "...e...e.....n" + /* 13 */ ".............l" + /* 14 */ ".............n" + /* 15 */ "...lnlnl..e..l" + + // Level 3 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ "lnlnl.lnlnl..." + /* 2 */ "lnlnl.lnlnl..." + /* 3 */ "lnlnl.lnlnl..." + /* 4 */ ".............." + /* 5 */ "..........lll." + /* 6 */ "..........nnn." + /* 7 */ "ll........lll." + /* 8 */ "nn........nnn." + /* 9 */ "ll........lll." + /* 10 */ "nn............" + /* 11 */ "ll........lll." + /* 12 */ "...lnlnl..nnn." + /* 13 */ "...lnlnl..lll." + /* 14 */ "...lnlnl..nnn." + /* 15 */ "..........lll.", + + // Connectors: + "-1: 5, 0, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // Marketplace +}; // g_SandFlatRoofVillagePrefabs + + + + + + +const cPrefab::sDef g_SandFlatRoofVillageStartingPrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Well: + // The data has been exported from the gallery Desert, area index 44, ID 275, created by Aloe_vera + { + // Size: + 5, 16, 5, // SizeX = 5, SizeY = 16, SizeZ = 5 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 4, 15, 4, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 1: 0\n" /* stone */ + "b: 24: 0\n" /* sandstone */ + "c: 8: 0\n" /* water */ + "d:128: 2\n" /* sandstonestairs */ + "e:128: 0\n" /* sandstonestairs */ + "f:128: 1\n" /* sandstonestairs */ + "g:128: 3\n" /* sandstonestairs */ + "h:128: 6\n" /* sandstonestairs */ + "i:128: 4\n" /* sandstonestairs */ + "j:128: 5\n" /* sandstonestairs */ + "k:128: 7\n" /* sandstonestairs */ + "l: 44: 1\n" /* step */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 01234 */ + /* 0 */ "aaaaa" + /* 1 */ "abbba" + /* 2 */ "abbba" + /* 3 */ "abbba" + /* 4 */ "aaaaa" + + // Level 1 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 2 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 3 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 4 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 5 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 6 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 7 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 8 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcbcb" + /* 2 */ "bbcbb" + /* 3 */ "bcbcb" + /* 4 */ "bbbbb" + + // Level 9 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcbcb" + /* 2 */ "bbbbb" + /* 3 */ "bcbcb" + /* 4 */ "bbbbb" + + // Level 10 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcbcb" + /* 2 */ "bbbbb" + /* 3 */ "bcbcb" + /* 4 */ "bbbbb" + + // Level 11 + /* z\x* 01234 */ + /* 0 */ "ddddd" + /* 1 */ "ecccf" + /* 2 */ "ecbcf" + /* 3 */ "ecccf" + /* 4 */ "ggggf" + + // Level 12 + /* z\x* 01234 */ + /* 0 */ "....." + /* 1 */ "....." + /* 2 */ "..b.." + /* 3 */ "....." + /* 4 */ "....." + + // Level 13 + /* z\x* 01234 */ + /* 0 */ "....." + /* 1 */ "....." + /* 2 */ "..b.." + /* 3 */ "....." + /* 4 */ "....." + + // Level 14 + /* z\x* 01234 */ + /* 0 */ "....." + /* 1 */ ".hhh." + /* 2 */ ".ibj." + /* 3 */ ".kkj." + /* 4 */ "....." + + // Level 15 + /* z\x* 01234 */ + /* 0 */ "lllll" + /* 1 */ "lllll" + /* 2 */ "lllll" + /* 3 */ "lllll" + /* 4 */ "lllll", + + // Connectors: + "2: 4, 11, 2: 5\n" /* Type 2, direction X+ */ + "2: 2, 11, 4: 3\n" /* Type 2, direction Z+ */ + "2: 0, 11, 2: 4\n" /* Type 2, direction X- */ + "2: 2, 11, 0: 2\n" /* Type 2, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // Well +}; + + + + + +// The prefab counts: + +const size_t g_SandFlatRoofVillagePrefabsCount = ARRAYCOUNT(g_SandFlatRoofVillagePrefabs); + +const size_t g_SandFlatRoofVillageStartingPrefabsCount = ARRAYCOUNT(g_SandFlatRoofVillageStartingPrefabs); + diff --git a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.h b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.h new file mode 100644 index 000000000..ea06de5b5 --- /dev/null +++ b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.h @@ -0,0 +1,15 @@ + +// SandFlatRoofVillagePrefabs.h + +// Declares the prefabs in the group SandFlatRoofVillage + +#include "../Prefab.h" + + + + + +extern const cPrefab::sDef g_SandFlatRoofVillagePrefabs[]; +extern const cPrefab::sDef g_SandFlatRoofVillageStartingPrefabs[]; +extern const size_t g_SandFlatRoofVillagePrefabsCount; +extern const size_t g_SandFlatRoofVillageStartingPrefabsCount; diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index 520d63029..862aa966f 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -7,6 +7,7 @@ #include "VillageGen.h" #include "Prefabs/PlainsVillagePrefabs.h" #include "Prefabs/SandVillagePrefabs.h" +#include "Prefabs/SandFlatRoofVillagePrefabs.h" #include "PieceGenerator.h" @@ -25,8 +26,8 @@ the roads and houses are then used as the following pieces. Only the houses are though, the roads are generated by code and their content is ignored. A special subclass of the cPiecePool class is used, so that the roads connect to each other and to the well only in predefined manners. -The well has connectors of type "1". The houses have connectors of type "-1". The roads have connectors of -both types, type "-1" at the far ends and type "1" on the long edges. +The well has connectors of type "2". The houses have connectors of type "-1". The roads have connectors of +both types' opposites, type "-2" at the far ends and type "1" on the long edges. When the village is about to be drawn into a chunk, it queries the heights for each piece intersecting the chunk. The pieces are shifted so that their pivot points lie on the surface, and the roads are drawn @@ -220,7 +221,10 @@ protected: // cVillageGen: /** The prefabs for the sand village. */ -static cVillagePiecePool g_SandVillage (g_SandVillagePrefabs, g_SandVillagePrefabsCount, g_SandVillageStartingPrefabs, g_SandVillageStartingPrefabsCount); +static cVillagePiecePool g_SandVillage(g_SandVillagePrefabs, g_SandVillagePrefabsCount, g_SandVillageStartingPrefabs, g_SandVillageStartingPrefabsCount); + +/** The prefabs for the flat-roofed sand village. */ +static cVillagePiecePool g_SandFlatRoofVillage(g_SandFlatRoofVillagePrefabs, g_SandFlatRoofVillagePrefabsCount, g_SandFlatRoofVillageStartingPrefabs, g_SandFlatRoofVillageStartingPrefabsCount); /** The prefabs for the plains village. */ static cVillagePiecePool g_PlainsVillage(g_PlainsVillagePrefabs, g_PlainsVillagePrefabsCount, g_PlainsVillageStartingPrefabs, g_PlainsVillageStartingPrefabsCount); @@ -254,6 +258,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ // If just one is not, no village is created, because it's likely that an unfriendly biome is too close cVillagePiecePool * VillagePrefabs = NULL; BLOCKTYPE RoadBlock = E_BLOCK_GRAVEL; + int rnd = (a_OriginX + 21 * a_OriginZ + 985) / 11; for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++) { switch (Biomes[i]) @@ -262,7 +267,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ case biDesertM: { // These biomes allow sand villages - VillagePrefabs = &g_SandVillage; + VillagePrefabs = (rnd % 2 == 0) ? &g_SandVillage : &g_SandFlatRoofVillage; RoadBlock = E_BLOCK_SANDSTONE; break; } -- cgit v1.2.3 From 85fc0dbd97bbf72ba98dfb69351d5c8fa6a8ddfd Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 21 May 2014 23:17:09 +0200 Subject: Changed desert village roads to gravel. --- src/Generating/VillageGen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index 862aa966f..a899d5837 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -268,7 +268,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ { // These biomes allow sand villages VillagePrefabs = (rnd % 2 == 0) ? &g_SandVillage : &g_SandFlatRoofVillage; - RoadBlock = E_BLOCK_SANDSTONE; + // RoadBlock = E_BLOCK_SANDSTONE; break; } case biPlains: -- cgit v1.2.3 From ebb1ef237a23ca1bd381afe0a19178e1c1af62ca Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 22 May 2014 08:57:57 +0200 Subject: Updated plains village prefabs. The DoublePlantBed had sponges in wrong places, plus a few cosmetic fixes. --- src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 87 ++++++++++++------------- 1 file changed, 43 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index 863720ab4..22aae5958 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -302,28 +302,28 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 0 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "aaaaaaamaaaaaaa" - /* 1 */ "abbcbbamabbcbba" - /* 2 */ "abbcbbamabbcbba" - /* 3 */ "abbcbbamabbcbba" - /* 4 */ "abbcbbamabbcbba" - /* 5 */ "abbcbbamabbcbba" - /* 6 */ "abbcbbamabbcbba" - /* 7 */ "abbcbbamabbcbba" - /* 8 */ "aaaaaaamaaaaaaa" + /* 0 */ "aaaaaaa.aaaaaaa" + /* 1 */ "abbcbba.abbcbba" + /* 2 */ "abbcbba.abbcbba" + /* 3 */ "abbcbba.abbcbba" + /* 4 */ "abbcbba.abbcbba" + /* 5 */ "abbcbba.abbcbba" + /* 6 */ "abbcbba.abbcbba" + /* 7 */ "abbcbba.abbcbba" + /* 8 */ "aaaaaaa.aaaaaaa" // Level 1 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "dmmmmmdmdmmmmmd" - /* 1 */ "meemeemmmeemeem" - /* 2 */ "memmmemmmeemeem" - /* 3 */ "memmmmmmmeemeem" - /* 4 */ "meemmemmmeemeem" - /* 5 */ "meemmemmmeemeem" - /* 6 */ "mmemmemmmeemeem" - /* 7 */ "mmememmmmeemeem" - /* 8 */ "dmmmmmdmdmmmmmd", + /* 0 */ "d.....d.d.....d" + /* 1 */ ".ee.ee...ee.ee." + /* 2 */ ".e...e...ee.ee." + /* 3 */ ".e.......ee.ee." + /* 4 */ ".ee..e...ee.ee." + /* 5 */ ".ee..e...ee.ee." + /* 6 */ "..e..e...ee.ee." + /* 7 */ "..e.e....ee.ee." + /* 8 */ "d.....d.d.....d", // Connectors: "-1: 7, 0, 8: 3\n" /* Type -1, direction Z+ */, @@ -779,7 +779,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 8 */ "uh...hv" /* 9 */ "uh...hv" /* 10 */ "uh...hv" - /* 11 */ "ughhhhv" + /* 11 */ "ughhhgv" /* 12 */ "uw...xv" // Level 6 @@ -901,7 +901,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 2 */ "uhDDDhv" /* 3 */ "uhDDDhv" /* 4 */ "uhDDDhv" - /* 5 */ "uhhhhhv" + /* 5 */ "ughhhgv" /* 6 */ "uw...xv" /* 7 */ "......." /* 8 */ "......." @@ -1893,16 +1893,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "k: 85: 0\n" /* fence */ "l: 53: 0\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 64: 6\n" /* wooddoorblock */ + "n: 64: 2\n" /* wooddoorblock */ "o: 64: 0\n" /* wooddoorblock */ "p:102: 0\n" /* glasspane */ "q: 72: 0\n" /* woodplate */ - "r: 64:12\n" /* wooddoorblock */ - "s: 64: 8\n" /* wooddoorblock */ - "t: 53: 5\n" /* woodstairs */ - "u: 53: 4\n" /* woodstairs */ - "v: 50: 1\n" /* torch */ - "w: 50: 2\n" /* torch */, + "r: 64: 8\n" /* wooddoorblock */ + "s: 53: 5\n" /* woodstairs */ + "t: 53: 4\n" /* woodstairs */ + "u: 50: 1\n" /* torch */ + "v: 50: 2\n" /* torch */, // Block data: // Level 0 @@ -1973,7 +1972,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 2 */ ".p.q.pmmmm" /* 3 */ ".p...p...." /* 4 */ ".d...d...." - /* 5 */ ".r...s...." + /* 5 */ ".r...r...." /* 6 */ ".d...d...." /* 7 */ ".p...p...." /* 8 */ ".p...p...." @@ -1983,22 +1982,22 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 5 /* z\x* */ /* * 0123456789 */ - /* 0 */ "lt...ujmmm" + /* 0 */ "ls...tjmmm" /* 1 */ "lidddijmmm" /* 2 */ "ld...djmmm" /* 3 */ "ld...dj..." - /* 4 */ "ldv.wdj..." + /* 4 */ "ldu.vdj..." /* 5 */ "ld...dj..." - /* 6 */ "ldv.wdj..." + /* 6 */ "ldu.vdj..." /* 7 */ "ld...dj..." /* 8 */ "ld...dj..." /* 9 */ "lidddijmmm" - /* 10 */ "lt...ujmmm" + /* 10 */ "ls...tjmmm" // Level 6 /* z\x* */ /* * 0123456789 */ - /* 0 */ "mlt.ujmmmm" + /* 0 */ "mls.tjmmmm" /* 1 */ "mldddjmmmm" /* 2 */ "mld.djmmmm" /* 3 */ "mld.djm..." @@ -2008,7 +2007,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ "mld.djm..." /* 8 */ "mld.djm..." /* 9 */ "mldddjmmmm" - /* 10 */ "mlt.ujmmmm" + /* 10 */ "mls.tjmmmm" // Level 7 /* z\x* */ @@ -3052,16 +3051,16 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 3 */ "lllllllllllll..." /* 4 */ "eeeeeeeeeeeen..." /* 5 */ "qqqqqqqqqqren..." - /* 6 */ "mmmmmmmmmmren..." - /* 7 */ "mmmmmmmmmmren..." - /* 8 */ "mmmmmmmmmmren..." - /* 9 */ "mmmmmmmmmmren..." - /* 10 */ "mmmmmmmmmmren..." - /* 11 */ "mmmmmmmmmmren..." - /* 12 */ "mmmmmmmmmmren..." - /* 13 */ "mmmmmmmmmmren..." - /* 14 */ "mmmmmmmmmmren..." - /* 15 */ "mmmmmmmmmmren...", + /* 6 */ "..........ren..." + /* 7 */ "..........ren..." + /* 8 */ "mmmmmmmm..ren..." + /* 9 */ "mmmmmmmm..ren..." + /* 10 */ "mmmmmmmm..ren..." + /* 11 */ "mmmmmmmm..ren..." + /* 12 */ "mmmmmmmm..ren..." + /* 13 */ "mmmmmmmm..ren..." + /* 14 */ "mmmmmmmm..ren..." + /* 15 */ "mmmmmmmm..ren...", // Connectors: "-1: 9, 0, 0: 2\n" /* Type -1, direction Z- */, -- cgit v1.2.3 From 5ef6c8fe72f96dec20e2305ba190759c17512861 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 22 May 2014 10:54:07 +0200 Subject: Both SetSpeed functions are now overridden by cPlayer --- src/Entities/Entity.h | 13 ++++++++----- src/Entities/Player.cpp | 20 ++++++++++++++++++++ src/Entities/Player.h | 5 ++++- 3 files changed, 32 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 0c393c0f5..0ea27ef10 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -214,8 +214,14 @@ public: void SetYaw (double a_Yaw); // In degrees, normalizes to [-180, +180) void SetPitch (double a_Pitch); // In degrees, normalizes to [-180, +180) void SetRoll (double a_Roll); // In degrees, normalizes to [-180, +180) - void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ); - void SetSpeed (const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); } + // tolua_end + + /** Measured in meter/second (m/s) */ + Vector3d m_Speed; + + // tolua_begin + virtual void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ); + virtual void SetSpeed (const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); } void SetSpeedX (double a_SpeedX); void SetSpeedY (double a_SpeedY); void SetSpeedZ (double a_SpeedZ); @@ -504,9 +510,6 @@ private: /** Measured in degrees, [-180, +180) */ double m_HeadYaw; - /** Measured in meter/second (m/s) */ - Vector3d m_Speed; - /** Measured in degrees, [-180, +180) */ Vector3d m_Rot; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index c3b763278..48320b6c9 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1252,6 +1252,26 @@ void cPlayer::ForceSetSpeed(const Vector3d & a_Speed) +void cPlayer::SetSpeed(const Vector3d & a_Speed) +{ + m_Speed.Set(a_Speed.x, a_Speed.y, a_Speed.z); + m_ClientHandle->SendEntityVelocity(*this); +} + + + + + +void cPlayer::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) +{ + m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ); + m_ClientHandle->SendEntityVelocity(*this); +} + + + + + void cPlayer::MoveTo( const Vector3d & a_NewPos ) { if ((a_NewPos.y < -990) && (GetPosY() > -100)) diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 78b534d83..43f27e045 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -191,9 +191,12 @@ public: // Sets the current gamemode, doesn't check validity, doesn't send update packets to client void LoginSetGameMode(eGameMode a_GameMode); - /** Forces the player to move in the given direction. */ + /** Forces the player to move in the given direction. DEPRECATED! Use SetSpeed instead */ void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export + virtual void SetSpeed(const Vector3d & a_Speed) override; + virtual void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override + /** Tries to move to a new position, with attachment-related checks (y == -999) */ void MoveTo(const Vector3d & a_NewPos); // tolua_export -- cgit v1.2.3 From 73455d293861c492388f3a28af3380318eaa0bae Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 22 May 2014 11:08:44 +0200 Subject: cPlayer overrides the SetSpeedXX functions Fixed compile error --- src/Entities/Entity.h | 6 +++--- src/Entities/Player.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/Entities/Player.h | 6 +++++- 3 files changed, 53 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 0ea27ef10..fc72462c3 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -222,9 +222,9 @@ public: // tolua_begin virtual void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ); virtual void SetSpeed (const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); } - void SetSpeedX (double a_SpeedX); - void SetSpeedY (double a_SpeedY); - void SetSpeedZ (double a_SpeedZ); + virtual void SetSpeedX (double a_SpeedX); + virtual void SetSpeedY (double a_SpeedY); + virtual void SetSpeedZ (double a_SpeedZ); void SetWidth (double a_Width); void AddPosX (double a_AddPosX); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 48320b6c9..0d79ff533 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1255,6 +1255,9 @@ void cPlayer::ForceSetSpeed(const Vector3d & a_Speed) void cPlayer::SetSpeed(const Vector3d & a_Speed) { m_Speed.Set(a_Speed.x, a_Speed.y, a_Speed.z); + WrapSpeed(); + + // Send the speed to the client so he actualy moves m_ClientHandle->SendEntityVelocity(*this); } @@ -1265,6 +1268,48 @@ void cPlayer::SetSpeed(const Vector3d & a_Speed) void cPlayer::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) { m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ); + WrapSpeed(); + + // Send the speed to the client so he actualy moves + m_ClientHandle->SendEntityVelocity(*this); +} + + + + + +void cPlayer::SetSpeedX(double a_SpeedX) +{ + m_Speed.x = a_SpeedX; + WrapSpeed(); + + // Send the speed to the client so he actualy moves + m_ClientHandle->SendEntityVelocity(*this); +} + + + + + +void cPlayer::SetSpeedY(double a_SpeedY) +{ + m_Speed.y = a_SpeedY; + WrapSpeed(); + + // Send the speed to the client so he actualy moves + m_ClientHandle->SendEntityVelocity(*this); +} + + + + + +void cPlayer::SetSpeedZ(double a_SpeedZ) +{ + m_Speed.z = a_SpeedZ; + WrapSpeed(); + + // Send the speed to the client so he actualy moves m_ClientHandle->SendEntityVelocity(*this); } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 43f27e045..fb6bdc3ee 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -195,7 +195,11 @@ public: void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export virtual void SetSpeed(const Vector3d & a_Speed) override; - virtual void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override + virtual void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override; + + virtual void SetSpeedX(double a_SpeedX) override; + virtual void SetSpeedY(double a_SpeedY) override; + virtual void SetSpeedZ(double a_SpeedZ) override; /** Tries to move to a new position, with attachment-related checks (y == -999) */ void MoveTo(const Vector3d & a_NewPos); // tolua_export -- cgit v1.2.3 From 592a0b6147f359fd9d12a28c9c43c208d84b5b3f Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 22 May 2014 11:46:38 +0200 Subject: cEntity::SetSpeed(a_Vector3d) isn't virtualized anymore --- src/Entities/Entity.h | 2 +- src/Entities/Player.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index fc72462c3..ed67465a3 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -221,7 +221,7 @@ public: // tolua_begin virtual void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ); - virtual void SetSpeed (const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); } + void SetSpeed (const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); } virtual void SetSpeedX (double a_SpeedX); virtual void SetSpeedY (double a_SpeedY); virtual void SetSpeedZ (double a_SpeedZ); diff --git a/src/Entities/Player.h b/src/Entities/Player.h index fb6bdc3ee..ee91beb4b 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -194,7 +194,7 @@ public: /** Forces the player to move in the given direction. DEPRECATED! Use SetSpeed instead */ void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export - virtual void SetSpeed(const Vector3d & a_Speed) override; + void SetSpeed(const Vector3d & a_Speed); virtual void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override; virtual void SetSpeedX(double a_SpeedX) override; -- cgit v1.2.3 From 5e90976cd972e044248f71238d3e6b0672701870 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 22 May 2014 17:10:35 +0200 Subject: Added doxy-comments --- src/Entities/Player.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index ee91beb4b..0f4773893 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -194,12 +194,14 @@ public: /** Forces the player to move in the given direction. DEPRECATED! Use SetSpeed instead */ void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export - void SetSpeed(const Vector3d & a_Speed); - virtual void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override; - - virtual void SetSpeedX(double a_SpeedX) override; - virtual void SetSpeedY(double a_SpeedY) override; - virtual void SetSpeedZ(double a_SpeedZ) override; + /** Sets the speed of the player and moves them in the given speed. */ + void SetSpeed (const Vector3d & a_Speed); + virtual void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ) override; + + /** Sets the speed for the X, Y or Z axis */ + virtual void SetSpeedX (double a_SpeedX) override; + virtual void SetSpeedY (double a_SpeedY) override; + virtual void SetSpeedZ (double a_SpeedZ) override; /** Tries to move to a new position, with attachment-related checks (y == -999) */ void MoveTo(const Vector3d & a_NewPos); // tolua_export -- cgit v1.2.3 From 6aa7df367f8db7506a8a5ab853c26e3c9fd60253 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 22 May 2014 21:47:56 +0200 Subject: Villages have min and max density setting. Also made roads use 3+9 scheme, instead of 3+5, for the house connectors. Fixes #1020. --- src/Generating/ComposableGenerator.cpp | 10 ++-- src/Generating/PieceGenerator.cpp | 9 ++++ src/Generating/PieceGenerator.h | 5 ++ src/Generating/VillageGen.cpp | 92 +++++++++++++++++++++++++++++----- src/Generating/VillageGen.h | 11 +++- 5 files changed, 110 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index f264599c9..4dd626ed4 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -408,10 +408,12 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "Villages") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "VillageGridSize", 384); - int MaxDepth = a_IniFile.GetValueSetI("Generator", "VillageMaxDepth", 3); - int MaxSize = a_IniFile.GetValueSetI("Generator", "VillageMaxSize", 128); - m_FinishGens.push_back(new cVillageGen(Seed, GridSize, MaxDepth, MaxSize, *m_BiomeGen, *m_HeightGen)); + int GridSize = a_IniFile.GetValueSetI("Generator", "VillageGridSize", 384); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "VillageMaxDepth", 2); + int MaxSize = a_IniFile.GetValueSetI("Generator", "VillageMaxSize", 128); + int MinDensity = a_IniFile.GetValueSetI("Generator", "VillageMinDensity", 50); + int MaxDensity = a_IniFile.GetValueSetI("Generator", "VillageMaxDensity", 80); + m_FinishGens.push_back(new cVillageGen(Seed, GridSize, MaxDepth, MaxSize, MinDensity, MaxDensity, *m_BiomeGen, *m_HeightGen)); } else if (NoCaseCompare(*itr, "WaterLakes") == 0) { diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index c12559d3f..7d478f1a1 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -308,6 +308,15 @@ cPiece::cConnector cPlacedPiece::GetRotatedConnector(size_t a_Index) const +cPiece::cConnector cPlacedPiece::GetRotatedConnector(const cPiece::cConnector & a_Connector) const +{ + return m_Piece->RotateMoveConnector(a_Connector, m_NumCCWRotations, m_Coords.x, m_Coords.y, m_Coords.z); +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cPieceGenerator: diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index 643ca58b6..e396643a9 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -110,6 +110,7 @@ public: virtual cPieces GetStartingPieces(void) = 0; /** Returns the relative weight with which the a_NewPiece is to be selected for placing under a_PlacedPiece through a_ExistingConnector. + a_ExistingConnector is the original connector, before any movement or rotation is applied to it. This allows the pool to tweak the piece's chances, based on the previous pieces in the tree and the connector used. The higher the number returned, the higher the chance the piece will be chosen. 0 means the piece will never be chosen. */ @@ -151,6 +152,10 @@ public: Undefined behavior if a_Index is out of range. */ cPiece::cConnector GetRotatedConnector(size_t a_Index) const; + /** Returns a copy of the specified connector, modified to account for the translation and rotation for + this placement. */ + cPiece::cConnector GetRotatedConnector(const cPiece::cConnector & a_Connector) const; + protected: const cPlacedPiece * m_Parent; const cPiece * m_Piece; diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index a899d5837..bcce62af5 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -27,11 +27,16 @@ though, the roads are generated by code and their content is ignored. A special class is used, so that the roads connect to each other and to the well only in predefined manners. The well has connectors of type "2". The houses have connectors of type "-1". The roads have connectors of -both types' opposites, type "-2" at the far ends and type "1" on the long edges. +both types' opposites, type "-2" at the far ends and type "1" on the long edges. Additionally, there are +type "2" connectors along the long edges of the roads as well, so that the roads create T junctions. When the village is about to be drawn into a chunk, it queries the heights for each piece intersecting the chunk. The pieces are shifted so that their pivot points lie on the surface, and the roads are drawn directly by turning the surface blocks into gravel / sandstone. + +The village prefabs are stored in global piecepools (one pool per village type). In order to support +per-village density setting, the cVillage class itself implements the cPiecePool interface, relaying the +calls to the underlying cVillagePiecePool, after processing the density check. */ class cVillagePiecePool : @@ -46,7 +51,7 @@ public: super(a_PieceDefs, a_NumPieceDefs, a_StartingPieceDefs, a_NumStartingPieceDefs) { // Add the road pieces: - for (int len = 19; len < 60; len += 8) + for (int len = 27; len < 60; len += 12) { cBlockArea BA; BA.Create(len, 1, 3, cBlockArea::baTypes | cBlockArea::baMetas); @@ -56,14 +61,14 @@ public: RoadPiece->AddConnector(len - 1, 0, 1, BLOCK_FACE_XP, -2); // Add the road connectors: - for (int x = 1; x < len; x += 8) + for (int x = 1; x < len; x += 12) { RoadPiece->AddConnector(x, 0, 0, BLOCK_FACE_ZM, 2); RoadPiece->AddConnector(x, 0, 2, BLOCK_FACE_ZP, 2); } // Add the buildings connectors: - for (int x = 5; x < len; x += 8) + for (int x = 7; x < len; x += 12) { RoadPiece->AddConnector(x, 0, 0, BLOCK_FACE_ZM, 1); RoadPiece->AddConnector(x, 0, 2, BLOCK_FACE_ZP, 1); @@ -94,7 +99,8 @@ public: class cVillageGen::cVillage : - public cGridStructGen::cStructure + public cGridStructGen::cStructure, + protected cPiecePool { typedef cGridStructGen::cStructure super; @@ -104,7 +110,8 @@ public: int a_OriginX, int a_OriginZ, int a_MaxRoadDepth, int a_MaxSize, - cPrefabPiecePool & a_Prefabs, + int a_Density, + cPiecePool & a_Prefabs, cTerrainHeightGen & a_HeightGen, BLOCKTYPE a_RoadBlock ) : @@ -112,12 +119,13 @@ public: m_Seed(a_Seed), m_Noise(a_Seed), m_MaxSize(a_MaxSize), + m_Density(a_Density), m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, 255, a_OriginZ + a_MaxSize), m_Prefabs(a_Prefabs), m_HeightGen(a_HeightGen), m_RoadBlock(a_RoadBlock) { - cBFSPieceGenerator pg(m_Prefabs, a_Seed); + cBFSPieceGenerator pg(*this, a_Seed); // Generate the pieces at very negative Y coords, so that we can later test // Piece has negative Y coord -> hasn't been height-adjusted yet pg.PlacePieces(a_OriginX, -1000, a_OriginZ, a_MaxRoadDepth + 1, m_Pieces); @@ -133,11 +141,14 @@ protected: /** Maximum size, in X/Z blocks, of the village (radius from the origin) */ int m_MaxSize; + /** The density for this village. Used to refrain from populating all house connectors. Range [0, 100] */ + int m_Density; + /** Borders of the vilalge - no item may reach out of this cuboid. */ cCuboid m_Borders; /** Prefabs to use for buildings */ - cPrefabPiecePool & m_Prefabs; + cPiecePool & m_Prefabs; /** The underlying height generator, used for placing the structures on top of the terrain. */ cTerrainHeightGen & m_HeightGen; @@ -149,7 +160,7 @@ protected: BLOCKTYPE m_RoadBlock; - // cGrdStructGen::cStructure overrides: + // cGridStructGen::cStructure overrides: virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override { // Iterate over all items @@ -211,6 +222,49 @@ protected: } } } + + + // cPiecePool overrides: + virtual cPieces GetPiecesWithConnector(int a_ConnectorType) + { + return m_Prefabs.GetPiecesWithConnector(a_ConnectorType); + } + + virtual cPieces GetStartingPieces(void) + { + return m_Prefabs.GetStartingPieces(); + } + + virtual int GetPieceWeight( + const cPlacedPiece & a_PlacedPiece, + const cPiece::cConnector & a_ExistingConnector, + const cPiece & a_NewPiece + ) override + { + // Check against the density: + if (a_ExistingConnector.m_Type == 1) + { + const Vector3i & Coords = a_PlacedPiece.GetRotatedConnector(a_ExistingConnector).m_Pos; + int rnd = (m_Noise.IntNoise3DInt(Coords.x, Coords.y, Coords.z) / 7) % 100; + if (rnd > m_Density) + { + return 0; + } + } + + // Density check passed, relay to m_Prefabs: + return m_Prefabs.GetPieceWeight(a_PlacedPiece, a_ExistingConnector, a_NewPiece); + } + + virtual void PiecePlaced(const cPiece & a_Piece) override + { + m_Prefabs.PiecePlaced(a_Piece); + } + + virtual void Reset(void) override + { + m_Prefabs.Reset(); + } } ; @@ -233,10 +287,13 @@ static cVillagePiecePool g_PlainsVillage(g_PlainsVillagePrefabs, g_PlainsVillage -cVillageGen::cVillageGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen) : +cVillageGen::cVillageGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, int a_MinDensity, int a_MaxDensity, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen) : super(a_Seed, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 100), + m_Noise(a_Seed + 1000), m_MaxDepth(a_MaxDepth), m_MaxSize(a_MaxSize), + m_MinDensity(a_MinDensity), + m_MaxDensity(a_MaxDensity), m_BiomeGen(a_BiomeGen), m_HeightGen(a_HeightGen) { @@ -258,7 +315,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ // If just one is not, no village is created, because it's likely that an unfriendly biome is too close cVillagePiecePool * VillagePrefabs = NULL; BLOCKTYPE RoadBlock = E_BLOCK_GRAVEL; - int rnd = (a_OriginX + 21 * a_OriginZ + 985) / 11; + int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 11; for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++) { switch (Biomes[i]) @@ -288,12 +345,23 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ } // switch (Biomes[i]) } // for i - Biomes[] + // Choose density for the village, random between m_MinDensity and m_MaxDensity: + int Density; + if (m_MaxDensity > m_MinDensity) + { + Density = m_MinDensity + rnd % (m_MaxDensity - m_MinDensity); + } + else + { + Density = m_MinDensity; + } + // Create a village based on the chosen prefabs: if (VillagePrefabs == NULL) { return cStructurePtr(); } - return cStructurePtr(new cVillage(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, *VillagePrefabs, m_HeightGen, RoadBlock)); + return cStructurePtr(new cVillage(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, Density, *VillagePrefabs, m_HeightGen, RoadBlock)); } diff --git a/src/Generating/VillageGen.h b/src/Generating/VillageGen.h index c6f8f024a..5faaae8a6 100644 --- a/src/Generating/VillageGen.h +++ b/src/Generating/VillageGen.h @@ -21,16 +21,25 @@ class cVillageGen : { typedef cGridStructGen super; public: - cVillageGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen); + cVillageGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, int a_MinDensity, int a_MaxDensity, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen); protected: class cVillage; // fwd: VillageGen.cpp + /** The noise used for generating random numbers */ + cNoise m_Noise; + /** Maximum depth of the generator tree*/ int m_MaxDepth; /** Maximum size, in X/Z blocks, of the village (radius from the origin) */ int m_MaxSize; + + /** Minimum density - percentage of allowed house connections. Range [0, 100] */ + int m_MinDensity; + + /** Maximum density - percentage of allowed house connections. Range [0, 100] */ + int m_MaxDensity; /** The underlying biome generator that defines whether the village is created or not */ cBiomeGen & m_BiomeGen; -- cgit v1.2.3 From da843a18811546ca51600a0f3e4438ae4ac5dee8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 22 May 2014 22:19:44 +0200 Subject: Updated plains village prefabs. Expanded the hitboxes so that houses don't touch each other. Fixed minor visual defects. --- src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 357 ++++++++++++------------ 1 file changed, 171 insertions(+), 186 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index 22aae5958..28488be14 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -135,8 +135,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 12, 8, 7, // SizeX = 12, SizeY = 8, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 11, 7, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 12, 7, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -357,8 +357,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 12, 10, 11, // SizeX = 12, SizeY = 10, SizeZ = 11 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 11, 9, 10, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 12, 9, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -649,8 +649,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 7, 16, 13, // SizeX = 7, SizeY = 16, SizeZ = 13 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 6, 15, 12, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 7, 15, 13, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -974,8 +974,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 7, 8, 9, // SizeX = 7, SizeY = 8, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 6, 7, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 7, 7, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1127,8 +1127,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 12, 9, 9, // SizeX = 12, SizeY = 9, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 11, 8, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 12, 8, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1308,8 +1308,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 7, 8, 7, // SizeX = 7, SizeY = 8, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 6, 7, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 7, 7, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1444,8 +1444,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 9, 8, 7, // SizeX = 9, SizeY = 8, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 8, 7, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 9, 7, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1580,8 +1580,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 11, 8, 7, // SizeX = 11, SizeY = 8, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 10, 7, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 11, 7, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1724,8 +1724,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 11, 8, 7, // SizeX = 11, SizeY = 8, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 10, 7, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 11, 7, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1872,18 +1872,18 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 9, ID 26, created by Aloe_vera { // Size: - 10, 8, 11, // SizeX = 10, SizeY = 8, SizeZ = 11 + 10, 7, 11, // SizeX = 10, SizeY = 7, SizeZ = 11 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 9, 7, 10, // MaxX, MaxY, MaxZ + 0, -1, -1, // MinX, MinY, MinZ + 10, 6, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 4: 0\n" /* cobblestone */ - "d: 5: 0\n" /* wood */ + "a: 4: 0\n" /* cobblestone */ + "b: 3: 0\n" /* dirt */ + "c: 5: 0\n" /* wood */ + "d: 2: 0\n" /* grass */ "e: 67: 2\n" /* stairs */ "f: 43: 0\n" /* doubleslab */ "g: 67: 0\n" /* stairs */ @@ -1907,125 +1907,110 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 0 /* z\x* */ /* * 0123456789 */ - /* 0 */ "aaaaaaaaaa" - /* 1 */ "aaaaaaaaaa" - /* 2 */ "aaaaaaaaaa" - /* 3 */ "aaaaaaaaaa" - /* 4 */ "aaaaaaaaaa" - /* 5 */ "aaaaaaaaaa" - /* 6 */ "aaaaaaaaaa" - /* 7 */ "aaaaaaaaaa" - /* 8 */ "aaaaaaaaaa" - /* 9 */ "aaaaaaaaaa" - /* 10 */ "aaaaaaaaaa" + /* 0 */ "mmmmmmmmmm" + /* 1 */ "maaaaammmm" + /* 2 */ "maaaaammmm" + /* 3 */ "maaaaabbbb" + /* 4 */ "aaaaaabbbb" + /* 5 */ "aaaaaabbbb" + /* 6 */ "aaaaaabbbb" + /* 7 */ "maaaaabbbb" + /* 8 */ "maaaaabbbb" + /* 9 */ "maaaaammmm" + /* 10 */ "mmmmmmmmmm" // Level 1 /* z\x* */ /* * 0123456789 */ - /* 0 */ "bbbbbbbbbb" - /* 1 */ "baaaaabbbb" - /* 2 */ "baaaaabbbb" - /* 3 */ "baaaaaaaaa" - /* 4 */ "aaaaaaaaaa" - /* 5 */ "aaaaaaaaaa" - /* 6 */ "aaaaaaaaaa" - /* 7 */ "baaaaaaaaa" - /* 8 */ "baaaaaaaaa" - /* 9 */ "baaaaabbbb" - /* 10 */ "bbbbbbbbbb" - - // Level 2 - /* z\x* */ - /* * 0123456789 */ /* 0 */ "......mmmm" - /* 1 */ ".cccccmmmm" - /* 2 */ ".cdddcmmmm" - /* 3 */ ".cdddcbbbb" - /* 4 */ "ecfffcbbbb" - /* 5 */ "gcffffbbbb" - /* 6 */ "hcfffcbbbb" - /* 7 */ ".cfffcbbbb" - /* 8 */ ".cfffcbbbb" - /* 9 */ ".cccccmmmm" + /* 1 */ ".aaaaammmm" + /* 2 */ ".acccammmm" + /* 3 */ ".acccadddd" + /* 4 */ "eafffadddd" + /* 5 */ "gaffffdddd" + /* 6 */ "hafffadddd" + /* 7 */ ".afffadddd" + /* 8 */ ".afffadddd" + /* 9 */ ".aaaaammmm" /* 10 */ "......mmmm" - // Level 3 + // Level 2 /* z\x* */ /* * 0123456789 */ /* 0 */ "......mmmm" - /* 1 */ ".idddimmmm" - /* 2 */ ".djkldmmmm" - /* 3 */ ".d...dkkkk" - /* 4 */ ".d...d...k" + /* 1 */ ".icccimmmm" + /* 2 */ ".cjklcmmmm" + /* 3 */ ".c...ckkkk" + /* 4 */ ".c...c...k" /* 5 */ ".n...o...k" - /* 6 */ ".d...d...k" - /* 7 */ ".dff.d...k" - /* 8 */ ".d...dkkkk" - /* 9 */ ".idddimmmm" + /* 6 */ ".c...c...k" + /* 7 */ ".cff.c...k" + /* 8 */ ".c...ckkkk" + /* 9 */ ".icccimmmm" /* 10 */ "......mmmm" - // Level 4 + // Level 3 /* z\x* */ /* * 0123456789 */ /* 0 */ "......mmmm" /* 1 */ ".ipppimmmm" /* 2 */ ".p.q.pmmmm" /* 3 */ ".p...p...." - /* 4 */ ".d...d...." + /* 4 */ ".c...c...." /* 5 */ ".r...r...." - /* 6 */ ".d...d...." + /* 6 */ ".c...c...." /* 7 */ ".p...p...." /* 8 */ ".p...p...." /* 9 */ ".ipppimmmm" /* 10 */ "......mmmm" - // Level 5 + // Level 4 /* z\x* */ /* * 0123456789 */ /* 0 */ "ls...tjmmm" - /* 1 */ "lidddijmmm" - /* 2 */ "ld...djmmm" - /* 3 */ "ld...dj..." - /* 4 */ "ldu.vdj..." - /* 5 */ "ld...dj..." - /* 6 */ "ldu.vdj..." - /* 7 */ "ld...dj..." - /* 8 */ "ld...dj..." - /* 9 */ "lidddijmmm" + /* 1 */ "licccijmmm" + /* 2 */ "lc...cjmmm" + /* 3 */ "lc...cj..." + /* 4 */ "lcu.vcj..." + /* 5 */ "lc...cj..." + /* 6 */ "lcu.vcj..." + /* 7 */ "lc...cj..." + /* 8 */ "lc...cj..." + /* 9 */ "licccijmmm" /* 10 */ "ls...tjmmm" - // Level 6 + // Level 5 /* z\x* */ /* * 0123456789 */ /* 0 */ "mls.tjmmmm" - /* 1 */ "mldddjmmmm" - /* 2 */ "mld.djmmmm" - /* 3 */ "mld.djm..." - /* 4 */ "mld.djm..." - /* 5 */ "mld.djm..." - /* 6 */ "mld.djm..." - /* 7 */ "mld.djm..." - /* 8 */ "mld.djm..." - /* 9 */ "mldddjmmmm" + /* 1 */ "mlcccjmmmm" + /* 2 */ "mlc.cjmmmm" + /* 3 */ "mlc.cjm..." + /* 4 */ "mlc.cjm..." + /* 5 */ "mlc.cjm..." + /* 6 */ "mlc.cjm..." + /* 7 */ "mlc.cjm..." + /* 8 */ "mlc.cjm..." + /* 9 */ "mlcccjmmmm" /* 10 */ "mls.tjmmmm" - // Level 7 + // Level 6 /* z\x* */ /* * 0123456789 */ - /* 0 */ "mmldjmmmmm" - /* 1 */ "mmldjmmmmm" - /* 2 */ "mmldjmmmmm" - /* 3 */ "mmldjmm..." - /* 4 */ "mmldjmm..." - /* 5 */ "mmldjmm..." - /* 6 */ "mmldjmm..." - /* 7 */ "mmldjmm..." - /* 8 */ "mmldjmm..." - /* 9 */ "mmldjmmmmm" - /* 10 */ "mmldjmmmmm", + /* 0 */ "mmlcjmmmmm" + /* 1 */ "mmlcjmmmmm" + /* 2 */ "mmlcjmmmmm" + /* 3 */ "mmlcjmm..." + /* 4 */ "mmlcjmm..." + /* 5 */ "mmlcjmm..." + /* 6 */ "mmlcjmm..." + /* 7 */ "mmlcjmm..." + /* 8 */ "mmlcjmm..." + /* 9 */ "mmlcjmmmmm" + /* 10 */ "mmlcjmmmmm", // Connectors: - "-1: 0, 2, 5: 4\n" /* Type -1, direction X- */, + "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2056,8 +2041,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 11, 9, 9, // SizeX = 11, SizeY = 9, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 10, 8, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 11, 8, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -2230,17 +2215,17 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 11, 9, 13, // SizeX = 11, SizeY = 9, SizeZ = 13 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 10, 8, 12, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 11, 8, 13, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ "a: 3: 0\n" /* dirt */ "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ + "c: 4: 0\n" /* cobblestone */ + "d: 67: 0\n" /* stairs */ + "e: 67: 2\n" /* stairs */ + "f: 67: 1\n" /* stairs */ "g: 43: 0\n" /* doubleslab */ "h: 17: 0\n" /* tree */ "i: 5: 0\n" /* wood */ @@ -2262,52 +2247,52 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "aaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaa" - /* 2 */ "aaaaaaaaaaa" - /* 3 */ "aaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaa" + /* 1 */ "aaaaaaaaaab" + /* 2 */ "aaaaaaaaaab" + /* 3 */ "aaaaaaaaaab" + /* 4 */ "aaaaaaaaaab" /* 5 */ "aaaaaaaaaaa" - /* 6 */ "aaaaaaaaaaa" - /* 7 */ "aaaaaaaaaaa" - /* 8 */ "aaaaaaaaaaa" - /* 9 */ "aaaaaaaaaaa" - /* 10 */ "aaaaaaaaaaa" - /* 11 */ "aaaaaaaaaaa" - /* 12 */ "aaaaaaaaaaa" + /* 6 */ "aaaaaaaaaab" + /* 7 */ "aaaaaaaaaab" + /* 8 */ "abaaaaaaabb" + /* 9 */ "aaaaaaaaabb" + /* 10 */ "aaaaaaaaabb" + /* 11 */ "abaaaaaaaba" + /* 12 */ "abaaaaaaabb" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "bbbbaaabbbb" - /* 1 */ "baaaaaaaaab" - /* 2 */ "baaaaaaaaab" - /* 3 */ "baaaaaaaaab" - /* 4 */ "baaaaaaaaab" - /* 5 */ "baaaaaaaaab" - /* 6 */ "baaaaaaaaab" - /* 7 */ "baaaaaaaaab" - /* 8 */ "bbaaaaaaabb" - /* 9 */ "bbaaaaaaabb" - /* 10 */ "bbaaaaaaabb" - /* 11 */ "bbaaaaaaabb" - /* 12 */ "bbaaaaaaabb" + /* 0 */ "mmmmcccmmmm" + /* 1 */ "mcccccccccm" + /* 2 */ "mcccccccccm" + /* 3 */ "mcccccccccm" + /* 4 */ "mcccccccccm" + /* 5 */ "mcccccccccm" + /* 6 */ "mcccccccccm" + /* 7 */ "mcccccccccm" + /* 8 */ "mmaaaaaaamm" + /* 9 */ "mmaaaaaaamm" + /* 10 */ "mmaaaaaaamm" + /* 11 */ "mmaaaaaaamm" + /* 12 */ "mmaaaaaaamm" // Level 2 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "....cde...." - /* 1 */ ".fffffffff." - /* 2 */ ".fggggffff." - /* 3 */ ".fggggffff." - /* 4 */ ".fggggffff." - /* 5 */ ".fggggffff." - /* 6 */ ".fggggffff." - /* 7 */ ".fffffffff." + /* 0 */ "....def...." + /* 1 */ ".ccccccccc." + /* 2 */ ".cggggcccc." + /* 3 */ ".cggggcccc." + /* 4 */ ".cggggcccc." + /* 5 */ ".cggggcccc." + /* 6 */ ".cggggcccc." + /* 7 */ ".ccccccccc." /* 8 */ "..bbbbbbb.." - /* 9 */ "mmbbbbbbbmm" - /* 10 */ "mmbbbbbbbmm" - /* 11 */ "mmbbbbbbbmm" - /* 12 */ "mmbbbbbbbmm" + /* 9 */ "..bbbbbbb.." + /* 10 */ "..bbbbbbb.." + /* 11 */ "..bbbbbbb.." + /* 12 */ "..bbbbbbb.." // Level 3 /* z\x* 1 */ @@ -2321,10 +2306,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ ".i.......i." /* 7 */ ".hiiijiiih." /* 8 */ "..l.....l.." - /* 9 */ "mml.....lmm" - /* 10 */ "mml.....lmm" - /* 11 */ "mml.....lmm" - /* 12 */ "mmlllllllmm" + /* 9 */ "..l.....l.." + /* 10 */ "..l.....l.." + /* 11 */ "..l.....l.." + /* 12 */ "..lllllll.." // Level 4 /* z\x* 1 */ @@ -2338,10 +2323,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ ".o.......o." /* 7 */ ".hooipiooh." /* 8 */ "..........." - /* 9 */ "mm.......mm" - /* 10 */ "mm.......mm" - /* 11 */ "mm.......mm" - /* 12 */ "mm.......mm" + /* 9 */ "..........." + /* 10 */ "..........." + /* 11 */ "..........." + /* 12 */ "..........." // Level 5 /* z\x* 1 */ @@ -2355,10 +2340,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ ".i.......i." /* 7 */ "uiiiiiiiiiu" /* 8 */ "kkkkkkkkkkk" - /* 9 */ "mm.......mm" - /* 10 */ "mm.......mm" - /* 11 */ "mm.......mm" - /* 12 */ "mm.......mm" + /* 9 */ "..........." + /* 10 */ "..........." + /* 11 */ "..........." + /* 12 */ "..........." // Level 6 /* z\x* 1 */ @@ -2372,10 +2357,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ "uiiiiiiiiiu" /* 7 */ "kkkkkkkkkkk" /* 8 */ "..........." - /* 9 */ "mm.......mm" - /* 10 */ "mm.......mm" - /* 11 */ "mm.......mm" - /* 12 */ "mm.......mm" + /* 9 */ "..........." + /* 10 */ "..........." + /* 11 */ "..........." + /* 12 */ "..........." // Level 7 /* z\x* 1 */ @@ -2389,10 +2374,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ "kkkkkkkkkkk" /* 7 */ "..........." /* 8 */ "..........." - /* 9 */ "mm.......mm" - /* 10 */ "mm.......mm" - /* 11 */ "mm.......mm" - /* 12 */ "mm.......mm" + /* 9 */ "..........." + /* 10 */ "..........." + /* 11 */ "..........." + /* 12 */ "..........." // Level 8 /* z\x* 1 */ @@ -2406,10 +2391,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ "..........." /* 7 */ "..........." /* 8 */ "..........." - /* 9 */ "mm.......mm" - /* 10 */ "mm.......mm" - /* 11 */ "mm.......mm" - /* 12 */ "mm.......mm", + /* 9 */ "..........." + /* 10 */ "..........." + /* 11 */ "..........." + /* 12 */ "...........", // Connectors: "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, @@ -2443,8 +2428,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 11, 9, 9, // SizeX = 11, SizeY = 9, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 10, 8, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 11, 8, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -2620,8 +2605,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 15, 10, 16, // SizeX = 15, SizeY = 10, SizeZ = 16 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 14, 9, 15, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 15, 9, 16, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -2891,8 +2876,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 16, 7, 16, // SizeX = 16, SizeY = 7, SizeZ = 16 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 15, 6, 15, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 16, 6, 16, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -3094,8 +3079,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 11, 8, 11, // SizeX = 11, SizeY = 8, SizeZ = 11 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 10, 7, 10, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 11, 7, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -3277,8 +3262,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 15, 8, 11, // SizeX = 15, SizeY = 8, SizeZ = 11 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 14, 7, 10, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 15, 7, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -3458,7 +3443,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 9, 18, 13, // SizeX = 9, SizeY = 18, SizeZ = 13 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ + -1, 0, 0, // MinX, MinY, MinZ 8, 17, 12, // MaxX, MaxY, MaxZ // Block definitions: @@ -3808,8 +3793,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = 15, 10, 9, // SizeX = 15, SizeY = 10, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 14, 9, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 15, 9, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ -- cgit v1.2.3 From 941cb88ae456f0d8b91f6b5dc835c2536eef15f6 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 23 May 2014 12:33:30 +0200 Subject: Fixed datatype conversion warning. --- src/Entities/Entity.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 15f456332..2567b7adc 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1018,10 +1018,10 @@ void cEntity::TickInVoid(cChunk & a_Chunk) -void cEntity::DetectCacti() +void cEntity::DetectCacti(void) { int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; - float w = m_Width / 2; + double w = m_Width / 2; if ( (((X + 1) - GetPosX() < w) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) || (((GetPosX() - (X - 1)) - 1 < w) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) || -- cgit v1.2.3 From a4c964c888748e7099308dc56578244112148cdd Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 23 May 2014 13:01:06 +0200 Subject: Auto-enlargement for cGridStructGen cache. --- src/Generating/GridStructGen.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp index 3bbc89054..bfa6bccb1 100644 --- a/src/Generating/GridStructGen.cpp +++ b/src/Generating/GridStructGen.cpp @@ -22,6 +22,15 @@ cGridStructGen::cGridStructGen( m_MaxStructureSizeZ(a_MaxStructureSizeZ), m_MaxCacheSize(a_MaxCacheSize) { + size_t NumStructuresPerQuery = (size_t)((m_MaxStructureSizeX / m_GridSizeX + 1) * (m_MaxStructureSizeZ / m_GridSizeZ + 1)); + if (NumStructuresPerQuery > m_MaxCacheSize) + { + m_MaxCacheSize = NumStructuresPerQuery * 4; + LOGINFO( + "cGridStructGen: The cache size is too small (%u), increasing the cache size to %u to avoid inefficiency.", + (unsigned)a_MaxCacheSize, (unsigned)m_MaxCacheSize + ); + } } -- cgit v1.2.3 From 97865bff7ce1595ae43be65082c1a02fed4ea8c4 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 23 May 2014 13:01:50 +0200 Subject: Fixed Mineshaft system size. --- src/Generating/MineShafts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index 391e4c04f..81ae6481d 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -1283,7 +1283,7 @@ cStructGenMineShafts::cStructGenMineShafts( int a_Seed, int a_GridSize, int a_MaxSystemSize, int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase ) : - super(a_Seed, a_GridSize, a_GridSize, 120 + a_MaxSystemSize * 10, 120 + a_MaxSystemSize * 10, 100), + super(a_Seed, a_GridSize, a_GridSize, a_MaxSystemSize, a_MaxSystemSize, 100), m_Noise(a_Seed), m_GridSize(a_GridSize), m_MaxSystemSize(a_MaxSystemSize), -- cgit v1.2.3 From 8f964886e0ccbf51dac07227f0ac4c739b47d3a5 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 24 May 2014 13:33:40 +0100 Subject: Implemented style changes --- src/BlockArea.cpp | 2 +- src/Chunk.cpp | 4 +- src/Chunk.h | 4 +- src/ChunkData.cpp | 61 +++++++++++++-------------- src/ChunkData.h | 108 ++++++++++++++++++++++++++---------------------- src/ChunkDataCallback.h | 8 ++-- 6 files changed, 95 insertions(+), 92 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 87236957a..11bd76e6c 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -1908,7 +1908,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer) if (m_Area.m_BlockLight != NULL) { - a_BlockBuffer.CopyLight(m_Area.m_BlockLight); + a_BlockBuffer.CopyBlockLight(m_Area.m_BlockLight); } if (m_Area.m_BlockSkyLight != NULL) diff --git a/src/Chunk.cpp b/src/Chunk.cpp index d85b44607..e5f8f1e29 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -284,7 +284,7 @@ void cChunk::SetAllData( m_ChunkData.SetBlocks(a_BlockTypes); m_ChunkData.SetMeta(a_BlockMeta); - m_ChunkData.SetLight(a_BlockLight); + m_ChunkData.SetBlockLight(a_BlockLight); m_ChunkData.SetSkyLight(a_BlockSkyLight); m_IsLightValid = (a_BlockLight != NULL) && (a_BlockSkyLight != NULL); @@ -326,7 +326,7 @@ void cChunk::SetLight( // TODO: We might get cases of wrong lighting when a chunk changes in the middle of a lighting calculation. // Postponing until we see how bad it is :) - m_ChunkData.SetLight(a_BlockLight); + m_ChunkData.SetBlockLight(a_BlockLight); m_ChunkData.SetSkyLight(a_SkyLight); diff --git a/src/Chunk.h b/src/Chunk.h index 2de45919e..d95537acf 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -67,7 +67,7 @@ public: cChunkMap * a_ChunkMap, cWorld * a_World, // Parent objects cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP // Neighbor chunks ); - cChunk(cChunk& other); + cChunk(cChunk & other); ~cChunk(); bool IsValid(void) const {return m_IsValid; } // Returns true if the chunk block data is valid (loaded / generated) @@ -156,7 +156,7 @@ public: void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta ); // Doesn't force block updates on neighbors, use for simple changes such as grass growing etc. BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const; - BLOCKTYPE GetBlock(Vector3i a_cords) const { return GetBlock(a_cords.x,a_cords.y,a_cords.z);} + BLOCKTYPE GetBlock(Vector3i a_cords) const { return GetBlock(a_cords.x, a_cords.y, a_cords.z);} void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta); void GetBlockInfo (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight); diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 86b0c431c..098f436f8 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -5,7 +5,7 @@ cChunkData cChunkData::Copy() const { cChunkData copy; - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { if (m_Sections[i] != NULL) { @@ -22,13 +22,16 @@ cChunkData cChunkData::Copy() const void cChunkData::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length) const { - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; - if (a_Idx > 0) a_Idx = a_Idx > length ? a_Idx - length : 0; + if (a_Idx > 0) + { + a_Idx = std::max(a_Idx - length, (size_t) 0); + } if (a_Idx == 0) { - size_t tocopy = length > segment_length ? segment_length : length; + size_t tocopy = std::min(segment_length, length); length -= tocopy; if (m_Sections[i] != NULL) { @@ -56,7 +59,7 @@ void cChunkData::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length) void cChunkData::CopyMeta(NIBBLETYPE * a_dest) const { - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) @@ -82,9 +85,9 @@ void cChunkData::CopyMeta(NIBBLETYPE * a_dest) const -void cChunkData::CopyLight(NIBBLETYPE * a_dest) const +void cChunkData::CopyBlockLight(NIBBLETYPE * a_dest) const { - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) @@ -112,7 +115,7 @@ void cChunkData::CopyLight(NIBBLETYPE * a_dest) const void cChunkData::CopySkyLight(NIBBLETYPE * a_dest) const { - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) @@ -140,7 +143,7 @@ void cChunkData::CopySkyLight(NIBBLETYPE * a_dest) const void cChunkData::SetBlocks(const BLOCKTYPE * a_src) { - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; if (m_Sections[i] != NULL) @@ -153,6 +156,9 @@ void cChunkData::SetBlocks(const BLOCKTYPE * a_src) } else { + // j counts how many of leading zeros the buffer has + // if j == segment_length then the buffer is all zeros so there is no point + // creating the buffer. size_t j = 0; // do nothing whilst 0 for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); @@ -180,11 +186,6 @@ void cChunkData::SetBlocks(const BLOCKTYPE * a_src) sizeof(m_Sections[i]->m_BlockSkyLight) ); } - else - { - Free(m_Sections[i]); - m_Sections[i] = 0; - } } } } @@ -194,7 +195,7 @@ void cChunkData::SetBlocks(const BLOCKTYPE * a_src) void cChunkData::SetMeta(const NIBBLETYPE * a_src) { - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) @@ -207,6 +208,9 @@ void cChunkData::SetMeta(const NIBBLETYPE * a_src) } else { + // j counts how many of leading zeros the buffer has + // if j == segment_length then the buffer is all zeros so there is no point + // creating the buffer. size_t j = 0; // do nothing whilst 0 for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); @@ -234,11 +238,6 @@ void cChunkData::SetMeta(const NIBBLETYPE * a_src) sizeof(m_Sections[i]->m_BlockSkyLight) ); } - else - { - Free(m_Sections[i]); - m_Sections[i] = 0; - } } } } @@ -246,10 +245,10 @@ void cChunkData::SetMeta(const NIBBLETYPE * a_src) -void cChunkData::SetLight(const NIBBLETYPE * a_src) +void cChunkData::SetBlockLight(const NIBBLETYPE * a_src) { if (!a_src) return; - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) @@ -262,6 +261,9 @@ void cChunkData::SetLight(const NIBBLETYPE * a_src) } else { + // j counts how many of leading zeros the buffer has + // if j == segment_length then the buffer is all zeros so there is no point + // creating the buffer. size_t j = 0; // do nothing whilst 0 for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); @@ -289,11 +291,6 @@ void cChunkData::SetLight(const NIBBLETYPE * a_src) sizeof(m_Sections[i]->m_BlockSkyLight) ); } - else - { - Free(m_Sections[i]); - m_Sections[i] = 0; - } } } } @@ -304,7 +301,7 @@ void cChunkData::SetLight(const NIBBLETYPE * a_src) void cChunkData::SetSkyLight (const NIBBLETYPE * a_src) { if (!a_src) return; - for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) @@ -317,6 +314,9 @@ void cChunkData::SetSkyLight (const NIBBLETYPE * a_src) } else { + // j counts how many of leading zeros the buffer has + // if j == segment_length then the buffer is all zeros so there is no point + // creating the buffer. size_t j = 0; // do nothing whilst 0 for (; j < segment_length && a_src[i * segment_length + j] == 0xFF; j++); @@ -344,11 +344,6 @@ void cChunkData::SetSkyLight (const NIBBLETYPE * a_src) sizeof(m_Sections[i]->m_BlockLight) ); } - else - { - Free(m_Sections[i]); - m_Sections[i] = 0; - } } } } diff --git a/src/ChunkData.h b/src/ChunkData.h index 9c852ee24..5a149f95f 100644 --- a/src/ChunkData.h +++ b/src/ChunkData.h @@ -8,8 +8,7 @@ #include "ChunkDef.h" -#define CHUNK_SECTION_HEIGHT 16 -#define CHUNK_SECTION_NUM (256 / CHUNK_SECTION_HEIGHT) + #if __cplusplus < 201103L // auto_ptr style interface for memory management @@ -23,8 +22,8 @@ public: cChunkData() #if __cplusplus < 201103L - // auto_ptr style interface for memory management - : IsOwner(true) + // auto_ptr style interface for memory management + : IsOwner(true) #endif { memset(m_Sections, 0, sizeof(m_Sections)); @@ -32,72 +31,75 @@ public: ~cChunkData() { #if __cplusplus < 201103L - // auto_ptr style interface for memory management - if (!IsOwner) return; + // auto_ptr style interface for memory management + if (!IsOwner) + { + return; + } #endif - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { if (m_Sections[i] == NULL) Free(m_Sections[i]);; } } #if __cplusplus < 201103L - // auto_ptr style interface for memory management - cChunkData(const cChunkData& other) : - IsOwner(true) - { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + // auto_ptr style interface for memory management + cChunkData(const cChunkData& other) : + IsOwner(true) { - m_Sections[i] = other.m_Sections[i]; + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + { + m_Sections[i] = other.m_Sections[i]; + } + other.IsOwner = false; } - other.IsOwner = false; - } - cChunkData& operator=(const cChunkData& other) - { - if (&other != this) + cChunkData& operator=(const cChunkData& other) { - if (IsOwner) + if (&other != this) { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + if (IsOwner) { - if (m_Sections[i]) Free(m_Sections[i]);; + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + { + if (m_Sections[i]) Free(m_Sections[i]);; + } } + IsOwner = true; + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + { + m_Sections[i] = other.m_Sections[i]; + } + other.IsOwner = false; } - IsOwner = true; - for (int i = 0; i < CHUNK_SECTION_NUM; i++) - { - m_Sections[i] = other.m_Sections[i]; - } - other.IsOwner = false; - } - return *this; + return *this; - } + } #else - // unique_ptr style interface for memory management - cChunkData(cChunkData&& other) - { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + // unique_ptr style interface for memory management + cChunkData(cChunkData&& other) { - m_Sections[i] = other.m_Sections[i]; - other.m_Sections[i] = 0; + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + { + m_Sections[i] = other.m_Sections[i]; + other.m_Sections[i] = NULL; + } } - } - cChunkData& operator=(cChunkData&& other) - { - if (&other != this) + cChunkData& operator=(cChunkData&& other) { - for (int i = 0; i < CHUNK_SECTION_NUM; i++) + if (&other != this) { - Free(m_Sections[i]);; - m_Sections[i] = other.m_Sections[i]; - other.m_Sections[i] = 0; + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + { + Free(m_Sections[i]);; + m_Sections[i] = other.m_Sections[i]; + other.m_Sections[i] = NULL; + } } + return *this; } - return *this; - } #endif BLOCKTYPE GetBlock(int a_X, int a_Y, int a_Z) const @@ -150,7 +152,10 @@ public: NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const { - if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) + if ( + (a_RelX < cChunkDef::Width) && (a_RelX > -1) && + (a_RelY < cChunkDef::Height) && (a_RelY > -1) && + (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) { int Section = a_RelY / CHUNK_SECTION_HEIGHT; if (m_Sections[Section] != NULL) @@ -244,16 +249,19 @@ public: cChunkData Copy() const; void CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx = 0, size_t length = cChunkDef::NumBlocks) const; void CopyMeta (NIBBLETYPE * a_dest) const; - void CopyLight (NIBBLETYPE * a_dest) const; + void CopyBlockLight (NIBBLETYPE * a_dest) const; void CopySkyLight (NIBBLETYPE * a_dest) const; void SetBlocks (const BLOCKTYPE * a_src); void SetMeta (const NIBBLETYPE * a_src); - void SetLight (const NIBBLETYPE * a_src); + void SetBlockLight (const NIBBLETYPE * a_src); void SetSkyLight (const NIBBLETYPE * a_src); private: + static const size_t CHUNK_SECTION_HEIGHT = 16; + static const size_t CHUNK_SECTION_COUNT = (256 / CHUNK_SECTION_HEIGHT); + #if __cplusplus < 201103L // auto_ptr style interface for memory management mutable bool IsOwner; @@ -266,7 +274,7 @@ private: NIBBLETYPE m_BlockSkyLight[CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; }; - sChunkSection *m_Sections[CHUNK_SECTION_NUM]; + sChunkSection *m_Sections[CHUNK_SECTION_COUNT]; sChunkSection * Allocate() const; void Free(sChunkSection * ptr) const; diff --git a/src/ChunkDataCallback.h b/src/ChunkDataCallback.h index 340582885..e916d6486 100644 --- a/src/ChunkDataCallback.h +++ b/src/ChunkDataCallback.h @@ -62,7 +62,7 @@ protected: /** A simple implementation of the cChunkDataCallback interface that collects all block data into a single buffer */ class cChunkDataArrayCollector : -public cChunkDataCallback + public cChunkDataCallback { public: @@ -75,7 +75,7 @@ protected: { a_ChunkBuffer.CopyBlocks(m_BlockData); a_ChunkBuffer.CopyMeta(m_BlockData + cChunkDef::NumBlocks); - a_ChunkBuffer.CopyLight(m_BlockData + 3 * cChunkDef::NumBlocks / 2); + a_ChunkBuffer.CopyBlockLight(m_BlockData + 3 * cChunkDef::NumBlocks / 2); a_ChunkBuffer.CopySkyLight(m_BlockData + 2 * cChunkDef::NumBlocks); } }; @@ -83,7 +83,7 @@ protected: /** A simple implementation of the cChunkDataCallback interface that collects all block data into a separate buffers */ class cChunkDataSeparateCollector : -public cChunkDataCallback + public cChunkDataCallback { public: @@ -98,7 +98,7 @@ protected: { a_ChunkBuffer.CopyBlocks(m_BlockTypes); a_ChunkBuffer.CopyMeta(m_BlockMetas); - a_ChunkBuffer.CopyLight(m_BlockLight); + a_ChunkBuffer.CopyBlockLight(m_BlockLight); a_ChunkBuffer.CopySkyLight(m_BlockSkyLight); } } ; -- cgit v1.2.3 From 7fac63cffbe226ab025435a1e01e5f2430e52806 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 24 May 2014 13:37:25 +0100 Subject: Moved accessors to cpp file --- src/ChunkData.cpp | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++++- src/ChunkData.h | 227 +++-------------------------------------------------- 2 files changed, 241 insertions(+), 216 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 098f436f8..162803292 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -2,7 +2,235 @@ #include "Globals.h" #include "ChunkData.h" -cChunkData cChunkData::Copy() const +cChunkData::cChunkData() +#if __cplusplus < 201103L + // auto_ptr style interface for memory management + : IsOwner(true) +#endif +{ + memset(m_Sections, 0, sizeof(m_Sections)); +} + + +cChunkData::~cChunkData() +{ + #if __cplusplus < 201103L + // auto_ptr style interface for memory management + if (!IsOwner) + { + return; + } + #endif + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + { + if (m_Sections[i] == NULL) Free(m_Sections[i]);; + } +} + +#if __cplusplus < 201103L + // auto_ptr style interface for memory management + cChunkData::cChunkData(const cChunkData& other) : + IsOwner(true) + { + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + { + m_Sections[i] = other.m_Sections[i]; + } + other.IsOwner = false; + } + + cChunkData::cChunkData& operator=(const cChunkData& other) + { + if (&other != this) + { + if (IsOwner) + { + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + { + if (m_Sections[i]) Free(m_Sections[i]);; + } + } + IsOwner = true; + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + { + m_Sections[i] = other.m_Sections[i]; + } + other.IsOwner = false; + } + return *this; + + } +#else + // unique_ptr style interface for memory management + cChunkData::cChunkData(cChunkData&& other) + { + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + { + m_Sections[i] = other.m_Sections[i]; + other.m_Sections[i] = NULL; + } + } + + cChunkData::cChunkData& operator=(cChunkData&& other) + { + if (&other != this) + { + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + { + Free(m_Sections[i]);; + m_Sections[i] = other.m_Sections[i]; + other.m_Sections[i] = NULL; + } + } + return *this; + } +#endif + +BLOCKTYPE cChunkData::GetBlock(int a_X, int a_Y, int a_Z) const +{ + ASSERT((a_X >= 0) && (a_X < cChunkDef::Width)); + ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height)); + ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width)); + int Section = a_Y / CHUNK_SECTION_HEIGHT; + if (m_Sections[Section] != NULL) + { + int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * CHUNK_SECTION_HEIGHT), a_Z); + return m_Sections[Section]->m_BlockTypes[Index]; + } + else + { + return 0; + } +} + +void cChunkData::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block) +{ + if ( + (a_RelX >= cChunkDef::Width) || (a_RelX < 0) || + (a_RelY >= cChunkDef::Height) || (a_RelY < 0) || + (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0) + ) + { + ASSERT(!"cChunkData::SetMeta(): index out of range!"); + return; + } + + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if (m_Sections[Section] == NULL) + { + if (a_Block == 0x00) + { + return; + } + m_Sections[Section] = Allocate(); + if (m_Sections[Section] == NULL) + { + ASSERT(!"Failed to allocate a new section in Chunkbuffer"); + return; + } + ZeroSection(m_Sections[Section]); + } + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + m_Sections[Section]->m_BlockTypes[Index] = a_Block; +} + +NIBBLETYPE cChunkData::GetMeta(int a_RelX, int a_RelY, int a_RelZ) const +{ + if ( + (a_RelX < cChunkDef::Width) && (a_RelX > -1) && + (a_RelY < cChunkDef::Height) && (a_RelY > -1) && + (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) + { + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if (m_Sections[Section] != NULL) + { + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + return (m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4)) & 0x0f; + } + else + { + return 0; + } + } + ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!"); + return 0; +} + +bool cChunkData::SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble) +{ + if ( + (a_RelX >= cChunkDef::Width) || (a_RelX < 0) || + (a_RelY >= cChunkDef::Height) || (a_RelY < 0) || + (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0) + ) + { + ASSERT(!"cChunkData::SetMeta(): index out of range!"); + return false; + } + + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if (m_Sections[Section] == NULL) + { + if ((a_Nibble & 0xf) == 0x00) + { + return false; + } + m_Sections[Section] = Allocate(); + if (m_Sections[Section] == NULL) + { + ASSERT(!"Failed to allocate a new section in Chunkbuffer"); + return false; + } + ZeroSection(m_Sections[Section]); + } + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + NIBBLETYPE oldval = m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4) & 0xf; + m_Sections[Section]->m_BlockMeta[Index / 2] = static_cast( + (m_Sections[Section]->m_BlockMeta[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble + ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set + ); + return oldval == a_Nibble; +} + +NIBBLETYPE cChunkData::GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const +{ + if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) + { + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if (m_Sections[Section] != NULL) + { + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; + } + else + { + return 0; + } + } + ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!"); + return 0; +} + +NIBBLETYPE cChunkData::GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const +{ + if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) + { + int Section = a_RelY / CHUNK_SECTION_HEIGHT; + if (m_Sections[Section] != NULL) + { + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; + } + else + { + return 0xF; + } + } + ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!"); + return 0; +} + +cChunkData cChunkData::cChunkData::Copy() const { cChunkData copy; for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) diff --git a/src/ChunkData.h b/src/ChunkData.h index 5a149f95f..16fcc4d37 100644 --- a/src/ChunkData.h +++ b/src/ChunkData.h @@ -20,231 +20,28 @@ class cChunkData { public: - cChunkData() - #if __cplusplus < 201103L - // auto_ptr style interface for memory management - : IsOwner(true) - #endif - { - memset(m_Sections, 0, sizeof(m_Sections)); - } - ~cChunkData() - { - #if __cplusplus < 201103L - // auto_ptr style interface for memory management - if (!IsOwner) - { - return; - } - #endif - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) - { - if (m_Sections[i] == NULL) Free(m_Sections[i]);; - } - } + cChunkData(); + ~cChunkData(); #if __cplusplus < 201103L // auto_ptr style interface for memory management - cChunkData(const cChunkData& other) : - IsOwner(true) - { - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) - { - m_Sections[i] = other.m_Sections[i]; - } - other.IsOwner = false; - } - - cChunkData& operator=(const cChunkData& other) - { - if (&other != this) - { - if (IsOwner) - { - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) - { - if (m_Sections[i]) Free(m_Sections[i]);; - } - } - IsOwner = true; - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) - { - m_Sections[i] = other.m_Sections[i]; - } - other.IsOwner = false; - } - return *this; - - } + cChunkData(const cChunkData& other); + cChunkData& operator=(const cChunkData& other); #else // unique_ptr style interface for memory management - cChunkData(cChunkData&& other) - { - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) - { - m_Sections[i] = other.m_Sections[i]; - other.m_Sections[i] = NULL; - } - } - - cChunkData& operator=(cChunkData&& other) - { - if (&other != this) - { - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) - { - Free(m_Sections[i]);; - m_Sections[i] = other.m_Sections[i]; - other.m_Sections[i] = NULL; - } - } - return *this; - } + cChunkData(cChunkData&& other); + cChunkData& operator=(cChunkData&& other); #endif - BLOCKTYPE GetBlock(int a_X, int a_Y, int a_Z) const - { - ASSERT((a_X >= 0) && (a_X < cChunkDef::Width)); - ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height)); - ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width)); - int Section = a_Y / CHUNK_SECTION_HEIGHT; - if (m_Sections[Section] != NULL) - { - int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * CHUNK_SECTION_HEIGHT), a_Z); - return m_Sections[Section]->m_BlockTypes[Index]; - } - else - { - return 0; - } - } - - void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block) - { - if ( - (a_RelX >= cChunkDef::Width) || (a_RelX < 0) || - (a_RelY >= cChunkDef::Height) || (a_RelY < 0) || - (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0) - ) - { - ASSERT(!"cChunkData::SetMeta(): index out of range!"); - return; - } - - int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if (m_Sections[Section] == NULL) - { - if (a_Block == 0x00) - { - return; - } - m_Sections[Section] = Allocate(); - if (m_Sections[Section] == NULL) - { - ASSERT(!"Failed to allocate a new section in Chunkbuffer"); - return; - } - ZeroSection(m_Sections[Section]); - } - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); - m_Sections[Section]->m_BlockTypes[Index] = a_Block; - } - - NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const - { - if ( - (a_RelX < cChunkDef::Width) && (a_RelX > -1) && - (a_RelY < cChunkDef::Height) && (a_RelY > -1) && - (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) - { - int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if (m_Sections[Section] != NULL) - { - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); - return (m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4)) & 0x0f; - } - else - { - return 0; - } - } - ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!"); - return 0; - } - - bool SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble) - { - if ( - (a_RelX >= cChunkDef::Width) || (a_RelX < 0) || - (a_RelY >= cChunkDef::Height) || (a_RelY < 0) || - (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0) - ) - { - ASSERT(!"cChunkData::SetMeta(): index out of range!"); - return false; - } + BLOCKTYPE GetBlock(int a_X, int a_Y, int a_Z) const; + void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block); - int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if (m_Sections[Section] == NULL) - { - if ((a_Nibble & 0xf) == 0x00) - { - return false; - } - m_Sections[Section] = Allocate(); - if (m_Sections[Section] == NULL) - { - ASSERT(!"Failed to allocate a new section in Chunkbuffer"); - return false; - } - ZeroSection(m_Sections[Section]); - } - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); - NIBBLETYPE oldval = m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4) & 0xf; - m_Sections[Section]->m_BlockMeta[Index / 2] = static_cast( - (m_Sections[Section]->m_BlockMeta[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble - ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set - ); - return oldval == a_Nibble; - } + NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const; + bool SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble); - NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const - { - if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) - { - int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if (m_Sections[Section] != NULL) - { - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); - return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; - } - else - { - return 0; - } - } - ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!"); - return 0; - } + NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const; - NIBBLETYPE GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const - { - if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) - { - int Section = a_RelY / CHUNK_SECTION_HEIGHT; - if (m_Sections[Section] != NULL) - { - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); - return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; - } - else - { - return 0xF; - } - } - ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!"); - return 0; - } + NIBBLETYPE GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const; cChunkData Copy() const; void CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx = 0, size_t length = cChunkDef::NumBlocks) const; -- cgit v1.2.3 From 96a22cd82c350b1205985a9b8e01f5e6c11f069a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 24 May 2014 15:03:39 +0200 Subject: Added Japanese village prefabs. --- src/Generating/Prefab.cpp | 9 + src/Generating/Prefab.h | 3 + src/Generating/Prefabs/JapaneseVillagePrefabs.cpp | 2404 +++++++++++++++++++++ src/Generating/Prefabs/JapaneseVillagePrefabs.h | 15 + src/Generating/VillageGen.cpp | 15 +- 5 files changed, 2442 insertions(+), 4 deletions(-) create mode 100644 src/Generating/Prefabs/JapaneseVillagePrefabs.cpp create mode 100644 src/Generating/Prefabs/JapaneseVillagePrefabs.h (limited to 'src') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 506e1c2cc..05979507a 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -292,6 +292,15 @@ int cPrefab::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cC +void cPrefab::SetDefaultWeight(int a_DefaultWeight) +{ + m_DefaultWeight = a_DefaultWeight; +} + + + + + void cPrefab::AddConnector(int a_RelX, int a_RelY, int a_RelZ, eBlockFace a_Direction, int a_Type) { m_Connectors.push_back(cConnector(a_RelX, a_RelY, a_RelZ, a_Type, a_Direction)); diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index 2b89a204c..adc0e688e 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -104,6 +104,9 @@ public: PiecePool implementations can use this for their GetPieceWeight() implementations. */ int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector) const; + /** Sets the (unmodified) DefaultWeight property for this piece. */ + void SetDefaultWeight(int a_DefaultWeight); + /** Returns the unmodified DefaultWeight property for the piece. */ int GetDefaultWeight(void) const { return m_DefaultWeight; } diff --git a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp new file mode 100644 index 000000000..2b129f520 --- /dev/null +++ b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp @@ -0,0 +1,2404 @@ + +// JapaneseVillagePrefabs.cpp + +// Defines the prefabs in the group JapaneseVillage + +// NOTE: This file has been generated automatically by GalExport! +// Any manual changes will be overwritten by the next automatic export! + +#include "Globals.h" +#include "JapaneseVillagePrefabs.h" + + + + + +const cPrefab::sDef g_JapaneseVillagePrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Arch: + // The data has been exported from the gallery Plains, area index 144, ID 488, created by Aloe_vera + { + // Size: + 11, 7, 5, // SizeX = 11, SizeY = 7, SizeZ = 5 + + // Hitbox (relative to bounding box): + -1, 0, 0, // MinX, MinY, MinZ + 11, 6, 4, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 2: 0\n" /* grass */ + "b: 13: 0\n" /* gravel */ + "c:113: 0\n" /* netherbrickfence */ + "d: 50: 5\n" /* torch */ + "e: 44: 8\n" /* step */ + "f: 44: 0\n" /* step */ + "g: 43: 0\n" /* doubleslab */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaaabbbaaaa" + /* 1 */ "aaaabbbaaaa" + /* 2 */ "aaaabbbaaaa" + /* 3 */ "aaaabbbaaaa" + /* 4 */ "aaaabbbaaaa" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..c.....c.." + /* 1 */ "..c.....c.." + /* 2 */ "..c.....c.." + /* 3 */ "..c.....c.." + /* 4 */ "..c.....c.." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..c.....c.." + /* 1 */ "..........." + /* 2 */ "..c.....c.." + /* 3 */ "..........." + /* 4 */ "..c.....c.." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..d.....d.." + /* 1 */ "..........." + /* 2 */ "..c.....c.." + /* 3 */ "..........." + /* 4 */ "..d.....d.." + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "...eeeee..." + /* 1 */ "..........." + /* 2 */ "..c.....c.." + /* 3 */ "..........." + /* 4 */ "...eeeee..." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..f.....f.." + /* 1 */ ".egfffffge." + /* 2 */ ".egeeeeege." + /* 3 */ ".egfffffge." + /* 4 */ "..f.....f.." + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "gf.......fg" + /* 3 */ "..........." + /* 4 */ "...........", + + // Connectors: + "2: 5, 1, 4: 3\n" /* Type 2, direction Z+ */ + "2: 5, 1, 0: 2\n" /* Type 2, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // Arch + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Forge: + // The data has been exported from the gallery Plains, area index 79, ID 145, created by Aloe_vera + { + // Size: + 16, 11, 14, // SizeX = 16, SizeY = 11, SizeZ = 14 + + // Hitbox (relative to bounding box): + 0, 0, -1, // MinX, MinY, MinZ + 16, 10, 14, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 4: 0\n" /* cobblestone */ + "b: 17: 1\n" /* tree */ + "c: 67: 0\n" /* stairs */ + "d: 5: 2\n" /* wood */ + "e: 67: 2\n" /* stairs */ + "f:113: 0\n" /* netherbrickfence */ + "g:118: 2\n" /* cauldronblock */ + "h: 67: 6\n" /* stairs */ + "i: 67: 4\n" /* stairs */ + "j: 87: 0\n" /* netherstone */ + "k: 67: 7\n" /* stairs */ + "l: 54: 5\n" /* chest */ + "m: 19: 0\n" /* sponge */ + "n: 61: 2\n" /* furnace */ + "o:101: 0\n" /* ironbars */ + "p: 51: 0\n" /* fire */ + "q: 50: 4\n" /* torch */ + "r: 50: 2\n" /* torch */ + "s: 35: 0\n" /* wool */ + "t: 67: 3\n" /* stairs */ + "u: 50: 3\n" /* torch */ + "v: 44: 8\n" /* step */ + "w: 43: 0\n" /* doubleslab */ + "x: 44: 0\n" /* step */ + "y: 17: 5\n" /* tree */ + "z: 17: 9\n" /* tree */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmmm" + /* 2 */ "mmaaaaaaaaaaaamm" + /* 3 */ "mmaaaaaaaaaaaamm" + /* 4 */ "mmaaaaaaaaaaaamm" + /* 5 */ "mmaaaaaaaaaaaamm" + /* 6 */ "mmaaaaaaaaaaaamm" + /* 7 */ "mmaaaaaaaaaaaamm" + /* 8 */ "mmaaaaaaaaaaaamm" + /* 9 */ "mmaaaaaaaaaaaamm" + /* 10 */ "mmaaaaaaaaaaaamm" + /* 11 */ "mmaaaaaaaaaaaamm" + /* 12 */ "mmmmmmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmmmm" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ ".....bbbbbbbbb.." + /* 3 */ ".....cdddddddb.." + /* 4 */ ".....cddaaaadb.." + /* 5 */ "..beeedaaaaadb.." + /* 6 */ "..bddddaaaaadb.." + /* 7 */ "..bddddaaaaadb.." + /* 8 */ "..bddddaaaaadb.." + /* 9 */ "..bddddaaaaadb.." + /* 10 */ "..bddddddddddb.." + /* 11 */ "..bbbbbbbbbbbb.." + /* 12 */ "................" + /* 13 */ "................" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ ".....bfffbfffb.." + /* 3 */ ".............a.." + /* 4 */ ".............a.." + /* 5 */ "..b.....ghh..a.." + /* 6 */ "..f.....haa..b.." + /* 7 */ "..f.....ija..b.." + /* 8 */ "..f.....kaa..a.." + /* 9 */ "..f..........a.." + /* 10 */ "..fl.........a.." + /* 11 */ "..bffffbbffffb.." + /* 12 */ "................" + /* 13 */ "................" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ ".....bfffbfffb.." + /* 3 */ ".............a.." + /* 4 */ ".............a.." + /* 5 */ "..b......nn..a.." + /* 6 */ "..f.....oaa..b.." + /* 7 */ "..f.....opa..b.." + /* 8 */ "..f.....oaa..a.." + /* 9 */ "..f..........a.." + /* 10 */ "..f..........a.." + /* 11 */ "..bffffbbffffb.." + /* 12 */ "................" + /* 13 */ "................" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ ".........q...q.." + /* 2 */ "....rbsssbsssb.." + /* 3 */ ".............a.." + /* 4 */ "..q..........a.." + /* 5 */ "..b......ce..a.." + /* 6 */ "..s......ea..b.." + /* 7 */ "..s......aa..b.." + /* 8 */ "..s......ta..a.." + /* 9 */ "..s..........a.." + /* 10 */ "..s..........a.." + /* 11 */ ".rbssssbbssssb.." + /* 12 */ "..u....uu....u.." + /* 13 */ "................" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ ".vwxxxxxxxxxxwv." + /* 1 */ "vvvvvvvvvvvvvvvv" + /* 2 */ "wvbyybyyybbyybvw" + /* 3 */ "xvz..........zvx" + /* 4 */ "xvz..........zvx" + /* 5 */ "xvb..........zvx" + /* 6 */ "xvz.......a..bvx" + /* 7 */ "xvz......ca..bvx" + /* 8 */ "xvz.......a..zvx" + /* 9 */ "xvz..........zvx" + /* 10 */ "xvz..........zvx" + /* 11 */ "wvbyyyyyyyyyybvw" + /* 12 */ "vvvvvvvvvvvvvvvv" + /* 13 */ ".vwxxxxxxxxxxwv." + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "wx............xw" + /* 1 */ "x..............x" + /* 2 */ "..xxxxxxxxxxxx.." + /* 3 */ "..xwwwwwwwwwwx.." + /* 4 */ "..xwvvvvvvvvvx.." + /* 5 */ "..xwv.......vx.." + /* 6 */ "..xwv.....a.vx.." + /* 7 */ "..xwv.....a.vx.." + /* 8 */ "..xwv.....a.vx.." + /* 9 */ "..xwvvvvvvvvvx.." + /* 10 */ "..xwwwwwwwwwwx.." + /* 11 */ "..xxxxxxxxxxxx.." + /* 12 */ "x..............x" + /* 13 */ "wx............xw" + + // Level 7 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "................" + /* 4 */ "....xxxxxxxx...." + /* 5 */ "....xxxxxxxx...." + /* 6 */ "....xwwwwwax...." + /* 7 */ "....xwvvvvax...." + /* 8 */ "....xwwwwwax...." + /* 9 */ "....xxxxxxxx...." + /* 10 */ "................" + /* 11 */ "................" + /* 12 */ "................" + /* 13 */ "................" + + // Level 8 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "................" + /* 4 */ "................" + /* 5 */ "................" + /* 6 */ "..........a....." + /* 7 */ ".......xx.a....." + /* 8 */ "..........a....." + /* 9 */ "................" + /* 10 */ "................" + /* 11 */ "................" + /* 12 */ "................" + /* 13 */ "................" + + // Level 9 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "................" + /* 4 */ "................" + /* 5 */ "................" + /* 6 */ "..........a....." + /* 7 */ "..........a....." + /* 8 */ "..........a....." + /* 9 */ "................" + /* 10 */ "................" + /* 11 */ "................" + /* 12 */ "................" + /* 13 */ "................" + + // Level 10 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "................" + /* 4 */ "................" + /* 5 */ "................" + /* 6 */ "..........a....." + /* 7 */ "..........a....." + /* 8 */ "..........a....." + /* 9 */ "................" + /* 10 */ "................" + /* 11 */ "................" + /* 12 */ "................" + /* 13 */ "................", + + // Connectors: + "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // Forge + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HouseMid: + // The data has been exported from the gallery Plains, area index 62, ID 119, created by Aloe_vera + { + // Size: + 10, 9, 9, // SizeX = 10, SizeY = 9, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, -1, // MinX, MinY, MinZ + 10, 8, 9, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 2\n" /* wood */ + "b:135: 2\n" /* 135 */ + "c:135: 0\n" /* 135 */ + "d: 17: 9\n" /* tree */ + "e:135: 3\n" /* 135 */ + "f: 85: 0\n" /* fence */ + "g: 17: 1\n" /* tree */ + "h:171: 0\n" /* carpet */ + "i: 50: 5\n" /* torch */ + "j: 35: 0\n" /* wool */ + "k: 17: 5\n" /* tree */ + "l:124: 0\n" /* redstonelampon */ + "m: 19: 0\n" /* sponge */ + "n: 69: 9\n" /* lever */ + "o: 44: 8\n" /* step */ + "p: 43: 0\n" /* doubleslab */ + "q: 44: 0\n" /* step */, + + // Block data: + // Level 0 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "maaaaaaaaa" + /* 1 */ "maaaaaaaaa" + /* 2 */ "aaaaaaaaaa" + /* 3 */ "aaaaaaaaaa" + /* 4 */ "aaaaaaaaaa" + /* 5 */ "aaaaaaaaaa" + /* 6 */ "aaaaaaaaaa" + /* 7 */ "maaaaaaaaa" + /* 8 */ "maaaaaaaaa" + + // Level 1 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".aaaaaaaaa" + /* 1 */ ".aaaaaaaaa" + /* 2 */ "baaaaaaaaa" + /* 3 */ "caaaaaaaaa" + /* 4 */ "caadaaaaaa" + /* 5 */ "caaaaaaaaa" + /* 6 */ "eaaaaaaaaa" + /* 7 */ ".aaaaaaaaa" + /* 8 */ ".aaaaaaaaa" + + // Level 2 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".fffffffff" + /* 1 */ ".f.......f" + /* 2 */ ".f.ggggg.f" + /* 3 */ "...ghhhg.f" + /* 4 */ "....hhhg.f" + /* 5 */ "...ghhhg.f" + /* 6 */ ".f.ggggg.f" + /* 7 */ ".f.......f" + /* 8 */ ".fffffffff" + + // Level 3 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".....i...i" + /* 1 */ ".........." + /* 2 */ ".i.jjgjj.." + /* 3 */ "...g...j.." + /* 4 */ ".......g.i" + /* 5 */ "...g...j.." + /* 6 */ ".i.jjgjj.." + /* 7 */ ".........." + /* 8 */ ".....i...i" + + // Level 4 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ ".........." + /* 2 */ "...jjgjj.." + /* 3 */ "...g...j.." + /* 4 */ "...j...g.." + /* 5 */ "...g...j.." + /* 6 */ "...jjgjj.." + /* 7 */ ".........." + /* 8 */ ".........." + + // Level 5 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ "...f...f.." + /* 2 */ "..fgkgkgf." + /* 3 */ "..fd...d.." + /* 4 */ "...d.lng.." + /* 5 */ "..fd...d.." + /* 6 */ "..fgkgkgf." + /* 7 */ "...f...f.." + /* 8 */ ".........." + + // Level 6 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "...ooooo.." + /* 1 */ "..opppppo." + /* 2 */ ".opgjjjgpo" + /* 3 */ ".opjgggjpo" + /* 4 */ ".opjgggjpo" + /* 5 */ ".opjgggjpo" + /* 6 */ ".opgjjjgpo" + /* 7 */ "..opppppo." + /* 8 */ "...ooooo.." + + // Level 7 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".opq...qpo" + /* 1 */ ".pq.....qp" + /* 2 */ ".q.qqqqq.q" + /* 3 */ "...qpppq.." + /* 4 */ "...qpppq.." + /* 5 */ "...qpppq.." + /* 6 */ ".q.qqqqq.q" + /* 7 */ ".pq.....qp" + /* 8 */ ".opq...qpo" + + // Level 8 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".q.......q" + /* 1 */ ".........." + /* 2 */ ".........." + /* 3 */ ".........." + /* 4 */ ".....q...." + /* 5 */ ".........." + /* 6 */ ".........." + /* 7 */ ".........." + /* 8 */ ".q.......q", + + // Connectors: + "-1: 0, 1, 4: 4\n" /* Type -1, direction X- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // HouseMid + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HouseSmall: + // The data has been exported from the gallery Plains, area index 68, ID 131, created by Aloe_vera + { + // Size: + 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7 + + // Hitbox (relative to bounding box): + -1, 0, 0, // MinX, MinY, MinZ + 7, 5, 7, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 2\n" /* wood */ + "b: 17: 1\n" /* tree */ + "c: 35: 0\n" /* wool */ + "d: 50: 4\n" /* torch */ + "e: 85: 0\n" /* fence */ + "f: 44: 8\n" /* step */ + "g: 43: 0\n" /* doubleslab */ + "h: 44: 0\n" /* step */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "maaaaam" + /* 2 */ "maaaaam" + /* 3 */ "maaaaam" + /* 4 */ "maaaaam" + /* 5 */ "maaaaam" + /* 6 */ "mmmmmmm" + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".bcc.b." + /* 2 */ ".c...c." + /* 3 */ ".c...c." + /* 4 */ ".c...c." + /* 5 */ ".bcccb." + /* 6 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ ".....d." + /* 1 */ ".bee.b." + /* 2 */ ".c...c." + /* 3 */ ".e...e." + /* 4 */ ".c...c." + /* 5 */ ".beeeb." + /* 6 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ ".fffff." + /* 1 */ "fbcccbf" + /* 2 */ "fc...cf" + /* 3 */ "fc...cf" + /* 4 */ "fc...cf" + /* 5 */ "fbcccbf" + /* 6 */ ".fffff." + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "gh...hg" + /* 1 */ "hhhhhhh" + /* 2 */ ".hgggh." + /* 3 */ ".hgggh." + /* 4 */ ".hgggh." + /* 5 */ "hhhhhhh" + /* 6 */ "gh...hg" + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "......." + /* 2 */ "......." + /* 3 */ "...h..." + /* 4 */ "......." + /* 5 */ "......." + /* 6 */ ".......", + + // Connectors: + "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // HouseSmall + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HouseSmallDouble: + // The data has been exported from the gallery Plains, area index 72, ID 135, created by Aloe_vera + { + // Size: + 11, 6, 7, // SizeX = 11, SizeY = 6, SizeZ = 7 + + // Hitbox (relative to bounding box): + -1, 0, 0, // MinX, MinY, MinZ + 11, 5, 7, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 2\n" /* wood */ + "b: 17: 1\n" /* tree */ + "c: 35: 0\n" /* wool */ + "d:171:12\n" /* carpet */ + "e:135: 1\n" /* 135 */ + "f:126: 2\n" /* woodenslab */ + "g:135: 2\n" /* 135 */ + "h: 50: 4\n" /* torch */ + "i: 85: 0\n" /* fence */ + "j: 44: 8\n" /* step */ + "k: 43: 0\n" /* doubleslab */ + "l: 44: 0\n" /* step */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmmmmmmmm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "maaaaaaaaam" + /* 3 */ "maaaaaaaaam" + /* 4 */ "maaaaaaaaam" + /* 5 */ "maaaaaaaaam" + /* 6 */ "mmmmmmmmmmm" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".bcc.bcccb." + /* 2 */ ".cddd.dddc." + /* 3 */ ".ceddcdfdc." + /* 4 */ ".cggdcdddc." + /* 5 */ ".bcccbcccb." + /* 6 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ ".h...h...h." + /* 1 */ ".bii.biiib." + /* 2 */ ".c.......c." + /* 3 */ ".i...i...i." + /* 4 */ ".c...i...c." + /* 5 */ ".biiibiiib." + /* 6 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ ".jjjjjjjjj." + /* 1 */ "jbiiibiiibj" + /* 2 */ "jc.......cj" + /* 3 */ "jc...c...cj" + /* 4 */ "jc...c...cj" + /* 5 */ "jbcccbcccbj" + /* 6 */ ".jjjjjjjjj." + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "kl...l...lk" + /* 1 */ "lllllllllll" + /* 2 */ ".lkkklkkkl." + /* 3 */ ".lkjklkkkl." + /* 4 */ ".lkkklkkkl." + /* 5 */ "lllllllllll" + /* 6 */ "kl...l...lk" + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "...l...l..." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "...........", + + // Connectors: + "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // HouseSmallDouble + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HouseWide: + // The data has been exported from the gallery Plains, area index 64, ID 121, created by STR_Warrior + { + // Size: + 11, 6, 11, // SizeX = 11, SizeY = 6, SizeZ = 11 + + // Hitbox (relative to bounding box): + -1, 0, -1, // MinX, MinY, MinZ + 11, 5, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 2\n" /* wood */ + "b: 17: 1\n" /* tree */ + "c: 35: 0\n" /* wool */ + "d:171: 0\n" /* carpet */ + "e:126: 1\n" /* woodenslab */ + "f: 64: 5\n" /* wooddoorblock */ + "g: 85: 0\n" /* fence */ + "h: 50: 1\n" /* torch */ + "i: 50: 2\n" /* torch */ + "j: 64:12\n" /* wooddoorblock */ + "k:126:11\n" /* woodenslab */ + "l: 17: 5\n" /* tree */ + "m: 19: 0\n" /* sponge */ + "n:126: 3\n" /* woodenslab */ + "o:125: 3\n" /* woodendoubleslab */ + "p: 5: 3\n" /* wood */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmmmmmmmm" + /* 1 */ "mmaaaaaaamm" + /* 2 */ "maaaaaaaaam" + /* 3 */ "maaaaaaaaam" + /* 4 */ "maaaaaaaaam" + /* 5 */ "maaaaaaaaam" + /* 6 */ "maaaaaaaaam" + /* 7 */ "maaaaaaaaam" + /* 8 */ "maaaaaaaaam" + /* 9 */ "mmaaaaaaamm" + /* 10 */ "mmmmmmmmmmm" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..bcbcbcb.." + /* 2 */ ".b.d.....b." + /* 3 */ ".cded....c." + /* 4 */ ".bded....b." + /* 5 */ ".c.d.....c." + /* 6 */ ".b.......b." + /* 7 */ ".c.......c." + /* 8 */ ".b.......b." + /* 9 */ "..bcbfbcb.." + /* 10 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..bgbgbgb.." + /* 2 */ ".b.......b." + /* 3 */ ".g.......g." + /* 4 */ ".bh.....ib." + /* 5 */ ".g.......g." + /* 6 */ ".b.......b." + /* 7 */ ".g.......g." + /* 8 */ ".b.......b." + /* 9 */ "..bgbjbgb.." + /* 10 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "...kkkkk..." + /* 1 */ "..bcbcbcb.." + /* 2 */ ".b.......b." + /* 3 */ "kc.......ck" + /* 4 */ "kb.......bk" + /* 5 */ "kc.......ck" + /* 6 */ "kb.......bk" + /* 7 */ "kc.......ck" + /* 8 */ ".b.......b." + /* 9 */ "..bcblbcb.." + /* 10 */ "...kkkkk..." + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ ".kn.....nk." + /* 1 */ "konnnnnnnok" + /* 2 */ "nnnnnnnnnnn" + /* 3 */ ".nnpppppnn." + /* 4 */ ".nnpkkkpnn." + /* 5 */ ".nnpkkkpnn." + /* 6 */ ".nnpkkkpnn." + /* 7 */ ".nnpppppnn." + /* 8 */ "nnnnnnnnnnn" + /* 9 */ "kknnnnnnnok" + /* 10 */ ".kn.....nk." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "n.........n" + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "....nnn...." + /* 5 */ "....non...." + /* 6 */ "....nnn...." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "n.........n", + + // Connectors: + "-1: 5, 1, 10: 3\n" /* Type -1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // HouseWide + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HouseWithGarden: + // The data has been exported from the gallery Plains, area index 67, ID 130, created by Aloe_vera + { + // Size: + 16, 9, 16, // SizeX = 16, SizeY = 9, SizeZ = 16 + + // Hitbox (relative to bounding box): + -1, 0, 0, // MinX, MinY, MinZ + 16, 8, 16, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 3: 0\n" /* dirt */ + "b: 5: 2\n" /* wood */ + "c: 2: 0\n" /* grass */ + "d:113: 0\n" /* netherbrickfence */ + "e: 17: 1\n" /* tree */ + "f: 35: 0\n" /* wool */ + "g:126: 2\n" /* woodenslab */ + "h: 31: 2\n" /* tallgrass */ + "i:125: 2\n" /* woodendoubleslab */ + "j: 38: 3\n" /* rose */ + "k: 38: 2\n" /* rose */ + "l: 38: 1\n" /* rose */ + "m: 19: 0\n" /* sponge */ + "n: 17: 2\n" /* tree */ + "o: 50: 4\n" /* torch */ + "p: 85: 0\n" /* fence */ + "q:140: 0\n" /* flowerpotblock */ + "r: 50: 3\n" /* torch */ + "s: 44: 8\n" /* step */ + "t: 50: 1\n" /* torch */ + "u: 50: 2\n" /* torch */ + "v: 43: 0\n" /* doubleslab */ + "w: 44: 0\n" /* step */ + "x: 18:10\n" /* leaves */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmaammmmm" + /* 1 */ "aabbbbbbbbbbaaam" + /* 2 */ "aabbbbbbbbbbaaam" + /* 3 */ "aabbbbbbbbbbaaam" + /* 4 */ "aabbbbbbbbbbaaam" + /* 5 */ "aabbbbbbbbbbaaam" + /* 6 */ "aabbbbbbbbbbaaam" + /* 7 */ "aabbbbbbbbbbaaam" + /* 8 */ "aabbbbbbbbbbaaam" + /* 9 */ "aabbbbbbbbbbaaam" + /* 10 */ "aaaaaaaaaaaaaaam" + /* 11 */ "aaaaaaaaaaaaaaam" + /* 12 */ "aaaaaaaaaaaaaaam" + /* 13 */ "aaaaaaaaaaaaaaam" + /* 14 */ "aaaaaaaaaaaaaaam" + /* 15 */ "mmmmmmmmmmmmmmmm" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmccmmmmm" + /* 1 */ "ccbbbbbbbbbbcccm" + /* 2 */ "ccbbbbbbbbbbcccm" + /* 3 */ "ccbbbbbbbbbbcccm" + /* 4 */ "ccbbbbbbbbbbcccm" + /* 5 */ "ccbbbbbbbbbbcccm" + /* 6 */ "ccbbbbbbbbbbcccm" + /* 7 */ "ccbbbbbbbbbbcccm" + /* 8 */ "ccbbbbbbbbbbcccm" + /* 9 */ "ccbbbbbbbbbbcccm" + /* 10 */ "cccccccccccccccm" + /* 11 */ "cccccccccccccccm" + /* 12 */ "cccccccccccccccm" + /* 13 */ "cccccccccccccacm" + /* 14 */ "cccccccccccccccm" + /* 15 */ "mmmmmmmmmmmmmmmm" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "ddeffeffe..eddd." + /* 2 */ "d.fbbgggg..f..d." + /* 3 */ "d.fbgggggggf.hd." + /* 4 */ "d.fbgggggggf..d." + /* 5 */ "d.eggggggggehhd." + /* 6 */ "d.fgiiggiigf.hd." + /* 7 */ "d.fgiiggiigf..d." + /* 8 */ "d.fggggggggf..d." + /* 9 */ "d.efffeefffe.hd." + /* 10 */ "d.............d." + /* 11 */ "djhhk.jhh..hh.d." + /* 12 */ "d.jlk.hj.h....d." + /* 13 */ "d..jh.hh..h..nd." + /* 14 */ "ddddddddddddddd." + /* 15 */ "................" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "........o..o...." + /* 1 */ "..eppeffe..e...." + /* 2 */ "..pqq......p...." + /* 3 */ "..pq.......p...." + /* 4 */ "..pq.......p...." + /* 5 */ "..e........e...." + /* 6 */ "..p........p...." + /* 7 */ "..p........p...." + /* 8 */ "..p........p...." + /* 9 */ "..epppeepppe...." + /* 10 */ "......rr........" + /* 11 */ "................" + /* 12 */ "................" + /* 13 */ ".............n.." + /* 14 */ "................" + /* 15 */ "................" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..ssssssssss...." + /* 1 */ ".seffeffeffes..." + /* 2 */ ".sf..r.....fs..." + /* 3 */ ".sf........fs..." + /* 4 */ ".sf........fs..." + /* 5 */ ".set......ues..." + /* 6 */ ".sf........fs..." + /* 7 */ ".sf........fs..." + /* 8 */ ".sf........fs..." + /* 9 */ ".sefffeefffes..." + /* 10 */ "..ssssssssss...." + /* 11 */ "................" + /* 12 */ "................" + /* 13 */ ".............n.." + /* 14 */ "................" + /* 15 */ "................" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ ".vw........wv..." + /* 1 */ ".wwwwwwwwwwww..." + /* 2 */ "..wvvvvvvvvw...." + /* 3 */ "..wvvvvvvvvw...." + /* 4 */ "..wvvvvvvvvw...." + /* 5 */ "..wvvvvvvvvw...." + /* 6 */ "..wvvvvvvvvw...." + /* 7 */ "..wvvvvvvvvw...." + /* 8 */ "..wvvvvvvvvw...." + /* 9 */ ".wwwwwwwwwwww..." + /* 10 */ ".vw........wv..." + /* 11 */ "............xxx." + /* 12 */ "...........xxxxx" + /* 13 */ "...........xxnxx" + /* 14 */ "...........xxxxx" + /* 15 */ "............xxx." + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "....wwwwww......" + /* 4 */ "....wvvvvw......" + /* 5 */ "....wvvvvw......" + /* 6 */ "....wvvvvw......" + /* 7 */ "....wwwwww......" + /* 8 */ "................" + /* 9 */ "................" + /* 10 */ "................" + /* 11 */ "............xxx." + /* 12 */ "...........xxxxx" + /* 13 */ "...........xxnxx" + /* 14 */ "...........xxxxx" + /* 15 */ "............xxx." + + // Level 7 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "................" + /* 4 */ "................" + /* 5 */ "......ww........" + /* 6 */ "................" + /* 7 */ "................" + /* 8 */ "................" + /* 9 */ "................" + /* 10 */ "................" + /* 11 */ "................" + /* 12 */ "............xxx." + /* 13 */ "............xnx." + /* 14 */ "............xx.." + /* 15 */ "................" + + // Level 8 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "................" + /* 4 */ "................" + /* 5 */ "................" + /* 6 */ "................" + /* 7 */ "................" + /* 8 */ "................" + /* 9 */ "................" + /* 10 */ "................" + /* 11 */ "................" + /* 12 */ ".............x.." + /* 13 */ "............xxx." + /* 14 */ ".............x.." + /* 15 */ "................", + + // Connectors: + "-1: 9, 2, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // HouseWithGarden + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HouseWithSakura1: + // The data has been exported from the gallery Plains, area index 75, ID 141, created by Aloe_vera + { + // Size: + 13, 7, 15, // SizeX = 13, SizeY = 7, SizeZ = 15 + + // Hitbox (relative to bounding box): + -1, 0, 0, // MinX, MinY, MinZ + 13, 6, 15, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 17: 5\n" /* tree */ + "d: 5: 2\n" /* wood */ + "e: 17: 9\n" /* tree */ + "f:113: 0\n" /* netherbrickfence */ + "g: 17: 1\n" /* tree */ + "h: 35: 0\n" /* wool */ + "i: 31: 2\n" /* tallgrass */ + "j: 54: 2\n" /* chest */ + "k: 38: 6\n" /* rose */ + "l: 38: 2\n" /* rose */ + "m: 19: 0\n" /* sponge */ + "n: 50: 4\n" /* torch */ + "o: 85: 0\n" /* fence */ + "p: 44: 8\n" /* step */ + "q: 35: 6\n" /* wool */ + "r: 43: 0\n" /* doubleslab */ + "s: 44: 0\n" /* step */, + + // Block data: + // Level 0 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "aaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaaaa" + /* 9 */ "aaaaaaaaaaaaa" + /* 10 */ "aaaaaaaaaaaaa" + /* 11 */ "aaaaaaaaaaaaa" + /* 12 */ "aaaaaaaaaaaaa" + /* 13 */ "aaaaaaaaaaaaa" + /* 14 */ "aaaaaaaaaaaaa" + + // Level 1 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "bbbbbbbbbbbbb" + /* 1 */ "bbbbbbbbbbbbb" + /* 2 */ "bbbaccdabbbbb" + /* 3 */ "bbbedddebbbbb" + /* 4 */ "bbbedddebbbbb" + /* 5 */ "bbbedddebbbbb" + /* 6 */ "bbbacccabbbbb" + /* 7 */ "bbbbbbbbbbbbb" + /* 8 */ "bbbbbbbbbbbbb" + /* 9 */ "bbbbbbbbbbbbb" + /* 10 */ "bbbbbbbbbbabb" + /* 11 */ "bbbbbbbbbbbbb" + /* 12 */ "bbbbbbbbbbbbb" + /* 13 */ "bbbbbbbbbbbbb" + /* 14 */ "bbbbbbbbbbbbb" + + // Level 2 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "ffff...ffffff" + /* 1 */ "f...........f" + /* 2 */ "f..ghh.g..i.f" + /* 3 */ "f..h...h..i.f" + /* 4 */ "f..h...h....f" + /* 5 */ "fi.h..jh..i.f" + /* 6 */ "f..ghhhg....f" + /* 7 */ "f.........i.f" + /* 8 */ "fii.........f" + /* 9 */ "f.k..k.i....f" + /* 10 */ "fl.i..i...g.f" + /* 11 */ "f.i..i.k....f" + /* 12 */ "f.l.k.......f" + /* 13 */ "f.....l.....f" + /* 14 */ "fffffffffffff" + + // Level 3 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ ".......n....." + /* 2 */ "...goo.g....." + /* 3 */ "...h...h....." + /* 4 */ "...o...o....." + /* 5 */ "...h...h....." + /* 6 */ "...gooog....." + /* 7 */ "............." + /* 8 */ "............." + /* 9 */ "............." + /* 10 */ "..........g.." + /* 11 */ "............." + /* 12 */ "............." + /* 13 */ "............." + /* 14 */ "............." + + // Level 4 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "...ppppp....." + /* 2 */ "..pghhhgp...." + /* 3 */ "..ph...hp...." + /* 4 */ "..ph...hp...." + /* 5 */ "..ph...hp...." + /* 6 */ "..pghhhgp...." + /* 7 */ "...ppppp....." + /* 8 */ "............." + /* 9 */ "..........q.." + /* 10 */ ".........qgq." + /* 11 */ "..........q.." + /* 12 */ "............." + /* 13 */ "............." + /* 14 */ "............." + + // Level 5 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "..rs...sr...." + /* 2 */ "..sssssss...." + /* 3 */ "...srrrs....." + /* 4 */ "...srrrs....." + /* 5 */ "...srrrs....." + /* 6 */ "..sssssss...." + /* 7 */ "..rs...sr...." + /* 8 */ "............." + /* 9 */ ".........qqq." + /* 10 */ ".........qqq." + /* 11 */ ".........qqq." + /* 12 */ "............." + /* 13 */ "............." + /* 14 */ "............." + + // Level 6 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "............." + /* 2 */ "............." + /* 3 */ "............." + /* 4 */ ".....s......." + /* 5 */ "............." + /* 6 */ "............." + /* 7 */ "............." + /* 8 */ "............." + /* 9 */ "............." + /* 10 */ "..........q.." + /* 11 */ "............." + /* 12 */ "............." + /* 13 */ "............." + /* 14 */ ".............", + + // Connectors: + "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // HouseWithSakura1 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Restaurant: + // The data has been exported from the gallery Plains, area index 61, ID 117, created by Aloe_vera + { + // Size: + 15, 10, 15, // SizeX = 15, SizeY = 10, SizeZ = 15 + + // Hitbox (relative to bounding box): + -1, 0, -1, // MinX, MinY, MinZ + 14, 9, 15, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 2\n" /* wood */ + "b:135: 0\n" /* 135 */ + "c:135: 2\n" /* 135 */ + "d:135: 1\n" /* 135 */ + "e: 17: 9\n" /* tree */ + "f:135: 3\n" /* 135 */ + "g: 85: 0\n" /* fence */ + "h: 17: 1\n" /* tree */ + "i:171: 0\n" /* carpet */ + "j:171:12\n" /* carpet */ + "k:126: 1\n" /* woodenslab */ + "l: 50: 5\n" /* torch */ + "m: 19: 0\n" /* sponge */ + "n: 35: 0\n" /* wool */ + "o: 50: 3\n" /* torch */ + "p: 50: 1\n" /* torch */ + "q: 50: 4\n" /* torch */ + "r: 35:14\n" /* wool */ + "s: 44: 8\n" /* step */ + "t: 43: 0\n" /* doubleslab */ + "u: 44: 0\n" /* step */ + "v: 17: 5\n" /* tree */, + + // Block data: + // Level 0 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmaaaaaaammmm" + /* 1 */ "maaaaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaaaam" + /* 4 */ "aaaaaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaaaaaa" + /* 9 */ "aaaaaaaaaaaaaaa" + /* 10 */ "aaaaaaaaaaaaaaa" + /* 11 */ "maaaaaaaaaaaaam" + /* 12 */ "maaaaaaaaaaaaam" + /* 13 */ "maaaaaaaaaaaaam" + /* 14 */ "mmmmaaaaaaammmm" + + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "....bcccccd...." + /* 1 */ ".aaaaaaaaaaaaa." + /* 2 */ ".aaaaaaaaaaaaa." + /* 3 */ ".aaaaaaaaaaaaa." + /* 4 */ "caaaaaaaaaaaaac" + /* 5 */ "baaaaaaaaaaaaad" + /* 6 */ "baaaaaaaaaaaaad" + /* 7 */ "baaaaaaaaaaeaad" + /* 8 */ "baaaaaaaaaaaaad" + /* 9 */ "baaaaaaaaaaaaad" + /* 10 */ "faaaaaaaaaaaaaf" + /* 11 */ ".aaaaaaaaaaaaa." + /* 12 */ ".aaaaaaaaaaaaa." + /* 13 */ ".aaaaaaaaaaaaa." + /* 14 */ "....bfffffd...." + + // Level 2 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".gggg.....gggg." + /* 2 */ ".g...........g." + /* 3 */ ".g.hhhhhhhhh.g." + /* 4 */ ".g.hiiijiiih.g." + /* 5 */ "...hikijikih..." + /* 6 */ "...hiiijiiihg.." + /* 7 */ "...hjjjjjjj...." + /* 8 */ "...hiiijiiihg.." + /* 9 */ "...hikijikih..." + /* 10 */ ".g.hiiijiiih.g." + /* 11 */ ".g.hhhhhhhhh.g." + /* 12 */ ".g...........g." + /* 13 */ ".gggg.....gggg." + /* 14 */ "..............." + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".l..g.....g..l." + /* 2 */ "..............." + /* 3 */ "...hnnnhnnnh..." + /* 4 */ ".g.n.......n.g." + /* 5 */ "...n.......n..." + /* 6 */ "...n.......hl.." + /* 7 */ "...h..........." + /* 8 */ "...n.......hl.." + /* 9 */ "...n.......n..." + /* 10 */ ".g.n.......n.g." + /* 11 */ "...hnnnhnnnh..." + /* 12 */ "..............." + /* 13 */ ".l..g.....g..l." + /* 14 */ "..............." + + // Level 4 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "....g.....g...." + /* 2 */ "..............." + /* 3 */ "...hn.nhn.nh..." + /* 4 */ ".g.n...o...n.g." + /* 5 */ "...n.......n..." + /* 6 */ "...n.......h..." + /* 7 */ "...hp......e..." + /* 8 */ "...n.......h..." + /* 9 */ "...n.......n..." + /* 10 */ ".g.n...q...n.g." + /* 11 */ "...hn.nhn.nh..." + /* 12 */ "..............." + /* 13 */ "....g.....g...." + /* 14 */ "..............." + + // Level 5 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "....g.....g...." + /* 2 */ "....ggggggg...." + /* 3 */ "...hnnnhnnnh..." + /* 4 */ ".ggn.......ngg." + /* 5 */ "..gn.......ng.." + /* 6 */ "..gn.......hg.." + /* 7 */ "..gh..r.r..ng.." + /* 8 */ "..gn.......hg.." + /* 9 */ "..gn.......ng.." + /* 10 */ ".ggn.......ngg." + /* 11 */ "...hnnnhnnnh..." + /* 12 */ "....ggggggg...." + /* 13 */ "....g.....g...." + /* 14 */ "..............." + + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "...stuuuuuts..." + /* 2 */ "..sttttttttts.." + /* 3 */ ".sthvvvhvvvhts." + /* 4 */ ".tte.......ett." + /* 5 */ ".ute.......etu." + /* 6 */ ".ute.......htu." + /* 7 */ ".uth..g.g..etu." + /* 8 */ ".ute.......htu." + /* 9 */ ".ute.......etu." + /* 10 */ ".tte.......ett." + /* 11 */ ".sthvvvhvvvhts." + /* 12 */ "..sttttttttts.." + /* 13 */ "...stuuuuuts..." + /* 14 */ "..............." + + // Level 7 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".stu.......uts." + /* 2 */ ".tu.........ut." + /* 3 */ ".u.uuuuuuuuu.u." + /* 4 */ "...utttttttu..." + /* 5 */ "...utttttttu..." + /* 6 */ "...utttttttu..." + /* 7 */ "...utttttttu..." + /* 8 */ "...utttttttu..." + /* 9 */ "...utttttttu..." + /* 10 */ "...utttttttu..." + /* 11 */ ".u.uuuuuuuuu.u." + /* 12 */ ".tu.........ut." + /* 13 */ ".stu.......uts." + /* 14 */ "..............." + + // Level 8 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".u...........u." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "..............." + /* 5 */ ".....uuuuu....." + /* 6 */ ".....utttu....." + /* 7 */ ".....utttu....." + /* 8 */ ".....utttu....." + /* 9 */ ".....uuuuu....." + /* 10 */ "..............." + /* 11 */ "..............." + /* 12 */ "..............." + /* 13 */ ".u...........u." + /* 14 */ "..............." + + // Level 9 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "..............." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ ".......u......." + /* 8 */ "..............." + /* 9 */ "..............." + /* 10 */ "..............." + /* 11 */ "..............." + /* 12 */ "..............." + /* 13 */ "..............." + /* 14 */ "...............", + + // Connectors: + "-1: 14, 1, 7: 5\n" /* Type -1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // Restaurant + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // SakuraDouble: + // The data has been exported from the gallery Plains, area index 76, ID 142, created by Aloe_vera + { + // Size: + 12, 8, 6, // SizeX = 12, SizeY = 8, SizeZ = 6 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 11, 7, 5, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 17: 1\n" /* tree */ + "d: 35: 6\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "aaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaa" + + // Level 1 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "bbbbbbbbbbbb" + /* 1 */ "bbbbbbbbbbbb" + /* 2 */ "bbabbbbbbbbb" + /* 3 */ "bbbbbbbbbabb" + /* 4 */ "bbbbbbbbbbbb" + /* 5 */ "bbbbbbbbbbbb" + + // Level 2 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "..c........." + /* 3 */ ".........c.." + /* 4 */ "............" + /* 5 */ "............" + + // Level 3 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "..c........." + /* 3 */ ".........c.." + /* 4 */ "............" + /* 5 */ "............" + + // Level 4 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "..d........." + /* 1 */ "ddddd......." + /* 2 */ "ddcdd...ddd." + /* 3 */ "ddddd...dcd." + /* 4 */ "..d.....ddd." + /* 5 */ "............" + + // Level 5 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ ".ddd........" + /* 1 */ ".ddd....ddd." + /* 2 */ "ddddd..ddddd" + /* 3 */ ".ddd...ddcdd" + /* 4 */ ".ddd...ddddd" + /* 5 */ "........ddd." + + // Level 6 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "..d......d.." + /* 2 */ ".ddd....ddd." + /* 3 */ "..d....ddddd" + /* 4 */ "........ddd." + /* 5 */ ".........d.." + + // Level 7 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "............" + /* 3 */ ".........d.." + /* 4 */ "............" + /* 5 */ "............", + + // Connectors: + "-1: 0, 2, 2: 4\n" /* Type -1, direction X- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // SakuraDouble + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // SakuraSmall: + // The data has been exported from the gallery Plains, area index 145, ID 489, created by Aloe_vera + { + // Size: + 5, 7, 5, // SizeX = 5, SizeY = 7, SizeZ = 5 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 4, 6, 4, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 17: 1\n" /* tree */ + "d: 35: 6\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 01234 */ + /* 0 */ "aaaaa" + /* 1 */ "aaaaa" + /* 2 */ "aaaaa" + /* 3 */ "aaaaa" + /* 4 */ "aaaaa" + + // Level 1 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bbbbb" + /* 2 */ "bbabb" + /* 3 */ "bbbbb" + /* 4 */ "bbbbb" + + // Level 2 + /* z\x* 01234 */ + /* 0 */ "....." + /* 1 */ "....." + /* 2 */ "..c.." + /* 3 */ "....." + /* 4 */ "....." + + // Level 3 + /* z\x* 01234 */ + /* 0 */ "....." + /* 1 */ "....." + /* 2 */ "..c.." + /* 3 */ "....." + /* 4 */ "....." + + // Level 4 + /* z\x* 01234 */ + /* 0 */ "..d.." + /* 1 */ "ddddd" + /* 2 */ "ddcdd" + /* 3 */ "ddddd" + /* 4 */ "..d.." + + // Level 5 + /* z\x* 01234 */ + /* 0 */ ".ddd." + /* 1 */ ".ddd." + /* 2 */ "ddddd" + /* 3 */ ".ddd." + /* 4 */ ".ddd." + + // Level 6 + /* z\x* 01234 */ + /* 0 */ "....." + /* 1 */ "..d.." + /* 2 */ ".ddd." + /* 3 */ "..d.." + /* 4 */ ".....", + + // Connectors: + "-1: 2, 2, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // SakuraSmall +}; // g_JapaneseVillagePrefabs + + + + + + +const cPrefab::sDef g_JapaneseVillageStartingPrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HighTemple: + // The data has been exported from the gallery Plains, area index 70, ID 133, created by Aloe_vera + { + // Size: + 11, 19, 11, // SizeX = 11, SizeY = 19, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 18, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 2\n" /* wood */ + "b:135: 0\n" /* 135 */ + "c:135: 2\n" /* 135 */ + "d:135: 1\n" /* 135 */ + "e: 17: 9\n" /* tree */ + "f:135: 3\n" /* 135 */ + "g: 85: 0\n" /* fence */ + "h: 17: 1\n" /* tree */ + "i:171: 0\n" /* carpet */ + "j: 50: 5\n" /* torch */ + "k: 35: 0\n" /* wool */ + "l: 17: 5\n" /* tree */ + "m: 19: 0\n" /* sponge */ + "n:124: 0\n" /* redstonelampon */ + "o: 69: 9\n" /* lever */ + "p: 44: 8\n" /* step */ + "q: 43: 0\n" /* doubleslab */ + "r: 44: 0\n" /* step */ + "s: 50: 4\n" /* torch */ + "t: 50: 1\n" /* torch */ + "u: 50: 3\n" /* torch */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmaaaaammm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "maaaaaaaaam" + /* 3 */ "aaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaa" + /* 8 */ "maaaaaaaaam" + /* 9 */ "maaaaaaaaam" + /* 10 */ "mmmaaaaammm" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "...bcccd..." + /* 1 */ ".aaaaaaaaa." + /* 2 */ ".aaaaaaaaa." + /* 3 */ "caaaaaaaaac" + /* 4 */ "baaaaaaaaad" + /* 5 */ "baaeaaaaaad" + /* 6 */ "baaaaaaaaad" + /* 7 */ "faaaaaaaaaf" + /* 8 */ ".aaaaaaaaa." + /* 9 */ ".aaaaaaaaa." + /* 10 */ "...bfffd..." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".ggg...ggg." + /* 2 */ ".g.......g." + /* 3 */ ".g.hhhhh.g." + /* 4 */ "...hiiih..." + /* 5 */ "....iiih..." + /* 6 */ "...hiiih..." + /* 7 */ ".g.hhhhh.g." + /* 8 */ ".g.......g." + /* 9 */ ".ggg...ggg." + /* 10 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".j.g...g.j." + /* 2 */ "..........." + /* 3 */ ".g.kkhkk.g." + /* 4 */ "...h...k..." + /* 5 */ ".......h..." + /* 6 */ "...h...k..." + /* 7 */ ".g.kkhkk.g." + /* 8 */ "..........." + /* 9 */ ".j.g...g.j." + /* 10 */ "..........." + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "...g...g..." + /* 2 */ "..........." + /* 3 */ ".g.kkhkk.g." + /* 4 */ "...h...k..." + /* 5 */ "...k...h..." + /* 6 */ "...h...k..." + /* 7 */ ".g.kkhkk.g." + /* 8 */ "..........." + /* 9 */ "...g...g..." + /* 10 */ "..........." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "...g...g..." + /* 2 */ "...ggggg..." + /* 3 */ ".gghlhlhgg." + /* 4 */ "..ge...eg.." + /* 5 */ "..ge.nohg.." + /* 6 */ "..ge...eg.." + /* 7 */ ".gghlhlhgg." + /* 8 */ "...ggggg..." + /* 9 */ "...g...g..." + /* 10 */ "..........." + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..pqrrrqp.." + /* 2 */ ".pqqqqqqqp." + /* 3 */ ".qqhkkkhqq." + /* 4 */ ".rqkhhhkqr." + /* 5 */ ".rqkhhhkqr." + /* 6 */ ".rqkhhhkqr." + /* 7 */ ".qqhkkkhqq." + /* 8 */ ".pqqqqqqqp." + /* 9 */ "..pqrrrqp.." + /* 10 */ "..........." + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".qr.....rq." + /* 2 */ ".........r." + /* 3 */ "...hhhhh..." + /* 4 */ "...hiiih..." + /* 5 */ "....iiih..." + /* 6 */ "...hiiih..." + /* 7 */ "...hhhhh..." + /* 8 */ ".r.......r." + /* 9 */ ".qr.....rq." + /* 10 */ "..........." + + // Level 8 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "...kkhkk..." + /* 4 */ "...h...k..." + /* 5 */ ".......h..." + /* 6 */ "...h...k..." + /* 7 */ "...kkhkk..." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 9 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ ".....s....." + /* 3 */ "...kkhkk..." + /* 4 */ "...h...k..." + /* 5 */ "...k...ht.." + /* 6 */ "...h...k..." + /* 7 */ "...kkhkk..." + /* 8 */ ".....u....." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 10 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "...ggggg..." + /* 3 */ "..ghlhlhg.." + /* 4 */ "..ge...eg.." + /* 5 */ "..ge.nohg.." + /* 6 */ "..ge...eg.." + /* 7 */ "..ghlhlhg.." + /* 8 */ "...ggggg..." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 11 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..prrrrrp.." + /* 2 */ ".pqqqqqqqp." + /* 3 */ ".qqhkkkhqq." + /* 4 */ ".rqkhhhkqr." + /* 5 */ ".rqkhhhkqr." + /* 6 */ ".rqkhhhkqr." + /* 7 */ ".qqhkkkhqr." + /* 8 */ ".pqqqqqqqp." + /* 9 */ "..pqrrrqp.." + /* 10 */ "..........." + + // Level 12 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".qr.....rq." + /* 2 */ ".r.......r." + /* 3 */ "...hhhhh..." + /* 4 */ "...hiiih..." + /* 5 */ "....iiih..." + /* 6 */ "...hiiih..." + /* 7 */ "...hhhhh..." + /* 8 */ ".r.......r." + /* 9 */ ".qr.....rq." + /* 10 */ "..........." + + // Level 13 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "...kkhkk..." + /* 4 */ "...h...k..." + /* 5 */ ".......h..." + /* 6 */ "...h...k..." + /* 7 */ "...kkhkk..." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 14 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ ".....s....." + /* 3 */ "...kkhkk..." + /* 4 */ "...h...k..." + /* 5 */ "...k...ht.." + /* 6 */ "...h...k..." + /* 7 */ "...kkhkk..." + /* 8 */ ".....u....." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 15 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "...ggggg..." + /* 3 */ "..ghlhlhg.." + /* 4 */ "..ge...eg.." + /* 5 */ "..ge.nohg.." + /* 6 */ "..ge...eg.." + /* 7 */ "..ghlhlhg.." + /* 8 */ "...ggggg..." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 16 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..pqrrrqp.." + /* 2 */ ".pqqqqqqqp." + /* 3 */ ".qqrrrrrqq." + /* 4 */ ".rqrrrrrqr." + /* 5 */ ".rqrrrrrqr." + /* 6 */ ".rqrrrrrqr." + /* 7 */ ".qqrrrrrqq." + /* 8 */ ".pqqqqqqqp." + /* 9 */ "..pqrrrqp.." + /* 10 */ "..........." + + // Level 17 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".qr.....rq." + /* 2 */ ".rr.....rr." + /* 3 */ "...rrrrr..." + /* 4 */ "...rqqqr..." + /* 5 */ "...rqqqr..." + /* 6 */ "...rqqqr..." + /* 7 */ "...rrrrr..." + /* 8 */ ".rr.....rr." + /* 9 */ ".qr.....rq." + /* 10 */ "..........." + + // Level 18 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ ".....r....." + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "...........", + + // Connectors: + "2: 0, 1, 5: 4\n" /* Type 2, direction X- */ + "2: 5, 1, 0: 2\n" /* Type 2, direction Z- */ + "2: 10, 1, 5: 5\n" /* Type 2, direction X+ */ + "2: 5, 1, 10: 3\n" /* Type 2, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // HighTemple + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Well: + // The data has been exported from the gallery Plains, area index 143, ID 487, created by STR_Warrior + { + // Size: + 7, 14, 7, // SizeX = 7, SizeY = 14, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 13, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 1: 0\n" /* stone */ + "b: 4: 0\n" /* cobblestone */ + "c: 8: 0\n" /* water */ + "d: 3: 0\n" /* dirt */ + "e: 2: 0\n" /* grass */ + "f: 13: 0\n" /* gravel */ + "g: 67: 1\n" /* stairs */ + "h: 67: 2\n" /* stairs */ + "i: 67: 0\n" /* stairs */ + "j: 67: 3\n" /* stairs */ + "k: 85: 0\n" /* fence */ + "l: 44: 8\n" /* step */ + "m: 19: 0\n" /* sponge */ + "n: 44: 0\n" /* step */ + "o: 43: 0\n" /* doubleslab */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "aaaaaaa" + /* 2 */ "aaaaaaa" + /* 3 */ "aaaaaaa" + /* 4 */ "aaaaaaa" + /* 5 */ "aaaaaaa" + /* 6 */ "aaaaaaa" + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcc.ba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "ddddddd" + /* 1 */ "dbbbbbd" + /* 2 */ "dbcccbd" + /* 3 */ "dbcccbd" + /* 4 */ "dbcccbd" + /* 5 */ "dbbbbbd" + /* 6 */ "ddddddd" + + // Level 6 + /* z\x* 0123456 */ + /* 0 */ "ddddddd" + /* 1 */ "dbbbbbd" + /* 2 */ "dbcccbd" + /* 3 */ "dbcccbd" + /* 4 */ "dbcccbd" + /* 5 */ "dbbbbbd" + /* 6 */ "ddddddd" + + // Level 7 + /* z\x* 0123456 */ + /* 0 */ "ddddddd" + /* 1 */ "dbbbbbd" + /* 2 */ "dbcccbd" + /* 3 */ "dbcccbd" + /* 4 */ "dbcccbd" + /* 5 */ "dbbbbbd" + /* 6 */ "ddddddd" + + // Level 8 + /* z\x* 0123456 */ + /* 0 */ "eefffee" + /* 1 */ "ebbbbbe" + /* 2 */ "fbcccbf" + /* 3 */ "fbcccbf" + /* 4 */ "fbcccbf" + /* 5 */ "ebbbbbe" + /* 6 */ "eefffee" + + // Level 9 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".bghib." + /* 2 */ ".j...j." + /* 3 */ ".i...g." + /* 4 */ ".h...h." + /* 5 */ ".bgjib." + /* 6 */ "......." + + // Level 10 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".k...k." + /* 2 */ "......." + /* 3 */ "......." + /* 4 */ "......." + /* 5 */ ".k...k." + /* 6 */ "......." + + // Level 11 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".k...k." + /* 2 */ "......." + /* 3 */ "......." + /* 4 */ "......." + /* 5 */ ".k...k." + /* 6 */ "......." + + // Level 12 + /* z\x* 0123456 */ + /* 0 */ ".lnnnl." + /* 1 */ "loooool" + /* 2 */ "nooooon" + /* 3 */ "nooooon" + /* 4 */ "nooooon" + /* 5 */ "loooool" + /* 6 */ ".lnnnl." + + // Level 13 + /* z\x* 0123456 */ + /* 0 */ "n.....n" + /* 1 */ "......." + /* 2 */ "..nnn.." + /* 3 */ "..non.." + /* 4 */ "..nnn.." + /* 5 */ "......." + /* 6 */ "n.....n", + + // Connectors: + "2: 0, 9, 3: 4\n" /* Type 2, direction X- */ + "2: 3, 9, 0: 2\n" /* Type 2, direction Z- */ + "2: 6, 9, 3: 5\n" /* Type 2, direction X+ */ + "2: 3, 9, 6: 3\n" /* Type 2, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // Well +}; + + + + + +// The prefab counts: + +const size_t g_JapaneseVillagePrefabsCount = ARRAYCOUNT(g_JapaneseVillagePrefabs); + +const size_t g_JapaneseVillageStartingPrefabsCount = ARRAYCOUNT(g_JapaneseVillageStartingPrefabs); + diff --git a/src/Generating/Prefabs/JapaneseVillagePrefabs.h b/src/Generating/Prefabs/JapaneseVillagePrefabs.h new file mode 100644 index 000000000..501b6c1cd --- /dev/null +++ b/src/Generating/Prefabs/JapaneseVillagePrefabs.h @@ -0,0 +1,15 @@ + +// JapaneseVillagePrefabs.h + +// Declares the prefabs in the group JapaneseVillage + +#include "../Prefab.h" + + + + + +extern const cPrefab::sDef g_JapaneseVillagePrefabs[]; +extern const cPrefab::sDef g_JapaneseVillageStartingPrefabs[]; +extern const size_t g_JapaneseVillagePrefabsCount; +extern const size_t g_JapaneseVillageStartingPrefabsCount; diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index bcce62af5..62822c33b 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -5,6 +5,7 @@ #include "Globals.h" #include "VillageGen.h" +#include "Prefabs/JapaneseVillagePrefabs.h" #include "Prefabs/PlainsVillagePrefabs.h" #include "Prefabs/SandVillagePrefabs.h" #include "Prefabs/SandFlatRoofVillagePrefabs.h" @@ -59,6 +60,7 @@ public: cPrefab * RoadPiece = new cPrefab(BA, 1); RoadPiece->AddConnector(0, 0, 1, BLOCK_FACE_XM, -2); RoadPiece->AddConnector(len - 1, 0, 1, BLOCK_FACE_XP, -2); + RoadPiece->SetDefaultWeight(100); // Add the road connectors: for (int x = 1; x < len; x += 12) @@ -84,8 +86,8 @@ public: // cPrefabPiecePool overrides: virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override { - // Roads cannot branch T-wise (appending -2 connector to a +2 connector): - if ((a_ExistingConnector.m_Type == 2) && (a_PlacedPiece.GetDepth() > 0)) + // Roads cannot branch T-wise (appending -2 connector to a +2 connector on a 1-high piece): + if ((a_ExistingConnector.m_Type == 2) && (a_PlacedPiece.GetDepth() > 0) && (a_PlacedPiece.GetPiece().GetSize().y == 1)) { return 0; } @@ -283,6 +285,9 @@ static cVillagePiecePool g_SandFlatRoofVillage(g_SandFlatRoofVillagePrefabs, g_S /** The prefabs for the plains village. */ static cVillagePiecePool g_PlainsVillage(g_PlainsVillagePrefabs, g_PlainsVillagePrefabsCount, g_PlainsVillageStartingPrefabs, g_PlainsVillageStartingPrefabsCount); +/** The prefabs for the Japanese village. */ +static cVillagePiecePool g_JapaneseVillage(g_JapaneseVillagePrefabs, g_JapaneseVillagePrefabsCount, g_JapaneseVillageStartingPrefabs, g_JapaneseVillageStartingPrefabsCount); + @@ -316,6 +321,8 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ cVillagePiecePool * VillagePrefabs = NULL; BLOCKTYPE RoadBlock = E_BLOCK_GRAVEL; int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 11; + cVillagePiecePool * PlainsVillage = (rnd % 2 == 0) ? &g_PlainsVillage : &g_JapaneseVillage; + cVillagePiecePool * DesertVillage = (rnd % 2 == 0) ? &g_SandVillage : &g_SandFlatRoofVillage; for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++) { switch (Biomes[i]) @@ -324,7 +331,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ case biDesertM: { // These biomes allow sand villages - VillagePrefabs = (rnd % 2 == 0) ? &g_SandVillage : &g_SandFlatRoofVillage; + VillagePrefabs = DesertVillage; // RoadBlock = E_BLOCK_SANDSTONE; break; } @@ -334,7 +341,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ case biSunflowerPlains: { // These biomes allow plains-style villages - VillagePrefabs = &g_PlainsVillage; + VillagePrefabs = PlainsVillage; break; } default: -- cgit v1.2.3 From 944d29c0ae3929471a11ea11aa98441bc31f4d7d Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 24 May 2014 14:09:51 +0100 Subject: inject TestGlobals.h correctly --- src/ChunkData.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 162803292..79029f0cf 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -1,5 +1,9 @@ +#ifdef TEST_GLOBALS +#include "TestGlobals.h" +#else #include "Globals.h" +#endif #include "ChunkData.h" cChunkData::cChunkData() @@ -39,7 +43,7 @@ cChunkData::~cChunkData() other.IsOwner = false; } - cChunkData::cChunkData& operator=(const cChunkData& other) + cChunkData& cChunkData::operator=(const cChunkData& other) { if (&other != this) { @@ -71,7 +75,7 @@ cChunkData::~cChunkData() } } - cChunkData::cChunkData& operator=(cChunkData&& other) + cChunkData& cChunkData::operator=(cChunkData&& other) { if (&other != this) { @@ -230,7 +234,7 @@ NIBBLETYPE cChunkData::GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const return 0; } -cChunkData cChunkData::cChunkData::Copy() const +cChunkData cChunkData::Copy() const { cChunkData copy; for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) -- cgit v1.2.3 From ee929793f09c431693e1bef7edd77213ba412f60 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 25 May 2014 13:46:34 +0100 Subject: Hopefully fixed piston duplication issues * Fixes #879 * Fixes #714 --- src/Blocks/BlockDropSpenser.h | 4 +- src/Blocks/BlockFurnace.h | 4 +- src/Blocks/BlockMobHead.h | 2 +- src/Blocks/BlockPiston.cpp | 166 +++++++++++++- src/Blocks/BlockPiston.h | 129 ++++++++++- src/Chunk.cpp | 11 +- src/Chunk.h | 4 +- src/ChunkMap.cpp | 4 +- src/ChunkMap.h | 2 +- src/ClientHandle.cpp | 1 - src/Piston.cpp | 297 ------------------------- src/Piston.h | 110 --------- src/Simulator/IncrementalRedstoneSimulator.cpp | 9 +- src/World.cpp | 48 +++- src/World.h | 18 +- 15 files changed, 372 insertions(+), 437 deletions(-) delete mode 100644 src/Piston.cpp delete mode 100644 src/Piston.h (limited to 'src') diff --git a/src/Blocks/BlockDropSpenser.h b/src/Blocks/BlockDropSpenser.h index 88b61a418..e2b3039fd 100644 --- a/src/Blocks/BlockDropSpenser.h +++ b/src/Blocks/BlockDropSpenser.h @@ -5,7 +5,7 @@ #pragma once -#include "../Piston.h" +#include "../Blocks/BlockPiston.h" #include "MetaRotator.h" @@ -32,7 +32,7 @@ public: a_BlockType = m_BlockType; // FIXME: Do not use cPiston class for dispenser placement! - a_BlockMeta = cPiston::RotationPitchToMetaData(a_Player->GetYaw(), a_Player->GetPitch()); + a_BlockMeta = cBlockPistonHandler::RotationPitchToMetaData(a_Player->GetYaw(), a_Player->GetPitch()); return true; } diff --git a/src/Blocks/BlockFurnace.h b/src/Blocks/BlockFurnace.h index a7a807957..74582c3b3 100644 --- a/src/Blocks/BlockFurnace.h +++ b/src/Blocks/BlockFurnace.h @@ -3,7 +3,7 @@ #include "BlockEntity.h" #include "../World.h" -#include "../Piston.h" +#include "../Blocks/BlockPiston.h" #include "MetaRotator.h" @@ -35,7 +35,7 @@ public: a_BlockType = m_BlockType; // FIXME: Do not use cPiston class for furnace placement! - a_BlockMeta = cPiston::RotationPitchToMetaData(a_Player->GetYaw(), 0); + a_BlockMeta = cBlockPistonHandler::RotationPitchToMetaData(a_Player->GetYaw(), 0); return true; } diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index b7629b07c..9855574ad 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -68,7 +68,7 @@ public: public: cPlayerCallback(const Vector3f & a_Pos) : m_Pos(a_Pos) {} - } PlayerCallback(Vector3f(a_BlockX, a_BlockY, a_BlockZ)); + } PlayerCallback(Vector3f((float)a_BlockX, (float)a_BlockY, (float)a_BlockZ)); a_World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, CallbackA); diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index 542eb33b5..f758013dc 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -4,14 +4,14 @@ #include "../Item.h" #include "../World.h" #include "../Entities/Player.h" -#include "../Piston.h" +#include "BlockInServerPluginInterface.h" #define AddPistonDir(x, y, z, dir, amount) \ - switch (dir) \ + switch (dir & 0x07) \ { \ case 0: (y) -= (amount); break; \ case 1: (y) += (amount); break; \ @@ -19,8 +19,15 @@ case 3: (z) += (amount); break; \ case 4: (x) -= (amount); break; \ case 5: (x) += (amount); break; \ + default: \ + { \ + LOGWARNING("%s: invalid direction %d, ignoring", __FUNCTION__, dir & 0x07); \ + break; \ + } \ } +#define PISTON_TICK_DELAY 1 + @@ -40,7 +47,7 @@ void cBlockPistonHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorld int newX = a_BlockX; int newY = a_BlockY; int newZ = a_BlockZ; - AddPistonDir(newX, newY, newZ, OldMeta & ~(8), 1); + AddPistonDir(newX, newY, newZ, OldMeta, 1); if (a_ChunkInterface.GetBlock(newX, newY, newZ) == E_BLOCK_PISTON_EXTENSION) { @@ -60,7 +67,7 @@ bool cBlockPistonHandler::GetPlacementBlockTypeMeta( ) { a_BlockType = m_BlockType; - a_BlockMeta = cPiston::RotationPitchToMetaData(a_Player->GetYaw(), a_Player->GetPitch()); + a_BlockMeta = RotationPitchToMetaData(a_Player->GetYaw(), a_Player->GetPitch()); return true; } @@ -68,6 +75,155 @@ bool cBlockPistonHandler::GetPlacementBlockTypeMeta( +int cBlockPistonHandler::FirstPassthroughBlock(int pistonX, int pistonY, int pistonZ, NIBBLETYPE pistonmeta, cWorld * a_World) +{ + // Examine each of the 12 blocks ahead of the piston: + for (int ret = 0; ret < 12; ret++) + { + BLOCKTYPE currBlock; + NIBBLETYPE currMeta; + AddPistonDir(pistonX, pistonY, pistonZ, pistonmeta, 1); + a_World->GetBlockTypeMeta(pistonX, pistonY, pistonZ, currBlock, currMeta); + if (CanBreakPush(currBlock)) + { + // This block breaks when pushed, extend up to here + return ret; + } + if (!CanPush(currBlock, currMeta)) + { + // This block cannot be pushed at all, the piston can't extend + return -1; + } + } + // There is no space for the blocks to move, piston can't extend + return -1; +} + + + + + +void cBlockPistonHandler::ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) +{ + BLOCKTYPE pistonBlock; + NIBBLETYPE pistonMeta; + a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta); + + if (IsExtended(pistonMeta)) + { + // Already extended, bail out + return; + } + + int dist = FirstPassthroughBlock(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, a_World); + if (dist < 0) + { + // FirstPassthroughBlock says piston can't push anything, bail out + return; + } + + a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 0, pistonMeta, pistonBlock); + a_World->BroadcastSoundEffect("tile.piston.out", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.7f); + + // Drop the breakable block in the line, if appropriate: + AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, dist + 1); // "a_Block" now at the breakable / empty block + BLOCKTYPE currBlock; + NIBBLETYPE currMeta; + a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, currBlock, currMeta); + if (currBlock != E_BLOCK_AIR) + { + cBlockHandler * Handler = BlockHandler(currBlock); + if (Handler->DoesDropOnUnsuitable()) + { + cChunkInterface ChunkInterface(a_World->GetChunkMap()); + cBlockInServerPluginInterface PluginInterface(*a_World); + Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, NULL, a_BlockX, a_BlockY, a_BlockZ); + } + } + + // Push blocks, from the furthest to the nearest: + int oldx = a_BlockX, oldy = a_BlockY, oldz = a_BlockZ; + NIBBLETYPE currBlockMeta; + for (int i = dist + 1; i > 1; i--) + { + AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1); + a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, currBlock, currBlockMeta); + a_World->SetBlock(oldx, oldy, oldz, currBlock, currBlockMeta, false); + a_World->ScheduleTask(PISTON_TICK_DELAY, new cWorld::cTaskSendBlockToAllPlayers(oldx, oldy, oldz)); + oldx = a_BlockX; + oldy = a_BlockY; + oldz = a_BlockZ; + } + + int extx = a_BlockX; + int exty = a_BlockY; + int extz = a_BlockZ; + AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1); + // "a_Block" now at piston body, "ext" at future extension + + a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta | 0x8); + a_World->SetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0), false); + a_World->ScheduleTask(PISTON_TICK_DELAY, new cWorld::cTaskSendBlockToAllPlayers(extx, exty, extz)); +} + + + + + +void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) +{ + BLOCKTYPE pistonBlock; + NIBBLETYPE pistonMeta; + a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta); + + if (!IsExtended(pistonMeta)) + { + // Already retracted, bail out + return; + } + + // Check the extension: + AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, 1); + if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) != E_BLOCK_PISTON_EXTENSION) + { + LOGD("%s: Piston without an extension - still extending, or just in an invalid state?", __FUNCTION__); + return; + } + + AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1); + a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta & ~(8)); + a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 1, pistonMeta & ~(8), pistonBlock); + a_World->BroadcastSoundEffect("tile.piston.in", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.7f); + AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, 1); + + // Retract the extension, pull block if appropriate + if (IsSticky(pistonBlock)) + { + int tempx = a_BlockX, tempy = a_BlockY, tempz = a_BlockZ; + AddPistonDir(tempx, tempy, tempz, pistonMeta, 1); + BLOCKTYPE tempBlock; + NIBBLETYPE tempMeta; + a_World->GetBlockTypeMeta(tempx, tempy, tempz, tempBlock, tempMeta); + if (CanPull(tempBlock, tempMeta)) + { + // Pull the block + a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, tempBlock, tempMeta, false); + a_World->SetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0, false); + a_World->ScheduleTask(PISTON_TICK_DELAY + 1, new cWorld::cTaskSendBlockToAllPlayers(a_BlockX, a_BlockY, a_BlockZ)); + a_World->ScheduleTask(PISTON_TICK_DELAY, new cWorld::cTaskSendBlockToAllPlayers(tempx, tempy, tempz)); + return; + } + } + + // Retract without pulling + a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0, false); + a_World->ScheduleTask(PISTON_TICK_DELAY + 1, new cWorld::cTaskSendBlockToAllPlayers(a_BlockX, a_BlockY, a_BlockZ)); +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cBlockPistonHeadHandler: @@ -87,7 +243,7 @@ void cBlockPistonHeadHandler::OnDestroyedByPlayer(cChunkInterface & a_ChunkInter int newX = a_BlockX; int newY = a_BlockY; int newZ = a_BlockZ; - AddPistonDir(newX, newY, newZ, OldMeta & ~(8), -1); + AddPistonDir(newX, newY, newZ, OldMeta, -1); BLOCKTYPE Block = a_ChunkInterface.GetBlock(newX, newY, newZ); if ((Block == E_BLOCK_STICKY_PISTON) || (Block == E_BLOCK_PISTON)) diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index 7632b5e5a..d7c92925b 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -21,6 +21,133 @@ public: int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override; + + static NIBBLETYPE RotationPitchToMetaData(double a_Rotation, double a_Pitch) + { + if (a_Pitch >= 50) + { + return 0x1; + } + else if (a_Pitch <= -50) + { + return 0x0; + } + else + { + a_Rotation += 90 + 45; // So its not aligned with axis + + if (a_Rotation > 360) + { + a_Rotation -= 360; + } + if ((a_Rotation >= 0) && (a_Rotation < 90)) + { + return 0x4; + } + else if ((a_Rotation >= 180) && (a_Rotation < 270)) + { + return 0x5; + } + else if ((a_Rotation >= 90) && (a_Rotation < 180)) + { + return 0x2; + } + else + { + return 0x3; + } + } + } + + static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) + { + switch (a_MetaData) + { + case 0x0: return BLOCK_FACE_YM; + case 0x1: return BLOCK_FACE_YP; + case 0x2: return BLOCK_FACE_ZM; + case 0x3: return BLOCK_FACE_ZP; + case 0x4: return BLOCK_FACE_XM; + case 0x5: return BLOCK_FACE_XP; + default: + { + ASSERT(!"Invalid Metadata"); + return BLOCK_FACE_NONE; + } + } + } + + static void ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); + static void RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); + +private: + + /// Returns true if the piston (specified by blocktype) is a sticky piston + static inline bool IsSticky(BLOCKTYPE a_BlockType) { return (a_BlockType == E_BLOCK_STICKY_PISTON); } + + /// Returns true if the piston (with the specified meta) is extended + static inline bool IsExtended(NIBBLETYPE a_PistonMeta) { return ((a_PistonMeta & 0x8) != 0x0); } + + /// Returns true if the specified block can be pushed by a piston (and left intact) + static inline bool CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) + { + switch (a_BlockType) + { + case E_BLOCK_ANVIL: + case E_BLOCK_BED: + case E_BLOCK_BEDROCK: + case E_BLOCK_BREWING_STAND: + case E_BLOCK_CHEST: + case E_BLOCK_COMMAND_BLOCK: + case E_BLOCK_DISPENSER: + case E_BLOCK_DROPPER: + case E_BLOCK_ENCHANTMENT_TABLE: + case E_BLOCK_END_PORTAL: + case E_BLOCK_END_PORTAL_FRAME: + case E_BLOCK_FURNACE: + case E_BLOCK_LIT_FURNACE: + case E_BLOCK_HOPPER: + case E_BLOCK_JUKEBOX: + case E_BLOCK_MOB_SPAWNER: + case E_BLOCK_NETHER_PORTAL: + case E_BLOCK_NOTE_BLOCK: + case E_BLOCK_OBSIDIAN: + case E_BLOCK_PISTON_EXTENSION: + { + return false; + } + case E_BLOCK_STICKY_PISTON: + case E_BLOCK_PISTON: + { + // A piston can only be pushed if retracted: + return !IsExtended(a_BlockMeta); + } + } + return true; + } + + /// Returns true if the specified block can be pushed by a piston and broken / replaced + static inline bool CanBreakPush(BLOCKTYPE a_BlockType) { return cBlockInfo::IsPistonBreakable(a_BlockType); } + + /// Returns true if the specified block can be pulled by a sticky piston + static inline bool CanPull(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) + { + switch (a_BlockType) + { + case E_BLOCK_LAVA: + case E_BLOCK_STATIONARY_LAVA: + case E_BLOCK_STATIONARY_WATER: + case E_BLOCK_WATER: + { + return false; + } + } + + return CanBreakPush(a_BlockType) ? false /* CanBreakPush returns true, but we need false to prevent pulling */ : CanPush(a_BlockType, a_BlockMeta); + } + + /// Returns how many blocks the piston has to push (where the first free space is); < 0 when unpushable + static int FirstPassthroughBlock(int a_PistonX, int a_PistonY, int a_PistonZ, NIBBLETYPE a_PistonMeta, cWorld * a_World); } ; @@ -40,7 +167,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { // No pickups - // Also with 1.7, the item forms of these tecnical blocks have been removed, so giving someone this will crash their client... + // Also with 1.7, the item forms of these technical blocks have been removed, so giving someone this will crash their client... } } ; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index ca536e89a..6bd68459c 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1462,9 +1462,9 @@ void cChunk::CalculateHeightmap(const BLOCKTYPE * a_BlockTypes) -void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) +void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients) { - FastSetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta); + FastSetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta, a_SendToClients); const int index = MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ); @@ -1565,7 +1565,7 @@ void cChunk::QueueTickBlockNeighbors(int a_RelX, int a_RelY, int a_RelZ) -void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta) +void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients) { ASSERT(!((a_RelX < 0) || (a_RelX >= Width) || (a_RelY < 0) || (a_RelY >= Height) || (a_RelZ < 0) || (a_RelZ >= Width))); @@ -1589,13 +1589,14 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT // The client doesn't need to distinguish between stationary and nonstationary fluids: if ( - (OldBlockMeta != a_BlockMeta) || // Different meta always gets sent to the client + a_SendToClients && + ((OldBlockMeta != a_BlockMeta) || // Different meta always gets sent to the client !( ((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water ((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water ((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water ((OldBlockType == E_BLOCK_LAVA) && (a_BlockType == E_BLOCK_STATIONARY_LAVA)) // Replacing water with stationary water - ) + )) ) { m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta)); diff --git a/src/Chunk.h b/src/Chunk.h index 84ec35496..8eeb183e3 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -139,7 +139,7 @@ public: cWorld * GetWorld(void) const { return m_World; } - void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ); + void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true); // SetBlock() does a lot of work (heightmap, tickblocks, blockentities) so a BlockIdx version doesn't make sense void SetBlock( const Vector3i & a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) { SetBlock( a_RelBlockPos.x, a_RelBlockPos.y, a_RelBlockPos.z, a_BlockType, a_BlockMeta ); } @@ -152,7 +152,7 @@ public: /** Queues all 6 neighbors of the specified block for ticking (m_ToTickQueue). If any are outside the chunk, relays the checking to the proper neighboring chunk */ void QueueTickBlockNeighbors(int a_RelX, int a_RelY, int a_RelZ); - void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta ); // Doesn't force block updates on neighbors, use for simple changes such as grass growing etc. + void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true); // Doesn't force block updates on neighbors, use for simple changes such as grass growing etc. BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const; BLOCKTYPE GetBlock(int a_BlockIdx) const; void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta); diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index d7164a6a5..3c87403ff 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1255,7 +1255,7 @@ void cChunkMap::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYP -void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta) +void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients) { cChunkInterface ChunkInterface(this); if (a_BlockType == E_BLOCK_AIR) @@ -1270,7 +1270,7 @@ void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); if ((Chunk != NULL) && Chunk->IsValid()) { - Chunk->SetBlock(X, Y, Z, a_BlockType, a_BlockMeta ); + Chunk->SetBlock(X, Y, Z, a_BlockType, a_BlockMeta, a_SendToClients); m_World->GetSimulatorManager()->WakeUp(a_BlockX, a_BlockY, a_BlockZ, Chunk); } BlockHandler(a_BlockType)->OnPlaced(ChunkInterface, a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 9d973f2a9..a64942112 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -152,7 +152,7 @@ public: NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ); NIBBLETYPE GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ); void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockMeta); - void SetBlock (cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta); + void SetBlock (cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true); void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType = E_BLOCK_AIR); bool GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta); bool GetBlockInfo (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight); diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 83b21ae3c..433b7edf7 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -12,7 +12,6 @@ #include "BlockEntities/SignEntity.h" #include "UI/Window.h" #include "Item.h" -#include "Piston.h" #include "Mobs/Monster.h" #include "ChatColor.h" #include "OSSupport/Socket.h" diff --git a/src/Piston.cpp b/src/Piston.cpp deleted file mode 100644 index b21d576f3..000000000 --- a/src/Piston.cpp +++ /dev/null @@ -1,297 +0,0 @@ -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Piston.h" -#include "ChunkDef.h" -#include "Entities/Pickup.h" -#include "Item.h" -#include "Root.h" -#include "ClientHandle.h" -#include "World.h" -#include "Server.h" -#include "Blocks/BlockHandler.h" -#include "BlockInServerPluginInterface.h" - - - - - -/// Number of ticks that the piston extending / retracting waits before setting the block -const int PISTON_TICK_DELAY = 1; - - - - - -cPiston::cPiston(cWorld * a_World) - : m_World(a_World) -{ -} - - - - - -int cPiston::FirstPassthroughBlock(int pistonX, int pistonY, int pistonZ, NIBBLETYPE pistonmeta) -{ - // Examine each of the 12 blocks ahead of the piston: - for (int ret = 0; ret < 12; ret++) - { - BLOCKTYPE currBlock; - NIBBLETYPE currMeta; - AddDir(pistonX, pistonY, pistonZ, pistonmeta, 1); - m_World->GetBlockTypeMeta(pistonX, pistonY, pistonZ, currBlock, currMeta); - if (CanBreakPush(currBlock, currMeta)) - { - // This block breaks when pushed, extend up to here - return ret; - } - if (!CanPush(currBlock, currMeta)) - { - // This block cannot be pushed at all, the piston can't extend - return -1; - } - } - // There is no space for the blocks to move, piston can't extend - return -1; -} - - - - - -void cPiston::ExtendPiston(int pistx, int pisty, int pistz) -{ - BLOCKTYPE pistonBlock; - NIBBLETYPE pistonMeta; - m_World->GetBlockTypeMeta(pistx, pisty, pistz, pistonBlock, pistonMeta); - - if (IsExtended(pistonMeta)) - { - // Already extended, bail out - return; - } - - int dist = FirstPassthroughBlock(pistx, pisty, pistz, pistonMeta); - if (dist < 0) - { - // FirstPassthroughBlock says piston can't push anything, bail out - return; - } - - m_World->BroadcastBlockAction(pistx, pisty, pistz, 0, pistonMeta, pistonBlock); - m_World->BroadcastSoundEffect("tile.piston.out", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f); - - // Drop the breakable block in the line, if appropriate: - AddDir(pistx, pisty, pistz, pistonMeta, dist + 1); // "pist" now at the breakable / empty block - BLOCKTYPE currBlock; - NIBBLETYPE currMeta; - m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currMeta); - if (currBlock != E_BLOCK_AIR) - { - cBlockHandler * Handler = BlockHandler(currBlock); - if (Handler->DoesDropOnUnsuitable()) - { - cChunkInterface ChunkInterface(m_World->GetChunkMap()); - cBlockInServerPluginInterface PluginInterface(*m_World); - Handler->DropBlock(ChunkInterface, *m_World, PluginInterface, NULL, pistx, pisty, pistz); - } - } - - // Push blocks, from the furthest to the nearest: - int oldx = pistx, oldy = pisty, oldz = pistz; - NIBBLETYPE currBlockMeta; - for (int i = dist + 1; i > 1; i--) - { - AddDir(pistx, pisty, pistz, pistonMeta, -1); - m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currBlockMeta); - m_World->QueueSetBlock( oldx, oldy, oldz, currBlock, currBlockMeta, PISTON_TICK_DELAY); - oldx = pistx; - oldy = pisty; - oldz = pistz; - } - - int extx = pistx; - int exty = pisty; - int extz = pistz; - AddDir(pistx, pisty, pistz, pistonMeta, -1); - // "pist" now at piston body, "ext" at future extension - - m_World->SetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta | 0x8); - m_World->QueueSetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0), PISTON_TICK_DELAY); -} - - - - - -void cPiston::RetractPiston(int pistx, int pisty, int pistz) -{ - BLOCKTYPE pistonBlock; - NIBBLETYPE pistonMeta; - m_World->GetBlockTypeMeta(pistx, pisty, pistz, pistonBlock, pistonMeta); - - if (!IsExtended(pistonMeta)) - { - // Already retracted, bail out - return; - } - - // Check the extension: - AddDir(pistx, pisty, pistz, pistonMeta, 1); - if (m_World->GetBlock(pistx, pisty, pistz) != E_BLOCK_PISTON_EXTENSION) - { - LOGD("%s: Piston without an extension - still extending, or just in an invalid state?", __FUNCTION__); - return; - } - - AddDir(pistx, pisty, pistz, pistonMeta, -1); - m_World->SetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8)); - m_World->BroadcastBlockAction(pistx, pisty, pistz, 1, pistonMeta & ~(8), pistonBlock); - m_World->BroadcastSoundEffect("tile.piston.in", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f); - AddDir(pistx, pisty, pistz, pistonMeta, 1); - - // Retract the extension, pull block if appropriate - if (IsSticky(pistonBlock)) - { - int tempx = pistx, tempy = pisty, tempz = pistz; - AddDir(tempx, tempy, tempz, pistonMeta, 1); - BLOCKTYPE tempBlock; - NIBBLETYPE tempMeta; - m_World->GetBlockTypeMeta(tempx, tempy, tempz, tempBlock, tempMeta); - if (CanPull(tempBlock, tempMeta)) - { - // Pull the block - m_World->QueueSetBlock(pistx, pisty, pistz, tempBlock, tempMeta, PISTON_TICK_DELAY); - m_World->QueueSetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY); - } - else - { - // Retract without pulling - m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY); - } - } - else - { - m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY); - } -} - - - - - -bool cPiston::IsExtended(NIBBLETYPE a_PistonMeta) -{ - return ((a_PistonMeta & 0x8) != 0x0); -} - - - - - -bool cPiston::IsSticky(BLOCKTYPE a_BlockType) -{ - return (a_BlockType == E_BLOCK_STICKY_PISTON); -} - - - - - -bool cPiston::CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) -{ - switch (a_BlockType) - { - case E_BLOCK_ANVIL: - case E_BLOCK_BED: - case E_BLOCK_BEDROCK: - case E_BLOCK_BREWING_STAND: - case E_BLOCK_CHEST: - case E_BLOCK_COMMAND_BLOCK: - case E_BLOCK_DISPENSER: - case E_BLOCK_DROPPER: - case E_BLOCK_ENCHANTMENT_TABLE: - case E_BLOCK_END_PORTAL: - case E_BLOCK_END_PORTAL_FRAME: - case E_BLOCK_FURNACE: - case E_BLOCK_LIT_FURNACE: - case E_BLOCK_HOPPER: - case E_BLOCK_JUKEBOX: - case E_BLOCK_MOB_SPAWNER: - case E_BLOCK_NETHER_PORTAL: - case E_BLOCK_NOTE_BLOCK: - case E_BLOCK_OBSIDIAN: - case E_BLOCK_PISTON_EXTENSION: - { - return false; - } - case E_BLOCK_STICKY_PISTON: - case E_BLOCK_PISTON: - { - // A piston can only be pushed if retracted: - return !IsExtended(a_BlockMeta); - } - } - return true; -} - - - - - -bool cPiston::CanBreakPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) -{ - UNUSED(a_BlockMeta); - return cBlockInfo::IsPistonBreakable(a_BlockType); -} - - - - - -bool cPiston::CanPull(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) -{ - switch (a_BlockType) - { - case E_BLOCK_LAVA: - case E_BLOCK_STATIONARY_LAVA: - case E_BLOCK_STATIONARY_WATER: - case E_BLOCK_WATER: - { - return false; - } - } - - if (CanBreakPush(a_BlockType, a_BlockMeta)) - { - return false; // CanBreakPush returns true, but we need false to prevent pulling - } - - return CanPush(a_BlockType, a_BlockMeta); -} - - - - - -void cPiston::AddDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_PistonMeta, int a_Amount) -{ - switch (a_PistonMeta & 0x07) - { - case 0: a_BlockY -= a_Amount; break; - case 1: a_BlockY += a_Amount; break; - case 2: a_BlockZ -= a_Amount; break; - case 3: a_BlockZ += a_Amount; break; - case 4: a_BlockX -= a_Amount; break; - case 5: a_BlockX += a_Amount; break; - default: - { - LOGWARNING("%s: invalid direction %d, ignoring", __FUNCTION__, a_PistonMeta & 0x07); - break; - } - } -} - - - - diff --git a/src/Piston.h b/src/Piston.h deleted file mode 100644 index 9bbc8c6b9..000000000 --- a/src/Piston.h +++ /dev/null @@ -1,110 +0,0 @@ - -#pragma once - - -#include "Defines.h" - - -// fwd: World.h -class cWorld; - - - - - -class cPiston -{ -public: - - cPiston(cWorld * a_World); - - static NIBBLETYPE RotationPitchToMetaData(double a_Rotation, double a_Pitch) - { - if (a_Pitch >= 50) - { - return 0x1; - } - else if (a_Pitch <= -50) - { - return 0x0; - } - else - { - a_Rotation += 90 + 45; // So its not aligned with axis - - if (a_Rotation > 360) - { - a_Rotation -= 360; - } - if ((a_Rotation >= 0) && (a_Rotation < 90)) - { - return 0x4; - } - else if ((a_Rotation >= 180) && (a_Rotation < 270)) - { - return 0x5; - } - else if ((a_Rotation >= 90) && (a_Rotation < 180)) - { - return 0x2; - } - else - { - return 0x3; - } - } - } - - static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) - { - switch (a_MetaData) - { - //case -1: return BLOCK_FACE_NONE; //can never happen as metadata is unsigned - case 0x0: return BLOCK_FACE_YM; - case 0x1: return BLOCK_FACE_YP; - case 0x2: return BLOCK_FACE_ZM; - case 0x3: return BLOCK_FACE_ZP; - case 0x4: return BLOCK_FACE_XM; - case 0x5: return BLOCK_FACE_XP; - default: - { - ASSERT(!"Invalid Metadata"); - return BLOCK_FACE_NONE; - } - } - } - - void ExtendPiston( int, int, int ); - void RetractPiston( int, int, int ); - - /// Returns true if the piston (specified by blocktype) is a sticky piston - static bool IsSticky(BLOCKTYPE a_BlockType); - - /// Returns true if the piston (with the specified meta) is extended - static bool IsExtended(NIBBLETYPE a_PistonMeta); - - /// Returns true if the specified block can be pushed by a piston (and left intact) - static bool CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); - - /// Returns true if the specified block can be pushed by a piston and broken / replaced - static bool CanBreakPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); - - /// Returns true if the specified block can be pulled by a sticky piston - static bool CanPull(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); - - /// Updates the coords by the specified amount in the direction a piston of the specified meta is facing - static void AddDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_PistonMeta, int a_Amount); - - - cWorld * m_World; - -private: - void ChainMove( int, int, int, char, unsigned short * ); - - /// Returns how many blocks the piston has to push (where the first free space is); <0 when unpushable - int FirstPassthroughBlock(int a_PistonX, int a_PistonY, int a_PistonZ, NIBBLETYPE a_PistonMeta); -} ; - - - - diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 074063add..c24b1c4b3 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -11,7 +11,7 @@ #include "../Blocks/BlockDoor.h" #include "../Blocks/BlockButton.h" #include "../Blocks/BlockLever.h" -#include "../Piston.h" +#include "../Blocks/BlockPiston.h" @@ -814,17 +814,16 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int void cIncrementalRedstoneSimulator::HandlePiston(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - cPiston Piston(&m_World); int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; if (IsPistonPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x7)) // We only want the bottom three bits (4th controls extended-ness) { - Piston.ExtendPiston(BlockX, a_RelBlockY, BlockZ); + cBlockPistonHandler::ExtendPiston(BlockX, a_RelBlockY, BlockZ, &m_World); } else { - Piston.RetractPiston(BlockX, a_RelBlockY, BlockZ); + cBlockPistonHandler::RetractPiston(BlockX, a_RelBlockY, BlockZ, &m_World); } } @@ -1491,7 +1490,7 @@ bool cIncrementalRedstoneSimulator::IsPistonPowered(int a_RelBlockX, int a_RelBl // Pistons cannot be powered through their front face; this function verifies that a source meets this requirement int OldX = a_RelBlockX, OldY = a_RelBlockY, OldZ = a_RelBlockZ; - eBlockFace Face = cPiston::MetaDataToDirection(a_Meta); + eBlockFace Face = cBlockPistonHandler::MetaDataToDirection(a_Meta); int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; diff --git a/src/World.cpp b/src/World.cpp index 807065bfa..29046bba9 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1551,9 +1551,9 @@ bool cWorld::SetAreaBiome(const cCuboid & a_Area, EMCSBiome a_Biome) -void cWorld::SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) +void cWorld::SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients) { - m_ChunkMap->SetBlock(*this, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); + m_ChunkMap->SetBlock(*this, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_SendToClients); } @@ -3127,6 +3127,50 @@ void cWorld::cTaskUnloadUnusedChunks::Run(cWorld & a_World) +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cWorld::cTaskSendBlockTo + +cWorld::cTaskSendBlockToAllPlayers::cTaskSendBlockToAllPlayers(int a_BlockX, int a_BlockY, int a_BlockZ) : + m_BlockX(a_BlockX), + m_BlockY(a_BlockY), + m_BlockZ(a_BlockZ) +{ +} + +void cWorld::cTaskSendBlockToAllPlayers::Run(cWorld & a_World) +{ + class cPlayerCallback : + public cPlayerListCallback + { + public: + cPlayerCallback(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld & a_World) : + m_BlockX(a_BlockX), + m_BlockY(a_BlockY), + m_BlockZ(a_BlockZ), + m_World(a_World) + { + } + + virtual bool Item(cPlayer * a_Player) + { + m_World.SendBlockTo(m_BlockX, m_BlockY, m_BlockZ, a_Player); + return false; + } + + private: + + int m_BlockX, m_BlockY, m_BlockZ; + cWorld & m_World; + + } PlayerCallback(m_BlockX, m_BlockY, m_BlockZ, a_World); + + a_World.ForEachPlayer(PlayerCallback); +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cWorld::cChunkGeneratorCallbacks: diff --git a/src/World.h b/src/World.h index 86cbb3e7e..5ef63a540 100644 --- a/src/World.h +++ b/src/World.h @@ -117,6 +117,22 @@ public: }; + class cTaskSendBlockToAllPlayers : + public cTask + { + public: + cTaskSendBlockToAllPlayers(int a_BlockX, int a_BlockY, int a_BlockZ); + + protected: + // cTask overrides: + virtual void Run(cWorld & a_World) override; + + int m_BlockX; + int m_BlockY; + int m_BlockZ; + }; + + static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates { return "cWorld"; @@ -373,7 +389,7 @@ public: /** Sets the block at the specified coords to the specified value. Full processing, incl. updating neighbors, is performed. */ - void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); + void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true); /** Sets the block at the specified coords to the specified value. The replacement doesn't trigger block updates. -- cgit v1.2.3 From 67308e4337b422ebefb249049e662266072b0ba2 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 25 May 2014 13:46:50 +0100 Subject: Fixed a food saturation issue --- src/Entities/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 0eacb67f9..1e1e868e7 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -551,7 +551,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation) } m_FoodLevel = std::min(a_Food + m_FoodLevel, (int)MAX_FOOD_LEVEL); - m_FoodSaturationLevel = std::min(m_FoodSaturationLevel + a_Saturation, (double)m_FoodLevel); + m_FoodSaturationLevel = m_FoodSaturationLevel + a_Saturation; SendHealth(); return true; -- cgit v1.2.3 From 50e29aba776dd6ad6296e5989faaf4642b4b6705 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sun, 25 May 2014 18:32:42 +0100 Subject: A fix that is better than #950. --- src/GroupManager.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index 3586560bf..ba25d95ba 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -45,8 +45,14 @@ cGroupManager::cGroupManager() { LOGD("-- Loading Groups --"); - LoadGroups(); - CheckUsers(); + if (!LoadGroups()) + { + LOGWARNING("ERROR: Groups could not load!"); + } + if (!CheckUsers()) + { + LOGWARNING("ERROR: User file could not be found!"); + } LOGD("-- Groups Successfully Loaded --"); } @@ -70,13 +76,13 @@ void cGroupManager::GenerateDefaultUsersIni(cIniFile & a_IniFile) -void cGroupManager::CheckUsers(void) +bool cGroupManager::CheckUsers() { cIniFile IniFile; if (!IniFile.ReadFile("users.ini")) { GenerateDefaultUsersIni(IniFile); - return; + return true; } int NumKeys = IniFile.GetNumKeys(); @@ -97,13 +103,15 @@ void cGroupManager::CheckUsers(void) } } // for itr - Split[] } // for i - ini file keys + // Always return true for now, just but we can handle writefile fails later. + return true } -void cGroupManager::LoadGroups() +bool cGroupManager::LoadGroups() { cIniFile IniFile; if (!IniFile.ReadFile("groups.ini")) @@ -180,6 +188,8 @@ void cGroupManager::LoadGroups() } } } + // Always return true, we can handle writefile fails later. + return true } -- cgit v1.2.3 From 6ce73ada6fc1cde9cd3ee25afdca11484e77cbb0 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 25 May 2014 19:17:01 +0100 Subject: Update GroupManager.h --- src/GroupManager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/GroupManager.h b/src/GroupManager.h index 9e1689a76..d42b55c4a 100644 --- a/src/GroupManager.h +++ b/src/GroupManager.h @@ -16,8 +16,8 @@ class cGroupManager public: bool ExistsGroup(const AString & a_Name); cGroup * GetGroup(const AString & a_Name); - void LoadGroups(void); - void CheckUsers(void); + bool LoadGroups(); + bool CheckUsers(); /** Writes the default header to the specified ini file, and saves it as "users.ini". */ static void GenerateDefaultUsersIni(cIniFile & a_IniFile); -- cgit v1.2.3 From a352ec38958f2884d6fe12fa7320947c65d1a65f Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sun, 25 May 2014 19:46:16 +0100 Subject: SEMICOLONS! --- src/GroupManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index ba25d95ba..523697b07 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -104,7 +104,7 @@ bool cGroupManager::CheckUsers() } // for itr - Split[] } // for i - ini file keys // Always return true for now, just but we can handle writefile fails later. - return true + return true; } @@ -189,7 +189,7 @@ bool cGroupManager::LoadGroups() } } // Always return true, we can handle writefile fails later. - return true + return true; } -- cgit v1.2.3 From 1a742a2b52d32bd22cd57b4d462bee312717e010 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 25 May 2014 23:50:16 +0200 Subject: Added support for Miners' Village. The village contains both prefabs that snap to ground and prefabs that connect strictly via connectors. Fixes #1027. --- src/Generating/PieceGenerator.cpp | 13 +- src/Generating/PieceGenerator.h | 21 +- src/Generating/Prefab.cpp | 6 +- src/Generating/Prefab.h | 12 + src/Generating/Prefabs/JapaneseVillagePrefabs.cpp | 808 +++- src/Generating/Prefabs/NetherFortPrefabs.cpp | 102 + src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 5069 ++++++++++++-------- .../Prefabs/SandFlatRoofVillagePrefabs.cpp | 111 +- src/Generating/Prefabs/SandVillagePrefabs.cpp | 545 ++- src/Generating/VillageGen.cpp | 45 +- 10 files changed, 4468 insertions(+), 2264 deletions(-) (limited to 'src') diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index 7d478f1a1..1880a20d5 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -286,7 +286,8 @@ cPlacedPiece::cPlacedPiece(const cPlacedPiece * a_Parent, const cPiece & a_Piece m_Parent(a_Parent), m_Piece(&a_Piece), m_Coords(a_Coords), - m_NumCCWRotations(a_NumCCWRotations) + m_NumCCWRotations(a_NumCCWRotations), + m_HasBeenMovedToGround(false) { m_Depth = (m_Parent == NULL) ? 0 : (m_Parent->GetDepth() + 1); m_HitBox = a_Piece.RotateMoveHitBox(a_NumCCWRotations, a_Coords.x, a_Coords.y, a_Coords.z); @@ -317,6 +318,16 @@ cPiece::cConnector cPlacedPiece::GetRotatedConnector(const cPiece::cConnector & +void cPlacedPiece::MoveToGroundBy(int a_OffsetY) +{ + m_Coords.y += a_OffsetY; + m_HasBeenMovedToGround = true; +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cPieceGenerator: diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index e396643a9..21c155c96 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -139,11 +139,13 @@ class cPlacedPiece public: cPlacedPiece(const cPlacedPiece * a_Parent, const cPiece & a_Piece, const Vector3i & a_Coords, int a_NumCCWRotations); - const cPiece & GetPiece (void) const { return *m_Piece; } - const Vector3i & GetCoords (void) const { return m_Coords; } - int GetNumCCWRotations(void) const { return m_NumCCWRotations; } - const cCuboid & GetHitBox (void) const { return m_HitBox; } - int GetDepth (void) const { return m_Depth; } + const cPlacedPiece * GetParent (void) const { return m_Parent; } + const cPiece & GetPiece (void) const { return *m_Piece; } + const Vector3i & GetCoords (void) const { return m_Coords; } + int GetNumCCWRotations (void) const { return m_NumCCWRotations; } + const cCuboid & GetHitBox (void) const { return m_HitBox; } + int GetDepth (void) const { return m_Depth; } + bool HasBeenMovedToGround(void) const { return m_HasBeenMovedToGround; } /** Returns the coords as a modifiable object. */ Vector3i & GetCoords(void) { return m_Coords; } @@ -156,6 +158,11 @@ public: this placement. */ cPiece::cConnector GetRotatedConnector(const cPiece::cConnector & a_Connector) const; + /** Moves the placed piece Y-wise by the specified offset. + Sets m_HasBeenMovedToGround to true, too. + Used eg. by village houses. */ + void MoveToGroundBy(int a_OffsetY); + protected: const cPlacedPiece * m_Parent; const cPiece * m_Piece; @@ -163,6 +170,10 @@ protected: int m_NumCCWRotations; cCuboid m_HitBox; // Hitbox of the placed piece, in world coords int m_Depth; // Depth in the generated piece tree + + /** Set to true once the piece has been moved Y-wise. + Used eg. by village houses. */ + bool m_HasBeenMovedToGround; }; typedef std::vector cPlacedPieces; diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 05979507a..e41907325 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -127,7 +127,8 @@ cPrefab::cPrefab(const cPrefab::sDef & a_Def) : m_MergeStrategy(a_Def.m_MergeStrategy), m_ShouldExtendFloor(a_Def.m_ShouldExtendFloor), m_DefaultWeight(a_Def.m_DefaultWeight), - m_AddWeightIfSame(a_Def.m_AddWeightIfSame) + m_AddWeightIfSame(a_Def.m_AddWeightIfSame), + m_MoveToGround(a_Def.m_MoveToGround) { m_BlockArea[0].Create(m_Size); CharMap cm; @@ -149,7 +150,8 @@ cPrefab::cPrefab(const cBlockArea & a_Image, int a_AllowedRotations) : m_MergeStrategy(cBlockArea::msOverwrite), m_ShouldExtendFloor(false), m_DefaultWeight(1), - m_AddWeightIfSame(0) + m_AddWeightIfSame(0), + m_MoveToGround(false) { m_HitBox.p1.Set(0, 0, 0); m_HitBox.p2.Set(m_Size.x - 1, m_Size.y - 1, m_Size.z - 1); diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index adc0e688e..8b4e4b4ef 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -82,6 +82,10 @@ public: Can be positive or negative. This is used e. g. to make nether bridges prefer spanning multiple segments or to penalize turrets next to each other. */ int m_AddWeightIfSame; + + /** If true, the piece will be moved Y-wise so that its first connector is sitting on the terrain. + This is used e. g. for village houses. */ + bool m_MoveToGround; }; @@ -115,6 +119,10 @@ public: /** Adds the specified connector to the list of connectors this piece supports. */ void AddConnector(int a_RelX, int a_RelY, int a_RelZ, eBlockFace a_Direction, int a_Type); + + /** Returns whether the prefab should be moved Y-wise to ground before drawing, rather than staying + at the coords governed by the connectors. */ + bool ShouldMoveToGround(void) const { return m_MoveToGround; } protected: /** Packs complete definition of a single block, for per-letter assignment. */ @@ -169,6 +177,10 @@ protected: Can be positive or negative. This is used e. g. to make nether bridges prefer spanning multiple segments or to penalize turrets next to each other. */ int m_AddWeightIfSame; + + /** If true, the piece will be moved Y-wise so that its first connector is sitting on the terrain. + This is used e. g. for village houses. */ + bool m_MoveToGround; // cPiece overrides: diff --git a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp index 2b129f520..5ec222f84 100644 --- a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp +++ b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp @@ -122,6 +122,9 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // Arch @@ -385,10 +388,165 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // Forge + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Garden2: + // The data has been exported from the gallery Plains, area index 147, ID 491, created by Aloe_vera + { + // Size: + 16, 5, 16, // SizeX = 16, SizeY = 5, SizeZ = 16 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 15, 4, 15, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 3: 0\n" /* dirt */ + "b: 8: 0\n" /* water */ + "c: 2: 0\n" /* grass */ + "d: 17: 1\n" /* tree */ + "e: 13: 0\n" /* gravel */ + "f: 31: 2\n" /* tallgrass */ + "g: 18: 5\n" /* leaves */ + "h: 38: 7\n" /* rose */ + "i: 17: 9\n" /* tree */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aaaaaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaaaaaaa" + /* 9 */ "aaaaaaaaaaaaaaaa" + /* 10 */ "aaaaaaaaaaaaaaaa" + /* 11 */ "aaaaaaaaaaaaaaaa" + /* 12 */ "aaaaaaaaaaaaaaaa" + /* 13 */ "aaaaaaaaaaaaaaaa" + /* 14 */ "aaaaaaaaaaaaaaaa" + /* 15 */ "aaaaaaaaaaaaaaaa" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aaaaaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaaaaaa" + /* 6 */ "aaaabbaaaaaaaaaa" + /* 7 */ "aaabbbaaaaaaaaaa" + /* 8 */ "aaabbaaaaaaaaaaa" + /* 9 */ "aaaabaaaaaaaaaaa" + /* 10 */ "aaaaaaaaaaaaaaaa" + /* 11 */ "aaaaaaaaaaaaaaaa" + /* 12 */ "aaaaaaaaaaaaaaaa" + /* 13 */ "aaaaaaaaaaaaaaaa" + /* 14 */ "aaaaaaaaaaaaaaaa" + /* 15 */ "aaaaaaaaaaaaaaaa" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "cccccccccccccccc" + /* 1 */ "ccdccccccccdcccc" + /* 2 */ "cccccceecccccdcc" + /* 3 */ "ccccccceeccccccc" + /* 4 */ "cccccccceccccccc" + /* 5 */ "cccbbbbceccccccc" + /* 6 */ "cccbbbbceecccccc" + /* 7 */ "ccbbbbbcceeeeccc" + /* 8 */ "ccbbbbbccccceecc" + /* 9 */ "ccbbbbcccccccecc" + /* 10 */ "ccccbcccccccceec" + /* 11 */ "ccccccccccccccec" + /* 12 */ "ccccccccaaacccec" + /* 13 */ "cccccccccaccccec" + /* 14 */ "ccccccccccccceec" + /* 15 */ "cccccccccccceecc" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "......f...gg.g.." + /* 1 */ "..gg.....gggggg." + /* 2 */ "ffgg......ghgggg" + /* 3 */ ".............gg." + /* 4 */ "...........f...." + /* 5 */ "...........h.ff." + /* 6 */ ".............fh." + /* 7 */ "...............f" + /* 8 */ "................" + /* 9 */ ".......ff.f....." + /* 10 */ ".f.....ffggf...." + /* 11 */ ".......gggg.f..." + /* 12 */ ".f......iddg...." + /* 13 */ ".....f..gdgg...." + /* 14 */ "....ff...gg....." + /* 15 */ "................" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "...........g.g.." + /* 2 */ ".............gg." + /* 3 */ "................" + /* 4 */ "................" + /* 5 */ "................" + /* 6 */ "................" + /* 7 */ "................" + /* 8 */ "................" + /* 9 */ "................" + /* 10 */ ".........g......" + /* 11 */ "........ggg....." + /* 12 */ "........ggg....." + /* 13 */ ".........g......" + /* 14 */ "................" + /* 15 */ "................", + + // Connectors: + "-1: 12, 3, 15: 3\n" /* Type -1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // Garden2 + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HouseMid: // The data has been exported from the gallery Plains, area index 62, ID 119, created by Aloe_vera @@ -558,6 +716,9 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // HouseMid @@ -666,10 +827,137 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // HouseSmall + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HouseSmallDblWithDoor: + // The data has been exported from the gallery Plains, area index 113, ID 265, created by Aloe_vera + { + // Size: + 11, 6, 7, // SizeX = 11, SizeY = 6, SizeZ = 7 + + // Hitbox (relative to bounding box): + -1, 0, 0, // MinX, MinY, MinZ + 11, 5, 7, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 2\n" /* wood */ + "b: 17: 9\n" /* tree */ + "c: 17: 1\n" /* tree */ + "d: 35: 0\n" /* wool */ + "e: 64: 7\n" /* wooddoorblock */ + "f:171:12\n" /* carpet */ + "g:135: 1\n" /* 135 */ + "h:126: 2\n" /* woodenslab */ + "i:135: 2\n" /* 135 */ + "j: 50: 4\n" /* torch */ + "k: 64:12\n" /* wooddoorblock */ + "l: 85: 0\n" /* fence */ + "m: 19: 0\n" /* sponge */ + "n: 44: 8\n" /* step */ + "o: 43: 0\n" /* doubleslab */ + "p: 44: 0\n" /* step */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmmmmmmmm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "maaaabaaaam" + /* 3 */ "maaaabaaaam" + /* 4 */ "maaaabaaaam" + /* 5 */ "maaaaaaaaam" + /* 6 */ "mmmmmmmmmmm" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".cdedcdddc." + /* 2 */ ".dfff.fffd." + /* 3 */ ".dgffdfhfd." + /* 4 */ ".diifdfffd." + /* 5 */ ".cdddcdddc." + /* 6 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ ".j...j...j." + /* 1 */ ".cdkdclllc." + /* 2 */ ".d.......l." + /* 3 */ ".l...l...l." + /* 4 */ ".d...l...l." + /* 5 */ ".clllclllc." + /* 6 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ ".nnnnnnnnn." + /* 1 */ "ncdddcdddcn" + /* 2 */ "nd...d...dn" + /* 3 */ "nd...d...dn" + /* 4 */ "nd...d...dn" + /* 5 */ "ncdddcdddcn" + /* 6 */ ".nnnnnnnnn." + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "op.......po" + /* 1 */ "ppppppppppp" + /* 2 */ ".pooooooop." + /* 3 */ ".ponndnnop." + /* 4 */ ".pooooooop." + /* 5 */ "ppppppppppp" + /* 6 */ "op.......po" + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "...ppppp..." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "...........", + + // Connectors: + "-1: 3, 1, -1: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // HouseSmallDblWithDoor + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HouseSmallDouble: // The data has been exported from the gallery Plains, area index 72, ID 135, created by Aloe_vera @@ -784,10 +1072,126 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // HouseSmallDouble + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HouseSmallWithDoor: + // The data has been exported from the gallery Plains, area index 112, ID 264, created by Aloe_vera + { + // Size: + 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7 + + // Hitbox (relative to bounding box): + -1, 0, 0, // MinX, MinY, MinZ + 7, 5, 7, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 2\n" /* wood */ + "b: 17: 1\n" /* tree */ + "c: 35: 0\n" /* wool */ + "d: 64: 7\n" /* wooddoorblock */ + "e: 50: 4\n" /* torch */ + "f: 64:12\n" /* wooddoorblock */ + "g: 85: 0\n" /* fence */ + "h: 44: 8\n" /* step */ + "i: 43: 0\n" /* doubleslab */ + "j: 44: 0\n" /* step */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "maaaaam" + /* 2 */ "maaaaam" + /* 3 */ "maaaaam" + /* 4 */ "maaaaam" + /* 5 */ "maaaaam" + /* 6 */ "mmmmmmm" + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".bcdcb." + /* 2 */ ".c...c." + /* 3 */ ".c...c." + /* 4 */ ".c...c." + /* 5 */ ".bcccb." + /* 6 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ ".....e." + /* 1 */ ".bcfcb." + /* 2 */ ".g...g." + /* 3 */ ".g...g." + /* 4 */ ".g...g." + /* 5 */ ".bgggb." + /* 6 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ ".hhhhh." + /* 1 */ "hbcccbh" + /* 2 */ "hc...ch" + /* 3 */ "hc...ch" + /* 4 */ "hc...ch" + /* 5 */ "hbcccbh" + /* 6 */ ".hhhhh." + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "ij...ji" + /* 1 */ "jjjjjjj" + /* 2 */ ".jiiij." + /* 3 */ ".jiiij." + /* 4 */ ".jiiij." + /* 5 */ "jjjjjjj" + /* 6 */ "ij...ji" + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "......." + /* 2 */ "......." + /* 3 */ "...j..." + /* 4 */ "......." + /* 5 */ "......." + /* 6 */ ".......", + + // Connectors: + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // HouseSmallWithDoor + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HouseWide: // The data has been exported from the gallery Plains, area index 64, ID 121, created by STR_Warrior @@ -929,6 +1333,9 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // HouseWide @@ -1172,6 +1579,9 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // HouseWithGarden @@ -1363,10 +1773,375 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // HouseWithSakura1 + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HouseWithSpa: + // The data has been exported from the gallery Plains, area index 73, ID 139, created by Aloe_vera + { + // Size: + 16, 8, 14, // SizeX = 16, SizeY = 8, SizeZ = 14 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 15, 7, 13, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 2\n" /* wood */ + "b: 3: 0\n" /* dirt */ + "c: 2: 0\n" /* grass */ + "d: 8: 0\n" /* water */ + "e:135: 3\n" /* 135 */ + "f:135: 1\n" /* 135 */ + "g:113: 0\n" /* netherbrickfence */ + "h: 17: 1\n" /* tree */ + "i: 35: 0\n" /* wool */ + "j:171:12\n" /* carpet */ + "k: 64: 6\n" /* wooddoorblock */ + "l:126: 2\n" /* woodenslab */ + "m: 19: 0\n" /* sponge */ + "n:135: 2\n" /* 135 */ + "o: 64: 7\n" /* wooddoorblock */ + "p: 50: 4\n" /* torch */ + "q: 85: 0\n" /* fence */ + "r: 64:12\n" /* wooddoorblock */ + "s: 50: 3\n" /* torch */ + "t: 44: 8\n" /* step */ + "u: 43: 0\n" /* doubleslab */ + "v: 44: 0\n" /* step */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ ".aaaaaaaaaaaaaa." + /* 2 */ ".aaaaaaaaaaaaaa." + /* 3 */ ".aaaaaaaaaaaaaa." + /* 4 */ ".aaaaaaaaaaaaaa." + /* 5 */ ".aaaaaaaaaaaaaa." + /* 6 */ ".aaaaaaaaaaaaaa." + /* 7 */ ".aaaaaabbbbbbbbb" + /* 8 */ ".aaaaaabbbbbbbbb" + /* 9 */ ".aaaaaabbbbbbbbb" + /* 10 */ ".aaaaaabbbbbbbbb" + /* 11 */ ".aaaaaabbbbbbbbb" + /* 12 */ ".aaaaaabbbbbbbbb" + /* 13 */ ".......bbbbbbbbb" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "maaaaaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaaaaam" + /* 6 */ "maaaaaaaaaaaaaam" + /* 7 */ "maaaaaaaaaaccccc" + /* 8 */ "maaaaaaacccccccc" + /* 9 */ "maaaaaaacccccccc" + /* 10 */ "maaaaaaacccccccc" + /* 11 */ "maaaaaaccccccccc" + /* 12 */ "maaaaaaccccccccc" + /* 13 */ "mmmmmmmccccccccc" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ ".aaaaaaaaaaaaaa." + /* 2 */ ".aaaaaaaaaaaaaa." + /* 3 */ ".aaaaaaaaaaaaaa." + /* 4 */ ".aaaaaaaaaaaaaa." + /* 5 */ ".aaaaaaaaaaaaaa." + /* 6 */ ".aaddaaaaaaaaaa." + /* 7 */ ".aaddaaeeef....." + /* 8 */ ".aaddaaf........" + /* 9 */ ".aaddaaf........" + /* 10 */ ".aaddaae........" + /* 11 */ ".aaddaa........." + /* 12 */ ".aaaaaa........." + /* 13 */ "................" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ ".ggggghiiihiiih." + /* 2 */ ".geee.ijjjjjjji." + /* 3 */ ".gf...kjjjijlji." + /* 4 */ ".gf...innjijjji." + /* 5 */ ".g....hiiohiiih." + /* 6 */ ".g....g........." + /* 7 */ ".g.............." + /* 8 */ ".g.............." + /* 9 */ ".g.............." + /* 10 */ ".g....g........." + /* 11 */ ".g....g........." + /* 12 */ ".gggggg........." + /* 13 */ "................" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "......p...p...p." + /* 1 */ ".g....hqqqhqqqh." + /* 2 */ "......i.......i." + /* 3 */ "......r...q...q." + /* 4 */ "......i...q...i." + /* 5 */ "......hqqrhqqqh." + /* 6 */ "......g...s....." + /* 7 */ "................" + /* 8 */ "................" + /* 9 */ "................" + /* 10 */ "................" + /* 11 */ "................" + /* 12 */ ".g....g........." + /* 13 */ "................" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ ".tttttttttttttt." + /* 1 */ "tggggghqqqhqqqht" + /* 2 */ "tg....i.......it" + /* 3 */ "tg....i...i...it" + /* 4 */ "tg....i...i...it" + /* 5 */ "tg....hiiihiiiht" + /* 6 */ "tg....gtttttttt." + /* 7 */ "tg....gt........" + /* 8 */ "tg....gt........" + /* 9 */ "tg....gt........" + /* 10 */ "tg....gt........" + /* 11 */ "tg....gt........" + /* 12 */ "tggggggt........" + /* 13 */ ".tttttt........." + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "uv............vu" + /* 1 */ "vvvvvvvvvvvvvvvv" + /* 2 */ ".vuuuuuuuuuuuuv." + /* 3 */ ".vuuuuuutuuuuuv." + /* 4 */ ".vuuuuuuuuuuuuv." + /* 5 */ ".vuuuuvvvvvvvvvv" + /* 6 */ ".vuuuuv.......vu" + /* 7 */ ".vuuuuv........." + /* 8 */ ".vuuuuv........." + /* 9 */ ".vuuuuv........." + /* 10 */ ".vuuuuv........." + /* 11 */ ".vuuuuv........." + /* 12 */ "vvvvvvvv........" + /* 13 */ "uv....vu........" + + // Level 7 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "...vvvvvvvvvv..." + /* 4 */ "...vv..........." + /* 5 */ "...vv..........." + /* 6 */ "...vv..........." + /* 7 */ "...vv..........." + /* 8 */ "...vv..........." + /* 9 */ "...vv..........." + /* 10 */ "...vv..........." + /* 11 */ "................" + /* 12 */ "................" + /* 13 */ "................", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // HouseWithSpa + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MediumSakuraTree: + // The data has been exported from the gallery Plains, area index 146, ID 490, created by STR_Warrior + { + // Size: + 7, 10, 7, // SizeX = 7, SizeY = 10, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 9, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 31: 1\n" /* tallgrass */ + "d: 38: 7\n" /* rose */ + "e: 17: 1\n" /* tree */ + "f: 38: 0\n" /* rose */ + "g: 38: 8\n" /* rose */ + "h: 38: 5\n" /* rose */ + "i: 35: 6\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "aaaaaaa" + /* 2 */ "aaaaaaa" + /* 3 */ "aaaaaaa" + /* 4 */ "aaaaaaa" + /* 5 */ "aaaaaaa" + /* 6 */ "aaaaaaa" + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "bbbbbbb" + /* 1 */ "bbbbbbb" + /* 2 */ "bbbbbbb" + /* 3 */ "bbbabbb" + /* 4 */ "bbbbbbb" + /* 5 */ "bbbbbbb" + /* 6 */ "bbbbbbb" + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "..c.c.." + /* 2 */ ".dccdc." + /* 3 */ "..cefc." + /* 4 */ ".ccfgh." + /* 5 */ "..ccc.." + /* 6 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "......." + /* 2 */ "......." + /* 3 */ "...e..." + /* 4 */ "......." + /* 5 */ "......." + /* 6 */ "......." + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "..i...." + /* 2 */ "......." + /* 3 */ "...e.i." + /* 4 */ ".i....." + /* 5 */ "......." + /* 6 */ "......." + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "..i...." + /* 2 */ "...i..." + /* 3 */ "..ieii." + /* 4 */ ".i.ii.." + /* 5 */ "...i..." + /* 6 */ "......." + + // Level 6 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "..ii..." + /* 2 */ "..iii.." + /* 3 */ ".iieii." + /* 4 */ ".iiii.." + /* 5 */ "..iii.." + /* 6 */ "......." + + // Level 7 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "..iii.." + /* 2 */ ".iiiii." + /* 3 */ ".iieii." + /* 4 */ ".iiiii." + /* 5 */ "..iii.." + /* 6 */ "......." + + // Level 8 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "...i..." + /* 2 */ "..iiii." + /* 3 */ ".iiiii." + /* 4 */ "..iii.." + /* 5 */ "...i..." + /* 6 */ "......." + + // Level 9 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "......." + /* 2 */ "...i..." + /* 3 */ "..iii.." + /* 4 */ "...i..." + /* 5 */ "......." + /* 6 */ ".......", + + // Connectors: + "-1: 3, 2, 0: 2\n" /* Type -1, direction Z- */ + "3: 6, 2, 3: 5\n" /* Type 3, direction X+ */ + "-3: 0, 2, 3: 4\n" /* Type -3, direction X- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // MediumSakuraTree + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Restaurant: // The data has been exported from the gallery Plains, area index 61, ID 117, created by Aloe_vera @@ -1614,6 +2389,9 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // Restaurant @@ -1626,8 +2404,8 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = 12, 8, 6, // SizeX = 12, SizeY = 8, SizeZ = 6 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 11, 7, 5, // MaxX, MaxY, MaxZ + -1, 0, -1, // MinX, MinY, MinZ + 12, 7, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1719,7 +2497,11 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = /* 5 */ "............", // Connectors: - "-1: 0, 2, 2: 4\n" /* Type -1, direction X- */, + "-1: -1, 2, 2: 4\n" /* Type -1, direction X- */ + "3: 5, 2, 6: 3\n" /* Type 3, direction Z+ */ + "-3: 6, 2, -1: 2\n" /* Type -3, direction Z- */ + "-3: 12, 2, 2: 5\n" /* Type -3, direction X+ */ + "3: 12, 2, 2: 5\n" /* Type 3, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1738,6 +2520,9 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // SakuraDouble @@ -1750,8 +2535,8 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = 5, 7, 5, // SizeX = 5, SizeY = 7, SizeZ = 5 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 4, 6, 4, // MaxX, MaxY, MaxZ + -1, 0, -1, // MinX, MinY, MinZ + 5, 6, 5, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1819,7 +2604,9 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = /* 4 */ ".....", // Connectors: - "-1: 2, 2, 0: 2\n" /* Type -1, direction Z- */, + "-1: 2, 2, -1: 2\n" /* Type -1, direction Z- */ + "3: 5, 2, 2: 5\n" /* Type 3, direction X+ */ + "-3: -1, 2, 2: 4\n" /* Type -3, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1838,6 +2625,9 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // SakuraSmall }; // g_JapaneseVillagePrefabs @@ -2192,6 +2982,9 @@ const cPrefab::sDef g_JapaneseVillageStartingPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // HighTemple @@ -2389,6 +3182,9 @@ const cPrefab::sDef g_JapaneseVillageStartingPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // Well }; diff --git a/src/Generating/Prefabs/NetherFortPrefabs.cpp b/src/Generating/Prefabs/NetherFortPrefabs.cpp index 088340391..2c97f28ea 100644 --- a/src/Generating/Prefabs/NetherFortPrefabs.cpp +++ b/src/Generating/Prefabs/NetherFortPrefabs.cpp @@ -155,6 +155,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // BalconyCorridor @@ -315,6 +318,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // BalconyTee2 @@ -435,6 +441,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // BlazePlatform @@ -605,6 +614,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // BlazePlatformOverhang @@ -805,6 +817,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: -1000, + + // MoveToGround: + false, }, // BridgeCircleCrossing @@ -1006,6 +1021,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // BridgeCrossing @@ -1100,6 +1118,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // BridgeCrumble1 @@ -1200,6 +1221,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // BridgeCrumble2 @@ -1379,6 +1403,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 1000, + + // MoveToGround: + false, }, // BridgeDoubleCrumble @@ -1619,6 +1646,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // BridgeFunnelDown @@ -1948,6 +1978,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // BridgeLevelCrossing @@ -2067,6 +2100,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 1000, + + // MoveToGround: + false, }, // BridgeSegment @@ -2227,6 +2263,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // BridgeTee @@ -2328,6 +2367,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // Corridor11 @@ -2429,6 +2471,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // Corridor13 @@ -2524,6 +2569,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 500, + + // MoveToGround: + false, }, // Corridor5 @@ -2663,6 +2711,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // CorridorCorner5 @@ -2803,6 +2854,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // CorridorCornerChest5 @@ -2928,6 +2982,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: -50, + + // MoveToGround: + false, }, // CorridorCrossing @@ -3080,6 +3137,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // CorridorStairs @@ -3181,6 +3241,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // DarkCorridor @@ -3438,6 +3501,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // LavaStaircase @@ -3769,6 +3835,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: -1000, + + // MoveToGround: + false, }, // LavaStaircaseBig @@ -4047,6 +4116,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // LavaStairsBridge @@ -4235,6 +4307,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: -1000, + + // MoveToGround: + false, }, // MidStaircase @@ -4378,6 +4453,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // StairsToOpen1 @@ -4521,6 +4599,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // StairsToOpen2 @@ -4638,6 +4719,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // Tee2x4 @@ -4767,6 +4851,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // Tee4x4 @@ -4863,6 +4950,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: -50, + + // MoveToGround: + false, }, // TinyCorridorCorner @@ -4960,6 +5050,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // TinyCorridorCornerChest @@ -5059,6 +5152,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: -50, + + // MoveToGround: + false, }, // TinyCorridorCrossing @@ -5174,6 +5270,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // AddWeightIfSame: -99, + + // MoveToGround: + false, }, // Turret }; // g_NetherFortPrefabs @@ -5378,6 +5477,9 @@ const cPrefab::sDef g_NetherFortStartingPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + false, }, // CentralRoom }; diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index 28488be14..fee6610c9 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -20,11 +20,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 26, ID 70, created by Taugrammaton { // Size: - 13, 4, 12, // SizeX = 13, SizeY = 4, SizeZ = 12 + 13, 8, 12, // SizeX = 13, SizeY = 8, SizeZ = 12 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 12, 3, 11, // MaxX, MaxY, MaxZ + 12, 7, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -36,6 +36,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "f: 8: 0\n" /* water */ "g: 85: 0\n" /* fence */ "h: 59: 7\n" /* crops */ + "i: 50: 5\n" /* torch */ "m: 19: 0\n" /* sponge */, // Block data: @@ -101,7 +102,71 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 8 */ "ghh..h....hhg" /* 9 */ "ghh.....h.hhg" /* 10 */ "ghh.hh.h..hhg" - /* 11 */ "g..g..g..g..g", + /* 11 */ "g..g..g..g..g" + + // Level 4 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "i..i..i..i..i" + /* 1 */ "............." + /* 2 */ "............." + /* 3 */ "............." + /* 4 */ "............." + /* 5 */ "............." + /* 6 */ "............." + /* 7 */ "............." + /* 8 */ "............." + /* 9 */ "............." + /* 10 */ "............." + /* 11 */ "i..i..i..i..i" + + // Level 5 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "............." + /* 2 */ "............." + /* 3 */ "............." + /* 4 */ "............." + /* 5 */ "............." + /* 6 */ "............." + /* 7 */ "............." + /* 8 */ "............." + /* 9 */ "............." + /* 10 */ "............." + /* 11 */ "............." + + // Level 6 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "............." + /* 2 */ "............." + /* 3 */ "............." + /* 4 */ "............." + /* 5 */ "............." + /* 6 */ "............." + /* 7 */ "............." + /* 8 */ "............." + /* 9 */ "............." + /* 10 */ "............." + /* 11 */ "............." + + // Level 7 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "............." + /* 2 */ "............." + /* 3 */ "............." + /* 4 */ "............." + /* 5 */ "............." + /* 6 */ "............." + /* 7 */ "............." + /* 8 */ "............." + /* 9 */ "............." + /* 10 */ "............." + /* 11 */ ".............", // Connectors: "-1: 7, 1, 11: 3\n" /* Type -1, direction Z+ */, @@ -123,6 +188,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // BigPlantBed @@ -132,130 +200,117 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 23, ID 66, created by xoft { // Size: - 12, 8, 7, // SizeX = 12, SizeY = 8, SizeZ = 7 + 12, 7, 7, // SizeX = 12, SizeY = 7, SizeZ = 7 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 12, 7, 7, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 12, 6, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 64: 7\n" /* wooddoorblock */ - "h: 53: 3\n" /* woodstairs */ - "i: 53: 1\n" /* woodstairs */ - "j: 85: 0\n" /* fence */ - "k: 53: 0\n" /* woodstairs */ - "l: 53: 2\n" /* woodstairs */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 64: 7\n" /* wooddoorblock */ + "f: 53: 3\n" /* woodstairs */ + "g: 53: 1\n" /* woodstairs */ + "h: 85: 0\n" /* fence */ + "i: 53: 0\n" /* woodstairs */ + "j: 53: 2\n" /* woodstairs */ + "k:102: 0\n" /* glasspane */ + "l: 64:12\n" /* wooddoorblock */ "m: 19: 0\n" /* sponge */ - "n:102: 0\n" /* glasspane */ - "o: 64:12\n" /* wooddoorblock */ - "p: 50: 3\n" /* torch */ - "q: 72: 0\n" /* woodplate */ - "r: 50: 4\n" /* torch */ - "s: 53: 7\n" /* woodstairs */ - "t: 47: 0\n" /* bookshelf */ - "u: 50: 1\n" /* torch */ - "v: 50: 2\n" /* torch */ - "w: 53: 6\n" /* woodstairs */ - "x: 5: 0\n" /* wood */, + "n: 50: 3\n" /* torch */ + "o: 72: 0\n" /* woodplate */ + "p: 50: 4\n" /* torch */ + "q: 53: 7\n" /* woodstairs */ + "r: 47: 0\n" /* bookshelf */ + "s: 50: 1\n" /* torch */ + "t: 50: 2\n" /* torch */ + "u: 53: 6\n" /* woodstairs */ + "v: 5: 0\n" /* wood */, // Block data: // Level 0 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "aaaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaaa" - /* 2 */ "aaaaaaaaaaaa" - /* 3 */ "aaaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaaa" - /* 5 */ "aaaaaaaaaaaa" - /* 6 */ "aaaaaaaaaaaa" + /* 0 */ "mmmmmmmaaamm" + /* 1 */ "maaaaaaaaaam" + /* 2 */ "maaaaaaaaaam" + /* 3 */ "maaaaaaaaaam" + /* 4 */ "maaaaaaaaaam" + /* 5 */ "maaaaaaaaaam" + /* 6 */ "mmmmmmmmmmmm" // Level 1 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "bbbbbbbaaabb" - /* 1 */ "baaaaaaaaaab" - /* 2 */ "baaaaaaaaaab" - /* 3 */ "baaaaaaaaaab" - /* 4 */ "baaaaaaaaaab" - /* 5 */ "baaaaaaaaaab" - /* 6 */ "bbbbbbbbbbbb" + /* 0 */ ".......bcd.." + /* 1 */ ".aaaaaaaaaa." + /* 2 */ ".aaaaaaaaaa." + /* 3 */ ".aaaaaaaaaa." + /* 4 */ ".aaaaaaaaaa." + /* 5 */ ".aaaaaaaaaa." + /* 6 */ "............" // Level 2 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ ".......cde.." - /* 1 */ ".ffffffffff." - /* 2 */ ".ffffffffff." - /* 3 */ ".ffffffffff." - /* 4 */ ".ffffffffff." - /* 5 */ ".ffffffffff." + /* 0 */ "............" + /* 1 */ ".aaaaaaaeaa." + /* 2 */ ".af.ghi...a." + /* 3 */ ".ah.......a." + /* 4 */ ".aj.ghighia." + /* 5 */ ".aaaaaaaaaa." /* 6 */ "............" // Level 3 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" - /* 1 */ ".fffffffgff." - /* 2 */ ".fh.ijk...f." - /* 3 */ ".fj.......f." - /* 4 */ ".fl.ijkijkf." - /* 5 */ ".ffffffffff." + /* 1 */ ".akkakkalaa." + /* 2 */ ".k..no.n.nk." + /* 3 */ ".ko.......k." + /* 4 */ ".k..po.po.k." + /* 5 */ ".akkakkakka." /* 6 */ "............" // Level 4 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ ".fnnfnnfoff." - /* 2 */ ".n..pq.p.pn." - /* 3 */ ".nq.......n." - /* 4 */ ".n..rq.rq.n." - /* 5 */ ".fnnfnnfnnf." - /* 6 */ "............" + /* 0 */ "jjjjjjjjjjjj" + /* 1 */ "qaaaaaaaaaaq" + /* 2 */ ".arrrrrrrra." + /* 3 */ ".as......ta." + /* 4 */ ".arrrrrrrra." + /* 5 */ "uaaaaaaaaaau" + /* 6 */ "ffffffffffff" // Level 5 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "llllllllllll" - /* 1 */ "sffffffffffs" - /* 2 */ ".fttttttttf." - /* 3 */ ".fu......vf." - /* 4 */ ".fttttttttf." - /* 5 */ "wffffffffffw" - /* 6 */ "hhhhhhhhhhhh" - - // Level 6 - /* z\x* 11 */ - /* * 012345678901 */ /* 0 */ "............" - /* 1 */ "llllllllllll" - /* 2 */ "sxxxxxxxxxxs" - /* 3 */ ".xxxxxxxxxx." - /* 4 */ "wxxxxxxxxxxw" - /* 5 */ "hhhhhhhhhhhh" + /* 1 */ "jjjjjjjjjjjj" + /* 2 */ "qvvvvvvvvvvq" + /* 3 */ ".vvvvvvvvvv." + /* 4 */ "uvvvvvvvvvvu" + /* 5 */ "ffffffffffff" /* 6 */ "............" - // Level 7 + // Level 6 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" /* 1 */ "............" - /* 2 */ "llllllllllll" - /* 3 */ "xxxxxxxxxxxx" - /* 4 */ "hhhhhhhhhhhh" + /* 2 */ "jjjjjjjjjjjj" + /* 3 */ "vvvvvvvvvvvv" + /* 4 */ "ffffffffffff" /* 5 */ "............" /* 6 */ "............", // Connectors: - "-1: 8, 2, 0: 2\n" /* Type -1, direction Z- */, + "-1: 8, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -274,6 +329,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // CobbleHouse10x5Library @@ -283,50 +341,130 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 5, ID 20, created by tonibm1999 { // Size: - 15, 2, 9, // SizeX = 15, SizeY = 2, SizeZ = 9 + 15, 8, 9, // SizeX = 15, SizeY = 8, SizeZ = 9 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 14, 1, 8, // MaxX, MaxY, MaxZ + 14, 7, 8, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 17: 0\n" /* tree */ - "b: 60: 7\n" /* tilleddirt */ - "c: 8: 0\n" /* water */ - "d: 50: 5\n" /* torch */ - "e: 59: 7\n" /* crops */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ + "c: 17: 0\n" /* tree */ + "d: 60: 7\n" /* tilleddirt */ + "e: 8: 0\n" /* water */ + "f: 50: 5\n" /* torch */ + "g: 59: 7\n" /* crops */ "m: 19: 0\n" /* sponge */, // Block data: // Level 0 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "aaaaaaa.aaaaaaa" - /* 1 */ "abbcbba.abbcbba" - /* 2 */ "abbcbba.abbcbba" - /* 3 */ "abbcbba.abbcbba" - /* 4 */ "abbcbba.abbcbba" - /* 5 */ "abbcbba.abbcbba" - /* 6 */ "abbcbba.abbcbba" - /* 7 */ "abbcbba.abbcbba" - /* 8 */ "aaaaaaa.aaaaaaa" + /* 0 */ "aaaaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaaaaaa" // Level 1 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "d.....d.d.....d" - /* 1 */ ".ee.ee...ee.ee." - /* 2 */ ".e...e...ee.ee." - /* 3 */ ".e.......ee.ee." - /* 4 */ ".ee..e...ee.ee." - /* 5 */ ".ee..e...ee.ee." - /* 6 */ "..e..e...ee.ee." - /* 7 */ "..e.e....ee.ee." - /* 8 */ "d.....d.d.....d", + /* 0 */ "aaaaaaabaaaaaaa" + /* 1 */ "aaaaaaabaaaaaaa" + /* 2 */ "aaaaaaabaaaaaaa" + /* 3 */ "aaaaaaabaaaaaaa" + /* 4 */ "aaaaaaabaaaaaaa" + /* 5 */ "aaaaaaabaaaaaaa" + /* 6 */ "aaaaaaabaaaaaaa" + /* 7 */ "aaaaaaabaaaaaaa" + /* 8 */ "aaaaaaabaaaaaaa" + + // Level 2 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "ccccccc.ccccccc" + /* 1 */ "cddeddc.cddeddc" + /* 2 */ "cddeddc.cddeddc" + /* 3 */ "cddeddc.cddeddc" + /* 4 */ "cddeddc.cddeddc" + /* 5 */ "cddeddc.cddeddc" + /* 6 */ "cddeddc.cddeddc" + /* 7 */ "cddeddc.cddeddc" + /* 8 */ "ccccccc.ccccccc" + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "f.....f.f.....f" + /* 1 */ ".gg.gg...gg.gg." + /* 2 */ ".g...g...gg.gg." + /* 3 */ ".g.......gg.gg." + /* 4 */ ".gg..g...gg.gg." + /* 5 */ ".gg..g...gg.gg." + /* 6 */ "..g..g...gg.gg." + /* 7 */ "..g.g....gg.gg." + /* 8 */ "f.....f.f.....f" + + // Level 4 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "..............." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "..............." + + // Level 5 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "..............." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "..............." + + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "..............." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "..............." + + // Level 7 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "..............." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "...............", // Connectors: - "-1: 7, 0, 8: 3\n" /* Type -1, direction Z+ */, + "-1: 7, 2, 8: 3\n" /* Type -1, direction Z+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -345,6 +483,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // DoublePlantBed @@ -354,193 +495,176 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 51, ID 102, created by Aloe_vera { // Size: - 12, 10, 11, // SizeX = 12, SizeY = 10, SizeZ = 11 + 12, 9, 11, // SizeX = 12, SizeY = 9, SizeZ = 11 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 12, 9, 11, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 12, 8, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 17: 0\n" /* tree */ - "h: 5: 0\n" /* wood */ - "i: 64: 6\n" /* wooddoorblock */ - "j: 10: 0\n" /* lava */ - "k: 54: 2\n" /* chest */ - "l: 61: 2\n" /* furnace */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 6\n" /* wooddoorblock */ + "h: 10: 0\n" /* lava */ + "i: 54: 2\n" /* chest */ + "j: 61: 2\n" /* furnace */ + "k:102: 0\n" /* glasspane */ + "l: 64:12\n" /* wooddoorblock */ "m: 19: 0\n" /* sponge */ - "n:102: 0\n" /* glasspane */ - "o: 64:12\n" /* wooddoorblock */ - "p:139: 0\n" /* cobblestonewall */ - "q:101: 0\n" /* ironbars */ - "r: 53: 2\n" /* woodstairs */ - "s: 53: 7\n" /* woodstairs */ - "t: 50: 2\n" /* torch */ - "u: 50: 1\n" /* torch */ - "v: 53: 6\n" /* woodstairs */ - "w: 53: 3\n" /* woodstairs */ - "x: 43: 0\n" /* doubleslab */ - "y: 44: 0\n" /* step */, + "n:139: 0\n" /* cobblestonewall */ + "o:101: 0\n" /* ironbars */ + "p: 53: 2\n" /* woodstairs */ + "q: 53: 7\n" /* woodstairs */ + "r: 50: 2\n" /* torch */ + "s: 50: 1\n" /* torch */ + "t: 53: 6\n" /* woodstairs */ + "u: 53: 3\n" /* woodstairs */ + "v: 43: 0\n" /* doubleslab */ + "w: 44: 0\n" /* step */, // Block data: // Level 0 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "aaaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaaa" - /* 2 */ "aaaaaaaaaaaa" - /* 3 */ "aaaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaaa" - /* 5 */ "aaaaaaaaaaaa" - /* 6 */ "aaaaaaaaaaaa" - /* 7 */ "aaaaaaaaaaaa" - /* 8 */ "aaaaaaaaaaaa" - /* 9 */ "aaaaaaaaaaaa" - /* 10 */ "aaaaaaaaaaaa" + /* 0 */ "mmmmmaaaaamm" + /* 1 */ "maaaaaaaaamm" + /* 2 */ "maaaaaaaaamm" + /* 3 */ "maaaaaaaaaaa" + /* 4 */ "maaaaaaaaaaa" + /* 5 */ "maaaaaaaaaaa" + /* 6 */ "maaaaaaaaaaa" + /* 7 */ "maaaaaaaaaaa" + /* 8 */ "maaaaammmmmm" + /* 9 */ "maaaaammmmmm" + /* 10 */ "mmmmmmmmmmmm" // Level 1 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "bbbbbaaaaabb" - /* 1 */ "baaaaaaaaabb" - /* 2 */ "baaaaaaaaabb" - /* 3 */ "baaaaaaaaaaa" - /* 4 */ "baaaaaaaaaaa" - /* 5 */ "baaaaaaaaaaa" - /* 6 */ "baaaaaaaaaaa" - /* 7 */ "baaaaaaaaaaa" - /* 8 */ "baaaaabbbbbb" - /* 9 */ "baaaaabbbbbb" - /* 10 */ "bbbbbbbbbbbb" + /* 0 */ ".....bcccd.." + /* 1 */ ".aaaaaaaad.." + /* 2 */ ".aaaaaaaad.." + /* 3 */ ".aaaaaaaaaaa" + /* 4 */ ".aaaaaaaaaaa" + /* 5 */ ".aaaaaaaaaaa" + /* 6 */ ".aaaaaaaaaaa" + /* 7 */ ".aaaaaaaaaaa" + /* 8 */ ".aaaaa......" + /* 9 */ ".aaaaa......" + /* 10 */ "............" // Level 2 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ ".....cddde.." - /* 1 */ ".ffffffffe.." - /* 2 */ ".ffffffffe.." - /* 3 */ ".fffffffffff" - /* 4 */ ".fffffffffff" - /* 5 */ ".fffffffffff" - /* 6 */ ".fffffffffff" - /* 7 */ ".fffffffffff" - /* 8 */ ".fffff.mmmmm" - /* 9 */ ".fffff.mmmmm" - /* 10 */ ".......mmmmm" + /* 0 */ "............" + /* 1 */ ".efffe......" + /* 2 */ ".f...g......" + /* 3 */ ".f...ea..aaa" + /* 4 */ ".f...f...aha" + /* 5 */ ".f...f...aha" + /* 6 */ ".f...fijjaha" + /* 7 */ ".f...eaaaaaa" + /* 8 */ ".f...f......" + /* 9 */ ".efffe......" + /* 10 */ "............" // Level 3 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" - /* 1 */ ".ghhhg......" - /* 2 */ ".h...i......" - /* 3 */ ".h...gf..fff" - /* 4 */ ".h...h...fjf" - /* 5 */ ".h...h...fjf" - /* 6 */ ".h...hkllfjf" - /* 7 */ ".h...gffffff" - /* 8 */ ".h...h.mmmmm" - /* 9 */ ".ghhhg.mmmmm" - /* 10 */ ".......mmmmm" + /* 1 */ ".ekkke......" + /* 2 */ ".k...l......" + /* 3 */ ".k...en..n.a" + /* 4 */ ".k...k.....o" + /* 5 */ ".f...k.....o" + /* 6 */ ".k...k.....o" + /* 7 */ ".k...eaooooa" + /* 8 */ ".k...f......" + /* 9 */ ".ekkke......" + /* 10 */ "............" // Level 4 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ ".gnnng......" - /* 2 */ ".n...o......" - /* 3 */ ".n...gp..p.f" - /* 4 */ ".n...n.....q" - /* 5 */ ".h...n.....q" - /* 6 */ ".n...n.....q" - /* 7 */ ".n...gfqqqqf" - /* 8 */ ".n...h.mmmmm" - /* 9 */ ".gnnng.mmmmm" - /* 10 */ ".......mmmmm" + /* 0 */ "ppppppp....." + /* 1 */ "qfffffq....." + /* 2 */ ".f...f......" + /* 3 */ ".f..rfa..aoa" + /* 4 */ ".f...f...o.a" + /* 5 */ ".f...f...o.a" + /* 6 */ ".fs..f...o.a" + /* 7 */ ".f...faaaaaa" + /* 8 */ ".f...f......" + /* 9 */ "tffffft....." + /* 10 */ "uuuuuuu....." // Level 5 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "rrrrrrr....." - /* 1 */ "shhhhhs....." - /* 2 */ ".h...h......" - /* 3 */ ".h..thf..fqf" - /* 4 */ ".h...h...q.f" - /* 5 */ ".h...h...q.f" - /* 6 */ ".hu..h...q.f" - /* 7 */ ".h...hffffff" - /* 8 */ ".h...h.mmmmm" - /* 9 */ "vhhhhhvmmmmm" - /* 10 */ "wwwwwwwmmmmm" - - // Level 6 - /* z\x* 11 */ - /* * 012345678901 */ /* 0 */ "............" - /* 1 */ "rrrrrrr....." - /* 2 */ "shhhhhs....." - /* 3 */ ".h...hxxxxxx" - /* 4 */ ".h...hxyyyyx" - /* 5 */ ".h...hxyyyyx" - /* 6 */ ".h...hxyyyyx" - /* 7 */ ".h...hxxxxxx" - /* 8 */ "vhhhhhvmmmmm" - /* 9 */ "wwwwwwwmmmmm" - /* 10 */ ".......mmmmm" + /* 1 */ "ppppppp....." + /* 2 */ "qfffffq....." + /* 3 */ ".f...fvvvvvv" + /* 4 */ ".f...fvwwwwv" + /* 5 */ ".f...fvwwwwv" + /* 6 */ ".f...fvwwwwv" + /* 7 */ ".f...fvvvvvv" + /* 8 */ "tffffft....." + /* 9 */ "uuuuuuu....." + /* 10 */ "............" - // Level 7 + // Level 6 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" /* 1 */ "............" - /* 2 */ "rrrrrrr....." - /* 3 */ "shhhhhs....." - /* 4 */ ".h...h......" - /* 5 */ ".h...h......" - /* 6 */ ".h...h......" - /* 7 */ "vhhhhhv....." - /* 8 */ "wwwwwwwmmmmm" - /* 9 */ ".......mmmmm" - /* 10 */ ".......mmmmm" + /* 2 */ "ppppppp....." + /* 3 */ "qfffffq....." + /* 4 */ ".f...f......" + /* 5 */ ".f...f......" + /* 6 */ ".f...f......" + /* 7 */ "tffffft....." + /* 8 */ "uuuuuuu....." + /* 9 */ "............" + /* 10 */ "............" - // Level 8 + // Level 7 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" /* 1 */ "............" /* 2 */ "............" - /* 3 */ "rrrrrrr....." - /* 4 */ "shhhhhs....." - /* 5 */ ".h...h......" - /* 6 */ "vhhhhhv....." - /* 7 */ "wwwwwww....." - /* 8 */ ".......mmmmm" - /* 9 */ ".......mmmmm" - /* 10 */ ".......mmmmm" + /* 3 */ "ppppppp....." + /* 4 */ "qfffffq....." + /* 5 */ ".f...f......" + /* 6 */ "tffffft....." + /* 7 */ "uuuuuuu....." + /* 8 */ "............" + /* 9 */ "............" + /* 10 */ "............" - // Level 9 + // Level 8 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" /* 1 */ "............" /* 2 */ "............" /* 3 */ "............" - /* 4 */ "rrrrrrr....." - /* 5 */ "hhhhhhh....." - /* 6 */ "wwwwwww....." + /* 4 */ "ppppppp....." + /* 5 */ "fffffff....." + /* 6 */ "uuuuuuu....." /* 7 */ "............" - /* 8 */ ".......mmmmm" - /* 9 */ ".......mmmmm" - /* 10 */ ".......mmmmm", + /* 8 */ "............" + /* 9 */ "............" + /* 10 */ "............", // Connectors: - "-1: 7, 2, -1: 2\n" /* Type -1, direction Z- */, + "-1: 7, 1, -1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -559,20 +683,484 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // Forge + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // LampPost: + // The data has been exported from the gallery Plains, area index 28, ID 73, created by STR_Warrior + { + // Size: + 3, 7, 3, // SizeX = 3, SizeY = 7, SizeZ = 3 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 2, 6, 2, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 3: 0\n" /* dirt */ + "b: 43: 0\n" /* doubleslab */ + "c:139: 0\n" /* cobblestonewall */ + "d: 50: 4\n" /* torch */ + "e: 50: 2\n" /* torch */ + "f: 50: 1\n" /* torch */ + "g: 50: 3\n" /* torch */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 012 */ + /* 0 */ "mmm" + /* 1 */ "mam" + /* 2 */ "mmm" + + // Level 1 + /* z\x* 012 */ + /* 0 */ "..." + /* 1 */ ".b." + /* 2 */ "..." + + // Level 2 + /* z\x* 012 */ + /* 0 */ "..." + /* 1 */ ".c." + /* 2 */ "..." + + // Level 3 + /* z\x* 012 */ + /* 0 */ "..." + /* 1 */ ".c." + /* 2 */ "..." + + // Level 4 + /* z\x* 012 */ + /* 0 */ ".d." + /* 1 */ "ebf" + /* 2 */ ".g." + + // Level 5 + /* z\x* 012 */ + /* 0 */ "..." + /* 1 */ "..." + /* 2 */ "..." + + // Level 6 + /* z\x* 012 */ + /* 0 */ "..." + /* 1 */ "..." + /* 2 */ "...", + + // Connectors: + "-1: 1, 1, 2: 3\n" /* Type -1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // LampPost + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MineshaftCorridor: + // The data has been exported from the gallery Plains, area index 139, ID 447, created by STR_Warrior + { + // Size: + 10, 4, 3, // SizeX = 10, SizeY = 4, SizeZ = 3 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 9, 3, 2, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "b: 85: 0\n" /* fence */ + "c: 50: 2\n" /* torch */ + "d: 50: 1\n" /* torch */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "aaaaaaaaaa" + /* 1 */ "aaaaaaaaaa" + /* 2 */ "aaaaaaaaaa" + + // Level 1 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "..b....b.." + /* 1 */ ".........." + /* 2 */ "..b....b.." + + // Level 2 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "..b....b.." + /* 1 */ ".........." + /* 2 */ "..b....b.." + + // Level 3 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "..a....a.." + /* 1 */ ".cad..cad." + /* 2 */ "..a....a..", + + // Connectors: + "-3: 0, 1, 1: 4\n" /* Type -3, direction X- */ + "3: 0, 1, 1: 4\n" /* Type 3, direction X- */ + "3: 9, 1, 1: 5\n" /* Type 3, direction X+ */ + "-3: 9, 1, 1: 5\n" /* Type -3, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 200, + + // MoveToGround: + false, + }, // MineshaftCorridor + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MineshaftCrossing: + // The data has been exported from the gallery Plains, area index 171, ID 578, created by Aloe_vera + { + // Size: + 5, 4, 5, // SizeX = 5, SizeY = 4, SizeZ = 5 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 4, 3, 4, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 01234 */ + /* 0 */ "aaaaa" + /* 1 */ "aaaaa" + /* 2 */ "aaaaa" + /* 3 */ "aaaaa" + /* 4 */ "aaaaa" + + // Level 1 + /* z\x* 01234 */ + /* 0 */ "m...m" + /* 1 */ ".a.a." + /* 2 */ "....." + /* 3 */ ".a.a." + /* 4 */ "m...m" + + // Level 2 + /* z\x* 01234 */ + /* 0 */ "m...m" + /* 1 */ ".a.a." + /* 2 */ "....." + /* 3 */ ".a.a." + /* 4 */ "m...m" + + // Level 3 + /* z\x* 01234 */ + /* 0 */ "m...m" + /* 1 */ ".a.a." + /* 2 */ "....." + /* 3 */ ".a.a." + /* 4 */ "m...m", + + // Connectors: + "3: 4, 1, 2: 5\n" /* Type 3, direction X+ */ + "-3: 4, 1, 2: 5\n" /* Type -3, direction X+ */ + "-3: 2, 1, 4: 3\n" /* Type -3, direction Z+ */ + "3: 2, 1, 4: 3\n" /* Type 3, direction Z+ */ + "3: 0, 1, 2: 4\n" /* Type 3, direction X- */ + "-3: 0, 1, 2: 4\n" /* Type -3, direction X- */ + "3: 2, 1, 0: 2\n" /* Type 3, direction Z- */ + "-3: 2, 1, 0: 2\n" /* Type -3, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 5, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // MineshaftCrossing + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MineshaftDoubleCrossing: + // The data has been exported from the gallery Plains, area index 172, ID 579, created by Aloe_vera + { + // Size: + 5, 8, 5, // SizeX = 5, SizeY = 8, SizeZ = 5 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 4, 7, 4, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 01234 */ + /* 0 */ "aaaaa" + /* 1 */ "aaaaa" + /* 2 */ "aaaaa" + /* 3 */ "aaaaa" + /* 4 */ "aaaaa" + + // Level 1 + /* z\x* 01234 */ + /* 0 */ "m...m" + /* 1 */ ".a.a." + /* 2 */ "....." + /* 3 */ ".a.a." + /* 4 */ "m...m" + + // Level 2 + /* z\x* 01234 */ + /* 0 */ "m...m" + /* 1 */ ".a.a." + /* 2 */ "....." + /* 3 */ ".a.a." + /* 4 */ "m...m" + + // Level 3 + /* z\x* 01234 */ + /* 0 */ "m...m" + /* 1 */ ".a.a." + /* 2 */ "....." + /* 3 */ ".a.a." + /* 4 */ "m...m" + + // Level 4 + /* z\x* 01234 */ + /* 0 */ "aaaaa" + /* 1 */ "aa.aa" + /* 2 */ "a...a" + /* 3 */ "aa.aa" + /* 4 */ "aaaaa" + + // Level 5 + /* z\x* 01234 */ + /* 0 */ "m...m" + /* 1 */ ".a.a." + /* 2 */ "....." + /* 3 */ ".a.a." + /* 4 */ "m...m" + + // Level 6 + /* z\x* 01234 */ + /* 0 */ "m...m" + /* 1 */ ".a.a." + /* 2 */ "....." + /* 3 */ ".a.a." + /* 4 */ "m...m" + + // Level 7 + /* z\x* 01234 */ + /* 0 */ "m...m" + /* 1 */ ".a.a." + /* 2 */ "....." + /* 3 */ ".a.a." + /* 4 */ "m...m", + + // Connectors: + "-3: 4, 5, 2: 5\n" /* Type -3, direction X+ */ + "3: 4, 5, 2: 5\n" /* Type 3, direction X+ */ + "-3: 2, 1, 4: 3\n" /* Type -3, direction Z+ */ + "3: 2, 1, 4: 3\n" /* Type 3, direction Z+ */ + "-3: 0, 1, 2: 4\n" /* Type -3, direction X- */ + "3: 0, 1, 2: 4\n" /* Type 3, direction X- */ + "-3: 2, 1, 0: 2\n" /* Type -3, direction Z- */ + "3: 2, 1, 0: 2\n" /* Type 3, direction Z- */ + "-3: 4, 1, 2: 5\n" /* Type -3, direction X+ */ + "3: 4, 1, 2: 5\n" /* Type 3, direction X+ */ + "-3: 2, 5, 4: 3\n" /* Type -3, direction Z+ */ + "3: 2, 5, 4: 3\n" /* Type 3, direction Z+ */ + "-3: 0, 5, 2: 4\n" /* Type -3, direction X- */ + "3: 0, 5, 2: 4\n" /* Type 3, direction X- */ + "-3: 2, 5, 0: 2\n" /* Type -3, direction Z- */ + "3: 2, 5, 0: 2\n" /* Type 3, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 5, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // MineshaftDoubleCrossing + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Scarecrow: + // The data has been exported from the gallery Plains, area index 150, ID 494, created by STR_Warrior + { + // Size: + 1, 6, 3, // SizeX = 1, SizeY = 6, SizeZ = 3 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 0, 5, 2, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:139: 0\n" /* cobblestonewall */ + "b: 85: 0\n" /* fence */ + "c:126: 4\n" /* woodenslab */ + "d: 86: 1\n" /* pumpkin */ + "e:139: 1\n" /* cobblestonewall */ + "f:163: 4\n" /* acaciawoodenstairs */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 0 */ + /* 0 */ "." + /* 1 */ "a" + /* 2 */ "." + + // Level 1 + /* z\x* 0 */ + /* 0 */ "." + /* 1 */ "b" + /* 2 */ "." + + // Level 2 + /* z\x* 0 */ + /* 0 */ "c" + /* 1 */ "d" + /* 2 */ "c" + + // Level 3 + /* z\x* 0 */ + /* 0 */ "." + /* 1 */ "e" + /* 2 */ "." + + // Level 4 + /* z\x* 0 */ + /* 0 */ "f" + /* 1 */ "d" + /* 2 */ "f" + + // Level 5 + /* z\x* 0 */ + /* 0 */ "." + /* 1 */ "f" + /* 2 */ ".", + + // Connectors: + "-1: -1, 0, 1: 4\n" /* Type -1, direction X- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 10, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // Scarecrow + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // SinglePlantBed: // The data has been exported from the gallery Plains, area index 17, ID 60, created by Aloe_vera { // Size: - 10, 3, 7, // SizeX = 10, SizeY = 3, SizeZ = 7 + 10, 7, 7, // SizeX = 10, SizeY = 7, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 9, 2, 6, // MaxX, MaxY, MaxZ + 9, 6, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -615,6 +1203,50 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 3 */ ".........." /* 4 */ ".eeeeeeee." /* 5 */ ".eeeeeeee." + /* 6 */ ".........." + + // Level 3 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ ".........." + /* 2 */ ".........." + /* 3 */ ".........." + /* 4 */ ".........." + /* 5 */ ".........." + /* 6 */ ".........." + + // Level 4 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ ".........." + /* 2 */ ".........." + /* 3 */ ".........." + /* 4 */ ".........." + /* 5 */ ".........." + /* 6 */ ".........." + + // Level 5 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ ".........." + /* 2 */ ".........." + /* 3 */ ".........." + /* 4 */ ".........." + /* 5 */ ".........." + /* 6 */ ".........." + + // Level 6 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." + /* 1 */ ".........." + /* 2 */ ".........." + /* 3 */ ".........." + /* 4 */ ".........." + /* 5 */ ".........." /* 6 */ "..........", // Connectors: @@ -637,6 +1269,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // SinglePlantBed @@ -646,182 +1281,164 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 58, ID 109, created by Aloe_vera { // Size: - 7, 16, 13, // SizeX = 7, SizeY = 16, SizeZ = 13 + 7, 15, 13, // SizeX = 7, SizeY = 15, SizeZ = 13 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 7, 15, 13, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 7, 14, 13, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "A: 54: 2\n" /* chest */ - "B: 50: 4\n" /* torch */ - "C: 85: 0\n" /* fence */ - "D:126: 8\n" /* woodenslab */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 17: 0\n" /* tree */ - "h: 5: 0\n" /* wood */ - "i: 64: 7\n" /* wooddoorblock */ - "j: 65: 3\n" /* ladder */ - "k: 53: 3\n" /* woodstairs */ - "l: 53: 7\n" /* woodstairs */ + "A: 85: 0\n" /* fence */ + "B:126: 8\n" /* woodenslab */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 7\n" /* wooddoorblock */ + "h: 65: 3\n" /* ladder */ + "i: 53: 3\n" /* woodstairs */ + "j: 53: 7\n" /* woodstairs */ + "k: 64:12\n" /* wooddoorblock */ + "l:102: 0\n" /* glasspane */ "m: 19: 0\n" /* sponge */ - "n: 64:12\n" /* wooddoorblock */ - "o:102: 0\n" /* glasspane */ - "p: 50: 1\n" /* torch */ - "q: 50: 2\n" /* torch */ - "r:171:14\n" /* carpet */ - "s: 50: 3\n" /* torch */ - "t: 53: 2\n" /* woodstairs */ - "u: 53: 0\n" /* woodstairs */ - "v: 53: 1\n" /* woodstairs */ - "w: 53: 5\n" /* woodstairs */ - "x: 53: 4\n" /* woodstairs */ - "y: 17: 4\n" /* tree */ - "z: 17: 8\n" /* tree */, + "n: 50: 1\n" /* torch */ + "o: 50: 2\n" /* torch */ + "p:171:14\n" /* carpet */ + "q: 50: 3\n" /* torch */ + "r: 53: 2\n" /* woodstairs */ + "s: 53: 0\n" /* woodstairs */ + "t: 53: 1\n" /* woodstairs */ + "u: 53: 5\n" /* woodstairs */ + "v: 53: 4\n" /* woodstairs */ + "w: 17: 4\n" /* tree */ + "x: 17: 8\n" /* tree */ + "y: 54: 2\n" /* chest */ + "z: 50: 4\n" /* torch */, // Block data: // Level 0 /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "aaaaaaa" - /* 2 */ "aaaaaaa" - /* 3 */ "aaaaaaa" - /* 4 */ "aaaaaaa" - /* 5 */ "aaaaaaa" - /* 6 */ "aaaaaaa" - /* 7 */ "aaaaaaa" - /* 8 */ "aaaaaaa" - /* 9 */ "aaaaaaa" - /* 10 */ "aaaaaaa" - /* 11 */ "aaaaaaa" - /* 12 */ "aaaaaaa" + /* 0 */ "mmaaamm" + /* 1 */ "maaaaam" + /* 2 */ "maaaaam" + /* 3 */ "maaaaam" + /* 4 */ "maaaaam" + /* 5 */ "maaaaam" + /* 6 */ "maaaaam" + /* 7 */ "maaaaam" + /* 8 */ "maaaaam" + /* 9 */ "maaaaam" + /* 10 */ "maaaaam" + /* 11 */ "maaaaam" + /* 12 */ "mmmmmmm" // Level 1 /* z\x* 0123456 */ - /* 0 */ "bbaaabb" - /* 1 */ "baaaaab" - /* 2 */ "baaaaab" - /* 3 */ "baaaaab" - /* 4 */ "baaaaab" - /* 5 */ "baaaaab" - /* 6 */ "baaaaab" - /* 7 */ "baaaaab" - /* 8 */ "baaaaab" - /* 9 */ "baaaaab" - /* 10 */ "baaaaab" - /* 11 */ "baaaaab" - /* 12 */ "bbbbbbb" + /* 0 */ "..bcd.." + /* 1 */ ".aaaaa." + /* 2 */ ".aaaaa." + /* 3 */ ".aaaaa." + /* 4 */ ".aaaaa." + /* 5 */ ".aaaaa." + /* 6 */ ".aaaaa." + /* 7 */ ".aaaaa." + /* 8 */ ".aaaaa." + /* 9 */ ".aaaaa." + /* 10 */ ".aaaaa." + /* 11 */ ".aaaaa." + /* 12 */ "......." // Level 2 /* z\x* 0123456 */ - /* 0 */ "..cde.." - /* 1 */ ".fffff." - /* 2 */ ".fffff." - /* 3 */ ".fffff." - /* 4 */ ".fffff." - /* 5 */ ".fffff." - /* 6 */ ".fffff." - /* 7 */ ".fffff." - /* 8 */ ".fffff." - /* 9 */ ".fffff." - /* 10 */ ".fffff." - /* 11 */ ".fffff." + /* 0 */ "......." + /* 1 */ ".efgfe." + /* 2 */ ".f..hf." + /* 3 */ ".f...f." + /* 4 */ ".f...f." + /* 5 */ ".ei.ie." + /* 6 */ ".f...f." + /* 7 */ ".fi.if." + /* 8 */ ".f...f." + /* 9 */ ".f.j.f." + /* 10 */ ".f...f." + /* 11 */ ".efffe." /* 12 */ "......." // Level 3 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".ghihg." - /* 2 */ ".h..jh." - /* 3 */ ".h...h." - /* 4 */ ".h...h." - /* 5 */ ".gk.kg." - /* 6 */ ".h...h." - /* 7 */ ".hk.kh." - /* 8 */ ".h...h." - /* 9 */ ".h.l.h." - /* 10 */ ".h...h." - /* 11 */ ".ghhhg." + /* 1 */ ".efkfe." + /* 2 */ ".l..hl." + /* 3 */ ".l...l." + /* 4 */ ".l...l." + /* 5 */ ".e...e." + /* 6 */ ".l...l." + /* 7 */ ".l...l." + /* 8 */ ".fn.of." + /* 9 */ ".l.p.l." + /* 10 */ ".l...l." + /* 11 */ ".ellle." /* 12 */ "......." // Level 4 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".ghnhg." - /* 2 */ ".o..jo." - /* 3 */ ".o...o." - /* 4 */ ".o...o." - /* 5 */ ".g...g." - /* 6 */ ".o...o." - /* 7 */ ".o...o." - /* 8 */ ".hp.qh." - /* 9 */ ".o.r.o." - /* 10 */ ".o...o." - /* 11 */ ".gooog." - /* 12 */ "......." + /* 1 */ ".efffe." + /* 2 */ ".f.qhf." + /* 3 */ ".f...f." + /* 4 */ ".f...f." + /* 5 */ "re...er" + /* 6 */ "sf...ft" + /* 7 */ "sf...ft" + /* 8 */ "sf...ft" + /* 9 */ "sf...ft" + /* 10 */ "sf...ft" + /* 11 */ "sefffet" + /* 12 */ "su...vt" // Level 5 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".ghhhg." - /* 2 */ ".h.sjh." - /* 3 */ ".h...h." - /* 4 */ ".h...h." - /* 5 */ "tg...gt" - /* 6 */ "uh...hv" - /* 7 */ "uh...hv" - /* 8 */ "uh...hv" - /* 9 */ "uh...hv" - /* 10 */ "uh...hv" - /* 11 */ "ughhhgv" - /* 12 */ "uw...xv" + /* 1 */ ".ewwwe." + /* 2 */ ".xffhx." + /* 3 */ ".xfffx." + /* 4 */ ".xfffx." + /* 5 */ ".ewwwe." + /* 6 */ ".sf.ft." + /* 7 */ ".sf.ft." + /* 8 */ ".sf.ft." + /* 9 */ ".sf.ft." + /* 10 */ ".sf.ft." + /* 11 */ ".sffft." + /* 12 */ ".su.vt." // Level 6 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".gyyyg." - /* 2 */ ".zhhjz." - /* 3 */ ".zhhhz." - /* 4 */ ".zhhhz." - /* 5 */ ".gyyyg." - /* 6 */ ".uh.hv." - /* 7 */ ".uh.hv." - /* 8 */ ".uh.hv." - /* 9 */ ".uh.hv." - /* 10 */ ".uh.hv." - /* 11 */ ".uhhhv." - /* 12 */ ".uw.xv." + /* 1 */ ".eflfe." + /* 2 */ ".f..hf." + /* 3 */ ".f...f." + /* 4 */ ".f.y.f." + /* 5 */ ".efffe." + /* 6 */ "..sft.." + /* 7 */ "..sft.." + /* 8 */ "..sft.." + /* 9 */ "..sft.." + /* 10 */ "..sft.." + /* 11 */ "..sft.." + /* 12 */ "..sft.." // Level 7 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".ghohg." - /* 2 */ ".h..jh." - /* 3 */ ".h...h." - /* 4 */ ".h.A.h." - /* 5 */ ".ghhhg." - /* 6 */ "..uhv.." - /* 7 */ "..uhv.." - /* 8 */ "..uhv.." - /* 9 */ "..uhv.." - /* 10 */ "..uhv.." - /* 11 */ "..uhv.." - /* 12 */ "..uhv.." - - // Level 8 - /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".ghohg." - /* 2 */ ".h..jh." - /* 3 */ ".o...o." - /* 4 */ ".h...h." - /* 5 */ ".ghhhg." + /* 1 */ ".eflfe." + /* 2 */ ".f..hf." + /* 3 */ ".l...l." + /* 4 */ ".f...f." + /* 5 */ ".efffe." /* 6 */ "......." /* 7 */ "......." /* 8 */ "......." @@ -830,14 +1447,14 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 9 + // Level 8 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".ghohg." - /* 2 */ ".h..jh." - /* 3 */ ".h...h." - /* 4 */ ".h.B.h." - /* 5 */ ".ghhhg." + /* 1 */ ".eflfe." + /* 2 */ ".f..hf." + /* 3 */ ".f...f." + /* 4 */ ".f.z.f." + /* 5 */ ".efffe." /* 6 */ "......." /* 7 */ "......." /* 8 */ "......." @@ -846,14 +1463,14 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 10 + // Level 9 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".gyyyg." - /* 2 */ ".zhhjz." - /* 3 */ ".zhhhz." - /* 4 */ ".zhhhz." - /* 5 */ ".gyyyg." + /* 1 */ ".ewwwe." + /* 2 */ ".xffhx." + /* 3 */ ".xfffx." + /* 4 */ ".xfffx." + /* 5 */ ".ewwwe." /* 6 */ "......." /* 7 */ "......." /* 8 */ "......." @@ -862,14 +1479,14 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 11 + // Level 10 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".gCCCg." - /* 2 */ ".C...C." - /* 3 */ ".C...C." - /* 4 */ ".C...C." - /* 5 */ ".gCCCg." + /* 1 */ ".eAAAe." + /* 2 */ ".A...A." + /* 3 */ ".A...A." + /* 4 */ ".A...A." + /* 5 */ ".eAAAe." /* 6 */ "......." /* 7 */ "......." /* 8 */ "......." @@ -878,14 +1495,14 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 12 + // Level 11 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".g...g." + /* 1 */ ".e...e." /* 2 */ "......." /* 3 */ "......." /* 4 */ "......." - /* 5 */ ".g...g." + /* 5 */ ".e...e." /* 6 */ "......." /* 7 */ "......." /* 8 */ "......." @@ -894,15 +1511,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 13 + // Level 12 /* z\x* 0123456 */ - /* 0 */ "uw...xv" - /* 1 */ "ughhhgv" - /* 2 */ "uhDDDhv" - /* 3 */ "uhDDDhv" - /* 4 */ "uhDDDhv" - /* 5 */ "ughhhgv" - /* 6 */ "uw...xv" + /* 0 */ "su...vt" + /* 1 */ "sefffet" + /* 2 */ "sfBBBft" + /* 3 */ "sfBBBft" + /* 4 */ "sfBBBft" + /* 5 */ "sefffet" + /* 6 */ "su...vt" /* 7 */ "......." /* 8 */ "......." /* 9 */ "......." @@ -910,15 +1527,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 14 + // Level 13 /* z\x* 0123456 */ - /* 0 */ ".uw.xv." - /* 1 */ ".uhhhv." - /* 2 */ ".uhhhv." - /* 3 */ ".uhhhv." - /* 4 */ ".uhhhv." - /* 5 */ ".uhhhv." - /* 6 */ ".uw.xv." + /* 0 */ ".su.vt." + /* 1 */ ".sffft." + /* 2 */ ".sffft." + /* 3 */ ".sffft." + /* 4 */ ".sffft." + /* 5 */ ".sffft." + /* 6 */ ".su.vt." /* 7 */ "......." /* 8 */ "......." /* 9 */ "......." @@ -926,15 +1543,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "......." /* 12 */ "......." - // Level 15 + // Level 14 /* z\x* 0123456 */ - /* 0 */ "..uhv.." - /* 1 */ "..uhv.." - /* 2 */ "..uhv.." - /* 3 */ "..uhv.." - /* 4 */ "..uhv.." - /* 5 */ "..uhv.." - /* 6 */ "..uhv.." + /* 0 */ "..sft.." + /* 1 */ "..sft.." + /* 2 */ "..sft.." + /* 3 */ "..sft.." + /* 4 */ "..sft.." + /* 5 */ "..sft.." + /* 6 */ "..sft.." /* 7 */ "......." /* 8 */ "......." /* 9 */ "......." @@ -943,7 +1560,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 12 */ ".......", // Connectors: - "-1: 3, 2, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -962,6 +1579,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenChurchMid @@ -971,132 +1591,118 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 54, ID 105, created by Aloe_vera { // Size: - 7, 8, 9, // SizeX = 7, SizeY = 8, SizeZ = 9 + 7, 7, 9, // SizeX = 7, SizeY = 7, SizeZ = 9 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 7, 7, 9, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 7, 6, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c:170: 0\n" /* haybale */ - "d: 67: 0\n" /* stairs */ - "e: 67: 2\n" /* stairs */ - "f: 67: 1\n" /* stairs */ - "g: 4: 0\n" /* cobblestone */ - "h: 17: 0\n" /* tree */ - "i: 5: 0\n" /* wood */ - "j:170: 4\n" /* haybale */ - "k:170: 8\n" /* haybale */ - "l: 54: 2\n" /* chest */ + "a: 4: 0\n" /* cobblestone */ + "b:170: 0\n" /* haybale */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 17: 0\n" /* tree */ + "g: 5: 0\n" /* wood */ + "h:170: 4\n" /* haybale */ + "i:170: 8\n" /* haybale */ + "j: 54: 2\n" /* chest */ + "k: 50: 4\n" /* torch */ + "l: 53: 0\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 50: 4\n" /* torch */ - "o: 53: 0\n" /* woodstairs */ - "p: 53: 5\n" /* woodstairs */ - "q: 53: 4\n" /* woodstairs */ - "r: 53: 1\n" /* woodstairs */, + "n: 53: 5\n" /* woodstairs */ + "o: 53: 4\n" /* woodstairs */ + "p: 53: 1\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "aaaaaaa" - /* 2 */ "aaaaaaa" - /* 3 */ "aaaaaaa" - /* 4 */ "aaaaaaa" - /* 5 */ "aaaaaaa" - /* 6 */ "aaaaaaa" - /* 7 */ "aaaaaaa" - /* 8 */ "aaaaaaa" + /* 0 */ "maaaaam" + /* 1 */ "maaaaam" + /* 2 */ "maaaaam" + /* 3 */ "maaaaam" + /* 4 */ "maaaaam" + /* 5 */ "maaaaam" + /* 6 */ "maaaaam" + /* 7 */ "maaaaam" + /* 8 */ "mmmmmmm" // Level 1 /* z\x* 0123456 */ - /* 0 */ "aaaaaab" - /* 1 */ "baaaaab" - /* 2 */ "baaaaab" - /* 3 */ "baaaaab" - /* 4 */ "baaaaab" - /* 5 */ "baaaaab" - /* 6 */ "baaaaab" - /* 7 */ "baaaaab" - /* 8 */ "bbbbbbb" + /* 0 */ "bcddde." + /* 1 */ ".aaaaa." + /* 2 */ ".aaaaa." + /* 3 */ ".aaaaa." + /* 4 */ ".aaaaa." + /* 5 */ ".aaaaa." + /* 6 */ ".aaaaa." + /* 7 */ ".aaaaa." + /* 8 */ "......." // Level 2 /* z\x* 0123456 */ - /* 0 */ "cdeeef." - /* 1 */ ".ggggg." - /* 2 */ ".ggggg." - /* 3 */ ".ggggg." - /* 4 */ ".ggggg." - /* 5 */ ".ggggg." - /* 6 */ ".ggggg." - /* 7 */ ".ggggg." + /* 0 */ "......." + /* 1 */ ".f..bf." + /* 2 */ ".g...g." + /* 3 */ ".gb.hg." + /* 4 */ ".fihif." + /* 5 */ ".gbbbg." + /* 6 */ ".gijbg." + /* 7 */ ".fgfgf." /* 8 */ "......." // Level 3 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".h..ch." - /* 2 */ ".i...i." - /* 3 */ ".ic.ji." - /* 4 */ ".hkjkh." - /* 5 */ ".iccci." - /* 6 */ ".iklci." - /* 7 */ ".hihih." + /* 0 */ ".k...k." + /* 1 */ ".f...f." + /* 2 */ ".g...g." + /* 3 */ ".g...g." + /* 4 */ ".fh..f." + /* 5 */ ".ghibg." + /* 6 */ ".ghiig." + /* 7 */ ".fgfgf." /* 8 */ "......." // Level 4 /* z\x* 0123456 */ - /* 0 */ ".n...n." - /* 1 */ ".h...h." - /* 2 */ ".i...i." - /* 3 */ ".i...i." - /* 4 */ ".hj..h." - /* 5 */ ".ijkci." - /* 6 */ ".ijkki." - /* 7 */ ".hihih." - /* 8 */ "......." + /* 0 */ "ln...op" + /* 1 */ "lgggggp" + /* 2 */ "lg...gp" + /* 3 */ "lg...gp" + /* 4 */ "lg...gp" + /* 5 */ "lgbb.gp" + /* 6 */ "lgibigp" + /* 7 */ "lgggggp" + /* 8 */ "ln...op" // Level 5 /* z\x* 0123456 */ - /* 0 */ "op...qr" - /* 1 */ "oiiiiir" - /* 2 */ "oi...ir" - /* 3 */ "oi...ir" - /* 4 */ "oi...ir" - /* 5 */ "oicc.ir" - /* 6 */ "oikckir" - /* 7 */ "oiiiiir" - /* 8 */ "op...qr" + /* 0 */ ".ln.op." + /* 1 */ ".lgggp." + /* 2 */ ".lg.gp." + /* 3 */ ".lg.gp." + /* 4 */ ".lg.gp." + /* 5 */ ".lg.gp." + /* 6 */ ".lg.gp." + /* 7 */ ".lgggp." + /* 8 */ ".ln.op." // Level 6 /* z\x* 0123456 */ - /* 0 */ ".op.qr." - /* 1 */ ".oiiir." - /* 2 */ ".oi.ir." - /* 3 */ ".oi.ir." - /* 4 */ ".oi.ir." - /* 5 */ ".oi.ir." - /* 6 */ ".oi.ir." - /* 7 */ ".oiiir." - /* 8 */ ".op.qr." - - // Level 7 - /* z\x* 0123456 */ - /* 0 */ "..oir.." - /* 1 */ "..oir.." - /* 2 */ "..oir.." - /* 3 */ "..oir.." - /* 4 */ "..oir.." - /* 5 */ "..oir.." - /* 6 */ "..oir.." - /* 7 */ "..oir.." - /* 8 */ "..oir..", + /* 0 */ "..lgp.." + /* 1 */ "..lgp.." + /* 2 */ "..lgp.." + /* 3 */ "..lgp.." + /* 4 */ "..lgp.." + /* 5 */ "..lgp.." + /* 6 */ "..lgp.." + /* 7 */ "..lgp.." + /* 8 */ "..lgp..", // Connectors: - "-1: 3, 2, -1: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, -1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1115,6 +1721,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenGranary @@ -1124,160 +1733,145 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 47, ID 98, created by Aloe_vera { // Size: - 12, 9, 9, // SizeX = 12, SizeY = 9, SizeZ = 9 + 12, 8, 9, // SizeX = 12, SizeY = 8, SizeZ = 9 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 12, 8, 9, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 12, 7, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 17: 0\n" /* tree */ - "h: 5: 0\n" /* wood */ - "i: 64: 7\n" /* wooddoorblock */ - "j: 64: 5\n" /* wooddoorblock */ - "k: 53: 3\n" /* woodstairs */ - "l: 85: 0\n" /* fence */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 7\n" /* wooddoorblock */ + "h: 64: 5\n" /* wooddoorblock */ + "i: 53: 3\n" /* woodstairs */ + "j: 85: 0\n" /* fence */ + "k: 53: 2\n" /* woodstairs */ + "l: 53: 1\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 2\n" /* woodstairs */ - "o: 53: 1\n" /* woodstairs */ - "p: 53: 0\n" /* woodstairs */ - "q:102: 0\n" /* glasspane */ - "r: 64:12\n" /* wooddoorblock */ - "s: 50: 3\n" /* torch */ - "t: 72: 0\n" /* woodplate */ - "u: 53: 7\n" /* woodstairs */ - "v: 47: 0\n" /* bookshelf */ - "w: 50: 1\n" /* torch */ - "x: 50: 2\n" /* torch */ - "y: 53: 6\n" /* woodstairs */, + "n: 53: 0\n" /* woodstairs */ + "o:102: 0\n" /* glasspane */ + "p: 64:12\n" /* wooddoorblock */ + "q: 50: 3\n" /* torch */ + "r: 72: 0\n" /* woodplate */ + "s: 53: 7\n" /* woodstairs */ + "t: 47: 0\n" /* bookshelf */ + "u: 50: 1\n" /* torch */ + "v: 50: 2\n" /* torch */ + "w: 53: 6\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "aaaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaaa" - /* 2 */ "aaaaaaaaaaaa" - /* 3 */ "aaaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaaa" - /* 5 */ "aaaaaaaaaaaa" - /* 6 */ "aaaaaaaaaaaa" - /* 7 */ "aaaaaaaaaaaa" - /* 8 */ "aaaaaaaaaaaa" + /* 0 */ "mmmmaaaammmm" + /* 1 */ "maaaaaaaaaam" + /* 2 */ "maaaaaaaaaam" + /* 3 */ "maaaaaaaaaam" + /* 4 */ "maaaaaaaaaam" + /* 5 */ "maaaaaaaaaam" + /* 6 */ "maaaaaaaaaam" + /* 7 */ "maaaaaaaaaam" + /* 8 */ "mmmmmmmmmmmm" // Level 1 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "bbbbaaaabbbb" - /* 1 */ "baaaaaaaaaab" - /* 2 */ "baaaaaaaaaab" - /* 3 */ "baaaaaaaaaab" - /* 4 */ "baaaaaaaaaab" - /* 5 */ "baaaaaaaaaab" - /* 6 */ "baaaaaaaaaab" - /* 7 */ "baaaaaaaaaab" - /* 8 */ "bbbbbbbbbbbb" + /* 0 */ "....bccd...." + /* 1 */ ".aaaaaaaaaa." + /* 2 */ ".aaaaaaaaaa." + /* 3 */ ".aaaaaaaaaa." + /* 4 */ ".aaaaaaaaaa." + /* 5 */ ".aaaaaaaaaa." + /* 6 */ ".aaaaaaaaaa." + /* 7 */ ".aaaaaaaaaa." + /* 8 */ "............" // Level 2 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "....cdde...." - /* 1 */ ".ffffffffff." - /* 2 */ ".ffffffffff." - /* 3 */ ".ffffffffff." - /* 4 */ ".ffffffffff." - /* 5 */ ".ffffffffff." - /* 6 */ ".ffffffffff." - /* 7 */ ".ffffffffff." + /* 0 */ "............" + /* 1 */ ".efffghfffe." + /* 2 */ ".f........f." + /* 3 */ ".fi......if." + /* 4 */ ".fj......jf." + /* 5 */ ".fk......kf." + /* 6 */ ".f.ljnljn.f." + /* 7 */ ".effffffffe." /* 8 */ "............" // Level 3 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" - /* 1 */ ".ghhhijhhhg." - /* 2 */ ".h........h." - /* 3 */ ".hk......kh." - /* 4 */ ".hl......lh." - /* 5 */ ".hn......nh." - /* 6 */ ".h.olpolp.h." - /* 7 */ ".ghhhhhhhhg." + /* 1 */ ".eoofppfooe." + /* 2 */ ".o..q..q..o." + /* 3 */ ".o........o." + /* 4 */ ".fr......rf." + /* 5 */ ".o........o." + /* 6 */ ".o..r..r..o." + /* 7 */ ".eoofoofooe." /* 8 */ "............" // Level 4 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ ".gqqhrrhqqg." - /* 2 */ ".q..s..s..q." - /* 3 */ ".q........q." - /* 4 */ ".ht......th." - /* 5 */ ".q........q." - /* 6 */ ".q..t..t..q." - /* 7 */ ".gqqhqqhqqg." - /* 8 */ "............" + /* 0 */ "kkkkkkkkkkkk" + /* 1 */ "sffffffffffs" + /* 2 */ ".fttttttttf." + /* 3 */ ".f........f." + /* 4 */ ".fu......vf." + /* 5 */ ".f........f." + /* 6 */ ".fttttttttf." + /* 7 */ "wffffffffffw" + /* 8 */ "iiiiiiiiiiii" // Level 5 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "nnnnnnnnnnnn" - /* 1 */ "uhhhhhhhhhhu" - /* 2 */ ".hvvvvvvvvh." - /* 3 */ ".h........h." - /* 4 */ ".hw......xh." - /* 5 */ ".h........h." - /* 6 */ ".hvvvvvvvvh." - /* 7 */ "yhhhhhhhhhhy" - /* 8 */ "kkkkkkkkkkkk" - - // Level 6 - /* z\x* 11 */ - /* * 012345678901 */ /* 0 */ "............" - /* 1 */ "nnnnnnnnnnnn" - /* 2 */ "uhhhhhhhhhhu" - /* 3 */ ".hvvvvvvvvh." - /* 4 */ ".h........h." - /* 5 */ ".hvvvvvvvvh." - /* 6 */ "yhhhhhhhhhhy" - /* 7 */ "kkkkkkkkkkkk" + /* 1 */ "kkkkkkkkkkkk" + /* 2 */ "sffffffffffs" + /* 3 */ ".fttttttttf." + /* 4 */ ".f........f." + /* 5 */ ".fttttttttf." + /* 6 */ "wffffffffffw" + /* 7 */ "iiiiiiiiiiii" /* 8 */ "............" - // Level 7 + // Level 6 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" /* 1 */ "............" - /* 2 */ "nnnnnnnnnnnn" - /* 3 */ "uhhhhhhhhhhu" - /* 4 */ ".h........h." - /* 5 */ "yhhhhhhhhhhy" - /* 6 */ "kkkkkkkkkkkk" + /* 2 */ "kkkkkkkkkkkk" + /* 3 */ "sffffffffffs" + /* 4 */ ".f........f." + /* 5 */ "wffffffffffw" + /* 6 */ "iiiiiiiiiiii" /* 7 */ "............" /* 8 */ "............" - // Level 8 + // Level 7 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" /* 1 */ "............" /* 2 */ "............" - /* 3 */ "nnnnnnnnnnnn" - /* 4 */ "hhhhhhhhhhhh" - /* 5 */ "kkkkkkkkkkkk" + /* 3 */ "kkkkkkkkkkkk" + /* 4 */ "ffffffffffff" + /* 5 */ "iiiiiiiiiiii" /* 6 */ "............" /* 7 */ "............" /* 8 */ "............", // Connectors: - "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, + "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1296,6 +1890,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenHouse10x7Library @@ -1305,115 +1902,103 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 49, ID 100, created by Aloe_vera { // Size: - 7, 8, 7, // SizeX = 7, SizeY = 8, SizeZ = 7 + 7, 7, 7, // SizeX = 7, SizeY = 7, SizeZ = 7 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 7, 7, 7, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 7, 6, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 17: 0\n" /* tree */ - "h: 5: 0\n" /* wood */ - "i: 64: 7\n" /* wooddoorblock */ - "j: 64:12\n" /* wooddoorblock */ - "k:102: 0\n" /* glasspane */ - "l: 53: 2\n" /* woodstairs */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 7\n" /* wooddoorblock */ + "h: 64:12\n" /* wooddoorblock */ + "i:102: 0\n" /* glasspane */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 7\n" /* woodstairs */ + "l: 50: 3\n" /* torch */ "m: 19: 0\n" /* sponge */ - "n: 53: 7\n" /* woodstairs */ - "o: 50: 3\n" /* torch */ - "p: 53: 6\n" /* woodstairs */ - "q: 53: 3\n" /* woodstairs */, + "n: 53: 6\n" /* woodstairs */ + "o: 53: 3\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "aaaaaaa" - /* 2 */ "aaaaaaa" - /* 3 */ "aaaaaaa" - /* 4 */ "aaaaaaa" - /* 5 */ "aaaaaaa" - /* 6 */ "aaaaaaa" + /* 0 */ "mmaaamm" + /* 1 */ "maaaaam" + /* 2 */ "maaaaam" + /* 3 */ "maaaaam" + /* 4 */ "maaaaam" + /* 5 */ "maaaaam" + /* 6 */ "mmmmmmm" // Level 1 /* z\x* 0123456 */ - /* 0 */ "bbaaabb" - /* 1 */ "baaaaab" - /* 2 */ "baaaaab" - /* 3 */ "baaaaab" - /* 4 */ "baaaaab" - /* 5 */ "baaaaab" - /* 6 */ "bbbbbbb" + /* 0 */ "..bcd.." + /* 1 */ ".aaaaa." + /* 2 */ ".aaaaa." + /* 3 */ ".aaaaa." + /* 4 */ ".aaaaa." + /* 5 */ ".aaaaa." + /* 6 */ "......." // Level 2 /* z\x* 0123456 */ - /* 0 */ "..cde.." - /* 1 */ ".fffff." - /* 2 */ ".fffff." - /* 3 */ ".fffff." - /* 4 */ ".fffff." - /* 5 */ ".fffff." + /* 0 */ "......." + /* 1 */ ".efgfe." + /* 2 */ ".f...f." + /* 3 */ ".f...f." + /* 4 */ ".f...f." + /* 5 */ ".efffe." /* 6 */ "......." // Level 3 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".ghihg." - /* 2 */ ".h...h." - /* 3 */ ".h...h." - /* 4 */ ".h...h." - /* 5 */ ".ghhhg." + /* 1 */ ".efhfe." + /* 2 */ ".i...i." + /* 3 */ ".i...i." + /* 4 */ ".i...i." + /* 5 */ ".eiiie." /* 6 */ "......." // Level 4 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".ghjhg." - /* 2 */ ".k...k." - /* 3 */ ".k...k." - /* 4 */ ".k...k." - /* 5 */ ".gkkkg." - /* 6 */ "......." + /* 0 */ "jjjjjjj" + /* 1 */ "kfffffk" + /* 2 */ ".fl.lf." + /* 3 */ ".f...f." + /* 4 */ ".f...f." + /* 5 */ "nfffffn" + /* 6 */ "ooooooo" // Level 5 /* z\x* 0123456 */ - /* 0 */ "lllllll" - /* 1 */ "nhhhhhn" - /* 2 */ ".ho.oh." - /* 3 */ ".h...h." - /* 4 */ ".h...h." - /* 5 */ "phhhhhp" - /* 6 */ "qqqqqqq" - - // Level 6 - /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ "lllllll" - /* 2 */ "nhhhhhn" - /* 3 */ ".h...h." - /* 4 */ "phhhhhp" - /* 5 */ "qqqqqqq" + /* 1 */ "jjjjjjj" + /* 2 */ "kfffffk" + /* 3 */ ".f...f." + /* 4 */ "nfffffn" + /* 5 */ "ooooooo" /* 6 */ "......." - // Level 7 + // Level 6 /* z\x* 0123456 */ /* 0 */ "......." /* 1 */ "......." - /* 2 */ "lllllll" - /* 3 */ "hhhhhhh" - /* 4 */ "qqqqqqq" + /* 2 */ "jjjjjjj" + /* 3 */ "fffffff" + /* 4 */ "ooooooo" /* 5 */ "......." /* 6 */ ".......", // Connectors: - "-1: 3, 2, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1432,6 +2017,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenHouse5x5 @@ -1441,259 +2029,103 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 40, ID 91, created by xoft { // Size: - 9, 8, 7, // SizeX = 9, SizeY = 8, SizeZ = 7 - - // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 9, 7, 7, // MaxX, MaxY, MaxZ - - // Block definitions: - ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 17: 0\n" /* tree */ - "h: 5: 0\n" /* wood */ - "i: 64: 7\n" /* wooddoorblock */ - "j:102: 0\n" /* glasspane */ - "k: 64:12\n" /* wooddoorblock */ - "l: 53: 2\n" /* woodstairs */ - "m: 19: 0\n" /* sponge */ - "n: 53: 7\n" /* woodstairs */ - "o: 50: 3\n" /* torch */ - "p: 53: 6\n" /* woodstairs */ - "q: 53: 3\n" /* woodstairs */, - - // Block data: - // Level 0 - /* z\x* 012345678 */ - /* 0 */ "aaaaaaaaa" - /* 1 */ "aaaaaaaaa" - /* 2 */ "aaaaaaaaa" - /* 3 */ "aaaaaaaaa" - /* 4 */ "aaaaaaaaa" - /* 5 */ "aaaaaaaaa" - /* 6 */ "aaaaaaaaa" - - // Level 1 - /* z\x* 012345678 */ - /* 0 */ "bbbaaabbb" - /* 1 */ "baaaaaaab" - /* 2 */ "baaaaaaab" - /* 3 */ "baaaaaaab" - /* 4 */ "baaaaaaab" - /* 5 */ "baaaaaaab" - /* 6 */ "bbbbbbbbb" - - // Level 2 - /* z\x* 012345678 */ - /* 0 */ "...cde..." - /* 1 */ ".fffffff." - /* 2 */ ".fffffff." - /* 3 */ ".fffffff." - /* 4 */ ".fffffff." - /* 5 */ ".fffffff." - /* 6 */ "........." - - // Level 3 - /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ ".ghhihhg." - /* 2 */ ".h.....h." - /* 3 */ ".h.....h." - /* 4 */ ".h.....h." - /* 5 */ ".ghhhhhg." - /* 6 */ "........." - - // Level 4 - /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ ".gjhkhjg." - /* 2 */ ".j.....j." - /* 3 */ ".j.....j." - /* 4 */ ".j.....j." - /* 5 */ ".gjjhjjg." - /* 6 */ "........." - - // Level 5 - /* z\x* 012345678 */ - /* 0 */ "lllllllll" - /* 1 */ "nghhhhhgn" - /* 2 */ ".h.o.o.h." - /* 3 */ ".h.....h." - /* 4 */ ".h.....h." - /* 5 */ "pghhhhhgp" - /* 6 */ "qqqqqqqqq" - - // Level 6 - /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "lllllllll" - /* 2 */ "nhhhhhhhn" - /* 3 */ ".h.....h." - /* 4 */ "phhhhhhhp" - /* 5 */ "qqqqqqqqq" - /* 6 */ "........." - - // Level 7 - /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "lllllllll" - /* 3 */ "hhhhhhhhh" - /* 4 */ "qqqqqqqqq" - /* 5 */ "........." - /* 6 */ ".........", - - // Connectors: - "-1: 4, 2, -1: 2\n" /* Type -1, direction Z- */, - - // AllowedRotations: - 7, /* 1, 2, 3 CCW rotation allowed */ - - // Merge strategy: - cBlockArea::msSpongePrint, - - // ShouldExtendFloor: - true, - - // DefaultWeight: - 100, - - // DepthWeight: - "", - - // AddWeightIfSame: - 0, - }, // WoodenHouse7x5 - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // WoodenHouse9x5: - // The data has been exported from the gallery Plains, area index 41, ID 92, created by xoft - { - // Size: - 11, 8, 7, // SizeX = 11, SizeY = 8, SizeZ = 7 + 9, 7, 7, // SizeX = 9, SizeY = 7, SizeZ = 7 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 11, 7, 7, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 9, 6, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 17: 0\n" /* tree */ - "h: 5: 0\n" /* wood */ - "i: 64: 7\n" /* wooddoorblock */ - "j:102: 0\n" /* glasspane */ - "k: 64:12\n" /* wooddoorblock */ - "l: 53: 2\n" /* woodstairs */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 7\n" /* wooddoorblock */ + "h:102: 0\n" /* glasspane */ + "i: 64:12\n" /* wooddoorblock */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 7\n" /* woodstairs */ + "l: 50: 3\n" /* torch */ "m: 19: 0\n" /* sponge */ - "n: 53: 7\n" /* woodstairs */ - "o: 50: 3\n" /* torch */ - "p: 53: 6\n" /* woodstairs */ - "q: 53: 3\n" /* woodstairs */, - - // Block data: - // Level 0 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "aaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaa" - /* 2 */ "aaaaaaaaaaa" - /* 3 */ "aaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaa" - /* 5 */ "aaaaaaaaaaa" - /* 6 */ "aaaaaaaaaaa" + "n: 53: 6\n" /* woodstairs */ + "o: 53: 3\n" /* woodstairs */, - // Level 1 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "bbbbaaabbbb" - /* 1 */ "baaaaaaaaab" - /* 2 */ "baaaaaaaaab" - /* 3 */ "baaaaaaaaab" - /* 4 */ "baaaaaaaaab" - /* 5 */ "baaaaaaaaab" - /* 6 */ "bbbbbbbbbbb" + // Block data: + // Level 0 + /* z\x* 012345678 */ + /* 0 */ "mmmaaammm" + /* 1 */ "maaaaaaam" + /* 2 */ "maaaaaaam" + /* 3 */ "maaaaaaam" + /* 4 */ "maaaaaaam" + /* 5 */ "maaaaaaam" + /* 6 */ "mmmmmmmmm" + + // Level 1 + /* z\x* 012345678 */ + /* 0 */ "...bcd..." + /* 1 */ ".aaaaaaa." + /* 2 */ ".aaaaaaa." + /* 3 */ ".aaaaaaa." + /* 4 */ ".aaaaaaa." + /* 5 */ ".aaaaaaa." + /* 6 */ "........." // Level 2 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "....cde...." - /* 1 */ ".fffffffff." - /* 2 */ ".fffffffff." - /* 3 */ ".fffffffff." - /* 4 */ ".fffffffff." - /* 5 */ ".fffffffff." - /* 6 */ "..........." + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".effgffe." + /* 2 */ ".f.....f." + /* 3 */ ".f.....f." + /* 4 */ ".f.....f." + /* 5 */ ".efffffe." + /* 6 */ "........." // Level 3 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".ghhhihhhg." - /* 2 */ ".h.......h." - /* 3 */ ".h.......h." - /* 4 */ ".h.......h." - /* 5 */ ".ghhhhhhhg." - /* 6 */ "..........." + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".ehfifhe." + /* 2 */ ".h.....h." + /* 3 */ ".h.....h." + /* 4 */ ".h.....h." + /* 5 */ ".ehhfhhe." + /* 6 */ "........." // Level 4 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".gjjhkhjjg." - /* 2 */ ".j.......j." - /* 3 */ ".j.......j." - /* 4 */ ".j.......j." - /* 5 */ ".gjjjhjjjg." - /* 6 */ "..........." + /* z\x* 012345678 */ + /* 0 */ "jjjjjjjjj" + /* 1 */ "kefffffek" + /* 2 */ ".f.l.l.f." + /* 3 */ ".f.....f." + /* 4 */ ".f.....f." + /* 5 */ "nefffffen" + /* 6 */ "ooooooooo" // Level 5 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "lllllllllll" - /* 1 */ "nhhhhhhhhhn" - /* 2 */ ".h..o.o.hh." - /* 3 */ ".h......hh." - /* 4 */ ".h......hh." - /* 5 */ "phhhhhhhhhp" - /* 6 */ "qqqqqqqqqqq" + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "jjjjjjjjj" + /* 2 */ "kfffffffk" + /* 3 */ ".f.....f." + /* 4 */ "nfffffffn" + /* 5 */ "ooooooooo" + /* 6 */ "........." // Level 6 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ "lllllllllll" - /* 2 */ "nhhhhhhhhhn" - /* 3 */ ".hhhhhhhhh." - /* 4 */ "phhhhhhhhhp" - /* 5 */ "qqqqqqqqqqq" - /* 6 */ "..........." - - // Level 7 - /* z\x* 1 */ - /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ "..........." - /* 2 */ "lllllllllll" - /* 3 */ "hhhhhhhhhhh" - /* 4 */ "qqqqqqqqqqq" - /* 5 */ "..........." - /* 6 */ "...........", + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "jjjjjjjjj" + /* 3 */ "fffffffff" + /* 4 */ "ooooooooo" + /* 5 */ "........." + /* 6 */ ".........", // Connectors: - "-1: 5, 2, -1: 2\n" /* Type -1, direction Z- */, + "-1: 4, 1, -1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1712,139 +2144,122 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, - }, // WoodenHouse9x5 + + // MoveToGround: + true, + }, // WoodenHouse7x5 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x5: - // The data has been exported from the gallery Plains, area index 46, ID 97, created by Aloe_vera + // The data has been exported from the gallery Plains, area index 41, ID 92, created by xoft { // Size: - 11, 8, 7, // SizeX = 11, SizeY = 8, SizeZ = 7 + 11, 7, 7, // SizeX = 11, SizeY = 7, SizeZ = 7 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 11, 7, 7, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 11, 6, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 17: 0\n" /* tree */ - "h: 5: 0\n" /* wood */ - "i: 64: 7\n" /* wooddoorblock */ - "j: 53: 3\n" /* woodstairs */ - "k: 85: 0\n" /* fence */ - "l: 53: 2\n" /* woodstairs */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 7\n" /* wooddoorblock */ + "h:102: 0\n" /* glasspane */ + "i: 64:12\n" /* wooddoorblock */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 7\n" /* woodstairs */ + "l: 50: 3\n" /* torch */ "m: 19: 0\n" /* sponge */ - "n: 53: 1\n" /* woodstairs */ - "o: 53: 0\n" /* woodstairs */ - "p:102: 0\n" /* glasspane */ - "q: 64:12\n" /* wooddoorblock */ - "r: 50: 3\n" /* torch */ - "s: 72: 0\n" /* woodplate */ - "t: 53: 7\n" /* woodstairs */ - "u: 47: 0\n" /* bookshelf */ - "v: 50: 1\n" /* torch */ - "w: 50: 2\n" /* torch */ - "x: 53: 6\n" /* woodstairs */, + "n: 53: 6\n" /* woodstairs */ + "o: 53: 3\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "aaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaa" - /* 2 */ "aaaaaaaaaaa" - /* 3 */ "aaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaa" - /* 5 */ "aaaaaaaaaaa" - /* 6 */ "aaaaaaaaaaa" + /* 0 */ "mmmmaaammmm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "maaaaaaaaam" + /* 3 */ "maaaaaaaaam" + /* 4 */ "maaaaaaaaam" + /* 5 */ "maaaaaaaaam" + /* 6 */ "mmmmmmmmmmm" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "bbbbaaabbbb" - /* 1 */ "baaaaaaaaab" - /* 2 */ "baaaaaaaaab" - /* 3 */ "baaaaaaaaab" - /* 4 */ "baaaaaaaaab" - /* 5 */ "baaaaaaaaab" - /* 6 */ "bbbbbbbbbbb" + /* 0 */ "....bcd...." + /* 1 */ ".aaaaaaaaa." + /* 2 */ ".aaaaaaaaa." + /* 3 */ ".aaaaaaaaa." + /* 4 */ ".aaaaaaaaa." + /* 5 */ ".aaaaaaaaa." + /* 6 */ "..........." // Level 2 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "....cde...." - /* 1 */ ".fffffffff." - /* 2 */ ".fffffffff." - /* 3 */ ".fffffffff." - /* 4 */ ".fffffffff." - /* 5 */ ".fffffffff." + /* 0 */ "..........." + /* 1 */ ".efffgfffe." + /* 2 */ ".f.......f." + /* 3 */ ".f.......f." + /* 4 */ ".f.......f." + /* 5 */ ".efffffffe." /* 6 */ "..........." // Level 3 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ ".ghhhihhhg." - /* 2 */ ".hj.....jh." - /* 3 */ ".hk.....kh." - /* 4 */ ".hl.nko.lh." - /* 5 */ ".ghhhhhhhg." + /* 1 */ ".ehhfifhhe." + /* 2 */ ".h.......h." + /* 3 */ ".h.......h." + /* 4 */ ".h.......h." + /* 5 */ ".ehhhfhhhe." /* 6 */ "..........." // Level 4 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".gpphqhppg." - /* 2 */ ".p..r.r..p." - /* 3 */ ".ps.....sp." - /* 4 */ ".p...s...p." - /* 5 */ ".gppphpppg." - /* 6 */ "..........." + /* 0 */ "jjjjjjjjjjj" + /* 1 */ "kfffffffffk" + /* 2 */ ".f..l.l.ff." + /* 3 */ ".f......ff." + /* 4 */ ".f......ff." + /* 5 */ "nfffffffffn" + /* 6 */ "ooooooooooo" // Level 5 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "lllllllllll" - /* 1 */ "thhhhhhhhht" - /* 2 */ ".huuuuuuuh." - /* 3 */ ".hv.....wh." - /* 4 */ ".huuuuuuuh." - /* 5 */ "xhhhhhhhhhx" - /* 6 */ "jjjjjjjjjjj" - - // Level 6 - /* z\x* 1 */ - /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ "lllllllllll" - /* 2 */ "thhhhhhhhht" - /* 3 */ ".h.......h." - /* 4 */ "xhhhhhhhhhx" - /* 5 */ "jjjjjjjjjjj" + /* 1 */ "jjjjjjjjjjj" + /* 2 */ "kfffffffffk" + /* 3 */ ".fffffffff." + /* 4 */ "nfffffffffn" + /* 5 */ "ooooooooooo" /* 6 */ "..........." - // Level 7 + // Level 6 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." - /* 2 */ "lllllllllll" - /* 3 */ "hhhhhhhhhhh" - /* 4 */ "jjjjjjjjjjj" + /* 2 */ "jjjjjjjjjjj" + /* 3 */ "fffffffffff" + /* 4 */ "ooooooooooo" /* 5 */ "..........." /* 6 */ "...........", // Connectors: - "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, + "-1: 5, 1, -1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1863,6 +2278,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenHouse9x5 @@ -1893,11 +2311,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "k: 85: 0\n" /* fence */ "l: 53: 0\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 64: 2\n" /* wooddoorblock */ - "o: 64: 0\n" /* wooddoorblock */ + "n: 64: 6\n" /* wooddoorblock */ + "o: 64: 4\n" /* wooddoorblock */ "p:102: 0\n" /* glasspane */ "q: 72: 0\n" /* woodplate */ - "r: 64: 8\n" /* wooddoorblock */ + "r: 64:12\n" /* wooddoorblock */ "s: 53: 5\n" /* woodstairs */ "t: 53: 4\n" /* woodstairs */ "u: 50: 1\n" /* torch */ @@ -2029,162 +2447,291 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenHouse9x5Fence + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // WoodenHouse9x5Library: + // The data has been exported from the gallery Plains, area index 46, ID 97, created by Aloe_vera + { + // Size: + 11, 7, 7, // SizeX = 11, SizeY = 7, SizeZ = 7 + + // Hitbox (relative to bounding box): + -1, -1, 0, // MinX, MinY, MinZ + 11, 6, 7, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 7\n" /* wooddoorblock */ + "h: 53: 3\n" /* woodstairs */ + "i: 85: 0\n" /* fence */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 1\n" /* woodstairs */ + "l: 53: 0\n" /* woodstairs */ + "m: 19: 0\n" /* sponge */ + "n:102: 0\n" /* glasspane */ + "o: 64:12\n" /* wooddoorblock */ + "p: 50: 3\n" /* torch */ + "q: 72: 0\n" /* woodplate */ + "r: 53: 7\n" /* woodstairs */ + "s: 47: 0\n" /* bookshelf */ + "t: 50: 1\n" /* torch */ + "u: 50: 2\n" /* torch */ + "v: 53: 6\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmaaammmm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "maaaaaaaaam" + /* 3 */ "maaaaaaaaam" + /* 4 */ "maaaaaaaaam" + /* 5 */ "maaaaaaaaam" + /* 6 */ "mmmmmmmmmmm" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "....bcd...." + /* 1 */ ".aaaaaaaaa." + /* 2 */ ".aaaaaaaaa." + /* 3 */ ".aaaaaaaaa." + /* 4 */ ".aaaaaaaaa." + /* 5 */ ".aaaaaaaaa." + /* 6 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".efffgfffe." + /* 2 */ ".fh.....hf." + /* 3 */ ".fi.....if." + /* 4 */ ".fj.kil.jf." + /* 5 */ ".efffffffe." + /* 6 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".ennfofnne." + /* 2 */ ".n..p.p..n." + /* 3 */ ".nq.....qn." + /* 4 */ ".n...q...n." + /* 5 */ ".ennnfnnne." + /* 6 */ "..........." + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "jjjjjjjjjjj" + /* 1 */ "rfffffffffr" + /* 2 */ ".fsssssssf." + /* 3 */ ".ft.....uf." + /* 4 */ ".fsssssssf." + /* 5 */ "vfffffffffv" + /* 6 */ "hhhhhhhhhhh" + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "jjjjjjjjjjj" + /* 2 */ "rfffffffffr" + /* 3 */ ".f.......f." + /* 4 */ "vfffffffffv" + /* 5 */ "hhhhhhhhhhh" + /* 6 */ "..........." + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "jjjjjjjjjjj" + /* 3 */ "fffffffffff" + /* 4 */ "hhhhhhhhhhh" + /* 5 */ "..........." + /* 6 */ "...........", + + // Connectors: + "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // WoodenHouse9x5Library + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x7: // The data has been exported from the gallery Plains, area index 52, ID 103, created by Aloe_vera { // Size: - 11, 9, 9, // SizeX = 11, SizeY = 9, SizeZ = 9 + 11, 8, 9, // SizeX = 11, SizeY = 8, SizeZ = 9 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 11, 8, 9, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 11, 7, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 17: 0\n" /* tree */ - "h: 5: 0\n" /* wood */ - "i: 64: 7\n" /* wooddoorblock */ - "j:102: 0\n" /* glasspane */ - "k: 64:12\n" /* wooddoorblock */ - "l: 53: 2\n" /* woodstairs */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 7\n" /* wooddoorblock */ + "h:102: 0\n" /* glasspane */ + "i: 64:12\n" /* wooddoorblock */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 7\n" /* woodstairs */ + "l: 50: 3\n" /* torch */ "m: 19: 0\n" /* sponge */ - "n: 53: 7\n" /* woodstairs */ - "o: 50: 3\n" /* torch */ - "p: 50: 4\n" /* torch */ - "q: 53: 6\n" /* woodstairs */ - "r: 53: 3\n" /* woodstairs */, + "n: 50: 4\n" /* torch */ + "o: 53: 6\n" /* woodstairs */ + "p: 53: 3\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "aaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaa" - /* 2 */ "aaaaaaaaaaa" - /* 3 */ "aaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaa" - /* 5 */ "aaaaaaaaaaa" - /* 6 */ "aaaaaaaaaaa" - /* 7 */ "aaaaaaaaaaa" - /* 8 */ "aaaaaaaaaaa" + /* 0 */ "mmmmaaammmm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "maaaaaaaaam" + /* 3 */ "maaaaaaaaam" + /* 4 */ "maaaaaaaaam" + /* 5 */ "maaaaaaaaam" + /* 6 */ "maaaaaaaaam" + /* 7 */ "maaaaaaaaam" + /* 8 */ "mmmmmmmmmmm" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "bbbbaaabbbb" - /* 1 */ "baaaaaaaaab" - /* 2 */ "baaaaaaaaab" - /* 3 */ "baaaaaaaaab" - /* 4 */ "baaaaaaaaab" - /* 5 */ "baaaaaaaaab" - /* 6 */ "baaaaaaaaab" - /* 7 */ "baaaaaaaaab" - /* 8 */ "bbbbbbbbbbb" + /* 0 */ "....bcd...." + /* 1 */ ".aaaaaaaaa." + /* 2 */ ".aaaaaaaaa." + /* 3 */ ".aaaaaaaaa." + /* 4 */ ".aaaaaaaaa." + /* 5 */ ".aaaaaaaaa." + /* 6 */ ".aaaaaaaaa." + /* 7 */ ".aaaaaaaaa." + /* 8 */ "..........." // Level 2 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "....cde...." - /* 1 */ ".fffffffff." - /* 2 */ ".fffffffff." - /* 3 */ ".fffffffff." - /* 4 */ ".fffffffff." - /* 5 */ ".fffffffff." - /* 6 */ ".fffffffff." - /* 7 */ ".fffffffff." + /* 0 */ "..........." + /* 1 */ ".efffgfffe." + /* 2 */ ".f.......f." + /* 3 */ ".f.......f." + /* 4 */ ".f.......f." + /* 5 */ ".f.......f." + /* 6 */ ".f.......f." + /* 7 */ ".efffffffe." /* 8 */ "..........." // Level 3 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ ".ghhhihhhg." + /* 1 */ ".ehhfifhhe." /* 2 */ ".h.......h." /* 3 */ ".h.......h." - /* 4 */ ".h.......h." + /* 4 */ ".f.......f." /* 5 */ ".h.......h." /* 6 */ ".h.......h." - /* 7 */ ".ghhhhhhhg." + /* 7 */ ".ehhhfhhhe." /* 8 */ "..........." // Level 4 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".gjjhkhjjg." - /* 2 */ ".j.......j." - /* 3 */ ".j.......j." - /* 4 */ ".h.......h." - /* 5 */ ".j.......j." - /* 6 */ ".j.......j." - /* 7 */ ".gjjjhjjjg." - /* 8 */ "..........." + /* 0 */ "jjjjjjjjjjj" + /* 1 */ "kfffffffffk" + /* 2 */ ".f..l.l..f." + /* 3 */ ".f.......f." + /* 4 */ ".f.......f." + /* 5 */ ".f.......f." + /* 6 */ ".f...n...f." + /* 7 */ "offfffffffo" + /* 8 */ "ppppppppppp" // Level 5 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "lllllllllll" - /* 1 */ "nhhhhhhhhhn" - /* 2 */ ".h..o.o..h." - /* 3 */ ".h.......h." - /* 4 */ ".h.......h." - /* 5 */ ".h.......h." - /* 6 */ ".h...p...h." - /* 7 */ "qhhhhhhhhhq" - /* 8 */ "rrrrrrrrrrr" - - // Level 6 - /* z\x* 1 */ - /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ "lllllllllll" - /* 2 */ "nhhhhhhhhhn" - /* 3 */ ".h.......h." - /* 4 */ ".h.......h." - /* 5 */ ".h.......h." - /* 6 */ "qhhhhhhhhhq" - /* 7 */ "rrrrrrrrrrr" + /* 1 */ "jjjjjjjjjjj" + /* 2 */ "kfffffffffk" + /* 3 */ ".f.......f." + /* 4 */ ".f.......f." + /* 5 */ ".f.......f." + /* 6 */ "offfffffffo" + /* 7 */ "ppppppppppp" /* 8 */ "..........." - // Level 7 + // Level 6 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." - /* 2 */ "lllllllllll" - /* 3 */ "nhhhhhhhhhn" - /* 4 */ ".h.......h." - /* 5 */ "qhhhhhhhhhq" - /* 6 */ "rrrrrrrrrrr" + /* 2 */ "jjjjjjjjjjj" + /* 3 */ "kfffffffffk" + /* 4 */ ".f.......f." + /* 5 */ "offfffffffo" + /* 6 */ "ppppppppppp" /* 7 */ "..........." /* 8 */ "..........." - // Level 8 + // Level 7 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ "lllllllllll" - /* 4 */ "hhhhhhhhhhh" - /* 5 */ "rrrrrrrrrrr" + /* 3 */ "jjjjjjjjjjj" + /* 4 */ "fffffffffff" + /* 5 */ "ppppppppppp" /* 6 */ "..........." /* 7 */ "..........." /* 8 */ "...........", // Connectors: - "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, + "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2203,6 +2750,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenHouse9x7 @@ -2246,19 +2796,19 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "aaaaaaaaaaa" - /* 1 */ "aaaaaaaaaab" - /* 2 */ "aaaaaaaaaab" - /* 3 */ "aaaaaaaaaab" - /* 4 */ "aaaaaaaaaab" - /* 5 */ "aaaaaaaaaaa" - /* 6 */ "aaaaaaaaaab" - /* 7 */ "aaaaaaaaaab" - /* 8 */ "abaaaaaaabb" - /* 9 */ "aaaaaaaaabb" - /* 10 */ "aaaaaaaaabb" - /* 11 */ "abaaaaaaaba" - /* 12 */ "abaaaaaaabb" + /* 0 */ "abaaaaabbbb" + /* 1 */ "baaaaaaaaab" + /* 2 */ "baaaaaaaaab" + /* 3 */ "baaaaaaaaab" + /* 4 */ "baaaaaaaaab" + /* 5 */ "baaaaaaaaab" + /* 6 */ "baaaaaaaaab" + /* 7 */ "baaaaaaaaab" + /* 8 */ "bbaaaaaaabb" + /* 9 */ "bbaaaaaaabb" + /* 10 */ "bbaaaaaaabb" + /* 11 */ "bbaaaaaaabb" + /* 12 */ "bbaaaaaaabb" // Level 1 /* z\x* 1 */ @@ -2416,6 +2966,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenHouse9x7Butcher @@ -2425,156 +2978,141 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 38, ID 87, created by Aloe_vera { // Size: - 11, 9, 9, // SizeX = 11, SizeY = 9, SizeZ = 9 + 11, 8, 9, // SizeX = 11, SizeY = 8, SizeZ = 9 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 11, 8, 9, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 11, 7, 9, // MaxX, MaxY, MaxZ // Block definitions: - ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 67: 3\n" /* stairs */ - "h: 17: 0\n" /* tree */ - "i: 5: 0\n" /* wood */ - "j: 64: 7\n" /* wooddoorblock */ - "k:102: 0\n" /* glasspane */ - "l: 64:12\n" /* wooddoorblock */ + ".: 0: 0\n" /* air */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 67: 3\n" /* stairs */ + "f: 17: 0\n" /* tree */ + "g: 5: 0\n" /* wood */ + "h: 64: 7\n" /* wooddoorblock */ + "i:102: 0\n" /* glasspane */ + "j: 64:12\n" /* wooddoorblock */ + "k: 53: 2\n" /* woodstairs */ + "l: 53: 7\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 2\n" /* woodstairs */ - "o: 53: 7\n" /* woodstairs */ - "p: 17: 4\n" /* tree */ - "q: 17: 8\n" /* tree */ - "r: 50: 3\n" /* torch */ - "s: 50: 4\n" /* torch */ - "t: 53: 6\n" /* woodstairs */ - "u: 53: 3\n" /* woodstairs */, + "n: 17: 4\n" /* tree */ + "o: 17: 8\n" /* tree */ + "p: 50: 3\n" /* torch */ + "q: 50: 4\n" /* torch */ + "r: 53: 6\n" /* woodstairs */ + "s: 53: 3\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "aaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaa" - /* 2 */ "aaaaaaaaaaa" - /* 3 */ "aaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaa" - /* 5 */ "aaaaaaaaaaa" - /* 6 */ "aaaaaaaaaaa" - /* 7 */ "aaaaaaaaaaa" - /* 8 */ "aaaaaaaaaaa" + /* 0 */ "mmmmaaammmm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "maaaaaaaaam" + /* 3 */ "maaaaaaaaam" + /* 4 */ "maaaaaaaaam" + /* 5 */ "maaaaaaaaam" + /* 6 */ "maaaaaaaaam" + /* 7 */ "maaaaaaaaam" + /* 8 */ "mmmmaaammmm" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "bbbbaaabbbb" - /* 1 */ "baaaaaaaaab" - /* 2 */ "baaaaaaaaab" - /* 3 */ "baaaaaaaaab" - /* 4 */ "baaaaaaaaab" - /* 5 */ "baaaaaaaaab" - /* 6 */ "baaaaaaaaab" - /* 7 */ "baaaaaaaaab" - /* 8 */ "bbbbaaabbbb" + /* 0 */ "....bcd...." + /* 1 */ ".aaaaaaaaa." + /* 2 */ ".aaaaaaaaa." + /* 3 */ ".aaaaaaaaa." + /* 4 */ ".aaaaaaaaa." + /* 5 */ ".aaaaaaaaa." + /* 6 */ ".aaaaaaaaa." + /* 7 */ ".aaaaaaaaa." + /* 8 */ "....bed...." // Level 2 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "....cde...." - /* 1 */ ".fffffffff." - /* 2 */ ".fffffffff." - /* 3 */ ".fffffffff." - /* 4 */ ".fffffffff." - /* 5 */ ".fffffffff." - /* 6 */ ".fffffffff." - /* 7 */ ".fffffffff." - /* 8 */ "....cge...." + /* 0 */ "..........." + /* 1 */ ".fggfhfggf." + /* 2 */ ".g.......g." + /* 3 */ ".g.......g." + /* 4 */ ".f.......f." + /* 5 */ ".g.......g." + /* 6 */ ".g.......g." + /* 7 */ ".fggfhfggf." + /* 8 */ "..........." // Level 3 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ ".hiihjhiih." + /* 1 */ ".fiifjfiif." /* 2 */ ".i.......i." /* 3 */ ".i.......i." - /* 4 */ ".h.......h." + /* 4 */ ".f.......f." /* 5 */ ".i.......i." /* 6 */ ".i.......i." - /* 7 */ ".hiihjhiih." + /* 7 */ ".fiifjfiif." /* 8 */ "..........." // Level 4 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".hkkhlhkkh." - /* 2 */ ".k.......k." - /* 3 */ ".k.......k." - /* 4 */ ".h.......h." - /* 5 */ ".k.......k." - /* 6 */ ".k.......k." - /* 7 */ ".hkkhlhkkh." - /* 8 */ "..........." + /* 0 */ "kkkkkkkkkkk" + /* 1 */ "lfnnnnnnnfl" + /* 2 */ ".o..p.p..o." + /* 3 */ ".o.......o." + /* 4 */ ".o.......o." + /* 5 */ ".o.......o." + /* 6 */ ".o..q.q..o." + /* 7 */ "rfnnnnnnnfr" + /* 8 */ "sssssssssss" // Level 5 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "nnnnnnnnnnn" - /* 1 */ "ohpppppppho" - /* 2 */ ".q..r.r..q." - /* 3 */ ".q.......q." - /* 4 */ ".q.......q." - /* 5 */ ".q.......q." - /* 6 */ ".q..s.s..q." - /* 7 */ "thpppppppht" - /* 8 */ "uuuuuuuuuuu" - - // Level 6 - /* z\x* 1 */ - /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ "nnnnnnnnnnn" - /* 2 */ "oiiiiiiiiio" - /* 3 */ ".i.......i." - /* 4 */ ".i.......i." - /* 5 */ ".i.......i." - /* 6 */ "tiiiiiiiiit" - /* 7 */ "uuuuuuuuuuu" + /* 1 */ "kkkkkkkkkkk" + /* 2 */ "lgggggggggl" + /* 3 */ ".g.......g." + /* 4 */ ".g.......g." + /* 5 */ ".g.......g." + /* 6 */ "rgggggggggr" + /* 7 */ "sssssssssss" /* 8 */ "..........." - // Level 7 + // Level 6 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." - /* 2 */ "nnnnnnnnnnn" - /* 3 */ "oiiiiiiiiio" - /* 4 */ ".i.......i." - /* 5 */ "tiiiiiiiiit" - /* 6 */ "uuuuuuuuuuu" + /* 2 */ "kkkkkkkkkkk" + /* 3 */ "lgggggggggl" + /* 4 */ ".g.......g." + /* 5 */ "rgggggggggr" + /* 6 */ "sssssssssss" /* 7 */ "..........." /* 8 */ "..........." - // Level 8 + // Level 7 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ "nnnnnnnnnnn" - /* 4 */ "iiiiiiiiiii" - /* 5 */ "uuuuuuuuuuu" + /* 3 */ "kkkkkkkkkkk" + /* 4 */ "ggggggggggg" + /* 5 */ "sssssssssss" /* 6 */ "..........." /* 7 */ "..........." /* 8 */ "...........", // Connectors: - "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, + "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2593,6 +3131,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenHouse9x7DoubleDoor @@ -2602,250 +3143,228 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 39, ID 90, created by STR_Warrior { // Size: - 15, 10, 16, // SizeX = 15, SizeY = 10, SizeZ = 16 + 15, 9, 16, // SizeX = 15, SizeY = 9, SizeZ = 16 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 15, 9, 16, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 15, 8, 16, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "A: 50: 4\n" /* torch */ - "B: 50: 2\n" /* torch */ - "C: 53: 7\n" /* woodstairs */ - "D: 53: 4\n" /* woodstairs */ - "E: 53: 5\n" /* woodstairs */ - "F: 53: 6\n" /* woodstairs */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 43: 0\n" /* doubleslab */ - "h: 17: 0\n" /* tree */ - "i: 5: 0\n" /* wood */ - "j: 64: 7\n" /* wooddoorblock */ - "k: 96: 8\n" /* trapdoor */ - "l: 61: 2\n" /* furnace */ + "A: 53: 7\n" /* woodstairs */ + "B: 53: 4\n" /* woodstairs */ + "C: 53: 5\n" /* woodstairs */ + "D: 53: 6\n" /* woodstairs */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 43: 0\n" /* doubleslab */ + "f: 17: 0\n" /* tree */ + "g: 5: 0\n" /* wood */ + "h: 64: 7\n" /* wooddoorblock */ + "i: 96: 8\n" /* trapdoor */ + "j: 61: 2\n" /* furnace */ + "k: 53: 3\n" /* woodstairs */ + "l: 85: 0\n" /* fence */ "m: 19: 0\n" /* sponge */ - "n: 53: 3\n" /* woodstairs */ - "o: 85: 0\n" /* fence */ - "p: 53: 2\n" /* woodstairs */ - "q: 53: 1\n" /* woodstairs */ - "r: 53: 0\n" /* woodstairs */ - "s: 47: 0\n" /* bookshelf */ - "t:102: 0\n" /* glasspane */ - "u: 64:12\n" /* wooddoorblock */ - "v: 72: 0\n" /* woodplate */ - "w: 17: 4\n" /* tree */ - "x: 17: 8\n" /* tree */ - "y: 50: 3\n" /* torch */ - "z: 50: 1\n" /* torch */, + "n: 53: 2\n" /* woodstairs */ + "o: 53: 1\n" /* woodstairs */ + "p: 53: 0\n" /* woodstairs */ + "q: 47: 0\n" /* bookshelf */ + "r:102: 0\n" /* glasspane */ + "s: 64:12\n" /* wooddoorblock */ + "t: 72: 0\n" /* woodplate */ + "u: 17: 4\n" /* tree */ + "v: 17: 8\n" /* tree */ + "w: 50: 3\n" /* torch */ + "x: 50: 1\n" /* torch */ + "y: 50: 4\n" /* torch */ + "z: 50: 2\n" /* torch */, // Block data: // Level 0 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "aaaaaaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaaaaaa" - /* 2 */ "aaaaaaaaaaaaaaa" - /* 3 */ "aaaaaaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaaaaaa" - /* 5 */ "aaaaaaaaaaaaaaa" - /* 6 */ "aaaaaaaaaaaaaaa" - /* 7 */ "aaaaaaaaaaaaaaa" - /* 8 */ "mmmmmmmmaaaaaaa" - /* 9 */ "mmmmmmmmaaaaaaa" - /* 10 */ "mmmmmmmmaaaaaaa" - /* 11 */ "mmmmmmmmaaaaaaa" - /* 12 */ "mmmmmmmmaaaaaaa" - /* 13 */ "mmmmmmmmaaaaaaa" - /* 14 */ "mmmmmmmmaaaaaaa" - /* 15 */ "mmmmmmmmaaaaaaa" + /* 0 */ "mmmmmmaaammmmmm" + /* 1 */ "maaaaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaaaam" + /* 6 */ "maaaaaaaaaaaaam" + /* 7 */ "maaaaaaaaaaaaam" + /* 8 */ "mmmmmmmmaaaaaam" + /* 9 */ "mmmmmmmmaaaaaam" + /* 10 */ "mmmmmmmmaaaaaam" + /* 11 */ "mmmmmmmmaaaaaam" + /* 12 */ "mmmmmmmmaaaaaam" + /* 13 */ "mmmmmmmmaaaaaam" + /* 14 */ "mmmmmmmmaaaaaam" + /* 15 */ "mmmmmmmmmmmmmmm" // Level 1 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "bbbbbbaaabbbbbb" - /* 1 */ "baaaaaaaaaaaaab" - /* 2 */ "baaaaaaaaaaaaab" - /* 3 */ "baaaaaaaaaaaaab" - /* 4 */ "baaaaaaaaaaaaab" - /* 5 */ "baaaaaaaaaaaaab" - /* 6 */ "baaaaaaaaaaaaab" - /* 7 */ "baaaaaaaaaaaaab" - /* 8 */ "mmmmmmmmaaaaaab" - /* 9 */ "mmmmmmmmaaaaaab" - /* 10 */ "mmmmmmmmaaaaaab" - /* 11 */ "mmmmmmmmaaaaaab" - /* 12 */ "mmmmmmmmaaaaaab" - /* 13 */ "mmmmmmmmaaaaaab" - /* 14 */ "mmmmmmmmaaaaaab" - /* 15 */ "mmmmmmmmbbbbbbb" + /* 0 */ "......bcd......" + /* 1 */ ".aaaaaaaaaaaaa." + /* 2 */ ".aeeeeaaaaaaaa." + /* 3 */ ".aeeeeaaaaaaaa." + /* 4 */ ".aaaaaaaaaaaaa." + /* 5 */ ".aaaaaaaaaaaaa." + /* 6 */ ".aaaaaaaaaaaaa." + /* 7 */ ".aaaaaaaaaaaaa." + /* 8 */ "........aaaaaa." + /* 9 */ "mmmmmmm.aaaaaa." + /* 10 */ "mmmmmmm.aaaaaa." + /* 11 */ "mmmmmmm.aaaaaa." + /* 12 */ "mmmmmmm.aaaaaa." + /* 13 */ "mmmmmmm.aaaaaa." + /* 14 */ "mmmmmmm.aaaaaa." + /* 15 */ "mmmmmmm........" // Level 2 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "......cde......" - /* 1 */ ".fffffffffffff." - /* 2 */ ".fggggffffffff." - /* 3 */ ".fggggffffffff." - /* 4 */ ".fffffffffffff." - /* 5 */ ".fffffffffffff." - /* 6 */ ".fffffffffffff." - /* 7 */ "mfffffffffffff." - /* 8 */ "mmmmmmmmffffff." - /* 9 */ "mmmmmmmmffffff." - /* 10 */ "mmmmmmmmffffff." - /* 11 */ "mmmmmmmmffffff." - /* 12 */ "mmmmmmmmffffff." - /* 13 */ "mmmmmmmmffffff." - /* 14 */ "mmmmmmmmffffff." - /* 15 */ "mmmmmmmm......." + /* 0 */ "..............." + /* 1 */ ".fggggfhfggggf." + /* 2 */ ".g...i.......g." + /* 3 */ ".gjeee......kg." + /* 4 */ ".f..........lg." + /* 5 */ ".g..........ng." + /* 6 */ ".g.olp..ol...g." + /* 7 */ ".fggggggfn...f." + /* 8 */ "........g....g." + /* 9 */ "mmmmmmm.gk...g." + /* 10 */ "mmmmmmm.gl..kg." + /* 11 */ "mmmmmmm.gn..lg." + /* 12 */ "mmmmmmm.g...ng." + /* 13 */ "mmmmmmm.gq..qg." + /* 14 */ "mmmmmmm.fggggf." + /* 15 */ "mmmmmmm........" // Level 3 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".hiiiihjhiiiih." - /* 2 */ ".i...k.......i." - /* 3 */ ".ilggg......ni." - /* 4 */ ".h..........oi." - /* 5 */ ".i..........pi." - /* 6 */ ".i.qor..qo...i." - /* 7 */ "mhiiiiiihp...h." - /* 8 */ "mmmmmmmmi....i." - /* 9 */ "mmmmmmmmin...i." - /* 10 */ "mmmmmmmmio..ni." - /* 11 */ "mmmmmmmmip..oi." - /* 12 */ "mmmmmmmmi...pi." - /* 13 */ "mmmmmmmmis..si." - /* 14 */ "mmmmmmmmhiiiih." - /* 15 */ "mmmmmmmm......." + /* 1 */ ".fgrrgfsfgrrgf." + /* 2 */ ".g...........g." + /* 3 */ ".g...........r." + /* 4 */ ".f..........tr." + /* 5 */ ".g...........r." + /* 6 */ ".g..t....t...g." + /* 7 */ ".fgrrrrgf....f." + /* 8 */ "........g....g." + /* 9 */ "mmmmmmm.r....r." + /* 10 */ "mmmmmmm.rt...r." + /* 11 */ "mmmmmmm.r...tr." + /* 12 */ "mmmmmmm.r....r." + /* 13 */ "mmmmmmm.gq..qg." + /* 14 */ "mmmmmmm.fgrrgf." + /* 15 */ "mmmmmmm........" // Level 4 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".hittihuhittih." - /* 2 */ ".i...........i." - /* 3 */ ".i...........t." - /* 4 */ ".h..........vt." - /* 5 */ ".i...........t." - /* 6 */ ".i..v....v...i." - /* 7 */ "mhittttih....h." - /* 8 */ "mmmmmmmmi....i." - /* 9 */ "mmmmmmmmt....t." - /* 10 */ "mmmmmmmmtv...t." - /* 11 */ "mmmmmmmmt...vt." - /* 12 */ "mmmmmmmmt....t." - /* 13 */ "mmmmmmmmis..si." - /* 14 */ "mmmmmmmmhittih." - /* 15 */ "mmmmmmmm......." + /* 1 */ ".fuuuuuuuuuuuf." + /* 2 */ ".v....w.w....v." + /* 3 */ ".v...........v." + /* 4 */ ".vx..........v." + /* 5 */ ".v...........v." + /* 6 */ ".v......y....v." + /* 7 */ ".fuuuuuufx..zv." + /* 8 */ "........v....v." + /* 9 */ "mmmmmmm.v....v." + /* 10 */ "mmmmmmm.v....v." + /* 11 */ "mmmmmmm.v....v." + /* 12 */ "mmmmmmm.v....v." + /* 13 */ "mmmmmmm.v.yy.v." + /* 14 */ "mmmmmmm.fuuuuf." + /* 15 */ "mmmmmmm........" // Level 5 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ ".hwwwwwwwwwwwh." - /* 2 */ ".x....y.y....x." - /* 3 */ ".x...........x." - /* 4 */ ".xz..........x." - /* 5 */ ".x...........x." - /* 6 */ ".x......A....x." - /* 7 */ "mhwwwwwwhz..Bx." - /* 8 */ "mmmmmmmmx....x." - /* 9 */ "mmmmmmmmx....x." - /* 10 */ "mmmmmmmmx....x." - /* 11 */ "mmmmmmmmx....x." - /* 12 */ "mmmmmmmmx....x." - /* 13 */ "mmmmmmmmx.AA.x." - /* 14 */ "mmmmmmmmhwwwwh." - /* 15 */ "mmmmmmmm......." + /* 0 */ "nnnnnnnnnnnnnno" + /* 1 */ "pgggggggggggggo" + /* 2 */ "pgAAAAAAAAAABgo" + /* 3 */ "pgC.........Bgo" + /* 4 */ "pgC.........Bgo" + /* 5 */ "pgC.........Bgo" + /* 6 */ "pgCDDDDDDD..Bgo" + /* 7 */ "pggggggggC..Bgo" + /* 8 */ "pkkkkkkpgC..Bgo" + /* 9 */ "mmmmmmmpgC..Bgo" + /* 10 */ "mmmmmmmpgC..Bgo" + /* 11 */ "mmmmmmmpgC..Bgo" + /* 12 */ "mmmmmmmpgC..Bgo" + /* 13 */ "mmmmmmmpgCDDBgo" + /* 14 */ "mmmmmmmpggggggo" + /* 15 */ "mmmmmmmpkkkkkkk" // Level 6 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "ppppppppppppppq" - /* 1 */ "riiiiiiiiiiiiiq" - /* 2 */ "riCCCCCCCCCCDiq" - /* 3 */ "riE.........Diq" - /* 4 */ "riE.........Diq" - /* 5 */ "riE.........Diq" - /* 6 */ "riEFFFFFFF..Diq" - /* 7 */ "riiiiiiiiE..Diq" - /* 8 */ "rnnnnnnriE..Diq" - /* 9 */ "mmmmmmmriE..Diq" - /* 10 */ "mmmmmmmriE..Diq" - /* 11 */ "mmmmmmmriE..Diq" - /* 12 */ "mmmmmmmriE..Diq" - /* 13 */ "mmmmmmmriEFFDiq" - /* 14 */ "mmmmmmmriiiiiiq" - /* 15 */ "mmmmmmmrnnnnnnn" + /* 0 */ "..............." + /* 1 */ ".pnnnnnnnnnnno." + /* 2 */ ".pgggggggggggo." + /* 3 */ ".pgggggggggggo." + /* 4 */ ".pgggggggggggo." + /* 5 */ ".pgggggggggggo." + /* 6 */ ".pgggggggggggo." + /* 7 */ ".pkkkkkkkggggo." + /* 8 */ "........pggggo." + /* 9 */ "mmmmmmm.pggggo." + /* 10 */ "mmmmmmm.pggggo." + /* 11 */ "mmmmmmm.pggggo." + /* 12 */ "mmmmmmm.pggggo." + /* 13 */ "mmmmmmm.pggggo." + /* 14 */ "mmmmmmm.kkkkko." + /* 15 */ "mmmmmmm........" // Level 7 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "mmmmmmmmmmmmmmm" - /* 1 */ "mrpppppppppppqm" - /* 2 */ "mriiiiiiiiiiiqm" - /* 3 */ "mriiiiiiiiiiiqm" - /* 4 */ "mriiiiiiiiiiiqm" - /* 5 */ "mriiiiiiiiiiiqm" - /* 6 */ "mriiiiiiiiiiiqm" - /* 7 */ "mrnnnnnnniiiiqm" - /* 8 */ "mmmmmmmmriiiiqm" - /* 9 */ "mmmmmmmmriiiiqm" - /* 10 */ "mmmmmmmmriiiiqm" - /* 11 */ "mmmmmmmmriiiiqm" - /* 12 */ "mmmmmmmmriiiiqm" - /* 13 */ "mmmmmmmmriiiiqm" - /* 14 */ "mmmmmmmmnnnnnqm" - /* 15 */ "mmmmmmmmmmmmmmm" + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..nnnnnnnnnnn.." + /* 3 */ "..pgggggggggo.." + /* 4 */ "..pgggggggggo.." + /* 5 */ "..pgggggggggo.." + /* 6 */ "..kkkkkkkkggo.." + /* 7 */ ".........pggo.." + /* 8 */ ".........pggo.." + /* 9 */ "mmmmmmm..pggo.." + /* 10 */ "mmmmmmm..pggo.." + /* 11 */ "mmmmmmm..pggo.." + /* 12 */ "mmmmmmm..pggo.." + /* 13 */ "mmmmmmm..kkko.." + /* 14 */ "mmmmmmm........" + /* 15 */ "mmmmmmm........" // Level 8 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "mmmmmmmmmmmmmmm" - /* 1 */ "mmmmmmmmmmmmmmm" - /* 2 */ "mmpppppppppppmm" - /* 3 */ "mmriiiiiiiiiqmm" - /* 4 */ "mmriiiiiiiiiqmm" - /* 5 */ "mmriiiiiiiiiqmm" - /* 6 */ "mmnnnnnnnniiqmm" - /* 7 */ "mmmmmmmmmriiqmm" - /* 8 */ "mmmmmmmmmriiqmm" - /* 9 */ "mmmmmmmmmriiqmm" - /* 10 */ "mmmmmmmmmriiqmm" - /* 11 */ "mmmmmmmmmriiqmm" - /* 12 */ "mmmmmmmmmriiqmm" - /* 13 */ "mmmmmmmmmnnnqmm" - /* 14 */ "mmmmmmmmmmmmmmm" - /* 15 */ "mmmmmmmmmmmmmmm" - - // Level 9 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "mmmmmmmmmmmmmmm" - /* 1 */ "mmmmmmmmmmmmmmm" - /* 2 */ "mmmmmmmmmmmmmmm" - /* 3 */ "mmmrpppppppqmmm" - /* 4 */ "mmmriiiiiiiqmmm" - /* 5 */ "mmmrnnnnnnrqmmm" - /* 6 */ "mmmmmmmmmmrqmmm" - /* 7 */ "mmmmmmmmmmrqmmm" - /* 8 */ "mmmmmmmmmmrqmmm" - /* 9 */ "mmmmmmmmmmrqmmm" - /* 10 */ "mmmmmmmmmmrqmmm" - /* 11 */ "mmmmmmmmmmrqmmm" - /* 12 */ "mmmmmmmmmmrnmmm" - /* 13 */ "mmmmmmmmmmmmmmm" - /* 14 */ "mmmmmmmmmmmmmmm" - /* 15 */ "mmmmmmmmmmmmmmm", + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "...pnnnnnnno..." + /* 4 */ "...pgggggggo..." + /* 5 */ "...pkkkkkkpo..." + /* 6 */ "..........po..." + /* 7 */ "..........po..." + /* 8 */ "..........po..." + /* 9 */ "mmmmmmm...po..." + /* 10 */ "mmmmmmm...po..." + /* 11 */ "mmmmmmm...po..." + /* 12 */ "mmmmmmm...pk..." + /* 13 */ "mmmmmmm........" + /* 14 */ "mmmmmmm........" + /* 15 */ "mmmmmmm........", // Connectors: - "-1: 7, 2, 0: 2\n" /* Type -1, direction Z- */, + "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2864,6 +3383,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenHouseL13x14 @@ -2873,182 +3395,203 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 0, ID 4, created by Aloe_vera { // Size: - 16, 7, 16, // SizeX = 16, SizeY = 7, SizeZ = 16 + 16, 8, 16, // SizeX = 16, SizeY = 8, SizeZ = 16 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 16, 6, 16, // MaxX, MaxY, MaxZ + -1, 1, 0, // MinX, MinY, MinZ + 16, 7, 16, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 67: 0\n" /* stairs */ - "b: 67: 2\n" /* stairs */ - "c: 67: 1\n" /* stairs */ - "d: 4: 0\n" /* cobblestone */ - "e: 5: 0\n" /* wood */ - "f: 67: 3\n" /* stairs */ - "g: 17: 0\n" /* tree */ - "h: 64: 7\n" /* wooddoorblock */ - "i: 64: 5\n" /* wooddoorblock */ - "j:102: 0\n" /* glasspane */ - "k: 64:12\n" /* wooddoorblock */ - "l: 53: 2\n" /* woodstairs */ + "a: 4: 0\n" /* cobblestone */ + "b: 2: 0\n" /* grass */ + "c: 67: 0\n" /* stairs */ + "d: 67: 2\n" /* stairs */ + "e: 67: 1\n" /* stairs */ + "f: 5: 0\n" /* wood */ + "g: 67: 3\n" /* stairs */ + "h: 17: 0\n" /* tree */ + "i: 64: 7\n" /* wooddoorblock */ + "j: 64: 5\n" /* wooddoorblock */ + "k:102: 0\n" /* glasspane */ + "l: 64:12\n" /* wooddoorblock */ "m: 19: 0\n" /* sponge */ - "n: 53: 1\n" /* woodstairs */ - "o: 53: 7\n" /* woodstairs */ - "p: 53: 6\n" /* woodstairs */ - "q: 53: 3\n" /* woodstairs */ - "r: 53: 0\n" /* woodstairs */ - "s: 53: 5\n" /* woodstairs */ - "t: 53: 4\n" /* woodstairs */ - "u: 50: 3\n" /* torch */ - "v: 50: 2\n" /* torch */ - "w: 50: 4\n" /* torch */ - "x: 50: 1\n" /* torch */, + "n: 53: 2\n" /* woodstairs */ + "o: 53: 1\n" /* woodstairs */ + "p: 53: 7\n" /* woodstairs */ + "q: 53: 6\n" /* woodstairs */ + "r: 53: 3\n" /* woodstairs */ + "s: 53: 0\n" /* woodstairs */ + "t: 53: 5\n" /* woodstairs */ + "u: 53: 4\n" /* woodstairs */ + "v: 50: 3\n" /* torch */ + "w: 50: 2\n" /* torch */ + "x: 50: 4\n" /* torch */ + "y: 50: 1\n" /* torch */, // Block data: // Level 0 /* z\x* 111111 */ /* * 0123456789012345 */ - /* 0 */ "........abc....." - /* 1 */ ".dddddddddddddd." - /* 2 */ ".deeeeeeeeeeeed." - /* 3 */ ".deeeeeeeeeeeed." - /* 4 */ ".deeeeeeeeeeeed." - /* 5 */ ".deeeeeeeeeeeed." - /* 6 */ ".deeeeeeeeeeeed." - /* 7 */ ".ddddddddeeeeed." - /* 8 */ "mmmmmafcdeeeeed." - /* 9 */ "mmmmmmmmdeeeeed." - /* 10 */ "mmmmmmmmdeeeeed." - /* 11 */ "mmmmmmmmdeeeeed." - /* 12 */ "mmmmmmmmdeeeeed." - /* 13 */ "mmmmmmmmdeeeeed." - /* 14 */ "mmmmmmmmddddddd." - /* 15 */ "mmmmmmmm........" + /* 0 */ "mmmmmmmmaaammmmm" + /* 1 */ "maaaaaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaaaaam" + /* 6 */ "maaaaaaaaaaaaaam" + /* 7 */ "maaaaaaaaaaaaaam" + /* 8 */ "bbbbbaaaaaaaaaam" + /* 9 */ "bbbbbbbbaaaaaaam" + /* 10 */ "bbbbbbbbaaaaaaam" + /* 11 */ "bbbbbbbbaaaaaaam" + /* 12 */ "bbbbbbbbaaaaaaam" + /* 13 */ "bbbbbbbbaaaaaaam" + /* 14 */ "bbbbbbbbaaaaaaam" + /* 15 */ "bbbbbbbbmmmmmmmm" // Level 1 /* z\x* 111111 */ /* * 0123456789012345 */ - /* 0 */ "................" - /* 1 */ ".geeeeeeghgeeeg." - /* 2 */ ".e............e." - /* 3 */ ".e............e." - /* 4 */ ".e............e." - /* 5 */ ".e............e." - /* 6 */ ".e............e." - /* 7 */ ".geeeeieg.....e." - /* 8 */ "mmmmmm.me.....e." - /* 9 */ "mmmmmmmme.....e." - /* 10 */ "mmmmmmmme.....e." - /* 11 */ "mmmmmmmme.....e." - /* 12 */ "mmmmmmmme.....e." - /* 13 */ "mmmmmmmme.....e." - /* 14 */ "mmmmmmmmgeeeeeg." - /* 15 */ "mmmmmmmm........" + /* 0 */ "........cde....." + /* 1 */ ".aaaaaaaaaaaaaa." + /* 2 */ ".affffffffffffa." + /* 3 */ ".affffffffffffa." + /* 4 */ ".affffffffffffa." + /* 5 */ ".affffffffffffa." + /* 6 */ ".affffffffffffa." + /* 7 */ ".aaaaaaaafffffa." + /* 8 */ ".....cgeafffffa." + /* 9 */ "........afffffa." + /* 10 */ "........afffffa." + /* 11 */ "........afffffa." + /* 12 */ "........afffffa." + /* 13 */ "........afffffa." + /* 14 */ "........aaaaaaa." + /* 15 */ "................" // Level 2 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" - /* 1 */ ".gejjejjgkgjjeg." - /* 2 */ ".j............e." - /* 3 */ ".j............j." - /* 4 */ ".j............j." - /* 5 */ ".j............e." - /* 6 */ ".j............j." - /* 7 */ ".gejjekeg.....j." - /* 8 */ "mmmmmm.me.....e." - /* 9 */ "mmmmmmmmj.....j." - /* 10 */ "mmmmmmmmj.....j." - /* 11 */ "mmmmmmmme.....e." - /* 12 */ "mmmmmmmmj.....j." - /* 13 */ "mmmmmmmmj.....j." - /* 14 */ "mmmmmmmmgjjjjjg." - /* 15 */ "mmmmmmmm........" + /* 1 */ ".hffffffhihfffh." + /* 2 */ ".f............f." + /* 3 */ ".f............f." + /* 4 */ ".f............f." + /* 5 */ ".f............f." + /* 6 */ ".f............f." + /* 7 */ ".hffffjfh.....f." + /* 8 */ "........f.....f." + /* 9 */ "........f.....f." + /* 10 */ "........f.....f." + /* 11 */ "........f.....f." + /* 12 */ "........f.....f." + /* 13 */ "........f.....f." + /* 14 */ "........hfffffh." + /* 15 */ "................" // Level 3 /* z\x* 111111 */ /* * 0123456789012345 */ - /* 0 */ "llllllllllllllln" - /* 1 */ "ogeeeeeegegeeegn" - /* 2 */ ".e............en" - /* 3 */ ".e............en" - /* 4 */ ".e............en" - /* 5 */ ".e............en" - /* 6 */ ".e............en" - /* 7 */ "pgeeeeeeg.....en" - /* 8 */ "qqqqqqqre.....en" - /* 9 */ "mmmmmmmre.....en" - /* 10 */ "mmmmmmmre.....en" - /* 11 */ "mmmmmmmre.....en" - /* 12 */ "mmmmmmmre.....en" - /* 13 */ "mmmmmmmre.....en" - /* 14 */ "mmmmmmmrgeeeeegn" - /* 15 */ "mmmmmmmrs.....tn" + /* 0 */ "................" + /* 1 */ ".hfkkfkkhlhkkfh." + /* 2 */ ".k............f." + /* 3 */ ".k............k." + /* 4 */ ".k............k." + /* 5 */ ".k............f." + /* 6 */ ".k............k." + /* 7 */ ".hfkkflfh.....k." + /* 8 */ "........f.....f." + /* 9 */ "........k.....k." + /* 10 */ "........k.....k." + /* 11 */ "........f.....f." + /* 12 */ "........k.....k." + /* 13 */ "........k.....k." + /* 14 */ "........hkkkkkh." + /* 15 */ "................" // Level 4 /* z\x* 111111 */ /* * 0123456789012345 */ - /* 0 */ "................" - /* 1 */ "lllllllllllllll." - /* 2 */ "oeeeeeeeeeeeeen." - /* 3 */ ".e.........u.en." - /* 4 */ ".e..........ven." - /* 5 */ ".e......w....en." - /* 6 */ "peeeeeeeee...en." - /* 7 */ "qqqqqqqqrex..en." - /* 8 */ "mmmmmmmmre...en." - /* 9 */ "mmmmmmmmre...en." - /* 10 */ "mmmmmmmmre...en." - /* 11 */ "mmmmmmmmre...en." - /* 12 */ "mmmmmmmmre...en." - /* 13 */ "mmmmmmmmre...en." - /* 14 */ "mmmmmmmmreeeeen." - /* 15 */ "mmmmmmmmrs...tn." + /* 0 */ "nnnnnnnnnnnnnnno" + /* 1 */ "phffffffhfhfffho" + /* 2 */ ".f............fo" + /* 3 */ ".f............fo" + /* 4 */ ".f............fo" + /* 5 */ ".f............fo" + /* 6 */ ".f............fo" + /* 7 */ "qhffffffh.....fo" + /* 8 */ "rrrrrrrsf.....fo" + /* 9 */ ".......sf.....fo" + /* 10 */ ".......sf.....fo" + /* 11 */ ".......sf.....fo" + /* 12 */ ".......sf.....fo" + /* 13 */ ".......sf.....fo" + /* 14 */ ".......shfffffho" + /* 15 */ ".......st.....uo" // Level 5 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" - /* 1 */ "................" - /* 2 */ "llllllllllllln.." - /* 3 */ "oeeeeeeeeeeeen.." - /* 4 */ ".ex.........en.." - /* 5 */ "peeeeeeeeee.en.." - /* 6 */ "qqqqqqqqqre.en.." - /* 7 */ ".........re.en.." - /* 8 */ "mmmmmmmm.re.en.." - /* 9 */ "mmmmmmmm.re.en.." - /* 10 */ "mmmmmmmm.re.en.." - /* 11 */ "mmmmmmmm.re.en.." - /* 12 */ "mmmmmmmm.re.en.." - /* 13 */ "mmmmmmmm.rewen.." - /* 14 */ "mmmmmmmm.reeen.." - /* 15 */ "mmmmmmmm.rs.tn.." + /* 1 */ "nnnnnnnnnnnnnnn." + /* 2 */ "pfffffffffffffo." + /* 3 */ ".f.........v.fo." + /* 4 */ ".f..........wfo." + /* 5 */ ".f......x....fo." + /* 6 */ "qfffffffff...fo." + /* 7 */ "rrrrrrrrsfy..fo." + /* 8 */ "........sf...fo." + /* 9 */ "........sf...fo." + /* 10 */ "........sf...fo." + /* 11 */ "........sf...fo." + /* 12 */ "........sf...fo." + /* 13 */ "........sf...fo." + /* 14 */ "........sfffffo." + /* 15 */ "........st...uo." // Level 6 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" /* 1 */ "................" + /* 2 */ "nnnnnnnnnnnnno.." + /* 3 */ "pffffffffffffo.." + /* 4 */ ".fy.........fo.." + /* 5 */ "qffffffffff.fo.." + /* 6 */ "rrrrrrrrrsf.fo.." + /* 7 */ ".........sf.fo.." + /* 8 */ ".........sf.fo.." + /* 9 */ ".........sf.fo.." + /* 10 */ ".........sf.fo.." + /* 11 */ ".........sf.fo.." + /* 12 */ ".........sf.fo.." + /* 13 */ ".........sfxfo.." + /* 14 */ ".........sfffo.." + /* 15 */ ".........st.uo.." + + // Level 7 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ "................" /* 2 */ "................" - /* 3 */ "lllllllllllll..." - /* 4 */ "eeeeeeeeeeeen..." - /* 5 */ "qqqqqqqqqqren..." - /* 6 */ "..........ren..." - /* 7 */ "..........ren..." - /* 8 */ "mmmmmmmm..ren..." - /* 9 */ "mmmmmmmm..ren..." - /* 10 */ "mmmmmmmm..ren..." - /* 11 */ "mmmmmmmm..ren..." - /* 12 */ "mmmmmmmm..ren..." - /* 13 */ "mmmmmmmm..ren..." - /* 14 */ "mmmmmmmm..ren..." - /* 15 */ "mmmmmmmm..ren...", + /* 3 */ "nnnnnnnnnnnnn..." + /* 4 */ "ffffffffffffo..." + /* 5 */ "rrrrrrrrrrsfo..." + /* 6 */ "..........sfo..." + /* 7 */ "..........sfo..." + /* 8 */ "..........sfo..." + /* 9 */ "..........sfo..." + /* 10 */ "..........sfo..." + /* 11 */ "..........sfo..." + /* 12 */ "..........sfo..." + /* 13 */ "..........sfo..." + /* 14 */ "..........sfo..." + /* 15 */ "..........sfo...", // Connectors: - "-1: 9, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 9, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3067,6 +3610,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenHouseL14x14 @@ -3076,162 +3622,145 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 42, ID 93, created by xoft { // Size: - 11, 8, 11, // SizeX = 11, SizeY = 8, SizeZ = 11 + 11, 7, 11, // SizeX = 11, SizeY = 7, SizeZ = 11 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 11, 7, 11, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 11, 6, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 17: 0\n" /* tree */ - "h: 5: 0\n" /* wood */ - "i: 64: 7\n" /* wooddoorblock */ - "j:102: 0\n" /* glasspane */ - "k: 64:12\n" /* wooddoorblock */ - "l: 53: 2\n" /* woodstairs */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 7\n" /* wooddoorblock */ + "h:102: 0\n" /* glasspane */ + "i: 64:12\n" /* wooddoorblock */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 7\n" /* woodstairs */ + "l: 53: 1\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 7\n" /* woodstairs */ - "o: 53: 1\n" /* woodstairs */ - "p: 50: 3\n" /* torch */ - "q: 50: 4\n" /* torch */ - "r: 53: 6\n" /* woodstairs */ - "s: 50: 1\n" /* torch */ - "t: 50: 2\n" /* torch */ - "u: 53: 3\n" /* woodstairs */ - "v: 53: 0\n" /* woodstairs */ - "w: 53: 5\n" /* woodstairs */ - "x: 53: 4\n" /* woodstairs */, + "n: 50: 3\n" /* torch */ + "o: 50: 4\n" /* torch */ + "p: 53: 6\n" /* woodstairs */ + "q: 50: 1\n" /* torch */ + "r: 50: 2\n" /* torch */ + "s: 53: 3\n" /* woodstairs */ + "t: 53: 0\n" /* woodstairs */ + "u: 53: 5\n" /* woodstairs */ + "v: 53: 4\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "aaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaa" - /* 2 */ "aaaaaaaaaaa" - /* 3 */ "aaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaa" - /* 5 */ "aaaaaaaaaaa" - /* 6 */ "aaaaaaaaaaa" - /* 7 */ "aaaaaaaaaaa" - /* 8 */ "aaaaaaaaaaa" - /* 9 */ "aaaaaaaaaaa" - /* 10 */ "aaaaaaaaaaa" + /* 0 */ "mmmmaaammmm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "maaaaaaaaam" + /* 3 */ "maaaaaaaaam" + /* 4 */ "maaaaaaaaam" + /* 5 */ "maaaaaaaaam" + /* 6 */ "mmmmmaaaaam" + /* 7 */ "mmmmmaaaaam" + /* 8 */ "mmmmmaaaaam" + /* 9 */ "mmmmmaaaaam" + /* 10 */ "mmmmmmmmmmm" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "bbbbaaabbbb" - /* 1 */ "baaaaaaaaab" - /* 2 */ "baaaaaaaaab" - /* 3 */ "baaaaaaaaab" - /* 4 */ "baaaaaaaaab" - /* 5 */ "baaaaaaaaab" - /* 6 */ "bbbbbaaaaab" - /* 7 */ "bbbbbaaaaab" - /* 8 */ "bbbbbaaaaab" - /* 9 */ "bbbbbaaaaab" - /* 10 */ "bbbbbbbbbbb" + /* 0 */ "....bcd...." + /* 1 */ ".aaaaaaaaa." + /* 2 */ ".aaaaaaaaa." + /* 3 */ ".aaaaaaaaa." + /* 4 */ ".aaaaaaaaa." + /* 5 */ ".aaaaaaaaa." + /* 6 */ ".....aaaaa." + /* 7 */ ".....aaaaa." + /* 8 */ ".....aaaaa." + /* 9 */ ".....aaaaa." + /* 10 */ "..........." // Level 2 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "....cde...." - /* 1 */ ".fffffffff." - /* 2 */ ".fffffffff." - /* 3 */ ".fffffffff." - /* 4 */ ".fffffffff." - /* 5 */ ".fffffffff." - /* 6 */ ".....fffff." - /* 7 */ "mmmm.fffff." - /* 8 */ "mmmm.fffff." - /* 9 */ "mmmm.fffff." - /* 10 */ "mmmm......." + /* 0 */ "..........." + /* 1 */ ".efffgfffe." + /* 2 */ ".f.......f." + /* 3 */ ".f.......f." + /* 4 */ ".f.......f." + /* 5 */ ".efffe...f." + /* 6 */ ".....f...f." + /* 7 */ ".....f...f." + /* 8 */ ".....f...f." + /* 9 */ ".....efffe." + /* 10 */ "..........." // Level 3 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ ".ghhhihhhg." + /* 1 */ ".ehhfifhhe." /* 2 */ ".h.......h." /* 3 */ ".h.......h." /* 4 */ ".h.......h." - /* 5 */ ".ghhhg...h." + /* 5 */ ".ehhhe...f." /* 6 */ ".....h...h." - /* 7 */ "mmmm.h...h." - /* 8 */ "mmmm.h...h." - /* 9 */ "mmmm.ghhhg." - /* 10 */ "mmmm......." + /* 7 */ ".....h...h." + /* 8 */ ".....h...h." + /* 9 */ ".....ehhhe." + /* 10 */ "..........." // Level 4 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".gjjhkhjjg." - /* 2 */ ".j.......j." - /* 3 */ ".j.......j." - /* 4 */ ".j.......j." - /* 5 */ ".gjjjg...h." - /* 6 */ ".....j...j." - /* 7 */ "mmmm.j...j." - /* 8 */ "mmmm.j...j." - /* 9 */ "mmmm.gjjjg." - /* 10 */ "mmmm......." + /* 0 */ "jjjjjjjjjjj" + /* 1 */ "kfffffffffl" + /* 2 */ ".f..n.n..fl" + /* 3 */ ".f.......fl" + /* 4 */ ".f...o...fl" + /* 5 */ "pfffffq.rfl" + /* 6 */ "sssssf...fl" + /* 7 */ "....tf...fl" + /* 8 */ "....tf...fl" + /* 9 */ "....tfffffl" + /* 10 */ "....tu...vl" // Level 5 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "lllllllllll" - /* 1 */ "nhhhhhhhhho" - /* 2 */ ".h..p.p..ho" - /* 3 */ ".h.......ho" - /* 4 */ ".h...q...ho" - /* 5 */ "rhhhhhs.tho" - /* 6 */ "uuuuuh...ho" - /* 7 */ "mmmmvh...ho" - /* 8 */ "mmmmvh...ho" - /* 9 */ "mmmmvhhhhho" - /* 10 */ "mmmmvw...xo" - - // Level 6 - /* z\x* 1 */ - /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ "lllllllllo." - /* 2 */ "nhhhhhhhho." - /* 3 */ ".h......ho." - /* 4 */ "rhhhhhh.ho." - /* 5 */ "uuuuuuh.ho." - /* 6 */ ".....vh.ho." - /* 7 */ "mmmm.vh.ho." - /* 8 */ "mmmm.vh.ho." - /* 9 */ "mmmm.vhhho." - /* 10 */ "mmmm.vw.xo." + /* 1 */ "jjjjjjjjjl." + /* 2 */ "kffffffffl." + /* 3 */ ".f......fl." + /* 4 */ "pffffff.fl." + /* 5 */ "ssssssf.fl." + /* 6 */ ".....tf.fl." + /* 7 */ ".....tf.fl." + /* 8 */ ".....tf.fl." + /* 9 */ ".....tfffl." + /* 10 */ ".....tu.vl." - // Level 7 + // Level 6 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." - /* 2 */ "lllllllll.." - /* 3 */ "hhhhhhhho.." - /* 4 */ "uuuuuuvho.." - /* 5 */ "......vho.." - /* 6 */ "......vho.." - /* 7 */ "mmmm..vho.." - /* 8 */ "mmmm..vho.." - /* 9 */ "mmmm..vho.." - /* 10 */ "mmmm..vho..", + /* 2 */ "jjjjjjjjj.." + /* 3 */ "ffffffffl.." + /* 4 */ "sssssstfl.." + /* 5 */ "......tfl.." + /* 6 */ "......tfl.." + /* 7 */ "......tfl.." + /* 8 */ "......tfl.." + /* 9 */ "......tfl.." + /* 10 */ "......tfl..", // Connectors: - "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, + "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3250,6 +3779,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenHouseL9x9 @@ -3259,160 +3791,143 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 43, ID 94, created by xoft { // Size: - 15, 8, 11, // SizeX = 15, SizeY = 8, SizeZ = 11 + 15, 7, 11, // SizeX = 15, SizeY = 7, SizeZ = 11 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 15, 7, 11, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 15, 6, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 17: 0\n" /* tree */ - "h: 5: 0\n" /* wood */ - "i: 64: 7\n" /* wooddoorblock */ - "j:102: 0\n" /* glasspane */ - "k: 64:12\n" /* wooddoorblock */ - "l: 53: 2\n" /* woodstairs */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 64: 7\n" /* wooddoorblock */ + "h:102: 0\n" /* glasspane */ + "i: 64:12\n" /* wooddoorblock */ + "j: 53: 2\n" /* woodstairs */ + "k: 53: 0\n" /* woodstairs */ + "l: 53: 1\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 0\n" /* woodstairs */ - "o: 53: 1\n" /* woodstairs */ - "p: 50: 3\n" /* torch */ - "q: 50: 4\n" /* torch */ - "r: 50: 2\n" /* torch */ - "s: 50: 1\n" /* torch */ - "t: 53: 3\n" /* woodstairs */ - "u: 53: 5\n" /* woodstairs */ - "v: 53: 4\n" /* woodstairs */, + "n: 50: 3\n" /* torch */ + "o: 50: 4\n" /* torch */ + "p: 50: 2\n" /* torch */ + "q: 50: 1\n" /* torch */ + "r: 53: 3\n" /* woodstairs */ + "s: 53: 5\n" /* woodstairs */ + "t: 53: 4\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "aaaaaaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaaaaaa" - /* 2 */ "aaaaaaaaaaaaaaa" - /* 3 */ "aaaaaaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaaaaaa" - /* 5 */ "aaaaaaaaaaaaaaa" - /* 6 */ "aaaaaaaaaaaaaaa" - /* 7 */ "aaaaaaaaaaaaaaa" - /* 8 */ "aaaaaaaaaaaaaaa" - /* 9 */ "aaaaaaaaaaaaaaa" - /* 10 */ "aaaaaaaaaaaaaaa" + /* 0 */ "mmmmmmaaammmmmm" + /* 1 */ "maaaaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaaaam" + /* 6 */ "maaaaammmaaaaam" + /* 7 */ "maaaaammmaaaaam" + /* 8 */ "maaaaammmaaaaam" + /* 9 */ "maaaaammmaaaaam" + /* 10 */ "mmmmmmmmmmmmmmm" // Level 1 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "bbbbbbaaabbbbbb" - /* 1 */ "baaaaaaaaaaaaab" - /* 2 */ "baaaaaaaaaaaaab" - /* 3 */ "baaaaaaaaaaaaab" - /* 4 */ "baaaaaaaaaaaaab" - /* 5 */ "baaaaaaaaaaaaab" - /* 6 */ "baaaaabbbaaaaab" - /* 7 */ "baaaaabbbaaaaab" - /* 8 */ "baaaaabbbaaaaab" - /* 9 */ "baaaaabbbaaaaab" - /* 10 */ "bbbbbbbbbbbbbbb" + /* 0 */ "......bcd......" + /* 1 */ ".aaaaaaaaaaaaa." + /* 2 */ ".aaaaaaaaaaaaa." + /* 3 */ ".aaaaaaaaaaaaa." + /* 4 */ ".aaaaaaaaaaaaa." + /* 5 */ ".aaaaaaaaaaaaa." + /* 6 */ ".aaaaa...aaaaa." + /* 7 */ ".aaaaa...aaaaa." + /* 8 */ ".aaaaa...aaaaa." + /* 9 */ ".aaaaa...aaaaa." + /* 10 */ "..............." // Level 2 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "......cde......" - /* 1 */ ".fffffffffffff." - /* 2 */ ".fffffffffffff." - /* 3 */ ".fffffffffffff." - /* 4 */ ".fffffffffffff." - /* 5 */ ".fffffffffffff." - /* 6 */ ".fffff...fffff." - /* 7 */ ".fffff...fffff." - /* 8 */ ".fffff...fffff." - /* 9 */ ".fffff...fffff." + /* 0 */ "..............." + /* 1 */ ".efffffgfffffe." + /* 2 */ ".f...........f." + /* 3 */ ".f...........f." + /* 4 */ ".f...........f." + /* 5 */ ".f...efffe...f." + /* 6 */ ".f...f...f...f." + /* 7 */ ".f...f...f...f." + /* 8 */ ".f...f...f...f." + /* 9 */ ".efffe...efffe." /* 10 */ "..............." // Level 3 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".ghhhhhihhhhhg." + /* 1 */ ".ehhhhfifhhhhe." /* 2 */ ".h...........h." /* 3 */ ".h...........h." /* 4 */ ".h...........h." - /* 5 */ ".h...ghhhg...h." + /* 5 */ ".f...ehhhe...f." /* 6 */ ".h...h...h...h." /* 7 */ ".h...h...h...h." /* 8 */ ".h...h...h...h." - /* 9 */ ".ghhhg...ghhhg." + /* 9 */ ".ehhhe...ehhhe." /* 10 */ "..............." // Level 4 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ ".gjjjjhkhjjjjg." - /* 2 */ ".j...........j." - /* 3 */ ".j...........j." - /* 4 */ ".j...........j." - /* 5 */ ".h...gjjjg...h." - /* 6 */ ".j...j...j...j." - /* 7 */ ".j...j...j...j." - /* 8 */ ".j...j...j...j." - /* 9 */ ".gjjjg...gjjjg." - /* 10 */ "..............." + /* 0 */ "jjjjjjjjjjjjjjj" + /* 1 */ "kfffffffffffffl" + /* 2 */ "kf....n.n....fl" + /* 3 */ "kf...........fl" + /* 4 */ "kf...o...o...fl" + /* 5 */ "kf..pfffffq..fl" + /* 6 */ "kf...frrrf...fl" + /* 7 */ "kf...fl.kf...fl" + /* 8 */ "kf...fl.kf...fl" + /* 9 */ "kfffffl.kfffffl" + /* 10 */ "ks...tl.ks...tl" // Level 5 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "lllllllllllllll" - /* 1 */ "nhhhhhhhhhhhhho" - /* 2 */ "nh....p.p....ho" - /* 3 */ "nh...........ho" - /* 4 */ "nh...q...q...ho" - /* 5 */ "nh..rhhhhhs..ho" - /* 6 */ "nh...httth...ho" - /* 7 */ "nh...ho.nh...ho" - /* 8 */ "nh...ho.nh...ho" - /* 9 */ "nhhhhho.nhhhhho" - /* 10 */ "nu...vo.nu...vo" - - // Level 6 - /* z\x* 11111 */ - /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".llllllllllllo." - /* 2 */ ".nhhhhhhhhhhho." - /* 3 */ ".nhhhhhhhhhhho." - /* 4 */ ".nhhhhhhhhhhho." - /* 5 */ ".nhhhotttthhho." - /* 6 */ ".nhhho...nhhho." - /* 7 */ ".nhhho...nhhho." - /* 8 */ ".nhhho...nhhho." - /* 9 */ ".nhhho...nhhho." - /* 10 */ ".nu.vo...nu.vo." + /* 1 */ ".jjjjjjjjjjjjl." + /* 2 */ ".kfffffffffffl." + /* 3 */ ".kfffffffffffl." + /* 4 */ ".kfffffffffffl." + /* 5 */ ".kffflrrrrfffl." + /* 6 */ ".kfffl...kfffl." + /* 7 */ ".kfffl...kfffl." + /* 8 */ ".kfffl...kfffl." + /* 9 */ ".kfffl...kfffl." + /* 10 */ ".ks.tl...ks.tl." - // Level 7 + // Level 6 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ "..nllllllllll.." - /* 3 */ "..nhhhhhhhhho.." - /* 4 */ "..nhotttttnho.." - /* 5 */ "..nho.....nho.." - /* 6 */ "..nho.....nho.." - /* 7 */ "..nho.....nho.." - /* 8 */ "..nho.....nho.." - /* 9 */ "..nho.....nho.." - /* 10 */ "..nho.....nho..", + /* 2 */ "..kjjjjjjjjjj.." + /* 3 */ "..kfffffffffl.." + /* 4 */ "..kflrrrrrkfl.." + /* 5 */ "..kfl.....kfl.." + /* 6 */ "..kfl.....kfl.." + /* 7 */ "..kfl.....kfl.." + /* 8 */ "..kfl.....kfl.." + /* 9 */ "..kfl.....kfl.." + /* 10 */ "..kfl.....kfl..", // Connectors: - "-1: 7, 2, 0: 2\n" /* Type -1, direction Z- */, + "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3431,6 +3946,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenHouseU13x9 @@ -3440,272 +3958,254 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 60, ID 111, created by Aloe_vera { // Size: - 9, 18, 13, // SizeX = 9, SizeY = 18, SizeZ = 13 + 9, 17, 13, // SizeX = 9, SizeY = 17, SizeZ = 13 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 8, 17, 12, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 8, 16, 12, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 4: 0\n" /* cobblestone */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 67: 3\n" /* stairs */ - "g: 17: 0\n" /* tree */ - "h: 5: 0\n" /* wood */ - "i: 54: 4\n" /* chest */ - "j:154: 4\n" /* hopper */ - "k: 64: 4\n" /* wooddoorblock */ - "l:102: 0\n" /* glasspane */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 2\n" /* stairs */ + "c: 67: 1\n" /* stairs */ + "d: 67: 3\n" /* stairs */ + "e: 17: 0\n" /* tree */ + "f: 5: 0\n" /* wood */ + "g: 54: 4\n" /* chest */ + "h:154: 4\n" /* hopper */ + "i: 64: 4\n" /* wooddoorblock */ + "j:102: 0\n" /* glasspane */ + "k: 85: 0\n" /* fence */ + "l: 64:12\n" /* wooddoorblock */ "m: 19: 0\n" /* sponge */ - "n: 85: 0\n" /* fence */ - "o: 64:12\n" /* wooddoorblock */ - "p: 50: 2\n" /* torch */ - "q: 35: 0\n" /* wool */ - "r: 17: 4\n" /* tree */ - "s: 17: 8\n" /* tree */ - "t: 53: 2\n" /* woodstairs */ - "u: 53: 7\n" /* woodstairs */ - "v: 53: 6\n" /* woodstairs */ - "w: 53: 3\n" /* woodstairs */, + "n: 50: 2\n" /* torch */ + "o: 35: 0\n" /* wool */ + "p: 17: 4\n" /* tree */ + "q: 17: 8\n" /* tree */ + "r: 53: 2\n" /* woodstairs */ + "s: 53: 7\n" /* woodstairs */ + "t: 53: 6\n" /* woodstairs */ + "u: 53: 3\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 012345678 */ - /* 0 */ "aaaaaaaaa" - /* 1 */ "aaaaaaaaa" - /* 2 */ "aaaaaaaaa" - /* 3 */ "aaaaaaaaa" - /* 4 */ "aaaaaaaaa" - /* 5 */ "aaaaaaaaa" - /* 6 */ "aaaaaaaaa" - /* 7 */ "aaaaaaaaa" - /* 8 */ "aaaaaaaaa" - /* 9 */ "aaaaaaaaa" - /* 10 */ "aaaaaaaaa" - /* 11 */ "aaaaaaaaa" - /* 12 */ "aaaaaaaaa" + /* 0 */ "mmmmmmmmm" + /* 1 */ "mmmmmmmmm" + /* 2 */ "mmmmmmmmm" + /* 3 */ "mmmmmmmmm" + /* 4 */ "maaaaammm" + /* 5 */ "maaaaaamm" + /* 6 */ "maaaaaamm" + /* 7 */ "maaaaaamm" + /* 8 */ "maaaaammm" + /* 9 */ "mmmmmmmmm" + /* 10 */ "mmmmmmmmm" + /* 11 */ "mmmmmmmmm" + /* 12 */ "mmmmmmmmm" // Level 1 /* z\x* 012345678 */ - /* 0 */ "bbbbbbbbb" - /* 1 */ "bbbbbbbbb" - /* 2 */ "bbbbbbbbb" - /* 3 */ "bbbbbbbbb" - /* 4 */ "baaaaabbb" - /* 5 */ "baaaaaabb" - /* 6 */ "baaaaaabb" - /* 7 */ "baaaaaabb" - /* 8 */ "baaaaabbb" - /* 9 */ "bbbbbbbbb" - /* 10 */ "bbbbbbbbb" - /* 11 */ "bbbbbbbbb" - /* 12 */ "bbbbbbbbb" + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." + /* 3 */ "........." + /* 4 */ ".aaaaa..." + /* 5 */ ".aaaaab.." + /* 6 */ ".aaaaac.." + /* 7 */ ".aaaaad.." + /* 8 */ ".aaaaa..." + /* 9 */ "........." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ "........." // Level 2 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.." - /* 1 */ "mmmmmmm.." - /* 2 */ "mmmmmmm.." + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." /* 3 */ "........." - /* 4 */ ".ccccc..." - /* 5 */ ".cccccd.." - /* 6 */ ".ccccce.." - /* 7 */ ".cccccf.." - /* 8 */ ".ccccc..." + /* 4 */ ".efffe..." + /* 5 */ ".f...f..." + /* 6 */ ".fgh.i..." + /* 7 */ ".f...f..." + /* 8 */ ".efffe..." /* 9 */ "........." - /* 10 */ "mmmmmmm.." - /* 11 */ "mmmmmmm.." - /* 12 */ "mmmmmmm.." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ "........." // Level 3 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.." - /* 1 */ "mmmmmmm.." - /* 2 */ "mmmmmmm.." + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." /* 3 */ "........." - /* 4 */ ".ghhhg..." - /* 5 */ ".h...h..." - /* 6 */ ".hij.k..." - /* 7 */ ".h...h..." - /* 8 */ ".ghhhg..." + /* 4 */ ".ejjje..." + /* 5 */ ".j...f..." + /* 6 */ ".j.k.l..." + /* 7 */ ".j...f..." + /* 8 */ ".ejjje..." /* 9 */ "........." - /* 10 */ "mmmmmmm.." - /* 11 */ "mmmmmmm.." - /* 12 */ "mmmmmmm.." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ "........." // Level 4 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.." - /* 1 */ "mmmmmmm.." - /* 2 */ "mmmmmmm.." + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." /* 3 */ "........." - /* 4 */ ".glllg..." - /* 5 */ ".l...h..." - /* 6 */ ".l.n.o..." - /* 7 */ ".l...h..." - /* 8 */ ".glllg..." + /* 4 */ ".efffe..." + /* 5 */ ".f..nf..." + /* 6 */ ".f.k.f..." + /* 7 */ ".f..nf..k" + /* 8 */ ".efffe..o" /* 9 */ "........." - /* 10 */ "mmmmmmm.." - /* 11 */ "mmmmmmm.." - /* 12 */ "mmmmmmm.." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ "........." // Level 5 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.." - /* 1 */ "mmmmmmm.." - /* 2 */ "mmmmmmm.." + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." /* 3 */ "........." - /* 4 */ ".ghhhg..." - /* 5 */ ".h..ph..." - /* 6 */ ".h.n.h..." - /* 7 */ ".h..ph..n" - /* 8 */ ".ghhhg..q" + /* 4 */ ".epppe..." + /* 5 */ ".q...q..." + /* 6 */ ".q.k.q..." + /* 7 */ ".q...q..k" + /* 8 */ ".epppe..o" /* 9 */ "........." - /* 10 */ "mmmmmmm.." - /* 11 */ "mmmmmmm.." - /* 12 */ "mmmmmmm.." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ "........." // Level 6 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.." - /* 1 */ "mmmmmmm.." - /* 2 */ "mmmmmmm.." + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." /* 3 */ "........." - /* 4 */ ".grrrg..." - /* 5 */ ".s...s..." - /* 6 */ ".s.n.s..." - /* 7 */ ".s...s..n" - /* 8 */ ".grrrg..q" + /* 4 */ ".efffe..." + /* 5 */ ".f...f..." + /* 6 */ ".f.k.f..k" + /* 7 */ ".f...f..o" + /* 8 */ ".efffe..o" /* 9 */ "........." - /* 10 */ "mmmmmmm.." - /* 11 */ "mmmmmmm.." - /* 12 */ "mmmmmmm.." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ "........." // Level 7 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.." - /* 1 */ "mmmmmmm.." - /* 2 */ "mmmmmmm.." + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." /* 3 */ "........." - /* 4 */ ".ghhhg..." - /* 5 */ ".h...h..." - /* 6 */ ".h.n.h..n" - /* 7 */ ".h...h..q" - /* 8 */ ".ghhhg..q" + /* 4 */ ".ejjje..." + /* 5 */ ".j...j..." + /* 6 */ ".j.k.j..k" + /* 7 */ ".j...j..o" + /* 8 */ ".ejjje..." /* 9 */ "........." - /* 10 */ "mmmmmmm.." - /* 11 */ "mmmmmmm.." - /* 12 */ "mmmmmmm.." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ "........." // Level 8 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.." - /* 1 */ "mmmmmmm.." - /* 2 */ "mmmmmmm.." + /* 0 */ "........o" + /* 1 */ "........o" + /* 2 */ "........o" /* 3 */ "........." - /* 4 */ ".glllg..." - /* 5 */ ".l...l..." - /* 6 */ ".l.n.l..n" - /* 7 */ ".l...l..q" - /* 8 */ ".glllg..." + /* 4 */ ".efffe..." + /* 5 */ ".f...f..k" + /* 6 */ ".f.k.f..o" + /* 7 */ ".f...f..o" + /* 8 */ ".efffe..." /* 9 */ "........." - /* 10 */ "mmmmmmm.." - /* 11 */ "mmmmmmm.." - /* 12 */ "mmmmmmm.." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ "........." // Level 9 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.q" - /* 1 */ "mmmmmmm.q" - /* 2 */ "mmmmmmm.q" - /* 3 */ "........." - /* 4 */ ".ghhhg..." - /* 5 */ ".h...h..n" - /* 6 */ ".h.n.h..q" - /* 7 */ ".h...h..q" - /* 8 */ ".ghhhg..." + /* 0 */ "........k" + /* 1 */ "........k" + /* 2 */ "........o" + /* 3 */ "........o" + /* 4 */ ".epppe..o" + /* 5 */ ".q...q..k" + /* 6 */ ".q.k.q..o" + /* 7 */ ".q...q..k" + /* 8 */ ".epppe..k" /* 9 */ "........." - /* 10 */ "mmmmmmm.." - /* 11 */ "mmmmmmm.." - /* 12 */ "mmmmmmm.." + /* 10 */ "........." + /* 11 */ "........." + /* 12 */ "........." // Level 10 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.n" - /* 1 */ "mmmmmmm.n" - /* 2 */ "mmmmmmm.q" - /* 3 */ "........q" - /* 4 */ ".grrrg..q" - /* 5 */ ".s...s..n" - /* 6 */ ".s.n.s..q" - /* 7 */ ".s...s..n" - /* 8 */ ".grrrg..n" - /* 9 */ "........." - /* 10 */ "mmmmmmm.." - /* 11 */ "mmmmmmm.." - /* 12 */ "mmmmmmm.." + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........k" + /* 3 */ "rrrrrrr.k" + /* 4 */ "sfffffs.o" + /* 5 */ ".f...f..o" + /* 6 */ ".f.kppppp" + /* 7 */ ".f...f..o" + /* 8 */ "tffffft.o" + /* 9 */ "uuuuuuu.k" + /* 10 */ "........k" + /* 11 */ "........." + /* 12 */ "........." // Level 11 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.." - /* 1 */ "mmmmmmm.." - /* 2 */ "mmmmmmm.n" - /* 3 */ "ttttttt.n" - /* 4 */ "uhhhhhu.q" - /* 5 */ ".h...h..q" - /* 6 */ ".h.nrrrrr" - /* 7 */ ".h...h..q" - /* 8 */ "vhhhhhv.q" - /* 9 */ "wwwwwww.n" - /* 10 */ "mmmmmmm.n" - /* 11 */ "mmmmmmm.." - /* 12 */ "mmmmmmm.." + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." + /* 3 */ "........." + /* 4 */ "rrrrrrr.k" + /* 5 */ "sfffffs.k" + /* 6 */ ".f...f..o" + /* 7 */ "tffffft.k" + /* 8 */ "uuuuuuu.o" + /* 9 */ "........o" + /* 10 */ "........o" + /* 11 */ "........k" + /* 12 */ "........k" // Level 12 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.." - /* 1 */ "mmmmmmm.." - /* 2 */ "mmmmmmm.." - /* 3 */ "mmmmmmm.." - /* 4 */ "ttttttt.n" - /* 5 */ "uhhhhhu.n" - /* 6 */ ".h...h..q" - /* 7 */ "vhhhhhv.n" - /* 8 */ "wwwwwww.q" - /* 9 */ "mmmmmmm.q" - /* 10 */ "mmmmmmm.q" - /* 11 */ "mmmmmmm.n" - /* 12 */ "mmmmmmm.n" + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "........." + /* 3 */ "........." + /* 4 */ "........." + /* 5 */ "rrrrrrr.o" + /* 6 */ "fffffff.o" + /* 7 */ "uuuuuuu.k" + /* 8 */ "........." + /* 9 */ "........." + /* 10 */ "........o" + /* 11 */ "........o" + /* 12 */ "........o" // Level 13 /* z\x* 012345678 */ - /* 0 */ "mmmmmmm.." - /* 1 */ "mmmmmmm.." - /* 2 */ "mmmmmmm.." - /* 3 */ "mmmmmmm.." - /* 4 */ "mmmmmmm.." - /* 5 */ "ttttttt.q" - /* 6 */ "hhhhhhh.q" - /* 7 */ "wwwwwww.n" - /* 8 */ "mmmmmmm.." - /* 9 */ "mmmmmmm.." - /* 10 */ "mmmmmmm.q" - /* 11 */ "mmmmmmm.q" - /* 12 */ "mmmmmmm.q" - - // Level 14 - /* z\x* 012345678 */ /* 0 */ "........." /* 1 */ "........." /* 2 */ "........." /* 3 */ "........." /* 4 */ "........." - /* 5 */ "........q" - /* 6 */ "........n" + /* 5 */ "........o" + /* 6 */ "........k" /* 7 */ "........." /* 8 */ "........." /* 9 */ "........." @@ -3713,15 +4213,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "........." /* 12 */ "........." - // Level 15 + // Level 14 /* z\x* 012345678 */ /* 0 */ "........." /* 1 */ "........." /* 2 */ "........." /* 3 */ "........." - /* 4 */ "........q" - /* 5 */ "........q" - /* 6 */ "........n" + /* 4 */ "........o" + /* 5 */ "........o" + /* 6 */ "........k" /* 7 */ "........." /* 8 */ "........." /* 9 */ "........." @@ -3729,14 +4229,14 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "........." /* 12 */ "........." - // Level 16 + // Level 15 /* z\x* 012345678 */ /* 0 */ "........." /* 1 */ "........." /* 2 */ "........." /* 3 */ "........." - /* 4 */ "........q" - /* 5 */ "........n" + /* 4 */ "........o" + /* 5 */ "........k" /* 6 */ "........." /* 7 */ "........." /* 8 */ "........." @@ -3745,14 +4245,14 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 11 */ "........." /* 12 */ "........." - // Level 17 + // Level 16 /* z\x* 012345678 */ /* 0 */ "........." /* 1 */ "........." /* 2 */ "........." /* 3 */ "........." - /* 4 */ "........q" - /* 5 */ "........n" + /* 4 */ "........o" + /* 5 */ "........k" /* 6 */ "........." /* 7 */ "........." /* 8 */ "........." @@ -3762,7 +4262,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 12 */ ".........", // Connectors: - "-1: 8, 2, 6: 5\n" /* Type -1, direction X+ */, + "-1: 8, 1, 6: 5\n" /* Type -1, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3781,6 +4281,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenMill5x5 @@ -3790,170 +4293,156 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 55, ID 106, created by Aloe_vera { // Size: - 15, 10, 9, // SizeX = 15, SizeY = 10, SizeZ = 9 + 15, 9, 9, // SizeX = 15, SizeY = 9, SizeZ = 9 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 15, 9, 9, // MaxX, MaxY, MaxZ + -1, -1, 0, // MinX, MinY, MinZ + 15, 8, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 4: 0\n" /* cobblestone */ - "g: 17: 0\n" /* tree */ - "h:107: 0\n" /* fencegate */ - "i:107: 4\n" /* fencegate */ - "j: 5: 0\n" /* wood */ - "k:107: 6\n" /* fencegate */ - "l: 85: 0\n" /* fence */ + "a: 4: 0\n" /* cobblestone */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 3: 0\n" /* dirt */ + "f: 17: 0\n" /* tree */ + "g:107: 0\n" /* fencegate */ + "h:107: 4\n" /* fencegate */ + "i: 5: 0\n" /* wood */ + "j:107: 6\n" /* fencegate */ + "k: 85: 0\n" /* fence */ + "l:170: 0\n" /* haybale */ "m: 19: 0\n" /* sponge */ - "n:170: 0\n" /* haybale */ - "o:170: 4\n" /* haybale */ - "p:170: 8\n" /* haybale */ - "q: 50: 1\n" /* torch */ - "r: 50: 2\n" /* torch */ - "s: 53: 2\n" /* woodstairs */ - "t: 53: 7\n" /* woodstairs */ - "u: 53: 6\n" /* woodstairs */ - "v: 53: 3\n" /* woodstairs */, + "n:170: 4\n" /* haybale */ + "o:170: 8\n" /* haybale */ + "p: 50: 1\n" /* torch */ + "q: 50: 2\n" /* torch */ + "r: 53: 2\n" /* woodstairs */ + "s: 53: 7\n" /* woodstairs */ + "t: 53: 6\n" /* woodstairs */ + "u: 53: 3\n" /* woodstairs */, // Block data: // Level 0 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "aaaaaaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaaaaaa" - /* 2 */ "aaaaaaaaaaaaaaa" - /* 3 */ "aaaaaaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaaaaaa" - /* 5 */ "aaaaaaaaaaaaaaa" - /* 6 */ "aaaaaaaaaaaaaaa" - /* 7 */ "aaaaaaaaaaaaaaa" - /* 8 */ "aaaaaaaaaaaaaaa" + /* 0 */ "maaaaaaaaaaaaam" + /* 1 */ "maaaaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaaaam" + /* 6 */ "maaaaaaaaaaaaam" + /* 7 */ "maaaaaaaaaaaaam" + /* 8 */ "mmmmmmmmmmmmmmm" // Level 1 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "baaaaaaaaaaaaab" - /* 1 */ "baaaaaaaaaaaaab" - /* 2 */ "baaaaaaaaaaaaab" - /* 3 */ "baaaaaaaaaaaaab" - /* 4 */ "baaaaaaaaaaaaab" - /* 5 */ "baaaaaaaaaaaaab" - /* 6 */ "baaaaaaaaaaaaab" - /* 7 */ "baaaaaaaaaaaaab" - /* 8 */ "bbbbbbbbbbbbbbb" - - // Level 2 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ ".cddddddddddde." - /* 1 */ ".fffffffffffff." - /* 2 */ ".faaaaaaaaaaaf." - /* 3 */ ".faaaaaaaaaaaf." - /* 4 */ ".faaaaaaaaaaaf." - /* 5 */ ".faaaaaaaaaaaf." - /* 6 */ ".faaaaaaaaaaaf." - /* 7 */ ".fffffffffffff." + /* 0 */ ".bcccccccccccd." + /* 1 */ ".aaaaaaaaaaaaa." + /* 2 */ ".aeeeeeeeeeeea." + /* 3 */ ".aeeeeeeeeeeea." + /* 4 */ ".aeeeeeeeeeeea." + /* 5 */ ".aeeeeeeeeeeea." + /* 6 */ ".aeeeeeeeeeeea." + /* 7 */ ".aaaaaaaaaaaaa." /* 8 */ "..............." - // Level 3 + // Level 2 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".ghihjhihjhkhg." - /* 2 */ ".l...l...l...l." - /* 3 */ ".l...l...l...l." - /* 4 */ ".l...l...l...l." - /* 5 */ ".l...l...l...l." - /* 6 */ ".ln..l..olp..l." - /* 7 */ ".gllljllljlllg." + /* 1 */ ".fghgighgigjgf." + /* 2 */ ".k...k...k...k." + /* 3 */ ".k...k...k...k." + /* 4 */ ".k...k...k...k." + /* 5 */ ".k...k...k...k." + /* 6 */ ".kl..k..nko..k." + /* 7 */ ".fkkkikkkikkkf." /* 8 */ "..............." - // Level 4 + // Level 3 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".g...j...j...g." + /* 1 */ ".f...i...i...f." /* 2 */ "..............." /* 3 */ "..............." /* 4 */ "..............." /* 5 */ "..............." /* 6 */ "..............." - /* 7 */ ".g...j...j...g." + /* 7 */ ".f...i...i...f." /* 8 */ "..............." - // Level 5 + // Level 4 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".gq.rjq.rjq.rg." + /* 1 */ ".fp.qip.qip.qf." /* 2 */ "..............." /* 3 */ "..............." /* 4 */ "..............." /* 5 */ "..............." /* 6 */ "..............." - /* 7 */ ".g...j...j...g." + /* 7 */ ".f...i...i...f." /* 8 */ "..............." - // Level 6 + // Level 5 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "sssssssssssssss" - /* 1 */ "tjjjjjjjjjjjjjt" - /* 2 */ ".j...........j." - /* 3 */ ".j...........j." - /* 4 */ ".j...........j." - /* 5 */ ".j...........j." - /* 6 */ ".j...........j." - /* 7 */ "ujjjjjjjjjjjjju" - /* 8 */ "vvvvvvvvvvvvvvv" + /* 0 */ "rrrrrrrrrrrrrrr" + /* 1 */ "siiiiiiiiiiiiis" + /* 2 */ ".i...........i." + /* 3 */ ".i...........i." + /* 4 */ ".i...........i." + /* 5 */ ".i...........i." + /* 6 */ ".i...........i." + /* 7 */ "tiiiiiiiiiiiiit" + /* 8 */ "uuuuuuuuuuuuuuu" - // Level 7 + // Level 6 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ "sssssssssssssss" - /* 2 */ "tjjjjjjjjjjjjjt" - /* 3 */ ".j...........j." - /* 4 */ ".j...........j." - /* 5 */ ".j...........j." - /* 6 */ "ujjjjjjjjjjjjju" - /* 7 */ "vvvvvvvvvvvvvvv" + /* 1 */ "rrrrrrrrrrrrrrr" + /* 2 */ "siiiiiiiiiiiiis" + /* 3 */ ".i...........i." + /* 4 */ ".i...........i." + /* 5 */ ".i...........i." + /* 6 */ "tiiiiiiiiiiiiit" + /* 7 */ "uuuuuuuuuuuuuuu" /* 8 */ "..............." - // Level 8 + // Level 7 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ "sssssssssssssss" - /* 3 */ "tjjjjjjjjjjjjjt" - /* 4 */ ".j...........j." - /* 5 */ "ujjjjjjjjjjjjju" - /* 6 */ "vvvvvvvvvvvvvvv" + /* 2 */ "rrrrrrrrrrrrrrr" + /* 3 */ "siiiiiiiiiiiiis" + /* 4 */ ".i...........i." + /* 5 */ "tiiiiiiiiiiiiit" + /* 6 */ "uuuuuuuuuuuuuuu" /* 7 */ "..............." /* 8 */ "..............." - // Level 9 + // Level 8 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." /* 2 */ "..............." - /* 3 */ "sssssssssssssss" - /* 4 */ "jjjjjjjjjjjjjjj" - /* 5 */ "vvvvvvvvvvvvvvv" + /* 3 */ "rrrrrrrrrrrrrrr" + /* 4 */ "iiiiiiiiiiiiiii" + /* 5 */ "uuuuuuuuuuuuuuu" /* 6 */ "..............." /* 7 */ "..............." /* 8 */ "...............", // Connectors: - "-1: 7, 2, -1: 2\n" /* Type -1, direction Z- */, + "-1: 7, 1, -1: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3972,6 +4461,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // WoodenStables }; // g_PlainsVillagePrefabs @@ -4109,17 +4601,467 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = true, // DefaultWeight: - 100, + 0, // DepthWeight: "", // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // CobbleWell4x4 + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MineEntrance: + // The data has been exported from the gallery Plains, area index 138, ID 446, created by STR_Warrior + { + // Size: + 7, 38, 7, // SizeX = 7, SizeY = 38, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 37, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "b: 77: 2\n" /* stonebutton */ + "c: 66: 6\n" /* tracks */ + "d: 27: 1\n" /* poweredrail */ + "e: 66: 5\n" /* tracks */ + "f: 66: 9\n" /* tracks */ + "g: 66: 2\n" /* tracks */ + "h: 50: 4\n" /* torch */ + "i: 66: 4\n" /* tracks */ + "j: 66: 8\n" /* tracks */ + "k: 66: 3\n" /* tracks */ + "l: 66: 7\n" /* tracks */ + "m: 19: 0\n" /* sponge */ + "n: 50: 2\n" /* torch */ + "o: 2: 0\n" /* grass */ + "p: 53: 2\n" /* woodstairs */ + "q: 77: 1\n" /* stonebutton */ + "r: 27: 0\n" /* poweredrail */ + "s: 53: 7\n" /* woodstairs */ + "t: 53: 6\n" /* woodstairs */ + "u: 53: 3\n" /* woodstairs */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "maaaaam" + /* 1 */ "maaaaam" + /* 2 */ "maaaaam" + /* 3 */ "maaaaam" + /* 4 */ "maaaaam" + /* 5 */ "maaaaam" + /* 6 */ "mmmmmmm" + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "mm...mm" + /* 1 */ "mm.abam" + /* 2 */ "mmcddam" + /* 3 */ "mae..am" + /* 4 */ "mmaa.mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "mm...mm" + /* 1 */ "mm.a.mm" + /* 2 */ "mm...mm" + /* 3 */ "ma..aam" + /* 4 */ "mmfgamm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "mm.h.mm" + /* 1 */ "mm.a.mm" + /* 2 */ "mm.aamm" + /* 3 */ "ma..iam" + /* 4 */ "mm..jmm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmaklmm" + /* 3 */ "maa..am" + /* 4 */ "mm...mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmc..mm" + /* 3 */ "mae.nam" + /* 4 */ "mmaa.mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 6 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mm...mm" + /* 3 */ "ma..aam" + /* 4 */ "mmfgamm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 7 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mm.aamm" + /* 3 */ "ma..iam" + /* 4 */ "mm..jmm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 8 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmaklmm" + /* 3 */ "maa..am" + /* 4 */ "mm...mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 9 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmc..mm" + /* 3 */ "mae.nam" + /* 4 */ "mmaa.mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 10 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mm...mm" + /* 3 */ "ma..aam" + /* 4 */ "mmfgamm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 11 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mm.aamm" + /* 3 */ "ma..iam" + /* 4 */ "mm..jmm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 12 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmaklmm" + /* 3 */ "maa..am" + /* 4 */ "mm...mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 13 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmc..mm" + /* 3 */ "mae.nam" + /* 4 */ "mmaa.mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 14 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mm...mm" + /* 3 */ "ma..aam" + /* 4 */ "mmfgamm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 15 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mm.aamm" + /* 3 */ "ma..iam" + /* 4 */ "mm..jmm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 16 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmaklmm" + /* 3 */ "maa..am" + /* 4 */ "mm...mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 17 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmc..mm" + /* 3 */ "mae.nam" + /* 4 */ "mmaa.mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 18 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mm...mm" + /* 3 */ "ma..aam" + /* 4 */ "mmfgamm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 19 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mm.aamm" + /* 3 */ "ma..iam" + /* 4 */ "mm..jmm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 20 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmaklmm" + /* 3 */ "maa..am" + /* 4 */ "mm...mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 21 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmc..mm" + /* 3 */ "mae.nam" + /* 4 */ "mmaa.mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 22 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mm...mm" + /* 3 */ "ma..aam" + /* 4 */ "mmfgamm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 23 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mm.aamm" + /* 3 */ "ma..iam" + /* 4 */ "mm..jmm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 24 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmaklmm" + /* 3 */ "maa..am" + /* 4 */ "mm...mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 25 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmc..mm" + /* 3 */ "mae.nam" + /* 4 */ "mmaa.mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 26 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mm...mm" + /* 3 */ "ma..aam" + /* 4 */ "mmfgamm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 27 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mm.aamm" + /* 3 */ "ma..iam" + /* 4 */ "mm..jmm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 28 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmaklmm" + /* 3 */ "maa..am" + /* 4 */ "mm...mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 29 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mmc..mm" + /* 3 */ "mae.nam" + /* 4 */ "mmaa.mm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 30 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmammm" + /* 2 */ "mm...mm" + /* 3 */ "ma..aam" + /* 4 */ "mmfgamm" + /* 5 */ "mmmammm" + /* 6 */ "mmmmmmm" + + // Level 31 + /* z\x* 0123456 */ + /* 0 */ "ooomooo" + /* 1 */ "oaaaaao" + /* 2 */ "oa.aaao" + /* 3 */ "oa..iao" + /* 4 */ "oa..jao" + /* 5 */ "oaaaaao" + /* 6 */ "ooooooo" + + // Level 32 + /* z\x* 0123456 */ + /* 0 */ "...p..." + /* 1 */ ".aqrba." + /* 2 */ "...fl.." + /* 3 */ "......." + /* 4 */ "......." + /* 5 */ ".a...a." + /* 6 */ "......." + + // Level 33 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".a...a." + /* 2 */ "......." + /* 3 */ "......." + /* 4 */ "......." + /* 5 */ ".a...a." + /* 6 */ "......." + + // Level 34 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".a...a." + /* 2 */ "......." + /* 3 */ "......." + /* 4 */ "......." + /* 5 */ ".a...a." + /* 6 */ "......." + + // Level 35 + /* z\x* 0123456 */ + /* 0 */ "ppppppp" + /* 1 */ "saaaaas" + /* 2 */ ".a...a." + /* 3 */ ".a...a." + /* 4 */ ".a...a." + /* 5 */ "taaaaat" + /* 6 */ "uuuuuuu" + + // Level 36 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "ppppppp" + /* 2 */ "saaaaas" + /* 3 */ ".aaaaa." + /* 4 */ "taaaaat" + /* 5 */ "uuuuuuu" + /* 6 */ "......." + + // Level 37 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "......." + /* 2 */ "ppppppp" + /* 3 */ "aaaaaaa" + /* 4 */ "uuuuuuu" + /* 5 */ "......." + /* 6 */ ".......", + + // Connectors: + "2: 6, 32, 3: 5\n" /* Type 2, direction X+ */ + "2: 3, 32, 6: 3\n" /* Type 2, direction Z+ */ + "2: 0, 32, 3: 4\n" /* Type 2, direction X- */ + "2: 3, 32, 0: 2\n" /* Type 2, direction Z- */ + "3: 3, 1, 0: 2\n" /* Type 3, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 1000, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // MineEntrance + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // RoofedWell: // The data has been exported from the gallery Plains, area index 119, ID 271, created by STR_Warrior @@ -4317,13 +5259,16 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = true, // DefaultWeight: - 100, + 0, // DepthWeight: "", // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // RoofedWell }; diff --git a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp index 93aa405c2..4f0efdcc6 100644 --- a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp +++ b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp @@ -141,6 +141,9 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // Forge @@ -264,6 +267,9 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House11x7 @@ -363,6 +369,9 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House5x4 @@ -468,6 +477,9 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House5x5 @@ -573,6 +585,9 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House7x5 @@ -683,6 +698,9 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House8x5 @@ -805,6 +823,9 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House8x7 @@ -928,6 +949,9 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House9x7 @@ -1078,6 +1102,9 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // HouseL13x12 @@ -1087,75 +1114,86 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 34, ID 175, created by Aloe_vera { // Size: - 7, 5, 7, // SizeX = 7, SizeY = 5, SizeZ = 7 + 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 6, 4, 6, // MaxX, MaxY, MaxZ + 6, 5, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 85: 0\n" /* fence */ - "b:171:14\n" /* carpet */ - "c:171:15\n" /* carpet */ - "d:171: 0\n" /* carpet */ - "e: 35:14\n" /* wool */ - "f: 35: 0\n" /* wool */ + "a: 12: 0\n" /* sand */ + "b: 85: 0\n" /* fence */ + "c:171:14\n" /* carpet */ + "d:171:15\n" /* carpet */ + "e:171: 0\n" /* carpet */ + "f: 35:14\n" /* wool */ + "g: 35: 0\n" /* wool */ "m: 19: 0\n" /* sponge */, // Block data: // Level 0 /* z\x* 0123456 */ - /* 0 */ "a.....a" - /* 1 */ "bccdccb" - /* 2 */ "bcdddcb" - /* 3 */ "bcdddcb" - /* 4 */ "bccdccb" - /* 5 */ "a.....a" - /* 6 */ "......." + /* 0 */ "aaaaaaa" + /* 1 */ "aaaaaaa" + /* 2 */ "aaaaaaa" + /* 3 */ "aaaaaaa" + /* 4 */ "aaaaaaa" + /* 5 */ "aaaaaaa" + /* 6 */ "aaaaaaa" // Level 1 /* z\x* 0123456 */ - /* 0 */ "a.....a" + /* 0 */ "b.....b" + /* 1 */ "cddeddc" + /* 2 */ "cdeeedc" + /* 3 */ "cdeeedc" + /* 4 */ "cddeddc" + /* 5 */ "b.....b" + /* 6 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "b.....b" /* 1 */ "......." /* 2 */ "......." /* 3 */ "......." /* 4 */ "......." - /* 5 */ "a.....a" + /* 5 */ "b.....b" /* 6 */ "......." - // Level 2 + // Level 3 /* z\x* 0123456 */ - /* 0 */ "a.....a" + /* 0 */ "b.....b" /* 1 */ "......." /* 2 */ "......." /* 3 */ "......." /* 4 */ "......." - /* 5 */ "a.....a" - /* 6 */ "efefefe" + /* 5 */ "b.....b" + /* 6 */ "fgfgfgf" - // Level 3 + // Level 4 /* z\x* 0123456 */ - /* 0 */ "efefefe" + /* 0 */ "fgfgfgf" /* 1 */ "......." /* 2 */ "......." /* 3 */ "......." /* 4 */ "......." - /* 5 */ "efefefe" + /* 5 */ "fgfgfgf" /* 6 */ "......." - // Level 4 + // Level 5 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ "efefefe" - /* 2 */ "efefefe" - /* 3 */ "efefefe" - /* 4 */ "efefefe" + /* 1 */ "fgfgfgf" + /* 2 */ "fgfgfgf" + /* 3 */ "fgfgfgf" + /* 4 */ "fgfgfgf" /* 5 */ "......." /* 6 */ ".......", // Connectors: - "-1: 2, -1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 2, 0, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1167,13 +1205,16 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = true, // DefaultWeight: - 100, + 5, // DepthWeight: "", // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // MarketStall @@ -1300,13 +1341,16 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = true, // DefaultWeight: - 100, + 20, // DepthWeight: "", // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // Marketplace }; // g_SandFlatRoofVillagePrefabs @@ -1496,6 +1540,9 @@ const cPrefab::sDef g_SandFlatRoofVillageStartingPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // Well }; diff --git a/src/Generating/Prefabs/SandVillagePrefabs.cpp b/src/Generating/Prefabs/SandVillagePrefabs.cpp index 539f57b9d..a062f8cd4 100644 --- a/src/Generating/Prefabs/SandVillagePrefabs.cpp +++ b/src/Generating/Prefabs/SandVillagePrefabs.cpp @@ -82,6 +82,9 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // DoubleField @@ -202,6 +205,9 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House11x7 @@ -345,6 +351,9 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House11x9 @@ -463,6 +472,9 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House13x7 @@ -606,6 +618,9 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House13x9 @@ -749,6 +764,9 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House15x9 @@ -892,6 +910,9 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House16x9 @@ -1003,6 +1024,9 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House7x7 @@ -1115,6 +1139,9 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // House9x7 @@ -1251,159 +1278,10 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // AddWeightIfSame: 0, - }, // House9x9 - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // HouseL14x12: - // The data has been exported from the gallery Desert, area index 7, ID 82, created by Aloe_vera - { - // Size: - 14, 6, 12, // SizeX = 14, SizeY = 6, SizeZ = 12 - - // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 13, 5, 11, // MaxX, MaxY, MaxZ - - // Block definitions: - ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ - "e:128: 3\n" /* sandstonestairs */ - "f: 64: 7\n" /* wooddoorblock */ - "g: 64: 5\n" /* wooddoorblock */ - "h:102: 0\n" /* glasspane */ - "i: 64:12\n" /* wooddoorblock */ - "j:128: 7\n" /* sandstonestairs */ - "k: 50: 3\n" /* torch */ - "l: 50: 4\n" /* torch */ - "m: 19: 0\n" /* sponge */ - "n:128: 6\n" /* sandstonestairs */ - "o:128: 5\n" /* sandstonestairs */ - "p:128: 4\n" /* sandstonestairs */ - "q: 50: 1\n" /* torch */, - - // Block data: - // Level 0 - /* z\x* 1111 */ - /* * 01234567890123 */ - /* 0 */ ".......abc...." - /* 1 */ ".dddddddddddd." - /* 2 */ ".dddddddddddd." - /* 3 */ ".dddddddddddd." - /* 4 */ ".dddddddddddd." - /* 5 */ ".dddddddddddd." - /* 6 */ "....aec.ddddd." - /* 7 */ "mmmmmmm.ddddd." - /* 8 */ "mmmmmmm.ddddd." - /* 9 */ "mmmmmmm.ddddd." - /* 10 */ "mmmmmmm.ddddd." - /* 11 */ "mmmmmmm......." - - // Level 1 - /* z\x* 1111 */ - /* * 01234567890123 */ - /* 0 */ ".............." - /* 1 */ ".dddddddfdddd." - /* 2 */ ".d..........d." - /* 3 */ ".d..........d." - /* 4 */ ".d..........d." - /* 5 */ ".ddddgddd...d." - /* 6 */ "........d...d." - /* 7 */ "mmmmmmm.d...d." - /* 8 */ "mmmmmmm.d...d." - /* 9 */ "mmmmmmm.d...d." - /* 10 */ "mmmmmmm.ddddd." - /* 11 */ "mmmmmmm......." - - // Level 2 - /* z\x* 1111 */ - /* * 01234567890123 */ - /* 0 */ ".............." - /* 1 */ ".dhhdhhdidhhd." - /* 2 */ ".h..........h." - /* 3 */ ".h..........h." - /* 4 */ ".h..........d." - /* 5 */ ".dhhdidhh...h." - /* 6 */ "........h...h." - /* 7 */ "mmmmmmm.d...d." - /* 8 */ "mmmmmmm.h...h." - /* 9 */ "mmmmmmm.h...h." - /* 10 */ "mmmmmmm.dhhhd." - /* 11 */ "mmmmmmm......." - - // Level 3 - /* z\x* 1111 */ - /* * 01234567890123 */ - /* 0 */ "bbbbbbbbbbbbbb" - /* 1 */ "jddddddddddddc" - /* 2 */ ".d.....k.k..dc" - /* 3 */ ".d..........dc" - /* 4 */ ".d..l.l.....dc" - /* 5 */ "ndddddddd...dc" - /* 6 */ "eeeeeeead...dc" - /* 7 */ "mmmmmmmad...dc" - /* 8 */ "mmmmmmmad...dc" - /* 9 */ "mmmmmmmad...dc" - /* 10 */ "mmmmmmmadddddc" - /* 11 */ "mmmmmmmao...pc" - - // Level 4 - /* z\x* 1111 */ - /* * 01234567890123 */ - /* 0 */ ".............." - /* 1 */ "bbbbbbbbbbbbb." - /* 2 */ "jdddddddddddc." - /* 3 */ ".dq........dc." - /* 4 */ "nddddddddd.dc." - /* 5 */ "eeeeeeeead.dc." - /* 6 */ "........ad.dc." - /* 7 */ "mmmmmmm.ad.dc." - /* 8 */ "mmmmmmm.ad.dc." - /* 9 */ "mmmmmmm.adldc." - /* 10 */ "mmmmmmm.adddc." - /* 11 */ "mmmmmmm.ao.pc." - - // Level 5 - /* z\x* 1111 */ - /* * 01234567890123 */ - /* 0 */ ".............." - /* 1 */ ".............." - /* 2 */ "bbbbbbbbbbbb.." - /* 3 */ "dddddddddddc.." - /* 4 */ "eeeeeeeeeadc.." - /* 5 */ ".........adc.." - /* 6 */ ".........adc.." - /* 7 */ "mmmmmmm..adc.." - /* 8 */ "mmmmmmm..adc.." - /* 9 */ "mmmmmmm..adc.." - /* 10 */ "mmmmmmm..adc.." - /* 11 */ "mmmmmmm..adc..", - - // Connectors: - "-1: 8, 0, 0: 2\n" /* Type -1, direction Z- */, - - // AllowedRotations: - 7, /* 1, 2, 3 CCW rotation allowed */ - // Merge strategy: - cBlockArea::msSpongePrint, - - // ShouldExtendFloor: + // MoveToGround: true, - - // DefaultWeight: - 100, - - // DepthWeight: - "", - - // AddWeightIfSame: - 0, - }, // HouseL14x12 + }, // House9x9 @@ -1571,6 +1449,164 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, + }, // HouseL14x12 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // HouseL14x12: + // The data has been exported from the gallery Desert, area index 7, ID 82, created by Aloe_vera + { + // Size: + 14, 6, 12, // SizeX = 14, SizeY = 6, SizeZ = 12 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 13, 5, 11, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:128: 0\n" /* sandstonestairs */ + "b:128: 2\n" /* sandstonestairs */ + "c:128: 1\n" /* sandstonestairs */ + "d: 24: 0\n" /* sandstone */ + "e:128: 3\n" /* sandstonestairs */ + "f: 64: 7\n" /* wooddoorblock */ + "g: 64: 5\n" /* wooddoorblock */ + "h:102: 0\n" /* glasspane */ + "i: 64:12\n" /* wooddoorblock */ + "j:128: 7\n" /* sandstonestairs */ + "k: 50: 3\n" /* torch */ + "l: 50: 4\n" /* torch */ + "m: 19: 0\n" /* sponge */ + "n:128: 6\n" /* sandstonestairs */ + "o:128: 5\n" /* sandstonestairs */ + "p:128: 4\n" /* sandstonestairs */ + "q: 50: 1\n" /* torch */, + + // Block data: + // Level 0 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".......abc...." + /* 1 */ ".dddddddddddd." + /* 2 */ ".dddddddddddd." + /* 3 */ ".dddddddddddd." + /* 4 */ ".dddddddddddd." + /* 5 */ ".dddddddddddd." + /* 6 */ "....aec.ddddd." + /* 7 */ "mmmmmmm.ddddd." + /* 8 */ "mmmmmmm.ddddd." + /* 9 */ "mmmmmmm.ddddd." + /* 10 */ "mmmmmmm.ddddd." + /* 11 */ "mmmmmmm......." + + // Level 1 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".dddddddfdddd." + /* 2 */ ".d..........d." + /* 3 */ ".d..........d." + /* 4 */ ".d..........d." + /* 5 */ ".ddddgddd...d." + /* 6 */ "........d...d." + /* 7 */ "mmmmmmm.d...d." + /* 8 */ "mmmmmmm.d...d." + /* 9 */ "mmmmmmm.d...d." + /* 10 */ "mmmmmmm.ddddd." + /* 11 */ "mmmmmmm......." + + // Level 2 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".dhhdhhdidhhd." + /* 2 */ ".h..........h." + /* 3 */ ".h..........h." + /* 4 */ ".h..........d." + /* 5 */ ".dhhdidhh...h." + /* 6 */ "........h...h." + /* 7 */ "mmmmmmm.d...d." + /* 8 */ "mmmmmmm.h...h." + /* 9 */ "mmmmmmm.h...h." + /* 10 */ "mmmmmmm.dhhhd." + /* 11 */ "mmmmmmm......." + + // Level 3 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "bbbbbbbbbbbbbb" + /* 1 */ "jddddddddddddc" + /* 2 */ ".d.....k.k..dc" + /* 3 */ ".d..........dc" + /* 4 */ ".d..l.l.....dc" + /* 5 */ "ndddddddd...dc" + /* 6 */ "eeeeeeead...dc" + /* 7 */ "mmmmmmmad...dc" + /* 8 */ "mmmmmmmad...dc" + /* 9 */ "mmmmmmmad...dc" + /* 10 */ "mmmmmmmadddddc" + /* 11 */ "mmmmmmmao...pc" + + // Level 4 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ "bbbbbbbbbbbbb." + /* 2 */ "jdddddddddddc." + /* 3 */ ".dq........dc." + /* 4 */ "nddddddddd.dc." + /* 5 */ "eeeeeeeead.dc." + /* 6 */ "........ad.dc." + /* 7 */ "mmmmmmm.ad.dc." + /* 8 */ "mmmmmmm.ad.dc." + /* 9 */ "mmmmmmm.adldc." + /* 10 */ "mmmmmmm.adddc." + /* 11 */ "mmmmmmm.ao.pc." + + // Level 5 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".............." + /* 2 */ "bbbbbbbbbbbb.." + /* 3 */ "dddddddddddc.." + /* 4 */ "eeeeeeeeeadc.." + /* 5 */ ".........adc.." + /* 6 */ ".........adc.." + /* 7 */ "mmmmmmm..adc.." + /* 8 */ "mmmmmmm..adc.." + /* 9 */ "mmmmmmm..adc.." + /* 10 */ "mmmmmmm..adc.." + /* 11 */ "mmmmmmm..adc..", + + // Connectors: + "-1: 8, 0, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, }, // HouseL14x12 @@ -1638,6 +1674,9 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // SingleField @@ -1731,6 +1770,9 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // SmallHut }; // g_SandVillagePrefabs @@ -1741,6 +1783,204 @@ const cPrefab::sDef g_SandVillagePrefabs[] = const cPrefab::sDef g_SandVillageStartingPrefabs[] = { + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // RoofedWell: + // The data has been exported from the gallery Desert, area index 43, ID 274, created by Aloe_vera + { + // Size: + 7, 14, 7, // SizeX = 7, SizeY = 14, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 13, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 1: 0\n" /* stone */ + "b: 24: 0\n" /* sandstone */ + "c: 8: 0\n" /* water */ + "d: 12: 0\n" /* sand */ + "e:118: 3\n" /* cauldronblock */ + "f: 85: 0\n" /* fence */ + "g:128: 2\n" /* sandstonestairs */ + "h:128: 7\n" /* sandstonestairs */ + "i:128: 4\n" /* sandstonestairs */ + "j:128: 5\n" /* sandstonestairs */ + "k:128: 6\n" /* sandstonestairs */ + "l:128: 3\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "aaaaaaa" + /* 2 */ "aaaaaaa" + /* 3 */ "aaaaaaa" + /* 4 */ "aaaaaaa" + /* 5 */ "aaaaaaa" + /* 6 */ "aaaaaaa" + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "abbbbba" + /* 2 */ "abcccba" + /* 3 */ "abcccba" + /* 4 */ "abcccba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "ddddddd" + /* 1 */ "dbbbbbd" + /* 2 */ "dbcccbd" + /* 3 */ "dbcccbd" + /* 4 */ "dbcccbd" + /* 5 */ "dbbbbbd" + /* 6 */ "ddddddd" + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "ddddddd" + /* 1 */ "dbbbbbd" + /* 2 */ "dbcccbd" + /* 3 */ "dbcccbd" + /* 4 */ "dbcccbd" + /* 5 */ "dbbbbbd" + /* 6 */ "ddddddd" + + // Level 6 + /* z\x* 0123456 */ + /* 0 */ "ddddddd" + /* 1 */ "dbbbbbd" + /* 2 */ "dbcccbd" + /* 3 */ "dbcccbd" + /* 4 */ "dbcccbd" + /* 5 */ "dbbbbbd" + /* 6 */ "ddddddd" + + // Level 7 + /* z\x* 0123456 */ + /* 0 */ "ddbbbdd" + /* 1 */ "dbbbbbd" + /* 2 */ "bbcccbb" + /* 3 */ "bbcccbb" + /* 4 */ "bbcccbb" + /* 5 */ "dbbbbbd" + /* 6 */ "ddbbbdd" + + // Level 8 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".bbbbb." + /* 2 */ ".b...b." + /* 3 */ ".b.e.b." + /* 4 */ ".b...b." + /* 5 */ ".bbbbb." + /* 6 */ "......." + + // Level 9 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".f...f." + /* 2 */ "......." + /* 3 */ "...f..." + /* 4 */ "......." + /* 5 */ ".f...f." + /* 6 */ "......." + + // Level 10 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".f...f." + /* 2 */ "......." + /* 3 */ "...f..." + /* 4 */ "......." + /* 5 */ ".f...f." + /* 6 */ "......." + + // Level 11 + /* z\x* 0123456 */ + /* 0 */ "ggggggg" + /* 1 */ "hbhhhbh" + /* 2 */ ".i...j." + /* 3 */ ".i.f.j." + /* 4 */ ".i...j." + /* 5 */ "kbkkkbk" + /* 6 */ "lllllll" + + // Level 12 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "ggggggg" + /* 2 */ "hb...bh" + /* 3 */ ".b.f.b." + /* 4 */ "kb...bk" + /* 5 */ "lllllll" + /* 6 */ "......." + + // Level 13 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "......." + /* 2 */ "ggggggg" + /* 3 */ "bbbbbbb" + /* 4 */ "lllllll" + /* 5 */ "......." + /* 6 */ ".......", + + // Connectors: + "2: 6, 8, 3: 5\n" /* Type 2, direction X+ */ + "2: 3, 8, 6: 3\n" /* Type 2, direction Z+ */ + "2: 0, 8, 3: 4\n" /* Type 2, direction X- */ + "2: 3, 8, 0: 2\n" /* Type 2, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // RoofedWell + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Well: // The data has been exported from the gallery Desert, area index 0, ID 1, created by Aloe_vera @@ -1875,6 +2115,9 @@ const cPrefab::sDef g_SandVillageStartingPrefabs[] = // AddWeightIfSame: 0, + + // MoveToGround: + true, }, // Well }; diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index 62822c33b..cb1f4fe0d 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -127,10 +127,23 @@ public: m_HeightGen(a_HeightGen), m_RoadBlock(a_RoadBlock) { + // Generate the pieces for this village; don't care about the Y coord: cBFSPieceGenerator pg(*this, a_Seed); - // Generate the pieces at very negative Y coords, so that we can later test - // Piece has negative Y coord -> hasn't been height-adjusted yet - pg.PlacePieces(a_OriginX, -1000, a_OriginZ, a_MaxRoadDepth + 1, m_Pieces); + pg.PlacePieces(a_OriginX, 0, a_OriginZ, a_MaxRoadDepth + 1, m_Pieces); + if (m_Pieces.empty()) + { + return; + } + + // If the central piece should be moved to ground, move it, and + // check all of its dependents and move those that are strictly connector-driven based on its new Y coord: + if (((cPrefab &)m_Pieces[0]->GetPiece()).ShouldMoveToGround()) + { + int OrigPosY = m_Pieces[0]->GetCoords().y; + PlacePieceOnGround(*m_Pieces[0]); + int NewPosY = m_Pieces[0]->GetCoords().y; + MoveAllDescendants(m_Pieces, 0, NewPosY - OrigPosY); + } } protected: @@ -179,7 +192,7 @@ protected: DrawRoad(a_Chunk, **itr, HeightMap); continue; } - if ((*itr)->GetCoords().y < 0) + if (Prefab.ShouldMoveToGround() && !(*itr)->HasBeenMovedToGround()) { PlacePieceOnGround(**itr); } @@ -201,7 +214,7 @@ protected: cChunkDef::HeightMap HeightMap; m_HeightGen.GenHeightMap(ChunkX, ChunkZ, HeightMap); int TerrainHeight = cChunkDef::GetHeight(HeightMap, BlockX, BlockZ); - a_Piece.GetCoords().y += TerrainHeight - FirstConnector.m_Pos.y + 1; + a_Piece.MoveToGroundBy(TerrainHeight - FirstConnector.m_Pos.y + 1); } @@ -232,11 +245,13 @@ protected: return m_Prefabs.GetPiecesWithConnector(a_ConnectorType); } + virtual cPieces GetStartingPieces(void) { return m_Prefabs.GetStartingPieces(); } + virtual int GetPieceWeight( const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, @@ -258,15 +273,35 @@ protected: return m_Prefabs.GetPieceWeight(a_PlacedPiece, a_ExistingConnector, a_NewPiece); } + virtual void PiecePlaced(const cPiece & a_Piece) override { m_Prefabs.PiecePlaced(a_Piece); } + virtual void Reset(void) override { m_Prefabs.Reset(); } + + + void MoveAllDescendants(cPlacedPieces & a_PlacedPieces, size_t a_Pivot, int a_HeightDifference) + { + size_t num = a_PlacedPieces.size(); + cPlacedPiece * Pivot = a_PlacedPieces[a_Pivot]; + for (size_t i = a_Pivot + 1; i < num; i++) + { + if ( + (a_PlacedPieces[i]->GetParent() == Pivot) && // It is a direct dependant of the pivot + !((const cPrefab &)a_PlacedPieces[i]->GetPiece()).ShouldMoveToGround() // It attaches strictly by connectors + ) + { + a_PlacedPieces[i]->MoveToGroundBy(a_HeightDifference); + MoveAllDescendants(a_PlacedPieces, i, a_HeightDifference); + } + } // for i - a_PlacedPieces[] + } } ; -- cgit v1.2.3 From c9c2a4f479474fe03acce598ba2687a0f4817083 Mon Sep 17 00:00:00 2001 From: JoannisO Date: Mon, 26 May 2014 08:44:16 +0200 Subject: Added Arrow- and FireCharge-Dispensing to DispenserEntity. --- src/BlockEntities/DispenserEntity.cpp | 107 ++++++++++++++++++++++++++++------ src/BlockEntities/DispenserEntity.h | 15 +++-- 2 files changed, 95 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 2a32f69d9..7257513df 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -6,8 +6,10 @@ #include "../Simulator/FluidSimulator.h" #include "../Chunk.h" - - +#include "../World.h" +#include "../Entities/ArrowEntity.h" +#include "../Entities/FireChargeEntity.h" +#include "../Matrix4.h" cDispenserEntity::cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) : @@ -69,7 +71,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) } break; } // E_ITEM_BUCKET - + case E_ITEM_WATER_BUCKET: { LOGD("Dispensing water bucket in slot %d; DispBlock is \"%s\" (%d).", a_SlotNum, ItemTypeToString(DispBlock).c_str(), DispBlock); @@ -83,7 +85,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) } break; } - + case E_ITEM_LAVA_BUCKET: { LOGD("Dispensing lava bucket in slot %d; DispBlock is \"%s\" (%d).", a_SlotNum, ItemTypeToString(DispBlock).c_str(), DispBlock); @@ -97,7 +99,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) } break; } - + case E_ITEM_SPAWN_EGG: { double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width); @@ -108,7 +110,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) } break; } - + case E_BLOCK_TNT: { // Spawn a primed TNT entity, if space allows: @@ -128,7 +130,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) if (DispChunk->GetBlock(DispX, DispY, DispZ) == E_BLOCK_AIR) { DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_FIRE, 0); - + bool ItemBroke = m_Contents.DamageItem(a_SlotNum, 1); if (ItemBroke) @@ -138,13 +140,63 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) } break; } - + case E_ITEM_FIRE_CHARGE: { - // TODO: Spawn fireball entity + Vector3d Speed = GetProjectileLookVector(a_Chunk); + + double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width); + double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); + + + cFireChargeEntity* fireCharge = new cFireChargeEntity(NULL /*was this*/, MobX, (double) DispY + 0.3, MobZ, Speed); + + + if (fireCharge == NULL) + { + break; + } + if (!fireCharge->Initialize(m_World)) + { + + delete fireCharge; + break; + } + m_World->BroadcastSpawnEntity(*fireCharge); + + m_Contents.ChangeSlotCount(a_SlotNum, -1); + + break; + } + + case E_ITEM_ARROW: + { + Vector3d Speed = GetProjectileLookVector(a_Chunk); + + double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width); + double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); + + + cArrowEntity* Arrow = new cArrowEntity(NULL /*was this*/, MobX, (double) DispY + 0.3, MobZ, Speed); + + + if (Arrow == NULL) + { + break; + } + if (!Arrow->Initialize(m_World)) + { + + delete Arrow; + break; + } + m_World->BroadcastSpawnEntity(*Arrow); + + m_Contents.ChangeSlotCount(a_SlotNum, -1); + break; } - + default: { DropFromSlot(a_Chunk, a_SlotNum); @@ -154,8 +206,29 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) } +Vector3d cDispenserEntity::GetProjectileLookVector(cChunk & a_Chunk) +{ + NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ); + int Direction = 0; + switch (Meta) + { + case E_META_DROPSPENSER_FACING_YP: Direction = 0; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block) + case E_META_DROPSPENSER_FACING_YM: Direction = 0; break; + case E_META_DROPSPENSER_FACING_XM: Direction = 90; break; // WEST + case E_META_DROPSPENSER_FACING_XP: Direction = 270; break; // EAST + case E_META_DROPSPENSER_FACING_ZM: Direction = 180; break; + case E_META_DROPSPENSER_FACING_ZP: Direction = 0; break; + } + + Matrix4d m; + m.Init(Vector3d(), 0, Direction, 0); + Vector3d Look = m.Transform(Vector3d(0, 0, 1)); + Vector3d Speed = Look * 20; + Speed.y = Speed.y + 1; + return Speed; +} bool cDispenserEntity::ScoopUpLiquid(int a_SlotNum, short a_BucketItemType) @@ -167,14 +240,14 @@ bool cDispenserEntity::ScoopUpLiquid(int a_SlotNum, short a_BucketItemType) m_Contents.SetSlot(a_SlotNum, LiquidBucket); return true; } - + // There are stacked buckets at the selected slot, see if a full bucket will fit somewhere else if (m_Contents.HowManyCanFit(LiquidBucket) < 1) { // Cannot fit into m_Contents return false; } - + m_Contents.ChangeSlotCount(a_SlotNum, -1); m_Contents.AddItem(LiquidBucket); return true; @@ -195,7 +268,7 @@ bool cDispenserEntity::EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum // Not a suitable block in front return false; } - + cItem EmptyBucket(E_ITEM_BUCKET, 1); if (m_Contents.GetSlot(a_SlotNum).m_ItemCount == 1) { @@ -203,20 +276,16 @@ bool cDispenserEntity::EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum m_Contents.SetSlot(a_SlotNum, EmptyBucket); return true; } - + // There are full buckets stacked at this slot, check if we can fit in the empty bucket if (m_Contents.HowManyCanFit(EmptyBucket) < 1) { // The empty bucket wouldn't fit into m_Contents return false; } - + // The empty bucket fits in, remove one full bucket and add the empty one m_Contents.ChangeSlotCount(a_SlotNum, -1); m_Contents.AddItem(EmptyBucket); return true; } - - - - diff --git a/src/BlockEntities/DispenserEntity.h b/src/BlockEntities/DispenserEntity.h index fdfe4e5b4..02a34be37 100644 --- a/src/BlockEntities/DispenserEntity.h +++ b/src/BlockEntities/DispenserEntity.h @@ -12,11 +12,11 @@ class cDispenserEntity : public cDropSpenserEntity { typedef cDropSpenserEntity super; - + public: // tolua_end - + /// Constructor used for normal operation cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); @@ -25,14 +25,13 @@ public: private: // cDropSpenser overrides: virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) override; - + /// If such a bucket can fit, adds it to m_Contents and returns true bool ScoopUpLiquid(int a_SlotNum, short a_BucketItemType); - + + // Returns how to aim the projectile + Vector3d GetProjectileLookVector(cChunk & a_Chunk); + /// If the a_BlockInFront is liquidable and the empty bucket can fit, does the m_Contents processing and returns true bool EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum); } ; // tolua_export - - - - -- cgit v1.2.3 From 24137e282bc97497bcf8c50745d2d45da59b1a27 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 26 May 2014 10:05:51 +0200 Subject: Fixed prefab test initialization. --- src/Generating/Prefab.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index e41907325..2ab1455b9 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -108,6 +108,9 @@ static const cPrefab::sDef g_TestPrefabDef = // AddWeightIfSame: 1000, + + // MoveToGround: + false, }; static cPrefab g_TestPrefab(g_TestPrefabDef); -- cgit v1.2.3 From 74801f564775ae4c6b70834f76167a54b8a84826 Mon Sep 17 00:00:00 2001 From: JoannisO Date: Mon, 26 May 2014 14:47:04 +0200 Subject: - Added support for more types of projectiles in the Dispenser - Improved the method of spawning projectiles in the world - Added another method for spawning the projectiles --- src/BlockEntities/DispenserEntity.cpp | 82 +++++++++++++++++++---------------- src/BlockEntities/DispenserEntity.h | 7 +++ 2 files changed, 51 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 7257513df..e2032a041 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -9,9 +9,12 @@ #include "../World.h" #include "../Entities/ArrowEntity.h" #include "../Entities/FireChargeEntity.h" +#include "../Entities/ProjectileEntity.h" #include "../Matrix4.h" + + cDispenserEntity::cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) : super(E_BLOCK_DISPENSER, a_BlockX, a_BlockY, a_BlockZ, a_World) { @@ -143,56 +146,37 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_FIRE_CHARGE: { - Vector3d Speed = GetProjectileLookVector(a_Chunk); - - double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width); - double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - - - cFireChargeEntity* fireCharge = new cFireChargeEntity(NULL /*was this*/, MobX, (double) DispY + 0.3, MobZ, Speed); - - - if (fireCharge == NULL) - { - break; - } - if (!fireCharge->Initialize(m_World)) - { - - delete fireCharge; - break; - } - m_World->BroadcastSpawnEntity(*fireCharge); - - m_Contents.ChangeSlotCount(a_SlotNum, -1); + spawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFireCharge); break; } case E_ITEM_ARROW: { - Vector3d Speed = GetProjectileLookVector(a_Chunk); - - double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width); - double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); + spawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkArrow); + break; + } - cArrowEntity* Arrow = new cArrowEntity(NULL /*was this*/, MobX, (double) DispY + 0.3, MobZ, Speed); + case E_ITEM_SNOWBALL: + { + // Not working as there is no such entity yet? + spawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkSnowball); + break; + } - if (Arrow == NULL) - { - break; - } - if (!Arrow->Initialize(m_World)) - { + case E_ITEM_EGG: + { + // Not working as there is no such entity yet? + spawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkEgg); - delete Arrow; - break; - } - m_World->BroadcastSpawnEntity(*Arrow); + break; + } - m_Contents.ChangeSlotCount(a_SlotNum, -1); + case E_ITEM_FIREWORK_ROCKET: + { + spawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFirework); break; } @@ -206,6 +190,20 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) } + +void cDispenserEntity::spawnProjectileFromDispenser(cChunk& a_Chunk, int& DispX, int& DispY, int& DispZ, cProjectileEntity::eKind kind) +{ + Vector3d Speed = GetProjectileLookVector(a_Chunk); + cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ); + + double EntityX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width); + double EntityZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); + + m_World->CreateProjectile((double) EntityX, (double) DispY, (double) EntityZ, cProjectileEntity::pkArrow, NULL, NULL, &Speed); +} + + + Vector3d cDispenserEntity::GetProjectileLookVector(cChunk & a_Chunk) { NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ); @@ -231,6 +229,10 @@ Vector3d cDispenserEntity::GetProjectileLookVector(cChunk & a_Chunk) } + + + + bool cDispenserEntity::ScoopUpLiquid(int a_SlotNum, short a_BucketItemType) { cItem LiquidBucket(a_BucketItemType, 1); @@ -289,3 +291,7 @@ bool cDispenserEntity::EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum m_Contents.AddItem(EmptyBucket); return true; } + + + + diff --git a/src/BlockEntities/DispenserEntity.h b/src/BlockEntities/DispenserEntity.h index 02a34be37..9290bee5c 100644 --- a/src/BlockEntities/DispenserEntity.h +++ b/src/BlockEntities/DispenserEntity.h @@ -29,9 +29,16 @@ private: /// If such a bucket can fit, adds it to m_Contents and returns true bool ScoopUpLiquid(int a_SlotNum, short a_BucketItemType); + // Spawns a projectile of the given kind in front of the dispenser + void spawnProjectileFromDispenser(cChunk& a_Chunk, int& DispX, int& DispY, int& DispZ, cProjectileEntity::eKind kind); + // Returns how to aim the projectile Vector3d GetProjectileLookVector(cChunk & a_Chunk); /// If the a_BlockInFront is liquidable and the empty bucket can fit, does the m_Contents processing and returns true bool EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum); } ; // tolua_export + + + + -- cgit v1.2.3 From 6449b5d11b5a07183812189d5eead0734f9dc191 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 26 May 2014 16:38:14 +0200 Subject: Revert "Add more move checks" This reverts commit 989312c4e7f517ae324e857cb255211e3fd8bb06. --- src/ClientHandle.cpp | 74 ++++++++++++---------------------------------------- src/ClientHandle.h | 2 +- 2 files changed, 17 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index e7537d74d..83b21ae3c 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -582,37 +582,16 @@ void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, return; } - if (m_Player->GetHealth() <= 0) - { - // The player is dead. He can't move :D - return; - } - - if (std::isnan(a_PosX) || std::isnan(a_PosY) || std::isnan(a_PosZ) || std::isnan(a_Stance)) - { - LOGWARN("%s was caught trying to crash the server with an invalid position.", m_Player->GetName().c_str()); - Kick("Nope!"); - return; - } - - // Invalid stance check - if (!m_Player->IsInBed()) - { - double Difference = a_Stance - a_PosY; - if ((Difference > 1.65) || (Difference < 1.0)) - { - Kick("Illegal stance!"); - LOGWARN("%s had an illegal stance: %f", m_Player->GetName().c_str(), a_Stance); - return; - } - } - - if ((std::abs(a_PosX) > 32000000.0) || (std::abs(a_PosZ) > 32000000.0)) + /* + // TODO: Invalid stance check + if ((a_PosY >= a_Stance) || (a_Stance > a_PosY + 1.65)) { - Kick("Illegal position!"); + LOGD("Invalid stance"); + SendPlayerMoveLook(); return; } - + */ + // If the player has moved too far, "repair" them: Vector3d Pos(a_PosX, a_PosY, a_PosZ); if ((m_Player->GetPosition() - Pos).SqrLength() > 100 * 100) @@ -1410,7 +1389,7 @@ void cClientHandle::HandlePlayerLook(float a_Rotation, float a_Pitch, bool a_IsO -void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Yaw, float a_Pitch, bool a_IsOnGround) +void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround) { if ((m_Player == NULL) || (m_State != csPlaying)) { @@ -1418,42 +1397,21 @@ void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_ return; } - if (m_Player->GetHealth() <= 0) - { - // The player is dead. He can't move :D - return; - } - - if (std::isnan(a_PosX) || std::isnan(a_PosY) || std::isnan(a_PosZ) || std::isnan(a_Stance)) - { - LOGWARN("%s was caught trying to crash the server with an invalid position.", m_Player->GetName().c_str()); - Kick("Nope!"); - return; - } - - // Invalid stance check - if (!m_Player->IsInBed()) - { - double Difference = a_Stance - a_PosY; - if ((Difference > 1.65) || (Difference < 1.0)) - { - Kick("Illegal stance!"); - LOGWARN("%s had an illegal stance: %f", m_Player->GetName().c_str(), a_Stance); - return; - } - } - - if ((std::abs(a_PosX) > 32000000.0) || (std::abs(a_PosZ) > 32000000.0)) + /* + // TODO: Invalid stance check + if ((a_PosY >= a_Stance) || (a_Stance > a_PosY + 1.65)) { - Kick("Illegal position!"); + LOGD("Invalid stance"); + SendPlayerMoveLook(); return; } + */ m_Player->MoveTo(Vector3d(a_PosX, a_PosY, a_PosZ)); m_Player->SetStance (a_Stance); m_Player->SetTouchGround(a_IsOnGround); - m_Player->SetHeadYaw (a_Yaw); - m_Player->SetYaw (a_Yaw); + m_Player->SetHeadYaw (a_Rotation); + m_Player->SetYaw (a_Rotation); m_Player->SetPitch (a_Pitch); } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 04d93e2c0..659c67658 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -225,7 +225,7 @@ public: void HandlePing (void); void HandlePlayerAbilities (bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed); void HandlePlayerLook (float a_Rotation, float a_Pitch, bool a_IsOnGround); - void HandlePlayerMoveLook (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Yaw, float a_Pitch, bool a_IsOnGround); // While m_bPositionConfirmed (normal gameplay) + void HandlePlayerMoveLook (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround); // While m_bPositionConfirmed (normal gameplay) void HandlePlayerPos (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround); void HandlePluginMessage (const AString & a_Channel, const AString & a_Message); void HandleRespawn (void); -- cgit v1.2.3 From 0a3570bc9daab9fb8772dee48aab1ba6bf4da92a Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 26 May 2014 14:13:40 -0700 Subject: ClientHandle.cpp: remove redundant code HandlePlayerMoveLook() calls HandlePlayerPos() and HandlePlayerLook() to reduce code redundancy. --- src/ClientHandle.cpp | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 83b21ae3c..4aa42a489 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1391,28 +1391,8 @@ void cClientHandle::HandlePlayerLook(float a_Rotation, float a_Pitch, bool a_IsO void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround) { - if ((m_Player == NULL) || (m_State != csPlaying)) - { - // The client hasn't been spawned yet and sends nonsense, we know better - return; - } - - /* - // TODO: Invalid stance check - if ((a_PosY >= a_Stance) || (a_Stance > a_PosY + 1.65)) - { - LOGD("Invalid stance"); - SendPlayerMoveLook(); - return; - } - */ - - m_Player->MoveTo(Vector3d(a_PosX, a_PosY, a_PosZ)); - m_Player->SetStance (a_Stance); - m_Player->SetTouchGround(a_IsOnGround); - m_Player->SetHeadYaw (a_Rotation); - m_Player->SetYaw (a_Rotation); - m_Player->SetPitch (a_Pitch); + HandlePlayerPos(a_PosX, a_PosY, a_PosZ, a_Stance, a_IsOnGround); + HandlePlayerLook(a_Rotation, a_Pitch, a_IsOnGround); } -- cgit v1.2.3 From c204735f3840d2199c48b13bd26e9b8d80394b83 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 27 May 2014 00:28:46 -0700 Subject: ClientHandle.cpp: Process look before pos --- src/ClientHandle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 4aa42a489..9b03bead9 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1391,8 +1391,8 @@ void cClientHandle::HandlePlayerLook(float a_Rotation, float a_Pitch, bool a_IsO void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround) { - HandlePlayerPos(a_PosX, a_PosY, a_PosZ, a_Stance, a_IsOnGround); HandlePlayerLook(a_Rotation, a_Pitch, a_IsOnGround); + HandlePlayerPos(a_PosX, a_PosY, a_PosZ, a_Stance, a_IsOnGround); } -- cgit v1.2.3 From 1128dc783f4ee0913f3395c0a79ebdbbce2cfdee Mon Sep 17 00:00:00 2001 From: Joannis Date: Tue, 27 May 2014 11:08:06 +0200 Subject: - Fixed the ampersands and asterisks to fit the format. - Fixed the method "SpawnProjectileFromDispenser" to use CamelCasing. --- src/BlockEntities/DispenserEntity.cpp | 14 +++++++------- src/BlockEntities/DispenserEntity.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index e2032a041..0f64118ef 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -146,14 +146,14 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_FIRE_CHARGE: { - spawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFireCharge); + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFireCharge); break; } case E_ITEM_ARROW: { - spawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkArrow); + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkArrow); break; } @@ -161,7 +161,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_SNOWBALL: { // Not working as there is no such entity yet? - spawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkSnowball); + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkSnowball); break; } @@ -169,14 +169,14 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_EGG: { // Not working as there is no such entity yet? - spawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkEgg); + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkEgg); break; } case E_ITEM_FIREWORK_ROCKET: { - spawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFirework); + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFirework); break; } @@ -191,7 +191,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) -void cDispenserEntity::spawnProjectileFromDispenser(cChunk& a_Chunk, int& DispX, int& DispY, int& DispZ, cProjectileEntity::eKind kind) +void cDispenserEntity::SpawnProjectileFromDispenser(cChunk & a_Chunk, int & DispX, int & DispY, int & DispZ, cProjectileEntity::eKind kind) { Vector3d Speed = GetProjectileLookVector(a_Chunk); cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ); @@ -199,7 +199,7 @@ void cDispenserEntity::spawnProjectileFromDispenser(cChunk& a_Chunk, int& DispX, double EntityX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width); double EntityZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - m_World->CreateProjectile((double) EntityX, (double) DispY, (double) EntityZ, cProjectileEntity::pkArrow, NULL, NULL, &Speed); + m_World->CreateProjectile((double) EntityX, (double) DispY, (double) EntityZ, cProjectileEntity::pkArrow, NULL, NULL, & Speed); } diff --git a/src/BlockEntities/DispenserEntity.h b/src/BlockEntities/DispenserEntity.h index 9290bee5c..8bc2475c9 100644 --- a/src/BlockEntities/DispenserEntity.h +++ b/src/BlockEntities/DispenserEntity.h @@ -30,7 +30,7 @@ private: bool ScoopUpLiquid(int a_SlotNum, short a_BucketItemType); // Spawns a projectile of the given kind in front of the dispenser - void spawnProjectileFromDispenser(cChunk& a_Chunk, int& DispX, int& DispY, int& DispZ, cProjectileEntity::eKind kind); + void SpawnProjectileFromDispenser(cChunk& a_Chunk, int& DispX, int& DispY, int& DispZ, cProjectileEntity::eKind kind); // Returns how to aim the projectile Vector3d GetProjectileLookVector(cChunk & a_Chunk); -- cgit v1.2.3 From 19df18c46199f06f3bf2058cc0efee9126e7670a Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 27 May 2014 12:44:56 +0100 Subject: Fixed test globals to work with precompiled headers --- src/ChunkData.cpp | 4 ---- src/Globals.h | 48 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 36 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 79029f0cf..c41dcb265 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -1,9 +1,5 @@ -#ifdef TEST_GLOBALS -#include "TestGlobals.h" -#else #include "Globals.h" -#endif #include "ChunkData.h" cChunkData::cChunkData() diff --git a/src/Globals.h b/src/Globals.h index 71e9191e4..85cfd2f18 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -225,16 +225,28 @@ template class SizeChecker; +#ifndef TEST_GLOBALS + // Common headers (part 1, without macros): + #include "StringUtils.h" + #include "OSSupport/Sleep.h" + #include "OSSupport/CriticalSection.h" + #include "OSSupport/Semaphore.h" + #include "OSSupport/Event.h" + #include "OSSupport/Thread.h" + #include "OSSupport/File.h" + #include "MCLogger.h" +#else + // Logging functions +void inline LOGERROR(const char* a_Format, ...) FORMATSTRING(1,2); -// Common headers (part 1, without macros): -#include "StringUtils.h" -#include "OSSupport/Sleep.h" -#include "OSSupport/CriticalSection.h" -#include "OSSupport/Semaphore.h" -#include "OSSupport/Event.h" -#include "OSSupport/Thread.h" -#include "OSSupport/File.h" -#include "MCLogger.h" +void inline LOGERROR(const char* a_Format, ...) +{ + va_list argList; + va_start(argList, a_Format); + vprintf(a_Format, argList); + va_end(argList); +} +#endif @@ -253,10 +265,22 @@ template class SizeChecker; #define FAST_FLOOR_DIV( x, div ) (((x) - (((x) < 0) ? ((div) - 1) : 0)) / (div)) // Own version of assert() that writes failed assertions to the log for review -#ifdef _DEBUG - #define ASSERT( x ) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), assert(0), 0 ) ) +#ifdef TEST_GLOBALS + + class cAssertFailure + { + }; + + #define ASSERT(x) do { if (!(x)) { throw cAssertFailure();} } while (0) + #define testassert(x) do { if(!(x)) { exit(1); } } while (0) + #define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } exit(1); } while (0) + #else - #define ASSERT(x) ((void)(x)) + #ifdef _DEBUG + #define ASSERT( x ) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), assert(0), 0 ) ) + #else + #define ASSERT(x) ((void)(x)) + #endif #endif // Pretty much the same as ASSERT() but stays in Release builds -- cgit v1.2.3 From 6c25c356c7769b64fd43b0dd2611deb18bdd5619 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 27 May 2014 21:18:15 +0200 Subject: Biome generators: biome lists can contain spaces. --- src/Generating/BioGen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index 32a687201..47ba080c6 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -212,7 +212,7 @@ void cBioGenCache::InitializeBiomeGen(cIniFile & a_IniFile) void cBiomeGenList::InitializeBiomes(const AString & a_Biomes) { - AStringVector Split = StringSplit(a_Biomes, ","); + AStringVector Split = StringSplitAndTrim(a_Biomes, ","); // Convert each string in the list into biome: for (AStringVector::const_iterator itr = Split.begin(); itr != Split.end(); ++itr) -- cgit v1.2.3 From ff99373237178e9f7da02f51581f9a83d0e624d9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 27 May 2014 22:05:50 +0200 Subject: cPieceGenerator chooses starting pieces based on weights. Fixes #1033. --- src/Generating/PieceGenerator.cpp | 26 +++++++++++++++++++++++++- src/Generating/PieceGenerator.h | 9 +++++++++ src/Generating/PrefabPiecePool.cpp | 9 +++++++++ src/Generating/PrefabPiecePool.h | 1 + 4 files changed, 44 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index 1880a20d5..5de231f75 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -362,7 +362,31 @@ cPlacedPiece * cPieceGenerator::PlaceStartingPiece(int a_BlockX, int a_BlockY, i // Choose a random one of the starting pieces: cPieces StartingPieces = m_PiecePool.GetStartingPieces(); - cPiece * StartingPiece = StartingPieces[rnd % StartingPieces.size()]; + int Total = 0; + for (cPieces::const_iterator itr = StartingPieces.begin(), end = StartingPieces.end(); itr != end; ++itr) + { + Total += m_PiecePool.GetStartingPieceWeight(**itr); + } + cPiece * StartingPiece; + if (Total > 0) + { + int Chosen = rnd % Total; + StartingPiece = StartingPieces.front(); + for (cPieces::const_iterator itr = StartingPieces.begin(), end = StartingPieces.end(); itr != end; ++itr) + { + Chosen -= m_PiecePool.GetStartingPieceWeight(**itr); + if (Chosen <= 0) + { + StartingPiece = *itr; + break; + } + } + } + else + { + // All pieces returned zero weight, but we need one to start. Choose with equal chance: + StartingPiece = StartingPieces[rnd % StartingPieces.size()]; + } rnd = rnd >> 16; // Choose a random supported rotation: diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index 21c155c96..fd8576706 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -120,6 +120,15 @@ public: const cPiece & a_NewPiece ) { return 1; } + /** Returns the relative weight with which the a_NewPiece is to be selected for placing as the first piece. + This allows the pool to tweak the piece's chances. + The higher the number returned, the higher the chance the piece will be chosen. 0 means the piece will not be chosen. + If all pieces return 0, a random piece is chosen, with all equal chances. + */ + virtual int GetStartingPieceWeight( + const cPiece & a_NewPiece + ) { return 1; } + /** Called after a piece is placed, to notify the pool that it has been used. The pool may adjust the pieces it will return the next time. */ virtual void PiecePlaced(const cPiece & a_Piece) = 0; diff --git a/src/Generating/PrefabPiecePool.cpp b/src/Generating/PrefabPiecePool.cpp index ed9340815..ad97ab0e7 100644 --- a/src/Generating/PrefabPiecePool.cpp +++ b/src/Generating/PrefabPiecePool.cpp @@ -101,6 +101,15 @@ int cPrefabPiecePool::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const c +int cPrefabPiecePool::GetStartingPieceWeight(const cPiece & a_NewPiece) +{ + return ((const cPrefab &)a_NewPiece).GetDefaultWeight(); +} + + + + + void cPrefabPiecePool::PiecePlaced(const cPiece & a_Piece) { // Do nothing diff --git a/src/Generating/PrefabPiecePool.h b/src/Generating/PrefabPiecePool.h index c6a5ad360..695ab4ea5 100644 --- a/src/Generating/PrefabPiecePool.h +++ b/src/Generating/PrefabPiecePool.h @@ -70,6 +70,7 @@ protected: virtual cPieces GetPiecesWithConnector(int a_ConnectorType) override; virtual cPieces GetStartingPieces(void) override; virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override; + virtual int GetStartingPieceWeight(const cPiece & a_NewPiece) override; virtual void PiecePlaced(const cPiece & a_Piece) override; virtual void Reset(void) override; } ; -- cgit v1.2.3 From 71256c98ed748d5cd789f94404e7984e11bdf115 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 27 May 2014 22:06:49 +0200 Subject: Fixed testing weights in PlainsVillages. --- src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index fee6610c9..f8cf867e5 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -4601,7 +4601,7 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = true, // DefaultWeight: - 0, + 100, // DepthWeight: "", @@ -5048,7 +5048,7 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = false, // DefaultWeight: - 1000, + 100, // DepthWeight: "", @@ -5259,7 +5259,7 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = true, // DefaultWeight: - 0, + 100, // DepthWeight: "", -- cgit v1.2.3 From 6b41d1a4220aa032f53b67637bbc3276272e5047 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 27 May 2014 22:08:20 +0200 Subject: Added AlchemistVillage prefabs (Thanks, KingsCraftAu). --- src/Generating/Prefabs/AlchemistVillagePrefabs.cpp | 2969 ++++++++++++++++++++ src/Generating/Prefabs/AlchemistVillagePrefabs.h | 15 + src/Generating/VillageGen.cpp | 32 +- 3 files changed, 3007 insertions(+), 9 deletions(-) create mode 100644 src/Generating/Prefabs/AlchemistVillagePrefabs.cpp create mode 100644 src/Generating/Prefabs/AlchemistVillagePrefabs.h (limited to 'src') diff --git a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp new file mode 100644 index 000000000..32ffe5b88 --- /dev/null +++ b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp @@ -0,0 +1,2969 @@ + +// AlchemistVillagePrefabs.cpp + +// Defines the prefabs in the group AlchemistVillage + +// NOTE: This file has been generated automatically by GalExport! +// Any manual changes will be overwritten by the next automatic export! + +#include "Globals.h" +#include "AlchemistVillagePrefabs.h" + + + + + +const cPrefab::sDef g_AlchemistVillagePrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // BarWithBasement: + // The data has been exported from the gallery Desert, area index 82, ID 598, created by STR_Warrior + { + // Size: + 11, 12, 9, // SizeX = 11, SizeY = 12, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 11, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "A:101: 0\n" /* ironbars */ + "B: 64:12\n" /* wooddoorblock */ + "C:128: 2\n" /* sandstonestairs */ + "D: 24: 1\n" /* sandstone */ + "E: 44: 9\n" /* step */ + "F:126: 8\n" /* woodenslab */ + "G:128: 7\n" /* sandstonestairs */ + "H: 44: 1\n" /* step */ + "I: 64: 7\n" /* wooddoorblock */ + "J:128: 6\n" /* sandstonestairs */ + "a: 1: 0\n" /* stone */ + "b: 24: 0\n" /* sandstone */ + "c: 12: 0\n" /* sand */ + "d:134: 4\n" /* 134 */ + "e: 5: 1\n" /* wood */ + "f:134: 5\n" /* 134 */ + "g: 65: 5\n" /* ladder */ + "h: 17: 3\n" /* tree */ + "i: 69:11\n" /* lever */ + "j:134: 0\n" /* 134 */ + "k:134: 1\n" /* 134 */ + "l: 50: 4\n" /* torch */ + "m: 19: 0\n" /* sponge */ + "n: 5: 0\n" /* wood */ + "o: 96:12\n" /* trapdoor */ + "p: 24: 2\n" /* sandstone */ + "q:128: 5\n" /* sandstonestairs */ + "r:107: 6\n" /* fencegate */ + "s:128: 4\n" /* sandstonestairs */ + "t:134: 3\n" /* 134 */ + "u: 85: 0\n" /* fence */ + "v:134: 7\n" /* 134 */ + "w:107: 5\n" /* fencegate */ + "x: 64: 5\n" /* wooddoorblock */ + "y: 50: 3\n" /* torch */ + "z:171: 8\n" /* carpet */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaa" + /* 2 */ "aabbbbbbbaa" + /* 3 */ "aabbbbbbbaa" + /* 4 */ "aabbbbbbbaa" + /* 5 */ "aabbbbbbbaa" + /* 6 */ "aabbbbbbbaa" + /* 7 */ "aabbbbbbbaa" + /* 8 */ "aaaaaaaaaaa" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "ccccccccccc" + /* 1 */ "cbbbbbbbbbc" + /* 2 */ "cbdef.defbc" + /* 3 */ "cbdef.defbc" + /* 4 */ "cbdef.defbc" + /* 5 */ "cb.......bc" + /* 6 */ "cb.......bc" + /* 7 */ "cbg......bc" + /* 8 */ "cbbbbbbbbbc" + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "ccccccccccc" + /* 1 */ "cbbbbbbbbbc" + /* 2 */ "cbeee.eeebc" + /* 3 */ "cbeee.eeebc" + /* 4 */ "cbehe.ehebc" + /* 5 */ "cb.i...i.bc" + /* 6 */ "cb.......bc" + /* 7 */ "cbg......bc" + /* 8 */ "cbbbbbbbbbc" + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "ccccccccccc" + /* 1 */ "cbbbbbbbbbc" + /* 2 */ "cbjek.jekbc" + /* 3 */ "cbjek.jekbc" + /* 4 */ "cbjek.jekbc" + /* 5 */ "cb.......bc" + /* 6 */ "cb.......bc" + /* 7 */ "cbg..l...bc" + /* 8 */ "cbbbbbbbbbc" + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "ccccccccccc" + /* 1 */ "ccccccccccc" + /* 2 */ "ccnnnnnnncc" + /* 3 */ "cnnnnnnnnnc" + /* 4 */ "cnnnnnnnnnc" + /* 5 */ "cnnnnnnnnnc" + /* 6 */ "cnnnnnnnnnc" + /* 7 */ "cnonnnnnnnc" + /* 8 */ "cnccccccccc" + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "...p...p..." + /* 1 */ "..........." + /* 2 */ "pbbbqrsbbbp" + /* 3 */ "bkt.....ttb" + /* 4 */ "bku.....ujb" + /* 5 */ "b.........b" + /* 6 */ "bfvvd.....b" + /* 7 */ "b...w..kujb" + /* 8 */ "pxbbbbbbbbp" + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "...p...p..." + /* 1 */ "..........." + /* 2 */ "pbbb...bbbp" + /* 3 */ "b..y...y..b" + /* 4 */ "b.z.....z.b" + /* 5 */ "A.........A" + /* 6 */ "b.........b" + /* 7 */ "b.......z.b" + /* 8 */ "pBbbAAAbbbp" + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "...C...C..." + /* 1 */ "...D...b..." + /* 2 */ "pbbbqEsbbbp" + /* 3 */ "bFFFFFFFFFb" + /* 4 */ "bFFFFFFFFFb" + /* 5 */ "sFFFFFFFFFq" + /* 6 */ "bFFFFFFFFFb" + /* 7 */ "bFFFFFFFFFb" + /* 8 */ "pbbbGGGbbbp" + + // Level 8 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "bHHHHbHHHHb" + /* 3 */ "HpbbbbbbbpH" + /* 4 */ "Hb.......bH" + /* 5 */ "bb.......bb" + /* 6 */ "Hb.......bH" + /* 7 */ "HpIbbbbbbpH" + /* 8 */ "bH.HHbHHHHb" + + // Level 9 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ ".pbbAAAbbp." + /* 4 */ ".b.......b." + /* 5 */ ".A.......A." + /* 6 */ ".b.......b." + /* 7 */ ".pBbAAAbbp." + /* 8 */ "..........." + + // Level 10 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ ".pbbJJJbbp." + /* 4 */ ".bFFFFFFFb." + /* 5 */ ".sFFFFFFFq." + /* 6 */ ".bFFFFFFFb." + /* 7 */ ".pbbGGGbbp." + /* 8 */ "..........." + + // Level 11 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ ".bHHHbHHHb." + /* 4 */ ".H.......H." + /* 5 */ ".b.......b." + /* 6 */ ".H.......H." + /* 7 */ ".bHHHbHHHb." + /* 8 */ "...........", + + // Connectors: + "-1: 5, 5, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // BarWithBasement + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // BarWithoutBasement: + // The data has been exported from the gallery Desert, area index 81, ID 597, created by STR_Warrior + { + // Size: + 11, 8, 9, // SizeX = 11, SizeY = 8, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 7, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "A: 44: 1\n" /* step */ + "B: 64: 3\n" /* wooddoorblock */ + "C: 64: 8\n" /* wooddoorblock */ + "D:128: 6\n" /* sandstonestairs */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 2\n" /* sandstone */ + "d: 24: 0\n" /* sandstone */ + "e:128: 5\n" /* sandstonestairs */ + "f:107: 6\n" /* fencegate */ + "g:128: 4\n" /* sandstonestairs */ + "h:134: 1\n" /* 134 */ + "i:134: 3\n" /* 134 */ + "j: 85: 0\n" /* fence */ + "k:134: 0\n" /* 134 */ + "l:134: 5\n" /* 134 */ + "m: 19: 0\n" /* sponge */ + "n:134: 7\n" /* 134 */ + "o:134: 4\n" /* 134 */ + "p:107: 5\n" /* fencegate */ + "q: 64: 5\n" /* wooddoorblock */ + "r: 50: 3\n" /* torch */ + "s:171: 8\n" /* carpet */ + "t:101: 0\n" /* ironbars */ + "u: 64:12\n" /* wooddoorblock */ + "v:128: 2\n" /* sandstonestairs */ + "w: 24: 1\n" /* sandstone */ + "x: 44: 9\n" /* step */ + "y:126: 8\n" /* woodenslab */ + "z:128: 7\n" /* sandstonestairs */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaa" + /* 2 */ "aaaabbbaaaa" + /* 3 */ "abbbbbbbbba" + /* 4 */ "abbbbbbbbba" + /* 5 */ "abbbbbbbbba" + /* 6 */ "abbbbbbbbba" + /* 7 */ "abbbbbbbbba" + /* 8 */ "abaaaaaaaaa" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "...c...c..." + /* 1 */ "..........." + /* 2 */ "cdddefgdddc" + /* 3 */ "dhi.....iid" + /* 4 */ "dhj.....jkd" + /* 5 */ "d.........d" + /* 6 */ "dlnno.....d" + /* 7 */ "d...p..hjkd" + /* 8 */ "cqddddddddc" + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "...c...c..." + /* 1 */ "..........." + /* 2 */ "cddd...dddc" + /* 3 */ "d..r...r..d" + /* 4 */ "d.s.....s.d" + /* 5 */ "t.........t" + /* 6 */ "d.........d" + /* 7 */ "d.......s.d" + /* 8 */ "cuddtttdddc" + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "...v...v..." + /* 1 */ "...w...d..." + /* 2 */ "cdddexgdddc" + /* 3 */ "dyyyyyyyyyd" + /* 4 */ "dyyyyyyyyyd" + /* 5 */ "gyyyyyyyyye" + /* 6 */ "dyyyyyyyyyd" + /* 7 */ "dyyyyyyyyyd" + /* 8 */ "cdddzzzdddc" + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "dAAAAdAAAAd" + /* 3 */ "AcdddddddcA" + /* 4 */ "Ad.......dA" + /* 5 */ "dd.......dd" + /* 6 */ "Ad.......dA" + /* 7 */ "AcBddddddcA" + /* 8 */ "dA.AAdAAAAd" + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ ".cddtttddc." + /* 4 */ ".d.......d." + /* 5 */ ".t.......t." + /* 6 */ ".d.......d." + /* 7 */ ".cCdtttddc." + /* 8 */ "..........." + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ ".cddDDDddc." + /* 4 */ ".dyyyyyyyd." + /* 5 */ ".gyyyyyyye." + /* 6 */ ".dyyyyyyyd." + /* 7 */ ".cddzzzddc." + /* 8 */ "..........." + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ ".dAAAdAAAd." + /* 4 */ ".A.......A." + /* 5 */ ".d.......d." + /* 6 */ ".A.......A." + /* 7 */ ".dAAAdAAAd." + /* 8 */ "...........", + + // Connectors: + "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // BarWithoutBasement + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // BlackSmith: + // The data has been exported from the gallery Desert, area index 92, ID 633, created by STR_Warrior + { + // Size: + 11, 5, 13, // SizeX = 11, SizeY = 5, SizeZ = 13 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 4, 12, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 0\n" /* sandstone */ + "d: 24: 2\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f: 43: 0\n" /* doubleslab */ + "g: 53: 5\n" /* woodstairs */ + "h: 53: 4\n" /* woodstairs */ + "i: 10: 0\n" /* lava */ + "j: 54: 5\n" /* chest */ + "k: 64:12\n" /* wooddoorblock */ + "l: 50: 3\n" /* torch */ + "m: 19: 0\n" /* sponge */ + "n:101: 0\n" /* ironbars */ + "o: 50: 1\n" /* torch */ + "p: 50: 2\n" /* torch */ + "q:128: 2\n" /* sandstonestairs */ + "r: 44: 9\n" /* step */ + "s:126: 8\n" /* woodenslab */ + "t:128: 4\n" /* sandstonestairs */ + "u:128: 5\n" /* sandstonestairs */ + "v:128: 7\n" /* sandstonestairs */ + "w: 44: 1\n" /* step */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaa" + /* 2 */ "aaaaaaaabaa" + /* 3 */ "acaaacabbba" + /* 4 */ "acaccaabbba" + /* 5 */ "acccccabbba" + /* 6 */ "acaadddbbba" + /* 7 */ "aaacdddbbba" + /* 8 */ "aaaadddbbba" + /* 9 */ "abbbbbbbbba" + /* 10 */ "abbbbbbbbba" + /* 11 */ "abbbbbbbbba" + /* 12 */ "aaaaaaaaaaa" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "......d...d" + /* 1 */ "..........." + /* 2 */ "......dcecd" + /* 3 */ ".d....c...c" + /* 4 */ "......c...c" + /* 5 */ "...f..c...c" + /* 6 */ ".....dc...c" + /* 7 */ ".gh.dic...c" + /* 8 */ "dcccccd...c" + /* 9 */ "cj........c" + /* 10 */ "c.........c" + /* 11 */ "c.........c" + /* 12 */ "dcccccccccd" + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "......d...d" + /* 1 */ "..........." + /* 2 */ "......dckcd" + /* 3 */ ".d....c..lc" + /* 4 */ "......n...c" + /* 5 */ "......c...c" + /* 6 */ "......c...n" + /* 7 */ "......c...n" + /* 8 */ "dcccccd...n" + /* 9 */ "co........c" + /* 10 */ "n.........c" + /* 11 */ "c........pc" + /* 12 */ "dcccnnncccd" + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "......q...q" + /* 1 */ "......c...c" + /* 2 */ "......dcccd" + /* 3 */ ".drrrrcsssc" + /* 4 */ ".rsssstsssc" + /* 5 */ ".rsssscsssc" + /* 6 */ ".rsssscsssu" + /* 7 */ ".rsssscsssu" + /* 8 */ "dcccccdsssu" + /* 9 */ "csssssssssc" + /* 10 */ "tsssssssssc" + /* 11 */ "csssssssssc" + /* 12 */ "dcccvvvcccd" + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "......cwwwc" + /* 3 */ ".w.w.ww...w" + /* 4 */ "......w...w" + /* 5 */ ".w....w...w" + /* 6 */ "......w...w" + /* 7 */ ".w....w...c" + /* 8 */ "cwwwwwc...w" + /* 9 */ "w.........w" + /* 10 */ "w.........w" + /* 11 */ "w.........w" + /* 12 */ "cwwwwcwwwwc", + + // Connectors: + "-1: 8, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // BlackSmith + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // LargeHouse1: + // The data has been exported from the gallery Desert, area index 77, ID 577, created by STR_Warrior + { + // Size: + 15, 13, 11, // SizeX = 15, SizeY = 13, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 14, 12, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "A:128: 2\n" /* sandstonestairs */ + "B:128: 0\n" /* sandstonestairs */ + "C: 87: 0\n" /* netherstone */ + "D:128: 3\n" /* sandstonestairs */ + "E: 51: 0\n" /* fire */ + "F: 44: 9\n" /* step */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 2\n" /* sandstone */ + "d: 24: 0\n" /* sandstone */ + "e: 85: 0\n" /* fence */ + "f: 5: 1\n" /* wood */ + "g: 64: 2\n" /* wooddoorblock */ + "h: 64: 0\n" /* wooddoorblock */ + "i: 61: 2\n" /* furnace */ + "j:118: 0\n" /* cauldronblock */ + "k:134: 4\n" /* 134 */ + "l: 65: 2\n" /* ladder */ + "m: 19: 0\n" /* sponge */ + "n:101: 0\n" /* ironbars */ + "o:140: 0\n" /* flowerpotblock */ + "p: 64: 8\n" /* wooddoorblock */ + "q: 69:12\n" /* lever */ + "r: 44:10\n" /* step */ + "s:128: 1\n" /* sandstonestairs */ + "t: 47: 0\n" /* bookshelf */ + "u: 96:12\n" /* trapdoor */ + "v:128: 4\n" /* sandstonestairs */ + "w:128: 5\n" /* sandstonestairs */ + "x:128: 7\n" /* sandstonestairs */ + "y: 44: 1\n" /* step */ + "z:128: 6\n" /* sandstonestairs */, + + // Block data: + // Level 0 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "aaaaaaaaaaaaaaa" + /* 1 */ "aaaaabbbbbbbaaa" + /* 2 */ "aaaabbbbbbbbaaa" + /* 3 */ "aaaaabbbbbbbbaa" + /* 4 */ "aaaaabbbbbbbaaa" + /* 5 */ "aaaaabbbbbbbaaa" + /* 6 */ "aaaaabbbbbbbaaa" + /* 7 */ "aaaaabbbbbbbaaa" + /* 8 */ "aaaaabbbbbbbaaa" + /* 9 */ "aaaaabbbbbbbaaa" + /* 10 */ "aaaaaaaaaaaaaaa" + + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "....cdddddddc.." + /* 1 */ "eeeed......fd.c" + /* 2 */ "e...g.......d.." + /* 3 */ "e...d.......h.." + /* 4 */ "e...dijk..l.d.." + /* 5 */ "e...dddd.dddd.c" + /* 6 */ "eeeed.......d.." + /* 7 */ "mmmmd.......d.." + /* 8 */ "mmmmd.......d.." + /* 9 */ "mmmmd.......d.." + /* 10 */ "mmmmcdddddddc.." + + // Level 2 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "....cddnnnddc.." + /* 1 */ "....d......od.c" + /* 2 */ "....p.......d.." + /* 3 */ "....d.......p.." + /* 4 */ "....d.q...l.d.." + /* 5 */ "....dddd.dddd.c" + /* 6 */ "....n.......n.." + /* 7 */ "mmmmn.......n.." + /* 8 */ "mmmmn.......n.." + /* 9 */ "mmmmd.......d.." + /* 10 */ "mmmmcddnnnddc.." + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "....cdddddddc.." + /* 1 */ "....drrrrrrrdds" + /* 2 */ "....drrrrrrrd.." + /* 3 */ "....drrrrrrrd.." + /* 4 */ "....dtttrrurd.." + /* 5 */ "....dddddddddds" + /* 6 */ "....vrrrrrrrw.." + /* 7 */ "mmmmvrrrrrrrw.." + /* 8 */ "mmmmvrrrrrrrw.." + /* 9 */ "mmmmdrrrrrrrd.." + /* 10 */ "mmmmcddxxxddc.." + + // Level 4 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "....dyyydyyyd.." + /* 1 */ "....ycdddddcy.." + /* 2 */ "....yd.....dy.." + /* 3 */ "....yd.....dy.." + /* 4 */ "....yd.....dy.." + /* 5 */ "....dcdd.ddcd.." + /* 6 */ "....y.......y.." + /* 7 */ "mmmmy.......y.." + /* 8 */ "mmmmy.......y.." + /* 9 */ "mmmmy.......y.." + /* 10 */ "mmmmdyyydyyyd.." + + // Level 5 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".....cddnddc..." + /* 2 */ ".....n.....n..." + /* 3 */ ".....n.....n..." + /* 4 */ ".....n.....n..." + /* 5 */ ".....cdd.ddc..." + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "..............." + /* 9 */ "..............." + /* 10 */ "..............." + + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".....cddzddc..." + /* 2 */ ".....vrrrrrw..." + /* 3 */ ".....vrrrrrw..." + /* 4 */ ".....vrrrrrw..." + /* 5 */ ".....cdddddc..." + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "..............." + /* 9 */ "..............." + /* 10 */ "..............." + + // Level 7 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".....dyydyyd..." + /* 2 */ ".....y.ddd.y..." + /* 3 */ ".....d.ddd.d..." + /* 4 */ ".....y.ddd.y..." + /* 5 */ ".....dyydyyd..." + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "..............." + /* 9 */ "..............." + /* 10 */ "..............." + + // Level 8 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ ".......cAc....." + /* 3 */ ".......BCs....." + /* 4 */ ".......cDc....." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "..............." + /* 9 */ "..............." + /* 10 */ "..............." + + // Level 9 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ ".......c.c....." + /* 3 */ "........E......" + /* 4 */ ".......c.c....." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "..............." + /* 9 */ "..............." + /* 10 */ "..............." + + // Level 10 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ ".......c.c....." + /* 3 */ "..............." + /* 4 */ ".......c.c....." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "..............." + /* 9 */ "..............." + /* 10 */ "..............." + + // Level 11 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ ".......ddd....." + /* 3 */ ".......dFd....." + /* 4 */ ".......ddd....." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "..............." + /* 9 */ "..............." + /* 10 */ "..............." + + // Level 12 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ ".......y.y....." + /* 3 */ "..............." + /* 4 */ ".......y.y....." + /* 5 */ "..............." + /* 6 */ "..............." + /* 7 */ "..............." + /* 8 */ "..............." + /* 9 */ "..............." + /* 10 */ "...............", + + // Connectors: + "-1: 14, 1, 3: 5\n" /* Type -1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // LargeHouse1 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // LargeTower: + // The data has been exported from the gallery Desert, area index 80, ID 596, created by STR_Warrior + { + // Size: + 7, 11, 7, // SizeX = 7, SizeY = 11, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 10, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 0\n" /* sandstonestairs */ + "e: 24: 2\n" /* sandstone */ + "f: 24: 0\n" /* sandstone */ + "g: 71: 3\n" /* irondoorblock */ + "h:128: 1\n" /* sandstonestairs */ + "i:128: 3\n" /* sandstonestairs */ + "j: 77: 4\n" /* stonebutton */ + "k: 71: 8\n" /* irondoorblock */ + "l:128: 6\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */ + "n:128: 4\n" /* sandstonestairs */ + "o:128: 5\n" /* sandstonestairs */ + "p: 50: 4\n" /* torch */ + "q:128: 7\n" /* sandstonestairs */ + "r: 85: 0\n" /* fence */ + "s: 24: 1\n" /* sandstone */ + "t: 44: 1\n" /* step */ + "u: 89: 0\n" /* lightstone */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "aaabaaa" + /* 2 */ "aabbbaa" + /* 3 */ "aabbbaa" + /* 4 */ "aabbbaa" + /* 5 */ "aaaaaaa" + /* 6 */ "aaaaaaa" + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "mc...cm" + /* 1 */ "defgfeh" + /* 2 */ ".f...f." + /* 3 */ ".f...f." + /* 4 */ ".f...f." + /* 5 */ "defffeh" + /* 6 */ "mi...im" + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "m.j...m" + /* 1 */ ".efkfe." + /* 2 */ ".f...f." + /* 3 */ ".f...f." + /* 4 */ ".f...f." + /* 5 */ ".efffe." + /* 6 */ "m.....m" + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "..lfl.." + /* 2 */ ".n...o." + /* 3 */ ".f...f." + /* 4 */ ".n.p.o." + /* 5 */ "..qfq.." + /* 6 */ "......." + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "..frf.." + /* 2 */ ".f...f." + /* 3 */ ".r...r." + /* 4 */ ".f...f." + /* 5 */ "..frf.." + /* 6 */ "......." + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "..frf.." + /* 2 */ ".f...f." + /* 3 */ ".r...r." + /* 4 */ ".f...f." + /* 5 */ "..frf.." + /* 6 */ "......." + + // Level 6 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "..frf.." + /* 2 */ ".f...f." + /* 3 */ ".r...r." + /* 4 */ ".f...f." + /* 5 */ "..frf.." + /* 6 */ "......." + + // Level 7 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "..cfc.." + /* 2 */ ".d...h." + /* 3 */ ".f...f." + /* 4 */ ".d...h." + /* 5 */ "..ifi.." + /* 6 */ "......." + + // Level 8 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".ffsff." + /* 2 */ ".f...f." + /* 3 */ ".s...s." + /* 4 */ ".f...f." + /* 5 */ ".ffsff." + /* 6 */ "......." + + // Level 9 + /* z\x* 0123456 */ + /* 0 */ "...l..." + /* 1 */ ".efffe." + /* 2 */ ".ftttf." + /* 3 */ "nftftfo" + /* 4 */ ".ftttf." + /* 5 */ ".efffe." + /* 6 */ "...q..." + + // Level 10 + /* z\x* 0123456 */ + /* 0 */ "...t..." + /* 1 */ ".t...t." + /* 2 */ "......." + /* 3 */ "t..u..t" + /* 4 */ "......." + /* 5 */ ".t...t." + /* 6 */ "...t...", + + // Connectors: + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // LargeTower + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // LittleHouse: + // The data has been exported from the gallery Desert, area index 65, ID 551, created by STR_Warrior + { + // Size: + 5, 5, 7, // SizeX = 5, SizeY = 5, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 4, 4, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 2\n" /* sandstone */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 3\n" /* wooddoorblock */ + "f: 61: 2\n" /* furnace */ + "g: 65: 2\n" /* ladder */ + "h: 64: 8\n" /* wooddoorblock */ + "i:101: 0\n" /* ironbars */ + "j: 50: 4\n" /* torch */ + "k:128: 2\n" /* sandstonestairs */ + "l:126: 8\n" /* woodenslab */ + "m: 19: 0\n" /* sponge */ + "n:128: 4\n" /* sandstonestairs */ + "o:128: 5\n" /* sandstonestairs */ + "p:128: 7\n" /* sandstonestairs */ + "q: 44: 1\n" /* step */ + "r: 96: 6\n" /* trapdoor */, + + // Block data: + // Level 0 + /* z\x* 01234 */ + /* 0 */ "aaaaa" + /* 1 */ "aaaaa" + /* 2 */ "aabaa" + /* 3 */ "abbba" + /* 4 */ "abbba" + /* 5 */ "abbba" + /* 6 */ "aaaaa" + + // Level 1 + /* z\x* 01234 */ + /* 0 */ "c...c" + /* 1 */ "....." + /* 2 */ "cdedc" + /* 3 */ "d...d" + /* 4 */ "d...d" + /* 5 */ "df.gd" + /* 6 */ "cdddc" + + // Level 2 + /* z\x* 01234 */ + /* 0 */ "c...c" + /* 1 */ "....." + /* 2 */ "cdhdc" + /* 3 */ "d...d" + /* 4 */ "i...i" + /* 5 */ "dj.gd" + /* 6 */ "cdidc" + + // Level 3 + /* z\x* 01234 */ + /* 0 */ "k...k" + /* 1 */ "d...d" + /* 2 */ "cdddc" + /* 3 */ "dllld" + /* 4 */ "nlllo" + /* 5 */ "dllgd" + /* 6 */ "cdpdc" + + // Level 4 + /* z\x* 01234 */ + /* 0 */ "....." + /* 1 */ "....." + /* 2 */ "dqdqd" + /* 3 */ "q...q" + /* 4 */ "d...d" + /* 5 */ "q..rq" + /* 6 */ "dqdqd", + + // Connectors: + "-1: 2, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // LittleHouse + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // LittleHouse2: + // The data has been exported from the gallery Desert, area index 72, ID 562, created by STR_Warrior + { + // Size: + 7, 5, 11, // SizeX = 7, SizeY = 5, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 4, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 2\n" /* sandstone */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 3\n" /* wooddoorblock */ + "f: 65: 5\n" /* ladder */ + "g: 85: 0\n" /* fence */ + "h:101: 0\n" /* ironbars */ + "i: 64: 8\n" /* wooddoorblock */ + "j: 50: 3\n" /* torch */ + "k:128: 2\n" /* sandstonestairs */ + "l:128: 6\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */ + "n:126: 8\n" /* woodenslab */ + "o:128: 4\n" /* sandstonestairs */ + "p:128: 5\n" /* sandstonestairs */ + "q:128: 7\n" /* sandstonestairs */ + "r: 44: 1\n" /* step */ + "s: 96: 0\n" /* trapdoor */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "aaaaaaa" + /* 1 */ "aaaaaaa" + /* 2 */ "aaaabaa" + /* 3 */ "abbbbba" + /* 4 */ "abbbbba" + /* 5 */ "abbbbba" + /* 6 */ "aaaaaaa" + /* 7 */ "aaaaaaa" + /* 8 */ "aaaaaaa" + /* 9 */ "aaaaaaa" + /* 10 */ "aaaaaaa" + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ ".c...c." + /* 1 */ "......." + /* 2 */ "cdddedc" + /* 3 */ "d.....d" + /* 4 */ "d.....d" + /* 5 */ "df....d" + /* 6 */ "cd.dddc" + /* 7 */ "g.....g" + /* 8 */ "g.....g" + /* 9 */ "g.....g" + /* 10 */ "ggggggg" + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ ".c...c." + /* 1 */ "......." + /* 2 */ "cdhdidc" + /* 3 */ "d..j..d" + /* 4 */ "h.....h" + /* 5 */ "df....d" + /* 6 */ "cd.dhdc" + /* 7 */ "......." + /* 8 */ "......." + /* 9 */ "......." + /* 10 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ ".k...k." + /* 1 */ ".d...d." + /* 2 */ "cdldddc" + /* 3 */ "dnnnnnd" + /* 4 */ "onnnnnp" + /* 5 */ "dfnnnnd" + /* 6 */ "cdddqdc" + /* 7 */ "......." + /* 8 */ "......." + /* 9 */ "......." + /* 10 */ "......." + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "......." + /* 2 */ "drrdrrd" + /* 3 */ "r.....r" + /* 4 */ "d.....d" + /* 5 */ "rs....r" + /* 6 */ "drrdrrd" + /* 7 */ "......." + /* 8 */ "......." + /* 9 */ "......." + /* 10 */ ".......", + + // Connectors: + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // LittleHouse2 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // LittleHouse3: + // The data has been exported from the gallery Desert, area index 66, ID 553, created by STR_Warrior + { + // Size: + 9, 5, 7, // SizeX = 9, SizeY = 5, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 8, 4, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 2\n" /* sandstone */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f: 65: 2\n" /* ladder */ + "g: 64:12\n" /* wooddoorblock */ + "h:101: 0\n" /* ironbars */ + "i: 50: 4\n" /* torch */ + "j:128: 2\n" /* sandstonestairs */ + "k:126: 8\n" /* woodenslab */ + "l:128: 4\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */ + "n:128: 5\n" /* sandstonestairs */ + "o:128: 7\n" /* sandstonestairs */ + "p: 44: 1\n" /* step */ + "q: 96: 2\n" /* trapdoor */, + + // Block data: + // Level 0 + /* z\x* 012345678 */ + /* 0 */ "aaaaaaaaa" + /* 1 */ "aaaaaaaaa" + /* 2 */ "aaaabaaaa" + /* 3 */ "abbbbbbba" + /* 4 */ "abbbbbbba" + /* 5 */ "abbbbbbba" + /* 6 */ "aaaaaaaaa" + + // Level 1 + /* z\x* 012345678 */ + /* 0 */ "..c...c.." + /* 1 */ "........." + /* 2 */ "cdddedddc" + /* 3 */ "d.......d" + /* 4 */ "d.......d" + /* 5 */ "d......fd" + /* 6 */ "cdddddddc" + + // Level 2 + /* z\x* 012345678 */ + /* 0 */ "..c...c.." + /* 1 */ "........." + /* 2 */ "cdddgdddc" + /* 3 */ "d.......d" + /* 4 */ "h.......h" + /* 5 */ "d.i....fd" + /* 6 */ "cddhhhddc" + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "..j...j.." + /* 1 */ "..d...d.." + /* 2 */ "cdddddddc" + /* 3 */ "dkkkkkkkd" + /* 4 */ "lkkkkkkkn" + /* 5 */ "dkkkkkkfd" + /* 6 */ "cddoooddc" + + // Level 4 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "dpppdpppd" + /* 3 */ "p.......p" + /* 4 */ "d.......d" + /* 5 */ "p......qp" + /* 6 */ "dpppdpppd", + + // Connectors: + "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // LittleHouse3 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // LittleHouse4: + // The data has been exported from the gallery Desert, area index 70, ID 560, created by STR_Warrior + { + // Size: + 5, 5, 11, // SizeX = 5, SizeY = 5, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 4, 4, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 2\n" /* sandstone */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 3\n" /* wooddoorblock */ + "f: 65: 5\n" /* ladder */ + "g:134: 3\n" /* 134 */ + "h: 85: 0\n" /* fence */ + "i:134: 2\n" /* 134 */ + "j: 61: 2\n" /* furnace */ + "k:134: 6\n" /* 134 */ + "l:134: 4\n" /* 134 */ + "m: 19: 0\n" /* sponge */ + "n: 64: 8\n" /* wooddoorblock */ + "o: 50: 2\n" /* torch */ + "p:101: 0\n" /* ironbars */ + "q:171: 8\n" /* carpet */ + "r:128: 2\n" /* sandstonestairs */ + "s:126: 8\n" /* woodenslab */ + "t:128: 5\n" /* sandstonestairs */ + "u:128: 7\n" /* sandstonestairs */ + "v: 44: 1\n" /* step */ + "w: 96: 7\n" /* trapdoor */, + + // Block data: + // Level 0 + /* z\x* 01234 */ + /* 0 */ "aaaaa" + /* 1 */ "aaaaa" + /* 2 */ "aabaa" + /* 3 */ "abbba" + /* 4 */ "abbba" + /* 5 */ "abbba" + /* 6 */ "abbba" + /* 7 */ "abbba" + /* 8 */ "abbba" + /* 9 */ "abbba" + /* 10 */ "aaaaa" + + // Level 1 + /* z\x* 01234 */ + /* 0 */ "c...c" + /* 1 */ "....." + /* 2 */ "cdedc" + /* 3 */ "df..d" + /* 4 */ "d...d" + /* 5 */ "d..gd" + /* 6 */ "d..hd" + /* 7 */ "d..id" + /* 8 */ "d...d" + /* 9 */ "djkld" + /* 10 */ "cdddc" + + // Level 2 + /* z\x* 01234 */ + /* 0 */ "c...c" + /* 1 */ "....." + /* 2 */ "cdndc" + /* 3 */ "df..d" + /* 4 */ "d..od" + /* 5 */ "p...p" + /* 6 */ "p..qp" + /* 7 */ "p...p" + /* 8 */ "d...d" + /* 9 */ "d...d" + /* 10 */ "cdpdc" + + // Level 3 + /* z\x* 01234 */ + /* 0 */ "r...r" + /* 1 */ "d...d" + /* 2 */ "cdddc" + /* 3 */ "dfssd" + /* 4 */ "dsssd" + /* 5 */ "tssst" + /* 6 */ "tssst" + /* 7 */ "tssst" + /* 8 */ "dsssd" + /* 9 */ "dsssd" + /* 10 */ "cdudc" + + // Level 4 + /* z\x* 01234 */ + /* 0 */ "....." + /* 1 */ "....." + /* 2 */ "dvdvd" + /* 3 */ "vw..v" + /* 4 */ "v...v" + /* 5 */ "v...v" + /* 6 */ "d...d" + /* 7 */ "v...v" + /* 8 */ "v...v" + /* 9 */ "v...v" + /* 10 */ "dvdvd", + + // Connectors: + "-1: 2, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // LittleHouse4 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // LittleHouse5: + // The data has been exported from the gallery Desert, area index 68, ID 558, created by STR_Warrior + { + // Size: + 9, 5, 9, // SizeX = 9, SizeY = 5, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 8, 4, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 2\n" /* sandstone */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f: 65: 2\n" /* ladder */ + "g: 64:12\n" /* wooddoorblock */ + "h:101: 0\n" /* ironbars */ + "i: 50: 1\n" /* torch */ + "j: 50: 4\n" /* torch */ + "k:128: 2\n" /* sandstonestairs */ + "l:126: 8\n" /* woodenslab */ + "m: 19: 0\n" /* sponge */ + "n:128: 6\n" /* sandstonestairs */ + "o:128: 5\n" /* sandstonestairs */ + "p:128: 4\n" /* sandstonestairs */ + "q:128: 7\n" /* sandstonestairs */ + "r: 44: 1\n" /* step */ + "s: 96: 6\n" /* trapdoor */, + + // Block data: + // Level 0 + /* z\x* 012345678 */ + /* 0 */ "aaaaaaaaa" + /* 1 */ "aaaaaaaaa" + /* 2 */ "aaaaaabaa" + /* 3 */ "aaaaabbba" + /* 4 */ "aaaaabbba" + /* 5 */ "abbbbbbba" + /* 6 */ "abbbbbbba" + /* 7 */ "abbbbbbba" + /* 8 */ "aaaaaaaaa" + + // Level 1 + /* z\x* 012345678 */ + /* 0 */ "mmmmc...c" + /* 1 */ "mmmm....." + /* 2 */ "mmmmcdedc" + /* 3 */ "mmmmd...d" + /* 4 */ "cdddd...d" + /* 5 */ "d.......d" + /* 6 */ "d.......d" + /* 7 */ "d......fd" + /* 8 */ "cdddddddc" + + // Level 2 + /* z\x* 012345678 */ + /* 0 */ "mmmmc...c" + /* 1 */ "mmmm....." + /* 2 */ "mmmmcdgdc" + /* 3 */ "mmmmd...d" + /* 4 */ "cdhdd...h" + /* 5 */ "d.......h" + /* 6 */ "h.......d" + /* 7 */ "di....jfd" + /* 8 */ "cddhhhddc" + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "mmmmk...k" + /* 1 */ "mmmmd...d" + /* 2 */ "mmmmcdddc" + /* 3 */ "mmmmdllld" + /* 4 */ "cdnddlllo" + /* 5 */ "dlllllllo" + /* 6 */ "pllllllld" + /* 7 */ "dllllllfd" + /* 8 */ "cddqqqddc" + + // Level 4 + /* z\x* 012345678 */ + /* 0 */ "mmmm....." + /* 1 */ "mmmm....." + /* 2 */ "mmmmcrdrd" + /* 3 */ "mmmmr...r" + /* 4 */ "drrrd...d" + /* 5 */ "r.......r" + /* 6 */ "r.......r" + /* 7 */ "r......sr" + /* 8 */ "drrrdrrrd", + + // Connectors: + "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // LittleHouse5 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // LittleHouse6: + // The data has been exported from the gallery Desert, area index 69, ID 559, created by STR_Warrior + { + // Size: + 9, 5, 9, // SizeX = 9, SizeY = 5, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 8, 4, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 12: 0\n" /* sand */ + "b: 2: 0\n" /* grass */ + "c: 5: 0\n" /* wood */ + "d: 85: 0\n" /* fence */ + "e: 24: 2\n" /* sandstone */ + "f: 24: 0\n" /* sandstone */ + "g: 64: 7\n" /* wooddoorblock */ + "h: 38: 1\n" /* rose */ + "i: 38: 2\n" /* rose */ + "j: 38: 5\n" /* rose */ + "k: 65: 2\n" /* ladder */ + "l: 64:12\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */ + "n:101: 0\n" /* ironbars */ + "o: 50: 1\n" /* torch */ + "p: 50: 4\n" /* torch */ + "q:128: 2\n" /* sandstonestairs */ + "r:126: 8\n" /* woodenslab */ + "s:128: 6\n" /* sandstonestairs */ + "t:128: 5\n" /* sandstonestairs */ + "u:128: 4\n" /* sandstonestairs */ + "v:128: 7\n" /* sandstonestairs */ + "w: 44: 1\n" /* step */ + "x: 96: 6\n" /* trapdoor */, + + // Block data: + // Level 0 + /* z\x* 012345678 */ + /* 0 */ "aaaaaaaaa" + /* 1 */ "abbbaaaaa" + /* 2 */ "abbbaacaa" + /* 3 */ "abbbaccca" + /* 4 */ "aaaaaccca" + /* 5 */ "accccccca" + /* 6 */ "accccccca" + /* 7 */ "accccccca" + /* 8 */ "aaaaaaaaa" + + // Level 1 + /* z\x* 012345678 */ + /* 0 */ "dddde...e" + /* 1 */ "d........" + /* 2 */ "d...efgfe" + /* 3 */ "dhijf...f" + /* 4 */ "effff...f" + /* 5 */ "f.......f" + /* 6 */ "f.......f" + /* 7 */ "f......kf" + /* 8 */ "efffffffe" + + // Level 2 + /* z\x* 012345678 */ + /* 0 */ "....e...e" + /* 1 */ "........." + /* 2 */ "....eflfe" + /* 3 */ "....f...f" + /* 4 */ "efnff...n" + /* 5 */ "f.......n" + /* 6 */ "n.......f" + /* 7 */ "fo....pkf" + /* 8 */ "effnnnffe" + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "....q...q" + /* 1 */ "....f...f" + /* 2 */ "....efffe" + /* 3 */ "....frrrf" + /* 4 */ "efsffrrrt" + /* 5 */ "frrrrrrrt" + /* 6 */ "urrrrrrrf" + /* 7 */ "frrrrrrkf" + /* 8 */ "effvvvffe" + + // Level 4 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "....ewfwf" + /* 3 */ "....w...w" + /* 4 */ "fwwwf...f" + /* 5 */ "w.......w" + /* 6 */ "w.......w" + /* 7 */ "w......xw" + /* 8 */ "fwwwfwwwf", + + // Connectors: + "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // LittleHouse6 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // LittleHouse7: + // The data has been exported from the gallery Desert, area index 73, ID 563, created by xoft + { + // Size: + 9, 5, 11, // SizeX = 9, SizeY = 5, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 8, 4, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 2\n" /* sandstone */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f: 65: 2\n" /* ladder */ + "g:101: 0\n" /* ironbars */ + "h: 64:12\n" /* wooddoorblock */ + "i: 50: 1\n" /* torch */ + "j: 50: 2\n" /* torch */ + "k:128: 2\n" /* sandstonestairs */ + "l:128: 6\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */ + "n:126: 8\n" /* woodenslab */ + "o:128: 4\n" /* sandstonestairs */ + "p:128: 5\n" /* sandstonestairs */ + "q:128: 7\n" /* sandstonestairs */ + "r: 44: 1\n" /* step */ + "s: 96: 6\n" /* trapdoor */, + + // Block data: + // Level 0 + /* z\x* 012345678 */ + /* 0 */ "aaaaaaaaa" + /* 1 */ "aaaaaaaaa" + /* 2 */ "aaaaaabaa" + /* 3 */ "abbbbbbba" + /* 4 */ "abbbbbbba" + /* 5 */ "abbbbbbba" + /* 6 */ "aaaaabbba" + /* 7 */ "aaaaabbba" + /* 8 */ "aaaaabbba" + /* 9 */ "aaaaabbba" + /* 10 */ "aaaaaaaaa" + + // Level 1 + /* z\x* 012345678 */ + /* 0 */ "....c...c" + /* 1 */ "........." + /* 2 */ "cdddddedc" + /* 3 */ "d.......d" + /* 4 */ "d.......d" + /* 5 */ "d.......d" + /* 6 */ "cdddd...d" + /* 7 */ "mmmmd...d" + /* 8 */ "mmmmd...d" + /* 9 */ "mmmmd..fd" + /* 10 */ "mmmmddddc" + + // Level 2 + /* z\x* 012345678 */ + /* 0 */ "....c...c" + /* 1 */ "........." + /* 2 */ "cdgdddhdc" + /* 3 */ "d.......d" + /* 4 */ "g.......d" + /* 5 */ "di......g" + /* 6 */ "cdgdd...g" + /* 7 */ "mmmmd...g" + /* 8 */ "mmmmg..jd" + /* 9 */ "mmmmd..fd" + /* 10 */ "mmmmddgdc" + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "....k...k" + /* 1 */ "....d...d" + /* 2 */ "cdldddddc" + /* 3 */ "dnnnnnnnd" + /* 4 */ "onnnnnnnd" + /* 5 */ "dnnnnnnnp" + /* 6 */ "cdqddnnnp" + /* 7 */ "mmmmdnnnp" + /* 8 */ "mmmmonnnd" + /* 9 */ "mmmmdnnfd" + /* 10 */ "mmmmddqdc" + + // Level 4 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ "........." + /* 2 */ "drrrdrdrd" + /* 3 */ "r.......r" + /* 4 */ "r.......r" + /* 5 */ "r.......r" + /* 6 */ "drrrd...d" + /* 7 */ "mmmmr...r" + /* 8 */ "mmmmr...r" + /* 9 */ "mmmmr..sr" + /* 10 */ "mmmmdrrrd", + + // Connectors: + "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // LittleHouse7 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // LittleTower: + // The data has been exported from the gallery Desert, area index 79, ID 595, created by STR_Warrior + { + // Size: + 5, 8, 7, // SizeX = 5, SizeY = 8, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 4, 7, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 2\n" /* sandstone */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f: 65: 5\n" /* ladder */ + "g: 64:12\n" /* wooddoorblock */ + "h:101: 0\n" /* ironbars */ + "i: 50: 4\n" /* torch */ + "j:128: 2\n" /* sandstonestairs */ + "k:126: 8\n" /* woodenslab */ + "l:128: 4\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */ + "n:128: 5\n" /* sandstonestairs */ + "o:128: 7\n" /* sandstonestairs */ + "p:128: 6\n" /* sandstonestairs */ + "q: 44: 1\n" /* step */ + "r: 96: 5\n" /* trapdoor */, + + // Block data: + // Level 0 + /* z\x* 01234 */ + /* 0 */ "aaaaa" + /* 1 */ "aaaaa" + /* 2 */ "aabaa" + /* 3 */ "abbba" + /* 4 */ "abbba" + /* 5 */ "abbba" + /* 6 */ "aaaaa" + + // Level 1 + /* z\x* 01234 */ + /* 0 */ "c...c" + /* 1 */ "....." + /* 2 */ "cdedc" + /* 3 */ "df..d" + /* 4 */ "d...d" + /* 5 */ "d...d" + /* 6 */ "cdddc" + + // Level 2 + /* z\x* 01234 */ + /* 0 */ "c...c" + /* 1 */ "....." + /* 2 */ "cdgdc" + /* 3 */ "df..d" + /* 4 */ "h...h" + /* 5 */ "d..id" + /* 6 */ "cdhdc" + + // Level 3 + /* z\x* 01234 */ + /* 0 */ "j...j" + /* 1 */ "d...d" + /* 2 */ "cdddc" + /* 3 */ "dfkkd" + /* 4 */ "lkkkn" + /* 5 */ "dkkkd" + /* 6 */ "cdodc" + + // Level 4 + /* z\x* 01234 */ + /* 0 */ "....." + /* 1 */ "....." + /* 2 */ "cdddc" + /* 3 */ "df..d" + /* 4 */ "d...d" + /* 5 */ "d...d" + /* 6 */ "cdddc" + + // Level 5 + /* z\x* 01234 */ + /* 0 */ "....." + /* 1 */ "....." + /* 2 */ "cdhdc" + /* 3 */ "df..d" + /* 4 */ "h...h" + /* 5 */ "d..id" + /* 6 */ "cdhdc" + + // Level 6 + /* z\x* 01234 */ + /* 0 */ "....." + /* 1 */ "....." + /* 2 */ "cdpdc" + /* 3 */ "dfkkd" + /* 4 */ "lkkkn" + /* 5 */ "dkkkd" + /* 6 */ "cdodc" + + // Level 7 + /* z\x* 01234 */ + /* 0 */ "....." + /* 1 */ "....." + /* 2 */ "dqdqd" + /* 3 */ "qr..q" + /* 4 */ "d...d" + /* 5 */ "q...q" + /* 6 */ "dqdqd", + + // Connectors: + "-1: 2, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // LittleTower + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MediumHouse1: + // The data has been exported from the gallery Desert, area index 71, ID 561, created by STR_Warrior + { + // Size: + 15, 8, 9, // SizeX = 15, SizeY = 8, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 14, 7, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 2\n" /* sandstone */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 3\n" /* wooddoorblock */ + "f: 85: 0\n" /* fence */ + "g: 64: 0\n" /* wooddoorblock */ + "h: 65: 5\n" /* ladder */ + "i: 64: 8\n" /* wooddoorblock */ + "j:101: 0\n" /* ironbars */ + "k: 50: 4\n" /* torch */ + "l:128: 2\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */ + "n:126: 8\n" /* woodenslab */ + "o:128: 4\n" /* sandstonestairs */ + "p:128: 7\n" /* sandstonestairs */ + "q: 44: 1\n" /* step */ + "r: 50: 3\n" /* torch */, + + // Block data: + // Level 0 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "aaaaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaaaa" + /* 2 */ "aaaaabaaaaaaaaa" + /* 3 */ "abbbbbbbbbaaaaa" + /* 4 */ "abbbbbbbbbaaaaa" + /* 5 */ "abbbbbbbbbbaaaa" + /* 6 */ "abbbbbbbbbaaaaa" + /* 7 */ "abbbbbbbbbaaaaa" + /* 8 */ "aaaaaaaaaaaaaaa" + + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "...c...c......." + /* 1 */ "..............." + /* 2 */ "cddddeddddcffff" + /* 3 */ "d.........d...f" + /* 4 */ "d.........d...f" + /* 5 */ "d.........g...f" + /* 6 */ "d.........d...f" + /* 7 */ "d.........dh..f" + /* 8 */ "cdddddddddcffff" + + // Level 2 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "...c...c......." + /* 1 */ "..............." + /* 2 */ "cddddiddddc...." + /* 3 */ "d.........d...." + /* 4 */ "j.........d...." + /* 5 */ "j.........i...." + /* 6 */ "j.........d...." + /* 7 */ "d..k...k..dh..." + /* 8 */ "cdddjjjdddc...." + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "...l...l......." + /* 1 */ "...d...d......." + /* 2 */ "cdddddddddc...." + /* 3 */ "dnnnnnnnnnd...." + /* 4 */ "onnnnnnnnnd...." + /* 5 */ "onnnnnnnnnd...." + /* 6 */ "onnnnnnnnnd...." + /* 7 */ "dnnnnnnnnndh..." + /* 8 */ "cdddpppdddc...." + + // Level 4 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "dqqqqdqqqqd...." + /* 3 */ "q..cdddc..q...." + /* 4 */ "q..d...d..q...." + /* 5 */ "d.........d...." + /* 6 */ "q..d...d..q...." + /* 7 */ "q..cdddc..q...." + /* 8 */ "dqqqqdqqqqd...." + + // Level 5 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "...cdjdc......." + /* 4 */ "...dr..d......." + /* 5 */ "..............." + /* 6 */ "...d...d......." + /* 7 */ "...cdjdc......." + /* 8 */ "..............." + + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "...cdddc......." + /* 4 */ "...dnnnd......." + /* 5 */ "...dnnnd......." + /* 6 */ "...dnnnd......." + /* 7 */ "...cdddc......." + /* 8 */ "..............." + + // Level 7 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "...dqdqd......." + /* 4 */ "...q...q......." + /* 5 */ "...d...d......." + /* 6 */ "...q...q......." + /* 7 */ "...dqdqd......." + /* 8 */ "...............", + + // Connectors: + "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // MediumHouse1 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MediumHouse2: + // The data has been exported from the gallery Desert, area index 74, ID 573, created by STR_Warrior + { + // Size: + 11, 9, 9, // SizeX = 11, SizeY = 9, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 8, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "A: 96: 3\n" /* trapdoor */ + "B: 96: 6\n" /* trapdoor */ + "C:128: 2\n" /* sandstonestairs */ + "D:128: 0\n" /* sandstonestairs */ + "E: 87: 0\n" /* netherstone */ + "F:128: 1\n" /* sandstonestairs */ + "G:128: 3\n" /* sandstonestairs */ + "H: 51: 0\n" /* fire */ + "I: 44: 9\n" /* step */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 2\n" /* sandstone */ + "d: 24: 0\n" /* sandstone */ + "e: 65: 3\n" /* ladder */ + "f: 85: 0\n" /* fence */ + "g: 64: 7\n" /* wooddoorblock */ + "h:134: 1\n" /* 134 */ + "i:134: 2\n" /* 134 */ + "j: 61: 2\n" /* furnace */ + "k:134: 6\n" /* 134 */ + "l:134: 4\n" /* 134 */ + "m: 19: 0\n" /* sponge */ + "n: 65: 2\n" /* ladder */ + "o:101: 0\n" /* ironbars */ + "p: 50: 2\n" /* torch */ + "q: 47: 0\n" /* bookshelf */ + "r: 64:12\n" /* wooddoorblock */ + "s: 50: 3\n" /* torch */ + "t:171: 8\n" /* carpet */ + "u:128: 6\n" /* sandstonestairs */ + "v:126: 8\n" /* woodenslab */ + "w:128: 5\n" /* sandstonestairs */ + "x:128: 4\n" /* sandstonestairs */ + "y:128: 7\n" /* sandstonestairs */ + "z: 44: 1\n" /* step */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaaaaaaaaaa" + /* 1 */ "abbbaaaaaaa" + /* 2 */ "abbbaaaaaaa" + /* 3 */ "abbbaaaaaaa" + /* 4 */ "abbbaaaabaa" + /* 5 */ "abbbbbbbbba" + /* 6 */ "abbbbbbbbba" + /* 7 */ "abbbbbbbbba" + /* 8 */ "aaaaaaaaaaa" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "cdddc......" + /* 1 */ "de..dfff.f." + /* 2 */ "d...d....f." + /* 3 */ "d...d....f." + /* 4 */ "d...ddddgdc" + /* 5 */ "d.........d" + /* 6 */ "dhf.......d" + /* 7 */ "dhi.jkl..nd" + /* 8 */ "cdddddddddc" + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "cdodc......" + /* 1 */ "de..o......" + /* 2 */ "d...o......" + /* 3 */ "o..pd......" + /* 4 */ "o...qdodrdc" + /* 5 */ "o......s..d" + /* 6 */ "d.t.......o" + /* 7 */ "d........nd" + /* 8 */ "cdddooodddc" + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "cdudc......" + /* 1 */ "devvw......" + /* 2 */ "dvvvw......" + /* 3 */ "xvvvd......" + /* 4 */ "xvvvddudddc" + /* 5 */ "xvvvvvvvvvd" + /* 6 */ "dvvvvvvvvvw" + /* 7 */ "dvvvqqqvvnd" + /* 8 */ "cdddyyydddc" + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "dzzzd......" + /* 1 */ "zA..z......" + /* 2 */ "z...z......" + /* 3 */ "z...z......" + /* 4 */ "d...dzzzzzd" + /* 5 */ "zddd......z" + /* 6 */ "zddd......z" + /* 7 */ "zddd.....Bz" + /* 8 */ "dzzzzdzzzzd" + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ ".cCc......." + /* 6 */ ".DEF......." + /* 7 */ ".cGc......." + /* 8 */ "..........." + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ ".c.c......." + /* 6 */ "..H........" + /* 7 */ ".c.c......." + /* 8 */ "..........." + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ ".ddd......." + /* 6 */ ".dId......." + /* 7 */ ".ddd......." + /* 8 */ "..........." + + // Level 8 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ ".z.z......." + /* 6 */ "..........." + /* 7 */ ".z.z......." + /* 8 */ "...........", + + // Connectors: + "-1: 8, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // MediumHouse2 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MediumHouse3: + // The data has been exported from the gallery Desert, area index 76, ID 575, created by STR_Warrior + { + // Size: + 12, 10, 11, // SizeX = 12, SizeY = 10, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 11, 9, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 12: 0\n" /* sand */ + "b: 3: 0\n" /* dirt */ + "c: 2: 0\n" /* grass */ + "d: 5: 0\n" /* wood */ + "e: 24: 0\n" /* sandstone */ + "f: 24: 2\n" /* sandstone */ + "g: 85: 0\n" /* fence */ + "h: 64: 3\n" /* wooddoorblock */ + "i: 64: 6\n" /* wooddoorblock */ + "j: 65: 4\n" /* ladder */ + "k: 65: 2\n" /* ladder */ + "l: 50: 1\n" /* torch */ + "m: 19: 0\n" /* sponge */ + "n: 50: 2\n" /* torch */ + "o:101: 0\n" /* ironbars */ + "p: 64: 8\n" /* wooddoorblock */ + "q: 64:12\n" /* wooddoorblock */ + "r:128: 2\n" /* sandstonestairs */ + "s:128: 6\n" /* sandstonestairs */ + "t:126: 8\n" /* woodenslab */ + "u:128: 5\n" /* sandstonestairs */ + "v:128: 7\n" /* sandstonestairs */ + "w: 44: 1\n" /* step */ + "x: 96: 6\n" /* trapdoor */ + "y:126: 0\n" /* woodenslab */ + "z:128: 4\n" /* sandstonestairs */, + + // Block data: + // Level 0 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "aaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaa" + /* 2 */ "bbbbbaaaaaaa" + /* 3 */ "bbbbbaaaaaaa" + /* 4 */ "bbbbbaaaaaaa" + /* 5 */ "bbbbbaaaaaaa" + /* 6 */ "bbbaaaaaaaaa" + /* 7 */ "aaaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaaa" + /* 9 */ "aaaaaaaaaaaa" + /* 10 */ "aaaaaaaaaaaa" + + // Level 1 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "aaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaa" + /* 2 */ "cccccaaaadaa" + /* 3 */ "cccccaddddda" + /* 4 */ "cccccdddddda" + /* 5 */ "cccccaddddda" + /* 6 */ "cccaadddddda" + /* 7 */ "aaaaddddddda" + /* 8 */ "aaaadddaaaaa" + /* 9 */ "aaaadddaaaaa" + /* 10 */ "aaaaaaaaaaaa" + + // Level 2 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ ".....e.....f" + /* 1 */ "............" + /* 2 */ "gggggfeeehef" + /* 3 */ "g....e.....e" + /* 4 */ "g....i.....e" + /* 5 */ "g....e.....e" + /* 6 */ "gggfe......e" + /* 7 */ "mmme......je" + /* 8 */ "mmme...eeeef" + /* 9 */ "mmme..kemmmm" + /* 10 */ "mmmfeeefmmmm" + + // Level 3 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ ".....el...nf" + /* 1 */ "............" + /* 2 */ ".....fooepef" + /* 3 */ ".....e.....e" + /* 4 */ ".....q.....e" + /* 5 */ ".....e.....o" + /* 6 */ "...ge......e" + /* 7 */ "mmme......je" + /* 8 */ "mmme...eeoof" + /* 9 */ "mmme..kemmmm" + /* 10 */ "mmmgeeegmmmm" + + // Level 4 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ ".....r.....r" + /* 1 */ ".....e.....e" + /* 2 */ ".....fsseeef" + /* 3 */ ".....ettttte" + /* 4 */ ".....ettttte" + /* 5 */ ".....etttttu" + /* 6 */ "...getttttte" + /* 7 */ "mmmettttttje" + /* 8 */ "mmmettteevvf" + /* 9 */ "mmmettkemmmm" + /* 10 */ "mmmgeeegmmmm" + + // Level 5 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ ".....ewwewwe" + /* 3 */ ".....w.....w" + /* 4 */ ".....w.....w" + /* 5 */ ".....w.....e" + /* 6 */ "...geeeg...w" + /* 7 */ "mmme...e..xw" + /* 8 */ "mmme...ewwwe" + /* 9 */ "mmme..kemmmm" + /* 10 */ "mmmgeeegmmmm" + + // Level 6 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "............" + /* 3 */ "............" + /* 4 */ "............" + /* 5 */ "............" + /* 6 */ "...ge.eg...." + /* 7 */ "mmme...e...." + /* 8 */ "mmmo........" + /* 9 */ "mmme..kemmmm" + /* 10 */ "mmmgeoegmmmm" + + // Level 7 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "............" + /* 3 */ "............" + /* 4 */ "............" + /* 5 */ "............" + /* 6 */ "...ge.eg...." + /* 7 */ "mmme...e...." + /* 8 */ "mmmo........" + /* 9 */ "mmmel.kemmmm" + /* 10 */ "mmmgeoegmmmm" + + // Level 8 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "............" + /* 3 */ "............" + /* 4 */ "............" + /* 5 */ "............" + /* 6 */ "...fesef...." + /* 7 */ "mmmeyyye...." + /* 8 */ "mmmzyyyu...." + /* 9 */ "mmmeyykemmmm" + /* 10 */ "mmmfevefmmmm" + + // Level 9 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" + /* 1 */ "............" + /* 2 */ "............" + /* 3 */ "............" + /* 4 */ "............" + /* 5 */ "............" + /* 6 */ "...w.w.w...." + /* 7 */ "mmm........." + /* 8 */ "mmmw...w...." + /* 9 */ "mmm.....mmmm" + /* 10 */ "mmmw.w.wmmmm", + + // Connectors: + "-1: 9, 2, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // MediumHouse3 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // SmallHouse9: + // The data has been exported from the gallery Desert, area index 67, ID 556, created by STR_Warrior + { + // Size: + 9, 5, 11, // SizeX = 9, SizeY = 5, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 8, 4, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 2\n" /* sandstone */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f: 65: 2\n" /* ladder */ + "g: 64:12\n" /* wooddoorblock */ + "h:101: 0\n" /* ironbars */ + "i: 50: 2\n" /* torch */ + "j: 50: 1\n" /* torch */ + "k:128: 2\n" /* sandstonestairs */ + "l:126: 8\n" /* woodenslab */ + "m: 19: 0\n" /* sponge */ + "n:128: 5\n" /* sandstonestairs */ + "o:128: 6\n" /* sandstonestairs */ + "p:128: 4\n" /* sandstonestairs */ + "q:128: 7\n" /* sandstonestairs */ + "r: 44: 1\n" /* step */ + "s: 96: 6\n" /* trapdoor */, + + // Block data: + // Level 0 + /* z\x* 012345678 */ + /* 0 */ "aaaaaaaaa" + /* 1 */ "aaaaaaaaa" + /* 2 */ "aaaaaabaa" + /* 3 */ "aaaaabbba" + /* 4 */ "aaaaabbba" + /* 5 */ "aaaaabbba" + /* 6 */ "aaaaabbba" + /* 7 */ "abbbbbbba" + /* 8 */ "abbbbbbba" + /* 9 */ "abbbbbbba" + /* 10 */ "aaaaaaaaa" + + // Level 1 + /* z\x* 012345678 */ + /* 0 */ "mmmmc...c" + /* 1 */ "mmmm....." + /* 2 */ "mmmmcdedc" + /* 3 */ "mmmmd...d" + /* 4 */ "mmmmd...d" + /* 5 */ "mmmmd...d" + /* 6 */ "cdddd...d" + /* 7 */ "d.......d" + /* 8 */ "d.......d" + /* 9 */ "d......fd" + /* 10 */ "cdddddddc" + + // Level 2 + /* z\x* 012345678 */ + /* 0 */ "mmmmc...c" + /* 1 */ "mmmm....." + /* 2 */ "mmmmcdgdc" + /* 3 */ "mmmmd...d" + /* 4 */ "mmmmd...d" + /* 5 */ "mmmmd...h" + /* 6 */ "cdhdd...h" + /* 7 */ "d.......h" + /* 8 */ "h......id" + /* 9 */ "dj.....fd" + /* 10 */ "cddhhhddc" + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "mmmmk...k" + /* 1 */ "mmmmd...d" + /* 2 */ "mmmmcdddc" + /* 3 */ "mmmmdllld" + /* 4 */ "mmmmdllld" + /* 5 */ "mmmmdllln" + /* 6 */ "cdoddllln" + /* 7 */ "dllllllln" + /* 8 */ "pllllllld" + /* 9 */ "dllllllfd" + /* 10 */ "cddqqqddc" + + // Level 4 + /* z\x* 012345678 */ + /* 0 */ "mmmm....." + /* 1 */ "mmmm....." + /* 2 */ "mmmmcrdrd" + /* 3 */ "mmmmr...r" + /* 4 */ "mmmmr...r" + /* 5 */ "mmmmr...r" + /* 6 */ "drrrd...d" + /* 7 */ "r.......r" + /* 8 */ "r.......r" + /* 9 */ "r......sr" + /* 10 */ "drrrdrrrd", + + // Connectors: + "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // SmallHouse9 +}; // g_AlchemistVillagePrefabs + + + + + + +const cPrefab::sDef g_AlchemistVillageStartingPrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Well: + // The data has been exported from the gallery Desert, area index 90, ID 631, created by STR_Warrior + { + // Size: + 5, 21, 5, // SizeX = 5, SizeY = 21, SizeZ = 5 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 4, 20, 4, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 1: 0\n" /* stone */ + "b: 24: 0\n" /* sandstone */ + "c: 8: 0\n" /* water */ + "d: 24: 2\n" /* sandstone */ + "e:128: 1\n" /* sandstonestairs */ + "f: 44: 1\n" /* step */ + "g:128: 0\n" /* sandstonestairs */ + "h:128: 3\n" /* sandstonestairs */ + "i:128: 2\n" /* sandstonestairs */ + "j: 44: 9\n" /* step */ + "k:126: 0\n" /* woodenslab */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 01234 */ + /* 0 */ "aaaaa" + /* 1 */ "aaaaa" + /* 2 */ "aaaaa" + /* 3 */ "aaaaa" + /* 4 */ "aaaaa" + + // Level 1 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 2 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 3 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 4 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 5 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 6 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 7 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 8 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 9 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 10 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 11 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 12 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 13 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 14 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 15 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bcccb" + /* 2 */ "bcccb" + /* 3 */ "bcccb" + /* 4 */ "bbbbb" + + // Level 16 + /* z\x* 01234 */ + /* 0 */ "defgd" + /* 1 */ "h...h" + /* 2 */ "f...f" + /* 3 */ "i...i" + /* 4 */ "defgd" + + // Level 17 + /* z\x* 01234 */ + /* 0 */ "d...d" + /* 1 */ "....." + /* 2 */ "....." + /* 3 */ "....." + /* 4 */ "d...d" + + // Level 18 + /* z\x* 01234 */ + /* 0 */ "djjjd" + /* 1 */ "j...j" + /* 2 */ "j...j" + /* 3 */ "j...j" + /* 4 */ "djjjd" + + // Level 19 + /* z\x* 01234 */ + /* 0 */ "bbbbb" + /* 1 */ "bkkkb" + /* 2 */ "bkkkb" + /* 3 */ "bkkkb" + /* 4 */ "bbbbb" + + // Level 20 + /* z\x* 01234 */ + /* 0 */ "f.f.f" + /* 1 */ "....." + /* 2 */ "f...f" + /* 3 */ "....." + /* 4 */ "f.f.f", + + // Connectors: + "2: 2, 16, 4: 3\n" /* Type 2, direction Z+ */ + "2: 0, 16, 2: 4\n" /* Type 2, direction X- */ + "2: 2, 16, 0: 2\n" /* Type 2, direction Z- */ + "2: 4, 16, 2: 5\n" /* Type 2, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // Well +}; + + + + + +// The prefab counts: + +const size_t g_AlchemistVillagePrefabsCount = ARRAYCOUNT(g_AlchemistVillagePrefabs); + +const size_t g_AlchemistVillageStartingPrefabsCount = ARRAYCOUNT(g_AlchemistVillageStartingPrefabs); + diff --git a/src/Generating/Prefabs/AlchemistVillagePrefabs.h b/src/Generating/Prefabs/AlchemistVillagePrefabs.h new file mode 100644 index 000000000..dddc5530a --- /dev/null +++ b/src/Generating/Prefabs/AlchemistVillagePrefabs.h @@ -0,0 +1,15 @@ + +// AlchemistVillagePrefabs.h + +// Declares the prefabs in the group AlchemistVillage + +#include "../Prefab.h" + + + + + +extern const cPrefab::sDef g_AlchemistVillagePrefabs[]; +extern const cPrefab::sDef g_AlchemistVillageStartingPrefabs[]; +extern const size_t g_AlchemistVillagePrefabsCount; +extern const size_t g_AlchemistVillageStartingPrefabsCount; diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index cb1f4fe0d..dfcdf6ef7 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -5,6 +5,7 @@ #include "Globals.h" #include "VillageGen.h" +#include "Prefabs/AlchemistVillagePrefabs.h" #include "Prefabs/JapaneseVillagePrefabs.h" #include "Prefabs/PlainsVillagePrefabs.h" #include "Prefabs/SandVillagePrefabs.h" @@ -274,6 +275,12 @@ protected: } + virtual int GetStartingPieceWeight(const cPiece & a_NewPiece) override + { + return m_Prefabs.GetStartingPieceWeight(a_NewPiece); + } + + virtual void PiecePlaced(const cPiece & a_Piece) override { m_Prefabs.PiecePlaced(a_Piece); @@ -311,18 +318,25 @@ protected: /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cVillageGen: -/** The prefabs for the sand village. */ static cVillagePiecePool g_SandVillage(g_SandVillagePrefabs, g_SandVillagePrefabsCount, g_SandVillageStartingPrefabs, g_SandVillageStartingPrefabsCount); - -/** The prefabs for the flat-roofed sand village. */ static cVillagePiecePool g_SandFlatRoofVillage(g_SandFlatRoofVillagePrefabs, g_SandFlatRoofVillagePrefabsCount, g_SandFlatRoofVillageStartingPrefabs, g_SandFlatRoofVillageStartingPrefabsCount); - -/** The prefabs for the plains village. */ +static cVillagePiecePool g_AlchemistVillage(g_AlchemistVillagePrefabs, g_AlchemistVillagePrefabsCount, g_AlchemistVillageStartingPrefabs, g_AlchemistVillageStartingPrefabsCount); static cVillagePiecePool g_PlainsVillage(g_PlainsVillagePrefabs, g_PlainsVillagePrefabsCount, g_PlainsVillageStartingPrefabs, g_PlainsVillageStartingPrefabsCount); - -/** The prefabs for the Japanese village. */ static cVillagePiecePool g_JapaneseVillage(g_JapaneseVillagePrefabs, g_JapaneseVillagePrefabsCount, g_JapaneseVillageStartingPrefabs, g_JapaneseVillageStartingPrefabsCount); +static cVillagePiecePool * g_DesertVillagePools[] = +{ + &g_SandVillage, + &g_SandFlatRoofVillage, + &g_AlchemistVillage, +} ; + +static cVillagePiecePool * g_PlainsVillagePools[] = +{ + &g_PlainsVillage, + &g_JapaneseVillage, +} ; + @@ -356,8 +370,8 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ cVillagePiecePool * VillagePrefabs = NULL; BLOCKTYPE RoadBlock = E_BLOCK_GRAVEL; int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 11; - cVillagePiecePool * PlainsVillage = (rnd % 2 == 0) ? &g_PlainsVillage : &g_JapaneseVillage; - cVillagePiecePool * DesertVillage = (rnd % 2 == 0) ? &g_SandVillage : &g_SandFlatRoofVillage; + cVillagePiecePool * PlainsVillage = g_PlainsVillagePools[rnd % ARRAYCOUNT(g_PlainsVillagePools)]; + cVillagePiecePool * DesertVillage = g_DesertVillagePools[rnd % ARRAYCOUNT(g_DesertVillagePools)]; for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++) { switch (Biomes[i]) -- cgit v1.2.3 From e5fd782524cdf4b838ad689baef44a61aa4933c2 Mon Sep 17 00:00:00 2001 From: Joannis Date: Wed, 28 May 2014 09:10:09 +0200 Subject: - Implemented vertical dispensing for projectiles. - Fixed some terrible commit issues on my side. --- src/BlockEntities/DispenserEntity.cpp | 54 +++++++++++++++++++++++++---------- src/BlockEntities/DispenserEntity.h | 2 +- 2 files changed, 40 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 0f64118ef..638a844e6 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -147,6 +147,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_FIRE_CHARGE: { SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFireCharge); + m_Contents.ChangeSlotCount(a_SlotNum, -1); break; } @@ -154,6 +155,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_ARROW: { SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkArrow); + m_Contents.ChangeSlotCount(a_SlotNum, -1); break; } @@ -162,6 +164,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) { // Not working as there is no such entity yet? SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkSnowball); + m_Contents.ChangeSlotCount(a_SlotNum, -1); break; } @@ -170,6 +173,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) { // Not working as there is no such entity yet? SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkEgg); + m_Contents.ChangeSlotCount(a_SlotNum, -1); break; } @@ -177,6 +181,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_FIREWORK_ROCKET: { SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFirework); + m_Contents.ChangeSlotCount(a_SlotNum, -1); break; } @@ -199,7 +204,7 @@ void cDispenserEntity::SpawnProjectileFromDispenser(cChunk & a_Chunk, int & Disp double EntityX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width); double EntityZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - m_World->CreateProjectile((double) EntityX, (double) DispY, (double) EntityZ, cProjectileEntity::pkArrow, NULL, NULL, & Speed); + m_World->CreateProjectile((double) EntityX, (double) DispY + 0.5, (double) EntityZ, cProjectileEntity::pkArrow, NULL, NULL, &Speed); } @@ -210,22 +215,45 @@ Vector3d cDispenserEntity::GetProjectileLookVector(cChunk & a_Chunk) int Direction = 0; switch (Meta) { - case E_META_DROPSPENSER_FACING_YP: Direction = 0; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block) - case E_META_DROPSPENSER_FACING_YM: Direction = 0; break; - case E_META_DROPSPENSER_FACING_XM: Direction = 90; break; // WEST - case E_META_DROPSPENSER_FACING_XP: Direction = 270; break; // EAST + case E_META_DROPSPENSER_FACING_YP: Direction = -1; break; // UP + case E_META_DROPSPENSER_FACING_YM: Direction = -2; break; // DOWN + case E_META_DROPSPENSER_FACING_XM: Direction = 90; break; // WEST + case E_META_DROPSPENSER_FACING_XP: Direction = 270; break; // EAST case E_META_DROPSPENSER_FACING_ZM: Direction = 180; break; case E_META_DROPSPENSER_FACING_ZP: Direction = 0; break; } - Matrix4d m; - m.Init(Vector3d(), 0, Direction, 0); - Vector3d Look = m.Transform(Vector3d(0, 0, 1)); + if(Direction >= 0) + { + Matrix4d m; + m.Init(Vector3d(), 0, Direction, 0); + Vector3d Look = m.Transform(Vector3d(0, 0, 1)); + + Vector3d Speed = Look * 20; + Speed.y = Speed.y + 1; + + return Speed; + + } else if(Direction == -1) + { + Matrix4d m; + m.Init(Vector3d(), 0, 180, 0); + Vector3d Look = m.Transform(Vector3d(0, 1, 0)); + + Vector3d Speed = Look * 20; + + return Speed; - Vector3d Speed = Look * 20; - Speed.y = Speed.y + 1; + } else { - return Speed; + Matrix4d m; + m.Init(Vector3d(), 0, -360, 0); + Vector3d Look = m.Transform(Vector3d(0, -1, 0)); + + Vector3d Speed = Look * 20; + + return Speed; + } } @@ -291,7 +319,3 @@ bool cDispenserEntity::EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum m_Contents.AddItem(EmptyBucket); return true; } - - - - diff --git a/src/BlockEntities/DispenserEntity.h b/src/BlockEntities/DispenserEntity.h index 8bc2475c9..0b7cd6bea 100644 --- a/src/BlockEntities/DispenserEntity.h +++ b/src/BlockEntities/DispenserEntity.h @@ -30,7 +30,7 @@ private: bool ScoopUpLiquid(int a_SlotNum, short a_BucketItemType); // Spawns a projectile of the given kind in front of the dispenser - void SpawnProjectileFromDispenser(cChunk& a_Chunk, int& DispX, int& DispY, int& DispZ, cProjectileEntity::eKind kind); + void SpawnProjectileFromDispenser(cChunk & a_Chunk, int & DispX, int & DispY, int & DispZ, cProjectileEntity::eKind kind); // Returns how to aim the projectile Vector3d GetProjectileLookVector(cChunk & a_Chunk); -- cgit v1.2.3 From 4bc02781af063456db438885d7f3cc8830d5cd92 Mon Sep 17 00:00:00 2001 From: JoannisO Date: Wed, 28 May 2014 14:34:33 +0200 Subject: - Fixed an issue where dispensers would only shoot arrows (appearantly some commits didn't come through) - Cleaned up the code according to suggestions. --- src/BlockEntities/DispenserEntity.cpp | 57 +++++++++++++++-------------------- 1 file changed, 24 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 638a844e6..2b0487c4a 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -198,13 +198,13 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) void cDispenserEntity::SpawnProjectileFromDispenser(cChunk & a_Chunk, int & DispX, int & DispY, int & DispZ, cProjectileEntity::eKind kind) { - Vector3d Speed = GetProjectileLookVector(a_Chunk); + Vector3d Angle = GetProjectileLookVector(a_Chunk); cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ); double EntityX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width); double EntityZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - m_World->CreateProjectile((double) EntityX, (double) DispY + 0.5, (double) EntityZ, cProjectileEntity::pkArrow, NULL, NULL, &Speed); + m_World->CreateProjectile((double) EntityX, (double) DispY + 0.5, (double) EntityZ, kind, NULL, NULL, &Angle); } @@ -213,47 +213,38 @@ Vector3d cDispenserEntity::GetProjectileLookVector(cChunk & a_Chunk) { NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ); int Direction = 0; + Matrix4d m; + Vector3d Look; + switch (Meta) { - case E_META_DROPSPENSER_FACING_YP: Direction = -1; break; // UP - case E_META_DROPSPENSER_FACING_YM: Direction = -2; break; // DOWN + case E_META_DROPSPENSER_FACING_YP: + m.Init(Vector3d(), 0, 180, 0); + Look = m.Transform(Vector3d(0, 1, 0)); + + return Look * 20; // UP + break; + + case E_META_DROPSPENSER_FACING_YM: + m.Init(Vector3d(), 0, -360, 0); + Look = m.Transform(Vector3d(0, -1, 0)); + + return Look * 20;; // DOWN + break; + case E_META_DROPSPENSER_FACING_XM: Direction = 90; break; // WEST case E_META_DROPSPENSER_FACING_XP: Direction = 270; break; // EAST case E_META_DROPSPENSER_FACING_ZM: Direction = 180; break; case E_META_DROPSPENSER_FACING_ZP: Direction = 0; break; } - if(Direction >= 0) - { - Matrix4d m; - m.Init(Vector3d(), 0, Direction, 0); - Vector3d Look = m.Transform(Vector3d(0, 0, 1)); - - Vector3d Speed = Look * 20; - Speed.y = Speed.y + 1; + m.Init(Vector3d(), 0, Direction, 0); + Look = m.Transform(Vector3d(0, 0, 1)); - return Speed; + Vector3d Angle = Look * 20; + Angle.y = Angle.y + 1; - } else if(Direction == -1) - { - Matrix4d m; - m.Init(Vector3d(), 0, 180, 0); - Vector3d Look = m.Transform(Vector3d(0, 1, 0)); - - Vector3d Speed = Look * 20; - - return Speed; - - } else { - - Matrix4d m; - m.Init(Vector3d(), 0, -360, 0); - Vector3d Look = m.Transform(Vector3d(0, -1, 0)); - - Vector3d Speed = Look * 20; - - return Speed; - } + return Angle; } -- cgit v1.2.3 From 427bddc18970bb66aa1f396c4fd19e52e3ad602d Mon Sep 17 00:00:00 2001 From: JoannisO Date: Wed, 28 May 2014 15:16:45 +0200 Subject: - Removed breaks. I thought it wouldn't compile without them but the issue was appearantly solved with an earlier commit. --- src/BlockEntities/DispenserEntity.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 2b0487c4a..341994be8 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -223,14 +223,12 @@ Vector3d cDispenserEntity::GetProjectileLookVector(cChunk & a_Chunk) Look = m.Transform(Vector3d(0, 1, 0)); return Look * 20; // UP - break; case E_META_DROPSPENSER_FACING_YM: m.Init(Vector3d(), 0, -360, 0); Look = m.Transform(Vector3d(0, -1, 0)); return Look * 20;; // DOWN - break; case E_META_DROPSPENSER_FACING_XM: Direction = 90; break; // WEST case E_META_DROPSPENSER_FACING_XP: Direction = 270; break; // EAST -- cgit v1.2.3 From d8072da61f8a098ea30f579034ad976cf86408f3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 15:54:43 +0200 Subject: Fix skull bugs. --- src/BlockEntities/MobHeadEntity.cpp | 5 +++++ src/Blocks/BlockMobHead.h | 43 +++++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/MobHeadEntity.cpp b/src/BlockEntities/MobHeadEntity.cpp index dc9c18d58..60d6a123f 100644 --- a/src/BlockEntities/MobHeadEntity.cpp +++ b/src/BlockEntities/MobHeadEntity.cpp @@ -70,6 +70,11 @@ void cMobHeadEntity::SetOwner(const AString & a_Owner) void cMobHeadEntity::SendTo(cClientHandle & a_Client) { + BLOCKTYPE Block; + NIBBLETYPE Meta; + a_Client.GetPlayer()->GetWorld()->GetBlockTypeMeta(m_PosX, m_PosY, m_PosZ, Block, Meta); + + a_Client.SendBlockChange(m_PosX, m_PosY, m_PosZ, Block, Meta); a_Client.SendUpdateBlockEntity(*this); } diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index b7629b07c..248f20d49 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -19,7 +19,46 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.push_back(cItem(E_ITEM_HEAD, 1, 0)); + // The drops spawns in OnDestroyed + } + + virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override + { + if (a_Player->IsGameModeCreative()) + { + // No drops in creative mode + return; + } + + class cCallback : public cMobHeadCallback + { + virtual bool Item(cMobHeadEntity * a_MobHeadEntity) + { + cItems Pickups; + Pickups.Add(E_ITEM_HEAD, 1, (short) a_MobHeadEntity->GetType()); + MTRand r1; + + // Mid-block position first + double MicroX, MicroY, MicroZ; + MicroX = a_MobHeadEntity->GetPosX() + 0.5; + MicroY = a_MobHeadEntity->GetPosY() + 0.5; + MicroZ = a_MobHeadEntity->GetPosZ() + 0.5; + + // Add random offset second + MicroX += r1.rand(1) - 0.5; + MicroZ += r1.rand(1) - 0.5; + + a_MobHeadEntity->GetWorld()->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ); + return false; + } + + public: + cCallback() {} + }; + cCallback Callback; + + cWorld * World = (cWorld *) &a_WorldInterface; + World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, Callback); } bool TrySpawnWither(cChunkInterface & a_ChunkInterface, cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) @@ -170,7 +209,7 @@ public: a_MobHeadEntity->SetType(static_cast(m_OldBlockMeta)); a_MobHeadEntity->SetRotation(static_cast(Rotation)); - a_MobHeadEntity->GetWorld()->BroadcastBlockEntity(a_MobHeadEntity->GetPosX(), a_MobHeadEntity->GetPosY(), a_MobHeadEntity->GetPosZ(), m_Player->GetClientHandle()); + a_MobHeadEntity->GetWorld()->BroadcastBlockEntity(a_MobHeadEntity->GetPosX(), a_MobHeadEntity->GetPosY(), a_MobHeadEntity->GetPosZ()); return false; } -- cgit v1.2.3 From 61b6fdde7553dac6e2d5c5a071b9a13fa0d71b2f Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 16:07:51 +0200 Subject: Fix right click bugs. --- src/ClientHandle.cpp | 81 ++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 9b03bead9..ce7ce0cea 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1088,32 +1088,51 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e ); cWorld * World = m_Player->GetWorld(); + m_NumBlockChangeInteractionsThisTick++; - if ( - (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || - (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || - (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) - ) + if (!CheckBlockInteractionsRate()) { + Kick("Too many blocks were placed/interacted with per unit time - hacked client?"); + return; + } + + const cItem & Equipped = m_Player->GetInventory().GetEquippedItem(); + if ((Equipped.m_ItemType != a_HeldItem.m_ItemType) && (a_HeldItem.m_ItemType != -1)) + { + // Only compare ItemType, not meta (torches have different metas) + // The -1 check is there because sometimes the client sends -1 instead of the held item + // ( http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 ) + LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)", + m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType + ); + + // Let's send the current world block to the client, so that it can immediately "let the user know" that they haven't placed the block if (a_BlockFace != BLOCK_FACE_NONE) { AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things - m_Player->GetInventory().SendEquippedSlot(); } return; } - cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); - if (PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) + BLOCKTYPE BlockType; + NIBBLETYPE BlockMeta; + World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); + cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); + cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType); + + if ( + ( + BlockHandler->IsUseable() || + (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE)) + ) && + ( + (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || + (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || + (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) + ) + ) { - // A plugin doesn't agree with the action, replace the block on the client and quit: - cChunkInterface ChunkInterface(World->GetChunkMap()); - BLOCKTYPE BlockType = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); - cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); - BlockHandler->OnCancelRightClick(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - if (a_BlockFace != BLOCK_FACE_NONE) { AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); @@ -1124,38 +1143,22 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e return; } - m_NumBlockChangeInteractionsThisTick++; - - if (!CheckBlockInteractionsRate()) - { - Kick("Too many blocks were placed/interacted with per unit time - hacked client?"); - return; - } - - const cItem & Equipped = m_Player->GetInventory().GetEquippedItem(); - - if ((Equipped.m_ItemType != a_HeldItem.m_ItemType) && (a_HeldItem.m_ItemType != -1)) + cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); + if (PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) { - // Only compare ItemType, not meta (torches have different metas) - // The -1 check is there because sometimes the client sends -1 instead of the held item - // ( http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 ) - LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)", - m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType - ); + // A plugin doesn't agree with the action, replace the block on the client and quit: + cChunkInterface ChunkInterface(World->GetChunkMap()); + BlockHandler->OnCancelRightClick(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - // Let's send the current world block to the client, so that it can immediately "let the user know" that they haven't placed the block if (a_BlockFace != BLOCK_FACE_NONE) { AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things + m_Player->GetInventory().SendEquippedSlot(); } return; } - - BLOCKTYPE BlockType; - NIBBLETYPE BlockMeta; - World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); - cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); if (BlockHandler->IsUseable() && !m_Player->IsCrouched()) { @@ -1170,8 +1173,6 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e return; } - cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType); - if (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE)) { HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); -- cgit v1.2.3 From d4f90259b8cd3e5d90dd419930c8635105ea4d0f Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 16:12:10 +0200 Subject: Fix Y-Position from arrow entity. --- src/Entities/ArrowEntity.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 8d2569125..fbc535e63 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -19,6 +19,7 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a m_bIsCollected(false), m_HitBlockPos(Vector3i(0, 0, 0)) { + SetPosY(GetPosY() + a_Creator->GetHeight() - 0.1000000014901161); SetSpeed(a_Speed); SetMass(0.1); SetYawFromSpeed(); -- cgit v1.2.3 From d29b242674fbf89035c8908753496522edf8eaee Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 28 May 2014 16:33:10 +0200 Subject: Fixed a memory leak in cPrefabPiecePool. The pool pieces weren't freed upon pool destruction. --- src/Generating/PrefabPiecePool.cpp | 28 ++++++++++++++++++++++++++++ src/Generating/PrefabPiecePool.h | 7 ++++++- 2 files changed, 34 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/PrefabPiecePool.cpp b/src/Generating/PrefabPiecePool.cpp index ed9340815..145474bcc 100644 --- a/src/Generating/PrefabPiecePool.cpp +++ b/src/Generating/PrefabPiecePool.cpp @@ -26,6 +26,34 @@ cPrefabPiecePool::cPrefabPiecePool( +cPrefabPiecePool::~cPrefabPiecePool() +{ + Clear(); +} + + + + + +void cPrefabPiecePool::Clear(void) +{ + m_PiecesByConnector.clear(); + for (cPieces::iterator itr = m_AllPieces.begin(), end = m_AllPieces.end(); itr != end; ++itr) + { + delete *itr; + } + m_AllPieces.clear(); + for (cPieces::iterator itr = m_StartingPieces.begin(), end = m_StartingPieces.end(); itr != end; ++itr) + { + delete *itr; + } + m_StartingPieces.clear(); +} + + + + + void cPrefabPiecePool::AddPieceDefs(const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs) { ASSERT(a_PieceDefs != NULL); diff --git a/src/Generating/PrefabPiecePool.h b/src/Generating/PrefabPiecePool.h index c6a5ad360..50ae63c0c 100644 --- a/src/Generating/PrefabPiecePool.h +++ b/src/Generating/PrefabPiecePool.h @@ -34,6 +34,12 @@ public: const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs ); + /** Destroys the pool, freeing all pieces. */ + ~cPrefabPiecePool(); + + /** Removes and frees all pieces from this pool. */ + void Clear(void); + /** Adds pieces from the specified definitions into m_AllPieces. Also adds the pieces into the m_PiecesByConnector map. May be called multiple times with different PieceDefs, will add all such pieces. */ @@ -44,7 +50,6 @@ public: May be called multiple times with different PieceDefs, will add all such pieces. */ void AddStartingPieceDefs(const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs); - protected: /** The type used to map a connector type to the list of pieces with that connector */ -- cgit v1.2.3 From 7ec44951a0841734be53e81088dcdbc79a104d02 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 28 May 2014 11:35:55 +0200 Subject: Fixed cChunkData formatting. --- src/ChunkData.cpp | 118 +++++++++++++++++++++++++++++++++++++++++------------- src/ChunkData.h | 22 +++++----- 2 files changed, 101 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index c41dcb265..8aed62000 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -5,64 +5,86 @@ cChunkData::cChunkData() #if __cplusplus < 201103L // auto_ptr style interface for memory management - : IsOwner(true) + : m_IsOwner(true) #endif { - memset(m_Sections, 0, sizeof(m_Sections)); + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + { + m_Sections[i] = NULL; + } } + + + cChunkData::~cChunkData() { #if __cplusplus < 201103L // auto_ptr style interface for memory management - if (!IsOwner) + if (!m_IsOwner) { return; } #endif for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { - if (m_Sections[i] == NULL) Free(m_Sections[i]);; + Free(m_Sections[i]); } } + + + + #if __cplusplus < 201103L // auto_ptr style interface for memory management - cChunkData::cChunkData(const cChunkData& other) : - IsOwner(true) + cChunkData::cChunkData(const cChunkData & a_Other) : + m_IsOwner(true) { + // Move contents and ownership from a_Other to this, pointer-wise: for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { - m_Sections[i] = other.m_Sections[i]; + m_Sections[i] = a_Other.m_Sections[i]; } - other.IsOwner = false; + a_Other.m_IsOwner = false; } - cChunkData& cChunkData::operator=(const cChunkData& other) + + + + + cChunkData & cChunkData::operator =(const cChunkData & a_Other) { - if (&other != this) + // If assigning to self, no-op + if (&a_Other == this) + { + return *this; + } + + // Free any currently held contents: + if (m_IsOwner) { - if (IsOwner) - { - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) - { - if (m_Sections[i]) Free(m_Sections[i]);; - } - } - IsOwner = true; for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { - m_Sections[i] = other.m_Sections[i]; + Free(m_Sections[i]); } - other.IsOwner = false; } + + // Move contents and ownership from a_Other to this, pointer-wise: + m_IsOwner = true; + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + { + m_Sections[i] = a_Other.m_Sections[i]; + } + a_Other.m_IsOwner = false; return *this; - } + #else + // unique_ptr style interface for memory management - cChunkData::cChunkData(cChunkData&& other) + cChunkData::cChunkData(cChunkData && other) { for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { @@ -70,14 +92,18 @@ cChunkData::~cChunkData() other.m_Sections[i] = NULL; } } + + + + - cChunkData& cChunkData::operator=(cChunkData&& other) + cChunkData & cChunkData::operator =(cChunkData && other) { if (&other != this) { for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { - Free(m_Sections[i]);; + Free(m_Sections[i]); m_Sections[i] = other.m_Sections[i]; other.m_Sections[i] = NULL; } @@ -86,6 +112,10 @@ cChunkData::~cChunkData() } #endif + + + + BLOCKTYPE cChunkData::GetBlock(int a_X, int a_Y, int a_Z) const { ASSERT((a_X >= 0) && (a_X < cChunkDef::Width)); @@ -103,6 +133,10 @@ BLOCKTYPE cChunkData::GetBlock(int a_X, int a_Y, int a_Z) const } } + + + + void cChunkData::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block) { if ( @@ -134,6 +168,10 @@ void cChunkData::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block) m_Sections[Section]->m_BlockTypes[Index] = a_Block; } + + + + NIBBLETYPE cChunkData::GetMeta(int a_RelX, int a_RelY, int a_RelZ) const { if ( @@ -156,6 +194,10 @@ NIBBLETYPE cChunkData::GetMeta(int a_RelX, int a_RelY, int a_RelZ) const return 0; } + + + + bool cChunkData::SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble) { if ( @@ -192,9 +234,17 @@ bool cChunkData::SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble return oldval == a_Nibble; } + + + + NIBBLETYPE cChunkData::GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const { - if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) + if ( + (a_RelX < cChunkDef::Width) && (a_RelX > -1) && + (a_RelY < cChunkDef::Height) && (a_RelY > -1) && + (a_RelZ < cChunkDef::Width) && (a_RelZ > -1) + ) { int Section = a_RelY / CHUNK_SECTION_HEIGHT; if (m_Sections[Section] != NULL) @@ -211,6 +261,10 @@ NIBBLETYPE cChunkData::GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const return 0; } + + + + NIBBLETYPE cChunkData::GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const { if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) @@ -230,7 +284,11 @@ NIBBLETYPE cChunkData::GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const return 0; } -cChunkData cChunkData::Copy() const + + + + +cChunkData cChunkData::Copy(void) const { cChunkData copy; for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) @@ -248,11 +306,11 @@ cChunkData cChunkData::Copy() const -void cChunkData::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length) const +void cChunkData::CopyBlocks(BLOCKTYPE * a_dest, size_t a_Idx, size_t length) const { for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; + const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; if (a_Idx > 0) { a_Idx = std::max(a_Idx - length, (size_t) 0); @@ -588,6 +646,8 @@ cChunkData::sChunkSection * cChunkData::Allocate() const + + void cChunkData::Free(cChunkData::sChunkSection * ptr) const { delete ptr; @@ -595,6 +655,8 @@ void cChunkData::Free(cChunkData::sChunkSection * ptr) const + + void cChunkData::ZeroSection(cChunkData::sChunkSection * ptr) const { memset( diff --git a/src/ChunkData.h b/src/ChunkData.h index 16fcc4d37..6544b246e 100644 --- a/src/ChunkData.h +++ b/src/ChunkData.h @@ -25,12 +25,12 @@ public: #if __cplusplus < 201103L // auto_ptr style interface for memory management - cChunkData(const cChunkData& other); - cChunkData& operator=(const cChunkData& other); + cChunkData(const cChunkData & other); + cChunkData & operator =(const cChunkData & other); #else // unique_ptr style interface for memory management - cChunkData(cChunkData&& other); - cChunkData& operator=(cChunkData&& other); + cChunkData(cChunkData && other); + cChunkData & operator =(cChunkData && other); #endif BLOCKTYPE GetBlock(int a_X, int a_Y, int a_Z) const; @@ -43,15 +43,15 @@ public: NIBBLETYPE GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const; - cChunkData Copy() const; + cChunkData Copy(void) const; void CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx = 0, size_t length = cChunkDef::NumBlocks) const; void CopyMeta (NIBBLETYPE * a_dest) const; - void CopyBlockLight (NIBBLETYPE * a_dest) const; + void CopyBlockLight(NIBBLETYPE * a_dest) const; void CopySkyLight (NIBBLETYPE * a_dest) const; void SetBlocks (const BLOCKTYPE * a_src); void SetMeta (const NIBBLETYPE * a_src); - void SetBlockLight (const NIBBLETYPE * a_src); + void SetBlockLight(const NIBBLETYPE * a_src); void SetSkyLight (const NIBBLETYPE * a_src); private: @@ -61,19 +61,19 @@ private: #if __cplusplus < 201103L // auto_ptr style interface for memory management - mutable bool IsOwner; + mutable bool m_IsOwner; #endif struct sChunkSection { - BLOCKTYPE m_BlockTypes [CHUNK_SECTION_HEIGHT * 16 * 16] ; + BLOCKTYPE m_BlockTypes [CHUNK_SECTION_HEIGHT * 16 * 16]; NIBBLETYPE m_BlockMeta [CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; NIBBLETYPE m_BlockLight [CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; NIBBLETYPE m_BlockSkyLight[CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; }; - sChunkSection *m_Sections[CHUNK_SECTION_COUNT]; + sChunkSection * m_Sections[CHUNK_SECTION_COUNT]; - sChunkSection * Allocate() const; + sChunkSection * Allocate(void) const; void Free(sChunkSection * ptr) const; void ZeroSection(sChunkSection * ptr) const; -- cgit v1.2.3 From e7a7c45c3681e90cb9ab13d16935aae9860f1077 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 16:39:59 +0200 Subject: Add throw sound and fix arrow server crash. --- src/Entities/ArrowEntity.cpp | 5 ++++- src/Entities/ThrownSnowballEntity.cpp | 4 ---- src/Items/ItemThrowable.h | 11 +++++++++++ src/WorldStorage/NBTChunkSerializer.cpp | 1 + 4 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index fbc535e63..769750bd4 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -19,7 +19,10 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a m_bIsCollected(false), m_HitBlockPos(Vector3i(0, 0, 0)) { - SetPosY(GetPosY() + a_Creator->GetHeight() - 0.1000000014901161); + if (a_Creator != NULL) + { + SetPosY(GetPosY() + a_Creator->GetHeight() - 0.1000000014901161); + } SetSpeed(a_Speed); SetMass(0.1); SetYawFromSpeed(); diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp index 427f630f7..cefc3433c 100644 --- a/src/Entities/ThrownSnowballEntity.cpp +++ b/src/Entities/ThrownSnowballEntity.cpp @@ -36,10 +36,6 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & { TotalDamage = 3; } - else if (MobType == cMonster::mtEnderDragon) - { - TotalDamage = 1; - } } // TODO: If entity is Ender Crystal, destroy it a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h index 35c2b8731..25935a1bc 100644 --- a/src/Items/ItemThrowable.h +++ b/src/Items/ItemThrowable.h @@ -31,6 +31,17 @@ public: Vector3d Pos = a_Player->GetThrowStartPos(); Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff; + // Play sound + cFastRandom Random; + a_World->BroadcastSoundEffect( + "random.bow", + (int)std::floor(a_Player->GetPosX() * 8.0), + (int)std::floor((a_Player->GetPosY() - a_Player->GetHeight()) * 8.0), + (int)std::floor(a_Player->GetPosZ() * 8.0), + 0.5F, + 0.4F / (Random.NextFloat(1.0F) * 0.4F + 0.8F) + ); + if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, a_Player->GetEquippedItem(), &Speed) < 0) { return false; diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 7b7cd3c7e..cc1ffe8f9 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -608,6 +608,7 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) case cProjectileEntity::pkGhastFireball: { m_Writer.AddInt("ExplosionPower", 1); + break; // fall-through: } case cProjectileEntity::pkFireCharge: -- cgit v1.2.3 From 421588d25dd4e2e293d48daece27444bfbc318bf Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 16:59:51 +0200 Subject: Fix fire break. --- src/Blocks/BlockFire.h | 4 ++-- src/ClientHandle.cpp | 33 +++++++++++++++++---------------- 2 files changed, 19 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockFire.h b/src/Blocks/BlockFire.h index f9f32eb50..147e4b53e 100644 --- a/src/Blocks/BlockFire.h +++ b/src/Blocks/BlockFire.h @@ -36,8 +36,8 @@ public: - Loop through boundary variables, and fill with portal blocks based on Dir with meta from Dir */ - a_BlockY--; // Because we want the block below the fire - FindAndSetPortalFrame(a_BlockX, a_BlockY, a_BlockZ, a_ChunkInterface, a_WorldInterface); + // a_BlockY - 1: Because we want the block below the fire + FindAndSetPortalFrame(a_BlockX, a_BlockY - 1, a_BlockZ, a_ChunkInterface, a_WorldInterface); } virtual void OnDigging(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index ce7ce0cea..9a7d1cd62 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -954,6 +954,23 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc m_LastDigBlockY = a_BlockY; m_LastDigBlockZ = a_BlockZ; + if (a_BlockFace != BLOCK_FACE_NONE) + { + int pX = a_BlockX; + int pY = a_BlockY; + int pZ = a_BlockZ; + + AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false) + cBlockHandler * Handler = cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(pX, pY, pZ)); + + if (Handler->IsClickedThrough()) + { + cChunkInterface ChunkInterface(m_Player->GetWorld()->GetChunkMap()); + Handler->OnDigging(ChunkInterface, *m_Player->GetWorld(), m_Player, pX, pY, pZ); + return; + } + } + if ( (m_Player->IsGameModeCreative()) || // In creative mode, digging is done immediately cBlockInfo::IsOneHitDig(a_OldBlock) // One-hit blocks get destroyed immediately, too @@ -980,22 +997,6 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem()); ItemHandler->OnDiggingBlock(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - - // Check for clickthrough-blocks: - if (a_BlockFace != BLOCK_FACE_NONE) - { - int pX = a_BlockX; - int pY = a_BlockY; - int pZ = a_BlockZ; - - AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false) - Handler = cBlockInfo::GetHandler(World->GetBlock(pX, pY, pZ)); - - if (Handler->IsClickedThrough()) - { - Handler->OnDigging(ChunkInterface, *World, m_Player, pX, pY, pZ); - } - } } -- cgit v1.2.3 From 9f645b2c75aa8dbfbab439e4afdf17a321072a88 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 17:05:13 +0200 Subject: Fix hay place sound. --- src/Blocks/BlockHandler.cpp | 3 ++- src/Blocks/BlockHayBale.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/Blocks/BlockHayBale.h (limited to 'src') diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 304e35e84..bae396ea8 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -38,6 +38,7 @@ #include "BlockGlass.h" #include "BlockGlowstone.h" #include "BlockGravel.h" +#include "BlockHayBale.h" #include "BlockMobHead.h" #include "BlockHopper.h" #include "BlockIce.h" @@ -132,7 +133,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_GLASS: return new cBlockGlassHandler (a_BlockType); case E_BLOCK_GRASS: return new cBlockDirtHandler (a_BlockType); case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType); - case E_BLOCK_HAY_BALE: return new cBlockSidewaysHandler (a_BlockType); + case E_BLOCK_HAY_BALE: return new cBlockHayBaleHandler (a_BlockType); case E_BLOCK_HEAD: return new cBlockMobHeadHandler (a_BlockType); case E_BLOCK_HOPPER: return new cBlockHopperHandler (a_BlockType); case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType); diff --git a/src/Blocks/BlockHayBale.h b/src/Blocks/BlockHayBale.h new file mode 100644 index 000000000..5b646e264 --- /dev/null +++ b/src/Blocks/BlockHayBale.h @@ -0,0 +1,29 @@ + +#pragma once + +#include "BlockHandler.h" +#include "BlockSideways.h" + + + + + +class cBlockHayBaleHandler : + public cBlockSidewaysHandler +{ +public: + cBlockHayBaleHandler(BLOCKTYPE a_BlockType) + : cBlockSidewaysHandler(a_BlockType) + { + } + + + virtual const char * GetStepSound(void) override + { + return "step.grass"; + } +} ; + + + + -- cgit v1.2.3 From 142fa83124fc3b766916ac79fb037fea91a19a1e Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 28 May 2014 19:32:20 +0200 Subject: Code improvements --- src/BlockEntities/MobHeadEntity.cpp | 7 ++----- src/Blocks/BlockMobHead.h | 8 ++------ src/WorldStorage/NBTChunkSerializer.cpp | 1 - 3 files changed, 4 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/MobHeadEntity.cpp b/src/BlockEntities/MobHeadEntity.cpp index 60d6a123f..ce895eb6f 100644 --- a/src/BlockEntities/MobHeadEntity.cpp +++ b/src/BlockEntities/MobHeadEntity.cpp @@ -70,11 +70,8 @@ void cMobHeadEntity::SetOwner(const AString & a_Owner) void cMobHeadEntity::SendTo(cClientHandle & a_Client) { - BLOCKTYPE Block; - NIBBLETYPE Meta; - a_Client.GetPlayer()->GetWorld()->GetBlockTypeMeta(m_PosX, m_PosY, m_PosZ, Block, Meta); - - a_Client.SendBlockChange(m_PosX, m_PosY, m_PosZ, Block, Meta); + cWorld * World = a_Client.GetPlayer()->GetWorld(); + a_Client.SendBlockChange(m_PosX, m_PosY, m_PosZ, m_BlockType, World->GetBlockMeta(m_PosX, m_PosY, m_PosZ)); a_Client.SendUpdateBlockEntity(*this); } diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index 248f20d49..fe4099835 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -19,7 +19,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - // The drops spawns in OnDestroyed + // The drop spawn is in OnDestroyed method } virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override @@ -51,11 +51,7 @@ public: a_MobHeadEntity->GetWorld()->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ); return false; } - - public: - cCallback() {} - }; - cCallback Callback; + } Callback; cWorld * World = (cWorld *) &a_WorldInterface; World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, Callback); diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index cc1ffe8f9..82e8ee8bd 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -609,7 +609,6 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) { m_Writer.AddInt("ExplosionPower", 1); break; - // fall-through: } case cProjectileEntity::pkFireCharge: case cProjectileEntity::pkWitherSkull: -- cgit v1.2.3 From 81f756cbda76507cc676fd50f20f33483c4ce6f8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 28 May 2014 22:40:19 +0200 Subject: cChunkData: Normalized code style. --- src/ChunkData.cpp | 168 +++++++++++++++++++++++++++++------------------------- src/ChunkData.h | 27 +++++---- 2 files changed, 106 insertions(+), 89 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 8aed62000..beee6c64a 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -306,33 +306,33 @@ cChunkData cChunkData::Copy(void) const -void cChunkData::CopyBlocks(BLOCKTYPE * a_dest, size_t a_Idx, size_t length) const +void cChunkData::CopyBlocks(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Length) const { for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; + const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16; if (a_Idx > 0) { - a_Idx = std::max(a_Idx - length, (size_t) 0); + a_Idx = std::max(a_Idx - a_Length, (size_t) 0); } if (a_Idx == 0) { - size_t tocopy = std::min(segment_length, length); - length -= tocopy; + size_t ToCopy = std::min(SegmentLength, a_Length); + length -= ToCopy; if (m_Sections[i] != NULL) { memcpy( - &a_dest[i * segment_length], + &a_Dest[i * SegmentLength], &m_Sections[i]->m_BlockTypes, - sizeof(BLOCKTYPE) * tocopy + sizeof(BLOCKTYPE) * ToCopy ); } else { memset( - &a_dest[i * segment_length], + &a_Dest[i * SegmentLength], 0, - sizeof(BLOCKTYPE) * tocopy + sizeof(BLOCKTYPE) * ToCopy ); } } @@ -343,25 +343,25 @@ void cChunkData::CopyBlocks(BLOCKTYPE * a_dest, size_t a_Idx, size_t length) co -void cChunkData::CopyMeta(NIBBLETYPE * a_dest) const +void cChunkData::CopyMeta(NIBBLETYPE * a_Dest) const { for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) { memcpy( - &a_dest[i * segment_length], + &a_Dest[i * SegmentLength], &m_Sections[i]->m_BlockMeta, - sizeof(NIBBLETYPE) * segment_length + sizeof(NIBBLETYPE) * SegmentLength ); } else { memset( - &a_dest[i * segment_length], + &a_Dest[i * SegmentLength], 0, - sizeof(BLOCKTYPE) * segment_length + sizeof(BLOCKTYPE) * SegmentLength ); } } @@ -371,25 +371,25 @@ void cChunkData::CopyMeta(NIBBLETYPE * a_dest) const -void cChunkData::CopyBlockLight(NIBBLETYPE * a_dest) const +void cChunkData::CopyBlockLight(NIBBLETYPE * a_Dest) const { for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) { memcpy( - &a_dest[i * segment_length], + &a_Dest[i * SegmentLength], &m_Sections[i]->m_BlockLight, - sizeof(NIBBLETYPE) * segment_length + sizeof(NIBBLETYPE) * SegmentLength ); } else { memset( - &a_dest[i * segment_length], + &a_Dest[i * SegmentLength], 0, - sizeof(BLOCKTYPE) * segment_length + sizeof(BLOCKTYPE) * SegmentLength ); } } @@ -399,25 +399,25 @@ void cChunkData::CopyBlockLight(NIBBLETYPE * a_dest) const -void cChunkData::CopySkyLight(NIBBLETYPE * a_dest) const +void cChunkData::CopySkyLight(NIBBLETYPE * a_Dest) const { for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) { memcpy( - &a_dest[i * segment_length], + &a_Dest[i * SegmentLength], &m_Sections[i]->m_BlockSkyLight, - sizeof(NIBBLETYPE) * segment_length + sizeof(NIBBLETYPE) * SegmentLength ); } else { memset( - &a_dest[i * segment_length], + &a_Dest[i * SegmentLength], 0xFF, - sizeof(BLOCKTYPE) * segment_length + sizeof(BLOCKTYPE) * SegmentLength ); } } @@ -427,34 +427,36 @@ void cChunkData::CopySkyLight(NIBBLETYPE * a_dest) const -void cChunkData::SetBlocks(const BLOCKTYPE * a_src) +void cChunkData::SetBlocks(const BLOCKTYPE * a_Src) { + ASSERT(a_Src != NULL); + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; + const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16; if (m_Sections[i] != NULL) { memcpy( &m_Sections[i]->m_BlockTypes, - &a_src[i * segment_length], - sizeof(BLOCKTYPE) * segment_length + &a_Src[i * SegmentLength], + sizeof(BLOCKTYPE) * SegmentLength ); } else { // j counts how many of leading zeros the buffer has - // if j == segment_length then the buffer is all zeros so there is no point + // if j == SegmentLength then the buffer is all zeros so there is no point // creating the buffer. size_t j = 0; // do nothing whilst 0 - for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); - if (j != segment_length) + for (; (j < SegmentLength) && (a_Src[i * SegmentLength + j] == 0); j++); + if (j != SegmentLength) { m_Sections[i] = Allocate(); memcpy( &m_Sections[i]->m_BlockTypes, - &a_src[i * segment_length], - sizeof(BLOCKTYPE) * segment_length + &a_Src[i * SegmentLength], + sizeof(BLOCKTYPE) * SegmentLength ); memset( m_Sections[i]->m_BlockMeta, @@ -479,34 +481,36 @@ void cChunkData::SetBlocks(const BLOCKTYPE * a_src) -void cChunkData::SetMeta(const NIBBLETYPE * a_src) +void cChunkData::SetMeta(const NIBBLETYPE * a_Src) { + ASSERT(a_Src != NULL); + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) { memcpy( &m_Sections[i]->m_BlockMeta, - &a_src[i * segment_length], - sizeof(NIBBLETYPE) * segment_length + &a_Src[i * SegmentLength], + sizeof(NIBBLETYPE) * SegmentLength ); } else { // j counts how many of leading zeros the buffer has - // if j == segment_length then the buffer is all zeros so there is no point + // if j == SegmentLength then the buffer is all zeros so there is no point // creating the buffer. size_t j = 0; // do nothing whilst 0 - for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); - if (j != segment_length) + for (; (j < SegmentLength) && (a_Src[i * SegmentLength + j] == 0); j++); + if (j != SegmentLength) { m_Sections[i] = Allocate(); memcpy( &m_Sections[i]->m_BlockMeta, - &a_src[i * segment_length], - sizeof(BLOCKTYPE) * segment_length + &a_Src[i * SegmentLength], + sizeof(BLOCKTYPE) * SegmentLength ); memset( m_Sections[i]->m_BlockTypes, @@ -531,35 +535,38 @@ void cChunkData::SetMeta(const NIBBLETYPE * a_src) -void cChunkData::SetBlockLight(const NIBBLETYPE * a_src) +void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src) { - if (!a_src) return; + if (a_Src == NULL) + { + return; + } for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) { memcpy( &m_Sections[i]->m_BlockLight, - &a_src[i * segment_length], - sizeof(NIBBLETYPE) * segment_length + &a_Src[i * SegmentLength], + sizeof(NIBBLETYPE) * SegmentLength ); } else { // j counts how many of leading zeros the buffer has - // if j == segment_length then the buffer is all zeros so there is no point + // if j == SegmentLength then the buffer is all zeros so there is no point // creating the buffer. size_t j = 0; // do nothing whilst 0 - for (; j < segment_length && a_src[i * segment_length + j] == 0; j++); - if (j != segment_length) + for (; (j < SegmentLength) && (a_Src[i * SegmentLength + j] == 0); j++); + if (j != SegmentLength) { m_Sections[i] = Allocate(); memcpy( &m_Sections[i]->m_BlockLight, - &a_src[i * segment_length], - sizeof(BLOCKTYPE) * segment_length + &a_Src[i * SegmentLength], + sizeof(BLOCKTYPE) * SegmentLength ); memset( m_Sections[i]->m_BlockTypes, @@ -584,35 +591,39 @@ void cChunkData::SetBlockLight(const NIBBLETYPE * a_src) -void cChunkData::SetSkyLight (const NIBBLETYPE * a_src) +void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src) { - if (!a_src) return; + if (a_Src == NULL) + { + return; + } + for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) { - const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; if (m_Sections[i] != NULL) { memcpy( &m_Sections[i]->m_BlockSkyLight, - &a_src[i * segment_length], - sizeof(NIBBLETYPE) * segment_length + &a_Src[i * SegmentLength], + sizeof(NIBBLETYPE) * SegmentLength ); } else { // j counts how many of leading zeros the buffer has - // if j == segment_length then the buffer is all zeros so there is no point + // if j == SegmentLength then the buffer is all zeros so there is no point // creating the buffer. size_t j = 0; // do nothing whilst 0 - for (; j < segment_length && a_src[i * segment_length + j] == 0xFF; j++); - if (j != segment_length) + for (; (j < SegmentLength) && (a_Src[i * SegmentLength + j]) == 0xFF; j++); + if (j != SegmentLength) { m_Sections[i] = Allocate(); memcpy( &m_Sections[i]->m_BlockSkyLight, - &a_src[i * segment_length], - sizeof(BLOCKTYPE) * segment_length + &a_Src[i * SegmentLength], + sizeof(BLOCKTYPE) * SegmentLength ); memset( m_Sections[i]->m_BlockTypes, @@ -638,9 +649,9 @@ void cChunkData::SetSkyLight (const NIBBLETYPE * a_src) -cChunkData::sChunkSection * cChunkData::Allocate() const +cChunkData::sChunkSection * cChunkData::Allocate(void) const { - // TODO: use a allocation pool + // TODO: Use an allocation pool return new cChunkData::sChunkSection; } @@ -648,36 +659,37 @@ cChunkData::sChunkSection * cChunkData::Allocate() const -void cChunkData::Free(cChunkData::sChunkSection * ptr) const +void cChunkData::Free(cChunkData::sChunkSection * a_Section) const { - delete ptr; + // TODO: Use an allocation pool + delete a_Section; } -void cChunkData::ZeroSection(cChunkData::sChunkSection * ptr) const +void cChunkData::ZeroSection(cChunkData::sChunkSection * a_Section) const { memset( - ptr->m_BlockTypes, + a_Section->m_BlockTypes, 0x00, - sizeof(ptr->m_BlockTypes) + sizeof(a_Section->m_BlockTypes) ); memset( - ptr->m_BlockMeta, + a_Section->m_BlockMeta, 0x00, - sizeof(ptr->m_BlockMeta) + sizeof(a_Section->m_BlockMeta) ); memset( - ptr->m_BlockLight, + a_Section->m_BlockLight, 0x00, - sizeof(ptr->m_BlockLight) + sizeof(a_Section->m_BlockLight) ); memset( - ptr->m_BlockSkyLight, + a_Section->m_BlockSkyLight, 0xFF, - sizeof(ptr->m_BlockSkyLight) + sizeof(a_Section->m_BlockSkyLight) ); } diff --git a/src/ChunkData.h b/src/ChunkData.h index 6544b246e..09b2cb563 100644 --- a/src/ChunkData.h +++ b/src/ChunkData.h @@ -25,12 +25,12 @@ public: #if __cplusplus < 201103L // auto_ptr style interface for memory management - cChunkData(const cChunkData & other); - cChunkData & operator =(const cChunkData & other); + cChunkData(const cChunkData & a_Other); + cChunkData & operator =(const cChunkData & a_Other); #else // unique_ptr style interface for memory management - cChunkData(cChunkData && other); - cChunkData & operator =(cChunkData && other); + cChunkData(cChunkData && a_Other); + cChunkData & operator =(cChunkData && a_ther); #endif BLOCKTYPE GetBlock(int a_X, int a_Y, int a_Z) const; @@ -44,10 +44,10 @@ public: NIBBLETYPE GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const; cChunkData Copy(void) const; - void CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx = 0, size_t length = cChunkDef::NumBlocks) const; - void CopyMeta (NIBBLETYPE * a_dest) const; - void CopyBlockLight(NIBBLETYPE * a_dest) const; - void CopySkyLight (NIBBLETYPE * a_dest) const; + void CopyBlocks (BLOCKTYPE * a_Dest, size_t a_Idx = 0, size_t a_Length = cChunkDef::NumBlocks) const; + void CopyMeta (NIBBLETYPE * a_Dest) const; + void CopyBlockLight(NIBBLETYPE * a_Dest) const; + void CopySkyLight (NIBBLETYPE * a_Dest) const; void SetBlocks (const BLOCKTYPE * a_src); void SetMeta (const NIBBLETYPE * a_src); @@ -73,10 +73,15 @@ private: sChunkSection * m_Sections[CHUNK_SECTION_COUNT]; - sChunkSection * Allocate(void) const; - void Free(sChunkSection * ptr) const; + /** Allocates a new section. Entry-point to custom allocators. */ + static sChunkSection * Allocate(void); - void ZeroSection(sChunkSection * ptr) const; + /** Frees the specified section, previously allocated using Allocate(). + Note that a_Section may be NULL. */ + static void Free(sChunkSection * a_Section); + + /** Sets the data in the specified section to their default values. */ + void ZeroSection(sChunkSection * a_Section) const; }; -- cgit v1.2.3 From 10273f64a2ec326201d3553f3704d2d6f21b7a86 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 28 May 2014 22:41:23 +0200 Subject: Fixed a crash in message formatter. The code would fail if a message is sent to a player not yet added to a world. --- src/Protocol/Protocol17x.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 7c526d103..f7564fe6d 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -234,7 +234,8 @@ void cProtocol172::SendChat(const cCompositeChat & a_Message) // Compose the complete Json string to send: Json::Value msg; - msg["text"] = cClientHandle::FormatMessageType(m_Client->GetPlayer()->GetWorld()->ShouldUseChatPrefixes(), a_Message.GetMessageType(), a_Message.GetAdditionalMessageTypeData()); // The client crashes without this field being present + cWorld * World = m_Client->GetPlayer()->GetWorld(); + msg["text"] = cClientHandle::FormatMessageType((World == NULL) ? false : World->ShouldUseChatPrefixes(), a_Message.GetMessageType(), a_Message.GetAdditionalMessageTypeData()); // The client crashes without this field being present const cCompositeChat::cParts & Parts = a_Message.GetParts(); for (cCompositeChat::cParts::const_iterator itr = Parts.begin(), end = Parts.end(); itr != end; ++itr) { -- cgit v1.2.3 From 999662503a90e6acd4528be50f8b6232b357d9c3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 29 May 2014 09:09:11 +0200 Subject: Fixed forgotten changes. --- src/ChunkData.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index beee6c64a..172858e4e 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -318,7 +318,7 @@ void cChunkData::CopyBlocks(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Length) if (a_Idx == 0) { size_t ToCopy = std::min(SegmentLength, a_Length); - length -= ToCopy; + a_Length -= ToCopy; if (m_Sections[i] != NULL) { memcpy( @@ -649,7 +649,7 @@ void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src) -cChunkData::sChunkSection * cChunkData::Allocate(void) const +cChunkData::sChunkSection * cChunkData::Allocate(void) { // TODO: Use an allocation pool return new cChunkData::sChunkSection; @@ -659,7 +659,7 @@ cChunkData::sChunkSection * cChunkData::Allocate(void) const -void cChunkData::Free(cChunkData::sChunkSection * a_Section) const +void cChunkData::Free(cChunkData::sChunkSection * a_Section) { // TODO: Use an allocation pool delete a_Section; -- cgit v1.2.3 From e5187aa645b0f06e58e347bed1f8d68916764ba1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 29 May 2014 09:19:20 +0200 Subject: Fixed a memory leak in cPOCPieceGenerator --- src/Generating/POCPieceGenerator.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/Generating/POCPieceGenerator.cpp b/src/Generating/POCPieceGenerator.cpp index 9ed4b565e..491f4d206 100644 --- a/src/Generating/POCPieceGenerator.cpp +++ b/src/Generating/POCPieceGenerator.cpp @@ -186,6 +186,11 @@ cPOCPieceGenerator::cPOCPieceGenerator(int a_Seed) : cPOCPieceGenerator::~cPOCPieceGenerator() { cPieceGenerator::FreePieces(m_Pieces); + for (cPieces::iterator itr = m_AvailPieces.begin(), end = m_AvailPieces.end(); itr != end; ++itr) + { + delete *itr; + } + m_AvailPieces.clear(); } -- cgit v1.2.3 From ae4371a733ee3ac029498ddef50850cc0ca9cbd9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 29 May 2014 11:56:22 +0100 Subject: Fixed piston power checking --- src/Simulator/IncrementalRedstoneSimulator.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index c24b1c4b3..51a7c2886 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -1489,41 +1489,36 @@ bool cIncrementalRedstoneSimulator::IsPistonPowered(int a_RelBlockX, int a_RelBl { // Pistons cannot be powered through their front face; this function verifies that a source meets this requirement - int OldX = a_RelBlockX, OldY = a_RelBlockY, OldZ = a_RelBlockZ; eBlockFace Face = cBlockPistonHandler::MetaDataToDirection(a_Meta); - int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; - int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX; + int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ; for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) { if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; } - AddFaceDirection(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Face); + AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face); if (!itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { return true; } - a_RelBlockX = OldX; - a_RelBlockY = OldY; - a_RelBlockZ = OldZ; + AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face, true); } for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) { if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; } - AddFaceDirection(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Face); + AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face); if (!itr->a_MiddlePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { return true; } - a_RelBlockX = OldX; - a_RelBlockY = OldY; - a_RelBlockZ = OldZ; + AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face, true); } return false; // Source was in front of the piston's front face } -- cgit v1.2.3 From 365c6f50bd057eb62c66b9b222a07ca6efcb2c47 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 29 May 2014 11:57:06 +0100 Subject: Changed block send queue to use vectors As suggested by @worktycho. --- src/Blocks/BlockPiston.cpp | 23 +++++++++++++++++------ src/World.cpp | 21 ++++++++++----------- src/World.h | 6 ++---- 3 files changed, 29 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index f758013dc..1f8e0d9e0 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -27,6 +27,7 @@ } #define PISTON_TICK_DELAY 1 +#define PISTON_MAX_PUSH_DISTANCE 12 @@ -78,7 +79,7 @@ bool cBlockPistonHandler::GetPlacementBlockTypeMeta( int cBlockPistonHandler::FirstPassthroughBlock(int pistonX, int pistonY, int pistonZ, NIBBLETYPE pistonmeta, cWorld * a_World) { // Examine each of the 12 blocks ahead of the piston: - for (int ret = 0; ret < 12; ret++) + for (int ret = 0; ret < PISTON_MAX_PUSH_DISTANCE; ret++) { BLOCKTYPE currBlock; NIBBLETYPE currMeta; @@ -144,12 +145,15 @@ void cBlockPistonHandler::ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, // Push blocks, from the furthest to the nearest: int oldx = a_BlockX, oldy = a_BlockY, oldz = a_BlockZ; NIBBLETYPE currBlockMeta; + std::vector ScheduledBlocks; + ScheduledBlocks.reserve(PISTON_MAX_PUSH_DISTANCE); + for (int i = dist + 1; i > 1; i--) { AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1); a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, currBlock, currBlockMeta); a_World->SetBlock(oldx, oldy, oldz, currBlock, currBlockMeta, false); - a_World->ScheduleTask(PISTON_TICK_DELAY, new cWorld::cTaskSendBlockToAllPlayers(oldx, oldy, oldz)); + ScheduledBlocks.push_back(Vector3i(oldx, oldy, oldz)); oldx = a_BlockX; oldy = a_BlockY; oldz = a_BlockZ; @@ -158,12 +162,13 @@ void cBlockPistonHandler::ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, int extx = a_BlockX; int exty = a_BlockY; int extz = a_BlockZ; + ScheduledBlocks.push_back(Vector3i(extx, exty, extz)); AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1); // "a_Block" now at piston body, "ext" at future extension a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta | 0x8); a_World->SetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0), false); - a_World->ScheduleTask(PISTON_TICK_DELAY, new cWorld::cTaskSendBlockToAllPlayers(extx, exty, extz)); + a_World->ScheduleTask(PISTON_TICK_DELAY, new cWorld::cTaskSendBlockToAllPlayers(ScheduledBlocks)); } @@ -209,15 +214,21 @@ void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ // Pull the block a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, tempBlock, tempMeta, false); a_World->SetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0, false); - a_World->ScheduleTask(PISTON_TICK_DELAY + 1, new cWorld::cTaskSendBlockToAllPlayers(a_BlockX, a_BlockY, a_BlockZ)); - a_World->ScheduleTask(PISTON_TICK_DELAY, new cWorld::cTaskSendBlockToAllPlayers(tempx, tempy, tempz)); + + std::vector ScheduledBlocks; + ScheduledBlocks.push_back(Vector3i(a_BlockX, a_BlockY, a_BlockZ)); + ScheduledBlocks.push_back(Vector3i(tempx, tempy, tempz)); + a_World->ScheduleTask(PISTON_TICK_DELAY + 1, new cWorld::cTaskSendBlockToAllPlayers(ScheduledBlocks)); return; } } // Retract without pulling a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0, false); - a_World->ScheduleTask(PISTON_TICK_DELAY + 1, new cWorld::cTaskSendBlockToAllPlayers(a_BlockX, a_BlockY, a_BlockZ)); + + std::vector ScheduledBlocks; + ScheduledBlocks.push_back(Vector3i(a_BlockX, a_BlockY, a_BlockZ)); + a_World->ScheduleTask(PISTON_TICK_DELAY + 1, new cWorld::cTaskSendBlockToAllPlayers(ScheduledBlocks)); } diff --git a/src/World.cpp b/src/World.cpp index 29046bba9..88e9c32e6 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -3130,10 +3130,8 @@ void cWorld::cTaskUnloadUnusedChunks::Run(cWorld & a_World) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cWorld::cTaskSendBlockTo -cWorld::cTaskSendBlockToAllPlayers::cTaskSendBlockToAllPlayers(int a_BlockX, int a_BlockY, int a_BlockZ) : - m_BlockX(a_BlockX), - m_BlockY(a_BlockY), - m_BlockZ(a_BlockZ) +cWorld::cTaskSendBlockToAllPlayers::cTaskSendBlockToAllPlayers(std::vector & a_SendQueue) : + m_SendQueue(a_SendQueue) { } @@ -3143,26 +3141,27 @@ void cWorld::cTaskSendBlockToAllPlayers::Run(cWorld & a_World) public cPlayerListCallback { public: - cPlayerCallback(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld & a_World) : - m_BlockX(a_BlockX), - m_BlockY(a_BlockY), - m_BlockZ(a_BlockZ), + cPlayerCallback(std::vector & a_SendQueue, cWorld & a_World) : + m_SendQueue(a_SendQueue), m_World(a_World) { } virtual bool Item(cPlayer * a_Player) { - m_World.SendBlockTo(m_BlockX, m_BlockY, m_BlockZ, a_Player); + for (std::vector::const_iterator itr = m_SendQueue.begin(); itr != m_SendQueue.end(); ++itr) + { + m_World.SendBlockTo(itr->x, itr->y, itr->z, a_Player); + } return false; } private: - int m_BlockX, m_BlockY, m_BlockZ; + std::vector m_SendQueue; cWorld & m_World; - } PlayerCallback(m_BlockX, m_BlockY, m_BlockZ, a_World); + } PlayerCallback(m_SendQueue, a_World); a_World.ForEachPlayer(PlayerCallback); } diff --git a/src/World.h b/src/World.h index 5ef63a540..98b241a2b 100644 --- a/src/World.h +++ b/src/World.h @@ -121,15 +121,13 @@ public: public cTask { public: - cTaskSendBlockToAllPlayers(int a_BlockX, int a_BlockY, int a_BlockZ); + cTaskSendBlockToAllPlayers(std::vector & a_SendQueue); protected: // cTask overrides: virtual void Run(cWorld & a_World) override; - int m_BlockX; - int m_BlockY; - int m_BlockZ; + std::vector m_SendQueue; }; -- cgit v1.2.3 From d9c667d28f556e489b2779b7510f3b12034c3fad Mon Sep 17 00:00:00 2001 From: worktycho Date: Thu, 29 May 2014 12:04:37 +0100 Subject: Add comment --- src/ChunkData.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/ChunkData.h b/src/ChunkData.h index 09b2cb563..e6aaa99b8 100644 --- a/src/ChunkData.h +++ b/src/ChunkData.h @@ -44,6 +44,10 @@ public: NIBBLETYPE GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const; cChunkData Copy(void) const; + + // Copys data from this object into the buffer in the a_Dest param + // CopyBlocks also povides the optional parameters a_Idx and a_Length which specify an offset and length for + // copying part of the BlockTypes array. void CopyBlocks (BLOCKTYPE * a_Dest, size_t a_Idx = 0, size_t a_Length = cChunkDef::NumBlocks) const; void CopyMeta (NIBBLETYPE * a_Dest) const; void CopyBlockLight(NIBBLETYPE * a_Dest) const; -- cgit v1.2.3 From bacc873a175cb37a1878fccf8fa40acb75fb8189 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 29 May 2014 12:12:10 +0100 Subject: Revert "Fixed a food saturation issue" This reverts commit 67308e4337b422ebefb249049e662266072b0ba2. --- src/Entities/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 1e1e868e7..0eacb67f9 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -551,7 +551,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation) } m_FoodLevel = std::min(a_Food + m_FoodLevel, (int)MAX_FOOD_LEVEL); - m_FoodSaturationLevel = m_FoodSaturationLevel + a_Saturation; + m_FoodSaturationLevel = std::min(m_FoodSaturationLevel + a_Saturation, (double)m_FoodLevel); SendHealth(); return true; -- cgit v1.2.3 From 3549d0d5e6e99342f3422396ac80b66c3e3d54db Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 29 May 2014 15:59:39 +0100 Subject: More comments! --- src/Chunk.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 6bd68459c..fbd0a5846 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1587,11 +1587,10 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT } m_BlockTypes[index] = a_BlockType; - // The client doesn't need to distinguish between stationary and nonstationary fluids: - if ( - a_SendToClients && - ((OldBlockMeta != a_BlockMeta) || // Different meta always gets sent to the client - !( + if ( // Queue block to be sent only if ... + a_SendToClients && // ... we are told to do so AND ... + ((OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ... + !( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them); see below for specifics: ((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water ((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water ((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water -- cgit v1.2.3 From aa4477822ab0f1cdba904fd39e065bf8e86f9aec Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 29 May 2014 16:03:41 +0100 Subject: Suggestions --- src/Blocks/BlockPiston.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index d7c92925b..e6fa48e54 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -143,7 +143,12 @@ private: } } - return CanBreakPush(a_BlockType) ? false /* CanBreakPush returns true, but we need false to prevent pulling */ : CanPush(a_BlockType, a_BlockMeta); + if (CanBreakPush(a_BlockType)) + { + return false; // CanBreakPush returns true, but we need false to prevent pulling + } + + return CanPush(a_BlockType, a_BlockMeta); } /// Returns how many blocks the piston has to push (where the first free space is); < 0 when unpushable -- cgit v1.2.3 From cea3a8e7e8cbf45f709ec63a096cf07b92c87073 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 29 May 2014 16:58:40 +0100 Subject: Cauldrons fill --- src/Blocks/BlockCauldron.h | 14 ++++++++++++++ src/Blocks/WorldInterface.h | 3 +++ src/Chunk.cpp | 1 - src/World.h | 4 ++-- 4 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h index 41b79b6c3..8b5cd9ccb 100644 --- a/src/Blocks/BlockCauldron.h +++ b/src/Blocks/BlockCauldron.h @@ -58,6 +58,20 @@ public: { return true; } + + virtual void OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override + { + if (!a_WorldInterface.IsWeatherWet()) + { + return; + } + + NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ); + if (Meta < 3) + { + a_Chunk.SetMeta(a_RelX, a_RelY, a_RelZ, Meta + 1); + } + } } ; diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h index bfbb053d9..08600d502 100644 --- a/src/Blocks/WorldInterface.h +++ b/src/Blocks/WorldInterface.h @@ -37,4 +37,7 @@ public: virtual void SetTimeOfDay(Int64 a_TimeOfDay) = 0; + /** Returns true if the current weather has any precipitation - rain or storm */ + virtual bool IsWeatherWet(void) const = 0; + }; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index ca536e89a..4506cfcc5 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -961,7 +961,6 @@ void cChunk::ApplyWeatherToTop() } break; } // case (snowy biomes) - // TODO: Rainy biomes should check for farmland and cauldrons default: { break; diff --git a/src/World.h b/src/World.h index 86cbb3e7e..067e18547 100644 --- a/src/World.h +++ b/src/World.h @@ -690,8 +690,8 @@ public: bool IsWeatherStorm(void) const { return (m_Weather == wStorm); } /** Returns true if the current weather has any precipitation - rain or storm */ - bool IsWeatherWet (void) const { return (m_Weather != wSunny); } - + virtual bool IsWeatherWet(void) const override { return (m_Weather != wSunny); } + // tolua_end cChunkGenerator & GetGenerator(void) { return m_Generator; } -- cgit v1.2.3 From 60a37c1370dc766c55a344090d8d26bc2e1c1c99 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 29 May 2014 16:58:55 +0100 Subject: Very minor code changes --- src/Blocks/BlockBed.cpp | 2 +- src/Blocks/BlockPortal.h | 2 +- src/Mobs/Monster.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index 6a3c6a55b..07ef997dd 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -108,7 +108,7 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); if (Meta & 0x4) { - a_Player->SendMessageFailure("This bed is occupied."); + a_Player->SendMessageFailure("This bed is occupied"); } else { diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 3b8030028..e718d9a70 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -55,7 +55,7 @@ public: virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { - if ((a_RelY - 1 < 0) || (a_RelY + 1 > cChunkDef::Height)) + if ((a_RelY == 0) || (a_RelY == cChunkDef::Height)) // Y can't be < 0 or > Height; (Fast)SetBlock won't allow it { return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1 } diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index a9ca7a2fa..839d21314 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -1024,7 +1024,7 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk) (a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand (GetWorld()->GetTimeOfDay() < (12000 + 1000)) && // It is nighttime !IsOnFire() && // Not already burning - (GetWorld()->GetWeather() != eWeather_Rain) // Not raining + (GetWorld()->IsWeatherWet()) // Not raining ) { // Burn for 100 ticks, then decide again -- cgit v1.2.3 From f7777e8c7559964f126a64af7673276e356dcedc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 29 May 2014 18:25:08 +0200 Subject: Added comments, reformatted code. --- src/BlockArea.cpp | 2 +- src/Chunk.cpp | 6 +- src/ChunkData.cpp | 391 ++++++++++++++++++------------------------------ src/ChunkData.h | 65 +++++--- src/ChunkDataCallback.h | 40 +++-- src/LightingThread.cpp | 2 +- 6 files changed, 226 insertions(+), 280 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 11bd76e6c..40fdd68c0 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -1903,7 +1903,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer) if (m_Area.m_BlockMetas != NULL) { - a_BlockBuffer.CopyMeta(m_Area.m_BlockMetas); + a_BlockBuffer.CopyMetas(m_Area.m_BlockMetas); } if (m_Area.m_BlockLight != NULL) diff --git a/src/Chunk.cpp b/src/Chunk.cpp index e5f8f1e29..23412a4c3 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -282,8 +282,8 @@ void cChunk::SetAllData( CalculateHeightmap(a_BlockTypes); } - m_ChunkData.SetBlocks(a_BlockTypes); - m_ChunkData.SetMeta(a_BlockMeta); + m_ChunkData.SetBlockTypes(a_BlockTypes); + m_ChunkData.SetMetas(a_BlockMeta); m_ChunkData.SetBlockLight(a_BlockLight); m_ChunkData.SetSkyLight(a_BlockSkyLight); @@ -339,7 +339,7 @@ void cChunk::SetLight( void cChunk::GetBlockTypes(BLOCKTYPE * a_BlockTypes) { - m_ChunkData.CopyBlocks(a_BlockTypes); + m_ChunkData.CopyBlockTypes(a_BlockTypes); } diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 172858e4e..cc4793ec3 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -1,14 +1,39 @@ +// ChunkData.cpp + +// Implements the cChunkData class that represents the block's type, meta, blocklight and skylight storage for a chunk + #include "Globals.h" #include "ChunkData.h" -cChunkData::cChunkData() + + + + +/** Returns true if all a_Array's elements between [0] and [a_NumElements - 1] are equal to a_Value. */ +template inline bool IsAllValue(const T * a_Array, size_t a_NumElements, T a_Value) +{ + for (size_t i = 0; i < a_NumElements; i++) + { + if (a_Array[i] != a_Value) + { + return false; + } + } + return true; +} + + + + + +cChunkData::cChunkData(void) #if __cplusplus < 201103L // auto_ptr style interface for memory management : m_IsOwner(true) #endif { - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + for (size_t i = 0; i < NumSections; i++) { m_Sections[i] = NULL; } @@ -27,7 +52,7 @@ cChunkData::~cChunkData() return; } #endif - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + for (size_t i = 0; i < NumSections; i++) { Free(m_Sections[i]); } @@ -43,7 +68,7 @@ cChunkData::~cChunkData() m_IsOwner(true) { // Move contents and ownership from a_Other to this, pointer-wise: - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + for (size_t i = 0; i < NumSections; i++) { m_Sections[i] = a_Other.m_Sections[i]; } @@ -65,7 +90,7 @@ cChunkData::~cChunkData() // Free any currently held contents: if (m_IsOwner) { - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + for (size_t i = 0; i < NumSections; i++) { Free(m_Sections[i]); } @@ -73,7 +98,7 @@ cChunkData::~cChunkData() // Move contents and ownership from a_Other to this, pointer-wise: m_IsOwner = true; - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + for (size_t i = 0; i < NumSections; i++) { m_Sections[i] = a_Other.m_Sections[i]; } @@ -86,7 +111,7 @@ cChunkData::~cChunkData() // unique_ptr style interface for memory management cChunkData::cChunkData(cChunkData && other) { - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + for (size_t i = 0; i < NumSections; i++) { m_Sections[i] = other.m_Sections[i]; other.m_Sections[i] = NULL; @@ -101,7 +126,7 @@ cChunkData::~cChunkData() { if (&other != this) { - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + for (size_t i = 0; i < NumSections; i++) { Free(m_Sections[i]); m_Sections[i] = other.m_Sections[i]; @@ -121,10 +146,10 @@ BLOCKTYPE cChunkData::GetBlock(int a_X, int a_Y, int a_Z) const ASSERT((a_X >= 0) && (a_X < cChunkDef::Width)); ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height)); ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width)); - int Section = a_Y / CHUNK_SECTION_HEIGHT; + int Section = a_Y / SectionHeight; if (m_Sections[Section] != NULL) { - int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * CHUNK_SECTION_HEIGHT), a_Z); + int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * SectionHeight), a_Z); return m_Sections[Section]->m_BlockTypes[Index]; } else @@ -149,7 +174,7 @@ void cChunkData::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block) return; } - int Section = a_RelY / CHUNK_SECTION_HEIGHT; + int Section = a_RelY / SectionHeight; if (m_Sections[Section] == NULL) { if (a_Block == 0x00) @@ -164,7 +189,7 @@ void cChunkData::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block) } ZeroSection(m_Sections[Section]); } - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ); m_Sections[Section]->m_BlockTypes[Index] = a_Block; } @@ -179,10 +204,10 @@ NIBBLETYPE cChunkData::GetMeta(int a_RelX, int a_RelY, int a_RelZ) const (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) { - int Section = a_RelY / CHUNK_SECTION_HEIGHT; + int Section = a_RelY / SectionHeight; if (m_Sections[Section] != NULL) { - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ); return (m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4)) & 0x0f; } else @@ -210,7 +235,7 @@ bool cChunkData::SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble return false; } - int Section = a_RelY / CHUNK_SECTION_HEIGHT; + int Section = a_RelY / SectionHeight; if (m_Sections[Section] == NULL) { if ((a_Nibble & 0xf) == 0x00) @@ -225,7 +250,7 @@ bool cChunkData::SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble } ZeroSection(m_Sections[Section]); } - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ); NIBBLETYPE oldval = m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4) & 0xf; m_Sections[Section]->m_BlockMeta[Index / 2] = static_cast( (m_Sections[Section]->m_BlockMeta[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble @@ -246,10 +271,10 @@ NIBBLETYPE cChunkData::GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const (a_RelZ < cChunkDef::Width) && (a_RelZ > -1) ) { - int Section = a_RelY / CHUNK_SECTION_HEIGHT; + int Section = a_RelY / SectionHeight; if (m_Sections[Section] != NULL) { - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ); return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; } else @@ -269,10 +294,10 @@ NIBBLETYPE cChunkData::GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const { if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) { - int Section = a_RelY / CHUNK_SECTION_HEIGHT; + int Section = a_RelY / SectionHeight; if (m_Sections[Section] != NULL) { - int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); + int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ); return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; } else @@ -291,7 +316,7 @@ NIBBLETYPE cChunkData::GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const cChunkData cChunkData::Copy(void) const { cChunkData copy; - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + for (size_t i = 0; i < NumSections; i++) { if (m_Sections[i] != NULL) { @@ -306,11 +331,12 @@ cChunkData cChunkData::Copy(void) const -void cChunkData::CopyBlocks(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Length) const +void cChunkData::CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Length) const { - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + // TODO: This code seems wrong. It always copies into a_Dest[i * SegmentLength], even when a_Idx > 0 + for (size_t i = 0; i < NumSections; i++) { - const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16; + const size_t SegmentLength = SectionHeight * 16 * 16; if (a_Idx > 0) { a_Idx = std::max(a_Idx - a_Length, (size_t) 0); @@ -321,19 +347,11 @@ void cChunkData::CopyBlocks(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Length) a_Length -= ToCopy; if (m_Sections[i] != NULL) { - memcpy( - &a_Dest[i * SegmentLength], - &m_Sections[i]->m_BlockTypes, - sizeof(BLOCKTYPE) * ToCopy - ); + memcpy(&a_Dest[i * SegmentLength], &m_Sections[i]->m_BlockTypes, sizeof(BLOCKTYPE) * ToCopy); } else { - memset( - &a_Dest[i * SegmentLength], - 0, - sizeof(BLOCKTYPE) * ToCopy - ); + memset(&a_Dest[i * SegmentLength], 0, sizeof(BLOCKTYPE) * ToCopy); } } } @@ -343,26 +361,18 @@ void cChunkData::CopyBlocks(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Length) -void cChunkData::CopyMeta(NIBBLETYPE * a_Dest) const +void cChunkData::CopyMetas(NIBBLETYPE * a_Dest) const { - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + for (size_t i = 0; i < NumSections; i++) { - const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + const size_t SegmentLength = SectionHeight * 16 * 16 / 2; if (m_Sections[i] != NULL) { - memcpy( - &a_Dest[i * SegmentLength], - &m_Sections[i]->m_BlockMeta, - sizeof(NIBBLETYPE) * SegmentLength - ); + memcpy(&a_Dest[i * SegmentLength], &m_Sections[i]->m_BlockMeta, sizeof(NIBBLETYPE) * SegmentLength); } else { - memset( - &a_Dest[i * SegmentLength], - 0, - sizeof(BLOCKTYPE) * SegmentLength - ); + memset(&a_Dest[i * SegmentLength], 0, sizeof(BLOCKTYPE) * SegmentLength); } } } @@ -373,24 +383,16 @@ void cChunkData::CopyMeta(NIBBLETYPE * a_Dest) const void cChunkData::CopyBlockLight(NIBBLETYPE * a_Dest) const { - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + for (size_t i = 0; i < NumSections; i++) { - const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + const size_t SegmentLength = SectionHeight * 16 * 16 / 2; if (m_Sections[i] != NULL) { - memcpy( - &a_Dest[i * SegmentLength], - &m_Sections[i]->m_BlockLight, - sizeof(NIBBLETYPE) * SegmentLength - ); + memcpy(&a_Dest[i * SegmentLength], &m_Sections[i]->m_BlockLight, sizeof(NIBBLETYPE) * SegmentLength); } else { - memset( - &a_Dest[i * SegmentLength], - 0, - sizeof(BLOCKTYPE) * SegmentLength - ); + memset(&a_Dest[i * SegmentLength], 0, sizeof(BLOCKTYPE) * SegmentLength); } } } @@ -401,24 +403,16 @@ void cChunkData::CopyBlockLight(NIBBLETYPE * a_Dest) const void cChunkData::CopySkyLight(NIBBLETYPE * a_Dest) const { - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + for (size_t i = 0; i < NumSections; i++) { - const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + const size_t SegmentLength = SectionHeight * 16 * 16 / 2; if (m_Sections[i] != NULL) { - memcpy( - &a_Dest[i * SegmentLength], - &m_Sections[i]->m_BlockSkyLight, - sizeof(NIBBLETYPE) * SegmentLength - ); + memcpy(&a_Dest[i * SegmentLength], &m_Sections[i]->m_BlockSkyLight, sizeof(NIBBLETYPE) * SegmentLength); } else { - memset( - &a_Dest[i * SegmentLength], - 0xFF, - sizeof(BLOCKTYPE) * SegmentLength - ); + memset(&a_Dest[i * SegmentLength], 0xff, sizeof(BLOCKTYPE) * SegmentLength); } } } @@ -427,165 +421,102 @@ void cChunkData::CopySkyLight(NIBBLETYPE * a_Dest) const -void cChunkData::SetBlocks(const BLOCKTYPE * a_Src) +void cChunkData::SetBlockTypes(const BLOCKTYPE * a_Src) { ASSERT(a_Src != NULL); - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + static const size_t SegmentLength = SectionHeight * 16 * 16; + for (size_t i = 0; i < NumSections; i++) { - const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16; + // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy( - &m_Sections[i]->m_BlockTypes, - &a_Src[i * SegmentLength], - sizeof(BLOCKTYPE) * SegmentLength - ); + memcpy(&m_Sections[i]->m_BlockTypes, &a_Src[i * SegmentLength], sizeof(BLOCKTYPE) * SegmentLength); + continue; } - else + + // The section doesn't exist, find out if it is needed: + if (IsAllValue(a_Src + i * SegmentLength, SegmentLength, (const BLOCKTYPE)0)) { - // j counts how many of leading zeros the buffer has - // if j == SegmentLength then the buffer is all zeros so there is no point - // creating the buffer. - size_t j = 0; - // do nothing whilst 0 - for (; (j < SegmentLength) && (a_Src[i * SegmentLength + j] == 0); j++); - if (j != SegmentLength) - { - m_Sections[i] = Allocate(); - memcpy( - &m_Sections[i]->m_BlockTypes, - &a_Src[i * SegmentLength], - sizeof(BLOCKTYPE) * SegmentLength - ); - memset( - m_Sections[i]->m_BlockMeta, - 0x00, - sizeof(m_Sections[i]->m_BlockMeta) - ); - memset( - m_Sections[i]->m_BlockLight, - 0x00, - sizeof(m_Sections[i]->m_BlockLight) - ); - memset( - m_Sections[i]->m_BlockSkyLight, - 0xFF, - sizeof(m_Sections[i]->m_BlockSkyLight) - ); - } + // No need for the section, the data is all-air + continue; } - } + + // Allocate the section and copy the data into it: + m_Sections[i] = Allocate(); + memcpy(&m_Sections[i]->m_BlockTypes, &a_Src[i * SegmentLength], sizeof(BLOCKTYPE) * SegmentLength); + memset(m_Sections[i]->m_BlockMeta, 0x00, sizeof(m_Sections[i]->m_BlockMeta)); + memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight)); + memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight)); + } // for i - m_Sections[] } -void cChunkData::SetMeta(const NIBBLETYPE * a_Src) +void cChunkData::SetMetas(const NIBBLETYPE * a_Src) { ASSERT(a_Src != NULL); - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + for (size_t i = 0; i < NumSections; i++) { - const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy( - &m_Sections[i]->m_BlockMeta, - &a_Src[i * SegmentLength], - sizeof(NIBBLETYPE) * SegmentLength - ); + memcpy(&m_Sections[i]->m_BlockMeta, &a_Src[i * SegmentLength], sizeof(NIBBLETYPE) * SegmentLength); + continue; } - else + + // The section doesn't exist, find out if it is needed: + if (IsAllValue(a_Src + i * SegmentLength, SegmentLength, (NIBBLETYPE)0)) { - // j counts how many of leading zeros the buffer has - // if j == SegmentLength then the buffer is all zeros so there is no point - // creating the buffer. - size_t j = 0; - // do nothing whilst 0 - for (; (j < SegmentLength) && (a_Src[i * SegmentLength + j] == 0); j++); - if (j != SegmentLength) - { - m_Sections[i] = Allocate(); - memcpy( - &m_Sections[i]->m_BlockMeta, - &a_Src[i * SegmentLength], - sizeof(BLOCKTYPE) * SegmentLength - ); - memset( - m_Sections[i]->m_BlockTypes, - 0x00, - sizeof(m_Sections[i]->m_BlockTypes) - ); - memset( - m_Sections[i]->m_BlockLight, - 0x00, - sizeof(m_Sections[i]->m_BlockLight) - ); - memset( - m_Sections[i]->m_BlockSkyLight, - 0xFF, - sizeof(m_Sections[i]->m_BlockSkyLight) - ); - } + // No need for the section, the data is all zeroes + continue; } - } + + // Allocate the section and copy the data into it: + m_Sections[i] = Allocate(); + memcpy(&m_Sections[i]->m_BlockMeta, &a_Src[i * SegmentLength], sizeof(BLOCKTYPE) * SegmentLength); + memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes)); + memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight)); + memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight)); + } // for i - m_Sections[] } + void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src) { if (a_Src == NULL) { return; } - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + + for (size_t i = 0; i < NumSections; i++) { - const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy( - &m_Sections[i]->m_BlockLight, - &a_Src[i * SegmentLength], - sizeof(NIBBLETYPE) * SegmentLength - ); + memcpy(&m_Sections[i]->m_BlockLight, &a_Src[i * SegmentLength], sizeof(NIBBLETYPE) * SegmentLength); + continue; } - else + + // The section doesn't exist, find out if it is needed: + if (IsAllValue(a_Src + i * SegmentLength, SegmentLength, (NIBBLETYPE)0)) { - // j counts how many of leading zeros the buffer has - // if j == SegmentLength then the buffer is all zeros so there is no point - // creating the buffer. - size_t j = 0; - // do nothing whilst 0 - for (; (j < SegmentLength) && (a_Src[i * SegmentLength + j] == 0); j++); - if (j != SegmentLength) - { - m_Sections[i] = Allocate(); - memcpy( - &m_Sections[i]->m_BlockLight, - &a_Src[i * SegmentLength], - sizeof(BLOCKTYPE) * SegmentLength - ); - memset( - m_Sections[i]->m_BlockTypes, - 0x00, - sizeof(m_Sections[i]->m_BlockTypes) - ); - memset( - m_Sections[i]->m_BlockMeta, - 0x00, - sizeof(m_Sections[i]->m_BlockMeta) - ); - memset( - m_Sections[i]->m_BlockSkyLight, - 0xFF, - sizeof(m_Sections[i]->m_BlockSkyLight) - ); - } + // No need for the section, the data is all zeroes + continue; } - } + + // Allocate the section and copy the data into it: + m_Sections[i] = Allocate(); + memcpy(&m_Sections[i]->m_BlockLight, &a_Src[i * SegmentLength], sizeof(BLOCKTYPE) * SegmentLength); + memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes)); + memset(m_Sections[i]->m_BlockMeta, 0x00, sizeof(m_Sections[i]->m_BlockMeta)); + memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight)); + } // for i - m_Sections[] } @@ -598,51 +529,29 @@ void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src) return; } - for (size_t i = 0; i < CHUNK_SECTION_COUNT; i++) + for (size_t i = 0; i < NumSections; i++) { - const size_t SegmentLength = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; + // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy( - &m_Sections[i]->m_BlockSkyLight, - &a_Src[i * SegmentLength], - sizeof(NIBBLETYPE) * SegmentLength - ); + memcpy(&m_Sections[i]->m_BlockSkyLight, &a_Src[i * SegmentLength], sizeof(NIBBLETYPE) * SegmentLength); + continue; } - else + + // The section doesn't exist, find out if it is needed: + if (IsAllValue(a_Src + i * SegmentLength, SegmentLength, (NIBBLETYPE)0xff)) { - // j counts how many of leading zeros the buffer has - // if j == SegmentLength then the buffer is all zeros so there is no point - // creating the buffer. - size_t j = 0; - // do nothing whilst 0 - for (; (j < SegmentLength) && (a_Src[i * SegmentLength + j]) == 0xFF; j++); - if (j != SegmentLength) - { - m_Sections[i] = Allocate(); - memcpy( - &m_Sections[i]->m_BlockSkyLight, - &a_Src[i * SegmentLength], - sizeof(BLOCKTYPE) * SegmentLength - ); - memset( - m_Sections[i]->m_BlockTypes, - 0x00, - sizeof(m_Sections[i]->m_BlockTypes) - ); - memset( - m_Sections[i]->m_BlockMeta, - 0x00, - sizeof(m_Sections[i]->m_BlockMeta) - ); - memset( - m_Sections[i]->m_BlockLight, - 0x00, - sizeof(m_Sections[i]->m_BlockLight) - ); - } + // No need for the section, the data is all zeroes + continue; } - } + + // Allocate the section and copy the data into it: + m_Sections[i] = Allocate(); + memcpy(&m_Sections[i]->m_BlockSkyLight, &a_Src[i * SegmentLength], sizeof(BLOCKTYPE) * SegmentLength); + memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes)); + memset(m_Sections[i]->m_BlockMeta, 0x00, sizeof(m_Sections[i]->m_BlockMeta)); + memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight)); + } // for i - m_Sections[] } @@ -671,26 +580,10 @@ void cChunkData::Free(cChunkData::sChunkSection * a_Section) void cChunkData::ZeroSection(cChunkData::sChunkSection * a_Section) const { - memset( - a_Section->m_BlockTypes, - 0x00, - sizeof(a_Section->m_BlockTypes) - ); - memset( - a_Section->m_BlockMeta, - 0x00, - sizeof(a_Section->m_BlockMeta) - ); - memset( - a_Section->m_BlockLight, - 0x00, - sizeof(a_Section->m_BlockLight) - ); - memset( - a_Section->m_BlockSkyLight, - 0xFF, - sizeof(a_Section->m_BlockSkyLight) - ); + memset(a_Section->m_BlockTypes, 0x00, sizeof(a_Section->m_BlockTypes)); + memset(a_Section->m_BlockMeta, 0x00, sizeof(a_Section->m_BlockMeta)); + memset(a_Section->m_BlockLight, 0x00, sizeof(a_Section->m_BlockLight)); + memset(a_Section->m_BlockSkyLight, 0xff, sizeof(a_Section->m_BlockSkyLight)); } diff --git a/src/ChunkData.h b/src/ChunkData.h index e6aaa99b8..341c15301 100644 --- a/src/ChunkData.h +++ b/src/ChunkData.h @@ -1,4 +1,12 @@ +// ChunkData.h + +// Declares the cChunkData class that represents the block's type, meta, blocklight and skylight storage for a chunk + + + + + #pragma once @@ -20,7 +28,7 @@ class cChunkData { public: - cChunkData(); + cChunkData(void); ~cChunkData(); #if __cplusplus < 201103L @@ -43,25 +51,48 @@ public: NIBBLETYPE GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const; + /** Creates a (deep) copy of self. */ cChunkData Copy(void) const; - // Copys data from this object into the buffer in the a_Dest param - // CopyBlocks also povides the optional parameters a_Idx and a_Length which specify an offset and length for - // copying part of the BlockTypes array. - void CopyBlocks (BLOCKTYPE * a_Dest, size_t a_Idx = 0, size_t a_Length = cChunkDef::NumBlocks) const; - void CopyMeta (NIBBLETYPE * a_Dest) const; + /** Copies the blocktype data into the specified flat array. + Optionally, only a part of the data is copied, as specified by the a_Idx and a_Length parameters. */ + void CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx = 0, size_t a_Length = cChunkDef::NumBlocks) const; + + /** Copies the metadata into the specified flat array. */ + void CopyMetas(NIBBLETYPE * a_Dest) const; + + /** Copies the block light data into the specified flat array. */ void CopyBlockLight(NIBBLETYPE * a_Dest) const; + + /** Copies the skylight data into the specified flat array. */ void CopySkyLight (NIBBLETYPE * a_Dest) const; - void SetBlocks (const BLOCKTYPE * a_src); - void SetMeta (const NIBBLETYPE * a_src); - void SetBlockLight(const NIBBLETYPE * a_src); - void SetSkyLight (const NIBBLETYPE * a_src); + /** Copies the blocktype data from the specified flat array into the internal representation. + Allocates sections that are needed for the operation. + Requires that a_Src is a valid pointer. */ + void SetBlockTypes(const BLOCKTYPE * a_Src); + + /** Copies the metadata from the specified flat array into the internal representation. + Allocates sectios that are needed for the operation. + Requires that a_Src is a valid pointer. */ + void SetMetas(const NIBBLETYPE * a_Src); + + /** Copies the blocklight data from the specified flat array into the internal representation. + Allocates sectios that are needed for the operation. + Allows a_Src to be NULL, in which case it doesn't do anything. */ + void SetBlockLight(const NIBBLETYPE * a_Src); + + /** Copies the skylight data from the specified flat array into the internal representation. + Allocates sectios that are needed for the operation. + Allows a_Src to be NULL, in which case it doesn't do anything. */ + void SetSkyLight(const NIBBLETYPE * a_Src); private: - static const size_t CHUNK_SECTION_HEIGHT = 16; - static const size_t CHUNK_SECTION_COUNT = (256 / CHUNK_SECTION_HEIGHT); + static const size_t SectionHeight = 16; + static const size_t NumSections = (cChunkDef::Height / SectionHeight); + static const size_t SegmentLength = cChunkDef::Width * cChunkDef::Height * SectionHeight; + static const size_t SectionBlockCount = SectionHeight * cChunkDef::Width * cChunkDef::Width; #if __cplusplus < 201103L // auto_ptr style interface for memory management @@ -69,13 +100,13 @@ private: #endif struct sChunkSection { - BLOCKTYPE m_BlockTypes [CHUNK_SECTION_HEIGHT * 16 * 16]; - NIBBLETYPE m_BlockMeta [CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; - NIBBLETYPE m_BlockLight [CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; - NIBBLETYPE m_BlockSkyLight[CHUNK_SECTION_HEIGHT * 16 * 16 / 2]; + BLOCKTYPE m_BlockTypes [SectionBlockCount]; + NIBBLETYPE m_BlockMeta [SectionBlockCount / 2]; + NIBBLETYPE m_BlockLight [SectionBlockCount / 2]; + NIBBLETYPE m_BlockSkyLight[SectionBlockCount / 2]; }; - sChunkSection * m_Sections[CHUNK_SECTION_COUNT]; + sChunkSection * m_Sections[NumSections]; /** Allocates a new section. Entry-point to custom allocators. */ static sChunkSection * Allocate(void); diff --git a/src/ChunkDataCallback.h b/src/ChunkDataCallback.h index e916d6486..0c8b1098f 100644 --- a/src/ChunkDataCallback.h +++ b/src/ChunkDataCallback.h @@ -1,11 +1,20 @@ +// ChunkDataCallback.h + +// Declares the cChunkDataCallback interface and several trivial descendants, for reading chunk data + -#pragma once + +#pragma once + #include "ChunkData.h" + + + /** Interface class used for getting data out of a chunk using the GetAllData() function. Implementation must use the pointers immediately and NOT store any of them for later use The virtual methods are called in the same order as they're declared here. @@ -41,6 +50,10 @@ public: virtual void BlockEntity(cBlockEntity * a_Entity) {UNUSED(a_Entity); }; } ; + + + + /** A simple implementation of the cChunkDataCallback interface that collects all block data into a buffer */ class cChunkDataCollector : @@ -59,6 +72,9 @@ protected: }; + + + /** A simple implementation of the cChunkDataCallback interface that collects all block data into a single buffer */ class cChunkDataArrayCollector : @@ -73,15 +89,18 @@ protected: virtual void ChunkData(const cChunkData & a_ChunkBuffer) override { - a_ChunkBuffer.CopyBlocks(m_BlockData); - a_ChunkBuffer.CopyMeta(m_BlockData + cChunkDef::NumBlocks); + a_ChunkBuffer.CopyBlockTypes(m_BlockData); + a_ChunkBuffer.CopyMetas(m_BlockData + cChunkDef::NumBlocks); a_ChunkBuffer.CopyBlockLight(m_BlockData + 3 * cChunkDef::NumBlocks / 2); a_ChunkBuffer.CopySkyLight(m_BlockData + 2 * cChunkDef::NumBlocks); } }; -/** A simple implementation of the cChunkDataCallback interface that collects all block data into a separate buffers -*/ + + + + +/** A simple implementation of the cChunkDataCallback interface that collects all block data into separate buffers */ class cChunkDataSeparateCollector : public cChunkDataCallback { @@ -96,10 +115,13 @@ protected: virtual void ChunkData(const cChunkData & a_ChunkBuffer) override { - a_ChunkBuffer.CopyBlocks(m_BlockTypes); - a_ChunkBuffer.CopyMeta(m_BlockMetas); - a_ChunkBuffer.CopyBlockLight(m_BlockLight); - a_ChunkBuffer.CopySkyLight(m_BlockSkyLight); + a_ChunkBuffer.CopyBlockTypes(m_BlockTypes); + a_ChunkBuffer.CopyMetas(m_BlockMetas); + a_ChunkBuffer.CopyBlockLight(m_BlockLight); + a_ChunkBuffer.CopySkyLight(m_BlockSkyLight); } } ; + + + diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index 879252c34..dc19bf500 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -27,7 +27,7 @@ class cReader : { for (int z = 0; z < cChunkDef::Width; z++) { - a_ChunkBuffer.CopyBlocks(OutputRows + OutputIdx * 16, InputIdx * 16, 16); + a_ChunkBuffer.CopyBlockTypes(OutputRows + OutputIdx * 16, InputIdx * 16, 16); InputIdx++; OutputIdx += 3; } // for z -- cgit v1.2.3 From 80fe19c0e2e4433d8332dbe5a9c2fcba0be06f68 Mon Sep 17 00:00:00 2001 From: worktycho Date: Thu, 29 May 2014 17:41:07 +0100 Subject: Fixed overflow bug --- src/ChunkData.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index cc4793ec3..13be65fd7 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -333,25 +333,28 @@ cChunkData cChunkData::Copy(void) const void cChunkData::CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Length) const { - // TODO: This code seems wrong. It always copies into a_Dest[i * SegmentLength], even when a_Idx > 0 + size_t toskip = a_Idx; + for (size_t i = 0; i < NumSections; i++) { const size_t SegmentLength = SectionHeight * 16 * 16; - if (a_Idx > 0) + size_t startpos = 0; + if (toskip > 0) { - a_Idx = std::max(a_Idx - a_Length, (size_t) 0); + toskip = std::max(toskip - SegmentLength, (size_t) 0); + startpos = SegmentLength - toskip; } - if (a_Idx == 0) + if (toskip == 0) { size_t ToCopy = std::min(SegmentLength, a_Length); a_Length -= ToCopy; if (m_Sections[i] != NULL) { - memcpy(&a_Dest[i * SegmentLength], &m_Sections[i]->m_BlockTypes, sizeof(BLOCKTYPE) * ToCopy); + memcpy(&a_Dest[(i * SegmentLength) - a_Idx], (&m_Sections[i]->m_BlockTypes) + startpos, sizeof(BLOCKTYPE) * (ToCopy - startpos)); } else { - memset(&a_Dest[i * SegmentLength], 0, sizeof(BLOCKTYPE) * ToCopy); + memset(&a_Dest[(i * SegmentLength) - a_Idx], 0, sizeof(BLOCKTYPE) * (ToCopy - startpos)); } } } -- cgit v1.2.3 From b4ba2209342d536e83b3461db00e9f9fd811120e Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 29 May 2014 19:21:56 +0200 Subject: Add SetOpen() and IsOpen() to BlockDoor.h and fix door redstone bug. --- src/Blocks/BlockDoor.h | 89 +++++++++++++++++++++++--- src/Simulator/IncrementalRedstoneSimulator.cpp | 14 ++-- 2 files changed, 90 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index 797fe484c..b5bfe4082 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -20,12 +20,12 @@ public: virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override; virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override; virtual const char * GetStepSound(void) override; - + virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override; virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override; virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override; virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override; - + virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, @@ -52,7 +52,7 @@ public: return true; } - + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { a_Pickups.push_back(cItem((m_BlockType == E_BLOCK_WOODEN_DOOR) ? E_ITEM_WOODEN_DOOR : E_ITEM_IRON_DOOR, 1, 0)); @@ -77,8 +77,8 @@ public: { return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR)); } - - + + bool CanReplaceBlock(BLOCKTYPE a_BlockType) { switch (a_BlockType) @@ -99,7 +99,7 @@ public: } - /// Converts the player's yaw to placed door's blockmeta + /** Converts the player's yaw to placed door's blockmeta */ inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw) { ASSERT((a_Yaw >= -180) && (a_Yaw < 180)); @@ -128,21 +128,92 @@ public: } - /// Returns true if the specified blocktype is any kind of door + /** Returns true if the specified blocktype is any kind of door */ inline static bool IsDoor(BLOCKTYPE a_Block) { return (a_Block == E_BLOCK_WOODEN_DOOR) || (a_Block == E_BLOCK_IRON_DOOR); } - /// Returns the metadata for the opposite door state (open vs closed) + /** Returns the metadata for the opposite door state (open vs closed) */ static NIBBLETYPE ChangeStateMetaData(NIBBLETYPE a_MetaData) { return a_MetaData ^ 4; } - /// Changes the door at the specified coords from open to close or vice versa + static bool IsOpen(cChunkInterface & a_ChunkInterface, int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) + { + BLOCKTYPE Block; + NIBBLETYPE Meta; + a_ChunkInterface.GetBlockTypeMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Block, Meta); + + if (!IsDoor(Block)) + { + return false; + } + + return ((Meta & 0x4) == 4); + } + + + static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) + { + BLOCKTYPE Block; + NIBBLETYPE Meta; + a_ChunkInterface.GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, Meta); + + if (!IsDoor(Block) || ((Meta & 0x4) == a_Open)) + { + return; + } + + // Change the door + if (a_Open) + { + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); + } + else + { + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xFFFFFFFB); + } + + int OtherPartY = a_BlockY; + if (Meta & 0x8) + { + // Current block is top of the door + a_ChunkInterface.GetBlockTypeMeta(a_BlockX, a_BlockY - 1, a_BlockZ, Block, Meta); + if (IsDoor(Block) && !(Meta & 0x8)) + { + OtherPartY--; + } + } + else + { + // Current block is bottom of the door + a_ChunkInterface.GetBlockTypeMeta(a_BlockX, a_BlockY + 1, a_BlockZ, Block, Meta); + if (IsDoor(Block) && (Meta & 0x8)) + { + OtherPartY++; + } + } + + // Change the other door part + if (a_BlockY != OtherPartY) + { + if (a_Open) + { + a_ChunkInterface.SetBlockMeta(a_BlockX, OtherPartY, a_BlockZ, Meta | 0x4); + } + else + { + a_ChunkInterface.SetBlockMeta(a_BlockX, OtherPartY, a_BlockZ, Meta & 0xFFFFFFFB); + } + } + } + + + /** Changes the door at the specified coords from open to close or vice versa */ static void ChangeDoor(cChunkInterface & a_ChunkInterface, int a_X, int a_Y, int a_Z) { NIBBLETYPE OldMetaData = a_ChunkInterface.GetBlockMeta(a_X, a_Y, a_Z); diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 074063add..d49142e4f 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -906,8 +906,11 @@ void cIncrementalRedstoneSimulator::HandleDoor(int a_RelBlockX, int a_RelBlockY, if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true)) { cChunkInterface ChunkInterface(m_World.GetChunkMap()); - cBlockDoorHandler::ChangeDoor(ChunkInterface, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + if (!cBlockDoorHandler::IsOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ)) + { + cBlockDoorHandler::SetOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ, true); + m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + } SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true); } } @@ -916,8 +919,11 @@ void cIncrementalRedstoneSimulator::HandleDoor(int a_RelBlockX, int a_RelBlockY, if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false)) { cChunkInterface ChunkInterface(m_World.GetChunkMap()); - cBlockDoorHandler::ChangeDoor(ChunkInterface, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + if (cBlockDoorHandler::IsOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ)) + { + cBlockDoorHandler::SetOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ, false); + m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + } SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false); } } -- cgit v1.2.3 From 0cfee5d141f63d0d9ee339e4fab3ad8ac15f884d Mon Sep 17 00:00:00 2001 From: worktycho Date: Thu, 29 May 2014 19:10:35 +0100 Subject: Fixed Wrong types in nibble sizeofs --- src/ChunkData.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 13be65fd7..46bd0b946 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -375,7 +375,7 @@ void cChunkData::CopyMetas(NIBBLETYPE * a_Dest) const } else { - memset(&a_Dest[i * SegmentLength], 0, sizeof(BLOCKTYPE) * SegmentLength); + memset(&a_Dest[i * SegmentLength], 0, sizeof(NIBBLETYPE) * SegmentLength); } } } @@ -395,7 +395,7 @@ void cChunkData::CopyBlockLight(NIBBLETYPE * a_Dest) const } else { - memset(&a_Dest[i * SegmentLength], 0, sizeof(BLOCKTYPE) * SegmentLength); + memset(&a_Dest[i * SegmentLength], 0, sizeof(NIBBLETYPE) * SegmentLength); } } } @@ -415,7 +415,7 @@ void cChunkData::CopySkyLight(NIBBLETYPE * a_Dest) const } else { - memset(&a_Dest[i * SegmentLength], 0xff, sizeof(BLOCKTYPE) * SegmentLength); + memset(&a_Dest[i * SegmentLength], 0xff, sizeof(NIBBLETYPE) * SegmentLength); } } } -- cgit v1.2.3 From ab633c8bd65b333630053334cb1119f38788698d Mon Sep 17 00:00:00 2001 From: JoannisO Date: Thu, 29 May 2014 20:19:36 +0200 Subject: - Prefixed all args with "a_" - Added braces around the cases. --- src/BlockEntities/DispenserEntity.cpp | 14 +++++++++----- src/BlockEntities/DispenserEntity.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 341994be8..799d41a1e 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -196,15 +196,15 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) -void cDispenserEntity::SpawnProjectileFromDispenser(cChunk & a_Chunk, int & DispX, int & DispY, int & DispZ, cProjectileEntity::eKind kind) +void cDispenserEntity::SpawnProjectileFromDispenser(cChunk & a_Chunk, int & a_DispX, int & a_DispY, int & a_DispZ, cProjectileEntity::eKind a_kind) { Vector3d Angle = GetProjectileLookVector(a_Chunk); - cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ); + cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(a_DispX, a_DispZ); - double EntityX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width); - double EntityZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); + double EntityX = 0.5 + (a_DispX + DispChunk->GetPosX() * cChunkDef::Width); + double EntityZ = 0.5 + (a_DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - m_World->CreateProjectile((double) EntityX, (double) DispY + 0.5, (double) EntityZ, kind, NULL, NULL, &Angle); + m_World->CreateProjectile((double) EntityX, (double) a_DispY + 0.5, (double) EntityZ, a_kind, NULL, NULL, &Angle); } @@ -219,16 +219,20 @@ Vector3d cDispenserEntity::GetProjectileLookVector(cChunk & a_Chunk) switch (Meta) { case E_META_DROPSPENSER_FACING_YP: + { m.Init(Vector3d(), 0, 180, 0); Look = m.Transform(Vector3d(0, 1, 0)); return Look * 20; // UP + } case E_META_DROPSPENSER_FACING_YM: + { m.Init(Vector3d(), 0, -360, 0); Look = m.Transform(Vector3d(0, -1, 0)); return Look * 20;; // DOWN + } case E_META_DROPSPENSER_FACING_XM: Direction = 90; break; // WEST case E_META_DROPSPENSER_FACING_XP: Direction = 270; break; // EAST diff --git a/src/BlockEntities/DispenserEntity.h b/src/BlockEntities/DispenserEntity.h index 0b7cd6bea..76aaccd3c 100644 --- a/src/BlockEntities/DispenserEntity.h +++ b/src/BlockEntities/DispenserEntity.h @@ -30,7 +30,7 @@ private: bool ScoopUpLiquid(int a_SlotNum, short a_BucketItemType); // Spawns a projectile of the given kind in front of the dispenser - void SpawnProjectileFromDispenser(cChunk & a_Chunk, int & DispX, int & DispY, int & DispZ, cProjectileEntity::eKind kind); + void SpawnProjectileFromDispenser(cChunk & a_Chunk, int & a_DispX, int & a_DispY, int & a_DispZ, cProjectileEntity::eKind a_kind); // Returns how to aim the projectile Vector3d GetProjectileLookVector(cChunk & a_Chunk); -- cgit v1.2.3 From 59068b77b7215461b4aaf11c2db91c1657b7f91d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 29 May 2014 20:18:37 +0200 Subject: Fixed wrong block sizes for copying / setting. --- src/ChunkData.cpp | 75 ++++++++++++++++++++++++++----------------------------- src/ChunkData.h | 3 +-- 2 files changed, 36 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 46bd0b946..2628b3410 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -208,7 +208,7 @@ NIBBLETYPE cChunkData::GetMeta(int a_RelX, int a_RelY, int a_RelZ) const if (m_Sections[Section] != NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ); - return (m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4)) & 0x0f; + return (m_Sections[Section]->m_BlockMetas[Index / 2] >> ((Index & 1) * 4)) & 0x0f; } else { @@ -251,9 +251,9 @@ bool cChunkData::SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble ZeroSection(m_Sections[Section]); } int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ); - NIBBLETYPE oldval = m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4) & 0xf; - m_Sections[Section]->m_BlockMeta[Index / 2] = static_cast( - (m_Sections[Section]->m_BlockMeta[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble + NIBBLETYPE oldval = m_Sections[Section]->m_BlockMetas[Index / 2] >> ((Index & 1) * 4) & 0xf; + m_Sections[Section]->m_BlockMetas[Index / 2] = static_cast( + (m_Sections[Section]->m_BlockMetas[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set ); return oldval == a_Nibble; @@ -333,28 +333,27 @@ cChunkData cChunkData::Copy(void) const void cChunkData::CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Length) const { - size_t toskip = a_Idx; + size_t ToSkip = a_Idx; for (size_t i = 0; i < NumSections; i++) { - const size_t SegmentLength = SectionHeight * 16 * 16; - size_t startpos = 0; - if (toskip > 0) + size_t StartPos = 0; + if (ToSkip > 0) { - toskip = std::max(toskip - SegmentLength, (size_t) 0); - startpos = SegmentLength - toskip; + ToSkip = std::max(ToSkip - SectionBlockCount, (size_t) 0); // TODO: Still can underflow + StartPos = SectionBlockCount - ToSkip; } - if (toskip == 0) + if (ToSkip == 0) { - size_t ToCopy = std::min(SegmentLength, a_Length); + size_t ToCopy = std::min(SectionBlockCount, a_Length); a_Length -= ToCopy; if (m_Sections[i] != NULL) { - memcpy(&a_Dest[(i * SegmentLength) - a_Idx], (&m_Sections[i]->m_BlockTypes) + startpos, sizeof(BLOCKTYPE) * (ToCopy - startpos)); + memcpy(&a_Dest[(i * SectionBlockCount) - a_Idx], (&m_Sections[i]->m_BlockTypes) + StartPos, sizeof(BLOCKTYPE) * (ToCopy - StartPos)); } else { - memset(&a_Dest[(i * SegmentLength) - a_Idx], 0, sizeof(BLOCKTYPE) * (ToCopy - startpos)); + memset(&a_Dest[(i * SectionBlockCount) - a_Idx], 0, sizeof(BLOCKTYPE) * (ToCopy - StartPos)); } } } @@ -368,14 +367,13 @@ void cChunkData::CopyMetas(NIBBLETYPE * a_Dest) const { for (size_t i = 0; i < NumSections; i++) { - const size_t SegmentLength = SectionHeight * 16 * 16 / 2; if (m_Sections[i] != NULL) { - memcpy(&a_Dest[i * SegmentLength], &m_Sections[i]->m_BlockMeta, sizeof(NIBBLETYPE) * SegmentLength); + memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockMetas, sizeof(m_Sections[i]->m_BlockMetas)); } else { - memset(&a_Dest[i * SegmentLength], 0, sizeof(NIBBLETYPE) * SegmentLength); + memset(&a_Dest[i * SectionBlockCount / 2], 0, sizeof(m_Sections[i]->m_BlockMetas)); } } } @@ -388,14 +386,13 @@ void cChunkData::CopyBlockLight(NIBBLETYPE * a_Dest) const { for (size_t i = 0; i < NumSections; i++) { - const size_t SegmentLength = SectionHeight * 16 * 16 / 2; if (m_Sections[i] != NULL) { - memcpy(&a_Dest[i * SegmentLength], &m_Sections[i]->m_BlockLight, sizeof(NIBBLETYPE) * SegmentLength); + memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockLight, sizeof(m_Sections[i]->m_BlockLight)); } else { - memset(&a_Dest[i * SegmentLength], 0, sizeof(NIBBLETYPE) * SegmentLength); + memset(&a_Dest[i * SectionBlockCount / 2], 0, sizeof(m_Sections[i]->m_BlockLight)); } } } @@ -408,14 +405,13 @@ void cChunkData::CopySkyLight(NIBBLETYPE * a_Dest) const { for (size_t i = 0; i < NumSections; i++) { - const size_t SegmentLength = SectionHeight * 16 * 16 / 2; if (m_Sections[i] != NULL) { - memcpy(&a_Dest[i * SegmentLength], &m_Sections[i]->m_BlockSkyLight, sizeof(NIBBLETYPE) * SegmentLength); + memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockSkyLight, sizeof(m_Sections[i]->m_BlockSkyLight)); } else { - memset(&a_Dest[i * SegmentLength], 0xff, sizeof(NIBBLETYPE) * SegmentLength); + memset(&a_Dest[i * SectionBlockCount / 2], 0xff, sizeof(m_Sections[i]->m_BlockSkyLight)); } } } @@ -428,18 +424,17 @@ void cChunkData::SetBlockTypes(const BLOCKTYPE * a_Src) { ASSERT(a_Src != NULL); - static const size_t SegmentLength = SectionHeight * 16 * 16; for (size_t i = 0; i < NumSections; i++) { // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy(&m_Sections[i]->m_BlockTypes, &a_Src[i * SegmentLength], sizeof(BLOCKTYPE) * SegmentLength); + memcpy(&m_Sections[i]->m_BlockTypes, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockTypes)); continue; } // The section doesn't exist, find out if it is needed: - if (IsAllValue(a_Src + i * SegmentLength, SegmentLength, (const BLOCKTYPE)0)) + if (IsAllValue(a_Src + i * SectionBlockCount, SectionBlockCount, (const BLOCKTYPE)0)) { // No need for the section, the data is all-air continue; @@ -447,8 +442,8 @@ void cChunkData::SetBlockTypes(const BLOCKTYPE * a_Src) // Allocate the section and copy the data into it: m_Sections[i] = Allocate(); - memcpy(&m_Sections[i]->m_BlockTypes, &a_Src[i * SegmentLength], sizeof(BLOCKTYPE) * SegmentLength); - memset(m_Sections[i]->m_BlockMeta, 0x00, sizeof(m_Sections[i]->m_BlockMeta)); + memcpy(&m_Sections[i]->m_BlockTypes, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockTypes)); + memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas)); memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight)); memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight)); } // for i - m_Sections[] @@ -466,12 +461,12 @@ void cChunkData::SetMetas(const NIBBLETYPE * a_Src) // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy(&m_Sections[i]->m_BlockMeta, &a_Src[i * SegmentLength], sizeof(NIBBLETYPE) * SegmentLength); + memcpy(&m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockMetas)); continue; } // The section doesn't exist, find out if it is needed: - if (IsAllValue(a_Src + i * SegmentLength, SegmentLength, (NIBBLETYPE)0)) + if (IsAllValue(a_Src + i * SectionBlockCount, SectionBlockCount, (NIBBLETYPE)0)) { // No need for the section, the data is all zeroes continue; @@ -479,7 +474,7 @@ void cChunkData::SetMetas(const NIBBLETYPE * a_Src) // Allocate the section and copy the data into it: m_Sections[i] = Allocate(); - memcpy(&m_Sections[i]->m_BlockMeta, &a_Src[i * SegmentLength], sizeof(BLOCKTYPE) * SegmentLength); + memcpy(&m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockMetas)); memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes)); memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight)); memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight)); @@ -502,12 +497,12 @@ void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src) // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy(&m_Sections[i]->m_BlockLight, &a_Src[i * SegmentLength], sizeof(NIBBLETYPE) * SegmentLength); + memcpy(&m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount], sizeof(NIBBLETYPE) * SectionBlockCount); continue; } // The section doesn't exist, find out if it is needed: - if (IsAllValue(a_Src + i * SegmentLength, SegmentLength, (NIBBLETYPE)0)) + if (IsAllValue(a_Src + i * SectionBlockCount, SectionBlockCount, (NIBBLETYPE)0)) { // No need for the section, the data is all zeroes continue; @@ -515,9 +510,9 @@ void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src) // Allocate the section and copy the data into it: m_Sections[i] = Allocate(); - memcpy(&m_Sections[i]->m_BlockLight, &a_Src[i * SegmentLength], sizeof(BLOCKTYPE) * SegmentLength); + memcpy(&m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount], sizeof(BLOCKTYPE) * SectionBlockCount); memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes)); - memset(m_Sections[i]->m_BlockMeta, 0x00, sizeof(m_Sections[i]->m_BlockMeta)); + memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas)); memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight)); } // for i - m_Sections[] } @@ -537,12 +532,12 @@ void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src) // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy(&m_Sections[i]->m_BlockSkyLight, &a_Src[i * SegmentLength], sizeof(NIBBLETYPE) * SegmentLength); + memcpy(&m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount], sizeof(NIBBLETYPE) * SectionBlockCount); continue; } // The section doesn't exist, find out if it is needed: - if (IsAllValue(a_Src + i * SegmentLength, SegmentLength, (NIBBLETYPE)0xff)) + if (IsAllValue(a_Src + i * SectionBlockCount, SectionBlockCount, (NIBBLETYPE)0xff)) { // No need for the section, the data is all zeroes continue; @@ -550,9 +545,9 @@ void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src) // Allocate the section and copy the data into it: m_Sections[i] = Allocate(); - memcpy(&m_Sections[i]->m_BlockSkyLight, &a_Src[i * SegmentLength], sizeof(BLOCKTYPE) * SegmentLength); + memcpy(&m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount], sizeof(BLOCKTYPE) * SectionBlockCount); memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes)); - memset(m_Sections[i]->m_BlockMeta, 0x00, sizeof(m_Sections[i]->m_BlockMeta)); + memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas)); memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight)); } // for i - m_Sections[] } @@ -584,7 +579,7 @@ void cChunkData::Free(cChunkData::sChunkSection * a_Section) void cChunkData::ZeroSection(cChunkData::sChunkSection * a_Section) const { memset(a_Section->m_BlockTypes, 0x00, sizeof(a_Section->m_BlockTypes)); - memset(a_Section->m_BlockMeta, 0x00, sizeof(a_Section->m_BlockMeta)); + memset(a_Section->m_BlockMetas, 0x00, sizeof(a_Section->m_BlockMetas)); memset(a_Section->m_BlockLight, 0x00, sizeof(a_Section->m_BlockLight)); memset(a_Section->m_BlockSkyLight, 0xff, sizeof(a_Section->m_BlockSkyLight)); } diff --git a/src/ChunkData.h b/src/ChunkData.h index 341c15301..fef31b5ad 100644 --- a/src/ChunkData.h +++ b/src/ChunkData.h @@ -91,7 +91,6 @@ private: static const size_t SectionHeight = 16; static const size_t NumSections = (cChunkDef::Height / SectionHeight); - static const size_t SegmentLength = cChunkDef::Width * cChunkDef::Height * SectionHeight; static const size_t SectionBlockCount = SectionHeight * cChunkDef::Width * cChunkDef::Width; #if __cplusplus < 201103L @@ -101,7 +100,7 @@ private: struct sChunkSection { BLOCKTYPE m_BlockTypes [SectionBlockCount]; - NIBBLETYPE m_BlockMeta [SectionBlockCount / 2]; + NIBBLETYPE m_BlockMetas [SectionBlockCount / 2]; NIBBLETYPE m_BlockLight [SectionBlockCount / 2]; NIBBLETYPE m_BlockSkyLight[SectionBlockCount / 2]; }; -- cgit v1.2.3 From b50181e3614286b9624cf3b8f296d7b25509a55d Mon Sep 17 00:00:00 2001 From: worktycho Date: Thu, 29 May 2014 19:29:06 +0100 Subject: fix underflow Wish c++ could specify saturating unsigned underflow. --- src/ChunkData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 2628b3410..72187f393 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -340,7 +340,7 @@ void cChunkData::CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Lengt size_t StartPos = 0; if (ToSkip > 0) { - ToSkip = std::max(ToSkip - SectionBlockCount, (size_t) 0); // TODO: Still can underflow + ToSkip = std::max((ssize_t)ToSkip - (ssize_t)SectionBlockCount, (size_t) 0); StartPos = SectionBlockCount - ToSkip; } if (ToSkip == 0) -- cgit v1.2.3 From 901e3ec4940f2a11f7866194f02732c813ce71b9 Mon Sep 17 00:00:00 2001 From: worktycho Date: Thu, 29 May 2014 19:35:47 +0100 Subject: Derp --- src/ChunkData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 72187f393..382e7a5a8 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -340,7 +340,7 @@ void cChunkData::CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Lengt size_t StartPos = 0; if (ToSkip > 0) { - ToSkip = std::max((ssize_t)ToSkip - (ssize_t)SectionBlockCount, (size_t) 0); + ToSkip = std::max((ssize_t)ToSkip - (ssize_t)SectionBlockCount, (ssize_t) 0); StartPos = SectionBlockCount - ToSkip; } if (ToSkip == 0) -- cgit v1.2.3 From be10f07db02565fad77937bc6e9ccc6580f19158 Mon Sep 17 00:00:00 2001 From: worktycho Date: Thu, 29 May 2014 19:44:36 +0100 Subject: Fix bug when a_Idx is not a multiple of SectionBLockCount --- src/ChunkData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 382e7a5a8..be96be051 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -343,7 +343,7 @@ void cChunkData::CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Lengt ToSkip = std::max((ssize_t)ToSkip - (ssize_t)SectionBlockCount, (ssize_t) 0); StartPos = SectionBlockCount - ToSkip; } - if (ToSkip == 0) + if (ToSkip < SectionBlockCount) { size_t ToCopy = std::min(SectionBlockCount, a_Length); a_Length -= ToCopy; -- cgit v1.2.3 From 8c4dd5dcfd91f8223e78ff7fd24f8e4e73d1f509 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 29 May 2014 21:41:44 +0200 Subject: Attempt at fixing an unresolved symbol in gcc / clang. --- src/ChunkData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index be96be051..74f5d78ba 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -345,7 +345,7 @@ void cChunkData::CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Lengt } if (ToSkip < SectionBlockCount) { - size_t ToCopy = std::min(SectionBlockCount, a_Length); + size_t ToCopy = std::min(+SectionBlockCount, a_Length); a_Length -= ToCopy; if (m_Sections[i] != NULL) { -- cgit v1.2.3 From 0e2138736cd969a0dc931bbef31262da906cb832 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 30 May 2014 09:17:17 +0200 Subject: Fixed wrong copy sizes in cChunkData. --- src/ChunkData.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 74f5d78ba..5c11212ea 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -333,14 +333,14 @@ cChunkData cChunkData::Copy(void) const void cChunkData::CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Length) const { - size_t ToSkip = a_Idx; + int ToSkip = a_Idx; for (size_t i = 0; i < NumSections; i++) { size_t StartPos = 0; if (ToSkip > 0) { - ToSkip = std::max((ssize_t)ToSkip - (ssize_t)SectionBlockCount, (ssize_t) 0); + ToSkip = std::max(ToSkip - (int)SectionBlockCount, 0); StartPos = SectionBlockCount - ToSkip; } if (ToSkip < SectionBlockCount) @@ -429,7 +429,7 @@ void cChunkData::SetBlockTypes(const BLOCKTYPE * a_Src) // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy(&m_Sections[i]->m_BlockTypes, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockTypes)); + memcpy(m_Sections[i]->m_BlockTypes, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockTypes)); continue; } @@ -442,7 +442,7 @@ void cChunkData::SetBlockTypes(const BLOCKTYPE * a_Src) // Allocate the section and copy the data into it: m_Sections[i] = Allocate(); - memcpy(&m_Sections[i]->m_BlockTypes, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockTypes)); + memcpy(m_Sections[i]->m_BlockTypes, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockTypes)); memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas)); memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight)); memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight)); @@ -461,7 +461,7 @@ void cChunkData::SetMetas(const NIBBLETYPE * a_Src) // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy(&m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockMetas)); + memcpy(m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockMetas)); continue; } @@ -474,7 +474,7 @@ void cChunkData::SetMetas(const NIBBLETYPE * a_Src) // Allocate the section and copy the data into it: m_Sections[i] = Allocate(); - memcpy(&m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockMetas)); + memcpy(m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockMetas)); memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes)); memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight)); memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight)); @@ -497,7 +497,7 @@ void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src) // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy(&m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount], sizeof(NIBBLETYPE) * SectionBlockCount); + memcpy(m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockLight)); continue; } @@ -510,7 +510,7 @@ void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src) // Allocate the section and copy the data into it: m_Sections[i] = Allocate(); - memcpy(&m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount], sizeof(BLOCKTYPE) * SectionBlockCount); + memcpy(m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockLight)); memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes)); memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas)); memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight)); @@ -532,7 +532,7 @@ void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src) // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy(&m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount], sizeof(NIBBLETYPE) * SectionBlockCount); + memcpy(m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockSkyLight)); continue; } @@ -545,7 +545,7 @@ void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src) // Allocate the section and copy the data into it: m_Sections[i] = Allocate(); - memcpy(&m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount], sizeof(BLOCKTYPE) * SectionBlockCount); + memcpy(m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockSkyLight)); memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes)); memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas)); memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight)); -- cgit v1.2.3 From 5368c5dd79bce465d32517eec62701abc9b380d9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 30 May 2014 09:49:57 +0200 Subject: Fixed sign comparison. --- src/ChunkData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 5c11212ea..6ccb28fe4 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -343,7 +343,7 @@ void cChunkData::CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Lengt ToSkip = std::max(ToSkip - (int)SectionBlockCount, 0); StartPos = SectionBlockCount - ToSkip; } - if (ToSkip < SectionBlockCount) + if (ToSkip < (int)SectionBlockCount) { size_t ToCopy = std::min(+SectionBlockCount, a_Length); a_Length -= ToCopy; -- cgit v1.2.3 From 0b60caac4ae8e7762cc530a0a7b6a7abe8c33262 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 30 May 2014 10:56:12 +0200 Subject: Test failures are reported verbosely and into the debug console on Win. --- src/Globals.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Globals.h b/src/Globals.h index 85cfd2f18..7b7a34541 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -271,9 +271,25 @@ void inline LOGERROR(const char* a_Format, ...) { }; + #ifdef _WIN32 + #define REPORT_ERROR(FMT, ...) \ + { \ + AString msg = Printf(FMT, __VA_ARGS__); \ + puts(msg.c_str()); \ + fflush(stdout); \ + OutputDebugStringA(msg.c_str()); \ + } + #else + #define REPORT_ERROR(FMT, ...) \ + { \ + AString msg = Printf(FMT, __VA_ARGS__); \ + puts(msg.c_str()); \ + fflush(stdout); \ + } + #endif #define ASSERT(x) do { if (!(x)) { throw cAssertFailure();} } while (0) - #define testassert(x) do { if(!(x)) { exit(1); } } while (0) - #define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } exit(1); } while (0) + #define testassert(x) do { if(!(x)) { REPORT_ERROR("Test failure: %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } } while (0) + #define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } REPORT_ERROR("Test failure: assert didn't fire for %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } while (0) #else #ifdef _DEBUG -- cgit v1.2.3 From 730e36844e152794cf85c4d1e9b7a84fd8be86ee Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 30 May 2014 11:01:13 +0200 Subject: Test failures break into MSVC debugger. --- src/Globals.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/Globals.h b/src/Globals.h index 7b7a34541..c5768facf 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -272,12 +272,18 @@ void inline LOGERROR(const char* a_Format, ...) }; #ifdef _WIN32 + #if (defined(_MSC_VER) && defined(_DEBUG)) + #define DBG_BREAK _CrtDbgBreak() + #else + #define DBG_BREAK + #endif #define REPORT_ERROR(FMT, ...) \ { \ AString msg = Printf(FMT, __VA_ARGS__); \ puts(msg.c_str()); \ fflush(stdout); \ OutputDebugStringA(msg.c_str()); \ + DBG_BREAK; \ } #else #define REPORT_ERROR(FMT, ...) \ -- cgit v1.2.3 From e136f6e0f5b41ee7c9d784009ef40c9ac2e2e6fe Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 30 May 2014 11:35:29 +0200 Subject: Fixed cChunkData nibble copying. --- src/ChunkData.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 6ccb28fe4..6178dbc0d 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -461,12 +461,12 @@ void cChunkData::SetMetas(const NIBBLETYPE * a_Src) // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy(m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockMetas)); + memcpy(m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockMetas)); continue; } // The section doesn't exist, find out if it is needed: - if (IsAllValue(a_Src + i * SectionBlockCount, SectionBlockCount, (NIBBLETYPE)0)) + if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, (NIBBLETYPE)0)) { // No need for the section, the data is all zeroes continue; @@ -474,7 +474,7 @@ void cChunkData::SetMetas(const NIBBLETYPE * a_Src) // Allocate the section and copy the data into it: m_Sections[i] = Allocate(); - memcpy(m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockMetas)); + memcpy(m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockMetas)); memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes)); memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight)); memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight)); @@ -497,12 +497,12 @@ void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src) // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy(m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockLight)); + memcpy(m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockLight)); continue; } // The section doesn't exist, find out if it is needed: - if (IsAllValue(a_Src + i * SectionBlockCount, SectionBlockCount, (NIBBLETYPE)0)) + if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, (NIBBLETYPE)0)) { // No need for the section, the data is all zeroes continue; @@ -510,7 +510,7 @@ void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src) // Allocate the section and copy the data into it: m_Sections[i] = Allocate(); - memcpy(m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockLight)); + memcpy(m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockLight)); memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes)); memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas)); memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight)); @@ -532,12 +532,12 @@ void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src) // If the section is already allocated, copy the data into it: if (m_Sections[i] != NULL) { - memcpy(m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockSkyLight)); + memcpy(m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockSkyLight)); continue; } // The section doesn't exist, find out if it is needed: - if (IsAllValue(a_Src + i * SectionBlockCount, SectionBlockCount, (NIBBLETYPE)0xff)) + if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, (NIBBLETYPE)0xff)) { // No need for the section, the data is all zeroes continue; @@ -545,7 +545,7 @@ void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src) // Allocate the section and copy the data into it: m_Sections[i] = Allocate(); - memcpy(m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockSkyLight)); + memcpy(m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockSkyLight)); memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes)); memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas)); memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight)); -- cgit v1.2.3 From d854d3af1c724304997488d2b61518c85acb076a Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 30 May 2014 14:43:33 +0100 Subject: removed unneded addressof --- src/ChunkData.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 6178dbc0d..258853ea0 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -55,6 +55,7 @@ cChunkData::~cChunkData() for (size_t i = 0; i < NumSections; i++) { Free(m_Sections[i]); + m_Sections[i] = NULL; } } @@ -93,6 +94,7 @@ cChunkData::~cChunkData() for (size_t i = 0; i < NumSections; i++) { Free(m_Sections[i]); + m_Sections[i] = NULL; } } @@ -101,6 +103,7 @@ cChunkData::~cChunkData() for (size_t i = 0; i < NumSections; i++) { m_Sections[i] = a_Other.m_Sections[i]; + a_Other.m_Sections[i] = NULL; } a_Other.m_IsOwner = false; return *this; @@ -333,27 +336,28 @@ cChunkData cChunkData::Copy(void) const void cChunkData::CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Length) const { - int ToSkip = a_Idx; + size_t ToSkip = a_Idx; for (size_t i = 0; i < NumSections; i++) { size_t StartPos = 0; if (ToSkip > 0) { - ToSkip = std::max(ToSkip - (int)SectionBlockCount, 0); - StartPos = SectionBlockCount - ToSkip; + StartPos = std::min(ToSkip, +SectionBlockCount); + ToSkip -= StartPos; } - if (ToSkip < (int)SectionBlockCount) + if (StartPos < SectionBlockCount) { - size_t ToCopy = std::min(+SectionBlockCount, a_Length); + size_t ToCopy = std::min(+SectionBlockCount - StartPos, a_Length); a_Length -= ToCopy; if (m_Sections[i] != NULL) { - memcpy(&a_Dest[(i * SectionBlockCount) - a_Idx], (&m_Sections[i]->m_BlockTypes) + StartPos, sizeof(BLOCKTYPE) * (ToCopy - StartPos)); + BLOCKTYPE * blockbuffer = m_Sections[i]->m_BlockTypes; + memcpy(&a_Dest[(i * SectionBlockCount) + StartPos - a_Idx], blockbuffer + StartPos, sizeof(BLOCKTYPE) * ToCopy); } else { - memset(&a_Dest[(i * SectionBlockCount) - a_Idx], 0, sizeof(BLOCKTYPE) * (ToCopy - StartPos)); + memset(&a_Dest[(i * SectionBlockCount) - a_Idx], 0, sizeof(BLOCKTYPE) * ToCopy); } } } -- cgit v1.2.3 From f26ddac61944ccae3223be5c4403171e04e306b9 Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 30 May 2014 14:50:30 +0100 Subject: removed NULL assignment to const value --- src/ChunkData.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 258853ea0..142c141c4 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -103,7 +103,6 @@ cChunkData::~cChunkData() for (size_t i = 0; i < NumSections; i++) { m_Sections[i] = a_Other.m_Sections[i]; - a_Other.m_Sections[i] = NULL; } a_Other.m_IsOwner = false; return *this; -- cgit v1.2.3 From d8e16f8c1fa771f77ef7505b45b9114b1f75aa61 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 30 May 2014 22:22:42 +0200 Subject: Better SetOpen() and IsOpen() function from the doors. --- src/Blocks/BlockDoor.cpp | 2 +- src/Blocks/BlockDoor.h | 102 ++++++++++++----------------------------------- 2 files changed, 27 insertions(+), 77 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp index 479c68153..fb2d6f2dc 100644 --- a/src/Blocks/BlockDoor.cpp +++ b/src/Blocks/BlockDoor.cpp @@ -62,7 +62,7 @@ void cBlockDoorHandler::OnCancelRightClick(cChunkInterface & a_ChunkInterface, c a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - if (Meta & 8) + if (Meta & 0x8) { // Current block is top of the door a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, a_Player); diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index b5bfe4082..c1e4de9d4 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -135,113 +135,63 @@ public: } - /** Returns the metadata for the opposite door state (open vs closed) */ - static NIBBLETYPE ChangeStateMetaData(NIBBLETYPE a_MetaData) + static NIBBLETYPE IsOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - return a_MetaData ^ 4; + NIBBLETYPE Meta = GetMetaFromRightDoor(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); + return ((Meta & 0x4) != 0); } - static bool IsOpen(cChunkInterface & a_ChunkInterface, int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) + static NIBBLETYPE GetMetaFromRightDoor(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - BLOCKTYPE Block; - NIBBLETYPE Meta; - a_ChunkInterface.GetBlockTypeMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Block, Meta); + NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - if (!IsDoor(Block)) + if ((Meta & 0x8) != 0) { - return false; + NIBBLETYPE DownMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ); + return (DownMeta & 0x7) | 0x8 | (((Meta & 0x1) != 0) ? 16 : 0); + } + else + { + NIBBLETYPE UpMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY + 1, a_BlockZ); + return (Meta & 0x7) | (((UpMeta & 0x1) != 0) ? 16 : 0); } - - return ((Meta & 0x4) == 4); } static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) { - BLOCKTYPE Block; - NIBBLETYPE Meta; - a_ChunkInterface.GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, Meta); + BLOCKTYPE Block = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); + NIBBLETYPE Meta = GetMetaFromRightDoor(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); - if (!IsDoor(Block) || ((Meta & 0x4) == a_Open)) + if (!IsDoor(Block)) { return; } - // Change the door - if (a_Open) + bool Opened = (Meta & 0x4) != 0; + if (Opened == a_Open) { - a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); - } - else - { - a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xFFFFFFFB); + return; } - int OtherPartY = a_BlockY; - if (Meta & 0x8) + // Change the door + NIBBLETYPE NewMeta = (Meta & 0x7) ^ 0x4; + if ((Meta & 0x8) == 0) { - // Current block is top of the door - a_ChunkInterface.GetBlockTypeMeta(a_BlockX, a_BlockY - 1, a_BlockZ, Block, Meta); - if (IsDoor(Block) && !(Meta & 0x8)) - { - OtherPartY--; - } + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, NewMeta); } else { - // Current block is bottom of the door - a_ChunkInterface.GetBlockTypeMeta(a_BlockX, a_BlockY + 1, a_BlockZ, Block, Meta); - if (IsDoor(Block) && (Meta & 0x8)) - { - OtherPartY++; - } - } - - // Change the other door part - if (a_BlockY != OtherPartY) - { - if (a_Open) - { - a_ChunkInterface.SetBlockMeta(a_BlockX, OtherPartY, a_BlockZ, Meta | 0x4); - } - else - { - a_ChunkInterface.SetBlockMeta(a_BlockX, OtherPartY, a_BlockZ, Meta & 0xFFFFFFFB); - } + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ, NewMeta); } } /** Changes the door at the specified coords from open to close or vice versa */ - static void ChangeDoor(cChunkInterface & a_ChunkInterface, int a_X, int a_Y, int a_Z) + static void ChangeDoor(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - NIBBLETYPE OldMetaData = a_ChunkInterface.GetBlockMeta(a_X, a_Y, a_Z); - - a_ChunkInterface.SetBlockMeta(a_X, a_Y, a_Z, ChangeStateMetaData(OldMetaData)); - - if (OldMetaData & 8) - { - // Current block is top of the door - BLOCKTYPE BottomBlock = a_ChunkInterface.GetBlock(a_X, a_Y - 1, a_Z); - NIBBLETYPE BottomMeta = a_ChunkInterface.GetBlockMeta(a_X, a_Y - 1, a_Z); - - if (IsDoor(BottomBlock) && !(BottomMeta & 8)) - { - a_ChunkInterface.SetBlockMeta(a_X, a_Y - 1, a_Z, ChangeStateMetaData(BottomMeta)); - } - } - else - { - // Current block is bottom of the door - BLOCKTYPE TopBlock = a_ChunkInterface.GetBlock(a_X, a_Y + 1, a_Z); - NIBBLETYPE TopMeta = a_ChunkInterface.GetBlockMeta(a_X, a_Y + 1, a_Z); - - if (IsDoor(TopBlock) && (TopMeta & 8)) - { - a_ChunkInterface.SetBlockMeta(a_X, a_Y + 1, a_Z, ChangeStateMetaData(TopMeta)); - } - } + SetOpen(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, !IsOpen(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ)); } } ; -- cgit v1.2.3 From 92d9ab0f6dbd5e6d9b23ed309daa473b00c70ebb Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 30 May 2014 22:25:57 +0200 Subject: Wrong arrow commit. --- src/Entities/ArrowEntity.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 769750bd4..8d2569125 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -19,10 +19,6 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a m_bIsCollected(false), m_HitBlockPos(Vector3i(0, 0, 0)) { - if (a_Creator != NULL) - { - SetPosY(GetPosY() + a_Creator->GetHeight() - 0.1000000014901161); - } SetSpeed(a_Speed); SetMass(0.1); SetYawFromSpeed(); -- cgit v1.2.3 From 8bf7aed67cb59edd72662114244da5c1cf5f2140 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 30 May 2014 22:40:19 +0200 Subject: Updated PlainsVillage and AlchemistVillage. --- src/Generating/Prefabs/AlchemistVillagePrefabs.cpp | 603 +++++++++----- src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 906 ++++++++++++++++++++- 2 files changed, 1270 insertions(+), 239 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp index 32ffe5b88..6e3f82212 100644 --- a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp +++ b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp @@ -20,24 +20,25 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 82, ID 598, created by STR_Warrior { // Size: - 11, 12, 9, // SizeX = 11, SizeY = 12, SizeZ = 9 + 11, 12, 10, // SizeX = 11, SizeY = 12, SizeZ = 10 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 10, 11, 8, // MaxX, MaxY, MaxZ + 10, 11, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "A:101: 0\n" /* ironbars */ - "B: 64:12\n" /* wooddoorblock */ - "C:128: 2\n" /* sandstonestairs */ - "D: 24: 1\n" /* sandstone */ - "E: 44: 9\n" /* step */ - "F:126: 8\n" /* woodenslab */ - "G:128: 7\n" /* sandstonestairs */ - "H: 44: 1\n" /* step */ - "I: 64: 7\n" /* wooddoorblock */ - "J:128: 6\n" /* sandstonestairs */ + "A:171: 8\n" /* carpet */ + "B:101: 0\n" /* ironbars */ + "C: 64:12\n" /* wooddoorblock */ + "D:128: 2\n" /* sandstonestairs */ + "E: 24: 1\n" /* sandstone */ + "F: 44: 9\n" /* step */ + "G:126: 8\n" /* woodenslab */ + "H:128: 7\n" /* sandstonestairs */ + "I: 44: 1\n" /* step */ + "J: 64: 7\n" /* wooddoorblock */ + "K:128: 6\n" /* sandstonestairs */ "a: 1: 0\n" /* stone */ "b: 24: 0\n" /* sandstone */ "c: 12: 0\n" /* sand */ @@ -62,8 +63,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "v:134: 7\n" /* 134 */ "w:107: 5\n" /* fencegate */ "x: 64: 5\n" /* wooddoorblock */ - "y: 50: 3\n" /* torch */ - "z:171: 8\n" /* carpet */, + "y: 65: 3\n" /* ladder */ + "z: 50: 3\n" /* torch */, // Block data: // Level 0 @@ -78,6 +79,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 6 */ "aabbbbbbbaa" /* 7 */ "aabbbbbbbaa" /* 8 */ "aaaaaaaaaaa" + /* 9 */ "aaaaaaaaaaa" // Level 1 /* z\x* 1 */ @@ -91,6 +93,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 6 */ "cb.......bc" /* 7 */ "cbg......bc" /* 8 */ "cbbbbbbbbbc" + /* 9 */ "ccccccccccc" // Level 2 /* z\x* 1 */ @@ -104,6 +107,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 6 */ "cb.......bc" /* 7 */ "cbg......bc" /* 8 */ "cbbbbbbbbbc" + /* 9 */ "ccccccccccc" // Level 3 /* z\x* 1 */ @@ -117,6 +121,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 6 */ "cb.......bc" /* 7 */ "cbg..l...bc" /* 8 */ "cbbbbbbbbbc" + /* 9 */ "ccccccccccc" // Level 4 /* z\x* 1 */ @@ -130,6 +135,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 6 */ "cnnnnnnnnnc" /* 7 */ "cnonnnnnnnc" /* 8 */ "cnccccccccc" + /* 9 */ "ccccccccccc" // Level 5 /* z\x* 1 */ @@ -143,6 +149,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 6 */ "bfvvd.....b" /* 7 */ "b...w..kujb" /* 8 */ "pxbbbbbbbbp" + /* 9 */ "..y........" // Level 6 /* z\x* 1 */ @@ -150,38 +157,41 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "...p...p..." /* 1 */ "..........." /* 2 */ "pbbb...bbbp" - /* 3 */ "b..y...y..b" - /* 4 */ "b.z.....z.b" - /* 5 */ "A.........A" + /* 3 */ "b..z...z..b" + /* 4 */ "b.A.....A.b" + /* 5 */ "B.........B" /* 6 */ "b.........b" - /* 7 */ "b.......z.b" - /* 8 */ "pBbbAAAbbbp" + /* 7 */ "b.......A.b" + /* 8 */ "pCbbBBBbbbp" + /* 9 */ "..y........" // Level 7 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "...C...C..." - /* 1 */ "...D...b..." - /* 2 */ "pbbbqEsbbbp" - /* 3 */ "bFFFFFFFFFb" - /* 4 */ "bFFFFFFFFFb" - /* 5 */ "sFFFFFFFFFq" - /* 6 */ "bFFFFFFFFFb" - /* 7 */ "bFFFFFFFFFb" - /* 8 */ "pbbbGGGbbbp" + /* 0 */ "...D...D..." + /* 1 */ "...E...b..." + /* 2 */ "pbbbqFsbbbp" + /* 3 */ "bGGGGGGGGGb" + /* 4 */ "bGGGGGGGGGb" + /* 5 */ "sGGGGGGGGGq" + /* 6 */ "bGGGGGGGGGb" + /* 7 */ "bGGGGGGGGGb" + /* 8 */ "pbbbHHHbbbp" + /* 9 */ "..y........" // Level 8 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." - /* 2 */ "bHHHHbHHHHb" - /* 3 */ "HpbbbbbbbpH" - /* 4 */ "Hb.......bH" + /* 2 */ "bIIIIbIIIIb" + /* 3 */ "IpbbbbbbbpI" + /* 4 */ "Ib.......bI" /* 5 */ "bb.......bb" - /* 6 */ "Hb.......bH" - /* 7 */ "HpIbbbbbbpH" - /* 8 */ "bH.HHbHHHHb" + /* 6 */ "Ib.......bI" + /* 7 */ "IpJbbbbbbpI" + /* 8 */ "bI.IIbIIIIb" + /* 9 */ "..........." // Level 9 /* z\x* 1 */ @@ -189,12 +199,13 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ ".pbbAAAbbp." + /* 3 */ ".pbbBBBbbp." /* 4 */ ".b.......b." - /* 5 */ ".A.......A." + /* 5 */ ".B.......B." /* 6 */ ".b.......b." - /* 7 */ ".pBbAAAbbp." + /* 7 */ ".pCbBBBbbp." /* 8 */ "..........." + /* 9 */ "..........." // Level 10 /* z\x* 1 */ @@ -202,12 +213,13 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ ".pbbJJJbbp." - /* 4 */ ".bFFFFFFFb." - /* 5 */ ".sFFFFFFFq." - /* 6 */ ".bFFFFFFFb." - /* 7 */ ".pbbGGGbbp." + /* 3 */ ".pbbKKKbbp." + /* 4 */ ".bGGGGGGGb." + /* 5 */ ".sGGGGGGGq." + /* 6 */ ".bGGGGGGGb." + /* 7 */ ".pbbHHHbbp." /* 8 */ "..........." + /* 9 */ "..........." // Level 11 /* z\x* 1 */ @@ -215,12 +227,13 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ ".bHHHbHHHb." - /* 4 */ ".H.......H." + /* 3 */ ".bIIIbIIIb." + /* 4 */ ".I.......I." /* 5 */ ".b.......b." - /* 6 */ ".H.......H." - /* 7 */ ".bHHHbHHHb." - /* 8 */ "...........", + /* 6 */ ".I.......I." + /* 7 */ ".bIIIbIIIb." + /* 8 */ "..........." + /* 9 */ "...........", // Connectors: "-1: 5, 5, 0: 2\n" /* Type -1, direction Z- */, @@ -235,7 +248,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = true, // DefaultWeight: - 100, + 70, // DepthWeight: "", @@ -254,18 +267,19 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 81, ID 597, created by STR_Warrior { // Size: - 11, 8, 9, // SizeX = 11, SizeY = 8, SizeZ = 9 + 11, 8, 10, // SizeX = 11, SizeY = 8, SizeZ = 10 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 10, 7, 8, // MaxX, MaxY, MaxZ + 10, 7, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "A: 44: 1\n" /* step */ - "B: 64: 3\n" /* wooddoorblock */ - "C: 64: 8\n" /* wooddoorblock */ - "D:128: 6\n" /* sandstonestairs */ + "A:128: 7\n" /* sandstonestairs */ + "B: 44: 1\n" /* step */ + "C: 64: 3\n" /* wooddoorblock */ + "D: 64: 8\n" /* wooddoorblock */ + "E:128: 6\n" /* sandstonestairs */ "a: 12: 0\n" /* sand */ "b: 5: 0\n" /* wood */ "c: 24: 2\n" /* sandstone */ @@ -283,15 +297,15 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "o:134: 4\n" /* 134 */ "p:107: 5\n" /* fencegate */ "q: 64: 5\n" /* wooddoorblock */ - "r: 50: 3\n" /* torch */ - "s:171: 8\n" /* carpet */ - "t:101: 0\n" /* ironbars */ - "u: 64:12\n" /* wooddoorblock */ - "v:128: 2\n" /* sandstonestairs */ - "w: 24: 1\n" /* sandstone */ - "x: 44: 9\n" /* step */ - "y:126: 8\n" /* woodenslab */ - "z:128: 7\n" /* sandstonestairs */, + "r: 65: 3\n" /* ladder */ + "s: 50: 3\n" /* torch */ + "t:171: 8\n" /* carpet */ + "u:101: 0\n" /* ironbars */ + "v: 64:12\n" /* wooddoorblock */ + "w:128: 2\n" /* sandstonestairs */ + "x: 24: 1\n" /* sandstone */ + "y: 44: 9\n" /* step */ + "z:126: 8\n" /* woodenslab */, // Block data: // Level 0 @@ -306,6 +320,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 6 */ "abbbbbbbbba" /* 7 */ "abbbbbbbbba" /* 8 */ "abaaaaaaaaa" + /* 9 */ "aaaaaaaaaaa" // Level 1 /* z\x* 1 */ @@ -319,6 +334,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 6 */ "dlnno.....d" /* 7 */ "d...p..hjkd" /* 8 */ "cqddddddddc" + /* 9 */ "..r........" // Level 2 /* z\x* 1 */ @@ -326,38 +342,41 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "...c...c..." /* 1 */ "..........." /* 2 */ "cddd...dddc" - /* 3 */ "d..r...r..d" - /* 4 */ "d.s.....s.d" - /* 5 */ "t.........t" + /* 3 */ "d..s...s..d" + /* 4 */ "d.t.....t.d" + /* 5 */ "u.........u" /* 6 */ "d.........d" - /* 7 */ "d.......s.d" - /* 8 */ "cuddtttdddc" + /* 7 */ "d.......t.d" + /* 8 */ "cvdduuudddc" + /* 9 */ "..r........" // Level 3 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "...v...v..." - /* 1 */ "...w...d..." - /* 2 */ "cdddexgdddc" - /* 3 */ "dyyyyyyyyyd" - /* 4 */ "dyyyyyyyyyd" - /* 5 */ "gyyyyyyyyye" - /* 6 */ "dyyyyyyyyyd" - /* 7 */ "dyyyyyyyyyd" - /* 8 */ "cdddzzzdddc" + /* 0 */ "...w...w..." + /* 1 */ "...x...d..." + /* 2 */ "cdddeygdddc" + /* 3 */ "dzzzzzzzzzd" + /* 4 */ "dzzzzzzzzzd" + /* 5 */ "gzzzzzzzzze" + /* 6 */ "dzzzzzzzzzd" + /* 7 */ "dzzzzzzzzzd" + /* 8 */ "cdddAAAdddc" + /* 9 */ "..r........" // Level 4 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." - /* 2 */ "dAAAAdAAAAd" - /* 3 */ "AcdddddddcA" - /* 4 */ "Ad.......dA" + /* 2 */ "dBBBBdBBBBd" + /* 3 */ "BcdddddddcB" + /* 4 */ "Bd.......dB" /* 5 */ "dd.......dd" - /* 6 */ "Ad.......dA" - /* 7 */ "AcBddddddcA" - /* 8 */ "dA.AAdAAAAd" + /* 6 */ "Bd.......dB" + /* 7 */ "BcCddddddcB" + /* 8 */ "dB.BBdBBBBd" + /* 9 */ "..........." // Level 5 /* z\x* 1 */ @@ -365,12 +384,13 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ ".cddtttddc." + /* 3 */ ".cdduuuddc." /* 4 */ ".d.......d." - /* 5 */ ".t.......t." + /* 5 */ ".u.......u." /* 6 */ ".d.......d." - /* 7 */ ".cCdtttddc." + /* 7 */ ".cDduuuddc." /* 8 */ "..........." + /* 9 */ "..........." // Level 6 /* z\x* 1 */ @@ -378,12 +398,13 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ ".cddDDDddc." - /* 4 */ ".dyyyyyyyd." - /* 5 */ ".gyyyyyyye." - /* 6 */ ".dyyyyyyyd." - /* 7 */ ".cddzzzddc." + /* 3 */ ".cddEEEddc." + /* 4 */ ".dzzzzzzzd." + /* 5 */ ".gzzzzzzze." + /* 6 */ ".dzzzzzzzd." + /* 7 */ ".cddAAAddc." /* 8 */ "..........." + /* 9 */ "..........." // Level 7 /* z\x* 1 */ @@ -391,12 +412,13 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ ".dAAAdAAAd." - /* 4 */ ".A.......A." + /* 3 */ ".dBBBdBBBd." + /* 4 */ ".B.......B." /* 5 */ ".d.......d." - /* 6 */ ".A.......A." - /* 7 */ ".dAAAdAAAd." - /* 8 */ "...........", + /* 6 */ ".B.......B." + /* 7 */ ".dBBBdBBBd." + /* 8 */ "..........." + /* 9 */ "...........", // Connectors: "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, @@ -411,7 +433,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = true, // DefaultWeight: - 100, + 80, // DepthWeight: "", @@ -427,7 +449,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // BlackSmith: - // The data has been exported from the gallery Desert, area index 92, ID 633, created by STR_Warrior + // The data has been exported from the gallery Desert, area index 97, ID 642, created by STR_Warrior { // Size: 11, 5, 13, // SizeX = 11, SizeY = 5, SizeZ = 13 @@ -460,7 +482,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "t:128: 4\n" /* sandstonestairs */ "u:128: 5\n" /* sandstonestairs */ "v:128: 7\n" /* sandstonestairs */ - "w: 44: 1\n" /* step */, + "w: 44: 1\n" /* step */ + "x: 43: 1\n" /* doubleslab */, // Block data: // Level 0 @@ -469,7 +492,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "aaaaaaaaaaa" /* 1 */ "aaaaaaaaaaa" /* 2 */ "aaaaaaaabaa" - /* 3 */ "acaaacabbba" + /* 3 */ "acacacabbba" /* 4 */ "acaccaabbba" /* 5 */ "acccccabbba" /* 6 */ "acaadddbbba" @@ -487,9 +510,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 1 */ "..........." /* 2 */ "......dcecd" /* 3 */ ".d....c...c" - /* 4 */ "......c...c" - /* 5 */ "...f..c...c" - /* 6 */ ".....dc...c" + /* 4 */ "..f...c...c" + /* 5 */ "......c...c" + /* 6 */ "....ddc...c" /* 7 */ ".gh.dic...c" /* 8 */ "dcccccd...c" /* 9 */ "cj........c" @@ -506,8 +529,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 3 */ ".d....c..lc" /* 4 */ "......n...c" /* 5 */ "......c...c" - /* 6 */ "......c...n" - /* 7 */ "......c...n" + /* 6 */ "....nnc...n" + /* 7 */ "....n.c...n" /* 8 */ "dcccccd...n" /* 9 */ "co........c" /* 10 */ "n.........c" @@ -523,8 +546,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 3 */ ".drrrrcsssc" /* 4 */ ".rsssstsssc" /* 5 */ ".rsssscsssc" - /* 6 */ ".rsssscsssu" - /* 7 */ ".rsssscsssu" + /* 6 */ ".rssddcsssu" + /* 7 */ ".rssd.csssu" /* 8 */ "dcccccdsssu" /* 9 */ "csssssssssc" /* 10 */ "tsssssssssc" @@ -540,9 +563,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 3 */ ".w.w.ww...w" /* 4 */ "......w...w" /* 5 */ ".w....w...w" - /* 6 */ "......w...w" - /* 7 */ ".w....w...c" - /* 8 */ "cwwwwwc...w" + /* 6 */ "....xwx...w" + /* 7 */ ".w..w.w...c" + /* 8 */ "cwwwxwc...w" /* 9 */ "w.........w" /* 10 */ "w.........w" /* 11 */ "w.........w" @@ -561,7 +584,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = true, // DefaultWeight: - 100, + 50, // DepthWeight: "", @@ -588,12 +611,14 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // Block definitions: ".: 0: 0\n" /* air */ - "A:128: 2\n" /* sandstonestairs */ - "B:128: 0\n" /* sandstonestairs */ - "C: 87: 0\n" /* netherstone */ - "D:128: 3\n" /* sandstonestairs */ - "E: 51: 0\n" /* fire */ - "F: 44: 9\n" /* step */ + "A:128: 7\n" /* sandstonestairs */ + "B: 44: 1\n" /* step */ + "C:128: 2\n" /* sandstonestairs */ + "D:128: 0\n" /* sandstonestairs */ + "E: 87: 0\n" /* netherstone */ + "F:128: 3\n" /* sandstonestairs */ + "G: 51: 0\n" /* fire */ + "H: 44: 9\n" /* step */ "a: 12: 0\n" /* sand */ "b: 5: 0\n" /* wood */ "c: 24: 2\n" /* sandstone */ @@ -610,16 +635,16 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "n:101: 0\n" /* ironbars */ "o:140: 0\n" /* flowerpotblock */ "p: 64: 8\n" /* wooddoorblock */ - "q: 69:12\n" /* lever */ - "r: 44:10\n" /* step */ - "s:128: 1\n" /* sandstonestairs */ - "t: 47: 0\n" /* bookshelf */ - "u: 96:12\n" /* trapdoor */ - "v:128: 4\n" /* sandstonestairs */ - "w:128: 5\n" /* sandstonestairs */ - "x:128: 7\n" /* sandstonestairs */ - "y: 44: 1\n" /* step */ - "z:128: 6\n" /* sandstonestairs */, + "q: 50: 3\n" /* torch */ + "r: 69:12\n" /* lever */ + "s: 50: 4\n" /* torch */ + "t:128: 6\n" /* sandstonestairs */ + "u: 44:10\n" /* step */ + "v:128: 1\n" /* sandstonestairs */ + "w: 47: 0\n" /* bookshelf */ + "x: 96:12\n" /* trapdoor */ + "y:128: 4\n" /* sandstonestairs */ + "z:128: 5\n" /* sandstonestairs */, // Block data: // Level 0 @@ -657,9 +682,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* * 012345678901234 */ /* 0 */ "....cddnnnddc.." /* 1 */ "....d......od.c" - /* 2 */ "....p.......d.." + /* 2 */ "....p.......d.q" /* 3 */ "....d.......p.." - /* 4 */ "....d.q...l.d.." + /* 4 */ "....d.r...l.d.s" /* 5 */ "....dddd.dddd.c" /* 6 */ "....n.......n.." /* 7 */ "mmmmn.......n.." @@ -670,32 +695,32 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // Level 3 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "....cdddddddc.." - /* 1 */ "....drrrrrrrdds" - /* 2 */ "....drrrrrrrd.." - /* 3 */ "....drrrrrrrd.." - /* 4 */ "....dtttrrurd.." - /* 5 */ "....dddddddddds" - /* 6 */ "....vrrrrrrrw.." - /* 7 */ "mmmmvrrrrrrrw.." - /* 8 */ "mmmmvrrrrrrrw.." - /* 9 */ "mmmmdrrrrrrrd.." - /* 10 */ "mmmmcddxxxddc.." + /* 0 */ "....cddtttddc.." + /* 1 */ "....duuuuuuuddv" + /* 2 */ "....duuuuuuud.." + /* 3 */ "....duuuuuuud.." + /* 4 */ "....dwwwuuxud.." + /* 5 */ "....ddddddddddv" + /* 6 */ "....yuuuuuuuz.." + /* 7 */ "mmmmyuuuuuuuz.." + /* 8 */ "mmmmyuuuuuuuz.." + /* 9 */ "mmmmduuuuuuud.." + /* 10 */ "mmmmcddAAAddc.." // Level 4 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "....dyyydyyyd.." - /* 1 */ "....ycdddddcy.." - /* 2 */ "....yd.....dy.." - /* 3 */ "....yd.....dy.." - /* 4 */ "....yd.....dy.." + /* 0 */ "....dBBBdBBBd.." + /* 1 */ "....BcdddddcB.." + /* 2 */ "....Bd.....dB.." + /* 3 */ "....Bd.....dB.." + /* 4 */ "....Bd.....dB.." /* 5 */ "....dcdd.ddcd.." - /* 6 */ "....y.......y.." - /* 7 */ "mmmmy.......y.." - /* 8 */ "mmmmy.......y.." - /* 9 */ "mmmmy.......y.." - /* 10 */ "mmmmdyyydyyyd.." + /* 6 */ "....B.......B.." + /* 7 */ "mmmmB.......B.." + /* 8 */ "mmmmB.......B.." + /* 9 */ "mmmmB.......B.." + /* 10 */ "mmmmdBBBdBBBd.." // Level 5 /* z\x* 11111 */ @@ -716,10 +741,10 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".....cddzddc..." - /* 2 */ ".....vrrrrrw..." - /* 3 */ ".....vrrrrrw..." - /* 4 */ ".....vrrrrrw..." + /* 1 */ ".....cddtddc..." + /* 2 */ ".....yuuuuuz..." + /* 3 */ ".....yuuuuuz..." + /* 4 */ ".....yuuuuuz..." /* 5 */ ".....cdddddc..." /* 6 */ "..............." /* 7 */ "..............." @@ -731,11 +756,11 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".....dyydyyd..." - /* 2 */ ".....y.ddd.y..." + /* 1 */ ".....dBBdBBd..." + /* 2 */ ".....B.ddd.B..." /* 3 */ ".....d.ddd.d..." - /* 4 */ ".....y.ddd.y..." - /* 5 */ ".....dyydyyd..." + /* 4 */ ".....B.ddd.B..." + /* 5 */ ".....dBBdBBd..." /* 6 */ "..............." /* 7 */ "..............." /* 8 */ "..............." @@ -747,9 +772,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ ".......cAc....." - /* 3 */ ".......BCs....." - /* 4 */ ".......cDc....." + /* 2 */ ".......cCc....." + /* 3 */ ".......DEv....." + /* 4 */ ".......cFc....." /* 5 */ "..............." /* 6 */ "..............." /* 7 */ "..............." @@ -763,7 +788,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..............." /* 1 */ "..............." /* 2 */ ".......c.c....." - /* 3 */ "........E......" + /* 3 */ "........G......" /* 4 */ ".......c.c....." /* 5 */ "..............." /* 6 */ "..............." @@ -777,9 +802,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ ".......c.c....." - /* 3 */ "..............." - /* 4 */ ".......c.c....." + /* 2 */ ".......ctc....." + /* 3 */ ".......y.z....." + /* 4 */ ".......cAc....." /* 5 */ "..............." /* 6 */ "..............." /* 7 */ "..............." @@ -793,7 +818,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..............." /* 1 */ "..............." /* 2 */ ".......ddd....." - /* 3 */ ".......dFd....." + /* 3 */ ".......dHd....." /* 4 */ ".......ddd....." /* 5 */ "..............." /* 6 */ "..............." @@ -807,9 +832,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ ".......y.y....." + /* 2 */ ".......B.B....." /* 3 */ "..............." - /* 4 */ ".......y.y....." + /* 4 */ ".......B.B....." /* 5 */ "..............." /* 6 */ "..............." /* 7 */ "..............." @@ -830,7 +855,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = true, // DefaultWeight: - 100, + 60, // DepthWeight: "", @@ -1169,7 +1194,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 3 */ "abbbbba" /* 4 */ "abbbbba" /* 5 */ "abbbbba" - /* 6 */ "aaaaaaa" + /* 6 */ "aabaaaa" /* 7 */ "aaaaaaa" /* 8 */ "aaaaaaa" /* 9 */ "aaaaaaa" @@ -1384,7 +1409,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "b: 5: 0\n" /* wood */ "c: 24: 2\n" /* sandstone */ "d: 24: 0\n" /* sandstone */ - "e: 64: 3\n" /* wooddoorblock */ + "e: 64: 7\n" /* wooddoorblock */ "f: 65: 5\n" /* ladder */ "g:134: 3\n" /* 134 */ "h: 85: 0\n" /* fence */ @@ -1393,16 +1418,17 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "k:134: 6\n" /* 134 */ "l:134: 4\n" /* 134 */ "m: 19: 0\n" /* sponge */ - "n: 64: 8\n" /* wooddoorblock */ + "n: 64:12\n" /* wooddoorblock */ "o: 50: 2\n" /* torch */ "p:101: 0\n" /* ironbars */ "q:171: 8\n" /* carpet */ "r:128: 2\n" /* sandstonestairs */ "s:126: 8\n" /* woodenslab */ - "t:128: 5\n" /* sandstonestairs */ - "u:128: 7\n" /* sandstonestairs */ - "v: 44: 1\n" /* step */ - "w: 96: 7\n" /* trapdoor */, + "t:128: 4\n" /* sandstonestairs */ + "u:128: 5\n" /* sandstonestairs */ + "v:128: 7\n" /* sandstonestairs */ + "w: 44: 1\n" /* step */ + "x: 96: 7\n" /* trapdoor */, // Block data: // Level 0 @@ -1454,26 +1480,26 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 2 */ "cdddc" /* 3 */ "dfssd" /* 4 */ "dsssd" - /* 5 */ "tssst" - /* 6 */ "tssst" - /* 7 */ "tssst" + /* 5 */ "tsssu" + /* 6 */ "tsssu" + /* 7 */ "tsssu" /* 8 */ "dsssd" /* 9 */ "dsssd" - /* 10 */ "cdudc" + /* 10 */ "cdvdc" // Level 4 /* z\x* 01234 */ /* 0 */ "....." /* 1 */ "....." - /* 2 */ "dvdvd" - /* 3 */ "vw..v" - /* 4 */ "v...v" - /* 5 */ "v...v" + /* 2 */ "dwdwd" + /* 3 */ "wx..w" + /* 4 */ "w...w" + /* 5 */ "w...w" /* 6 */ "d...d" - /* 7 */ "v...v" - /* 8 */ "v...v" - /* 9 */ "v...v" - /* 10 */ "dvdvd", + /* 7 */ "w...w" + /* 8 */ "w...w" + /* 9 */ "w...w" + /* 10 */ "dwdwd", // Connectors: "-1: 2, 1, 0: 2\n" /* Type -1, direction Z- */, @@ -2050,7 +2076,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "o:128: 4\n" /* sandstonestairs */ "p:128: 7\n" /* sandstonestairs */ "q: 44: 1\n" /* step */ - "r: 50: 3\n" /* torch */, + "r: 50: 3\n" /* torch */ + "s:128: 6\n" /* sandstonestairs */, // Block data: // Level 0 @@ -2137,11 +2164,11 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..............." /* 1 */ "..............." /* 2 */ "..............." - /* 3 */ "...cdddc......." + /* 3 */ "...cdsdc......." /* 4 */ "...dnnnd......." /* 5 */ "...dnnnd......." /* 6 */ "...dnnnd......." - /* 7 */ "...cdddc......." + /* 7 */ "...cdpdc......." /* 8 */ "..............." // Level 7 @@ -2170,7 +2197,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = true, // DefaultWeight: - 100, + 80, // DepthWeight: "", @@ -2364,7 +2391,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = true, // DefaultWeight: - 100, + 80, // DepthWeight: "", @@ -2582,7 +2609,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = true, // DefaultWeight: - 100, + 80, // DepthWeight: "", @@ -2690,7 +2717,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* z\x* 012345678 */ /* 0 */ "mmmm....." /* 1 */ "mmmm....." - /* 2 */ "mmmmcrdrd" + /* 2 */ "mmmmdrdrd" /* 3 */ "mmmmr...r" /* 4 */ "mmmmr...r" /* 5 */ "mmmmr...r" @@ -2724,6 +2751,192 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // MoveToGround: true, }, // SmallHouse9 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Temple: + // The data has been exported from the gallery Desert, area index 83, ID 599, created by STR_Warrior + { + // Size: + 13, 9, 9, // SizeX = 13, SizeY = 9, SizeZ = 9 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 12, 8, 8, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "A: 44: 9\n" /* step */ + "a: 12: 0\n" /* sand */ + "b: 5: 0\n" /* wood */ + "c: 24: 2\n" /* sandstone */ + "d: 24: 0\n" /* sandstone */ + "e: 64: 7\n" /* wooddoorblock */ + "f: 17: 0\n" /* tree */ + "g:128: 5\n" /* sandstonestairs */ + "h:128: 4\n" /* sandstonestairs */ + "i:128: 7\n" /* sandstonestairs */ + "j:128: 6\n" /* sandstonestairs */ + "k:118: 3\n" /* cauldronblock */ + "l:155: 1\n" /* quartzblock */ + "m: 19: 0\n" /* sponge */ + "n: 64:12\n" /* wooddoorblock */ + "o: 50: 3\n" /* torch */ + "p:101: 0\n" /* ironbars */ + "q:140: 0\n" /* flowerpotblock */ + "r: 24: 1\n" /* sandstone */ + "s:128: 2\n" /* sandstonestairs */ + "t:126: 8\n" /* woodenslab */ + "u: 44: 1\n" /* step */ + "v:128: 0\n" /* sandstonestairs */ + "w: 87: 0\n" /* netherstone */ + "x:128: 1\n" /* sandstonestairs */ + "y:128: 3\n" /* sandstonestairs */ + "z: 51: 0\n" /* fire */, + + // Block data: + // Level 0 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "aaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaa" + /* 2 */ "aaabbababbaaa" + /* 3 */ "abbbbbbbbbbba" + /* 4 */ "abbbbbbbbbbba" + /* 5 */ "abbbbbbbbbbba" + /* 6 */ "abbbbbbbbbbba" + /* 7 */ "abbbbbbbbbbba" + /* 8 */ "aaaaaaaaaaaaa" + + // Level 1 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "....c...c...." + /* 1 */ "............." + /* 2 */ "cdddddedddddc" + /* 3 */ "dfg.......hfd" + /* 4 */ "di.........id" + /* 5 */ "d...........d" + /* 6 */ "dj.........jd" + /* 7 */ "dfg.khlgk.hfd" + /* 8 */ "cdddddddddddc" + + // Level 2 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "....c...c...." + /* 1 */ "............." + /* 2 */ "cdddddndddddc" + /* 3 */ "df...o.o...fd" + /* 4 */ "d...........d" + /* 5 */ "p...........p" + /* 6 */ "d...........d" + /* 7 */ "df...qrq...fd" + /* 8 */ "cdpppdddpppdc" + + // Level 3 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "....s...s...." + /* 1 */ "....r...d...." + /* 2 */ "cdddddddddddc" + /* 3 */ "dftttttttttfd" + /* 4 */ "dtttttttttttd" + /* 5 */ "htttttttttttg" + /* 6 */ "dtttttttttttd" + /* 7 */ "dftttttttttfd" + /* 8 */ "cdiiidddiiidc" + + // Level 4 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "............." + /* 2 */ "duuuuuduuuuud" + /* 3 */ "u...........u" + /* 4 */ "u.ddd...ddd.u" + /* 5 */ "d.ddd...ddd.d" + /* 6 */ "u.ddd...ddd.u" + /* 7 */ "u...........u" + /* 8 */ "duuuuuduuuuud" + + // Level 5 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "............." + /* 2 */ "............." + /* 3 */ "............." + /* 4 */ "..csc...csc.." + /* 5 */ "..vwx...vwx.." + /* 6 */ "..cyc...cyc.." + /* 7 */ "............." + /* 8 */ "............." + + // Level 6 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "............." + /* 2 */ "............." + /* 3 */ "............." + /* 4 */ "..c.c...c.c.." + /* 5 */ "...z.....z..." + /* 6 */ "..c.c...c.c.." + /* 7 */ "............." + /* 8 */ "............." + + // Level 7 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "............." + /* 2 */ "............." + /* 3 */ "............." + /* 4 */ "..ddd...ddd.." + /* 5 */ "..dAd...dAd.." + /* 6 */ "..ddd...ddd.." + /* 7 */ "............." + /* 8 */ "............." + + // Level 8 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ "............." + /* 2 */ "............." + /* 3 */ "............." + /* 4 */ "..u.u...u.u.." + /* 5 */ "............." + /* 6 */ "..u.u...u.u.." + /* 7 */ "............." + /* 8 */ ".............", + + // Connectors: + "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 50, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + true, + }, // Temple }; // g_AlchemistVillagePrefabs diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index f8cf867e5..f5e531955 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -797,8 +797,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = ".: 0: 0\n" /* air */ "a: 5: 0\n" /* wood */ "b: 85: 0\n" /* fence */ - "c: 50: 2\n" /* torch */ - "d: 50: 1\n" /* torch */ + "c: 66: 1\n" /* tracks */ + "d: 50: 2\n" /* torch */ + "e: 50: 1\n" /* torch */ "m: 19: 0\n" /* sponge */, // Block data: @@ -813,7 +814,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* z\x* */ /* * 0123456789 */ /* 0 */ "..b....b.." - /* 1 */ ".........." + /* 1 */ "cccccccccc" /* 2 */ "..b....b.." // Level 2 @@ -827,14 +828,12 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* z\x* */ /* * 0123456789 */ /* 0 */ "..a....a.." - /* 1 */ ".cad..cad." + /* 1 */ ".dae..dae." /* 2 */ "..a....a..", // Connectors: "-3: 0, 1, 1: 4\n" /* Type -3, direction X- */ - "3: 0, 1, 1: 4\n" /* Type 3, direction X- */ - "3: 9, 1, 1: 5\n" /* Type 3, direction X+ */ - "-3: 9, 1, 1: 5\n" /* Type -3, direction X+ */, + "3: 9, 1, 1: 5\n" /* Type 3, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -874,6 +873,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Block definitions: ".: 0: 0\n" /* air */ "a: 5: 0\n" /* wood */ + "b: 66: 0\n" /* tracks */ + "c: 66: 1\n" /* tracks */ "m: 19: 0\n" /* sponge */, // Block data: @@ -887,11 +888,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 1 /* z\x* 01234 */ - /* 0 */ "m...m" - /* 1 */ ".a.a." - /* 2 */ "....." - /* 3 */ ".a.a." - /* 4 */ "m...m" + /* 0 */ "m.b.m" + /* 1 */ ".aba." + /* 2 */ "ccccc" + /* 3 */ ".aba." + /* 4 */ "m.b.m" // Level 2 /* z\x* 01234 */ @@ -929,7 +930,125 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = false, // DefaultWeight: - 5, + 1, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // MineshaftCrossing + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MineshaftCrossing: + // The data has been exported from the gallery Plains, area index 193, ID 657, created by Aloe_vera + { + // Size: + 11, 4, 11, // SizeX = 11, SizeY = 4, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 3, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "b: 66: 0\n" /* tracks */ + "c: 85: 0\n" /* fence */ + "d: 66: 1\n" /* tracks */ + "e: 50: 4\n" /* torch */ + "f: 50: 3\n" /* torch */ + "g: 50: 2\n" /* torch */ + "h: 50: 1\n" /* torch */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmaaammmm" + /* 1 */ "mmmmaaammmm" + /* 2 */ "mmmmaaammmm" + /* 3 */ "mmmmaaammmm" + /* 4 */ "aaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaa" + /* 7 */ "mmmmaaammmm" + /* 8 */ "mmmmaaammmm" + /* 9 */ "mmmmaaammmm" + /* 10 */ "mmmmaaammmm" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmm.b.mmmm" + /* 1 */ "mmmm.b.mmmm" + /* 2 */ "mmmmcbcmmmm" + /* 3 */ "mmmm.b.mmmm" + /* 4 */ "..c..b..c.." + /* 5 */ "ddddddddddd" + /* 6 */ "..c..b..c.." + /* 7 */ "mmmm.b.mmmm" + /* 8 */ "mmmmcbcmmmm" + /* 9 */ "mmmm.b.mmmm" + /* 10 */ "mmmm.b.mmmm" + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmm...mmmm" + /* 1 */ "mmmm...mmmm" + /* 2 */ "mmmmc.cmmmm" + /* 3 */ "mmmm...mmmm" + /* 4 */ "..c.....c.." + /* 5 */ "..........." + /* 6 */ "..c.....c.." + /* 7 */ "mmmm...mmmm" + /* 8 */ "mmmmc.cmmmm" + /* 9 */ "mmmm...mmmm" + /* 10 */ "mmmm...mmmm" + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmm...mmmm" + /* 1 */ "mmmm.e.mmmm" + /* 2 */ "mmmmaaammmm" + /* 3 */ "mmmm.f.mmmm" + /* 4 */ "..a.....a.." + /* 5 */ ".gah...gah." + /* 6 */ "..a.....a.." + /* 7 */ "mmmm.e.mmmm" + /* 8 */ "mmmmaaammmm" + /* 9 */ "mmmm.f.mmmm" + /* 10 */ "mmmm...mmmm", + + // Connectors: + "3: 5, 1, 0: 2\n" /* Type 3, direction Z- */ + "-3: 5, 1, 0: 2\n" /* Type -3, direction Z- */ + "3: 0, 1, 5: 4\n" /* Type 3, direction X- */ + "-3: 0, 1, 5: 4\n" /* Type -3, direction X- */ + "3: 5, 1, 10: 3\n" /* Type 3, direction Z+ */ + "-3: 5, 1, 10: 3\n" /* Type -3, direction Z+ */ + "3: 10, 1, 5: 5\n" /* Type 3, direction X+ */ + "-3: 10, 1, 5: 5\n" /* Type -3, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 10, // DepthWeight: "", @@ -957,6 +1076,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Block definitions: ".: 0: 0\n" /* air */ "a: 5: 0\n" /* wood */ + "b: 66: 0\n" /* tracks */ + "c: 66: 1\n" /* tracks */ "m: 19: 0\n" /* sponge */, // Block data: @@ -970,11 +1091,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 1 /* z\x* 01234 */ - /* 0 */ "m...m" - /* 1 */ ".a.a." - /* 2 */ "....." - /* 3 */ ".a.a." - /* 4 */ "m...m" + /* 0 */ "m.b.m" + /* 1 */ ".aba." + /* 2 */ "ccccc" + /* 3 */ ".aba." + /* 4 */ "m.b.m" // Level 2 /* z\x* 01234 */ @@ -1052,7 +1173,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = false, // DefaultWeight: - 5, + 1, // DepthWeight: "", @@ -1066,6 +1187,703 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MineshaftSpiral: + // The data has been exported from the gallery Plains, area index 198, ID 662, created by Aloe_vera + { + // Size: + 7, 12, 7, // SizeX = 7, SizeY = 12, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 11, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "b: 85: 0\n" /* fence */ + "c: 66: 4\n" /* tracks */ + "d: 66: 0\n" /* tracks */ + "e: 66: 6\n" /* tracks */ + "f: 66: 2\n" /* tracks */ + "g: 50: 1\n" /* torch */ + "h: 50: 3\n" /* torch */ + "i: 66: 1\n" /* tracks */ + "j: 66: 7\n" /* tracks */ + "k: 66: 5\n" /* tracks */ + "l: 50: 2\n" /* torch */ + "m: 19: 0\n" /* sponge */ + "n: 66: 3\n" /* tracks */ + "o: 66: 8\n" /* tracks */ + "p: 50: 4\n" /* torch */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmmmmm" + /* 2 */ "mmmmmmm" + /* 3 */ "aaabmmm" + /* 4 */ "aaammmm" + /* 5 */ "aaammmm" + /* 6 */ "aaammmm" + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmmmmm" + /* 2 */ "aaammmm" + /* 3 */ "aaabmmm" + /* 4 */ ".c.mmmm" + /* 5 */ ".d.mmmm" + /* 6 */ ".d.mmmm" + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "aaaammm" + /* 1 */ "aaaammm" + /* 2 */ "aaaammm" + /* 3 */ ".c.bmmm" + /* 4 */ "...mmmm" + /* 5 */ "...mmmm" + /* 6 */ "...mmmm" + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "b..aamm" + /* 1 */ ".efaamm" + /* 2 */ ".d.aamm" + /* 3 */ "...bmmm" + /* 4 */ "...mmmm" + /* 5 */ "...mmmm" + /* 6 */ "...mmmm" + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "b...aaa" + /* 1 */ "...faaa" + /* 2 */ "....aaa" + /* 3 */ "...baaa" + /* 4 */ "...mmmm" + /* 5 */ "mmmmmmm" + /* 6 */ "mmmmmmm" + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "ag....b" + /* 1 */ "h...ij." + /* 2 */ ".....k." + /* 3 */ "...baaa" + /* 4 */ "mmmmaaa" + /* 5 */ "mmmmmmm" + /* 6 */ "mmmmmmm" + + // Level 6 + /* z\x* 0123456 */ + /* 0 */ "mm....b" + /* 1 */ "mm....." + /* 2 */ "mm....." + /* 3 */ "mmmb.k." + /* 4 */ "mmmaaaa" + /* 5 */ "mmmaaaa" + /* 6 */ "mmmaaaa" + + // Level 7 + /* z\x* 0123456 */ + /* 0 */ "mmm..la" + /* 1 */ "mmm...h" + /* 2 */ "mmm...." + /* 3 */ "mmmb..." + /* 4 */ "mmaa.d." + /* 5 */ "mmaano." + /* 6 */ "mmaa..b" + + // Level 8 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmmmmm" + /* 2 */ "mmmm..." + /* 3 */ "mmmb..." + /* 4 */ "aaa...." + /* 5 */ "aaan..." + /* 6 */ "aaa...b" + + // Level 9 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmmmmm" + /* 2 */ "mmmmmmm" + /* 3 */ "mmmb..." + /* 4 */ "......." + /* 5 */ "iii...p" + /* 6 */ ".....la" + + // Level 10 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmmmmm" + /* 2 */ "mmmmmmm" + /* 3 */ "mmmbmmm" + /* 4 */ ".....mm" + /* 5 */ ".....mm" + /* 6 */ ".....mm" + + // Level 11 + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mmmmmmm" + /* 2 */ "mmmmmmm" + /* 3 */ "mmmbmmm" + /* 4 */ "....mmm" + /* 5 */ "....mmm" + /* 6 */ "....mmm", + + // Connectors: + "3: 1, 1, 6: 3\n" /* Type 3, direction Z+ */ + "-3: 1, 1, 6: 3\n" /* Type -3, direction Z+ */ + "3: 0, 9, 5: 4\n" /* Type 3, direction X- */ + "-3: 0, 9, 5: 4\n" /* Type -3, direction X- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // MineshaftSpiral + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MineshaftStairs: + // The data has been exported from the gallery Plains, area index 195, ID 659, created by Aloe_vera + { + // Size: + 7, 8, 3, // SizeX = 7, SizeY = 8, SizeZ = 3 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 7, 2, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "b: 66: 1\n" /* tracks */ + "c: 66: 2\n" /* tracks */ + "d: 85: 0\n" /* fence */ + "e: 50: 1\n" /* torch */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "aaammmm" + /* 1 */ "aaammmm" + /* 2 */ "aaammmm" + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "..aammm" + /* 1 */ "bcaammm" + /* 2 */ "..aammm" + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "...aamm" + /* 1 */ "..caamm" + /* 2 */ "...aamm" + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "...daam" + /* 1 */ "...caam" + /* 2 */ "...daam" + + // Level 4 + /* z\x* 0123456 */ + /* 0 */ "m..d.aa" + /* 1 */ "m...caa" + /* 2 */ "m..d.aa" + + // Level 5 + /* z\x* 0123456 */ + /* 0 */ "mm.d..." + /* 1 */ "mm...bb" + /* 2 */ "mm.d..." + + // Level 6 + /* z\x* 0123456 */ + /* 0 */ "mmmd..." + /* 1 */ "mmm...." + /* 2 */ "mmmd..." + + // Level 7 + /* z\x* 0123456 */ + /* 0 */ "mmma..." + /* 1 */ "mmmae.." + /* 2 */ "mmma...", + + // Connectors: + "3: 0, 1, 1: 4\n" /* Type 3, direction X- */ + "-3: 0, 1, 1: 4\n" /* Type -3, direction X- */ + "3: 6, 5, 1: 5\n" /* Type 3, direction X+ */ + "-3: 6, 5, 1: 5\n" /* Type -3, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // MineshaftStairs + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MineshaftStairsCrossing: + // The data has been exported from the gallery Plains, area index 199, ID 663, created by Aloe_vera + { + // Size: + 11, 12, 11, // SizeX = 11, SizeY = 12, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 11, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "b: 66: 5\n" /* tracks */ + "c: 85: 0\n" /* fence */ + "d: 66: 0\n" /* tracks */ + "e: 66: 1\n" /* tracks */ + "f: 50: 3\n" /* torch */ + "g: 50: 2\n" /* torch */ + "h: 50: 1\n" /* torch */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmaaammmm" + /* 1 */ "mmmmaaammmm" + /* 2 */ "mmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmm" + /* 4 */ "mmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmm" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmm.b.mmmm" + /* 1 */ "mmmmaaammmm" + /* 2 */ "mmmmaaammmm" + /* 3 */ "mmmmmmmmmmm" + /* 4 */ "mmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmm" + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmm...mmmm" + /* 1 */ "mmmm.b.mmmm" + /* 2 */ "mmmmaaammmm" + /* 3 */ "mmmmaaammmm" + /* 4 */ "mmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmm" + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmm...mmmm" + /* 1 */ "mmmm...mmmm" + /* 2 */ "mmmmcbcmmmm" + /* 3 */ "mmmmaaammmm" + /* 4 */ "mmmmaaammmm" + /* 5 */ "mmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmm" + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmm...mmmm" + /* 1 */ "mmmm...mmmm" + /* 2 */ "mmmmc.cmmmm" + /* 3 */ "mmmm.b.mmmm" + /* 4 */ "aaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaa" + /* 7 */ "mmmmaaammmm" + /* 8 */ "mmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmm" + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmmmmmmmm" + /* 1 */ "mmmm...mmmm" + /* 2 */ "mmmmc.cmmmm" + /* 3 */ "mmmm...mmmm" + /* 4 */ "..c..d..c.." + /* 5 */ "eeeeeeeeeee" + /* 6 */ "..c..b..c.." + /* 7 */ "mmmmaaammmm" + /* 8 */ "mmmmaaammmm" + /* 9 */ "mmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmm" + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmm" + /* 2 */ "mmmmc.cmmmm" + /* 3 */ "mmmm...mmmm" + /* 4 */ "..c.....c.." + /* 5 */ "..........." + /* 6 */ "..c.....c.." + /* 7 */ "mmmm.b.mmmm" + /* 8 */ "mmmmaaammmm" + /* 9 */ "mmmmaaammmm" + /* 10 */ "mmmmmmmmmmm" + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmm" + /* 2 */ "mmmmaaammmm" + /* 3 */ "mmmm.f.mmmm" + /* 4 */ "..a.....a.." + /* 5 */ ".gah...gah." + /* 6 */ "..a.....a.." + /* 7 */ "mmmm...mmmm" + /* 8 */ "mmmmcbcmmmm" + /* 9 */ "mmmmaaammmm" + /* 10 */ "mmmmaaammmm" + + // Level 8 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmm" + /* 4 */ "mmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmm" + /* 6 */ "mmmm...mmmm" + /* 7 */ "mmmm...mmmm" + /* 8 */ "mmmmc.cmmmm" + /* 9 */ "mmmm.b.mmmm" + /* 10 */ "mmmmaaammmm" + + // Level 9 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmm" + /* 4 */ "mmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmm" + /* 7 */ "mmmm...mmmm" + /* 8 */ "mmmmc.cmmmm" + /* 9 */ "mmmm...mmmm" + /* 10 */ "mmmm.d.mmmm" + + // Level 10 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmm" + /* 4 */ "mmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmm" + /* 8 */ "mmmmc.cmmmm" + /* 9 */ "mmmm...mmmm" + /* 10 */ "mmmm...mmmm" + + // Level 11 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmm" + /* 4 */ "mmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmm" + /* 8 */ "mmmmaaammmm" + /* 9 */ "mmmm.f.mmmm" + /* 10 */ "mmmm...mmmm", + + // Connectors: + "3: 0, 5, 5: 4\n" /* Type 3, direction X- */ + "-3: 0, 5, 5: 4\n" /* Type -3, direction X- */ + "3: 10, 5, 5: 5\n" /* Type 3, direction X+ */ + "-3: 10, 5, 5: 5\n" /* Type -3, direction X+ */ + "3: 5, 9, 10: 3\n" /* Type 3, direction Z+ */ + "-3: 5, 9, 10: 3\n" /* Type -3, direction Z+ */ + "3: 5, 1, 0: 2\n" /* Type 3, direction Z- */ + "-3: 5, 1, 0: 2\n" /* Type -3, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 30, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // MineshaftStairsCrossing + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MineshaftTee: + // The data has been exported from the gallery Plains, area index 194, ID 658, created by Aloe_vera + { + // Size: + 11, 4, 7, // SizeX = 11, SizeY = 4, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 3, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "b: 66: 0\n" /* tracks */ + "c: 85: 0\n" /* fence */ + "d: 66: 1\n" /* tracks */ + "e: 50: 4\n" /* torch */ + "f: 50: 3\n" /* torch */ + "g: 50: 2\n" /* torch */ + "h: 50: 1\n" /* torch */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmaaammmm" + /* 1 */ "mmmmaaammmm" + /* 2 */ "mmmmaaammmm" + /* 3 */ "mmmmaaammmm" + /* 4 */ "aaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaa" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmm.b.mmmm" + /* 1 */ "mmmm.b.mmmm" + /* 2 */ "mmmmcbcmmmm" + /* 3 */ "mmmm.b.mmmm" + /* 4 */ "..c..b..c.." + /* 5 */ "ddddddddddd" + /* 6 */ "..c.....c.." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmm...mmmm" + /* 1 */ "mmmm...mmmm" + /* 2 */ "mmmmc.cmmmm" + /* 3 */ "mmmm...mmmm" + /* 4 */ "..c.....c.." + /* 5 */ "..........." + /* 6 */ "..c.....c.." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmm...mmmm" + /* 1 */ "mmmm.e.mmmm" + /* 2 */ "mmmmaaammmm" + /* 3 */ "mmmm.f.mmmm" + /* 4 */ "..a.....a.." + /* 5 */ ".gah...gah." + /* 6 */ "..a.....a..", + + // Connectors: + "3: 0, 1, 5: 4\n" /* Type 3, direction X- */ + "-3: 0, 1, 5: 4\n" /* Type -3, direction X- */ + "3: 5, 1, 0: 2\n" /* Type 3, direction Z- */ + "-3: 5, 1, 0: 2\n" /* Type -3, direction Z- */ + "3: 10, 1, 5: 5\n" /* Type 3, direction X+ */ + "-3: 10, 1, 5: 5\n" /* Type -3, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 20, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // MineshaftTee + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // MineshaftsCorridor5: + // The data has been exported from the gallery Plains, area index 200, ID 664, created by Aloe_vera + { + // Size: + 11, 4, 3, // SizeX = 11, SizeY = 4, SizeZ = 3 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 3, 2, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "b: 85: 0\n" /* fence */ + "c: 66: 1\n" /* tracks */ + "d: 50: 2\n" /* torch */ + "e: 50: 1\n" /* torch */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaa" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..b.....b.." + /* 1 */ "ccccccccccc" + /* 2 */ "..b.....b.." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..b.....b.." + /* 1 */ "..........." + /* 2 */ "..b.....b.." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..a.....a.." + /* 1 */ ".dae...dae." + /* 2 */ "..a.....a..", + + // Connectors: + "3: 10, 1, 1: 5\n" /* Type 3, direction X+ */ + "-3: 10, 1, 1: 5\n" /* Type -3, direction X+ */ + "-3: 0, 1, 1: 4\n" /* Type -3, direction X- */ + "3: 0, 1, 1: 4\n" /* Type 3, direction X- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // MineshaftsCorridor5 + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Scarecrow: // The data has been exported from the gallery Plains, area index 150, ID 494, created by STR_Warrior @@ -2770,8 +3588,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Block definitions: ".: 0: 0\n" /* air */ - "a: 3: 0\n" /* dirt */ - "b: 2: 0\n" /* grass */ + "a: 2: 0\n" /* grass */ + "b: 3: 0\n" /* dirt */ "c: 4: 0\n" /* cobblestone */ "d: 67: 0\n" /* stairs */ "e: 67: 2\n" /* stairs */ @@ -2796,19 +3614,19 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "abaaaaabbbb" - /* 1 */ "baaaaaaaaab" - /* 2 */ "baaaaaaaaab" - /* 3 */ "baaaaaaaaab" - /* 4 */ "baaaaaaaaab" - /* 5 */ "baaaaaaaaab" - /* 6 */ "baaaaaaaaab" - /* 7 */ "baaaaaaaaab" - /* 8 */ "bbaaaaaaabb" - /* 9 */ "bbaaaaaaabb" - /* 10 */ "bbaaaaaaabb" - /* 11 */ "bbaaaaaaabb" - /* 12 */ "bbaaaaaaabb" + /* 0 */ "aaabbbbaaaa" + /* 1 */ "abbbbbbbbba" + /* 2 */ "abbbbbbbbba" + /* 3 */ "abbbbbbbbba" + /* 4 */ "abbbbbbbbba" + /* 5 */ "abbbbbbbbba" + /* 6 */ "abbbbbbbbba" + /* 7 */ "abbbbbbbbba" + /* 8 */ "aabbbbbbbaa" + /* 9 */ "aabbbbbbbaa" + /* 10 */ "aabbbbbbbaa" + /* 11 */ "aabbbbbbbaa" + /* 12 */ "aabbbbbbbaa" // Level 1 /* z\x* 1 */ @@ -2821,11 +3639,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 5 */ "mcccccccccm" /* 6 */ "mcccccccccm" /* 7 */ "mcccccccccm" - /* 8 */ "mmaaaaaaamm" - /* 9 */ "mmaaaaaaamm" - /* 10 */ "mmaaaaaaamm" - /* 11 */ "mmaaaaaaamm" - /* 12 */ "mmaaaaaaamm" + /* 8 */ "mmbbbbbbbmm" + /* 9 */ "mmbbbbbbbmm" + /* 10 */ "mmbbbbbbbmm" + /* 11 */ "mmbbbbbbbmm" + /* 12 */ "mmbbbbbbbmm" // Level 2 /* z\x* 1 */ @@ -2838,11 +3656,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 5 */ ".cggggcccc." /* 6 */ ".cggggcccc." /* 7 */ ".ccccccccc." - /* 8 */ "..bbbbbbb.." - /* 9 */ "..bbbbbbb.." - /* 10 */ "..bbbbbbb.." - /* 11 */ "..bbbbbbb.." - /* 12 */ "..bbbbbbb.." + /* 8 */ "..aaaaaaa.." + /* 9 */ "..aaaaaaa.." + /* 10 */ "..aaaaaaa.." + /* 11 */ "..aaaaaaa.." + /* 12 */ "..aaaaaaa.." // Level 3 /* z\x* 1 */ -- cgit v1.2.3 From b9d306a801af7de6c620740d5f8c827c7df29dce Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 30 May 2014 22:41:47 +0200 Subject: Fixed bindings for cCompositeChat:SetMessageType(). --- src/Bindings/ManualBindings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 10e560ac0..14d9d16fc 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -2864,8 +2864,8 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S) } // Set the type: - int MessageType; - L.GetStackValue(1, MessageType); + int MessageType = mtCustom; + L.GetStackValue(2, MessageType); self->SetMessageType((eMessageType)MessageType); // Cut away everything from the stack except for the cCompositeChat instance; return that: -- cgit v1.2.3 From 843288493e1dcf9e22ac644d652ea3b13c7858ab Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 30 May 2014 23:41:17 +0200 Subject: Fix the furnace result slot. --- src/UI/SlotArea.cpp | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 507b45833..6853ff90c 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1381,14 +1381,99 @@ cSlotAreaFurnace::~cSlotAreaFurnace() void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) { - super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem); - if (m_Furnace == NULL) { LOGERROR("cSlotAreaFurnace::Clicked(): m_Furnace == NULL"); ASSERT(!"cSlotAreaFurnace::Clicked(): m_Furnace == NULL"); return; } + + if (a_SlotNum == 2) + { + bool bAsync = false; + if (GetSlot(a_SlotNum, a_Player) == NULL) + { + LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum); + return; + } + + if (a_ClickAction == caDblClick) + { + return; + } + + if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick)) + { + ShiftClicked(a_Player, a_SlotNum, a_ClickedItem); + } + + cItem Slot(*GetSlot(a_SlotNum, a_Player)); + if (!Slot.IsSameType(a_ClickedItem)) + { + LOGWARNING("*** Window lost sync at item %d in SlotArea with %d items ***", a_SlotNum, m_NumSlots); + LOGWARNING("My item: %s", ItemToFullString(Slot).c_str()); + LOGWARNING("Their item: %s", ItemToFullString(a_ClickedItem).c_str()); + bAsync = true; + } + cItem & DraggingItem = a_Player.GetDraggingItem(); + + if (!DraggingItem.IsEmpty()) + { + if (!DraggingItem.IsEqual(Slot)) + { + return; + } + if ((DraggingItem.m_ItemCount + Slot.m_ItemCount) > Slot.GetMaxStackSize()) + { + return; + } + + DraggingItem.m_ItemCount += Slot.m_ItemCount; + Slot.Empty(); + } + else + { + switch (a_ClickAction) + { + case caDblClick: + { + DblClicked(a_Player, a_SlotNum); + return; + } + case caLeftClick: + { + DraggingItem = cItem(Slot); + Slot.Empty(); + break; + } + case caRightClick: + { + DraggingItem = Slot.CopyOne(); + DraggingItem.m_ItemCount = (char)(((float)Slot.m_ItemCount) / 2.f + 0.5f); + Slot.m_ItemCount -= DraggingItem.m_ItemCount; + + if (Slot.IsEmpty()) + { + Slot.Empty(); + } + break; + } + default: + { + ASSERT(!"Unhandled click type!"); + } + } + } + + SetSlot(a_SlotNum, a_Player, Slot); + if (bAsync) + { + m_ParentWindow.BroadcastWholeWindow(); + } + return; + } + + super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem); } @@ -1397,6 +1482,7 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a const cItem * cSlotAreaFurnace::GetSlot(int a_SlotNum, cPlayer & a_Player) const { + UNUSED(a_Player); // a_SlotNum ranges from 0 to 2, query the items from the underlying furnace: return &(m_Furnace->GetSlot(a_SlotNum)); } @@ -1407,6 +1493,7 @@ const cItem * cSlotAreaFurnace::GetSlot(int a_SlotNum, cPlayer & a_Player) const void cSlotAreaFurnace::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) { + UNUSED(a_Player); m_Furnace->SetSlot(a_SlotNum, a_Item); } @@ -1416,6 +1503,7 @@ void cSlotAreaFurnace::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & void cSlotAreaFurnace::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) { + UNUSED(a_SlotNum); // Something has changed in the window, broadcast the entire window to all clients ASSERT(a_ItemGrid == &(m_Furnace->GetContents())); -- cgit v1.2.3 From 01fc93857cb18d918ab98109dabd9665038871af Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 31 May 2014 00:22:24 +0200 Subject: Change "Slot.IsEmpty()" to "Slot.m_ItemCount <= 0" --- src/UI/SlotArea.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 6853ff90c..3acc49cde 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1452,7 +1452,7 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a DraggingItem.m_ItemCount = (char)(((float)Slot.m_ItemCount) / 2.f + 0.5f); Slot.m_ItemCount -= DraggingItem.m_ItemCount; - if (Slot.IsEmpty()) + if (Slot.m_ItemCount <= 0) { Slot.Empty(); } -- cgit v1.2.3 From d422aa4081cd5c64ab0df4017630674a245c701d Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 31 May 2014 00:25:20 +0200 Subject: Fix DBL bug. --- src/UI/SlotArea.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 3acc49cde..7c79e290a 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1397,11 +1397,6 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a return; } - if (a_ClickAction == caDblClick) - { - return; - } - if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick)) { ShiftClicked(a_Player, a_SlotNum, a_ClickedItem); @@ -1419,6 +1414,10 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a if (!DraggingItem.IsEmpty()) { + if (a_ClickAction == caDblClick) + { + return; + } if (!DraggingItem.IsEqual(Slot)) { return; -- cgit v1.2.3 From 2030800ad78678b783224010e22382d413863975 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 31 May 2014 00:27:24 +0200 Subject: Set DraggingItem to Slot directly. --- src/UI/SlotArea.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 7c79e290a..b3e126247 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1441,7 +1441,7 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a } case caLeftClick: { - DraggingItem = cItem(Slot); + DraggingItem = Slot; Slot.Empty(); break; } -- cgit v1.2.3 From f4e9c88dcdefee2b6e4ca7f97483d4cdfba939ae Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 31 May 2014 10:33:12 +0200 Subject: Fixed a memory leak in VillagGen. --- src/Generating/VillageGen.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index dfcdf6ef7..b9cb056ad 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -147,6 +147,11 @@ public: } } + ~cVillage() + { + cPieceGenerator::FreePieces(m_Pieces); + } + protected: /** Seed for the random functions */ int m_Seed; -- cgit v1.2.3 From 600c93bdc16e6826ebf9822ad941a1f87139bab5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 31 May 2014 10:33:29 +0200 Subject: Updated PlainsVillage prefabs. --- src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 158 +++++++++++++----------- 1 file changed, 85 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index f5e531955..f5c5b7a20 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -1472,18 +1472,18 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 199, ID 663, created by Aloe_vera { // Size: - 11, 12, 11, // SizeX = 11, SizeY = 12, SizeZ = 11 + 11, 12, 12, // SizeX = 11, SizeY = 12, SizeZ = 12 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 10, 11, 10, // MaxX, MaxY, MaxZ + 10, 11, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ "a: 5: 0\n" /* wood */ - "b: 66: 5\n" /* tracks */ - "c: 85: 0\n" /* fence */ - "d: 66: 0\n" /* tracks */ + "b: 66: 0\n" /* tracks */ + "c: 66: 5\n" /* tracks */ + "d: 85: 0\n" /* fence */ "e: 66: 1\n" /* tracks */ "f: 50: 3\n" /* torch */ "g: 50: 2\n" /* torch */ @@ -1496,7 +1496,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* * 01234567890 */ /* 0 */ "mmmmaaammmm" /* 1 */ "mmmmaaammmm" - /* 2 */ "mmmmmmmmmmm" + /* 2 */ "mmmmaaammmm" /* 3 */ "mmmmmmmmmmm" /* 4 */ "mmmmmmmmmmm" /* 5 */ "mmmmmmmmmmm" @@ -1505,14 +1505,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 8 */ "mmmmmmmmmmm" /* 9 */ "mmmmmmmmmmm" /* 10 */ "mmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmm" // Level 1 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "mmmm.b.mmmm" - /* 1 */ "mmmmaaammmm" + /* 1 */ "mmmm.c.mmmm" /* 2 */ "mmmmaaammmm" - /* 3 */ "mmmmmmmmmmm" + /* 3 */ "mmmmaaammmm" /* 4 */ "mmmmmmmmmmm" /* 5 */ "mmmmmmmmmmm" /* 6 */ "mmmmmmmmmmm" @@ -1520,96 +1521,103 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 8 */ "mmmmmmmmmmm" /* 9 */ "mmmmmmmmmmm" /* 10 */ "mmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmm" // Level 2 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "mmmm...mmmm" - /* 1 */ "mmmm.b.mmmm" - /* 2 */ "mmmmaaammmm" + /* 1 */ "mmmm...mmmm" + /* 2 */ "mmmm.c.mmmm" /* 3 */ "mmmmaaammmm" - /* 4 */ "mmmmmmmmmmm" + /* 4 */ "mmmmaaammmm" /* 5 */ "mmmmmmmmmmm" /* 6 */ "mmmmmmmmmmm" /* 7 */ "mmmmmmmmmmm" /* 8 */ "mmmmmmmmmmm" /* 9 */ "mmmmmmmmmmm" /* 10 */ "mmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmm" // Level 3 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "mmmm...mmmm" /* 1 */ "mmmm...mmmm" - /* 2 */ "mmmmcbcmmmm" - /* 3 */ "mmmmaaammmm" + /* 2 */ "mmmm...mmmm" + /* 3 */ "mmmmdcdmmmm" /* 4 */ "mmmmaaammmm" - /* 5 */ "mmmmmmmmmmm" + /* 5 */ "mmmmaaammmm" /* 6 */ "mmmmmmmmmmm" /* 7 */ "mmmmmmmmmmm" /* 8 */ "mmmmmmmmmmm" /* 9 */ "mmmmmmmmmmm" /* 10 */ "mmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmm" // Level 4 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "mmmm...mmmm" + /* 0 */ "mmmmmmmmmmm" /* 1 */ "mmmm...mmmm" - /* 2 */ "mmmmc.cmmmm" - /* 3 */ "mmmm.b.mmmm" - /* 4 */ "aaaaaaaaaaa" + /* 2 */ "mmmm...mmmm" + /* 3 */ "mmmmd.dmmmm" + /* 4 */ "mmmm.c.mmmm" /* 5 */ "aaaaaaaaaaa" /* 6 */ "aaaaaaaaaaa" - /* 7 */ "mmmmaaammmm" - /* 8 */ "mmmmmmmmmmm" + /* 7 */ "aaaaaaaaaaa" + /* 8 */ "mmmmaaammmm" /* 9 */ "mmmmmmmmmmm" /* 10 */ "mmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmm" // Level 5 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "mmmmmmmmmmm" - /* 1 */ "mmmm...mmmm" - /* 2 */ "mmmmc.cmmmm" - /* 3 */ "mmmm...mmmm" - /* 4 */ "..c..d..c.." - /* 5 */ "eeeeeeeeeee" - /* 6 */ "..c..b..c.." - /* 7 */ "mmmmaaammmm" + /* 1 */ "mmmmmmmmmmm" + /* 2 */ "mmmm...mmmm" + /* 3 */ "mmmmd.dmmmm" + /* 4 */ "mmmm...mmmm" + /* 5 */ "..d..b..d.." + /* 6 */ "eeeeeeeeeee" + /* 7 */ "..d..c..d.." /* 8 */ "mmmmaaammmm" - /* 9 */ "mmmmmmmmmmm" + /* 9 */ "mmmmaaammmm" /* 10 */ "mmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmm" // Level 6 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "mmmmmmmmmmm" /* 1 */ "mmmmmmmmmmm" - /* 2 */ "mmmmc.cmmmm" - /* 3 */ "mmmm...mmmm" - /* 4 */ "..c.....c.." - /* 5 */ "..........." - /* 6 */ "..c.....c.." - /* 7 */ "mmmm.b.mmmm" - /* 8 */ "mmmmaaammmm" + /* 2 */ "mmmmmmmmmmm" + /* 3 */ "mmmmd.dmmmm" + /* 4 */ "mmmm...mmmm" + /* 5 */ "..d.....d.." + /* 6 */ "..........." + /* 7 */ "..d.....d.." + /* 8 */ "mmmm.c.mmmm" /* 9 */ "mmmmaaammmm" - /* 10 */ "mmmmmmmmmmm" + /* 10 */ "mmmmaaammmm" + /* 11 */ "mmmmmmmmmmm" // Level 7 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "mmmmmmmmmmm" /* 1 */ "mmmmmmmmmmm" - /* 2 */ "mmmmaaammmm" - /* 3 */ "mmmm.f.mmmm" - /* 4 */ "..a.....a.." - /* 5 */ ".gah...gah." - /* 6 */ "..a.....a.." - /* 7 */ "mmmm...mmmm" - /* 8 */ "mmmmcbcmmmm" - /* 9 */ "mmmmaaammmm" + /* 2 */ "mmmmmmmmmmm" + /* 3 */ "mmmmaaammmm" + /* 4 */ "mmmm.f.mmmm" + /* 5 */ "..a.....a.." + /* 6 */ ".gah...gah." + /* 7 */ "..a.....a.." + /* 8 */ "mmmm...mmmm" + /* 9 */ "mmmmdcdmmmm" /* 10 */ "mmmmaaammmm" + /* 11 */ "mmmmaaammmm" // Level 8 /* z\x* 1 */ @@ -1620,11 +1628,12 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 3 */ "mmmmmmmmmmm" /* 4 */ "mmmmmmmmmmm" /* 5 */ "mmmmmmmmmmm" - /* 6 */ "mmmm...mmmm" + /* 6 */ "mmmmmmmmmmm" /* 7 */ "mmmm...mmmm" - /* 8 */ "mmmmc.cmmmm" - /* 9 */ "mmmm.b.mmmm" - /* 10 */ "mmmmaaammmm" + /* 8 */ "mmmm...mmmm" + /* 9 */ "mmmmd.dmmmm" + /* 10 */ "mmmm.c.mmmm" + /* 11 */ "mmmmaaammmm" // Level 9 /* z\x* 1 */ @@ -1636,10 +1645,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 4 */ "mmmmmmmmmmm" /* 5 */ "mmmmmmmmmmm" /* 6 */ "mmmmmmmmmmm" - /* 7 */ "mmmm...mmmm" - /* 8 */ "mmmmc.cmmmm" - /* 9 */ "mmmm...mmmm" - /* 10 */ "mmmm.d.mmmm" + /* 7 */ "mmmmmmmmmmm" + /* 8 */ "mmmm...mmmm" + /* 9 */ "mmmmd.dmmmm" + /* 10 */ "mmmm...mmmm" + /* 11 */ "mmmm.b.mmmm" // Level 10 /* z\x* 1 */ @@ -1652,9 +1662,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 5 */ "mmmmmmmmmmm" /* 6 */ "mmmmmmmmmmm" /* 7 */ "mmmmmmmmmmm" - /* 8 */ "mmmmc.cmmmm" - /* 9 */ "mmmm...mmmm" + /* 8 */ "mmmmmmmmmmm" + /* 9 */ "mmmmd.dmmmm" /* 10 */ "mmmm...mmmm" + /* 11 */ "mmmm...mmmm" // Level 11 /* z\x* 1 */ @@ -1667,19 +1678,20 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 5 */ "mmmmmmmmmmm" /* 6 */ "mmmmmmmmmmm" /* 7 */ "mmmmmmmmmmm" - /* 8 */ "mmmmaaammmm" - /* 9 */ "mmmm.f.mmmm" - /* 10 */ "mmmm...mmmm", + /* 8 */ "mmmmmmmmmmm" + /* 9 */ "mmmmaaammmm" + /* 10 */ "mmmm.f.mmmm" + /* 11 */ "mmmm...mmmm", // Connectors: - "3: 0, 5, 5: 4\n" /* Type 3, direction X- */ - "-3: 0, 5, 5: 4\n" /* Type -3, direction X- */ - "3: 10, 5, 5: 5\n" /* Type 3, direction X+ */ - "-3: 10, 5, 5: 5\n" /* Type -3, direction X+ */ - "3: 5, 9, 10: 3\n" /* Type 3, direction Z+ */ - "-3: 5, 9, 10: 3\n" /* Type -3, direction Z+ */ - "3: 5, 1, 0: 2\n" /* Type 3, direction Z- */ - "-3: 5, 1, 0: 2\n" /* Type -3, direction Z- */, + "3: 0, 5, 6: 4\n" /* Type 3, direction X- */ + "-3: 0, 5, 6: 4\n" /* Type -3, direction X- */ + "3: 10, 5, 6: 5\n" /* Type 3, direction X+ */ + "-3: 10, 5, 6: 5\n" /* Type -3, direction X+ */ + "3: 5, 9, 11: 3\n" /* Type 3, direction Z+ */ + "-3: 5, 9, 11: 3\n" /* Type -3, direction Z+ */ + "3: 5, 1, 1: 2\n" /* Type 3, direction Z- */ + "-3: 5, 1, 1: 2\n" /* Type -3, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -3143,17 +3155,17 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 0 /* z\x* */ /* * 0123456789 */ - /* 0 */ "mmmmmmmmmm" - /* 1 */ "maaaaammmm" - /* 2 */ "maaaaammmm" - /* 3 */ "maaaaabbbb" + /* 0 */ ".........." + /* 1 */ ".aaaaa...." + /* 2 */ ".aaaaa...." + /* 3 */ ".aaaaabbbb" /* 4 */ "aaaaaabbbb" /* 5 */ "aaaaaabbbb" /* 6 */ "aaaaaabbbb" - /* 7 */ "maaaaabbbb" - /* 8 */ "maaaaabbbb" - /* 9 */ "maaaaammmm" - /* 10 */ "mmmmmmmmmm" + /* 7 */ ".aaaaabbbb" + /* 8 */ ".aaaaabbbb" + /* 9 */ ".aaaaa...." + /* 10 */ ".........." // Level 1 /* z\x* */ -- cgit v1.2.3 From 0b7ed0f4934b75f959d13ce7b8a4c73cb88ce318 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 31 May 2014 11:47:03 +0200 Subject: Add doxy-comment --- src/Blocks/BlockDoor.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index c1e4de9d4..d8ce916fa 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -137,12 +137,13 @@ public: static NIBBLETYPE IsOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - NIBBLETYPE Meta = GetMetaFromRightDoor(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); + NIBBLETYPE Meta = GetTrueDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); return ((Meta & 0x4) != 0); } - static NIBBLETYPE GetMetaFromRightDoor(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) + /** Read the meta from the true part of the door and returns a meta with all infos include. */ + static NIBBLETYPE GetTrueDoorMeta(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); @@ -162,7 +163,7 @@ public: static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) { BLOCKTYPE Block = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); - NIBBLETYPE Meta = GetMetaFromRightDoor(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); + NIBBLETYPE Meta = GetTrueDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); if (!IsDoor(Block)) { -- cgit v1.2.3 From 683da71c0fa33c2542e28bed5d2f106ddfc68b64 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 31 May 2014 11:48:54 +0200 Subject: Moved the IsDoor check before the meta get. --- src/Blocks/BlockDoor.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index d8ce916fa..eaa039c50 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -163,13 +163,12 @@ public: static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) { BLOCKTYPE Block = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); - NIBBLETYPE Meta = GetTrueDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); - if (!IsDoor(Block)) { return; } + NIBBLETYPE Meta = GetTrueDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); bool Opened = (Meta & 0x4) != 0; if (Opened == a_Open) { -- cgit v1.2.3 From d1b23060ada3946d68453e381867861bc768999b Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 31 May 2014 14:14:55 +0200 Subject: Used recommendations --- src/Bindings/Plugin.h | 2 +- src/Bindings/PluginLua.cpp | 4 ++-- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 4 ++-- src/Bindings/PluginManager.h | 2 +- src/Entities/ProjectileEntity.cpp | 3 +-- 6 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index a6f91382c..3f1e0f0bc 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -90,7 +90,7 @@ public: virtual bool OnPluginsLoaded (void) = 0; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; - virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face, const Vector3i * a_BlockHitPos) = 0; + virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d * a_BlockHitPos) = 0; virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) = 0; virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) = 0; virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 97f78351b..da98f3f95 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -1108,14 +1108,14 @@ bool cPluginLua::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a -bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, eBlockFace a_Face, const Vector3i * a_BlockHitPos) +bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d * a_BlockHitPos) { cCSLock Lock(m_CriticalSection); bool res = false; cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_BLOCK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Projectile, a_Face, a_BlockHitPos, cLuaState::Return, res); + m_LuaState.Call((int)(**itr), &a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos, cLuaState::Return, res); if (res) { return true; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 627aa3cc8..6d0a90654 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -113,7 +113,7 @@ public: virtual bool OnPluginsLoaded (void) override; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; - virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face, const Vector3i * a_BlockHitPos) override; + virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d * a_BlockHitPos) override; virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) override; virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) override; virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index a5c904a77..066616c2a 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1154,7 +1154,7 @@ bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCrafti -bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, eBlockFace a_Face, const Vector3i * a_BlockHitPos) +bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d * a_BlockHitPos) { HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_BLOCK); if (Plugins == m_Hooks.end()) @@ -1163,7 +1163,7 @@ bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnProjectileHitBlock(a_Projectile, a_Face, a_BlockHitPos)) + if ((*itr)->OnProjectileHitBlock(a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos)) { return true; } diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 35755459a..47aab74e6 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -206,7 +206,7 @@ public: // tolua_export bool CallHookPluginsLoaded (void); bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); - bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, eBlockFace a_Face, const Vector3i * a_BlockHitPos); + bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d * a_BlockHitPos); bool CallHookProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity); bool CallHookSpawnedEntity (cWorld & a_World, cEntity & a_Entity); bool CallHookSpawnedMonster (cWorld & a_World, cMonster & a_Monster); diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 7a869a957..acb10539d 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -68,8 +68,7 @@ protected: if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face)) { Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff; - const Vector3i BlockHitPos = Vector3i(Intersection); - if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, Face, &BlockHitPos)) + if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, a_BlockX, a_BlockY, a_BlockZ, Face, &Intersection)) { return false; } -- cgit v1.2.3 From b436359237a9faa1dc5709e4359b73aa6faf4f78 Mon Sep 17 00:00:00 2001 From: JoannisO Date: Sat, 31 May 2014 16:08:15 +0200 Subject: - Changed the name of the ProjectileLookVector method. Note: I still think the new name is unclear. Any other suggestions are welcome. --- src/BlockEntities/DispenserEntity.cpp | 4 ++-- src/BlockEntities/DispenserEntity.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 799d41a1e..db1b405cd 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -198,7 +198,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) void cDispenserEntity::SpawnProjectileFromDispenser(cChunk & a_Chunk, int & a_DispX, int & a_DispY, int & a_DispZ, cProjectileEntity::eKind a_kind) { - Vector3d Angle = GetProjectileLookVector(a_Chunk); + Vector3d Angle = GetShootVector(a_Chunk); cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(a_DispX, a_DispZ); double EntityX = 0.5 + (a_DispX + DispChunk->GetPosX() * cChunkDef::Width); @@ -209,7 +209,7 @@ void cDispenserEntity::SpawnProjectileFromDispenser(cChunk & a_Chunk, int & a_Di -Vector3d cDispenserEntity::GetProjectileLookVector(cChunk & a_Chunk) +Vector3d cDispenserEntity::GetShootVector(cChunk & a_Chunk) { NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ); int Direction = 0; diff --git a/src/BlockEntities/DispenserEntity.h b/src/BlockEntities/DispenserEntity.h index 76aaccd3c..adbe2070c 100644 --- a/src/BlockEntities/DispenserEntity.h +++ b/src/BlockEntities/DispenserEntity.h @@ -33,7 +33,7 @@ private: void SpawnProjectileFromDispenser(cChunk & a_Chunk, int & a_DispX, int & a_DispY, int & a_DispZ, cProjectileEntity::eKind a_kind); // Returns how to aim the projectile - Vector3d GetProjectileLookVector(cChunk & a_Chunk); + Vector3d GetShootVector(cChunk & a_Chunk); /// If the a_BlockInFront is liquidable and the empty bucket can fit, does the m_Contents processing and returns true bool EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum); -- cgit v1.2.3 From 7672ca7eefc7233b507938d0592d1f565191d0ee Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 31 May 2014 22:06:14 +0200 Subject: Added an initial version of the underwater base generator. --- src/Generating/ComposableGenerator.cpp | 8 + src/Generating/Prefabs/UnderwaterBasePrefabs.cpp | 1888 ++++++++++++++++++++++ src/Generating/Prefabs/UnderwaterBasePrefabs.h | 15 + src/Generating/UnderwaterBaseGen.cpp | 142 ++ src/Generating/UnderwaterBaseGen.h | 50 + 5 files changed, 2103 insertions(+) create mode 100644 src/Generating/Prefabs/UnderwaterBasePrefabs.cpp create mode 100644 src/Generating/Prefabs/UnderwaterBasePrefabs.h create mode 100644 src/Generating/UnderwaterBaseGen.cpp create mode 100644 src/Generating/UnderwaterBaseGen.h (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 4dd626ed4..cf736ce64 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -25,6 +25,7 @@ #include "Noise3DGenerator.h" #include "POCPieceGenerator.h" #include "Ravines.h" +#include "UnderwaterBaseGen.h" #include "VillageGen.h" @@ -406,6 +407,13 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) { m_FinishGens.push_back(new cStructGenTrees(Seed, m_BiomeGen, m_HeightGen, m_CompositionGen)); } + else if (NoCaseCompare(*itr, "UnderwaterBases") == 0) + { + int GridSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseGridSize", 1024); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxDepth", 7); + int MaxSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxSize", 128); + m_FinishGens.push_back(new cUnderwaterBaseGen(Seed, GridSize, MaxDepth, MaxSize, *m_BiomeGen)); + } else if (NoCaseCompare(*itr, "Villages") == 0) { int GridSize = a_IniFile.GetValueSetI("Generator", "VillageGridSize", 384); diff --git a/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp new file mode 100644 index 000000000..54d1b6745 --- /dev/null +++ b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp @@ -0,0 +1,1888 @@ + +// UnderwaterBasePrefabs.cpp + +// Defines the prefabs in the group UnderwaterBase + +// NOTE: This file has been generated automatically by GalExport! +// Any manual changes will be overwritten by the next automatic export! + +#include "Globals.h" +#include "UnderwaterBasePrefabs.h" + + + + + +const cPrefab::sDef g_UnderwaterBasePrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Corridor16: + // The data has been exported from the gallery Water, area index 25, ID 566, created by xoft + { + // Size: + 16, 4, 4, // SizeX = 16, SizeY = 4, SizeZ = 4 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 15, 3, 3, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 5\n" /* wood */ + "b: 5: 0\n" /* wood */ + "c: 64: 2\n" /* wooddoorblock */ + "d: 64: 0\n" /* wooddoorblock */ + "e: 20: 0\n" /* glass */ + "f: 64: 9\n" /* wooddoorblock */ + "g: 76: 3\n" /* redstonetorchon */ + "h: 64: 8\n" /* wooddoorblock */ + "i: 76: 4\n" /* redstonetorchon */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "abbbbbbbbbbbbbba" + /* 2 */ "abbbbbbbbbbbbbba" + /* 3 */ "mmmmmmmmmmmmmmmm" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "abbbbbbbbbbbbbba" + /* 1 */ "c..............d" + /* 2 */ "c..............d" + /* 3 */ "abbbbbbbbbbbbbba" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "abeebbbeebbbeeba" + /* 1 */ "f.........g....h" + /* 2 */ "h....i.........f" + /* 3 */ "abeebbbeebbbeeba" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "abbbbbbbbbbbbbba" + /* 1 */ "abbbbbbbbbbbbbba" + /* 2 */ "abbbbbbbbbbbbbba" + /* 3 */ "abbbbbbbbbbbbbba", + + // Connectors: + "1: 0, 1, 1: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */ + "1: 15, 1, 2: 5\n" /* Type 1, direction X+ */ + "-1: 15, 1, 1: 5\n" /* Type -1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // Corridor16 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CorridorCorner: + // The data has been exported from the gallery Water, area index 26, ID 569, created by xoft + { + // Size: + 10, 4, 10, // SizeX = 10, SizeY = 4, SizeZ = 10 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 9, 3, 9, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 5\n" /* wood */ + "b: 5: 0\n" /* wood */ + "c: 64: 5\n" /* wooddoorblock */ + "d: 64: 2\n" /* wooddoorblock */ + "e: 64: 4\n" /* wooddoorblock */ + "f: 64: 1\n" /* wooddoorblock */ + "g: 20: 0\n" /* glass */ + "h: 64:12\n" /* wooddoorblock */ + "i: 76: 3\n" /* redstonetorchon */ + "j: 64: 8\n" /* wooddoorblock */ + "k: 76: 2\n" /* redstonetorchon */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "mmmmmmmmmm" + /* 1 */ "abbbbbmmmm" + /* 2 */ "abbbbbbbmm" + /* 3 */ "mmmbbbbbmm" + /* 4 */ "mmmmmbbbbm" + /* 5 */ "mmmmmmbbbm" + /* 6 */ "mmmmmmbbbm" + /* 7 */ "mmmmmmmbbm" + /* 8 */ "mmmmmmmbbm" + /* 9 */ "mmmmmmmaam" + + // Level 1 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "abbbbbmmmm" + /* 1 */ "c.....bbmm" + /* 2 */ "d.......bm" + /* 3 */ "abb.....bm" + /* 4 */ "mmmbb....b" + /* 5 */ "mmmmmb...b" + /* 6 */ "mmmmmb...b" + /* 7 */ "mmmmmmb..b" + /* 8 */ "mmmmmmb..b" + /* 9 */ "mmmmmmaefa" + + // Level 2 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "abggbbmmmm" + /* 1 */ "h...i.bbmm" + /* 2 */ "j.......bm" + /* 3 */ "abb.....bm" + /* 4 */ "mmmbb....b" + /* 5 */ "mmmmmb..kb" + /* 6 */ "mmmmmb...g" + /* 7 */ "mmmmmmb..g" + /* 8 */ "mmmmmmb..b" + /* 9 */ "mmmmmmahja" + + // Level 3 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "abbbbbmmmm" + /* 1 */ "abbbbbbbmm" + /* 2 */ "abbbbbbbbm" + /* 3 */ "abbbbbbbbm" + /* 4 */ "mmmbbbbbbb" + /* 5 */ "mmmmmbbbbb" + /* 6 */ "mmmmmbbbbb" + /* 7 */ "mmmmmmbbbb" + /* 8 */ "mmmmmmbbbb" + /* 9 */ "mmmmmmaaaa", + + // Connectors: + "1: 7, 1, 9: 3\n" /* Type 1, direction Z+ */ + "-1: 8, 1, 9: 3\n" /* Type -1, direction Z+ */ + "1: 0, 1, 1: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CorridorCorner + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CorridorCrossing: + // The data has been exported from the gallery Water, area index 31, ID 581, created by LO1ZB + { + // Size: + 16, 4, 16, // SizeX = 16, SizeY = 4, SizeZ = 16 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 15, 3, 15, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 5\n" /* wood */ + "b: 5: 0\n" /* wood */ + "c: 64: 3\n" /* wooddoorblock */ + "d: 64: 6\n" /* wooddoorblock */ + "e: 64: 5\n" /* wooddoorblock */ + "f: 64: 0\n" /* wooddoorblock */ + "g: 64: 2\n" /* wooddoorblock */ + "h: 64: 1\n" /* wooddoorblock */ + "i: 64: 8\n" /* wooddoorblock */ + "j: 64:12\n" /* wooddoorblock */ + "k: 20: 0\n" /* glass */ + "l: 76: 1\n" /* redstonetorchon */ + "m: 19: 0\n" /* sponge */ + "n: 76: 3\n" /* redstonetorchon */ + "o: 76: 4\n" /* redstonetorchon */ + "p: 64: 9\n" /* wooddoorblock */ + "q: 76: 2\n" /* redstonetorchon */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmaammmmmmm" + /* 1 */ "mmmmmmmbbmmmmmmm" + /* 2 */ "mmmmmmmbbmmmmmmm" + /* 3 */ "mmmmmmmbbmmmmmmm" + /* 4 */ "mmmmmmmbbmmmmmmm" + /* 5 */ "mmmmmmmbbmmmmmmm" + /* 6 */ "mmmmmmmbbmmmmmmm" + /* 7 */ "abbbbbbbbbbbbbba" + /* 8 */ "abbbbbbbbbbbbbba" + /* 9 */ "mmmmmmmbbmmmmmmm" + /* 10 */ "mmmmmmmbbmmmmmmm" + /* 11 */ "mmmmmmmbbmmmmmmm" + /* 12 */ "mmmmmmmbbmmmmmmm" + /* 13 */ "mmmmmmmbbmmmmmmm" + /* 14 */ "mmmmmmmbbmmmmmmm" + /* 15 */ "mmmmmmmaammmmmmm" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmacdammmmmm" + /* 1 */ "mmmmmmb..bmmmmmm" + /* 2 */ "mmmmmmb..bmmmmmm" + /* 3 */ "mmmmmmb..bmmmmmm" + /* 4 */ "mmmmmmb..bmmmmmm" + /* 5 */ "mmmmmmb..bmmmmmm" + /* 6 */ "abbbbbb..bbbbbba" + /* 7 */ "e..............f" + /* 8 */ "g..............f" + /* 9 */ "abbbbbb..bbbbbba" + /* 10 */ "mmmmmmb..bmmmmmm" + /* 11 */ "mmmmmmb..bmmmmmm" + /* 12 */ "mmmmmmb..bmmmmmm" + /* 13 */ "mmmmmmb..bmmmmmm" + /* 14 */ "mmmmmmb..bmmmmmm" + /* 15 */ "mmmmmmahhammmmmm" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmaijammmmmm" + /* 1 */ "mmmmmmb..bmmmmmm" + /* 2 */ "mmmmmmk..kmmmmmm" + /* 3 */ "mmmmmmk..kmmmmmm" + /* 4 */ "mmmmmmb..bmmmmmm" + /* 5 */ "mmmmmmbl.bmmmmmm" + /* 6 */ "abkkbbb..bbbkkba" + /* 7 */ "j.........n....i" + /* 8 */ "i....o.........p" + /* 9 */ "abkkbbb..bbbkkba" + /* 10 */ "mmmmmmb.qbmmmmmm" + /* 11 */ "mmmmmmb..bmmmmmm" + /* 12 */ "mmmmmmk..kmmmmmm" + /* 13 */ "mmmmmmk..kmmmmmm" + /* 14 */ "mmmmmmb..bmmmmmm" + /* 15 */ "mmmmmmapiammmmmm" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmaaaammmmmm" + /* 1 */ "mmmmmmbbbbmmmmmm" + /* 2 */ "mmmmmmbbbbmmmmmm" + /* 3 */ "mmmmmmbbbbmmmmmm" + /* 4 */ "mmmmmmbbbbmmmmmm" + /* 5 */ "mmmmmmbbbbmmmmmm" + /* 6 */ "abbbbbbbbbbbbbba" + /* 7 */ "abbbbbbbbbbbbbba" + /* 8 */ "abbbbbbbbbbbbbba" + /* 9 */ "abbbbbbbbbbbbbba" + /* 10 */ "mmmmmmbbbbmmmmmm" + /* 11 */ "mmmmmmbbbbmmmmmm" + /* 12 */ "mmmmmmbbbbmmmmmm" + /* 13 */ "mmmmmmbbbbmmmmmm" + /* 14 */ "mmmmmmbbbbmmmmmm" + /* 15 */ "mmmmmmaaaammmmmm", + + // Connectors: + "1: 0, 1, 7: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 8: 4\n" /* Type -1, direction X- */ + "1: 7, 1, 15: 3\n" /* Type 1, direction Z+ */ + "-1: 8, 1, 15: 3\n" /* Type -1, direction Z+ */ + "1: 8, 1, 0: 2\n" /* Type 1, direction Z- */ + "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */ + "1: 15, 1, 8: 5\n" /* Type 1, direction X+ */ + "-1: 15, 1, 7: 5\n" /* Type -1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CorridorCrossing + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CorridorStairs: + // The data has been exported from the gallery Water, area index 32, ID 582, created by LO1ZB + { + // Size: + 16, 9, 4, // SizeX = 16, SizeY = 9, SizeZ = 4 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 15, 8, 3, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 5\n" /* wood */ + "b: 5: 0\n" /* wood */ + "c: 64: 2\n" /* wooddoorblock */ + "d: 53: 0\n" /* woodstairs */ + "e: 20: 0\n" /* glass */ + "f: 64: 9\n" /* wooddoorblock */ + "g: 64: 8\n" /* wooddoorblock */ + "h: 76: 4\n" /* redstonetorchon */ + "i: 64: 0\n" /* wooddoorblock */ + "j: 64: 7\n" /* wooddoorblock */ + "k: 76: 3\n" /* redstonetorchon */ + "l: 64:12\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "abbbbbbbmmmmmmmm" + /* 2 */ "abbbbbbbmmmmmmmm" + /* 3 */ "mmmmmmmmmmmmmmmm" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "abbbbbbbmmmmmmmm" + /* 1 */ "c.....dbbmmmmmmm" + /* 2 */ "c.....dbbmmmmmmm" + /* 3 */ "abbbbbbbmmmmmmmm" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "abeebbbbbmmmmmmm" + /* 1 */ "f......dbbmmmmmm" + /* 2 */ "g...h..dbbmmmmmm" + /* 3 */ "abeebbbbbmmmmmmm" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "abbbbbbbbbmmmmmm" + /* 1 */ "abbbb...dbbmmmmm" + /* 2 */ "abbbb...dbbmmmmm" + /* 3 */ "abbbbbbbbbmmmmmm" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmbbbbbmmmmmm" + /* 1 */ "mmmmmb...dbbmmmm" + /* 2 */ "mmmmmb...dbbmmmm" + /* 3 */ "mmmmmbbbbbmmmmmm" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmbbbbbmmmmm" + /* 1 */ "mmmmmmb...dbbbba" + /* 2 */ "mmmmmmb...dbbbba" + /* 3 */ "mmmmmmbbbbbmmmmm" + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmbbbbbbbba" + /* 1 */ "mmmmmmmb.......i" + /* 2 */ "mmmmmmmb.......j" + /* 3 */ "mmmmmmmbbbbbbbba" + + // Level 7 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmbbbeebba" + /* 1 */ "mmmmmmmmb.k....g" + /* 2 */ "mmmmmmmmb......l" + /* 3 */ "mmmmmmmmbbbeebba" + + // Level 8 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmbbbbbba" + /* 1 */ "mmmmmmmmmbbbbbba" + /* 2 */ "mmmmmmmmmbbbbbba" + /* 3 */ "mmmmmmmmmbbbbbba", + + // Connectors: + "1: 0, 1, 1: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */ + "1: 15, 6, 2: 5\n" /* Type 1, direction X+ */ + "-1: 15, 6, 1: 5\n" /* Type -1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CorridorStairs + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CorridorTee: + // The data has been exported from the gallery Water, area index 29, ID 576, created by LO1ZB + { + // Size: + 16, 4, 10, // SizeX = 16, SizeY = 4, SizeZ = 10 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 15, 3, 9, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 5\n" /* wood */ + "b: 5: 0\n" /* wood */ + "c: 64: 3\n" /* wooddoorblock */ + "d: 64: 6\n" /* wooddoorblock */ + "e: 64: 5\n" /* wooddoorblock */ + "f: 64: 0\n" /* wooddoorblock */ + "g: 64: 2\n" /* wooddoorblock */ + "h: 64: 8\n" /* wooddoorblock */ + "i: 64:12\n" /* wooddoorblock */ + "j: 20: 0\n" /* glass */ + "k: 76: 1\n" /* redstonetorchon */ + "l: 76: 3\n" /* redstonetorchon */ + "m: 19: 0\n" /* sponge */ + "n: 76: 4\n" /* redstonetorchon */ + "o: 64: 9\n" /* wooddoorblock */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmaammmmmmm" + /* 1 */ "mmmmmmmbbmmmmmmm" + /* 2 */ "mmmmmmmbbmmmmmmm" + /* 3 */ "mmmmmmmbbmmmmmmm" + /* 4 */ "mmmmmmmbbmmmmmmm" + /* 5 */ "mmmmmmmbbmmmmmmm" + /* 6 */ "mmmmmmmbbmmmmmmm" + /* 7 */ "abbbbbbbbbbbbbba" + /* 8 */ "abbbbbbbbbbbbbba" + /* 9 */ "mmmmmmmmmmmmmmmm" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmacdammmmmm" + /* 1 */ "mmmmmmb..bmmmmmm" + /* 2 */ "mmmmmmb..bmmmmmm" + /* 3 */ "mmmmmmb..bmmmmmm" + /* 4 */ "mmmmmmb..bmmmmmm" + /* 5 */ "mmmmmmb..bmmmmmm" + /* 6 */ "abbbbbb..bbbbbba" + /* 7 */ "e..............f" + /* 8 */ "g..............f" + /* 9 */ "abbbbbbbbbbbbbba" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmahiammmmmm" + /* 1 */ "mmmmmmb..bmmmmmm" + /* 2 */ "mmmmmmj..jmmmmmm" + /* 3 */ "mmmmmmj..jmmmmmm" + /* 4 */ "mmmmmmb..bmmmmmm" + /* 5 */ "mmmmmmbk.bmmmmmm" + /* 6 */ "abjjbbb..bbbjjba" + /* 7 */ "i.........l....h" + /* 8 */ "h....n.........o" + /* 9 */ "abjjbbbjjbbbjjba" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmaaaammmmmm" + /* 1 */ "mmmmmmbbbbmmmmmm" + /* 2 */ "mmmmmmbbbbmmmmmm" + /* 3 */ "mmmmmmbbbbmmmmmm" + /* 4 */ "mmmmmmbbbbmmmmmm" + /* 5 */ "mmmmmmbbbbmmmmmm" + /* 6 */ "abbbbbbbbbbbbbba" + /* 7 */ "abbbbbbbbbbbbbba" + /* 8 */ "abbbbbbbbbbbbbba" + /* 9 */ "abbbbbbbbbbbbbba", + + // Connectors: + "1: 0, 1, 7: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 8: 4\n" /* Type -1, direction X- */ + "1: 8, 1, 0: 2\n" /* Type 1, direction Z- */ + "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */ + "1: 15, 1, 8: 5\n" /* Type 1, direction X+ */ + "-1: 15, 1, 7: 5\n" /* Type -1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CorridorTee + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ViewingCorner: + // The data has been exported from the gallery Water, area index 40, ID 613, created by LO1ZB + { + // Size: + 14, 7, 14, // SizeX = 14, SizeY = 7, SizeZ = 14 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 13, 6, 13, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "b: 20: 0\n" /* glass */ + "c: 5: 5\n" /* wood */ + "d: 64: 0\n" /* wooddoorblock */ + "e: 64: 1\n" /* wooddoorblock */ + "f: 64: 8\n" /* wooddoorblock */ + "g: 64: 9\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmaaaammmmmm" + /* 2 */ "mmmaabbaammmmm" + /* 3 */ "mmaabbbbaammmm" + /* 4 */ "maabbbbbbaammm" + /* 5 */ "mabbbbbbbbaaac" + /* 6 */ "mabbbbbbbbaaac" + /* 7 */ "maabbbbbbaammm" + /* 8 */ "mmaabbbbaammmm" + /* 9 */ "mmmaabbaammmmm" + /* 10 */ "mmmmaaaammmmmm" + /* 11 */ "mmmmmaammmmmmm" + /* 12 */ "mmmmmaammmmmmm" + /* 13 */ "mmmmmccmmmmmmm" + + // Level 1 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmaammmmmmm" + /* 1 */ "mmmaa..aammmmm" + /* 2 */ "mmaa....aammmm" + /* 3 */ "maa......aammm" + /* 4 */ "ma........aaac" + /* 5 */ "a............d" + /* 6 */ "a............d" + /* 7 */ "ma........aaac" + /* 8 */ "maa......aammm" + /* 9 */ "mmaa....aammmm" + /* 10 */ "mmmaa..aammmmm" + /* 11 */ "mmmma..ammmmmm" + /* 12 */ "mmmma..ammmmmm" + /* 13 */ "mmmmceecmmmmmm" + + // Level 2 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmbbmmmmmmm" + /* 1 */ "mmmbb..bbmmmmm" + /* 2 */ "mmbb....bbmmmm" + /* 3 */ "mbb......bbmmm" + /* 4 */ "mb........bbac" + /* 5 */ "b............f" + /* 6 */ "b............g" + /* 7 */ "mb........bbac" + /* 8 */ "mbb......bbmmm" + /* 9 */ "mmbb....bbmmmm" + /* 10 */ "mmmbb..bbmmmmm" + /* 11 */ "mmmmb..bmmmmmm" + /* 12 */ "mmmma..ammmmmm" + /* 13 */ "mmmmcgfcmmmmmm" + + // Level 3 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmbbmmmmmmm" + /* 1 */ "mmmbb..bbmmmmm" + /* 2 */ "mmbb....bbmmmm" + /* 3 */ "mbb......bbmmm" + /* 4 */ "mb........bbac" + /* 5 */ "b..........bac" + /* 6 */ "b..........bac" + /* 7 */ "mb........bbac" + /* 8 */ "mbb......bbmmm" + /* 9 */ "mmbb....bbmmmm" + /* 10 */ "mmmbb..bbmmmmm" + /* 11 */ "mmmmbbbbmmmmmm" + /* 12 */ "mmmmaaaammmmmm" + /* 13 */ "mmmmccccmmmmmm" + + // Level 4 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmmbbmmmmmmm" + /* 2 */ "mmmmb..bmmmmmm" + /* 3 */ "mmmb....bmmmmm" + /* 4 */ "mmb......bmmmm" + /* 5 */ "mb........bmmm" + /* 6 */ "mb........bmmm" + /* 7 */ "mmb......bmmmm" + /* 8 */ "mmmbb...bmmmmm" + /* 9 */ "mmmmb..bmmmmmm" + /* 10 */ "mmmmmbbmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmm" + /* 12 */ "mmmmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmm" + + // Level 5 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmm" + /* 2 */ "mmmmmbbmmmmmmm" + /* 3 */ "mmmmb..bmmmmmm" + /* 4 */ "mmmb....bmmmmm" + /* 5 */ "mmb......bmmmm" + /* 6 */ "mmb......bmmmm" + /* 7 */ "mmmb....bmmmmm" + /* 8 */ "mmmmb.bbmmmmmm" + /* 9 */ "mmmmmbbmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmm" + /* 12 */ "mmmmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmm" + + // Level 6 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmm" + /* 3 */ "mmmmmbbmmmmmmm" + /* 4 */ "mmmmbbbbmmmmmm" + /* 5 */ "mmmbbbbbbmmmmm" + /* 6 */ "mmmbbbbbbmmmmm" + /* 7 */ "mmmmbbbbmmmmmm" + /* 8 */ "mmmmmbbmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmm" + /* 12 */ "mmmmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmm", + + // Connectors: + "1: 13, 1, 6: 5\n" /* Type 1, direction X+ */ + "-1: 13, 1, 5: 5\n" /* Type -1, direction X+ */ + "1: 5, 1, 13: 3\n" /* Type 1, direction Z+ */ + "-1: 6, 1, 13: 3\n" /* Type -1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // ViewingCorner + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ViewingCorridor: + // The data has been exported from the gallery Water, area index 27, ID 571, created by LO1ZB + { + // Size: + 16, 5, 6, // SizeX = 16, SizeY = 5, SizeZ = 6 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 15, 4, 5, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "b: 5: 5\n" /* wood */ + "c: 20: 0\n" /* glass */ + "d: 64: 1\n" /* wooddoorblock */ + "e: 64: 0\n" /* wooddoorblock */ + "f: 64: 6\n" /* wooddoorblock */ + "g: 76: 3\n" /* redstonetorchon */ + "h: 64: 8\n" /* wooddoorblock */ + "i: 64:12\n" /* wooddoorblock */ + "j: 64: 9\n" /* wooddoorblock */ + "k: 76: 4\n" /* redstonetorchon */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmaaaaaaaaaaaamm" + /* 1 */ "mmaaaaaaaaaaaamm" + /* 2 */ "baaccccccccccaab" + /* 3 */ "baaccccccccccaab" + /* 4 */ "mmaaaaaaaaaaaamm" + /* 5 */ "mmmaaaaaaaaaammm" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmaccccccccccamm" + /* 1 */ "ba............ab" + /* 2 */ "d..............e" + /* 3 */ "f..............e" + /* 4 */ "ba............ab" + /* 5 */ "mmaccccccccccamm" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmaccccccccccamm" + /* 1 */ "bag..........gab" + /* 2 */ "h..............h" + /* 3 */ "i..............j" + /* 4 */ "bak..........kab" + /* 5 */ "mmaccccccccccamm" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmaccccccccccamm" + /* 1 */ "ba............ab" + /* 2 */ "ba............ab" + /* 3 */ "ba............ab" + /* 4 */ "ba............ab" + /* 5 */ "mmaccccccccccamm" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmaaaaaaaaaammm" + /* 1 */ "mmaaaaaaaaaaaamm" + /* 2 */ "mmaccccccccccamm" + /* 3 */ "mmaccccccccccamm" + /* 4 */ "mmaaaaaaaaaaaamm" + /* 5 */ "mmmaaaaaaaaaammm", + + // Connectors: + "1: 0, 1, 2: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */ + "1: 15, 1, 3: 5\n" /* Type 1, direction X+ */ + "-1: 15, 1, 2: 5\n" /* Type -1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // ViewingCorridor + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ViewingCorridorBulge: + // The data has been exported from the gallery Water, area index 42, ID 615, created by LO1ZB + { + // Size: + 12, 8, 16, // SizeX = 12, SizeY = 8, SizeZ = 16 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 11, 7, 15, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 5\n" /* wood */ + "b: 5: 0\n" /* wood */ + "c: 20: 0\n" /* glass */ + "d: 64: 3\n" /* wooddoorblock */ + "e: 64: 1\n" /* wooddoorblock */ + "f: 64: 8\n" /* wooddoorblock */ + "g: 64: 9\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "mmmmmaammmmm" + /* 1 */ "mmmmmbbmmmmm" + /* 2 */ "mmmmmbbmmmmm" + /* 3 */ "mmmmbbbbmmmm" + /* 4 */ "mmmbbccbbmmm" + /* 5 */ "mmbbccccbbmm" + /* 6 */ "mbbccccccbbm" + /* 7 */ "mbccccccccbm" + /* 8 */ "mbccccccccbm" + /* 9 */ "mbbccccccbbm" + /* 10 */ "mmbbccccbbmm" + /* 11 */ "mmmbbccbbmmm" + /* 12 */ "mmmmbbbbmmmm" + /* 13 */ "mmmmmbbmmmmm" + /* 14 */ "mmmmmbbmmmmm" + /* 15 */ "mmmmmaammmmm" + + // Level 1 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "mmmmaddammmm" + /* 1 */ "mmmmb..bmmmm" + /* 2 */ "mmmmb..bmmmm" + /* 3 */ "mmmbb..bbmmm" + /* 4 */ "mmbb....bbmm" + /* 5 */ "mbb......bbm" + /* 6 */ "mb........bm" + /* 7 */ "b..........b" + /* 8 */ "b..........b" + /* 9 */ "mb........bm" + /* 10 */ "mbb......bbm" + /* 11 */ "mmbb....bbmm" + /* 12 */ "mmmbb..bbmmm" + /* 13 */ "mmmmb..bmmmm" + /* 14 */ "mmmmb..bmmmm" + /* 15 */ "mmmmaeeammmm" + + // Level 2 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "mmmmaffammmm" + /* 1 */ "mmmmb..bmmmm" + /* 2 */ "mmmmc..cmmmm" + /* 3 */ "mmmcc..ccmmm" + /* 4 */ "mmcc....ccmm" + /* 5 */ "mcc......ccm" + /* 6 */ "mc........cm" + /* 7 */ "c..........c" + /* 8 */ "c..........c" + /* 9 */ "mc........cm" + /* 10 */ "mcc......ccm" + /* 11 */ "mmcc....ccmm" + /* 12 */ "mmmcc..ccmmm" + /* 13 */ "mmmmc..cmmmm" + /* 14 */ "mmmmb..bmmmm" + /* 15 */ "mmmmagfammmm" + + // Level 3 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "mmmmaaaammmm" + /* 1 */ "mmmmbbbbmmmm" + /* 2 */ "mmmmccccmmmm" + /* 3 */ "mmmcc..ccmmm" + /* 4 */ "mmcc....ccmm" + /* 5 */ "mcc......ccm" + /* 6 */ "mc........cm" + /* 7 */ "c..........c" + /* 8 */ "c..........c" + /* 9 */ "mc........cm" + /* 10 */ "mcc......ccm" + /* 11 */ "mmcc....ccmm" + /* 12 */ "mmmcc..ccmmm" + /* 13 */ "mmmmccccmmmm" + /* 14 */ "mmmmbbbbmmmm" + /* 15 */ "mmmmaaaammmm" + + // Level 4 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "mmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmm" + /* 3 */ "mmmmmccmmmmm" + /* 4 */ "mmmmc..cmmmm" + /* 5 */ "mmmc....cmmm" + /* 6 */ "mmc......cmm" + /* 7 */ "mc........cm" + /* 8 */ "mc........cm" + /* 9 */ "mmc......cmm" + /* 10 */ "mmmcc...cmmm" + /* 11 */ "mmmmc..cmmmm" + /* 12 */ "mmmmmccmmmmm" + /* 13 */ "mmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmm" + + // Level 5 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "mmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmmm" + /* 4 */ "mmmmmccmmmmm" + /* 5 */ "mmmmc..cmmmm" + /* 6 */ "mmmc....cmmm" + /* 7 */ "mmc......cmm" + /* 8 */ "mmc......cmm" + /* 9 */ "mmmc....cmmm" + /* 10 */ "mmmmc.ccmmmm" + /* 11 */ "mmmmmccmmmmm" + /* 12 */ "mmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmm" + + // Level 6 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "mmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmmm" + /* 4 */ "mmmmmmmmmmmm" + /* 5 */ "mmmmmccmmmmm" + /* 6 */ "mmmmccccmmmm" + /* 7 */ "mmmccccccmmm" + /* 8 */ "mmmccccccmmm" + /* 9 */ "mmmmccccmmmm" + /* 10 */ "mmmmmccmmmmm" + /* 11 */ "mmmmmmmmmmmm" + /* 12 */ "mmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmm" + + // Level 7 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "mmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmmm" + /* 4 */ "mmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmm" + /* 12 */ "mmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmm", + + // Connectors: + "1: 6, 1, 0: 2\n" /* Type 1, direction Z- */ + "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */ + "1: 5, 1, 15: 3\n" /* Type 1, direction Z+ */ + "-1: 6, 1, 15: 3\n" /* Type -1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // ViewingCorridorBulge + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ViewingCrossing: + // The data has been exported from the gallery Water, area index 38, ID 611, created by LO1ZB + { + // Size: + 16, 7, 16, // SizeX = 16, SizeY = 7, SizeZ = 16 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 15, 6, 15, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 5\n" /* wood */ + "b: 5: 0\n" /* wood */ + "c: 20: 0\n" /* glass */ + "d: 64: 3\n" /* wooddoorblock */ + "e: 64: 2\n" /* wooddoorblock */ + "f: 64: 0\n" /* wooddoorblock */ + "g: 64: 1\n" /* wooddoorblock */ + "h: 64: 8\n" /* wooddoorblock */ + "i: 64: 9\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmaammmmmmm" + /* 1 */ "mmmmmmmbbmmmmmmm" + /* 2 */ "mmmmmmmbbmmmmmmm" + /* 3 */ "mmmmmmbbbbmmmmmm" + /* 4 */ "mmmmmbbccbbmmmmm" + /* 5 */ "mmmmbbccccbbmmmm" + /* 6 */ "mmmbbccccccbbmmm" + /* 7 */ "abbbccccccccbbba" + /* 8 */ "abbbccccccccbbba" + /* 9 */ "mmmbbccccccbbmmm" + /* 10 */ "mmmmbbccccbbmmmm" + /* 11 */ "mmmmmbbccbbmmmmm" + /* 12 */ "mmmmmmbbbbmmmmmm" + /* 13 */ "mmmmmmmbbmmmmmmm" + /* 14 */ "mmmmmmmbbmmmmmmm" + /* 15 */ "mmmmmmmaammmmmmm" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmaddammmmmm" + /* 1 */ "mmmmmmb..bmmmmmm" + /* 2 */ "mmmmmmb..bmmmmmm" + /* 3 */ "mmmmmbb..bbmmmmm" + /* 4 */ "mmmmbb....bbmmmm" + /* 5 */ "mmmbb......bbmmm" + /* 6 */ "abbb........bbba" + /* 7 */ "e..............f" + /* 8 */ "e..............f" + /* 9 */ "abbb........bbba" + /* 10 */ "mmmbb......bbmmm" + /* 11 */ "mmmmbb....bbmmmm" + /* 12 */ "mmmmmbb..bbmmmmm" + /* 13 */ "mmmmmmb..bmmmmmm" + /* 14 */ "mmmmmmb..bmmmmmm" + /* 15 */ "mmmmmmaggammmmmm" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmahiammmmmm" + /* 1 */ "mmmmmmb..bmmmmmm" + /* 2 */ "mmmmmmc..cmmmmmm" + /* 3 */ "mmmmmcc..ccmmmmm" + /* 4 */ "mmmmcc....ccmmmm" + /* 5 */ "mmmcc......ccmmm" + /* 6 */ "abcc........ccba" + /* 7 */ "i..............h" + /* 8 */ "h..............i" + /* 9 */ "abcc........ccba" + /* 10 */ "mmmcc......ccmmm" + /* 11 */ "mmmmcc....ccmmmm" + /* 12 */ "mmmmmcc..ccmmmmm" + /* 13 */ "mmmmmmc..cmmmmmm" + /* 14 */ "mmmmmmb..bmmmmmm" + /* 15 */ "mmmmmmaihammmmmm" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmaaaammmmmm" + /* 1 */ "mmmmmmbbbbmmmmmm" + /* 2 */ "mmmmmmccccmmmmmm" + /* 3 */ "mmmmmcc..ccmmmmm" + /* 4 */ "mmmmcc....ccmmmm" + /* 5 */ "mmmcc......ccmmm" + /* 6 */ "abcc........ccba" + /* 7 */ "abc..........cba" + /* 8 */ "abc..........cba" + /* 9 */ "abcc........ccba" + /* 10 */ "mmmcc......ccmmm" + /* 11 */ "mmmmcc....ccmmmm" + /* 12 */ "mmmmmcc..ccmmmmm" + /* 13 */ "mmmmmmccccmmmmmm" + /* 14 */ "mmmmmmbbbbmmmmmm" + /* 15 */ "mmmmmmaaaammmmmm" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmmmm" + /* 3 */ "mmmmmmmccmmmmmmm" + /* 4 */ "mmmmmmc..cmmmmmm" + /* 5 */ "mmmmmc....cmmmmm" + /* 6 */ "mmmmc......cmmmm" + /* 7 */ "mmmc........cmmm" + /* 8 */ "mmmc........cmmm" + /* 9 */ "mmmmc......cmmmm" + /* 10 */ "mmmmmcc...cmmmmm" + /* 11 */ "mmmmmmc..cmmmmmm" + /* 12 */ "mmmmmmmccmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmmmm" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmmmmmmm" + /* 4 */ "mmmmmmmccmmmmmmm" + /* 5 */ "mmmmmmc..cmmmmmm" + /* 6 */ "mmmmmc....cmmmmm" + /* 7 */ "mmmmc......cmmmm" + /* 8 */ "mmmmc......cmmmm" + /* 9 */ "mmmmmc....cmmmmm" + /* 10 */ "mmmmmmc.ccmmmmmm" + /* 11 */ "mmmmmmmccmmmmmmm" + /* 12 */ "mmmmmmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmmmm" + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmmmmmmm" + /* 4 */ "mmmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmccmmmmmmm" + /* 6 */ "mmmmmmccccmmmmmm" + /* 7 */ "mmmmmccccccmmmmm" + /* 8 */ "mmmmmccccccmmmmm" + /* 9 */ "mmmmmmccccmmmmmm" + /* 10 */ "mmmmmmmccmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmmm" + /* 12 */ "mmmmmmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmmmm", + + // Connectors: + "1: 0, 1, 7: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 8: 4\n" /* Type -1, direction X- */ + "1: 8, 1, 0: 2\n" /* Type 1, direction Z- */ + "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */ + "1: 15, 1, 8: 5\n" /* Type 1, direction X+ */ + "-1: 15, 1, 7: 5\n" /* Type -1, direction X+ */ + "1: 7, 1, 15: 3\n" /* Type 1, direction Z+ */ + "-1: 8, 1, 15: 3\n" /* Type -1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // ViewingCrossing + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ViewingEnd: + // The data has been exported from the gallery Water, area index 41, ID 614, created by LO1ZB + { + // Size: + 14, 7, 12, // SizeX = 14, SizeY = 7, SizeZ = 12 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 13, 6, 11, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "b: 20: 0\n" /* glass */ + "c: 5: 5\n" /* wood */ + "d: 64: 0\n" /* wooddoorblock */ + "e: 64: 8\n" /* wooddoorblock */ + "f: 64: 9\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmaaaammmmmm" + /* 2 */ "mmmaabbaammmmm" + /* 3 */ "mmaabbbbaammmm" + /* 4 */ "maabbbbbbaammm" + /* 5 */ "mabbbbbbbbaaac" + /* 6 */ "mabbbbbbbbaaac" + /* 7 */ "maabbbbbbaammm" + /* 8 */ "mmaabbbbaammmm" + /* 9 */ "mmmaabbaammmmm" + /* 10 */ "mmmmaaaammmmmm" + /* 11 */ "mmmmmmmmmmmmmm" + + // Level 1 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmaammmmmmm" + /* 1 */ "mmmaa..aammmmm" + /* 2 */ "mmaa....aammmm" + /* 3 */ "maa......aammm" + /* 4 */ "ma........aaac" + /* 5 */ "a............d" + /* 6 */ "a............d" + /* 7 */ "ma........aaac" + /* 8 */ "maa......aammm" + /* 9 */ "mmaa....aammmm" + /* 10 */ "mmmaa..aammmmm" + /* 11 */ "mmmmmaammmmmmm" + + // Level 2 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmbbmmmmmmm" + /* 1 */ "mmmbb..bbmmmmm" + /* 2 */ "mmbb....bbmmmm" + /* 3 */ "mbb......bbmmm" + /* 4 */ "mb........bbac" + /* 5 */ "b............e" + /* 6 */ "b............f" + /* 7 */ "mb........bbac" + /* 8 */ "mbb......bbmmm" + /* 9 */ "mmbb....bbmmmm" + /* 10 */ "mmmbb..bbmmmmm" + /* 11 */ "mmmmmbbmmmmmmm" + + // Level 3 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmbbmmmmmmm" + /* 1 */ "mmmbb..bbmmmmm" + /* 2 */ "mmbb....bbmmmm" + /* 3 */ "mbb......bbmmm" + /* 4 */ "mb........bbac" + /* 5 */ "b..........bac" + /* 6 */ "b..........bac" + /* 7 */ "mb........bbac" + /* 8 */ "mbb......bbmmm" + /* 9 */ "mmbb....bbmmmm" + /* 10 */ "mmmbb..bbmmmmm" + /* 11 */ "mmmmmbbmmmmmmm" + + // Level 4 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmmbbmmmmmmm" + /* 2 */ "mmmmb..bmmmmmm" + /* 3 */ "mmmb....bmmmmm" + /* 4 */ "mmb......bmmmm" + /* 5 */ "mb........bmmm" + /* 6 */ "mb........bmmm" + /* 7 */ "mmb......bmmmm" + /* 8 */ "mmmbb...bmmmmm" + /* 9 */ "mmmmb..bmmmmmm" + /* 10 */ "mmmmmbbmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmm" + + // Level 5 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmm" + /* 2 */ "mmmmmbbmmmmmmm" + /* 3 */ "mmmmb..bmmmmmm" + /* 4 */ "mmmb....bmmmmm" + /* 5 */ "mmb......bmmmm" + /* 6 */ "mmb......bmmmm" + /* 7 */ "mmmb....bmmmmm" + /* 8 */ "mmmmb.bbmmmmmm" + /* 9 */ "mmmmmbbmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmm" + + // Level 6 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmm" + /* 3 */ "mmmmmbbmmmmmmm" + /* 4 */ "mmmmbbbbmmmmmm" + /* 5 */ "mmmbbbbbbmmmmm" + /* 6 */ "mmmbbbbbbmmmmm" + /* 7 */ "mmmmbbbbmmmmmm" + /* 8 */ "mmmmmbbmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmm", + + // Connectors: + "1: 13, 1, 6: 5\n" /* Type 1, direction X+ */ + "-1: 13, 1, 5: 5\n" /* Type -1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // ViewingEnd + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ViewingTee: + // The data has been exported from the gallery Water, area index 39, ID 612, created by LO1ZB + { + // Size: + 14, 7, 17, // SizeX = 14, SizeY = 7, SizeZ = 17 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 13, 6, 16, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 5\n" /* wood */ + "b: 5: 0\n" /* wood */ + "c: 20: 0\n" /* glass */ + "d: 1: 0\n" /* stone */ + "e: 64: 3\n" /* wooddoorblock */ + "f: 64: 0\n" /* wooddoorblock */ + "g: 64: 1\n" /* wooddoorblock */ + "h: 64: 8\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmaammmmmmm" + /* 1 */ "mmmmmbbmmmmmmm" + /* 2 */ "mmmmmbbmmmmmmm" + /* 3 */ "mmmmbbbbmmmmmm" + /* 4 */ "mmmbbccbbmmmmm" + /* 5 */ "mmbbccccbbmmmm" + /* 6 */ "mbbccccccbbmmm" + /* 7 */ "mbccccccccbbba" + /* 8 */ "mbccccccccbbba" + /* 9 */ "mbbccccccbbmmm" + /* 10 */ "mmbbccccbbmmmm" + /* 11 */ "mmmbbccbbmmmmm" + /* 12 */ "mmmmbbbbmmmmmm" + /* 13 */ "mmmmmbbmmmmmmm" + /* 14 */ "mmmmmbbmmmmmmm" + /* 15 */ "mmmmmaammmmmmm" + /* 16 */ "dddddddddddddd" + + // Level 1 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmaeeammmmmm" + /* 1 */ "mmmmb..bmmmmmm" + /* 2 */ "mmmmb..bmmmmmm" + /* 3 */ "mmmbb..bbmmmmm" + /* 4 */ "mmbb....bbmmmm" + /* 5 */ "mbb......bbmmm" + /* 6 */ "mb........bbba" + /* 7 */ "b............f" + /* 8 */ "b............f" + /* 9 */ "mb........bbba" + /* 10 */ "mbb......bbmmm" + /* 11 */ "mmbb....bbmmmm" + /* 12 */ "mmmbb..bbmmmmm" + /* 13 */ "mmmmb..bmmmmmm" + /* 14 */ "mmmmb..bmmmmmm" + /* 15 */ "mmmmaggammmmmm" + /* 16 */ "dddddddddddddd" + + // Level 2 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmahhammmmmm" + /* 1 */ "mmmmb..bmmmmmm" + /* 2 */ "mmmmc..cmmmmmm" + /* 3 */ "mmmcc..ccmmmmm" + /* 4 */ "mmcc....ccmmmm" + /* 5 */ "mcc......ccmmm" + /* 6 */ "mc........ccba" + /* 7 */ "c............h" + /* 8 */ "c............h" + /* 9 */ "mc........ccba" + /* 10 */ "mcc......ccmmm" + /* 11 */ "mmcc....ccmmmm" + /* 12 */ "mmmcc..ccmmmmm" + /* 13 */ "mmmmc..cmmmmmm" + /* 14 */ "mmmmb..bmmmmmm" + /* 15 */ "mmmmahhammmmmm" + /* 16 */ "dddddddddddddd" + + // Level 3 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmaaaammmmmm" + /* 1 */ "mmmmbbbbmmmmmm" + /* 2 */ "mmmmccccmmmmmm" + /* 3 */ "mmmcc..ccmmmmm" + /* 4 */ "mmcc....ccmmmm" + /* 5 */ "mcc......ccmmm" + /* 6 */ "mc........ccba" + /* 7 */ "c..........cba" + /* 8 */ "c..........cba" + /* 9 */ "mc........ccba" + /* 10 */ "mcc......ccmmm" + /* 11 */ "mmcc....ccmmmm" + /* 12 */ "mmmcc..ccmmmmm" + /* 13 */ "mmmmccccmmmmmm" + /* 14 */ "mmmmbbbbmmmmmm" + /* 15 */ "mmmmaaaammmmmm" + /* 16 */ "dddddddddddddd" + + // Level 4 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmm" + /* 3 */ "mmmmmccmmmmmmm" + /* 4 */ "mmmmc..cmmmmmm" + /* 5 */ "mmmc....cmmmmm" + /* 6 */ "mmc......cmmmm" + /* 7 */ "mc........cmmm" + /* 8 */ "mc........cmmm" + /* 9 */ "mmc......cmmmm" + /* 10 */ "mmmcc...cmmmmm" + /* 11 */ "mmmmc..cmmmmmm" + /* 12 */ "mmmmmccmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmm" + /* 16 */ "dddddddddddddd" + + // Level 5 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmmmmm" + /* 4 */ "mmmmmccmmmmmmm" + /* 5 */ "mmmmc..cmmmmmm" + /* 6 */ "mmmc....cmmmmm" + /* 7 */ "mmc......cmmmm" + /* 8 */ "mmc......cmmmm" + /* 9 */ "mmmc....cmmmmm" + /* 10 */ "mmmmc.ccmmmmmm" + /* 11 */ "mmmmmccmmmmmmm" + /* 12 */ "mmmmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmm" + /* 16 */ "dddddddddddddd" + + // Level 6 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmmmmm" + /* 4 */ "mmmmmmmmmmmmmm" + /* 5 */ "mmmmmccmmmmmmm" + /* 6 */ "mmmmccccmmmmmm" + /* 7 */ "mmmccccccmmmmm" + /* 8 */ "mmmccccccmmmmm" + /* 9 */ "mmmmccccmmmmmm" + /* 10 */ "mmmmmccmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmm" + /* 12 */ "mmmmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmm" + /* 16 */ "dddddddddddddd", + + // Connectors: + "", + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // ViewingTee +}; // g_UnderwaterBasePrefabs + + + + + + +const cPrefab::sDef g_UnderwaterBaseStartingPrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CentralRoom: + // The data has been exported from the gallery Water, area index 24, ID 564, created by xoft + { + // Size: + 16, 7, 16, // SizeX = 16, SizeY = 7, SizeZ = 16 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 15, 6, 15, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 5\n" /* wood */ + "b: 5: 0\n" /* wood */ + "c: 20: 0\n" /* glass */ + "d: 64: 3\n" /* wooddoorblock */ + "e: 64: 2\n" /* wooddoorblock */ + "f: 64: 0\n" /* wooddoorblock */ + "g: 64: 1\n" /* wooddoorblock */ + "h: 64: 8\n" /* wooddoorblock */ + "i: 64: 9\n" /* wooddoorblock */ + "j: 76: 3\n" /* redstonetorchon */ + "k: 76: 1\n" /* redstonetorchon */ + "l: 76: 2\n" /* redstonetorchon */ + "m: 19: 0\n" /* sponge */ + "n: 76: 4\n" /* redstonetorchon */ + "o:125: 8\n" /* woodendoubleslab */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmaammmmmmm" + /* 1 */ "mmmmmmmbbmmmmmmm" + /* 2 */ "mmmmmmmbbmmmmmmm" + /* 3 */ "mmmmmmbbbbmmmmmm" + /* 4 */ "mmmmmbbbbbbmmmmm" + /* 5 */ "mmmmbbbccbbbmmmm" + /* 6 */ "mmmbbbccccbbbmmm" + /* 7 */ "abbbbccccccbbbba" + /* 8 */ "abbbbccccccbbbba" + /* 9 */ "mmmbbbccccbbbmmm" + /* 10 */ "mmmmbbbccbbbmmmm" + /* 11 */ "mmmmmbbbbbbmmmmm" + /* 12 */ "mmmmmmbbbbmmmmmm" + /* 13 */ "mmmmmmmbbmmmmmmm" + /* 14 */ "mmmmmmmbbmmmmmmm" + /* 15 */ "mmmmmmmaammmmmmm" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmaddammmmmm" + /* 1 */ "mmmmmmb..bmmmmmm" + /* 2 */ "mmmmmmb..bmmmmmm" + /* 3 */ "mmmmmbb..bbmmmmm" + /* 4 */ "mmmmbb....bbmmmm" + /* 5 */ "mmmbb......bbmmm" + /* 6 */ "abbb........bbba" + /* 7 */ "e..............f" + /* 8 */ "e..............f" + /* 9 */ "abbb........bbba" + /* 10 */ "mmmbb......bbmmm" + /* 11 */ "mmmmbb....bbmmmm" + /* 12 */ "mmmmmbb..bbmmmmm" + /* 13 */ "mmmmmmb..bmmmmmm" + /* 14 */ "mmmmmmb..bmmmmmm" + /* 15 */ "mmmmmmaggammmmmm" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmahiammmmmm" + /* 1 */ "mmmmmmb..bmmmmmm" + /* 2 */ "mmmmmmb..bmmmmmm" + /* 3 */ "mmmmmcc..ccmmmmm" + /* 4 */ "mmmmcc....ccmmmm" + /* 5 */ "mmmcc......ccmmm" + /* 6 */ "abbc........cbba" + /* 7 */ "h..............h" + /* 8 */ "h..............i" + /* 9 */ "abbc........cbba" + /* 10 */ "mmmcc......ccmmm" + /* 11 */ "mmmmcc....ccmmmm" + /* 12 */ "mmmmmcc..ccmmmmm" + /* 13 */ "mmmmmmb..bmmmmmm" + /* 14 */ "mmmmmmb..bmmmmmm" + /* 15 */ "mmmmmmaihammmmmm" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmaaaammmmmm" + /* 1 */ "mmmmmmbbbbmmmmmm" + /* 2 */ "mmmmmmbbbbmmmmmm" + /* 3 */ "mmmmmbb..bbmmmmm" + /* 4 */ "mmmmbb....bbmmmm" + /* 5 */ "mmmbb......bbmmm" + /* 6 */ "abbb........bbba" + /* 7 */ "abb..........bba" + /* 8 */ "abb..........bba" + /* 9 */ "abbb........bbba" + /* 10 */ "mmmbb......bbmmm" + /* 11 */ "mmmmbb....bbmmmm" + /* 12 */ "mmmmmbb..bbmmmmm" + /* 13 */ "mmmmmmbbbbmmmmmm" + /* 14 */ "mmmmmmbbbbmmmmmm" + /* 15 */ "mmmmmmaaaammmmmm" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmmmm" + /* 3 */ "mmmmmmmbbmmmmmmm" + /* 4 */ "mmmmmmbjjbmmmmmm" + /* 5 */ "mmmmmb....bmmmmm" + /* 6 */ "mmmmb......bmmmm" + /* 7 */ "mmmbk......lbmmm" + /* 8 */ "mmmbk......lbmmm" + /* 9 */ "mmmmb......bmmmm" + /* 10 */ "mmmmmb....bmmmmm" + /* 11 */ "mmmmmmbnnbmmmmmm" + /* 12 */ "mmmmmmmbbmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmmmm" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmmmmmmm" + /* 4 */ "mmmmmmmbbmmmmmmm" + /* 5 */ "mmmmmmb..bmmmmmm" + /* 6 */ "mmmmmb....bmmmmm" + /* 7 */ "mmmmb......bmmmm" + /* 8 */ "mmmmb......bmmmm" + /* 9 */ "mmmmmb....bmmmmm" + /* 10 */ "mmmmmmboobmmmmmm" + /* 11 */ "mmmmmmmbbmmmmmmm" + /* 12 */ "mmmmmmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmmmm" + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmmmmmmm" + /* 4 */ "mmmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmbbmmmmmmm" + /* 6 */ "mmmmmmbbbbmmmmmm" + /* 7 */ "mmmmmbbccbbmmmmm" + /* 8 */ "mmmmmbbccbbmmmmm" + /* 9 */ "mmmmmmbbbbmmmmmm" + /* 10 */ "mmmmmmmbbmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmmm" + /* 12 */ "mmmmmmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmmmm", + + // Connectors: + "1: 0, 1, 7: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 8: 4\n" /* Type -1, direction X- */ + "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */ + "1: 8, 1, 0: 2\n" /* Type 1, direction Z- */ + "1: 15, 1, 8: 5\n" /* Type 1, direction X+ */ + "-1: 15, 1, 7: 5\n" /* Type -1, direction X+ */ + "1: 7, 1, 15: 3\n" /* Type 1, direction Z+ */ + "-1: 8, 1, 15: 3\n" /* Type -1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CentralRoom +}; + + + + + +// The prefab counts: + +const size_t g_UnderwaterBasePrefabsCount = ARRAYCOUNT(g_UnderwaterBasePrefabs); + +const size_t g_UnderwaterBaseStartingPrefabsCount = ARRAYCOUNT(g_UnderwaterBaseStartingPrefabs); + diff --git a/src/Generating/Prefabs/UnderwaterBasePrefabs.h b/src/Generating/Prefabs/UnderwaterBasePrefabs.h new file mode 100644 index 000000000..d7b248bb8 --- /dev/null +++ b/src/Generating/Prefabs/UnderwaterBasePrefabs.h @@ -0,0 +1,15 @@ + +// UnderwaterBasePrefabs.h + +// Declares the prefabs in the group UnderwaterBase + +#include "../Prefab.h" + + + + + +extern const cPrefab::sDef g_UnderwaterBasePrefabs[]; +extern const cPrefab::sDef g_UnderwaterBaseStartingPrefabs[]; +extern const size_t g_UnderwaterBasePrefabsCount; +extern const size_t g_UnderwaterBaseStartingPrefabsCount; diff --git a/src/Generating/UnderwaterBaseGen.cpp b/src/Generating/UnderwaterBaseGen.cpp new file mode 100644 index 000000000..ff6f17dde --- /dev/null +++ b/src/Generating/UnderwaterBaseGen.cpp @@ -0,0 +1,142 @@ + +// UnderwaterBaseGen.cpp + +// Implements the cUnderwaterBaseGen class representing the underwater base generator + +#include "Globals.h" +#include "UnderwaterBaseGen.h" +#include "Prefabs/UnderwaterBasePrefabs.h" +#include "PieceGenerator.h" + + + + + +static cPrefabPiecePool g_UnderwaterBase(g_UnderwaterBasePrefabs, g_UnderwaterBasePrefabsCount, g_UnderwaterBaseStartingPrefabs, g_UnderwaterBaseStartingPrefabsCount); + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cUnderwaterBaseGen::cUnderwaterBase: + +class cUnderwaterBaseGen::cUnderwaterBase : + public cGridStructGen::cStructure +{ + typedef cGridStructGen::cStructure super; + +public: + cUnderwaterBase( + int a_Seed, + int a_OriginX, int a_OriginZ, + int a_MaxDepth, + int a_MaxSize + ) : + super(a_OriginX, a_OriginZ), + m_Seed(a_Seed), + m_Noise(a_Seed), + m_MaxSize(a_MaxSize), + m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, 255, a_OriginZ + a_MaxSize) + { + // Generate the pieces for this base: + cBFSPieceGenerator pg(g_UnderwaterBase, a_Seed); + pg.PlacePieces(a_OriginX, 50, a_OriginZ, a_MaxDepth, m_Pieces); + if (m_Pieces.empty()) + { + return; + } + } + + ~cUnderwaterBase() + { + cPieceGenerator::FreePieces(m_Pieces); + } + +protected: + /** Seed for the random functions */ + int m_Seed; + + /** The noise used as a pseudo-random generator */ + cNoise m_Noise; + + /** Maximum size, in X/Z blocks, of the village (radius from the origin) */ + int m_MaxSize; + + /** Borders of the vilalge - no item may reach out of this cuboid. */ + cCuboid m_Borders; + + /** The village pieces, placed by the generator. */ + cPlacedPieces m_Pieces; + + + // cGridStructGen::cStructure overrides: + virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override + { + for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr) + { + cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece()); + Prefab.Draw(a_Chunk, *itr); + } // for itr - m_PlacedPieces[] + } +} ; + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cUnderwaterBaseGen: + + + + + +cUnderwaterBaseGen::cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 100), + m_Noise(a_Seed + 1000), + m_MaxDepth(a_MaxDepth), + m_MaxSize(a_MaxSize), + m_BiomeGen(a_BiomeGen) +{ +} + + + + + +cGridStructGen::cStructurePtr cUnderwaterBaseGen::CreateStructure(int a_OriginX, int a_OriginZ) +{ + // Generate the biomes for the chunk surrounding the origin: + int ChunkX, ChunkZ; + cChunkDef::BlockToChunk(a_OriginX, a_OriginZ, ChunkX, ChunkZ); + cChunkDef::BiomeMap Biomes; + m_BiomeGen.GenBiomes(ChunkX, ChunkZ, Biomes); + + // Check if all the biomes are ocean: + // If just one is not, no base is created, because it's likely that an unfriendly biome is too close + for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++) + { + switch (Biomes[i]) + { + case biOcean: + case biDeepOcean: + { + // These biomes allow underwater bases + break; + } + default: + { + // base-unfriendly biome, bail out with zero structure: + return cStructurePtr(); + } + } // switch (Biomes[i]) + } // for i - Biomes[] + + // Create a base based on the chosen prefabs: + return cStructurePtr(new cUnderwaterBase(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize)); +} + + + + diff --git a/src/Generating/UnderwaterBaseGen.h b/src/Generating/UnderwaterBaseGen.h new file mode 100644 index 000000000..0aefbb4c7 --- /dev/null +++ b/src/Generating/UnderwaterBaseGen.h @@ -0,0 +1,50 @@ + +// UnderwaterBaseGen.h + +// Declares the cUnderwaterBaseGen class representing the underwater base generator + + + + + +#pragma once + +#include "GridStructGen.h" +#include "PrefabPiecePool.h" + + + + + +class cUnderwaterBaseGen : + public cGridStructGen +{ + typedef cGridStructGen super; + +public: + cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen); + +protected: + class cUnderwaterBase; // fwd: UnderwaterBaseGen.cpp + + + /** The noise used for generating random numbers */ + cNoise m_Noise; + + /** Maximum depth of the generator tree*/ + int m_MaxDepth; + + /** Maximum size, in X/Z blocks, of the base (radius from the origin) */ + int m_MaxSize; + + /** The underlying biome generator that defines whether the base is created or not */ + cBiomeGen & m_BiomeGen; + + + // cGridStructGen overrides: + virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; +} ; + + + + -- cgit v1.2.3 From 8bff3e5af220070ecc789ef551c0b8428b8953ef Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 31 May 2014 22:28:51 +0100 Subject: Implemented end and nether portals --- src/Chunk.cpp | 74 +++++++++++---------- src/Chunk.h | 1 + src/ClientHandle.cpp | 7 +- src/ClientHandle.h | 2 +- src/Entities/Entity.cpp | 117 +++++++++++++++++++++++++++++++++ src/Entities/Entity.h | 6 ++ src/Entities/Player.cpp | 36 +++++++--- src/Entities/Player.h | 2 +- src/Generating/BioGen.cpp | 2 +- src/Generating/ComposableGenerator.cpp | 16 +---- src/Generating/EndGen.cpp | 2 +- src/Generating/EndGen.h | 3 +- src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.cpp | 4 +- src/Protocol/Protocol125.h | 2 +- src/Protocol/Protocol16x.cpp | 4 +- src/Protocol/Protocol16x.h | 2 +- src/Protocol/Protocol17x.cpp | 4 +- src/Protocol/Protocol17x.h | 2 +- src/Protocol/ProtocolRecognizer.cpp | 4 +- src/Protocol/ProtocolRecognizer.h | 2 +- src/Root.cpp | 21 +++--- src/World.cpp | 31 +++++++++ 23 files changed, 254 insertions(+), 92 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 4506cfcc5..7131a26af 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -638,30 +638,22 @@ void cChunk::Tick(float a_Dt) for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) { // Mobs are tickes inside MobTick (as we don't have to tick them if they are far away from players) - if (!((*itr)->IsMob())) + // Don't tick things queued to be removed + if (!((*itr)->IsMob()) && (std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID()) == m_EntitiesToRemove.end())) { (*itr)->Tick(a_Dt, *this); } } // for itr - m_Entitites[] - // Remove all entities that were scheduled for removal: for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) { - if ((*itr)->IsDestroyed()) - { - LOGD("Destroying entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass()); - cEntity * ToDelete = *itr; - itr = m_Entities.erase(itr); - delete ToDelete; - continue; - } - ++itr; - } // for itr - m_Entitites[] - - // If any entity moved out of the chunk, move it to the neighbor: - for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) - { - if ( + auto itr2 = std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID()); + if (itr2 != m_EntitiesToRemove.end()) + { + itr = m_Entities.erase(itr); + m_EntitiesToRemove.erase(itr2); + } + else if ( // If any entity moved out of the chunk, move it to the neighbor: ((*itr)->GetChunkX() != m_PosX) || ((*itr)->GetChunkZ() != m_PosZ) ) @@ -671,9 +663,19 @@ void cChunk::Tick(float a_Dt) } else { - ++itr; + if ((*itr)->IsDestroyed()) // Remove all entities that were scheduled for removal: + { + LOGD("Destroying entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass()); + cEntity * ToDelete = *itr; + itr = m_Entities.erase(itr); + delete ToDelete; + } + else + { + ++itr; + } } - } + } // for itr - m_Entitites[] ApplyWeatherToTop(); } @@ -1847,7 +1849,7 @@ void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity ) -bool cChunk::AddClient(cClientHandle* a_Client) +bool cChunk::AddClient(cClientHandle * a_Client) { for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { @@ -1878,7 +1880,7 @@ bool cChunk::AddClient(cClientHandle* a_Client) -void cChunk::RemoveClient( cClientHandle* a_Client ) +void cChunk::RemoveClient(cClientHandle * a_Client) { for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { @@ -1886,12 +1888,12 @@ void cChunk::RemoveClient( cClientHandle* a_Client ) { continue; } - + m_LoadedByClient.erase(itr); if (!a_Client->IsDestroyed()) { - for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr ) + for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) { /* // DEBUG: @@ -1911,7 +1913,7 @@ void cChunk::RemoveClient( cClientHandle* a_Client ) -bool cChunk::HasClient( cClientHandle* a_Client ) +bool cChunk::HasClient(cClientHandle* a_Client) { for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { @@ -1942,9 +1944,9 @@ void cChunk::AddEntity(cEntity * a_Entity) { MarkDirty(); } - + ASSERT(std::find(m_Entities.begin(), m_Entities.end(), a_Entity) == m_Entities.end()); // Not there already - + m_Entities.push_back(a_Entity); } @@ -1954,17 +1956,12 @@ void cChunk::AddEntity(cEntity * a_Entity) void cChunk::RemoveEntity(cEntity * a_Entity) { - size_t SizeBefore = m_Entities.size(); - m_Entities.remove(a_Entity); - size_t SizeAfter = m_Entities.size(); - - if (SizeBefore != SizeAfter) + m_EntitiesToRemove.push_back(a_Entity->GetUniqueID()); + + // Mark as dirty if it was a server-generated entity: + if (!a_Entity->IsPlayer()) { - // Mark as dirty if it was a server-generated entity: - if (!a_Entity->IsPlayer()) - { - MarkDirty(); - } + MarkDirty(); } } @@ -1974,6 +1971,11 @@ void cChunk::RemoveEntity(cEntity * a_Entity) bool cChunk::HasEntity(int a_EntityID) { + if (std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), a_EntityID) != m_EntitiesToRemove.end()) + { + return false; // If EntitiesToRemove contains our ID, this chunk doesn't have it, as it should be removed soon + } + for (cEntityList::const_iterator itr = m_Entities.begin(), end = m_Entities.end(); itr != end; ++itr) { if ((*itr)->GetUniqueID() == a_EntityID) diff --git a/src/Chunk.h b/src/Chunk.h index 84ec35496..f61520e8f 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -411,6 +411,7 @@ private: // A critical section is not needed, because all chunk access is protected by its parent ChunkMap's csLayers cClientHandleList m_LoadedByClient; cEntityList m_Entities; + std::vector m_EntitiesToRemove; cBlockEntityList m_BlockEntities; /** Number of times the chunk has been requested to stay (by various cChunkStay objects); if zero, the chunk can be unloaded */ diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 9b03bead9..8a5c81e70 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -125,7 +125,6 @@ cClientHandle::~cClientHandle() } if (World != NULL) { - World->RemovePlayer(m_Player); m_Player->Destroy(); } delete m_Player; @@ -1754,7 +1753,7 @@ void cClientHandle::MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket) if (a_SendRespawnPacket) { - SendRespawn(); + SendRespawn(a_World); } cWorld * World = m_Player->GetWorld(); @@ -2373,9 +2372,9 @@ void cClientHandle::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effec -void cClientHandle::SendRespawn(void) +void cClientHandle::SendRespawn(const cWorld & a_World) { - m_Protocol->SendRespawn(); + m_Protocol->SendRespawn(a_World); } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 659c67658..e86287735 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -149,7 +149,7 @@ public: void SendPlayerSpawn (const cPlayer & a_Player); void SendPluginMessage (const AString & a_Channel, const AString & a_Message); // Exported in ManualBindings.cpp void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID); - void SendRespawn (void); + void SendRespawn (const cWorld & a_World); void SendExperience (void); void SendExperienceOrb (const cExpOrb & a_ExpOrb); void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode); diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 1226a2319..b5c272cf2 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -629,6 +629,7 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk) // Handle drowning HandleAir(); } + DetectPortal(); // None of the above functions change position, we remain in the chunk of NextChunk HandlePhysics(a_Dt, *NextChunk); @@ -1039,6 +1040,122 @@ void cEntity::DetectCacti(void) +void cEntity::DetectPortal() +{ + int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; + if ((Y > 0) && (Y < cChunkDef::Height)) + { + switch (GetWorld()->GetBlock(X, Y, Z)) + { + case E_BLOCK_NETHER_PORTAL: + { + switch (GetWorld()->GetDimension()) + { + case dimNether: + { + AString OverworldName = GetWorld()->GetName().substr(0, GetWorld()->GetName().size() - 7); + cFile::CreateFolder(FILE_IO_PREFIX + OverworldName); + cIniFile File; + File.ReadFile(OverworldName + "/world.ini"); + File.SetValue("General", "Dimension", "Overworld"); + File.WriteFile(OverworldName + "/world.ini"); + + MoveToWorld(OverworldName, cRoot::Get()->CreateAndInitializeWorld(OverworldName)); + break; + } + case dimOverworld: + { + AString NetherWorldName = GetWorld()->GetName() + "_nether"; + cFile::CreateFolder(FILE_IO_PREFIX + NetherWorldName); + cIniFile File; + File.ReadFile(NetherWorldName + "/world.ini"); + File.SetValue("General", "Dimension", "Nether"); + File.WriteFile(NetherWorldName + "/world.ini"); + + MoveToWorld(NetherWorldName, cRoot::Get()->CreateAndInitializeWorld(NetherWorldName)); + break; + } + default: break; + } + break; + } + case E_BLOCK_END_PORTAL: + { + switch (GetWorld()->GetDimension()) + { + case dimEnd: + { + AString OverworldName = GetWorld()->GetName().substr(0, GetWorld()->GetName().size() - 4); + cFile::CreateFolder(FILE_IO_PREFIX + OverworldName); + cIniFile File; + File.ReadFile(OverworldName + "/world.ini"); + File.SetValue("General", "Dimension", "Overworld"); + File.WriteFile(OverworldName + "/world.ini"); + + MoveToWorld(OverworldName, cRoot::Get()->CreateAndInitializeWorld(OverworldName)); + break; + } + case dimOverworld: + { + AString EndWorldName = GetWorld()->GetName() + "_end"; + cFile::CreateFolder(FILE_IO_PREFIX + EndWorldName); + cIniFile File; + File.ReadFile(EndWorldName + "/world.ini"); + File.SetValue("General", "Dimension", "End"); + File.WriteFile(EndWorldName + "/world.ini"); + + MoveToWorld(EndWorldName, cRoot::Get()->CreateAndInitializeWorld(EndWorldName)); + break; + } + default: break; + } + } + default: break; + } + } +} + + + + + +bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World) +{ + cWorld * World; + if (a_World == NULL) + { + World = cRoot::Get()->GetWorld(a_WorldName); + if (World == NULL) + { + LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName); + return false; + } + } + else + { + World = a_World; + } + + if (GetWorld() == World) + { + return false; + } + + // Remove all links to the old world + GetWorld()->RemoveEntity(this); + GetWorld()->BroadcastDestroyEntity(*this); + + // Add to all the necessary parts of the new world + SetWorld(World); + World->AddEntity(this); + + return true; +} + + + + + void cEntity::SetSwimState(cChunk & a_Chunk) { int RelY = (int)floor(GetPosY() + 0.1); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 0c393c0f5..da8256606 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -323,6 +323,9 @@ public: /** Detects the time for application of cacti damage */ virtual void DetectCacti(void); + + /** Detects whether we are in a portal block and begins teleportation procedures if so */ + virtual void DetectPortal(void); /// Handles when the entity is in the void virtual void TickInVoid(cChunk & a_Chunk); @@ -365,6 +368,9 @@ public: /// Teleports to the coordinates specified virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ); + + /** Moves entity to specified world */ + virtual bool MoveToWorld(const AString & a_WorldName, cWorld * a_World = NULL); // tolua_end diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 0dfdcfd8b..140b98d5d 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -134,7 +134,7 @@ cPlayer::~cPlayer(void) SaveToDisk(); - m_World->RemovePlayer( this ); + m_World->RemovePlayer(this); m_ClientHandle = NULL; @@ -150,8 +150,6 @@ cPlayer::~cPlayer(void) void cPlayer::Destroyed() { CloseWindow(false); - - m_ClientHandle = NULL; } @@ -952,7 +950,7 @@ void cPlayer::Respawn(void) m_LifetimeTotalXp = 0; // ToDo: send score to client? How? - m_ClientHandle->SendRespawn(); + m_ClientHandle->SendRespawn(*GetWorld()); // Extinguish the fire: StopBurning(); @@ -1574,12 +1572,25 @@ void cPlayer::TossItems(const cItems & a_Items) -bool cPlayer::MoveToWorld(const char * a_WorldName) +bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World) { - cWorld * World = cRoot::Get()->GetWorld(a_WorldName); - if (World == NULL) + cWorld * World; + if (a_World == NULL) + { + World = cRoot::Get()->GetWorld(a_WorldName); + if (World == NULL) + { + LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName); + return false; + } + } + else + { + World = a_World; + } + + if (GetWorld() == World) { - LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName); return false; } @@ -1588,11 +1599,11 @@ bool cPlayer::MoveToWorld(const char * a_WorldName) // Remove all links to the old world m_World->RemovePlayer(this); m_ClientHandle->RemoveFromAllChunks(); - m_World->RemoveEntity(this); // If the dimension is different, we can send the respawn packet // http://wiki.vg/Protocol#0x09 says "don't send if dimension is the same" as of 2013_07_02 - m_ClientHandle->MoveToWorld(*World, (OldDimension != World->GetDimension())); + bool SendRespawn = OldDimension != World->GetDimension(); + m_ClientHandle->MoveToWorld(*World, SendRespawn); // Add player to all the necessary parts of the new world SetWorld(World); @@ -1600,6 +1611,11 @@ bool cPlayer::MoveToWorld(const char * a_WorldName) World->AddEntity(this); World->AddPlayer(this); + if (SendRespawn) + { + GetClientHandle()->SendPlayerMoveLook(); + } + return true; } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index b7cb27d6c..582f79b86 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -328,7 +328,7 @@ public: void SetVisible( bool a_bVisible ); // tolua_export bool IsVisible(void) const { return m_bVisible; } // tolua_export - bool MoveToWorld(const char * a_WorldName); // tolua_export + virtual bool MoveToWorld(const AString & a_WorldName, cWorld * a_World = NULL) override; // tolua_export bool SaveToDisk(void); bool LoadFromDisk(void); diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index 32a687201..e08e242e2 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -95,7 +95,7 @@ void cBioGenConstant::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap void cBioGenConstant::InitializeBiomeGen(cIniFile & a_IniFile) { - AString Biome = a_IniFile.GetValueSet("Generator", "ConstantBiome", "Plains"); + AString Biome = a_IniFile.GetValueSet("Generator", "ConstantBiome", ""); m_Biome = StringToBiome(Biome); if (m_Biome == biInvalidBiome) { diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 2e886336f..03ed0291f 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -39,7 +39,6 @@ cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile & { LOGWARN("[Generator] CompositionGen value not set in world.ini, using \"Biomal\"."); CompoGenName = "Biomal"; - a_IniFile.SetValue("Generator", "CompositionGen", CompoGenName); } cTerrainCompositionGen * res = NULL; @@ -93,7 +92,6 @@ cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile & else { LOGWARN("Unknown CompositionGen \"%s\", using \"Biomal\" instead.", CompoGenName.c_str()); - a_IniFile.DeleteValue("Generator", "CompositionGen"); a_IniFile.SetValue("Generator", "CompositionGen", "Biomal"); return CreateCompositionGen(a_IniFile, a_BiomeGen, a_HeightGen, a_Seed); } @@ -291,19 +289,7 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) int Seed = m_ChunkGenerator.GetSeed(); eDimension Dimension = StringToDimension(a_IniFile.GetValue("General", "Dimension", "Overworld")); - // Older configuration used "Structures" in addition to "Finishers"; we don't distinguish between the two anymore (#398) - // Therefore, we load Structures from the ini file for compatibility, but move its contents over to Finishers: - AString Structures = a_IniFile.GetValue("Generator", "Structures", ""); - AString Finishers = a_IniFile.GetValueSet("Generator", "Finishers", "Ravines, WormNestCaves, WaterLakes, LavaLakes, OreNests, Trees, SprinkleFoliage, Ice, Snow, Lilypads, BottomLava, DeadBushes, PreSimulator"); - if (!Structures.empty()) - { - LOGINFO("[Generator].Structures is deprecated, moving the contents to [Generator].Finishers."); - // Structures used to generate before Finishers, so place them first: - Structures.append(", "); - Finishers = Structures + Finishers; - a_IniFile.SetValue("Generator", "Finishers", Finishers); - } - a_IniFile.DeleteValue("Generator", "Structures"); + AString Finishers = a_IniFile.GetValueSet("Generator", "Finishers", ""); // Create all requested finishers: AStringVector Str = StringSplitAndTrim(Finishers, ","); diff --git a/src/Generating/EndGen.cpp b/src/Generating/EndGen.cpp index f466039b9..5be73bfbe 100644 --- a/src/Generating/EndGen.cpp +++ b/src/Generating/EndGen.cpp @@ -50,7 +50,7 @@ cEndGen::cEndGen(int a_Seed) : -void cEndGen::Initialize(cIniFile & a_IniFile) +void cEndGen::InitializeCompoGen(cIniFile & a_IniFile) { m_IslandSizeX = a_IniFile.GetValueSetI("Generator", "EndGenIslandSizeX", m_IslandSizeX); m_IslandSizeY = a_IniFile.GetValueSetI("Generator", "EndGenIslandSizeY", m_IslandSizeY); diff --git a/src/Generating/EndGen.h b/src/Generating/EndGen.h index 4904a0e3d..322061810 100644 --- a/src/Generating/EndGen.h +++ b/src/Generating/EndGen.h @@ -23,8 +23,6 @@ class cEndGen : public: cEndGen(int a_Seed); - void Initialize(cIniFile & a_IniFile); - protected: /// Seed for the noise @@ -66,4 +64,5 @@ protected: // cTerrainCompositionGen overrides: virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override; + virtual void InitializeCompoGen(cIniFile & a_IniFile) override; } ; diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index a543c6361..c6e569919 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -100,7 +100,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) = 0; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) = 0; - virtual void SendRespawn (void) = 0; + virtual void SendRespawn (const cWorld & a_World) = 0; virtual void SendExperience (void) = 0; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) = 0; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index f3bdae3ac..873295f62 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -831,12 +831,12 @@ void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect -void cProtocol125::SendRespawn(void) +void cProtocol125::SendRespawn(const cWorld & a_World) { cCSLock Lock(m_CSPacket); cPlayer * Player = m_Client->GetPlayer(); WriteByte (PACKET_RESPAWN); - WriteInt ((int)(Player->GetWorld()->GetDimension())); + WriteInt ((int)(a_World.GetDimension())); WriteByte (2); // TODO: Difficulty; 2 = Normal WriteChar ((char)Player->GetGameMode()); WriteShort (256); // Current world height diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 18a626a2d..3f39c8965 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -72,7 +72,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (void) override; + virtual void SendRespawn (const cWorld & a_World) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp index 714bf5e46..9e0f3f852 100644 --- a/src/Protocol/Protocol16x.cpp +++ b/src/Protocol/Protocol16x.cpp @@ -158,10 +158,10 @@ void cProtocol161::SendPlayerMaxSpeed(void) -void cProtocol161::SendRespawn(void) +void cProtocol161::SendRespawn(const cWorld & a_World) { // Besides sending the respawn, we need to also send the player max speed, otherwise the client reverts to super-fast - super::SendRespawn(); + super::SendRespawn(a_World); SendPlayerMaxSpeed(); } diff --git a/src/Protocol/Protocol16x.h b/src/Protocol/Protocol16x.h index 8eedce8d5..e91dc8a1c 100644 --- a/src/Protocol/Protocol16x.h +++ b/src/Protocol/Protocol16x.h @@ -42,7 +42,7 @@ protected: virtual void SendGameMode (eGameMode a_GameMode) override; virtual void SendHealth (void) override; virtual void SendPlayerMaxSpeed(void) override; - virtual void SendRespawn (void) override; + virtual void SendRespawn (const cWorld & a_World) override; virtual void SendWindowOpen (const cWindow & a_Window) override; virtual int ParseEntityAction (void) override; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 7c526d103..96e1cbad9 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -983,11 +983,11 @@ void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect -void cProtocol172::SendRespawn(void) +void cProtocol172::SendRespawn(const cWorld & a_World) { cPacketizer Pkt(*this, 0x07); // Respawn packet cPlayer * Player = m_Client->GetPlayer(); - Pkt.WriteInt(Player->GetWorld()->GetDimension()); + Pkt.WriteInt((int)a_World.GetDimension()); Pkt.WriteByte(2); // TODO: Difficulty (set to Normal) Pkt.WriteByte((Byte)Player->GetEffectiveGameMode()); Pkt.WriteString("default"); diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 3c6a8c085..cafdb50e4 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -104,7 +104,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (void) override; + virtual void SendRespawn (const cWorld & a_World) override; virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8 virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index b0cbb6def..35a331f43 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -555,10 +555,10 @@ void cProtocolRecognizer::SendRemoveEntityEffect(const cEntity & a_Entity, int a -void cProtocolRecognizer::SendRespawn(void) +void cProtocolRecognizer::SendRespawn(const cWorld & a_World) { ASSERT(m_Protocol != NULL); - m_Protocol->SendRespawn(); + m_Protocol->SendRespawn(a_World); } diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 3a291bf7a..5e178447c 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -107,7 +107,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (void) override; + virtual void SendRespawn (const cWorld & a_World) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; diff --git a/src/Root.cpp b/src/Root.cpp index c82b05a66..2a80baeb3 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -320,7 +320,7 @@ cWorld * cRoot::CreateAndInitializeWorld(const AString & a_WorldName) { return NULL; } - cWorld* NewWorld = new cWorld(a_WorldName.c_str()); + cWorld * NewWorld = new cWorld(a_WorldName.c_str()); m_WorldsByName[a_WorldName] = NewWorld; NewWorld->Start(); NewWorld->InitializeSpawn(); @@ -372,7 +372,7 @@ void cRoot::UnloadWorlds(void) -cWorld* cRoot::GetDefaultWorld() +cWorld * cRoot::GetDefaultWorld() { return m_pDefaultWorld; } @@ -381,12 +381,14 @@ cWorld* cRoot::GetDefaultWorld() -cWorld* cRoot::GetWorld( const AString & a_WorldName ) +cWorld * cRoot::GetWorld(const AString & a_WorldName) { - WorldMap::iterator itr = m_WorldsByName.find( a_WorldName ); - if( itr != m_WorldsByName.end() ) + WorldMap::iterator itr = m_WorldsByName.find(a_WorldName); + if (itr != m_WorldsByName.end()) + { return itr->second; - return 0; + } + return NULL; } @@ -398,9 +400,12 @@ bool cRoot::ForEachWorld(cWorldListCallback & a_Callback) for (WorldMap::iterator itr = m_WorldsByName.begin(), itr2 = itr; itr != m_WorldsByName.end(); itr = itr2) { ++itr2; - if (a_Callback.Item(itr->second)) + if (itr->second != NULL) { - return false; + if (a_Callback.Item(itr->second)) + { + return false; + } } } return true; diff --git a/src/World.cpp b/src/World.cpp index 807065bfa..9869e90fa 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -571,6 +571,37 @@ void cWorld::Start(void) m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmAdventure); m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll); + switch (GetDimension()) + { + case dimEnd: + { + IniFile.GetValueSet("Generator", "BiomeGen", "Constant"); + IniFile.GetValueSet("Generator", "ConstantBiome", "End"); + IniFile.GetValueSet("Generator", "HeightGen", "Biomal"); + IniFile.GetValueSet("Generator", "CompositionGen", "End"); + break; + } + case dimOverworld: + { + IniFile.GetValueSet("Generator", "BiomeGen", "MultiStepMap"); + IniFile.GetValueSet("Generator", "HeightGen", "DistortedHeightmap"); + IniFile.GetValueSet("Generator", "CompositionGen", "DistortedHeightmap"); + IniFile.GetValueSet("Generator", "Finishers", "Ravines, WormNestCaves, WaterLakes, WaterSprings, LavaLakes, LavaSprings, OreNests, Mineshafts, Trees, SprinkleFoliage, Ice, Snow, Lilypads, BottomLava, DeadBushes, PreSimulator"); + break; + } + case dimNether: + { + IniFile.GetValueSet("Generator", "BiomeGen", "Constant"); + IniFile.GetValueSet("Generator", "ConstantBiome", "Nether"); + IniFile.GetValueSet("Generator", "HeightGen", "Flat"); + IniFile.GetValueSet("Generator", "FlatHeight", "128"); + IniFile.GetValueSet("Generator", "CompositionGen", "Nether"); + IniFile.GetValueSet("Generator", "Finishers", "WormNestCaves, BottomLava, LavaSprings, NetherClumpFoliage, NetherForts, PreSimulator"); + IniFile.GetValueSet("Generator", "BottomLavaHeight", "30"); + break; + } + } + // Load allowed mobs: const char * DefaultMonsters = ""; switch (m_Dimension) -- cgit v1.2.3 From 5368e664864094c51a919dc8846f2b41039417e6 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 1 Jun 2014 00:29:17 +0200 Subject: Missing return; --- src/UI/SlotArea.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index b3e126247..bc8dd9cd6 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1400,6 +1400,7 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick)) { ShiftClicked(a_Player, a_SlotNum, a_ClickedItem); + return; } cItem Slot(*GetSlot(a_SlotNum, a_Player)); -- cgit v1.2.3 From a18b6c231102c78604b9ada7e6ce8a4eb074591e Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 1 Jun 2014 00:43:09 +0200 Subject: Add HandleSmeltItem() call for achievements. --- src/UI/SlotArea.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index bc8dd9cd6..ac85322b3 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1397,12 +1397,6 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a return; } - if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick)) - { - ShiftClicked(a_Player, a_SlotNum, a_ClickedItem); - return; - } - cItem Slot(*GetSlot(a_SlotNum, a_Player)); if (!Slot.IsSameType(a_ClickedItem)) { @@ -1411,8 +1405,15 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a LOGWARNING("Their item: %s", ItemToFullString(a_ClickedItem).c_str()); bAsync = true; } - cItem & DraggingItem = a_Player.GetDraggingItem(); + if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick)) + { + HandleSmeltItem(Slot, a_Player); + ShiftClicked(a_Player, a_SlotNum, Slot); + return; + } + + cItem & DraggingItem = a_Player.GetDraggingItem(); if (!DraggingItem.IsEmpty()) { if (a_ClickAction == caDblClick) @@ -1429,6 +1430,7 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a } DraggingItem.m_ItemCount += Slot.m_ItemCount; + HandleSmeltItem(Slot, a_Player); Slot.Empty(); } else @@ -1443,6 +1445,7 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a case caLeftClick: { DraggingItem = Slot; + HandleSmeltItem(Slot, a_Player); Slot.Empty(); break; } @@ -1456,6 +1459,7 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a { Slot.Empty(); } + HandleSmeltItem(DraggingItem, a_Player); break; } default: -- cgit v1.2.3 From 12f3c0fcdf6e45cbeed630730edb1223a2ecc4d8 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 1 Jun 2014 00:50:35 +0200 Subject: Players can't set items in the result slot, when they shift a item. --- src/UI/SlotArea.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/UI/SlotArea.h | 1 + 2 files changed, 39 insertions(+) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index ac85322b3..59a6384b1 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1484,6 +1484,44 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a +void cSlotAreaFurnace::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) +{ + for (int i = 0; i < 2; i++) + { + const cItem * Slot = GetSlot(i, a_Player); + if (!Slot->IsEqual(a_ItemStack) && (!Slot->IsEmpty() || a_KeepEmptySlots)) + { + // Different items + continue; + } + int NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount; + if (NumFit <= 0) + { + // Full stack already + continue; + } + if (NumFit > a_ItemStack.m_ItemCount) + { + NumFit = a_ItemStack.m_ItemCount; + } + if (a_ShouldApply) + { + cItem NewSlot(a_ItemStack); + NewSlot.m_ItemCount = Slot->m_ItemCount + NumFit; + SetSlot(i, a_Player, NewSlot); + } + a_ItemStack.m_ItemCount -= NumFit; + if (a_ItemStack.IsEmpty()) + { + return; + } + } // for i - Slots +} + + + + + const cItem * cSlotAreaFurnace::GetSlot(int a_SlotNum, cPlayer & a_Player) const { UNUSED(a_Player); diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index e297bcff7..b4b693cf6 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -392,6 +392,7 @@ public: virtual ~cSlotAreaFurnace(); virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override; + virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override; virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override; virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override; -- cgit v1.2.3 From 75fe89b8aef77d8e684a30aae07c09297d1653cb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 1 Jun 2014 09:27:27 +0200 Subject: Updated AlchemistVillage prefabs. --- src/Generating/Prefabs/AlchemistVillagePrefabs.cpp | 208 +++++++++++---------- 1 file changed, 105 insertions(+), 103 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp index 6e3f82212..eb0d30fdf 100644 --- a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp +++ b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp @@ -23,8 +23,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 11, 12, 10, // SizeX = 11, SizeY = 12, SizeZ = 10 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 10, 11, 9, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 11, 11, 10, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -270,8 +270,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 11, 8, 10, // SizeX = 11, SizeY = 8, SizeZ = 10 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 10, 7, 9, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 11, 7, 10, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -455,8 +455,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 11, 5, 13, // SizeX = 11, SizeY = 5, SizeZ = 13 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 10, 4, 12, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 11, 4, 13, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -606,26 +606,28 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 15, 13, 11, // SizeX = 15, SizeY = 13, SizeZ = 11 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 14, 12, 10, // MaxX, MaxY, MaxZ + -1, 0, -1, // MinX, MinY, MinZ + 14, 12, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "A:128: 7\n" /* sandstonestairs */ - "B: 44: 1\n" /* step */ - "C:128: 2\n" /* sandstonestairs */ - "D:128: 0\n" /* sandstonestairs */ - "E: 87: 0\n" /* netherstone */ - "F:128: 3\n" /* sandstonestairs */ - "G: 51: 0\n" /* fire */ - "H: 44: 9\n" /* step */ + "A:128: 4\n" /* sandstonestairs */ + "B:128: 5\n" /* sandstonestairs */ + "C:128: 7\n" /* sandstonestairs */ + "D: 44: 1\n" /* step */ + "E:128: 2\n" /* sandstonestairs */ + "F:128: 0\n" /* sandstonestairs */ + "G: 87: 0\n" /* netherstone */ + "H:128: 3\n" /* sandstonestairs */ + "I: 51: 0\n" /* fire */ + "J: 44: 9\n" /* step */ "a: 12: 0\n" /* sand */ "b: 5: 0\n" /* wood */ "c: 24: 2\n" /* sandstone */ "d: 24: 0\n" /* sandstone */ "e: 85: 0\n" /* fence */ "f: 5: 1\n" /* wood */ - "g: 64: 2\n" /* wooddoorblock */ + "g: 64: 6\n" /* wooddoorblock */ "h: 64: 0\n" /* wooddoorblock */ "i: 61: 2\n" /* furnace */ "j:118: 0\n" /* cauldronblock */ @@ -633,18 +635,18 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "l: 65: 2\n" /* ladder */ "m: 19: 0\n" /* sponge */ "n:101: 0\n" /* ironbars */ - "o:140: 0\n" /* flowerpotblock */ - "p: 64: 8\n" /* wooddoorblock */ - "q: 50: 3\n" /* torch */ - "r: 69:12\n" /* lever */ - "s: 50: 4\n" /* torch */ - "t:128: 6\n" /* sandstonestairs */ - "u: 44:10\n" /* step */ - "v:128: 1\n" /* sandstonestairs */ - "w: 47: 0\n" /* bookshelf */ - "x: 96:12\n" /* trapdoor */ - "y:128: 4\n" /* sandstonestairs */ - "z:128: 5\n" /* sandstonestairs */, + "o: 50: 1\n" /* torch */ + "p:140: 0\n" /* flowerpotblock */ + "q: 64:12\n" /* wooddoorblock */ + "r: 50: 3\n" /* torch */ + "s: 64: 8\n" /* wooddoorblock */ + "t: 69:12\n" /* lever */ + "u: 50: 4\n" /* torch */ + "v:128: 6\n" /* sandstonestairs */ + "w: 44:10\n" /* step */ + "x:128: 1\n" /* sandstonestairs */ + "y: 47: 0\n" /* bookshelf */ + "z: 96:10\n" /* trapdoor */, // Block data: // Level 0 @@ -681,12 +683,12 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "....cddnnnddc.." - /* 1 */ "....d......od.c" - /* 2 */ "....p.......d.q" - /* 3 */ "....d.......p.." - /* 4 */ "....d.r...l.d.s" + /* 1 */ "....do.....pd.c" + /* 2 */ "....q.......d.r" + /* 3 */ "....d.......s.." + /* 4 */ "....d.t...l.d.u" /* 5 */ "....dddd.dddd.c" - /* 6 */ "....n.......n.." + /* 6 */ "....n..r.r..n.." /* 7 */ "mmmmn.......n.." /* 8 */ "mmmmn.......n.." /* 9 */ "mmmmd.......d.." @@ -695,32 +697,32 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // Level 3 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "....cddtttddc.." - /* 1 */ "....duuuuuuuddv" - /* 2 */ "....duuuuuuud.." - /* 3 */ "....duuuuuuud.." - /* 4 */ "....dwwwuuxud.." - /* 5 */ "....ddddddddddv" - /* 6 */ "....yuuuuuuuz.." - /* 7 */ "mmmmyuuuuuuuz.." - /* 8 */ "mmmmyuuuuuuuz.." - /* 9 */ "mmmmduuuuuuud.." - /* 10 */ "mmmmcddAAAddc.." + /* 0 */ "....cddvvvddc.." + /* 1 */ "....dwwwwwwwddx" + /* 2 */ "....dwwwwwwwd.." + /* 3 */ "....dwwwwwwwd.." + /* 4 */ "....dyyywwzwd.." + /* 5 */ "....ddddddddddx" + /* 6 */ "....AwwwwwwwB.." + /* 7 */ "mmmmAwwwwwwwB.." + /* 8 */ "mmmmAwwwwwwwB.." + /* 9 */ "mmmmdwwwwwwwd.." + /* 10 */ "mmmmcddCCCddc.." // Level 4 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "....dBBBdBBBd.." - /* 1 */ "....BcdddddcB.." - /* 2 */ "....Bd.....dB.." - /* 3 */ "....Bd.....dB.." - /* 4 */ "....Bd.....dB.." + /* 0 */ "....dDDDdDDDd.." + /* 1 */ "....DcdddddcD.." + /* 2 */ "....Dd.....dD.." + /* 3 */ "....Dd.....dD.." + /* 4 */ "....Dd.....dD.." /* 5 */ "....dcdd.ddcd.." - /* 6 */ "....B.......B.." - /* 7 */ "mmmmB.......B.." - /* 8 */ "mmmmB.......B.." - /* 9 */ "mmmmB.......B.." - /* 10 */ "mmmmdBBBdBBBd.." + /* 6 */ "....D.......D.." + /* 7 */ "mmmmD.......D.." + /* 8 */ "mmmmD.......D.." + /* 9 */ "mmmmD.......D.." + /* 10 */ "mmmmdDDDdDDDd.." // Level 5 /* z\x* 11111 */ @@ -741,10 +743,10 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".....cddtddc..." - /* 2 */ ".....yuuuuuz..." - /* 3 */ ".....yuuuuuz..." - /* 4 */ ".....yuuuuuz..." + /* 1 */ ".....cddvddc..." + /* 2 */ ".....AwwwwwB..." + /* 3 */ ".....AwwwwwB..." + /* 4 */ ".....AwwwwwB..." /* 5 */ ".....cdddddc..." /* 6 */ "..............." /* 7 */ "..............." @@ -756,11 +758,11 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".....dBBdBBd..." - /* 2 */ ".....B.ddd.B..." + /* 1 */ ".....dDDdDDd..." + /* 2 */ ".....D.ddd.D..." /* 3 */ ".....d.ddd.d..." - /* 4 */ ".....B.ddd.B..." - /* 5 */ ".....dBBdBBd..." + /* 4 */ ".....D.ddd.D..." + /* 5 */ ".....dDDdDDd..." /* 6 */ "..............." /* 7 */ "..............." /* 8 */ "..............." @@ -772,9 +774,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ ".......cCc....." - /* 3 */ ".......DEv....." - /* 4 */ ".......cFc....." + /* 2 */ ".......cEc....." + /* 3 */ ".......FGx....." + /* 4 */ ".......cHc....." /* 5 */ "..............." /* 6 */ "..............." /* 7 */ "..............." @@ -788,7 +790,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..............." /* 1 */ "..............." /* 2 */ ".......c.c....." - /* 3 */ "........G......" + /* 3 */ "........I......" /* 4 */ ".......c.c....." /* 5 */ "..............." /* 6 */ "..............." @@ -802,9 +804,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ ".......ctc....." - /* 3 */ ".......y.z....." - /* 4 */ ".......cAc....." + /* 2 */ ".......cvc....." + /* 3 */ ".......A.B....." + /* 4 */ ".......cCc....." /* 5 */ "..............." /* 6 */ "..............." /* 7 */ "..............." @@ -818,7 +820,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..............." /* 1 */ "..............." /* 2 */ ".......ddd....." - /* 3 */ ".......dHd....." + /* 3 */ ".......dJd....." /* 4 */ ".......ddd....." /* 5 */ "..............." /* 6 */ "..............." @@ -832,9 +834,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ ".......B.B....." + /* 2 */ ".......D.D....." /* 3 */ "..............." - /* 4 */ ".......B.B....." + /* 4 */ ".......D.D....." /* 5 */ "..............." /* 6 */ "..............." /* 7 */ "..............." @@ -877,8 +879,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 7, 11, 7, // SizeX = 7, SizeY = 11, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 6, 10, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 7, 10, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1050,8 +1052,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 5, 5, 7, // SizeX = 5, SizeY = 5, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 4, 4, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 5, 4, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1160,8 +1162,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 7, 5, 11, // SizeX = 7, SizeY = 5, SizeZ = 11 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 6, 4, 10, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 7, 4, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1291,8 +1293,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 9, 5, 7, // SizeX = 9, SizeY = 5, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 8, 4, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 9, 4, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1400,8 +1402,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 5, 5, 11, // SizeX = 5, SizeY = 5, SizeZ = 11 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 4, 4, 10, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 5, 4, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1428,7 +1430,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "u:128: 5\n" /* sandstonestairs */ "v:128: 7\n" /* sandstonestairs */ "w: 44: 1\n" /* step */ - "x: 96: 7\n" /* trapdoor */, + "x: 96: 1\n" /* trapdoor */, // Block data: // Level 0 @@ -1536,8 +1538,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 9, 5, 9, // SizeX = 9, SizeY = 5, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 8, 4, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 9, 4, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1657,8 +1659,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 9, 5, 9, // SizeX = 9, SizeY = 5, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 8, 4, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 9, 4, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1783,8 +1785,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 9, 5, 11, // SizeX = 9, SizeY = 5, SizeZ = 11 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 8, 4, 10, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 9, 4, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1914,8 +1916,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 5, 8, 7, // SizeX = 5, SizeY = 8, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 4, 7, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 5, 7, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -2054,8 +2056,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 15, 8, 9, // SizeX = 15, SizeY = 8, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 14, 7, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 15, 7, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -2219,8 +2221,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 11, 9, 9, // SizeX = 11, SizeY = 9, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 10, 8, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 11, 8, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -2413,8 +2415,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 12, 10, 11, // SizeX = 12, SizeY = 10, SizeZ = 11 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 11, 9, 10, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 12, 9, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -2441,7 +2443,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "u:128: 5\n" /* sandstonestairs */ "v:128: 7\n" /* sandstonestairs */ "w: 44: 1\n" /* step */ - "x: 96: 6\n" /* trapdoor */ + "x: 96: 4\n" /* trapdoor */ "y:126: 0\n" /* woodenslab */ "z:128: 4\n" /* sandstonestairs */, @@ -2631,8 +2633,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 9, 5, 11, // SizeX = 9, SizeY = 5, SizeZ = 11 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 8, 4, 10, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 9, 4, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -2762,8 +2764,8 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 13, 9, 9, // SizeX = 13, SizeY = 9, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 12, 8, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 13, 8, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ -- cgit v1.2.3 From 046c1497979cf96a2fc4d1847dad2d7daf050e60 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 1 Jun 2014 10:07:57 +0200 Subject: Updated UnderwaterBase prefabs. --- src/Generating/Prefabs/UnderwaterBasePrefabs.cpp | 226 ++++++++++++----------- 1 file changed, 123 insertions(+), 103 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp index 54d1b6745..a20ff9e26 100644 --- a/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp +++ b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp @@ -60,8 +60,8 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "abeebbbeebbbeeba" - /* 1 */ "f.........g....h" - /* 2 */ "h....i.........f" + /* 1 */ "f...g......g...h" + /* 2 */ "h...i......i...f" /* 3 */ "abeebbbeebbbeeba" // Level 3 @@ -88,7 +88,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = true, // DefaultWeight: - 100, + 2000, // DepthWeight: "", @@ -125,8 +125,10 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = "h: 64:12\n" /* wooddoorblock */ "i: 76: 3\n" /* redstonetorchon */ "j: 64: 8\n" /* wooddoorblock */ - "k: 76: 2\n" /* redstonetorchon */ - "m: 19: 0\n" /* sponge */, + "k: 76: 4\n" /* redstonetorchon */ + "l: 76: 2\n" /* redstonetorchon */ + "m: 19: 0\n" /* sponge */ + "n: 76: 1\n" /* redstonetorchon */, // Block data: // Level 0 @@ -163,10 +165,10 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 0 */ "abggbbmmmm" /* 1 */ "h...i.bbmm" /* 2 */ "j.......bm" - /* 3 */ "abb.....bm" + /* 3 */ "abbk....bm" /* 4 */ "mmmbb....b" - /* 5 */ "mmmmmb..kb" - /* 6 */ "mmmmmb...g" + /* 5 */ "mmmmmb..lb" + /* 6 */ "mmmmmbn..g" /* 7 */ "mmmmmmb..g" /* 8 */ "mmmmmmb..b" /* 9 */ "mmmmmmahja" @@ -241,10 +243,10 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = "k: 20: 0\n" /* glass */ "l: 76: 1\n" /* redstonetorchon */ "m: 19: 0\n" /* sponge */ - "n: 76: 3\n" /* redstonetorchon */ - "o: 76: 4\n" /* redstonetorchon */ - "p: 64: 9\n" /* wooddoorblock */ - "q: 76: 2\n" /* redstonetorchon */, + "n: 76: 2\n" /* redstonetorchon */ + "o: 76: 3\n" /* redstonetorchon */ + "p: 76: 4\n" /* redstonetorchon */ + "q: 64: 9\n" /* wooddoorblock */, // Block data: // Level 0 @@ -294,18 +296,18 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 1 */ "mmmmmmb..bmmmmmm" /* 2 */ "mmmmmmk..kmmmmmm" /* 3 */ "mmmmmmk..kmmmmmm" - /* 4 */ "mmmmmmb..bmmmmmm" - /* 5 */ "mmmmmmbl.bmmmmmm" + /* 4 */ "mmmmmmblnbmmmmmm" + /* 5 */ "mmmmmmb..bmmmmmm" /* 6 */ "abkkbbb..bbbkkba" - /* 7 */ "j.........n....i" - /* 8 */ "i....o.........p" + /* 7 */ "j...o......o...i" + /* 8 */ "i...p......p...q" /* 9 */ "abkkbbb..bbbkkba" - /* 10 */ "mmmmmmb.qbmmmmmm" - /* 11 */ "mmmmmmb..bmmmmmm" + /* 10 */ "mmmmmmb..bmmmmmm" + /* 11 */ "mmmmmmblnbmmmmmm" /* 12 */ "mmmmmmk..kmmmmmm" /* 13 */ "mmmmmmk..kmmmmmm" /* 14 */ "mmmmmmb..bmmmmmm" - /* 15 */ "mmmmmmapiammmmmm" + /* 15 */ "mmmmmmaqiammmmmm" // Level 3 /* z\x* 111111 */ @@ -380,11 +382,11 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = "d: 53: 0\n" /* woodstairs */ "e: 20: 0\n" /* glass */ "f: 64: 9\n" /* wooddoorblock */ - "g: 64: 8\n" /* wooddoorblock */ - "h: 76: 4\n" /* redstonetorchon */ - "i: 64: 0\n" /* wooddoorblock */ - "j: 64: 7\n" /* wooddoorblock */ - "k: 76: 3\n" /* redstonetorchon */ + "g: 76: 3\n" /* redstonetorchon */ + "h: 64: 8\n" /* wooddoorblock */ + "i: 76: 4\n" /* redstonetorchon */ + "j: 64: 0\n" /* wooddoorblock */ + "k: 64: 7\n" /* wooddoorblock */ "l: 64:12\n" /* wooddoorblock */ "m: 19: 0\n" /* sponge */, @@ -409,8 +411,8 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "abeebbbbbmmmmmmm" - /* 1 */ "f......dbbmmmmmm" - /* 2 */ "g...h..dbbmmmmmm" + /* 1 */ "f...g..dbbmmmmmm" + /* 2 */ "h...i..dbbmmmmmm" /* 3 */ "abeebbbbbmmmmmmm" // Level 3 @@ -441,16 +443,16 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "mmmmmmmbbbbbbbba" - /* 1 */ "mmmmmmmb.......i" - /* 2 */ "mmmmmmmb.......j" + /* 1 */ "mmmmmmmb.......j" + /* 2 */ "mmmmmmmb.......k" /* 3 */ "mmmmmmmbbbbbbbba" // Level 7 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "mmmmmmmmbbbeebba" - /* 1 */ "mmmmmmmmb.k....g" - /* 2 */ "mmmmmmmmb......l" + /* 1 */ "mmmmmmmmb.g....h" + /* 2 */ "mmmmmmmmb.i....l" /* 3 */ "mmmmmmmmbbbeebba" // Level 8 @@ -515,10 +517,11 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = "i: 64:12\n" /* wooddoorblock */ "j: 20: 0\n" /* glass */ "k: 76: 1\n" /* redstonetorchon */ - "l: 76: 3\n" /* redstonetorchon */ + "l: 76: 2\n" /* redstonetorchon */ "m: 19: 0\n" /* sponge */ - "n: 76: 4\n" /* redstonetorchon */ - "o: 64: 9\n" /* wooddoorblock */, + "n: 76: 3\n" /* redstonetorchon */ + "o: 76: 4\n" /* redstonetorchon */ + "p: 64: 9\n" /* wooddoorblock */, // Block data: // Level 0 @@ -556,11 +559,11 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 1 */ "mmmmmmb..bmmmmmm" /* 2 */ "mmmmmmj..jmmmmmm" /* 3 */ "mmmmmmj..jmmmmmm" - /* 4 */ "mmmmmmb..bmmmmmm" - /* 5 */ "mmmmmmbk.bmmmmmm" + /* 4 */ "mmmmmmbklbmmmmmm" + /* 5 */ "mmmmmmb..bmmmmmm" /* 6 */ "abjjbbb..bbbjjba" - /* 7 */ "i.........l....h" - /* 8 */ "h....n.........o" + /* 7 */ "i...n......n...h" + /* 8 */ "h...o......o...p" /* 9 */ "abjjbbbjjbbbjjba" // Level 3 @@ -625,10 +628,14 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = "a: 5: 0\n" /* wood */ "b: 20: 0\n" /* glass */ "c: 5: 5\n" /* wood */ - "d: 64: 0\n" /* wooddoorblock */ - "e: 64: 1\n" /* wooddoorblock */ - "f: 64: 8\n" /* wooddoorblock */ - "g: 64: 9\n" /* wooddoorblock */ + "d: 76: 3\n" /* redstonetorchon */ + "e: 76: 1\n" /* redstonetorchon */ + "f: 64: 0\n" /* wooddoorblock */ + "g: 76: 4\n" /* redstonetorchon */ + "h: 76: 2\n" /* redstonetorchon */ + "i: 64: 1\n" /* wooddoorblock */ + "j: 64: 8\n" /* wooddoorblock */ + "k: 64: 9\n" /* wooddoorblock */ "m: 19: 0\n" /* sponge */, // Block data: @@ -654,19 +661,19 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ "mmmmmaammmmmmm" - /* 1 */ "mmmaa..aammmmm" + /* 1 */ "mmmaaddaammmmm" /* 2 */ "mmaa....aammmm" /* 3 */ "maa......aammm" /* 4 */ "ma........aaac" - /* 5 */ "a............d" - /* 6 */ "a............d" + /* 5 */ "ae........d..f" + /* 6 */ "ae........g..f" /* 7 */ "ma........aaac" /* 8 */ "maa......aammm" /* 9 */ "mmaa....aammmm" - /* 10 */ "mmmaa..aammmmm" + /* 10 */ "mmmaaehaammmmm" /* 11 */ "mmmma..ammmmmm" /* 12 */ "mmmma..ammmmmm" - /* 13 */ "mmmmceecmmmmmm" + /* 13 */ "mmmmciicmmmmmm" // Level 2 /* z\x* 1111 */ @@ -676,15 +683,15 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 2 */ "mmbb....bbmmmm" /* 3 */ "mbb......bbmmm" /* 4 */ "mb........bbac" - /* 5 */ "b............f" - /* 6 */ "b............g" + /* 5 */ "b............j" + /* 6 */ "b............k" /* 7 */ "mb........bbac" /* 8 */ "mbb......bbmmm" /* 9 */ "mmbb....bbmmmm" /* 10 */ "mmmbb..bbmmmmm" /* 11 */ "mmmmb..bmmmmmm" /* 12 */ "mmmma..ammmmmm" - /* 13 */ "mmmmcgfcmmmmmm" + /* 13 */ "mmmmckjcmmmmmm" // Level 3 /* z\x* 1111 */ @@ -804,12 +811,12 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = "a: 5: 0\n" /* wood */ "b: 5: 5\n" /* wood */ "c: 20: 0\n" /* glass */ - "d: 64: 1\n" /* wooddoorblock */ + "d: 64: 5\n" /* wooddoorblock */ "e: 64: 0\n" /* wooddoorblock */ - "f: 64: 6\n" /* wooddoorblock */ + "f: 64: 2\n" /* wooddoorblock */ "g: 76: 3\n" /* redstonetorchon */ - "h: 64: 8\n" /* wooddoorblock */ - "i: 64:12\n" /* wooddoorblock */ + "h: 64:12\n" /* wooddoorblock */ + "i: 64: 8\n" /* wooddoorblock */ "j: 64: 9\n" /* wooddoorblock */ "k: 76: 4\n" /* redstonetorchon */ "m: 19: 0\n" /* sponge */, @@ -840,7 +847,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* * 0123456789012345 */ /* 0 */ "mmaccccccccccamm" /* 1 */ "bag..........gab" - /* 2 */ "h..............h" + /* 2 */ "h..............i" /* 3 */ "i..............j" /* 4 */ "bak..........kab" /* 5 */ "mmaccccccccccamm" @@ -912,9 +919,11 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = "b: 5: 0\n" /* wood */ "c: 20: 0\n" /* glass */ "d: 64: 3\n" /* wooddoorblock */ - "e: 64: 1\n" /* wooddoorblock */ - "f: 64: 8\n" /* wooddoorblock */ - "g: 64: 9\n" /* wooddoorblock */ + "e: 76: 1\n" /* redstonetorchon */ + "f: 76: 2\n" /* redstonetorchon */ + "g: 64: 1\n" /* wooddoorblock */ + "h: 64: 8\n" /* wooddoorblock */ + "i: 64: 9\n" /* wooddoorblock */ "m: 19: 0\n" /* sponge */, // Block data: @@ -944,24 +953,24 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 0 */ "mmmmaddammmm" /* 1 */ "mmmmb..bmmmm" /* 2 */ "mmmmb..bmmmm" - /* 3 */ "mmmbb..bbmmm" + /* 3 */ "mmmbbefbbmmm" /* 4 */ "mmbb....bbmm" /* 5 */ "mbb......bbm" /* 6 */ "mb........bm" - /* 7 */ "b..........b" - /* 8 */ "b..........b" + /* 7 */ "be........fb" + /* 8 */ "be........fb" /* 9 */ "mb........bm" /* 10 */ "mbb......bbm" /* 11 */ "mmbb....bbmm" - /* 12 */ "mmmbb..bbmmm" + /* 12 */ "mmmbbefbbmmm" /* 13 */ "mmmmb..bmmmm" /* 14 */ "mmmmb..bmmmm" - /* 15 */ "mmmmaeeammmm" + /* 15 */ "mmmmaggammmm" // Level 2 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "mmmmaffammmm" + /* 0 */ "mmmmahiammmm" /* 1 */ "mmmmb..bmmmm" /* 2 */ "mmmmc..cmmmm" /* 3 */ "mmmcc..ccmmm" @@ -976,7 +985,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 12 */ "mmmcc..ccmmm" /* 13 */ "mmmmc..cmmmm" /* 14 */ "mmmmb..bmmmm" - /* 15 */ "mmmmagfammmm" + /* 15 */ "mmmmaihammmm" // Level 3 /* z\x* 11 */ @@ -1125,12 +1134,16 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = "b: 5: 0\n" /* wood */ "c: 20: 0\n" /* glass */ "d: 64: 3\n" /* wooddoorblock */ - "e: 64: 2\n" /* wooddoorblock */ - "f: 64: 0\n" /* wooddoorblock */ - "g: 64: 1\n" /* wooddoorblock */ - "h: 64: 8\n" /* wooddoorblock */ - "i: 64: 9\n" /* wooddoorblock */ - "m: 19: 0\n" /* sponge */, + "e: 76: 1\n" /* redstonetorchon */ + "f: 76: 2\n" /* redstonetorchon */ + "g: 64: 2\n" /* wooddoorblock */ + "h: 76: 3\n" /* redstonetorchon */ + "i: 64: 0\n" /* wooddoorblock */ + "j: 76: 4\n" /* redstonetorchon */ + "k: 64: 1\n" /* wooddoorblock */ + "l: 64: 8\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */ + "n: 64: 9\n" /* wooddoorblock */, // Block data: // Level 0 @@ -1159,39 +1172,39 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 0 */ "mmmmmmaddammmmmm" /* 1 */ "mmmmmmb..bmmmmmm" /* 2 */ "mmmmmmb..bmmmmmm" - /* 3 */ "mmmmmbb..bbmmmmm" + /* 3 */ "mmmmmbbefbbmmmmm" /* 4 */ "mmmmbb....bbmmmm" /* 5 */ "mmmbb......bbmmm" /* 6 */ "abbb........bbba" - /* 7 */ "e..............f" - /* 8 */ "e..............f" + /* 7 */ "g..h........h..i" + /* 8 */ "g..j........j..i" /* 9 */ "abbb........bbba" /* 10 */ "mmmbb......bbmmm" /* 11 */ "mmmmbb....bbmmmm" - /* 12 */ "mmmmmbb..bbmmmmm" + /* 12 */ "mmmmmbbefbbmmmmm" /* 13 */ "mmmmmmb..bmmmmmm" /* 14 */ "mmmmmmb..bmmmmmm" - /* 15 */ "mmmmmmaggammmmmm" + /* 15 */ "mmmmmmakkammmmmm" // Level 2 /* z\x* 111111 */ /* * 0123456789012345 */ - /* 0 */ "mmmmmmahiammmmmm" + /* 0 */ "mmmmmmalnammmmmm" /* 1 */ "mmmmmmb..bmmmmmm" /* 2 */ "mmmmmmc..cmmmmmm" /* 3 */ "mmmmmcc..ccmmmmm" /* 4 */ "mmmmcc....ccmmmm" /* 5 */ "mmmcc......ccmmm" /* 6 */ "abcc........ccba" - /* 7 */ "i..............h" - /* 8 */ "h..............i" + /* 7 */ "n..............l" + /* 8 */ "l..............n" /* 9 */ "abcc........ccba" /* 10 */ "mmmcc......ccmmm" /* 11 */ "mmmmcc....ccmmmm" /* 12 */ "mmmmmcc..ccmmmmm" /* 13 */ "mmmmmmc..cmmmmmm" /* 14 */ "mmmmmmb..bmmmmmm" - /* 15 */ "mmmmmmaihammmmmm" + /* 15 */ "mmmmmmanlammmmmm" // Level 3 /* z\x* 111111 */ @@ -1293,7 +1306,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = true, // DefaultWeight: - 100, + 50, // DepthWeight: "", @@ -1323,9 +1336,12 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = "a: 5: 0\n" /* wood */ "b: 20: 0\n" /* glass */ "c: 5: 5\n" /* wood */ - "d: 64: 0\n" /* wooddoorblock */ - "e: 64: 8\n" /* wooddoorblock */ - "f: 64: 9\n" /* wooddoorblock */ + "d: 76: 3\n" /* redstonetorchon */ + "e: 76: 1\n" /* redstonetorchon */ + "f: 64: 0\n" /* wooddoorblock */ + "g: 76: 4\n" /* redstonetorchon */ + "h: 64: 8\n" /* wooddoorblock */ + "i: 64: 9\n" /* wooddoorblock */ "m: 19: 0\n" /* sponge */, // Block data: @@ -1349,16 +1365,16 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ "mmmmmaammmmmmm" - /* 1 */ "mmmaa..aammmmm" + /* 1 */ "mmmaaddaammmmm" /* 2 */ "mmaa....aammmm" /* 3 */ "maa......aammm" /* 4 */ "ma........aaac" - /* 5 */ "a............d" - /* 6 */ "a............d" + /* 5 */ "ae........d..f" + /* 6 */ "ae........g..f" /* 7 */ "ma........aaac" /* 8 */ "maa......aammm" /* 9 */ "mmaa....aammmm" - /* 10 */ "mmmaa..aammmmm" + /* 10 */ "mmmaaggaammmmm" /* 11 */ "mmmmmaammmmmmm" // Level 2 @@ -1369,8 +1385,8 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 2 */ "mmbb....bbmmmm" /* 3 */ "mbb......bbmmm" /* 4 */ "mb........bbac" - /* 5 */ "b............e" - /* 6 */ "b............f" + /* 5 */ "b............h" + /* 6 */ "b............i" /* 7 */ "mb........bbac" /* 8 */ "mbb......bbmmm" /* 9 */ "mmbb....bbmmmm" @@ -1455,7 +1471,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = true, // DefaultWeight: - 100, + 200, // DepthWeight: "", @@ -1487,9 +1503,13 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = "c: 20: 0\n" /* glass */ "d: 1: 0\n" /* stone */ "e: 64: 3\n" /* wooddoorblock */ - "f: 64: 0\n" /* wooddoorblock */ - "g: 64: 1\n" /* wooddoorblock */ - "h: 64: 8\n" /* wooddoorblock */ + "f: 76: 1\n" /* redstonetorchon */ + "g: 76: 2\n" /* redstonetorchon */ + "h: 76: 3\n" /* redstonetorchon */ + "i: 64: 0\n" /* wooddoorblock */ + "j: 76: 4\n" /* redstonetorchon */ + "k: 64: 1\n" /* wooddoorblock */ + "l: 64: 8\n" /* wooddoorblock */ "m: 19: 0\n" /* sponge */, // Block data: @@ -1520,40 +1540,40 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 0 */ "mmmmaeeammmmmm" /* 1 */ "mmmmb..bmmmmmm" /* 2 */ "mmmmb..bmmmmmm" - /* 3 */ "mmmbb..bbmmmmm" + /* 3 */ "mmmbbfgbbmmmmm" /* 4 */ "mmbb....bbmmmm" /* 5 */ "mbb......bbmmm" /* 6 */ "mb........bbba" - /* 7 */ "b............f" - /* 8 */ "b............f" + /* 7 */ "bf........h..i" + /* 8 */ "bf........j..i" /* 9 */ "mb........bbba" /* 10 */ "mbb......bbmmm" /* 11 */ "mmbb....bbmmmm" - /* 12 */ "mmmbb..bbmmmmm" + /* 12 */ "mmmbbfgbbmmmmm" /* 13 */ "mmmmb..bmmmmmm" /* 14 */ "mmmmb..bmmmmmm" - /* 15 */ "mmmmaggammmmmm" + /* 15 */ "mmmmakkammmmmm" /* 16 */ "dddddddddddddd" // Level 2 /* z\x* 1111 */ /* * 01234567890123 */ - /* 0 */ "mmmmahhammmmmm" + /* 0 */ "mmmmallammmmmm" /* 1 */ "mmmmb..bmmmmmm" /* 2 */ "mmmmc..cmmmmmm" /* 3 */ "mmmcc..ccmmmmm" /* 4 */ "mmcc....ccmmmm" /* 5 */ "mcc......ccmmm" /* 6 */ "mc........ccba" - /* 7 */ "c............h" - /* 8 */ "c............h" + /* 7 */ "c............l" + /* 8 */ "c............l" /* 9 */ "mc........ccba" /* 10 */ "mcc......ccmmm" /* 11 */ "mmcc....ccmmmm" /* 12 */ "mmmcc..ccmmmmm" /* 13 */ "mmmmc..cmmmmmm" /* 14 */ "mmmmb..bmmmmmm" - /* 15 */ "mmmmahhammmmmm" + /* 15 */ "mmmmallammmmmm" /* 16 */ "dddddddddddddd" // Level 3 @@ -1653,7 +1673,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = true, // DefaultWeight: - 100, + 75, // DepthWeight: "", -- cgit v1.2.3 From 319169eafbbe5630a311051ea5fdf91e7f482a71 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 1 Jun 2014 14:06:47 +0200 Subject: Made a_BlockHitPos a reference --- src/Bindings/Plugin.h | 2 +- src/Bindings/PluginLua.cpp | 4 ++-- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 2 +- src/Bindings/PluginManager.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 3f1e0f0bc..837b1ae13 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -90,7 +90,7 @@ public: virtual bool OnPluginsLoaded (void) = 0; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; - virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d * a_BlockHitPos) = 0; + virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos) = 0; virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) = 0; virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) = 0; virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index da98f3f95..46ee7da9e 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -1108,14 +1108,14 @@ bool cPluginLua::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a -bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d * a_BlockHitPos) +bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos) { cCSLock Lock(m_CriticalSection); bool res = false; cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_BLOCK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos, cLuaState::Return, res); + m_LuaState.Call((int)(**itr), &a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, &a_BlockHitPos, cLuaState::Return, res); if (res) { return true; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 6d0a90654..ec74f07c6 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -113,7 +113,7 @@ public: virtual bool OnPluginsLoaded (void) override; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; - virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d * a_BlockHitPos) override; + virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos) override; virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) override; virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) override; virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 066616c2a..4f528c2ae 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1154,7 +1154,7 @@ bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCrafti -bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d * a_BlockHitPos) +bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos) { HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_BLOCK); if (Plugins == m_Hooks.end()) diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 47aab74e6..6c4e8bae7 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -206,7 +206,7 @@ public: // tolua_export bool CallHookPluginsLoaded (void); bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); - bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d * a_BlockHitPos); + bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos); bool CallHookProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity); bool CallHookSpawnedEntity (cWorld & a_World, cEntity & a_Entity); bool CallHookSpawnedMonster (cWorld & a_World, cMonster & a_Monster); -- cgit v1.2.3 From 476fdc99523c458506416b06d9b939d1e6065364 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 1 Jun 2014 17:05:51 +0100 Subject: Use abort in SIGSEGV and SIGABRT handlers This should cause Mcserver to generate core dumps when it crashes. --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 68eea7f4d..1f458b0c1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -61,7 +61,7 @@ void NonCtrlHandler(int a_Signal) std::signal(SIGSEGV, SIG_DFL); LOGERROR(" D: | MCServer has encountered an error and needs to close"); LOGERROR("Details | SIGSEGV: Segmentation fault"); - exit(EXIT_FAILURE); + abort(EXIT_FAILURE); } case SIGABRT: #ifdef SIGABRT_COMPAT @@ -71,7 +71,7 @@ void NonCtrlHandler(int a_Signal) std::signal(a_Signal, SIG_DFL); LOGERROR(" D: | MCServer has encountered an error and needs to close"); LOGERROR("Details | SIGABRT: Server self-terminated due to an internal fault"); - exit(EXIT_FAILURE); + abort(EXIT_FAILURE); } case SIGINT: case SIGTERM: -- cgit v1.2.3 From 750333855c7d8eeb6993e0bb27a6e505022c8a30 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 1 Jun 2014 17:23:02 +0100 Subject: abort does not take a parameter. --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 1f458b0c1..6925d9ff1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -61,7 +61,7 @@ void NonCtrlHandler(int a_Signal) std::signal(SIGSEGV, SIG_DFL); LOGERROR(" D: | MCServer has encountered an error and needs to close"); LOGERROR("Details | SIGSEGV: Segmentation fault"); - abort(EXIT_FAILURE); + abort(); } case SIGABRT: #ifdef SIGABRT_COMPAT @@ -71,7 +71,7 @@ void NonCtrlHandler(int a_Signal) std::signal(a_Signal, SIG_DFL); LOGERROR(" D: | MCServer has encountered an error and needs to close"); LOGERROR("Details | SIGABRT: Server self-terminated due to an internal fault"); - abort(EXIT_FAILURE); + abort(); } case SIGINT: case SIGTERM: -- cgit v1.2.3 From 576f89c1d5bdb067c0ca06237440f754d80bd13c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 1 Jun 2014 18:46:59 +0100 Subject: Implemented bed homes + Implemented bed home positions * Fixed some inventory and health server/client mismatches after world change --- src/Blocks/BlockBed.cpp | 2 ++ src/Entities/Entity.cpp | 6 ++++++ src/Entities/Player.cpp | 35 ++++++++++++++++++++++------------- src/Entities/Player.h | 15 ++++++++++++--- 4 files changed, 42 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index 07ef997dd..5525f0d0c 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -133,6 +133,8 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); // Where 0x4 = occupied bit a_Player->SetIsInBed(true); + a_Player->SetBedPos(Vector3i(a_BlockX, a_BlockY, a_BlockZ)); + a_Player->SendMessageSuccess("Home position set successfully"); cTimeFastForwardTester Tester; if (a_WorldInterface.ForEachPlayer(Tester)) diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index b5c272cf2..de6c628e9 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1093,6 +1093,12 @@ void cEntity::DetectPortal() File.WriteFile(OverworldName + "/world.ini"); MoveToWorld(OverworldName, cRoot::Get()->CreateAndInitializeWorld(OverworldName)); + + if (IsPlayer()) + { + cPlayer * Player = (cPlayer *)this; + Player->TeleportToCoords(Player->GetLastBedPos().x, Player->GetLastBedPos().y, Player->GetLastBedPos().z); + } break; } case dimOverworld: diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 140b98d5d..3058d6e94 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -82,13 +82,13 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) m_PlayerName = a_PlayerName; - if (!LoadFromDisk()) + cWorld * World; + if (!LoadFromDisk(World)) { m_Inventory.Clear(); - cWorld * DefaultWorld = cRoot::Get()->GetDefaultWorld(); - SetPosX(DefaultWorld->GetSpawnX()); - SetPosY(DefaultWorld->GetSpawnY()); - SetPosZ(DefaultWorld->GetSpawnZ()); + SetPosX(World->GetSpawnX()); + SetPosY(World->GetSpawnY()); + SetPosZ(World->GetSpawnZ()); LOGD("Player \"%s\" is connecting for the first time, spawning at default world spawn {%.2f, %.2f, %.2f}", a_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ() @@ -101,11 +101,6 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) if (m_GameMode == gmNotSet) { - cWorld * World = cRoot::Get()->GetWorld(GetLoadedWorldName()); - if (World == NULL) - { - World = cRoot::Get()->GetDefaultWorld(); - } if (World->IsGameModeCreative()) { m_CanFly = true; @@ -955,7 +950,7 @@ void cPlayer::Respawn(void) // Extinguish the fire: StopBurning(); - TeleportToCoords(GetWorld()->GetSpawnX(), GetWorld()->GetSpawnY(), GetWorld()->GetSpawnZ()); + TeleportToCoords(GetLastBedPos().x, GetLastBedPos().y, GetLastBedPos().z); SetVisible(true); } @@ -1614,6 +1609,8 @@ bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World) if (SendRespawn) { GetClientHandle()->SendPlayerMoveLook(); + GetClientHandle()->SendHealth(); + GetClientHandle()->SendWholeInventory((cWindow &)GetInventory()); } return true; @@ -1662,8 +1659,14 @@ void cPlayer::LoadPermissionsFromDisk() -bool cPlayer::LoadFromDisk() +bool cPlayer::LoadFromDisk(cWorld * a_World) { + a_World = cRoot::Get()->GetWorld(GetLoadedWorldName()); + if (a_World == NULL) + { + a_World = cRoot::Get()->GetDefaultWorld(); + } + LoadPermissionsFromDisk(); // Log player permissions, cause it's what the cool kids do @@ -1724,6 +1727,9 @@ bool cPlayer::LoadFromDisk() m_LifetimeTotalXp = (short) root.get("xpTotal", 0).asInt(); m_CurrentXp = (short) root.get("xpCurrent", 0).asInt(); m_IsFlying = root.get("isflying", 0).asBool(); + m_LastBedPos.x = root.get("SpawnX", a_World->GetSpawnX()).asInt(); + m_LastBedPos.y = root.get("SpawnY", a_World->GetSpawnY()).asInt(); + m_LastBedPos.z = root.get("SpawnZ", a_World->GetSpawnZ()).asInt(); m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt(); @@ -1742,7 +1748,7 @@ bool cPlayer::LoadFromDisk() StatSerializer.Load(); LOGD("Player \"%s\" was read from file, spawning at {%.2f, %.2f, %.2f} in world \"%s\"", - GetName().c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str() + GetName().c_str(), GetPosX(), GetPosY(), GetPosZ(), GetLoadedWorldName().c_str() ); return true; @@ -1784,6 +1790,9 @@ bool cPlayer::SaveToDisk() root["foodExhaustion"] = m_FoodExhaustionLevel; root["world"] = GetWorld()->GetName(); root["isflying"] = IsFlying(); + root["SpawnX"] = GetLastBedPos().x; + root["SpawnY"] = GetLastBedPos().y; + root["SpawnZ"] = GetLastBedPos().z; if (m_GameMode == GetWorld()->GetGameMode()) { diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 582f79b86..5c0b61064 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -331,7 +331,7 @@ public: virtual bool MoveToWorld(const AString & a_WorldName, cWorld * a_World = NULL) override; // tolua_export bool SaveToDisk(void); - bool LoadFromDisk(void); + bool LoadFromDisk(cWorld * a_World); void LoadPermissionsFromDisk(void); // tolua_export const AString & GetLoadedWorldName() { return m_LoadedWorldName; } @@ -391,11 +391,19 @@ public: /** If true the player can fly even when he's not in creative. */ void SetCanFly(bool a_CanFly); + /** Gets the last position that the player slept in */ + Vector3i GetLastBedPos(void) const { return m_LastBedPos; } + + /** Sets the player's bed (home) position */ + void SetBedPos(const Vector3i & a_Pos) { m_LastBedPos = a_Pos; } + /** Update movement-related statistics. */ void UpdateMovementStats(const Vector3d & a_DeltaPos); /** Returns wheter the player can fly or not. */ virtual bool CanFly(void) const { return m_CanFly; } + + // tolua_end // cEntity overrides: @@ -450,6 +458,9 @@ protected: cWindow * m_CurrentWindow; cWindow * m_InventoryWindow; + /** The player's last saved bed position */ + Vector3i m_LastBedPos; + char m_Color; eGameMode m_GameMode; @@ -508,8 +519,6 @@ protected: cStatManager m_Stats; - - void ResolvePermissions(void); void ResolveGroups(void); -- cgit v1.2.3 From a84f107400a326b0be27c290359220b8bf0e6635 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 1 Jun 2014 20:00:11 +0100 Subject: Suggestions two --- src/Blocks/BlockPiston.cpp | 6 +++--- src/Chunk.cpp | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index 1f8e0d9e0..faf639312 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -76,15 +76,15 @@ bool cBlockPistonHandler::GetPlacementBlockTypeMeta( -int cBlockPistonHandler::FirstPassthroughBlock(int pistonX, int pistonY, int pistonZ, NIBBLETYPE pistonmeta, cWorld * a_World) +int cBlockPistonHandler::FirstPassthroughBlock(int a_PistonX, int a_PistonY, int a_PistonZ, NIBBLETYPE pistonmeta, cWorld * a_World) { // Examine each of the 12 blocks ahead of the piston: for (int ret = 0; ret < PISTON_MAX_PUSH_DISTANCE; ret++) { BLOCKTYPE currBlock; NIBBLETYPE currMeta; - AddPistonDir(pistonX, pistonY, pistonZ, pistonmeta, 1); - a_World->GetBlockTypeMeta(pistonX, pistonY, pistonZ, currBlock, currMeta); + AddPistonDir(a_PistonX, a_PistonY, a_PistonZ, pistonmeta, 1); + a_World->GetBlockTypeMeta(a_PistonX, a_PistonY, a_PistonZ, currBlock, currMeta); if (CanBreakPush(currBlock)) { // This block breaks when pushed, extend up to here diff --git a/src/Chunk.cpp b/src/Chunk.cpp index fbd0a5846..6dce29e68 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1589,13 +1589,15 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT if ( // Queue block to be sent only if ... a_SendToClients && // ... we are told to do so AND ... - ((OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ... - !( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them); see below for specifics: - ((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water - ((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water - ((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water - ((OldBlockType == E_BLOCK_LAVA) && (a_BlockType == E_BLOCK_STATIONARY_LAVA)) // Replacing water with stationary water - )) + ( + (OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ... + !( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them); see below for specifics: + ((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water + ((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water + ((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water + ((OldBlockType == E_BLOCK_LAVA) && (a_BlockType == E_BLOCK_STATIONARY_LAVA)) // Replacing water with stationary water + ) + ) ) { m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta)); -- cgit v1.2.3 From 23b08231086ad1edb373811ae4f93d07a60401ad Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 1 Jun 2014 22:02:58 +0200 Subject: Update UnderwaterBase prefabs. Added the waterfall room and the decaying sphere room. Re-tweaked the pieces' weights. --- src/Generating/Prefabs/UnderwaterBasePrefabs.cpp | 390 ++++++++++++++++++++++- 1 file changed, 378 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp index a20ff9e26..39748a223 100644 --- a/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp +++ b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp @@ -15,6 +15,169 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = { + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // BrokenRoom: + // The data has been exported from the gallery Water, area index 49, ID 680, created by STR_Warrior + { + // Size: + 14, 7, 12, // SizeX = 14, SizeY = 7, SizeZ = 12 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 13, 6, 11, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 0\n" /* wood */ + "b: 20: 0\n" /* glass */ + "c: 5: 5\n" /* wood */ + "d: 8: 0\n" /* water */ + "e: 64: 4\n" /* wooddoorblock */ + "f: 64:12\n" /* wooddoorblock */ + "g: 64:13\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmaaaammmmmm" + /* 2 */ "mmmaabbaammmmm" + /* 3 */ "mmaabbbbaammmm" + /* 4 */ "maabbbbbbaammm" + /* 5 */ "mabbbbbbbbaaac" + /* 6 */ "mabbbbbbbbaaac" + /* 7 */ "maabbbbbbaammm" + /* 8 */ "mmaabbbbaammmm" + /* 9 */ "mmmaabbaammmmm" + /* 10 */ "mmmmaaaammmmmm" + /* 11 */ "mmmmmmmmmmmmmm" + + // Level 1 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmaammmmmmm" + /* 1 */ "mmmaaddaammmmm" + /* 2 */ "mmaaddddaammmm" + /* 3 */ "maaddddddaammm" + /* 4 */ "maddddddddaaac" + /* 5 */ "adddddddddddde" + /* 6 */ "adddddddddddde" + /* 7 */ "maddddddddaaac" + /* 8 */ "maaddddddaammm" + /* 9 */ "mmaaddddaammmm" + /* 10 */ "mmmaaddaammmmm" + /* 11 */ "mmmmmaammmmmmm" + + // Level 2 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmbbmmmmmmm" + /* 1 */ "mmmbb..bbmmmmm" + /* 2 */ "mmbb....bbmmmm" + /* 3 */ "mbb......bbmmm" + /* 4 */ "mb........bbac" + /* 5 */ "b............f" + /* 6 */ "b............g" + /* 7 */ "mb........bbac" + /* 8 */ "mbb......bbmmm" + /* 9 */ "mmbb....bbmmmm" + /* 10 */ "mmmbb..bbmmmmm" + /* 11 */ "mmmmmbbmmmmmmm" + + // Level 3 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmbbmmmmmmm" + /* 1 */ "mmmbb..bbmmmmm" + /* 2 */ "mmbb....bbmmmm" + /* 3 */ "mbb......bbmmm" + /* 4 */ "mb........bbac" + /* 5 */ "b..........bac" + /* 6 */ "b..........bac" + /* 7 */ "mb........bbac" + /* 8 */ "mbb......bbmmm" + /* 9 */ "mmbb....bbmmmm" + /* 10 */ "mmmbb..bbmmmmm" + /* 11 */ "mmmmmbbmmmmmmm" + + // Level 4 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmm.bmmmmmmm" + /* 2 */ "mmmmb..bmmmmmm" + /* 3 */ "mmmb....bmmmmm" + /* 4 */ "mmb......bmmmm" + /* 5 */ "m.........bmmm" + /* 6 */ "mb........bmmm" + /* 7 */ "mmb......bmmmm" + /* 8 */ "mmm.....bmmmmm" + /* 9 */ "mmmmb..bmmmmmm" + /* 10 */ "mmmmmbbmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmm" + + // Level 5 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmm" + /* 2 */ "mmmmmbbmmmmmmm" + /* 3 */ "mmmm....mmmmmm" + /* 4 */ "mmmb....bmmmmm" + /* 5 */ "mmb......bmmmm" + /* 6 */ "mmb......bmmmm" + /* 7 */ "mmmb.....mmmmm" + /* 8 */ "mmmmb..bmmmmmm" + /* 9 */ "mmmmmbbmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmm" + + // Level 6 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "mmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmm" + /* 3 */ "mmmmmbbmmmmmmm" + /* 4 */ "mmmmbbbbmmmmmm" + /* 5 */ "mmmbbbbbbmmmmm" + /* 6 */ "mmmbb.bbbmmmmm" + /* 7 */ "mmmmbbbbmmmmmm" + /* 8 */ "mmmmmbbmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmm", + + // Connectors: + "1: 13, 1, 6: 5\n" /* Type 1, direction X+ */ + "-1: 13, 1, 5: 5\n" /* Type -1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // BrokenRoom + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Corridor16: // The data has been exported from the gallery Water, area index 25, ID 566, created by xoft @@ -88,7 +251,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = true, // DefaultWeight: - 2000, + 500, // DepthWeight: "", @@ -722,7 +885,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 5 */ "mb........bmmm" /* 6 */ "mb........bmmm" /* 7 */ "mmb......bmmmm" - /* 8 */ "mmmbb...bmmmmm" + /* 8 */ "mmmb....bmmmmm" /* 9 */ "mmmmb..bmmmmmm" /* 10 */ "mmmmmbbmmmmmmm" /* 11 */ "mmmmmmmmmmmmmm" @@ -740,7 +903,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 5 */ "mmb......bmmmm" /* 6 */ "mmb......bmmmm" /* 7 */ "mmmb....bmmmmm" - /* 8 */ "mmmmb.bbmmmmmm" + /* 8 */ "mmmmb..bmmmmmm" /* 9 */ "mmmmmbbmmmmmmm" /* 10 */ "mmmmmmmmmmmmmm" /* 11 */ "mmmmmmmmmmmmmm" @@ -1020,7 +1183,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 7 */ "mc........cm" /* 8 */ "mc........cm" /* 9 */ "mmc......cmm" - /* 10 */ "mmmcc...cmmm" + /* 10 */ "mmmc....cmmm" /* 11 */ "mmmmc..cmmmm" /* 12 */ "mmmmmccmmmmm" /* 13 */ "mmmmmmmmmmmm" @@ -1040,7 +1203,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 7 */ "mmc......cmm" /* 8 */ "mmc......cmm" /* 9 */ "mmmc....cmmm" - /* 10 */ "mmmmc.ccmmmm" + /* 10 */ "mmmmc..cmmmm" /* 11 */ "mmmmmccmmmmm" /* 12 */ "mmmmmmmmmmmm" /* 13 */ "mmmmmmmmmmmm" @@ -1239,7 +1402,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 7 */ "mmmc........cmmm" /* 8 */ "mmmc........cmmm" /* 9 */ "mmmmc......cmmmm" - /* 10 */ "mmmmmcc...cmmmmm" + /* 10 */ "mmmmmc....cmmmmm" /* 11 */ "mmmmmmc..cmmmmmm" /* 12 */ "mmmmmmmccmmmmmmm" /* 13 */ "mmmmmmmmmmmmmmmm" @@ -1259,7 +1422,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 7 */ "mmmmc......cmmmm" /* 8 */ "mmmmc......cmmmm" /* 9 */ "mmmmmc....cmmmmm" - /* 10 */ "mmmmmmc.ccmmmmmm" + /* 10 */ "mmmmmmc..cmmmmmm" /* 11 */ "mmmmmmmccmmmmmmm" /* 12 */ "mmmmmmmmmmmmmmmm" /* 13 */ "mmmmmmmmmmmmmmmm" @@ -1420,7 +1583,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 5 */ "mb........bmmm" /* 6 */ "mb........bmmm" /* 7 */ "mmb......bmmmm" - /* 8 */ "mmmbb...bmmmmm" + /* 8 */ "mmmb....bmmmmm" /* 9 */ "mmmmb..bmmmmmm" /* 10 */ "mmmmmbbmmmmmmm" /* 11 */ "mmmmmmmmmmmmmm" @@ -1436,7 +1599,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 5 */ "mmb......bmmmm" /* 6 */ "mmb......bmmmm" /* 7 */ "mmmb....bmmmmm" - /* 8 */ "mmmmb.bbmmmmmm" + /* 8 */ "mmmmb..bmmmmmm" /* 9 */ "mmmmmbbmmmmmmm" /* 10 */ "mmmmmmmmmmmmmm" /* 11 */ "mmmmmmmmmmmmmm" @@ -1610,7 +1773,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 7 */ "mc........cmmm" /* 8 */ "mc........cmmm" /* 9 */ "mmc......cmmmm" - /* 10 */ "mmmcc...cmmmmm" + /* 10 */ "mmmc....cmmmmm" /* 11 */ "mmmmc..cmmmmmm" /* 12 */ "mmmmmccmmmmmmm" /* 13 */ "mmmmmmmmmmmmmm" @@ -1631,7 +1794,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = /* 7 */ "mmc......cmmmm" /* 8 */ "mmc......cmmmm" /* 9 */ "mmmc....cmmmmm" - /* 10 */ "mmmmc.ccmmmmmm" + /* 10 */ "mmmmc..cmmmmmm" /* 11 */ "mmmmmccmmmmmmm" /* 12 */ "mmmmmmmmmmmmmm" /* 13 */ "mmmmmmmmmmmmmm" @@ -1684,6 +1847,209 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = // MoveToGround: false, }, // ViewingTee + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // WaterfallRoom: + // The data has been exported from the gallery Water, area index 50, ID 681, created by Aloe_vera + { + // Size: + 16, 7, 16, // SizeX = 16, SizeY = 7, SizeZ = 16 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 15, 6, 15, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 5: 5\n" /* wood */ + "b: 5: 0\n" /* wood */ + "c: 20: 0\n" /* glass */ + "d: 64: 3\n" /* wooddoorblock */ + "e: 76: 1\n" /* redstonetorchon */ + "f: 76: 2\n" /* redstonetorchon */ + "g: 64: 2\n" /* wooddoorblock */ + "h: 76: 3\n" /* redstonetorchon */ + "i: 64: 0\n" /* wooddoorblock */ + "j: 76: 4\n" /* redstonetorchon */ + "k: 64: 1\n" /* wooddoorblock */ + "l: 64: 8\n" /* wooddoorblock */ + "m: 19: 0\n" /* sponge */ + "n: 64: 9\n" /* wooddoorblock */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmaammmmmmm" + /* 1 */ "mmmmmmmbbmmmmmmm" + /* 2 */ "mmmmmmmbbmmmmmmm" + /* 3 */ "mmmmmmbbbbmmmmmm" + /* 4 */ "mmmmmbbccbbmmmmm" + /* 5 */ "mmmmbbccccbbmmmm" + /* 6 */ "mmmbbccccccbbmmm" + /* 7 */ "abbbcccmmcccbbba" + /* 8 */ "abbbcccmmcccbbba" + /* 9 */ "mmmbbccccccbbmmm" + /* 10 */ "mmmmbbccccbbmmmm" + /* 11 */ "mmmmmbbccbbmmmmm" + /* 12 */ "mmmmmmbbbbmmmmmm" + /* 13 */ "mmmmmmmbbmmmmmmm" + /* 14 */ "mmmmmmmbbmmmmmmm" + /* 15 */ "mmmmmmmaammmmmmm" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmaddammmmmm" + /* 1 */ "mmmmmmb..bmmmmmm" + /* 2 */ "mmmmmmb..bmmmmmm" + /* 3 */ "mmmmmbbefbbmmmmm" + /* 4 */ "mmmmbb....bbmmmm" + /* 5 */ "mmmbb......bbmmm" + /* 6 */ "abbb...cc...bbba" + /* 7 */ "g..h..c..c..h..i" + /* 8 */ "g..j..c..c..j..i" + /* 9 */ "abbb...cc...bbba" + /* 10 */ "mmmbb......bbmmm" + /* 11 */ "mmmmbb....bbmmmm" + /* 12 */ "mmmmmbbefbbmmmmm" + /* 13 */ "mmmmmmb..bmmmmmm" + /* 14 */ "mmmmmmb..bmmmmmm" + /* 15 */ "mmmmmmakkammmmmm" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmalnammmmmm" + /* 1 */ "mmmmmmb..bmmmmmm" + /* 2 */ "mmmmmmc..cmmmmmm" + /* 3 */ "mmmmmcc..ccmmmmm" + /* 4 */ "mmmmcc....ccmmmm" + /* 5 */ "mmmcc......ccmmm" + /* 6 */ "abcc........ccba" + /* 7 */ "n..............l" + /* 8 */ "l..............n" + /* 9 */ "abcc........ccba" + /* 10 */ "mmmcc......ccmmm" + /* 11 */ "mmmmcc....ccmmmm" + /* 12 */ "mmmmmcc..ccmmmmm" + /* 13 */ "mmmmmmc..cmmmmmm" + /* 14 */ "mmmmmmb..bmmmmmm" + /* 15 */ "mmmmmmanlammmmmm" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmaaaammmmmm" + /* 1 */ "mmmmmmbbbbmmmmmm" + /* 2 */ "mmmmmmccccmmmmmm" + /* 3 */ "mmmmmcc..ccmmmmm" + /* 4 */ "mmmmcc....ccmmmm" + /* 5 */ "mmmcc......ccmmm" + /* 6 */ "abcc........ccba" + /* 7 */ "abc..........cba" + /* 8 */ "abc..........cba" + /* 9 */ "abcc........ccba" + /* 10 */ "mmmcc......ccmmm" + /* 11 */ "mmmmcc....ccmmmm" + /* 12 */ "mmmmmcc..ccmmmmm" + /* 13 */ "mmmmmmccccmmmmmm" + /* 14 */ "mmmmmmbbbbmmmmmm" + /* 15 */ "mmmmmmaaaammmmmm" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmmmm" + /* 3 */ "mmmmmmmccmmmmmmm" + /* 4 */ "mmmmm.c..cmmmmmm" + /* 5 */ "mmmmmc....cmmmmm" + /* 6 */ "mmmmc......cmmmm" + /* 7 */ "mmmc........cmmm" + /* 8 */ "mmmc........cmmm" + /* 9 */ "mmmmc......cmmmm" + /* 10 */ "mmmmmc....cmmmmm" + /* 11 */ "mmmmmmc..cmmmmmm" + /* 12 */ "mmmmmmmccmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmmmm" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmmmmmmm" + /* 4 */ "mmmmmm.ccmmmmmmm" + /* 5 */ "mmmmmmc..cmmmmmm" + /* 6 */ "mmmmmc....cmmmmm" + /* 7 */ "mmmmc......cmmmm" + /* 8 */ "mmmmc......cmmmm" + /* 9 */ "mmmmmc....cmmmmm" + /* 10 */ "mmmmmmc..cmmmmmm" + /* 11 */ "mmmmmmmccmmmmmmm" + /* 12 */ "mmmmmmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmmmm" + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "mmmmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmmmmmmm" + /* 4 */ "mmmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmccmmmmmmm" + /* 6 */ "mmmmmmccccmmmmmm" + /* 7 */ "mmmmmcc..ccmmmmm" + /* 8 */ "mmmmmcc..ccmmmmm" + /* 9 */ "mmmmmmccccmmmmmm" + /* 10 */ "mmmmmmmccmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmmm" + /* 12 */ "mmmmmmmmmmmmmmmm" + /* 13 */ "mmmmmmmmmmmmmmmm" + /* 14 */ "mmmmmmmmmmmmmmmm" + /* 15 */ "mmmmmmmmmmmmmmmm", + + // Connectors: + "1: 15, 1, 8: 5\n" /* Type 1, direction X+ */ + "-1: 15, 1, 7: 5\n" /* Type -1, direction X+ */ + "1: 8, 1, 0: 2\n" /* Type 1, direction Z- */ + "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */ + "1: 0, 1, 7: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 8: 4\n" /* Type -1, direction X- */ + "1: 7, 1, 15: 3\n" /* Type 1, direction Z+ */ + "-1: 8, 1, 15: 3\n" /* Type -1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 5, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // WaterfallRoom }; // g_UnderwaterBasePrefabs @@ -1773,7 +2139,7 @@ const cPrefab::sDef g_UnderwaterBaseStartingPrefabs[] = /* 4 */ "mmmmcc....ccmmmm" /* 5 */ "mmmcc......ccmmm" /* 6 */ "abbc........cbba" - /* 7 */ "h..............h" + /* 7 */ "i..............h" /* 8 */ "h..............i" /* 9 */ "abbc........cbba" /* 10 */ "mmmcc......ccmmm" -- cgit v1.2.3 From b7dc4177d0cf7677b3e74f5a9bb89277df2b2ebd Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 2 Jun 2014 14:07:18 +0200 Subject: cBlockArea reading hotfix. This should fix the crashes introduced with chunksparsing. Not the most performant solution, but at least it should work. Ref.: #1056 --- src/BlockArea.cpp | 172 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 109 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 40fdd68c0..e3a859e4f 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -1835,87 +1835,133 @@ bool cBlockArea::cChunkReader::Coords(int a_ChunkX, int a_ChunkZ) -void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer) +void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer) { + int SizeY = m_Area.m_Size.y; + int MinY = m_Origin.y; + + // SizeX, SizeZ are the dimensions of the block data to copy from the current chunk (size of the geometric union) + // OffX, OffZ are the offsets of the current chunk data from the area origin + // BaseX, BaseZ are the offsets of the area data within the current chunk from the chunk borders + int SizeX = cChunkDef::Width; + int SizeZ = cChunkDef::Width; + int OffX, OffZ; + int BaseX, BaseZ; + OffX = m_CurrentChunkX * cChunkDef::Width - m_Origin.x; + if (OffX < 0) { - if (m_Area.m_BlockTypes != NULL) - { - int SizeY = m_Area.m_Size.y; - int MinY = m_Origin.y; + BaseX = -OffX; + SizeX += OffX; // SizeX is decreased, OffX is negative + OffX = 0; + } + else + { + BaseX = 0; + } + OffZ = m_CurrentChunkZ * cChunkDef::Width - m_Origin.z; + if (OffZ < 0) + { + BaseZ = -OffZ; + SizeZ += OffZ; // SizeZ is decreased, OffZ is negative + OffZ = 0; + } + else + { + BaseZ = 0; + } + // If the chunk extends beyond the area in the X or Z axis, cut off the Size: + if ((m_CurrentChunkX + 1) * cChunkDef::Width > m_Origin.x + m_Area.m_Size.x) + { + SizeX -= (m_CurrentChunkX + 1) * cChunkDef::Width - (m_Origin.x + m_Area.m_Size.x); + } + if ((m_CurrentChunkZ + 1) * cChunkDef::Width > m_Origin.z + m_Area.m_Size.z) + { + SizeZ -= (m_CurrentChunkZ + 1) * cChunkDef::Width - (m_Origin.z + m_Area.m_Size.z); + } - // SizeX, SizeZ are the dimensions of the block data to copy from the current chunk (size of the geometric union) - // OffX, OffZ are the offsets of the current chunk data from the area origin - // BaseX, BaseZ are the offsets of the area data within the current chunk from the chunk borders - int SizeX = cChunkDef::Width; - int SizeZ = cChunkDef::Width; - int OffX, OffZ; - int BaseX, BaseZ; - OffX = m_CurrentChunkX * cChunkDef::Width - m_Origin.x; - if (OffX < 0) - { - BaseX = -OffX; - SizeX += OffX; // SizeX is decreased, OffX is negative - OffX = 0; - } - else - { - BaseX = 0; - } - OffZ = m_CurrentChunkZ * cChunkDef::Width - m_Origin.z; - if (OffZ < 0) - { - BaseZ = -OffZ; - SizeZ += OffZ; // SizeZ is decreased, OffZ is negative - OffZ = 0; - } - else - { - BaseZ = 0; - } - // If the chunk extends beyond the area in the X or Z axis, cut off the Size: - if ((m_CurrentChunkX + 1) * cChunkDef::Width > m_Origin.x + m_Area.m_Size.x) - { - SizeX -= (m_CurrentChunkX + 1) * cChunkDef::Width - (m_Origin.x + m_Area.m_Size.x); - } - if ((m_CurrentChunkZ + 1) * cChunkDef::Width > m_Origin.z + m_Area.m_Size.z) - { - SizeZ -= (m_CurrentChunkZ + 1) * cChunkDef::Width - (m_Origin.z + m_Area.m_Size.z); - } - - for (int y = 0; y < SizeY; y++) + // Copy the blocktypes: + if (m_Area.m_BlockTypes != NULL) + { + for (int y = 0; y < SizeY; y++) + { + int InChunkY = MinY + y; + int AreaY = y; + for (int z = 0; z < SizeZ; z++) { - int ChunkY = MinY + y; - int AreaY = y; - for (int z = 0; z < SizeZ; z++) + int InChunkZ = BaseZ + z; + int AreaZ = OffZ + z; + for (int x = 0; x < SizeX; x++) { - int ChunkZ = BaseZ + z; - int AreaZ = OffZ + z; - for (int x = 0; x < SizeX; x++) - { - int ChunkX = BaseX + x; - int AreaX = OffX + x; - m_Area.m_BlockTypes[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = a_BlockBuffer.GetBlock(ChunkX, ChunkY, ChunkZ); - } // for x - } // for z - } // for y - } + int InChunkX = BaseX + x; + int AreaX = OffX + x; + m_Area.m_BlockTypes[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = a_BlockBuffer.GetBlock(InChunkX, InChunkY, InChunkZ); + } // for x + } // for z + } // for y } + // Copy the block metas: if (m_Area.m_BlockMetas != NULL) { - a_BlockBuffer.CopyMetas(m_Area.m_BlockMetas); + for (int y = 0; y < SizeY; y++) + { + int InChunkY = MinY + y; + int AreaY = y; + for (int z = 0; z < SizeZ; z++) + { + int InChunkZ = BaseZ + z; + int AreaZ = OffZ + z; + for (int x = 0; x < SizeX; x++) + { + int InChunkX = BaseX + x; + int AreaX = OffX + x; + m_Area.m_BlockMetas[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = a_BlockBuffer.GetMeta(InChunkX, InChunkY, InChunkZ); + } // for x + } // for z + } // for y } + // Copy the blocklight: if (m_Area.m_BlockLight != NULL) { - a_BlockBuffer.CopyBlockLight(m_Area.m_BlockLight); + for (int y = 0; y < SizeY; y++) + { + int InChunkY = MinY + y; + int AreaY = y; + for (int z = 0; z < SizeZ; z++) + { + int InChunkZ = BaseZ + z; + int AreaZ = OffZ + z; + for (int x = 0; x < SizeX; x++) + { + int InChunkX = BaseX + x; + int AreaX = OffX + x; + m_Area.m_BlockLight[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = a_BlockBuffer.GetBlockLight(InChunkX, InChunkY, InChunkZ); + } // for x + } // for z + } // for y } + // Copy the skylight: if (m_Area.m_BlockSkyLight != NULL) { - a_BlockBuffer.CopySkyLight(m_Area.m_BlockSkyLight); + for (int y = 0; y < SizeY; y++) + { + int InChunkY = MinY + y; + int AreaY = y; + for (int z = 0; z < SizeZ; z++) + { + int InChunkZ = BaseZ + z; + int AreaZ = OffZ + z; + for (int x = 0; x < SizeX; x++) + { + int InChunkX = BaseX + x; + int AreaX = OffX + x; + m_Area.m_BlockSkyLight[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = a_BlockBuffer.GetSkyLight(InChunkX, InChunkY, InChunkZ); + } // for x + } // for z + } // for y } - } -- cgit v1.2.3 From b9ca7bd1203f704d4f9d6215d72728d40a187b7c Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 2 Jun 2014 14:16:36 +0200 Subject: Small tweak for mobs Mobs move a bit smoother and aren't able to move allot when in air. --- src/Mobs/Monster.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index a9ca7a2fa..5843ca5a6 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -301,7 +301,7 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) if (DoesPosYRequireJump((int)floor(m_Destination.y))) { m_bOnGround = false; - AddPosY(1.5); // Jump!! + AddSpeedY(5.2); // Jump!! } } @@ -310,9 +310,19 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) { Distance.y = 0; Distance.Normalize(); - Distance *= 5; - SetSpeedX(Distance.x); - SetSpeedZ(Distance.z); + + if (m_bOnGround) + { + Distance *= 2.5; + } + else + { + // Don't let the mob move too much if he's falling. + Distance *= 0.25; + } + + AddSpeedX(Distance.x); + AddSpeedZ(Distance.z); if (m_EMState == ESCAPING) { //Runs Faster when escaping :D otherwise they just walk away -- cgit v1.2.3 From 545478802b7a8b81ecb9d20ad3355eff1427f575 Mon Sep 17 00:00:00 2001 From: Joannis Date: Tue, 3 Jun 2014 09:26:14 +0200 Subject: - Added doxy comments and exported to lua - Manipulation of the ShootVector is not to be done by the function that wants to spawn a projectile. --- src/BlockEntities/DispenserEntity.cpp | 74 +++++++++++++++++++++++++++-------- src/BlockEntities/DispenserEntity.h | 12 +++--- 2 files changed, 64 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index db1b405cd..043a140e3 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -146,7 +146,18 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_FIRE_CHARGE: { - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFireCharge); + if(Meta == E_META_DROPSPENSER_FACING_YP || Meta == E_META_DROPSPENSER_FACING_YM) + { + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFireCharge, GetShootVector(a_Chunk) * 20); + } + else + { + Vector3d ShootVector = GetShootVector(a_Chunk); + ShootVector = ShootVector * 20; + + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFireCharge, ShootVector); + } + m_Contents.ChangeSlotCount(a_SlotNum, -1); break; @@ -154,7 +165,19 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_ARROW: { - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkArrow); + if(Meta == E_META_DROPSPENSER_FACING_YP || Meta == E_META_DROPSPENSER_FACING_YM) + { + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkArrow, GetShootVector(a_Chunk) * 20); + } + else + { + Vector3d ShootVector = GetShootVector(a_Chunk); + ShootVector = ShootVector * 20; + ShootVector.y = ShootVector.y + 1; + + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkArrow, ShootVector); + } + m_Contents.ChangeSlotCount(a_SlotNum, -1); break; @@ -162,8 +185,19 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_SNOWBALL: { - // Not working as there is no such entity yet? - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkSnowball); + if(Meta == E_META_DROPSPENSER_FACING_YP || Meta == E_META_DROPSPENSER_FACING_YM) + { + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkSnowball, GetShootVector(a_Chunk) * 20); + } + else + { + Vector3d ShootVector = GetShootVector(a_Chunk); + ShootVector = ShootVector * 20; + ShootVector.y = ShootVector.y + 1; + + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkSnowball, ShootVector); + } + m_Contents.ChangeSlotCount(a_SlotNum, -1); break; @@ -171,8 +205,19 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_EGG: { - // Not working as there is no such entity yet? - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkEgg); + if(Meta == E_META_DROPSPENSER_FACING_YP || Meta == E_META_DROPSPENSER_FACING_YM) + { + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkEgg, GetShootVector(a_Chunk) * 20); + } + else + { + Vector3d ShootVector = GetShootVector(a_Chunk); + ShootVector = ShootVector * 20; + ShootVector.y = ShootVector.y + 1; + + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkEgg, ShootVector); + } + m_Contents.ChangeSlotCount(a_SlotNum, -1); break; @@ -180,7 +225,8 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_FIREWORK_ROCKET: { - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFirework); + SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFirework, GetShootVector(a_Chunk) * 0); + m_Contents.ChangeSlotCount(a_SlotNum, -1); break; @@ -196,15 +242,14 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) -void cDispenserEntity::SpawnProjectileFromDispenser(cChunk & a_Chunk, int & a_DispX, int & a_DispY, int & a_DispZ, cProjectileEntity::eKind a_kind) +void cDispenserEntity::SpawnProjectileFromDispenser(cChunk & a_Chunk, int & a_DispX, int & a_DispY, int & a_DispZ, cProjectileEntity::eKind a_kind, Vector3d a_ShootVector) { - Vector3d Angle = GetShootVector(a_Chunk); cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(a_DispX, a_DispZ); double EntityX = 0.5 + (a_DispX + DispChunk->GetPosX() * cChunkDef::Width); double EntityZ = 0.5 + (a_DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - m_World->CreateProjectile((double) EntityX, (double) a_DispY + 0.5, (double) EntityZ, a_kind, NULL, NULL, &Angle); + m_World->CreateProjectile((double) EntityX, (double) a_DispY + 0.5, (double) EntityZ, a_kind, NULL, NULL, &a_ShootVector); } @@ -223,7 +268,7 @@ Vector3d cDispenserEntity::GetShootVector(cChunk & a_Chunk) m.Init(Vector3d(), 0, 180, 0); Look = m.Transform(Vector3d(0, 1, 0)); - return Look * 20; // UP + return Look; // UP } case E_META_DROPSPENSER_FACING_YM: @@ -231,7 +276,7 @@ Vector3d cDispenserEntity::GetShootVector(cChunk & a_Chunk) m.Init(Vector3d(), 0, -360, 0); Look = m.Transform(Vector3d(0, -1, 0)); - return Look * 20;; // DOWN + return Look; // DOWN } case E_META_DROPSPENSER_FACING_XM: Direction = 90; break; // WEST @@ -243,10 +288,7 @@ Vector3d cDispenserEntity::GetShootVector(cChunk & a_Chunk) m.Init(Vector3d(), 0, Direction, 0); Look = m.Transform(Vector3d(0, 0, 1)); - Vector3d Angle = Look * 20; - Angle.y = Angle.y + 1; - - return Angle; + return Look; } diff --git a/src/BlockEntities/DispenserEntity.h b/src/BlockEntities/DispenserEntity.h index adbe2070c..558cf41c5 100644 --- a/src/BlockEntities/DispenserEntity.h +++ b/src/BlockEntities/DispenserEntity.h @@ -22,6 +22,12 @@ public: static const char * GetClassStatic(void) { return "cDispenserEntity"; } + /** Spawns a projectile of the given kind in front of the dispenser */ + void SpawnProjectileFromDispenser(cChunk & a_Chunk, int & a_DispX, int & a_DispY, int & a_DispZ, cProjectileEntity::eKind a_kind, Vector3d a_ShootVector); // tolua_export + + /** Returns how to aim the projectile */ + Vector3d GetShootVector(cChunk & a_Chunk); // tolua_export + private: // cDropSpenser overrides: virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) override; @@ -29,12 +35,6 @@ private: /// If such a bucket can fit, adds it to m_Contents and returns true bool ScoopUpLiquid(int a_SlotNum, short a_BucketItemType); - // Spawns a projectile of the given kind in front of the dispenser - void SpawnProjectileFromDispenser(cChunk & a_Chunk, int & a_DispX, int & a_DispY, int & a_DispZ, cProjectileEntity::eKind a_kind); - - // Returns how to aim the projectile - Vector3d GetShootVector(cChunk & a_Chunk); - /// If the a_BlockInFront is liquidable and the empty bucket can fit, does the m_Contents processing and returns true bool EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum); } ; // tolua_export -- cgit v1.2.3 From daae75b30b7d5e70a26e1518cd7c75988dbfdf9f Mon Sep 17 00:00:00 2001 From: JoannisO Date: Tue, 3 Jun 2014 17:21:38 +0200 Subject: - Cleaned up the code massively - Stopped using cChunk in the GetShootVector class. Parameter is now the Metadata of the block - Stopped using cChunk in the SpawnProjectileFromDispenser method now using coordinates and finding the chunk by itself. - Removed the matrix calculations from GetShootVector. --- src/BlockEntities/DispenserEntity.cpp | 113 +++++++++------------------------- src/BlockEntities/DispenserEntity.h | 8 +-- 2 files changed, 31 insertions(+), 90 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 043a140e3..2ac7c085c 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -146,17 +146,11 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_FIRE_CHARGE: { - if(Meta == E_META_DROPSPENSER_FACING_YP || Meta == E_META_DROPSPENSER_FACING_YM) - { - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFireCharge, GetShootVector(a_Chunk) * 20); - } - else - { - Vector3d ShootVector = GetShootVector(a_Chunk); - ShootVector = ShootVector * 20; + cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ); + int BlockX = (DispX + DispChunk->GetPosX() * cChunkDef::Width); + int BlockZ = (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFireCharge, ShootVector); - } + SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkFireCharge, GetShootVector(Meta) * 20); m_Contents.ChangeSlotCount(a_SlotNum, -1); @@ -165,18 +159,11 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_ARROW: { - if(Meta == E_META_DROPSPENSER_FACING_YP || Meta == E_META_DROPSPENSER_FACING_YM) - { - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkArrow, GetShootVector(a_Chunk) * 20); - } - else - { - Vector3d ShootVector = GetShootVector(a_Chunk); - ShootVector = ShootVector * 20; - ShootVector.y = ShootVector.y + 1; + cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ); + int BlockX = (DispX + DispChunk->GetPosX() * cChunkDef::Width); + int BlockZ = (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkArrow, ShootVector); - } + SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkArrow, GetShootVector(Meta) * 20); m_Contents.ChangeSlotCount(a_SlotNum, -1); @@ -185,18 +172,11 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_SNOWBALL: { - if(Meta == E_META_DROPSPENSER_FACING_YP || Meta == E_META_DROPSPENSER_FACING_YM) - { - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkSnowball, GetShootVector(a_Chunk) * 20); - } - else - { - Vector3d ShootVector = GetShootVector(a_Chunk); - ShootVector = ShootVector * 20; - ShootVector.y = ShootVector.y + 1; + cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ); + int BlockX = (DispX + DispChunk->GetPosX() * cChunkDef::Width); + int BlockZ = (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkSnowball, ShootVector); - } + SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkSnowball, GetShootVector(Meta) * 20); m_Contents.ChangeSlotCount(a_SlotNum, -1); @@ -205,27 +185,18 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_EGG: { - if(Meta == E_META_DROPSPENSER_FACING_YP || Meta == E_META_DROPSPENSER_FACING_YM) - { - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkEgg, GetShootVector(a_Chunk) * 20); - } - else - { - Vector3d ShootVector = GetShootVector(a_Chunk); - ShootVector = ShootVector * 20; - ShootVector.y = ShootVector.y + 1; + cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ); + int BlockX = (DispX + DispChunk->GetPosX() * cChunkDef::Width); + int BlockZ = (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkEgg, ShootVector); - } - - m_Contents.ChangeSlotCount(a_SlotNum, -1); + SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkEgg, GetShootVector(Meta) * 20); break; } case E_ITEM_FIREWORK_ROCKET: { - SpawnProjectileFromDispenser(a_Chunk, DispX, DispY, DispZ, cProjectileEntity::pkFirework, GetShootVector(a_Chunk) * 0); + // TODO: Add the fireworks entity m_Contents.ChangeSlotCount(a_SlotNum, -1); @@ -242,60 +213,34 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) -void cDispenserEntity::SpawnProjectileFromDispenser(cChunk & a_Chunk, int & a_DispX, int & a_DispY, int & a_DispZ, cProjectileEntity::eKind a_kind, Vector3d a_ShootVector) +void cDispenserEntity::SpawnProjectileFromDispenser(int & a_BlockX, int & a_BlockY, int & a_BlockZ, cProjectileEntity::eKind a_kind, Vector3d a_ShootVector) { - cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(a_DispX, a_DispZ); - - double EntityX = 0.5 + (a_DispX + DispChunk->GetPosX() * cChunkDef::Width); - double EntityZ = 0.5 + (a_DispZ + DispChunk->GetPosZ() * cChunkDef::Width); + if(a_kind != E_ITEM_FIRE_CHARGE) + a_ShootVector.y = a_ShootVector.y + 1; - m_World->CreateProjectile((double) EntityX, (double) a_DispY + 0.5, (double) EntityZ, a_kind, NULL, NULL, &a_ShootVector); + m_World->CreateProjectile((double) a_BlockX + 0.5, (double) a_BlockY + 0.5, (double) a_BlockZ + 0.5, a_kind, NULL, NULL, &a_ShootVector); } - -Vector3d cDispenserEntity::GetShootVector(cChunk & a_Chunk) +Vector3d cDispenserEntity::GetShootVector(NIBBLETYPE & a_Meta) { - NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ); - int Direction = 0; - Matrix4d m; - Vector3d Look; - - switch (Meta) + switch(a_Meta) { - case E_META_DROPSPENSER_FACING_YP: - { - m.Init(Vector3d(), 0, 180, 0); - Look = m.Transform(Vector3d(0, 1, 0)); + case E_META_DROPSPENSER_FACING_YP: return Vector3d(0, 1, 0); // UP + case E_META_DROPSPENSER_FACING_YM: return Vector3d(0, -1, 0); // DOWN - return Look; // UP - } - - case E_META_DROPSPENSER_FACING_YM: - { - m.Init(Vector3d(), 0, -360, 0); - Look = m.Transform(Vector3d(0, -1, 0)); - - return Look; // DOWN - } + case E_META_DROPSPENSER_FACING_XM: return Vector3d(-1, 0, 0); // WEST + case E_META_DROPSPENSER_FACING_XP: return Vector3d(1, 0, 0); // EAST - case E_META_DROPSPENSER_FACING_XM: Direction = 90; break; // WEST - case E_META_DROPSPENSER_FACING_XP: Direction = 270; break; // EAST - case E_META_DROPSPENSER_FACING_ZM: Direction = 180; break; - case E_META_DROPSPENSER_FACING_ZP: Direction = 0; break; + case E_META_DROPSPENSER_FACING_ZM: return Vector3d(0, 0, -1); + case E_META_DROPSPENSER_FACING_ZP: return Vector3d(0, 0, 1); } - - m.Init(Vector3d(), 0, Direction, 0); - Look = m.Transform(Vector3d(0, 0, 1)); - - return Look; } - bool cDispenserEntity::ScoopUpLiquid(int a_SlotNum, short a_BucketItemType) { cItem LiquidBucket(a_BucketItemType, 1); diff --git a/src/BlockEntities/DispenserEntity.h b/src/BlockEntities/DispenserEntity.h index 558cf41c5..5a2de7965 100644 --- a/src/BlockEntities/DispenserEntity.h +++ b/src/BlockEntities/DispenserEntity.h @@ -23,10 +23,10 @@ public: static const char * GetClassStatic(void) { return "cDispenserEntity"; } /** Spawns a projectile of the given kind in front of the dispenser */ - void SpawnProjectileFromDispenser(cChunk & a_Chunk, int & a_DispX, int & a_DispY, int & a_DispZ, cProjectileEntity::eKind a_kind, Vector3d a_ShootVector); // tolua_export + void SpawnProjectileFromDispenser(int & a_BlockX, int & a_BlockY, int & a_BlockZ, cProjectileEntity::eKind a_kind, Vector3d a_ShootVector); /** Returns how to aim the projectile */ - Vector3d GetShootVector(cChunk & a_Chunk); // tolua_export + Vector3d GetShootVector(NIBBLETYPE & a_Meta); private: // cDropSpenser overrides: @@ -38,7 +38,3 @@ private: /// If the a_BlockInFront is liquidable and the empty bucket can fit, does the m_Contents processing and returns true bool EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum); } ; // tolua_export - - - - -- cgit v1.2.3 From 2ecf425c39452a96398346d114525eeff7cbf50a Mon Sep 17 00:00:00 2001 From: JoannisO Date: Tue, 3 Jun 2014 18:19:06 +0200 Subject: - Fixed a bug where I used the FireCharge ITEM instead of the Projectile ENUM --- src/BlockEntities/DispenserEntity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 2ac7c085c..904ab871b 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -215,7 +215,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) void cDispenserEntity::SpawnProjectileFromDispenser(int & a_BlockX, int & a_BlockY, int & a_BlockZ, cProjectileEntity::eKind a_kind, Vector3d a_ShootVector) { - if(a_kind != E_ITEM_FIRE_CHARGE) + if(a_kind != cProjectileEntity::pkFireCharge) a_ShootVector.y = a_ShootVector.y + 1; m_World->CreateProjectile((double) a_BlockX + 0.5, (double) a_BlockY + 0.5, (double) a_BlockZ + 0.5, a_kind, NULL, NULL, &a_ShootVector); -- cgit v1.2.3 From d92520016dab97a12174b1b6229909d66169bac9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 3 Jun 2014 19:29:04 +0200 Subject: Fixed OnProjectileHitBlock bindings. Also sorted the various cLuaState::Push() functions. --- src/Bindings/LuaState.cpp | 147 ++++++++++++++++++++++++++------------------- src/Bindings/LuaState.h | 44 ++++++++------ src/Bindings/PluginLua.cpp | 2 +- 3 files changed, 111 insertions(+), 82 deletions(-) (limited to 'src') diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index a33459ad2..7a5ed1425 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -372,11 +372,11 @@ void cLuaState::Push(const AStringVector & a_Vector) -void cLuaState::PushUserType(void * a_Object, const char * a_Type) +void cLuaState::Push(const cCraftingGrid * a_Grid) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_Object, a_Type); + tolua_pushusertype(m_LuaState, (void *)a_Grid, "cCraftingGrid"); m_NumCurrentFunctionArgs += 1; } @@ -384,11 +384,11 @@ void cLuaState::PushUserType(void * a_Object, const char * a_Type) -void cLuaState::Push(int a_Value) +void cLuaState::Push(const cCraftingRecipe * a_Recipe) { ASSERT(IsValid()); - tolua_pushnumber(m_LuaState, a_Value); + tolua_pushusertype(m_LuaState, (void *)a_Recipe, "cCraftingRecipe"); m_NumCurrentFunctionArgs += 1; } @@ -396,11 +396,11 @@ void cLuaState::Push(int a_Value) -void cLuaState::Push(double a_Value) +void cLuaState::Push(const char * a_Value) { ASSERT(IsValid()); - tolua_pushnumber(m_LuaState, a_Value); + tolua_pushstring(m_LuaState, a_Value); m_NumCurrentFunctionArgs += 1; } @@ -408,11 +408,11 @@ void cLuaState::Push(double a_Value) -void cLuaState::Push(const char * a_Value) +void cLuaState::Push(const cItems & a_Items) { ASSERT(IsValid()); - tolua_pushstring(m_LuaState, a_Value); + tolua_pushusertype(m_LuaState, (void *)&a_Items, "cItems"); m_NumCurrentFunctionArgs += 1; } @@ -420,11 +420,11 @@ void cLuaState::Push(const char * a_Value) -void cLuaState::Push(bool a_Value) +void cLuaState::Push(const cPlayer * a_Player) { ASSERT(IsValid()); - tolua_pushboolean(m_LuaState, a_Value ? 1 : 0); + tolua_pushusertype(m_LuaState, (void *)a_Player, "cPlayer"); m_NumCurrentFunctionArgs += 1; } @@ -432,11 +432,11 @@ void cLuaState::Push(bool a_Value) -void cLuaState::Push(cWorld * a_World) +void cLuaState::Push(const HTTPRequest * a_Request) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_World, "cWorld"); + tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPRequest"); m_NumCurrentFunctionArgs += 1; } @@ -444,11 +444,11 @@ void cLuaState::Push(cWorld * a_World) -void cLuaState::Push(cPlayer * a_Player) +void cLuaState::Push(const HTTPTemplateRequest * a_Request) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_Player, "cPlayer"); + tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPTemplateRequest"); m_NumCurrentFunctionArgs += 1; } @@ -456,11 +456,11 @@ void cLuaState::Push(cPlayer * a_Player) -void cLuaState::Push(const cPlayer * a_Player) +void cLuaState::Push(const Vector3d & a_Vector) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)a_Player, "cPlayer"); + tolua_pushusertype(m_LuaState, (void *)&a_Vector, "Vector3d"); m_NumCurrentFunctionArgs += 1; } @@ -468,11 +468,11 @@ void cLuaState::Push(const cPlayer * a_Player) -void cLuaState::Push(cEntity * a_Entity) +void cLuaState::Push(bool a_Value) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_Entity, "cEntity"); + tolua_pushboolean(m_LuaState, a_Value ? 1 : 0); m_NumCurrentFunctionArgs += 1; } @@ -480,11 +480,11 @@ void cLuaState::Push(cEntity * a_Entity) -void cLuaState::Push(cProjectileEntity * a_ProjectileEntity) +void cLuaState::Push(cBlockEntity * a_BlockEntity) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_ProjectileEntity, "cProjectileEntity"); + tolua_pushusertype(m_LuaState, a_BlockEntity, "cBlockEntity"); m_NumCurrentFunctionArgs += 1; } @@ -492,11 +492,47 @@ void cLuaState::Push(cProjectileEntity * a_ProjectileEntity) -void cLuaState::Push(cMonster * a_Monster) +void cLuaState::Push(cChunkDesc * a_ChunkDesc) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_Monster, "cMonster"); + tolua_pushusertype(m_LuaState, a_ChunkDesc, "cChunkDesc"); + m_NumCurrentFunctionArgs += 1; +} + + + + + +void cLuaState::Push(cClientHandle * a_Client) +{ + ASSERT(IsValid()); + + tolua_pushusertype(m_LuaState, a_Client, "cClientHandle"); + m_NumCurrentFunctionArgs += 1; +} + + + + + +void cLuaState::Push(cEntity * a_Entity) +{ + ASSERT(IsValid()); + + tolua_pushusertype(m_LuaState, a_Entity, "cEntity"); + m_NumCurrentFunctionArgs += 1; +} + + + + + +void cLuaState::Push(cHopperEntity * a_Hopper) +{ + ASSERT(IsValid()); + + tolua_pushusertype(m_LuaState, a_Hopper, "cHopperEntity"); m_NumCurrentFunctionArgs += 1; } @@ -528,11 +564,11 @@ void cLuaState::Push(cItems * a_Items) -void cLuaState::Push(const cItems & a_Items) +void cLuaState::Push(cMonster * a_Monster) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)&a_Items, "cItems"); + tolua_pushusertype(m_LuaState, a_Monster, "cMonster"); m_NumCurrentFunctionArgs += 1; } @@ -540,11 +576,11 @@ void cLuaState::Push(const cItems & a_Items) -void cLuaState::Push(cClientHandle * a_Client) +void cLuaState::Push(cPickup * a_Pickup) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_Client, "cClientHandle"); + tolua_pushusertype(m_LuaState, a_Pickup, "cPickup"); m_NumCurrentFunctionArgs += 1; } @@ -552,11 +588,11 @@ void cLuaState::Push(cClientHandle * a_Client) -void cLuaState::Push(cPickup * a_Pickup) +void cLuaState::Push(cPlayer * a_Player) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_Pickup, "cPickup"); + tolua_pushusertype(m_LuaState, a_Player, "cPlayer"); m_NumCurrentFunctionArgs += 1; } @@ -564,11 +600,11 @@ void cLuaState::Push(cPickup * a_Pickup) -void cLuaState::Push(cChunkDesc * a_ChunkDesc) +void cLuaState::Push(cPluginLua * a_Plugin) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_ChunkDesc, "cChunkDesc"); + tolua_pushusertype(m_LuaState, a_Plugin, "cPluginLua"); m_NumCurrentFunctionArgs += 1; } @@ -576,11 +612,11 @@ void cLuaState::Push(cChunkDesc * a_ChunkDesc) -void cLuaState::Push(const cCraftingGrid * a_Grid) +void cLuaState::Push(cProjectileEntity * a_ProjectileEntity) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)a_Grid, "cCraftingGrid"); + tolua_pushusertype(m_LuaState, a_ProjectileEntity, "cProjectileEntity"); m_NumCurrentFunctionArgs += 1; } @@ -588,11 +624,11 @@ void cLuaState::Push(const cCraftingGrid * a_Grid) -void cLuaState::Push(const cCraftingRecipe * a_Recipe) +void cLuaState::Push(cTNTEntity * a_TNTEntity) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)a_Recipe, "cCraftingRecipe"); + tolua_pushusertype(m_LuaState, a_TNTEntity, "cTNTEntity"); m_NumCurrentFunctionArgs += 1; } @@ -600,11 +636,11 @@ void cLuaState::Push(const cCraftingRecipe * a_Recipe) -void cLuaState::Push(TakeDamageInfo * a_TDI) +void cLuaState::Push(cWebAdmin * a_WebAdmin) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_TDI, "TakeDamageInfo"); + tolua_pushusertype(m_LuaState, a_WebAdmin, "cWebAdmin"); m_NumCurrentFunctionArgs += 1; } @@ -624,11 +660,11 @@ void cLuaState::Push(cWindow * a_Window) -void cLuaState::Push(cPluginLua * a_Plugin) +void cLuaState::Push(cWorld * a_World) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_Plugin, "cPluginLua"); + tolua_pushusertype(m_LuaState, a_World, "cWorld"); m_NumCurrentFunctionArgs += 1; } @@ -636,11 +672,11 @@ void cLuaState::Push(cPluginLua * a_Plugin) -void cLuaState::Push(const HTTPRequest * a_Request) +void cLuaState::Push(double a_Value) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPRequest"); + tolua_pushnumber(m_LuaState, a_Value); m_NumCurrentFunctionArgs += 1; } @@ -648,11 +684,11 @@ void cLuaState::Push(const HTTPRequest * a_Request) -void cLuaState::Push(cWebAdmin * a_WebAdmin) +void cLuaState::Push(int a_Value) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_WebAdmin, "cWebAdmin"); + tolua_pushnumber(m_LuaState, a_Value); m_NumCurrentFunctionArgs += 1; } @@ -660,11 +696,11 @@ void cLuaState::Push(cWebAdmin * a_WebAdmin) -void cLuaState::Push(const HTTPTemplateRequest * a_Request) +void cLuaState::Push(TakeDamageInfo * a_TDI) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPTemplateRequest"); + tolua_pushusertype(m_LuaState, a_TDI, "TakeDamageInfo"); m_NumCurrentFunctionArgs += 1; } @@ -672,11 +708,11 @@ void cLuaState::Push(const HTTPTemplateRequest * a_Request) -void cLuaState::Push(cTNTEntity * a_TNTEntity) +void cLuaState::Push(Vector3i * a_Vector) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_TNTEntity, "cTNTEntity"); + tolua_pushusertype(m_LuaState, a_Vector, "Vector3i"); m_NumCurrentFunctionArgs += 1; } @@ -684,11 +720,11 @@ void cLuaState::Push(cTNTEntity * a_TNTEntity) -void cLuaState::Push(Vector3i * a_Vector) +void cLuaState::Push(Vector3d * a_Vector) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_Vector, "Vector3i"); + tolua_pushusertype(m_LuaState, a_Vector, "Vector3d"); m_NumCurrentFunctionArgs += 1; } @@ -715,23 +751,12 @@ void cLuaState::Push(void * a_Ptr) -void cLuaState::Push(cHopperEntity * a_Hopper) -{ - ASSERT(IsValid()); - - tolua_pushusertype(m_LuaState, a_Hopper, "cHopperEntity"); - m_NumCurrentFunctionArgs += 1; -} - - - - -void cLuaState::Push(cBlockEntity * a_BlockEntity) +void cLuaState::PushUserType(void * a_Object, const char * a_Type) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_BlockEntity, "cBlockEntity"); + tolua_pushusertype(m_LuaState, a_Object, a_Type); m_NumCurrentFunctionArgs += 1; } diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index b9ca2f29b..066390e39 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -173,38 +173,42 @@ public: /** Returns true if a_FunctionName is a valid Lua function that can be called */ bool HasFunction(const char * a_FunctionName); - // Push a value onto the stack + // Push a const value onto the stack (keep alpha-sorted): void Push(const AString & a_String); void Push(const AStringVector & a_Vector); - void Push(int a_Value); - void Push(double a_Value); + void Push(const cCraftingGrid * a_Grid); + void Push(const cCraftingRecipe * a_Recipe); void Push(const char * a_Value); - void Push(bool a_Value); - void Push(cWorld * a_World); - void Push(cPlayer * a_Player); + void Push(const cItems & a_Items); void Push(const cPlayer * a_Player); + void Push(const HTTPRequest * a_Request); + void Push(const HTTPTemplateRequest * a_Request); + void Push(const Vector3d & a_Vector); + + // Push a value onto the stack (keep alpha-sorted): + void Push(bool a_Value); + void Push(cBlockEntity * a_BlockEntity); + void Push(cChunkDesc * a_ChunkDesc); + void Push(cClientHandle * a_ClientHandle); void Push(cEntity * a_Entity); - void Push(cProjectileEntity * a_ProjectileEntity); - void Push(cMonster * a_Monster); + void Push(cHopperEntity * a_Hopper); void Push(cItem * a_Item); void Push(cItems * a_Items); - void Push(const cItems & a_Items); - void Push(cClientHandle * a_ClientHandle); + void Push(cMonster * a_Monster); void Push(cPickup * a_Pickup); - void Push(cChunkDesc * a_ChunkDesc); - void Push(const cCraftingGrid * a_Grid); - void Push(const cCraftingRecipe * a_Recipe); - void Push(TakeDamageInfo * a_TDI); - void Push(cWindow * a_Window); + void Push(cPlayer * a_Player); void Push(cPluginLua * a_Plugin); - void Push(const HTTPRequest * a_Request); - void Push(cWebAdmin * a_WebAdmin); - void Push(const HTTPTemplateRequest * a_Request); + void Push(cProjectileEntity * a_ProjectileEntity); void Push(cTNTEntity * a_TNTEntity); + void Push(cWebAdmin * a_WebAdmin); + void Push(cWindow * a_Window); + void Push(cWorld * a_World); + void Push(double a_Value); + void Push(int a_Value); + void Push(TakeDamageInfo * a_TDI); + void Push(Vector3d * a_Vector); void Push(Vector3i * a_Vector); void Push(void * a_Ptr); - void Push(cHopperEntity * a_Hopper); - void Push(cBlockEntity * a_BlockEntity); /** Retrieve value at a_StackPos, if it is a valid bool. If not, a_Value is unchanged */ void GetStackValue(int a_StackPos, bool & a_Value); diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 625931931..04639da60 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -1120,7 +1120,7 @@ bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, int a_Bl cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_BLOCK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, &a_BlockHitPos, cLuaState::Return, res); + m_LuaState.Call((int)(**itr), &a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos, cLuaState::Return, res); if (res) { return true; -- cgit v1.2.3 From c0716bfcf6cce720f41e98544eb4a4532a694a0a Mon Sep 17 00:00:00 2001 From: JoannisO Date: Tue, 3 Jun 2014 19:39:56 +0200 Subject: - Fixed a bug where I didn't return anything in the GetShootVector function. This was however passed as "working" by GCC. --- src/BlockEntities/DispenserEntity.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 904ab871b..bbf924417 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -235,6 +235,8 @@ Vector3d cDispenserEntity::GetShootVector(NIBBLETYPE & a_Meta) case E_META_DROPSPENSER_FACING_ZM: return Vector3d(0, 0, -1); case E_META_DROPSPENSER_FACING_ZP: return Vector3d(0, 0, 1); } + + return Vector3d(0, 1, 0); } -- cgit v1.2.3 From 7993caa553e3317da21763226bf6bd5c2e965f8c Mon Sep 17 00:00:00 2001 From: JoannisO Date: Tue, 3 Jun 2014 19:43:15 +0200 Subject: - Fixed an issue where there were 2 "DispChunk"-s in the same function. Resused the initial one. --- src/BlockEntities/DispenserEntity.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index bbf924417..a4a660034 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -38,7 +38,10 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) // Would dispense into / interact with a non-loaded chunk, ignore the tick return; } + BLOCKTYPE DispBlock = DispChunk->GetBlock(DispX, DispY, DispZ); + int BlockX = (DispX + DispChunk->GetPosX() * cChunkDef::Width); + int BlockZ = (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); // Dispense the item: switch (m_Contents.GetSlot(a_SlotNum).m_ItemType) @@ -146,10 +149,6 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_FIRE_CHARGE: { - cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ); - int BlockX = (DispX + DispChunk->GetPosX() * cChunkDef::Width); - int BlockZ = (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkFireCharge, GetShootVector(Meta) * 20); m_Contents.ChangeSlotCount(a_SlotNum, -1); @@ -159,10 +158,6 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_ARROW: { - cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ); - int BlockX = (DispX + DispChunk->GetPosX() * cChunkDef::Width); - int BlockZ = (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkArrow, GetShootVector(Meta) * 20); m_Contents.ChangeSlotCount(a_SlotNum, -1); @@ -172,10 +167,6 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_SNOWBALL: { - cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ); - int BlockX = (DispX + DispChunk->GetPosX() * cChunkDef::Width); - int BlockZ = (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkSnowball, GetShootVector(Meta) * 20); m_Contents.ChangeSlotCount(a_SlotNum, -1); @@ -185,12 +176,10 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_EGG: { - cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ); - int BlockX = (DispX + DispChunk->GetPosX() * cChunkDef::Width); - int BlockZ = (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); - SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkEgg, GetShootVector(Meta) * 20); + m_Contents.ChangeSlotCount(a_SlotNum, -1); + break; } -- cgit v1.2.3 From c0015d01c6be8b4061a19484d13b7d0e74426be5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 3 Jun 2014 19:50:27 +0200 Subject: Player permissions aren't logged to console anymore. This was only logspam on most servers and there are alternative ways to list players' permissions. --- src/Entities/Player.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 0dfdcfd8b..3a9324d09 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1650,13 +1650,6 @@ bool cPlayer::LoadFromDisk() { LoadPermissionsFromDisk(); - // Log player permissions, cause it's what the cool kids do - LOGINFO("Player %s has permissions:", GetName().c_str() ); - for( PermissionMap::iterator itr = m_ResolvedPermissions.begin(); itr != m_ResolvedPermissions.end(); ++itr ) - { - if( itr->second ) LOG(" - %s", itr->first.c_str() ); - } - AString SourceFile; Printf(SourceFile, "players/%s.json", GetName().c_str() ); -- cgit v1.2.3 From 8604dedfdf4e9522fa99e6280e09180523ecce09 Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Wed, 4 Jun 2014 10:20:20 +0200 Subject: Update IncrementalRedstoneSimulator.cpp --- src/Simulator/IncrementalRedstoneSimulator.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 8d29fbec7..a89c017df 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -17,14 +17,14 @@ -cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulator(cWorld & a_World) - : super(a_World), - m_RedstoneSimulatorChunkData(), - m_PoweredBlocks(), - m_LinkedPoweredBlocks(), - m_SimulatedPlayerToggleableBlocks(), - m_RepeatersDelayList(), - m_Chunk() +cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulator(cWorld & a_World) : + super(a_World), + m_RedstoneSimulatorChunkData(), + m_PoweredBlocks(), + m_LinkedPoweredBlocks(), + m_SimulatedPlayerToggleableBlocks(), + m_RepeatersDelayList(), + m_Chunk() { } -- cgit v1.2.3 From 8e57f75622e7bb98a0251809fe7e31faaa7c1fee Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 09:21:44 +0100 Subject: Fixed #1057 --- src/ChunkData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 142c141c4..1fa2fd212 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -300,7 +300,7 @@ NIBBLETYPE cChunkData::GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const if (m_Sections[Section] != NULL) { int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ); - return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; + return (m_Sections[Section]->m_BlockSkyLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; } else { -- cgit v1.2.3 From c4e0da2d0ac8e07a8143f1292020b3839c155eba Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 09:22:19 +0100 Subject: Fixed mob loading, part of #1058 --- src/WorldStorage/WSSAnvil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index d310c9124..1891762fd 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -2445,7 +2445,7 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT & a_NBT, int a_TagIdx) { float DropChance[5]; - if (!LoadFloatsListFromNBT(DropChance, 5, a_NBT, a_NBT.FindChildByName(a_TagIdx, "DropChance"))) + if (!LoadFloatsListFromNBT(DropChance, 5, a_NBT, a_NBT.FindChildByName(a_TagIdx, "DropChances"))) { return false; } -- cgit v1.2.3 From 9ef4b9d52d0b3b19eed90daf528bab5b9c01d8dc Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 09:27:50 +0100 Subject: Exploded creepers drop nothing, part of #1058 --- src/Mobs/Creeper.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp index 9cf539427..a7b97f604 100644 --- a/src/Mobs/Creeper.cpp +++ b/src/Mobs/Creeper.cpp @@ -43,7 +43,7 @@ void cCreeper::Tick(float a_Dt, cChunk & a_Chunk) if (m_ExplodingTimer == 30) { m_World->DoExplosionAt((m_bIsCharged ? 5 : 3), GetPosX(), GetPosY(), GetPosZ(), false, esMonster, this); - Destroy(); + Destroy(); // Just in case we aren't killed by the explosion } } } @@ -54,6 +54,12 @@ void cCreeper::Tick(float a_Dt, cChunk & a_Chunk) void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer) { + if (m_ExplodingTimer == 30) + { + // Exploded creepers drop naught but charred flesh, which Minecraft doesn't have + return; + } + int LootingLevel = 0; if (a_Killer != NULL) { @@ -65,7 +71,7 @@ void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer) { if (((cMonster *)((cProjectileEntity *)a_Killer)->GetCreator())->GetMobType() == mtSkeleton) { - // 12 music discs. TickRand starts from 0, so range = 11. Disk IDs start at 2256, so add that. There. + // 12 music discs. TickRand starts from 0 to 11. Disk IDs start at 2256, so add that. There. AddRandomDropItem(a_Drops, 1, 1, (short)m_World->GetTickRandomNumber(11) + 2256); } } -- cgit v1.2.3 From 87c4d0ea576d6a3e8ec78329ff510291ccf0e674 Mon Sep 17 00:00:00 2001 From: worktycho Date: Wed, 4 Jun 2014 10:58:09 +0100 Subject: Initialise m_Callbacks field to NULL in empty constructor. --- src/PolarSSL++/CallbackSslContext.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/PolarSSL++/CallbackSslContext.cpp b/src/PolarSSL++/CallbackSslContext.cpp index 0cc88a14a..c4d19b2a0 100644 --- a/src/PolarSSL++/CallbackSslContext.cpp +++ b/src/PolarSSL++/CallbackSslContext.cpp @@ -11,7 +11,8 @@ -cCallbackSslContext::cCallbackSslContext(void) +cCallbackSslContext::cCallbackSslContext(void) : + m_Callbacks(NULL) { // Nothing needed, but the constructor needs to exist so } -- cgit v1.2.3 From 85be62a8cd7eeb1c5c9a2967f9928abf46817261 Mon Sep 17 00:00:00 2001 From: worktycho Date: Wed, 4 Jun 2014 11:02:17 +0100 Subject: Removed unused field test --- src/PolarSSL++/AesCfb128Decryptor.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/PolarSSL++/AesCfb128Decryptor.h b/src/PolarSSL++/AesCfb128Decryptor.h index 68c203d70..84c790b83 100644 --- a/src/PolarSSL++/AesCfb128Decryptor.h +++ b/src/PolarSSL++/AesCfb128Decryptor.h @@ -19,7 +19,6 @@ class cAesCfb128Decryptor { public: - Byte test; cAesCfb128Decryptor(void); ~cAesCfb128Decryptor(); -- cgit v1.2.3 From 98c575ebc276b9825c3da186b8b560811e855da6 Mon Sep 17 00:00:00 2001 From: worktycho Date: Wed, 4 Jun 2014 11:12:06 +0100 Subject: Make sure m_StackSizeToBeUsedInRepair Always has a valid value --- src/UI/SlotArea.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 59a6384b1..682f20c00 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -625,7 +625,8 @@ void cSlotAreaCrafting::HandleCraftItem(const cItem & a_Result, cPlayer & a_Play cSlotAreaAnvil::cSlotAreaAnvil(cAnvilWindow & a_ParentWindow) : cSlotAreaTemporary(3, a_ParentWindow), - m_MaximumCost(0) + m_MaximumCost(0), + m_StackSizeToBeUsedInRepair(0); { } @@ -796,6 +797,7 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player) { cItem NewSecondItem(*Item); NewSecondItem.m_ItemCount -= m_StackSizeToBeUsedInRepair; + m_StackSizeToBeUsedInRepair = 0; SetSlot(1, a_Player, NewSecondItem); } else -- cgit v1.2.3 From ae37dfec8d44f2a4adca0c47bf3e490f85f1ed0b Mon Sep 17 00:00:00 2001 From: worktycho Date: Wed, 4 Jun 2014 11:29:08 +0100 Subject: Fixed bad coordinate --- src/ClientHandle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 080e859d1..d47ceff0e 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1306,7 +1306,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e if (!a_ItemHandler.GetPlacementBlockTypeMeta(World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta)) { // Handler refused the placement, send that information back to the client: - World->SendBlockTo(a_BlockX, a_BlockY, a_BlockY, m_Player); + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); m_Player->GetInventory().SendEquippedSlot(); return; } -- cgit v1.2.3 From 2c103a713e0ce77ccb8b86c98e2571d5ba6dd9c0 Mon Sep 17 00:00:00 2001 From: JoannisO Date: Wed, 4 Jun 2014 12:35:45 +0200 Subject: - Fixed a lot of astethics --- src/BlockEntities/DispenserEntity.cpp | 26 +++++++++++++------------- src/BlockEntities/DispenserEntity.h | 5 ++++- 2 files changed, 17 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index a4a660034..242ac4024 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -10,7 +10,6 @@ #include "../Entities/ArrowEntity.h" #include "../Entities/FireChargeEntity.h" #include "../Entities/ProjectileEntity.h" -#include "../Matrix4.h" @@ -150,7 +149,6 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_FIRE_CHARGE: { SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkFireCharge, GetShootVector(Meta) * 20); - m_Contents.ChangeSlotCount(a_SlotNum, -1); break; @@ -159,7 +157,6 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_ARROW: { SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkArrow, GetShootVector(Meta) * 20); - m_Contents.ChangeSlotCount(a_SlotNum, -1); break; @@ -168,7 +165,6 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_SNOWBALL: { SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkSnowball, GetShootVector(Meta) * 20); - m_Contents.ChangeSlotCount(a_SlotNum, -1); break; @@ -177,7 +173,6 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_EGG: { SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkEgg, GetShootVector(Meta) * 20); - m_Contents.ChangeSlotCount(a_SlotNum, -1); break; @@ -202,10 +197,12 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) -void cDispenserEntity::SpawnProjectileFromDispenser(int & a_BlockX, int & a_BlockY, int & a_BlockZ, cProjectileEntity::eKind a_kind, Vector3d a_ShootVector) +void cDispenserEntity::SpawnProjectileFromDispenser(int & a_BlockX, int & a_BlockY, int & a_BlockZ, cProjectileEntity::eKind a_Kind, Vector3d a_ShootVector) { - if(a_kind != cProjectileEntity::pkFireCharge) + if( a_kind != cProjectileEntity::pkFireCharge ) + { a_ShootVector.y = a_ShootVector.y + 1; + } m_World->CreateProjectile((double) a_BlockX + 0.5, (double) a_BlockY + 0.5, (double) a_BlockZ + 0.5, a_kind, NULL, NULL, &a_ShootVector); } @@ -215,14 +212,14 @@ Vector3d cDispenserEntity::GetShootVector(NIBBLETYPE & a_Meta) { switch(a_Meta) { - case E_META_DROPSPENSER_FACING_YP: return Vector3d(0, 1, 0); // UP - case E_META_DROPSPENSER_FACING_YM: return Vector3d(0, -1, 0); // DOWN + case E_META_DROPSPENSER_FACING_YP: return Vector3d(0, 1, 0); // UP + case E_META_DROPSPENSER_FACING_YM: return Vector3d(0, -1, 0); // DOWN - case E_META_DROPSPENSER_FACING_XM: return Vector3d(-1, 0, 0); // WEST - case E_META_DROPSPENSER_FACING_XP: return Vector3d(1, 0, 0); // EAST + case E_META_DROPSPENSER_FACING_XM: return Vector3d(-1, 0, 0); // WEST + case E_META_DROPSPENSER_FACING_XP: return Vector3d(1, 0, 0); // EAST - case E_META_DROPSPENSER_FACING_ZM: return Vector3d(0, 0, -1); - case E_META_DROPSPENSER_FACING_ZP: return Vector3d(0, 0, 1); + case E_META_DROPSPENSER_FACING_ZM: return Vector3d(0, 0, -1); + case E_META_DROPSPENSER_FACING_ZP: return Vector3d(0, 0, 1); } return Vector3d(0, 1, 0); @@ -290,3 +287,6 @@ bool cDispenserEntity::EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum m_Contents.AddItem(EmptyBucket); return true; } + + + diff --git a/src/BlockEntities/DispenserEntity.h b/src/BlockEntities/DispenserEntity.h index 5a2de7965..9410a1129 100644 --- a/src/BlockEntities/DispenserEntity.h +++ b/src/BlockEntities/DispenserEntity.h @@ -23,7 +23,7 @@ public: static const char * GetClassStatic(void) { return "cDispenserEntity"; } /** Spawns a projectile of the given kind in front of the dispenser */ - void SpawnProjectileFromDispenser(int & a_BlockX, int & a_BlockY, int & a_BlockZ, cProjectileEntity::eKind a_kind, Vector3d a_ShootVector); + void SpawnProjectileFromDispenser(int & a_BlockX, int & a_BlockY, int & a_BlockZ, cProjectileEntity::eKind a_Kind, Vector3d a_ShootVector); /** Returns how to aim the projectile */ Vector3d GetShootVector(NIBBLETYPE & a_Meta); @@ -38,3 +38,6 @@ private: /// If the a_BlockInFront is liquidable and the empty bucket can fit, does the m_Contents processing and returns true bool EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum); } ; // tolua_export + + + -- cgit v1.2.3 From e5b345a9c95225c18728f5692bf12ffae82ba4cd Mon Sep 17 00:00:00 2001 From: JoannisO Date: Wed, 4 Jun 2014 12:37:51 +0200 Subject: - Fixed variable names in a function. --- src/BlockEntities/DispenserEntity.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 242ac4024..7b468bdea 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -199,12 +199,12 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) void cDispenserEntity::SpawnProjectileFromDispenser(int & a_BlockX, int & a_BlockY, int & a_BlockZ, cProjectileEntity::eKind a_Kind, Vector3d a_ShootVector) { - if( a_kind != cProjectileEntity::pkFireCharge ) + if( a_Kind != cProjectileEntity::pkFireCharge ) { a_ShootVector.y = a_ShootVector.y + 1; } - m_World->CreateProjectile((double) a_BlockX + 0.5, (double) a_BlockY + 0.5, (double) a_BlockZ + 0.5, a_kind, NULL, NULL, &a_ShootVector); + m_World->CreateProjectile((double) a_BlockX + 0.5, (double) a_BlockY + 0.5, (double) a_BlockZ + 0.5, a_Kind, NULL, NULL, &a_ShootVector); } -- cgit v1.2.3 From c94d0c814442785b2be7654c3a8c0d9c1fc5f765 Mon Sep 17 00:00:00 2001 From: worktycho Date: Wed, 4 Jun 2014 11:39:21 +0100 Subject: derp --- src/UI/SlotArea.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 682f20c00..728692f2a 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -626,7 +626,7 @@ void cSlotAreaCrafting::HandleCraftItem(const cItem & a_Result, cPlayer & a_Play cSlotAreaAnvil::cSlotAreaAnvil(cAnvilWindow & a_ParentWindow) : cSlotAreaTemporary(3, a_ParentWindow), m_MaximumCost(0), - m_StackSizeToBeUsedInRepair(0); + m_StackSizeToBeUsedInRepair(0) { } -- cgit v1.2.3 From 852e162f95742d5c5454e458ed7883e4b0209a73 Mon Sep 17 00:00:00 2001 From: JoannisO Date: Wed, 4 Jun 2014 12:40:01 +0200 Subject: - Removed the code that removed fireworks from a dispenser even thought they weren't launched. --- src/BlockEntities/DispenserEntity.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 7b468bdea..475125719 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -181,9 +181,6 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) case E_ITEM_FIREWORK_ROCKET: { // TODO: Add the fireworks entity - - m_Contents.ChangeSlotCount(a_SlotNum, -1); - break; } -- cgit v1.2.3 From 01f38d883602045e84fdf98bf3395e97608d9aad Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 13:22:50 +0100 Subject: Added checks for no downfall biomes --- src/Blocks/BlockCauldron.h | 2 +- src/Entities/Entity.cpp | 2 +- src/Mobs/Monster.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h index 8b5cd9ccb..5ec776df6 100644 --- a/src/Blocks/BlockCauldron.h +++ b/src/Blocks/BlockCauldron.h @@ -61,7 +61,7 @@ public: virtual void OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override { - if (!a_WorldInterface.IsWeatherWet()) + if (IsBiomeNoDownfall(a_Chunk.GetBiomeAt(a_RelX, a_RelZ)) || !a_WorldInterface.IsWeatherWet()) { return; } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index de6c628e9..16264a608 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -869,7 +869,7 @@ void cEntity::TickBurning(cChunk & a_Chunk) // Remember the current burning state: bool HasBeenBurning = (m_TicksLeftBurning > 0); - if (m_World->IsWeatherWet()) + if (IsBiomeNoDownfall(a_Chunk.GetBiomeAt(POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width, POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width)) || GetWorld()->IsWeatherWet()) { if (POSY_TOINT > m_World->GetHeight(POSX_TOINT, POSZ_TOINT)) { diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index fa3969d5e..c25ee6b75 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -1034,7 +1034,7 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk) (a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand (GetWorld()->GetTimeOfDay() < (12000 + 1000)) && // It is nighttime !IsOnFire() && // Not already burning - (GetWorld()->IsWeatherWet()) // Not raining + (IsBiomeNoDownfall(a_Chunk.GetBiomeAt(RelX, RelZ)) || GetWorld()->IsWeatherWet()) // Not raining ) { // Burn for 100 ticks, then decide again -- cgit v1.2.3 From 3278a403b5bc951818ed418c39c64934d55dbd65 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 13:24:43 +0100 Subject: Removed use of auto --- src/Chunk.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 59f4a8507..c6122852a 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -588,7 +588,7 @@ void cChunk::Tick(float a_Dt) for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) { - auto itr2 = std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID()); + std::vector::const_iterator itr2 = std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID()); if (itr2 != m_EntitiesToRemove.end()) { itr = m_Entities.erase(itr); -- cgit v1.2.3 From 33fbdedea3b9d48f2bec329b93d86024befbb6ab Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 4 Jun 2014 15:16:30 +0200 Subject: Fix itemframe break. --- src/Entities/ItemFrame.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp index 9dd909880..7bc7bda8d 100644 --- a/src/Entities/ItemFrame.cpp +++ b/src/Entities/ItemFrame.cpp @@ -55,6 +55,7 @@ void cItemFrame::KilledBy(cEntity * a_Killer) { if (m_Item.IsEmpty()) { + SetHealth(0); super::KilledBy(a_Killer); Destroy(); return; @@ -69,8 +70,9 @@ void cItemFrame::KilledBy(cEntity * a_Killer) } SetHealth(GetMaxHealth()); - m_Item.Clear(); + m_Item.Empty(); m_Rotation = 0; + SetInvulnerableTicks(0); GetWorld()->BroadcastEntityMetadata(*this); } -- cgit v1.2.3 From 74cd4f552152f73d0d46cf726bcef472841e2da5 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 18:59:56 +0100 Subject: Suggestions --- src/Entities/Player.cpp | 2 +- src/Entities/Player.h | 12 ++++++++---- src/UI/Window.cpp | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 02a55566c..8e4c89f68 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1659,7 +1659,7 @@ void cPlayer::LoadPermissionsFromDisk() -bool cPlayer::LoadFromDisk(cWorld * a_World) +bool cPlayer::LoadFromDisk(cWorld *& a_World) { a_World = cRoot::Get()->GetWorld(GetLoadedWorldName()); if (a_World == NULL) diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 5c0b61064..39031fbfb 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -127,7 +127,7 @@ public: inline const cItem & GetEquippedItem(void) const { return GetInventory().GetEquippedItem(); } // tolua_export - /** Returns whether the player is climbing (ladders, vines e.t.c). */ + /** Returns whether the player is climbing (ladders, vines etc.) */ bool IsClimbing(void) const; virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) override; @@ -330,8 +330,13 @@ public: virtual bool MoveToWorld(const AString & a_WorldName, cWorld * a_World = NULL) override; // tolua_export + /** Saves all player data, such as inventory, to JSON */ bool SaveToDisk(void); - bool LoadFromDisk(cWorld * a_World); + + /** Loads player data from JSON to the object + Takes a (NULL) cWorld pointer which it will assign a value to based on either the loaded world or default world + */ + bool LoadFromDisk(cWorld *& a_World); void LoadPermissionsFromDisk(void); // tolua_export const AString & GetLoadedWorldName() { return m_LoadedWorldName; } @@ -342,8 +347,7 @@ public: void SendExperience(void); - // In UI windows, the item that the player is dragging: - bool IsDraggingItem(void) const { return !m_DraggingItem.IsEmpty(); } + /** In UI windows, the item that the player is dragging */ cItem & GetDraggingItem(void) {return m_DraggingItem; } // In UI windows, when inventory-painting: diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 46885390b..c0e2cef64 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -283,7 +283,7 @@ void cWindow::OpenedByPlayer(cPlayer & a_Player) bool cWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) { // Checks whether the player is still holding an item - if (a_Player.IsDraggingItem()) + if (!a_Player.GetDraggingItem().IsEmpty()) { LOGD("Player holds item! Dropping it..."); a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount); -- cgit v1.2.3 From ccbf6cc446ad67fbba8163d4d4d61456c1ba0bc6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 20:00:55 +0100 Subject: Configurable portals --- src/Entities/Entity.cpp | 45 ++++++++++++++++++++++++++++++++------------- src/Entities/Player.cpp | 2 +- src/World.cpp | 26 ++++++++++++++++++++++++++ src/World.h | 24 ++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 16264a608..7d9c10ec6 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1042,6 +1042,11 @@ void cEntity::DetectCacti(void) void cEntity::DetectPortal() { + if (!GetWorld()->AreNetherPortalsEnabled() && !GetWorld()->AreEndPortalsEnabled()) + { + return; + } + int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; if ((Y > 0) && (Y < cChunkDef::Height)) { @@ -1049,11 +1054,18 @@ void cEntity::DetectPortal() { case E_BLOCK_NETHER_PORTAL: { + if (!GetWorld()->AreNetherPortalsEnabled()) + { + return; + } + switch (GetWorld()->GetDimension()) { case dimNether: { - AString OverworldName = GetWorld()->GetName().substr(0, GetWorld()->GetName().size() - 7); + cIniFile OwnIni; OwnIni.ReadFile(GetWorld()->GetIniFileName()); + AString OverworldName = OwnIni.GetValue("General", "OverworldName", cRoot::Get()->GetDefaultWorld()->GetName()); + cFile::CreateFolder(FILE_IO_PREFIX + OverworldName); cIniFile File; File.ReadFile(OverworldName + "/world.ini"); @@ -1065,14 +1077,14 @@ void cEntity::DetectPortal() } case dimOverworld: { - AString NetherWorldName = GetWorld()->GetName() + "_nether"; - cFile::CreateFolder(FILE_IO_PREFIX + NetherWorldName); + cFile::CreateFolder(FILE_IO_PREFIX + GetWorld()->GetNetherWorldName()); cIniFile File; - File.ReadFile(NetherWorldName + "/world.ini"); + File.ReadFile(GetWorld()->GetNetherWorldName() + "/world.ini"); File.SetValue("General", "Dimension", "Nether"); - File.WriteFile(NetherWorldName + "/world.ini"); + File.SetValue("General", "OverworldName", GetWorld()->GetName()); + File.WriteFile(GetWorld()->GetNetherWorldName() + "/world.ini"); - MoveToWorld(NetherWorldName, cRoot::Get()->CreateAndInitializeWorld(NetherWorldName)); + MoveToWorld(GetWorld()->GetNetherWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetNetherWorldName())); break; } default: break; @@ -1081,11 +1093,18 @@ void cEntity::DetectPortal() } case E_BLOCK_END_PORTAL: { + if (!GetWorld()->AreEndPortalsEnabled()) + { + return; + } + switch (GetWorld()->GetDimension()) { case dimEnd: { - AString OverworldName = GetWorld()->GetName().substr(0, GetWorld()->GetName().size() - 4); + cIniFile OwnIni; OwnIni.ReadFile(GetWorld()->GetIniFileName()); + AString OverworldName = OwnIni.GetValue("General", "OverworldName", cRoot::Get()->GetDefaultWorld()->GetName()); + cFile::CreateFolder(FILE_IO_PREFIX + OverworldName); cIniFile File; File.ReadFile(OverworldName + "/world.ini"); @@ -1103,14 +1122,14 @@ void cEntity::DetectPortal() } case dimOverworld: { - AString EndWorldName = GetWorld()->GetName() + "_end"; - cFile::CreateFolder(FILE_IO_PREFIX + EndWorldName); + cFile::CreateFolder(FILE_IO_PREFIX + GetWorld()->GetEndWorldName()); cIniFile File; - File.ReadFile(EndWorldName + "/world.ini"); + File.ReadFile(GetWorld()->GetEndWorldName() + "/world.ini"); File.SetValue("General", "Dimension", "End"); - File.WriteFile(EndWorldName + "/world.ini"); + File.SetValue("General", "OverworldName", GetWorld()->GetName()); + File.WriteFile(GetWorld()->GetEndWorldName() + "/world.ini"); - MoveToWorld(EndWorldName, cRoot::Get()->CreateAndInitializeWorld(EndWorldName)); + MoveToWorld(GetWorld()->GetEndWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetEndWorldName())); break; } default: break; @@ -1133,7 +1152,7 @@ bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World) World = cRoot::Get()->GetWorld(a_WorldName); if (World == NULL) { - LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName); + LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName.c_str()); return false; } } diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 8e4c89f68..eebc9ecf9 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1610,7 +1610,7 @@ bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World) { GetClientHandle()->SendPlayerMoveLook(); GetClientHandle()->SendHealth(); - GetClientHandle()->SendWholeInventory((cWindow &)GetInventory()); + GetClientHandle()->SendWholeInventory(*GetWindow()); } return true; diff --git a/src/World.cpp b/src/World.cpp index 66aca83ef..345c894eb 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -66,6 +66,9 @@ const int TIME_NIGHT_END = 22812; const int TIME_SUNRISE = 23999; const int TIME_SPAWN_DIVISOR = 148; +#define DEFAULT_NETHER_NAME GetName() + "_nether" +#define DEFAULT_END_NAME GetName() + "_end" + @@ -566,6 +569,14 @@ void cWorld::Start(void) m_bUseChatPrefixes = IniFile.GetValueSetB("Mechanics", "UseChatPrefixes", true); m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true); int GameMode = IniFile.GetValueSetI("General", "Gamemode", (int)m_GameMode); + + if ((GetDimension() != dimNether) && (GetDimension() != dimEnd)) + { + m_bNetherPortalsEnabled = IniFile.GetValueSetB("General", "NetherPortalsEnabled", true); + m_NetherWorldName = IniFile.GetValueSet("General", "NetherWorldName", DEFAULT_NETHER_NAME); + m_bEndPortalsEnabled = IniFile.GetValueSetB("General", "EndPortalsEnabled", true); + m_EndWorldName = IniFile.GetValueSet("General", "EndWorldName", DEFAULT_END_NAME); + } // Adjust the enum-backed variables into their respective bounds: m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmAdventure); @@ -734,6 +745,21 @@ void cWorld::Stop(void) } // for itr - m_Clients[] m_Clients.clear(); } + + // Write settings to file; these are all plugin changeable values - keep updated! + cIniFile IniFile; + IniFile.ReadFile(m_IniFileName); + if ((GetDimension() != dimNether) && (GetDimension() != dimEnd)) + { + IniFile.SetValueB("General", "NetherPortalsEnabled", m_bNetherPortalsEnabled); + IniFile.SetValue("General", "NetherWorldName", m_NetherWorldName); + IniFile.SetValueB("General", "EndPortalsEnabled", m_bEndPortalsEnabled); + IniFile.SetValue("General", "EndWorldName", m_EndWorldName); + } + IniFile.SetValueI("Physics", "TNTShrapnelLevel", (int)m_TNTShrapnelLevel); + IniFile.SetValueB("Mechanics", "CommandBlocksEnabled", m_bCommandBlocksEnabled); + IniFile.SetValueB("Mechanics", "UseChatPrefixes", m_bUseChatPrefixes); + IniFile.WriteFile(m_IniFileName); m_TickThread.Stop(); m_Lighting.Stop(); diff --git a/src/World.h b/src/World.h index e72675194..7b87a76ac 100644 --- a/src/World.h +++ b/src/World.h @@ -624,6 +624,18 @@ public: bool ShouldUseChatPrefixes(void) const { return m_bUseChatPrefixes; } void SetShouldUseChatPrefixes(bool a_Flag) { m_bUseChatPrefixes = a_Flag; } + + bool AreNetherPortalsEnabled(void) const { return m_bNetherPortalsEnabled; } + void SetNetherPortalsEnabled(bool a_Flag) { m_bNetherPortalsEnabled = a_Flag; } + + bool AreEndPortalsEnabled(void) const { return m_bEndPortalsEnabled; } + void SetEndPortalsEnabled(bool a_Flag) { m_bEndPortalsEnabled = a_Flag; } + + AString GetNetherWorldName(void) const { return m_NetherWorldName; } + void SetNetherWorldName(const AString & a_Name) { m_NetherWorldName = a_Name; } + + AString GetEndWorldName(void) const { return m_EndWorldName; } + void SetEndWorldName(const AString & a_Name) { m_EndWorldName = a_Name; } // tolua_end @@ -886,6 +898,18 @@ private: See the eShrapnelLevel enumeration for details */ eShrapnelLevel m_TNTShrapnelLevel; + + /** Whether nether portals teleport entities */ + bool m_bNetherPortalsEnabled; + + /** Whether end portals teleport entities */ + bool m_bEndPortalsEnabled; + + /** Name of the nether world */ + AString m_NetherWorldName; + + /** Name of the end world */ + AString m_EndWorldName; cChunkGenerator m_Generator; -- cgit v1.2.3 From 7d3d9e92e89e726fc3e999ac343db06b694d95e7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 20:01:05 +0100 Subject: Fixed a NetherFinisher bug --- src/Generating/ChunkDesc.cpp | 21 --------------------- src/Generating/ChunkDesc.h | 3 --- src/Generating/FinishGen.cpp | 9 +++++++++ 3 files changed, 9 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp index 7711723fc..759d57b83 100644 --- a/src/Generating/ChunkDesc.cpp +++ b/src/Generating/ChunkDesc.cpp @@ -20,7 +20,6 @@ cChunkDesc::cChunkDesc(int a_ChunkX, int a_ChunkZ) : m_bUseDefaultBiomes(true), m_bUseDefaultHeight(true), m_bUseDefaultComposition(true), - m_bUseDefaultStructures(true), m_bUseDefaultFinish(true) { m_BlockArea.Create(cChunkDef::Width, cChunkDef::Height, cChunkDef::Width); @@ -207,26 +206,6 @@ bool cChunkDesc::IsUsingDefaultComposition(void) const -void cChunkDesc::SetUseDefaultStructures(bool a_bUseDefaultStructures) -{ - LOGWARNING("%s: Structures are no longer accounted for, use Finishers instead", __FUNCTION__); - m_bUseDefaultStructures = a_bUseDefaultStructures; -} - - - - - -bool cChunkDesc::IsUsingDefaultStructures(void) const -{ - LOGWARNING("%s: Structures are no longer accounted for, use Finishers instead", __FUNCTION__); - return m_bUseDefaultStructures; -} - - - - - void cChunkDesc::SetUseDefaultFinish(bool a_bUseDefaultFinish) { m_bUseDefaultFinish = a_bUseDefaultFinish; diff --git a/src/Generating/ChunkDesc.h b/src/Generating/ChunkDesc.h index 8edc2800b..2680fe3fa 100644 --- a/src/Generating/ChunkDesc.h +++ b/src/Generating/ChunkDesc.h @@ -68,8 +68,6 @@ public: bool IsUsingDefaultHeight(void) const; void SetUseDefaultComposition(bool a_bUseDefaultComposition); bool IsUsingDefaultComposition(void) const; - void SetUseDefaultStructures(bool a_bUseDefaultStructures); - bool IsUsingDefaultStructures(void) const; void SetUseDefaultFinish(bool a_bUseDefaultFinish); bool IsUsingDefaultFinish(void) const; @@ -214,7 +212,6 @@ private: bool m_bUseDefaultBiomes; bool m_bUseDefaultHeight; bool m_bUseDefaultComposition; - bool m_bUseDefaultStructures; bool m_bUseDefaultFinish; } ; // tolua_export diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index f2d66af70..c77145bc6 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -125,6 +125,15 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a float zz = (float) a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; for (int y = a_RelY - 2; y < a_RelY + 2; y++) { + if ( + ((x < 0) || (x >= cChunkDef::Width)) || + ((y < 0) || (y >= cChunkDef::Height)) || + ((z < 0) || (z >= cChunkDef::Width)) + ) + { + continue; + } + if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks. { continue; -- cgit v1.2.3 From 9c7a6bc443605612c09be824c452b9287fa2bfdb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 20:09:02 +0100 Subject: Health of monsters is now saved --- src/WorldStorage/NBTChunkSerializer.cpp | 1 + src/WorldStorage/WSSAnvil.cpp | 1 + 2 files changed, 2 insertions(+) (limited to 'src') diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index a3b0d57be..70c07af50 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -484,6 +484,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster) m_Writer.AddFloat("", a_Monster->GetDropChanceBoots()); m_Writer.EndList(); m_Writer.AddByte("CanPickUpLoot", (char)a_Monster->CanPickUpLoot()); + m_Writer.AddShort("Health", (short)a_Monster->GetHealth()); switch (a_Monster->GetMobType()) { case cMonster::mtBat: diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 1891762fd..f58e876e0 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -2456,6 +2456,7 @@ bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT & a_Monster.SetDropChanceBoots(DropChance[4]); bool CanPickUpLoot = (a_NBT.GetByte(a_NBT.FindChildByName(a_TagIdx, "CanPickUpLoot")) == 1); a_Monster.SetCanPickUpLoot(CanPickUpLoot); + a_Monster.SetHealth(a_NBT.GetShort(a_NBT.FindChildByName(a_TagIdx, "Health"))); return true; } -- cgit v1.2.3 From ea49abd113050eb36fb85ac792cdab0e901b77e6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 20:52:54 +0100 Subject: Time and weather is saved, part of #1058 Also fixed unreliability in Health and LootPickup loading. --- src/World.cpp | 12 ++++++++++++ src/WorldStorage/WSSAnvil.cpp | 13 ++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/World.cpp b/src/World.cpp index 345c894eb..739ae39d4 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -11,6 +11,7 @@ #include "ChunkMap.h" #include "Generating/ChunkDesc.h" #include "OSSupport/Timer.h" +#include // Serializers #include "WorldStorage/ScoreboardSerializer.h" @@ -569,6 +570,11 @@ void cWorld::Start(void) m_bUseChatPrefixes = IniFile.GetValueSetB("Mechanics", "UseChatPrefixes", true); m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true); int GameMode = IniFile.GetValueSetI("General", "Gamemode", (int)m_GameMode); + int Weather = IniFile.GetValueSetI("General", "Weather", (int)m_Weather); + + std::stringstream ss; + ss << m_TimeOfDay; + Int64 TimeOfDay = _atoi64(IniFile.GetValueSet("General", "TimeInTicks", ss.str()).c_str()); if ((GetDimension() != dimNether) && (GetDimension() != dimEnd)) { @@ -581,6 +587,7 @@ void cWorld::Start(void) // Adjust the enum-backed variables into their respective bounds: m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmAdventure); m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll); + m_Weather = (eWeather) Clamp(Weather, (int)wSunny, (int)wStorm); switch (GetDimension()) { @@ -759,6 +766,11 @@ void cWorld::Stop(void) IniFile.SetValueI("Physics", "TNTShrapnelLevel", (int)m_TNTShrapnelLevel); IniFile.SetValueB("Mechanics", "CommandBlocksEnabled", m_bCommandBlocksEnabled); IniFile.SetValueB("Mechanics", "UseChatPrefixes", m_bUseChatPrefixes); + IniFile.SetValueI("General", "Weather", (int)m_Weather); + + std::stringstream ss; + ss << m_TimeOfDay; + IniFile.SetValue("General", "TimeInTicks", ss.str()); IniFile.WriteFile(m_IniFileName); m_TickThread.Stop(); diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index f58e876e0..c84763ac2 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -2454,9 +2454,16 @@ bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT & a_Monster.SetDropChanceChestplate(DropChance[2]); a_Monster.SetDropChanceLeggings(DropChance[3]); a_Monster.SetDropChanceBoots(DropChance[4]); - bool CanPickUpLoot = (a_NBT.GetByte(a_NBT.FindChildByName(a_TagIdx, "CanPickUpLoot")) == 1); - a_Monster.SetCanPickUpLoot(CanPickUpLoot); - a_Monster.SetHealth(a_NBT.GetShort(a_NBT.FindChildByName(a_TagIdx, "Health"))); + + int LootTag = a_NBT.FindChildByName(a_TagIdx, "CanPickUpLoot"); + if (LootTag > 0) + { + bool CanPickUpLoot = (a_NBT.GetByte(LootTag) == 1); + a_Monster.SetCanPickUpLoot(CanPickUpLoot); + } + + int HealthTag = a_NBT.FindChildByName(a_TagIdx, "Health"); + a_Monster.SetHealth(HealthTag > 0 ? a_NBT.GetShort(HealthTag) : a_Monster.GetMaxHealth()); return true; } -- cgit v1.2.3 From 873043c8e46dfd1ec764fbd5b673173ffe88271f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 21:51:19 +0100 Subject: Suggestions --- src/Entities/Entity.cpp | 6 ++++-- src/Entities/Player.cpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 7d9c10ec6..2d8f385cb 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1063,7 +1063,8 @@ void cEntity::DetectPortal() { case dimNether: { - cIniFile OwnIni; OwnIni.ReadFile(GetWorld()->GetIniFileName()); + cIniFile OwnIni; + OwnIni.ReadFile(GetWorld()->GetIniFileName()); AString OverworldName = OwnIni.GetValue("General", "OverworldName", cRoot::Get()->GetDefaultWorld()->GetName()); cFile::CreateFolder(FILE_IO_PREFIX + OverworldName); @@ -1102,7 +1103,8 @@ void cEntity::DetectPortal() { case dimEnd: { - cIniFile OwnIni; OwnIni.ReadFile(GetWorld()->GetIniFileName()); + cIniFile OwnIni; + OwnIni.ReadFile(GetWorld()->GetIniFileName()); AString OverworldName = OwnIni.GetValue("General", "OverworldName", cRoot::Get()->GetDefaultWorld()->GetName()); cFile::CreateFolder(FILE_IO_PREFIX + OverworldName); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index eebc9ecf9..c2f384abf 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -89,6 +89,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) SetPosX(World->GetSpawnX()); SetPosY(World->GetSpawnY()); SetPosZ(World->GetSpawnZ()); + SetBedPos(Vector3i(World->GetSpawnX(), World->GetSpawnY(), World->GetSpawnZ())); LOGD("Player \"%s\" is connecting for the first time, spawning at default world spawn {%.2f, %.2f, %.2f}", a_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ() -- cgit v1.2.3 From 22236a103ac506b27236469f353f6ec24bd5f9c6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 23:23:09 +0100 Subject: Redstone fixes and improvements [SEE DESC] Haha, see desc. * Improved redstone speed through a marking dirty system. Only a select few devices are still continuously simulated * Fixed redstone crashing with recent piston changes --- src/Chunk.cpp | 1 + src/Chunk.h | 9 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 147 +++++++++++++++---------- 3 files changed, 96 insertions(+), 61 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 1aaf076df..44fcefbe1 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1514,6 +1514,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT } MarkDirty(); + m_IsRedstoneDirty = true; m_ChunkData.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType); diff --git a/src/Chunk.h b/src/Chunk.h index e92a5bc29..dfdabea04 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -332,6 +332,7 @@ public: if (hasChanged) { MarkDirty(); + m_IsRedstoneDirty = true; m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), a_Meta)); } @@ -378,10 +379,13 @@ public: cSandSimulatorChunkData & GetSandSimulatorData (void) { return m_SandSimulatorData; } cRedstoneSimulatorChunkData * GetRedstoneSimulatorData(void) { return &m_RedstoneSimulatorData; } + cRedstoneSimulatorChunkData * GetRedstoneSimulatorQueuedData(void) { return &m_RedstoneSimulatorQueuedData; } cIncrementalRedstoneSimulator::PoweredBlocksList * GetRedstoneSimulatorPoweredBlocksList(void) { return &m_RedstoneSimulatorPoweredBlocksList; } cIncrementalRedstoneSimulator::LinkedBlocksList * GetRedstoneSimulatorLinkedBlocksList(void) { return &m_RedstoneSimulatorLinkedBlocksList; }; cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList * GetRedstoneSimulatorSimulatedPlayerToggleableList(void) { return &m_RedstoneSimulatorSimulatedPlayerToggleableList; }; cIncrementalRedstoneSimulator::RepeatersDelayList * GetRedstoneSimulatorRepeatersDelayList(void) { return &m_RedstoneSimulatorRepeatersDelayList; }; + bool IsRedstoneDirty(void) const { return m_IsRedstoneDirty; } + void SetIsRedstoneDirty(bool a_Flag) { m_IsRedstoneDirty = a_Flag; } cBlockEntity * GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ); cBlockEntity * GetBlockEntity(const Vector3i & a_BlockPos) { return GetBlockEntity(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z); } @@ -449,13 +453,16 @@ private: cSandSimulatorChunkData m_SandSimulatorData; cRedstoneSimulatorChunkData m_RedstoneSimulatorData; + cRedstoneSimulatorChunkData m_RedstoneSimulatorQueuedData; cIncrementalRedstoneSimulator::PoweredBlocksList m_RedstoneSimulatorPoweredBlocksList; cIncrementalRedstoneSimulator::LinkedBlocksList m_RedstoneSimulatorLinkedBlocksList; cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList m_RedstoneSimulatorSimulatedPlayerToggleableList; cIncrementalRedstoneSimulator::RepeatersDelayList m_RedstoneSimulatorRepeatersDelayList; + /** Indicates if simulate-once blocks should be updated by the redstone simulator */ + bool m_IsRedstoneDirty; - // pick up a random block of this chunk + // Pick up a random block of this chunk void getRandomBlockCoords(int& a_X, int& a_Y, int& a_Z); void getThreeRandomNumber(int& a_X, int& a_Y, int& a_Z,int a_MaxX, int a_MaxY, int a_MaxZ); diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index f4355b33b..fb8a3e81d 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -89,6 +89,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list as it no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = PoweredBlocks->erase(itr); + a_Chunk->SetIsRedstoneDirty(true); continue; } else if ( @@ -103,6 +104,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = PoweredBlocks->erase(itr); + a_Chunk->SetIsRedstoneDirty(true); continue; } ++itr; @@ -118,6 +120,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); + a_Chunk->SetIsRedstoneDirty(true); continue; } else if ( @@ -131,6 +134,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); + a_Chunk->SetIsRedstoneDirty(true); continue; } } @@ -140,6 +144,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer powered through a valid middle block", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); + a_Chunk->SetIsRedstoneDirty(true); continue; } } @@ -205,7 +210,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, return; } - RedstoneSimulatorChunkData->push_back(cCoordWithBlockAndBool(RelX, a_BlockY, RelZ, Block, false)); + a_Chunk->GetRedstoneSimulatorQueuedData()->push_back(cCoordWithBlockAndBool(RelX, a_BlockY, RelZ, Block, false)); } @@ -214,22 +219,29 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) { - // We still attempt to simulate all blocks in the chunk every tick, because of outside influence that needs to be taken into account - // For example, repeaters need to be ticked, pressure plates checked for entities, daylight sensor checked for light changes, etc. - // The easiest way to make this more efficient is probably just to reduce code within the handlers that put too much strain on server, like getting or setting blocks - // A marking dirty system might be a TODO for later on, perhaps - m_RedstoneSimulatorChunkData = a_Chunk->GetRedstoneSimulatorData(); - if (m_RedstoneSimulatorChunkData->empty()) + if (m_RedstoneSimulatorChunkData->empty() && a_Chunk->GetRedstoneSimulatorQueuedData()->empty()) { return; } + m_RedstoneSimulatorChunkData->insert(m_RedstoneSimulatorChunkData->end(), a_Chunk->GetRedstoneSimulatorQueuedData()->begin(), a_Chunk->GetRedstoneSimulatorQueuedData()->end()); + a_Chunk->GetRedstoneSimulatorQueuedData()->clear(); + m_PoweredBlocks = a_Chunk->GetRedstoneSimulatorPoweredBlocksList(); m_RepeatersDelayList = a_Chunk->GetRedstoneSimulatorRepeatersDelayList(); m_SimulatedPlayerToggleableBlocks = a_Chunk->GetRedstoneSimulatorSimulatedPlayerToggleableList(); m_LinkedPoweredBlocks = a_Chunk->GetRedstoneSimulatorLinkedBlocksList(); m_Chunk = a_Chunk; + bool ShouldUpdateSimulateOnceBlocks = false; + + if (a_Chunk->IsRedstoneDirty()) + { + // Simulate the majority of devices only if something (blockwise or power-wise) has changed + // Make sure to allow the chunk to resimulate after the initial run if there was a power change (ShouldUpdateSimulateOnceBlocks helps to do this) + a_Chunk->SetIsRedstoneDirty(false); // + ShouldUpdateSimulateOnceBlocks = true; + } for (cRedstoneSimulatorChunkData::iterator dataitr = m_RedstoneSimulatorChunkData->begin(); dataitr != m_RedstoneSimulatorChunkData->end();) { @@ -241,65 +253,15 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int switch (dataitr->Data) { - case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_LEVER: HandleRedstoneLever(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_FENCE_GATE: HandleFenceGate(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_TNT: HandleTNT(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_TRAPDOOR: HandleTrapdoor(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_COMMAND_BLOCK: HandleCommandBlock(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_REDSTONE_TORCH_OFF: - case E_BLOCK_REDSTONE_TORCH_ON: - { - HandleRedstoneTorch(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); - break; - } - case E_BLOCK_STONE_BUTTON: - case E_BLOCK_WOODEN_BUTTON: - { - HandleRedstoneButton(dataitr->x, dataitr->y, dataitr->z); - break; - } case E_BLOCK_REDSTONE_REPEATER_OFF: case E_BLOCK_REDSTONE_REPEATER_ON: { HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); break; } - case E_BLOCK_PISTON: - case E_BLOCK_STICKY_PISTON: - { - HandlePiston(dataitr->x, dataitr->y, dataitr->z); - break; - } - case E_BLOCK_REDSTONE_LAMP_OFF: - case E_BLOCK_REDSTONE_LAMP_ON: - { - HandleRedstoneLamp(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); - break; - } - case E_BLOCK_DISPENSER: - case E_BLOCK_DROPPER: - { - HandleDropSpenser(dataitr->x, dataitr->y, dataitr->z); - break; - } - case E_BLOCK_WOODEN_DOOR: - case E_BLOCK_IRON_DOOR: - { - HandleDoor(dataitr->x, dataitr->y, dataitr->z); - break; - } - case E_BLOCK_ACTIVATOR_RAIL: - case E_BLOCK_DETECTOR_RAIL: - case E_BLOCK_POWERED_RAIL: - { - HandleRail(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); - break; - } case E_BLOCK_WOODEN_PRESSURE_PLATE: case E_BLOCK_STONE_PRESSURE_PLATE: case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: @@ -308,7 +270,66 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int HandlePressurePlate(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); break; } - default: LOGD("Unhandled block (!) or unimplemented redstone block: %s", ItemToString(dataitr->Data).c_str()); break; + default: break; + } + + if (ShouldUpdateSimulateOnceBlocks) + { + switch (dataitr->Data) + { + case E_BLOCK_COMMAND_BLOCK: HandleCommandBlock(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_LEVER: HandleRedstoneLever(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_FENCE_GATE: HandleFenceGate(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_TNT: HandleTNT(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_TRAPDOOR: HandleTrapdoor(dataitr->x, dataitr->y, dataitr->z); break; + + case E_BLOCK_ACTIVATOR_RAIL: + case E_BLOCK_DETECTOR_RAIL: + case E_BLOCK_POWERED_RAIL: + { + HandleRail(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + break; + } + case E_BLOCK_WOODEN_DOOR: + case E_BLOCK_IRON_DOOR: + { + HandleDoor(dataitr->x, dataitr->y, dataitr->z); + break; + } + case E_BLOCK_REDSTONE_LAMP_OFF: + case E_BLOCK_REDSTONE_LAMP_ON: + { + HandleRedstoneLamp(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + break; + } + case E_BLOCK_DISPENSER: + case E_BLOCK_DROPPER: + { + HandleDropSpenser(dataitr->x, dataitr->y, dataitr->z); + break; + } + case E_BLOCK_PISTON: + case E_BLOCK_STICKY_PISTON: + { + HandlePiston(dataitr->x, dataitr->y, dataitr->z); + break; + } + case E_BLOCK_REDSTONE_TORCH_OFF: + case E_BLOCK_REDSTONE_TORCH_ON: + { + HandleRedstoneTorch(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + break; + } + case E_BLOCK_STONE_BUTTON: + case E_BLOCK_WOODEN_BUTTON: + { + HandleRedstoneButton(dataitr->x, dataitr->y, dataitr->z); + break; + } + default: break; + } } ++dataitr; } @@ -1736,7 +1757,8 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl return; } - PoweredBlocksList * Powered = m_Chunk->GetNeighborChunk(BlockX, BlockZ)->GetRedstoneSimulatorPoweredBlocksList(); + cChunk * Neighbour = m_Chunk->GetNeighborChunk(BlockX, BlockZ); + PoweredBlocksList * Powered = Neighbour->GetRedstoneSimulatorPoweredBlocksList(); for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr) // Check powered list { if ( @@ -1768,6 +1790,8 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl RC.a_SourcePos = Vector3i(SourceX, a_RelSourceY, SourceZ); RC.a_PowerLevel = a_PowerLevel; Powered->push_back(RC); + Neighbour->SetIsRedstoneDirty(true); + m_Chunk->SetIsRedstoneDirty(true); } @@ -1807,7 +1831,8 @@ void cIncrementalRedstoneSimulator::SetBlockLinkedPowered( return; } - LinkedBlocksList * Linked = m_Chunk->GetNeighborChunk(BlockX, BlockZ)->GetRedstoneSimulatorLinkedBlocksList(); + cChunk * Neighbour = m_Chunk->GetNeighborChunk(BlockX, BlockZ); + LinkedBlocksList * Linked = Neighbour->GetRedstoneSimulatorLinkedBlocksList(); for (LinkedBlocksList::iterator itr = Linked->begin(); itr != Linked->end(); ++itr) // Check linked powered list { if ( @@ -1828,6 +1853,8 @@ void cIncrementalRedstoneSimulator::SetBlockLinkedPowered( RC.a_SourcePos = Vector3i(SourceX, a_RelSourceY, SourceZ); RC.a_PowerLevel = a_PowerLevel; Linked->push_back(RC); + Neighbour->SetIsRedstoneDirty(true); + m_Chunk->SetIsRedstoneDirty(true); } -- cgit v1.2.3 From f22a1b226ca1f5969ab9882c3f9c6f00c6c90aa2 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 5 Jun 2014 08:25:26 +0100 Subject: Fixed compilation --- src/Entities/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index c2f384abf..af4299e4b 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1576,7 +1576,7 @@ bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World) World = cRoot::Get()->GetWorld(a_WorldName); if (World == NULL) { - LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName); + LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName.c_str()); return false; } } -- cgit v1.2.3 From b73bf1a1e37a9455ff32cef37d23e0441d6ec555 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 5 Jun 2014 08:28:01 +0100 Subject: Fixed decision failure --- src/Mobs/Monster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index c25ee6b75..0f030da2d 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -1034,7 +1034,7 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk) (a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand (GetWorld()->GetTimeOfDay() < (12000 + 1000)) && // It is nighttime !IsOnFire() && // Not already burning - (IsBiomeNoDownfall(a_Chunk.GetBiomeAt(RelX, RelZ)) || GetWorld()->IsWeatherWet()) // Not raining + (IsBiomeNoDownfall(a_Chunk.GetBiomeAt(RelX, RelZ)) || !GetWorld()->IsWeatherWet()) // Not raining ) { // Burn for 100 ticks, then decide again -- cgit v1.2.3 From 720ae4f75777a8286014e9934429ab248df6d9e9 Mon Sep 17 00:00:00 2001 From: JoannisO Date: Thu, 5 Jun 2014 12:26:27 +0200 Subject: - Fixed a lot of alignment --- src/BlockEntities/DispenserEntity.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 475125719..97e25ca6d 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -196,7 +196,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) void cDispenserEntity::SpawnProjectileFromDispenser(int & a_BlockX, int & a_BlockY, int & a_BlockZ, cProjectileEntity::eKind a_Kind, Vector3d a_ShootVector) { - if( a_Kind != cProjectileEntity::pkFireCharge ) + if (a_Kind != cProjectileEntity::pkFireCharge) { a_ShootVector.y = a_ShootVector.y + 1; } @@ -209,14 +209,14 @@ Vector3d cDispenserEntity::GetShootVector(NIBBLETYPE & a_Meta) { switch(a_Meta) { - case E_META_DROPSPENSER_FACING_YP: return Vector3d(0, 1, 0); // UP - case E_META_DROPSPENSER_FACING_YM: return Vector3d(0, -1, 0); // DOWN + case E_META_DROPSPENSER_FACING_YP: return Vector3d( 0, 1, 0); // UP + case E_META_DROPSPENSER_FACING_YM: return Vector3d( 0, -1, 0); // DOWN - case E_META_DROPSPENSER_FACING_XM: return Vector3d(-1, 0, 0); // WEST - case E_META_DROPSPENSER_FACING_XP: return Vector3d(1, 0, 0); // EAST + case E_META_DROPSPENSER_FACING_XM: return Vector3d(-1, 0, 0); // WEST + case E_META_DROPSPENSER_FACING_XP: return Vector3d( 1, 0, 0); // EAST - case E_META_DROPSPENSER_FACING_ZM: return Vector3d(0, 0, -1); - case E_META_DROPSPENSER_FACING_ZP: return Vector3d(0, 0, 1); + case E_META_DROPSPENSER_FACING_ZM: return Vector3d( 0, 0, -1); + case E_META_DROPSPENSER_FACING_ZP: return Vector3d( 0, 0, 1); } return Vector3d(0, 1, 0); -- cgit v1.2.3 From 156c9851b8a099656fa86ea52d989e35e5b7ebf1 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 5 Jun 2014 17:58:29 +0100 Subject: Suggestions --- src/Blocks/WorldInterface.h | 4 +++- src/Chunk.cpp | 7 +++++-- src/Generating/ChunkGenerator.cpp | 2 +- src/World.cpp | 11 ++--------- src/World.h | 4 +++- 5 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h index 08600d502..7df82197e 100644 --- a/src/Blocks/WorldInterface.h +++ b/src/Blocks/WorldInterface.h @@ -37,7 +37,9 @@ public: virtual void SetTimeOfDay(Int64 a_TimeOfDay) = 0; - /** Returns true if the current weather has any precipitation - rain or storm */ + /** Returns true if the current weather has any precipitation - rain or storm + Does not check if biome has no downfall, use cChunk::GetBiomeAt(RelX, RelZ) for that + */ virtual bool IsWeatherWet(void) const = 0; }; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index c6122852a..2850dd93b 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -580,7 +580,10 @@ void cChunk::Tick(float a_Dt) { // Mobs are tickes inside MobTick (as we don't have to tick them if they are far away from players) // Don't tick things queued to be removed - if (!((*itr)->IsMob()) && (std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID()) == m_EntitiesToRemove.end())) + if ( + !((*itr)->IsMob()) && + (std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID()) == m_EntitiesToRemove.end()) + ) { (*itr)->Tick(a_Dt, *this); } @@ -588,7 +591,7 @@ void cChunk::Tick(float a_Dt) for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) { - std::vector::const_iterator itr2 = std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID()); + std::vector::iterator itr2 = std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID()); if (itr2 != m_EntitiesToRemove.end()) { itr = m_Entities.erase(itr); diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp index 73f0223e8..1f2958901 100644 --- a/src/Generating/ChunkGenerator.cpp +++ b/src/Generating/ChunkGenerator.cpp @@ -52,7 +52,7 @@ bool cChunkGenerator::Start(cPluginInterface & a_PluginInterface, cChunkSink & a m_ChunkSink = &a_ChunkSink; MTRand rnd; - m_Seed = a_IniFile.GetValueSetI("Seed", "Seed", rnd.randInt()); + m_Seed = a_IniFile.GetValueSetI("Seed", "Seed", (int)rnd.randInt()); AString GeneratorName = a_IniFile.GetValueSet("Generator", "Generator", "Composable"); if (NoCaseCompare(GeneratorName, "Noise3D") == 0) diff --git a/src/World.cpp b/src/World.cpp index 739ae39d4..3e02caf8e 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -11,7 +11,6 @@ #include "ChunkMap.h" #include "Generating/ChunkDesc.h" #include "OSSupport/Timer.h" -#include // Serializers #include "WorldStorage/ScoreboardSerializer.h" @@ -571,10 +570,7 @@ void cWorld::Start(void) m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true); int GameMode = IniFile.GetValueSetI("General", "Gamemode", (int)m_GameMode); int Weather = IniFile.GetValueSetI("General", "Weather", (int)m_Weather); - - std::stringstream ss; - ss << m_TimeOfDay; - Int64 TimeOfDay = _atoi64(IniFile.GetValueSet("General", "TimeInTicks", ss.str()).c_str()); + Int64 TimeOfDay = IniFile.GetValueSetI("General", "TimeInTicks", m_TimeOfDay); if ((GetDimension() != dimNether) && (GetDimension() != dimEnd)) { @@ -767,10 +763,7 @@ void cWorld::Stop(void) IniFile.SetValueB("Mechanics", "CommandBlocksEnabled", m_bCommandBlocksEnabled); IniFile.SetValueB("Mechanics", "UseChatPrefixes", m_bUseChatPrefixes); IniFile.SetValueI("General", "Weather", (int)m_Weather); - - std::stringstream ss; - ss << m_TimeOfDay; - IniFile.SetValue("General", "TimeInTicks", ss.str()); + IniFile.SetValueI("General", "TimeInTicks", m_TimeOfDay); IniFile.WriteFile(m_IniFileName); m_TickThread.Stop(); diff --git a/src/World.h b/src/World.h index 7b87a76ac..80f69f22f 100644 --- a/src/World.h +++ b/src/World.h @@ -715,7 +715,9 @@ public: bool IsWeatherRain (void) const { return (m_Weather == wRain); } bool IsWeatherStorm(void) const { return (m_Weather == wStorm); } - /** Returns true if the current weather has any precipitation - rain or storm */ + /** Returns true if the current weather has any precipitation - rain or storm + Does not check if biome has no downfall, use cChunk::GetBiomeAt(RelX, RelZ) for that + */ virtual bool IsWeatherWet(void) const override { return (m_Weather != wSunny); } // tolua_end -- cgit v1.2.3 From 5f56773dde8d06a291f42def9302ad932c490a28 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 6 Jun 2014 20:36:50 +0100 Subject: Further reduced redstone idle CPU consumption * Repeaters and wires are no longer unnecessarily ticked * Fixed #1063, likely addressed #1062 * Fixed bugs regarding duplicate values --- src/Simulator/IncrementalRedstoneSimulator.cpp | 34 ++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index fb8a3e81d..21326c7c4 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -209,7 +209,15 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { return; } - + + for (cRedstoneSimulatorChunkData::iterator itr = a_Chunk->GetRedstoneSimulatorQueuedData()->begin(); itr != a_Chunk->GetRedstoneSimulatorQueuedData()->end(); ++itr) + { + if ((itr->x == RelX) && (itr->y == a_BlockY) && (itr->z == RelZ)) + { + // Can't have duplicates in here either, in case something adds the block again before the structure can written to the main chunk data + return; + } + } a_Chunk->GetRedstoneSimulatorQueuedData()->push_back(cCoordWithBlockAndBool(RelX, a_BlockY, RelZ, Block, false)); } @@ -239,7 +247,7 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int { // Simulate the majority of devices only if something (blockwise or power-wise) has changed // Make sure to allow the chunk to resimulate after the initial run if there was a power change (ShouldUpdateSimulateOnceBlocks helps to do this) - a_Chunk->SetIsRedstoneDirty(false); // + a_Chunk->SetIsRedstoneDirty(false); ShouldUpdateSimulateOnceBlocks = true; } @@ -253,13 +261,24 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int switch (dataitr->Data) { - case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_REDSTONE_REPEATER_OFF: case E_BLOCK_REDSTONE_REPEATER_ON: { - HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + if (ShouldUpdateSimulateOnceBlocks) + { + HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + break; + } + for (RepeatersDelayList::const_iterator repeateritr = m_RepeatersDelayList->begin(); repeateritr != m_RepeatersDelayList->end(); ++repeateritr) + { + if (repeateritr->a_RelBlockPos == Vector3i(dataitr->x, dataitr->y, dataitr->z)) + { + HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + break; + } + } break; } case E_BLOCK_WOODEN_PRESSURE_PLATE: @@ -277,10 +296,11 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int { switch (dataitr->Data) { + case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_COMMAND_BLOCK: HandleCommandBlock(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_LEVER: HandleRedstoneLever(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_LEVER: HandleRedstoneLever(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_FENCE_GATE: HandleFenceGate(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_TNT: HandleTNT(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_TRAPDOOR: HandleTrapdoor(dataitr->x, dataitr->y, dataitr->z); break; -- cgit v1.2.3 From 43342540c80169c1d539751cfd48cae99d97e058 Mon Sep 17 00:00:00 2001 From: worktycho Date: Fri, 6 Jun 2014 23:54:24 +0100 Subject: Fixed Time of day --- src/World.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/World.cpp b/src/World.cpp index 3e02caf8e..1b5582b81 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -570,7 +570,7 @@ void cWorld::Start(void) m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true); int GameMode = IniFile.GetValueSetI("General", "Gamemode", (int)m_GameMode); int Weather = IniFile.GetValueSetI("General", "Weather", (int)m_Weather); - Int64 TimeOfDay = IniFile.GetValueSetI("General", "TimeInTicks", m_TimeOfDay); + m_TimeOfDay = IniFile.GetValueSetI("General", "TimeInTicks", m_TimeOfDay); if ((GetDimension() != dimNether) && (GetDimension() != dimEnd)) { -- cgit v1.2.3 From b768e54ce88819f3363b55879c0550b2830b3a56 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 00:40:01 -0700 Subject: Fixed mob hitbox sizes, removed TODOs Measured bat and blaze in vanilla, updated values. Cavespiders are, in fact, passive in the day. --- src/Mobs/Bat.cpp | 3 +-- src/Mobs/Blaze.cpp | 3 +-- src/Mobs/CaveSpider.cpp | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Mobs/Bat.cpp b/src/Mobs/Bat.cpp index 1417ddd9e..c072d4f48 100644 --- a/src/Mobs/Bat.cpp +++ b/src/Mobs/Bat.cpp @@ -7,8 +7,7 @@ cBat::cBat(void) : - // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here - super("Bat", mtBat, "mob.bat.hurt", "mob.bat.death", 0.7, 0.7) + super("Bat", mtBat, "mob.bat.hurt", "mob.bat.death", 0.5, 0.9) { } diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp index 326b42f07..2a6a761bf 100644 --- a/src/Mobs/Blaze.cpp +++ b/src/Mobs/Blaze.cpp @@ -9,8 +9,7 @@ cBlaze::cBlaze(void) : - // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here - super("Blaze", mtBlaze, "mob.blaze.hit", "mob.blaze.death", 0.7, 1.8) + super("Blaze", mtBlaze, "mob.blaze.hit", "mob.blaze.death", 0.6, 1.8) { } diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp index 56ecd2d28..1157b81f9 100644 --- a/src/Mobs/CaveSpider.cpp +++ b/src/Mobs/CaveSpider.cpp @@ -20,7 +20,6 @@ void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - // TODO: Check vanilla if cavespiders really get passive during the day / in daylight m_EMPersonality = (GetWorld()->GetTimeOfDay() < (12000 + 1000)) ? PASSIVE : AGGRESSIVE; } -- cgit v1.2.3 From d5649df326d90361bbf64e2ebb4893caa0499521 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 6 Jun 2014 23:23:28 +0100 Subject: Further improvements on redstone speed Based on suggestions of @worktycho * Repeaters now walk their data structure only when needed * Fixed a bug with cChunkData returning an incorrect value for whether a meta had changed --- src/ChunkData.cpp | 2 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 141 ++++++++++++++----------- src/Simulator/IncrementalRedstoneSimulator.h | 6 +- 3 files changed, 81 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 1fa2fd212..f2d220bd2 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -258,7 +258,7 @@ bool cChunkData::SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble (m_Sections[Section]->m_BlockMetas[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set ); - return oldval == a_Nibble; + return oldval != a_Nibble; } diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 21326c7c4..aef332e9f 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -266,19 +266,20 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int case E_BLOCK_REDSTONE_REPEATER_OFF: case E_BLOCK_REDSTONE_REPEATER_ON: { - if (ShouldUpdateSimulateOnceBlocks) - { - HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); - break; - } - for (RepeatersDelayList::const_iterator repeateritr = m_RepeatersDelayList->begin(); repeateritr != m_RepeatersDelayList->end(); ++repeateritr) + bool FoundItem = false; + for (RepeatersDelayList::iterator repeateritr = m_RepeatersDelayList->begin(); repeateritr != m_RepeatersDelayList->end(); ++repeateritr) { if (repeateritr->a_RelBlockPos == Vector3i(dataitr->x, dataitr->y, dataitr->z)) { - HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data, repeateritr); + FoundItem = true; break; } } + if (!FoundItem && ShouldUpdateSimulateOnceBlocks) + { + HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data, m_RepeatersDelayList->end()); + } break; } case E_BLOCK_WOODEN_PRESSURE_PLATE: @@ -746,7 +747,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re -void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState) +void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState, RepeatersDelayList::iterator a_Itr) { /* Repeater Orientation Mini Guide: =================================== @@ -772,87 +773,99 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int // Create a variable holding my meta to avoid multiple lookups. NIBBLETYPE a_Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); bool IsOn = (a_MyState == E_BLOCK_REDSTONE_REPEATER_ON); - + + bool WereItrsChanged = false; if (!IsRepeaterLocked(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta)) // If we're locked, change nothing. Otherwise: { bool IsSelfPowered = IsRepeaterPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta); if (IsSelfPowered && !IsOn) // Queue a power change if powered, but not on and not locked. { - QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, true); + WereItrsChanged = QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, true); } else if (!IsSelfPowered && IsOn) // Queue a power change if unpowered, on, and not locked. { - QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false); + WereItrsChanged = QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false); + } + else + { + return; } } + else + { + return; + } - for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end(); ++itr) + if (WereItrsChanged) { - if (!itr->a_RelBlockPos.Equals(Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) + for (a_Itr = m_RepeatersDelayList->begin(); a_Itr != m_RepeatersDelayList->end(); ++a_Itr) { - continue; + if (a_Itr->a_RelBlockPos == Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) + { + break; + } } + } - if (itr->a_ElapsedTicks >= itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks? + if (a_Itr->a_ElapsedTicks >= a_Itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks? + { + if (a_Itr->ShouldPowerOn) { - if (itr->ShouldPowerOn) + if (!IsOn) { - if (!IsOn) + m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_REPEATER_ON, a_Meta); // For performance + } + + switch (a_Meta & 0x3) // We only want the direction (bottom) bits + { + case 0x0: { - m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_REPEATER_ON, a_Meta); // For performance + SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM); + break; } - - switch (a_Meta & 0x3) // We only want the direction (bottom) bits + case 0x1: { - case 0x0: - { - SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM); - break; - } - case 0x1: - { - SetBlockPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP); - break; - } - case 0x2: - { - SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP); - break; - } - case 0x3: - { - SetBlockPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM); - break; - } + SetBlockPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP); + break; } - - // Removal of the data entry will be handled in SimChunk - we still want to continue trying to power blocks, even if our delay time has reached - // Otherwise, the power state of blocks in front won't update after we have powered on - return; - } - else - { - if (IsOn) + case 0x2: + { + SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP); + break; + } + case 0x3: { - m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta); + SetBlockPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM); + break; } - m_RepeatersDelayList->erase(itr); // We can remove off repeaters which don't need further updating - return; } + + // Removal of the data entry will be handled in SimChunk - we still want to continue trying to power blocks, even if our delay time has reached + // Otherwise, the power state of blocks in front won't update after we have powered on + return; } else { - // Apparently, incrementing ticks only works reliably here, and not in SimChunk; - // With a world with lots of redstone, the repeaters simply do not delay - // I am confounded to say why. Perhaps optimisation failure. - LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", itr->a_RelBlockPos.x, itr->a_RelBlockPos.y, itr->a_RelBlockPos.z, itr->a_ElapsedTicks, itr->a_DelayTicks); - itr->a_ElapsedTicks++; + if (IsOn) + { + m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta); + } + m_RepeatersDelayList->erase(a_Itr); // We can remove off repeaters which don't need further updating + return; } } + else + { + // Apparently, incrementing ticks only works reliably here, and not in SimChunk; + // With a world with lots of redstone, the repeaters simply do not delay + // I am confounded to say why. Perhaps optimisation failure. + LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", a_Itr->a_RelBlockPos.x, a_Itr->a_RelBlockPos.y, a_Itr->a_RelBlockPos.z, a_Itr->a_ElapsedTicks, a_Itr->a_DelayTicks); + a_Itr->a_ElapsedTicks++; + } } @@ -1914,7 +1927,7 @@ void cIncrementalRedstoneSimulator::SetPlayerToggleableBlockAsSimulated(int a_Re -void cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn) +bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn) { for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end(); ++itr) { @@ -1922,14 +1935,14 @@ void cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in { if (ShouldPowerOn == itr->ShouldPowerOn) // We are queued already for the same thing, don't replace entry { - return; + return false; } // Already in here (normal to allow repeater to continue on powering and updating blocks in front) - just update info and quit itr->a_DelayTicks = (((a_Meta & 0xC) >> 0x2) + 1) * 2; // See below for description itr->a_ElapsedTicks = 0; itr->ShouldPowerOn = ShouldPowerOn; - return; + return false; } } @@ -1944,7 +1957,7 @@ void cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in RC.a_ElapsedTicks = 0; RC.ShouldPowerOn = ShouldPowerOn; m_RepeatersDelayList->push_back(RC); - return; + return true; } diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index 233a3d408..83076311a 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -108,7 +108,7 @@ private: /** Handles redstone wire */ void HandleRedstoneWire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles repeaters */ - void HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState); + void HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState, RepeatersDelayList::iterator a_Itr); /* ====================== */ /* ====== DEVICES ====== */ @@ -145,8 +145,8 @@ private: void SetDirectionLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, char a_Direction, unsigned char a_PowerLevel = MAX_POWER_LEVEL); /** Marks all blocks immediately surrounding a coordinate as powered */ void SetAllDirsAsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char a_PowerLevel = MAX_POWER_LEVEL); - /** Queues a repeater to be powered or unpowered */ - void QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn); + /** Queues a repeater to be powered or unpowered and returns if the m_RepeatersDelayList iterators were invalidated */ + bool QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn); /** Returns if a coordinate is powered or linked powered */ bool AreCoordsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { return AreCoordsDirectlyPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ) || AreCoordsLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); } -- cgit v1.2.3 From ec40c7c83ad1ef62b2c8e759bd9a76cf916f5e5b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 5 Jun 2014 23:44:31 +0200 Subject: Added RainbowRoads finisher generator. --- src/Generating/ComposableGenerator.cpp | 14 +- src/Generating/Prefabs/RainbowRoadPrefabs.cpp | 1406 +++++++++++++++++++++++++ src/Generating/Prefabs/RainbowRoadPrefabs.h | 15 + src/Generating/RainbowRoadsGen.cpp | 115 ++ src/Generating/RainbowRoadsGen.h | 47 + 5 files changed, 1594 insertions(+), 3 deletions(-) create mode 100644 src/Generating/Prefabs/RainbowRoadPrefabs.cpp create mode 100644 src/Generating/Prefabs/RainbowRoadPrefabs.h create mode 100644 src/Generating/RainbowRoadsGen.cpp create mode 100644 src/Generating/RainbowRoadsGen.h (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index cf736ce64..1801b7375 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -24,6 +24,7 @@ #include "NetherFortGen.h" #include "Noise3DGenerator.h" #include "POCPieceGenerator.h" +#include "RainbowRoadsGen.h" #include "Ravines.h" #include "UnderwaterBaseGen.h" #include "VillageGen.h" @@ -391,6 +392,13 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) { m_FinishGens.push_back(new cFinishGenPreSimulator); } + else if (NoCaseCompare(*itr, "RainbowRoads") == 0) + { + int GridSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsGridSize", 512); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxDepth", 30); + int MaxSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxSize", 260); + m_FinishGens.push_back(new cRainbowRoadsGen(Seed, GridSize, MaxDepth, MaxSize)); + } else if (NoCaseCompare(*itr, "Ravines") == 0) { m_FinishGens.push_back(new cStructGenRavines(Seed, 128)); @@ -409,9 +417,9 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "UnderwaterBases") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseGridSize", 1024); - int MaxDepth = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxDepth", 7); - int MaxSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxSize", 128); + int GridSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseGridSize", 1024); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxDepth", 7); + int MaxSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxSize", 128); m_FinishGens.push_back(new cUnderwaterBaseGen(Seed, GridSize, MaxDepth, MaxSize, *m_BiomeGen)); } else if (NoCaseCompare(*itr, "Villages") == 0) diff --git a/src/Generating/Prefabs/RainbowRoadPrefabs.cpp b/src/Generating/Prefabs/RainbowRoadPrefabs.cpp new file mode 100644 index 000000000..1a3765c5a --- /dev/null +++ b/src/Generating/Prefabs/RainbowRoadPrefabs.cpp @@ -0,0 +1,1406 @@ + +// RainbowRoadPrefabs.cpp + +// Defines the prefabs in the group RainbowRoad + +// NOTE: This file has been generated automatically by GalExport! +// Any manual changes will be overwritten by the next automatic export! + +#include "Globals.h" +#include "RainbowRoadPrefabs.h" + + + + + +const cPrefab::sDef g_RainbowRoadPrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CurveDouble: + // The data has been exported from the gallery Cube, area index 89, ID 467, created by Aloe_vera + { + // Size: + 14, 1, 14, // SizeX = 14, SizeY = 1, SizeZ = 14 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 13, 2, 13, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:11\n" /* wool */ + "b: 35: 3\n" /* wool */ + "c: 35: 5\n" /* wool */ + "d: 35: 4\n" /* wool */ + "e: 35: 1\n" /* wool */ + "f: 35:14\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "aaaaaa........" + /* 1 */ "bbbbbba......." + /* 2 */ "cccccbbaaa...." + /* 3 */ "dddddccbbaa..." + /* 4 */ "eeeeeddccbaa.." + /* 5 */ "fffffeddccba.." + /* 6 */ "ffffffeedcbaa." + /* 7 */ "eeeefffeddcba." + /* 8 */ "dddeefffedcbba" + /* 9 */ "cccddefffedcba" + /* 10 */ "bbccdeeffedcba" + /* 11 */ "abbccdeffedcba" + /* 12 */ ".abbcdeffedcba" + /* 13 */ "..abcdeffedcba", + + // Connectors: + "2: 2, 1, 13: 3\n" /* Type 2, direction Z+ */ + "2: 0, 1, 0: 4\n" /* Type 2, direction X- */ + "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */ + "-2: 13, 1, 13: 3\n" /* Type -2, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CurveDouble + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CurveDownFromTopSingle: + // The data has been exported from the gallery Cube, area index 100, ID 478, created by Aloe_vera + { + // Size: + 11, 8, 11, // SizeX = 11, SizeY = 8, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 10, 9, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 5\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 1\n" /* wool */ + "e: 35:11\n" /* wool */ + "f: 35: 3\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........a" + /* 9 */ ".......bcda" + /* 10 */ ".....efbcda" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "........cda" + /* 7 */ ".......bcda" + /* 8 */ ".......bcd." + /* 9 */ ".....ef...." + /* 10 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ ".........a." + /* 5 */ ".......cdda" + /* 6 */ "......bc..." + /* 7 */ "......b...." + /* 8 */ ".....ff...." + /* 9 */ "....ee....." + /* 10 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "........aa." + /* 4 */ "......ccd.." + /* 5 */ ".....bb...." + /* 6 */ ".....f....." + /* 7 */ "....ef....." + /* 8 */ "....e......" + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "......daa.." + /* 3 */ ".....ccd..." + /* 4 */ "....bb....." + /* 5 */ "....f......" + /* 6 */ "...ef......" + /* 7 */ "...ee......" + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".....daa..." + /* 2 */ "...ccd....." + /* 3 */ "...bc......" + /* 4 */ "...b......." + /* 5 */ "..ff......." + /* 6 */ "..ee......." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "...aaa....." + /* 1 */ "..ddd......" + /* 2 */ ".cc........" + /* 3 */ ".bb........" + /* 4 */ ".ff........" + /* 5 */ ".e........." + /* 6 */ ".ee........" + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaa........" + /* 1 */ "dd........." + /* 2 */ "cc........." + /* 3 */ "bb........." + /* 4 */ "ff........." + /* 5 */ "e.........." + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "...........", + + // Connectors: + "-1: 0, 8, 5: 4\n" /* Type -1, direction X- */ + "1: 5, 1, 10: 3\n" /* Type 1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CurveDownFromTopSingle + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CurveSingle: + // The data has been exported from the gallery Cube, area index 84, ID 462, created by Aloe_vera + { + // Size: + 11, 1, 11, // SizeX = 11, SizeY = 1, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 10, 2, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 1\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 5\n" /* wool */ + "e: 35: 3\n" /* wool */ + "f: 35:11\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaaaaa....." + /* 1 */ "bbbbbbaa..." + /* 2 */ "cccccbbaa.." + /* 3 */ "ddddcccbaa." + /* 4 */ "eeedddccba." + /* 5 */ "ffeeeddcbba" + /* 6 */ ".fffeedccba" + /* 7 */ "...ffeddcba" + /* 8 */ "....feedcba" + /* 9 */ "....ffedcba" + /* 10 */ ".....fedcba", + + // Connectors: + "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */ + "1: 5, 1, 10: 3\n" /* Type 1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CurveSingle + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CurveSingleLeft: + // The data has been exported from the gallery Cube, area index 97, ID 475, created by Aloe_vera + { + // Size: + 11, 1, 11, // SizeX = 11, SizeY = 1, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 10, 2, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 1\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 5\n" /* wool */ + "e: 35: 3\n" /* wool */ + "f: 35:11\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ ".....abcdef" + /* 1 */ "....aabcdef" + /* 2 */ "....abbcdef" + /* 3 */ "...aabccdef" + /* 4 */ ".aaabbcddef" + /* 5 */ "aabbbccdeef" + /* 6 */ "bbbcccddef." + /* 7 */ "ccccdddeff." + /* 8 */ "dddddeeff.." + /* 9 */ "eeeeeeff..." + /* 10 */ "ffffff.....", + + // Connectors: + "-1: 0, 1, 10: 4\n" /* Type -1, direction X- */ + "1: 10, 1, 0: 2\n" /* Type 1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CurveSingleLeft + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CurveUpDouble: + // The data has been exported from the gallery Cube, area index 92, ID 470, created by Aloe_vera + { + // Size: + 14, 8, 14, // SizeX = 14, SizeY = 8, SizeZ = 14 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 13, 9, 13, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:11\n" /* wool */ + "b: 35: 3\n" /* wool */ + "c: 35: 5\n" /* wool */ + "d: 35: 4\n" /* wool */ + "e: 35: 1\n" /* wool */ + "f: 35:14\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "a............." + /* 1 */ "b............." + /* 2 */ "c............." + /* 3 */ "d............." + /* 4 */ "e............." + /* 5 */ "f............." + /* 6 */ "f............." + /* 7 */ "e............." + /* 8 */ "d............." + /* 9 */ "c............." + /* 10 */ "b............." + /* 11 */ "a............." + /* 12 */ ".............." + /* 13 */ ".............." + + // Level 1 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".aa..........." + /* 1 */ ".bb..........." + /* 2 */ ".cc..........." + /* 3 */ ".dd..........." + /* 4 */ ".ee..........." + /* 5 */ ".f............" + /* 6 */ ".f............" + /* 7 */ ".e............" + /* 8 */ ".d............" + /* 9 */ ".c............" + /* 10 */ ".b............" + /* 11 */ ".b............" + /* 12 */ ".............." + /* 13 */ ".............." + + // Level 2 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "...aaa........" + /* 1 */ "...bb........." + /* 2 */ "...cc........." + /* 3 */ "...dd........." + /* 4 */ "...ee........." + /* 5 */ "..ff.........." + /* 6 */ "..ff.........." + /* 7 */ "..ee.........." + /* 8 */ "..de.........." + /* 9 */ "..c..........." + /* 10 */ ".b............" + /* 11 */ ".b............" + /* 12 */ ".............." + /* 13 */ ".............." + + // Level 3 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".....baa......" + /* 2 */ ".....bbaaa...." + /* 3 */ "....dccbba...." + /* 4 */ "....eddcc....." + /* 5 */ "....fedd......" + /* 6 */ "....ffee......" + /* 7 */ "....ff........" + /* 8 */ "....e........." + /* 9 */ "...dd........." + /* 10 */ "..cc.........." + /* 11 */ "..b..........." + /* 12 */ ".a............" + /* 13 */ ".............." + + // Level 4 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".............." + /* 2 */ ".............." + /* 3 */ "..........a..." + /* 4 */ ".........ba..." + /* 5 */ "........cc...." + /* 6 */ ".......edc...." + /* 7 */ "......fedd...." + /* 8 */ ".....ff......." + /* 9 */ "....de........" + /* 10 */ "...cde........" + /* 11 */ "..b..........." + /* 12 */ ".a............" + /* 13 */ ".............." + + // Level 5 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".............." + /* 2 */ ".............." + /* 3 */ ".............." + /* 4 */ "...........a.." + /* 5 */ "..........ba.." + /* 6 */ "..........baa." + /* 7 */ "..........cba." + /* 8 */ ".......fedcb.." + /* 9 */ "......fffed..." + /* 10 */ ".....eef......" + /* 11 */ "...ccd........" + /* 12 */ "..b..........." + /* 13 */ ".............." + + // Level 6 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".............." + /* 2 */ ".............." + /* 3 */ ".............." + /* 4 */ ".............." + /* 5 */ ".............." + /* 6 */ ".............." + /* 7 */ ".............." + /* 8 */ "............ba" + /* 9 */ "...........cba" + /* 10 */ "........fedcba" + /* 11 */ "......effedc.." + /* 12 */ "..bbcdef......" + /* 13 */ "..a..........." + + // Level 7 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".............." + /* 2 */ ".............." + /* 3 */ ".............." + /* 4 */ ".............." + /* 5 */ ".............." + /* 6 */ ".............." + /* 7 */ ".............." + /* 8 */ ".............." + /* 9 */ ".............." + /* 10 */ ".............." + /* 11 */ "............ba" + /* 12 */ "........fedcba" + /* 13 */ "..abcdeffedcba", + + // Connectors: + "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */ + "2: 0, 1, 0: 4\n" /* Type 2, direction X- */ + "2: 2, 8, 13: 3\n" /* Type 2, direction Z+ */ + "-2: 13, 8, 13: 3\n" /* Type -2, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CurveUpDouble + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CurveUpSingle: + // The data has been exported from the gallery Cube, area index 87, ID 465, created by Aloe_vera + { + // Size: + 11, 8, 11, // SizeX = 11, SizeY = 8, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 10, 9, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 1\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 5\n" /* wool */ + "e: 35: 3\n" /* wool */ + "f: 35:11\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaa........" + /* 1 */ "bb........." + /* 2 */ "cc........." + /* 3 */ "dd........." + /* 4 */ "ee........." + /* 5 */ "f.........." + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "...aaa....." + /* 1 */ "..bbb......" + /* 2 */ ".cc........" + /* 3 */ ".dd........" + /* 4 */ ".ee........" + /* 5 */ ".f........." + /* 6 */ ".ff........" + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".....baa..." + /* 2 */ "...ccb....." + /* 3 */ "...dc......" + /* 4 */ "...d......." + /* 5 */ "..ee......." + /* 6 */ "..ff......." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "......baa.." + /* 3 */ ".....ccb..." + /* 4 */ "....dd....." + /* 5 */ "....e......" + /* 6 */ "...fe......" + /* 7 */ "...ff......" + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "........aa." + /* 4 */ "......ccb.." + /* 5 */ ".....dd...." + /* 6 */ ".....e....." + /* 7 */ "....fe....." + /* 8 */ "....f......" + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ ".........a." + /* 5 */ ".......cbba" + /* 6 */ "......dc..." + /* 7 */ "......d...." + /* 8 */ ".....ee...." + /* 9 */ "....ff....." + /* 10 */ "..........." + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "........cba" + /* 7 */ ".......dcba" + /* 8 */ ".......dcb." + /* 9 */ ".....fe...." + /* 10 */ ".....f....." + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........a" + /* 9 */ ".......dcba" + /* 10 */ ".....fedcba", + + // Connectors: + "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */ + "1: 5, 8, 10: 3\n" /* Type 1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CurveUpSingle + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // SlopeDownFromTopSingle: + // The data has been exported from the gallery Cube, area index 98, ID 476, created by Aloe_vera + { + // Size: + 16, 8, 6, // SizeX = 16, SizeY = 8, SizeZ = 6 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 15, 9, 5, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 1\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 5\n" /* wool */ + "e: 35: 3\n" /* wool */ + "f: 35:11\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..............aa" + /* 1 */ "..............bb" + /* 2 */ "..............cc" + /* 3 */ "..............dd" + /* 4 */ "..............ee" + /* 5 */ "..............ff" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "............aa.." + /* 1 */ "............bb.." + /* 2 */ "............cc.." + /* 3 */ "............dd.." + /* 4 */ "............ee.." + /* 5 */ "............ff.." + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..........aa...." + /* 1 */ "..........bb...." + /* 2 */ "..........cc...." + /* 3 */ "..........dd...." + /* 4 */ "..........ee...." + /* 5 */ "..........ff...." + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "........aa......" + /* 1 */ "........bb......" + /* 2 */ "........cc......" + /* 3 */ "........dd......" + /* 4 */ "........ee......" + /* 5 */ "........ff......" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "......aa........" + /* 1 */ "......bb........" + /* 2 */ "......cc........" + /* 3 */ "......dd........" + /* 4 */ "......ee........" + /* 5 */ "......ff........" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "....aa.........." + /* 1 */ "....bb.........." + /* 2 */ "....cc.........." + /* 3 */ "....dd.........." + /* 4 */ "....ee.........." + /* 5 */ "....ff.........." + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..aa............" + /* 1 */ "..bb............" + /* 2 */ "..cc............" + /* 3 */ "..dd............" + /* 4 */ "..ee............" + /* 5 */ "..ff............" + + // Level 7 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aa.............." + /* 1 */ "bb.............." + /* 2 */ "cc.............." + /* 3 */ "dd.............." + /* 4 */ "ee.............." + /* 5 */ "ff..............", + + // Connectors: + "-1: 0, 8, 5: 4\n" /* Type -1, direction X- */ + "1: 15, 1, 5: 5\n" /* Type 1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // SlopeDownFromTopSingle + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // SlopeUpDouble: + // The data has been exported from the gallery Cube, area index 90, ID 468, created by Aloe_vera + { + // Size: + 16, 8, 12, // SizeX = 16, SizeY = 8, SizeZ = 12 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 15, 9, 11, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:11\n" /* wool */ + "b: 35: 3\n" /* wool */ + "c: 35: 5\n" /* wool */ + "d: 35: 4\n" /* wool */ + "e: 35: 1\n" /* wool */ + "f: 35:14\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aa.............." + /* 1 */ "bb.............." + /* 2 */ "cc.............." + /* 3 */ "dd.............." + /* 4 */ "ee.............." + /* 5 */ "ff.............." + /* 6 */ "ff.............." + /* 7 */ "ee.............." + /* 8 */ "dd.............." + /* 9 */ "cc.............." + /* 10 */ "bb.............." + /* 11 */ "aa.............." + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..aa............" + /* 1 */ "..bb............" + /* 2 */ "..cc............" + /* 3 */ "..dd............" + /* 4 */ "..ee............" + /* 5 */ "..ff............" + /* 6 */ "..ff............" + /* 7 */ "..ee............" + /* 8 */ "..dd............" + /* 9 */ "..cc............" + /* 10 */ "..bb............" + /* 11 */ "..aa............" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "....aa.........." + /* 1 */ "....bb.........." + /* 2 */ "....cc.........." + /* 3 */ "....dd.........." + /* 4 */ "....ee.........." + /* 5 */ "....ff.........." + /* 6 */ "....ff.........." + /* 7 */ "....ee.........." + /* 8 */ "....dd.........." + /* 9 */ "....cc.........." + /* 10 */ "....bb.........." + /* 11 */ "....aa.........." + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "......aa........" + /* 1 */ "......bb........" + /* 2 */ "......cc........" + /* 3 */ "......dd........" + /* 4 */ "......ee........" + /* 5 */ "......ff........" + /* 6 */ "......ff........" + /* 7 */ "......ee........" + /* 8 */ "......dd........" + /* 9 */ "......cc........" + /* 10 */ "......bb........" + /* 11 */ "......aa........" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "........aa......" + /* 1 */ "........bb......" + /* 2 */ "........cc......" + /* 3 */ "........dd......" + /* 4 */ "........ee......" + /* 5 */ "........ff......" + /* 6 */ "........ff......" + /* 7 */ "........ee......" + /* 8 */ "........dd......" + /* 9 */ "........cc......" + /* 10 */ "........bb......" + /* 11 */ "........aa......" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..........aa...." + /* 1 */ "..........bb...." + /* 2 */ "..........cc...." + /* 3 */ "..........dd...." + /* 4 */ "..........ee...." + /* 5 */ "..........ff...." + /* 6 */ "..........ff...." + /* 7 */ "..........ee...." + /* 8 */ "..........dd...." + /* 9 */ "..........cc...." + /* 10 */ "..........bb...." + /* 11 */ "..........aa...." + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "............aa.." + /* 1 */ "............bb.." + /* 2 */ "............cc.." + /* 3 */ "............dd.." + /* 4 */ "............ee.." + /* 5 */ "............ff.." + /* 6 */ "............ff.." + /* 7 */ "............ee.." + /* 8 */ "............dd.." + /* 9 */ "............cc.." + /* 10 */ "............bb.." + /* 11 */ "............aa.." + + // Level 7 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..............aa" + /* 1 */ "..............bb" + /* 2 */ "..............cc" + /* 3 */ "..............dd" + /* 4 */ "..............ee" + /* 5 */ "..............ff" + /* 6 */ "..............ff" + /* 7 */ "..............ee" + /* 8 */ "..............dd" + /* 9 */ "..............cc" + /* 10 */ "..............bb" + /* 11 */ "..............aa", + + // Connectors: + "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */ + "2: 0, 1, 0: 4\n" /* Type 2, direction X- */ + "-2: 15, 8, 0: 5\n" /* Type -2, direction X+ */ + "2: 15, 8, 11: 5\n" /* Type 2, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // SlopeUpDouble + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // SlopeUpSingle: + // The data has been exported from the gallery Cube, area index 85, ID 463, created by Aloe_vera + { + // Size: + 16, 8, 6, // SizeX = 16, SizeY = 8, SizeZ = 6 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 15, 9, 5, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 1\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 5\n" /* wool */ + "e: 35: 3\n" /* wool */ + "f: 35:11\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aa.............." + /* 1 */ "bb.............." + /* 2 */ "cc.............." + /* 3 */ "dd.............." + /* 4 */ "ee.............." + /* 5 */ "ff.............." + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..aa............" + /* 1 */ "..bb............" + /* 2 */ "..cc............" + /* 3 */ "..dd............" + /* 4 */ "..ee............" + /* 5 */ "..ff............" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "....aa.........." + /* 1 */ "....bb.........." + /* 2 */ "....cc.........." + /* 3 */ "....dd.........." + /* 4 */ "....ee.........." + /* 5 */ "....ff.........." + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "......aa........" + /* 1 */ "......bb........" + /* 2 */ "......cc........" + /* 3 */ "......dd........" + /* 4 */ "......ee........" + /* 5 */ "......ff........" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "........aa......" + /* 1 */ "........bb......" + /* 2 */ "........cc......" + /* 3 */ "........dd......" + /* 4 */ "........ee......" + /* 5 */ "........ff......" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..........aa...." + /* 1 */ "..........bb...." + /* 2 */ "..........cc...." + /* 3 */ "..........dd...." + /* 4 */ "..........ee...." + /* 5 */ "..........ff...." + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "............aa.." + /* 1 */ "............bb.." + /* 2 */ "............cc.." + /* 3 */ "............dd.." + /* 4 */ "............ee.." + /* 5 */ "............ff.." + + // Level 7 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..............aa" + /* 1 */ "..............bb" + /* 2 */ "..............cc" + /* 3 */ "..............dd" + /* 4 */ "..............ee" + /* 5 */ "..............ff", + + // Connectors: + "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */ + "1: 15, 8, 5: 5\n" /* Type 1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + -1000, + + // MoveToGround: + false, + }, // SlopeUpSingle + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // SplitTee: + // The data has been exported from the gallery Cube, area index 93, ID 471, created by Aloe_vera + { + // Size: + 16, 1, 14, // SizeX = 16, SizeY = 1, SizeZ = 14 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 15, 2, 13, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:11\n" /* wool */ + "b: 35: 3\n" /* wool */ + "c: 35: 5\n" /* wool */ + "d: 35: 4\n" /* wool */ + "e: 35: 1\n" /* wool */ + "f: 35:14\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aaaaaa.........." + /* 1 */ "bbbbbbaaa......." + /* 2 */ "ccccccbbbaaa...." + /* 3 */ "ddddddcccbbbaaaa" + /* 4 */ "eeeeeedddcccbbbb" + /* 5 */ "ffffffeeedddcccc" + /* 6 */ "fffffffffeeedddd" + /* 7 */ "eeeeff...fffeeee" + /* 8 */ "dddeeff.....ffff" + /* 9 */ "cccddeff........" + /* 10 */ "bbbccdeef......." + /* 11 */ "aaabbcddef......" + /* 12 */ "...aabcddef....." + /* 13 */ ".....abcdef.....", + + // Connectors: + "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */ + "2: 0, 1, 0: 4\n" /* Type 2, direction X- */ + "-1: 15, 1, 3: 5\n" /* Type -1, direction X+ */ + "1: 5, 1, 13: 3\n" /* Type 1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // SplitTee + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // StraightDouble: + // The data has been exported from the gallery Cube, area index 88, ID 466, created by Aloe_vera + { + // Size: + 16, 1, 12, // SizeX = 16, SizeY = 1, SizeZ = 12 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 15, 2, 11, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:11\n" /* wool */ + "b: 35: 3\n" /* wool */ + "c: 35: 5\n" /* wool */ + "d: 35: 4\n" /* wool */ + "e: 35: 1\n" /* wool */ + "f: 35:14\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aaaaaaaaaaaaaaaa" + /* 1 */ "bbbbbbbbbbbbbbbb" + /* 2 */ "cccccccccccccccc" + /* 3 */ "dddddddddddddddd" + /* 4 */ "eeeeeeeeeeeeeeee" + /* 5 */ "ffffffffffffffff" + /* 6 */ "ffffffffffffffff" + /* 7 */ "eeeeeeeeeeeeeeee" + /* 8 */ "dddddddddddddddd" + /* 9 */ "cccccccccccccccc" + /* 10 */ "bbbbbbbbbbbbbbbb" + /* 11 */ "aaaaaaaaaaaaaaaa", + + // Connectors: + "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */ + "2: 0, 1, 0: 4\n" /* Type 2, direction X- */ + "-2: 15, 1, 0: 5\n" /* Type -2, direction X+ */ + "2: 15, 1, 11: 5\n" /* Type 2, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // StraightDouble +}; // g_RainbowRoadPrefabs + + + + + + +const cPrefab::sDef g_RainbowRoadStartingPrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // StraightSingle: + // The data has been exported from the gallery Cube, area index 83, ID 461, created by Aloe_vera + { + // Size: + 16, 1, 6, // SizeX = 16, SizeY = 1, SizeZ = 6 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 15, 2, 5, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 1\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 5\n" /* wool */ + "e: 35: 3\n" /* wool */ + "f: 35:11\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aaaaaaaaaaaaaaaa" + /* 1 */ "bbbbbbbbbbbbbbbb" + /* 2 */ "cccccccccccccccc" + /* 3 */ "dddddddddddddddd" + /* 4 */ "eeeeeeeeeeeeeeee" + /* 5 */ "ffffffffffffffff", + + // Connectors: + "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */ + "1: 15, 1, 5: 5\n" /* Type 1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 500, + + // MoveToGround: + false, + }, // StraightSingle +}; + + + + + +// The prefab counts: + +const size_t g_RainbowRoadPrefabsCount = ARRAYCOUNT(g_RainbowRoadPrefabs); + +const size_t g_RainbowRoadStartingPrefabsCount = ARRAYCOUNT(g_RainbowRoadStartingPrefabs); + diff --git a/src/Generating/Prefabs/RainbowRoadPrefabs.h b/src/Generating/Prefabs/RainbowRoadPrefabs.h new file mode 100644 index 000000000..ab0a0fbb2 --- /dev/null +++ b/src/Generating/Prefabs/RainbowRoadPrefabs.h @@ -0,0 +1,15 @@ + +// RainbowRoadPrefabs.h + +// Declares the prefabs in the group RainbowRoad + +#include "../Prefab.h" + + + + + +extern const cPrefab::sDef g_RainbowRoadPrefabs[]; +extern const cPrefab::sDef g_RainbowRoadStartingPrefabs[]; +extern const size_t g_RainbowRoadPrefabsCount; +extern const size_t g_RainbowRoadStartingPrefabsCount; diff --git a/src/Generating/RainbowRoadsGen.cpp b/src/Generating/RainbowRoadsGen.cpp new file mode 100644 index 000000000..d1e1f4bda --- /dev/null +++ b/src/Generating/RainbowRoadsGen.cpp @@ -0,0 +1,115 @@ + +// RainbowRoadsGen.cpp + +// Implements the cRainbowRoadsGen class representing the rainbow road generator + +#include "Globals.h" +#include "RainbowRoadsGen.h" +#include "Prefabs/RainbowRoadPrefabs.h" +#include "PieceGenerator.h" + + + + + +static cPrefabPiecePool g_RainbowRoads(g_RainbowRoadPrefabs, g_RainbowRoadPrefabsCount, g_RainbowRoadStartingPrefabs, g_RainbowRoadStartingPrefabsCount); + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cRainbowRoadsGen::cRainbowRoads: + +class cRainbowRoadsGen::cRainbowRoads : + public cGridStructGen::cStructure +{ + typedef cGridStructGen::cStructure super; + +public: + cRainbowRoads( + int a_Seed, + int a_OriginX, int a_OriginZ, + int a_MaxDepth, + int a_MaxSize + ) : + super(a_OriginX, a_OriginZ), + m_Seed(a_Seed), + m_Noise(a_Seed), + m_MaxSize(a_MaxSize), + m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, 255, a_OriginZ + a_MaxSize) + { + // Generate the pieces for this base: + cBFSPieceGenerator pg(g_RainbowRoads, a_Seed); + pg.PlacePieces(a_OriginX, 190, a_OriginZ, a_MaxDepth, m_Pieces); + if (m_Pieces.empty()) + { + return; + } + } + + ~cRainbowRoads() + { + cPieceGenerator::FreePieces(m_Pieces); + } + +protected: + /** Seed for the random functions */ + int m_Seed; + + /** The noise used as a pseudo-random generator */ + cNoise m_Noise; + + /** Maximum size, in X/Z blocks, of the village (radius from the origin) */ + int m_MaxSize; + + /** Borders of the vilalge - no item may reach out of this cuboid. */ + cCuboid m_Borders; + + /** The village pieces, placed by the generator. */ + cPlacedPieces m_Pieces; + + + // cGridStructGen::cStructure overrides: + virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override + { + for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr) + { + cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece()); + Prefab.Draw(a_Chunk, *itr); + } // for itr - m_PlacedPieces[] + } +} ; + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cRainbowRoadsGen: + + + + + +cRainbowRoadsGen::cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 100), + m_Noise(a_Seed + 9000), + m_MaxDepth(a_MaxDepth), + m_MaxSize(a_MaxSize) +{ +} + + + + + +cGridStructGen::cStructurePtr cRainbowRoadsGen::CreateStructure(int a_OriginX, int a_OriginZ) +{ + // Create a base based on the chosen prefabs: + return cStructurePtr(new cRainbowRoads(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize)); +} + + + + diff --git a/src/Generating/RainbowRoadsGen.h b/src/Generating/RainbowRoadsGen.h new file mode 100644 index 000000000..acbd5abf9 --- /dev/null +++ b/src/Generating/RainbowRoadsGen.h @@ -0,0 +1,47 @@ + +// RainbowRoadsGen.h + +// Declares the cRainbowRoadsGen class representing the underwater base generator + + + + + +#pragma once + +#include "GridStructGen.h" +#include "PrefabPiecePool.h" + + + + + +class cRainbowRoadsGen : + public cGridStructGen +{ + typedef cGridStructGen super; + +public: + cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize); + +protected: + class cRainbowRoads; // fwd: RainbowRoadsGen.cpp + + + /** The noise used for generating random numbers */ + cNoise m_Noise; + + /** Maximum depth of the generator tree*/ + int m_MaxDepth; + + /** Maximum size, in X/Z blocks, of the base (radius from the origin) */ + int m_MaxSize; + + + // cGridStructGen overrides: + virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; +} ; + + + + -- cgit v1.2.3 From 0544b96f8041e5dd31b4da84b52d23883d0853f0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 7 Jun 2014 13:59:10 +0200 Subject: docs/Generator: Added the easy Finishers. --- src/Generating/CompoGen.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 578bb2481..688d19c40 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -561,10 +561,16 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) // Interpolate the lowest floor: for (int z = 0; z <= 16 / INTERPOL_Z; z++) for (int x = 0; x <= 16 / INTERPOL_X; x++) { - FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = + //* + FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) * m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) / 256; + //*/ + /* + FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = + m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) / 256; + //*/ } // for x, z - FloorLo[] LinearUpscale2DArrayInPlace<17, 17, INTERPOL_X, INTERPOL_Z>(FloorLo); @@ -574,10 +580,16 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) // First update the high floor: for (int z = 0; z <= 16 / INTERPOL_Z; z++) for (int x = 0; x <= 16 / INTERPOL_X; x++) { + //* FloorHi[INTERPOL_X * x + 17 * INTERPOL_Z * z] = m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) * m_Noise2.IntNoise3DInt(BaseX + INTERPOL_Z * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) / 256; + //*/ + /* + FloorHi[INTERPOL_X * x + 17 * INTERPOL_Z * z] = + m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) / 256; + //*/ } // for x, z - FloorLo[] LinearUpscale2DArrayInPlace<17, 17, INTERPOL_X, INTERPOL_Z>(FloorHi); -- cgit v1.2.3 From 28b82d5bbb4a0c7df901bea9e9f65a66186379ec Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 8 Jun 2014 11:32:52 +0200 Subject: Proper fix for long interaction. Fixes #1078 and #1038. --- src/ClientHandle.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index d47ceff0e..77f3b274a 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1089,18 +1089,25 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e cWorld * World = m_Player->GetWorld(); if ( - (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || - (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || - (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) + (a_BlockFace != BLOCK_FACE_NONE) && // The client is interacting with a specific block + ( + (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || // The block is too far away + (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || + (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) + ) ) { - if (a_BlockFace != BLOCK_FACE_NONE) + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + if (a_BlockY < cChunkDef::Height - 1) { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things - m_Player->GetInventory().SendEquippedSlot(); } + if (a_BlockY > 0) + { + World->SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, m_Player); // 2 block high things + } + m_Player->GetInventory().SendEquippedSlot(); return; } -- cgit v1.2.3 From b904223b9dbbe7b696dbd30e748bc131742e11ea Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 6 Jun 2014 22:31:16 +0200 Subject: Added queue for adding entities to cWorld. This alone doesn't work properly yet, further changes to cPlayer are needed. --- src/ClientHandle.h | 3 ++- src/Entities/Entity.h | 5 +++-- src/Entities/Player.cpp | 2 -- src/Entities/Player.h | 2 ++ src/World.cpp | 28 +++++++++++++++++++++++++++- src/World.h | 9 ++++++++- 6 files changed, 42 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 659c67658..3f1cdf55a 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -250,7 +250,8 @@ public: void SendData(const char * a_Data, size_t a_Size); - /** Called when the player moves into a different world; queues sreaming the new chunks */ + /** Called when the player moves into a different world. + Locks the current world, doesn't lock the new world. */ void MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket); /** Called when the player will enchant a Item */ diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 0c393c0f5..9fe771120 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -421,6 +421,9 @@ public: UNUSED(a_Killer); } + /** Sets the internal world pointer to a new cWorld, doesn't update anything else. */ + void SetWorld(cWorld * a_World) { m_World = a_World; } + protected: static cCriticalSection m_CSCount; static int m_EntityCount; @@ -485,8 +488,6 @@ protected: virtual void Destroyed(void) {} // Called after the entity has been destroyed - void SetWorld(cWorld * a_World) { m_World = a_World; } - /** Called in each tick to handle air-related processing i.e. drowning */ virtual void HandleAir(); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 3a9324d09..b83419903 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1595,8 +1595,6 @@ bool cPlayer::MoveToWorld(const char * a_WorldName) m_ClientHandle->MoveToWorld(*World, (OldDimension != World->GetDimension())); // Add player to all the necessary parts of the new world - SetWorld(World); - m_ClientHandle->StreamChunks(); World->AddEntity(this); World->AddPlayer(this); diff --git a/src/Entities/Player.h b/src/Entities/Player.h index b7cb27d6c..83b9ad593 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -328,6 +328,8 @@ public: void SetVisible( bool a_bVisible ); // tolua_export bool IsVisible(void) const { return m_bVisible; } // tolua_export + /** Moves the player to the specified world. + Returns true if successful, false on failure (world not found). */ bool MoveToWorld(const char * a_WorldName); // tolua_export bool SaveToDisk(void); diff --git a/src/World.cpp b/src/World.cpp index 88e9c32e6..ccd47d3b0 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -743,6 +743,17 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec) m_LastTimeUpdate = m_WorldAge; } + // Add entities waiting in the queue to be added: + { + cCSLock Lock(m_CSEntitiesToAdd); + for (cEntityList::iterator itr = m_EntitiesToAdd.begin(), end = m_EntitiesToAdd.end(); itr != end; ++itr) + { + (*itr)->SetWorld(this); + m_ChunkMap->AddEntity(*itr); + } + m_EntitiesToAdd.clear(); + } + m_ChunkMap->Tick(a_Dt); TickClients(a_Dt); @@ -2808,9 +2819,11 @@ void cWorld::ScheduleTask(int a_DelayTicks, cTask * a_Task) + void cWorld::AddEntity(cEntity * a_Entity) { - m_ChunkMap->AddEntity(a_Entity); + cCSLock Lock(m_CSEntitiesToAdd); + m_EntitiesToAdd.push_back(a_Entity); } @@ -2819,6 +2832,19 @@ void cWorld::AddEntity(cEntity * a_Entity) bool cWorld::HasEntity(int a_UniqueID) { + // Check if the entity is in the queue to be added to the world: + { + cCSLock Lock(m_CSEntitiesToAdd); + for (cEntityList::const_iterator itr = m_EntitiesToAdd.begin(), end = m_EntitiesToAdd.end(); itr != end; ++itr) + { + if ((*itr)->GetUniqueID() == a_UniqueID) + { + return true; + } + } // for itr - m_EntitiesToAdd[] + } + + // Check if the entity is in the chunkmap: return m_ChunkMap->HasEntity(a_UniqueID); } diff --git a/src/World.h b/src/World.h index 98b241a2b..4c014a976 100644 --- a/src/World.h +++ b/src/World.h @@ -301,7 +301,8 @@ public: void SendPlayerList(cPlayer * a_DestPlayer); // Sends playerlist to the player - /** Adds the entity into its appropriate chunk; takes ownership of the entity ptr */ + /** Adds the entity into its appropriate chunk; takes ownership of the entity ptr. + The entity is added lazily - this function only puts it in a queue that is then processed by the Tick thread. */ void AddEntity(cEntity * a_Entity); bool HasEntity(int a_UniqueID); @@ -926,6 +927,12 @@ private: /** Clients that are scheduled for adding, waiting for TickClients to add them */ cClientHandleList m_ClientsToAdd; + /** Guards m_EntitiesToAdd */ + cCriticalSection m_CSEntitiesToAdd; + + /** List of entities that are scheduled for adding, waiting for the Tick thread to add them. */ + cEntityList m_EntitiesToAdd; + cWorld(const AString & a_WorldName); virtual ~cWorld(); -- cgit v1.2.3 From af4a21ea0689107b377818574cb07dc4a2e8b755 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 8 Jun 2014 21:58:08 +0200 Subject: Fixed deadlock when moving players to other worlds. Fixes #1039, fixes #851 --- src/BlockID.h | 1 + src/ClientHandle.cpp | 21 ++----- src/ClientHandle.h | 6 +- src/Entities/Entity.cpp | 10 ++-- src/Entities/Entity.h | 5 +- src/Entities/Player.cpp | 18 +++--- src/Items/ItemBoat.h | 2 +- src/Items/ItemBow.h | 2 +- src/Items/ItemFishingRod.h | 2 +- src/Items/ItemItemFrame.h | 2 +- src/Items/ItemMinecart.h | 2 +- src/Items/ItemPainting.h | 2 +- src/Mobs/Blaze.cpp | 2 +- src/Mobs/Ghast.cpp | 2 +- src/Mobs/Skeleton.cpp | 2 +- src/Mobs/Wither.cpp | 2 +- src/Mobs/Wither.h | 2 +- src/OSSupport/IsThread.cpp | 21 ++++++- src/OSSupport/IsThread.h | 4 ++ src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.cpp | 15 ++++- src/Protocol/Protocol125.h | 6 +- src/Protocol/Protocol132.cpp | 2 +- src/Protocol/Protocol16x.cpp | 4 +- src/Protocol/Protocol16x.h | 2 +- src/Protocol/Protocol17x.cpp | 15 ++++- src/Protocol/Protocol17x.h | 6 +- src/Protocol/ProtocolRecognizer.cpp | 4 +- src/Protocol/ProtocolRecognizer.h | 2 +- src/Simulator/SandSimulator.cpp | 2 +- src/World.cpp | 111 ++++++++++++++++++++++++++---------- src/World.h | 21 ++++++- 32 files changed, 204 insertions(+), 96 deletions(-) (limited to 'src') diff --git a/src/BlockID.h b/src/BlockID.h index a227245aa..272fd319d 100644 --- a/src/BlockID.h +++ b/src/BlockID.h @@ -790,6 +790,7 @@ enum eDimension dimNether = -1, dimOverworld = 0, dimEnd = 1, + dimNotSet = 255, // For things that need an "indeterminate" state, such as cProtocol's LastSentDimension } ; diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 77f3b274a..e4bb9d8e9 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -327,7 +327,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID) // Send experience m_Player->SendExperience(); - m_Player->Initialize(World); + m_Player->Initialize(*World); m_State = csAuthenticated; // Query player team @@ -356,7 +356,7 @@ void cClientHandle::StreamChunks(void) } ASSERT(m_Player != NULL); - + int ChunkPosX = FAST_FLOOR_DIV((int)m_Player->GetPosX(), cChunkDef::Width); int ChunkPosZ = FAST_FLOOR_DIV((int)m_Player->GetPosZ(), cChunkDef::Width); if ((ChunkPosX == m_LastStreamedChunkX) && (ChunkPosZ == m_LastStreamedChunkZ)) @@ -1753,18 +1753,8 @@ void cClientHandle::SendData(const char * a_Data, size_t a_Size) -void cClientHandle::MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket) +void cClientHandle::RemoveFromWorld(void) { - UNUSED(a_World); - ASSERT(m_Player != NULL); - - if (a_SendRespawnPacket) - { - SendRespawn(); - } - - cWorld * World = m_Player->GetWorld(); - // Remove all associated chunks: cChunkCoordsList Chunks; { @@ -1774,7 +1764,6 @@ void cClientHandle::MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket) } for (cChunkCoordsList::iterator itr = Chunks.begin(), end = Chunks.end(); itr != end; ++itr) { - World->RemoveChunkClient(itr->m_ChunkX, itr->m_ChunkZ, this); m_Protocol->SendUnloadChunk(itr->m_ChunkX, itr->m_ChunkZ); } // for itr - Chunks[] @@ -2379,9 +2368,9 @@ void cClientHandle::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effec -void cClientHandle::SendRespawn(void) +void cClientHandle::SendRespawn(const cWorld & a_World) { - m_Protocol->SendRespawn(); + m_Protocol->SendRespawn(a_World); } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 3f1cdf55a..0d883f3af 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -149,7 +149,7 @@ public: void SendPlayerSpawn (const cPlayer & a_Player); void SendPluginMessage (const AString & a_Channel, const AString & a_Message); // Exported in ManualBindings.cpp void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID); - void SendRespawn (void); + void SendRespawn (const cWorld & a_World); void SendExperience (void); void SendExperienceOrb (const cExpOrb & a_ExpOrb); void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode); @@ -251,8 +251,8 @@ public: void SendData(const char * a_Data, size_t a_Size); /** Called when the player moves into a different world. - Locks the current world, doesn't lock the new world. */ - void MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket); + Sends an UnloadChunk packet for each loaded chunk and resets the streamed chunks. */ + void RemoveFromWorld(void); /** Called when the player will enchant a Item */ void HandleEnchantItem(Byte & WindowID, Byte & Enchantment); diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 1226a2319..8f736a269 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -129,9 +129,9 @@ const char * cEntity::GetParentClass(void) const -bool cEntity::Initialize(cWorld * a_World) +bool cEntity::Initialize(cWorld & a_World) { - if (cPluginManager::Get()->CallHookSpawningEntity(*a_World, *this)) + if (cPluginManager::Get()->CallHookSpawningEntity(a_World, *this)) { return false; } @@ -144,13 +144,13 @@ bool cEntity::Initialize(cWorld * a_World) */ m_IsInitialized = true; - m_World = a_World; + m_World = &a_World; m_World->AddEntity(this); - cPluginManager::Get()->CallHookSpawnedEntity(*a_World, *this); + cPluginManager::Get()->CallHookSpawnedEntity(a_World, *this); // Spawn the entity on the clients: - a_World->BroadcastSpawnEntity(*this); + a_World.BroadcastSpawnEntity(*this); return true; } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 9fe771120..85ad42d54 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -146,8 +146,9 @@ public: cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height); virtual ~cEntity(); - /// Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed) - virtual bool Initialize(cWorld * a_World); + /** Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed). + Adds the entity to the world. */ + virtual bool Initialize(cWorld & a_World); // tolua_begin diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index b83419903..feb09b5d2 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -940,6 +940,8 @@ void cPlayer::Killed(cEntity * a_Victim) void cPlayer::Respawn(void) { + ASSERT(m_World != NULL); + m_Health = GetMaxHealth(); SetInvulnerableTicks(20); @@ -952,7 +954,7 @@ void cPlayer::Respawn(void) m_LifetimeTotalXp = 0; // ToDo: send score to client? How? - m_ClientHandle->SendRespawn(); + m_ClientHandle->SendRespawn(*m_World); // Extinguish the fire: StopBurning(); @@ -1583,19 +1585,19 @@ bool cPlayer::MoveToWorld(const char * a_WorldName) return false; } - eDimension OldDimension = m_World->GetDimension(); - + // Send the respawn packet: + if (m_ClientHandle != NULL) + { + m_ClientHandle->SendRespawn(*World); + } + // Remove all links to the old world m_World->RemovePlayer(this); - m_ClientHandle->RemoveFromAllChunks(); - m_World->RemoveEntity(this); // If the dimension is different, we can send the respawn packet // http://wiki.vg/Protocol#0x09 says "don't send if dimension is the same" as of 2013_07_02 - m_ClientHandle->MoveToWorld(*World, (OldDimension != World->GetDimension())); - // Add player to all the necessary parts of the new world - World->AddEntity(this); + // Queue adding player to the new world, including all the necessary adjustments to the object World->AddPlayer(this); return true; diff --git a/src/Items/ItemBoat.h b/src/Items/ItemBoat.h index 42f4ffc8f..7faac1e32 100644 --- a/src/Items/ItemBoat.h +++ b/src/Items/ItemBoat.h @@ -75,7 +75,7 @@ public: double z = Callbacks.m_Pos.z; cBoat * Boat = new cBoat(x + 0.5, y + 1, z + 0.5); - Boat->Initialize(a_World); + Boat->Initialize(*a_World); return true; } diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index 8c0b3a0a3..e0ab339d3 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -66,7 +66,7 @@ public: { return; } - if (!Arrow->Initialize(a_Player->GetWorld())) + if (!Arrow->Initialize(*a_Player->GetWorld())) { delete Arrow; return; diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index 32c151db5..3b1ad1717 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -231,7 +231,7 @@ public: else { cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 15, a_Player->GetUniqueID(), 100 + a_World->GetTickRandomNumber(800) - (a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchLure) * 100)); - Floater->Initialize(a_World); + Floater->Initialize(*a_World); a_Player->SetIsFishing(true, Floater->GetUniqueID()); } return true; diff --git a/src/Items/ItemItemFrame.h b/src/Items/ItemItemFrame.h index 27e7dba35..097f04d0b 100644 --- a/src/Items/ItemItemFrame.h +++ b/src/Items/ItemItemFrame.h @@ -34,7 +34,7 @@ public: if (Block == E_BLOCK_AIR) { cItemFrame * ItemFrame = new cItemFrame(a_Dir, a_BlockX, a_BlockY, a_BlockZ); - if (!ItemFrame->Initialize(a_World)) + if (!ItemFrame->Initialize(*a_World)) { delete ItemFrame; return false; diff --git a/src/Items/ItemMinecart.h b/src/Items/ItemMinecart.h index 4e7d8fcff..63038de51 100644 --- a/src/Items/ItemMinecart.h +++ b/src/Items/ItemMinecart.h @@ -70,7 +70,7 @@ public: return false; } } // switch (m_ItemType) - Minecart->Initialize(a_World); + Minecart->Initialize(*a_World); if (!a_Player->IsGameModeCreative()) { diff --git a/src/Items/ItemPainting.h b/src/Items/ItemPainting.h index b85098221..e4bb76ebe 100644 --- a/src/Items/ItemPainting.h +++ b/src/Items/ItemPainting.h @@ -79,7 +79,7 @@ public: }; cPainting * Painting = new cPainting(gPaintingTitlesList[a_World->GetTickRandomNumber(ARRAYCOUNT(gPaintingTitlesList) - 1)].Title, Dir, a_BlockX, a_BlockY, a_BlockZ); - Painting->Initialize(a_World); + Painting->Initialize(*a_World); if (!a_Player->IsGameModeCreative()) { diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp index 2a6a761bf..19bdf8737 100644 --- a/src/Mobs/Blaze.cpp +++ b/src/Mobs/Blaze.cpp @@ -44,7 +44,7 @@ void cBlaze::Attack(float a_Dt) { return; } - if (!FireCharge->Initialize(m_World)) + if (!FireCharge->Initialize(*m_World)) { delete FireCharge; return; diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp index d8a7663f8..4df8e165c 100644 --- a/src/Mobs/Ghast.cpp +++ b/src/Mobs/Ghast.cpp @@ -46,7 +46,7 @@ void cGhast::Attack(float a_Dt) { return; } - if (!GhastBall->Initialize(m_World)) + if (!GhastBall->Initialize(*m_World)) { delete GhastBall; return; diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index 1e62d7987..e7f3971cc 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -81,7 +81,7 @@ void cSkeleton::Attack(float a_Dt) { return; } - if (!Arrow->Initialize(m_World)) + if (!Arrow->Initialize(*m_World)) { delete Arrow; return; diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp index 170f4fdc0..da4cc7765 100644 --- a/src/Mobs/Wither.cpp +++ b/src/Mobs/Wither.cpp @@ -30,7 +30,7 @@ bool cWither::IsArmored(void) const -bool cWither::Initialize(cWorld * a_World) +bool cWither::Initialize(cWorld & a_World) { // Set health before BroadcastSpawnEntity() SetHealth(GetMaxHealth() / 3); diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index 93b4f8bfc..03a320788 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -25,7 +25,7 @@ public: bool IsArmored(void) const; // cEntity overrides - virtual bool Initialize(cWorld * a_World) override; + virtual bool Initialize(cWorld & a_World) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; diff --git a/src/OSSupport/IsThread.cpp b/src/OSSupport/IsThread.cpp index 04fc818e4..67f336c97 100644 --- a/src/OSSupport/IsThread.cpp +++ b/src/OSSupport/IsThread.cpp @@ -60,6 +60,9 @@ static void SetThreadName(DWORD dwThreadID, const char * threadName) cIsThread::cIsThread(const AString & iThreadName) : m_ShouldTerminate(false), m_ThreadName(iThreadName), + #ifdef _WIN32 + m_ThreadID(0), + #endif m_Handle(NULL_HANDLE) { } @@ -83,8 +86,8 @@ bool cIsThread::Start(void) ASSERT(m_Handle == NULL_HANDLE); // Has already started one thread? #ifdef _WIN32 // Create the thread suspended, so that the mHandle variable is valid in the thread procedure - DWORD ThreadID = 0; - m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &ThreadID); + m_ThreadID = 0; + m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &m_ThreadID); if (m_Handle == NULL) { LOGERROR("ERROR: Could not create thread \"%s\", GLE = %d!", m_ThreadName.c_str(), GetLastError()); @@ -96,7 +99,7 @@ bool cIsThread::Start(void) // Thread naming is available only in MSVC if (!m_ThreadName.empty()) { - SetThreadName(ThreadID, m_ThreadName.c_str()); + SetThreadName(m_ThreadID, m_ThreadName.c_str()); } #endif // _DEBUG and _MSC_VER @@ -177,3 +180,15 @@ unsigned long cIsThread::GetCurrentID(void) +bool cIsThread::IsCurrentThread(void) const +{ + #ifdef _WIN32 + return (GetCurrentThreadId() == m_ThreadID); + #else + return (m_Handle == pthread_self()); + #endif +} + + + + diff --git a/src/OSSupport/IsThread.h b/src/OSSupport/IsThread.h index 57651a490..c20fc3e7e 100644 --- a/src/OSSupport/IsThread.h +++ b/src/OSSupport/IsThread.h @@ -48,6 +48,9 @@ public: /// Returns the OS-dependent thread ID for the caller's thread static unsigned long GetCurrentID(void); + /** Returns true if the thread calling this function is the thread contained within this object. */ + bool IsCurrentThread(void) const; + protected: AString m_ThreadName; @@ -60,6 +63,7 @@ protected: #ifdef _WIN32 + DWORD m_ThreadID; HANDLE m_Handle; static DWORD __stdcall thrExecute(LPVOID a_Param) diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index a543c6361..c6e569919 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -100,7 +100,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) = 0; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) = 0; - virtual void SendRespawn (void) = 0; + virtual void SendRespawn (const cWorld & a_World) = 0; virtual void SendExperience (void) = 0; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) = 0; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index f3bdae3ac..491058919 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -133,7 +133,8 @@ typedef unsigned char Byte; cProtocol125::cProtocol125(cClientHandle * a_Client) : super(a_Client), - m_ReceivedData(32 KiB) + m_ReceivedData(32 KiB), + m_LastSentDimension(dimNotSet) { } @@ -591,6 +592,7 @@ void cProtocol125::SendLogin(const cPlayer & a_Player, const cWorld & a_World) WriteByte (0); // Unused WriteByte (60); // Client list width or something Flush(); + m_LastSentDimension = a_World.GetDimension(); } @@ -831,16 +833,23 @@ void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect -void cProtocol125::SendRespawn(void) +void cProtocol125::SendRespawn(const cWorld & a_World) { cCSLock Lock(m_CSPacket); + if (m_LastSentDimension == a_World.GetDimension()) + { + // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do + return; + } cPlayer * Player = m_Client->GetPlayer(); WriteByte (PACKET_RESPAWN); - WriteInt ((int)(Player->GetWorld()->GetDimension())); + WriteInt (a_World.GetDimension()); WriteByte (2); // TODO: Difficulty; 2 = Normal WriteChar ((char)Player->GetGameMode()); WriteShort (256); // Current world height WriteString("default"); + Flush(); + m_LastSentDimension = a_World.GetDimension(); } diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 18a626a2d..85418f71f 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -72,7 +72,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (void) override; + virtual void SendRespawn (const cWorld & a_World) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; @@ -113,6 +113,10 @@ protected: cByteBuffer m_ReceivedData; ///< Buffer for the received data AString m_Username; ///< Stored in ParseHandshake(), compared to Login username + + /** The dimension that was last sent to a player in a Respawn or Login packet. + Used to avoid Respawning into the same dimension, which confuses the client. */ + eDimension m_LastSentDimension; virtual void SendData(const char * a_Data, size_t a_Size) override; diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index f4717f592..1e3fc8de8 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -253,7 +253,7 @@ void cProtocol132::SendLogin(const cPlayer & a_Player, const cWorld & a_World) WriteByte (0); // Unused, used to be world height WriteByte (8); // Client list width or something Flush(); - + m_LastSentDimension = a_World.GetDimension(); SendCompass(a_World); } diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp index 714bf5e46..9e0f3f852 100644 --- a/src/Protocol/Protocol16x.cpp +++ b/src/Protocol/Protocol16x.cpp @@ -158,10 +158,10 @@ void cProtocol161::SendPlayerMaxSpeed(void) -void cProtocol161::SendRespawn(void) +void cProtocol161::SendRespawn(const cWorld & a_World) { // Besides sending the respawn, we need to also send the player max speed, otherwise the client reverts to super-fast - super::SendRespawn(); + super::SendRespawn(a_World); SendPlayerMaxSpeed(); } diff --git a/src/Protocol/Protocol16x.h b/src/Protocol/Protocol16x.h index 8eedce8d5..e91dc8a1c 100644 --- a/src/Protocol/Protocol16x.h +++ b/src/Protocol/Protocol16x.h @@ -42,7 +42,7 @@ protected: virtual void SendGameMode (eGameMode a_GameMode) override; virtual void SendHealth (void) override; virtual void SendPlayerMaxSpeed(void) override; - virtual void SendRespawn (void) override; + virtual void SendRespawn (const cWorld & a_World) override; virtual void SendWindowOpen (const cWindow & a_Window) override; virtual int ParseEntityAction (void) override; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index f7564fe6d..02c577dc8 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -92,7 +92,8 @@ cProtocol172::cProtocol172(cClientHandle * a_Client, const AString & a_ServerAdd m_ReceivedData(32 KiB), m_OutPacketBuffer(64 KiB), m_OutPacketLenBuffer(20), // 20 bytes is more than enough for one VarInt - m_IsEncrypted(false) + m_IsEncrypted(false), + m_LastSentDimension(dimNotSet) { // Create the comm log file, if so requested: if (g_ShouldLogCommIn || g_ShouldLogCommOut) @@ -656,6 +657,7 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World) Pkt.WriteByte(std::min(Server->GetMaxPlayers(), 60)); Pkt.WriteString("default"); // Level type - wtf? } + m_LastSentDimension = a_World.GetDimension(); // Send the spawn position: { @@ -984,14 +986,21 @@ void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect -void cProtocol172::SendRespawn(void) +void cProtocol172::SendRespawn(const cWorld & a_World) { + if (m_LastSentDimension == a_World.GetDimension()) + { + // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do + return; + } + cPacketizer Pkt(*this, 0x07); // Respawn packet cPlayer * Player = m_Client->GetPlayer(); - Pkt.WriteInt(Player->GetWorld()->GetDimension()); + Pkt.WriteInt(a_World.GetDimension()); Pkt.WriteByte(2); // TODO: Difficulty (set to Normal) Pkt.WriteByte((Byte)Player->GetEffectiveGameMode()); Pkt.WriteString("default"); + m_LastSentDimension = a_World.GetDimension(); } diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 3c6a8c085..8be1d9211 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -104,7 +104,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (void) override; + virtual void SendRespawn (const cWorld & a_World) override; virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8 virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; @@ -244,6 +244,10 @@ protected: /** The logfile where the comm is logged, when g_ShouldLogComm is true */ cFile m_CommLogFile; + /** The dimension that was last sent to a player in a Respawn or Login packet. + Used to avoid Respawning into the same dimension, which confuses the client. */ + eDimension m_LastSentDimension; + /** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets */ void AddReceivedData(const char * a_Data, size_t a_Size); diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index b0cbb6def..35a331f43 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -555,10 +555,10 @@ void cProtocolRecognizer::SendRemoveEntityEffect(const cEntity & a_Entity, int a -void cProtocolRecognizer::SendRespawn(void) +void cProtocolRecognizer::SendRespawn(const cWorld & a_World) { ASSERT(m_Protocol != NULL); - m_Protocol->SendRespawn(); + m_Protocol->SendRespawn(a_World); } diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 3a291bf7a..5e178447c 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -107,7 +107,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (void) override; + virtual void SendRespawn (const cWorld & a_World) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp index b8f34559f..1380f8841 100644 --- a/src/Simulator/SandSimulator.cpp +++ b/src/Simulator/SandSimulator.cpp @@ -60,7 +60,7 @@ void cSandSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun ); */ cFallingBlock * FallingBlock = new cFallingBlock(Pos, BlockType, a_Chunk->GetMeta(itr->x, itr->y, itr->z)); - FallingBlock->Initialize(&m_World); + FallingBlock->Initialize(m_World); a_Chunk->SetBlock(itr->x, itr->y, itr->z, E_BLOCK_AIR, 0); } } diff --git a/src/World.cpp b/src/World.cpp index ccd47d3b0..ebe6b53e6 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -754,6 +754,9 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec) m_EntitiesToAdd.clear(); } + // Add players waiting in the queue to be added: + AddQueuedPlayers(); + m_ChunkMap->Tick(a_Dt); TickClients(a_Dt); @@ -1642,7 +1645,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockX, a_BlockY, a_BlockZ, *itr, IsPlayerCreated, SpeedX, SpeedY, SpeedZ ); - Pickup->Initialize(this); + Pickup->Initialize(*this); } } @@ -1663,7 +1666,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockX, a_BlockY, a_BlockZ, *itr, IsPlayerCreated, (float)a_SpeedX, (float)a_SpeedY, (float)a_SpeedZ ); - Pickup->Initialize(this); + Pickup->Initialize(*this); } } @@ -1674,7 +1677,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double int cWorld::SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE BlockType, NIBBLETYPE BlockMeta) { cFallingBlock * FallingBlock = new cFallingBlock(Vector3i(a_X, a_Y, a_Z), BlockType, BlockMeta); - FallingBlock->Initialize(this); + FallingBlock->Initialize(*this); return FallingBlock->GetUniqueID(); } @@ -1690,7 +1693,7 @@ int cWorld::SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) } cExpOrb * ExpOrb = new cExpOrb(a_X, a_Y, a_Z, a_Reward); - ExpOrb->Initialize(this); + ExpOrb->Initialize(*this); return ExpOrb->GetUniqueID(); } @@ -1713,7 +1716,7 @@ int cWorld::SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType return -1; } } // switch (a_MinecartType) - Minecart->Initialize(this); + Minecart->Initialize(*this); return Minecart->GetUniqueID(); } @@ -1724,7 +1727,7 @@ int cWorld::SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType void cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTicks, double a_InitialVelocityCoeff) { cTNTEntity * TNT = new cTNTEntity(a_X, a_Y, a_Z, a_FuseTicks); - TNT->Initialize(this); + TNT->Initialize(*this); TNT->SetSpeed( a_InitialVelocityCoeff * (GetTickRandomNumber(2) - 1), /** -1, 0, 1 */ a_InitialVelocityCoeff * 2, @@ -2240,7 +2243,7 @@ void cWorld::SetChunkData( // Initialize the entities (outside the m_ChunkMap's CS, to fix FS #347): for (cEntityList::iterator itr = a_Entities.begin(), end = a_Entities.end(); itr != end; ++itr) { - (*itr)->Initialize(this); + (*itr)->Initialize(*this); } // If a client is requesting this chunk, send it to them: @@ -2333,23 +2336,8 @@ void cWorld::CollectPickupsByPlayer(cPlayer * a_Player) void cWorld::AddPlayer(cPlayer * a_Player) { - { - cCSLock Lock(m_CSPlayers); - - ASSERT(std::find(m_Players.begin(), m_Players.end(), a_Player) == m_Players.end()); // Is it already in the list? HOW? - - m_Players.remove(a_Player); // Make sure the player is registered only once - m_Players.push_back(a_Player); - } - - // Add the player's client to the list of clients to be ticked: - if (a_Player->GetClientHandle() != NULL) - { - cCSLock Lock(m_CSClients); - m_ClientsToAdd.push_back(a_Player->GetClientHandle()); - } - - // The player has already been added to the chunkmap as the entity, do NOT add again! + cCSLock Lock(m_CSPlayersToAdd); + m_PlayersToAdd.push_back(a_Player); } @@ -2358,17 +2346,26 @@ void cWorld::AddPlayer(cPlayer * a_Player) void cWorld::RemovePlayer(cPlayer * a_Player) { + m_ChunkMap->RemoveEntity(a_Player); + { + cCSLock Lock(m_CSPlayersToAdd); + m_PlayersToAdd.remove(a_Player); + } { cCSLock Lock(m_CSPlayers); + LOGD("Removing player \"%s\" from world \"%s\".", a_Player->GetName().c_str(), m_WorldName.c_str()); m_Players.remove(a_Player); } // Remove the player's client from the list of clients to be ticked: - if (a_Player->GetClientHandle() != NULL) + cClientHandle * Client = a_Player->GetClientHandle(); + if (Client != NULL) { + Client->RemoveFromWorld(); + m_ChunkMap->RemoveClientFromChunks(Client); cCSLock Lock(m_CSClients); - m_ClientsToRemove.push_back(a_Player->GetClientHandle()); + m_ClientsToRemove.push_back(Client); } } @@ -2977,7 +2974,7 @@ int cWorld::SpawnMobFinalize(cMonster * a_Monster) delete a_Monster; return -1; } - if (!a_Monster->Initialize(this)) + if (!a_Monster->Initialize(*this)) { delete a_Monster; return -1; @@ -2999,7 +2996,7 @@ int cWorld::CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProje { return -1; } - if (!Projectile->Initialize(this)) + if (!Projectile->Initialize(*this)) { delete Projectile; return -1; @@ -3129,6 +3126,63 @@ cFluidSimulator * cWorld::InitializeFluidSimulator(cIniFile & a_IniFile, const c +void cWorld::AddQueuedPlayers(void) +{ + ASSERT(m_TickThread.IsCurrentThread()); + + // Grab the list of players to add, it has to be locked to access it: + cPlayerList PlayersToAdd; + { + cCSLock Lock(m_CSPlayersToAdd); + std::swap(PlayersToAdd, m_PlayersToAdd); + } + + // Add all the players in the grabbed list: + { + cCSLock Lock(m_CSPlayers); + for (cPlayerList::iterator itr = PlayersToAdd.begin(), end = PlayersToAdd.end(); itr != end; ++itr) + { + ASSERT(std::find(m_Players.begin(), m_Players.end(), *itr) == m_Players.end()); // Is it already in the list? HOW? + + m_Players.push_back(*itr); + (*itr)->SetWorld(this); + + // Add to chunkmap, if not already there (Spawn vs MoveToWorld): + if (!m_ChunkMap->HasEntity((*itr)->GetUniqueID())) + { + m_ChunkMap->AddEntity(*itr); + } + } // for itr - PlayersToAdd[] + } // Lock(m_CSPlayers) + + // Add all the players' clienthandles: + { + cCSLock Lock(m_CSClients); + for (cPlayerList::iterator itr = PlayersToAdd.begin(), end = PlayersToAdd.end(); itr != end; ++itr) + { + cClientHandle * Client = (*itr)->GetClientHandle(); + if (Client != NULL) + { + m_Clients.push_back(Client); + } + } // for itr - PlayersToAdd[] + } // Lock(m_CSClients) + + // Stream chunks to all eligible clients: + for (cPlayerList::iterator itr = PlayersToAdd.begin(), end = PlayersToAdd.end(); itr != end; ++itr) + { + cClientHandle * Client = (*itr)->GetClientHandle(); + if (Client != NULL) + { + Client->StreamChunks(); + } + } // for itr - PlayersToAdd[] +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cWorld::cTaskSaveAllChunks: @@ -3269,4 +3323,3 @@ void cWorld::cChunkGeneratorCallbacks::CallHookChunkGenerated (cChunkDesc & a_Ch - diff --git a/src/World.h b/src/World.h index 4c014a976..abdc3120c 100644 --- a/src/World.h +++ b/src/World.h @@ -284,8 +284,15 @@ public: void CollectPickupsByPlayer(cPlayer * a_Player); - void AddPlayer( cPlayer* a_Player ); - void RemovePlayer( cPlayer* a_Player ); + /** Adds the player to the world. + Uses a queue to store the player object until the Tick thread processes the addition event. + Also adds the player as an entity in the chunkmap, and the player's ClientHandle, if any, for ticking. */ + void AddPlayer(cPlayer * a_Player); + + /** Removes the player from the world. + Removes the player from the addition queue, too, if appropriate. + If the player has a ClientHandle, the ClientHandle is removed from all chunks in the world and will not be ticked by this world anymore. */ + void RemovePlayer(cPlayer * a_Player); /** Calls the callback for each player in the list; returns true if all players processed, false if the callback aborted by returning true */ virtual bool ForEachPlayer(cPlayerListCallback & a_Callback) override; // >> EXPORTED IN MANUALBINDINGS << @@ -933,6 +940,12 @@ private: /** List of entities that are scheduled for adding, waiting for the Tick thread to add them. */ cEntityList m_EntitiesToAdd; + /** Guards m_PlayersToAdd */ + cCriticalSection m_CSPlayersToAdd; + + /** List of players that are scheduled for adding, waiting for the Tick thread to add them. */ + cPlayerList m_PlayersToAdd; + cWorld(const AString & a_WorldName); virtual ~cWorld(); @@ -970,6 +983,10 @@ private: /** Creates a new redstone simulator.*/ cRedstoneSimulator * InitializeRedstoneSimulator(cIniFile & a_IniFile); + + /** Adds the players queued in the m_PlayersToAdd queue into the m_Players list. + Assumes it is called from the Tick thread. */ + void AddQueuedPlayers(void); }; // tolua_export -- cgit v1.2.3 From ec0976f9b0ace946022f48fdb360830985e7ee14 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 9 Jun 2014 00:49:02 +0200 Subject: Fixed a crash when creating negative-size blockareas. Now the server emits a warning instead and continues execution. --- src/BlockArea.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index e3a859e4f..4fe6cd51e 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -309,6 +309,14 @@ void cBlockArea::Clear(void) void cBlockArea::Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes) { + if ((a_SizeX < 0) || (a_SizeY < 0) || (a_SizeZ < 0)) + { + LOGWARNING("Creating a cBlockArea with a negative size! Call to Create ignored. (%d, %d, %d)", + a_SizeX, a_SizeY, a_SizeZ + ); + return; + } + Clear(); int BlockCount = a_SizeX * a_SizeY * a_SizeZ; if ((a_DataTypes & baTypes) != 0) -- cgit v1.2.3 From 02b509b81d4543a958caaad8389fa0cebd0a8e1a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 9 Jun 2014 17:05:22 +0200 Subject: ToLua can now be run in pure-lua mode. See the src/Bindings/AllToLua_lua.bat for usage example. --- src/Bindings/AllToLua_lua.bat.bat | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Bindings/AllToLua_lua.bat.bat (limited to 'src') diff --git a/src/Bindings/AllToLua_lua.bat.bat b/src/Bindings/AllToLua_lua.bat.bat new file mode 100644 index 000000000..81c738f32 --- /dev/null +++ b/src/Bindings/AllToLua_lua.bat.bat @@ -0,0 +1,27 @@ + +:: AllToLua_Lua.bat +:: This scripts updates the automatically-generates Lua bindings in Bindings.cpp / Bindings.h +:: When called without any parameters, it will pause for a keypress at the end +:: Call with any parameter to disable the wait (for buildserver use) +:: This script assumes "lua" executable to be in PATH, it uses a pure-lua implementation of the ToLua processor + +@echo off + + + + + +:: Regenerate the files: +echo Regenerating LUA bindings . . . +lua ..\..\lib\tolua++\src\bin\lua\_driver.lua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + + + + +: Wait for keypress, if no param given: +echo. +if %ALLTOLUA_WAIT%N == N pause + + + + -- cgit v1.2.3 From 2b45e720adc801ece3dc562772747791efc3567e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 9 Jun 2014 21:35:46 +0200 Subject: Added Y coord checks and documentation to cBlockDoorHandler. --- src/Blocks/BlockDoor.h | 59 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index eaa039c50..bc59051c3 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -111,19 +111,19 @@ public: } if ((a_Yaw >= 0) && (a_Yaw < 90)) { - return 0x0; + return 0x00; } else if ((a_Yaw >= 180) && (a_Yaw < 270)) { - return 0x2; + return 0x02; } else if ((a_Yaw >= 90) && (a_Yaw < 180)) { - return 0x1; + return 0x01; } else { - return 0x3; + return 0x03; } } @@ -137,29 +137,45 @@ public: static NIBBLETYPE IsOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - NIBBLETYPE Meta = GetTrueDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); - return ((Meta & 0x4) != 0); + NIBBLETYPE Meta = GetCompleteDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); + return ((Meta & 0x04) != 0); } - /** Read the meta from the true part of the door and returns a meta with all infos include. */ - static NIBBLETYPE GetTrueDoorMeta(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) + /** Returns the complete meta composed from the both parts of the door as (TopMeta << 4) | BottomMeta + The coords may point to either part of the door. + The returned value has bit 3 (0x08) set iff the coords point to the top part of the door. + Fails gracefully for (invalid) doors on the world's top and bottom. */ + static NIBBLETYPE GetCompleteDoorMeta(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - if ((Meta & 0x8) != 0) + if ((Meta & 0x08) != 0) { - NIBBLETYPE DownMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ); - return (DownMeta & 0x7) | 0x8 | (((Meta & 0x1) != 0) ? 16 : 0); + // The coords are pointing at the top part of the door + if (a_BlockX > 0) + { + NIBBLETYPE DownMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ); + return (DownMeta & 0x07) | 0x08 | (Meta << 4); + } + // This is the top part of the door at the bottommost layer of the world, there's no bottom: + return 0x08 | (Meta << 4); } else { - NIBBLETYPE UpMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY + 1, a_BlockZ); - return (Meta & 0x7) | (((UpMeta & 0x1) != 0) ? 16 : 0); + // The coords are pointing at the bottom part of the door + if (a_BlockY < cChunkDef::Height - 1) + { + NIBBLETYPE UpMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY + 1, a_BlockZ); + return Meta | (UpMeta << 4); + } + // This is the bottom part of the door at the topmost layer of the world, there's no top: + return Meta; } } + /** Sets the door to the specified state. If the door is already in that state, does nothing. */ static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) { BLOCKTYPE Block = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); @@ -168,22 +184,27 @@ public: return; } - NIBBLETYPE Meta = GetTrueDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); - bool Opened = (Meta & 0x4) != 0; - if (Opened == a_Open) + NIBBLETYPE Meta = GetCompleteDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); + bool IsOpened = ((Meta & 0x04) != 0); + if (IsOpened == a_Open) { return; } // Change the door - NIBBLETYPE NewMeta = (Meta & 0x7) ^ 0x4; - if ((Meta & 0x8) == 0) + NIBBLETYPE NewMeta = (Meta & 0x07) ^ 0x04; // Flip the "IsOpen" bit (0x04) + if ((Meta & 0x08) == 0) { + // The block is the bottom part of the door a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, NewMeta); } else { - a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ, NewMeta); + // The block is the top part of the door, set the meta to the corresponding top part + if (a_BlockY > 0) + { + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ, NewMeta); + } } } -- cgit v1.2.3 From bead36f5ed9ec9501ff9fa67bbaa8d734a7a168a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 9 Jun 2014 23:38:50 +0200 Subject: Added cRidgedMultiNoise, fixed cPerlinNoise. --- src/Noise.cpp | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/Noise.h | 64 ++++++++++++++++++++++ 2 files changed, 233 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Noise.cpp b/src/Noise.cpp index 89115d992..9c7042b02 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -854,7 +854,7 @@ void cPerlinNoise::Generate2D( NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude; for (int i = 0; i < ArrayCount; i++) { - a_Array[i] *= Amplitude; + a_Array[i] = a_Workspace[i] * Amplitude; } // Add each octave: @@ -949,3 +949,171 @@ void cPerlinNoise::Generate3D( + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cRidgedMultiNoise: + +cRidgedMultiNoise::cRidgedMultiNoise(void) : + m_Seed(0) +{ +} + + + + + +cRidgedMultiNoise::cRidgedMultiNoise(int a_Seed) : + m_Seed(a_Seed) +{ +} + + + + + +void cRidgedMultiNoise::SetSeed(int a_Seed) +{ + m_Seed = a_Seed; +} + + + + + +void cRidgedMultiNoise::AddOctave(float a_Frequency, float a_Amplitude) +{ + m_Octaves.push_back(cOctave(m_Seed * ((int)m_Octaves.size() + 4) * 4 + 1024, a_Frequency, a_Amplitude)); +} + + + + + +void cRidgedMultiNoise::Generate2D( + NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y] + int a_SizeX, int a_SizeY, ///< Count of the array, in each direction + NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction + NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction + NOISE_DATATYPE * a_Workspace ///< Workspace that this function can use and trash +) const +{ + if (m_Octaves.empty()) + { + // No work to be done + ASSERT(!"RidgedMulti: No octaves to generate!"); + return; + } + + bool ShouldFreeWorkspace = (a_Workspace == NULL); + int ArrayCount = a_SizeX * a_SizeY; + if (ShouldFreeWorkspace) + { + a_Workspace = new NOISE_DATATYPE[ArrayCount]; + } + + // Generate the first octave directly into array: + const cOctave & FirstOctave = m_Octaves.front(); + + FirstOctave.m_Noise.Generate2D( + a_Workspace, a_SizeX, a_SizeY, + a_StartX * FirstOctave.m_Frequency, a_EndX * FirstOctave.m_Frequency, + a_StartY * FirstOctave.m_Frequency, a_EndY * FirstOctave.m_Frequency + ); + NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude; + for (int i = 0; i < ArrayCount; i++) + { + a_Array[i] = std::abs(a_Workspace[i] * Amplitude); + } + + // Add each octave: + for (cOctaves::const_iterator itr = m_Octaves.begin() + 1, end = m_Octaves.end(); itr != end; ++itr) + { + // Generate cubic noise for the octave: + itr->m_Noise.Generate2D( + a_Workspace, a_SizeX, a_SizeY, + a_StartX * itr->m_Frequency, a_EndX * itr->m_Frequency, + a_StartY * itr->m_Frequency, a_EndY * itr->m_Frequency + ); + // Add the cubic noise into the output: + NOISE_DATATYPE Amplitude = itr->m_Amplitude; + for (int i = 0; i < ArrayCount; i++) + { + a_Array[i] += std::abs(a_Workspace[i] * Amplitude); + } + } + + if (ShouldFreeWorkspace) + { + delete[] a_Workspace; + } +} + + + + + +void cRidgedMultiNoise::Generate3D( + NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y + a_SizeX * a_SizeY * z] + int a_SizeX, int a_SizeY, int a_SizeZ, ///< Count of the array, in each direction + NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction + NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction + NOISE_DATATYPE a_StartZ, NOISE_DATATYPE a_EndZ, ///< Noise-space coords of the array in the Z direction + NOISE_DATATYPE * a_Workspace ///< Workspace that this function can use and trash +) const +{ + if (m_Octaves.empty()) + { + // No work to be done + ASSERT(!"RidgedMulti: No octaves to generate!"); + return; + } + + bool ShouldFreeWorkspace = (a_Workspace == NULL); + int ArrayCount = a_SizeX * a_SizeY * a_SizeZ; + if (ShouldFreeWorkspace) + { + a_Workspace = new NOISE_DATATYPE[ArrayCount]; + } + + // Generate the first octave directly into array: + const cOctave & FirstOctave = m_Octaves.front(); + + FirstOctave.m_Noise.Generate3D( + a_Workspace, a_SizeX, a_SizeY, a_SizeZ, + a_StartX * FirstOctave.m_Frequency, a_EndX * FirstOctave.m_Frequency, + a_StartY * FirstOctave.m_Frequency, a_EndY * FirstOctave.m_Frequency, + a_StartZ * FirstOctave.m_Frequency, a_EndZ * FirstOctave.m_Frequency + ); + NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude; + for (int i = 0; i < ArrayCount; i++) + { + a_Array[i] = a_Workspace[i] * Amplitude; + } + + // Add each octave: + for (cOctaves::const_iterator itr = m_Octaves.begin() + 1, end = m_Octaves.end(); itr != end; ++itr) + { + // Generate cubic noise for the octave: + itr->m_Noise.Generate3D( + a_Workspace, a_SizeX, a_SizeY, a_SizeZ, + a_StartX * itr->m_Frequency, a_EndX * itr->m_Frequency, + a_StartY * itr->m_Frequency, a_EndY * itr->m_Frequency, + a_StartZ * itr->m_Frequency, a_EndZ * itr->m_Frequency + ); + // Add the cubic noise into the output: + NOISE_DATATYPE Amplitude = itr->m_Amplitude; + for (int i = 0; i < ArrayCount; i++) + { + a_Array[i] += a_Workspace[i] * Amplitude; + } + } + + if (ShouldFreeWorkspace) + { + delete[] a_Workspace; + } +} + + + + diff --git a/src/Noise.h b/src/Noise.h index e605051b5..83af0cf08 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -192,6 +192,70 @@ protected: +class cRidgedMultiNoise +{ +public: + cRidgedMultiNoise(void); + cRidgedMultiNoise(int a_Seed); + + + void SetSeed(int a_Seed); + + void AddOctave(NOISE_DATATYPE a_Frequency, NOISE_DATATYPE a_Amplitude); + + void Generate1D( + NOISE_DATATYPE * a_Array, ///< Array to generate into + int a_SizeX, ///< Count of the array + NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array + NOISE_DATATYPE * a_Workspace = NULL ///< Workspace that this function can use and trash + ) const; + + + void Generate2D( + NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y] + int a_SizeX, int a_SizeY, ///< Count of the array, in each direction + NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction + NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction + NOISE_DATATYPE * a_Workspace = NULL ///< Workspace that this function can use and trash + ) const; + + + void Generate3D( + NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y + a_SizeX * a_SizeY * z] + int a_SizeX, int a_SizeY, int a_SizeZ, ///< Count of the array, in each direction + NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction + NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction + NOISE_DATATYPE a_StartZ, NOISE_DATATYPE a_EndZ, ///< Noise-space coords of the array in the Z direction + NOISE_DATATYPE * a_Workspace = NULL ///< Workspace that this function can use and trash + ) const; + +protected: + class cOctave + { + public: + cCubicNoise m_Noise; + + NOISE_DATATYPE m_Frequency; // Coord multiplier + NOISE_DATATYPE m_Amplitude; // Value multiplier + + cOctave(int a_Seed, NOISE_DATATYPE a_Frequency, NOISE_DATATYPE a_Amplitude) : + m_Noise(a_Seed), + m_Frequency(a_Frequency), + m_Amplitude(a_Amplitude) + { + } + } ; + + typedef std::vector cOctaves; + + int m_Seed; + cOctaves m_Octaves; +} ; + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Inline function definitions: // These need to be in the header, otherwise linker error occur in MSVC -- cgit v1.2.3 From 9ff0ef87d4bca688b7fab8c7f4c9f9fcf683c06f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 9 Jun 2014 23:40:51 +0200 Subject: Added an experimental height generator, Mountains. --- src/Generating/HeiGen.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++ src/Generating/HeiGen.h | 21 +++++++++++++++ 2 files changed, 87 insertions(+) (limited to 'src') diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index 3621421c2..25ac912fd 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -47,6 +47,10 @@ cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBio { res = new cEndGen(a_Seed); } + else if (NoCaseCompare(HeightGenName, "Mountains") == 0) + { + res = new cHeiGenMountains(a_Seed); + } else if (NoCaseCompare(HeightGenName, "Noise3D") == 0) { res = new cNoise3DComposable(a_Seed); @@ -300,6 +304,68 @@ void cHeiGenClassic::InitializeHeightGen(cIniFile & a_IniFile) +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cHeiGenMountains: + +cHeiGenMountains::cHeiGenMountains(int a_Seed) : + m_Seed(a_Seed), + m_Noise(a_Seed) +{ +} + + + + + +void cHeiGenMountains::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) +{ + NOISE_DATATYPE StartX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width); + NOISE_DATATYPE EndX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + cChunkDef::Width - 1); + NOISE_DATATYPE StartZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width); + NOISE_DATATYPE EndZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + cChunkDef::Width - 1); + NOISE_DATATYPE Workspace[16 * 16]; + NOISE_DATATYPE Noise[16 * 16]; + NOISE_DATATYPE PerlinNoise[16 * 16]; + m_Noise.Generate2D(Noise, 16, 16, StartX, EndX, StartZ, EndZ, Workspace); + m_Perlin.Generate2D(PerlinNoise, 16, 16, StartX, EndX, StartZ, EndZ, Workspace); + for (int z = 0; z < cChunkDef::Width; z++) + { + int IdxZ = z * cChunkDef::Width; + for (int x = 0; x < cChunkDef::Width; x++) + { + int idx = IdxZ + x; + int hei = 100 - (int)((Noise[idx] + PerlinNoise[idx]) * 15); + if (hei < 10) + { + hei = 10; + } + if (hei > 250) + { + hei = 250; + } + cChunkDef::SetHeight(a_HeightMap, x , z, hei); + } // for x + } // for z +} + + + + + +void cHeiGenMountains::InitializeHeightGen(cIniFile & a_IniFile) +{ + // TODO: Read the params from an INI file + m_Noise.AddOctave(0.1f, 0.1f); + m_Noise.AddOctave(0.05f, 0.5f); + m_Noise.AddOctave(0.02f, 1.5f); + + m_Perlin.AddOctave(0.01f, 1.5f); +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cHeiGenBiomal: diff --git a/src/Generating/HeiGen.h b/src/Generating/HeiGen.h index 1376f2a25..5c106c7d9 100644 --- a/src/Generating/HeiGen.h +++ b/src/Generating/HeiGen.h @@ -106,6 +106,27 @@ protected: +class cHeiGenMountains : + public cTerrainHeightGen +{ +public: + cHeiGenMountains(int a_Seed); + +protected: + + int m_Seed; + cRidgedMultiNoise m_Noise; + cPerlinNoise m_Perlin; + + // cTerrainHeightGen overrides: + virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override; + virtual void InitializeHeightGen(cIniFile & a_IniFile) override; +} ; + + + + + class cHeiGenBiomal : public cTerrainHeightGen { -- cgit v1.2.3 From 6c43799cc558a435a03d82218738a9ff57fb6702 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 10 Jun 2014 09:20:32 +0200 Subject: Fixed gcc compilation. --- src/Noise.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Noise.cpp b/src/Noise.cpp index 9c7042b02..e2e54efdf 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -1022,7 +1022,7 @@ void cRidgedMultiNoise::Generate2D( NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude; for (int i = 0; i < ArrayCount; i++) { - a_Array[i] = std::abs(a_Workspace[i] * Amplitude); + a_Array[i] = abs(a_Workspace[i] * Amplitude); } // Add each octave: @@ -1038,7 +1038,7 @@ void cRidgedMultiNoise::Generate2D( NOISE_DATATYPE Amplitude = itr->m_Amplitude; for (int i = 0; i < ArrayCount; i++) { - a_Array[i] += std::abs(a_Workspace[i] * Amplitude); + a_Array[i] += abs(a_Workspace[i] * Amplitude); } } -- cgit v1.2.3 From 366ecf9dfd38d612c0685f3fbf8b3a95b9900697 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 10 Jun 2014 18:25:53 +0200 Subject: Fixed a race condition when adding a player to a world. --- src/ChunkMap.cpp | 24 ++++++++++++++++++++++++ src/ChunkMap.h | 4 ++++ src/World.cpp | 5 +---- 3 files changed, 29 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 0a8164b47..dba6f3f41 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1665,6 +1665,30 @@ void cChunkMap::AddEntity(cEntity * a_Entity) +void cChunkMap::AddEntityIfNotPresent(cEntity * a_Entity) +{ + cCSLock Lock(m_CSLayers); + cChunkPtr Chunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ()); + if ( + (Chunk == NULL) || // Chunk not present at all + (!Chunk->IsValid() && !a_Entity->IsPlayer()) // Chunk present, but no valid data; players need to spawn in such chunks (#953) + ) + { + LOGWARNING("Entity at %p (%s, ID %d) spawning in a non-existent chunk, the entity is lost.", + a_Entity, a_Entity->GetClass(), a_Entity->GetUniqueID() + ); + return; + } + if (!Chunk->HasEntity(a_Entity->GetUniqueID())) + { + Chunk->AddEntity(a_Entity); + } +} + + + + + bool cChunkMap::HasEntity(int a_UniqueID) { cCSLock Lock(m_CSLayers); diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 8786d7016..7e85bb6f1 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -199,6 +199,10 @@ public: /** Adds the entity to its appropriate chunk, takes ownership of the entity pointer */ void AddEntity(cEntity * a_Entity); + /** Adds the entity to its appropriate chunk, if the entity is not already added. + Takes ownership of the entity pointer */ + void AddEntityIfNotPresent(cEntity * a_Entity); + /** Returns true if the entity with specified ID is present in the chunks */ bool HasEntity(int a_EntityID); diff --git a/src/World.cpp b/src/World.cpp index ebe6b53e6..6bcd1391a 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -3148,10 +3148,7 @@ void cWorld::AddQueuedPlayers(void) (*itr)->SetWorld(this); // Add to chunkmap, if not already there (Spawn vs MoveToWorld): - if (!m_ChunkMap->HasEntity((*itr)->GetUniqueID())) - { - m_ChunkMap->AddEntity(*itr); - } + m_ChunkMap->AddEntityIfNotPresent(*itr); } // for itr - PlayersToAdd[] } // Lock(m_CSPlayers) -- cgit v1.2.3 From c259dad7b8561c9712c8e2c5c55d6399e9d26325 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 10 Jun 2014 18:27:17 +0200 Subject: Fixed clang warnings about abs() in Noise.cpp. MSVC provides a float overload of abs(), clang does not. Using the proper fabs(). --- src/Noise.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Noise.cpp b/src/Noise.cpp index e2e54efdf..040421106 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -1022,7 +1022,7 @@ void cRidgedMultiNoise::Generate2D( NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude; for (int i = 0; i < ArrayCount; i++) { - a_Array[i] = abs(a_Workspace[i] * Amplitude); + a_Array[i] = fabs(a_Workspace[i] * Amplitude); } // Add each octave: @@ -1038,7 +1038,7 @@ void cRidgedMultiNoise::Generate2D( NOISE_DATATYPE Amplitude = itr->m_Amplitude; for (int i = 0; i < ArrayCount; i++) { - a_Array[i] += abs(a_Workspace[i] * Amplitude); + a_Array[i] += fabs(a_Workspace[i] * Amplitude); } } -- cgit v1.2.3 From 35b79e5d710862f957bc494638a8d8906992665d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 10 Jun 2014 20:43:27 +0100 Subject: Portal improvements and suggestions --- src/BlockID.cpp | 35 +++++++++++++ src/BlockID.h | 7 ++- src/Chunk.cpp | 15 +++++- src/Entities/Entity.cpp | 130 +++++++++++++++++++++++++++++++++--------------- src/Entities/Entity.h | 3 ++ src/Root.cpp | 6 +-- src/Root.h | 2 +- src/World.cpp | 18 +++++-- src/World.h | 13 ++++- 9 files changed, 175 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/BlockID.cpp b/src/BlockID.cpp index bfe826f40..641a6a225 100644 --- a/src/BlockID.cpp +++ b/src/BlockID.cpp @@ -345,6 +345,41 @@ eDimension StringToDimension(const AString & a_DimensionString) +AString DimensionToString(eDimension a_Dimension) +{ + // Decode using a built-in map: + static struct + { + eDimension m_Dimension; + const char * m_String; + } DimensionMap[] = + { + { dimOverworld, "Overworld" }, + { dimOverworld, "Normal" }, + { dimOverworld, "World" }, + { dimNether, "Nether" }, + { dimNether, "Hell" }, // Alternate name for Nether + { dimEnd, "End" }, + { dimEnd, "Sky" }, // Old name for End + }; + + for (size_t i = 0; i < ARRAYCOUNT(DimensionMap); i++) + { + if (DimensionMap[i].m_Dimension == a_Dimension) + { + return DimensionMap[i].m_String; + } + } // for i - DimensionMap[] + + // Not found + LOGWARNING("Unknown dimension: \"%i\". Setting to Overworld", (int)a_Dimension); + return "Overworld"; +} + + + + + /// Translates damage type constant to a string representation (built-in). AString DamageTypeToString(eDamageType a_DamageType) { diff --git a/src/BlockID.h b/src/BlockID.h index a227245aa..97c1aae86 100644 --- a/src/BlockID.h +++ b/src/BlockID.h @@ -916,9 +916,14 @@ extern AString ItemToFullString(const cItem & a_Item); /// Translates a mob string ("ocelot") to mobtype (E_ENTITY_TYPE_OCELOT) extern int StringToMobType(const AString & a_MobString); -/// Translates a dimension string to dimension enum. Takes either a number or a dimension alias (built-in). Returns -1000 on failure +/// Translates a dimension string to dimension enum. Takes either a number or a dimension alias (built-in). Returns dimOverworld on failure extern eDimension StringToDimension(const AString & a_DimensionString); +/** Translates a dimension enum to dimension string. +Takes a string and returns "Overworld" on failure +*/ +extern AString DimensionToString(eDimension a_Dimension); + /// Translates damage type constant to a string representation (built-in). extern AString DamageTypeToString(eDamageType a_DamageType); diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 2850dd93b..02857ba5a 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1859,7 +1859,20 @@ void cChunk::AddEntity(cEntity * a_Entity) MarkDirty(); } - ASSERT(std::find(m_Entities.begin(), m_Entities.end(), a_Entity) == m_Entities.end()); // Not there already + if (std::find(m_Entities.begin(), m_Entities.end(), a_Entity) != m_Entities.end()) + { + // Not there already + std::vector::iterator itr = std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), a_Entity->GetUniqueID()); + if (itr != m_EntitiesToRemove.end()) + { + m_EntitiesToRemove.erase(itr); + return; + } + else + { + ASSERT(!"Entity already present when AddEntity was called!"); + } + } m_Entities.push_back(a_Entity); } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 2d8f385cb..4b376a1fe 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -12,6 +12,7 @@ #include "../Bindings/PluginManager.h" #include "../Tracer.h" #include "Player.h" +#include "BlockArea.h" @@ -1047,6 +1048,28 @@ void cEntity::DetectPortal() return; } + class cPortalChunkLoader : public cChunkStay + { + public: + cPortalChunkLoader(cEntity * a_Entity, Vector3i & a_PortalPos) : + m_Entity(a_Entity), + m_PortalPos(a_PortalPos) + {} + + private: + virtual bool OnAllChunksAvailable(void) override + { + m_Entity->CreateExitPortal(m_PortalPos.x, m_PortalPos.y, m_PortalPos.z); + return true; + } + + virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override {}; + virtual void OnDisabled(void) override {}; + + cEntity * m_Entity; + Vector3i m_PortalPos; + }; + int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; if ((Y > 0) && (Y < cChunkDef::Height)) { @@ -1061,31 +1084,31 @@ void cEntity::DetectPortal() switch (GetWorld()->GetDimension()) { - case dimNether: + case dimNether: MoveToWorld(GetWorld()->GetLinkedOverworldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName())); break; + case dimOverworld: { - cIniFile OwnIni; - OwnIni.ReadFile(GetWorld()->GetIniFileName()); - AString OverworldName = OwnIni.GetValue("General", "OverworldName", cRoot::Get()->GetDefaultWorld()->GetName()); + if (IsPlayer()) + { + ((cPlayer *)this)->AwardAchievement(achEnterPortal); + } + MoveToWorld(GetWorld()->GetNetherWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetNetherWorldName(), dimNether, GetWorld()->GetName())); + + cChunkStay * Stay = new cPortalChunkLoader(this, Vector3i(X, Y, Z)); - cFile::CreateFolder(FILE_IO_PREFIX + OverworldName); - cIniFile File; - File.ReadFile(OverworldName + "/world.ini"); - File.SetValue("General", "Dimension", "Overworld"); - File.WriteFile(OverworldName + "/world.ini"); + int MinChunkX, MaxChunkX; + int MinChunkZ, MaxChunkZ; + cChunkDef::BlockToChunk(X - 128, Z - 128, MinChunkX, MinChunkZ); + cChunkDef::BlockToChunk(X + 128, Z + 128, MaxChunkX, MaxChunkZ); - MoveToWorld(OverworldName, cRoot::Get()->CreateAndInitializeWorld(OverworldName)); - break; - } - case dimOverworld: - { - cFile::CreateFolder(FILE_IO_PREFIX + GetWorld()->GetNetherWorldName()); - cIniFile File; - File.ReadFile(GetWorld()->GetNetherWorldName() + "/world.ini"); - File.SetValue("General", "Dimension", "Nether"); - File.SetValue("General", "OverworldName", GetWorld()->GetName()); - File.WriteFile(GetWorld()->GetNetherWorldName() + "/world.ini"); - - MoveToWorld(GetWorld()->GetNetherWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetNetherWorldName())); + for (int OtherMinChunkX = MinChunkX; OtherMinChunkX <= MaxChunkX; ++OtherMinChunkX) + { + for (int OtherMinChunkZ = MinChunkZ; OtherMinChunkZ <= MaxChunkZ; ++OtherMinChunkZ) + { + Stay->Add(OtherMinChunkX, OtherMinChunkZ); + } + } + + Stay->Enable(*GetWorld()->GetChunkMap()); break; } default: break; @@ -1103,17 +1126,7 @@ void cEntity::DetectPortal() { case dimEnd: { - cIniFile OwnIni; - OwnIni.ReadFile(GetWorld()->GetIniFileName()); - AString OverworldName = OwnIni.GetValue("General", "OverworldName", cRoot::Get()->GetDefaultWorld()->GetName()); - - cFile::CreateFolder(FILE_IO_PREFIX + OverworldName); - cIniFile File; - File.ReadFile(OverworldName + "/world.ini"); - File.SetValue("General", "Dimension", "Overworld"); - File.WriteFile(OverworldName + "/world.ini"); - - MoveToWorld(OverworldName, cRoot::Get()->CreateAndInitializeWorld(OverworldName)); + MoveToWorld(GetWorld()->GetLinkedOverworldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName())); if (IsPlayer()) { @@ -1124,14 +1137,11 @@ void cEntity::DetectPortal() } case dimOverworld: { - cFile::CreateFolder(FILE_IO_PREFIX + GetWorld()->GetEndWorldName()); - cIniFile File; - File.ReadFile(GetWorld()->GetEndWorldName() + "/world.ini"); - File.SetValue("General", "Dimension", "End"); - File.SetValue("General", "OverworldName", GetWorld()->GetName()); - File.WriteFile(GetWorld()->GetEndWorldName() + "/world.ini"); - - MoveToWorld(GetWorld()->GetEndWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetEndWorldName())); + if (IsPlayer()) + { + ((cPlayer *)this)->AwardAchievement(achEnterTheEnd); + } + MoveToWorld(GetWorld()->GetEndWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetEndWorldName(), dimEnd, GetWorld()->GetName())); break; } default: break; @@ -1146,6 +1156,44 @@ void cEntity::DetectPortal() +void cEntity::CreateExitPortal(int a_BlockX, int a_BlockY, int a_BlockZ) +{ + cBlockArea Area; + Area.Read(GetWorld(), a_BlockX - 128, a_BlockX + 128, 0, 128, a_BlockZ - 128, a_BlockZ + 128); + for (int x = a_BlockX - 128; x <= a_BlockX + 128; ++x) for (int y = 0; y <= 128; ++y) for (int z = a_BlockZ - 128; z <= a_BlockZ + 128; ++z) + { + if ( + (Area.GetBlockType(x, y, z) == E_BLOCK_NETHER_PORTAL) && + ( + (Area.GetBlockType(x, (int)floor(y + GetHeight()), z) == E_BLOCK_NETHER_PORTAL) || + (Area.GetBlockType(x, (int)floor(y - GetHeight()), z) == E_BLOCK_NETHER_PORTAL) + ) + ) + { + TeleportToCoords(x, y, z); + return; + } + } + + int MinX = std::max(a_BlockX - (int)ceil(GetWidth()), a_BlockX - 2), MaxX = std::max(a_BlockX + (int)ceil(GetWidth()), a_BlockX + 1); + int MinY = std::max(a_BlockY - (int)ceil(GetHeight()), a_BlockY - 2), MaxY = std::max(a_BlockY + (int)ceil(GetHeight()), a_BlockY + 1); + + for (int y = MinY; y < MaxY + 1; y += MaxY - MinY) for (int x = MinX; x < MaxX + 1; ++x) + { + Area.SetBlockType(x, y, a_BlockZ, E_BLOCK_OBSIDIAN); + } + for (int y = MinY; y < MaxY + 1; ++y) for (int x = MinX; x < MaxX + 1; x += MaxX - MinX) + { + Area.SetBlockType(x, y, a_BlockZ, E_BLOCK_OBSIDIAN); + } + + Area.Write(GetWorld(), MinX, MinY, a_BlockZ); +} + + + + + bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World) { cWorld * World; diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index da8256606..b2317aaac 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -335,6 +335,9 @@ public: /// Called when the entity finishes burning virtual void OnFinishedBurning(void); + + /** Creates exit portal at given coordinates */ + void CreateExitPortal(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_begin diff --git a/src/Root.cpp b/src/Root.cpp index 2a80baeb3..572cbf1fc 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -314,15 +314,15 @@ void cRoot::LoadWorlds(cIniFile & IniFile) -cWorld * cRoot::CreateAndInitializeWorld(const AString & a_WorldName) +cWorld * cRoot::CreateAndInitializeWorld(const AString & a_WorldName, eDimension a_Dimension, const AString & a_OverworldName) { if (m_WorldsByName[a_WorldName] != NULL) { return NULL; } - cWorld * NewWorld = new cWorld(a_WorldName.c_str()); + cWorld * NewWorld = new cWorld(a_WorldName.c_str(), a_Dimension, a_OverworldName); m_WorldsByName[a_WorldName] = NewWorld; - NewWorld->Start(); + NewWorld->Start(!a_OverworldName.empty()); NewWorld->InitializeSpawn(); m_PluginManager->CallHookWorldStarted(*NewWorld); return NewWorld; diff --git a/src/Root.h b/src/Root.h index d2a4d1eed..1b56b4528 100644 --- a/src/Root.h +++ b/src/Root.h @@ -44,7 +44,7 @@ public: cServer * GetServer(void) { return m_Server; } // tolua_export cWorld * GetDefaultWorld(void); // tolua_export cWorld * GetWorld(const AString & a_WorldName); // tolua_export - cWorld * CreateAndInitializeWorld(const AString & a_WorldName); // tolua_export + cWorld * CreateAndInitializeWorld(const AString & a_WorldName, eDimension a_Dimension = dimOverworld, const AString & a_OverworldName = ""); // tolua_export /// Calls the callback for each world; returns true if the callback didn't abort (return true) bool ForEachWorld(cWorldListCallback & a_Callback); // >> Exported in ManualBindings << diff --git a/src/World.cpp b/src/World.cpp index 1b5582b81..1f4a88fa0 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -232,7 +232,7 @@ void cWorld::cTickThread::Execute(void) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cWorld: -cWorld::cWorld(const AString & a_WorldName) : +cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AString & a_OverworldName) : m_WorldName(a_WorldName), m_IniFileName(m_WorldName + "/world.ini"), m_StorageSchema("Default"), @@ -253,7 +253,9 @@ cWorld::cWorld(const AString & a_WorldName) : m_Scoreboard(this), m_MapManager(this), m_GeneratorCallbacks(*this), - m_TickThread(*this) + m_TickThread(*this), + m_Dimension(a_Dimension), + m_OverworldName(a_OverworldName) { LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str()); @@ -511,7 +513,7 @@ void cWorld::InitializeSpawn(void) -void cWorld::Start(void) +void cWorld::Start(bool a_WasDimensionSet) { m_SpawnX = 0; m_SpawnY = cChunkDef::Height; @@ -523,8 +525,10 @@ void cWorld::Start(void) { LOGWARNING("Cannot read world settings from \"%s\", defaults will be used.", m_IniFileName.c_str()); } - AString Dimension = IniFile.GetValueSet("General", "Dimension", "Overworld"); + + AString Dimension = IniFile.GetValueSet("General", "Dimension", a_WasDimensionSet ? DimensionToString(GetDimension()) : "Overworld"); m_Dimension = StringToDimension(Dimension); + m_OverworldName = IniFile.GetValue("General", "OverworldName", a_WasDimensionSet ? m_OverworldName : ""); // Try to find the "SpawnPosition" key and coord values in the world configuration, set the flag if found int KeyNum = IniFile.FindKey("SpawnPosition"); @@ -570,7 +574,7 @@ void cWorld::Start(void) m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true); int GameMode = IniFile.GetValueSetI("General", "Gamemode", (int)m_GameMode); int Weather = IniFile.GetValueSetI("General", "Weather", (int)m_Weather); - m_TimeOfDay = IniFile.GetValueSetI("General", "TimeInTicks", m_TimeOfDay); + m_TimeOfDay = IniFile.GetValueSetI("General", "TimeInTicks", m_TimeOfDay); if ((GetDimension() != dimNether) && (GetDimension() != dimEnd)) { @@ -759,6 +763,10 @@ void cWorld::Stop(void) IniFile.SetValueB("General", "EndPortalsEnabled", m_bEndPortalsEnabled); IniFile.SetValue("General", "EndWorldName", m_EndWorldName); } + else + { + IniFile.SetValue("General", "OverworldName", m_OverworldName); + } IniFile.SetValueI("Physics", "TNTShrapnelLevel", (int)m_TNTShrapnelLevel); IniFile.SetValueB("Mechanics", "CommandBlocksEnabled", m_bCommandBlocksEnabled); IniFile.SetValueB("Mechanics", "UseChatPrefixes", m_bUseChatPrefixes); diff --git a/src/World.h b/src/World.h index 80f69f22f..676c5d69a 100644 --- a/src/World.h +++ b/src/World.h @@ -636,6 +636,9 @@ public: AString GetEndWorldName(void) const { return m_EndWorldName; } void SetEndWorldName(const AString & a_Name) { m_EndWorldName = a_Name; } + + AString GetLinkedOverworldName(void) const { return m_OverworldName; } + void SetLinkedOverworldName(const AString & a_Name) { m_OverworldName = a_Name; } // tolua_end @@ -679,7 +682,7 @@ public: void InitializeSpawn(void); /** Starts threads that belong to this world */ - void Start(void); + void Start(bool a_WasDimensionSet = true); /** Stops threads that belong to this world (part of deinit) */ void Stop(void); @@ -816,6 +819,12 @@ private: AString m_WorldName; + + /** The name of the world that a portal in this world should link to + Only has effect if this world is a nether or end world, as it is used by entities to see which world to teleport to when in a portal + */ + AString m_OverworldName; + AString m_IniFileName; /** Name of the storage schema used to load and save chunks */ @@ -953,7 +962,7 @@ private: cClientHandleList m_ClientsToAdd; - cWorld(const AString & a_WorldName); + cWorld(const AString & a_WorldName, eDimension a_Dimension = dimOverworld, const AString & a_OverworldName = ""); virtual ~cWorld(); void Tick(float a_Dt, int a_LastTickDurationMSec); -- cgit v1.2.3 From 1ff1a93866ab81e3868588a256f446a902a1a8c4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 10 Jun 2014 22:59:45 +0200 Subject: Initial Mesa Bryce implementation. --- src/Generating/DistortedHeightmap.cpp | 4 +- src/Generating/DistortedHeightmap.h | 6 +-- src/Generating/HeiGen.cpp | 89 +++++++++++++++++++++++++++++++++++ src/Generating/HeiGen.h | 21 +++++++++ 4 files changed, 116 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp index eb9fe92ba..e50f36d57 100644 --- a/src/Generating/DistortedHeightmap.cpp +++ b/src/Generating/DistortedHeightmap.cpp @@ -282,7 +282,7 @@ cDistortedHeightmap::cDistortedHeightmap(int a_Seed, cBiomeGen & a_BiomeGen) : m_OceanFloorSelect(a_Seed + 3000), m_MesaFloor(a_Seed + 4000), m_BiomeGen(a_BiomeGen), - m_UnderlyingHeiGen(a_Seed, a_BiomeGen), + m_UnderlyingHeiGen(a_Seed), m_HeightGen(m_UnderlyingHeiGen, 64), m_IsInitialized(false) { @@ -308,6 +308,8 @@ void cDistortedHeightmap::Initialize(cIniFile & a_IniFile) return; } + ((cTerrainHeightGen &)m_UnderlyingHeiGen).InitializeHeightGen(a_IniFile); + // Read the params from the INI file: m_SeaLevel = a_IniFile.GetValueSetI("Generator", "DistortedHeightmapSeaLevel", 62); m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "DistortedHeightmapFrequencyX", 10); diff --git a/src/Generating/DistortedHeightmap.h b/src/Generating/DistortedHeightmap.h index e6b3c9d3f..31fb17df2 100644 --- a/src/Generating/DistortedHeightmap.h +++ b/src/Generating/DistortedHeightmap.h @@ -64,9 +64,9 @@ protected: int m_CurChunkZ; NOISE_DATATYPE m_DistortedHeightmap[17 * 257 * 17]; - cBiomeGen & m_BiomeGen; - cHeiGenBiomal m_UnderlyingHeiGen; // This generator provides us with base heightmap (before distortion) - cHeiGenCache m_HeightGen; // Cache above m_UnderlyingHeiGen + cBiomeGen & m_BiomeGen; + cHeiGenMesaBryce m_UnderlyingHeiGen; // This generator provides us with base heightmap (before distortion) + cHeiGenCache m_HeightGen; // Cache above m_UnderlyingHeiGen /// Heightmap for the current chunk, before distortion (from m_HeightGen). Used for optimization. cChunkDef::HeightMap m_CurChunkHeights; diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index 25ac912fd..dedf3fe3f 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -47,6 +47,10 @@ cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBio { res = new cEndGen(a_Seed); } + else if (NoCaseCompare(HeightGenName, "MesaBryce") == 0) + { + res = new cHeiGenMesaBryce(a_Seed); + } else if (NoCaseCompare(HeightGenName, "Mountains") == 0) { res = new cHeiGenMountains(a_Seed); @@ -366,6 +370,91 @@ void cHeiGenMountains::InitializeHeightGen(cIniFile & a_IniFile) +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cHeiGenMesaBryce: + +cHeiGenMesaBryce::cHeiGenMesaBryce(int a_Seed) : + m_Seed(a_Seed), + m_PerlinHFHA(a_Seed), + m_PerlinLFLA(a_Seed + 10) +{ +} + + + + + +void cHeiGenMesaBryce::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) +{ + NOISE_DATATYPE StartX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width); + NOISE_DATATYPE EndX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + cChunkDef::Width - 1); + NOISE_DATATYPE StartZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width); + NOISE_DATATYPE EndZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + cChunkDef::Width - 1); + NOISE_DATATYPE Workspace[16 * 16]; + NOISE_DATATYPE Noise1[16 * 16]; + NOISE_DATATYPE Noise2[16 * 16]; + NOISE_DATATYPE Noise3[16 * 16]; + m_PerlinHFHA.Generate2D(Noise1, 16, 16, StartX, EndX, StartZ, EndZ, Workspace); + m_PerlinLFLA.Generate2D(Noise2, 16, 16, StartX, EndX, StartZ, EndZ, Workspace); + m_PerlinTops.Generate2D(Noise3, 16, 16, StartX, EndX, StartZ, EndZ, Workspace); + for (int z = 0; z < cChunkDef::Width; z++) + { + int IdxZ = z * cChunkDef::Width; + for (int x = 0; x < cChunkDef::Width; x++) + { + int idx = IdxZ + x; + // int hei = 70 + (int)(std::min(Noise1[idx], Noise2[idx]) * 15); + int hei; + if (Noise1[idx] > 1.5f) + { + hei = 83 + (int)floor(Noise3[idx]); + } + else + { + hei = 63 + (int)floor(Noise2[idx]); + } + /* + NOISE_DATATYPE v1 = sqrt(sqrt(std::max(Noise1[idx], (NOISE_DATATYPE)0))) - 50; + int hei = 60 + (int)floor(std::max(v1, 5 + Noise2[idx])); + */ + if (hei < 10) + { + hei = 10; + } + if (hei > 250) + { + hei = 250; + } + cChunkDef::SetHeight(a_HeightMap, x , z, hei); + } // for x + } // for z +} + + + + + +void cHeiGenMesaBryce::InitializeHeightGen(cIniFile & a_IniFile) +{ + // TODO: Read the params from an INI file + // m_PerlinHFHA.AddOctave(0.32f, 0.1); + /* + m_PerlinHFHA.AddOctave(0.13f, 17800000); + m_PerlinHFHA.AddOctave(0.12f, 19000000); + */ + m_PerlinHFHA.AddOctave(0.13f, 2); + m_PerlinHFHA.AddOctave(0.12f, 2); + + m_PerlinLFLA.AddOctave(0.04f, 1); + m_PerlinLFLA.AddOctave(0.02f, 2); + + m_PerlinTops.AddOctave(0.1f, 8); +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cHeiGenBiomal: diff --git a/src/Generating/HeiGen.h b/src/Generating/HeiGen.h index 5c106c7d9..5fc4f4abc 100644 --- a/src/Generating/HeiGen.h +++ b/src/Generating/HeiGen.h @@ -127,6 +127,27 @@ protected: +class cHeiGenMesaBryce : + public cTerrainHeightGen +{ +public: + cHeiGenMesaBryce(int a_Seed); + +protected: + int m_Seed; + cPerlinNoise m_PerlinHFHA; // HighFrequencyHighAmplitude, for the hills + cPerlinNoise m_PerlinLFLA; // LowFrequencyLowAmplitude, for the floor + cPerlinNoise m_PerlinTops; + + // cTerrainHeightGen overrides: + virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override; + virtual void InitializeHeightGen(cIniFile & a_IniFile) override; +} ; + + + + + class cHeiGenBiomal : public cTerrainHeightGen { -- cgit v1.2.3 From 3e258523821e67a5892fe44dd585bae896866d9a Mon Sep 17 00:00:00 2001 From: worktycho Date: Wed, 11 Jun 2014 10:04:34 +0100 Subject: Removed assert that is now informed by type system --- src/ByteBuffer.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index 4de89f7c1..d77f402fd 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -762,7 +762,6 @@ bool cByteBuffer::ReadUTF16String(AString & a_String, size_t a_NumChars) // Reads 2 * a_NumChars bytes and interprets it as a UTF16 string, converting it into UTF8 string a_String CHECK_THREAD; CheckValid(); - ASSERT(a_NumChars >= 0); AString RawData; if (!ReadString(RawData, a_NumChars * 2)) { -- cgit v1.2.3 From c3c3782c67265f2844dc66667d3e6bc79a6b25ff Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 11 Jun 2014 10:33:16 +0100 Subject: Add new IsWeatherWet hook for cauldrons. @madmaxoft can you comment? --- src/World.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/World.h b/src/World.h index abdc3120c..b0fed84ba 100644 --- a/src/World.h +++ b/src/World.h @@ -708,12 +708,23 @@ public: eWeather GetWeather (void) const { return m_Weather; }; bool IsWeatherSunny(void) const { return (m_Weather == wSunny); } + bool IsWeatherSunny(int a_BlockX, int a_BlockZ) const { + return (m_Weather == wSunny) + } bool IsWeatherRain (void) const { return (m_Weather == wRain); } + bool IsWeatherRain (int a_BlockX, int a_BlockZ) const { + return (m_Weather == wRain) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))) + } bool IsWeatherStorm(void) const { return (m_Weather == wStorm); } + bool IsWeatherStorm(int a_BlockX, int a_BlockZ) const { + return (m_Weather == wStorm) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))) + } /** Returns true if the current weather has any precipitation - rain or storm */ bool IsWeatherWet (void) const { return (m_Weather != wSunny); } - + bool IsWeatherWet (int a_BlockX, int a_BlockZ) const { + return (m_Weather != wSunny) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))) + } // tolua_end cChunkGenerator & GetGenerator(void) { return m_Generator; } -- cgit v1.2.3 From c5010ebcc13c29a567755d938dabfa5250de73fc Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 11 Jun 2014 13:01:52 +0100 Subject: Add DoxyComments to he weather things. Also changed the function names. --- src/World.h | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/World.h b/src/World.h index b0fed84ba..ac275b991 100644 --- a/src/World.h +++ b/src/World.h @@ -707,22 +707,39 @@ public: /** Returns the current weather. Instead of comparing values directly to the weather constants, use IsWeatherXXX() functions, if possible */ eWeather GetWeather (void) const { return m_Weather; }; + /** Returns true if the current weather is sun */ bool IsWeatherSunny(void) const { return (m_Weather == wSunny); } - bool IsWeatherSunny(int a_BlockX, int a_BlockZ) const { + + /** Returns true if it is sunny at the specified location. This takes into accunt biomes. */ + bool IsWeatherSunnyAt(int a_BlockX, int a_BlockZ) const + { return (m_Weather == wSunny) } - bool IsWeatherRain (void) const { return (m_Weather == wRain); } - bool IsWeatherRain (int a_BlockX, int a_BlockZ) const { + + /** Returns true if the current weather is rain */ + bool IsWeatherRain(void) const { return (m_Weather == wRain); } + + /** Returns true if it is raining at the specified location. This takes into accunt biomes. */ + bool IsWeatherRainAt (int a_BlockX, int a_BlockZ) const + { return (m_Weather == wRain) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))) } + + /** Returns true if the current weather is stormy */ bool IsWeatherStorm(void) const { return (m_Weather == wStorm); } - bool IsWeatherStorm(int a_BlockX, int a_BlockZ) const { + + /** Returns true if the weather is stormy at the specified location. This takes into accunt biomes. */ + bool IsWeatherStormAt(int a_BlockX, int a_BlockZ) const + { return (m_Weather == wStorm) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))) } - /** Returns true if the current weather has any precipitation - rain or storm */ - bool IsWeatherWet (void) const { return (m_Weather != wSunny); } - bool IsWeatherWet (int a_BlockX, int a_BlockZ) const { + /** Returns true if the current weather has any precipitation - rain, storm or snow */ + bool IsWeatherWet(void) const { return (m_Weather != wSunny); } + + /** Returns true if it is raining, stormy or snowing at the specified location. This takes into accunt biomes. */ + bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) const + { return (m_Weather != wSunny) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))) } // tolua_end -- cgit v1.2.3 From 711113cd2b9deaa2f556c446885e976a79fadcbf Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 11 Jun 2014 13:10:10 +0100 Subject: Updated unnecessary function :/ --- src/World.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/World.h b/src/World.h index ac275b991..11c262e3a 100644 --- a/src/World.h +++ b/src/World.h @@ -710,9 +710,13 @@ public: /** Returns true if the current weather is sun */ bool IsWeatherSunny(void) const { return (m_Weather == wSunny); } - /** Returns true if it is sunny at the specified location. This takes into accunt biomes. */ + /** Returns true if it is sunny at the specified location. This takes into accunt biomes. + This function is identical to IsWeatherSunny except for two extra parameters that aren't used, but bearbin insists :/ + */ bool IsWeatherSunnyAt(int a_BlockX, int a_BlockZ) const { + UNUSED(a_BlockX); + UNUSED(a_BlockZ); return (m_Weather == wSunny) } -- cgit v1.2.3 From 7e4abcfe2d2b1b5d5f73ebb990b24427323624e8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 11 Jun 2014 14:14:54 +0200 Subject: Revert "Initial Mesa Bryce implementation." This reverts commit 1ff1a93866ab81e3868588a256f446a902a1a8c4. --- src/Generating/DistortedHeightmap.cpp | 4 +- src/Generating/DistortedHeightmap.h | 6 +-- src/Generating/HeiGen.cpp | 89 ----------------------------------- src/Generating/HeiGen.h | 21 --------- 4 files changed, 4 insertions(+), 116 deletions(-) (limited to 'src') diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp index e50f36d57..eb9fe92ba 100644 --- a/src/Generating/DistortedHeightmap.cpp +++ b/src/Generating/DistortedHeightmap.cpp @@ -282,7 +282,7 @@ cDistortedHeightmap::cDistortedHeightmap(int a_Seed, cBiomeGen & a_BiomeGen) : m_OceanFloorSelect(a_Seed + 3000), m_MesaFloor(a_Seed + 4000), m_BiomeGen(a_BiomeGen), - m_UnderlyingHeiGen(a_Seed), + m_UnderlyingHeiGen(a_Seed, a_BiomeGen), m_HeightGen(m_UnderlyingHeiGen, 64), m_IsInitialized(false) { @@ -308,8 +308,6 @@ void cDistortedHeightmap::Initialize(cIniFile & a_IniFile) return; } - ((cTerrainHeightGen &)m_UnderlyingHeiGen).InitializeHeightGen(a_IniFile); - // Read the params from the INI file: m_SeaLevel = a_IniFile.GetValueSetI("Generator", "DistortedHeightmapSeaLevel", 62); m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "DistortedHeightmapFrequencyX", 10); diff --git a/src/Generating/DistortedHeightmap.h b/src/Generating/DistortedHeightmap.h index 31fb17df2..e6b3c9d3f 100644 --- a/src/Generating/DistortedHeightmap.h +++ b/src/Generating/DistortedHeightmap.h @@ -64,9 +64,9 @@ protected: int m_CurChunkZ; NOISE_DATATYPE m_DistortedHeightmap[17 * 257 * 17]; - cBiomeGen & m_BiomeGen; - cHeiGenMesaBryce m_UnderlyingHeiGen; // This generator provides us with base heightmap (before distortion) - cHeiGenCache m_HeightGen; // Cache above m_UnderlyingHeiGen + cBiomeGen & m_BiomeGen; + cHeiGenBiomal m_UnderlyingHeiGen; // This generator provides us with base heightmap (before distortion) + cHeiGenCache m_HeightGen; // Cache above m_UnderlyingHeiGen /// Heightmap for the current chunk, before distortion (from m_HeightGen). Used for optimization. cChunkDef::HeightMap m_CurChunkHeights; diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index dedf3fe3f..25ac912fd 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -47,10 +47,6 @@ cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBio { res = new cEndGen(a_Seed); } - else if (NoCaseCompare(HeightGenName, "MesaBryce") == 0) - { - res = new cHeiGenMesaBryce(a_Seed); - } else if (NoCaseCompare(HeightGenName, "Mountains") == 0) { res = new cHeiGenMountains(a_Seed); @@ -370,91 +366,6 @@ void cHeiGenMountains::InitializeHeightGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cHeiGenMesaBryce: - -cHeiGenMesaBryce::cHeiGenMesaBryce(int a_Seed) : - m_Seed(a_Seed), - m_PerlinHFHA(a_Seed), - m_PerlinLFLA(a_Seed + 10) -{ -} - - - - - -void cHeiGenMesaBryce::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) -{ - NOISE_DATATYPE StartX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width); - NOISE_DATATYPE EndX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + cChunkDef::Width - 1); - NOISE_DATATYPE StartZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width); - NOISE_DATATYPE EndZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + cChunkDef::Width - 1); - NOISE_DATATYPE Workspace[16 * 16]; - NOISE_DATATYPE Noise1[16 * 16]; - NOISE_DATATYPE Noise2[16 * 16]; - NOISE_DATATYPE Noise3[16 * 16]; - m_PerlinHFHA.Generate2D(Noise1, 16, 16, StartX, EndX, StartZ, EndZ, Workspace); - m_PerlinLFLA.Generate2D(Noise2, 16, 16, StartX, EndX, StartZ, EndZ, Workspace); - m_PerlinTops.Generate2D(Noise3, 16, 16, StartX, EndX, StartZ, EndZ, Workspace); - for (int z = 0; z < cChunkDef::Width; z++) - { - int IdxZ = z * cChunkDef::Width; - for (int x = 0; x < cChunkDef::Width; x++) - { - int idx = IdxZ + x; - // int hei = 70 + (int)(std::min(Noise1[idx], Noise2[idx]) * 15); - int hei; - if (Noise1[idx] > 1.5f) - { - hei = 83 + (int)floor(Noise3[idx]); - } - else - { - hei = 63 + (int)floor(Noise2[idx]); - } - /* - NOISE_DATATYPE v1 = sqrt(sqrt(std::max(Noise1[idx], (NOISE_DATATYPE)0))) - 50; - int hei = 60 + (int)floor(std::max(v1, 5 + Noise2[idx])); - */ - if (hei < 10) - { - hei = 10; - } - if (hei > 250) - { - hei = 250; - } - cChunkDef::SetHeight(a_HeightMap, x , z, hei); - } // for x - } // for z -} - - - - - -void cHeiGenMesaBryce::InitializeHeightGen(cIniFile & a_IniFile) -{ - // TODO: Read the params from an INI file - // m_PerlinHFHA.AddOctave(0.32f, 0.1); - /* - m_PerlinHFHA.AddOctave(0.13f, 17800000); - m_PerlinHFHA.AddOctave(0.12f, 19000000); - */ - m_PerlinHFHA.AddOctave(0.13f, 2); - m_PerlinHFHA.AddOctave(0.12f, 2); - - m_PerlinLFLA.AddOctave(0.04f, 1); - m_PerlinLFLA.AddOctave(0.02f, 2); - - m_PerlinTops.AddOctave(0.1f, 8); -} - - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cHeiGenBiomal: diff --git a/src/Generating/HeiGen.h b/src/Generating/HeiGen.h index 5fc4f4abc..5c106c7d9 100644 --- a/src/Generating/HeiGen.h +++ b/src/Generating/HeiGen.h @@ -127,27 +127,6 @@ protected: -class cHeiGenMesaBryce : - public cTerrainHeightGen -{ -public: - cHeiGenMesaBryce(int a_Seed); - -protected: - int m_Seed; - cPerlinNoise m_PerlinHFHA; // HighFrequencyHighAmplitude, for the hills - cPerlinNoise m_PerlinLFLA; // LowFrequencyLowAmplitude, for the floor - cPerlinNoise m_PerlinTops; - - // cTerrainHeightGen overrides: - virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override; - virtual void InitializeHeightGen(cIniFile & a_IniFile) override; -} ; - - - - - class cHeiGenBiomal : public cTerrainHeightGen { -- cgit v1.2.3 From c09207cabcecb94b134f92e2dbfdad69da930b43 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 11 Jun 2014 13:20:31 +0100 Subject: SMICOLOSL Meant to be semicolons up there. --- src/World.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/World.h b/src/World.h index 11c262e3a..a72904f6a 100644 --- a/src/World.h +++ b/src/World.h @@ -717,7 +717,7 @@ public: { UNUSED(a_BlockX); UNUSED(a_BlockZ); - return (m_Weather == wSunny) + return (m_Weather == wSunny); } /** Returns true if the current weather is rain */ @@ -726,7 +726,7 @@ public: /** Returns true if it is raining at the specified location. This takes into accunt biomes. */ bool IsWeatherRainAt (int a_BlockX, int a_BlockZ) const { - return (m_Weather == wRain) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))) + return (m_Weather == wRain) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } /** Returns true if the current weather is stormy */ @@ -735,7 +735,7 @@ public: /** Returns true if the weather is stormy at the specified location. This takes into accunt biomes. */ bool IsWeatherStormAt(int a_BlockX, int a_BlockZ) const { - return (m_Weather == wStorm) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))) + return (m_Weather == wStorm) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } /** Returns true if the current weather has any precipitation - rain, storm or snow */ @@ -744,7 +744,7 @@ public: /** Returns true if it is raining, stormy or snowing at the specified location. This takes into accunt biomes. */ bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) const { - return (m_Weather != wSunny) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))) + return (m_Weather != wSunny) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } // tolua_end -- cgit v1.2.3 From b3300e3854861d6957f5dac30ce0c7b027a3e2ad Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 11 Jun 2014 14:22:27 +0200 Subject: Added cBlockArea:GetCoordRange to Lua API. --- src/Bindings/ManualBindings.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src') diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 14d9d16fc..acfd6f4f8 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -2538,6 +2538,37 @@ static int tolua_cBlockArea_GetSize(lua_State * tolua_S) +static int tolua_cBlockArea_GetCoordRange(lua_State * tolua_S) +{ + // function cBlockArea::GetCoordRange() + // Returns all three sizes of the area, miuns one, so that they represent the maximum coord value + // Exported manually because there's no direct C++ equivalent, + // plus tolua would generate extra input params for the outputs + + cLuaState L(tolua_S); + if (!L.CheckParamUserType(1, "cBlockArea")) + { + return 0; + } + + cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL); + if (self == NULL) + { + tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", NULL); + return 0; + } + + // Push the three origin coords: + lua_pushnumber(tolua_S, self->GetSizeX() - 1); + lua_pushnumber(tolua_S, self->GetSizeY() - 1); + lua_pushnumber(tolua_S, self->GetSizeZ() - 1); + return 3; +} + + + + + static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S) { // function cBlockArea::LoadFromSchematicFile @@ -2926,6 +2957,7 @@ void ManualBindings::Bind(lua_State * tolua_S) tolua_beginmodule(tolua_S, "cBlockArea"); tolua_function(tolua_S, "GetBlockTypeMeta", tolua_cBlockArea_GetBlockTypeMeta); + tolua_function(tolua_S, "GetCoordRange", tolua_cBlockArea_GetCoordRange); tolua_function(tolua_S, "GetOrigin", tolua_cBlockArea_GetOrigin); tolua_function(tolua_S, "GetRelBlockTypeMeta", tolua_cBlockArea_GetRelBlockTypeMeta); tolua_function(tolua_S, "GetSize", tolua_cBlockArea_GetSize); -- cgit v1.2.3 From f7913d3b742e13595e3ded99820a13ade8a3b674 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 11 Jun 2014 13:37:04 +0100 Subject: IsWeatherSunnyAt does something useful :D --- src/World.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/World.h b/src/World.h index a72904f6a..f9471e881 100644 --- a/src/World.h +++ b/src/World.h @@ -710,20 +710,16 @@ public: /** Returns true if the current weather is sun */ bool IsWeatherSunny(void) const { return (m_Weather == wSunny); } - /** Returns true if it is sunny at the specified location. This takes into accunt biomes. - This function is identical to IsWeatherSunny except for two extra parameters that aren't used, but bearbin insists :/ - */ + /** Returns true if it is sunny at the specified location. This takes into account biomes. */ bool IsWeatherSunnyAt(int a_BlockX, int a_BlockZ) const { - UNUSED(a_BlockX); - UNUSED(a_BlockZ); - return (m_Weather == wSunny); + return (IsWeatherSunny() || IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } /** Returns true if the current weather is rain */ bool IsWeatherRain(void) const { return (m_Weather == wRain); } - /** Returns true if it is raining at the specified location. This takes into accunt biomes. */ + /** Returns true if it is raining at the specified location. This takes into account biomes. */ bool IsWeatherRainAt (int a_BlockX, int a_BlockZ) const { return (m_Weather == wRain) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); @@ -732,7 +728,7 @@ public: /** Returns true if the current weather is stormy */ bool IsWeatherStorm(void) const { return (m_Weather == wStorm); } - /** Returns true if the weather is stormy at the specified location. This takes into accunt biomes. */ + /** Returns true if the weather is stormy at the specified location. This takes into account biomes. */ bool IsWeatherStormAt(int a_BlockX, int a_BlockZ) const { return (m_Weather == wStorm) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); @@ -741,7 +737,7 @@ public: /** Returns true if the current weather has any precipitation - rain, storm or snow */ bool IsWeatherWet(void) const { return (m_Weather != wSunny); } - /** Returns true if it is raining, stormy or snowing at the specified location. This takes into accunt biomes. */ + /** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */ bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) const { return (m_Weather != wSunny) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); -- cgit v1.2.3 From 1a9467574e462f467dc9e1a9cc45b68c87276968 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 11 Jun 2014 13:40:34 +0100 Subject: Reduced code duplication call @maxmaxoft! calling... call connected (0:20) call ended --- src/World.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/World.h b/src/World.h index f9471e881..7469c1054 100644 --- a/src/World.h +++ b/src/World.h @@ -722,7 +722,7 @@ public: /** Returns true if it is raining at the specified location. This takes into account biomes. */ bool IsWeatherRainAt (int a_BlockX, int a_BlockZ) const { - return (m_Weather == wRain) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); + return (IsWeatherRain() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } /** Returns true if the current weather is stormy */ @@ -731,16 +731,16 @@ public: /** Returns true if the weather is stormy at the specified location. This takes into account biomes. */ bool IsWeatherStormAt(int a_BlockX, int a_BlockZ) const { - return (m_Weather == wStorm) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); + return (IsWeatherStorm() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } /** Returns true if the current weather has any precipitation - rain, storm or snow */ - bool IsWeatherWet(void) const { return (m_Weather != wSunny); } + bool IsWeatherWet(void) const { return !IsWeatherSunny(); } /** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */ bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) const { - return (m_Weather != wSunny) && (!IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); + return (IsWeatherWet() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } // tolua_end -- cgit v1.2.3 From e24830f0b12597896d895855298e8dde5f448b5b Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 11 Jun 2014 13:49:57 +0100 Subject: Compile fix --- src/World.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/World.h b/src/World.h index 7469c1054..45b42b280 100644 --- a/src/World.h +++ b/src/World.h @@ -597,7 +597,7 @@ public: void GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow); /** Returns the biome at the specified coords. Reads the biome from the chunk, if loaded, otherwise uses the world generator to provide the biome value */ - EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ); + EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ) const; /** Sets the biome at the specified coords. Returns true if successful, false if not (chunk not loaded). Doesn't resend the chunk to clients, use ForceSendChunkTo() for that. */ -- cgit v1.2.3 From aa7c82580f2493052d119b1f27d5255c1609aa19 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 10 Jun 2014 23:16:38 -0700 Subject: Player.h: Moved doxy-comments to Entity.h Moved doxy-comments to the defining function in Entity.h rather than the overloaded functions in Player.h Comment for each function (instead of assumed encapsulating comments) @deprecated tag for ForceSetSpeed() --- src/Entities/Entity.h | 7 +++++++ src/Entities/Player.h | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index ed67465a3..ecd26b194 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -220,11 +220,18 @@ public: Vector3d m_Speed; // tolua_begin + /** Sets the speed of the entity and moves them in the given speed. */ virtual void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ); + /** Sets the speed of the entity and moves them in the given speed. */ void SetSpeed (const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); } + + /** Sets the speed for the X axis */ virtual void SetSpeedX (double a_SpeedX); + /** Sets the speed for the Y axis */ virtual void SetSpeedY (double a_SpeedY); + /** Sets the speed for the Z axis */ virtual void SetSpeedZ (double a_SpeedZ); + void SetWidth (double a_Width); void AddPosX (double a_AddPosX); diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 0f4773893..0fcf767e9 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -191,14 +191,14 @@ public: // Sets the current gamemode, doesn't check validity, doesn't send update packets to client void LoginSetGameMode(eGameMode a_GameMode); - /** Forces the player to move in the given direction. DEPRECATED! Use SetSpeed instead */ + /** Forces the player to move in the given direction. + * @deprecated Use SetSpeed instead. + */ void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export /** Sets the speed of the player and moves them in the given speed. */ void SetSpeed (const Vector3d & a_Speed); virtual void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ) override; - - /** Sets the speed for the X, Y or Z axis */ virtual void SetSpeedX (double a_SpeedX) override; virtual void SetSpeedY (double a_SpeedY) override; virtual void SetSpeedZ (double a_SpeedZ) override; -- cgit v1.2.3 From 70c20d77721f69e9f04a27630a4e4b65c5be601f Mon Sep 17 00:00:00 2001 From: worktycho Date: Wed, 11 Jun 2014 16:23:53 +0100 Subject: Fixed constness --- src/World.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/World.h b/src/World.h index 45b42b280..0a8dcffc4 100644 --- a/src/World.h +++ b/src/World.h @@ -597,7 +597,7 @@ public: void GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow); /** Returns the biome at the specified coords. Reads the biome from the chunk, if loaded, otherwise uses the world generator to provide the biome value */ - EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ) const; + EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ); /** Sets the biome at the specified coords. Returns true if successful, false if not (chunk not loaded). Doesn't resend the chunk to clients, use ForceSendChunkTo() for that. */ @@ -711,7 +711,7 @@ public: bool IsWeatherSunny(void) const { return (m_Weather == wSunny); } /** Returns true if it is sunny at the specified location. This takes into account biomes. */ - bool IsWeatherSunnyAt(int a_BlockX, int a_BlockZ) const + bool IsWeatherSunnyAt(int a_BlockX, int a_BlockZ) { return (IsWeatherSunny() || IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } @@ -720,7 +720,7 @@ public: bool IsWeatherRain(void) const { return (m_Weather == wRain); } /** Returns true if it is raining at the specified location. This takes into account biomes. */ - bool IsWeatherRainAt (int a_BlockX, int a_BlockZ) const + bool IsWeatherRainAt (int a_BlockX, int a_BlockZ) { return (IsWeatherRain() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } @@ -729,7 +729,7 @@ public: bool IsWeatherStorm(void) const { return (m_Weather == wStorm); } /** Returns true if the weather is stormy at the specified location. This takes into account biomes. */ - bool IsWeatherStormAt(int a_BlockX, int a_BlockZ) const + bool IsWeatherStormAt(int a_BlockX, int a_BlockZ) { return (IsWeatherStorm() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } @@ -738,7 +738,7 @@ public: bool IsWeatherWet(void) const { return !IsWeatherSunny(); } /** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */ - bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) const + bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) { return (IsWeatherWet() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } -- cgit v1.2.3 From f9fd5193602f4cbf0b201e13e9b410b264d09bf2 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 11 Jun 2014 17:26:10 +0100 Subject: Changed the teleport permissions to the new ones. --- src/GroupManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index 523697b07..e570bb2b1 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -123,7 +123,7 @@ bool cGroupManager::LoadGroups() IniFile.SetValue("Owner", "Permissions", "*", true); IniFile.SetValue("Owner", "Color", "2", true); - IniFile.SetValue("Moderator", "Permissions", "core.time,core.item,core.teleport,core.ban,core.unban,core.save-all,core.toggledownfall"); + IniFile.SetValue("Moderator", "Permissions", "core.time,core.item,core.tpa,core.tpaccept,core.ban,core.unban,core.save-all,core.toggledownfall"); IniFile.SetValue("Moderator", "Color", "2", true); IniFile.SetValue("Moderator", "Inherits", "Player", true); -- cgit v1.2.3 From 7cf544079f910ac8068b67ad39178ad040816367 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 11 Jun 2014 19:12:29 +0200 Subject: Roads in villages are made out of wooden planks if they generate on water. --- src/Generating/VillageGen.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index b9cb056ad..9917141ed 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -116,7 +116,8 @@ public: int a_Density, cPiecePool & a_Prefabs, cTerrainHeightGen & a_HeightGen, - BLOCKTYPE a_RoadBlock + BLOCKTYPE a_RoadBlock, + BLOCKTYPE a_WaterRoadBlock ) : super(a_OriginX, a_OriginZ), m_Seed(a_Seed), @@ -126,7 +127,8 @@ public: m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, 255, a_OriginZ + a_MaxSize), m_Prefabs(a_Prefabs), m_HeightGen(a_HeightGen), - m_RoadBlock(a_RoadBlock) + m_RoadBlock(a_RoadBlock), + m_WaterRoadBlock(a_WaterRoadBlock) { // Generate the pieces for this village; don't care about the Y coord: cBFSPieceGenerator pg(*this, a_Seed); @@ -179,6 +181,9 @@ protected: /** The block to use for the roads. */ BLOCKTYPE m_RoadBlock; + + /** The block used for the roads if the road is on water. */ + BLOCKTYPE m_WaterRoadBlock; // cGridStructGen::cStructure overrides: @@ -239,7 +244,14 @@ protected: { for (int x = MinX; x <= MaxX; x++) { - a_Chunk.SetBlockType(x, cChunkDef::GetHeight(a_HeightMap, x, z), z, m_RoadBlock); + if (IsBlockWater(a_Chunk.GetBlockType(x, cChunkDef::GetHeight(a_HeightMap, x, z), z))) + { + a_Chunk.SetBlockType(x, cChunkDef::GetHeight(a_HeightMap, x, z), z, m_WaterRoadBlock); + } + else + { + a_Chunk.SetBlockType(x, cChunkDef::GetHeight(a_HeightMap, x, z), z, m_RoadBlock); + } } } } @@ -374,6 +386,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ // If just one is not, no village is created, because it's likely that an unfriendly biome is too close cVillagePiecePool * VillagePrefabs = NULL; BLOCKTYPE RoadBlock = E_BLOCK_GRAVEL; + BLOCKTYPE WaterRoadBlock = E_BLOCK_PLANKS; int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 11; cVillagePiecePool * PlainsVillage = g_PlainsVillagePools[rnd % ARRAYCOUNT(g_PlainsVillagePools)]; cVillagePiecePool * DesertVillage = g_DesertVillagePools[rnd % ARRAYCOUNT(g_DesertVillagePools)]; @@ -422,7 +435,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ { return cStructurePtr(); } - return cStructurePtr(new cVillage(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, Density, *VillagePrefabs, m_HeightGen, RoadBlock)); + return cStructurePtr(new cVillage(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, Density, *VillagePrefabs, m_HeightGen, RoadBlock, WaterRoadBlock)); } -- cgit v1.2.3 From 220e6f5880354c9984e18718f723331bb904df45 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 11 Jun 2014 19:46:24 +0200 Subject: DispenserEntity code cleanup after PR merge. --- src/BlockEntities/DispenserEntity.cpp | 41 +++++++++++++++-------------------- src/BlockEntities/DispenserEntity.h | 19 ++++++++++------ 2 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 97e25ca6d..c02c68afa 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -150,31 +150,27 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) { SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkFireCharge, GetShootVector(Meta) * 20); m_Contents.ChangeSlotCount(a_SlotNum, -1); - break; } case E_ITEM_ARROW: { - SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkArrow, GetShootVector(Meta) * 20); + SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkArrow, GetShootVector(Meta) * 20 + Vector3d(0, 1, 0)); m_Contents.ChangeSlotCount(a_SlotNum, -1); - break; } case E_ITEM_SNOWBALL: { - SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkSnowball, GetShootVector(Meta) * 20); + SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkSnowball, GetShootVector(Meta) * 20 + Vector3d(0, 1, 0)); m_Contents.ChangeSlotCount(a_SlotNum, -1); - break; } case E_ITEM_EGG: { - SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkEgg, GetShootVector(Meta) * 20); + SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkEgg, GetShootVector(Meta) * 20 + Vector3d(0, 1, 0)); m_Contents.ChangeSlotCount(a_SlotNum, -1); - break; } @@ -194,31 +190,30 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) -void cDispenserEntity::SpawnProjectileFromDispenser(int & a_BlockX, int & a_BlockY, int & a_BlockZ, cProjectileEntity::eKind a_Kind, Vector3d a_ShootVector) -{ - if (a_Kind != cProjectileEntity::pkFireCharge) - { - a_ShootVector.y = a_ShootVector.y + 1; - } - m_World->CreateProjectile((double) a_BlockX + 0.5, (double) a_BlockY + 0.5, (double) a_BlockZ + 0.5, a_Kind, NULL, NULL, &a_ShootVector); + +void cDispenserEntity::SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_ShootVector) +{ + m_World->CreateProjectile((double)a_BlockX + 0.5, (double)a_BlockY + 0.5, (double)a_BlockZ + 0.5, a_Kind, NULL, NULL, &a_ShootVector); } -Vector3d cDispenserEntity::GetShootVector(NIBBLETYPE & a_Meta) -{ - switch(a_Meta) - { - case E_META_DROPSPENSER_FACING_YP: return Vector3d( 0, 1, 0); // UP - case E_META_DROPSPENSER_FACING_YM: return Vector3d( 0, -1, 0); // DOWN - case E_META_DROPSPENSER_FACING_XM: return Vector3d(-1, 0, 0); // WEST - case E_META_DROPSPENSER_FACING_XP: return Vector3d( 1, 0, 0); // EAST + +Vector3d cDispenserEntity::GetShootVector(NIBBLETYPE a_Meta) +{ + switch (a_Meta) + { + case E_META_DROPSPENSER_FACING_YP: return Vector3d( 0, 1, 0); + case E_META_DROPSPENSER_FACING_YM: return Vector3d( 0, -1, 0); + case E_META_DROPSPENSER_FACING_XM: return Vector3d(-1, 0, 0); + case E_META_DROPSPENSER_FACING_XP: return Vector3d( 1, 0, 0); case E_META_DROPSPENSER_FACING_ZM: return Vector3d( 0, 0, -1); case E_META_DROPSPENSER_FACING_ZP: return Vector3d( 0, 0, 1); } - + LOGWARNING("Unhandled dispenser meta: %d", a_Meta); + ASSERT(!"Unhandled dispenser facing"); return Vector3d(0, 1, 0); } diff --git a/src/BlockEntities/DispenserEntity.h b/src/BlockEntities/DispenserEntity.h index 9410a1129..b33d08342 100644 --- a/src/BlockEntities/DispenserEntity.h +++ b/src/BlockEntities/DispenserEntity.h @@ -17,25 +17,30 @@ public: // tolua_end - /// Constructor used for normal operation + /** Constructor used for normal operation */ cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); static const char * GetClassStatic(void) { return "cDispenserEntity"; } - /** Spawns a projectile of the given kind in front of the dispenser */ - void SpawnProjectileFromDispenser(int & a_BlockX, int & a_BlockY, int & a_BlockZ, cProjectileEntity::eKind a_Kind, Vector3d a_ShootVector); + // tolua_begin + + /** Spawns a projectile of the given kind in front of the dispenser with the specified speed. */ + void SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_Speed); - /** Returns how to aim the projectile */ - Vector3d GetShootVector(NIBBLETYPE & a_Meta); + /** Returns a unit vector in the cardinal direction of where the dispenser is facing. */ + Vector3d GetShootVector(NIBBLETYPE a_Meta); + + // tolua_end private: // cDropSpenser overrides: virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) override; - /// If such a bucket can fit, adds it to m_Contents and returns true + /** If such a bucket can fit, adds it to m_Contents and returns true */ bool ScoopUpLiquid(int a_SlotNum, short a_BucketItemType); - /// If the a_BlockInFront is liquidable and the empty bucket can fit, does the m_Contents processing and returns true + /** If the a_BlockInFront can be washed away by liquid and the empty bucket can fit, + does the m_Contents processing and returns true. Returns false otherwise. */ bool EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum); } ; // tolua_export -- cgit v1.2.3 From 29567c56107c86b70da130f995564beb2eaf424c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 12 Jun 2014 15:21:07 +0100 Subject: Portals animate and delay correctly --- src/Chunk.cpp | 74 ++++++++++------------ src/Chunk.h | 2 +- src/ChunkMap.cpp | 1 + src/ClientHandle.cpp | 7 +-- src/ClientHandle.h | 2 +- src/Entities/Entity.cpp | 121 +++++++++++++++++++++++++++--------- src/Entities/Entity.h | 10 ++- src/Entities/Player.cpp | 21 ++----- src/Entities/Player.h | 10 +-- src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.cpp | 8 +-- src/Protocol/Protocol125.h | 2 +- src/Protocol/Protocol16x.cpp | 4 +- src/Protocol/Protocol16x.h | 2 +- src/Protocol/Protocol17x.cpp | 8 +-- src/Protocol/Protocol17x.h | 2 +- src/Protocol/ProtocolRecognizer.cpp | 4 +- src/Protocol/ProtocolRecognizer.h | 2 +- src/World.cpp | 9 ++- 19 files changed, 174 insertions(+), 117 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 399c8b9c7..c9e4f5411 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -85,7 +85,8 @@ cChunk::cChunk( m_NeighborZM(a_NeighborZM), m_NeighborZP(a_NeighborZP), m_WaterSimulatorData(a_World->GetWaterSimulator()->CreateChunkData()), - m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData()) + m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData()), + m_EntityTickIteratorData(std::make_pair(false, &m_Entities.end())) { if (a_NeighborXM != NULL) { @@ -576,26 +577,38 @@ void cChunk::Tick(float a_Dt) } // Tick all entities in this chunk (except mobs): - for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) + m_EntityTickIteratorData.first = true; + for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) { - // Mobs are tickes inside MobTick (as we don't have to tick them if they are far away from players) + // Mobs are ticked inside cWorld::TickMobs() (as we don't have to tick them if they are far away from players) // Don't tick things queued to be removed - if ( - !((*itr)->IsMob()) && - (std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID()) == m_EntitiesToRemove.end()) - ) + if (!((*itr)->IsMob())) { + m_EntityTickIteratorData.second = &itr; (*itr)->Tick(a_Dt, *this); + + if (itr != *m_EntityTickIteratorData.second) + { + itr = *m_EntityTickIteratorData.second; + } + else + { + ++itr; + } + continue; } + ++itr; } // for itr - m_Entitites[] + m_EntityTickIteratorData.first = false; for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) { - std::vector::iterator itr2 = std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID()); - if (itr2 != m_EntitiesToRemove.end()) + if ((*itr)->IsDestroyed()) // Remove all entities that were scheduled for removal: { + LOGD("Destroying entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass()); + cEntity * ToDelete = *itr; itr = m_Entities.erase(itr); - m_EntitiesToRemove.erase(itr2); + delete ToDelete; } else if ( // If any entity moved out of the chunk, move it to the neighbor: ((*itr)->GetChunkX() != m_PosX) || @@ -607,17 +620,7 @@ void cChunk::Tick(float a_Dt) } else { - if ((*itr)->IsDestroyed()) // Remove all entities that were scheduled for removal: - { - LOGD("Destroying entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass()); - cEntity * ToDelete = *itr; - itr = m_Entities.erase(itr); - delete ToDelete; - } - else - { - ++itr; - } + ++itr; } } // for itr - m_Entitites[] @@ -1860,20 +1863,7 @@ void cChunk::AddEntity(cEntity * a_Entity) MarkDirty(); } - if (std::find(m_Entities.begin(), m_Entities.end(), a_Entity) != m_Entities.end()) - { - // Not there already - std::vector::iterator itr = std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), a_Entity->GetUniqueID()); - if (itr != m_EntitiesToRemove.end()) - { - m_EntitiesToRemove.erase(itr); - return; - } - else - { - ASSERT(!"Entity already present when AddEntity was called!"); - } - } + ASSERT(std::find(m_Entities.begin(), m_Entities.end(), a_Entity) == m_Entities.end()); m_Entities.push_back(a_Entity); } @@ -1884,7 +1874,14 @@ void cChunk::AddEntity(cEntity * a_Entity) void cChunk::RemoveEntity(cEntity * a_Entity) { - m_EntitiesToRemove.push_back(a_Entity->GetUniqueID()); + if (m_EntityTickIteratorData.first) + { + *m_EntityTickIteratorData.second = m_Entities.erase(*m_EntityTickIteratorData.second); + } + else + { + m_Entities.remove(a_Entity); + } // Mark as dirty if it was a server-generated entity: if (!a_Entity->IsPlayer()) @@ -1899,11 +1896,6 @@ void cChunk::RemoveEntity(cEntity * a_Entity) bool cChunk::HasEntity(int a_EntityID) { - if (std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), a_EntityID) != m_EntitiesToRemove.end()) - { - return false; // If EntitiesToRemove contains our ID, this chunk doesn't have it, as it should be removed soon - } - for (cEntityList::const_iterator itr = m_Entities.begin(), end = m_Entities.end(); itr != end; ++itr) { if ((*itr)->GetUniqueID() == a_EntityID) diff --git a/src/Chunk.h b/src/Chunk.h index 8123ac062..3046b2efe 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -425,7 +425,7 @@ private: // A critical section is not needed, because all chunk access is protected by its parent ChunkMap's csLayers cClientHandleList m_LoadedByClient; cEntityList m_Entities; - std::vector m_EntitiesToRemove; + std::pair m_EntityTickIteratorData; cBlockEntityList m_BlockEntities; /** Number of times the chunk has been requested to stay (by various cChunkStay objects); if zero, the chunk can be unloaded */ diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index dba6f3f41..d06b67b67 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2398,6 +2398,7 @@ bool cChunkMap::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinCh { for (int x = a_MinChunkX; x <= a_MaxChunkX; x++) { + LOG("Request %i %i", x, z); cChunkPtr Chunk = GetChunkNoLoad(x, ZERO_CHUNK_Y, z); if ((Chunk == NULL) || (!Chunk->IsValid())) { diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 256dad7da..84f096d67 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1766,8 +1766,7 @@ void cClientHandle::RemoveFromWorld(void) m_Protocol->SendUnloadChunk(itr->m_ChunkX, itr->m_ChunkZ); } // for itr - Chunks[] - // StreamChunks() called in cPlayer::MoveToWorld() after new world has been set - // Meanwhile here, we set last streamed values to bogus ones so everything is resent + // Here, we set last streamed values to bogus ones so everything is resent m_LastStreamedChunkX = 0x7fffffff; m_LastStreamedChunkZ = 0x7fffffff; m_HasSentPlayerChunk = false; @@ -2367,9 +2366,9 @@ void cClientHandle::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effec -void cClientHandle::SendRespawn(const cWorld & a_World) +void cClientHandle::SendRespawn(eDimension a_Dimension) { - m_Protocol->SendRespawn(a_World); + m_Protocol->SendRespawn(a_Dimension); } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 0d883f3af..99d10c3aa 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -149,7 +149,7 @@ public: void SendPlayerSpawn (const cPlayer & a_Player); void SendPluginMessage (const AString & a_Channel, const AString & a_Message); // Exported in ManualBindings.cpp void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID); - void SendRespawn (const cWorld & a_World); + void SendRespawn (eDimension a_Dimension); void SendExperience (void); void SendExperienceOrb (const cExpOrb & a_ExpOrb); void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode); diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 334cf5aa7..a7b6cca27 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1051,15 +1051,16 @@ void cEntity::DetectPortal() class cPortalChunkLoader : public cChunkStay { public: - cPortalChunkLoader(cEntity * a_Entity, Vector3i & a_PortalPos) : + cPortalChunkLoader(cEntity * a_Entity, cWorld & a_World, Vector3i & a_PortalPos) : m_Entity(a_Entity), - m_PortalPos(a_PortalPos) + m_PortalPos(a_PortalPos), + m_World(a_World) {} private: virtual bool OnAllChunksAvailable(void) override { - m_Entity->CreateExitPortal(m_PortalPos.x, m_PortalPos.y, m_PortalPos.z); + cEntity::CreateExitPortal(m_PortalPos.x, m_PortalPos.y, m_PortalPos.z, m_Entity->GetWidth(), m_Entity->GetHeight(), m_World, m_Entity->GetUniqueID()); return true; } @@ -1068,6 +1069,7 @@ void cEntity::DetectPortal() cEntity * m_Entity; Vector3i m_PortalPos; + cWorld & m_World; }; int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; @@ -1077,106 +1079,167 @@ void cEntity::DetectPortal() { case E_BLOCK_NETHER_PORTAL: { - if (!GetWorld()->AreNetherPortalsEnabled()) + if (!GetWorld()->AreNetherPortalsEnabled() || m_PortalCooldownData.second) { return; } + if (m_PortalCooldownData.first != 80) + { + m_PortalCooldownData.first++; + return; + } + m_PortalCooldownData.first = 0; + switch (GetWorld()->GetDimension()) { - case dimNether: MoveToWorld(GetWorld()->GetLinkedOverworldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName())); break; + case dimNether: + { + m_PortalCooldownData.second = true; // Stop portals from working on respawn + + if (IsPlayer()) + { + ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimOverworld); + } + MoveToWorld(GetWorld()->GetLinkedOverworldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false); + + return; + } case dimOverworld: { + m_PortalCooldownData.second = true; // Stop portals from working on respawn + if (IsPlayer()) { ((cPlayer *)this)->AwardAchievement(achEnterPortal); + ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimNether); } - MoveToWorld(GetWorld()->GetNetherWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetNetherWorldName(), dimNether, GetWorld()->GetName())); + MoveToWorld(GetWorld()->GetNetherWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetNetherWorldName(), dimNether, GetWorld()->GetName()), false); - cChunkStay * Stay = new cPortalChunkLoader(this, Vector3i(X, Y, Z)); + cChunkStay * Stay = new cPortalChunkLoader(this, *cRoot::Get()->GetWorld(GetWorld()->GetNetherWorldName()), Vector3i(X, Y, Z)); int MinChunkX, MaxChunkX; int MinChunkZ, MaxChunkZ; cChunkDef::BlockToChunk(X - 128, Z - 128, MinChunkX, MinChunkZ); cChunkDef::BlockToChunk(X + 128, Z + 128, MaxChunkX, MaxChunkZ); - for (int OtherMinChunkX = MinChunkX; OtherMinChunkX <= MaxChunkX; ++OtherMinChunkX) + for (int ChunkX = MinChunkX; ChunkX <= MaxChunkX; ++ChunkX) { - for (int OtherMinChunkZ = MinChunkZ; OtherMinChunkZ <= MaxChunkZ; ++OtherMinChunkZ) + for (int ChunkZ = MinChunkZ; ChunkZ <= MaxChunkZ; ++ChunkZ) { - Stay->Add(OtherMinChunkX, OtherMinChunkZ); + LOG("Queue %i %i", ChunkX, ChunkZ); + Stay->Add(ChunkX, ChunkZ); } } Stay->Enable(*GetWorld()->GetChunkMap()); - break; + return; } default: break; } - break; + return; } case E_BLOCK_END_PORTAL: { - if (!GetWorld()->AreEndPortalsEnabled()) + if (!GetWorld()->AreEndPortalsEnabled() || m_PortalCooldownData.second) + { + return; + } + + if (m_PortalCooldownData.first != 80) { + m_PortalCooldownData.first++; return; } + m_PortalCooldownData.first = 0; switch (GetWorld()->GetDimension()) { case dimEnd: { - MoveToWorld(GetWorld()->GetLinkedOverworldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName())); + m_PortalCooldownData.second = true; // Stop portals from working on respawn if (IsPlayer()) { cPlayer * Player = (cPlayer *)this; Player->TeleportToCoords(Player->GetLastBedPos().x, Player->GetLastBedPos().y, Player->GetLastBedPos().z); + Player->GetClientHandle()->SendRespawn(dimOverworld); } - break; + MoveToWorld(GetWorld()->GetLinkedOverworldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false); + + return; } case dimOverworld: { + m_PortalCooldownData.second = true; // Stop portals from working on respawn + if (IsPlayer()) { ((cPlayer *)this)->AwardAchievement(achEnterTheEnd); + ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimEnd); } - MoveToWorld(GetWorld()->GetEndWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetEndWorldName(), dimEnd, GetWorld()->GetName())); - break; + MoveToWorld(GetWorld()->GetEndWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetEndWorldName(), dimEnd, GetWorld()->GetName()), false); + + return; } default: break; } + return; } default: break; } } + + // Allow portals to work again + m_PortalCooldownData.second = false; + m_PortalCooldownData.first = 0; } -void cEntity::CreateExitPortal(int a_BlockX, int a_BlockY, int a_BlockZ) +void cEntity::CreateExitPortal(int a_BlockX, int a_BlockY, int a_BlockZ, double a_EntityWidth, double a_EntityHeight, cWorld & a_World, int a_UniqueIDToTeleport) { cBlockArea Area; - Area.Read(GetWorld(), a_BlockX - 128, a_BlockX + 128, 0, 128, a_BlockZ - 128, a_BlockZ + 128); + Area.Read(&a_World, a_BlockX - 128, a_BlockX + 128, 0, 128, a_BlockZ - 128, a_BlockZ + 128); for (int x = a_BlockX - 128; x <= a_BlockX + 128; ++x) for (int y = 0; y <= 128; ++y) for (int z = a_BlockZ - 128; z <= a_BlockZ + 128; ++z) { if ( (Area.GetBlockType(x, y, z) == E_BLOCK_NETHER_PORTAL) && ( - (Area.GetBlockType(x, (int)floor(y + GetHeight()), z) == E_BLOCK_NETHER_PORTAL) || - (Area.GetBlockType(x, (int)floor(y - GetHeight()), z) == E_BLOCK_NETHER_PORTAL) + (Area.GetBlockType(x, (int)floor(y + a_EntityHeight), z) == E_BLOCK_NETHER_PORTAL) || + (Area.GetBlockType(x, (int)floor(y - a_EntityHeight), z) == E_BLOCK_NETHER_PORTAL) ) ) { - TeleportToCoords(x, y, z); + class cTeleportEntityToPortalCallback : public cEntityCallback + { + public: + cTeleportEntityToPortalCallback(int a_X, int a_Y, int a_Z) : + m_X(a_X), + m_Y(a_Y), + m_Z(a_Z) + {} + + virtual bool Item(cEntity * a_Entity) override + { + a_Entity->TeleportToCoords(m_X, m_Y, m_Z); + return true; + } + + private: + int m_X, m_Y, m_Z; + }; + + cTeleportEntityToPortalCallback TETPC(x, y, z); + a_World.DoWithEntityByID(a_UniqueIDToTeleport, TETPC); return; } } - int MinX = std::max(a_BlockX - (int)ceil(GetWidth()), a_BlockX - 2), MaxX = std::max(a_BlockX + (int)ceil(GetWidth()), a_BlockX + 1); - int MinY = std::max(a_BlockY - (int)ceil(GetHeight()), a_BlockY - 2), MaxY = std::max(a_BlockY + (int)ceil(GetHeight()), a_BlockY + 1); + int MinX = std::max(a_BlockX - (int)ceil(a_EntityWidth), a_BlockX - 2), MaxX = std::max(a_BlockX + (int)ceil(a_EntityWidth), a_BlockX + 1); + int MinY = std::max(a_BlockY - (int)ceil(a_EntityHeight), a_BlockY - 2), MaxY = std::max(a_BlockY + (int)ceil(a_EntityHeight), a_BlockY + 1); for (int y = MinY; y < MaxY + 1; y += MaxY - MinY) for (int x = MinX; x < MaxX + 1; ++x) { @@ -1187,15 +1250,17 @@ void cEntity::CreateExitPortal(int a_BlockX, int a_BlockY, int a_BlockZ) Area.SetBlockType(x, y, a_BlockZ, E_BLOCK_OBSIDIAN); } - Area.Write(GetWorld(), MinX, MinY, a_BlockZ); + Area.Write(&a_World, MinX, MinY, a_BlockZ); } -bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World) +bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ShouldSendRespawn) { + UNUSED(a_ShouldSendRespawn); + cWorld * World; if (a_World == NULL) { @@ -1213,6 +1278,7 @@ bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World) if (GetWorld() == World) { + // Don't move to same world return false; } @@ -1220,8 +1286,7 @@ bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World) GetWorld()->RemoveEntity(this); GetWorld()->BroadcastDestroyEntity(*this); - // Add to all the necessary parts of the new world - SetWorld(World); + // Queue add to new world World->AddEntity(this); return true; diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 934e0302b..4d922aa11 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -338,7 +338,7 @@ public: virtual void OnFinishedBurning(void); /** Creates exit portal at given coordinates */ - void CreateExitPortal(int a_BlockX, int a_BlockY, int a_BlockZ); + static void CreateExitPortal(int a_BlockX, int a_BlockY, int a_BlockZ, double a_EntityWidth, double a_EntityHeight, cWorld & a_World, int a_UniqueIDToTeleport); // tolua_begin @@ -374,7 +374,7 @@ public: virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ); /** Moves entity to specified world */ - virtual bool MoveToWorld(const AString & a_WorldName, cWorld * a_World = NULL); + virtual bool MoveToWorld(const AString & a_WorldName, cWorld * a_World = NULL, bool a_ShouldSendRespawn = true); // tolua_end @@ -510,6 +510,12 @@ protected: /** Air level of a mobile */ int m_AirLevel; int m_AirTickTimer; + + /** Portal delay timer and cooldown boolean + First value is to delay sending the repsawn packet (which triggers the Entering the {Dimension} screen). + Second value is to prevent a teleportation loop by ensuring we do not reenter a portal that we came out of. + */ + std::pair m_PortalCooldownData; private: /** Measured in degrees, [-180, +180) */ diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 4d6688694..a346e68cf 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -948,7 +948,7 @@ void cPlayer::Respawn(void) m_LifetimeTotalXp = 0; // ToDo: send score to client? How? - m_ClientHandle->SendRespawn(*GetWorld()); + m_ClientHandle->SendRespawn(GetWorld()->GetDimension()); // Extinguish the fire: StopBurning(); @@ -1570,7 +1570,7 @@ void cPlayer::TossItems(const cItems & a_Items) -bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World) +bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ShouldSendRespawn) { cWorld * World; if (a_World == NULL) @@ -1589,31 +1589,22 @@ bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World) if (GetWorld() == World) { + // Don't move to same world return false; } // Send the respawn packet: - if (m_ClientHandle != NULL) + if (a_ShouldSendRespawn && (m_ClientHandle != NULL)) { - m_ClientHandle->SendRespawn(*World); + m_ClientHandle->SendRespawn(World->GetDimension()); } - // Remove all links to the old world + // Remove player from old world m_World->RemovePlayer(this); - // If the dimension is different, we can send the respawn packet - // http://wiki.vg/Protocol#0x09 says "don't send if dimension is the same" as of 2013_07_02 - // Queue adding player to the new world, including all the necessary adjustments to the object World->AddPlayer(this); - if (GetWorld()->GetDimension() != World->GetDimension()) - { - GetClientHandle()->SendPlayerMoveLook(); - GetClientHandle()->SendHealth(); - GetClientHandle()->SendWholeInventory(*GetWindow()); - } - return true; } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 99a0e601c..8f319f1ae 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -323,14 +323,14 @@ public: virtual void Killed(cEntity * a_Victim) override; - void Respawn(void); // tolua_export + void Respawn(void); // tolua_export - void SetVisible( bool a_bVisible ); // tolua_export - bool IsVisible(void) const { return m_bVisible; } // tolua_export + void SetVisible(bool a_bVisible); // tolua_export + bool IsVisible(void) const { return m_bVisible; } // tolua_export /** Moves the player to the specified world. Returns true if successful, false on failure (world not found). */ - virtual bool MoveToWorld(const AString & a_WorldName, cWorld * a_World = NULL) override; // tolua_export + virtual bool MoveToWorld(const AString & a_WorldName, cWorld * a_World = NULL, bool a_ShouldSendRespawn = true) override; // tolua_export /** Saves all player data, such as inventory, to JSON */ bool SaveToDisk(void); @@ -339,7 +339,7 @@ public: Takes a (NULL) cWorld pointer which it will assign a value to based on either the loaded world or default world */ bool LoadFromDisk(cWorld *& a_World); - void LoadPermissionsFromDisk(void); // tolua_export + void LoadPermissionsFromDisk(void); // tolua_export const AString & GetLoadedWorldName() { return m_LoadedWorldName; } diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index c6e569919..5b69d32a0 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -100,7 +100,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) = 0; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) = 0; - virtual void SendRespawn (const cWorld & a_World) = 0; + virtual void SendRespawn (eDimension a_Dimension) = 0; virtual void SendExperience (void) = 0; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) = 0; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 5796ba271..f33965cb9 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -833,23 +833,23 @@ void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect -void cProtocol125::SendRespawn(const cWorld & a_World) +void cProtocol125::SendRespawn(eDimension a_Dimension) { cCSLock Lock(m_CSPacket); - if (m_LastSentDimension == a_World.GetDimension()) + if (m_LastSentDimension == a_Dimension) { // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do return; } cPlayer * Player = m_Client->GetPlayer(); WriteByte (PACKET_RESPAWN); - WriteInt ((int)(a_World.GetDimension())); + WriteInt ((int)(a_Dimension)); WriteByte (2); // TODO: Difficulty; 2 = Normal WriteChar ((char)Player->GetGameMode()); WriteShort (256); // Current world height WriteString("default"); Flush(); - m_LastSentDimension = a_World.GetDimension(); + m_LastSentDimension = a_Dimension; } diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 85418f71f..dbf30a8e6 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -72,7 +72,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (const cWorld & a_World) override; + virtual void SendRespawn (eDimension a_Dimension) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp index 9e0f3f852..cc675c075 100644 --- a/src/Protocol/Protocol16x.cpp +++ b/src/Protocol/Protocol16x.cpp @@ -158,10 +158,10 @@ void cProtocol161::SendPlayerMaxSpeed(void) -void cProtocol161::SendRespawn(const cWorld & a_World) +void cProtocol161::SendRespawn(eDimension a_Dimension) { // Besides sending the respawn, we need to also send the player max speed, otherwise the client reverts to super-fast - super::SendRespawn(a_World); + super::SendRespawn(a_Dimension); SendPlayerMaxSpeed(); } diff --git a/src/Protocol/Protocol16x.h b/src/Protocol/Protocol16x.h index e91dc8a1c..2d50749ec 100644 --- a/src/Protocol/Protocol16x.h +++ b/src/Protocol/Protocol16x.h @@ -42,7 +42,7 @@ protected: virtual void SendGameMode (eGameMode a_GameMode) override; virtual void SendHealth (void) override; virtual void SendPlayerMaxSpeed(void) override; - virtual void SendRespawn (const cWorld & a_World) override; + virtual void SendRespawn (eDimension a_Dimension) override; virtual void SendWindowOpen (const cWindow & a_Window) override; virtual int ParseEntityAction (void) override; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index f5b176e54..2460a4914 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -986,9 +986,9 @@ void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect -void cProtocol172::SendRespawn(const cWorld & a_World) +void cProtocol172::SendRespawn(eDimension a_Dimension) { - if (m_LastSentDimension == a_World.GetDimension()) + if (m_LastSentDimension == a_Dimension) { // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do return; @@ -996,11 +996,11 @@ void cProtocol172::SendRespawn(const cWorld & a_World) cPacketizer Pkt(*this, 0x07); // Respawn packet cPlayer * Player = m_Client->GetPlayer(); - Pkt.WriteInt((int)a_World.GetDimension()); + Pkt.WriteInt((int)a_Dimension); Pkt.WriteByte(2); // TODO: Difficulty (set to Normal) Pkt.WriteByte((Byte)Player->GetEffectiveGameMode()); Pkt.WriteString("default"); - m_LastSentDimension = a_World.GetDimension(); + m_LastSentDimension = a_Dimension; } diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 8be1d9211..5e3bf0e2a 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -104,7 +104,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (const cWorld & a_World) override; + virtual void SendRespawn (eDimension a_Dimension) override; virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8 virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 35a331f43..4b9d2e97a 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -555,10 +555,10 @@ void cProtocolRecognizer::SendRemoveEntityEffect(const cEntity & a_Entity, int a -void cProtocolRecognizer::SendRespawn(const cWorld & a_World) +void cProtocolRecognizer::SendRespawn(eDimension a_Dimension) { ASSERT(m_Protocol != NULL); - m_Protocol->SendRespawn(a_World); + m_Protocol->SendRespawn(a_Dimension); } diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 5e178447c..eb83fb0c0 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -107,7 +107,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (const cWorld & a_World) override; + virtual void SendRespawn (eDimension a_Dimension) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; diff --git a/src/World.cpp b/src/World.cpp index 6904000ea..c86827080 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2416,7 +2416,6 @@ void cWorld::AddPlayer(cPlayer * a_Player) void cWorld::RemovePlayer(cPlayer * a_Player) { - m_ChunkMap->RemoveEntity(a_Player); { cCSLock Lock(m_CSPlayersToAdd); @@ -2424,7 +2423,7 @@ void cWorld::RemovePlayer(cPlayer * a_Player) } { cCSLock Lock(m_CSPlayers); - LOGD("Removing player \"%s\" from world \"%s\".", a_Player->GetName().c_str(), m_WorldName.c_str()); + LOGD("Removing player %s from world \"%s\".", a_Player->GetName().c_str(), m_WorldName.c_str()); m_Players.remove(a_Player); } @@ -3213,7 +3212,8 @@ void cWorld::AddQueuedPlayers(void) for (cPlayerList::iterator itr = PlayersToAdd.begin(), end = PlayersToAdd.end(); itr != end; ++itr) { ASSERT(std::find(m_Players.begin(), m_Players.end(), *itr) == m_Players.end()); // Is it already in the list? HOW? - + + LOGD("Adding player %s to world \"%s\".", (*itr)->GetName().c_str(), m_WorldName.c_str()); m_Players.push_back(*itr); (*itr)->SetWorld(this); @@ -3242,6 +3242,9 @@ void cWorld::AddQueuedPlayers(void) if (Client != NULL) { Client->StreamChunks(); + Client->SendPlayerMoveLook(); + Client->SendHealth(); + Client->SendWholeInventory(*(*itr)->GetWindow()); } } // for itr - PlayersToAdd[] } -- cgit v1.2.3 From 1bce1ac4327965453d7709503c5f0b4d8b3edea6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 12 Jun 2014 17:13:39 +0100 Subject: Fixed two redstone bugs * Fixed chunk border powering * Fixed quick place-replace powering --- src/Simulator/IncrementalRedstoneSimulator.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index b32a57165..eff11bd01 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -65,6 +65,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width; RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width; a_OtherChunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta); + a_OtherChunk->SetIsRedstoneDirty(true); } else { @@ -199,6 +200,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, } else { + itr->DataTwo = false; itr->Data = Block; // Update block information } return; @@ -802,11 +804,15 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int { if (a_Itr->a_RelBlockPos == Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) { + // Leave a_Itr at where we found the entry break; } } } + // a_Itr may be passed with m_RepeatersDelayList::end, however, we can guarantee this iterator is always valid because... + // ...QueueRepeaterPowerChange is called to add an entry (and the above code updates iterator). However, if the repeater was locked or something similar... + // ...we will never get here because of the returns. if (a_Itr->a_ElapsedTicks >= a_Itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks? { if (a_Itr->ShouldPowerOn) -- cgit v1.2.3 From e10940d57cf8500eb306e986d7cc2d79bca00467 Mon Sep 17 00:00:00 2001 From: worktycho Date: Thu, 12 Jun 2014 17:24:14 +0100 Subject: Fixed compile --- src/Entities/Entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index a7b6cca27..1c8818fe5 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1051,7 +1051,7 @@ void cEntity::DetectPortal() class cPortalChunkLoader : public cChunkStay { public: - cPortalChunkLoader(cEntity * a_Entity, cWorld & a_World, Vector3i & a_PortalPos) : + cPortalChunkLoader(cEntity * a_Entity, cWorld & a_World, const Vector3i & a_PortalPos) : m_Entity(a_Entity), m_PortalPos(a_PortalPos), m_World(a_World) -- cgit v1.2.3 From 9254666a85f9e4562081bea336c8be0e612fa44d Mon Sep 17 00:00:00 2001 From: tycho Date: Thu, 12 Jun 2014 18:00:53 +0100 Subject: automaticlly build tolua and generate bindings as part of build. --- src/Bindings/tolua++.exe | Bin 200704 -> 0 bytes src/CMakeLists.txt | 169 ++++++++++++++++++++++++----------------------- 2 files changed, 85 insertions(+), 84 deletions(-) delete mode 100644 src/Bindings/tolua++.exe (limited to 'src') diff --git a/src/Bindings/tolua++.exe b/src/Bindings/tolua++.exe deleted file mode 100644 index ba3a6b0c7..000000000 Binary files a/src/Bindings/tolua++.exe and /dev/null differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 900577526..c5156e50c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,6 +8,91 @@ include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/polarssl/include") set(FOLDERS OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++) set(FOLDERS ${FOLDERS} WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs) +set(BINDING_DEPENDECIES + tolua + ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/virtual_method_hooks.lua + ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/AllToLua.pkg + Bindings/LuaFunctions.h + Bindings/LuaWindow.h + Bindings/Plugin.h + Bindings/PluginLua.h + Bindings/PluginManager.h + Bindings/WebPlugin.h + BiomeDef.h + BlockArea.h + BlockEntities/BlockEntity.h + BlockEntities/BlockEntityWithItems.h + BlockEntities/ChestEntity.h + BlockEntities/DispenserEntity.h + BlockEntities/DropSpenserEntity.h + BlockEntities/DropperEntity.h + BlockEntities/FurnaceEntity.h + BlockEntities/HopperEntity.h + BlockEntities/JukeboxEntity.h + BlockEntities/NoteEntity.h + BlockEntities/SignEntity.h + BlockEntities/MobHeadEntity.h + BlockEntities/FlowerPotEntity.h + BlockID.h + BoundingBox.h + ChatColor.h + ChunkDef.h + ClientHandle.h + CraftingRecipes.h + Cuboid.h + Defines.h + Enchantments.h + Entities/Effects.h + Entities/Entity.h + Entities/Floater.h + Entities/Pawn.h + Entities/Painting.h + Entities/Pickup.h + Entities/Player.h + Entities/ProjectileEntity.h + Entities/ArrowEntity.h + Entities/ThrownEggEntity.h + Entities/ThrownEnderPearlEntity.h + Entities/ExpBottleEntity.h + Entities/ThrownSnowballEntity.h + Entities/FireChargeEntity.h + Entities/FireworkEntity.h + Entities/GhastFireballEntity.h + Entities/TNTEntity.h + Entities/ExpOrb.h + Entities/HangingEntity.h + Entities/ItemFrame.h + Generating/ChunkDesc.h + Group.h + Inventory.h + Item.h + ItemGrid.h + Mobs/Monster.h + OSSupport/File.h + Root.h + Server.h + StringUtils.h + Tracer.h + UI/Window.h + Vector3.h + WebAdmin.h + World.h +) + +include_directories(Bindings) +include_directories(.) + +ADD_CUSTOM_COMMAND( + # add any new generated bindings here + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h + + # command execuded to regerate bindings + COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/ + + # add any new generation dependencies here + DEPENDS ${BINDING_DEPENDECIES} +) if (NOT MSVC) @@ -15,91 +100,7 @@ if (NOT MSVC) # lib dependencies are not included - set(BINDING_DEPENDECIES - tolua - ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/virtual_method_hooks.lua - ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/AllToLua.pkg - Bindings/LuaFunctions.h - Bindings/LuaWindow.h - Bindings/Plugin.h - Bindings/PluginLua.h - Bindings/PluginManager.h - Bindings/WebPlugin.h - BiomeDef.h - BlockArea.h - BlockEntities/BlockEntity.h - BlockEntities/BlockEntityWithItems.h - BlockEntities/ChestEntity.h - BlockEntities/DispenserEntity.h - BlockEntities/DropSpenserEntity.h - BlockEntities/DropperEntity.h - BlockEntities/FurnaceEntity.h - BlockEntities/HopperEntity.h - BlockEntities/JukeboxEntity.h - BlockEntities/NoteEntity.h - BlockEntities/SignEntity.h - BlockEntities/MobHeadEntity.h - BlockEntities/FlowerPotEntity.h - BlockID.h - BoundingBox.h - ChatColor.h - ChunkDef.h - ClientHandle.h - CraftingRecipes.h - Cuboid.h - Defines.h - Enchantments.h - Entities/Effects.h - Entities/Entity.h - Entities/Floater.h - Entities/Pawn.h - Entities/Painting.h - Entities/Pickup.h - Entities/Player.h - Entities/ProjectileEntity.h - Entities/ArrowEntity.h - Entities/ThrownEggEntity.h - Entities/ThrownEnderPearlEntity.h - Entities/ExpBottleEntity.h - Entities/ThrownSnowballEntity.h - Entities/FireChargeEntity.h - Entities/FireworkEntity.h - Entities/GhastFireballEntity.h - Entities/TNTEntity.h - Entities/ExpOrb.h - Entities/HangingEntity.h - Entities/ItemFrame.h - Generating/ChunkDesc.h - Group.h - Inventory.h - Item.h - ItemGrid.h - Mobs/Monster.h - OSSupport/File.h - Root.h - Server.h - StringUtils.h - Tracer.h - UI/Window.h - Vector3.h - WebAdmin.h - World.h - ) - - include_directories(Bindings) - include_directories(.) - - ADD_CUSTOM_COMMAND( - # add any new generated bindings here - OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h - # command execuded to regerate bindings - COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/ - - # add any new generation dependencies here - DEPENDS ${BINDING_DEPENDECIES} - ) #add cpp files here add_library(Bindings Bindings/Bindings -- cgit v1.2.3 From 93d4a8aa92af58bb073f18c87167358d18632899 Mon Sep 17 00:00:00 2001 From: Tycho Date: Thu, 12 Jun 2014 18:51:33 +0100 Subject: Removed unnessicary indirection from Entity iterator list --- src/Chunk.cpp | 10 +++++----- src/Chunk.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index c9e4f5411..7ca0a4afd 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -86,7 +86,7 @@ cChunk::cChunk( m_NeighborZP(a_NeighborZP), m_WaterSimulatorData(a_World->GetWaterSimulator()->CreateChunkData()), m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData()), - m_EntityTickIteratorData(std::make_pair(false, &m_Entities.end())) + m_EntityTickIteratorData(std::make_pair(false, m_Entities.end())) { if (a_NeighborXM != NULL) { @@ -584,12 +584,12 @@ void cChunk::Tick(float a_Dt) // Don't tick things queued to be removed if (!((*itr)->IsMob())) { - m_EntityTickIteratorData.second = &itr; + m_EntityTickIteratorData.second = itr; (*itr)->Tick(a_Dt, *this); - if (itr != *m_EntityTickIteratorData.second) + if (itr != m_EntityTickIteratorData.second) { - itr = *m_EntityTickIteratorData.second; + itr = m_EntityTickIteratorData.second; } else { @@ -1876,7 +1876,7 @@ void cChunk::RemoveEntity(cEntity * a_Entity) { if (m_EntityTickIteratorData.first) { - *m_EntityTickIteratorData.second = m_Entities.erase(*m_EntityTickIteratorData.second); + m_EntityTickIteratorData.second = m_Entities.erase(m_EntityTickIteratorData.second); } else { diff --git a/src/Chunk.h b/src/Chunk.h index 3046b2efe..1619df333 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -425,7 +425,7 @@ private: // A critical section is not needed, because all chunk access is protected by its parent ChunkMap's csLayers cClientHandleList m_LoadedByClient; cEntityList m_Entities; - std::pair m_EntityTickIteratorData; + std::pair m_EntityTickIteratorData; cBlockEntityList m_BlockEntities; /** Number of times the chunk has been requested to stay (by various cChunkStay objects); if zero, the chunk can be unloaded */ -- cgit v1.2.3 From c82f4f6309f760186c43b4f32596c3e78a5725b7 Mon Sep 17 00:00:00 2001 From: Tycho Date: Thu, 12 Jun 2014 18:56:48 +0100 Subject: Fixed order of initalisation --- src/Chunk.cpp | 4 ++-- src/World.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 7ca0a4afd..8255fdcaf 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -71,6 +71,7 @@ cChunk::cChunk( m_IsDirty(false), m_IsSaving(false), m_HasLoadFailed(false), + m_EntityTickIteratorData(std::make_pair(false, m_Entities.end())), m_StayCount(0), m_PosX(a_ChunkX), m_PosY(a_ChunkY), @@ -85,8 +86,7 @@ cChunk::cChunk( m_NeighborZM(a_NeighborZM), m_NeighborZP(a_NeighborZP), m_WaterSimulatorData(a_World->GetWaterSimulator()->CreateChunkData()), - m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData()), - m_EntityTickIteratorData(std::make_pair(false, m_Entities.end())) + m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData()) { if (a_NeighborXM != NULL) { diff --git a/src/World.cpp b/src/World.cpp index c86827080..3ed2f5f13 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -234,6 +234,7 @@ void cWorld::cTickThread::Execute(void) cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AString & a_OverworldName) : m_WorldName(a_WorldName), + m_OverworldName(a_OverworldName), m_IniFileName(m_WorldName + "/world.ini"), m_StorageSchema("Default"), #ifdef __arm__ @@ -241,6 +242,7 @@ cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AStrin #else m_StorageCompressionFactor(6), #endif + m_Dimension(a_Dimension), m_IsSpawnExplicitlySet(false), m_WorldAgeSecs(0), m_TimeOfDaySecs(0), @@ -253,9 +255,8 @@ cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AStrin m_Scoreboard(this), m_MapManager(this), m_GeneratorCallbacks(*this), - m_TickThread(*this), - m_Dimension(a_Dimension), - m_OverworldName(a_OverworldName) + m_TickThread(*this) + { LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str()); -- cgit v1.2.3 From f76420ac55edd82e06042a93927e275e5799d59f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Jun 2014 09:38:25 +0200 Subject: Removed an unused fwd declaration. --- src/World.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/World.h b/src/World.h index 0a8dcffc4..3e63e2b8c 100644 --- a/src/World.h +++ b/src/World.h @@ -47,7 +47,6 @@ class cFlowerPotEntity; class cFurnaceEntity; class cNoteEntity; class cMobHeadEntity; -class cMobCensus; class cCompositeChat; class cCuboid; -- cgit v1.2.3 From 4b28a24514316f04d596e248a75b382701a01217 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 14 Jun 2014 09:51:42 +0100 Subject: Reduced cPluginManager code duplication --- src/Bindings/PluginManager.cpp | 464 ++++++++++++++++------------------------- 1 file changed, 178 insertions(+), 286 deletions(-) (limited to 'src') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index acfc91bf8..9bcd8e3b7 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -14,6 +14,13 @@ #include "inifile/iniFile.h" #include "../Entities/Player.h" +#define FIND_HOOK(a_HookName) HookMap::iterator Plugins = m_Hooks.find(a_HookName); +#define VERIFY_HOOK \ + if (Plugins == m_Hooks.end()) \ + { \ + return false; \ + } + @@ -192,7 +199,7 @@ void cPluginManager::Tick(float a_Dt) ReloadPluginsNow(); } - HookMap::iterator Plugins = m_Hooks.find(HOOK_TICK); + FIND_HOOK(HOOK_TICK); if (Plugins != m_Hooks.end()) { for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) @@ -208,11 +215,9 @@ void cPluginManager::Tick(float a_Dt) bool cPluginManager::CallHookBlockSpread(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_BLOCK_SPREAD); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_BLOCK_SPREAD); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnBlockSpread(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Source)) @@ -233,11 +238,9 @@ bool cPluginManager::CallHookBlockToPickups( cItems & a_Pickups ) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_BLOCK_TO_PICKUPS); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_BLOCK_TO_PICKUPS); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_Pickups)) @@ -275,11 +278,8 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message) return true; // Cancel sending } - HookMap::iterator Plugins = m_Hooks.find(HOOK_CHAT); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_CHAT); + VERIFY_HOOK; for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { @@ -298,11 +298,9 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message) bool cPluginManager::CallHookChunkAvailable(cWorld * a_World, int a_ChunkX, int a_ChunkZ) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_AVAILABLE); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_CHUNK_AVAILABLE); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnChunkAvailable(a_World, a_ChunkX, a_ChunkZ)) @@ -319,11 +317,9 @@ bool cPluginManager::CallHookChunkAvailable(cWorld * a_World, int a_ChunkX, int bool cPluginManager::CallHookChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_GENERATED); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_CHUNK_GENERATED); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)) @@ -340,11 +336,9 @@ bool cPluginManager::CallHookChunkGenerated(cWorld * a_World, int a_ChunkX, int bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_GENERATING); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_CHUNK_GENERATING); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnChunkGenerating(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)) @@ -361,11 +355,9 @@ bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int bool cPluginManager::CallHookChunkUnloaded(cWorld * a_World, int a_ChunkX, int a_ChunkZ) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_UNLOADED); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_CHUNK_UNLOADED); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnChunkUnloaded(a_World, a_ChunkX, a_ChunkZ)) @@ -382,11 +374,9 @@ bool cPluginManager::CallHookChunkUnloaded(cWorld * a_World, int a_ChunkX, int a bool cPluginManager::CallHookChunkUnloading(cWorld * a_World, int a_ChunkX, int a_ChunkZ) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_UNLOADING); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_CHUNK_UNLOADING); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnChunkUnloading(a_World, a_ChunkX, a_ChunkZ)) @@ -403,11 +393,9 @@ bool cPluginManager::CallHookChunkUnloading(cWorld * a_World, int a_ChunkX, int bool cPluginManager::CallHookCollectingPickup(cPlayer * a_Player, cPickup & a_Pickup) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_COLLECTING_PICKUP); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_COLLECTING_PICKUP); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnCollectingPickup(a_Player, &a_Pickup)) @@ -424,11 +412,9 @@ bool cPluginManager::CallHookCollectingPickup(cPlayer * a_Player, cPickup & a_Pi bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_CRAFTING_NO_RECIPE); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_CRAFTING_NO_RECIPE); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnCraftingNoRecipe(a_Player, a_Grid, a_Recipe)) @@ -445,11 +431,9 @@ bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cC bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString & a_Reason) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_DISCONNECT); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_DISCONNECT); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnDisconnect(a_Client, a_Reason)) @@ -466,11 +450,9 @@ bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_EXECUTE_COMMAND); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_EXECUTE_COMMAND); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnExecuteCommand(a_Player, a_Split)) @@ -487,11 +469,9 @@ bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVec bool cPluginManager::CallHookExploded(cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_EXPLODED); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_EXPLODED); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnExploded(a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData)) @@ -508,11 +488,9 @@ bool cPluginManager::CallHookExploded(cWorld & a_World, double a_ExplosionSize, bool cPluginManager::CallHookExploding(cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_EXPLODING); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_EXPLODING); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnExploding(a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData)) @@ -529,11 +507,9 @@ bool cPluginManager::CallHookExploding(cWorld & a_World, double & a_ExplosionSiz bool cPluginManager::CallHookHandshake(cClientHandle * a_ClientHandle, const AString & a_Username) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_HANDSHAKE); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_HANDSHAKE); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnHandshake(a_ClientHandle, a_Username)) @@ -550,11 +526,9 @@ bool cPluginManager::CallHookHandshake(cClientHandle * a_ClientHandle, const ASt bool cPluginManager::CallHookHopperPullingItem(cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_HOPPER_PULLING_ITEM); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_HOPPER_PULLING_ITEM); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnHopperPullingItem(a_World, a_Hopper, a_DstSlotNum, a_SrcEntity, a_SrcSlotNum)) @@ -571,11 +545,9 @@ bool cPluginManager::CallHookHopperPullingItem(cWorld & a_World, cHopperEntity & bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_HOPPER_PUSHING_ITEM); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_HOPPER_PUSHING_ITEM); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnHopperPushingItem(a_World, a_Hopper, a_SrcSlotNum, a_DstEntity, a_DstSlotNum)) @@ -592,11 +564,9 @@ bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity & bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_KILLING); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_KILLING); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnKilling(a_Victim, a_Killer)) @@ -613,11 +583,9 @@ bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer) bool cPluginManager::CallHookLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_LOGIN); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_LOGIN); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnLogin(a_Client, a_ProtocolVersion, a_Username)) @@ -634,11 +602,9 @@ bool cPluginManager::CallHookLogin(cClientHandle * a_Client, int a_ProtocolVersi bool cPluginManager::CallHookPlayerAnimation(cPlayer & a_Player, int a_Animation) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_ANIMATION); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_ANIMATION); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerAnimation(a_Player, a_Animation)) @@ -655,11 +621,9 @@ bool cPluginManager::CallHookPlayerAnimation(cPlayer & a_Player, int a_Animation bool cPluginManager::CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_BREAKING_BLOCK); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_BREAKING_BLOCK); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerBreakingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta)) @@ -676,11 +640,9 @@ bool cPluginManager::CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_Block bool cPluginManager::CallHookPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_BROKEN_BLOCK); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_BROKEN_BLOCK); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerBrokenBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta)) @@ -697,11 +659,9 @@ bool cPluginManager::CallHookPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX, bool cPluginManager::CallHookPlayerDestroyed(cPlayer & a_Player) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_DESTROYED); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_DESTROYED); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerDestroyed(a_Player)) @@ -718,11 +678,9 @@ bool cPluginManager::CallHookPlayerDestroyed(cPlayer & a_Player) bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_EATING); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_EATING); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerEating(a_Player)) @@ -739,11 +697,9 @@ bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player) bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Reward) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_FISHED); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_FISHED); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerFished(a_Player, a_Reward)) @@ -760,11 +716,9 @@ bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Rew bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems a_Reward) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_FISHING); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_FISHING); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerFishing(a_Player, a_Reward)) @@ -781,11 +735,9 @@ bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems a_Reward) bool cPluginManager::CallHookPlayerJoined(cPlayer & a_Player) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_JOINED); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_JOINED); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerJoined(a_Player)) @@ -802,11 +754,9 @@ bool cPluginManager::CallHookPlayerJoined(cPlayer & a_Player) bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_LEFT_CLICK); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_LEFT_CLICK); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerLeftClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status)) @@ -823,11 +773,9 @@ bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, int a_BlockX, i bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_MOVING); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_MOVING); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerMoved(a_Player)) @@ -844,11 +792,9 @@ bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player) bool cPluginManager::CallHookPlayerPlacedBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_PLACED_BLOCK); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_PLACED_BLOCK); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerPlacedBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta)) @@ -865,11 +811,9 @@ bool cPluginManager::CallHookPlayerPlacedBlock(cPlayer & a_Player, int a_BlockX, bool cPluginManager::CallHookPlayerPlacingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_PLACING_BLOCK); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_PLACING_BLOCK); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerPlacingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta)) @@ -886,11 +830,9 @@ bool cPluginManager::CallHookPlayerPlacingBlock(cPlayer & a_Player, int a_BlockX bool cPluginManager::CallHookPlayerRightClick(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_RIGHT_CLICK); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_RIGHT_CLICK); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerRightClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) @@ -907,11 +849,9 @@ bool cPluginManager::CallHookPlayerRightClick(cPlayer & a_Player, int a_BlockX, bool cPluginManager::CallHookPlayerRightClickingEntity(cPlayer & a_Player, cEntity & a_Entity) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_RIGHT_CLICKING_ENTITY); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_RIGHT_CLICKING_ENTITY); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerRightClickingEntity(a_Player, a_Entity)) @@ -928,11 +868,9 @@ bool cPluginManager::CallHookPlayerRightClickingEntity(cPlayer & a_Player, cEnti bool cPluginManager::CallHookPlayerShooting(cPlayer & a_Player) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_SHOOTING); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_SHOOTING); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerShooting(a_Player)) @@ -949,11 +887,9 @@ bool cPluginManager::CallHookPlayerShooting(cPlayer & a_Player) bool cPluginManager::CallHookPlayerSpawned(cPlayer & a_Player) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_SPAWNED); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_SPAWNED); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerSpawned(a_Player)) @@ -970,11 +906,9 @@ bool cPluginManager::CallHookPlayerSpawned(cPlayer & a_Player) bool cPluginManager::CallHookPlayerTossingItem(cPlayer & a_Player) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_TOSSING_ITEM); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_TOSSING_ITEM); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerTossingItem(a_Player)) @@ -991,11 +925,9 @@ bool cPluginManager::CallHookPlayerTossingItem(cPlayer & a_Player) bool cPluginManager::CallHookPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USED_BLOCK); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_USED_BLOCK); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerUsedBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta)) @@ -1012,11 +944,9 @@ bool cPluginManager::CallHookPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, i bool cPluginManager::CallHookPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USED_ITEM); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_USED_ITEM); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerUsedItem(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) @@ -1033,11 +963,9 @@ bool cPluginManager::CallHookPlayerUsedItem(cPlayer & a_Player, int a_BlockX, in bool cPluginManager::CallHookPlayerUsingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USING_BLOCK); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_USING_BLOCK); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerUsingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta)) @@ -1054,11 +982,9 @@ bool cPluginManager::CallHookPlayerUsingBlock(cPlayer & a_Player, int a_BlockX, bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USING_ITEM); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLAYER_USING_ITEM); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPlayerUsingItem(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) @@ -1075,11 +1001,9 @@ bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, int a_BlockX, i bool cPluginManager::CallHookPluginMessage(cClientHandle & a_Client, const AString & a_Channel, const AString & a_Message) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLUGIN_MESSAGE); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLUGIN_MESSAGE); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPluginMessage(a_Client, a_Channel, a_Message)) @@ -1096,11 +1020,9 @@ bool cPluginManager::CallHookPluginMessage(cClientHandle & a_Client, const AStri bool cPluginManager::CallHookPluginsLoaded(void) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PLUGINS_LOADED); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PLUGINS_LOADED); + VERIFY_HOOK; + bool res = false; for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { @@ -1115,11 +1037,9 @@ bool cPluginManager::CallHookPluginsLoaded(void) bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_POST_CRAFTING); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_POST_CRAFTING); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPostCrafting(a_Player, a_Grid, a_Recipe)) @@ -1136,11 +1056,9 @@ bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraft bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PRE_CRAFTING); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PRE_CRAFTING); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnPreCrafting(a_Player, a_Grid, a_Recipe)) @@ -1157,11 +1075,9 @@ bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCrafti bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_BLOCK); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PROJECTILE_HIT_BLOCK); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnProjectileHitBlock(a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos)) @@ -1178,11 +1094,9 @@ bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile bool cPluginManager::CallHookProjectileHitEntity(cProjectileEntity & a_Projectile, cEntity & a_HitEntity) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_ENTITY); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_PROJECTILE_HIT_ENTITY); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnProjectileHitEntity(a_Projectile, a_HitEntity)) @@ -1199,11 +1113,9 @@ bool cPluginManager::CallHookProjectileHitEntity(cProjectileEntity & a_Projectil bool cPluginManager::CallHookSpawnedEntity(cWorld & a_World, cEntity & a_Entity) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNED_ENTITY); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_SPAWNED_ENTITY); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnSpawnedEntity(a_World, a_Entity)) @@ -1219,11 +1131,9 @@ bool cPluginManager::CallHookSpawnedEntity(cWorld & a_World, cEntity & a_Entity) bool cPluginManager::CallHookSpawnedMonster(cWorld & a_World, cMonster & a_Monster) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNED_MONSTER); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_SPAWNED_MONSTER); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnSpawnedMonster(a_World, a_Monster)) @@ -1239,11 +1149,9 @@ bool cPluginManager::CallHookSpawnedMonster(cWorld & a_World, cMonster & a_Monst bool cPluginManager::CallHookSpawningEntity(cWorld & a_World, cEntity & a_Entity) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNING_ENTITY); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_SPAWNING_ENTITY); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnSpawningEntity(a_World, a_Entity)) @@ -1260,11 +1168,9 @@ bool cPluginManager::CallHookSpawningEntity(cWorld & a_World, cEntity & a_Entity bool cPluginManager::CallHookSpawningMonster(cWorld & a_World, cMonster & a_Monster) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNING_MONSTER); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_SPAWNING_MONSTER); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnSpawningMonster(a_World, a_Monster)) @@ -1281,11 +1187,9 @@ bool cPluginManager::CallHookSpawningMonster(cWorld & a_World, cMonster & a_Mons bool cPluginManager::CallHookTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a_TDI) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_TAKE_DAMAGE); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_TAKE_DAMAGE); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnTakeDamage(a_Receiver, a_TDI)) @@ -1302,11 +1206,9 @@ bool cPluginManager::CallHookTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a bool cPluginManager::CallHookUpdatingSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_UPDATING_SIGN); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_UPDATING_SIGN); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnUpdatingSign(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player)) @@ -1323,11 +1225,9 @@ bool cPluginManager::CallHookUpdatingSign(cWorld * a_World, int a_BlockX, int a_ bool cPluginManager::CallHookUpdatedSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_UPDATED_SIGN); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_UPDATED_SIGN); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnUpdatedSign(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player)) @@ -1344,11 +1244,9 @@ bool cPluginManager::CallHookUpdatedSign(cWorld * a_World, int a_BlockX, int a_B bool cPluginManager::CallHookWeatherChanged(cWorld & a_World) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_WEATHER_CHANGED); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_WEATHER_CHANGED); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnWeatherChanged(a_World)) @@ -1365,11 +1263,9 @@ bool cPluginManager::CallHookWeatherChanged(cWorld & a_World) bool cPluginManager::CallHookWeatherChanging(cWorld & a_World, eWeather & a_NewWeather) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_WEATHER_CHANGING); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_WEATHER_CHANGING); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnWeatherChanging(a_World, a_NewWeather)) @@ -1386,11 +1282,9 @@ bool cPluginManager::CallHookWeatherChanging(cWorld & a_World, eWeather & a_NewW bool cPluginManager::CallHookWorldStarted(cWorld & a_World) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_WORLD_STARTED); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_WORLD_STARTED); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnWorldStarted(a_World)) @@ -1407,11 +1301,9 @@ bool cPluginManager::CallHookWorldStarted(cWorld & a_World) bool cPluginManager::CallHookWorldTick(cWorld & a_World, float a_Dt, int a_LastTickDurationMSec) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_WORLD_TICK); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_WORLD_TICK); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnWorldTick(a_World, a_Dt, a_LastTickDurationMSec)) -- cgit v1.2.3 From a70b8298b6ada8abead9ef2b292531407225c2d1 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 14 Jun 2014 10:14:04 +0100 Subject: Cauldrons check the heightmap --- src/Blocks/BlockCauldron.h | 6 +++++- src/Blocks/WorldInterface.h | 8 ++++---- src/World.h | 6 +++--- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h index 5ec776df6..e0f86f4cb 100644 --- a/src/Blocks/BlockCauldron.h +++ b/src/Blocks/BlockCauldron.h @@ -61,8 +61,12 @@ public: virtual void OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override { - if (IsBiomeNoDownfall(a_Chunk.GetBiomeAt(a_RelX, a_RelZ)) || !a_WorldInterface.IsWeatherWet()) + int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width; + int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width; + if (!a_WorldInterface.IsWeatherWetAt(BlockX, BlockZ) || (a_RelY != a_WorldInterface.GetHeight(BlockX, BlockZ))) { + // It's not raining at our current location or we do not have a direct view of the sky + // We cannot eat the rain :( return; } diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h index 7df82197e..e5638c16e 100644 --- a/src/Blocks/WorldInterface.h +++ b/src/Blocks/WorldInterface.h @@ -37,9 +37,9 @@ public: virtual void SetTimeOfDay(Int64 a_TimeOfDay) = 0; - /** Returns true if the current weather has any precipitation - rain or storm - Does not check if biome has no downfall, use cChunk::GetBiomeAt(RelX, RelZ) for that - */ - virtual bool IsWeatherWet(void) const = 0; + /** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */ + virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) = 0; + /** Returns the world height at the specified coords; waits for the chunk to get loaded / generated */ + virtual int GetHeight(int a_BlockX, int a_BlockZ) = 0; }; diff --git a/src/World.h b/src/World.h index ab36e0a9b..0592c78fc 100644 --- a/src/World.h +++ b/src/World.h @@ -180,7 +180,7 @@ public: virtual eDimension GetDimension(void) const { return m_Dimension; } /** Returns the world height at the specified coords; waits for the chunk to get loaded / generated */ - int GetHeight(int a_BlockX, int a_BlockZ); + virtual int GetHeight(int a_BlockX, int a_BlockZ); // tolua_end @@ -749,10 +749,10 @@ public: } /** Returns true if the current weather has any precipitation - rain, storm or snow */ - virtual bool IsWeatherWet(void) const { return !IsWeatherSunny(); } + bool IsWeatherWet(void) const { return !IsWeatherSunny(); } /** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */ - bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) + virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) { return (IsWeatherWet() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } -- cgit v1.2.3 From 8a80843ddf062b4a2df622d661628e4c77b9c399 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 14 Jun 2014 10:18:16 +0100 Subject: Reverted portal creation code It wasn't really working and needs more development --- src/Entities/Entity.cpp | 100 ------------------------------------------------ src/Entities/Entity.h | 3 -- 2 files changed, 103 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 1c8818fe5..d42c49abe 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -12,7 +12,6 @@ #include "../Bindings/PluginManager.h" #include "../Tracer.h" #include "Player.h" -#include "BlockArea.h" @@ -1048,30 +1047,6 @@ void cEntity::DetectPortal() return; } - class cPortalChunkLoader : public cChunkStay - { - public: - cPortalChunkLoader(cEntity * a_Entity, cWorld & a_World, const Vector3i & a_PortalPos) : - m_Entity(a_Entity), - m_PortalPos(a_PortalPos), - m_World(a_World) - {} - - private: - virtual bool OnAllChunksAvailable(void) override - { - cEntity::CreateExitPortal(m_PortalPos.x, m_PortalPos.y, m_PortalPos.z, m_Entity->GetWidth(), m_Entity->GetHeight(), m_World, m_Entity->GetUniqueID()); - return true; - } - - virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override {}; - virtual void OnDisabled(void) override {}; - - cEntity * m_Entity; - Vector3i m_PortalPos; - cWorld & m_World; - }; - int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; if ((Y > 0) && (Y < cChunkDef::Height)) { @@ -1115,24 +1090,7 @@ void cEntity::DetectPortal() ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimNether); } MoveToWorld(GetWorld()->GetNetherWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetNetherWorldName(), dimNether, GetWorld()->GetName()), false); - - cChunkStay * Stay = new cPortalChunkLoader(this, *cRoot::Get()->GetWorld(GetWorld()->GetNetherWorldName()), Vector3i(X, Y, Z)); - - int MinChunkX, MaxChunkX; - int MinChunkZ, MaxChunkZ; - cChunkDef::BlockToChunk(X - 128, Z - 128, MinChunkX, MinChunkZ); - cChunkDef::BlockToChunk(X + 128, Z + 128, MaxChunkX, MaxChunkZ); - for (int ChunkX = MinChunkX; ChunkX <= MaxChunkX; ++ChunkX) - { - for (int ChunkZ = MinChunkZ; ChunkZ <= MaxChunkZ; ++ChunkZ) - { - LOG("Queue %i %i", ChunkX, ChunkZ); - Stay->Add(ChunkX, ChunkZ); - } - } - - Stay->Enable(*GetWorld()->GetChunkMap()); return; } default: break; @@ -1199,64 +1157,6 @@ void cEntity::DetectPortal() -void cEntity::CreateExitPortal(int a_BlockX, int a_BlockY, int a_BlockZ, double a_EntityWidth, double a_EntityHeight, cWorld & a_World, int a_UniqueIDToTeleport) -{ - cBlockArea Area; - Area.Read(&a_World, a_BlockX - 128, a_BlockX + 128, 0, 128, a_BlockZ - 128, a_BlockZ + 128); - for (int x = a_BlockX - 128; x <= a_BlockX + 128; ++x) for (int y = 0; y <= 128; ++y) for (int z = a_BlockZ - 128; z <= a_BlockZ + 128; ++z) - { - if ( - (Area.GetBlockType(x, y, z) == E_BLOCK_NETHER_PORTAL) && - ( - (Area.GetBlockType(x, (int)floor(y + a_EntityHeight), z) == E_BLOCK_NETHER_PORTAL) || - (Area.GetBlockType(x, (int)floor(y - a_EntityHeight), z) == E_BLOCK_NETHER_PORTAL) - ) - ) - { - class cTeleportEntityToPortalCallback : public cEntityCallback - { - public: - cTeleportEntityToPortalCallback(int a_X, int a_Y, int a_Z) : - m_X(a_X), - m_Y(a_Y), - m_Z(a_Z) - {} - - virtual bool Item(cEntity * a_Entity) override - { - a_Entity->TeleportToCoords(m_X, m_Y, m_Z); - return true; - } - - private: - int m_X, m_Y, m_Z; - }; - - cTeleportEntityToPortalCallback TETPC(x, y, z); - a_World.DoWithEntityByID(a_UniqueIDToTeleport, TETPC); - return; - } - } - - int MinX = std::max(a_BlockX - (int)ceil(a_EntityWidth), a_BlockX - 2), MaxX = std::max(a_BlockX + (int)ceil(a_EntityWidth), a_BlockX + 1); - int MinY = std::max(a_BlockY - (int)ceil(a_EntityHeight), a_BlockY - 2), MaxY = std::max(a_BlockY + (int)ceil(a_EntityHeight), a_BlockY + 1); - - for (int y = MinY; y < MaxY + 1; y += MaxY - MinY) for (int x = MinX; x < MaxX + 1; ++x) - { - Area.SetBlockType(x, y, a_BlockZ, E_BLOCK_OBSIDIAN); - } - for (int y = MinY; y < MaxY + 1; ++y) for (int x = MinX; x < MaxX + 1; x += MaxX - MinX) - { - Area.SetBlockType(x, y, a_BlockZ, E_BLOCK_OBSIDIAN); - } - - Area.Write(&a_World, MinX, MinY, a_BlockZ); -} - - - - - bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ShouldSendRespawn) { UNUSED(a_ShouldSendRespawn); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 4d922aa11..9f3b06c29 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -336,9 +336,6 @@ public: /// Called when the entity finishes burning virtual void OnFinishedBurning(void); - - /** Creates exit portal at given coordinates */ - static void CreateExitPortal(int a_BlockX, int a_BlockY, int a_BlockZ, double a_EntityWidth, double a_EntityHeight, cWorld & a_World, int a_UniqueIDToTeleport); // tolua_begin -- cgit v1.2.3 From c1deda5d8f01811efa5094e9375166acb69d50ed Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 14 Jun 2014 10:47:10 +0100 Subject: Fixed a repeater issue * Repeaters now properly continuously update their powering * Minor cosmetic improvements --- src/Simulator/IncrementalRedstoneSimulator.cpp | 31 +++++++++++++------------- src/Simulator/IncrementalRedstoneSimulator.h | 2 +- 2 files changed, 16 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index eff11bd01..f20f396f2 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -788,12 +788,12 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int { WereItrsChanged = QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false); } - else + else if (a_Itr != m_RepeatersDelayList->end()) { return; } } - else + else if (a_Itr != m_RepeatersDelayList->end()) { return; } @@ -1429,8 +1429,7 @@ bool cIncrementalRedstoneSimulator::AreCoordsLinkedPowered(int a_RelBlockX, int -// IsRepeaterPowered tests if a repeater should be powered by testing for power sources behind the repeater. -// It takes the coordinates of the repeater the the meta value. + bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta) { // Repeaters cannot be powered by any face except their back; verify that this is true for a source @@ -1510,19 +1509,19 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelB case 0x0: case 0x2: { - // Check if eastern(right) neighbor is a powered on repeater who is facing us. + // Check if eastern(right) neighbor is a powered on repeater who is facing us BLOCKTYPE Block = 0; if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) // Is right neighbor a powered repeater? { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ) & 0x3; - if (OtherRepeaterDir == 0x3) { return true; } // If so, I am latched/locked. + if (OtherRepeaterDir == 0x3) { return true; } // If so, I am latched/locked } - // Check if western(left) neighbor is a powered on repeater who is facing us. + // Check if western(left) neighbor is a powered on repeater who is facing us if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX -1, a_RelBlockY, a_RelBlockZ) & 0x3; - if (OtherRepeaterDir == 0x1) { return true; } // If so, I am latched/locked. + if (OtherRepeaterDir == 0x1) { return true; } // If so, I am latched/locked } break; @@ -1532,26 +1531,26 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelB case 0x1: case 0x3: { - // Check if southern(down) neighbor is a powered on repeater who is facing us. + // Check if southern(down) neighbor is a powered on repeater who is facing us BLOCKTYPE Block = 0; if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1) & 0x3; - if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked. + if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked } - // Check if northern(up) neighbor is a powered on repeater who is facing us. + // Check if northern(up) neighbor is a powered on repeater who is facing us if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1) & 0x3; - if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked. + if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked } break; } } - return false; // None of the checks succeeded, I am not a locked repeater. + return false; // None of the checks succeeded, I am not a locked repeater } @@ -1610,7 +1609,7 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc { continue; } - a_PowerLevel = std::max(a_PowerLevel, itr->a_PowerLevel); + a_PowerLevel = itr->a_PowerLevel; } for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list @@ -1619,10 +1618,10 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc { continue; } - a_PowerLevel = std::max(a_PowerLevel, itr->a_PowerLevel); + a_PowerLevel = itr->a_PowerLevel; } - return (a_PowerLevel != 0); // Source was in front of the piston's front face + return (a_PowerLevel != 0); // Answer the inital question: is the wire powered? } diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index 83076311a..1d6a49aca 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -156,7 +156,7 @@ private: bool AreCoordsLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Returns if a coordinate was marked as simulated (for blocks toggleable by players) */ bool AreCoordsSimulated(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, bool IsCurrentStatePowered); - /** Returns if a repeater is powered */ + /** Returns if a repeater is powered by testing for power sources behind the repeater */ bool IsRepeaterPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta); /** Returns if a repeater is locked */ bool IsRepeaterLocked(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta); -- cgit v1.2.3 From d5a99d5b78857d6377ee607cf2021283d83e13d1 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sat, 14 Jun 2014 13:48:12 +0100 Subject: Remove windows bindings crutch --- src/CMakeLists.txt | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c5156e50c..65cf14a7f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -149,16 +149,6 @@ if (NOT MSVC) else () # MSVC-specific handling: Put all files into one project, separate by the folders: - # Generate the Bindings if they don't exist: - if (NOT EXISTS "${PROJECT_SOURCE_DIR}/Bindings/Bindings.cpp") - message("Bindings.cpp not found, generating now") - set(tolua_executable ${PROJECT_SOURCE_DIR}/Bindings/tolua++.exe) - execute_process( - COMMAND ${tolua_executable} -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Bindings - ) - endif() - # Get all files in this folder: file(GLOB_RECURSE SOURCE "*.cpp" -- cgit v1.2.3 From af981cc7185bc3c855a535cdb8bb8ea9d5311921 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 14 Jun 2014 15:00:57 +0200 Subject: Fixed MSVC Bindings generation. --- src/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 65cf14a7f..f60a6d453 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -157,6 +157,9 @@ else () ) source_group("" FILES ${SOURCE}) + LIST(APPEND SOURCE "Bindings/Bindings.cpp" "Bindings/Bindings.h") + source_group(Bindings FILES "Bindings/Bindings.cpp" "Bindings/Bindings.h") + # Add all subfolders as solution-folders: list(APPEND FOLDERS "Resources") list(APPEND FOLDERS "Bindings") -- cgit v1.2.3 From f1e3010839f2ccd26a6f71b93df08c9146464870 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 14 Jun 2014 15:47:37 +0200 Subject: Fixed bindings generation for Win64 builds. Fixes #1092. --- src/Bindings/.gitignore | 1 + src/Bindings/lua51.dll | Bin 167424 -> 0 bytes src/CMakeLists.txt | 37 ++++++++++++++++++++++++++++--------- 3 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 src/Bindings/.gitignore delete mode 100644 src/Bindings/lua51.dll (limited to 'src') diff --git a/src/Bindings/.gitignore b/src/Bindings/.gitignore new file mode 100644 index 000000000..af8aa76fa --- /dev/null +++ b/src/Bindings/.gitignore @@ -0,0 +1 @@ +lua51.dll diff --git a/src/Bindings/lua51.dll b/src/Bindings/lua51.dll deleted file mode 100644 index 515cf8b30..000000000 Binary files a/src/Bindings/lua51.dll and /dev/null differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f60a6d453..335ce8315 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -82,17 +82,36 @@ set(BINDING_DEPENDECIES include_directories(Bindings) include_directories(.) -ADD_CUSTOM_COMMAND( - # add any new generated bindings here - OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h +if (WIN32) + ADD_CUSTOM_COMMAND( + # add any new generated bindings here + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h - # command execuded to regerate bindings - COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/ + # Copy the Lua DLL into the Bindings folder, so that tolua can run from there: + COMMAND copy /y ..\\..\\MCServer\\lua51.dll . - # add any new generation dependencies here - DEPENDS ${BINDING_DEPENDECIES} -) + # Regenerate bindings: + COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/ + + # add any new generation dependencies here + DEPENDS ${BINDING_DEPENDECIES} + ) +else () + ADD_CUSTOM_COMMAND( + # add any new generated bindings here + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h + + # Regenerate bindings: + COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/ + + # add any new generation dependencies here + DEPENDS ${BINDING_DEPENDECIES} + ) +endif () +set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE) +set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE) if (NOT MSVC) -- cgit v1.2.3 From 3f009a7c9e35a08d5685cd4276e17fc8f3443f9e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Jun 2014 17:10:53 +0200 Subject: Refactored speed-setting to use a common function for all cases. --- src/Entities/Entity.cpp | 27 +++++++++++++---------- src/Entities/Entity.h | 39 +++++++++++++++++++-------------- src/Entities/Player.cpp | 58 ++----------------------------------------------- src/Entities/Player.h | 13 ++++------- 4 files changed, 44 insertions(+), 93 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 8f736a269..76bd11406 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1076,6 +1076,17 @@ void cEntity::SetSwimState(cChunk & a_Chunk) +void cEntity::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) +{ + m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ); + + WrapSpeed(); +} + + + + + void cEntity::HandleAir(void) { // Ref.: http://www.minecraftwiki.net/wiki/Chunk_format @@ -1428,9 +1439,7 @@ void cEntity::SetRoll(double a_Roll) void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) { - m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ); - - WrapSpeed(); + DoSetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ); } @@ -1438,9 +1447,7 @@ void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) void cEntity::SetSpeedX(double a_SpeedX) { - m_Speed.x = a_SpeedX; - - WrapSpeed(); + SetSpeed(a_SpeedX, m_Speed.y, m_Speed.z); } @@ -1448,9 +1455,7 @@ void cEntity::SetSpeedX(double a_SpeedX) void cEntity::SetSpeedY(double a_SpeedY) { - m_Speed.y = a_SpeedY; - - WrapSpeed(); + SetSpeed(m_Speed.x, a_SpeedY, m_Speed.z); } @@ -1458,9 +1463,7 @@ void cEntity::SetSpeedY(double a_SpeedY) void cEntity::SetSpeedZ(double a_SpeedZ) { - m_Speed.z = a_SpeedZ; - - WrapSpeed(); + SetSpeed(m_Speed.x, m_Speed.y, a_SpeedZ); } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index fed856b30..cb35db43b 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -217,21 +217,21 @@ public: void SetRoll (double a_Roll); // In degrees, normalizes to [-180, +180) // tolua_end - /** Measured in meter/second (m/s) */ - Vector3d m_Speed; - // tolua_begin - /** Sets the speed of the entity and moves them in the given speed. */ - virtual void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ); - /** Sets the speed of the entity and moves them in the given speed. */ - void SetSpeed (const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); } - - /** Sets the speed for the X axis */ - virtual void SetSpeedX (double a_SpeedX); - /** Sets the speed for the Y axis */ - virtual void SetSpeedY (double a_SpeedY); - /** Sets the speed for the Z axis */ - virtual void SetSpeedZ (double a_SpeedZ); + /** Sets the speed of the entity, measured in m / sec */ + void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ); + + /** Sets the speed of the entity, measured in m / sec */ + void SetSpeed(const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); } + + /** Sets the speed in the X axis, leaving the other speed components intact. Measured in m / sec. */ + void SetSpeedX(double a_SpeedX); + + /** Sets the speed in the Y axis, leaving the other speed components intact. Measured in m / sec. */ + void SetSpeedY(double a_SpeedY); + + /** Sets the speed in the Z axis, leaving the other speed components intact. Measured in m / sec. */ + void SetSpeedZ(double a_SpeedZ); void SetWidth (double a_Width); @@ -442,6 +442,9 @@ protected: static cCriticalSection m_CSCount; static int m_EntityCount; + /** Measured in meter/second (m/s) */ + Vector3d m_Speed; + int m_UniqueID; int m_Health; @@ -499,11 +502,15 @@ protected: /// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void. int m_TicksSinceLastVoidDamage; - + + /** Does the actual speed-setting. The default implementation just sets the member variable value; + overrides can provide further processing, such as forcing players to move at the given speed. */ + virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ); + virtual void Destroyed(void) {} // Called after the entity has been destroyed /** Called in each tick to handle air-related processing i.e. drowning */ - virtual void HandleAir(); + virtual void HandleAir(void); /** Called once per tick to set IsSwimming and IsSubmerged */ virtual void SetSwimState(cChunk & a_Chunk); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 33b339f8e..f1e0aad7e 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1257,30 +1257,15 @@ Vector3d cPlayer::GetThrowSpeed(double a_SpeedCoeff) const void cPlayer::ForceSetSpeed(const Vector3d & a_Speed) { SetSpeed(a_Speed); - m_ClientHandle->SendEntityVelocity(*this); -} - - - - - -void cPlayer::SetSpeed(const Vector3d & a_Speed) -{ - m_Speed.Set(a_Speed.x, a_Speed.y, a_Speed.z); - WrapSpeed(); - - // Send the speed to the client so he actualy moves - m_ClientHandle->SendEntityVelocity(*this); } -void cPlayer::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) +void cPlayer::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) { - m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ); - WrapSpeed(); + super::DoSetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ); // Send the speed to the client so he actualy moves m_ClientHandle->SendEntityVelocity(*this); @@ -1290,45 +1275,6 @@ void cPlayer::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) -void cPlayer::SetSpeedX(double a_SpeedX) -{ - m_Speed.x = a_SpeedX; - WrapSpeed(); - - // Send the speed to the client so he actualy moves - m_ClientHandle->SendEntityVelocity(*this); -} - - - - - -void cPlayer::SetSpeedY(double a_SpeedY) -{ - m_Speed.y = a_SpeedY; - WrapSpeed(); - - // Send the speed to the client so he actualy moves - m_ClientHandle->SendEntityVelocity(*this); -} - - - - - -void cPlayer::SetSpeedZ(double a_SpeedZ) -{ - m_Speed.z = a_SpeedZ; - WrapSpeed(); - - // Send the speed to the client so he actualy moves - m_ClientHandle->SendEntityVelocity(*this); -} - - - - - void cPlayer::MoveTo( const Vector3d & a_NewPos ) { if ((a_NewPos.y < -990) && (GetPosY() > -100)) diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 165963e6e..325ff9005 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -195,17 +195,9 @@ public: void LoginSetGameMode(eGameMode a_GameMode); /** Forces the player to move in the given direction. - * @deprecated Use SetSpeed instead. - */ + @deprecated Use SetSpeed instead. */ void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export - /** Sets the speed of the player and moves them in the given speed. */ - void SetSpeed (const Vector3d & a_Speed); - virtual void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ) override; - virtual void SetSpeedX (double a_SpeedX) override; - virtual void SetSpeedY (double a_SpeedY) override; - virtual void SetSpeedZ (double a_SpeedZ) override; - /** Tries to move to a new position, with attachment-related checks (y == -999) */ void MoveTo(const Vector3d & a_NewPos); // tolua_export @@ -521,6 +513,9 @@ protected: + /** Sets the speed and sends it to the client, so that they are forced to move so. */ + virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override; + void ResolvePermissions(void); void ResolveGroups(void); -- cgit v1.2.3 From a89422ea4c5859464a9d955675ca666b67453190 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Jun 2014 18:16:10 +0200 Subject: Simplified speed clamping. --- src/Entities/Entity.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 76bd11406..ee7ce06ac 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -179,14 +179,9 @@ void cEntity::WrapRotation(void) void cEntity::WrapSpeed(void) { - // There shoudn't be a need for flipping the flag on because this function is called - // after any update, so the flag is already turned on - if (m_Speed.x > 78.0f) m_Speed.x = 78.0f; - else if (m_Speed.x < -78.0f) m_Speed.x = -78.0f; - if (m_Speed.y > 78.0f) m_Speed.y = 78.0f; - else if (m_Speed.y < -78.0f) m_Speed.y = -78.0f; - if (m_Speed.z > 78.0f) m_Speed.z = 78.0f; - else if (m_Speed.z < -78.0f) m_Speed.z = -78.0f; + m_Speed.x = Clamp(m_Speed.x, -78.0, 78.0); + m_Speed.y = Clamp(m_Speed.y, -78.0, 78.0); + m_Speed.z = Clamp(m_Speed.z, -78.0, 78.0); } -- cgit v1.2.3 From 493d36433108735553ec073ccfbb563a4468a3fd Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Jun 2014 18:23:27 +0200 Subject: Removed an unused tolua_end and tolua_begin pair. --- src/Entities/Entity.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index cb35db43b..2df66e353 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -215,9 +215,7 @@ public: void SetYaw (double a_Yaw); // In degrees, normalizes to [-180, +180) void SetPitch (double a_Pitch); // In degrees, normalizes to [-180, +180) void SetRoll (double a_Roll); // In degrees, normalizes to [-180, +180) - // tolua_end - // tolua_begin /** Sets the speed of the entity, measured in m / sec */ void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ); -- cgit v1.2.3 From 2a6ca71a0b8839a299335f5f02872128db325b59 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 15 Jun 2014 16:27:20 +0100 Subject: Fixed daylight sensor unpowering * Fixes #1094 --- src/Simulator/IncrementalRedstoneSimulator.cpp | 34 +++++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index f20f396f2..3d8229e16 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -59,19 +59,21 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, int RelZ = 0; BLOCKTYPE Block; NIBBLETYPE Meta; + cChunk * Chunk; if (a_OtherChunk != NULL) { RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width; RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width; a_OtherChunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta); - a_OtherChunk->SetIsRedstoneDirty(true); + Chunk = a_OtherChunk; } else { RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width; RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width; a_Chunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta); + Chunk = a_Chunk; } // Every time a block is changed (AddBlock called), we want to go through all lists and check to see if the coordiantes stored within are still valid @@ -90,7 +92,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list as it no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = PoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); + Chunk->SetIsRedstoneDirty(true); continue; } else if ( @@ -105,9 +107,25 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = PoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); + Chunk->SetIsRedstoneDirty(true); continue; } + else if (Block == E_BLOCK_DAYLIGHT_SENSOR) + { + if (!m_World.IsChunkLighted(Chunk->GetPosX(), Chunk->GetPosZ())) + { + m_World.QueueLightChunk(Chunk->GetPosX(), Chunk->GetPosZ()); + } + else + { + if (Chunk->GetTimeAlteredLight(Chunk->GetSkyLight(RelX, a_BlockY + 1, RelZ)) <= 7) + { + itr = PoweredBlocks->erase(itr); + Chunk->SetIsRedstoneDirty(true); + continue; + } + } + } ++itr; } @@ -121,7 +139,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); + Chunk->SetIsRedstoneDirty(true); continue; } else if ( @@ -135,7 +153,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); + Chunk->SetIsRedstoneDirty(true); continue; } } @@ -145,7 +163,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer powered through a valid middle block", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); + Chunk->SetIsRedstoneDirty(true); continue; } } @@ -1145,6 +1163,10 @@ void cIncrementalRedstoneSimulator::HandleDaylightSensor(int a_RelBlockX, int a_ { SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); } + else + { + WakeUp(BlockX, a_RelBlockY, BlockZ, m_Chunk); + } } } -- cgit v1.2.3 From f822a46bdb24a9c693e897d3619ece15a1cc1a5a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 15 Jun 2014 19:42:14 +0100 Subject: Fixed bad comparison crash * Fixes #1095 --- src/Simulator/IncrementalRedstoneSimulator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 3d8229e16..69c8b9f56 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -806,12 +806,12 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int { WereItrsChanged = QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false); } - else if (a_Itr != m_RepeatersDelayList->end()) + else if (a_Itr == m_RepeatersDelayList->end()) { return; } } - else if (a_Itr != m_RepeatersDelayList->end()) + else if (a_Itr == m_RepeatersDelayList->end()) { return; } -- cgit v1.2.3 From abbd11be6da261293f2086135e05e9a0659220f2 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 15 Jun 2014 20:28:08 +0100 Subject: Players are saved regularly * Fixes #1076 --- src/Entities/Player.cpp | 19 ++++++++++++++++++- src/Entities/Player.h | 5 ++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index feb09b5d2..cffdd71b1 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -22,6 +22,12 @@ #include "inifile/iniFile.h" #include "json/json.h" +// 6000 ticks or 5 minutes +#define PLAYER_INVENTORY_SAVE_INTERVAL 6000 + +// 1000 = once per second +#define PLAYER_LIST_TIME_MS 1000 + @@ -64,6 +70,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) , m_BowCharge(0) , m_FloaterID(-1) , m_Team(NULL) + , m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL) { LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d", a_PlayerName.c_str(), a_Client->GetIPString().c_str(), @@ -250,7 +257,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) // Send Player List (Once per m_LastPlayerListTime/1000 ms) cTimer t1; - if (m_LastPlayerListTime + cPlayer::PLAYER_LIST_TIME_MS <= t1.GetNowTime()) + if (m_LastPlayerListTime + PLAYER_LIST_TIME_MS <= t1.GetNowTime()) { m_World->SendPlayerList(this); m_LastPlayerListTime = t1.GetNowTime(); @@ -260,6 +267,16 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) { m_LastGroundHeight = (float)GetPosY(); } + + if (m_TicksUntilNextSave == 0) + { + SaveToDisk(); + m_TicksUntilNextSave = PLAYER_INVENTORY_SAVE_INTERVAL; + } + else + { + m_TicksUntilNextSave--; + } } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 83b9ad593..a9acf6efc 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -461,7 +461,6 @@ protected: cItem m_DraggingItem; long long m_LastPlayerListTime; - static const unsigned short PLAYER_LIST_TIME_MS = 1000; // 1000 = once per second cClientHandle * m_ClientHandle; @@ -539,6 +538,10 @@ protected: Set by a right click on unoccupied bed, unset by a time fast forward or teleport */ bool m_bIsInBed; + /** How long till the player's inventory will be saved + Default save interval is #defined in PLAYER_INVENTORY_SAVE_INTERVAL */ + unsigned int m_TicksUntilNextSave; + } ; // tolua_export -- cgit v1.2.3 From d9719e696ce11df0557acbbc56545cb0d0f95075 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 15 Jun 2014 23:30:43 +0200 Subject: Added random offsets to cGridStructGen. Fixes #740. --- src/Generating/Caves.cpp | 10 +++++----- src/Generating/Caves.h | 4 ++-- src/Generating/ComposableGenerator.cpp | 36 +++++++++++++++++++++------------- src/Generating/GridStructGen.cpp | 31 +++++++++++++++++------------ src/Generating/GridStructGen.h | 33 +++++++++++++++++++++++++------ src/Generating/MineShafts.cpp | 16 ++++++++------- src/Generating/MineShafts.h | 4 ++-- src/Generating/NetherFortGen.cpp | 15 ++++++++------ src/Generating/NetherFortGen.h | 4 ++-- src/Generating/RainbowRoadsGen.cpp | 11 ++++++----- src/Generating/RainbowRoadsGen.h | 4 ++-- src/Generating/Ravines.cpp | 12 ++++++------ src/Generating/Ravines.h | 2 +- src/Generating/UnderwaterBaseGen.cpp | 11 ++++++----- src/Generating/UnderwaterBaseGen.h | 4 ++-- src/Generating/VillageGen.cpp | 11 ++++++----- src/Generating/VillageGen.h | 4 ++-- 17 files changed, 127 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index 872e3341d..6aa7fd4cb 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -125,7 +125,7 @@ public: int m_BlockX; int m_BlockZ; - cCaveSystem(int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise); + cCaveSystem(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise); ~cCaveSystem(); protected: @@ -574,8 +574,8 @@ AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) cons /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cStructGenWormNestCaves::cCaveSystem: -cStructGenWormNestCaves::cCaveSystem::cCaveSystem(int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise) : - super(a_OriginX, a_OriginZ), +cStructGenWormNestCaves::cCaveSystem::cCaveSystem(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise) : + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_Size(a_Size) { int Num = 1 + a_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) % 3; @@ -690,9 +690,9 @@ int cStructGenWormNestCaves::cCaveSystem::GetRadius(cNoise & a_Noise, int a_Orig /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cStructGenWormNestCaves: -cGridStructGen::cStructurePtr cStructGenWormNestCaves::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cStructGenWormNestCaves::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { - return cStructurePtr(new cCaveSystem(a_OriginX, a_OriginZ, m_MaxOffset, m_Size, m_Noise)); + return cStructurePtr(new cCaveSystem(a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxOffset, m_Size, m_Noise)); } diff --git a/src/Generating/Caves.h b/src/Generating/Caves.h index 254dcddbd..0e17acf9e 100644 --- a/src/Generating/Caves.h +++ b/src/Generating/Caves.h @@ -69,7 +69,7 @@ class cStructGenWormNestCaves : typedef cGridStructGen super; public: cStructGenWormNestCaves(int a_Seed, int a_Size = 64, int a_Grid = 96, int a_MaxOffset = 128) : - super(a_Seed, a_Grid, a_Grid, a_Size + a_MaxOffset, a_Size + a_MaxOffset, 100), + super(a_Seed, a_Grid, a_Grid, a_MaxOffset, a_MaxOffset, a_Size, a_Size, 100), m_Noise(a_Seed), m_Size(a_Size), m_MaxOffset(a_MaxOffset), @@ -86,7 +86,7 @@ protected: int m_Grid; // average spacing of the nests // cGridStructGen override: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 1801b7375..f332b4d78 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -357,12 +357,13 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) else if (NoCaseCompare(*itr, "MineShafts") == 0) { int GridSize = a_IniFile.GetValueSetI("Generator", "MineShaftsGridSize", 512); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "MineShaftsMaxOffset", 256); int MaxSystemSize = a_IniFile.GetValueSetI("Generator", "MineShaftsMaxSystemSize", 160); int ChanceCorridor = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCorridor", 600); int ChanceCrossing = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCrossing", 200); int ChanceStaircase = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceStaircase", 200); m_FinishGens.push_back(new cStructGenMineShafts( - Seed, GridSize, MaxSystemSize, + Seed, GridSize, MaxOffset, MaxSystemSize, ChanceCorridor, ChanceCrossing, ChanceStaircase )); } @@ -376,9 +377,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "NetherForts") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "NetherFortsGridSize", 512); - int MaxDepth = a_IniFile.GetValueSetI("Generator", "NetherFortsMaxDepth", 12); - m_FinishGens.push_back(new cNetherFortGen(Seed, GridSize, MaxDepth)); + int GridSize = a_IniFile.GetValueSetI("Generator", "NetherFortsGridSize", 512); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "NetherFortMaxOffset", 128); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "NetherFortsMaxDepth", 12); + m_FinishGens.push_back(new cNetherFortGen(Seed, GridSize, MaxOffset, MaxDepth)); } else if (NoCaseCompare(*itr, "OreNests") == 0) { @@ -394,10 +396,11 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "RainbowRoads") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsGridSize", 512); - int MaxDepth = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxDepth", 30); - int MaxSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxSize", 260); - m_FinishGens.push_back(new cRainbowRoadsGen(Seed, GridSize, MaxDepth, MaxSize)); + int GridSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsGridSize", 512); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxOffset", 128); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxDepth", 30); + int MaxSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxSize", 260); + m_FinishGens.push_back(new cRainbowRoadsGen(Seed, GridSize, MaxOffset, MaxDepth, MaxSize)); } else if (NoCaseCompare(*itr, "Ravines") == 0) { @@ -417,19 +420,21 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "UnderwaterBases") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseGridSize", 1024); - int MaxDepth = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxDepth", 7); - int MaxSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxSize", 128); - m_FinishGens.push_back(new cUnderwaterBaseGen(Seed, GridSize, MaxDepth, MaxSize, *m_BiomeGen)); + int GridSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseGridSize", 1024); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxOffset", 128); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxDepth", 7); + int MaxSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxSize", 128); + m_FinishGens.push_back(new cUnderwaterBaseGen(Seed, GridSize, MaxOffset, MaxDepth, MaxSize, *m_BiomeGen)); } else if (NoCaseCompare(*itr, "Villages") == 0) { int GridSize = a_IniFile.GetValueSetI("Generator", "VillageGridSize", 384); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "VillageMaxOffset", 128); int MaxDepth = a_IniFile.GetValueSetI("Generator", "VillageMaxDepth", 2); int MaxSize = a_IniFile.GetValueSetI("Generator", "VillageMaxSize", 128); int MinDensity = a_IniFile.GetValueSetI("Generator", "VillageMinDensity", 50); int MaxDensity = a_IniFile.GetValueSetI("Generator", "VillageMaxDensity", 80); - m_FinishGens.push_back(new cVillageGen(Seed, GridSize, MaxDepth, MaxSize, MinDensity, MaxDensity, *m_BiomeGen, *m_HeightGen)); + m_FinishGens.push_back(new cVillageGen(Seed, GridSize, MaxOffset, MaxDepth, MaxSize, MinDensity, MaxDensity, *m_BiomeGen, *m_HeightGen)); } else if (NoCaseCompare(*itr, "WaterLakes") == 0) { @@ -442,7 +447,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "WormNestCaves") == 0) { - m_FinishGens.push_back(new cStructGenWormNestCaves(Seed)); + int Size = a_IniFile.GetValueSetI("Generator", "WormNestCavesSize", 64); + int Grid = a_IniFile.GetValueSetI("Generator", "WormNestCavesGrid", 96); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "NetherFortMaxOffset", 32); + m_FinishGens.push_back(new cStructGenWormNestCaves(Seed, Size, Grid, MaxOffset)); } else { diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp index 474242557..2931df3eb 100644 --- a/src/Generating/GridStructGen.cpp +++ b/src/Generating/GridStructGen.cpp @@ -21,8 +21,8 @@ class cEmptyStructure : typedef cGridStructGen::cStructure super; public: - cEmptyStructure(int a_OriginX, int a_OriginZ) : - super(a_OriginX, a_OriginZ) + cEmptyStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) : + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ) { } @@ -40,17 +40,20 @@ protected: cGridStructGen::cGridStructGen( int a_Seed, int a_GridSizeX, int a_GridSizeZ, + int a_MaxOffsetX, int a_MaxOffsetZ, int a_MaxStructureSizeX, int a_MaxStructureSizeZ, size_t a_MaxCacheSize ) : - m_Seed(a_Seed), + m_Noise(a_Seed), m_GridSizeX(a_GridSizeX), m_GridSizeZ(a_GridSizeZ), + m_MaxOffsetX(a_MaxOffsetX), + m_MaxOffsetZ(a_MaxOffsetZ), m_MaxStructureSizeX(a_MaxStructureSizeX), m_MaxStructureSizeZ(a_MaxStructureSizeZ), m_MaxCacheSize(a_MaxCacheSize) { - size_t NumStructuresPerQuery = (size_t)((m_MaxStructureSizeX / m_GridSizeX + 1) * (m_MaxStructureSizeZ / m_GridSizeZ + 1)); + size_t NumStructuresPerQuery = (size_t)(((m_MaxStructureSizeX + m_MaxOffsetX) / m_GridSizeX + 1) * ((m_MaxStructureSizeZ + m_MaxOffsetZ) / m_GridSizeZ + 1)); if (NumStructuresPerQuery > m_MaxCacheSize) { m_MaxCacheSize = NumStructuresPerQuery * 4; @@ -68,10 +71,10 @@ cGridStructGen::cGridStructGen( void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructurePtrs & a_Structures) { // Calculate the min and max grid coords of the structures to be returned: - int MinBlockX = a_ChunkX * cChunkDef::Width - m_MaxStructureSizeX; - int MinBlockZ = a_ChunkZ * cChunkDef::Width - m_MaxStructureSizeZ; - int MaxBlockX = a_ChunkX * cChunkDef::Width + m_MaxStructureSizeX + cChunkDef::Width - 1; - int MaxBlockZ = a_ChunkZ * cChunkDef::Width + m_MaxStructureSizeZ + cChunkDef::Width - 1; + int MinBlockX = a_ChunkX * cChunkDef::Width - m_MaxStructureSizeX - m_MaxOffsetX; + int MinBlockZ = a_ChunkZ * cChunkDef::Width - m_MaxStructureSizeZ - m_MaxOffsetZ; + int MaxBlockX = a_ChunkX * cChunkDef::Width + m_MaxStructureSizeX + m_MaxOffsetX + cChunkDef::Width - 1; + int MaxBlockZ = a_ChunkZ * cChunkDef::Width + m_MaxStructureSizeZ + m_MaxOffsetZ + cChunkDef::Width - 1; int MinGridX = MinBlockX / m_GridSizeX; int MinGridZ = MinBlockZ / m_GridSizeZ; int MaxGridX = (MaxBlockX + m_GridSizeX - 1) / m_GridSizeX; @@ -103,14 +106,14 @@ void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructur // Create those structures that haven't been in the cache: for (int x = MinGridX; x < MaxGridX; x++) { - int OriginX = x * m_GridSizeX; + int GridX = x * m_GridSizeX; for (int z = MinGridZ; z < MaxGridZ; z++) { - int OriginZ = z * m_GridSizeZ; + int GridZ = z * m_GridSizeZ; bool Found = false; for (cStructurePtrs::const_iterator itr = a_Structures.begin(), end = a_Structures.end(); itr != end; ++itr) { - if (((*itr)->m_OriginX == OriginX) && ((*itr)->m_OriginZ == OriginZ)) + if (((*itr)->m_GridX == GridX) && ((*itr)->m_GridZ == GridZ)) { Found = true; break; @@ -118,10 +121,12 @@ void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructur } // for itr - a_Structures[] if (!Found) { - cStructurePtr Structure = CreateStructure(OriginX, OriginZ); + int OriginX = GridX + ((m_Noise.IntNoise2DInt(GridX + 3, GridZ + 5) / 7) % (m_MaxOffsetX * 2)) - m_MaxOffsetX; + int OriginZ = GridZ + ((m_Noise.IntNoise2DInt(GridX + 5, GridZ + 3) / 7) % (m_MaxOffsetZ * 2)) - m_MaxOffsetZ; + cStructurePtr Structure = CreateStructure(GridX, GridZ, OriginX, OriginZ); if (Structure.get() == NULL) { - Structure.reset(new cEmptyStructure(OriginX, OriginZ)); + Structure.reset(new cEmptyStructure(GridX, GridZ, OriginX, OriginZ)); } a_Structures.push_back(Structure); } diff --git a/src/Generating/GridStructGen.h b/src/Generating/GridStructGen.h index 630a5e44e..03131fce9 100644 --- a/src/Generating/GridStructGen.h +++ b/src/Generating/GridStructGen.h @@ -10,6 +10,7 @@ #pragma once #include "ComposableGenerator.h" +#include "../Noise.h" @@ -19,7 +20,12 @@ Defines a grid in the XZ space with predefined cell size in each direction. Each cell then receives exactly one structure (provided by the descendant class). The structure is placed within the cell, but doesn't need to be bounded by the cell, it can be well outside the cell; the generator uses the MaxStructureSize parameter -to determine how far away from the cell the structure can be at most. +to determine how far away from the cell the structure can be at most. Each structure has an offset from the +grid's center point, the offset is generated randomly from a range given to this class as a parameter. + +Each structure thus contains the coords of its grid center (m_GridX, m_GridZ) and the actual origin from +which it's built (m_OriginX, m_OriginZ). + This class provides a cache for the structures generated for successive chunks and manages that cache. It also provides the cFinishGen override that uses the cache to actually generate the structure into chunk data. @@ -43,12 +49,17 @@ public: class cStructure { public: - /** The origin (the coords of the gridpoint for which the structure is generated) */ + /** The grid point for which the structure is generated. */ + int m_GridX, m_GridZ; + + /** The origin (the coords for which the structure is generated) */ int m_OriginX, m_OriginZ; - /** Creates a structure that has its originset at the specified coords. */ - cStructure (int a_OriginX, int a_OriginZ) : + /** Creates a structure that has its origin set at the specified coords. */ + cStructure (int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) : + m_GridX(a_GridX), + m_GridZ(a_GridZ), m_OriginX(a_OriginX), m_OriginZ(a_OriginZ) { @@ -70,20 +81,30 @@ public: cGridStructGen( int a_Seed, int a_GridSizeX, int a_GridSizeZ, + int a_MaxOffsetX, int a_MaxOffsetZ, int a_MaxStructureSizeX, int a_MaxStructureSizeZ, size_t a_MaxCacheSize ); protected: - /** Seed for generating the semi-random grid. */ + /** Seed for generating grid offsets and also available for descendants. */ int m_Seed; + /** The noise used for generating grid offsets. */ + cNoise m_Noise; + /** The size of each grid's cell in the X axis */ int m_GridSizeX; /** The size of each grid's cell in the Z axis */ int m_GridSizeZ; + /** The maximum offset of the structure's origin from the grid midpoint, in X coord. */ + int m_MaxOffsetX; + + /** The maximum offset of the structure's origin from the grid midpoint, in Z coord. */ + int m_MaxOffsetZ; + /** Maximum theoretical size of the structure in the X axis. This limits the structures considered for a single chunk, so the lesser the number, the better performance. Structures large than this may get cropped. */ @@ -115,7 +136,7 @@ protected: // Functions for the descendants to override: /** Create a new structure at the specified gridpoint */ - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) = 0; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) = 0; } ; diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index 81ae6481d..ab9b1aa29 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -248,7 +248,8 @@ public: /** Creates and generates the entire system */ cMineShaftSystem( - int a_OriginX, int a_OriginZ, int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise, + int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, + int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise, int a_ProbLevelCorridor, int a_ProbLevelCrossing, int a_ProbLevelStaircase ); @@ -278,10 +279,11 @@ public: // cStructGenMineShafts::cMineShaftSystem: cStructGenMineShafts::cMineShaftSystem::cMineShaftSystem( - int a_OriginX, int a_OriginZ, int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise, + int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, + int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise, int a_ProbLevelCorridor, int a_ProbLevelCrossing, int a_ProbLevelStaircase ) : - super(a_OriginX, a_OriginZ), + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_GridSize(a_GridSize), m_MaxRecursion(8), // TODO: settable m_ProbLevelCorridor(a_ProbLevelCorridor), @@ -1280,10 +1282,10 @@ void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc) // cStructGenMineShafts: cStructGenMineShafts::cStructGenMineShafts( - int a_Seed, int a_GridSize, int a_MaxSystemSize, + int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxSystemSize, int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase ) : - super(a_Seed, a_GridSize, a_GridSize, a_MaxSystemSize, a_MaxSystemSize, 100), + super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSystemSize, a_MaxSystemSize, 100), m_Noise(a_Seed), m_GridSize(a_GridSize), m_MaxSystemSize(a_MaxSystemSize), @@ -1297,9 +1299,9 @@ cStructGenMineShafts::cStructGenMineShafts( -cGridStructGen::cStructurePtr cStructGenMineShafts::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cStructGenMineShafts::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { - return cStructurePtr(new cMineShaftSystem(a_OriginX, a_OriginZ, m_GridSize, m_MaxSystemSize, m_Noise, m_ProbLevelCorridor, m_ProbLevelCrossing, m_ProbLevelStaircase)); + return cStructurePtr(new cMineShaftSystem(a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_GridSize, m_MaxSystemSize, m_Noise, m_ProbLevelCorridor, m_ProbLevelCrossing, m_ProbLevelStaircase)); } diff --git a/src/Generating/MineShafts.h b/src/Generating/MineShafts.h index c29b6cdac..2850db571 100644 --- a/src/Generating/MineShafts.h +++ b/src/Generating/MineShafts.h @@ -23,7 +23,7 @@ class cStructGenMineShafts : public: cStructGenMineShafts( - int a_Seed, int a_GridSize, int a_MaxSystemSize, + int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxSystemSize, int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase ); @@ -43,7 +43,7 @@ protected: int m_ProbLevelStaircase; ///< Probability level of a branch object being the staircase, minus Crossing // cGridStructGen overrides: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Generating/NetherFortGen.cpp b/src/Generating/NetherFortGen.cpp index 3867ec80c..23fa56048 100644 --- a/src/Generating/NetherFortGen.cpp +++ b/src/Generating/NetherFortGen.cpp @@ -26,8 +26,8 @@ public: cPlacedPieces m_Pieces; - cNetherFort(cNetherFortGen & a_ParentGen, int a_OriginX, int a_OriginZ, int a_GridSize, int a_MaxDepth, int a_Seed) : - super(a_OriginX, a_OriginZ), + cNetherFort(cNetherFortGen & a_ParentGen, int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_GridSize, int a_MaxDepth, int a_Seed) : + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_ParentGen(a_ParentGen), m_GridSize(a_GridSize), m_Seed(a_Seed) @@ -108,8 +108,8 @@ cPrefabPiecePool cNetherFortGen::m_PiecePool(g_NetherFortPrefabs, g_NetherFortPr -cNetherFortGen::cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxDepth) : - super(a_Seed, a_GridSize, a_GridSize, a_MaxDepth * 10, a_MaxDepth * 10, 200), +cNetherFortGen::cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxDepth * 10, a_MaxDepth * 10, 200), m_MaxDepth(a_MaxDepth) { /* @@ -124,8 +124,11 @@ cNetherFortGen::cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxDepth) : -cGridStructGen::cStructurePtr cNetherFortGen::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cNetherFortGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { - return cStructurePtr(new cNetherFort(*this, a_OriginX, a_OriginZ, m_GridSizeX, m_MaxDepth, m_Seed)); + return cStructurePtr(new cNetherFort(*this, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_GridSizeX, m_MaxDepth, m_Seed)); } + + + diff --git a/src/Generating/NetherFortGen.h b/src/Generating/NetherFortGen.h index f35801a3c..9b31aa0e2 100644 --- a/src/Generating/NetherFortGen.h +++ b/src/Generating/NetherFortGen.h @@ -23,7 +23,7 @@ class cNetherFortGen : typedef cGridStructGen super; public: - cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxDepth); + cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth); protected: friend class cNetherFortPerfTest; // fwd: NetherFortGen.cpp @@ -37,7 +37,7 @@ protected: // cGridStructGen overrides: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Generating/RainbowRoadsGen.cpp b/src/Generating/RainbowRoadsGen.cpp index d1e1f4bda..3b0ff7df8 100644 --- a/src/Generating/RainbowRoadsGen.cpp +++ b/src/Generating/RainbowRoadsGen.cpp @@ -29,11 +29,12 @@ class cRainbowRoadsGen::cRainbowRoads : public: cRainbowRoads( int a_Seed, + int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxDepth, int a_MaxSize ) : - super(a_OriginX, a_OriginZ), + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_Seed(a_Seed), m_Noise(a_Seed), m_MaxSize(a_MaxSize), @@ -92,8 +93,8 @@ protected: -cRainbowRoadsGen::cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize) : - super(a_Seed, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 100), +cRainbowRoadsGen::cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 100), m_Noise(a_Seed + 9000), m_MaxDepth(a_MaxDepth), m_MaxSize(a_MaxSize) @@ -104,10 +105,10 @@ cRainbowRoadsGen::cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxDepth, i -cGridStructGen::cStructurePtr cRainbowRoadsGen::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cRainbowRoadsGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { // Create a base based on the chosen prefabs: - return cStructurePtr(new cRainbowRoads(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize)); + return cStructurePtr(new cRainbowRoads(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize)); } diff --git a/src/Generating/RainbowRoadsGen.h b/src/Generating/RainbowRoadsGen.h index acbd5abf9..5813e1d14 100644 --- a/src/Generating/RainbowRoadsGen.h +++ b/src/Generating/RainbowRoadsGen.h @@ -22,7 +22,7 @@ class cRainbowRoadsGen : typedef cGridStructGen super; public: - cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize); + cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize); protected: class cRainbowRoads; // fwd: RainbowRoadsGen.cpp @@ -39,7 +39,7 @@ protected: // cGridStructGen overrides: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index 2722e4ca3..24f2cc3ab 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -61,7 +61,7 @@ class cStructGenRavines::cRavine : public: - cRavine(int a_BlockX, int a_BlockZ, int a_Size, cNoise & a_Noise); + cRavine(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_Size, cNoise & a_Noise); #ifdef _DEBUG /// Exports itself as a SVG line definition @@ -81,7 +81,7 @@ protected: // cStructGenRavines: cStructGenRavines::cStructGenRavines(int a_Seed, int a_Size) : - super(a_Seed, a_Size, a_Size, a_Size * 2, a_Size * 2, 100), + super(a_Seed, a_Size, a_Size, a_Size, a_Size, a_Size * 2, a_Size * 2, 100), m_Noise(a_Seed), m_Size(a_Size) { @@ -91,9 +91,9 @@ cStructGenRavines::cStructGenRavines(int a_Seed, int a_Size) : -cGridStructGen::cStructurePtr cStructGenRavines::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cStructGenRavines::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { - return cStructurePtr(new cRavine(a_OriginX, a_OriginZ, m_Size, m_Noise)); + return cStructurePtr(new cRavine(a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_Size, m_Noise)); } @@ -104,8 +104,8 @@ cGridStructGen::cStructurePtr cStructGenRavines::CreateStructure(int a_OriginX, /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cStructGenRavines::cRavine -cStructGenRavines::cRavine::cRavine(int a_OriginX, int a_OriginZ, int a_Size, cNoise & a_Noise) : - super(a_OriginX, a_OriginZ) +cStructGenRavines::cRavine::cRavine(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_Size, cNoise & a_Noise) : + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ) { // Calculate the ravine shape-defining points: GenerateBaseDefPoints(a_OriginX, a_OriginZ, a_Size, a_Noise); diff --git a/src/Generating/Ravines.h b/src/Generating/Ravines.h index 30b47e9ec..3e41c5ce6 100644 --- a/src/Generating/Ravines.h +++ b/src/Generating/Ravines.h @@ -32,7 +32,7 @@ protected: // cGridStructGen overrides: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Generating/UnderwaterBaseGen.cpp b/src/Generating/UnderwaterBaseGen.cpp index ff6f17dde..d3abae9b7 100644 --- a/src/Generating/UnderwaterBaseGen.cpp +++ b/src/Generating/UnderwaterBaseGen.cpp @@ -29,11 +29,12 @@ class cUnderwaterBaseGen::cUnderwaterBase : public: cUnderwaterBase( int a_Seed, + int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxDepth, int a_MaxSize ) : - super(a_OriginX, a_OriginZ), + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_Seed(a_Seed), m_Noise(a_Seed), m_MaxSize(a_MaxSize), @@ -92,8 +93,8 @@ protected: -cUnderwaterBaseGen::cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen) : - super(a_Seed, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 100), +cUnderwaterBaseGen::cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 100), m_Noise(a_Seed + 1000), m_MaxDepth(a_MaxDepth), m_MaxSize(a_MaxSize), @@ -105,7 +106,7 @@ cUnderwaterBaseGen::cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxDept -cGridStructGen::cStructurePtr cUnderwaterBaseGen::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cUnderwaterBaseGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { // Generate the biomes for the chunk surrounding the origin: int ChunkX, ChunkZ; @@ -134,7 +135,7 @@ cGridStructGen::cStructurePtr cUnderwaterBaseGen::CreateStructure(int a_OriginX, } // for i - Biomes[] // Create a base based on the chosen prefabs: - return cStructurePtr(new cUnderwaterBase(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize)); + return cStructurePtr(new cUnderwaterBase(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize)); } diff --git a/src/Generating/UnderwaterBaseGen.h b/src/Generating/UnderwaterBaseGen.h index 0aefbb4c7..d6267b602 100644 --- a/src/Generating/UnderwaterBaseGen.h +++ b/src/Generating/UnderwaterBaseGen.h @@ -22,7 +22,7 @@ class cUnderwaterBaseGen : typedef cGridStructGen super; public: - cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen); + cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen); protected: class cUnderwaterBase; // fwd: UnderwaterBaseGen.cpp @@ -42,7 +42,7 @@ protected: // cGridStructGen overrides: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index 9917141ed..2b7ecc837 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -110,6 +110,7 @@ class cVillageGen::cVillage : public: cVillage( int a_Seed, + int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxRoadDepth, int a_MaxSize, @@ -119,7 +120,7 @@ public: BLOCKTYPE a_RoadBlock, BLOCKTYPE a_WaterRoadBlock ) : - super(a_OriginX, a_OriginZ), + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_Seed(a_Seed), m_Noise(a_Seed), m_MaxSize(a_MaxSize), @@ -358,8 +359,8 @@ static cVillagePiecePool * g_PlainsVillagePools[] = -cVillageGen::cVillageGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, int a_MinDensity, int a_MaxDensity, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen) : - super(a_Seed, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 100), +cVillageGen::cVillageGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize, int a_MinDensity, int a_MaxDensity, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 100), m_Noise(a_Seed + 1000), m_MaxDepth(a_MaxDepth), m_MaxSize(a_MaxSize), @@ -374,7 +375,7 @@ cVillageGen::cVillageGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSi -cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { // Generate the biomes for the chunk surrounding the origin: int ChunkX, ChunkZ; @@ -435,7 +436,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ { return cStructurePtr(); } - return cStructurePtr(new cVillage(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, Density, *VillagePrefabs, m_HeightGen, RoadBlock, WaterRoadBlock)); + return cStructurePtr(new cVillage(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, Density, *VillagePrefabs, m_HeightGen, RoadBlock, WaterRoadBlock)); } diff --git a/src/Generating/VillageGen.h b/src/Generating/VillageGen.h index 5faaae8a6..694ea2358 100644 --- a/src/Generating/VillageGen.h +++ b/src/Generating/VillageGen.h @@ -21,7 +21,7 @@ class cVillageGen : { typedef cGridStructGen super; public: - cVillageGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, int a_MinDensity, int a_MaxDensity, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen); + cVillageGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize, int a_MinDensity, int a_MaxDensity, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen); protected: class cVillage; // fwd: VillageGen.cpp @@ -49,7 +49,7 @@ protected: // cGridStructGen overrides: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; -- cgit v1.2.3 From b2fbcaf1bf43ca1f0e6df48de8584149cbe50222 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 15 Jun 2014 20:27:27 -0700 Subject: Implemented PR suggestions Furnace.txt: newline BlockID: removed extraneous dimension mapping cEntity: fixed typo cPlayer: WorldPtr typedef --- src/BlockID.cpp | 4 ---- src/Entities/Entity.h | 2 +- src/Entities/Player.cpp | 2 +- src/Entities/Player.h | 3 ++- 4 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/BlockID.cpp b/src/BlockID.cpp index 641a6a225..70cb801b6 100644 --- a/src/BlockID.cpp +++ b/src/BlockID.cpp @@ -355,12 +355,8 @@ AString DimensionToString(eDimension a_Dimension) } DimensionMap[] = { { dimOverworld, "Overworld" }, - { dimOverworld, "Normal" }, - { dimOverworld, "World" }, { dimNether, "Nether" }, - { dimNether, "Hell" }, // Alternate name for Nether { dimEnd, "End" }, - { dimEnd, "Sky" }, // Old name for End }; for (size_t i = 0; i < ARRAYCOUNT(DimensionMap); i++) diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 9f3b06c29..8975803a2 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -509,7 +509,7 @@ protected: int m_AirTickTimer; /** Portal delay timer and cooldown boolean - First value is to delay sending the repsawn packet (which triggers the Entering the {Dimension} screen). + First value is to delay sending the respawn packet (which triggers the Entering the {Dimension} screen). Second value is to prevent a teleportation loop by ensuring we do not reenter a portal that we came out of. */ std::pair m_PortalCooldownData; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index a346e68cf..c26c18690 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1651,7 +1651,7 @@ void cPlayer::LoadPermissionsFromDisk() -bool cPlayer::LoadFromDisk(cWorld *& a_World) +bool cPlayer::LoadFromDisk(cWorldPtr & a_World) { a_World = cRoot::Get()->GetWorld(GetLoadedWorldName()); if (a_World == NULL) diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 8f319f1ae..b1fef1b68 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -335,10 +335,11 @@ public: /** Saves all player data, such as inventory, to JSON */ bool SaveToDisk(void); + typedef cWorld * cWorldPtr; /** Loads player data from JSON to the object Takes a (NULL) cWorld pointer which it will assign a value to based on either the loaded world or default world */ - bool LoadFromDisk(cWorld *& a_World); + bool LoadFromDisk(cWorldPtr & a_World); void LoadPermissionsFromDisk(void); // tolua_export const AString & GetLoadedWorldName() { return m_LoadedWorldName; } -- cgit v1.2.3 From c41299b4d486116b80056a898b0685f83419cbed Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 16 Jun 2014 10:18:23 +0200 Subject: Updated the SandFlatRoofVillage prefabs. --- .../Prefabs/SandFlatRoofVillagePrefabs.cpp | 669 ++++++++++++--------- 1 file changed, 381 insertions(+), 288 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp index 4f0efdcc6..eb01cf59e 100644 --- a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp +++ b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp @@ -20,18 +20,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 32, ID 173, created by Aloe_vera { // Size: - 12, 5, 10, // SizeX = 12, SizeY = 5, SizeZ = 10 + 12, 6, 10, // SizeX = 12, SizeY = 6, SizeZ = 10 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 11, 4, 9, // MaxX, MaxY, MaxZ + 11, 5, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 2\n" /* sandstonestairs */ - "b:128: 1\n" /* sandstonestairs */ - "c:128: 0\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e:128: 3\n" /* sandstonestairs */ "f:171:15\n" /* carpet */ "g: 64: 6\n" /* wooddoorblock */ @@ -54,35 +54,49 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Level 0 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "aaaaaab....." - /* 1 */ "cdddddddddd." - /* 2 */ "cdddddddddd." - /* 3 */ "cdddddddddd." - /* 4 */ "cdddddddddd." - /* 5 */ "edddddddddd." - /* 6 */ ".dddddddddd." - /* 7 */ ".dddddddddd." - /* 8 */ ".dddddddddd." - /* 9 */ "............" + /* 0 */ "aaaaaaammmmm" + /* 1 */ "aaaaaaaaaaam" + /* 2 */ "aaaaaaaaaaam" + /* 3 */ "aaaaaaaaaaam" + /* 4 */ "aaaaaaaaaaam" + /* 5 */ "aaaaaaaaaaam" + /* 6 */ "maaaaaaaaaam" + /* 7 */ "maaaaaaaaaam" + /* 8 */ "maaaaaaaaaam" + /* 9 */ "mmmmmmmmmmmm" // Level 1 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ ".d....ddddd." - /* 2 */ "......dfffd." - /* 3 */ "......ghfhd." - /* 4 */ "......diiid." - /* 5 */ ".d....dhfhd." - /* 6 */ ".djddjdfffd." - /* 7 */ ".ddkkddl..d." - /* 8 */ ".dddddddddd." + /* 0 */ "bcccccd....." + /* 1 */ "baaaaaaaaaa." + /* 2 */ "baaaaaaaaaa." + /* 3 */ "baaaaaaaaaa." + /* 4 */ "baaaaaaaaaa." + /* 5 */ "eaaaaaaaaaa." + /* 6 */ ".aaaaaaaaaa." + /* 7 */ ".aaaaaaaaaa." + /* 8 */ ".aaaaaaaaaa." /* 9 */ "............" // Level 2 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" + /* 1 */ ".a....aaaaa." + /* 2 */ "......afffa." + /* 3 */ "......ghfha." + /* 4 */ "......aiiia." + /* 5 */ ".a....ahfha." + /* 6 */ ".ajaajafffa." + /* 7 */ ".aakkaal..a." + /* 8 */ ".aaaaaaaaaa." + /* 9 */ "............" + + // Level 3 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" /* 1 */ ".n....nn.nn." /* 2 */ "......n...n." /* 3 */ "......o...n." @@ -93,36 +107,36 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 8 */ ".nnn.nnn.nn." /* 9 */ "............" - // Level 3 + // Level 4 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" - /* 1 */ ".d....ddddd." - /* 2 */ "......d...d." - /* 3 */ "......d...d." - /* 4 */ "......dp..d." - /* 5 */ ".d....d...d." - /* 6 */ ".dqqqqd...d." - /* 7 */ ".d....d...d." - /* 8 */ ".dddddddddd." + /* 1 */ ".a....aaaaa." + /* 2 */ "......a...a." + /* 3 */ "......a...a." + /* 4 */ "......ap..a." + /* 5 */ ".a....a...a." + /* 6 */ ".aqqqqa...a." + /* 7 */ ".a....a...a." + /* 8 */ ".aaaaaaaaaa." /* 9 */ "............" - // Level 4 + // Level 5 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "rsssssssssss" - /* 1 */ "rddddddddddt" - /* 2 */ "rddddddddddt" - /* 3 */ "rddddddddddt" - /* 4 */ "rddddddddddt" - /* 5 */ "rddddddddddt" - /* 6 */ "rddddddddddt" - /* 7 */ "rddddddddddt" - /* 8 */ "rddddddddddt" + /* 1 */ "raaaaaaaaaat" + /* 2 */ "raaaaaaaaaat" + /* 3 */ "raaaaaaaaaat" + /* 4 */ "raaaaaaaaaat" + /* 5 */ "raaaaaaaaaat" + /* 6 */ "raaaaaaaaaat" + /* 7 */ "raaaaaaaaaat" + /* 8 */ "raaaaaaaaaat" /* 9 */ "uuuuuuuuuuut", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -153,18 +167,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 31, ID 172, created by Aloe_vera { // Size: - 13, 5, 9, // SizeX = 13, SizeY = 5, SizeZ = 9 + 13, 6, 9, // SizeX = 13, SizeY = 6, SizeZ = 9 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 12, 4, 8, // MaxX, MaxY, MaxZ + 12, 5, 8, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171: 0\n" /* carpet */ "g:171:15\n" /* carpet */ @@ -185,33 +199,46 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Level 0 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ "..abc........" - /* 1 */ ".ddddddddddd." - /* 2 */ ".ddddddddddd." - /* 3 */ ".ddddddddddd." - /* 4 */ ".ddddddddddd." - /* 5 */ ".ddddddddddd." - /* 6 */ ".ddddddddddd." - /* 7 */ ".ddddddddddd." - /* 8 */ "............." + /* 0 */ "mmaaammmmmmmm" + /* 1 */ "maaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaam" + /* 6 */ "maaaaaaaaaaam" + /* 7 */ "maaaaaaaaaaam" + /* 8 */ "mmmmmmmmmmmmm" // Level 1 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ "............." - /* 1 */ ".ddedddddddd." - /* 2 */ ".dffgggggffd." - /* 3 */ ".dfghhhhhgfd." - /* 4 */ ".dfghfffhgfd." - /* 5 */ ".dfghhhhhgfd." - /* 6 */ ".dffgggggffd." - /* 7 */ ".ddddddddddd." + /* 0 */ "..bcd........" + /* 1 */ ".aaaaaaaaaaa." + /* 2 */ ".aaaaaaaaaaa." + /* 3 */ ".aaaaaaaaaaa." + /* 4 */ ".aaaaaaaaaaa." + /* 5 */ ".aaaaaaaaaaa." + /* 6 */ ".aaaaaaaaaaa." + /* 7 */ ".aaaaaaaaaaa." /* 8 */ "............." // Level 2 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." + /* 1 */ ".aaeaaaaaaaa." + /* 2 */ ".affgggggffa." + /* 3 */ ".afghhhhhgfa." + /* 4 */ ".afghfffhgfa." + /* 5 */ ".afghhhhhgfa." + /* 6 */ ".affgggggffa." + /* 7 */ ".aaaaaaaaaaa." + /* 8 */ "............." + + // Level 3 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." /* 1 */ ".iiji.iii.ii." /* 2 */ ".i.........i." /* 3 */ ".i.........i." @@ -221,34 +248,34 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 7 */ ".ii.ii.ii.ii." /* 8 */ "............." - // Level 3 + // Level 4 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." - /* 1 */ ".ddddddddddd." - /* 2 */ ".d..k..k...d." - /* 3 */ ".d.........d." - /* 4 */ ".dl.......nd." - /* 5 */ ".d.........d." - /* 6 */ ".d....o....d." - /* 7 */ ".ddddddddddd." + /* 1 */ ".aaaaaaaaaaa." + /* 2 */ ".a..k..k...a." + /* 3 */ ".a.........a." + /* 4 */ ".al.......na." + /* 5 */ ".a.........a." + /* 6 */ ".a....o....a." + /* 7 */ ".aaaaaaaaaaa." /* 8 */ "............." - // Level 4 + // Level 5 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "pqqqqqqqqqqqq" - /* 1 */ "pdddddddddddr" - /* 2 */ "pdddddddddddr" - /* 3 */ "pdddddddddddr" - /* 4 */ "pdddddddddddr" - /* 5 */ "pdddddddddddr" - /* 6 */ "pdddddddddddr" - /* 7 */ "pdddddddddddr" + /* 1 */ "paaaaaaaaaaar" + /* 2 */ "paaaaaaaaaaar" + /* 3 */ "paaaaaaaaaaar" + /* 4 */ "paaaaaaaaaaar" + /* 5 */ "paaaaaaaaaaar" + /* 6 */ "paaaaaaaaaaar" + /* 7 */ "paaaaaaaaaaar" /* 8 */ "ssssssssssssr", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -279,18 +306,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 25, ID 166, created by Aloe_vera { // Size: - 7, 5, 6, // SizeX = 7, SizeY = 5, SizeZ = 6 + 7, 6, 6, // SizeX = 7, SizeY = 6, SizeZ = 6 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 6, 4, 5, // MaxX, MaxY, MaxZ + 6, 5, 5, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171: 0\n" /* carpet */ "g:171:14\n" /* carpet */ @@ -306,51 +333,60 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Block data: // Level 0 /* z\x* 0123456 */ - /* 0 */ "..abc.." - /* 1 */ ".ddddd." - /* 2 */ ".ddddd." - /* 3 */ ".ddddd." - /* 4 */ ".ddddd." - /* 5 */ "......." + /* 0 */ "mmaaamm" + /* 1 */ "maaaaam" + /* 2 */ "maaaaam" + /* 3 */ "maaaaam" + /* 4 */ "maaaaam" + /* 5 */ "mmmmmmm" // Level 1 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".ddedd." - /* 2 */ ".dfgfd." - /* 3 */ ".dfgfd." - /* 4 */ ".ddddd." + /* 0 */ "..bcd.." + /* 1 */ ".aaaaa." + /* 2 */ ".aaaaa." + /* 3 */ ".aaaaa." + /* 4 */ ".aaaaa." /* 5 */ "......." // Level 2 /* z\x* 0123456 */ /* 0 */ "......." + /* 1 */ ".aaeaa." + /* 2 */ ".afgfa." + /* 3 */ ".afgfa." + /* 4 */ ".aaaaa." + /* 5 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "......." /* 1 */ ".hhihh." /* 2 */ ".h...h." /* 3 */ ".h...h." /* 4 */ ".hh.hh." /* 5 */ "......." - // Level 3 + // Level 4 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".ddddd." - /* 2 */ ".dj.jd." - /* 3 */ ".d...d." - /* 4 */ ".ddddd." + /* 1 */ ".aaaaa." + /* 2 */ ".aj.ja." + /* 3 */ ".a...a." + /* 4 */ ".aaaaa." /* 5 */ "......." - // Level 4 + // Level 5 /* z\x* 0123456 */ /* 0 */ "kllllln" - /* 1 */ "kdddddn" - /* 2 */ "kdddddn" - /* 3 */ "kdddddn" - /* 4 */ "kdddddn" + /* 1 */ "kaaaaan" + /* 2 */ "kaaaaan" + /* 3 */ "kaaaaan" + /* 4 */ "kaaaaan" /* 5 */ "oooooon", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -381,18 +417,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 26, ID 167, created by Aloe_vera { // Size: - 7, 5, 7, // SizeX = 7, SizeY = 5, SizeZ = 7 + 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 6, 4, 6, // MaxX, MaxY, MaxZ + 6, 5, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171: 0\n" /* carpet */ "g:171:15\n" /* carpet */ @@ -409,27 +445,37 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Block data: // Level 0 /* z\x* 0123456 */ - /* 0 */ "..abc.." - /* 1 */ ".ddddd." - /* 2 */ ".ddddd." - /* 3 */ ".ddddd." - /* 4 */ ".ddddd." - /* 5 */ ".ddddd." - /* 6 */ "......." + /* 0 */ "mmaaamm" + /* 1 */ "maaaaam" + /* 2 */ "maaaaam" + /* 3 */ "maaaaam" + /* 4 */ "maaaaam" + /* 5 */ "maaaaam" + /* 6 */ "mmmmmmm" // Level 1 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".ddedd." - /* 2 */ ".dfffd." - /* 3 */ ".dghgd." - /* 4 */ ".dfffd." - /* 5 */ ".ddddd." + /* 0 */ "..bcd.." + /* 1 */ ".aaaaa." + /* 2 */ ".aaaaa." + /* 3 */ ".aaaaa." + /* 4 */ ".aaaaa." + /* 5 */ ".aaaaa." /* 6 */ "......." // Level 2 /* z\x* 0123456 */ /* 0 */ "......." + /* 1 */ ".aaeaa." + /* 2 */ ".afffa." + /* 3 */ ".aghga." + /* 4 */ ".afffa." + /* 5 */ ".aaaaa." + /* 6 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "......." /* 1 */ ".iijii." /* 2 */ ".i...i." /* 3 */ "......." @@ -437,28 +483,28 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 5 */ ".ii.ii." /* 6 */ "......." - // Level 3 + // Level 4 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".ddddd." - /* 2 */ ".dk.kd." - /* 3 */ ".d...d." - /* 4 */ ".d...d." - /* 5 */ ".ddddd." + /* 1 */ ".aaaaa." + /* 2 */ ".ak.ka." + /* 3 */ ".a...a." + /* 4 */ ".a...a." + /* 5 */ ".aaaaa." /* 6 */ "......." - // Level 4 + // Level 5 /* z\x* 0123456 */ /* 0 */ "lnnnnno" - /* 1 */ "ldddddo" - /* 2 */ "ldddddo" - /* 3 */ "ldddddo" - /* 4 */ "ldddddo" - /* 5 */ "ldddddo" + /* 1 */ "laaaaao" + /* 2 */ "laaaaao" + /* 3 */ "laaaaao" + /* 4 */ "laaaaao" + /* 5 */ "laaaaao" /* 6 */ "ppppppo", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -489,18 +535,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 27, ID 168, created by Aloe_vera { // Size: - 9, 5, 7, // SizeX = 9, SizeY = 5, SizeZ = 7 + 9, 6, 7, // SizeX = 9, SizeY = 6, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 8, 4, 6, // MaxX, MaxY, MaxZ + 8, 5, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171:14\n" /* carpet */ "g:171: 0\n" /* carpet */ @@ -517,27 +563,37 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Block data: // Level 0 /* z\x* 012345678 */ - /* 0 */ "..abc...." - /* 1 */ ".ddddddd." - /* 2 */ ".ddddddd." - /* 3 */ ".ddddddd." - /* 4 */ ".ddddddd." - /* 5 */ ".ddddddd." - /* 6 */ "........." + /* 0 */ "mmaaammmm" + /* 1 */ "maaaaaaam" + /* 2 */ "maaaaaaam" + /* 3 */ "maaaaaaam" + /* 4 */ "maaaaaaam" + /* 5 */ "maaaaaaam" + /* 6 */ "mmmmmmmmm" // Level 1 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ ".ddedddd." - /* 2 */ ".dfffffd." - /* 3 */ ".dghhhgd." - /* 4 */ ".dfffffd." - /* 5 */ ".ddddddd." + /* 0 */ "..bcd...." + /* 1 */ ".aaaaaaa." + /* 2 */ ".aaaaaaa." + /* 3 */ ".aaaaaaa." + /* 4 */ ".aaaaaaa." + /* 5 */ ".aaaaaaa." /* 6 */ "........." // Level 2 /* z\x* 012345678 */ /* 0 */ "........." + /* 1 */ ".aaeaaaa." + /* 2 */ ".afffffa." + /* 3 */ ".aghhhga." + /* 4 */ ".afffffa." + /* 5 */ ".aaaaaaa." + /* 6 */ "........." + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "........." /* 1 */ ".iiji.ii." /* 2 */ ".i.....i." /* 3 */ "........." @@ -545,28 +601,28 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 5 */ ".iii.iii." /* 6 */ "........." - // Level 3 + // Level 4 /* z\x* 012345678 */ /* 0 */ "........." - /* 1 */ ".ddddddd." - /* 2 */ ".dk.k..d." - /* 3 */ ".d.....d." - /* 4 */ ".d.....d." - /* 5 */ ".ddddddd." + /* 1 */ ".aaaaaaa." + /* 2 */ ".ak.k..a." + /* 3 */ ".a.....a." + /* 4 */ ".a.....a." + /* 5 */ ".aaaaaaa." /* 6 */ "........." - // Level 4 + // Level 5 /* z\x* 012345678 */ /* 0 */ "lnnnnnnnn" - /* 1 */ "ldddddddo" - /* 2 */ "ldddddddo" - /* 3 */ "ldddddddo" - /* 4 */ "ldddddddo" - /* 5 */ "ldddddddo" + /* 1 */ "laaaaaaao" + /* 2 */ "laaaaaaao" + /* 3 */ "laaaaaaao" + /* 4 */ "laaaaaaao" + /* 5 */ "laaaaaaao" /* 6 */ "ppppppppo", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -597,18 +653,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 28, ID 169, created by Aloe_vera { // Size: - 10, 5, 7, // SizeX = 10, SizeY = 5, SizeZ = 7 + 10, 6, 7, // SizeX = 10, SizeY = 6, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 9, 4, 6, // MaxX, MaxY, MaxZ + 9, 5, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171: 0\n" /* carpet */ "g:171:14\n" /* carpet */ @@ -626,29 +682,40 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Level 0 /* z\x* */ /* * 0123456789 */ - /* 0 */ "..abc....." - /* 1 */ ".dddddddd." - /* 2 */ ".dddddddd." - /* 3 */ ".dddddddd." - /* 4 */ ".dddddddd." - /* 5 */ ".dddddddd." - /* 6 */ ".........." + /* 0 */ "mmaaammmmm" + /* 1 */ "maaaaaaaam" + /* 2 */ "maaaaaaaam" + /* 3 */ "maaaaaaaam" + /* 4 */ "maaaaaaaam" + /* 5 */ "maaaaaaaam" + /* 6 */ "mmmmmmmmmm" // Level 1 /* z\x* */ /* * 0123456789 */ - /* 0 */ ".........." - /* 1 */ ".ddeddddd." - /* 2 */ ".dfghhgfd." - /* 3 */ ".dfhffhfd." - /* 4 */ ".dfghhgfd." - /* 5 */ ".dddddddd." + /* 0 */ "..bcd....." + /* 1 */ ".aaaaaaaa." + /* 2 */ ".aaaaaaaa." + /* 3 */ ".aaaaaaaa." + /* 4 */ ".aaaaaaaa." + /* 5 */ ".aaaaaaaa." /* 6 */ ".........." // Level 2 /* z\x* */ /* * 0123456789 */ /* 0 */ ".........." + /* 1 */ ".aaeaaaaa." + /* 2 */ ".afghhgfa." + /* 3 */ ".afhffhfa." + /* 4 */ ".afghhgfa." + /* 5 */ ".aaaaaaaa." + /* 6 */ ".........." + + // Level 3 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." /* 1 */ ".iijii.ii." /* 2 */ ".i......i." /* 3 */ ".........." @@ -656,30 +723,30 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 5 */ ".ii.ii.ii." /* 6 */ ".........." - // Level 3 + // Level 4 /* z\x* */ /* * 0123456789 */ /* 0 */ ".........." - /* 1 */ ".dddddddd." - /* 2 */ ".dk.k...d." - /* 3 */ ".d......d." - /* 4 */ ".d......d." - /* 5 */ ".dddddddd." + /* 1 */ ".aaaaaaaa." + /* 2 */ ".ak.k...a." + /* 3 */ ".a......a." + /* 4 */ ".a......a." + /* 5 */ ".aaaaaaaa." /* 6 */ ".........." - // Level 4 + // Level 5 /* z\x* */ /* * 0123456789 */ /* 0 */ "lnnnnnnnnn" - /* 1 */ "lddddddddo" - /* 2 */ "lddddddddo" - /* 3 */ "lddddddddo" - /* 4 */ "lddddddddo" - /* 5 */ "lddddddddo" + /* 1 */ "laaaaaaaao" + /* 2 */ "laaaaaaaao" + /* 3 */ "laaaaaaaao" + /* 4 */ "laaaaaaaao" + /* 5 */ "laaaaaaaao" /* 6 */ "pppppppppo", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -710,18 +777,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 29, ID 170, created by Aloe_vera { // Size: - 10, 5, 9, // SizeX = 10, SizeY = 5, SizeZ = 9 + 10, 6, 9, // SizeX = 10, SizeY = 6, SizeZ = 9 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 9, 4, 8, // MaxX, MaxY, MaxZ + 9, 5, 8, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171: 0\n" /* carpet */ "g:171:14\n" /* carpet */ @@ -741,33 +808,46 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Level 0 /* z\x* */ /* * 0123456789 */ - /* 0 */ "..abc....." - /* 1 */ ".dddddddd." - /* 2 */ ".dddddddd." - /* 3 */ ".dddddddd." - /* 4 */ ".dddddddd." - /* 5 */ ".dddddddd." - /* 6 */ ".dddddddd." - /* 7 */ ".dddddddd." - /* 8 */ ".........." + /* 0 */ "mmaaammmmm" + /* 1 */ "maaaaaaaam" + /* 2 */ "maaaaaaaam" + /* 3 */ "maaaaaaaam" + /* 4 */ "maaaaaaaam" + /* 5 */ "maaaaaaaam" + /* 6 */ "maaaaaaaam" + /* 7 */ "maaaaaaaam" + /* 8 */ "mmmmmmmmmm" // Level 1 /* z\x* */ /* * 0123456789 */ - /* 0 */ ".........." - /* 1 */ ".ddeddddd." - /* 2 */ ".dfghhgfd." - /* 3 */ ".dfhffhfd." - /* 4 */ ".dfhgghfd." - /* 5 */ ".dfhffhfd." - /* 6 */ ".dfghhgfd." - /* 7 */ ".dddddddd." + /* 0 */ "..bcd....." + /* 1 */ ".aaaaaaaa." + /* 2 */ ".aaaaaaaa." + /* 3 */ ".aaaaaaaa." + /* 4 */ ".aaaaaaaa." + /* 5 */ ".aaaaaaaa." + /* 6 */ ".aaaaaaaa." + /* 7 */ ".aaaaaaaa." /* 8 */ ".........." // Level 2 /* z\x* */ /* * 0123456789 */ /* 0 */ ".........." + /* 1 */ ".aaeaaaaa." + /* 2 */ ".afghhgfa." + /* 3 */ ".afhffhfa." + /* 4 */ ".afhgghfa." + /* 5 */ ".afhffhfa." + /* 6 */ ".afghhgfa." + /* 7 */ ".aaaaaaaa." + /* 8 */ ".........." + + // Level 3 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." /* 1 */ ".iijii.ii." /* 2 */ ".i......i." /* 3 */ ".i......i." @@ -777,34 +857,34 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 7 */ ".ii.ii.ii." /* 8 */ ".........." - // Level 3 + // Level 4 /* z\x* */ /* * 0123456789 */ /* 0 */ ".........." - /* 1 */ ".dddddddd." - /* 2 */ ".d..k...d." - /* 3 */ ".d......d." - /* 4 */ ".dl....nd." - /* 5 */ ".d......d." - /* 6 */ ".d......d." - /* 7 */ ".dddddddd." + /* 1 */ ".aaaaaaaa." + /* 2 */ ".a..k...a." + /* 3 */ ".a......a." + /* 4 */ ".al....na." + /* 5 */ ".a......a." + /* 6 */ ".a......a." + /* 7 */ ".aaaaaaaa." /* 8 */ ".........." - // Level 4 + // Level 5 /* z\x* */ /* * 0123456789 */ /* 0 */ "oppppppppp" - /* 1 */ "oddddddddq" - /* 2 */ "oddddddddq" - /* 3 */ "oddddddddq" - /* 4 */ "oddddddddq" - /* 5 */ "oddddddddq" - /* 6 */ "oddddddddq" - /* 7 */ "oddddddddq" + /* 1 */ "oaaaaaaaaq" + /* 2 */ "oaaaaaaaaq" + /* 3 */ "oaaaaaaaaq" + /* 4 */ "oaaaaaaaaq" + /* 5 */ "oaaaaaaaaq" + /* 6 */ "oaaaaaaaaq" + /* 7 */ "oaaaaaaaaq" /* 8 */ "rrrrrrrrrq", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -835,18 +915,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 30, ID 171, created by Aloe_vera { // Size: - 11, 5, 9, // SizeX = 11, SizeY = 5, SizeZ = 9 + 11, 6, 9, // SizeX = 11, SizeY = 6, SizeZ = 9 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 10, 4, 8, // MaxX, MaxY, MaxZ + 10, 5, 8, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171: 0\n" /* carpet */ "g:171:15\n" /* carpet */ @@ -867,33 +947,46 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..abc......" - /* 1 */ ".ddddddddd." - /* 2 */ ".ddddddddd." - /* 3 */ ".ddddddddd." - /* 4 */ ".ddddddddd." - /* 5 */ ".ddddddddd." - /* 6 */ ".ddddddddd." - /* 7 */ ".ddddddddd." - /* 8 */ "..........." + /* 0 */ "mmaaammmmmm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "maaaaaaaaam" + /* 3 */ "maaaaaaaaam" + /* 4 */ "maaaaaaaaam" + /* 5 */ "maaaaaaaaam" + /* 6 */ "maaaaaaaaam" + /* 7 */ "maaaaaaaaam" + /* 8 */ "mmmmmmmmmmm" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".ddedddddd." - /* 2 */ ".dffgggffd." - /* 3 */ ".dfghhhgfd." - /* 4 */ ".dfghfhgfd." - /* 5 */ ".dfghhhgfd." - /* 6 */ ".dffgggffd." - /* 7 */ ".ddddddddd." + /* 0 */ "..bcd......" + /* 1 */ ".aaaaaaaaa." + /* 2 */ ".aaaaaaaaa." + /* 3 */ ".aaaaaaaaa." + /* 4 */ ".aaaaaaaaa." + /* 5 */ ".aaaaaaaaa." + /* 6 */ ".aaaaaaaaa." + /* 7 */ ".aaaaaaaaa." /* 8 */ "..........." // Level 2 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." + /* 1 */ ".aaeaaaaaa." + /* 2 */ ".affgggffa." + /* 3 */ ".afghhhgfa." + /* 4 */ ".afghfhgfa." + /* 5 */ ".afghhhgfa." + /* 6 */ ".affgggffa." + /* 7 */ ".aaaaaaaaa." + /* 8 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." /* 1 */ ".iijii.iii." /* 2 */ ".i.......i." /* 3 */ ".i.......i." @@ -903,34 +996,34 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 7 */ ".ii.iii.ii." /* 8 */ "..........." - // Level 3 + // Level 4 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ ".ddddddddd." - /* 2 */ ".d..k....d." - /* 3 */ ".d.......d." - /* 4 */ ".dl.....nd." - /* 5 */ ".d.......d." - /* 6 */ ".d...o...d." - /* 7 */ ".ddddddddd." + /* 1 */ ".aaaaaaaaa." + /* 2 */ ".a..k....a." + /* 3 */ ".a.......a." + /* 4 */ ".al.....na." + /* 5 */ ".a.......a." + /* 6 */ ".a...o...a." + /* 7 */ ".aaaaaaaaa." /* 8 */ "..........." - // Level 4 + // Level 5 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "pqqqqqqqqqq" - /* 1 */ "pdddddddddr" - /* 2 */ "pdddddddddr" - /* 3 */ "pdddddddddr" - /* 4 */ "pdddddddddr" - /* 5 */ "pdddddddddr" - /* 6 */ "pdddddddddr" - /* 7 */ "pdddddddddr" + /* 1 */ "paaaaaaaaar" + /* 2 */ "paaaaaaaaar" + /* 3 */ "paaaaaaaaar" + /* 4 */ "paaaaaaaaar" + /* 5 */ "paaaaaaaaar" + /* 6 */ "paaaaaaaaar" + /* 7 */ "paaaaaaaaar" /* 8 */ "ssssssssssr", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ -- cgit v1.2.3 From 6b503b45a06429513cca2bf69d2835853b906337 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 16 Jun 2014 14:53:33 +0200 Subject: Fixed a copypasta error in WormNestCaves generator settings. --- src/Generating/ComposableGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index f332b4d78..22941dcbe 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -449,7 +449,7 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) { int Size = a_IniFile.GetValueSetI("Generator", "WormNestCavesSize", 64); int Grid = a_IniFile.GetValueSetI("Generator", "WormNestCavesGrid", 96); - int MaxOffset = a_IniFile.GetValueSetI("Generator", "NetherFortMaxOffset", 32); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "WormNestMaxOffset", 32); m_FinishGens.push_back(new cStructGenWormNestCaves(Seed, Size, Grid, MaxOffset)); } else -- cgit v1.2.3 From 84c83e0deb8c46be5bd4a25ef00515d48cf296a9 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 16 Jun 2014 15:03:07 +0100 Subject: Fix a few warnings --- src/Blocks/BlockDoor.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index bc59051c3..049c4a334 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -156,10 +156,10 @@ public: if (a_BlockX > 0) { NIBBLETYPE DownMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ); - return (DownMeta & 0x07) | 0x08 | (Meta << 4); + return (NIBBLETYPE) ((DownMeta & 0x07) | 0x08 | (Meta << 4)); } // This is the top part of the door at the bottommost layer of the world, there's no bottom: - return 0x08 | (Meta << 4); + return (NIBBLETYPE) (0x08 | (Meta << 4)); } else { @@ -167,7 +167,7 @@ public: if (a_BlockY < cChunkDef::Height - 1) { NIBBLETYPE UpMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY + 1, a_BlockZ); - return Meta | (UpMeta << 4); + return (NIBBLETYPE) (Meta | (UpMeta << 4)); } // This is the bottom part of the door at the topmost layer of the world, there's no top: return Meta; -- cgit v1.2.3 From aa3537112d5c69b676f2e0f594bba716487b401d Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 16 Jun 2014 15:07:41 +0100 Subject: Moved repeater handling to seperate pass --- src/Simulator/IncrementalRedstoneSimulator.cpp | 157 ++++++++++--------------- src/Simulator/IncrementalRedstoneSimulator.h | 4 +- 2 files changed, 64 insertions(+), 97 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index f20f396f2..61258cd45 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -1,6 +1,8 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules +#include + #include "IncrementalRedstoneSimulator.h" #include "../BlockEntities/DropSpenserEntity.h" #include "../BlockEntities/NoteEntity.h" @@ -253,6 +255,8 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int ShouldUpdateSimulateOnceBlocks = true; } + HandleRedstoneRepeaterDelays(); + for (cRedstoneSimulatorChunkData::iterator dataitr = m_RedstoneSimulatorChunkData->begin(); dataitr != m_RedstoneSimulatorChunkData->end();) { if (dataitr->DataTwo) @@ -264,26 +268,6 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int switch (dataitr->Data) { case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(dataitr->x, dataitr->y, dataitr->z); break; - - case E_BLOCK_REDSTONE_REPEATER_OFF: - case E_BLOCK_REDSTONE_REPEATER_ON: - { - bool FoundItem = false; - for (RepeatersDelayList::iterator repeateritr = m_RepeatersDelayList->begin(); repeateritr != m_RepeatersDelayList->end(); ++repeateritr) - { - if (repeateritr->a_RelBlockPos == Vector3i(dataitr->x, dataitr->y, dataitr->z)) - { - HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data, repeateritr); - FoundItem = true; - break; - } - } - if (!FoundItem && ShouldUpdateSimulateOnceBlocks) - { - HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data, m_RepeatersDelayList->end()); - } - break; - } case E_BLOCK_WOODEN_PRESSURE_PLATE: case E_BLOCK_STONE_PRESSURE_PLATE: case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: @@ -339,6 +323,11 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int HandlePiston(dataitr->x, dataitr->y, dataitr->z); break; } + case E_BLOCK_REDSTONE_REPEATER_OFF: + case E_BLOCK_REDSTONE_REPEATER_ON: + { + HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + } case E_BLOCK_REDSTONE_TORCH_OFF: case E_BLOCK_REDSTONE_TORCH_ON: { @@ -493,7 +482,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneLever(int a_RelBlockX, int a_R { SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); - NIBBLETYPE Dir = cBlockLeverHandler::BlockMetaDataToBlockFace(Meta); + eBlockFace Dir = cBlockLeverHandler::BlockMetaDataToBlockFace(Meta); switch (Dir) // Now, flip the direction into the type used by SetBlockLinkedPowered() { case BLOCK_FACE_YP: @@ -562,7 +551,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneButton(int a_RelBlockX, int a_ { SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); - NIBBLETYPE Dir = cBlockButtonHandler::BlockMetaDataToBlockFace(Meta); + eBlockFace Dir = cBlockButtonHandler::BlockMetaDataToBlockFace(Meta); switch (Dir) // Now, flip the direction into the type used by SetBlockLinkedPowered() { case BLOCK_FACE_XP: @@ -749,7 +738,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re -void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState, RepeatersDelayList::iterator a_Itr) +void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState) { /* Repeater Orientation Mini Guide: =================================== @@ -776,102 +765,78 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int NIBBLETYPE a_Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); bool IsOn = (a_MyState == E_BLOCK_REDSTONE_REPEATER_ON); - bool WereItrsChanged = false; if (!IsRepeaterLocked(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta)) // If we're locked, change nothing. Otherwise: { bool IsSelfPowered = IsRepeaterPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta); if (IsSelfPowered && !IsOn) // Queue a power change if powered, but not on and not locked. { - WereItrsChanged = QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, true); + QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, true); } else if (!IsSelfPowered && IsOn) // Queue a power change if unpowered, on, and not locked. { - WereItrsChanged = QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false); - } - else if (a_Itr != m_RepeatersDelayList->end()) - { - return; - } - } - else if (a_Itr != m_RepeatersDelayList->end()) - { - return; - } - - if (WereItrsChanged) - { - for (a_Itr = m_RepeatersDelayList->begin(); a_Itr != m_RepeatersDelayList->end(); ++a_Itr) - { - if (a_Itr->a_RelBlockPos == Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) - { - // Leave a_Itr at where we found the entry - break; - } + QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false); } } +} - // a_Itr may be passed with m_RepeatersDelayList::end, however, we can guarantee this iterator is always valid because... - // ...QueueRepeaterPowerChange is called to add an entry (and the above code updates iterator). However, if the repeater was locked or something similar... - // ...we will never get here because of the returns. - if (a_Itr->a_ElapsedTicks >= a_Itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks? +void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() +{ + for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end(); itr++) { - if (a_Itr->ShouldPowerOn) + if (itr->a_ElapsedTicks >= itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks? { - if (!IsOn) + int RelBlockX = itr->a_RelBlockPos.x; + int RelBlockY = itr->a_RelBlockPos.y; + int RelBlockZ = itr->a_RelBlockPos.z; + NIBBLETYPE Meta = m_Chunk->GetMeta(RelBlockX, RelBlockY, RelBlockZ); + if (itr->ShouldPowerOn) { - m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_REPEATER_ON, a_Meta); // For performance - } + + m_Chunk->SetBlock(itr->a_RelBlockPos, E_BLOCK_REDSTONE_REPEATER_ON, Meta); // For performance - switch (a_Meta & 0x3) // We only want the direction (bottom) bits - { - case 0x0: + switch (Meta & 0x3) // We only want the direction (bottom) bits { - SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM); - break; - } - case 0x1: - { - SetBlockPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP); - break; - } - case 0x2: - { - SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP); - break; - } - case 0x3: - { - SetBlockPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM); - break; + case 0x0: + { + SetBlockPowered(RelBlockX, RelBlockY, RelBlockZ - 1, RelBlockX, RelBlockY, RelBlockZ); + SetDirectionLinkedPowered(RelBlockX, RelBlockY, RelBlockZ, BLOCK_FACE_ZM); + break; + } + case 0x1: + { + SetBlockPowered(RelBlockX + 1, RelBlockY, RelBlockZ, RelBlockX, RelBlockY, RelBlockZ); + SetDirectionLinkedPowered(RelBlockX, RelBlockY, RelBlockZ, BLOCK_FACE_XP); + break; + } + case 0x2: + { + SetBlockPowered(RelBlockX, RelBlockY, RelBlockZ + 1, RelBlockX, RelBlockY, RelBlockZ); + SetDirectionLinkedPowered(RelBlockX, RelBlockY, RelBlockZ, BLOCK_FACE_ZP); + break; + } + case 0x3: + { + SetBlockPowered(RelBlockX - 1, RelBlockY, RelBlockZ, RelBlockX, RelBlockY, RelBlockZ); + SetDirectionLinkedPowered(RelBlockX, RelBlockY, RelBlockZ, BLOCK_FACE_XM); + break; + } } } - - // Removal of the data entry will be handled in SimChunk - we still want to continue trying to power blocks, even if our delay time has reached - // Otherwise, the power state of blocks in front won't update after we have powered on - return; + else + { + m_Chunk->SetBlock(RelBlockX, RelBlockY, RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, Meta); + } + m_RepeatersDelayList->erase(itr); } else { - if (IsOn) - { - m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta); - } - m_RepeatersDelayList->erase(a_Itr); // We can remove off repeaters which don't need further updating - return; + // Apparently, incrementing ticks only works reliably here, and not in SimChunk; + // With a world with lots of redstone, the repeaters simply do not delay + // I am confounded to say why. Perhaps optimisation failure. + LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", itr->a_RelBlockPos.x, itr->a_RelBlockPos.y, itr->a_RelBlockPos.z, itr->a_ElapsedTicks, itr->a_DelayTicks); + itr->a_ElapsedTicks++; } } - else - { - // Apparently, incrementing ticks only works reliably here, and not in SimChunk; - // With a world with lots of redstone, the repeaters simply do not delay - // I am confounded to say why. Perhaps optimisation failure. - LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", a_Itr->a_RelBlockPos.x, a_Itr->a_RelBlockPos.y, a_Itr->a_RelBlockPos.z, a_Itr->a_ElapsedTicks, a_Itr->a_DelayTicks); - a_Itr->a_ElapsedTicks++; - } } diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index 1d6a49aca..9c1f9460c 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -108,7 +108,9 @@ private: /** Handles redstone wire */ void HandleRedstoneWire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles repeaters */ - void HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState, RepeatersDelayList::iterator a_Itr); + void HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState); + /** Handles delayed updates to Repeaters **/ + void HandleRedstoneRepeaterDelays(); /* ====================== */ /* ====== DEVICES ====== */ -- cgit v1.2.3 From ee50790398791c38e563eee04cf12780fab74baf Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 16 Jun 2014 15:12:50 +0100 Subject: Merge branch 'master' of github.com:mc-server/MCServer --- src/AllocationPool.h | 109 ++++ src/Chunk.cpp | 4 +- src/Chunk.h | 3 +- src/ChunkData.cpp | 25 +- src/ChunkData.h | 54 +- src/ChunkMap.cpp | 20 +- src/ChunkMap.h | 27 +- src/Entities/Entity.cpp | 38 +- src/Entities/Entity.h | 35 +- src/Entities/Player.cpp | 30 +- src/Entities/Player.h | 11 +- src/Generating/Caves.cpp | 10 +- src/Generating/Caves.h | 4 +- src/Generating/ComposableGenerator.cpp | 36 +- src/Generating/GridStructGen.cpp | 31 +- src/Generating/GridStructGen.h | 33 +- src/Generating/MineShafts.cpp | 16 +- src/Generating/MineShafts.h | 4 +- src/Generating/NetherFortGen.cpp | 15 +- src/Generating/NetherFortGen.h | 4 +- .../Prefabs/SandFlatRoofVillagePrefabs.cpp | 669 ++++++++++++--------- src/Generating/RainbowRoadsGen.cpp | 11 +- src/Generating/RainbowRoadsGen.h | 4 +- src/Generating/Ravines.cpp | 12 +- src/Generating/Ravines.h | 2 +- src/Generating/UnderwaterBaseGen.cpp | 11 +- src/Generating/UnderwaterBaseGen.h | 4 +- src/Generating/VillageGen.cpp | 11 +- src/Generating/VillageGen.h | 4 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 38 +- 30 files changed, 820 insertions(+), 455 deletions(-) create mode 100644 src/AllocationPool.h (limited to 'src') diff --git a/src/AllocationPool.h b/src/AllocationPool.h new file mode 100644 index 000000000..5d749a79e --- /dev/null +++ b/src/AllocationPool.h @@ -0,0 +1,109 @@ + +#pragma once + +#include + +template +class cAllocationPool +{ +public: + class cStarvationCallbacks + { + public: + virtual ~cStarvationCallbacks() {} + + /** Is called when the reserve buffer starts to be used **/ + virtual void OnStartUsingReserve() = 0; + + /** Is called once the reserve buffer has returned to normal size **/ + virtual void OnEndUsingReserve() = 0; + + /** Is called when the allocation pool is unable to allocate memory. Will be repeatedly + called if it does not free sufficient memory **/ + virtual void OnOutOfReserve() = 0; + }; + + virtual ~cAllocationPool() {} + + /** Allocates a pointer to T **/ + virtual T * Allocate() = 0; + + /** Frees the pointer passed in a_ptr, invalidating it **/ + virtual void Free(T * a_ptr) = 0; +}; + +/** Allocates memory storing unused elements in a linked list. Keeps at least NumElementsInReserve +elements in the list unless malloc fails so that the program has a reserve to handle OOM.**/ +template +class cListAllocationPool : public cAllocationPool +{ + public: + + cListAllocationPool(std::auto_ptr::cStarvationCallbacks> a_Callbacks) : + m_Callbacks(a_Callbacks) + { + for (size_t i = 0; i < NumElementsInReserve; i++) + { + void * space = malloc(sizeof(T)); + if (space == NULL) + { + m_Callbacks->OnStartUsingReserve(); + break; + } + m_FreeList.push_front(space); + } + } + + virtual ~cListAllocationPool() + { + while (!m_FreeList.empty()) + { + free (m_FreeList.front()); + m_FreeList.pop_front(); + } + } + + virtual T * Allocate() override + { + if (m_FreeList.size() <= NumElementsInReserve) + { + void * space = malloc(sizeof(T)); + if (space != NULL) + { + return new(space) T; + } + else if (m_FreeList.size() == NumElementsInReserve) + { + m_Callbacks->OnStartUsingReserve(); + } + else if (m_FreeList.empty()) + { + m_Callbacks->OnOutOfReserve(); + // Try again until the memory is avalable + return Allocate(); + } + } + // placement new, used to initalize the object + T * ret = new (m_FreeList.front()) T; + m_FreeList.pop_front(); + return ret; + } + virtual void Free(T * a_ptr) override + { + if (a_ptr == NULL) + { + return; + } + // placement destruct. + a_ptr->~T(); + m_FreeList.push_front(a_ptr); + if (m_FreeList.size() == NumElementsInReserve) + { + m_Callbacks->OnEndUsingReserve(); + } + } + + private: + std::list m_FreeList; + std::auto_ptr::cStarvationCallbacks> m_Callbacks; +}; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 44fcefbe1..4703e4536 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -64,7 +64,8 @@ sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_Bloc cChunk::cChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkMap * a_ChunkMap, cWorld * a_World, - cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP + cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP, + cAllocationPool & a_Pool ) : m_IsValid(false), m_IsLightValid(false), @@ -77,6 +78,7 @@ cChunk::cChunk( m_PosZ(a_ChunkZ), m_World(a_World), m_ChunkMap(a_ChunkMap), + m_ChunkData(a_Pool), m_BlockTickX(0), m_BlockTickY(0), m_BlockTickZ(0), diff --git a/src/Chunk.h b/src/Chunk.h index dfdabea04..7664a7afd 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -65,7 +65,8 @@ public: cChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ, // Chunk coords cChunkMap * a_ChunkMap, cWorld * a_World, // Parent objects - cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP // Neighbor chunks + cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP, // Neighbor chunks + cAllocationPool & a_Pool ); cChunk(cChunk & other); ~cChunk(); diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index f2d220bd2..03b0224a6 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -27,11 +27,12 @@ template inline bool IsAllValue(const T * a_Array, size_t a_NumElem -cChunkData::cChunkData(void) +cChunkData::cChunkData(cAllocationPool & a_Pool) : #if __cplusplus < 201103L // auto_ptr style interface for memory management - : m_IsOwner(true) + m_IsOwner(true), #endif + m_Pool(a_Pool) { for (size_t i = 0; i < NumSections; i++) { @@ -66,7 +67,8 @@ cChunkData::~cChunkData() #if __cplusplus < 201103L // auto_ptr style interface for memory management cChunkData::cChunkData(const cChunkData & a_Other) : - m_IsOwner(true) + m_IsOwner(true), + m_Pool(a_Other.m_Pool) { // Move contents and ownership from a_Other to this, pointer-wise: for (size_t i = 0; i < NumSections; i++) @@ -97,7 +99,7 @@ cChunkData::~cChunkData() m_Sections[i] = NULL; } } - + // Move contents and ownership from a_Other to this, pointer-wise: m_IsOwner = true; for (size_t i = 0; i < NumSections; i++) @@ -105,13 +107,15 @@ cChunkData::~cChunkData() m_Sections[i] = a_Other.m_Sections[i]; } a_Other.m_IsOwner = false; + ASSERT(&m_Pool == &a_Other.m_Pool); return *this; } #else // unique_ptr style interface for memory management - cChunkData::cChunkData(cChunkData && other) + cChunkData::cChunkData(cChunkData && other) : + m_Pool(other.m_Pool) { for (size_t i = 0; i < NumSections; i++) { @@ -128,6 +132,7 @@ cChunkData::~cChunkData() { if (&other != this) { + ASSERT(&m_Pool == &other.m_Pool); for (size_t i = 0; i < NumSections; i++) { Free(m_Sections[i]); @@ -317,12 +322,12 @@ NIBBLETYPE cChunkData::GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const cChunkData cChunkData::Copy(void) const { - cChunkData copy; + cChunkData copy(m_Pool); for (size_t i = 0; i < NumSections; i++) { if (m_Sections[i] != NULL) { - copy.m_Sections[i] = Allocate(); + copy.m_Sections[i] = copy.Allocate(); *copy.m_Sections[i] = *m_Sections[i]; } } @@ -561,8 +566,7 @@ void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src) cChunkData::sChunkSection * cChunkData::Allocate(void) { - // TODO: Use an allocation pool - return new cChunkData::sChunkSection; + return m_Pool.Allocate(); } @@ -571,8 +575,7 @@ cChunkData::sChunkSection * cChunkData::Allocate(void) void cChunkData::Free(cChunkData::sChunkSection * a_Section) { - // TODO: Use an allocation pool - delete a_Section; + m_Pool.Free(a_Section); } diff --git a/src/ChunkData.h b/src/ChunkData.h index fef31b5ad..fe8b068a2 100644 --- a/src/ChunkData.h +++ b/src/ChunkData.h @@ -15,6 +15,7 @@ #include "ChunkDef.h" +#include "AllocationPool.h" @@ -26,9 +27,17 @@ class cChunkData { +private: + + static const size_t SectionHeight = 16; + static const size_t NumSections = (cChunkDef::Height / SectionHeight); + static const size_t SectionBlockCount = SectionHeight * cChunkDef::Width * cChunkDef::Width; + public: - cChunkData(void); + struct sChunkSection; + + cChunkData(cAllocationPool & a_Pool); ~cChunkData(); #if __cplusplus < 201103L @@ -53,17 +62,17 @@ public: /** Creates a (deep) copy of self. */ cChunkData Copy(void) const; - + /** Copies the blocktype data into the specified flat array. Optionally, only a part of the data is copied, as specified by the a_Idx and a_Length parameters. */ void CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx = 0, size_t a_Length = cChunkDef::NumBlocks) const; - + /** Copies the metadata into the specified flat array. */ void CopyMetas(NIBBLETYPE * a_Dest) const; - + /** Copies the block light data into the specified flat array. */ void CopyBlockLight(NIBBLETYPE * a_Dest) const; - + /** Copies the skylight data into the specified flat array. */ void CopySkyLight (NIBBLETYPE * a_Dest) const; @@ -71,12 +80,12 @@ public: Allocates sections that are needed for the operation. Requires that a_Src is a valid pointer. */ void SetBlockTypes(const BLOCKTYPE * a_Src); - + /** Copies the metadata from the specified flat array into the internal representation. Allocates sectios that are needed for the operation. Requires that a_Src is a valid pointer. */ void SetMetas(const NIBBLETYPE * a_Src); - + /** Copies the blocklight data from the specified flat array into the internal representation. Allocates sectios that are needed for the operation. Allows a_Src to be NULL, in which case it doesn't do anything. */ @@ -86,36 +95,35 @@ public: Allocates sectios that are needed for the operation. Allows a_Src to be NULL, in which case it doesn't do anything. */ void SetSkyLight(const NIBBLETYPE * a_Src); + + struct sChunkSection + { + BLOCKTYPE m_BlockTypes [SectionHeight * 16 * 16] ; + NIBBLETYPE m_BlockMetas [SectionHeight * 16 * 16 / 2]; + NIBBLETYPE m_BlockLight [SectionHeight * 16 * 16 / 2]; + NIBBLETYPE m_BlockSkyLight[SectionHeight * 16 * 16 / 2]; + }; private: - - static const size_t SectionHeight = 16; - static const size_t NumSections = (cChunkDef::Height / SectionHeight); - static const size_t SectionBlockCount = SectionHeight * cChunkDef::Width * cChunkDef::Width; - #if __cplusplus < 201103L // auto_ptr style interface for memory management mutable bool m_IsOwner; #endif - - struct sChunkSection { - BLOCKTYPE m_BlockTypes [SectionBlockCount]; - NIBBLETYPE m_BlockMetas [SectionBlockCount / 2]; - NIBBLETYPE m_BlockLight [SectionBlockCount / 2]; - NIBBLETYPE m_BlockSkyLight[SectionBlockCount / 2]; - }; - + sChunkSection * m_Sections[NumSections]; + + cAllocationPool & m_Pool; /** Allocates a new section. Entry-point to custom allocators. */ - static sChunkSection * Allocate(void); - + sChunkSection * Allocate(void); + /** Frees the specified section, previously allocated using Allocate(). Note that a_Section may be NULL. */ - static void Free(sChunkSection * a_Section); + void Free(sChunkSection * a_Section); /** Sets the data in the specified section to their default values. */ void ZeroSection(sChunkSection * a_Section) const; + }; diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index dba6f3f41..d2ccca94e 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -34,8 +34,15 @@ // cChunkMap: cChunkMap::cChunkMap(cWorld * a_World ) - : m_World( a_World ) + : m_World( a_World ), + m_Pool( + new cListAllocationPool( + std::auto_ptr::cStarvationCallbacks>( + new cStarvationCallbacks()) + ) + ) { + } @@ -78,7 +85,7 @@ cChunkMap::cChunkLayer * cChunkMap::GetLayer(int a_LayerX, int a_LayerZ) } // Not found, create new: - cChunkLayer * Layer = new cChunkLayer(a_LayerX, a_LayerZ, this); + cChunkLayer * Layer = new cChunkLayer(a_LayerX, a_LayerZ, this, *m_Pool); if (Layer == NULL) { LOGERROR("cChunkMap: Cannot create new layer, server out of memory?"); @@ -2670,11 +2677,16 @@ void cChunkMap::QueueTickBlock(int a_BlockX, int a_BlockY, int a_BlockZ) //////////////////////////////////////////////////////////////////////////////// // cChunkMap::cChunkLayer: -cChunkMap::cChunkLayer::cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent) +cChunkMap::cChunkLayer::cChunkLayer( + int a_LayerX, int a_LayerZ, + cChunkMap * a_Parent, + cAllocationPool & a_Pool +) : m_LayerX( a_LayerX ) , m_LayerZ( a_LayerZ ) , m_Parent( a_Parent ) , m_NumChunksLoaded( 0 ) + , m_Pool(a_Pool) { memset(m_Chunks, 0, sizeof(m_Chunks)); } @@ -2716,7 +2728,7 @@ cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_Ch cChunk * neixp = (LocalX < LAYER_SIZE - 1) ? m_Chunks[Index + 1] : m_Parent->FindChunk(a_ChunkX + 1, a_ChunkZ); cChunk * neizm = (LocalZ > 0) ? m_Chunks[Index - LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ - 1); cChunk * neizp = (LocalZ < LAYER_SIZE - 1) ? m_Chunks[Index + LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ + 1); - m_Chunks[Index] = new cChunk(a_ChunkX, 0, a_ChunkZ, m_Parent, m_Parent->GetWorld(), neixm, neixp, neizm, neizp); + m_Chunks[Index] = new cChunk(a_ChunkX, 0, a_ChunkZ, m_Parent, m_Parent->GetWorld(), neixm, neixp, neizm, neizp, m_Pool); } return m_Chunks[Index]; } diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 7e85bb6f1..5aad0dd2a 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -351,7 +351,11 @@ private: class cChunkLayer { public: - cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent); + cChunkLayer( + int a_LayerX, int a_LayerZ, + cChunkMap * a_Parent, + cAllocationPool & a_Pool + ); ~cChunkLayer(); /** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */ @@ -395,6 +399,25 @@ private: int m_LayerZ; cChunkMap * m_Parent; int m_NumChunksLoaded; + + cAllocationPool & m_Pool; + }; + + class cStarvationCallbacks + : public cAllocationPool::cStarvationCallbacks + { + virtual void OnStartUsingReserve() override + { + LOG("Using backup memory buffer"); + } + virtual void OnEndUsingReserve() override + { + LOG("Stoped using backup memory buffer"); + } + virtual void OnOutOfReserve() override + { + LOG("Out of Memory"); + } }; typedef std::list cChunkLayerList; @@ -427,6 +450,8 @@ private: /** The cChunkStay descendants that are currently enabled in this chunkmap */ cChunkStays m_ChunkStays; + std::auto_ptr> m_Pool; + cChunkPtr GetChunk (int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Also queues the chunk for loading / generating if not valid cChunkPtr GetChunkNoGen (int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Also queues the chunk for loading if not valid; doesn't generate cChunkPtr GetChunkNoLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Doesn't load, doesn't generate diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 8f736a269..ee7ce06ac 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -179,14 +179,9 @@ void cEntity::WrapRotation(void) void cEntity::WrapSpeed(void) { - // There shoudn't be a need for flipping the flag on because this function is called - // after any update, so the flag is already turned on - if (m_Speed.x > 78.0f) m_Speed.x = 78.0f; - else if (m_Speed.x < -78.0f) m_Speed.x = -78.0f; - if (m_Speed.y > 78.0f) m_Speed.y = 78.0f; - else if (m_Speed.y < -78.0f) m_Speed.y = -78.0f; - if (m_Speed.z > 78.0f) m_Speed.z = 78.0f; - else if (m_Speed.z < -78.0f) m_Speed.z = -78.0f; + m_Speed.x = Clamp(m_Speed.x, -78.0, 78.0); + m_Speed.y = Clamp(m_Speed.y, -78.0, 78.0); + m_Speed.z = Clamp(m_Speed.z, -78.0, 78.0); } @@ -1076,6 +1071,17 @@ void cEntity::SetSwimState(cChunk & a_Chunk) +void cEntity::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) +{ + m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ); + + WrapSpeed(); +} + + + + + void cEntity::HandleAir(void) { // Ref.: http://www.minecraftwiki.net/wiki/Chunk_format @@ -1428,9 +1434,7 @@ void cEntity::SetRoll(double a_Roll) void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) { - m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ); - - WrapSpeed(); + DoSetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ); } @@ -1438,9 +1442,7 @@ void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) void cEntity::SetSpeedX(double a_SpeedX) { - m_Speed.x = a_SpeedX; - - WrapSpeed(); + SetSpeed(a_SpeedX, m_Speed.y, m_Speed.z); } @@ -1448,9 +1450,7 @@ void cEntity::SetSpeedX(double a_SpeedX) void cEntity::SetSpeedY(double a_SpeedY) { - m_Speed.y = a_SpeedY; - - WrapSpeed(); + SetSpeed(m_Speed.x, a_SpeedY, m_Speed.z); } @@ -1458,9 +1458,7 @@ void cEntity::SetSpeedY(double a_SpeedY) void cEntity::SetSpeedZ(double a_SpeedZ) { - m_Speed.z = a_SpeedZ; - - WrapSpeed(); + SetSpeed(m_Speed.x, m_Speed.y, a_SpeedZ); } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 85ad42d54..2df66e353 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -215,11 +215,22 @@ public: void SetYaw (double a_Yaw); // In degrees, normalizes to [-180, +180) void SetPitch (double a_Pitch); // In degrees, normalizes to [-180, +180) void SetRoll (double a_Roll); // In degrees, normalizes to [-180, +180) - void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ); - void SetSpeed (const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); } - void SetSpeedX (double a_SpeedX); - void SetSpeedY (double a_SpeedY); - void SetSpeedZ (double a_SpeedZ); + + /** Sets the speed of the entity, measured in m / sec */ + void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ); + + /** Sets the speed of the entity, measured in m / sec */ + void SetSpeed(const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); } + + /** Sets the speed in the X axis, leaving the other speed components intact. Measured in m / sec. */ + void SetSpeedX(double a_SpeedX); + + /** Sets the speed in the Y axis, leaving the other speed components intact. Measured in m / sec. */ + void SetSpeedY(double a_SpeedY); + + /** Sets the speed in the Z axis, leaving the other speed components intact. Measured in m / sec. */ + void SetSpeedZ(double a_SpeedZ); + void SetWidth (double a_Width); void AddPosX (double a_AddPosX); @@ -429,6 +440,9 @@ protected: static cCriticalSection m_CSCount; static int m_EntityCount; + /** Measured in meter/second (m/s) */ + Vector3d m_Speed; + int m_UniqueID; int m_Health; @@ -486,11 +500,15 @@ protected: /// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void. int m_TicksSinceLastVoidDamage; - + + /** Does the actual speed-setting. The default implementation just sets the member variable value; + overrides can provide further processing, such as forcing players to move at the given speed. */ + virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ); + virtual void Destroyed(void) {} // Called after the entity has been destroyed /** Called in each tick to handle air-related processing i.e. drowning */ - virtual void HandleAir(); + virtual void HandleAir(void); /** Called once per tick to set IsSwimming and IsSubmerged */ virtual void SetSwimState(cChunk & a_Chunk); @@ -506,9 +524,6 @@ private: /** Measured in degrees, [-180, +180) */ double m_HeadYaw; - /** Measured in meter/second (m/s) */ - Vector3d m_Speed; - /** Measured in degrees, [-180, +180) */ Vector3d m_Rot; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index feb09b5d2..fdc0bb390 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -22,6 +22,12 @@ #include "inifile/iniFile.h" #include "json/json.h" +// 6000 ticks or 5 minutes +#define PLAYER_INVENTORY_SAVE_INTERVAL 6000 + +// 1000 = once per second +#define PLAYER_LIST_TIME_MS 1000 + @@ -64,6 +70,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) , m_BowCharge(0) , m_FloaterID(-1) , m_Team(NULL) + , m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL) { LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d", a_PlayerName.c_str(), a_Client->GetIPString().c_str(), @@ -250,7 +257,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) // Send Player List (Once per m_LastPlayerListTime/1000 ms) cTimer t1; - if (m_LastPlayerListTime + cPlayer::PLAYER_LIST_TIME_MS <= t1.GetNowTime()) + if (m_LastPlayerListTime + PLAYER_LIST_TIME_MS <= t1.GetNowTime()) { m_World->SendPlayerList(this); m_LastPlayerListTime = t1.GetNowTime(); @@ -260,6 +267,16 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) { m_LastGroundHeight = (float)GetPosY(); } + + if (m_TicksUntilNextSave == 0) + { + SaveToDisk(); + m_TicksUntilNextSave = PLAYER_INVENTORY_SAVE_INTERVAL; + } + else + { + m_TicksUntilNextSave--; + } } @@ -1257,6 +1274,17 @@ Vector3d cPlayer::GetThrowSpeed(double a_SpeedCoeff) const void cPlayer::ForceSetSpeed(const Vector3d & a_Speed) { SetSpeed(a_Speed); +} + + + + + +void cPlayer::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) +{ + super::DoSetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ); + + // Send the speed to the client so he actualy moves m_ClientHandle->SendEntityVelocity(*this); } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 83b9ad593..b2142a18b 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -194,7 +194,8 @@ public: // Sets the current gamemode, doesn't check validity, doesn't send update packets to client void LoginSetGameMode(eGameMode a_GameMode); - /** Forces the player to move in the given direction. */ + /** Forces the player to move in the given direction. + @deprecated Use SetSpeed instead. */ void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export /** Tries to move to a new position, with attachment-related checks (y == -999) */ @@ -461,7 +462,6 @@ protected: cItem m_DraggingItem; long long m_LastPlayerListTime; - static const unsigned short PLAYER_LIST_TIME_MS = 1000; // 1000 = once per second cClientHandle * m_ClientHandle; @@ -512,6 +512,9 @@ protected: + /** Sets the speed and sends it to the client, so that they are forced to move so. */ + virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override; + void ResolvePermissions(void); void ResolveGroups(void); @@ -539,6 +542,10 @@ protected: Set by a right click on unoccupied bed, unset by a time fast forward or teleport */ bool m_bIsInBed; + /** How long till the player's inventory will be saved + Default save interval is #defined in PLAYER_INVENTORY_SAVE_INTERVAL */ + unsigned int m_TicksUntilNextSave; + } ; // tolua_export diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index 872e3341d..6aa7fd4cb 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -125,7 +125,7 @@ public: int m_BlockX; int m_BlockZ; - cCaveSystem(int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise); + cCaveSystem(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise); ~cCaveSystem(); protected: @@ -574,8 +574,8 @@ AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) cons /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cStructGenWormNestCaves::cCaveSystem: -cStructGenWormNestCaves::cCaveSystem::cCaveSystem(int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise) : - super(a_OriginX, a_OriginZ), +cStructGenWormNestCaves::cCaveSystem::cCaveSystem(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise) : + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_Size(a_Size) { int Num = 1 + a_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) % 3; @@ -690,9 +690,9 @@ int cStructGenWormNestCaves::cCaveSystem::GetRadius(cNoise & a_Noise, int a_Orig /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cStructGenWormNestCaves: -cGridStructGen::cStructurePtr cStructGenWormNestCaves::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cStructGenWormNestCaves::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { - return cStructurePtr(new cCaveSystem(a_OriginX, a_OriginZ, m_MaxOffset, m_Size, m_Noise)); + return cStructurePtr(new cCaveSystem(a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxOffset, m_Size, m_Noise)); } diff --git a/src/Generating/Caves.h b/src/Generating/Caves.h index 254dcddbd..0e17acf9e 100644 --- a/src/Generating/Caves.h +++ b/src/Generating/Caves.h @@ -69,7 +69,7 @@ class cStructGenWormNestCaves : typedef cGridStructGen super; public: cStructGenWormNestCaves(int a_Seed, int a_Size = 64, int a_Grid = 96, int a_MaxOffset = 128) : - super(a_Seed, a_Grid, a_Grid, a_Size + a_MaxOffset, a_Size + a_MaxOffset, 100), + super(a_Seed, a_Grid, a_Grid, a_MaxOffset, a_MaxOffset, a_Size, a_Size, 100), m_Noise(a_Seed), m_Size(a_Size), m_MaxOffset(a_MaxOffset), @@ -86,7 +86,7 @@ protected: int m_Grid; // average spacing of the nests // cGridStructGen override: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 1801b7375..22941dcbe 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -357,12 +357,13 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) else if (NoCaseCompare(*itr, "MineShafts") == 0) { int GridSize = a_IniFile.GetValueSetI("Generator", "MineShaftsGridSize", 512); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "MineShaftsMaxOffset", 256); int MaxSystemSize = a_IniFile.GetValueSetI("Generator", "MineShaftsMaxSystemSize", 160); int ChanceCorridor = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCorridor", 600); int ChanceCrossing = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCrossing", 200); int ChanceStaircase = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceStaircase", 200); m_FinishGens.push_back(new cStructGenMineShafts( - Seed, GridSize, MaxSystemSize, + Seed, GridSize, MaxOffset, MaxSystemSize, ChanceCorridor, ChanceCrossing, ChanceStaircase )); } @@ -376,9 +377,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "NetherForts") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "NetherFortsGridSize", 512); - int MaxDepth = a_IniFile.GetValueSetI("Generator", "NetherFortsMaxDepth", 12); - m_FinishGens.push_back(new cNetherFortGen(Seed, GridSize, MaxDepth)); + int GridSize = a_IniFile.GetValueSetI("Generator", "NetherFortsGridSize", 512); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "NetherFortMaxOffset", 128); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "NetherFortsMaxDepth", 12); + m_FinishGens.push_back(new cNetherFortGen(Seed, GridSize, MaxOffset, MaxDepth)); } else if (NoCaseCompare(*itr, "OreNests") == 0) { @@ -394,10 +396,11 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "RainbowRoads") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsGridSize", 512); - int MaxDepth = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxDepth", 30); - int MaxSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxSize", 260); - m_FinishGens.push_back(new cRainbowRoadsGen(Seed, GridSize, MaxDepth, MaxSize)); + int GridSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsGridSize", 512); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxOffset", 128); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxDepth", 30); + int MaxSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxSize", 260); + m_FinishGens.push_back(new cRainbowRoadsGen(Seed, GridSize, MaxOffset, MaxDepth, MaxSize)); } else if (NoCaseCompare(*itr, "Ravines") == 0) { @@ -417,19 +420,21 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "UnderwaterBases") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseGridSize", 1024); - int MaxDepth = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxDepth", 7); - int MaxSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxSize", 128); - m_FinishGens.push_back(new cUnderwaterBaseGen(Seed, GridSize, MaxDepth, MaxSize, *m_BiomeGen)); + int GridSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseGridSize", 1024); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxOffset", 128); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxDepth", 7); + int MaxSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxSize", 128); + m_FinishGens.push_back(new cUnderwaterBaseGen(Seed, GridSize, MaxOffset, MaxDepth, MaxSize, *m_BiomeGen)); } else if (NoCaseCompare(*itr, "Villages") == 0) { int GridSize = a_IniFile.GetValueSetI("Generator", "VillageGridSize", 384); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "VillageMaxOffset", 128); int MaxDepth = a_IniFile.GetValueSetI("Generator", "VillageMaxDepth", 2); int MaxSize = a_IniFile.GetValueSetI("Generator", "VillageMaxSize", 128); int MinDensity = a_IniFile.GetValueSetI("Generator", "VillageMinDensity", 50); int MaxDensity = a_IniFile.GetValueSetI("Generator", "VillageMaxDensity", 80); - m_FinishGens.push_back(new cVillageGen(Seed, GridSize, MaxDepth, MaxSize, MinDensity, MaxDensity, *m_BiomeGen, *m_HeightGen)); + m_FinishGens.push_back(new cVillageGen(Seed, GridSize, MaxOffset, MaxDepth, MaxSize, MinDensity, MaxDensity, *m_BiomeGen, *m_HeightGen)); } else if (NoCaseCompare(*itr, "WaterLakes") == 0) { @@ -442,7 +447,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "WormNestCaves") == 0) { - m_FinishGens.push_back(new cStructGenWormNestCaves(Seed)); + int Size = a_IniFile.GetValueSetI("Generator", "WormNestCavesSize", 64); + int Grid = a_IniFile.GetValueSetI("Generator", "WormNestCavesGrid", 96); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "WormNestMaxOffset", 32); + m_FinishGens.push_back(new cStructGenWormNestCaves(Seed, Size, Grid, MaxOffset)); } else { diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp index 474242557..2931df3eb 100644 --- a/src/Generating/GridStructGen.cpp +++ b/src/Generating/GridStructGen.cpp @@ -21,8 +21,8 @@ class cEmptyStructure : typedef cGridStructGen::cStructure super; public: - cEmptyStructure(int a_OriginX, int a_OriginZ) : - super(a_OriginX, a_OriginZ) + cEmptyStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) : + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ) { } @@ -40,17 +40,20 @@ protected: cGridStructGen::cGridStructGen( int a_Seed, int a_GridSizeX, int a_GridSizeZ, + int a_MaxOffsetX, int a_MaxOffsetZ, int a_MaxStructureSizeX, int a_MaxStructureSizeZ, size_t a_MaxCacheSize ) : - m_Seed(a_Seed), + m_Noise(a_Seed), m_GridSizeX(a_GridSizeX), m_GridSizeZ(a_GridSizeZ), + m_MaxOffsetX(a_MaxOffsetX), + m_MaxOffsetZ(a_MaxOffsetZ), m_MaxStructureSizeX(a_MaxStructureSizeX), m_MaxStructureSizeZ(a_MaxStructureSizeZ), m_MaxCacheSize(a_MaxCacheSize) { - size_t NumStructuresPerQuery = (size_t)((m_MaxStructureSizeX / m_GridSizeX + 1) * (m_MaxStructureSizeZ / m_GridSizeZ + 1)); + size_t NumStructuresPerQuery = (size_t)(((m_MaxStructureSizeX + m_MaxOffsetX) / m_GridSizeX + 1) * ((m_MaxStructureSizeZ + m_MaxOffsetZ) / m_GridSizeZ + 1)); if (NumStructuresPerQuery > m_MaxCacheSize) { m_MaxCacheSize = NumStructuresPerQuery * 4; @@ -68,10 +71,10 @@ cGridStructGen::cGridStructGen( void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructurePtrs & a_Structures) { // Calculate the min and max grid coords of the structures to be returned: - int MinBlockX = a_ChunkX * cChunkDef::Width - m_MaxStructureSizeX; - int MinBlockZ = a_ChunkZ * cChunkDef::Width - m_MaxStructureSizeZ; - int MaxBlockX = a_ChunkX * cChunkDef::Width + m_MaxStructureSizeX + cChunkDef::Width - 1; - int MaxBlockZ = a_ChunkZ * cChunkDef::Width + m_MaxStructureSizeZ + cChunkDef::Width - 1; + int MinBlockX = a_ChunkX * cChunkDef::Width - m_MaxStructureSizeX - m_MaxOffsetX; + int MinBlockZ = a_ChunkZ * cChunkDef::Width - m_MaxStructureSizeZ - m_MaxOffsetZ; + int MaxBlockX = a_ChunkX * cChunkDef::Width + m_MaxStructureSizeX + m_MaxOffsetX + cChunkDef::Width - 1; + int MaxBlockZ = a_ChunkZ * cChunkDef::Width + m_MaxStructureSizeZ + m_MaxOffsetZ + cChunkDef::Width - 1; int MinGridX = MinBlockX / m_GridSizeX; int MinGridZ = MinBlockZ / m_GridSizeZ; int MaxGridX = (MaxBlockX + m_GridSizeX - 1) / m_GridSizeX; @@ -103,14 +106,14 @@ void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructur // Create those structures that haven't been in the cache: for (int x = MinGridX; x < MaxGridX; x++) { - int OriginX = x * m_GridSizeX; + int GridX = x * m_GridSizeX; for (int z = MinGridZ; z < MaxGridZ; z++) { - int OriginZ = z * m_GridSizeZ; + int GridZ = z * m_GridSizeZ; bool Found = false; for (cStructurePtrs::const_iterator itr = a_Structures.begin(), end = a_Structures.end(); itr != end; ++itr) { - if (((*itr)->m_OriginX == OriginX) && ((*itr)->m_OriginZ == OriginZ)) + if (((*itr)->m_GridX == GridX) && ((*itr)->m_GridZ == GridZ)) { Found = true; break; @@ -118,10 +121,12 @@ void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructur } // for itr - a_Structures[] if (!Found) { - cStructurePtr Structure = CreateStructure(OriginX, OriginZ); + int OriginX = GridX + ((m_Noise.IntNoise2DInt(GridX + 3, GridZ + 5) / 7) % (m_MaxOffsetX * 2)) - m_MaxOffsetX; + int OriginZ = GridZ + ((m_Noise.IntNoise2DInt(GridX + 5, GridZ + 3) / 7) % (m_MaxOffsetZ * 2)) - m_MaxOffsetZ; + cStructurePtr Structure = CreateStructure(GridX, GridZ, OriginX, OriginZ); if (Structure.get() == NULL) { - Structure.reset(new cEmptyStructure(OriginX, OriginZ)); + Structure.reset(new cEmptyStructure(GridX, GridZ, OriginX, OriginZ)); } a_Structures.push_back(Structure); } diff --git a/src/Generating/GridStructGen.h b/src/Generating/GridStructGen.h index 630a5e44e..03131fce9 100644 --- a/src/Generating/GridStructGen.h +++ b/src/Generating/GridStructGen.h @@ -10,6 +10,7 @@ #pragma once #include "ComposableGenerator.h" +#include "../Noise.h" @@ -19,7 +20,12 @@ Defines a grid in the XZ space with predefined cell size in each direction. Each cell then receives exactly one structure (provided by the descendant class). The structure is placed within the cell, but doesn't need to be bounded by the cell, it can be well outside the cell; the generator uses the MaxStructureSize parameter -to determine how far away from the cell the structure can be at most. +to determine how far away from the cell the structure can be at most. Each structure has an offset from the +grid's center point, the offset is generated randomly from a range given to this class as a parameter. + +Each structure thus contains the coords of its grid center (m_GridX, m_GridZ) and the actual origin from +which it's built (m_OriginX, m_OriginZ). + This class provides a cache for the structures generated for successive chunks and manages that cache. It also provides the cFinishGen override that uses the cache to actually generate the structure into chunk data. @@ -43,12 +49,17 @@ public: class cStructure { public: - /** The origin (the coords of the gridpoint for which the structure is generated) */ + /** The grid point for which the structure is generated. */ + int m_GridX, m_GridZ; + + /** The origin (the coords for which the structure is generated) */ int m_OriginX, m_OriginZ; - /** Creates a structure that has its originset at the specified coords. */ - cStructure (int a_OriginX, int a_OriginZ) : + /** Creates a structure that has its origin set at the specified coords. */ + cStructure (int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) : + m_GridX(a_GridX), + m_GridZ(a_GridZ), m_OriginX(a_OriginX), m_OriginZ(a_OriginZ) { @@ -70,20 +81,30 @@ public: cGridStructGen( int a_Seed, int a_GridSizeX, int a_GridSizeZ, + int a_MaxOffsetX, int a_MaxOffsetZ, int a_MaxStructureSizeX, int a_MaxStructureSizeZ, size_t a_MaxCacheSize ); protected: - /** Seed for generating the semi-random grid. */ + /** Seed for generating grid offsets and also available for descendants. */ int m_Seed; + /** The noise used for generating grid offsets. */ + cNoise m_Noise; + /** The size of each grid's cell in the X axis */ int m_GridSizeX; /** The size of each grid's cell in the Z axis */ int m_GridSizeZ; + /** The maximum offset of the structure's origin from the grid midpoint, in X coord. */ + int m_MaxOffsetX; + + /** The maximum offset of the structure's origin from the grid midpoint, in Z coord. */ + int m_MaxOffsetZ; + /** Maximum theoretical size of the structure in the X axis. This limits the structures considered for a single chunk, so the lesser the number, the better performance. Structures large than this may get cropped. */ @@ -115,7 +136,7 @@ protected: // Functions for the descendants to override: /** Create a new structure at the specified gridpoint */ - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) = 0; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) = 0; } ; diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index 81ae6481d..ab9b1aa29 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -248,7 +248,8 @@ public: /** Creates and generates the entire system */ cMineShaftSystem( - int a_OriginX, int a_OriginZ, int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise, + int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, + int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise, int a_ProbLevelCorridor, int a_ProbLevelCrossing, int a_ProbLevelStaircase ); @@ -278,10 +279,11 @@ public: // cStructGenMineShafts::cMineShaftSystem: cStructGenMineShafts::cMineShaftSystem::cMineShaftSystem( - int a_OriginX, int a_OriginZ, int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise, + int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, + int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise, int a_ProbLevelCorridor, int a_ProbLevelCrossing, int a_ProbLevelStaircase ) : - super(a_OriginX, a_OriginZ), + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_GridSize(a_GridSize), m_MaxRecursion(8), // TODO: settable m_ProbLevelCorridor(a_ProbLevelCorridor), @@ -1280,10 +1282,10 @@ void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc) // cStructGenMineShafts: cStructGenMineShafts::cStructGenMineShafts( - int a_Seed, int a_GridSize, int a_MaxSystemSize, + int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxSystemSize, int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase ) : - super(a_Seed, a_GridSize, a_GridSize, a_MaxSystemSize, a_MaxSystemSize, 100), + super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSystemSize, a_MaxSystemSize, 100), m_Noise(a_Seed), m_GridSize(a_GridSize), m_MaxSystemSize(a_MaxSystemSize), @@ -1297,9 +1299,9 @@ cStructGenMineShafts::cStructGenMineShafts( -cGridStructGen::cStructurePtr cStructGenMineShafts::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cStructGenMineShafts::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { - return cStructurePtr(new cMineShaftSystem(a_OriginX, a_OriginZ, m_GridSize, m_MaxSystemSize, m_Noise, m_ProbLevelCorridor, m_ProbLevelCrossing, m_ProbLevelStaircase)); + return cStructurePtr(new cMineShaftSystem(a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_GridSize, m_MaxSystemSize, m_Noise, m_ProbLevelCorridor, m_ProbLevelCrossing, m_ProbLevelStaircase)); } diff --git a/src/Generating/MineShafts.h b/src/Generating/MineShafts.h index c29b6cdac..2850db571 100644 --- a/src/Generating/MineShafts.h +++ b/src/Generating/MineShafts.h @@ -23,7 +23,7 @@ class cStructGenMineShafts : public: cStructGenMineShafts( - int a_Seed, int a_GridSize, int a_MaxSystemSize, + int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxSystemSize, int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase ); @@ -43,7 +43,7 @@ protected: int m_ProbLevelStaircase; ///< Probability level of a branch object being the staircase, minus Crossing // cGridStructGen overrides: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Generating/NetherFortGen.cpp b/src/Generating/NetherFortGen.cpp index 3867ec80c..23fa56048 100644 --- a/src/Generating/NetherFortGen.cpp +++ b/src/Generating/NetherFortGen.cpp @@ -26,8 +26,8 @@ public: cPlacedPieces m_Pieces; - cNetherFort(cNetherFortGen & a_ParentGen, int a_OriginX, int a_OriginZ, int a_GridSize, int a_MaxDepth, int a_Seed) : - super(a_OriginX, a_OriginZ), + cNetherFort(cNetherFortGen & a_ParentGen, int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_GridSize, int a_MaxDepth, int a_Seed) : + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_ParentGen(a_ParentGen), m_GridSize(a_GridSize), m_Seed(a_Seed) @@ -108,8 +108,8 @@ cPrefabPiecePool cNetherFortGen::m_PiecePool(g_NetherFortPrefabs, g_NetherFortPr -cNetherFortGen::cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxDepth) : - super(a_Seed, a_GridSize, a_GridSize, a_MaxDepth * 10, a_MaxDepth * 10, 200), +cNetherFortGen::cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxDepth * 10, a_MaxDepth * 10, 200), m_MaxDepth(a_MaxDepth) { /* @@ -124,8 +124,11 @@ cNetherFortGen::cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxDepth) : -cGridStructGen::cStructurePtr cNetherFortGen::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cNetherFortGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { - return cStructurePtr(new cNetherFort(*this, a_OriginX, a_OriginZ, m_GridSizeX, m_MaxDepth, m_Seed)); + return cStructurePtr(new cNetherFort(*this, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_GridSizeX, m_MaxDepth, m_Seed)); } + + + diff --git a/src/Generating/NetherFortGen.h b/src/Generating/NetherFortGen.h index f35801a3c..9b31aa0e2 100644 --- a/src/Generating/NetherFortGen.h +++ b/src/Generating/NetherFortGen.h @@ -23,7 +23,7 @@ class cNetherFortGen : typedef cGridStructGen super; public: - cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxDepth); + cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth); protected: friend class cNetherFortPerfTest; // fwd: NetherFortGen.cpp @@ -37,7 +37,7 @@ protected: // cGridStructGen overrides: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp index 4f0efdcc6..eb01cf59e 100644 --- a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp +++ b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp @@ -20,18 +20,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 32, ID 173, created by Aloe_vera { // Size: - 12, 5, 10, // SizeX = 12, SizeY = 5, SizeZ = 10 + 12, 6, 10, // SizeX = 12, SizeY = 6, SizeZ = 10 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 11, 4, 9, // MaxX, MaxY, MaxZ + 11, 5, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 2\n" /* sandstonestairs */ - "b:128: 1\n" /* sandstonestairs */ - "c:128: 0\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e:128: 3\n" /* sandstonestairs */ "f:171:15\n" /* carpet */ "g: 64: 6\n" /* wooddoorblock */ @@ -54,35 +54,49 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Level 0 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "aaaaaab....." - /* 1 */ "cdddddddddd." - /* 2 */ "cdddddddddd." - /* 3 */ "cdddddddddd." - /* 4 */ "cdddddddddd." - /* 5 */ "edddddddddd." - /* 6 */ ".dddddddddd." - /* 7 */ ".dddddddddd." - /* 8 */ ".dddddddddd." - /* 9 */ "............" + /* 0 */ "aaaaaaammmmm" + /* 1 */ "aaaaaaaaaaam" + /* 2 */ "aaaaaaaaaaam" + /* 3 */ "aaaaaaaaaaam" + /* 4 */ "aaaaaaaaaaam" + /* 5 */ "aaaaaaaaaaam" + /* 6 */ "maaaaaaaaaam" + /* 7 */ "maaaaaaaaaam" + /* 8 */ "maaaaaaaaaam" + /* 9 */ "mmmmmmmmmmmm" // Level 1 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "............" - /* 1 */ ".d....ddddd." - /* 2 */ "......dfffd." - /* 3 */ "......ghfhd." - /* 4 */ "......diiid." - /* 5 */ ".d....dhfhd." - /* 6 */ ".djddjdfffd." - /* 7 */ ".ddkkddl..d." - /* 8 */ ".dddddddddd." + /* 0 */ "bcccccd....." + /* 1 */ "baaaaaaaaaa." + /* 2 */ "baaaaaaaaaa." + /* 3 */ "baaaaaaaaaa." + /* 4 */ "baaaaaaaaaa." + /* 5 */ "eaaaaaaaaaa." + /* 6 */ ".aaaaaaaaaa." + /* 7 */ ".aaaaaaaaaa." + /* 8 */ ".aaaaaaaaaa." /* 9 */ "............" // Level 2 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" + /* 1 */ ".a....aaaaa." + /* 2 */ "......afffa." + /* 3 */ "......ghfha." + /* 4 */ "......aiiia." + /* 5 */ ".a....ahfha." + /* 6 */ ".ajaajafffa." + /* 7 */ ".aakkaal..a." + /* 8 */ ".aaaaaaaaaa." + /* 9 */ "............" + + // Level 3 + /* z\x* 11 */ + /* * 012345678901 */ + /* 0 */ "............" /* 1 */ ".n....nn.nn." /* 2 */ "......n...n." /* 3 */ "......o...n." @@ -93,36 +107,36 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 8 */ ".nnn.nnn.nn." /* 9 */ "............" - // Level 3 + // Level 4 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" - /* 1 */ ".d....ddddd." - /* 2 */ "......d...d." - /* 3 */ "......d...d." - /* 4 */ "......dp..d." - /* 5 */ ".d....d...d." - /* 6 */ ".dqqqqd...d." - /* 7 */ ".d....d...d." - /* 8 */ ".dddddddddd." + /* 1 */ ".a....aaaaa." + /* 2 */ "......a...a." + /* 3 */ "......a...a." + /* 4 */ "......ap..a." + /* 5 */ ".a....a...a." + /* 6 */ ".aqqqqa...a." + /* 7 */ ".a....a...a." + /* 8 */ ".aaaaaaaaaa." /* 9 */ "............" - // Level 4 + // Level 5 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "rsssssssssss" - /* 1 */ "rddddddddddt" - /* 2 */ "rddddddddddt" - /* 3 */ "rddddddddddt" - /* 4 */ "rddddddddddt" - /* 5 */ "rddddddddddt" - /* 6 */ "rddddddddddt" - /* 7 */ "rddddddddddt" - /* 8 */ "rddddddddddt" + /* 1 */ "raaaaaaaaaat" + /* 2 */ "raaaaaaaaaat" + /* 3 */ "raaaaaaaaaat" + /* 4 */ "raaaaaaaaaat" + /* 5 */ "raaaaaaaaaat" + /* 6 */ "raaaaaaaaaat" + /* 7 */ "raaaaaaaaaat" + /* 8 */ "raaaaaaaaaat" /* 9 */ "uuuuuuuuuuut", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -153,18 +167,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 31, ID 172, created by Aloe_vera { // Size: - 13, 5, 9, // SizeX = 13, SizeY = 5, SizeZ = 9 + 13, 6, 9, // SizeX = 13, SizeY = 6, SizeZ = 9 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 12, 4, 8, // MaxX, MaxY, MaxZ + 12, 5, 8, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171: 0\n" /* carpet */ "g:171:15\n" /* carpet */ @@ -185,33 +199,46 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Level 0 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ "..abc........" - /* 1 */ ".ddddddddddd." - /* 2 */ ".ddddddddddd." - /* 3 */ ".ddddddddddd." - /* 4 */ ".ddddddddddd." - /* 5 */ ".ddddddddddd." - /* 6 */ ".ddddddddddd." - /* 7 */ ".ddddddddddd." - /* 8 */ "............." + /* 0 */ "mmaaammmmmmmm" + /* 1 */ "maaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaam" + /* 6 */ "maaaaaaaaaaam" + /* 7 */ "maaaaaaaaaaam" + /* 8 */ "mmmmmmmmmmmmm" // Level 1 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ "............." - /* 1 */ ".ddedddddddd." - /* 2 */ ".dffgggggffd." - /* 3 */ ".dfghhhhhgfd." - /* 4 */ ".dfghfffhgfd." - /* 5 */ ".dfghhhhhgfd." - /* 6 */ ".dffgggggffd." - /* 7 */ ".ddddddddddd." + /* 0 */ "..bcd........" + /* 1 */ ".aaaaaaaaaaa." + /* 2 */ ".aaaaaaaaaaa." + /* 3 */ ".aaaaaaaaaaa." + /* 4 */ ".aaaaaaaaaaa." + /* 5 */ ".aaaaaaaaaaa." + /* 6 */ ".aaaaaaaaaaa." + /* 7 */ ".aaaaaaaaaaa." /* 8 */ "............." // Level 2 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." + /* 1 */ ".aaeaaaaaaaa." + /* 2 */ ".affgggggffa." + /* 3 */ ".afghhhhhgfa." + /* 4 */ ".afghfffhgfa." + /* 5 */ ".afghhhhhgfa." + /* 6 */ ".affgggggffa." + /* 7 */ ".aaaaaaaaaaa." + /* 8 */ "............." + + // Level 3 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." /* 1 */ ".iiji.iii.ii." /* 2 */ ".i.........i." /* 3 */ ".i.........i." @@ -221,34 +248,34 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 7 */ ".ii.ii.ii.ii." /* 8 */ "............." - // Level 3 + // Level 4 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." - /* 1 */ ".ddddddddddd." - /* 2 */ ".d..k..k...d." - /* 3 */ ".d.........d." - /* 4 */ ".dl.......nd." - /* 5 */ ".d.........d." - /* 6 */ ".d....o....d." - /* 7 */ ".ddddddddddd." + /* 1 */ ".aaaaaaaaaaa." + /* 2 */ ".a..k..k...a." + /* 3 */ ".a.........a." + /* 4 */ ".al.......na." + /* 5 */ ".a.........a." + /* 6 */ ".a....o....a." + /* 7 */ ".aaaaaaaaaaa." /* 8 */ "............." - // Level 4 + // Level 5 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "pqqqqqqqqqqqq" - /* 1 */ "pdddddddddddr" - /* 2 */ "pdddddddddddr" - /* 3 */ "pdddddddddddr" - /* 4 */ "pdddddddddddr" - /* 5 */ "pdddddddddddr" - /* 6 */ "pdddddddddddr" - /* 7 */ "pdddddddddddr" + /* 1 */ "paaaaaaaaaaar" + /* 2 */ "paaaaaaaaaaar" + /* 3 */ "paaaaaaaaaaar" + /* 4 */ "paaaaaaaaaaar" + /* 5 */ "paaaaaaaaaaar" + /* 6 */ "paaaaaaaaaaar" + /* 7 */ "paaaaaaaaaaar" /* 8 */ "ssssssssssssr", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -279,18 +306,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 25, ID 166, created by Aloe_vera { // Size: - 7, 5, 6, // SizeX = 7, SizeY = 5, SizeZ = 6 + 7, 6, 6, // SizeX = 7, SizeY = 6, SizeZ = 6 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 6, 4, 5, // MaxX, MaxY, MaxZ + 6, 5, 5, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171: 0\n" /* carpet */ "g:171:14\n" /* carpet */ @@ -306,51 +333,60 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Block data: // Level 0 /* z\x* 0123456 */ - /* 0 */ "..abc.." - /* 1 */ ".ddddd." - /* 2 */ ".ddddd." - /* 3 */ ".ddddd." - /* 4 */ ".ddddd." - /* 5 */ "......." + /* 0 */ "mmaaamm" + /* 1 */ "maaaaam" + /* 2 */ "maaaaam" + /* 3 */ "maaaaam" + /* 4 */ "maaaaam" + /* 5 */ "mmmmmmm" // Level 1 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".ddedd." - /* 2 */ ".dfgfd." - /* 3 */ ".dfgfd." - /* 4 */ ".ddddd." + /* 0 */ "..bcd.." + /* 1 */ ".aaaaa." + /* 2 */ ".aaaaa." + /* 3 */ ".aaaaa." + /* 4 */ ".aaaaa." /* 5 */ "......." // Level 2 /* z\x* 0123456 */ /* 0 */ "......." + /* 1 */ ".aaeaa." + /* 2 */ ".afgfa." + /* 3 */ ".afgfa." + /* 4 */ ".aaaaa." + /* 5 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "......." /* 1 */ ".hhihh." /* 2 */ ".h...h." /* 3 */ ".h...h." /* 4 */ ".hh.hh." /* 5 */ "......." - // Level 3 + // Level 4 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".ddddd." - /* 2 */ ".dj.jd." - /* 3 */ ".d...d." - /* 4 */ ".ddddd." + /* 1 */ ".aaaaa." + /* 2 */ ".aj.ja." + /* 3 */ ".a...a." + /* 4 */ ".aaaaa." /* 5 */ "......." - // Level 4 + // Level 5 /* z\x* 0123456 */ /* 0 */ "kllllln" - /* 1 */ "kdddddn" - /* 2 */ "kdddddn" - /* 3 */ "kdddddn" - /* 4 */ "kdddddn" + /* 1 */ "kaaaaan" + /* 2 */ "kaaaaan" + /* 3 */ "kaaaaan" + /* 4 */ "kaaaaan" /* 5 */ "oooooon", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -381,18 +417,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 26, ID 167, created by Aloe_vera { // Size: - 7, 5, 7, // SizeX = 7, SizeY = 5, SizeZ = 7 + 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 6, 4, 6, // MaxX, MaxY, MaxZ + 6, 5, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171: 0\n" /* carpet */ "g:171:15\n" /* carpet */ @@ -409,27 +445,37 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Block data: // Level 0 /* z\x* 0123456 */ - /* 0 */ "..abc.." - /* 1 */ ".ddddd." - /* 2 */ ".ddddd." - /* 3 */ ".ddddd." - /* 4 */ ".ddddd." - /* 5 */ ".ddddd." - /* 6 */ "......." + /* 0 */ "mmaaamm" + /* 1 */ "maaaaam" + /* 2 */ "maaaaam" + /* 3 */ "maaaaam" + /* 4 */ "maaaaam" + /* 5 */ "maaaaam" + /* 6 */ "mmmmmmm" // Level 1 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".ddedd." - /* 2 */ ".dfffd." - /* 3 */ ".dghgd." - /* 4 */ ".dfffd." - /* 5 */ ".ddddd." + /* 0 */ "..bcd.." + /* 1 */ ".aaaaa." + /* 2 */ ".aaaaa." + /* 3 */ ".aaaaa." + /* 4 */ ".aaaaa." + /* 5 */ ".aaaaa." /* 6 */ "......." // Level 2 /* z\x* 0123456 */ /* 0 */ "......." + /* 1 */ ".aaeaa." + /* 2 */ ".afffa." + /* 3 */ ".aghga." + /* 4 */ ".afffa." + /* 5 */ ".aaaaa." + /* 6 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "......." /* 1 */ ".iijii." /* 2 */ ".i...i." /* 3 */ "......." @@ -437,28 +483,28 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 5 */ ".ii.ii." /* 6 */ "......." - // Level 3 + // Level 4 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".ddddd." - /* 2 */ ".dk.kd." - /* 3 */ ".d...d." - /* 4 */ ".d...d." - /* 5 */ ".ddddd." + /* 1 */ ".aaaaa." + /* 2 */ ".ak.ka." + /* 3 */ ".a...a." + /* 4 */ ".a...a." + /* 5 */ ".aaaaa." /* 6 */ "......." - // Level 4 + // Level 5 /* z\x* 0123456 */ /* 0 */ "lnnnnno" - /* 1 */ "ldddddo" - /* 2 */ "ldddddo" - /* 3 */ "ldddddo" - /* 4 */ "ldddddo" - /* 5 */ "ldddddo" + /* 1 */ "laaaaao" + /* 2 */ "laaaaao" + /* 3 */ "laaaaao" + /* 4 */ "laaaaao" + /* 5 */ "laaaaao" /* 6 */ "ppppppo", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -489,18 +535,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 27, ID 168, created by Aloe_vera { // Size: - 9, 5, 7, // SizeX = 9, SizeY = 5, SizeZ = 7 + 9, 6, 7, // SizeX = 9, SizeY = 6, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 8, 4, 6, // MaxX, MaxY, MaxZ + 8, 5, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171:14\n" /* carpet */ "g:171: 0\n" /* carpet */ @@ -517,27 +563,37 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Block data: // Level 0 /* z\x* 012345678 */ - /* 0 */ "..abc...." - /* 1 */ ".ddddddd." - /* 2 */ ".ddddddd." - /* 3 */ ".ddddddd." - /* 4 */ ".ddddddd." - /* 5 */ ".ddddddd." - /* 6 */ "........." + /* 0 */ "mmaaammmm" + /* 1 */ "maaaaaaam" + /* 2 */ "maaaaaaam" + /* 3 */ "maaaaaaam" + /* 4 */ "maaaaaaam" + /* 5 */ "maaaaaaam" + /* 6 */ "mmmmmmmmm" // Level 1 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ ".ddedddd." - /* 2 */ ".dfffffd." - /* 3 */ ".dghhhgd." - /* 4 */ ".dfffffd." - /* 5 */ ".ddddddd." + /* 0 */ "..bcd...." + /* 1 */ ".aaaaaaa." + /* 2 */ ".aaaaaaa." + /* 3 */ ".aaaaaaa." + /* 4 */ ".aaaaaaa." + /* 5 */ ".aaaaaaa." /* 6 */ "........." // Level 2 /* z\x* 012345678 */ /* 0 */ "........." + /* 1 */ ".aaeaaaa." + /* 2 */ ".afffffa." + /* 3 */ ".aghhhga." + /* 4 */ ".afffffa." + /* 5 */ ".aaaaaaa." + /* 6 */ "........." + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "........." /* 1 */ ".iiji.ii." /* 2 */ ".i.....i." /* 3 */ "........." @@ -545,28 +601,28 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 5 */ ".iii.iii." /* 6 */ "........." - // Level 3 + // Level 4 /* z\x* 012345678 */ /* 0 */ "........." - /* 1 */ ".ddddddd." - /* 2 */ ".dk.k..d." - /* 3 */ ".d.....d." - /* 4 */ ".d.....d." - /* 5 */ ".ddddddd." + /* 1 */ ".aaaaaaa." + /* 2 */ ".ak.k..a." + /* 3 */ ".a.....a." + /* 4 */ ".a.....a." + /* 5 */ ".aaaaaaa." /* 6 */ "........." - // Level 4 + // Level 5 /* z\x* 012345678 */ /* 0 */ "lnnnnnnnn" - /* 1 */ "ldddddddo" - /* 2 */ "ldddddddo" - /* 3 */ "ldddddddo" - /* 4 */ "ldddddddo" - /* 5 */ "ldddddddo" + /* 1 */ "laaaaaaao" + /* 2 */ "laaaaaaao" + /* 3 */ "laaaaaaao" + /* 4 */ "laaaaaaao" + /* 5 */ "laaaaaaao" /* 6 */ "ppppppppo", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -597,18 +653,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 28, ID 169, created by Aloe_vera { // Size: - 10, 5, 7, // SizeX = 10, SizeY = 5, SizeZ = 7 + 10, 6, 7, // SizeX = 10, SizeY = 6, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 9, 4, 6, // MaxX, MaxY, MaxZ + 9, 5, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171: 0\n" /* carpet */ "g:171:14\n" /* carpet */ @@ -626,29 +682,40 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Level 0 /* z\x* */ /* * 0123456789 */ - /* 0 */ "..abc....." - /* 1 */ ".dddddddd." - /* 2 */ ".dddddddd." - /* 3 */ ".dddddddd." - /* 4 */ ".dddddddd." - /* 5 */ ".dddddddd." - /* 6 */ ".........." + /* 0 */ "mmaaammmmm" + /* 1 */ "maaaaaaaam" + /* 2 */ "maaaaaaaam" + /* 3 */ "maaaaaaaam" + /* 4 */ "maaaaaaaam" + /* 5 */ "maaaaaaaam" + /* 6 */ "mmmmmmmmmm" // Level 1 /* z\x* */ /* * 0123456789 */ - /* 0 */ ".........." - /* 1 */ ".ddeddddd." - /* 2 */ ".dfghhgfd." - /* 3 */ ".dfhffhfd." - /* 4 */ ".dfghhgfd." - /* 5 */ ".dddddddd." + /* 0 */ "..bcd....." + /* 1 */ ".aaaaaaaa." + /* 2 */ ".aaaaaaaa." + /* 3 */ ".aaaaaaaa." + /* 4 */ ".aaaaaaaa." + /* 5 */ ".aaaaaaaa." /* 6 */ ".........." // Level 2 /* z\x* */ /* * 0123456789 */ /* 0 */ ".........." + /* 1 */ ".aaeaaaaa." + /* 2 */ ".afghhgfa." + /* 3 */ ".afhffhfa." + /* 4 */ ".afghhgfa." + /* 5 */ ".aaaaaaaa." + /* 6 */ ".........." + + // Level 3 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." /* 1 */ ".iijii.ii." /* 2 */ ".i......i." /* 3 */ ".........." @@ -656,30 +723,30 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 5 */ ".ii.ii.ii." /* 6 */ ".........." - // Level 3 + // Level 4 /* z\x* */ /* * 0123456789 */ /* 0 */ ".........." - /* 1 */ ".dddddddd." - /* 2 */ ".dk.k...d." - /* 3 */ ".d......d." - /* 4 */ ".d......d." - /* 5 */ ".dddddddd." + /* 1 */ ".aaaaaaaa." + /* 2 */ ".ak.k...a." + /* 3 */ ".a......a." + /* 4 */ ".a......a." + /* 5 */ ".aaaaaaaa." /* 6 */ ".........." - // Level 4 + // Level 5 /* z\x* */ /* * 0123456789 */ /* 0 */ "lnnnnnnnnn" - /* 1 */ "lddddddddo" - /* 2 */ "lddddddddo" - /* 3 */ "lddddddddo" - /* 4 */ "lddddddddo" - /* 5 */ "lddddddddo" + /* 1 */ "laaaaaaaao" + /* 2 */ "laaaaaaaao" + /* 3 */ "laaaaaaaao" + /* 4 */ "laaaaaaaao" + /* 5 */ "laaaaaaaao" /* 6 */ "pppppppppo", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -710,18 +777,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 29, ID 170, created by Aloe_vera { // Size: - 10, 5, 9, // SizeX = 10, SizeY = 5, SizeZ = 9 + 10, 6, 9, // SizeX = 10, SizeY = 6, SizeZ = 9 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 9, 4, 8, // MaxX, MaxY, MaxZ + 9, 5, 8, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171: 0\n" /* carpet */ "g:171:14\n" /* carpet */ @@ -741,33 +808,46 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Level 0 /* z\x* */ /* * 0123456789 */ - /* 0 */ "..abc....." - /* 1 */ ".dddddddd." - /* 2 */ ".dddddddd." - /* 3 */ ".dddddddd." - /* 4 */ ".dddddddd." - /* 5 */ ".dddddddd." - /* 6 */ ".dddddddd." - /* 7 */ ".dddddddd." - /* 8 */ ".........." + /* 0 */ "mmaaammmmm" + /* 1 */ "maaaaaaaam" + /* 2 */ "maaaaaaaam" + /* 3 */ "maaaaaaaam" + /* 4 */ "maaaaaaaam" + /* 5 */ "maaaaaaaam" + /* 6 */ "maaaaaaaam" + /* 7 */ "maaaaaaaam" + /* 8 */ "mmmmmmmmmm" // Level 1 /* z\x* */ /* * 0123456789 */ - /* 0 */ ".........." - /* 1 */ ".ddeddddd." - /* 2 */ ".dfghhgfd." - /* 3 */ ".dfhffhfd." - /* 4 */ ".dfhgghfd." - /* 5 */ ".dfhffhfd." - /* 6 */ ".dfghhgfd." - /* 7 */ ".dddddddd." + /* 0 */ "..bcd....." + /* 1 */ ".aaaaaaaa." + /* 2 */ ".aaaaaaaa." + /* 3 */ ".aaaaaaaa." + /* 4 */ ".aaaaaaaa." + /* 5 */ ".aaaaaaaa." + /* 6 */ ".aaaaaaaa." + /* 7 */ ".aaaaaaaa." /* 8 */ ".........." // Level 2 /* z\x* */ /* * 0123456789 */ /* 0 */ ".........." + /* 1 */ ".aaeaaaaa." + /* 2 */ ".afghhgfa." + /* 3 */ ".afhffhfa." + /* 4 */ ".afhgghfa." + /* 5 */ ".afhffhfa." + /* 6 */ ".afghhgfa." + /* 7 */ ".aaaaaaaa." + /* 8 */ ".........." + + // Level 3 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ ".........." /* 1 */ ".iijii.ii." /* 2 */ ".i......i." /* 3 */ ".i......i." @@ -777,34 +857,34 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 7 */ ".ii.ii.ii." /* 8 */ ".........." - // Level 3 + // Level 4 /* z\x* */ /* * 0123456789 */ /* 0 */ ".........." - /* 1 */ ".dddddddd." - /* 2 */ ".d..k...d." - /* 3 */ ".d......d." - /* 4 */ ".dl....nd." - /* 5 */ ".d......d." - /* 6 */ ".d......d." - /* 7 */ ".dddddddd." + /* 1 */ ".aaaaaaaa." + /* 2 */ ".a..k...a." + /* 3 */ ".a......a." + /* 4 */ ".al....na." + /* 5 */ ".a......a." + /* 6 */ ".a......a." + /* 7 */ ".aaaaaaaa." /* 8 */ ".........." - // Level 4 + // Level 5 /* z\x* */ /* * 0123456789 */ /* 0 */ "oppppppppp" - /* 1 */ "oddddddddq" - /* 2 */ "oddddddddq" - /* 3 */ "oddddddddq" - /* 4 */ "oddddddddq" - /* 5 */ "oddddddddq" - /* 6 */ "oddddddddq" - /* 7 */ "oddddddddq" + /* 1 */ "oaaaaaaaaq" + /* 2 */ "oaaaaaaaaq" + /* 3 */ "oaaaaaaaaq" + /* 4 */ "oaaaaaaaaq" + /* 5 */ "oaaaaaaaaq" + /* 6 */ "oaaaaaaaaq" + /* 7 */ "oaaaaaaaaq" /* 8 */ "rrrrrrrrrq", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -835,18 +915,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 30, ID 171, created by Aloe_vera { // Size: - 11, 5, 9, // SizeX = 11, SizeY = 5, SizeZ = 9 + 11, 6, 9, // SizeX = 11, SizeY = 6, SizeZ = 9 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 10, 4, 8, // MaxX, MaxY, MaxZ + 10, 5, 8, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:171: 0\n" /* carpet */ "g:171:15\n" /* carpet */ @@ -867,33 +947,46 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..abc......" - /* 1 */ ".ddddddddd." - /* 2 */ ".ddddddddd." - /* 3 */ ".ddddddddd." - /* 4 */ ".ddddddddd." - /* 5 */ ".ddddddddd." - /* 6 */ ".ddddddddd." - /* 7 */ ".ddddddddd." - /* 8 */ "..........." + /* 0 */ "mmaaammmmmm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "maaaaaaaaam" + /* 3 */ "maaaaaaaaam" + /* 4 */ "maaaaaaaaam" + /* 5 */ "maaaaaaaaam" + /* 6 */ "maaaaaaaaam" + /* 7 */ "maaaaaaaaam" + /* 8 */ "mmmmmmmmmmm" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".ddedddddd." - /* 2 */ ".dffgggffd." - /* 3 */ ".dfghhhgfd." - /* 4 */ ".dfghfhgfd." - /* 5 */ ".dfghhhgfd." - /* 6 */ ".dffgggffd." - /* 7 */ ".ddddddddd." + /* 0 */ "..bcd......" + /* 1 */ ".aaaaaaaaa." + /* 2 */ ".aaaaaaaaa." + /* 3 */ ".aaaaaaaaa." + /* 4 */ ".aaaaaaaaa." + /* 5 */ ".aaaaaaaaa." + /* 6 */ ".aaaaaaaaa." + /* 7 */ ".aaaaaaaaa." /* 8 */ "..........." // Level 2 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." + /* 1 */ ".aaeaaaaaa." + /* 2 */ ".affgggffa." + /* 3 */ ".afghhhgfa." + /* 4 */ ".afghfhgfa." + /* 5 */ ".afghhhgfa." + /* 6 */ ".affgggffa." + /* 7 */ ".aaaaaaaaa." + /* 8 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." /* 1 */ ".iijii.iii." /* 2 */ ".i.......i." /* 3 */ ".i.......i." @@ -903,34 +996,34 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 7 */ ".ii.iii.ii." /* 8 */ "..........." - // Level 3 + // Level 4 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ ".ddddddddd." - /* 2 */ ".d..k....d." - /* 3 */ ".d.......d." - /* 4 */ ".dl.....nd." - /* 5 */ ".d.......d." - /* 6 */ ".d...o...d." - /* 7 */ ".ddddddddd." + /* 1 */ ".aaaaaaaaa." + /* 2 */ ".a..k....a." + /* 3 */ ".a.......a." + /* 4 */ ".al.....na." + /* 5 */ ".a.......a." + /* 6 */ ".a...o...a." + /* 7 */ ".aaaaaaaaa." /* 8 */ "..........." - // Level 4 + // Level 5 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "pqqqqqqqqqq" - /* 1 */ "pdddddddddr" - /* 2 */ "pdddddddddr" - /* 3 */ "pdddddddddr" - /* 4 */ "pdddddddddr" - /* 5 */ "pdddddddddr" - /* 6 */ "pdddddddddr" - /* 7 */ "pdddddddddr" + /* 1 */ "paaaaaaaaar" + /* 2 */ "paaaaaaaaar" + /* 3 */ "paaaaaaaaar" + /* 4 */ "paaaaaaaaar" + /* 5 */ "paaaaaaaaar" + /* 6 */ "paaaaaaaaar" + /* 7 */ "paaaaaaaaar" /* 8 */ "ssssssssssr", // Connectors: - "-1: 3, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ diff --git a/src/Generating/RainbowRoadsGen.cpp b/src/Generating/RainbowRoadsGen.cpp index d1e1f4bda..3b0ff7df8 100644 --- a/src/Generating/RainbowRoadsGen.cpp +++ b/src/Generating/RainbowRoadsGen.cpp @@ -29,11 +29,12 @@ class cRainbowRoadsGen::cRainbowRoads : public: cRainbowRoads( int a_Seed, + int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxDepth, int a_MaxSize ) : - super(a_OriginX, a_OriginZ), + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_Seed(a_Seed), m_Noise(a_Seed), m_MaxSize(a_MaxSize), @@ -92,8 +93,8 @@ protected: -cRainbowRoadsGen::cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize) : - super(a_Seed, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 100), +cRainbowRoadsGen::cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 100), m_Noise(a_Seed + 9000), m_MaxDepth(a_MaxDepth), m_MaxSize(a_MaxSize) @@ -104,10 +105,10 @@ cRainbowRoadsGen::cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxDepth, i -cGridStructGen::cStructurePtr cRainbowRoadsGen::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cRainbowRoadsGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { // Create a base based on the chosen prefabs: - return cStructurePtr(new cRainbowRoads(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize)); + return cStructurePtr(new cRainbowRoads(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize)); } diff --git a/src/Generating/RainbowRoadsGen.h b/src/Generating/RainbowRoadsGen.h index acbd5abf9..5813e1d14 100644 --- a/src/Generating/RainbowRoadsGen.h +++ b/src/Generating/RainbowRoadsGen.h @@ -22,7 +22,7 @@ class cRainbowRoadsGen : typedef cGridStructGen super; public: - cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize); + cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize); protected: class cRainbowRoads; // fwd: RainbowRoadsGen.cpp @@ -39,7 +39,7 @@ protected: // cGridStructGen overrides: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index 2722e4ca3..24f2cc3ab 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -61,7 +61,7 @@ class cStructGenRavines::cRavine : public: - cRavine(int a_BlockX, int a_BlockZ, int a_Size, cNoise & a_Noise); + cRavine(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_Size, cNoise & a_Noise); #ifdef _DEBUG /// Exports itself as a SVG line definition @@ -81,7 +81,7 @@ protected: // cStructGenRavines: cStructGenRavines::cStructGenRavines(int a_Seed, int a_Size) : - super(a_Seed, a_Size, a_Size, a_Size * 2, a_Size * 2, 100), + super(a_Seed, a_Size, a_Size, a_Size, a_Size, a_Size * 2, a_Size * 2, 100), m_Noise(a_Seed), m_Size(a_Size) { @@ -91,9 +91,9 @@ cStructGenRavines::cStructGenRavines(int a_Seed, int a_Size) : -cGridStructGen::cStructurePtr cStructGenRavines::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cStructGenRavines::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { - return cStructurePtr(new cRavine(a_OriginX, a_OriginZ, m_Size, m_Noise)); + return cStructurePtr(new cRavine(a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_Size, m_Noise)); } @@ -104,8 +104,8 @@ cGridStructGen::cStructurePtr cStructGenRavines::CreateStructure(int a_OriginX, /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cStructGenRavines::cRavine -cStructGenRavines::cRavine::cRavine(int a_OriginX, int a_OriginZ, int a_Size, cNoise & a_Noise) : - super(a_OriginX, a_OriginZ) +cStructGenRavines::cRavine::cRavine(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_Size, cNoise & a_Noise) : + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ) { // Calculate the ravine shape-defining points: GenerateBaseDefPoints(a_OriginX, a_OriginZ, a_Size, a_Noise); diff --git a/src/Generating/Ravines.h b/src/Generating/Ravines.h index 30b47e9ec..3e41c5ce6 100644 --- a/src/Generating/Ravines.h +++ b/src/Generating/Ravines.h @@ -32,7 +32,7 @@ protected: // cGridStructGen overrides: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Generating/UnderwaterBaseGen.cpp b/src/Generating/UnderwaterBaseGen.cpp index ff6f17dde..d3abae9b7 100644 --- a/src/Generating/UnderwaterBaseGen.cpp +++ b/src/Generating/UnderwaterBaseGen.cpp @@ -29,11 +29,12 @@ class cUnderwaterBaseGen::cUnderwaterBase : public: cUnderwaterBase( int a_Seed, + int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxDepth, int a_MaxSize ) : - super(a_OriginX, a_OriginZ), + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_Seed(a_Seed), m_Noise(a_Seed), m_MaxSize(a_MaxSize), @@ -92,8 +93,8 @@ protected: -cUnderwaterBaseGen::cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen) : - super(a_Seed, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 100), +cUnderwaterBaseGen::cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 100), m_Noise(a_Seed + 1000), m_MaxDepth(a_MaxDepth), m_MaxSize(a_MaxSize), @@ -105,7 +106,7 @@ cUnderwaterBaseGen::cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxDept -cGridStructGen::cStructurePtr cUnderwaterBaseGen::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cUnderwaterBaseGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { // Generate the biomes for the chunk surrounding the origin: int ChunkX, ChunkZ; @@ -134,7 +135,7 @@ cGridStructGen::cStructurePtr cUnderwaterBaseGen::CreateStructure(int a_OriginX, } // for i - Biomes[] // Create a base based on the chosen prefabs: - return cStructurePtr(new cUnderwaterBase(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize)); + return cStructurePtr(new cUnderwaterBase(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize)); } diff --git a/src/Generating/UnderwaterBaseGen.h b/src/Generating/UnderwaterBaseGen.h index 0aefbb4c7..d6267b602 100644 --- a/src/Generating/UnderwaterBaseGen.h +++ b/src/Generating/UnderwaterBaseGen.h @@ -22,7 +22,7 @@ class cUnderwaterBaseGen : typedef cGridStructGen super; public: - cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen); + cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen); protected: class cUnderwaterBase; // fwd: UnderwaterBaseGen.cpp @@ -42,7 +42,7 @@ protected: // cGridStructGen overrides: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index 9917141ed..2b7ecc837 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -110,6 +110,7 @@ class cVillageGen::cVillage : public: cVillage( int a_Seed, + int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxRoadDepth, int a_MaxSize, @@ -119,7 +120,7 @@ public: BLOCKTYPE a_RoadBlock, BLOCKTYPE a_WaterRoadBlock ) : - super(a_OriginX, a_OriginZ), + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_Seed(a_Seed), m_Noise(a_Seed), m_MaxSize(a_MaxSize), @@ -358,8 +359,8 @@ static cVillagePiecePool * g_PlainsVillagePools[] = -cVillageGen::cVillageGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, int a_MinDensity, int a_MaxDensity, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen) : - super(a_Seed, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 100), +cVillageGen::cVillageGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize, int a_MinDensity, int a_MaxDensity, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 100), m_Noise(a_Seed + 1000), m_MaxDepth(a_MaxDepth), m_MaxSize(a_MaxSize), @@ -374,7 +375,7 @@ cVillageGen::cVillageGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSi -cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_OriginZ) +cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { // Generate the biomes for the chunk surrounding the origin: int ChunkX, ChunkZ; @@ -435,7 +436,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_OriginX, int a_ { return cStructurePtr(); } - return cStructurePtr(new cVillage(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, Density, *VillagePrefabs, m_HeightGen, RoadBlock, WaterRoadBlock)); + return cStructurePtr(new cVillage(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, Density, *VillagePrefabs, m_HeightGen, RoadBlock, WaterRoadBlock)); } diff --git a/src/Generating/VillageGen.h b/src/Generating/VillageGen.h index 5faaae8a6..694ea2358 100644 --- a/src/Generating/VillageGen.h +++ b/src/Generating/VillageGen.h @@ -21,7 +21,7 @@ class cVillageGen : { typedef cGridStructGen super; public: - cVillageGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize, int a_MinDensity, int a_MaxDensity, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen); + cVillageGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize, int a_MinDensity, int a_MaxDensity, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen); protected: class cVillage; // fwd: VillageGen.cpp @@ -49,7 +49,7 @@ protected: // cGridStructGen overrides: - virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; } ; diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index f20f396f2..69c8b9f56 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -59,19 +59,21 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, int RelZ = 0; BLOCKTYPE Block; NIBBLETYPE Meta; + cChunk * Chunk; if (a_OtherChunk != NULL) { RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width; RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width; a_OtherChunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta); - a_OtherChunk->SetIsRedstoneDirty(true); + Chunk = a_OtherChunk; } else { RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width; RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width; a_Chunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta); + Chunk = a_Chunk; } // Every time a block is changed (AddBlock called), we want to go through all lists and check to see if the coordiantes stored within are still valid @@ -90,7 +92,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list as it no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = PoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); + Chunk->SetIsRedstoneDirty(true); continue; } else if ( @@ -105,9 +107,25 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = PoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); + Chunk->SetIsRedstoneDirty(true); continue; } + else if (Block == E_BLOCK_DAYLIGHT_SENSOR) + { + if (!m_World.IsChunkLighted(Chunk->GetPosX(), Chunk->GetPosZ())) + { + m_World.QueueLightChunk(Chunk->GetPosX(), Chunk->GetPosZ()); + } + else + { + if (Chunk->GetTimeAlteredLight(Chunk->GetSkyLight(RelX, a_BlockY + 1, RelZ)) <= 7) + { + itr = PoweredBlocks->erase(itr); + Chunk->SetIsRedstoneDirty(true); + continue; + } + } + } ++itr; } @@ -121,7 +139,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); + Chunk->SetIsRedstoneDirty(true); continue; } else if ( @@ -135,7 +153,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); + Chunk->SetIsRedstoneDirty(true); continue; } } @@ -145,7 +163,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer powered through a valid middle block", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); + Chunk->SetIsRedstoneDirty(true); continue; } } @@ -788,12 +806,12 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int { WereItrsChanged = QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false); } - else if (a_Itr != m_RepeatersDelayList->end()) + else if (a_Itr == m_RepeatersDelayList->end()) { return; } } - else if (a_Itr != m_RepeatersDelayList->end()) + else if (a_Itr == m_RepeatersDelayList->end()) { return; } @@ -1145,6 +1163,10 @@ void cIncrementalRedstoneSimulator::HandleDaylightSensor(int a_RelBlockX, int a_ { SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); } + else + { + WakeUp(BlockX, a_RelBlockY, BlockZ, m_Chunk); + } } } -- cgit v1.2.3 From 3a7c0c8ce9ff323690293dda6c8d2066db7ba985 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 16 Jun 2014 15:29:49 +0100 Subject: Fixed tigers weird enums --- src/Simulator/IncrementalRedstoneSimulator.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 2e73195f1..79c23a7ba 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -501,20 +501,12 @@ void cIncrementalRedstoneSimulator::HandleRedstoneLever(int a_RelBlockX, int a_R eBlockFace Dir = cBlockLeverHandler::BlockMetaDataToBlockFace(Meta); switch (Dir) // Now, flip the direction into the type used by SetBlockLinkedPowered() { - case BLOCK_FACE_YP: - case BLOCK_FACE_XP: - case BLOCK_FACE_ZP: - { - Dir--; - break; - } - case BLOCK_FACE_XM: - case BLOCK_FACE_ZM: - case BLOCK_FACE_YM: - { - Dir++; - break; - } + case BLOCK_FACE_YP: Dir = BLOCK_FACE_YM; break; + case BLOCK_FACE_XP: Dir = BLOCK_FACE_XM; break; + case BLOCK_FACE_ZP: Dir = BLOCK_FACE_ZM; break; + case BLOCK_FACE_YM: Dir = BLOCK_FACE_YP; break; + case BLOCK_FACE_XM: Dir = BLOCK_FACE_XP; break; + case BLOCK_FACE_ZM :Dir = BLOCK_FACE_ZP; break; default: { ASSERT(!"Unhandled lever metadata!"); -- cgit v1.2.3 From d379f27ea483a23bf6065e4bc668e82c915fa511 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 16 Jun 2014 16:51:30 +0200 Subject: Fixed gcc compilation. --- src/ChunkMap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 5aad0dd2a..f02dd3302 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -450,7 +450,7 @@ private: /** The cChunkStay descendants that are currently enabled in this chunkmap */ cChunkStays m_ChunkStays; - std::auto_ptr> m_Pool; + std::auto_ptr > m_Pool; cChunkPtr GetChunk (int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Also queues the chunk for loading / generating if not valid cChunkPtr GetChunkNoGen (int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Also queues the chunk for loading if not valid; doesn't generate -- cgit v1.2.3 From 6fa99a211ec792ea4dbb4a303a26608de2cd5990 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 16 Jun 2014 17:55:58 +0100 Subject: Refactored reversing logic into seperate function --- src/Defines.h | 15 +++++++++++++-- src/Simulator/IncrementalRedstoneSimulator.cpp | 17 +++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/Defines.h b/src/Defines.h index 563fc308c..ee91ee596 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -274,8 +274,19 @@ inline eBlockFace RotateBlockFaceCW(eBlockFace a_BlockFace) } } - - +inline eBlockFace ReverseBlockFace(eBlockFace a_BlockFace) +{ + switch (a_BlockFace) + { + case BLOCK_FACE_YP: return BLOCK_FACE_YM; + case BLOCK_FACE_XP: return BLOCK_FACE_XM; + case BLOCK_FACE_ZP: return BLOCK_FACE_ZM; + case BLOCK_FACE_YM: return BLOCK_FACE_YP; + case BLOCK_FACE_XM: return BLOCK_FACE_XP; + case BLOCK_FACE_ZM: return BLOCK_FACE_ZP; + default: return a_BlockFace; + } +} /** Returns the textual representation of the BlockFace constant. */ diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 79c23a7ba..a49d0fb50 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -499,20 +499,9 @@ void cIncrementalRedstoneSimulator::HandleRedstoneLever(int a_RelBlockX, int a_R SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); eBlockFace Dir = cBlockLeverHandler::BlockMetaDataToBlockFace(Meta); - switch (Dir) // Now, flip the direction into the type used by SetBlockLinkedPowered() - { - case BLOCK_FACE_YP: Dir = BLOCK_FACE_YM; break; - case BLOCK_FACE_XP: Dir = BLOCK_FACE_XM; break; - case BLOCK_FACE_ZP: Dir = BLOCK_FACE_ZM; break; - case BLOCK_FACE_YM: Dir = BLOCK_FACE_YP; break; - case BLOCK_FACE_XM: Dir = BLOCK_FACE_XP; break; - case BLOCK_FACE_ZM :Dir = BLOCK_FACE_ZP; break; - default: - { - ASSERT(!"Unhandled lever metadata!"); - return; - } - } + + Dir = ReverseBlockFace(Dir); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Dir); } } -- cgit v1.2.3 From 74cd73058955683c277baf29f3cd7378c79292a9 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 16 Jun 2014 18:06:09 +0100 Subject: FIxed second weird enum --- src/Simulator/IncrementalRedstoneSimulator.cpp | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index a49d0fb50..1e7ff543d 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -549,26 +549,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneButton(int a_RelBlockX, int a_ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); eBlockFace Dir = cBlockButtonHandler::BlockMetaDataToBlockFace(Meta); - switch (Dir) // Now, flip the direction into the type used by SetBlockLinkedPowered() - { - case BLOCK_FACE_XP: - case BLOCK_FACE_ZP: - { - Dir--; - break; - } - case BLOCK_FACE_XM: - case BLOCK_FACE_ZM: - { - Dir++; - break; - } - default: - { - ASSERT(!"Unhandled button metadata!"); - return; - } - } + Dir = ReverseBlockFace(Dir); SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Dir); } } -- cgit v1.2.3 From e50423991e56f1edb0954f2db066acd1f27b4ed7 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 16 Jun 2014 21:57:23 +0200 Subject: Add bow charging animation --- src/Entities/Player.cpp | 6 +++++- src/Entities/Player.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index fdc0bb390..978517086 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1,4 +1,4 @@ - + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Player.h" @@ -411,6 +411,7 @@ void cPlayer::StartChargingBow(void) LOGD("Player \"%s\" started charging their bow", GetName().c_str()); m_IsChargingBow = true; m_BowCharge = 0; + m_World->BroadcastEntityMetadata(*this, m_ClientHandle); } @@ -423,6 +424,8 @@ int cPlayer::FinishChargingBow(void) int res = m_BowCharge; m_IsChargingBow = false; m_BowCharge = 0; + m_World->BroadcastEntityMetadata(*this, m_ClientHandle); + return res; } @@ -435,6 +438,7 @@ void cPlayer::CancelChargingBow(void) LOGD("Player \"%s\" cancelled charging their bow at a charge of %d", GetName().c_str(), m_BowCharge); m_IsChargingBow = false; m_BowCharge = 0; + m_World->BroadcastEntityMetadata(*this, m_ClientHandle); } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index b2142a18b..2f7957f16 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -404,7 +404,7 @@ public: // cEntity overrides: virtual bool IsCrouched (void) const { return m_IsCrouched; } virtual bool IsSprinting(void) const { return m_IsSprinting; } - virtual bool IsRclking (void) const { return IsEating(); } + virtual bool IsRclking (void) const { return IsEating() || IsChargingBow(); } virtual void Detach(void); -- cgit v1.2.3 From 9c3086d88c3bc593a378c0ea8eecb912aecde2ec Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 16 Jun 2014 22:42:50 +0200 Subject: Fixed MSVC builds. --- src/ChunkDef.cpp | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 src/ChunkDef.cpp (limited to 'src') diff --git a/src/ChunkDef.cpp b/src/ChunkDef.cpp deleted file mode 100644 index 367f66ccc..000000000 --- a/src/ChunkDef.cpp +++ /dev/null @@ -1,9 +0,0 @@ - -#include "Globals.h" - -#include "ChunkDef.h" - -// It appears that failing to have this definition causes link errors as cChunkDef::Height is not -// defined. It also appears that we can have the initalizer in the declaration so it can be inlined -// if the declaration is in a class???? -const int cChunkDef::Height; -- cgit v1.2.3 From d6979ad95d2430e78c8e3ccef376704516814da0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 16 Jun 2014 22:53:08 +0200 Subject: Fixed GCC compilation. --- src/LightingThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index d3873ab3c..33bc08467 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -23,7 +23,7 @@ class cReader : BLOCKTYPE * OutputRows = m_BlockTypes; int InputIdx = 0; int OutputIdx = m_ReadingChunkX + m_ReadingChunkZ * cChunkDef::Width * 3; - int MaxHeight = std::min(cChunkDef::Height, m_MaxHeight + 16); // Need 16 blocks above the highest + int MaxHeight = std::min(+cChunkDef::Height, m_MaxHeight + 16); // Need 16 blocks above the highest for (int y = 0; y < MaxHeight; y++) { for (int z = 0; z < cChunkDef::Width; z++) -- cgit v1.2.3 From 885a50d77a26eea6619de681bf6ee746e79308cd Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 16 Jun 2014 22:57:13 +0200 Subject: Fix bow sound and creative arrow pickup. --- src/Entities/ArrowEntity.cpp | 32 ++++++++++++++++++++++---------- src/Items/ItemBow.h | 17 ++++++++--------- 2 files changed, 30 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 8d2569125..bdbaaab0d 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -3,6 +3,7 @@ #include "Player.h" #include "ArrowEntity.h" #include "../Chunk.h" +#include "FastRandom.h" @@ -24,9 +25,9 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a SetYawFromSpeed(); SetPitchFromSpeed(); LOGD("Created arrow %d with speed {%.02f, %.02f, %.02f} and rot {%.02f, %.02f}", - m_UniqueID, GetSpeedX(), GetSpeedY(), GetSpeedZ(), - GetYaw(), GetPitch() - ); + m_UniqueID, GetSpeedX(), GetSpeedY(), GetSpeedZ(), + GetYaw(), GetPitch() + ); } @@ -44,6 +45,10 @@ cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) : m_bIsCollected(false), m_HitBlockPos(0, 0, 0) { + if (a_Player.IsGameModeCreative()) + { + m_PickupState = psInCreative; + } } @@ -120,16 +125,23 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) void cArrowEntity::CollectedBy(cPlayer * a_Dest) { - if ((m_IsInGround) && (!m_bIsCollected) && (CanPickup(*a_Dest))) + if (m_IsInGround && !m_bIsCollected && CanPickup(*a_Dest)) { - int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW); - if (NumAdded > 0) // Only play effects if there was space in inventory + if (m_PickupState == 1) { - m_World->BroadcastCollectPickup((const cPickup &)*this, *a_Dest); - // Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;) - m_World->BroadcastSoundEffect("random.pop", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); - m_bIsCollected = true; + int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW); + if (NumAdded == 0) + { + // No space in the inventory + return; + } } + + m_World->BroadcastCollectPickup((const cPickup &)*this, *a_Dest); + m_bIsCollected = true; + + cFastRandom Random; + m_World->BroadcastSoundEffect("random.pop", (int)std::floor(GetPosX() * 8.0), (int)std::floor(GetPosY() * 8), (int)std::floor(GetPosZ() * 8), 0.2F, ((Random.NextFloat(1.0F) - Random.NextFloat(1.0F)) * 0.7F + 1.0F) * 2.0F); } } diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index e0ab339d3..a8fac13cc 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -46,20 +46,17 @@ public: { // Actual shot - produce the arrow with speed based on the ticks that the bow was charged ASSERT(a_Player != NULL); - + int BowCharge = a_Player->FinishChargingBow(); - double Force = (double)BowCharge / 20; - Force = (Force * Force + 2 * Force) / 3; // This formula is used by the 1.6.2 client + double Force = (double)BowCharge / 20.0; + Force = (Force * Force + 2.0 * Force) / 3.0; // This formula is used by the 1.6.2 client if (Force < 0.1) { // Too little force, ignore the shot return; } - if (Force > 1) - { - Force = 1; - } - + Force = std::max(Force, 1.0); + // Create the arrow entity: cArrowEntity * Arrow = new cArrowEntity(*a_Player, Force * 2); if (Arrow == NULL) @@ -71,8 +68,10 @@ public: delete Arrow; return; } + + cFastRandom Random; a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow); - a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)a_Player->GetPosX() * 8, (int)a_Player->GetPosY() * 8, (int)a_Player->GetPosZ() * 8, 0.5, (float)Force); + a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)std::floor(a_Player->GetPosX() * 8.0), (int)std::floor(a_Player->GetPosY() * 8.0), (int)std::floor(a_Player->GetPosZ() * 8.0), 1.0F, 1.0F / (Random.NextFloat(1.0F) * 0.4F + 1.2F) + (float)Force * 0.5F); if (!a_Player->IsGameModeCreative()) { -- cgit v1.2.3 From b45e85a6784861e225c7a4ecfd7838a6d32c7875 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 16 Jun 2014 22:57:27 +0200 Subject: This isn't needed --- src/Items/ItemBow.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index a8fac13cc..a2f740ba7 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -70,7 +70,6 @@ public: } cFastRandom Random; - a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow); a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)std::floor(a_Player->GetPosX() * 8.0), (int)std::floor(a_Player->GetPosY() * 8.0), (int)std::floor(a_Player->GetPosZ() * 8.0), 1.0F, 1.0F / (Random.NextFloat(1.0F) * 0.4F + 1.2F) + (float)Force * 0.5F); if (!a_Player->IsGameModeCreative()) -- cgit v1.2.3 From 7c4b8306aaf02e2aaa8acc70432f6f9636076f3e Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 16 Jun 2014 23:05:29 +0200 Subject: Glass shouldn't drop. --- src/Blocks/BlockHandler.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 304e35e84..4440e39a9 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -130,6 +130,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_GLOWSTONE: return new cBlockGlowstoneHandler (a_BlockType); case E_BLOCK_GOLD_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_GLASS: return new cBlockGlassHandler (a_BlockType); + case E_BLOCK_GLASS_PANE: return new cBlockGlassHandler (a_BlockType); case E_BLOCK_GRASS: return new cBlockDirtHandler (a_BlockType); case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType); case E_BLOCK_HAY_BALE: return new cBlockSidewaysHandler (a_BlockType); @@ -186,6 +187,8 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_SIGN_POST: return new cBlockSignHandler (a_BlockType); case E_BLOCK_SNOW: return new cBlockSnowHandler (a_BlockType); case E_BLOCK_SPRUCE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); + case E_BLOCK_STAINED_GLASS: return new cBlockGlassHandler (a_BlockType); + case E_BLOCK_STAINED_GLASS_PANE: return new cBlockGlassHandler (a_BlockType); case E_BLOCK_STATIONARY_LAVA: return new cBlockLavaHandler (a_BlockType); case E_BLOCK_STATIONARY_WATER: return new cBlockFluidHandler (a_BlockType); case E_BLOCK_STICKY_PISTON: return new cBlockPistonHandler (a_BlockType); -- cgit v1.2.3 From 9dea609194e27d282480ca56be99f0becec8d899 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 16 Jun 2014 23:35:30 +0200 Subject: Fix doubleslab meta. --- src/Blocks/BlockSlab.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 80841b094..f3f2366fd 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -80,6 +80,7 @@ public: if (IsAnySlabType(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ))) { a_BlockType = GetDoubleSlabType(m_BlockType); + a_BlockMeta = a_BlockMeta & 0x7; } return true; -- cgit v1.2.3 From a1fd0b0335a5b19af29a4862f4d0ac39bec6887f Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 16 Jun 2014 23:41:23 +0200 Subject: Split Broadcast Sound Effect function call in multiple lines. --- src/Entities/ArrowEntity.cpp | 18 ++++++++++++++++-- src/Items/ItemBow.h | 9 ++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index bdbaaab0d..7f2c8dca5 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -114,7 +114,14 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1); // Broadcast successful hit sound - m_World->BroadcastSoundEffect("random.successful_hit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + m_World->BroadcastSoundEffect( + "random.successful_hit", + (int)std::floor(GetPosX() * 8.0), + (int)std::floor(GetPosY() * 8.0), + (int)std::floor(GetPosZ() * 8.0), + 0.5, + (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64) + ); Destroy(); } @@ -141,7 +148,14 @@ void cArrowEntity::CollectedBy(cPlayer * a_Dest) m_bIsCollected = true; cFastRandom Random; - m_World->BroadcastSoundEffect("random.pop", (int)std::floor(GetPosX() * 8.0), (int)std::floor(GetPosY() * 8), (int)std::floor(GetPosZ() * 8), 0.2F, ((Random.NextFloat(1.0F) - Random.NextFloat(1.0F)) * 0.7F + 1.0F) * 2.0F); + m_World->BroadcastSoundEffect( + "random.pop", + (int)std::floor(GetPosX() * 8.0), + (int)std::floor(GetPosY() * 8), + (int)std::floor(GetPosZ() * 8), + 0.2F, + ((Random.NextFloat(1.0F) - Random.NextFloat(1.0F)) * 0.7F + 1.0F) * 2.0F + ); } } diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index a2f740ba7..d79fecd30 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -70,7 +70,14 @@ public: } cFastRandom Random; - a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)std::floor(a_Player->GetPosX() * 8.0), (int)std::floor(a_Player->GetPosY() * 8.0), (int)std::floor(a_Player->GetPosZ() * 8.0), 1.0F, 1.0F / (Random.NextFloat(1.0F) * 0.4F + 1.2F) + (float)Force * 0.5F); + a_Player->GetWorld()->BroadcastSoundEffect( + "random.bow", + (int)std::floor(a_Player->GetPosX() * 8.0), + (int)std::floor(a_Player->GetPosY() * 8.0), + (int)std::floor(a_Player->GetPosZ() * 8.0), + 1.0F, + 1.0F / (Random.NextFloat(1.0F) * 0.4F + 1.2F) + (float)Force * 0.5F + ); if (!a_Player->IsGameModeCreative()) { -- cgit v1.2.3 From a10b716ba2c0c50cd15bff7a1981e6b8c5e896bd Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 00:22:57 +0200 Subject: Fix fence gate redstone simulator. --- src/Simulator/IncrementalRedstoneSimulator.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 69c8b9f56..b8da978f2 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -546,8 +546,7 @@ void cIncrementalRedstoneSimulator::HandleFenceGate(int a_RelBlockX, int a_RelBl { int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; - cChunkInterface ChunkInterface(m_World.GetChunkMap()); - NIBBLETYPE MetaData = ChunkInterface.GetBlockMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); + NIBBLETYPE MetaData = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) { -- cgit v1.2.3 From 43ff96f66494dd1719d7bdb1d0f0c3957e5f61b7 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 00:40:35 +0200 Subject: Add pressure plate handler --- src/BlockInfo.cpp | 2 ++ src/Blocks/BlockHandler.cpp | 5 +++++ src/Blocks/BlockPressurePlate.h | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 src/Blocks/BlockPressurePlate.h (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index e8d9a7ec4..564b3fcca 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -341,6 +341,8 @@ void cBlockInfo::Initialize(void) ms_Info[E_BLOCK_DANDELION ].m_IsSolid = false; ms_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false; ms_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false; + ms_Info[E_BLOCK_FENCE ].m_IsSolid = false; + ms_Info[E_BLOCK_FENCE_GATE ].m_IsSolid = false; ms_Info[E_BLOCK_FIRE ].m_IsSolid = false; ms_Info[E_BLOCK_FLOWER ].m_IsSolid = false; ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false; diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 304e35e84..521de5684 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -56,6 +56,7 @@ #include "BlockPlanks.h" #include "BlockPortal.h" #include "BlockPumpkin.h" +#include "BlockPressurePlate.h" #include "BlockQuartz.h" #include "BlockRail.h" #include "BlockRedstone.h" @@ -134,6 +135,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType); case E_BLOCK_HAY_BALE: return new cBlockSidewaysHandler (a_BlockType); case E_BLOCK_HEAD: return new cBlockMobHeadHandler (a_BlockType); + case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler(a_BlockType); case E_BLOCK_HOPPER: return new cBlockHopperHandler (a_BlockType); case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType); case E_BLOCK_INACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType); @@ -149,6 +151,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType); case E_BLOCK_LILY_PAD: return new cBlockLilypadHandler (a_BlockType); case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType); + case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler(a_BlockType); case E_BLOCK_LOG: return new cBlockSidewaysHandler (a_BlockType); case E_BLOCK_MELON: return new cBlockMelonHandler (a_BlockType); case E_BLOCK_MELON_STEM: return new cBlockStemsHandler (a_BlockType); @@ -192,6 +195,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_STONE: return new cBlockStoneHandler (a_BlockType); case E_BLOCK_STONE_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_STONE_BUTTON: return new cBlockButtonHandler (a_BlockType); + case E_BLOCK_STONE_PRESSURE_PLATE: return new cBlockPressurePlateHandler (a_BlockType); case E_BLOCK_STONE_SLAB: return new cBlockSlabHandler (a_BlockType); case E_BLOCK_SUGARCANE: return new cBlockSugarcaneHandler (a_BlockType); case E_BLOCK_TALL_GRASS: return new cBlockTallGrassHandler (a_BlockType); @@ -203,6 +207,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType); case E_BLOCK_WOODEN_BUTTON: return new cBlockButtonHandler (a_BlockType); case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (a_BlockType); + case E_BLOCK_WOODEN_PRESSURE_PLATE: return new cBlockPressurePlateHandler (a_BlockType); case E_BLOCK_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType); case E_BLOCK_WOODEN_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_WOOL: return new cBlockClothHandler (a_BlockType); diff --git a/src/Blocks/BlockPressurePlate.h b/src/Blocks/BlockPressurePlate.h new file mode 100644 index 000000000..2e6754cdb --- /dev/null +++ b/src/Blocks/BlockPressurePlate.h @@ -0,0 +1,34 @@ + +#pragma once + +#include "BlockHandler.h" + + + + +class cBlockPressurePlateHandler : + public cBlockHandler +{ +public: + cBlockPressurePlateHandler(BLOCKTYPE a_BlockType) + : cBlockHandler(a_BlockType) + { + } + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + // Reset meta to 0 + a_Pickups.push_back(cItem(m_BlockType, 1, 0)); + } + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override + { + if (a_RelY <= 0) + { + return false; + } + BLOCKTYPE BlockBelow = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ); + + return (BlockBelow == E_BLOCK_FENCE_GATE || BlockBelow == E_BLOCK_FENCE || cBlockInfo::IsSolid(BlockBelow)); + } +}; \ No newline at end of file -- cgit v1.2.3 From 1316d2d24d2760f191a873e35959aee209b70f87 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 00:41:31 +0200 Subject: Add end lines to BlockPressurePlate.h --- src/Blocks/BlockPressurePlate.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Blocks/BlockPressurePlate.h b/src/Blocks/BlockPressurePlate.h index 2e6754cdb..01d5e8174 100644 --- a/src/Blocks/BlockPressurePlate.h +++ b/src/Blocks/BlockPressurePlate.h @@ -31,4 +31,8 @@ public: return (BlockBelow == E_BLOCK_FENCE_GATE || BlockBelow == E_BLOCK_FENCE || cBlockInfo::IsSolid(BlockBelow)); } -}; \ No newline at end of file +} ; + + + + -- cgit v1.2.3 From a89524d5330ffbdbaea1d38421dabe8d8f62999e Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 01:15:38 +0200 Subject: Add DoWithBlockEntityAt() to WorldInterface.h --- src/Blocks/BlockMobHead.h | 89 ++++++++++++++++++++++++++------------------- src/Blocks/WorldInterface.h | 9 +++++ src/ChunkMap.h | 4 +- src/World.h | 2 +- 4 files changed, 64 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index fe4099835..34a92c150 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -30,48 +30,58 @@ public: return; } - class cCallback : public cMobHeadCallback + class cCallback : public cBlockEntityCallback { - virtual bool Item(cMobHeadEntity * a_MobHeadEntity) + virtual bool Item(cBlockEntity * a_BlockEntity) { + cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); + if (MobHeadEntity == NULL) + { + return false; + } + cItems Pickups; - Pickups.Add(E_ITEM_HEAD, 1, (short) a_MobHeadEntity->GetType()); + Pickups.Add(E_ITEM_HEAD, 1, (short) MobHeadEntity->GetType()); MTRand r1; // Mid-block position first double MicroX, MicroY, MicroZ; - MicroX = a_MobHeadEntity->GetPosX() + 0.5; - MicroY = a_MobHeadEntity->GetPosY() + 0.5; - MicroZ = a_MobHeadEntity->GetPosZ() + 0.5; + MicroX = MobHeadEntity->GetPosX() + 0.5; + MicroY = MobHeadEntity->GetPosY() + 0.5; + MicroZ = MobHeadEntity->GetPosZ() + 0.5; // Add random offset second MicroX += r1.rand(1) - 0.5; MicroZ += r1.rand(1) - 0.5; - a_MobHeadEntity->GetWorld()->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ); + MobHeadEntity->GetWorld()->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ); return false; } } Callback; - cWorld * World = (cWorld *) &a_WorldInterface; - World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, Callback); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, Callback); } - bool TrySpawnWither(cChunkInterface & a_ChunkInterface, cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) + bool TrySpawnWither(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { if (a_BlockY < 2) { return false; } - class cCallback : public cMobHeadCallback + class cCallback : public cBlockEntityCallback { bool m_IsWither; - virtual bool Item (cMobHeadEntity * a_MobHeadEntity) + virtual bool Item (cBlockEntity * a_BlockEntity) { - m_IsWither = (a_MobHeadEntity->GetType() == SKULL_TYPE_WITHER); + cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); + if (MobHeadEntity == NULL) + { + return false; + } + m_IsWither = (MobHeadEntity->GetType() == SKULL_TYPE_WITHER); return false; } @@ -105,7 +115,7 @@ public: } PlayerCallback(Vector3f(a_BlockX, a_BlockY, a_BlockZ)); - a_World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, CallbackA); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, CallbackA); if (!CallbackA.IsWither()) { @@ -122,8 +132,8 @@ public: return false; } - a_World->DoWithMobHeadAt(a_BlockX - 1, a_BlockY, a_BlockZ, CallbackA); - a_World->DoWithMobHeadAt(a_BlockX + 1, a_BlockY, a_BlockZ, CallbackB); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX - 1, a_BlockY, a_BlockZ, CallbackA); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX + 1, a_BlockY, a_BlockZ, CallbackB); BLOCKTYPE Block1 = a_ChunkInterface.GetBlock(a_BlockX - 1, a_BlockY - 1, a_BlockZ); BLOCKTYPE Block2 = a_ChunkInterface.GetBlock(a_BlockX + 1, a_BlockY - 1, a_BlockZ); @@ -136,15 +146,15 @@ public: a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0); // Block entities - a_World->SetBlock(a_BlockX + 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); - a_World->SetBlock(a_BlockX - 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX + 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX - 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); // Spawn the wither: - a_World->SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); + a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); // Award Achievement - a_World->ForEachPlayer(PlayerCallback); + a_WorldInterface.ForEachPlayer(PlayerCallback); return true; } @@ -152,8 +162,8 @@ public: CallbackA.Reset(); CallbackB.Reset(); - a_World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ - 1, CallbackA); - a_World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ + 1, CallbackB); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ - 1, CallbackA); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ + 1, CallbackB); Block1 = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ - 1); Block2 = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ + 1); @@ -166,15 +176,15 @@ public: a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0); // Block entities - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ + 1, E_BLOCK_AIR, 0); - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ - 1, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ + 1, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ - 1, E_BLOCK_AIR, 0); // Spawn the wither: - a_World->SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); + a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); // Award Achievement - a_World->ForEachPlayer(PlayerCallback); + a_WorldInterface.ForEachPlayer(PlayerCallback); return true; } @@ -189,23 +199,29 @@ public: BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) override { - class cCallback : public cMobHeadCallback + class cCallback : public cBlockEntityCallback { cPlayer * m_Player; NIBBLETYPE m_OldBlockMeta; NIBBLETYPE m_NewBlockMeta; - virtual bool Item (cMobHeadEntity * a_MobHeadEntity) + virtual bool Item (cBlockEntity * a_BlockEntity) { + cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); + if (MobHeadEntity == NULL) + { + return false; + } + int Rotation = 0; if (m_NewBlockMeta == 1) { Rotation = (int) floor(m_Player->GetYaw() * 16.0F / 360.0F + 0.5) & 0xF; } - - a_MobHeadEntity->SetType(static_cast(m_OldBlockMeta)); - a_MobHeadEntity->SetRotation(static_cast(Rotation)); - a_MobHeadEntity->GetWorld()->BroadcastBlockEntity(a_MobHeadEntity->GetPosX(), a_MobHeadEntity->GetPosY(), a_MobHeadEntity->GetPosZ()); + + MobHeadEntity->SetType(static_cast(m_OldBlockMeta)); + MobHeadEntity->SetRotation(static_cast(Rotation)); + MobHeadEntity->GetWorld()->BroadcastBlockEntity(MobHeadEntity->GetPosX(), MobHeadEntity->GetPosY(), MobHeadEntity->GetPosZ()); return false; } @@ -219,8 +235,7 @@ public: cCallback Callback(a_Player, a_BlockMeta, static_cast(a_BlockFace)); a_BlockMeta = (NIBBLETYPE)a_BlockFace; - cWorld * World = (cWorld *) &a_WorldInterface; - World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, Callback); + a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, Callback); a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockMeta); if (a_BlockMeta == SKULL_TYPE_WITHER) @@ -235,7 +250,7 @@ public: }; for (size_t i = 0; i < ARRAYCOUNT(Coords); ++i) { - if (TrySpawnWither(a_ChunkInterface, World, a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z)) + if (TrySpawnWither(a_ChunkInterface, a_WorldInterface, a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z)) { break; } diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h index bfbb053d9..650a216c0 100644 --- a/src/Blocks/WorldInterface.h +++ b/src/Blocks/WorldInterface.h @@ -6,6 +6,12 @@ class cItems; +typedef cItemCallback cBlockEntityCallback; + + + + + class cWorldInterface { public: @@ -29,6 +35,9 @@ public: /** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */ virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eType a_MonsterType) = 0; + /** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */ + virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback) = 0; + /** Sends the block on those coords to the player */ virtual void SendBlockTo(int a_BlockX, int a_BlockY, int a_BlockZ, cPlayer * a_Player) = 0; diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 9d973f2a9..adcf687c0 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -34,8 +34,8 @@ class cBlockArea; class cMobCensus; class cMobSpawner; -typedef std::list cClientHandleList; -typedef cChunk * cChunkPtr; +typedef std::list cClientHandleList; +typedef cChunk * cChunkPtr; typedef cItemCallback cEntityCallback; typedef cItemCallback cBlockEntityCallback; typedef cItemCallback cChestCallback; diff --git a/src/World.h b/src/World.h index 86cbb3e7e..cd465bece 100644 --- a/src/World.h +++ b/src/World.h @@ -511,7 +511,7 @@ public: virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData) override; // tolua_export /** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */ - bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback); // Exported in ManualBindings.cpp + virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback) override; // Exported in ManualBindings.cpp /** Calls the callback for the chest at the specified coords; returns false if there's no chest at those coords, true if found */ bool DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback & a_Callback); // Exported in ManualBindings.cpp -- cgit v1.2.3 From 46b84aa8b63015a5a553f4b7a1905582e25cc2e1 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 01:17:35 +0200 Subject: The motion is already set in AddBasicEntity() --- src/WorldStorage/NBTChunkSerializer.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 82e8ee8bd..6e1bf41aa 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -614,11 +614,6 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) case cProjectileEntity::pkWitherSkull: case cProjectileEntity::pkEnderPearl: { - m_Writer.BeginList("Motion", TAG_Double); - m_Writer.AddDouble("", a_Projectile->GetSpeedX()); - m_Writer.AddDouble("", a_Projectile->GetSpeedY()); - m_Writer.AddDouble("", a_Projectile->GetSpeedZ()); - m_Writer.EndList(); break; } default: -- cgit v1.2.3 From 1086b8ba05a3ed604423f8222a8a1834324006d2 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 01:18:09 +0200 Subject: Revert "Fix right click bugs." This reverts commit 61b6fdde7553dac6e2d5c5a071b9a13fa0d71b2f. --- src/ClientHandle.cpp | 81 ++++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 9a7d1cd62..06c389d99 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1089,49 +1089,11 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e ); cWorld * World = m_Player->GetWorld(); - m_NumBlockChangeInteractionsThisTick++; - - if (!CheckBlockInteractionsRate()) - { - Kick("Too many blocks were placed/interacted with per unit time - hacked client?"); - return; - } - - const cItem & Equipped = m_Player->GetInventory().GetEquippedItem(); - if ((Equipped.m_ItemType != a_HeldItem.m_ItemType) && (a_HeldItem.m_ItemType != -1)) - { - // Only compare ItemType, not meta (torches have different metas) - // The -1 check is there because sometimes the client sends -1 instead of the held item - // ( http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 ) - LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)", - m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType - ); - - // Let's send the current world block to the client, so that it can immediately "let the user know" that they haven't placed the block - if (a_BlockFace != BLOCK_FACE_NONE) - { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - } - return; - } - - BLOCKTYPE BlockType; - NIBBLETYPE BlockMeta; - World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); - cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); - cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType); if ( - ( - BlockHandler->IsUseable() || - (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE)) - ) && - ( - (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || - (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || - (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) - ) + (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || + (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || + (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) ) { if (a_BlockFace != BLOCK_FACE_NONE) @@ -1149,6 +1111,8 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e { // A plugin doesn't agree with the action, replace the block on the client and quit: cChunkInterface ChunkInterface(World->GetChunkMap()); + BLOCKTYPE BlockType = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); BlockHandler->OnCancelRightClick(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); if (a_BlockFace != BLOCK_FACE_NONE) @@ -1160,6 +1124,39 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e } return; } + + m_NumBlockChangeInteractionsThisTick++; + + if (!CheckBlockInteractionsRate()) + { + Kick("Too many blocks were placed/interacted with per unit time - hacked client?"); + return; + } + + const cItem & Equipped = m_Player->GetInventory().GetEquippedItem(); + + if ((Equipped.m_ItemType != a_HeldItem.m_ItemType) && (a_HeldItem.m_ItemType != -1)) + { + // Only compare ItemType, not meta (torches have different metas) + // The -1 check is there because sometimes the client sends -1 instead of the held item + // ( http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 ) + LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)", + m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType + ); + + // Let's send the current world block to the client, so that it can immediately "let the user know" that they haven't placed the block + if (a_BlockFace != BLOCK_FACE_NONE) + { + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + } + return; + } + + BLOCKTYPE BlockType; + NIBBLETYPE BlockMeta; + World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); + cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); if (BlockHandler->IsUseable() && !m_Player->IsCrouched()) { @@ -1174,6 +1171,8 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e return; } + cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType); + if (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE)) { HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); -- cgit v1.2.3 From d89f03b90c60c2aaae3f937f5b84dc3c8f2f6ad1 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 12:43:45 +0200 Subject: Float, not Double --- src/Entities/ArrowEntity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 7f2c8dca5..ea782940a 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -119,7 +119,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) (int)std::floor(GetPosX() * 8.0), (int)std::floor(GetPosY() * 8.0), (int)std::floor(GetPosZ() * 8.0), - 0.5, + 0.5F, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64) ); -- cgit v1.2.3 From 37de63895f029342b92923d08585aa8f4fdae2ea Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 12:45:12 +0200 Subject: The same: Float, not Double --- src/Entities/ArrowEntity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index ea782940a..9a8571a31 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -120,7 +120,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) (int)std::floor(GetPosY() * 8.0), (int)std::floor(GetPosZ() * 8.0), 0.5F, - (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64) + 0.75F + ((float)((GetUniqueID() * 23) % 32)) / 64F ); Destroy(); -- cgit v1.2.3 From a4d4621fbe6dbab3e2202f17e8f0b384120041e0 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 12:47:18 +0200 Subject: Add parenthesis --- src/Blocks/BlockPressurePlate.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockPressurePlate.h b/src/Blocks/BlockPressurePlate.h index 01d5e8174..adec36eb6 100644 --- a/src/Blocks/BlockPressurePlate.h +++ b/src/Blocks/BlockPressurePlate.h @@ -27,9 +27,9 @@ public: { return false; } - BLOCKTYPE BlockBelow = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ); - return (BlockBelow == E_BLOCK_FENCE_GATE || BlockBelow == E_BLOCK_FENCE || cBlockInfo::IsSolid(BlockBelow)); + BLOCKTYPE BlockBelow = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ); + return ((BlockBelow == E_BLOCK_FENCE_GATE) || (BlockBelow == E_BLOCK_FENCE) || cBlockInfo::IsSolid(BlockBelow)); } } ; -- cgit v1.2.3 From da88c980347aac9562e3f4862ba76948d4d6f120 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 13:25:36 +0200 Subject: Add comment. --- src/ClientHandle.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 06c389d99..683ee418c 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -954,6 +954,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc m_LastDigBlockY = a_BlockY; m_LastDigBlockZ = a_BlockZ; + // Check for clickthrough-blocks: if (a_BlockFace != BLOCK_FACE_NONE) { int pX = a_BlockX; -- cgit v1.2.3 From 8928310fd8308c583609edd1cb111276ffe79f8e Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 17 Jun 2014 13:27:04 +0200 Subject: Fixed possible confusion. If a command handler gets an error then the player will receive an unknown command error. This can be confusing for players. --- src/Bindings/PluginManager.cpp | 8 +++++++- src/Bindings/PluginManager.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 9bcd8e3b7..f9035e869 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1356,7 +1356,13 @@ bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command ASSERT(cmd->second.m_Plugin != NULL); - return cmd->second.m_Plugin->HandleCommand(Split, a_Player); + if (!cmd->second.m_Plugin->HandleCommand(Split, a_Player)) + { + a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", Split[0].c_str())); + return true; // The command handler was found and executed, so we return true. + } + + return true; } diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index be40bd2f7..0b0498280 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -321,7 +321,7 @@ private: /** Adds the plugin into the internal list of plugins and initializes it. If initialization fails, the plugin is removed again. */ bool AddPlugin(cPlugin * a_Plugin); - /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns true if the command is handled. */ + /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns true if the command is executed. */ bool HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions, bool & a_WasCommandForbidden); bool HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions) { -- cgit v1.2.3 From ce06ec1632ffb15243e2270ed31632e8d3566f39 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 13:33:41 +0200 Subject: derp --- src/Entities/ArrowEntity.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 9a8571a31..e46d21515 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -119,8 +119,8 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) (int)std::floor(GetPosX() * 8.0), (int)std::floor(GetPosY() * 8.0), (int)std::floor(GetPosZ() * 8.0), - 0.5F, - 0.75F + ((float)((GetUniqueID() * 23) % 32)) / 64F + 0.5f, + 0.75f + ((float)((GetUniqueID() * 23) % 32)) / 64.0f ); Destroy(); @@ -134,7 +134,7 @@ void cArrowEntity::CollectedBy(cPlayer * a_Dest) { if (m_IsInGround && !m_bIsCollected && CanPickup(*a_Dest)) { - if (m_PickupState == 1) + if (m_PickupState == psInSurvivalOrCreative) { int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW); if (NumAdded == 0) -- cgit v1.2.3 From 7e985f3c7d0a301fafdef01e31553e7215c72e5b Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 13:44:07 +0200 Subject: Add more documentation. --- src/ClientHandle.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 683ee418c..664bcf875 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -955,6 +955,8 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc m_LastDigBlockZ = a_BlockZ; // Check for clickthrough-blocks: + /* When the user breaks a fire block, the client send the wrong block location. + We must find the right block with the face direction. */ if (a_BlockFace != BLOCK_FACE_NONE) { int pX = a_BlockX; -- cgit v1.2.3 From 8e927e6e2bfb461b26a3413cbde829f98fbcaa28 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 14:45:29 +0200 Subject: Check block type from cBlockEntity --- src/Blocks/BlockMobHead.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index 34a92c150..68996aa3f 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -34,11 +34,11 @@ public: { virtual bool Item(cBlockEntity * a_BlockEntity) { - cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); - if (MobHeadEntity == NULL) + if (a_BlockEntity->GetBlockType() != E_BLOCK_HEAD) { return false; } + cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); cItems Pickups; Pickups.Add(E_ITEM_HEAD, 1, (short) MobHeadEntity->GetType()); @@ -73,13 +73,13 @@ public: { bool m_IsWither; - virtual bool Item (cBlockEntity * a_BlockEntity) + virtual bool Item(cBlockEntity * a_BlockEntity) { - cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); - if (MobHeadEntity == NULL) + if (a_BlockEntity->GetBlockType() != E_BLOCK_HEAD) { return false; } + cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); m_IsWither = (MobHeadEntity->GetType() == SKULL_TYPE_WITHER); return false; @@ -205,13 +205,13 @@ public: NIBBLETYPE m_OldBlockMeta; NIBBLETYPE m_NewBlockMeta; - virtual bool Item (cBlockEntity * a_BlockEntity) + virtual bool Item(cBlockEntity * a_BlockEntity) { - cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); - if (MobHeadEntity == NULL) + if (a_BlockEntity->GetBlockType() != E_BLOCK_HEAD) { return false; } + cMobHeadEntity * MobHeadEntity = static_cast(a_BlockEntity); int Rotation = 0; if (m_NewBlockMeta == 1) -- cgit v1.2.3 From 15ae4ce23371ec6bc1b1f61f4dd7c4ffbd1adf64 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 17 Jun 2014 14:55:15 +0200 Subject: HandleCommand now returns an CommandResult enum. --- src/Bindings/PluginManager.cpp | 28 +++++++++++----------------- src/Bindings/PluginManager.h | 14 ++++++++------ 2 files changed, 19 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index f9035e869..abbb05ae0 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -257,18 +257,13 @@ bool cPluginManager::CallHookBlockToPickups( bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message) { - bool WasCommandForbidden = false; - if (HandleCommand(a_Player, a_Message, true, WasCommandForbidden)) // We use HandleCommand as opposed to ExecuteCommand to accomodate the need to the WasCommandForbidden bool + if (HandleCommand(a_Player, a_Message, true) != crUnknownCommand) // We use HandleCommand as opposed to ExecuteCommand to accomodate the need to the WasCommandForbidden bool { return true; // Chat message was handled as command } - else if (WasCommandForbidden) // Couldn't be handled as command, was it because of insufficient permissions? - { - return true; // Yes - message was sent in HandleCommand, abort - } // Check if it was a standard command (starts with a slash) - // If it was, we know that it was completely unrecognised (WasCommandForbidden == false) + // If it was, we know that it was completely unrecognised if (!a_Message.empty() && (a_Message[0] == '/')) { AStringVector Split(StringSplit(a_Message, " ")); @@ -1318,28 +1313,28 @@ bool cPluginManager::CallHookWorldTick(cWorld & a_World, float a_Dt, int a_LastT -bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions, bool & a_WasCommandForbidden) +cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions) { ASSERT(a_Player != NULL); AStringVector Split(StringSplit(a_Command, " ")); if (Split.empty()) { - return false; + return crUnknownCommand; } CommandMap::iterator cmd = m_Commands.find(Split[0]); if (cmd == m_Commands.end()) { // Command not found - return false; + return crUnknownCommand; } // Ask plugins first if a command is okay to execute the command: if (CallHookExecuteCommand(a_Player, Split)) { LOGINFO("Player %s tried executing command \"%s\" that was stopped by the HOOK_EXECUTE_COMMAND hook", a_Player->GetName().c_str(), Split[0].c_str()); - return false; + return crError; } if ( @@ -1350,8 +1345,7 @@ bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command { a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", Split[0].c_str())); LOGINFO("Player %s tried to execute forbidden command: \"%s\"", a_Player->GetName().c_str(), Split[0].c_str()); - a_WasCommandForbidden = true; - return false; + return crError; } ASSERT(cmd->second.m_Plugin != NULL); @@ -1359,10 +1353,10 @@ bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command if (!cmd->second.m_Plugin->HandleCommand(Split, a_Player)) { a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", Split[0].c_str())); - return true; // The command handler was found and executed, so we return true. + return crError; } - return true; + return crExecuted; } @@ -1561,7 +1555,7 @@ AString cPluginManager::GetCommandPermission(const AString & a_Command) bool cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Command) { - return HandleCommand(a_Player, a_Command, true); + return (HandleCommand(a_Player, a_Command, true) == crExecuted); } @@ -1570,7 +1564,7 @@ bool cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Comman bool cPluginManager::ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command) { - return HandleCommand(a_Player, a_Command, false); + return (HandleCommand(a_Player, a_Command, false) == crExecuted); } diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 0b0498280..049e70b49 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -58,6 +58,13 @@ public: // tolua_export // Called each tick virtual void Tick(float a_Dt); + enum CommandResult + { + crExecuted, + crUnknownCommand, + crError, + } ; + // tolua_begin enum PluginHook { @@ -322,12 +329,7 @@ private: bool AddPlugin(cPlugin * a_Plugin); /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns true if the command is executed. */ - bool HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions, bool & a_WasCommandForbidden); - bool HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions) - { - bool DummyBoolean = false; - return HandleCommand(a_Player, a_Command, a_ShouldCheckPermissions, DummyBoolean); - } + cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions); } ; // tolua_export -- cgit v1.2.3 From 008a6ce311d3020927d5ef4b0d53905df48bcae5 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 17 Jun 2014 16:19:31 +0200 Subject: Added crBlocked and crNoPermission --- src/Bindings/PluginManager.cpp | 4 ++-- src/Bindings/PluginManager.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index abbb05ae0..c317ae362 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1334,7 +1334,7 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player, if (CallHookExecuteCommand(a_Player, Split)) { LOGINFO("Player %s tried executing command \"%s\" that was stopped by the HOOK_EXECUTE_COMMAND hook", a_Player->GetName().c_str(), Split[0].c_str()); - return crError; + return crBlocked; } if ( @@ -1345,7 +1345,7 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player, { a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", Split[0].c_str())); LOGINFO("Player %s tried to execute forbidden command: \"%s\"", a_Player->GetName().c_str(), Split[0].c_str()); - return crError; + return crNoPermission; } ASSERT(cmd->second.m_Plugin != NULL); diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 049e70b49..96b7a979b 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -63,6 +63,8 @@ public: // tolua_export crExecuted, crUnknownCommand, crError, + crBlocked, + crNoPermission, } ; // tolua_begin -- cgit v1.2.3 From 0d08b9a62e1516e0f725791e42c3123cecf7028f Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 17:00:51 +0200 Subject: Add door sound --- src/Blocks/BlockDoor.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp index fb2d6f2dc..2d7c849c6 100644 --- a/src/Blocks/BlockDoor.cpp +++ b/src/Blocks/BlockDoor.cpp @@ -48,6 +48,7 @@ void cBlockDoorHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterfac if (a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_DOOR) { ChangeDoor(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); + a_Player->GetWorld()->BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle()); } } -- cgit v1.2.3 From 8de8768f02b5d9b066aa935d47c851552b6c7341 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 17:01:23 +0200 Subject: Add UNUSED() Tags --- src/Blocks/BlockDoor.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp index 2d7c849c6..934a01994 100644 --- a/src/Blocks/BlockDoor.cpp +++ b/src/Blocks/BlockDoor.cpp @@ -45,6 +45,12 @@ void cBlockDoorHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldIn void cBlockDoorHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { + UNUSED(a_WorldInterface); + UNUSED(a_BlockFace); + UNUSED(a_CursorX); + UNUSED(a_CursorY); + UNUSED(a_CursorZ); + if (a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_DOOR) { ChangeDoor(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); -- cgit v1.2.3 From bde51d87784b37b5a900a40085350ce5080f402c Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 19:08:36 +0200 Subject: Add fence gate sound. --- src/Blocks/BlockFenceGate.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Blocks/BlockFenceGate.h b/src/Blocks/BlockFenceGate.h index e202c6610..e992870d4 100644 --- a/src/Blocks/BlockFenceGate.h +++ b/src/Blocks/BlockFenceGate.h @@ -45,6 +45,7 @@ public: // Standing aside - use last direction a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, OldMetaData); } + a_Player->GetWorld()->BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle()); } -- cgit v1.2.3 From bcf798f260d55b6c8ce8e71ed619048c3e595877 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 19:47:32 +0200 Subject: Fix fence gate sound (Redstone simulator). --- src/Simulator/IncrementalRedstoneSimulator.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 69c8b9f56..542bff8ad 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -553,8 +553,11 @@ void cIncrementalRedstoneSimulator::HandleFenceGate(int a_RelBlockX, int a_RelBl { if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true)) { - m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MetaData | 0x4); - m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + if ((MetaData & 0x4) == 0) + { + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MetaData | 0x4); + m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + } SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true); } } @@ -562,8 +565,11 @@ void cIncrementalRedstoneSimulator::HandleFenceGate(int a_RelBlockX, int a_RelBl { if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false)) { - m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MetaData & 0xFFFFFFFB); - m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + if ((MetaData & 0x4) != 0) + { + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MetaData & 0xFFFFFFFB); + m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + } SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false); } } -- cgit v1.2.3 From c1692a2e3be114c2807fdaaea0fa4fcd3d4bbc5d Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 00:16:33 -0700 Subject: Added classes for splash potions and wither skulls --- src/Entities/ProjectileEntity.cpp | 4 ++++ src/Entities/SplashPotionEntity.cpp | 37 ++++++++++++++++++++++++++++++++++ src/Entities/SplashPotionEntity.h | 34 +++++++++++++++++++++++++++++++ src/Entities/WitherSkullEntity.cpp | 40 +++++++++++++++++++++++++++++++++++++ src/Entities/WitherSkullEntity.h | 34 +++++++++++++++++++++++++++++++ 5 files changed, 149 insertions(+) create mode 100644 src/Entities/SplashPotionEntity.cpp create mode 100644 src/Entities/SplashPotionEntity.h create mode 100644 src/Entities/WitherSkullEntity.cpp create mode 100644 src/Entities/WitherSkullEntity.h (limited to 'src') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 95c494569..ee3890f23 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -18,9 +18,11 @@ #include "ThrownEnderPearlEntity.h" #include "ExpBottleEntity.h" #include "ThrownSnowballEntity.h" +#include "SplashPotionEntity.h" #include "FireChargeEntity.h" #include "FireworkEntity.h" #include "GhastFireballEntity.h" +#include "WitherSkullEntity.h" @@ -250,6 +252,8 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator, case pkGhastFireball: return new cGhastFireballEntity (a_Creator, a_X, a_Y, a_Z, Speed); case pkFireCharge: return new cFireChargeEntity (a_Creator, a_X, a_Y, a_Z, Speed); case pkExpBottle: return new cExpBottleEntity (a_Creator, a_X, a_Y, a_Z, Speed); + case pkSplashPotion: return new cSplashPotionEntity (a_Creator, a_X, a_Y, a_Z, Speed); + case pkWitherSkull: return new cWitherSkullEntity (a_Creator, a_X, a_Y, a_Z, Speed); case pkFirework: { if (a_Item.m_FireworkItem.m_Colours.empty()) diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp new file mode 100644 index 000000000..c6be2baf7 --- /dev/null +++ b/src/Entities/SplashPotionEntity.cpp @@ -0,0 +1,37 @@ +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "SplashPotionEntity.h" +#include "../World.h" + + + + + +cSplashPotionEntity::cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : +super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) +{ + SetSpeed(a_Speed); +} + + + + + +void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) +{ + // TODO: Apply potion effect to entities nearby + Destroy(); +} + + + + + +void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) +{ + a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1); + + // TODO: Apply potion effect to entity and others nearby + + Destroy(true); +} diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h new file mode 100644 index 000000000..d82a7bfcd --- /dev/null +++ b/src/Entities/SplashPotionEntity.h @@ -0,0 +1,34 @@ +// +// SplashPotionEntity.h +// + +#pragma once + +#include "ProjectileEntity.h" + + + + + +// tolua_begin + +class cSplashPotionEntity : +public cProjectileEntity +{ + typedef cProjectileEntity super; + +public: + + // tolua_end + + CLASS_PROTODEF(cSplashPotionEntity); + + cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + +protected: + + // cProjectileEntity overrides: + virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; + virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; + +} ; // tolua_export diff --git a/src/Entities/WitherSkullEntity.cpp b/src/Entities/WitherSkullEntity.cpp new file mode 100644 index 000000000..ea78bba5d --- /dev/null +++ b/src/Entities/WitherSkullEntity.cpp @@ -0,0 +1,40 @@ +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "WitherSkullEntity.h" +#include "../World.h" + + + + + +cWitherSkullEntity::cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : +super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) +{ + SetSpeed(a_Speed); +} + + + + + +void cWitherSkullEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) +{ + // TODO: Explode + // TODO: Apply wither effect to entities nearby + Destroy(); +} + + + + + +void cWitherSkullEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) +{ + // TODO: If entity is Ender Crystal, destroy it + a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1); + + // TODO: Explode + // TODO: Apply wither effect to entity and others nearby + + Destroy(true); +} diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h new file mode 100644 index 000000000..85ba55d4d --- /dev/null +++ b/src/Entities/WitherSkullEntity.h @@ -0,0 +1,34 @@ +// +// WitherSkullEntity.h +// + +#pragma once + +#include "ProjectileEntity.h" + + + + + +// tolua_begin + +class cWitherSkullEntity : +public cProjectileEntity +{ + typedef cProjectileEntity super; + +public: + + // tolua_end + + CLASS_PROTODEF(cWitherSkullEntity); + + cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + +protected: + + // cProjectileEntity overrides: + virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; + virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; + +} ; // tolua_export -- cgit v1.2.3 From 87b1bfaf2aa62bf600293d11d0b3c73cfe9f9e33 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 00:17:49 -0700 Subject: Moved Effects.h to EntityEffects.h, added initial impl --- src/Bindings/AllToLua.pkg | 2 +- src/CMakeLists.txt | 2 +- src/Entities/Effects.h | 30 ------------------------ src/Entities/EntityEffects.cpp | 25 ++++++++++++++++++++ src/Entities/EntityEffects.h | 53 ++++++++++++++++++++++++++++++++++++++++++ src/Entities/Pawn.cpp | 25 ++++++++++++++++++++ src/Entities/Pawn.h | 7 ++++++ src/Entities/Player.cpp | 6 ++--- src/Globals.h | 1 - 9 files changed, 115 insertions(+), 36 deletions(-) delete mode 100644 src/Entities/Effects.h create mode 100644 src/Entities/EntityEffects.cpp create mode 100644 src/Entities/EntityEffects.h (limited to 'src') diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg index 4fe86e1c5..4a6eb7535 100644 --- a/src/Bindings/AllToLua.pkg +++ b/src/Bindings/AllToLua.pkg @@ -40,7 +40,7 @@ $cfile "../Entities/Painting.h" $cfile "../Entities/Pickup.h" $cfile "../Entities/ProjectileEntity.h" $cfile "../Entities/TNTEntity.h" -$cfile "../Entities/Effects.h" +$cfile "../Entities/EntityEffects.h" $cfile "../Server.h" $cfile "../World.h" $cfile "../Inventory.h" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 335ce8315..3d5a0e396 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,7 +42,7 @@ set(BINDING_DEPENDECIES Cuboid.h Defines.h Enchantments.h - Entities/Effects.h + Entities/EntityEffects.h Entities/Entity.h Entities/Floater.h Entities/Pawn.h diff --git a/src/Entities/Effects.h b/src/Entities/Effects.h deleted file mode 100644 index baf3302fb..000000000 --- a/src/Entities/Effects.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -// tolua_begin -enum ENUM_ENTITY_EFFECT -{ - E_EFFECT_SPEED = 1, - E_EFFECT_SLOWNESS = 2, - E_EFFECT_HASTE = 3, - E_EFFECT_MINING_FATIGUE = 4, - E_EFFECT_STENGTH = 5, - E_EFFECT_INSTANT_HEALTH = 6, - E_EFFECT_INSTANT_DAMAGE = 7, - E_EFFECT_JUMP_BOOST = 8, - E_EFFECT_NAUSEA = 9, - E_EFFECT_REGENERATION = 10, - E_EFFECT_RESISTANCE = 11, - E_EFFECT_FIRE_RESISTANCE = 12, - E_EFFECT_WATER_BREATHING = 13, - E_EFFECT_INVISIBILITY = 14, - E_EFFECT_BLINDNESS = 15, - E_EFFECT_NIGHT_VISION = 16, - E_EFFECT_HUNGER = 17, - E_EFFECT_WEAKNESS = 18, - E_EFFECT_POISON = 19, - E_EFFECT_WITHER = 20, - E_EFFECT_HEALTH_BOOST = 21, - E_EFFECT_ABSORPTION = 22, - E_EFFECT_SATURATION = 23, -} ; -// tolua_end diff --git a/src/Entities/EntityEffects.cpp b/src/Entities/EntityEffects.cpp new file mode 100644 index 000000000..3aa3fd1ed --- /dev/null +++ b/src/Entities/EntityEffects.cpp @@ -0,0 +1,25 @@ +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "EntityEffects.h" + + + + + +cEntityEffect::cEntityEffect(): + m_Ticks(0), + m_Intensity(0) +{ + +} + + + + + +cEntityEffect::cEntityEffect(int a_Ticks, short a_Intensity): + m_Ticks(a_Ticks), + m_Intensity(a_Intensity) +{ + +} diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h new file mode 100644 index 000000000..6ddd86b01 --- /dev/null +++ b/src/Entities/EntityEffects.h @@ -0,0 +1,53 @@ +#pragma once + +// tolua_begin +class cEntityEffect { +public: + + /** All types of entity effects (numbers correspond to IDs) */ + enum eType + { + efSpeed = 1, + efSlowness = 2, + efHaste = 3, + efMiningFatigue = 4, + efStrength = 5, + efInstantHealth = 6, + efInstantDamage = 7, + efJumpBoost = 8, + efNausia = 9, + efRegeneration = 10, + efResistance = 11, + efFireResistance = 12, + efWaterBreathing = 13, + efInvisibility = 14, + efBlindness = 15, + efNightVision = 16, + efHunger = 17, + efWeakness = 18, + efPoison = 19, + efWither = 20, + efHealthBoost = 21, + efAbsorption = 22, + efSaturation = 23, + } ; + + /** The duration of the effect */ + int m_Ticks; + + /** How strong the effect will be applied */ + short m_Intensity; + + /** + * An empty entity effect + */ + cEntityEffect(); + + /** + * An entity effect + * @param a_Ticks The duration of the effect + * @param a_Intensity How strong the effect will be applied + */ + cEntityEffect(int a_Ticks, short a_Intensity); +}; +// tolua_end diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index fffefd538..e1ddca27e 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -10,6 +10,7 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) : cEntity(a_EntityType, 0, 0, 0, a_Width, a_Height) , m_bBurnable(true) + , m_EntityEffects(std::map()) { } @@ -17,3 +18,27 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) +void cPawn::Tick(float a_Dt, cChunk & a_Chunk) +{ + + + super::Tick(a_Dt, a_Chunk); +} + + + + + +void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) +{ + m_EntityEffects[a_EffectType] = a_Effect; +} + + + + + +void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType) +{ + m_EntityEffects.erase(a_EffectType); +} diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index e76337d86..7824a06f8 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -2,6 +2,7 @@ #pragma once #include "Entity.h" +#include "EntityEffects.h" @@ -18,9 +19,15 @@ public: CLASS_PROTODEF(cPawn); cPawn(eEntityType a_EntityType, double a_Width, double a_Height); + + virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + + void AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect); + void RemoveEntityEffect(cEntityEffect::eType a_EffectType); protected: bool m_bBurnable; + std::map m_EntityEffects; } ; // tolua_export diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index fdc0bb390..035973a16 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -584,12 +584,12 @@ void cPlayer::FoodPoison(int a_NumTicks) m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks); if (!HasBeenFoodPoisoned) { - m_World->BroadcastRemoveEntityEffect(*this, E_EFFECT_HUNGER); + m_World->BroadcastRemoveEntityEffect(*this, cEntityEffect::efHunger); SendHealth(); } else { - m_World->BroadcastEntityEffect(*this, E_EFFECT_HUNGER, 0, 400); // Give the player the "Hunger" effect for 20 seconds. + m_World->BroadcastEntityEffect(*this, cEntityEffect::efHunger, 0, 400); // Give the player the "Hunger" effect for 20 seconds. } } @@ -1930,7 +1930,7 @@ void cPlayer::HandleFood(void) } else { - m_World->BroadcastRemoveEntityEffect(*this, E_EFFECT_HUNGER); // Remove the "Hunger" effect. + m_World->BroadcastRemoveEntityEffect(*this, cEntityEffect::efHunger); // Remove the "Hunger" effect. } // Apply food exhaustion that has accumulated: diff --git a/src/Globals.h b/src/Globals.h index c5768facf..e99333693 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -368,6 +368,5 @@ T Clamp(T a_Value, T a_Min, T a_Max) #include "BiomeDef.h" #include "BlockID.h" #include "BlockInfo.h" -#include "Entities/Effects.h" -- cgit v1.2.3 From aa7b3f33b939e6a43af713549e7b3bf28d0f5ab5 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 19:09:33 -0700 Subject: cPawn: Remove unused m_bBurnable --- src/Entities/Pawn.cpp | 1 - src/Entities/Pawn.h | 1 - 2 files changed, 2 deletions(-) (limited to 'src') diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index e1ddca27e..13934d943 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -9,7 +9,6 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) : cEntity(a_EntityType, 0, 0, 0, a_Width, a_Height) - , m_bBurnable(true) , m_EntityEffects(std::map()) { } diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index 7824a06f8..a954f4a70 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -26,7 +26,6 @@ public: void RemoveEntityEffect(cEntityEffect::eType a_EffectType); protected: - bool m_bBurnable; std::map m_EntityEffects; } ; // tolua_export -- cgit v1.2.3 From 90145a95144a7895fe9a2d7bb1d5c7a192f3a0ad Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 20:02:39 -0700 Subject: Added iterator on tick to manage entity effect duration --- src/Entities/Pawn.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 13934d943..95d1b113e 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -19,7 +19,22 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) void cPawn::Tick(float a_Dt, cChunk & a_Chunk) { - + // Iterate through this entity's applied effects + for (std::map::iterator iter = m_EntityEffects.begin(); + iter != m_EntityEffects.end(); + ++iter) + { + // Reduce the effect's duration + iter->second.m_Ticks--; + + // Remove effect if duration has elapsed + if (iter->second.m_Ticks <= 0) + { + RemoveEntityEffect(iter->first); + } + + // TODO: Check for discrepancies between client and server effect values + } super::Tick(a_Dt, a_Chunk); } @@ -31,6 +46,7 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk) void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) { m_EntityEffects[a_EffectType] = a_Effect; + //m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.m_Intensity, a_Effect.m_Ticks); } @@ -40,4 +56,5 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_E void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType) { m_EntityEffects.erase(a_EffectType); + //m_World->BroadcastRemoveEntityEffect(*this, a_EffectType); } -- cgit v1.2.3 From 481f05b011230cba42901df939306b803bd670b6 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 21:48:20 -0700 Subject: Entity effects: Added handlers for entity effects Implemented hunger, instant health, damage, poison, regen Added "template" entity effect implementations --- src/Entities/Pawn.cpp | 95 +++++++++++++++++++++++++++++++++++++++++++++++++ src/Entities/Pawn.h | 2 ++ src/Entities/Player.cpp | 51 +++++++++++++++++++------- src/Entities/Player.h | 3 ++ 4 files changed, 138 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 95d1b113e..1d2542d58 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -24,6 +24,9 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk) iter != m_EntityEffects.end(); ++iter) { + // Apply entity effect + HandleEntityEffects(iter->first, iter->second); + // Reduce the effect's duration iter->second.m_Ticks--; @@ -58,3 +61,95 @@ void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType) m_EntityEffects.erase(a_EffectType); //m_World->BroadcastRemoveEntityEffect(*this, a_EffectType); } + + + + + +void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) +{ + switch (a_EffectType) + { + // Default effect behaviors + case cEntityEffect::efInstantHealth: + { + // Base heal = 6, doubles for every increase in intensity + Heal(6 * std::pow(2, a_Effect.GetIntensity())); + + // TODO: Harms undead + return; + } + case cEntityEffect::efInstantDamage: + { + // Base damage = 6, doubles for every increase in intensity + int damage = 6 * std::pow(2, a_Effect.GetIntensity()); + TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0); + + // TODO: Heals undead + return; + } + case cEntityEffect::efStrength: + { + // TODO: Implement me! + return; + } + case cEntityEffect::efWeakness: + { + // Damage reduction = 0.5 damage, multiplied by potion level (Weakness II = 1 damage) + //double dmg_reduc = 0.5 * (a_Effect.GetIntensity() + 1); + + // TODO: Implement me! + // TODO: Weakened villager zombies can be turned back to villagers with the god apple + return; + } + case cEntityEffect::efRegeneration: + { + // Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks) + int frequency = std::floor(50.0 / (double)(a_Effect.GetIntensity() + 1)); + + static short counter = 0; + if (++counter >= frequency) + { + Heal(1); + counter = 0; + } + + // TODO: Doesn't effect undead + return; + } + case cEntityEffect::efPoison: + { + // Poison frequency = 25 ticks, divided by potion level (Poison II = 25 ticks) + int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1)); + + static short counter = 0; + if (++counter >= frequency) + { + // Cannot take poison damage when health is at 1 + if (GetHealth() > 1) + { + TakeDamage(dtPoisoning, a_Effect.GetUser(), 1, 0); + } + counter = 0; + } + + // TODO: Doesn't effect undead or spiders + return; + } + case cEntityEffect::efFireResistance: + { + // TODO: Implement me! + return; + } + case cEntityEffect::efSpeed: + { + // TODO: Implement me! + return; + } + case cEntityEffect::efSlowness: + { + // TODO: Implement me! + return; + } + } +} diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index a954f4a70..f7d7213ff 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -27,6 +27,8 @@ public: protected: std::map m_EntityEffects; + + virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect); } ; // tolua_export diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 035973a16..95ee8b39d 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -584,12 +584,11 @@ void cPlayer::FoodPoison(int a_NumTicks) m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks); if (!HasBeenFoodPoisoned) { - m_World->BroadcastRemoveEntityEffect(*this, cEntityEffect::efHunger); SendHealth(); } else { - m_World->BroadcastEntityEffect(*this, cEntityEffect::efHunger, 0, 400); // Give the player the "Hunger" effect for 20 seconds. + AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, 400)); // Give the player the "Hunger" effect for 20 seconds. } } @@ -1887,6 +1886,43 @@ void cPlayer::TickBurning(cChunk & a_Chunk) +void cPlayer::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) +{ + switch (a_EffectType) + { + // Effects whose behaviors are overridden + case cEntityEffect::efMiningFatigue: + { + // TODO: Implement me! + return; + } + case cEntityEffect::efHunger: + { + m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick + return; + } + case cEntityEffect::efSaturation: + { + // Increase saturation 1 per tick, adds 1 for every increase in level + m_FoodSaturationLevel += (1 + a_Effect.GetIntensity()); + return; + } + + // Client-side-only effects + case cEntityEffect::efNausia: + case cEntityEffect::efNightVision: + { + return; + } + } + + super::HandleEntityEffects(a_EffectType, a_Effect); +} + + + + + void cPlayer::HandleFood(void) { // Ref.: http://www.minecraftwiki.net/wiki/Hunger @@ -1921,17 +1957,6 @@ void cPlayer::HandleFood(void) } } } - - // Apply food poisoning food exhaustion: - if (m_FoodPoisonedTicksRemaining > 0) - { - m_FoodPoisonedTicksRemaining--; - m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick - } - else - { - m_World->BroadcastRemoveEntityEffect(*this, cEntityEffect::efHunger); // Remove the "Hunger" effect. - } // Apply food exhaustion that has accumulated: if (m_FoodExhaustionLevel >= 4) diff --git a/src/Entities/Player.h b/src/Entities/Player.h index b2142a18b..88f732096 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -526,6 +526,9 @@ protected: /** Stops players from burning in creative mode */ virtual void TickBurning(cChunk & a_Chunk) override; + /** Called each tick to handle entity effects*/ + virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override; + /** Called in each tick to handle food-related processing */ void HandleFood(void); -- cgit v1.2.3 From 2123173202554487386697625342b7ba21744960 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 21:55:23 -0700 Subject: Player: Removed food-poisoning-specific code, set duration to 30 seconds http://minecraft.gamepedia.com/Hunger#Behavior --- src/Entities/Player.cpp | 21 +-------------------- src/Entities/Player.h | 7 +------ src/Items/ItemHandler.cpp | 2 +- 3 files changed, 3 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 95ee8b39d..3a1ebf3f9 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -40,7 +40,6 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) , m_FoodSaturationLevel(5) , m_FoodTickTimer(0) , m_FoodExhaustionLevel(0) - , m_FoodPoisonedTicksRemaining(0) , m_LastJumpHeight(0) , m_LastGroundHeight(0) , m_bTouchGround(false) @@ -551,15 +550,6 @@ void cPlayer::SetFoodExhaustionLevel(double a_FoodExhaustionLevel) -void cPlayer::SetFoodPoisonedTicksRemaining(int a_FoodPoisonedTicksRemaining) -{ - m_FoodPoisonedTicksRemaining = a_FoodPoisonedTicksRemaining; -} - - - - - bool cPlayer::Feed(int a_Food, double a_Saturation) { if (m_FoodLevel >= MAX_FOOD_LEVEL) @@ -580,16 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation) void cPlayer::FoodPoison(int a_NumTicks) { - bool HasBeenFoodPoisoned = (m_FoodPoisonedTicksRemaining > 0); - m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks); - if (!HasBeenFoodPoisoned) - { - SendHealth(); - } - else - { - AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, 400)); // Give the player the "Hunger" effect for 20 seconds. - } + AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, a_NumTicks)); } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 88f732096..83114a4dd 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -267,7 +267,6 @@ public: double GetFoodSaturationLevel (void) const { return m_FoodSaturationLevel; } int GetFoodTickTimer (void) const { return m_FoodTickTimer; } double GetFoodExhaustionLevel (void) const { return m_FoodExhaustionLevel; } - int GetFoodPoisonedTicksRemaining(void) const { return m_FoodPoisonedTicksRemaining; } /** Returns true if the player is satiated, i. e. their foodlevel is at the max and they cannot eat anymore */ bool IsSatiated(void) const { return (m_FoodLevel >= MAX_FOOD_LEVEL); } @@ -276,7 +275,6 @@ public: void SetFoodSaturationLevel (double a_FoodSaturationLevel); void SetFoodTickTimer (int a_FoodTickTimer); void SetFoodExhaustionLevel (double a_FoodExhaustionLevel); - void SetFoodPoisonedTicksRemaining(int a_FoodPoisonedTicksRemaining); /** Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed, false if player "full" */ bool Feed(int a_Food, double a_Saturation); @@ -287,7 +285,7 @@ public: m_FoodExhaustionLevel += a_Exhaustion; } - /** Starts the food poisoning for the specified amount of ticks; if already foodpoisoned, sets FoodPoisonedTicksRemaining to the larger of the two */ + /** Starts the food poisoning for the specified amount of ticks */ void FoodPoison(int a_NumTicks); /** Returns true if the player is currently in the process of eating the currently equipped item */ @@ -442,9 +440,6 @@ protected: /** A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel. Each action adds a little */ double m_FoodExhaustionLevel; - /** Number of ticks remaining for the foodpoisoning effect; zero if not foodpoisoned */ - int m_FoodPoisonedTicksRemaining; - float m_LastJumpHeight; float m_LastGroundHeight; bool m_bTouchGround; diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index d97f986ba..67740e860 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -577,7 +577,7 @@ bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item) cFastRandom r1; if ((r1.NextInt(100, a_Player->GetUniqueID()) - Info.PoisonChance) <= 0) { - a_Player->FoodPoison(300); + a_Player->FoodPoison(600); // Give the player food poisoning for 30 seconds. } } -- cgit v1.2.3 From a9a4c9c6b25438aaebdeef03c323e9aa4a0348c2 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 23:05:29 -0700 Subject: EntityEffect: read-only getters, added user and distance modifier fields User: the pawn that uses or produces the entity effect (drinks/throws a potion) Distance modifier: the potency modifier from splash potion effectivity radius --- src/Entities/EntityEffects.cpp | 14 +++++++++----- src/Entities/EntityEffects.h | 30 +++++++++++++++++++++++++----- src/Entities/Player.cpp | 2 +- 3 files changed, 35 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffects.cpp b/src/Entities/EntityEffects.cpp index 3aa3fd1ed..c74463bfa 100644 --- a/src/Entities/EntityEffects.cpp +++ b/src/Entities/EntityEffects.cpp @@ -1,14 +1,16 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "EntityEffects.h" - +#include "Pawn.h" cEntityEffect::cEntityEffect(): m_Ticks(0), - m_Intensity(0) + m_Intensity(0), + m_User(NULL), + m_DistanceModifier(1) { } @@ -17,9 +19,11 @@ cEntityEffect::cEntityEffect(): -cEntityEffect::cEntityEffect(int a_Ticks, short a_Intensity): +cEntityEffect::cEntityEffect(int a_Ticks, short a_Intensity, cPawn *a_User, double a_DistanceModifier): m_Ticks(a_Ticks), - m_Intensity(a_Intensity) + m_Intensity(a_Intensity), + m_User(a_User), + m_DistanceModifier(a_DistanceModifier) { -} +} \ No newline at end of file diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h index 6ddd86b01..2bda2e104 100644 --- a/src/Entities/EntityEffects.h +++ b/src/Entities/EntityEffects.h @@ -1,5 +1,7 @@ #pragma once +class cPawn; + // tolua_begin class cEntityEffect { public: @@ -35,8 +37,14 @@ public: /** The duration of the effect */ int m_Ticks; - /** How strong the effect will be applied */ - short m_Intensity; + /** Returns how strong the effect will be applied */ + short GetIntensity() { return m_Intensity; } + + /** Returns the pawn that used this entity effect */ + cPawn *GetUser() { return m_User; } + + /** Returns the distance modifier for affecting potency */ + double GetDistanceModifier() { return m_DistanceModifier; } /** * An empty entity effect @@ -45,9 +53,21 @@ public: /** * An entity effect - * @param a_Ticks The duration of the effect - * @param a_Intensity How strong the effect will be applied + * @param a_Ticks The duration of the effect + * @param a_Intensity How strong the effect will be applied + * @param a_User The pawn that used this entity effect + * @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ - cEntityEffect(int a_Ticks, short a_Intensity); + cEntityEffect(int a_Ticks, short a_Intensity, cPawn *a_User, double a_DistanceModifier = 1); + +private: + /** How strong the effect will be applied */ + short m_Intensity; + + /** The pawn that used this entity effect */ + cPawn *m_User; + + /** The distance modifier for affecting potency */ + double m_DistanceModifier; }; // tolua_end diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 3a1ebf3f9..d075957fe 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -570,7 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation) void cPlayer::FoodPoison(int a_NumTicks) { - AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, a_NumTicks)); + AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, a_NumTicks, NULL)); } -- cgit v1.2.3 From e98ffccd80ae05d09b40d5edd407428515b14406 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 00:54:03 -0700 Subject: Pawn: Enabled entity effect broadcast, added typedef Typedef'd std::map to tEffectMap --- src/Entities/Pawn.cpp | 7 ++++--- src/Entities/Pawn.h | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 1d2542d58..1f93e59fa 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Pawn.h" +#include "../World.h" @@ -20,7 +21,7 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) void cPawn::Tick(float a_Dt, cChunk & a_Chunk) { // Iterate through this entity's applied effects - for (std::map::iterator iter = m_EntityEffects.begin(); + for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end(); ++iter) { @@ -49,7 +50,7 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk) void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) { m_EntityEffects[a_EffectType] = a_Effect; - //m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.m_Intensity, a_Effect.m_Ticks); + m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.m_Ticks); } @@ -59,7 +60,7 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_E void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType) { m_EntityEffects.erase(a_EffectType); - //m_World->BroadcastRemoveEntityEffect(*this, a_EffectType); + m_World->BroadcastRemoveEntityEffect(*this, a_EffectType); } diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index f7d7213ff..1a897c958 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -26,7 +26,8 @@ public: void RemoveEntityEffect(cEntityEffect::eType a_EffectType); protected: - std::map m_EntityEffects; + typedef std::map tEffectMap; + tEffectMap m_EntityEffects; virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect); } ; // tolua_export -- cgit v1.2.3 From 615152eb8c6c88083f7b9eac57ec07147f34a6d6 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 02:02:20 -0700 Subject: Pawn.cpp: fixed effect iterator BAD_ACCESS Erasure was occurring before the iterator increased, causing a bad access. Solved by storing map pairs in variables and manually updating iterator before erasure. Fixed mix-up in function arguments on food poisoning --- src/Entities/Pawn.cpp | 21 +++++++++++++-------- src/Entities/Player.cpp | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 1f93e59fa..93f6a69bc 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -10,7 +10,7 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) : cEntity(a_EntityType, 0, 0, 0, a_Width, a_Height) - , m_EntityEffects(std::map()) + , m_EntityEffects(tEffectMap()) { } @@ -21,20 +21,25 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) void cPawn::Tick(float a_Dt, cChunk & a_Chunk) { // Iterate through this entity's applied effects - for (tEffectMap::iterator iter = m_EntityEffects.begin(); - iter != m_EntityEffects.end(); - ++iter) + for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();) { + // Copies values to prevent pesky wrong accesses and erasures + cEntityEffect::eType effect_type = iter->first; + cEntityEffect &effect_values = iter->second; + // Apply entity effect - HandleEntityEffects(iter->first, iter->second); + HandleEntityEffects(effect_type, effect_values); // Reduce the effect's duration - iter->second.m_Ticks--; + effect_values.m_Ticks--; + + // Iterates (must be called before any possible erasure) + ++iter; // Remove effect if duration has elapsed - if (iter->second.m_Ticks <= 0) + if (effect_values.m_Ticks <= 0) { - RemoveEntityEffect(iter->first); + RemoveEntityEffect(effect_type); } // TODO: Check for discrepancies between client and server effect values diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index d075957fe..67449f800 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -570,7 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation) void cPlayer::FoodPoison(int a_NumTicks) { - AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, a_NumTicks, NULL)); + AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(a_NumTicks, 0, NULL)); } -- cgit v1.2.3 From 1eb04a48ee3ec4114adc4334e6fbcc7561834025 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 13:45:00 -0700 Subject: Implemented milk, added documentation to Pawn.h --- src/ClientHandle.cpp | 6 +++--- src/Entities/Pawn.cpp | 20 ++++++++++++++++++++ src/Entities/Pawn.h | 15 +++++++++++++++ src/Entities/Player.cpp | 2 +- src/Items/ItemHandler.cpp | 19 ++++++++++++++++++- src/Items/ItemHandler.h | 3 +++ src/Items/ItemMilk.h | 26 ++++++++++++++++++++++++++ 7 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 src/Items/ItemMilk.h (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index e4bb9d8e9..7b114b927 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -850,7 +850,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB case DIG_STATUS_SHOOT_EAT: { cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem()); - if (ItemHandler->IsFood()) + if (ItemHandler->IsFood() || ItemHandler->IsDrinkable()) { m_Player->AbortEating(); return; @@ -1182,9 +1182,9 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e { HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); } - else if (ItemHandler->IsFood() && !m_Player->IsGameModeCreative()) + else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable()) && !m_Player->IsGameModeCreative()) { - if (m_Player->IsSatiated()) + if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable()) { // The player is satiated, they cannot eat return; diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 93f6a69bc..4c840e6e1 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -72,6 +72,26 @@ void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType) +void cPawn::ClearEntityEffects() +{ + // Iterate through this entity's applied effects + for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();) + { + // Copy values to prevent pesky wrong erasures + cEntityEffect::eType effect_type = iter->first; + + // Iterates (must be called before any possible erasure) + ++iter; + + // Remove effect + RemoveEntityEffect(effect_type); + } +} + + + + + void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) { switch (a_EffectType) diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index 1a897c958..857488901 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -22,13 +22,28 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + /** Applies an entity effect + * @param a_EffectType The entity effect to apply + * @param a_Effect The parameters of the effect + */ void AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect); + + /** Removes a currently applied entity effect + * @param a_EffectType The entity effect to remove + */ void RemoveEntityEffect(cEntityEffect::eType a_EffectType); + + /** Removes all currently applied entity effects (used when drinking milk) */ + void ClearEntityEffects(); protected: typedef std::map tEffectMap; tEffectMap m_EntityEffects; + /** Applies entity effect effects + * @param a_EffectType The selected entity effect + * @param a_Effect The parameters of the selected entity effect + */ virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect); } ; // tolua_export diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 67449f800..b4b344584 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -552,7 +552,7 @@ void cPlayer::SetFoodExhaustionLevel(double a_FoodExhaustionLevel) bool cPlayer::Feed(int a_Food, double a_Saturation) { - if (m_FoodLevel >= MAX_FOOD_LEVEL) + if (IsSatiated()) { return false; } diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 67740e860..83be87b9e 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -19,6 +19,7 @@ #include "ItemCloth.h" #include "ItemComparator.h" #include "ItemDoor.h" +#include "ItemMilk.h" #include "ItemDye.h" #include "ItemEmptyMap.h" #include "ItemFishingRod.h" @@ -119,6 +120,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) case E_ITEM_FLOWER_POT: return new cItemFlowerPotHandler(a_ItemType); case E_BLOCK_LILY_PAD: return new cItemLilypadHandler(a_ItemType); case E_ITEM_MAP: return new cItemMapHandler(); + case E_ITEM_MILK: return new cItemMilkHandler(); case E_ITEM_ITEM_FRAME: return new cItemItemFrameHandler(a_ItemType); case E_ITEM_NETHER_WART: return new cItemNetherWartHandler(a_ItemType); case E_ITEM_PAINTING: return new cItemPaintingHandler(a_ItemType); @@ -475,7 +477,6 @@ bool cItemHandler::IsFood(void) case E_ITEM_BREAD: case E_ITEM_RAW_PORKCHOP: case E_ITEM_COOKED_PORKCHOP: - case E_ITEM_MILK: case E_ITEM_RAW_FISH: case E_ITEM_COOKED_FISH: case E_ITEM_COOKIE: @@ -501,6 +502,22 @@ bool cItemHandler::IsFood(void) +bool cItemHandler::IsDrinkable(void) +{ + switch (m_ItemType) + { + case E_ITEM_MILK: + { + return true; + } + } // switch (m_ItemType) + return false; +} + + + + + bool cItemHandler::IsPlaceable(void) { // We can place any block that has a corresponding E_BLOCK_TYPE: diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index e13198cd7..3a25a3f9d 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -82,6 +82,9 @@ public: /** Indicates if this item is food */ virtual bool IsFood(void); + /** Indicates if this item is drinkable */ + virtual bool IsDrinkable(void); + /** Blocks simply get placed */ virtual bool IsPlaceable(void); diff --git a/src/Items/ItemMilk.h b/src/Items/ItemMilk.h new file mode 100644 index 000000000..8569c8cbe --- /dev/null +++ b/src/Items/ItemMilk.h @@ -0,0 +1,26 @@ + +#pragma once + +class cItemMilkHandler: + public cItemHandler +{ + typedef cItemHandler super; +public: + cItemMilkHandler(): + super(E_ITEM_MILK) + { + } + + virtual bool IsDrinkable(void) override + { + return true; + } + + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + { + a_Player->ClearEntityEffects(); + a_Player->GetInventory().RemoveOneEquippedItem(); + a_Player->GetInventory().AddItem(E_ITEM_BUCKET); + return true; + } +}; -- cgit v1.2.3 From 2185c72c2ca2d66b238d7d3234c173bd820d32ac Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 16:32:37 -0700 Subject: Implemented drinkable potions, noeffect entity effect, Clears entity effects on death --- src/ClientHandle.cpp | 6 +- src/Entities/EntityEffects.h | 1 + src/Entities/Pawn.cpp | 14 +++++ src/Entities/Pawn.h | 1 + src/Items/ItemHandler.cpp | 6 +- src/Items/ItemHandler.h | 2 +- src/Items/ItemMilk.h | 4 +- src/Items/ItemPotion.h | 137 +++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 165 insertions(+), 6 deletions(-) create mode 100644 src/Items/ItemPotion.h (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 7b114b927..ab36bff91 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -850,7 +850,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB case DIG_STATUS_SHOOT_EAT: { cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem()); - if (ItemHandler->IsFood() || ItemHandler->IsDrinkable()) + if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(&m_Player->GetEquippedItem())) { m_Player->AbortEating(); return; @@ -1182,9 +1182,9 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e { HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); } - else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable()) && !m_Player->IsGameModeCreative()) + else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(&Equipped)) && !m_Player->IsGameModeCreative()) { - if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable()) + if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(&Equipped)) { // The player is satiated, they cannot eat return; diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h index 2bda2e104..137eb6480 100644 --- a/src/Entities/EntityEffects.h +++ b/src/Entities/EntityEffects.h @@ -9,6 +9,7 @@ public: /** All types of entity effects (numbers correspond to IDs) */ enum eType { + efNoEffect = 0, efSpeed = 1, efSlowness = 2, efHaste = 3, diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 4c840e6e1..5cf270006 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -52,8 +52,22 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk) +void cPawn::KilledBy(cEntity *a_Killer) +{ + ClearEntityEffects(); +} + + + + + void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) { + if (a_EffectType == cEntityEffect::efNoEffect) + { + return; + } + m_EntityEffects[a_EffectType] = a_Effect; m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.m_Ticks); } diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index 857488901..47fb691f4 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -21,6 +21,7 @@ public: cPawn(eEntityType a_EntityType, double a_Width, double a_Height); virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void KilledBy(cEntity * a_Killer) override; /** Applies an entity effect * @param a_EffectType The entity effect to apply diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 83be87b9e..f847c8ffa 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -35,6 +35,7 @@ #include "ItemNetherWart.h" #include "ItemPainting.h" #include "ItemPickaxe.h" +#include "ItemPotion.h" #include "ItemThrowable.h" #include "ItemRedstoneDust.h" #include "ItemRedstoneRepeater.h" @@ -124,6 +125,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) case E_ITEM_ITEM_FRAME: return new cItemItemFrameHandler(a_ItemType); case E_ITEM_NETHER_WART: return new cItemNetherWartHandler(a_ItemType); case E_ITEM_PAINTING: return new cItemPaintingHandler(a_ItemType); + case E_ITEM_POTIONS: return new cItemPotionHandler(); case E_ITEM_REDSTONE_DUST: return new cItemRedstoneDustHandler(a_ItemType); case E_ITEM_REDSTONE_REPEATER: return new cItemRedstoneRepeaterHandler(a_ItemType); case E_ITEM_SHEARS: return new cItemShearsHandler(a_ItemType); @@ -502,8 +504,10 @@ bool cItemHandler::IsFood(void) -bool cItemHandler::IsDrinkable(void) +bool cItemHandler::IsDrinkable(const cItem * a_Item) { + UNUSED(a_Item); + switch (m_ItemType) { case E_ITEM_MILK: diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index 3a25a3f9d..ead2c9769 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -83,7 +83,7 @@ public: virtual bool IsFood(void); /** Indicates if this item is drinkable */ - virtual bool IsDrinkable(void); + virtual bool IsDrinkable(const cItem * a_Item); /** Blocks simply get placed */ virtual bool IsPlaceable(void); diff --git a/src/Items/ItemMilk.h b/src/Items/ItemMilk.h index 8569c8cbe..62506a223 100644 --- a/src/Items/ItemMilk.h +++ b/src/Items/ItemMilk.h @@ -11,13 +11,15 @@ public: { } - virtual bool IsDrinkable(void) override + virtual bool IsDrinkable(const cItem * a_Item) override { + UNUSED(a_Item); return true; } virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override { + UNUSED(a_Item); a_Player->ClearEntityEffects(); a_Player->GetInventory().RemoveOneEquippedItem(); a_Player->GetInventory().AddItem(E_ITEM_BUCKET); diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h new file mode 100644 index 000000000..e34b251aa --- /dev/null +++ b/src/Items/ItemPotion.h @@ -0,0 +1,137 @@ + +#pragma once + +#include "../Entities/EntityEffects.h" + +class cItemPotionHandler: +public cItemHandler +{ + typedef cItemHandler super; + + cEntityEffect::eType GetEntityEffectType(short a_ItemDamage) + { + // Potion effect bits are different from entity effect values + // For reference: http://minecraft.gamepedia.com/Data_values#.22Potion_effect.22_bits + switch (a_ItemDamage & 15) + { + case 1: return cEntityEffect::efRegeneration; + case 2: return cEntityEffect::efSpeed; + case 3: return cEntityEffect::efFireResistance; + case 4: return cEntityEffect::efPoison; + case 5: return cEntityEffect::efInstantHealth; + case 6: return cEntityEffect::efNightVision; + case 8: return cEntityEffect::efWeakness; + case 9: return cEntityEffect::efStrength; + case 10: return cEntityEffect::efSlowness; + case 12: return cEntityEffect::efInstantDamage; + case 13: return cEntityEffect::efWaterBreathing; + case 14: return cEntityEffect::efInvisibility; + + // No effect potions + case 0: + case 7: + case 11: + case 15: + { + break; + } + } + + return cEntityEffect::efNoEffect; + } + + short GetEntityEffectIntensity(short a_ItemDamage) + { + // Level II potion if fifth bit is set + if (a_ItemDamage & 32) return 1; + else return 0; + } + + int GetEntityEffectDuration(short a_ItemDamage) + { + // Base duration in ticks + int base = 0; + double tier_multi = 1, ext_multi = 1, splash_multi = 1; + + switch (GetEntityEffectType(a_ItemDamage)) + { + case cEntityEffect::efRegeneration: + case cEntityEffect::efPoison: + { + base = 900; + break; + } + + case cEntityEffect::efSpeed: + case cEntityEffect::efFireResistance: + case cEntityEffect::efNightVision: + case cEntityEffect::efStrength: + case cEntityEffect::efWaterBreathing: + case cEntityEffect::efInvisibility: + { + base = 3600; + break; + } + + case cEntityEffect::efWeakness: + case cEntityEffect::efSlowness: + { + base = 1800; + break; + } + } + + // If potion is level 2, half the duration. If not, stays the same + tier_multi = GetEntityEffectIntensity(a_ItemDamage) > 0 ? 0.5 : 1; + + // If potion is extended, multiply duration by 8/3. If not, stays the same + // Extended potion if sixth bit is set + ext_multi = a_ItemDamage & 64 ? (8.0/3.0) : 1; + + // If potion is splash potion, multiply duration by 3/4. If not, stays the same + splash_multi = !IsDrinkable(a_ItemDamage) ? 0.75 : 1; + + // For reference: http://minecraft.gamepedia.com/Data_values#.22Tier.22_bit + // http://minecraft.gamepedia.com/Data_values#.22Extended_duration.22_bit + // http://minecraft.gamepedia.com/Data_values#.22Splash_potion.22_bit + + return base * tier_multi * ext_multi * splash_multi; + } + + bool IsDrinkable(short a_ItemDamage) + { + // Drinkable potion if 13th bit is set + // For reference: http://minecraft.gamepedia.com/Potions#Data_value_table + return a_ItemDamage & 8192; + } + +public: + cItemPotionHandler(): + super(E_ITEM_POTIONS) + { + } + + virtual bool IsDrinkable(const cItem * a_Item) override + { + return IsDrinkable(a_Item->m_ItemDamage); + } + + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override + { + // Called when potion is a splash potion + return true; + } + + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + { + // Called when potion is a drinkable potion + short potion_damage = a_Item->m_ItemDamage; + a_Player->AddEntityEffect(GetEntityEffectType(potion_damage), + cEntityEffect(GetEntityEffectDuration(potion_damage), + GetEntityEffectIntensity(potion_damage), + a_Player)); + a_Player->GetInventory().RemoveOneEquippedItem(); + a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE); + return true; + } +}; -- cgit v1.2.3 From 8eceaf9b0cadbc253e46cdcbf8a7b5e8d6070846 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 18:48:33 -0700 Subject: Player: made healing instantaneous --- src/Entities/Entity.h | 2 +- src/Entities/Player.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 2df66e353..b8f1f4c1c 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -315,7 +315,7 @@ public: virtual void Killed(cEntity * a_Victim) {} /// Heals the specified amount of HPs - void Heal(int a_HitPoints); + virtual void Heal(int a_HitPoints); /// Returns the health of this entity int GetHealth(void) const { return m_Health; } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 83114a4dd..3aba3289d 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -261,7 +261,7 @@ public: void TossPickup(const cItem & a_Item); /** Heals the player by the specified amount of HPs (positive only); sends health update */ - void Heal(int a_Health); + virtual void Heal(int a_Health) override; int GetFoodLevel (void) const { return m_FoodLevel; } double GetFoodSaturationLevel (void) const { return m_FoodSaturationLevel; } -- cgit v1.2.3 From 5803094d7d0a852568c45c450dc2cc52e6c7d681 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 19:58:41 -0700 Subject: Entity: only fire critical hit if damage type is physical --- src/Entities/Entity.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index ee7ce06ac..ba829bf6b 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -310,7 +310,8 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) cPlayer * Player = (cPlayer *)a_TDI.Attacker; // IsOnGround() only is false if the player is moving downwards - if (!Player->IsOnGround()) // TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain) + // TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain) + if (!Player->IsOnGround() && (a_TDI.DamageType == dtAttack || a_TDI.DamageType == dtArrowAttack)) { a_TDI.FinalDamage += 2; m_World->BroadcastEntityAnimation(*this, 4); // Critical hit -- cgit v1.2.3 From 58f35af6e71f11844b9c6c1d1ebd2d7390439cca Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 21:56:01 -0700 Subject: Added splash potion functionality --- src/Entities/EntityEffects.h | 4 +++ src/Entities/Pawn.cpp | 7 +++-- src/Entities/ProjectileEntity.cpp | 2 -- src/Entities/SplashPotionEntity.cpp | 58 +++++++++++++++++++++++++++++++++---- src/Entities/SplashPotionEntity.h | 30 +++++++++++++++++-- src/Items/ItemPotion.h | 36 ++++++++++++++++++++++- 6 files changed, 122 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h index 137eb6480..e6b5bdd5d 100644 --- a/src/Entities/EntityEffects.h +++ b/src/Entities/EntityEffects.h @@ -47,6 +47,10 @@ public: /** Returns the distance modifier for affecting potency */ double GetDistanceModifier() { return m_DistanceModifier; } + void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; } + void SetUser(cPawn *a_User) { m_User = a_User; } + void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; } + /** * An empty entity effect */ diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 5cf270006..5cd493a06 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -69,7 +69,8 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_E } m_EntityEffects[a_EffectType] = a_Effect; - m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.m_Ticks); + m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), + a_Effect.m_Ticks * a_Effect.GetDistanceModifier()); } @@ -114,7 +115,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect case cEntityEffect::efInstantHealth: { // Base heal = 6, doubles for every increase in intensity - Heal(6 * std::pow(2, a_Effect.GetIntensity())); + Heal(6 * std::pow(2, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); // TODO: Harms undead return; @@ -123,7 +124,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect { // Base damage = 6, doubles for every increase in intensity int damage = 6 * std::pow(2, a_Effect.GetIntensity()); - TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0); + TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage * a_Effect.GetDistanceModifier(), 0); // TODO: Heals undead return; diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index ee3890f23..664f929f6 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -18,7 +18,6 @@ #include "ThrownEnderPearlEntity.h" #include "ExpBottleEntity.h" #include "ThrownSnowballEntity.h" -#include "SplashPotionEntity.h" #include "FireChargeEntity.h" #include "FireworkEntity.h" #include "GhastFireballEntity.h" @@ -252,7 +251,6 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator, case pkGhastFireball: return new cGhastFireballEntity (a_Creator, a_X, a_Y, a_Z, Speed); case pkFireCharge: return new cFireChargeEntity (a_Creator, a_X, a_Y, a_Z, Speed); case pkExpBottle: return new cExpBottleEntity (a_Creator, a_X, a_Y, a_Z, Speed); - case pkSplashPotion: return new cSplashPotionEntity (a_Creator, a_X, a_Y, a_Z, Speed); case pkWitherSkull: return new cWitherSkullEntity (a_Creator, a_X, a_Y, a_Z, Speed); case pkFirework: { diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index c6be2baf7..5dcea2385 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -1,14 +1,17 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "SplashPotionEntity.h" -#include "../World.h" +#include "Player.h" -cSplashPotionEntity::cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : -super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) +cSplashPotionEntity::cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName) : + super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), + m_EntityEffectType(a_EntityEffectType), + m_EntityEffect(a_EntityEffect), + m_PotionName(a_PotionName) { SetSpeed(a_Speed); } @@ -19,7 +22,7 @@ super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { - // TODO: Apply potion effect to entities nearby + Splash(a_HitPos); Destroy(); } @@ -30,8 +33,51 @@ void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) { a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1); + Splash(a_HitPos); + Destroy(true); +} + + + + + +void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) +{ + cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect); + m_World->ForEachPlayer(Callback); + // TODO: Should be for each pawn - // TODO: Apply potion effect to entity and others nearby + m_World->BroadcastSoundParticleEffect(2002, a_HitPos.x, a_HitPos.y, a_HitPos.z, m_PotionName); +} + + + + + +cSplashPotionEntity::cSplashPotionCallback::cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect): + m_HitPos(a_HitPos), + m_EntityEffectType(a_EntityEffectType), + m_EntityEffect(a_EntityEffect) +{ - Destroy(true); +} + + + + + +bool cSplashPotionEntity::cSplashPotionCallback::Item(cPlayer * a_Player) +{ + double distance_splash = (a_Player->GetPosition() - m_HitPos).Length(); + if (distance_splash < 20) + { + // y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash. + // TODO: better equation + double reduction = -0.25 * distance_splash + 1.0; + if (reduction < 0) reduction = 0; + + m_EntityEffect.SetDistanceModifier(reduction); + a_Player->AddEntityEffect(m_EntityEffectType, m_EntityEffect); + } + return false; } diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index d82a7bfcd..b64b668a5 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -5,7 +5,8 @@ #pragma once #include "ProjectileEntity.h" - +#include "EntityEffects.h" +#include "../World.h" @@ -13,7 +14,7 @@ // tolua_begin class cSplashPotionEntity : -public cProjectileEntity + public cProjectileEntity { typedef cProjectileEntity super; @@ -23,7 +24,7 @@ public: CLASS_PROTODEF(cSplashPotionEntity); - cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName); protected: @@ -31,4 +32,27 @@ protected: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; + /** Splashes the potion, fires its particle effects and sounds + * @param a_HitPos The position where the potion will splash + */ + void Splash(const Vector3d & a_HitPos); + + cEntityEffect::eType m_EntityEffectType; + cEntityEffect m_EntityEffect; + int m_PotionName; + + class cSplashPotionCallback : + public cPlayerListCallback + { + public: + cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect); + + virtual bool Item(cPlayer * a_Player) override; + + private: + const Vector3d &m_HitPos; + cEntityEffect::eType &m_EntityEffectType; + cEntityEffect &m_EntityEffect; + }; + } ; // tolua_export diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index e34b251aa..528268cfe 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -2,12 +2,18 @@ #pragma once #include "../Entities/EntityEffects.h" +#include "../Entities/SplashPotionEntity.h" class cItemPotionHandler: -public cItemHandler + public cItemHandler { typedef cItemHandler super; + int GetPotionName(short a_ItemDamage) + { + return a_ItemDamage & 63; + } + cEntityEffect::eType GetEntityEffectType(short a_ItemDamage) { // Potion effect bits are different from entity effect values @@ -118,6 +124,34 @@ public: virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { + Vector3d Speed = a_Player->GetLookVector() * 10; + + short potion_damage = a_Item.m_ItemDamage; + cProjectileEntity * Projectile = new cSplashPotionEntity(a_Player, + (double)a_BlockX, + (double)a_BlockY, + (double)a_BlockZ, + &Speed, + GetEntityEffectType(potion_damage), + cEntityEffect(GetEntityEffectDuration(potion_damage), + GetEntityEffectIntensity(potion_damage), + a_Player), + GetPotionName(potion_damage)); + if (Projectile == NULL) + { + return false; + } + if (!Projectile->Initialize(*a_World)) + { + delete Projectile; + return false; + } + + if (!a_Player->IsGameModeCreative()) + { + a_Player->GetInventory().RemoveOneEquippedItem(); + } + // Called when potion is a splash potion return true; } -- cgit v1.2.3 From 73cea7065db458da7704917788ac80b75e042d6e Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 03:27:22 -0700 Subject: Entity effect type: use 'eff' as a prefix instead of 'ef' --- src/Entities/EntityEffects.h | 48 +++++++++++++-------------- src/Entities/Pawn.cpp | 20 ++++++------ src/Entities/Player.cpp | 12 +++---- src/Entities/WitherSkullEntity.cpp | 2 +- src/Items/ItemPotion.h | 66 +++++++++++++++++++------------------- 5 files changed, 74 insertions(+), 74 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h index e6b5bdd5d..26d2c92e5 100644 --- a/src/Entities/EntityEffects.h +++ b/src/Entities/EntityEffects.h @@ -9,30 +9,30 @@ public: /** All types of entity effects (numbers correspond to IDs) */ enum eType { - efNoEffect = 0, - efSpeed = 1, - efSlowness = 2, - efHaste = 3, - efMiningFatigue = 4, - efStrength = 5, - efInstantHealth = 6, - efInstantDamage = 7, - efJumpBoost = 8, - efNausia = 9, - efRegeneration = 10, - efResistance = 11, - efFireResistance = 12, - efWaterBreathing = 13, - efInvisibility = 14, - efBlindness = 15, - efNightVision = 16, - efHunger = 17, - efWeakness = 18, - efPoison = 19, - efWither = 20, - efHealthBoost = 21, - efAbsorption = 22, - efSaturation = 23, + effNoEffect = 0, + effSpeed = 1, + effSlowness = 2, + effHaste = 3, + effMiningFatigue = 4, + effStrength = 5, + effInstantHealth = 6, + effInstantDamage = 7, + effJumpBoost = 8, + effNausea = 9, + effRegeneration = 10, + effResistance = 11, + effFireResistance = 12, + effWaterBreathing = 13, + effInvisibility = 14, + effBlindness = 15, + effNightVision = 16, + effHunger = 17, + effWeakness = 18, + effPoison = 19, + effWither = 20, + effHealthBoost = 21, + effAbsorption = 22, + effSaturation = 23, } ; /** The duration of the effect */ diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 5cd493a06..a1f24138d 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -63,7 +63,7 @@ void cPawn::KilledBy(cEntity *a_Killer) void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) { - if (a_EffectType == cEntityEffect::efNoEffect) + if (a_EffectType == cEntityEffect::effNoEffect) { return; } @@ -112,7 +112,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect switch (a_EffectType) { // Default effect behaviors - case cEntityEffect::efInstantHealth: + case cEntityEffect::effInstantHealth: { // Base heal = 6, doubles for every increase in intensity Heal(6 * std::pow(2, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); @@ -120,7 +120,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect // TODO: Harms undead return; } - case cEntityEffect::efInstantDamage: + case cEntityEffect::effInstantDamage: { // Base damage = 6, doubles for every increase in intensity int damage = 6 * std::pow(2, a_Effect.GetIntensity()); @@ -129,12 +129,12 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect // TODO: Heals undead return; } - case cEntityEffect::efStrength: + case cEntityEffect::effStrength: { // TODO: Implement me! return; } - case cEntityEffect::efWeakness: + case cEntityEffect::effWeakness: { // Damage reduction = 0.5 damage, multiplied by potion level (Weakness II = 1 damage) //double dmg_reduc = 0.5 * (a_Effect.GetIntensity() + 1); @@ -143,7 +143,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect // TODO: Weakened villager zombies can be turned back to villagers with the god apple return; } - case cEntityEffect::efRegeneration: + case cEntityEffect::effRegeneration: { // Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks) int frequency = std::floor(50.0 / (double)(a_Effect.GetIntensity() + 1)); @@ -158,7 +158,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect // TODO: Doesn't effect undead return; } - case cEntityEffect::efPoison: + case cEntityEffect::effPoison: { // Poison frequency = 25 ticks, divided by potion level (Poison II = 25 ticks) int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1)); @@ -177,17 +177,17 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect // TODO: Doesn't effect undead or spiders return; } - case cEntityEffect::efFireResistance: + case cEntityEffect::effFireResistance: { // TODO: Implement me! return; } - case cEntityEffect::efSpeed: + case cEntityEffect::effSpeed: { // TODO: Implement me! return; } - case cEntityEffect::efSlowness: + case cEntityEffect::effSlowness: { // TODO: Implement me! return; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index b4b344584..6bceab26f 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -570,7 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation) void cPlayer::FoodPoison(int a_NumTicks) { - AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(a_NumTicks, 0, NULL)); + AddEntityEffect(cEntityEffect::effHunger, cEntityEffect(a_NumTicks, 0, NULL)); } @@ -1872,17 +1872,17 @@ void cPlayer::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffe switch (a_EffectType) { // Effects whose behaviors are overridden - case cEntityEffect::efMiningFatigue: + case cEntityEffect::effMiningFatigue: { // TODO: Implement me! return; } - case cEntityEffect::efHunger: + case cEntityEffect::effHunger: { m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick return; } - case cEntityEffect::efSaturation: + case cEntityEffect::effSaturation: { // Increase saturation 1 per tick, adds 1 for every increase in level m_FoodSaturationLevel += (1 + a_Effect.GetIntensity()); @@ -1890,8 +1890,8 @@ void cPlayer::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffe } // Client-side-only effects - case cEntityEffect::efNausia: - case cEntityEffect::efNightVision: + case cEntityEffect::effNausea: + case cEntityEffect::effNightVision: { return; } diff --git a/src/Entities/WitherSkullEntity.cpp b/src/Entities/WitherSkullEntity.cpp index ea78bba5d..03e36a3f4 100644 --- a/src/Entities/WitherSkullEntity.cpp +++ b/src/Entities/WitherSkullEntity.cpp @@ -8,7 +8,7 @@ cWitherSkullEntity::cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : -super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) +super(pkWitherSkull, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) { SetSpeed(a_Speed); } diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index 528268cfe..4c67e9dc7 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -20,18 +20,18 @@ class cItemPotionHandler: // For reference: http://minecraft.gamepedia.com/Data_values#.22Potion_effect.22_bits switch (a_ItemDamage & 15) { - case 1: return cEntityEffect::efRegeneration; - case 2: return cEntityEffect::efSpeed; - case 3: return cEntityEffect::efFireResistance; - case 4: return cEntityEffect::efPoison; - case 5: return cEntityEffect::efInstantHealth; - case 6: return cEntityEffect::efNightVision; - case 8: return cEntityEffect::efWeakness; - case 9: return cEntityEffect::efStrength; - case 10: return cEntityEffect::efSlowness; - case 12: return cEntityEffect::efInstantDamage; - case 13: return cEntityEffect::efWaterBreathing; - case 14: return cEntityEffect::efInvisibility; + case 1: return cEntityEffect::effRegeneration; + case 2: return cEntityEffect::effSpeed; + case 3: return cEntityEffect::effFireResistance; + case 4: return cEntityEffect::effPoison; + case 5: return cEntityEffect::effInstantHealth; + case 6: return cEntityEffect::effNightVision; + case 8: return cEntityEffect::effWeakness; + case 9: return cEntityEffect::effStrength; + case 10: return cEntityEffect::effSlowness; + case 12: return cEntityEffect::effInstantDamage; + case 13: return cEntityEffect::effWaterBreathing; + case 14: return cEntityEffect::effInvisibility; // No effect potions case 0: @@ -43,7 +43,7 @@ class cItemPotionHandler: } } - return cEntityEffect::efNoEffect; + return cEntityEffect::effNoEffect; } short GetEntityEffectIntensity(short a_ItemDamage) @@ -61,26 +61,26 @@ class cItemPotionHandler: switch (GetEntityEffectType(a_ItemDamage)) { - case cEntityEffect::efRegeneration: - case cEntityEffect::efPoison: + case cEntityEffect::effRegeneration: + case cEntityEffect::effPoison: { base = 900; break; } - case cEntityEffect::efSpeed: - case cEntityEffect::efFireResistance: - case cEntityEffect::efNightVision: - case cEntityEffect::efStrength: - case cEntityEffect::efWaterBreathing: - case cEntityEffect::efInvisibility: + case cEntityEffect::effSpeed: + case cEntityEffect::effFireResistance: + case cEntityEffect::effNightVision: + case cEntityEffect::effStrength: + case cEntityEffect::effWaterBreathing: + case cEntityEffect::effInvisibility: { base = 3600; break; } - case cEntityEffect::efWeakness: - case cEntityEffect::efSlowness: + case cEntityEffect::effWeakness: + case cEntityEffect::effSlowness: { base = 1800; break; @@ -127,16 +127,16 @@ public: Vector3d Speed = a_Player->GetLookVector() * 10; short potion_damage = a_Item.m_ItemDamage; - cProjectileEntity * Projectile = new cSplashPotionEntity(a_Player, - (double)a_BlockX, - (double)a_BlockY, - (double)a_BlockZ, - &Speed, - GetEntityEffectType(potion_damage), - cEntityEffect(GetEntityEffectDuration(potion_damage), - GetEntityEffectIntensity(potion_damage), - a_Player), - GetPotionName(potion_damage)); + cSplashPotionEntity * Projectile = new cSplashPotionEntity(a_Player, + (double)a_BlockX, + (double)a_BlockY, + (double)a_BlockZ, + &Speed, + GetEntityEffectType(potion_damage), + cEntityEffect(GetEntityEffectDuration(potion_damage), + GetEntityEffectIntensity(potion_damage), + a_Player), + GetPotionName(potion_damage)); if (Projectile == NULL) { return false; -- cgit v1.2.3 From a1a8b7c0eee2189dfc129eb366edb43a315749f9 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 16:31:18 -0700 Subject: Splash potion: Adjusted speed, fixed spawn position --- src/Items/ItemPotion.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index 4c67e9dc7..029bb52cd 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -124,14 +124,11 @@ public: virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { - Vector3d Speed = a_Player->GetLookVector() * 10; + Vector3d Pos = a_Player->GetThrowStartPos(); + Vector3d Speed = a_Player->GetLookVector() * 7; short potion_damage = a_Item.m_ItemDamage; - cSplashPotionEntity * Projectile = new cSplashPotionEntity(a_Player, - (double)a_BlockX, - (double)a_BlockY, - (double)a_BlockZ, - &Speed, + cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, GetEntityEffectType(potion_damage), cEntityEffect(GetEntityEffectDuration(potion_damage), GetEntityEffectIntensity(potion_damage), -- cgit v1.2.3 From 3766ac96d77329c679d01d1ab1a846384acab42f Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 17:06:15 -0700 Subject: ItemHandler: changed IsDrinkable() to take a short argument --- src/ClientHandle.cpp | 7 ++++--- src/Items/ItemHandler.cpp | 4 ++-- src/Items/ItemHandler.h | 4 ++-- src/Items/ItemMilk.h | 4 ++-- src/Items/ItemPotion.h | 13 ++++--------- 5 files changed, 14 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index ab36bff91..9443cf2c9 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -850,7 +850,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB case DIG_STATUS_SHOOT_EAT: { cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem()); - if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(&m_Player->GetEquippedItem())) + if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(m_Player->GetEquippedItem().m_ItemDamage)) { m_Player->AbortEating(); return; @@ -1176,15 +1176,16 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e return; } + short EquippedDamage = Equipped.m_ItemDamage; cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType); if (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE)) { HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); } - else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(&Equipped)) && !m_Player->IsGameModeCreative()) + else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage)) && !m_Player->IsGameModeCreative()) { - if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(&Equipped)) + if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(EquippedDamage)) { // The player is satiated, they cannot eat return; diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index f847c8ffa..3d13af3a7 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -504,9 +504,9 @@ bool cItemHandler::IsFood(void) -bool cItemHandler::IsDrinkable(const cItem * a_Item) +bool cItemHandler::IsDrinkable(short a_ItemDamage) { - UNUSED(a_Item); + UNUSED(a_ItemDamage); switch (m_ItemType) { diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index ead2c9769..cffca11ab 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -83,7 +83,7 @@ public: virtual bool IsFood(void); /** Indicates if this item is drinkable */ - virtual bool IsDrinkable(const cItem * a_Item); + virtual bool IsDrinkable(short a_ItemDamage); /** Blocks simply get placed */ virtual bool IsPlaceable(void); @@ -102,7 +102,7 @@ public: BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ); - /** Returns whether this tool/item can harvest a specific block (e.g. wooden pickaxe can harvest stone, but wood can�t) DEFAULT: False */ + /** Returns whether this tool/item can harvest a specific block (e.g. wooden pickaxe can harvest stone, but wood can't) DEFAULT: False */ virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType); static cItemHandler * GetItemHandler(int a_ItemType); diff --git a/src/Items/ItemMilk.h b/src/Items/ItemMilk.h index 62506a223..db7bc13be 100644 --- a/src/Items/ItemMilk.h +++ b/src/Items/ItemMilk.h @@ -11,9 +11,9 @@ public: { } - virtual bool IsDrinkable(const cItem * a_Item) override + virtual bool IsDrinkable(short a_ItemDamage) override { - UNUSED(a_Item); + UNUSED(a_ItemDamage); return true; } diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index 029bb52cd..c2441fa48 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -104,22 +104,17 @@ class cItemPotionHandler: return base * tier_multi * ext_multi * splash_multi; } - bool IsDrinkable(short a_ItemDamage) - { - // Drinkable potion if 13th bit is set - // For reference: http://minecraft.gamepedia.com/Potions#Data_value_table - return a_ItemDamage & 8192; - } - public: cItemPotionHandler(): super(E_ITEM_POTIONS) { } - virtual bool IsDrinkable(const cItem * a_Item) override + virtual bool IsDrinkable(short a_ItemDamage) override { - return IsDrinkable(a_Item->m_ItemDamage); + // Drinkable potion if 13th bit is set + // For reference: http://minecraft.gamepedia.com/Potions#Data_value_table + return a_ItemDamage & 8192; } virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override -- cgit v1.2.3 From 68011a004a83adc793f0df563cc924c5a2b7dddc Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 17:17:30 -0700 Subject: Removed long function wrapping --- src/Entities/Pawn.cpp | 3 +-- src/Items/ItemPotion.h | 12 ++---------- 2 files changed, 3 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index a1f24138d..297b4afda 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -69,8 +69,7 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_E } m_EntityEffects[a_EffectType] = a_Effect; - m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), - a_Effect.m_Ticks * a_Effect.GetDistanceModifier()); + m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.m_Ticks * a_Effect.GetDistanceModifier()); } diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index c2441fa48..40748d71c 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -123,12 +123,7 @@ public: Vector3d Speed = a_Player->GetLookVector() * 7; short potion_damage = a_Item.m_ItemDamage; - cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, - GetEntityEffectType(potion_damage), - cEntityEffect(GetEntityEffectDuration(potion_damage), - GetEntityEffectIntensity(potion_damage), - a_Player), - GetPotionName(potion_damage)); + cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, GetEntityEffectType(potion_damage), cEntityEffect(GetEntityEffectDuration(potion_damage), GetEntityEffectIntensity(potion_damage), a_Player), GetPotionName(potion_damage)); if (Projectile == NULL) { return false; @@ -152,10 +147,7 @@ public: { // Called when potion is a drinkable potion short potion_damage = a_Item->m_ItemDamage; - a_Player->AddEntityEffect(GetEntityEffectType(potion_damage), - cEntityEffect(GetEntityEffectDuration(potion_damage), - GetEntityEffectIntensity(potion_damage), - a_Player)); + a_Player->AddEntityEffect(GetEntityEffectType(potion_damage), cEntityEffect(GetEntityEffectDuration(potion_damage), GetEntityEffectIntensity(potion_damage), a_Player)); a_Player->GetInventory().RemoveOneEquippedItem(); a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE); return true; -- cgit v1.2.3 From 52abd90a28736ca07ad4b2df1259f3b54fd74c9d Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 18:14:34 -0700 Subject: Applies splash potion effects to mobs as well as players --- src/Entities/SplashPotionEntity.cpp | 15 +++++++++------ src/Entities/SplashPotionEntity.h | 5 +++-- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 5dcea2385..e8bb0a420 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -1,7 +1,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "SplashPotionEntity.h" -#include "Player.h" +#include "Pawn.h" @@ -44,8 +44,7 @@ void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) { cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect); - m_World->ForEachPlayer(Callback); - // TODO: Should be for each pawn + m_World->ForEachEntity(Callback); m_World->BroadcastSoundParticleEffect(2002, a_HitPos.x, a_HitPos.y, a_HitPos.z, m_PotionName); } @@ -66,9 +65,9 @@ cSplashPotionEntity::cSplashPotionCallback::cSplashPotionCallback(const Vector3d -bool cSplashPotionEntity::cSplashPotionCallback::Item(cPlayer * a_Player) +bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity) { - double distance_splash = (a_Player->GetPosition() - m_HitPos).Length(); + double distance_splash = (a_Entity->GetPosition() - m_HitPos).Length(); if (distance_splash < 20) { // y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash. @@ -77,7 +76,11 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cPlayer * a_Player) if (reduction < 0) reduction = 0; m_EntityEffect.SetDistanceModifier(reduction); - a_Player->AddEntityEffect(m_EntityEffectType, m_EntityEffect); + + if (a_Entity->IsMob() || a_Entity->IsPlayer()) + { + ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect); + } } return false; } diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index b64b668a5..0f84e6387 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -7,6 +7,7 @@ #include "ProjectileEntity.h" #include "EntityEffects.h" #include "../World.h" +#include "Entity.h" @@ -42,12 +43,12 @@ protected: int m_PotionName; class cSplashPotionCallback : - public cPlayerListCallback + public cEntityCallback { public: cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect); - virtual bool Item(cPlayer * a_Player) override; + virtual bool Item(cEntity *a_Entity) override; private: const Vector3d &m_HitPos; -- cgit v1.2.3 From 2574573c883fd7b5d19d19547f34dbef6820b5ea Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 18:44:20 -0700 Subject: Monster: added IsUndead(), undead-specific entity effects --- src/Entities/Pawn.cpp | 6 ----- src/Mobs/Monster.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/Mobs/Monster.h | 6 +++++ 3 files changed, 71 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 297b4afda..fee595e54 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -115,8 +115,6 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect { // Base heal = 6, doubles for every increase in intensity Heal(6 * std::pow(2, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); - - // TODO: Harms undead return; } case cEntityEffect::effInstantDamage: @@ -124,8 +122,6 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect // Base damage = 6, doubles for every increase in intensity int damage = 6 * std::pow(2, a_Effect.GetIntensity()); TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage * a_Effect.GetDistanceModifier(), 0); - - // TODO: Heals undead return; } case cEntityEffect::effStrength: @@ -154,7 +150,6 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect counter = 0; } - // TODO: Doesn't effect undead return; } case cEntityEffect::effPoison: @@ -173,7 +168,6 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect counter = 0; } - // TODO: Doesn't effect undead or spiders return; } case cEntityEffect::effFireResistance: diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 5843ca5a6..b8afbbc0c 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -435,6 +435,52 @@ void cMonster::HandleFalling() + +void cMonster::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) +{ + switch (a_EffectType) + { + case cEntityEffect::effPoison: + { + // Default effect for non-undead mobs and non-spiders + if (!IsUndead() && GetMobType() != mtSpider) break; + return; // No effect + } + case cEntityEffect::effRegeneration: + { + // Default effect for non-undead mobs + if (!IsUndead() && GetMobType()) break; + return; // No effect + } + case cEntityEffect::effInstantDamage: + { + // Default effect for non-undead mobs + if (!IsUndead() && GetMobType()) break; + + // Undead mobs are healed by instant damage + // Base heal = 6, doubles for every increase in intensity + Heal(6 * std::pow(2, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); + return; + } + case cEntityEffect::effInstantHealth: + { + // Default effect for non-undead mobs + if (!IsUndead() && GetMobType()) break; + + // Undead mobs are damaged by instant health + // Base damage = 6, doubles for every increase in intensity + int damage = 6 * std::pow(2, a_Effect.GetIntensity()); + TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage * a_Effect.GetDistanceModifier(), 0); + return; + } + } + + super::HandleEntityEffects(a_EffectType, a_Effect); +} + + + + int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ) { int PosY = POSY_TOINT; @@ -706,6 +752,25 @@ void cMonster::GetMonsterConfig(const AString & a_Name) +bool cMonster::IsUndead(void) +{ + switch (GetMobType()) + { + case mtZombie: + case mtZombiePigman: + case mtSkeleton: + case mtWither: + { + return true; + } + } + return false; +} + + + + + AString cMonster::MobTypeToString(cMonster::eType a_MobType) { // Mob types aren't sorted, so we need to search linearly: diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 7d7e90eb2..dbf95fbed 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -107,6 +107,9 @@ public: /// Reads the monster configuration for the specified monster name and assigns it to this object. void GetMonsterConfig(const AString & a_Name); + /** Returns whether this mob is undead (skeleton, zombie, etc.) */ + bool IsUndead(void); + virtual void EventLosePlayer(void); virtual void CheckEventLostPlayer(void); @@ -178,6 +181,7 @@ protected: /** Stores if mobile is currently moving towards the ultimate, final destination */ bool m_bMovingToDestination; + /** Finds the first non-air block position (not the highest, as cWorld::GetHeight does) If current Y is nonsolid, goes down to try to find a solid block, then returns that + 1 If current Y is solid, goes up to find first nonsolid block, and returns that */ @@ -220,6 +224,8 @@ protected: int m_LastGroundHeight; /* =========================== */ + + virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override; float m_IdleInterval; float m_DestroyTimer; -- cgit v1.2.3 From 814cdca054bec5826b491f6d9d9867ce587d2def Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 21:51:55 -0700 Subject: Added wither damage type, wither entity effect. --- src/BlockID.cpp | 3 +++ src/BlockID.h | 2 ++ src/Entities/Entity.cpp | 1 + src/Entities/Pawn.cpp | 16 +++++++++++++++- 4 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/BlockID.cpp b/src/BlockID.cpp index bfe826f40..8edc51664 100644 --- a/src/BlockID.cpp +++ b/src/BlockID.cpp @@ -363,6 +363,7 @@ AString DamageTypeToString(eDamageType a_DamageType) case dtLightning: return "dtLightning"; case dtOnFire: return "dtOnFire"; case dtPoisoning: return "dtPoisoning"; + case dtWithering: return "dtWithering"; case dtPotionOfHarming: return "dtPotionOfHarming"; case dtRangedAttack: return "dtRangedAttack"; case dtStarving: return "dtStarving"; @@ -408,6 +409,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString) { dtCactusContact, "dtCactusContact"}, { dtLavaContact, "dtLavaContact"}, { dtPoisoning, "dtPoisoning"}, + { dtWithering, "dtWithering"}, { dtOnFire, "dtOnFire"}, { dtFireContact, "dtFireContact"}, { dtInVoid, "dtInVoid"}, @@ -433,6 +435,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString) { dtCactusContact, "dtCacti"}, { dtLavaContact, "dtLava"}, { dtPoisoning, "dtPoison"}, + { dtWithering, "dtWither"}, { dtOnFire, "dtBurning"}, { dtFireContact, "dtInFire"}, { dtAdmin, "dtPlugin"}, diff --git a/src/BlockID.h b/src/BlockID.h index 272fd319d..e3567b6fc 100644 --- a/src/BlockID.h +++ b/src/BlockID.h @@ -811,6 +811,7 @@ enum eDamageType dtCactusContact, // Contact with a cactus block dtLavaContact, // Contact with a lava block dtPoisoning, // Having the poison effect + dtWithering, // Having the wither effect dtOnFire, // Being on fire dtFireContact, // Standing inside a fire block dtInVoid, // Falling into the Void (Y < 0) @@ -837,6 +838,7 @@ enum eDamageType dtCacti = dtCactusContact, dtLava = dtLavaContact, dtPoison = dtPoisoning, + dtWither = dtWithering, dtBurning = dtOnFire, dtInFire = dtFireContact, dtPlugin = dtAdmin, diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index ba829bf6b..06833e1ba 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -432,6 +432,7 @@ bool cEntity::ArmorCoversAgainst(eDamageType a_DamageType) case dtStarving: case dtInVoid: case dtPoisoning: + case dtWithering: case dtPotionOfHarming: case dtFalling: case dtLightning: diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index fee595e54..51ffc46b2 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -154,7 +154,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect } case cEntityEffect::effPoison: { - // Poison frequency = 25 ticks, divided by potion level (Poison II = 25 ticks) + // Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks) int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1)); static short counter = 0; @@ -170,6 +170,20 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect return; } + case cEntityEffect::effWither: + { + // Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks) + int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1)); + + static short counter = 0; + if (++counter >= frequency) + { + TakeDamage(dtWither, a_Effect.GetUser(), 1, 0); + counter = 0; + } + //TODO: " withered away> + return; + } case cEntityEffect::effFireResistance: { // TODO: Implement me! -- cgit v1.2.3 From 71b4c4949087860ab9962d6545a0ad2eb9c0ee5a Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 11 Jun 2014 16:21:47 -0700 Subject: Cave spider now poisons its victim, added IsPawn function to Entity --- src/Entities/Entity.h | 1 + src/Entities/SplashPotionEntity.cpp | 2 +- src/Mobs/AggressiveMonster.cpp | 10 ++++++---- src/Mobs/CaveSpider.cpp | 15 +++++++++++++++ src/Mobs/CaveSpider.h | 1 + 5 files changed, 24 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index b8f1f4c1c..b5d5cc34c 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -158,6 +158,7 @@ public: bool IsPlayer (void) const { return (m_EntityType == etPlayer); } bool IsPickup (void) const { return (m_EntityType == etPickup); } bool IsMob (void) const { return (m_EntityType == etMonster); } + bool IsPawn (void) const { return (IsMob() || IsPlayer()); } bool IsFallingBlock(void) const { return (m_EntityType == etFallingBlock); } bool IsMinecart (void) const { return (m_EntityType == etMinecart); } bool IsBoat (void) const { return (m_EntityType == etBoat); } diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index e8bb0a420..5574ea53c 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -77,7 +77,7 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity) m_EntityEffect.SetDistanceModifier(reduction); - if (a_Entity->IsMob() || a_Entity->IsPlayer()) + if (a_Entity->IsPawn()) { ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect); } diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index 85b122034..de881f4eb 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -95,12 +95,14 @@ void cAggressiveMonster::Attack(float a_Dt) { m_AttackInterval += a_Dt * m_AttackRate; - if ((m_Target != NULL) && (m_AttackInterval > 3.0)) + if ((m_Target == NULL) || (m_AttackInterval < 3.0)) { - // Setting this higher gives us more wiggle room for attackrate - m_AttackInterval = 0.0; - m_Target->TakeDamage(dtMobAttack, this, m_AttackDamage, 0); + return; } + + // Setting this higher gives us more wiggle room for attackrate + m_AttackInterval = 0.0; + m_Target->TakeDamage(dtMobAttack, this, m_AttackDamage, 0); } diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp index 1157b81f9..fe0f2ac73 100644 --- a/src/Mobs/CaveSpider.cpp +++ b/src/Mobs/CaveSpider.cpp @@ -27,6 +27,21 @@ void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk) +void cCaveSpider::Attack(float a_Dt) +{ + super::Attack(a_Dt); + + if (m_Target->IsPawn()) + { + // TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds + ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, cEntityEffect(140, 0, this)); + } +} + + + + + void cCaveSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer) { int LootingLevel = 0; diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h index be9f174f9..3f8b2cece 100644 --- a/src/Mobs/CaveSpider.h +++ b/src/Mobs/CaveSpider.h @@ -17,6 +17,7 @@ public: CLASS_PROTODEF(cCaveSpider); virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Attack(float a_Dt) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; } ; -- cgit v1.2.3 From 5b2b6e06150b6299d1e19374be092c0858b0e3a8 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 12 Jun 2014 19:50:02 -0700 Subject: Pawn: renamed HandleEntityEffects to HandleEntityEffect Exported entity effect functions for ToLua and documented them in APIDesc.lua --- src/Entities/Pawn.cpp | 4 ++-- src/Entities/Pawn.h | 4 +++- src/Entities/Player.cpp | 4 ++-- src/Entities/Player.h | 2 +- src/Items/ItemPotion.h | 2 +- src/Mobs/Monster.cpp | 4 ++-- src/Mobs/Monster.h | 2 +- 7 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 51ffc46b2..67b6fe4db 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -28,7 +28,7 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk) cEntityEffect &effect_values = iter->second; // Apply entity effect - HandleEntityEffects(effect_type, effect_values); + HandleEntityEffect(effect_type, effect_values); // Reduce the effect's duration effect_values.m_Ticks--; @@ -106,7 +106,7 @@ void cPawn::ClearEntityEffects() -void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) +void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) { switch (a_EffectType) { diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index 47fb691f4..2ffdd9fbb 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -23,6 +23,7 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void KilledBy(cEntity * a_Killer) override; + // tolua_begin /** Applies an entity effect * @param a_EffectType The entity effect to apply * @param a_Effect The parameters of the effect @@ -36,6 +37,7 @@ public: /** Removes all currently applied entity effects (used when drinking milk) */ void ClearEntityEffects(); + // tolua_end protected: typedef std::map tEffectMap; @@ -45,7 +47,7 @@ protected: * @param a_EffectType The selected entity effect * @param a_Effect The parameters of the selected entity effect */ - virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect); + virtual void HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect); } ; // tolua_export diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 6bceab26f..5d8c3479b 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1867,7 +1867,7 @@ void cPlayer::TickBurning(cChunk & a_Chunk) -void cPlayer::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) +void cPlayer::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) { switch (a_EffectType) { @@ -1897,7 +1897,7 @@ void cPlayer::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffe } } - super::HandleEntityEffects(a_EffectType, a_Effect); + super::HandleEntityEffect(a_EffectType, a_Effect); } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 3aba3289d..a793d3c30 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -522,7 +522,7 @@ protected: virtual void TickBurning(cChunk & a_Chunk) override; /** Called each tick to handle entity effects*/ - virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override; + virtual void HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override; /** Called in each tick to handle food-related processing */ void HandleFood(void); diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index 40748d71c..2c5760e34 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -128,7 +128,7 @@ public: { return false; } - if (!Projectile->Initialize(*a_World)) + if (!Projectile->Initialize(a_World)) { delete Projectile; return false; diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index b8afbbc0c..4dfd81d88 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -436,7 +436,7 @@ void cMonster::HandleFalling() -void cMonster::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) +void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) { switch (a_EffectType) { @@ -475,7 +475,7 @@ void cMonster::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEff } } - super::HandleEntityEffects(a_EffectType, a_Effect); + super::HandleEntityEffect(a_EffectType, a_Effect); } diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index dbf95fbed..ca6cb0593 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -225,7 +225,7 @@ protected: /* =========================== */ - virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override; + virtual void HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override; float m_IdleInterval; float m_DestroyTimer; -- cgit v1.2.3 From 045ae2ef2c0d72b4902fa5151aad095823da9300 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Jun 2014 09:49:42 +0200 Subject: Fixed MSVC compilation. --- src/Entities/Pawn.cpp | 11 +++++++---- src/Items/ItemPotion.h | 14 +++++++------- src/Mobs/Monster.cpp | 6 +++--- 3 files changed, 17 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 67b6fe4db..186e7df2a 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -114,14 +114,14 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect case cEntityEffect::effInstantHealth: { // Base heal = 6, doubles for every increase in intensity - Heal(6 * std::pow(2, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); + Heal((int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier())); return; } case cEntityEffect::effInstantDamage: { // Base damage = 6, doubles for every increase in intensity - int damage = 6 * std::pow(2, a_Effect.GetIntensity()); - TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage * a_Effect.GetDistanceModifier(), 0); + int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); + TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0); return; } case cEntityEffect::effStrength: @@ -132,7 +132,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect case cEntityEffect::effWeakness: { // Damage reduction = 0.5 damage, multiplied by potion level (Weakness II = 1 damage) - //double dmg_reduc = 0.5 * (a_Effect.GetIntensity() + 1); + // double dmg_reduc = 0.5 * (a_Effect.GetIntensity() + 1); // TODO: Implement me! // TODO: Weakened villager zombies can be turned back to villagers with the god apple @@ -143,6 +143,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect // Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks) int frequency = std::floor(50.0 / (double)(a_Effect.GetIntensity() + 1)); + // TODO: The counter needs to be specific to one cPawn, make it a member variable. static short counter = 0; if (++counter >= frequency) { @@ -157,6 +158,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect // Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks) int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1)); + // TODO: The counter needs to be specific to one cPawn, make it a member variable. static short counter = 0; if (++counter >= frequency) { @@ -175,6 +177,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect // Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks) int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1)); + // TODO: The counter needs to be specific to one cPawn, make it a member variable. static short counter = 0; if (++counter >= frequency) { diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index 2c5760e34..200c13cab 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -57,7 +57,7 @@ class cItemPotionHandler: { // Base duration in ticks int base = 0; - double tier_multi = 1, ext_multi = 1, splash_multi = 1; + double TierCoeff = 1, ExtCoeff = 1, SplashCoeff = 1; switch (GetEntityEffectType(a_ItemDamage)) { @@ -88,20 +88,20 @@ class cItemPotionHandler: } // If potion is level 2, half the duration. If not, stays the same - tier_multi = GetEntityEffectIntensity(a_ItemDamage) > 0 ? 0.5 : 1; + TierCoeff = (GetEntityEffectIntensity(a_ItemDamage) > 0) ? 0.5 : 1; // If potion is extended, multiply duration by 8/3. If not, stays the same // Extended potion if sixth bit is set - ext_multi = a_ItemDamage & 64 ? (8.0/3.0) : 1; + ExtCoeff = (a_ItemDamage & 64) ? (8.0/3.0) : 1; // If potion is splash potion, multiply duration by 3/4. If not, stays the same - splash_multi = !IsDrinkable(a_ItemDamage) ? 0.75 : 1; + SplashCoeff = IsDrinkable(a_ItemDamage) ? 1 : 0.75; // For reference: http://minecraft.gamepedia.com/Data_values#.22Tier.22_bit // http://minecraft.gamepedia.com/Data_values#.22Extended_duration.22_bit // http://minecraft.gamepedia.com/Data_values#.22Splash_potion.22_bit - return base * tier_multi * ext_multi * splash_multi; + return (int)(base * TierCoeff * ExtCoeff * SplashCoeff); } public: @@ -114,7 +114,7 @@ public: { // Drinkable potion if 13th bit is set // For reference: http://minecraft.gamepedia.com/Potions#Data_value_table - return a_ItemDamage & 8192; + return ((a_ItemDamage & 8192) != 0); } virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override @@ -128,7 +128,7 @@ public: { return false; } - if (!Projectile->Initialize(a_World)) + if (!Projectile->Initialize(*a_World)) { delete Projectile; return false; diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 4dfd81d88..8a8c4f67a 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -459,7 +459,7 @@ void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffe // Undead mobs are healed by instant damage // Base heal = 6, doubles for every increase in intensity - Heal(6 * std::pow(2, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); + Heal((int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier())); return; } case cEntityEffect::effInstantHealth: @@ -469,8 +469,8 @@ void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffe // Undead mobs are damaged by instant health // Base damage = 6, doubles for every increase in intensity - int damage = 6 * std::pow(2, a_Effect.GetIntensity()); - TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage * a_Effect.GetDistanceModifier(), 0); + int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); + TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0); return; } } -- cgit v1.2.3 From 22761bb6ad4b121ae3b2319a9a2541a6bb8a982c Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 13 Jun 2014 01:50:09 -0700 Subject: Entity Effect: Separates total duration and ticks of activity Changed HandleEntityEffect to use cEntityEffect's ticks instead of a static counter --- src/Entities/EntityEffects.cpp | 8 +++++--- src/Entities/EntityEffects.h | 13 ++++++++++--- src/Entities/Pawn.cpp | 24 ++++++++---------------- 3 files changed, 23 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffects.cpp b/src/Entities/EntityEffects.cpp index c74463bfa..e8448a6f1 100644 --- a/src/Entities/EntityEffects.cpp +++ b/src/Entities/EntityEffects.cpp @@ -8,6 +8,7 @@ cEntityEffect::cEntityEffect(): m_Ticks(0), + m_Duration(0), m_Intensity(0), m_User(NULL), m_DistanceModifier(1) @@ -19,11 +20,12 @@ cEntityEffect::cEntityEffect(): -cEntityEffect::cEntityEffect(int a_Ticks, short a_Intensity, cPawn *a_User, double a_DistanceModifier): - m_Ticks(a_Ticks), +cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_User, double a_DistanceModifier): + m_Ticks(0), + m_Duration(a_Duration), m_Intensity(a_Intensity), m_User(a_User), m_DistanceModifier(a_DistanceModifier) { -} \ No newline at end of file +} diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h index 26d2c92e5..6b2532aae 100644 --- a/src/Entities/EntityEffects.h +++ b/src/Entities/EntityEffects.h @@ -35,9 +35,12 @@ public: effSaturation = 23, } ; - /** The duration of the effect */ + /** How many ticks this effect has been active for */ int m_Ticks; + /** Returns the duration of the effect */ + int GetDuration() { return m_Duration; } + /** Returns how strong the effect will be applied */ short GetIntensity() { return m_Intensity; } @@ -47,6 +50,7 @@ public: /** Returns the distance modifier for affecting potency */ double GetDistanceModifier() { return m_DistanceModifier; } + void SetDuration(int a_Duration) { m_Duration = a_Duration; } void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; } void SetUser(cPawn *a_User) { m_User = a_User; } void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; } @@ -58,14 +62,17 @@ public: /** * An entity effect - * @param a_Ticks The duration of the effect + * @param a_Duration How long this effect will last * @param a_Intensity How strong the effect will be applied * @param a_User The pawn that used this entity effect * @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ - cEntityEffect(int a_Ticks, short a_Intensity, cPawn *a_User, double a_DistanceModifier = 1); + cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_User, double a_DistanceModifier = 1); private: + /** How long this effect will last */ + int m_Duration; + /** How strong the effect will be applied */ short m_Intensity; diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 186e7df2a..0273981f9 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -30,14 +30,14 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk) // Apply entity effect HandleEntityEffect(effect_type, effect_values); - // Reduce the effect's duration - effect_values.m_Ticks--; + // Increase the effect's tick counter + effect_values.m_Ticks++; // Iterates (must be called before any possible erasure) ++iter; // Remove effect if duration has elapsed - if (effect_values.m_Ticks <= 0) + if (effect_values.GetDuration() - effect_values.m_Ticks <= 0) { RemoveEntityEffect(effect_type); } @@ -68,8 +68,9 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_E return; } + a_Effect.SetDuration(a_Effect.GetDuration() * a_Effect.GetDistanceModifier()); m_EntityEffects[a_EffectType] = a_Effect; - m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.m_Ticks * a_Effect.GetDistanceModifier()); + m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.GetDuration()); } @@ -143,12 +144,9 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect // Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks) int frequency = std::floor(50.0 / (double)(a_Effect.GetIntensity() + 1)); - // TODO: The counter needs to be specific to one cPawn, make it a member variable. - static short counter = 0; - if (++counter >= frequency) + if (a_Effect.m_Ticks % frequency == 0) { Heal(1); - counter = 0; } return; @@ -158,16 +156,13 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect // Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks) int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1)); - // TODO: The counter needs to be specific to one cPawn, make it a member variable. - static short counter = 0; - if (++counter >= frequency) + if (a_Effect.m_Ticks % frequency == 0) { // Cannot take poison damage when health is at 1 if (GetHealth() > 1) { TakeDamage(dtPoisoning, a_Effect.GetUser(), 1, 0); } - counter = 0; } return; @@ -177,12 +172,9 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect // Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks) int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1)); - // TODO: The counter needs to be specific to one cPawn, make it a member variable. - static short counter = 0; - if (++counter >= frequency) + if (a_Effect.m_Ticks % frequency == 0) { TakeDamage(dtWither, a_Effect.GetUser(), 1, 0); - counter = 0; } //TODO: " withered away> return; -- cgit v1.2.3 From e289fe4dd7372a029ba85722e3ce99991e9d1d6b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Jun 2014 11:04:16 +0200 Subject: Changed the AddEntityEffect() params for easier calls. --- src/Entities/EntityEffects.h | 27 ++++++++++++--------------- src/Entities/Pawn.cpp | 33 ++++++++++++++++----------------- src/Entities/Pawn.h | 16 +++++++++------- src/Entities/Player.cpp | 2 +- src/Entities/SplashPotionEntity.cpp | 19 ++++++++++++------- src/Items/ItemPotion.h | 3 +-- src/Mobs/CaveSpider.cpp | 2 +- 7 files changed, 52 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h index 6b2532aae..c0e8abd28 100644 --- a/src/Entities/EntityEffects.h +++ b/src/Entities/EntityEffects.h @@ -3,7 +3,8 @@ class cPawn; // tolua_begin -class cEntityEffect { +class cEntityEffect +{ public: /** All types of entity effects (numbers correspond to IDs) */ @@ -52,25 +53,21 @@ public: void SetDuration(int a_Duration) { m_Duration = a_Duration; } void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; } - void SetUser(cPawn *a_User) { m_User = a_User; } + void SetUser(cPawn * a_User) { m_User = a_User; } void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; } - /** - * An empty entity effect - */ - cEntityEffect(); + /** Creates an empty entity effect */ + cEntityEffect(void); - /** - * An entity effect - * @param a_Duration How long this effect will last - * @param a_Intensity How strong the effect will be applied - * @param a_User The pawn that used this entity effect - * @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 - */ - cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_User, double a_DistanceModifier = 1); + /** Creates an entity effect of the specified type + @param a_Duration How long this effect will last, in ticks + @param a_Intensity How strong the effect will be applied + @param a_User The pawn that used this entity effect + @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ + cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_User, double a_DistanceModifier = 1); private: - /** How long this effect will last */ + /** How long this effect will last, in ticks */ int m_Duration; /** How strong the effect will be applied */ diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 0273981f9..ec829f6f8 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -8,9 +8,9 @@ -cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) - : cEntity(a_EntityType, 0, 0, 0, a_Width, a_Height) - , m_EntityEffects(tEffectMap()) +cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height): + super(a_EntityType, 0, 0, 0, a_Width, a_Height), + m_EntityEffects(tEffectMap()) { } @@ -24,22 +24,22 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk) for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();) { // Copies values to prevent pesky wrong accesses and erasures - cEntityEffect::eType effect_type = iter->first; - cEntityEffect &effect_values = iter->second; + cEntityEffect::eType EffectType = iter->first; + cEntityEffect & EffectValues = iter->second; // Apply entity effect - HandleEntityEffect(effect_type, effect_values); + HandleEntityEffect(EffectType, EffectValues); - // Increase the effect's tick counter - effect_values.m_Ticks++; + // Reduce the effect's duration + EffectValues.m_Ticks++; // Iterates (must be called before any possible erasure) ++iter; // Remove effect if duration has elapsed - if (effect_values.GetDuration() - effect_values.m_Ticks <= 0) + if (EffectValues.GetDuration() - EffectValues.m_Ticks <= 0) { - RemoveEntityEffect(effect_type); + RemoveEntityEffect(EffectType); } // TODO: Check for discrepancies between client and server effect values @@ -52,7 +52,7 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk) -void cPawn::KilledBy(cEntity *a_Killer) +void cPawn::KilledBy(cEntity * a_Killer) { ClearEntityEffects(); } @@ -61,16 +61,15 @@ void cPawn::KilledBy(cEntity *a_Killer) -void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) +void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier) { if (a_EffectType == cEntityEffect::effNoEffect) { return; } - a_Effect.SetDuration(a_Effect.GetDuration() * a_Effect.GetDistanceModifier()); - m_EntityEffects[a_EffectType] = a_Effect; - m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.GetDuration()); + m_EntityEffects[a_EffectType] = cEntityEffect(a_EffectDurationTicks, a_EffectIntensity, this, a_DistanceModifier); + m_World->BroadcastEntityEffect(*this, a_EffectType, a_EffectIntensity, (short)(a_EffectDurationTicks * a_DistanceModifier)); } @@ -93,13 +92,13 @@ void cPawn::ClearEntityEffects() for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();) { // Copy values to prevent pesky wrong erasures - cEntityEffect::eType effect_type = iter->first; + cEntityEffect::eType EffectType = iter->first; // Iterates (must be called before any possible erasure) ++iter; // Remove effect - RemoveEntityEffect(effect_type); + RemoveEntityEffect(EffectType); } } diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index 2ffdd9fbb..399e02e64 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -24,19 +24,21 @@ public: virtual void KilledBy(cEntity * a_Killer) override; // tolua_begin + /** Applies an entity effect - * @param a_EffectType The entity effect to apply - * @param a_Effect The parameters of the effect - */ - void AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect); + @param a_EffectType The entity effect to apply + @param a_Effect The parameters of the effect + */ + void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier = 1); /** Removes a currently applied entity effect - * @param a_EffectType The entity effect to remove - */ + @param a_EffectType The entity effect to remove + */ void RemoveEntityEffect(cEntityEffect::eType a_EffectType); /** Removes all currently applied entity effects (used when drinking milk) */ - void ClearEntityEffects(); + void ClearEntityEffects(void); + // tolua_end protected: diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 5d8c3479b..f2ec81957 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -570,7 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation) void cPlayer::FoodPoison(int a_NumTicks) { - AddEntityEffect(cEntityEffect::effHunger, cEntityEffect(a_NumTicks, 0, NULL)); + AddEntityEffect(cEntityEffect::effHunger, a_NumTicks, 0); } diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 5574ea53c..4035b4794 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -67,20 +67,25 @@ cSplashPotionEntity::cSplashPotionCallback::cSplashPotionCallback(const Vector3d bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity) { - double distance_splash = (a_Entity->GetPosition() - m_HitPos).Length(); - if (distance_splash < 20) + double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length(); + if (SplashDistance < 20) { // y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash. // TODO: better equation - double reduction = -0.25 * distance_splash + 1.0; - if (reduction < 0) reduction = 0; - - m_EntityEffect.SetDistanceModifier(reduction); + double Reduction = -0.25 * SplashDistance + 1.0; + if (Reduction < 0) + { + Reduction = 0; + } if (a_Entity->IsPawn()) { - ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect); + ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.m_Ticks, m_EntityEffect.GetIntensity(), Reduction); } } return false; } + + + + diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index 200c13cab..70a926cad 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -146,8 +146,7 @@ public: virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override { // Called when potion is a drinkable potion - short potion_damage = a_Item->m_ItemDamage; - a_Player->AddEntityEffect(GetEntityEffectType(potion_damage), cEntityEffect(GetEntityEffectDuration(potion_damage), GetEntityEffectIntensity(potion_damage), a_Player)); + a_Player->AddEntityEffect(GetEntityEffectType(a_Item->m_ItemDamage), GetEntityEffectDuration(a_Item->m_ItemDamage), GetEntityEffectIntensity(a_Item->m_ItemDamage)); a_Player->GetInventory().RemoveOneEquippedItem(); a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE); return true; diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp index fe0f2ac73..118a6e93b 100644 --- a/src/Mobs/CaveSpider.cpp +++ b/src/Mobs/CaveSpider.cpp @@ -34,7 +34,7 @@ void cCaveSpider::Attack(float a_Dt) if (m_Target->IsPawn()) { // TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds - ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, cEntityEffect(140, 0, this)); + ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0); } } -- cgit v1.2.3 From 9e8361976b6b0dc4c62ef48a4744ba1f59fe4346 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 13 Jun 2014 02:41:43 -0700 Subject: Entity Effects: Clarified user, added it to AddEntityEffect Added second AddEntityEffect with a pass-by-value of the class. --- src/Entities/EntityEffects.h | 6 +++--- src/Entities/Pawn.cpp | 16 +++++++++++++--- src/Entities/Pawn.h | 11 ++++++++++- src/Entities/Player.cpp | 2 +- src/Entities/SplashPotionEntity.cpp | 8 +++----- src/Items/ItemPotion.h | 2 +- src/Mobs/CaveSpider.cpp | 2 +- 7 files changed, 32 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h index c0e8abd28..2a4d0f723 100644 --- a/src/Entities/EntityEffects.h +++ b/src/Entities/EntityEffects.h @@ -45,7 +45,7 @@ public: /** Returns how strong the effect will be applied */ short GetIntensity() { return m_Intensity; } - /** Returns the pawn that used this entity effect */ + /** Returns the pawn that produced this entity effect */ cPawn *GetUser() { return m_User; } /** Returns the distance modifier for affecting potency */ @@ -62,7 +62,7 @@ public: /** Creates an entity effect of the specified type @param a_Duration How long this effect will last, in ticks @param a_Intensity How strong the effect will be applied - @param a_User The pawn that used this entity effect + @param a_User The pawn that produced this entity effect @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_User, double a_DistanceModifier = 1); @@ -73,7 +73,7 @@ private: /** How strong the effect will be applied */ short m_Intensity; - /** The pawn that used this entity effect */ + /** The pawn that produced this entity effect (threw the potion, etc) */ cPawn *m_User; /** The distance modifier for affecting potency */ diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index ec829f6f8..2986799b7 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -61,15 +61,25 @@ void cPawn::KilledBy(cEntity * a_Killer) -void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier) +void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier) +{ + AddEntityEffect(a_EffectType, cEntityEffect(a_EffectDurationTicks, a_EffectIntensity, a_User, a_DistanceModifier)); +} + + + + + +void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) { if (a_EffectType == cEntityEffect::effNoEffect) { return; } - m_EntityEffects[a_EffectType] = cEntityEffect(a_EffectDurationTicks, a_EffectIntensity, this, a_DistanceModifier); - m_World->BroadcastEntityEffect(*this, a_EffectType, a_EffectIntensity, (short)(a_EffectDurationTicks * a_DistanceModifier)); + a_Effect.SetDuration(a_Effect.GetDuration() * a_Effect.GetDistanceModifier()); + m_EntityEffects[a_EffectType] = a_Effect; + m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.GetDuration()); } diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index 399e02e64..3b83ec52f 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -25,11 +25,20 @@ public: // tolua_begin + /** Applies an entity effect + @param a_EffectType The entity effect to apply + @param a_EffectDurationTicks The duration of the effect + @param a_EffectIntensity The level of the effect (0 = Potion I, 1 = Potion II, etc) + @param a_User The pawn that produced the effect (e.g. threw the potion) + @param a_DistanceModifier The scalar multiplied to the potion duration, only applies to splash potions) + */ + void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier = 1); + /** Applies an entity effect @param a_EffectType The entity effect to apply @param a_Effect The parameters of the effect */ - void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier = 1); + void AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect); /** Removes a currently applied entity effect @param a_EffectType The entity effect to remove diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index f2ec81957..b7a315a40 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -570,7 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation) void cPlayer::FoodPoison(int a_NumTicks) { - AddEntityEffect(cEntityEffect::effHunger, a_NumTicks, 0); + AddEntityEffect(cEntityEffect::effHunger, a_NumTicks, 0, NULL); } diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 4035b4794..714e4021d 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -68,7 +68,7 @@ cSplashPotionEntity::cSplashPotionCallback::cSplashPotionCallback(const Vector3d bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity) { double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length(); - if (SplashDistance < 20) + if (SplashDistance < 20 && a_Entity->IsPawn()) { // y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash. // TODO: better equation @@ -78,10 +78,8 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity) Reduction = 0; } - if (a_Entity->IsPawn()) - { - ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.m_Ticks, m_EntityEffect.GetIntensity(), Reduction); - } + m_EntityEffect.SetDistanceModifier(Reduction); + ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect); } return false; } diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index 70a926cad..853ed53a8 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -146,7 +146,7 @@ public: virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override { // Called when potion is a drinkable potion - a_Player->AddEntityEffect(GetEntityEffectType(a_Item->m_ItemDamage), GetEntityEffectDuration(a_Item->m_ItemDamage), GetEntityEffectIntensity(a_Item->m_ItemDamage)); + a_Player->AddEntityEffect(GetEntityEffectType(a_Item->m_ItemDamage), GetEntityEffectDuration(a_Item->m_ItemDamage), GetEntityEffectIntensity(a_Item->m_ItemDamage), a_Player); a_Player->GetInventory().RemoveOneEquippedItem(); a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE); return true; diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp index 118a6e93b..34135714d 100644 --- a/src/Mobs/CaveSpider.cpp +++ b/src/Mobs/CaveSpider.cpp @@ -34,7 +34,7 @@ void cCaveSpider::Attack(float a_Dt) if (m_Target->IsPawn()) { // TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds - ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0); + ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0, this); } } -- cgit v1.2.3 From fa1d85feca6beee9e07cf92f015a883a190c726a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Jun 2014 12:47:01 +0200 Subject: Added the OnEntityAddEffect hook. --- src/Bindings/Plugin.h | 1 + src/Bindings/PluginLua.cpp | 21 +++++++++++++++++++++ src/Bindings/PluginLua.h | 1 + src/Bindings/PluginManager.cpp | 21 +++++++++++++++++++++ src/Bindings/PluginManager.h | 2 ++ src/Entities/Pawn.cpp | 9 +++++++++ src/Entities/Pawn.h | 2 ++ 7 files changed, 57 insertions(+) (limited to 'src') diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index c6461c861..2e02cba54 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -57,6 +57,7 @@ public: virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) = 0; virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) = 0; + virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) = 0; virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) = 0; virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0; virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 04639da60..09ffa6064 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -420,6 +420,26 @@ bool cPluginLua::OnDisconnect(cClientHandle & a_Client, const AString & a_Reason +bool cPluginLua::OnEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) +{ + cCSLock Lock(m_CriticalSection); + bool res = false; + cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_ADD_EFFECT]; + for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) + { + m_LuaState.Call((int)(**itr), &a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Originator, a_DistanceModifier, cLuaState::Return, res); + if (res) + { + return true; + } + } + return false; +} + + + + + bool cPluginLua::OnExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split) { cCSLock Lock(m_CriticalSection); @@ -1507,6 +1527,7 @@ const char * cPluginLua::GetHookFnName(int a_HookType) case cPluginManager::HOOK_CRAFTING_NO_RECIPE: return "OnCraftingNoRecipe"; case cPluginManager::HOOK_DISCONNECT: return "OnDisconnect"; case cPluginManager::HOOK_PLAYER_ANIMATION: return "OnPlayerAnimation"; + case cPluginManager::HOOK_ENTITY_ADD_EFFECT: return "OnEntityAddEffect"; case cPluginManager::HOOK_EXECUTE_COMMAND: return "OnExecuteCommand"; case cPluginManager::HOOK_HANDSHAKE: return "OnHandshake"; case cPluginManager::HOOK_KILLING: return "OnKilling"; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 598e031c0..d0dcfb011 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -80,6 +80,7 @@ public: virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) override; virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override; + virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) override; virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) override; virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override; virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 9bcd8e3b7..d332980bd 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -448,6 +448,27 @@ bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString +bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) +{ + HookMap::iterator Plugins = m_Hooks.find(HOOK_ENTITY_ADD_EFFECT); + if (Plugins == m_Hooks.end()) + { + return false; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnEntityAddEffect(a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Originator, a_DistanceModifier)) + { + return true; + } + } + return false; +} + + + + + bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split) { FIND_HOOK(HOOK_EXECUTE_COMMAND); diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index be40bd2f7..4bd6b4837 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -73,6 +73,7 @@ public: // tolua_export HOOK_CRAFTING_NO_RECIPE, HOOK_DISCONNECT, HOOK_PLAYER_ANIMATION, + HOOK_ENTITY_ADD_EFFECT, HOOK_EXECUTE_COMMAND, HOOK_EXPLODED, HOOK_EXPLODING, @@ -173,6 +174,7 @@ public: // tolua_export bool CallHookCollectingPickup (cPlayer * a_Player, cPickup & a_Pickup); bool CallHookCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason); + bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier); bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == NULL, it is a console cmd bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData); bool CallHookExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData); diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 2986799b7..41a5b33ff 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -3,6 +3,7 @@ #include "Pawn.h" #include "../World.h" +#include "../Bindings/PluginManager.h" @@ -72,6 +73,14 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurat void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) { + // Check if the plugins allow the addition: + if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_Effect.GetDuration(), a_Effect.GetIntensity(), a_Effect.GetUser(), a_Effect.GetDistanceModifier())) + { + // A plugin disallows the addition, bail out. + return; + } + + // No need to add empty effects: if (a_EffectType == cEntityEffect::effNoEffect) { return; diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index 3b83ec52f..c6be6f668 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -26,6 +26,7 @@ public: // tolua_begin /** Applies an entity effect + Checks with plugins if they allow the addition. @param a_EffectType The entity effect to apply @param a_EffectDurationTicks The duration of the effect @param a_EffectIntensity The level of the effect (0 = Potion I, 1 = Potion II, etc) @@ -35,6 +36,7 @@ public: void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier = 1); /** Applies an entity effect + Checks with plugins if they allow the addition. @param a_EffectType The entity effect to apply @param a_Effect The parameters of the effect */ -- cgit v1.2.3 From 68c30790db17b9d21b2fcda4c7edec679162c577 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 13 Jun 2014 10:59:59 -0700 Subject: Entity effects: changed User to Creator, removed pawn pass-by-value --- src/Entities/EntityEffects.cpp | 6 +++--- src/Entities/EntityEffects.h | 10 +++++----- src/Entities/Pawn.cpp | 25 ++++++++----------------- src/Entities/Pawn.h | 11 ++--------- src/Entities/SplashPotionEntity.cpp | 2 +- src/Mobs/Monster.cpp | 2 +- 6 files changed, 20 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffects.cpp b/src/Entities/EntityEffects.cpp index e8448a6f1..a9edeee25 100644 --- a/src/Entities/EntityEffects.cpp +++ b/src/Entities/EntityEffects.cpp @@ -10,7 +10,7 @@ cEntityEffect::cEntityEffect(): m_Ticks(0), m_Duration(0), m_Intensity(0), - m_User(NULL), + m_Creator(NULL), m_DistanceModifier(1) { @@ -20,11 +20,11 @@ cEntityEffect::cEntityEffect(): -cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_User, double a_DistanceModifier): +cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_Creator, double a_DistanceModifier): m_Ticks(0), m_Duration(a_Duration), m_Intensity(a_Intensity), - m_User(a_User), + m_Creator(a_Creator), m_DistanceModifier(a_DistanceModifier) { diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h index 2a4d0f723..9de3fcb86 100644 --- a/src/Entities/EntityEffects.h +++ b/src/Entities/EntityEffects.h @@ -46,14 +46,14 @@ public: short GetIntensity() { return m_Intensity; } /** Returns the pawn that produced this entity effect */ - cPawn *GetUser() { return m_User; } + cPawn *GetCreator() { return m_Creator; } /** Returns the distance modifier for affecting potency */ double GetDistanceModifier() { return m_DistanceModifier; } void SetDuration(int a_Duration) { m_Duration = a_Duration; } void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; } - void SetUser(cPawn * a_User) { m_User = a_User; } + void SetCreator(cPawn * a_Creator) { m_Creator = a_Creator; } void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; } /** Creates an empty entity effect */ @@ -62,9 +62,9 @@ public: /** Creates an entity effect of the specified type @param a_Duration How long this effect will last, in ticks @param a_Intensity How strong the effect will be applied - @param a_User The pawn that produced this entity effect + @param a_Creator The pawn that produced this entity effect @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ - cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_User, double a_DistanceModifier = 1); + cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1); private: /** How long this effect will last, in ticks */ @@ -74,7 +74,7 @@ private: short m_Intensity; /** The pawn that produced this entity effect (threw the potion, etc) */ - cPawn *m_User; + cPawn *m_Creator; /** The distance modifier for affecting potency */ double m_DistanceModifier; diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 41a5b33ff..6c70fd2a6 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -62,19 +62,10 @@ void cPawn::KilledBy(cEntity * a_Killer) -void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier) -{ - AddEntityEffect(a_EffectType, cEntityEffect(a_EffectDurationTicks, a_EffectIntensity, a_User, a_DistanceModifier)); -} - - - - - -void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) +void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_Creator, double a_DistanceModifier) { // Check if the plugins allow the addition: - if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_Effect.GetDuration(), a_Effect.GetIntensity(), a_Effect.GetUser(), a_Effect.GetDistanceModifier())) + if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Creator, a_DistanceModifier)) { // A plugin disallows the addition, bail out. return; @@ -86,9 +77,9 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_E return; } - a_Effect.SetDuration(a_Effect.GetDuration() * a_Effect.GetDistanceModifier()); - m_EntityEffects[a_EffectType] = a_Effect; - m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.GetDuration()); + int EffectDuration = (int)(a_EffectDurationTicks * a_DistanceModifier); + m_EntityEffects[a_EffectType] = cEntityEffect(EffectDuration, a_EffectIntensity, a_Creator, a_DistanceModifier); + m_World->BroadcastEntityEffect(*this, a_EffectType, a_EffectIntensity, EffectDuration); } @@ -140,7 +131,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect { // Base damage = 6, doubles for every increase in intensity int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); - TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0); + TakeDamage(dtPotionOfHarming, a_Effect.GetCreator(), damage, 0); return; } case cEntityEffect::effStrength: @@ -179,7 +170,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect // Cannot take poison damage when health is at 1 if (GetHealth() > 1) { - TakeDamage(dtPoisoning, a_Effect.GetUser(), 1, 0); + TakeDamage(dtPoisoning, a_Effect.GetCreator(), 1, 0); } } @@ -192,7 +183,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect if (a_Effect.m_Ticks % frequency == 0) { - TakeDamage(dtWither, a_Effect.GetUser(), 1, 0); + TakeDamage(dtWither, a_Effect.GetCreator(), 1, 0); } //TODO: " withered away> return; diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index c6be6f668..9f7771d79 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -30,17 +30,10 @@ public: @param a_EffectType The entity effect to apply @param a_EffectDurationTicks The duration of the effect @param a_EffectIntensity The level of the effect (0 = Potion I, 1 = Potion II, etc) - @param a_User The pawn that produced the effect (e.g. threw the potion) + @param a_Creator The pawn that produced the effect (e.g. threw the potion) @param a_DistanceModifier The scalar multiplied to the potion duration, only applies to splash potions) */ - void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier = 1); - - /** Applies an entity effect - Checks with plugins if they allow the addition. - @param a_EffectType The entity effect to apply - @param a_Effect The parameters of the effect - */ - void AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect); + void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_Creator, double a_DistanceModifier = 1); /** Removes a currently applied entity effect @param a_EffectType The entity effect to remove diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 714e4021d..2a1e9d981 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -79,7 +79,7 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity) } m_EntityEffect.SetDistanceModifier(Reduction); - ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect); + ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.m_Ticks, m_EntityEffect.GetIntensity(), m_EntityEffect.GetCreator(), Reduction); } return false; } diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 8a8c4f67a..4c59960f6 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -470,7 +470,7 @@ void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffe // Undead mobs are damaged by instant health // Base damage = 6, doubles for every increase in intensity int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); - TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0); + TakeDamage(dtPotionOfHarming, a_Effect.GetCreator(), damage, 0); return; } } -- cgit v1.2.3 From e0a9f37d909e9d82ccac88dae910ce21a7fdba6f Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 18 Jun 2014 12:13:01 +0200 Subject: (Force)ExecuteCommand returns the CommandResult enums Exported and documented the CommandResult enums --- src/Bindings/PluginManager.cpp | 8 ++++---- src/Bindings/PluginManager.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index c317ae362..2cd514211 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1553,18 +1553,18 @@ AString cPluginManager::GetCommandPermission(const AString & a_Command) -bool cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Command) +cPluginManager::CommandResult cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Command) { - return (HandleCommand(a_Player, a_Command, true) == crExecuted); + return HandleCommand(a_Player, a_Command, true); } -bool cPluginManager::ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command) +cPluginManager::CommandResult cPluginManager::ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command) { - return (HandleCommand(a_Player, a_Command, false) == crExecuted); + return HandleCommand(a_Player, a_Command, false); } diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 96b7a979b..e2bd9cd94 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -57,7 +57,8 @@ public: // tolua_export // Called each tick virtual void Tick(float a_Dt); - + + // tolua_begin enum CommandResult { crExecuted, @@ -67,7 +68,6 @@ public: // tolua_export crNoPermission, } ; - // tolua_begin enum PluginHook { HOOK_BLOCK_SPREAD, @@ -254,10 +254,10 @@ public: // tolua_export AString GetCommandPermission(const AString & a_Command); // tolua_export /** Executes the command, as if it was requested by a_Player. Checks permissions first. Returns true if executed. */ - bool ExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export + CommandResult ExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export /** Executes the command, as if it was requested by a_Player. Permisssions are not checked. Returns true if executed (false if not found) */ - bool ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export + CommandResult ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export /** Removes all console command bindings that the specified plugin has made */ void RemovePluginConsoleCommands(cPlugin * a_Plugin); -- cgit v1.2.3 From f5529e544cf8350daf8a20bb8d997f85ee2824f7 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 16 Jun 2014 20:22:17 -0700 Subject: EntityEffects.x -> EntityEffect.x, Object-Oriented effects Changed effect map to take a pointer of the effect as a result. --- src/Bindings/AllToLua.pkg | 2 +- src/CMakeLists.txt | 2 +- src/Entities/EntityEffect.cpp | 291 ++++++++++++++++++++++++ src/Entities/EntityEffect.h | 438 ++++++++++++++++++++++++++++++++++++ src/Entities/EntityEffects.cpp | 31 --- src/Entities/EntityEffects.h | 82 ------- src/Entities/Pawn.cpp | 119 +--------- src/Entities/Pawn.h | 10 +- src/Entities/Player.cpp | 37 --- src/Entities/Player.h | 3 - src/Entities/SplashPotionEntity.cpp | 2 +- src/Entities/SplashPotionEntity.h | 2 +- src/Items/ItemPotion.h | 2 +- src/Mobs/Monster.cpp | 45 ---- src/Mobs/Monster.h | 2 - 15 files changed, 748 insertions(+), 320 deletions(-) create mode 100644 src/Entities/EntityEffect.cpp create mode 100644 src/Entities/EntityEffect.h delete mode 100644 src/Entities/EntityEffects.cpp delete mode 100644 src/Entities/EntityEffects.h (limited to 'src') diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg index 4a6eb7535..1e5dfd2fe 100644 --- a/src/Bindings/AllToLua.pkg +++ b/src/Bindings/AllToLua.pkg @@ -40,7 +40,7 @@ $cfile "../Entities/Painting.h" $cfile "../Entities/Pickup.h" $cfile "../Entities/ProjectileEntity.h" $cfile "../Entities/TNTEntity.h" -$cfile "../Entities/EntityEffects.h" +$cfile "../Entities/EntityEffect.h" $cfile "../Server.h" $cfile "../World.h" $cfile "../Inventory.h" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3d5a0e396..678db3fb4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,7 +42,7 @@ set(BINDING_DEPENDECIES Cuboid.h Defines.h Enchantments.h - Entities/EntityEffects.h + Entities/EntityEffect.h Entities/Entity.h Entities/Floater.h Entities/Pawn.h diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp new file mode 100644 index 000000000..9881785cb --- /dev/null +++ b/src/Entities/EntityEffect.cpp @@ -0,0 +1,291 @@ +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "EntityEffect.h" +#include "../Mobs/Monster.h" +#include "Player.h" + + + + +cEntityEffect::cEntityEffect(): + m_Ticks(0), + m_Duration(0), + m_Intensity(0), + m_Creator(NULL), + m_DistanceModifier(1) +{ + +} + + + + + +cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_Creator, double a_DistanceModifier): + m_Ticks(0), + m_Duration(a_Duration), + m_Intensity(a_Intensity), + m_Creator(a_Creator), + m_DistanceModifier(a_DistanceModifier) +{ + +} + + + + + +cEntityEffect::~cEntityEffect() +{ + +} + + + + + +cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier) +{ + switch (a_EffectType) + { + case cEntityEffect::effNoEffect: return new cEntityEffect (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + + case cEntityEffect::effAbsorption: return new cEntityEffectAbsorption (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effBlindness: return new cEntityEffectBlindness (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effFireResistance: return new cEntityEffectFireResistance(a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effHaste: return new cEntityEffectHaste (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effHealthBoost: return new cEntityEffectHealthBoost (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effHunger: return new cEntityEffectHunger (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effInstantDamage: return new cEntityEffectInstantDamage (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effInstantHealth: return new cEntityEffectInstantHealth (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effInvisibility: return new cEntityEffectInvisibility (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effJumpBoost: return new cEntityEffectJumpBoost (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effMiningFatigue: return new cEntityEffectMiningFatigue (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effNausea: return new cEntityEffectNausea (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effNightVision: return new cEntityEffectNightVision (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effPoison: return new cEntityEffectPoison (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effRegeneration: return new cEntityEffectRegeneration (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effResistance: return new cEntityEffectResistance (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effSaturation: return new cEntityEffectSaturation (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effSlowness: return new cEntityEffectSlowness (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effSpeed: return new cEntityEffectSpeed (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effStrength: return new cEntityEffectStrength (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effWaterBreathing: return new cEntityEffectWaterBreathing(a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effWeakness: return new cEntityEffectWeakness (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effWither: return new cEntityEffectWither (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + } + + ASSERT(!"Unhandled entity effect type!"); +} + + + + + +void cEntityEffect::OnTick(cPawn & a_Target) +{ + // Reduce the effect's duration + ++m_Ticks; +} + + + + + +void cEntityEffect::OnActivate(cPawn & a_Target) +{ +} + + + + + +void cEntityEffect::OnDeactivate(cPawn & a_Target) +{ +} + + + + + +/************************************************************************ + **** Instant Health + ************************************************************************/ +void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target) +{ + // Base amount = 6, doubles for every increase in intensity + int amount = (int)(6 * std::pow(2.0, m_Intensity) * m_DistanceModifier); + + if (a_Target.IsMob()) + { + if (((cMonster &) a_Target).IsUndead()) + { + a_Target.TakeDamage(dtPotionOfHarming, m_Creator, amount, 0); + return; + } + } + a_Target.Heal(amount); +} + + + + + +/************************************************************************ + **** Instant Damage + ************************************************************************/ +void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target) +{ + // Base amount = 6, doubles for every increase in intensity + int amount = (int)(6 * std::pow(2.0, m_Intensity) * m_DistanceModifier); + + if (a_Target.IsMob()) + { + if (((cMonster &) a_Target).IsUndead()) + { + a_Target.Heal(amount); + return; + } + } + a_Target.TakeDamage(dtPotionOfHarming, m_Creator, amount, 0); +} + + + + + +/************************************************************************ + **** Regeneration + ************************************************************************/ +void cEntityEffectRegeneration::OnTick(cPawn & a_Target) +{ + super::OnTick(a_Target); + + if (a_Target.IsMob()) + { + if (((cMonster &) a_Target).IsUndead()) + { + return; + } + } + + // Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks) + int frequency = (int) std::floor(50.0 / (double)(m_Intensity + 1)); + + if (m_Ticks % frequency != 0) + { + return; + } + + a_Target.Heal(1); +} + + + + + +/************************************************************************ + **** Hunger + ************************************************************************/ +void cEntityEffectHunger::OnTick(cPawn & a_Target) +{ + super::OnTick(a_Target); + + if (a_Target.IsPlayer()) + { + cPlayer & Target = (cPlayer &) a_Target; + Target.SetFoodExhaustionLevel(Target.GetFoodExhaustionLevel() + 0.025); // 0.5 per second = 0.025 per tick + } +} + + + + + +/************************************************************************ + **** Weakness + ************************************************************************/ +void cEntityEffectWeakness::OnTick(cPawn & a_Target) +{ + super::OnTick(a_Target); + + // Damage reduction = 0.5 damage, multiplied by potion level (Weakness II = 1 damage) + // double dmg_reduc = 0.5 * (a_Effect.GetIntensity() + 1); + + // TODO: Implement me! + // TODO: Weakened villager zombies can be turned back to villagers with the god apple +} + + + + + +/************************************************************************ + **** Poison + ************************************************************************/ +void cEntityEffectPoison::OnTick(cPawn & a_Target) +{ + super::OnTick(a_Target); + + if (a_Target.IsMob()) + { + cMonster & Target = (cMonster &) a_Target; + + // Doesn't effect undead mobs, spiders + if (Target.IsUndead() + || Target.GetMobType() == cMonster::mtSpider + || Target.GetMobType() == cMonster::mtCaveSpider) + { + return; + } + } + + // Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks) + int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1)); + + if (m_Ticks % frequency == 0) + { + // Cannot take poison damage when health is at 1 + if (a_Target.GetHealth() > 1) + { + a_Target.TakeDamage(dtPoisoning, m_Creator, 1, 0); + } + } +} + + + + + +/************************************************************************ + **** Wither + ************************************************************************/ +void cEntityEffectWither::OnTick(cPawn & a_Target) +{ + super::OnTick(a_Target); + + // Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks) + int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1)); + + if (m_Ticks % frequency == 0) + { + a_Target.TakeDamage(dtWither, m_Creator, 1, 0); + } + //TODO: " withered away> +} + + + + + +/************************************************************************ + **** Saturation + ************************************************************************/ +void cEntityEffectSaturation::OnTick(cPawn & a_Target) +{ + if (a_Target.IsPlayer()) + { + cPlayer & Target = (cPlayer &) a_Target; + Target.SetFoodSaturationLevel(Target.GetFoodSaturationLevel() + (1 + m_Intensity)); // Increase saturation 1 per tick, adds 1 for every increase in level + } +} diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h new file mode 100644 index 000000000..ae7958e11 --- /dev/null +++ b/src/Entities/EntityEffect.h @@ -0,0 +1,438 @@ +#pragma once + +class cPawn; + +// tolua_begin +class cEntityEffect +{ +public: + + /** All types of entity effects (numbers correspond to IDs) */ + enum eType + { + effNoEffect = 0, + effSpeed = 1, + effSlowness = 2, + effHaste = 3, + effMiningFatigue = 4, + effStrength = 5, + effInstantHealth = 6, + effInstantDamage = 7, + effJumpBoost = 8, + effNausea = 9, + effRegeneration = 10, + effResistance = 11, + effFireResistance = 12, + effWaterBreathing = 13, + effInvisibility = 14, + effBlindness = 15, + effNightVision = 16, + effHunger = 17, + effWeakness = 18, + effPoison = 19, + effWither = 20, + effHealthBoost = 21, + effAbsorption = 22, + effSaturation = 23, + } ; + + /** Creates an empty entity effect */ + cEntityEffect(void); + + /** Creates an entity effect of the specified type + @param a_Duration How long this effect will last, in ticks + @param a_Intensity How strong the effect will be applied + @param a_Creator The pawn that produced this entity effect + @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ + cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1); + + virtual ~cEntityEffect(void); + + /** Creates a pointer to the proper entity effect from the effect type + @warning This function creates raw pointers that must be manually managed. + @param a_EffectType The effect type to create the effect from + @param a_Duration How long this effect will last, in ticks + @param a_Intensity How strong the effect will be applied + @param a_Creator The pawn that produced this entity effect + @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ + static cEntityEffect * CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier); + + /** Returns how many ticks this effect has been active for */ + int GetTicks() { return m_Ticks; } + /** Returns the duration of the effect */ + int GetDuration() { return m_Duration; } + /** Returns how strong the effect will be applied */ + short GetIntensity() { return m_Intensity; } + /** Returns the pawn that produced this entity effect */ + cPawn *GetCreator() { return m_Creator; } + /** Returns the distance modifier for affecting potency */ + double GetDistanceModifier() { return m_DistanceModifier; } + + void SetTicks(int a_Ticks) { m_Ticks = a_Ticks; } + void SetDuration(int a_Duration) { m_Duration = a_Duration; } + void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; } + void SetCreator(cPawn * a_Creator) { m_Creator = a_Creator; } + void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; } + + virtual void OnTick(cPawn & a_Target); + virtual void OnActivate(cPawn & a_Target); + virtual void OnDeactivate(cPawn & a_Target); + +protected: + /** How many ticks this effect has been active for */ + int m_Ticks; + + /** How long this effect will last, in ticks */ + int m_Duration; + + /** How strong the effect will be applied */ + short m_Intensity; + + /** The pawn that produced this entity effect (threw the potion, etc) */ + cPawn *m_Creator; + + /** The distance modifier for affecting potency */ + double m_DistanceModifier; +}; + +/************************************************************************ + **** Speed + ************************************************************************/ +class cEntityEffectSpeed: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectSpeed(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Slowness + ************************************************************************/ +class cEntityEffectSlowness: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectSlowness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Haste + ************************************************************************/ +class cEntityEffectHaste: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectHaste(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Mining Fatigue + ************************************************************************/ +class cEntityEffectMiningFatigue: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectMiningFatigue(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Strength + ************************************************************************/ +class cEntityEffectStrength: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectStrength(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Instant Health + ************************************************************************/ +class cEntityEffectInstantHealth: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectInstantHealth(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnActivate(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Instant Damage + ************************************************************************/ +class cEntityEffectInstantDamage: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectInstantDamage(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnActivate(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Jump Boost + ************************************************************************/ +class cEntityEffectJumpBoost: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectJumpBoost(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Nausea + ************************************************************************/ +class cEntityEffectNausea: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectNausea(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Regeneration + ************************************************************************/ +class cEntityEffectRegeneration: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectRegeneration(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnTick(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Resistance + ************************************************************************/ +class cEntityEffectResistance: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectResistance(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Fire Resistance + ************************************************************************/ +class cEntityEffectFireResistance: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectFireResistance(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Water Breathing + ************************************************************************/ +class cEntityEffectWaterBreathing: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectWaterBreathing(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Invisibility + ************************************************************************/ +class cEntityEffectInvisibility: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectInvisibility(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Blindness + ************************************************************************/ +class cEntityEffectBlindness: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectBlindness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Night Vision + ************************************************************************/ +class cEntityEffectNightVision: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectNightVision(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Hunger + ************************************************************************/ +class cEntityEffectHunger: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectHunger(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnTick(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Weakness + ************************************************************************/ +class cEntityEffectWeakness: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectWeakness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnTick(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Poison + ************************************************************************/ +class cEntityEffectPoison: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectPoison(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnTick(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Wither + ************************************************************************/ +class cEntityEffectWither: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectWither(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnTick(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Health Boost + ************************************************************************/ +class cEntityEffectHealthBoost: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectHealthBoost(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Absorption + ************************************************************************/ +class cEntityEffectAbsorption: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectAbsorption(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Saturation + ************************************************************************/ +class cEntityEffectSaturation: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectSaturation(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnTick(cPawn & a_Target) override; +}; + + + +// tolua_end diff --git a/src/Entities/EntityEffects.cpp b/src/Entities/EntityEffects.cpp deleted file mode 100644 index a9edeee25..000000000 --- a/src/Entities/EntityEffects.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "EntityEffects.h" -#include "Pawn.h" - - - - -cEntityEffect::cEntityEffect(): - m_Ticks(0), - m_Duration(0), - m_Intensity(0), - m_Creator(NULL), - m_DistanceModifier(1) -{ - -} - - - - - -cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_Creator, double a_DistanceModifier): - m_Ticks(0), - m_Duration(a_Duration), - m_Intensity(a_Intensity), - m_Creator(a_Creator), - m_DistanceModifier(a_DistanceModifier) -{ - -} diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h deleted file mode 100644 index 9de3fcb86..000000000 --- a/src/Entities/EntityEffects.h +++ /dev/null @@ -1,82 +0,0 @@ -#pragma once - -class cPawn; - -// tolua_begin -class cEntityEffect -{ -public: - - /** All types of entity effects (numbers correspond to IDs) */ - enum eType - { - effNoEffect = 0, - effSpeed = 1, - effSlowness = 2, - effHaste = 3, - effMiningFatigue = 4, - effStrength = 5, - effInstantHealth = 6, - effInstantDamage = 7, - effJumpBoost = 8, - effNausea = 9, - effRegeneration = 10, - effResistance = 11, - effFireResistance = 12, - effWaterBreathing = 13, - effInvisibility = 14, - effBlindness = 15, - effNightVision = 16, - effHunger = 17, - effWeakness = 18, - effPoison = 19, - effWither = 20, - effHealthBoost = 21, - effAbsorption = 22, - effSaturation = 23, - } ; - - /** How many ticks this effect has been active for */ - int m_Ticks; - - /** Returns the duration of the effect */ - int GetDuration() { return m_Duration; } - - /** Returns how strong the effect will be applied */ - short GetIntensity() { return m_Intensity; } - - /** Returns the pawn that produced this entity effect */ - cPawn *GetCreator() { return m_Creator; } - - /** Returns the distance modifier for affecting potency */ - double GetDistanceModifier() { return m_DistanceModifier; } - - void SetDuration(int a_Duration) { m_Duration = a_Duration; } - void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; } - void SetCreator(cPawn * a_Creator) { m_Creator = a_Creator; } - void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; } - - /** Creates an empty entity effect */ - cEntityEffect(void); - - /** Creates an entity effect of the specified type - @param a_Duration How long this effect will last, in ticks - @param a_Intensity How strong the effect will be applied - @param a_Creator The pawn that produced this entity effect - @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ - cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1); - -private: - /** How long this effect will last, in ticks */ - int m_Duration; - - /** How strong the effect will be applied */ - short m_Intensity; - - /** The pawn that produced this entity effect (threw the potion, etc) */ - cPawn *m_Creator; - - /** The distance modifier for affecting potency */ - double m_DistanceModifier; -}; -// tolua_end diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 6c70fd2a6..62f71e20f 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -26,19 +26,15 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk) { // Copies values to prevent pesky wrong accesses and erasures cEntityEffect::eType EffectType = iter->first; - cEntityEffect & EffectValues = iter->second; + cEntityEffect * Effect = iter->second; - // Apply entity effect - HandleEntityEffect(EffectType, EffectValues); - - // Reduce the effect's duration - EffectValues.m_Ticks++; + Effect->OnTick(*this); // Iterates (must be called before any possible erasure) ++iter; // Remove effect if duration has elapsed - if (EffectValues.GetDuration() - EffectValues.m_Ticks <= 0) + if (Effect->GetDuration() - Effect->GetTicks() <= 0) { RemoveEntityEffect(EffectType); } @@ -62,10 +58,10 @@ void cPawn::KilledBy(cEntity * a_Killer) -void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_Creator, double a_DistanceModifier) +void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier) { // Check if the plugins allow the addition: - if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Creator, a_DistanceModifier)) + if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_Duration, a_Intensity, a_Creator, a_DistanceModifier)) { // A plugin disallows the addition, bail out. return; @@ -76,10 +72,11 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurat { return; } + a_Duration = (int)(a_Duration * a_DistanceModifier); - int EffectDuration = (int)(a_EffectDurationTicks * a_DistanceModifier); - m_EntityEffects[a_EffectType] = cEntityEffect(EffectDuration, a_EffectIntensity, a_Creator, a_DistanceModifier); - m_World->BroadcastEntityEffect(*this, a_EffectType, a_EffectIntensity, EffectDuration); + m_EntityEffects[a_EffectType] = cEntityEffect::CreateEntityEffect(a_EffectType, a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + m_World->BroadcastEntityEffect(*this, a_EffectType, a_Intensity, a_Duration); + m_EntityEffects[a_EffectType]->OnActivate(*this); } @@ -88,8 +85,10 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurat void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType) { - m_EntityEffects.erase(a_EffectType); m_World->BroadcastRemoveEntityEffect(*this, a_EffectType); + m_EntityEffects[a_EffectType]->OnDeactivate(*this); + delete m_EntityEffects[a_EffectType]; + m_EntityEffects.erase(a_EffectType); } @@ -111,97 +110,3 @@ void cPawn::ClearEntityEffects() RemoveEntityEffect(EffectType); } } - - - - - -void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) -{ - switch (a_EffectType) - { - // Default effect behaviors - case cEntityEffect::effInstantHealth: - { - // Base heal = 6, doubles for every increase in intensity - Heal((int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier())); - return; - } - case cEntityEffect::effInstantDamage: - { - // Base damage = 6, doubles for every increase in intensity - int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); - TakeDamage(dtPotionOfHarming, a_Effect.GetCreator(), damage, 0); - return; - } - case cEntityEffect::effStrength: - { - // TODO: Implement me! - return; - } - case cEntityEffect::effWeakness: - { - // Damage reduction = 0.5 damage, multiplied by potion level (Weakness II = 1 damage) - // double dmg_reduc = 0.5 * (a_Effect.GetIntensity() + 1); - - // TODO: Implement me! - // TODO: Weakened villager zombies can be turned back to villagers with the god apple - return; - } - case cEntityEffect::effRegeneration: - { - // Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks) - int frequency = std::floor(50.0 / (double)(a_Effect.GetIntensity() + 1)); - - if (a_Effect.m_Ticks % frequency == 0) - { - Heal(1); - } - - return; - } - case cEntityEffect::effPoison: - { - // Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks) - int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1)); - - if (a_Effect.m_Ticks % frequency == 0) - { - // Cannot take poison damage when health is at 1 - if (GetHealth() > 1) - { - TakeDamage(dtPoisoning, a_Effect.GetCreator(), 1, 0); - } - } - - return; - } - case cEntityEffect::effWither: - { - // Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks) - int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1)); - - if (a_Effect.m_Ticks % frequency == 0) - { - TakeDamage(dtWither, a_Effect.GetCreator(), 1, 0); - } - //TODO: " withered away> - return; - } - case cEntityEffect::effFireResistance: - { - // TODO: Implement me! - return; - } - case cEntityEffect::effSpeed: - { - // TODO: Implement me! - return; - } - case cEntityEffect::effSlowness: - { - // TODO: Implement me! - return; - } - } -} diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index 9f7771d79..307e5db3d 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -2,7 +2,7 @@ #pragma once #include "Entity.h" -#include "EntityEffects.h" +#include "EntityEffect.h" @@ -46,14 +46,8 @@ public: // tolua_end protected: - typedef std::map tEffectMap; + typedef std::map tEffectMap; tEffectMap m_EntityEffects; - - /** Applies entity effect effects - * @param a_EffectType The selected entity effect - * @param a_Effect The parameters of the selected entity effect - */ - virtual void HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect); } ; // tolua_export diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index b7a315a40..77ab6d309 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1867,43 +1867,6 @@ void cPlayer::TickBurning(cChunk & a_Chunk) -void cPlayer::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) -{ - switch (a_EffectType) - { - // Effects whose behaviors are overridden - case cEntityEffect::effMiningFatigue: - { - // TODO: Implement me! - return; - } - case cEntityEffect::effHunger: - { - m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick - return; - } - case cEntityEffect::effSaturation: - { - // Increase saturation 1 per tick, adds 1 for every increase in level - m_FoodSaturationLevel += (1 + a_Effect.GetIntensity()); - return; - } - - // Client-side-only effects - case cEntityEffect::effNausea: - case cEntityEffect::effNightVision: - { - return; - } - } - - super::HandleEntityEffect(a_EffectType, a_Effect); -} - - - - - void cPlayer::HandleFood(void) { // Ref.: http://www.minecraftwiki.net/wiki/Hunger diff --git a/src/Entities/Player.h b/src/Entities/Player.h index a793d3c30..e80b82901 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -521,9 +521,6 @@ protected: /** Stops players from burning in creative mode */ virtual void TickBurning(cChunk & a_Chunk) override; - /** Called each tick to handle entity effects*/ - virtual void HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override; - /** Called in each tick to handle food-related processing */ void HandleFood(void); diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 2a1e9d981..3d2ef279f 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -79,7 +79,7 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity) } m_EntityEffect.SetDistanceModifier(Reduction); - ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.m_Ticks, m_EntityEffect.GetIntensity(), m_EntityEffect.GetCreator(), Reduction); + ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), m_EntityEffect.GetCreator(), Reduction); } return false; } diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 0f84e6387..548ba3a3e 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -5,7 +5,7 @@ #pragma once #include "ProjectileEntity.h" -#include "EntityEffects.h" +#include "EntityEffect.h" #include "../World.h" #include "Entity.h" diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index 853ed53a8..43b9f280d 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -1,7 +1,7 @@ #pragma once -#include "../Entities/EntityEffects.h" +#include "../Entities/EntityEffect.h" #include "../Entities/SplashPotionEntity.h" class cItemPotionHandler: diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 4c59960f6..a51315ecf 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -436,51 +436,6 @@ void cMonster::HandleFalling() -void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) -{ - switch (a_EffectType) - { - case cEntityEffect::effPoison: - { - // Default effect for non-undead mobs and non-spiders - if (!IsUndead() && GetMobType() != mtSpider) break; - return; // No effect - } - case cEntityEffect::effRegeneration: - { - // Default effect for non-undead mobs - if (!IsUndead() && GetMobType()) break; - return; // No effect - } - case cEntityEffect::effInstantDamage: - { - // Default effect for non-undead mobs - if (!IsUndead() && GetMobType()) break; - - // Undead mobs are healed by instant damage - // Base heal = 6, doubles for every increase in intensity - Heal((int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier())); - return; - } - case cEntityEffect::effInstantHealth: - { - // Default effect for non-undead mobs - if (!IsUndead() && GetMobType()) break; - - // Undead mobs are damaged by instant health - // Base damage = 6, doubles for every increase in intensity - int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); - TakeDamage(dtPotionOfHarming, a_Effect.GetCreator(), damage, 0); - return; - } - } - - super::HandleEntityEffect(a_EffectType, a_Effect); -} - - - - int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ) { int PosY = POSY_TOINT; diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index ca6cb0593..638d5be39 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -224,8 +224,6 @@ protected: int m_LastGroundHeight; /* =========================== */ - - virtual void HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override; float m_IdleInterval; float m_DestroyTimer; -- cgit v1.2.3 From e8143de01bff31f9e153949d7ab5b0df82629541 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 19 Jun 2014 01:49:56 -0700 Subject: Nullify deleted pointers. --- src/Bindings/ManualBindings.cpp | 1 + src/Bindings/PluginLua.cpp | 1 + src/Bindings/PluginManager.cpp | 1 + src/BlockArea.cpp | 28 +++++++++++++++++----------- src/BlockInfo.cpp | 1 + src/ByteBuffer.cpp | 1 + src/Chunk.cpp | 4 ++++ src/CraftingRecipes.cpp | 1 + src/Entities/Player.cpp | 1 + src/FurnaceRecipe.cpp | 4 ++++ src/Generating/BioGen.cpp | 2 ++ src/Generating/CompoGen.cpp | 2 ++ src/Generating/HeiGen.cpp | 2 ++ src/GroupManager.cpp | 2 ++ src/HTTPServer/HTTPConnection.cpp | 1 + src/ItemGrid.cpp | 1 + src/Items/ItemBow.h | 1 + src/Items/ItemHandler.cpp | 1 + src/Items/ItemItemFrame.h | 1 + src/MCLogger.cpp | 1 + src/Mobs/Blaze.cpp | 1 + src/Mobs/Ghast.cpp | 1 + src/Mobs/Skeleton.cpp | 1 + src/MonsterConfig.cpp | 1 + src/Noise.cpp | 4 ++++ src/OSSupport/Event.cpp | 1 + src/OSSupport/SocketThreads.cpp | 1 + src/OSSupport/Thread.cpp | 2 ++ src/Protocol/ProtocolRecognizer.cpp | 1 + src/Server.cpp | 1 + src/Simulator/FluidSimulator.cpp | 4 +++- src/WebAdmin.cpp | 1 + src/World.cpp | 15 +++++++++------ src/World.h | 1 + src/WorldStorage/WSSCompact.cpp | 1 + 35 files changed, 75 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index acfd6f4f8..f52d970bf 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -1765,6 +1765,7 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S) if (!ChunkStay->AddChunks(2)) { delete ChunkStay; + ChunkStay = NULL; return 0; } diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 04639da60..96c5ccde7 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -1571,6 +1571,7 @@ bool cPluginLua::AddHookRef(int a_HookType, int a_FnRefIdx) LOGWARNING("Plugin %s tried to add a hook %d with bad handler function.", GetName().c_str(), a_HookType); m_LuaState.LogStackTrace(); delete Ref; + Ref = NULL; return false; } diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 9bcd8e3b7..c50100d6f 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1467,6 +1467,7 @@ void cPluginManager::RemovePlugin(cPlugin * a_Plugin) a_Plugin->OnDisable(); } delete a_Plugin; + a_Plugin = NULL; } diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 4fe6cd51e..185582ba3 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -295,9 +295,9 @@ cBlockArea::~cBlockArea() void cBlockArea::Clear(void) { - delete[] m_BlockTypes; m_BlockTypes = NULL; - delete[] m_BlockMetas; m_BlockMetas = NULL; - delete[] m_BlockLight; m_BlockLight = NULL; + delete[] m_BlockTypes; m_BlockTypes = NULL; + delete[] m_BlockMetas; m_BlockMetas = NULL; + delete[] m_BlockLight; m_BlockLight = NULL; delete[] m_BlockSkyLight; m_BlockSkyLight = NULL; m_Origin.Set(0, 0, 0); m_Size.Set(0, 0, 0); @@ -1013,8 +1013,8 @@ void cBlockArea::RotateCCW(void) } // for x std::swap(m_BlockTypes, NewTypes); std::swap(m_BlockMetas, NewMetas); - delete[] NewTypes; - delete[] NewMetas; + delete[] NewTypes; NewTypes = NULL; + delete[] NewMetas; NewMetas = NULL; std::swap(m_Size.x, m_Size.z); } @@ -1058,8 +1058,8 @@ void cBlockArea::RotateCW(void) } // for x std::swap(m_BlockTypes, NewTypes); std::swap(m_BlockMetas, NewMetas); - delete[] NewTypes; - delete[] NewMetas; + delete[] NewTypes; NewTypes = NULL; + delete[] NewMetas; NewMetas = NULL; std::swap(m_Size.x, m_Size.z); } @@ -1206,7 +1206,7 @@ void cBlockArea::RotateCCWNoMeta(void) } // for z } // for x std::swap(m_BlockTypes, NewTypes); - delete[] NewTypes; + delete[] NewTypes; NewTypes = NULL; } if (HasBlockMetas()) { @@ -1224,7 +1224,7 @@ void cBlockArea::RotateCCWNoMeta(void) } // for z } // for x std::swap(m_BlockMetas, NewMetas); - delete[] NewMetas; + delete[] NewMetas; NewMetas = NULL; } std::swap(m_Size.x, m_Size.z); } @@ -1251,7 +1251,7 @@ void cBlockArea::RotateCWNoMeta(void) } // for x } // for z std::swap(m_BlockTypes, NewTypes); - delete[] NewTypes; + delete[] NewTypes; NewTypes = NULL; } if (HasBlockMetas()) { @@ -1269,7 +1269,7 @@ void cBlockArea::RotateCWNoMeta(void) } // for x } // for z std::swap(m_BlockMetas, NewMetas); - delete[] NewMetas; + delete[] NewMetas; NewMetas = NULL; } std::swap(m_Size.x, m_Size.z); } @@ -1658,6 +1658,7 @@ bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes) if (m_BlockMetas == NULL) { delete[] m_BlockTypes; + m_BlockTypes = NULL; return false; } } @@ -1667,7 +1668,9 @@ bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes) if (m_BlockLight == NULL) { delete[] m_BlockMetas; + m_BlockMetas = NULL; delete[] m_BlockTypes; + m_BlockTypes = NULL; return false; } } @@ -1677,8 +1680,11 @@ bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes) if (m_BlockSkyLight == NULL) { delete[] m_BlockLight; + m_BlockLight = NULL; delete[] m_BlockMetas; + m_BlockMetas = NULL; delete[] m_BlockTypes; + m_BlockTypes = NULL; return false; } } diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 564b3fcca..32fdec905 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -34,6 +34,7 @@ cBlockInfo::cBlockInfo() cBlockInfo::~cBlockInfo() { delete m_Handler; + m_Handler = NULL; } diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index d77f402fd..1a69c856f 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -165,6 +165,7 @@ cByteBuffer::~cByteBuffer() { CheckValid(); delete[] m_Buffer; + m_Buffer = NULL; } diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 4703e4536..6ab49036d 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -152,7 +152,9 @@ cChunk::~cChunk() m_NeighborZP->m_NeighborZM = NULL; } delete m_WaterSimulatorData; + m_WaterSimulatorData = NULL; delete m_LavaSimulatorData; + m_LavaSimulatorData = NULL; } @@ -596,6 +598,7 @@ void cChunk::Tick(float a_Dt) cEntity * ToDelete = *itr; itr = m_Entities.erase(itr); delete ToDelete; + ToDelete = NULL; continue; } ++itr; @@ -1417,6 +1420,7 @@ void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BlockEntity->Destroy(); RemoveBlockEntity(BlockEntity); delete BlockEntity; + BlockEntity = NULL; } // If the new block is a block entity, create the entity object: diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index 53a638ee5..0f1951351 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -59,6 +59,7 @@ cCraftingGrid::cCraftingGrid(const cCraftingGrid & a_Original) : cCraftingGrid::~cCraftingGrid() { delete[] m_Items; + m_Items = NULL; } diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index fdc0bb390..e1e03fded 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -146,6 +146,7 @@ cPlayer::~cPlayer(void) m_ClientHandle = NULL; delete m_InventoryWindow; + m_InventoryWindow = NULL; LOGD("Player %p deleted", this); } diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index bd7fd8079..2cb204ccf 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -42,6 +42,7 @@ cFurnaceRecipe::~cFurnaceRecipe() { ClearRecipes(); delete m_pState; + m_pState = NULL; } @@ -187,7 +188,9 @@ void cFurnaceRecipe::ClearRecipes(void) { Recipe R = *itr; delete R.In; + R.In = NULL; delete R.Out; + R.Out = NULL; } m_pState->Recipes.clear(); @@ -195,6 +198,7 @@ void cFurnaceRecipe::ClearRecipes(void) { Fuel F = *itr; delete F.In; + F.In = NULL; } m_pState->Fuel.clear(); } diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index 47ba080c6..3e3a034b2 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -135,7 +135,9 @@ cBioGenCache::cBioGenCache(cBiomeGen * a_BioGenToCache, int a_CacheSize) : cBioGenCache::~cBioGenCache() { delete[] m_CacheData; + m_CacheData = NULL; delete[] m_CacheOrder; + m_CacheOrder = NULL; } diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 688d19c40..2da285d72 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -672,7 +672,9 @@ cCompoGenCache::cCompoGenCache(cTerrainCompositionGen & a_Underlying, int a_Cach cCompoGenCache::~cCompoGenCache() { delete[] m_CacheData; + m_CacheData = NULL; delete[] m_CacheOrder; + m_CacheOrder = NULL; } diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index 25ac912fd..202f7db7e 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -142,7 +142,9 @@ cHeiGenCache::cHeiGenCache(cTerrainHeightGen & a_HeiGenToCache, int a_CacheSize) cHeiGenCache::~cHeiGenCache() { delete[] m_CacheData; + m_CacheData = NULL; delete[] m_CacheOrder; + m_CacheOrder = NULL; } diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index e570bb2b1..11e62c223 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -30,10 +30,12 @@ cGroupManager::~cGroupManager() for( GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr ) { delete itr->second; + itr->second = NULL; } m_pState->Groups.clear(); delete m_pState; + m_pState = NULL; } diff --git a/src/HTTPServer/HTTPConnection.cpp b/src/HTTPServer/HTTPConnection.cpp index b127e7091..21ff14373 100644 --- a/src/HTTPServer/HTTPConnection.cpp +++ b/src/HTTPServer/HTTPConnection.cpp @@ -28,6 +28,7 @@ cHTTPConnection::~cHTTPConnection() { // LOGD("HTTP: Connection deleting: %p", this); delete m_CurrentRequest; + m_CurrentRequest = NULL; } diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp index 34a267bab..cd36b1f2a 100644 --- a/src/ItemGrid.cpp +++ b/src/ItemGrid.cpp @@ -28,6 +28,7 @@ cItemGrid::cItemGrid(int a_Width, int a_Height) : cItemGrid::~cItemGrid() { delete[] m_Slots; + m_Slots = NULL; } diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index e0ab339d3..821e2ab26 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -69,6 +69,7 @@ public: if (!Arrow->Initialize(*a_Player->GetWorld())) { delete Arrow; + Arrow = NULL; return; } a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow); diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index d97f986ba..f639423ae 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -260,6 +260,7 @@ void cItemHandler::Deinit() for(int i = 0; i < 2267; i++) { delete m_ItemHandler[i]; + m_ItemHandler[i] = NULL; } memset(m_ItemHandler, 0, sizeof(m_ItemHandler)); // Don't leave any dangling pointers around, just in case m_HandlerInitialized = false; diff --git a/src/Items/ItemItemFrame.h b/src/Items/ItemItemFrame.h index 097f04d0b..b258b4aea 100644 --- a/src/Items/ItemItemFrame.h +++ b/src/Items/ItemItemFrame.h @@ -37,6 +37,7 @@ public: if (!ItemFrame->Initialize(*a_World)) { delete ItemFrame; + ItemFrame = NULL; return false; } diff --git a/src/MCLogger.cpp b/src/MCLogger.cpp index 583438d65..ad2029589 100644 --- a/src/MCLogger.cpp +++ b/src/MCLogger.cpp @@ -57,6 +57,7 @@ cMCLogger::~cMCLogger() { m_Log->Log("--- Stopped Log ---\n"); delete m_Log; + m_Log = NULL; if (this == s_MCLogger) { s_MCLogger = NULL; diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp index 19bdf8737..b4104d530 100644 --- a/src/Mobs/Blaze.cpp +++ b/src/Mobs/Blaze.cpp @@ -47,6 +47,7 @@ void cBlaze::Attack(float a_Dt) if (!FireCharge->Initialize(*m_World)) { delete FireCharge; + FireCharge = NULL; return; } m_World->BroadcastSpawnEntity(*FireCharge); diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp index 4df8e165c..6aac14779 100644 --- a/src/Mobs/Ghast.cpp +++ b/src/Mobs/Ghast.cpp @@ -49,6 +49,7 @@ void cGhast::Attack(float a_Dt) if (!GhastBall->Initialize(*m_World)) { delete GhastBall; + GhastBall = NULL; return; } m_World->BroadcastSpawnEntity(*GhastBall); diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index e7f3971cc..e3357185d 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -84,6 +84,7 @@ void cSkeleton::Attack(float a_Dt) if (!Arrow->Initialize(*m_World)) { delete Arrow; + Arrow = NULL; return; } m_World->BroadcastSpawnEntity(*Arrow); diff --git a/src/MonsterConfig.cpp b/src/MonsterConfig.cpp index 72a3a3245..f5e746ce8 100644 --- a/src/MonsterConfig.cpp +++ b/src/MonsterConfig.cpp @@ -47,6 +47,7 @@ cMonsterConfig::cMonsterConfig(void) cMonsterConfig::~cMonsterConfig() { delete m_pState; + m_pState = NULL; } diff --git a/src/Noise.cpp b/src/Noise.cpp index 040421106..fbd2a1800 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -877,6 +877,7 @@ void cPerlinNoise::Generate2D( if (ShouldFreeWorkspace) { delete[] a_Workspace; + a_Workspace = NULL; } } @@ -943,6 +944,7 @@ void cPerlinNoise::Generate3D( if (ShouldFreeWorkspace) { delete[] a_Workspace; + a_Workspace = NULL; } } @@ -1045,6 +1047,7 @@ void cRidgedMultiNoise::Generate2D( if (ShouldFreeWorkspace) { delete[] a_Workspace; + a_Workspace = NULL; } } @@ -1111,6 +1114,7 @@ void cRidgedMultiNoise::Generate3D( if (ShouldFreeWorkspace) { delete[] a_Workspace; + a_Workspace = NULL; } } diff --git a/src/OSSupport/Event.cpp b/src/OSSupport/Event.cpp index 649a0a3cf..6b8fccde2 100644 --- a/src/OSSupport/Event.cpp +++ b/src/OSSupport/Event.cpp @@ -71,6 +71,7 @@ cEvent::~cEvent() { sem_destroy(m_Event); delete m_Event; + m_Event = NULL; } #endif } diff --git a/src/OSSupport/SocketThreads.cpp b/src/OSSupport/SocketThreads.cpp index 0ab5b6298..ca8b8438d 100644 --- a/src/OSSupport/SocketThreads.cpp +++ b/src/OSSupport/SocketThreads.cpp @@ -61,6 +61,7 @@ bool cSocketThreads::AddClient(const cSocket & a_Socket, cCallback * a_Client) // There was an error launching the thread (but it was already logged along with the reason) LOGERROR("A new cSocketThread failed to start"); delete Thread; + Thread = NULL; return false; } Thread->AddClient(a_Socket, a_Client); diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp index 7a10ef8d2..535784613 100644 --- a/src/OSSupport/Thread.cpp +++ b/src/OSSupport/Thread.cpp @@ -66,11 +66,13 @@ cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_Thre cThread::~cThread() { delete m_Event; + m_Event = NULL; if( m_StopEvent ) { m_StopEvent->Wait(); delete m_StopEvent; + m_StopEvent = NULL; } } diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 35a331f43..80f5da25a 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -37,6 +37,7 @@ cProtocolRecognizer::cProtocolRecognizer(cClientHandle * a_Client) : cProtocolRecognizer::~cProtocolRecognizer() { delete m_Protocol; + m_Protocol = NULL; } diff --git a/src/Server.cpp b/src/Server.cpp index 66bccd680..2c695cc70 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -326,6 +326,7 @@ void cServer::OnConnectionAccepted(cSocket & a_Socket) LOGERROR("Client \"%s\" cannot be handled, server probably unstable", ClientIP.c_str()); a_Socket.CloseSocket(); delete NewHandle; + NewHandle = NULL; return; } diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp index 4a84084d2..f64955cb2 100644 --- a/src/Simulator/FluidSimulator.cpp +++ b/src/Simulator/FluidSimulator.cpp @@ -169,7 +169,8 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a X = Pos->x; Z = Pos->z; } - }else if(BlockID == E_BLOCK_AIR) + } + else if(BlockID == E_BLOCK_AIR) { LowestPoint = 9; //This always dominates X = Pos->x; @@ -177,6 +178,7 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a } delete Pos; + Pos = NULL; } if (LowestPoint == m_World.GetBlockMeta(a_X, a_Y, a_Z)) diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index 08e164d78..d80849433 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -524,6 +524,7 @@ void cWebAdmin::OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & // Delete any request data assigned to the request: cRequestData * Data = (cRequestData *)(a_Request.GetUserData()); delete Data; + Data = NULL; } diff --git a/src/World.cpp b/src/World.cpp index 6bcd1391a..5b067b386 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -267,12 +267,12 @@ cWorld::cWorld(const AString & a_WorldName) : cWorld::~cWorld() { - delete m_SimulatorManager; - delete m_SandSimulator; - delete m_WaterSimulator; - delete m_LavaSimulator; - delete m_FireSimulator; - delete m_RedstoneSimulator; + delete m_SimulatorManager; m_SimulatorManager = NULL; + delete m_SandSimulator; m_SandSimulator = NULL; + delete m_WaterSimulator; m_WaterSimulator = NULL; + delete m_LavaSimulator; m_LavaSimulator = NULL; + delete m_FireSimulator; m_FireSimulator = NULL; + delete m_RedstoneSimulator; m_RedstoneSimulator = NULL; UnloadUnusedChunks(); @@ -2972,11 +2972,13 @@ int cWorld::SpawnMobFinalize(cMonster * a_Monster) if (cPluginManager::Get()->CallHookSpawningMonster(*this, *a_Monster)) { delete a_Monster; + a_Monster = NULL; return -1; } if (!a_Monster->Initialize(*this)) { delete a_Monster; + a_Monster = NULL; return -1; } BroadcastSpawnEntity(*a_Monster); @@ -2999,6 +3001,7 @@ int cWorld::CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProje if (!Projectile->Initialize(*this)) { delete Projectile; + Projectile = NULL; return -1; } return Projectile->GetUniqueID(); diff --git a/src/World.h b/src/World.h index f638b4b22..2b7f78760 100644 --- a/src/World.h +++ b/src/World.h @@ -830,6 +830,7 @@ private: virtual ~cScheduledTask() { delete m_Task; + m_Task = NULL; } }; diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index 7a113849a..a853f6ec9 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -473,6 +473,7 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ { LOGERROR("ERROR READING %s FROM FILE %s (line %d); file offset %d", "Header", m_FileName.c_str(), __LINE__, f.Tell()); delete Header; + Header = NULL; return; } m_ChunkHeaders.push_back(Header); -- cgit v1.2.3 From 3e15c92d18c344c95bd805d7795db990258eed5a Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Fri, 20 Jun 2014 10:50:21 +0200 Subject: Added pig riding. Now you can ride a pig using a carrot on a stick. --- src/Mobs/Pig.cpp | 13 +++++++++++++ src/Mobs/Pig.h | 1 + 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp index e862f5aaa..ddd98eb94 100644 --- a/src/Mobs/Pig.cpp +++ b/src/Mobs/Pig.cpp @@ -76,5 +76,18 @@ void cPig::OnRightClicked(cPlayer & a_Player) } } +void cPig::Tick(float a_Dt, cChunk & a_Chunk) +{ + super::Tick(a_Dt, a_Chunk); + + if (m_bIsSaddled && m_Attachee != NULL) + { + if (m_Attachee->IsPlayer() && m_Attachee->GetEquippedWeapon().m_ItemType == E_ITEM_CARROT_ON_STICK) + { + MoveToPosition((m_Attachee->GetPosition()) + (m_Attachee->GetLookVector()*10)); + m_bMovingToDestination = true; + } + } +} diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h index d434324c1..313af2f44 100644 --- a/src/Mobs/Pig.h +++ b/src/Mobs/Pig.h @@ -19,6 +19,7 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; + virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); } -- cgit v1.2.3 From 9db9445e9fec2ce0ab52434e50cc21f30d4ef313 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 20 Jun 2014 17:10:18 +0200 Subject: Optimized Voronoi calculation. Fixes #818. --- src/Generating/BioGen.cpp | 21 ++++++++++++-------- src/Generating/BioGen.h | 7 ++++++- src/VoronoiMap.cpp | 49 ++++++++++++++++++++++++++++++++++++++--------- src/VoronoiMap.h | 25 +++++++++++++++++++++--- 4 files changed, 81 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index 3e3a034b2..a17555f37 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -747,7 +747,12 @@ cBioGenTwoLevel::cBioGenTwoLevel(int a_Seed) : m_VoronoiSmall(a_Seed + 2000), m_DistortX(a_Seed + 3000), m_DistortZ(a_Seed + 4000), - m_Noise(a_Seed + 5000) + m_Noise1(a_Seed + 5001), + m_Noise2(a_Seed + 5002), + m_Noise3(a_Seed + 5003), + m_Noise4(a_Seed + 5004), + m_Noise5(a_Seed + 5005), + m_Noise6(a_Seed + 5006) { } @@ -769,12 +774,12 @@ void cBioGenTwoLevel::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap int BlockZ = BaseZ + z * 4; float BlockXF = (float)(16 * BlockX) / 128; float BlockZF = (float)(16 * BlockZ) / 128; - double NoiseX = m_Noise.CubicNoise3D(BlockXF / 16, BlockZF / 16, 1000); - NoiseX += 0.5 * m_Noise.CubicNoise3D(BlockXF / 8, BlockZF / 8, 2000); - NoiseX += 0.08 * m_Noise.CubicNoise3D(BlockXF, BlockZF, 3000); - double NoiseZ = m_Noise.CubicNoise3D(BlockXF / 16, BlockZF / 16, 4000); - NoiseZ += 0.5 * m_Noise.CubicNoise3D(BlockXF / 8, BlockZF / 8, 5000); - NoiseZ += 0.08 * m_Noise.CubicNoise3D(BlockXF, BlockZF, 6000); + double NoiseX = m_Noise1.CubicNoise2D(BlockXF / 16, BlockZF / 16); + NoiseX += 0.5 * m_Noise2.CubicNoise2D(BlockXF / 8, BlockZF / 8); + NoiseX += 0.08 * m_Noise3.CubicNoise2D(BlockXF, BlockZF); + double NoiseZ = m_Noise4.CubicNoise2D(BlockXF / 16, BlockZF / 16); + NoiseZ += 0.5 * m_Noise5.CubicNoise2D(BlockXF / 8, BlockZF / 8); + NoiseZ += 0.08 * m_Noise6.CubicNoise2D(BlockXF, BlockZF); DistortX[4 * x][4 * z] = BlockX + (int)(64 * NoiseX); DistortZ[4 * x][4 * z] = BlockZ + (int)(64 * NoiseZ); @@ -788,8 +793,8 @@ void cBioGenTwoLevel::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap { for (int x = 0; x < cChunkDef::Width; x++) { - int BiomeGroup = m_VoronoiLarge.GetValueAt(DistortX[x][z], DistortZ[x][z]) / 7; int MinDist1, MinDist2; + int BiomeGroup = m_VoronoiLarge.GetValueAt(DistortX[x][z], DistortZ[x][z], MinDist1, MinDist2) / 7; int BiomeIdx = m_VoronoiSmall.GetValueAt(DistortX[x][z], DistortZ[x][z], MinDist1, MinDist2) / 11; cChunkDef::SetBiome(a_BiomeMap, x, z, SelectBiome(BiomeGroup, BiomeIdx, (MinDist1 < MinDist2 / 4) ? 0 : 1)); } diff --git a/src/Generating/BioGen.h b/src/Generating/BioGen.h index 8bd460d8f..227ec97d7 100644 --- a/src/Generating/BioGen.h +++ b/src/Generating/BioGen.h @@ -261,7 +261,12 @@ protected: /// The noise used to distort the inupt Z coord cPerlinNoise m_DistortZ; - cNoise m_Noise; + cNoise m_Noise1; + cNoise m_Noise2; + cNoise m_Noise3; + cNoise m_Noise4; + cNoise m_Noise5; + cNoise m_Noise6; // cBiomeGen overrides: diff --git a/src/VoronoiMap.cpp b/src/VoronoiMap.cpp index 7a36edebc..9c3ca7e65 100644 --- a/src/VoronoiMap.cpp +++ b/src/VoronoiMap.cpp @@ -11,7 +11,9 @@ cVoronoiMap::cVoronoiMap(int a_Seed, int a_CellSize) : - m_Noise(a_Seed), + m_Noise1(a_Seed + 1), + m_Noise2(a_Seed + 2), + m_Noise3(a_Seed + 3), m_CellSize(a_CellSize) { } @@ -57,26 +59,25 @@ int cVoronoiMap::GetValueAt(int a_X, int a_Y, int & a_MinDist1, int & a_MinDist2 int CellX = a_X / m_CellSize; int CellZ = a_Y / m_CellSize; + UpdateCell(CellX, CellZ); + // Get 5x5 neighboring cell seeds, compare distance to each. Return the value in the minumim-distance cell int MinDist = m_CellSize * m_CellSize * 16; // There has to be a cell closer than this int MinDist2 = MinDist; int res = 0; // Will be overriden - for (int x = CellX - 2; x <= CellX + 2; x++) + for (int x = 0; x < 5; x++) { - int BaseX = x * m_CellSize; - for (int z = CellZ - 2; z < CellZ + 2; z++) + for (int z = 0; z < 5; z++) { - int OffsetX = (m_Noise.IntNoise3DInt(x, 16 * x + 32 * z, z) / 8) % m_CellSize; - int OffsetZ = (m_Noise.IntNoise3DInt(x, 32 * x - 16 * z, z) / 8) % m_CellSize; - int SeedX = BaseX + OffsetX; - int SeedZ = z * m_CellSize + OffsetZ; + int SeedX = m_SeedX[x][z]; + int SeedZ = m_SeedZ[x][z]; int Dist = (SeedX - a_X) * (SeedX - a_X) + (SeedZ - a_Y) * (SeedZ - a_Y); if (Dist < MinDist) { MinDist2 = MinDist; MinDist = Dist; - res = m_Noise.IntNoise3DInt(x, x - z + 1000, z); + res = m_Noise3.IntNoise2DInt(x + CellX - 2, z + CellZ - 2); } else if (Dist < MinDist2) { @@ -93,3 +94,33 @@ int cVoronoiMap::GetValueAt(int a_X, int a_Y, int & a_MinDist1, int & a_MinDist2 + +void cVoronoiMap::UpdateCell(int a_CellX, int a_CellZ) +{ + // If the specified cell is currently cached, bail out: + if ((a_CellX == m_CurrentCellX) && (a_CellZ == m_CurrentCellZ)) + { + return; + } + + // Update the cell cache for the new cell position: + int NoiseBaseX = a_CellX - 2; + int NoiseBaseZ = a_CellZ - 2; + for (int x = 0; x < 5; x++) + { + int BaseX = (NoiseBaseX + x) * m_CellSize; + for (int z = 0; z < 5; z++) + { + int OffsetX = (m_Noise1.IntNoise2DInt(NoiseBaseX + x, NoiseBaseZ + z) / 8) % m_CellSize; + int OffsetZ = (m_Noise2.IntNoise2DInt(NoiseBaseX + x, NoiseBaseZ + z) / 8) % m_CellSize; + m_SeedX[x][z] = BaseX + OffsetX; + m_SeedZ[x][z] = (NoiseBaseZ + z) * m_CellSize + OffsetZ; + } // for z + } // for x + m_CurrentCellX = a_CellX; + m_CurrentCellZ = a_CellZ; +} + + + + diff --git a/src/VoronoiMap.h b/src/VoronoiMap.h index bcd37f9cf..84cf206e9 100644 --- a/src/VoronoiMap.h +++ b/src/VoronoiMap.h @@ -29,15 +29,34 @@ public: /// Returns the value in the cell into which the specified point lies, and the distance to the nearest Voronoi seed int GetValueAt(int a_X, int a_Y, int & a_MinDistance); - /// Returns the value in the cell into which the specified point lies, and the distances to the 2 nearest Voronoi seeds + /// Returns the value in the cell into which the specified point lies, and the distances to the 2 nearest Voronoi seeds. Uses a cache int GetValueAt(int a_X, int a_Y, int & a_MinDistance1, int & a_MinDistance2); - + protected: /// The noise used for generating Voronoi seeds - cNoise m_Noise; + cNoise m_Noise1; + cNoise m_Noise2; + cNoise m_Noise3; /// Size of the Voronoi cells (avg X/Y distance between the seeds) int m_CellSize; + + /** The X coordinate of the currently cached cell neighborhood */ + int m_CurrentCellX; + + /** The Z coordinate of the currently cached cell neighborhood */ + int m_CurrentCellZ; + + /** The seeds of cells around m_CurrentCellX, m_CurrentCellZ, X-coords */ + int m_SeedX[5][5]; + + /** The seeds of cells around m_CurrentCellX, m_CurrentCellZ, X-coords */ + int m_SeedZ[5][5]; + + + /** Updates the cached cell seeds to match the specified cell. Noop if cell pos already matches. + Updates m_SeedX and m_SeedZ. */ + void UpdateCell(int a_CellX, int a_CellZ); } ; -- cgit v1.2.3 From 79c19662904eb010d90c2d80ab6382b90027c67d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 20 Jun 2014 21:30:11 +0200 Subject: MCA saver marks chunks as populated. Fixes #140. --- src/WorldStorage/WSSAnvil.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 1891762fd..0f84a0eb1 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -469,6 +469,9 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_ a_Writer.AddByte("MCSIsLightValid", 1); } + // Store the flag that the chunk has all the ores, trees, dungeons etc. MCS chunks are always complete. + a_Writer.AddByte("TerrainPopulated", 1); + a_Writer.EndCompound(); // "Level" return true; } -- cgit v1.2.3 From b4ba86d75897900b63186fa6a6420619f8cdd897 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 20 Jun 2014 22:45:08 +0200 Subject: Updated all prefabs to current Gallery content. --- src/Generating/Prefabs/SandVillagePrefabs.cpp | 1472 ++++++++++++---------- src/Generating/Prefabs/UnderwaterBasePrefabs.cpp | 2 +- 2 files changed, 824 insertions(+), 650 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/SandVillagePrefabs.cpp b/src/Generating/Prefabs/SandVillagePrefabs.cpp index a062f8cd4..72881a678 100644 --- a/src/Generating/Prefabs/SandVillagePrefabs.cpp +++ b/src/Generating/Prefabs/SandVillagePrefabs.cpp @@ -20,11 +20,11 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 5, ID 75, created by tonibm1999 { // Size: - 13, 2, 9, // SizeX = 13, SizeY = 2, SizeZ = 9 + 13, 3, 9, // SizeX = 13, SizeY = 3, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 12, 1, 8, // MaxX, MaxY, MaxZ + -1, 0, -1, // MinX, MinY, MinZ + 13, 2, 8, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -40,6 +40,19 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "aaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaaa" + /* 5 */ "aaaaaaaaaaaaa" + /* 6 */ "aaaaaaaaaaaaa" + /* 7 */ "aaaaaaaaaaaaa" + /* 8 */ "aaaaaaaaaaaaa" + + // Level 1 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "aaaaaaaaaaaaa" /* 1 */ "abbcbbabbcbba" /* 2 */ "abbcbbabbcbba" /* 3 */ "abbcbbabbcbba" @@ -49,21 +62,21 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 7 */ "abbcbbabbcbba" /* 8 */ "aaaaaaaaaaaaa" - // Level 1 + // Level 2 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "d.....d.....d" - /* 1 */ ".......ee.ee." - /* 2 */ ".......ee.ee." - /* 3 */ ".......ee.ee." - /* 4 */ ".......ee.ee." - /* 5 */ ".......ee.ee." - /* 6 */ ".......ee.ee." - /* 7 */ ".......ee.ee." + /* 1 */ ".ee.ee.ee.ee." + /* 2 */ ".ee.ee.ee.ee." + /* 3 */ ".ee.ee.ee.ee." + /* 4 */ ".ee.ee.ee.ee." + /* 5 */ ".ee.ee.ee.ee." + /* 6 */ ".ee.ee.ee.ee." + /* 7 */ ".ee.ee.ee.ee." /* 8 */ "d.....d.....d", // Connectors: - "-1: 6, 0, 8: 3\n" /* Type -1, direction Z+ */, + "-1: 6, 1, 8: 3\n" /* Type -1, direction Z+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -94,18 +107,18 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 6, ID 81, created by Aloe_vera { // Size: - 11, 6, 7, // SizeX = 11, SizeY = 6, SizeZ = 7 + 11, 7, 7, // SizeX = 11, SizeY = 7, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 10, 5, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 11, 6, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ @@ -122,71 +135,82 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "....abc...." - /* 1 */ ".ddddddddd." - /* 2 */ ".ddddddddd." - /* 3 */ ".ddddddddd." - /* 4 */ ".ddddddddd." - /* 5 */ ".ddddddddd." - /* 6 */ "..........." + /* 0 */ "mmmmaaammmm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "maaaaaaaaam" + /* 3 */ "maaaaaaaaam" + /* 4 */ "maaaaaaaaam" + /* 5 */ "maaaaaaaaam" + /* 6 */ "mmmmmmmmmmm" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".ddddedddd." - /* 2 */ ".d.......d." - /* 3 */ ".d.......d." - /* 4 */ ".d.......d." - /* 5 */ ".ddddddddd." + /* 0 */ "....bcd...." + /* 1 */ ".aaaaaaaaa." + /* 2 */ ".aaaaaaaaa." + /* 3 */ ".aaaaaaaaa." + /* 4 */ ".aaaaaaaaa." + /* 5 */ ".aaaaaaaaa." /* 6 */ "..........." // Level 2 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ ".dffdgdffd." + /* 1 */ ".aaaaeaaaa." + /* 2 */ ".a.......a." + /* 3 */ ".a.......a." + /* 4 */ ".a.......a." + /* 5 */ ".aaaaaaaaa." + /* 6 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".affagaffa." /* 2 */ ".f.......f." /* 3 */ ".f.......f." /* 4 */ ".f.......f." - /* 5 */ ".dffdfdffd." + /* 5 */ ".affafaffa." /* 6 */ "..........." - // Level 3 + // Level 4 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "bbbbbbbbbbb" - /* 1 */ "hdddddddddh" - /* 2 */ ".d..i.i..d." - /* 3 */ ".d.......d." - /* 4 */ ".d..j.j..d." - /* 5 */ "kdddddddddk" + /* 0 */ "ccccccccccc" + /* 1 */ "haaaaaaaaah" + /* 2 */ ".a..i.i..a." + /* 3 */ ".a.......a." + /* 4 */ ".a..j.j..a." + /* 5 */ "kaaaaaaaaak" /* 6 */ "lllllllllll" - // Level 4 + // Level 5 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ "bbbbbbbbbbb" - /* 2 */ "hdddddddddh" - /* 3 */ ".dn.....od." - /* 4 */ "kdddddddddk" + /* 1 */ "ccccccccccc" + /* 2 */ "haaaaaaaaah" + /* 3 */ ".an.....oa." + /* 4 */ "kaaaaaaaaak" /* 5 */ "lllllllllll" /* 6 */ "..........." - // Level 5 + // Level 6 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." - /* 2 */ "bbbbbbbbbbb" - /* 3 */ "ddddddddddd" + /* 2 */ "ccccccccccc" + /* 3 */ "aaaaaaaaaaa" /* 4 */ "lllllllllll" /* 5 */ "..........." /* 6 */ "...........", // Connectors: - "-1: 5, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -217,18 +241,18 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 11, ID 115, created by xoft { // Size: - 11, 7, 9, // SizeX = 11, SizeY = 7, SizeZ = 9 + 11, 8, 9, // SizeX = 11, SizeY = 8, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 10, 6, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 11, 7, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ @@ -243,96 +267,109 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "....abc...." - /* 1 */ ".ddddddddd." - /* 2 */ ".ddddddddd." - /* 3 */ ".ddddddddd." - /* 4 */ ".ddddddddd." - /* 5 */ ".ddddddddd." - /* 6 */ ".ddddddddd." - /* 7 */ ".ddddddddd." - /* 8 */ "..........." + /* 0 */ "mmmmaaammmm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "maaaaaaaaam" + /* 3 */ "maaaaaaaaam" + /* 4 */ "maaaaaaaaam" + /* 5 */ "maaaaaaaaam" + /* 6 */ "maaaaaaaaam" + /* 7 */ "maaaaaaaaam" + /* 8 */ "mmmmmmmmmmm" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ ".ddddedddd." - /* 2 */ ".d.......d." - /* 3 */ ".d.......d." - /* 4 */ ".d.......d." - /* 5 */ ".d.......d." - /* 6 */ ".d.......d." - /* 7 */ ".ddddddddd." + /* 0 */ "....bcd...." + /* 1 */ ".aaaaaaaaa." + /* 2 */ ".aaaaaaaaa." + /* 3 */ ".aaaaaaaaa." + /* 4 */ ".aaaaaaaaa." + /* 5 */ ".aaaaaaaaa." + /* 6 */ ".aaaaaaaaa." + /* 7 */ ".aaaaaaaaa." /* 8 */ "..........." // Level 2 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ ".dffdgdffd." + /* 1 */ ".aaaaeaaaa." + /* 2 */ ".a.......a." + /* 3 */ ".a.......a." + /* 4 */ ".a.......a." + /* 5 */ ".a.......a." + /* 6 */ ".a.......a." + /* 7 */ ".aaaaaaaaa." + /* 8 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".affagaffa." /* 2 */ ".f.......f." /* 3 */ ".f.......f." - /* 4 */ ".d.......d." + /* 4 */ ".a.......a." /* 5 */ ".f.......f." /* 6 */ ".f.......f." - /* 7 */ ".dfffdfffd." + /* 7 */ ".afffafffa." /* 8 */ "..........." - // Level 3 + // Level 4 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "bbbbbbbbbbb" - /* 1 */ "hdddddddddh" - /* 2 */ ".d..i.i..d." - /* 3 */ ".d.......d." - /* 4 */ ".d.......d." - /* 5 */ ".d.......d." - /* 6 */ ".d...j...d." - /* 7 */ "kdddddddddk" + /* 0 */ "ccccccccccc" + /* 1 */ "haaaaaaaaah" + /* 2 */ ".a..i.i..a." + /* 3 */ ".a.......a." + /* 4 */ ".a.......a." + /* 5 */ ".a.......a." + /* 6 */ ".a...j...a." + /* 7 */ "kaaaaaaaaak" /* 8 */ "lllllllllll" - // Level 4 + // Level 5 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." - /* 1 */ "bbbbbbbbbbb" - /* 2 */ "hdddddddddh" - /* 3 */ ".d.......d." - /* 4 */ ".d.......d." - /* 5 */ ".d.......d." - /* 6 */ "kdddddddddk" + /* 1 */ "ccccccccccc" + /* 2 */ "haaaaaaaaah" + /* 3 */ ".a.......a." + /* 4 */ ".a.......a." + /* 5 */ ".a.......a." + /* 6 */ "kaaaaaaaaak" /* 7 */ "lllllllllll" /* 8 */ "..........." - // Level 5 + // Level 6 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." - /* 2 */ "bbbbbbbbbbb" - /* 3 */ "hdddddddddh" - /* 4 */ ".d.......d." - /* 5 */ "kdddddddddk" + /* 2 */ "ccccccccccc" + /* 3 */ "haaaaaaaaah" + /* 4 */ ".a.......a." + /* 5 */ "kaaaaaaaaak" /* 6 */ "lllllllllll" /* 7 */ "..........." /* 8 */ "..........." - // Level 6 + // Level 7 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ "bbbbbbbbbbb" - /* 4 */ "ddddddddddd" + /* 3 */ "ccccccccccc" + /* 4 */ "aaaaaaaaaaa" /* 5 */ "lllllllllll" /* 6 */ "..........." /* 7 */ "..........." /* 8 */ "...........", // Connectors: - "-1: 5, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -363,18 +400,18 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 15, ID 125, created by Aloe_vera { // Size: - 13, 6, 7, // SizeX = 13, SizeY = 6, SizeZ = 7 + 13, 7, 7, // SizeX = 13, SizeY = 7, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 12, 5, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 13, 6, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ @@ -389,71 +426,82 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // Level 0 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ ".....abc....." - /* 1 */ ".ddddddddddd." - /* 2 */ ".ddddddddddd." - /* 3 */ ".ddddddddddd." - /* 4 */ ".ddddddddddd." - /* 5 */ ".ddddddddddd." - /* 6 */ "............." + /* 0 */ "mmmmmaaammmmm" + /* 1 */ "maaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaam" + /* 6 */ "mmmmmmmmmmmmm" // Level 1 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ "............." - /* 1 */ ".dddddeddddd." - /* 2 */ ".d.........d." - /* 3 */ ".d.........d." - /* 4 */ ".d.........d." - /* 5 */ ".ddddddddddd." + /* 0 */ ".....bcd....." + /* 1 */ ".aaaaaaaaaaa." + /* 2 */ ".aaaaaaaaaaa." + /* 3 */ ".aaaaaaaaaaa." + /* 4 */ ".aaaaaaaaaaa." + /* 5 */ ".aaaaaaaaaaa." /* 6 */ "............." // Level 2 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." - /* 1 */ ".dfffdgdfffd." + /* 1 */ ".aaaaaeaaaaa." + /* 2 */ ".a.........a." + /* 3 */ ".a.........a." + /* 4 */ ".a.........a." + /* 5 */ ".aaaaaaaaaaa." + /* 6 */ "............." + + // Level 3 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ ".afffagafffa." /* 2 */ ".f.........f." /* 3 */ ".f.........f." /* 4 */ ".f.........f." - /* 5 */ ".dffdfffdffd." + /* 5 */ ".affafffaffa." /* 6 */ "............." - // Level 3 + // Level 4 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ "bbbbbbbbbbbbb" - /* 1 */ "hdddddddddddh" - /* 2 */ ".d...i.i...d." - /* 3 */ ".d.........d." - /* 4 */ ".d..j...j..d." - /* 5 */ "kdddddddddddk" + /* 0 */ "ccccccccccccc" + /* 1 */ "haaaaaaaaaaah" + /* 2 */ ".a...i.i...a." + /* 3 */ ".a.........a." + /* 4 */ ".a..j...j..a." + /* 5 */ "kaaaaaaaaaaak" /* 6 */ "lllllllllllll" - // Level 4 + // Level 5 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." - /* 1 */ "bbbbbbbbbbbbb" - /* 2 */ "hdddddddddddh" - /* 3 */ ".d.........d." - /* 4 */ "kdddddddddddk" + /* 1 */ "ccccccccccccc" + /* 2 */ "haaaaaaaaaaah" + /* 3 */ ".a.........a." + /* 4 */ "kaaaaaaaaaaak" /* 5 */ "lllllllllllll" /* 6 */ "............." - // Level 5 + // Level 6 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." /* 1 */ "............." - /* 2 */ "bbbbbbbbbbbbb" - /* 3 */ "ddddddddddddd" + /* 2 */ "ccccccccccccc" + /* 3 */ "aaaaaaaaaaaaa" /* 4 */ "lllllllllllll" /* 5 */ "............." /* 6 */ ".............", // Connectors: - "-1: 6, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -484,18 +532,18 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 12, ID 116, created by xoft { // Size: - 13, 7, 9, // SizeX = 13, SizeY = 7, SizeZ = 9 + 13, 8, 9, // SizeX = 13, SizeY = 8, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 12, 6, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 13, 7, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ @@ -510,96 +558,109 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // Level 0 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ ".....abc....." - /* 1 */ ".ddddddddddd." - /* 2 */ ".ddddddddddd." - /* 3 */ ".ddddddddddd." - /* 4 */ ".ddddddddddd." - /* 5 */ ".ddddddddddd." - /* 6 */ ".ddddddddddd." - /* 7 */ ".ddddddddddd." - /* 8 */ "............." + /* 0 */ "mmmmmaaammmmm" + /* 1 */ "maaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaam" + /* 6 */ "maaaaaaaaaaam" + /* 7 */ "maaaaaaaaaaam" + /* 8 */ "mmmmmmmmmmmmm" // Level 1 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ "............." - /* 1 */ ".dddddeddddd." - /* 2 */ ".d.........d." - /* 3 */ ".d.........d." - /* 4 */ ".d.........d." - /* 5 */ ".d.........d." - /* 6 */ ".d.........d." - /* 7 */ ".ddddddddddd." + /* 0 */ ".....bcd....." + /* 1 */ ".aaaaaaaaaaa." + /* 2 */ ".aaaaaaaaaaa." + /* 3 */ ".aaaaaaaaaaa." + /* 4 */ ".aaaaaaaaaaa." + /* 5 */ ".aaaaaaaaaaa." + /* 6 */ ".aaaaaaaaaaa." + /* 7 */ ".aaaaaaaaaaa." /* 8 */ "............." // Level 2 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." - /* 1 */ ".dfffdgdfffd." + /* 1 */ ".aaaaaeaaaaa." + /* 2 */ ".a.........a." + /* 3 */ ".a.........a." + /* 4 */ ".a.........a." + /* 5 */ ".a.........a." + /* 6 */ ".a.........a." + /* 7 */ ".aaaaaaaaaaa." + /* 8 */ "............." + + // Level 3 + /* z\x* 111 */ + /* * 0123456789012 */ + /* 0 */ "............." + /* 1 */ ".afffagafffa." /* 2 */ ".f.........f." /* 3 */ ".f.........f." - /* 4 */ ".d.........d." + /* 4 */ ".a.........a." /* 5 */ ".f.........f." /* 6 */ ".f.........f." - /* 7 */ ".dffdffdfffd." + /* 7 */ ".affaffafffa." /* 8 */ "............." - // Level 3 + // Level 4 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ "bbbbbbbbbbbbb" - /* 1 */ "hdddddddddddh" - /* 2 */ ".d...i.i...d." - /* 3 */ ".d.........d." - /* 4 */ ".d.........d." - /* 5 */ ".d.........d." - /* 6 */ ".d..j..j...d." - /* 7 */ "kdddddddddddk" + /* 0 */ "ccccccccccccc" + /* 1 */ "haaaaaaaaaaah" + /* 2 */ ".a...i.i...a." + /* 3 */ ".a.........a." + /* 4 */ ".a.........a." + /* 5 */ ".a.........a." + /* 6 */ ".a..j..j...a." + /* 7 */ "kaaaaaaaaaaak" /* 8 */ "lllllllllllll" - // Level 4 + // Level 5 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." - /* 1 */ "bbbbbbbbbbbbb" - /* 2 */ "hdddddddddddh" - /* 3 */ ".d.........d." - /* 4 */ ".d.........d." - /* 5 */ ".d.........d." - /* 6 */ "kdddddddddddk" + /* 1 */ "ccccccccccccc" + /* 2 */ "haaaaaaaaaaah" + /* 3 */ ".a.........a." + /* 4 */ ".a.........a." + /* 5 */ ".a.........a." + /* 6 */ "kaaaaaaaaaaak" /* 7 */ "lllllllllllll" /* 8 */ "............." - // Level 5 + // Level 6 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." /* 1 */ "............." - /* 2 */ "bbbbbbbbbbbbb" - /* 3 */ "hdddddddddddh" - /* 4 */ ".d.........d." - /* 5 */ "kdddddddddddk" + /* 2 */ "ccccccccccccc" + /* 3 */ "haaaaaaaaaaah" + /* 4 */ ".a.........a." + /* 5 */ "kaaaaaaaaaaak" /* 6 */ "lllllllllllll" /* 7 */ "............." /* 8 */ "............." - // Level 6 + // Level 7 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." /* 1 */ "............." /* 2 */ "............." - /* 3 */ "bbbbbbbbbbbbb" - /* 4 */ "ddddddddddddd" + /* 3 */ "ccccccccccccc" + /* 4 */ "aaaaaaaaaaaaa" /* 5 */ "lllllllllllll" /* 6 */ "............." /* 7 */ "............." /* 8 */ ".............", // Connectors: - "-1: 6, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -630,18 +691,18 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 13, ID 118, created by xoft { // Size: - 15, 7, 9, // SizeX = 15, SizeY = 7, SizeZ = 9 + 15, 8, 9, // SizeX = 15, SizeY = 8, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 14, 6, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 15, 7, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ @@ -656,96 +717,109 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // Level 0 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ ".....abc......." - /* 1 */ ".ddddddddddddd." - /* 2 */ ".ddddddddddddd." - /* 3 */ ".ddddddddddddd." - /* 4 */ ".ddddddddddddd." - /* 5 */ ".ddddddddddddd." - /* 6 */ ".ddddddddddddd." - /* 7 */ ".ddddddddddddd." - /* 8 */ "..............." + /* 0 */ "mmmmmaaammmmmmm" + /* 1 */ "maaaaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaaaam" + /* 6 */ "maaaaaaaaaaaaam" + /* 7 */ "maaaaaaaaaaaaam" + /* 8 */ "mmmmmmmmmmmmmmm" // Level 1 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ ".dddddeddddddd." - /* 2 */ ".d...........d." - /* 3 */ ".d...........d." - /* 4 */ ".d...........d." - /* 5 */ ".d...........d." - /* 6 */ ".d...........d." - /* 7 */ ".ddddddddddddd." + /* 0 */ ".....bcd......." + /* 1 */ ".aaaaaaaaaaaaa." + /* 2 */ ".aaaaaaaaaaaaa." + /* 3 */ ".aaaaaaaaaaaaa." + /* 4 */ ".aaaaaaaaaaaaa." + /* 5 */ ".aaaaaaaaaaaaa." + /* 6 */ ".aaaaaaaaaaaaa." + /* 7 */ ".aaaaaaaaaaaaa." /* 8 */ "..............." // Level 2 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".dfffdgdffdffd." + /* 1 */ ".aaaaaeaaaaaaa." + /* 2 */ ".a...........a." + /* 3 */ ".a...........a." + /* 4 */ ".a...........a." + /* 5 */ ".a...........a." + /* 6 */ ".a...........a." + /* 7 */ ".aaaaaaaaaaaaa." + /* 8 */ "..............." + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." + /* 1 */ ".afffagaffaffa." /* 2 */ ".f...........f." /* 3 */ ".f...........f." - /* 4 */ ".d...........d." + /* 4 */ ".a...........a." /* 5 */ ".f...........f." /* 6 */ ".f...........f." - /* 7 */ ".dffdffdffdffd." + /* 7 */ ".affaffaffaffa." /* 8 */ "..............." - // Level 3 + // Level 4 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "bbbbbbbbbbbbbbb" - /* 1 */ "hdddddddddddddh" - /* 2 */ ".d...i.i..i..d." - /* 3 */ ".d...........d." - /* 4 */ ".d...........d." - /* 5 */ ".d...........d." - /* 6 */ ".d..j..j..j..d." - /* 7 */ "kdddddddddddddk" + /* 0 */ "ccccccccccccccc" + /* 1 */ "haaaaaaaaaaaaah" + /* 2 */ ".a...i.i..i..a." + /* 3 */ ".a...........a." + /* 4 */ ".a...........a." + /* 5 */ ".a...........a." + /* 6 */ ".a..j..j..j..a." + /* 7 */ "kaaaaaaaaaaaaak" /* 8 */ "lllllllllllllll" - // Level 4 + // Level 5 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ "bbbbbbbbbbbbbbb" - /* 2 */ "hdddddddddddddh" - /* 3 */ ".d...........d." - /* 4 */ ".d...........d." - /* 5 */ ".d...........d." - /* 6 */ "kdddddddddddddk" + /* 1 */ "ccccccccccccccc" + /* 2 */ "haaaaaaaaaaaaah" + /* 3 */ ".a...........a." + /* 4 */ ".a...........a." + /* 5 */ ".a...........a." + /* 6 */ "kaaaaaaaaaaaaak" /* 7 */ "lllllllllllllll" /* 8 */ "..............." - // Level 5 + // Level 6 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ "bbbbbbbbbbbbbbb" - /* 3 */ "hdddddddddddddh" - /* 4 */ ".d...........d." - /* 5 */ "kdddddddddddddk" + /* 2 */ "ccccccccccccccc" + /* 3 */ "haaaaaaaaaaaaah" + /* 4 */ ".a...........a." + /* 5 */ "kaaaaaaaaaaaaak" /* 6 */ "lllllllllllllll" /* 7 */ "..............." /* 8 */ "..............." - // Level 6 + // Level 7 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." /* 2 */ "..............." - /* 3 */ "bbbbbbbbbbbbbbb" - /* 4 */ "ddddddddddddddd" + /* 3 */ "ccccccccccccccc" + /* 4 */ "aaaaaaaaaaaaaaa" /* 5 */ "lllllllllllllll" /* 6 */ "..............." /* 7 */ "..............." /* 8 */ "...............", // Connectors: - "-1: 6, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -776,18 +850,18 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 16, ID 126, created by Aloe_vera { // Size: - 16, 7, 9, // SizeX = 16, SizeY = 7, SizeZ = 9 + 16, 8, 9, // SizeX = 16, SizeY = 8, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 15, 6, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 16, 7, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ @@ -802,96 +876,109 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // Level 0 /* z\x* 111111 */ /* * 0123456789012345 */ - /* 0 */ "........abc....." - /* 1 */ ".dddddddddddddd." - /* 2 */ ".dddddddddddddd." - /* 3 */ ".dddddddddddddd." - /* 4 */ ".dddddddddddddd." - /* 5 */ ".dddddddddddddd." - /* 6 */ ".dddddddddddddd." - /* 7 */ ".dddddddddddddd." - /* 8 */ "................" + /* 0 */ "mmmmmmmmaaammmmm" + /* 1 */ "maaaaaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaaaaam" + /* 6 */ "maaaaaaaaaaaaaam" + /* 7 */ "maaaaaaaaaaaaaam" + /* 8 */ "mmmmmmmmmmmmmmmm" // Level 1 /* z\x* 111111 */ /* * 0123456789012345 */ - /* 0 */ "................" - /* 1 */ ".ddddddddeddddd." - /* 2 */ ".d............d." - /* 3 */ ".d............d." - /* 4 */ ".d............d." - /* 5 */ ".d............d." - /* 6 */ ".d............d." - /* 7 */ ".dddddddddddddd." + /* 0 */ "........bcd....." + /* 1 */ ".aaaaaaaaaaaaaa." + /* 2 */ ".aaaaaaaaaaaaaa." + /* 3 */ ".aaaaaaaaaaaaaa." + /* 4 */ ".aaaaaaaaaaaaaa." + /* 5 */ ".aaaaaaaaaaaaaa." + /* 6 */ ".aaaaaaaaaaaaaa." + /* 7 */ ".aaaaaaaaaaaaaa." /* 8 */ "................" // Level 2 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" - /* 1 */ ".dffdfffdgdfffd." + /* 1 */ ".aaaaaaaaeaaaaa." + /* 2 */ ".a............a." + /* 3 */ ".a............a." + /* 4 */ ".a............a." + /* 5 */ ".a............a." + /* 6 */ ".a............a." + /* 7 */ ".aaaaaaaaaaaaaa." + /* 8 */ "................" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "................" + /* 1 */ ".affafffagafffa." /* 2 */ ".f............f." /* 3 */ ".f............f." - /* 4 */ ".d............d." + /* 4 */ ".a............a." /* 5 */ ".f............f." /* 6 */ ".f............f." - /* 7 */ ".dffdffdfffdffd." + /* 7 */ ".affaffafffaffa." /* 8 */ "................" - // Level 3 + // Level 4 /* z\x* 111111 */ /* * 0123456789012345 */ - /* 0 */ "bbbbbbbbbbbbbbbb" - /* 1 */ "hddddddddddddddh" - /* 2 */ ".d..i...i.i...d." - /* 3 */ ".d............d." - /* 4 */ ".d............d." - /* 5 */ ".d............d." - /* 6 */ ".d..j..j...j..d." - /* 7 */ "kddddddddddddddk" + /* 0 */ "cccccccccccccccc" + /* 1 */ "haaaaaaaaaaaaaah" + /* 2 */ ".a..i...i.i...a." + /* 3 */ ".a............a." + /* 4 */ ".a............a." + /* 5 */ ".a............a." + /* 6 */ ".a..j..j...j..a." + /* 7 */ "kaaaaaaaaaaaaaak" /* 8 */ "llllllllllllllll" - // Level 4 + // Level 5 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" - /* 1 */ "bbbbbbbbbbbbbbbb" - /* 2 */ "hddddddddddddddh" - /* 3 */ ".d............d." - /* 4 */ ".d............d." - /* 5 */ ".d............d." - /* 6 */ "kddddddddddddddk" + /* 1 */ "cccccccccccccccc" + /* 2 */ "haaaaaaaaaaaaaah" + /* 3 */ ".a............a." + /* 4 */ ".a............a." + /* 5 */ ".a............a." + /* 6 */ "kaaaaaaaaaaaaaak" /* 7 */ "llllllllllllllll" /* 8 */ "................" - // Level 5 + // Level 6 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" /* 1 */ "................" - /* 2 */ "bbbbbbbbbbbbbbbb" - /* 3 */ "hddddddddddddddh" - /* 4 */ ".d............d." - /* 5 */ "kddddddddddddddk" + /* 2 */ "cccccccccccccccc" + /* 3 */ "haaaaaaaaaaaaaah" + /* 4 */ ".a............a." + /* 5 */ "kaaaaaaaaaaaaaak" /* 6 */ "llllllllllllllll" /* 7 */ "................" /* 8 */ "................" - // Level 6 + // Level 7 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" /* 1 */ "................" /* 2 */ "................" - /* 3 */ "bbbbbbbbbbbbbbbb" - /* 4 */ "dddddddddddddddd" + /* 3 */ "cccccccccccccccc" + /* 4 */ "aaaaaaaaaaaaaaaa" /* 5 */ "llllllllllllllll" /* 6 */ "................" /* 7 */ "................" /* 8 */ "................", // Connectors: - "-1: 9, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 9, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -922,18 +1009,18 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 8, ID 112, created by Aloe_vera { // Size: - 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7 + 7, 7, 7, // SizeX = 7, SizeY = 7, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 6, 5, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 7, 6, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ @@ -946,66 +1033,76 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // Block data: // Level 0 /* z\x* 0123456 */ - /* 0 */ "...abc." - /* 1 */ ".ddddd." - /* 2 */ ".ddddd." - /* 3 */ ".ddddd." - /* 4 */ ".ddddd." - /* 5 */ ".ddddd." - /* 6 */ "......." + /* 0 */ "mmmaaam" + /* 1 */ "maaaaam" + /* 2 */ "maaaaam" + /* 3 */ "maaaaam" + /* 4 */ "maaaaam" + /* 5 */ "maaaaam" + /* 6 */ "mmmmmmm" // Level 1 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".ddded." - /* 2 */ ".d...d." - /* 3 */ ".d...d." - /* 4 */ ".d...d." - /* 5 */ ".ddddd." + /* 0 */ "...bcd." + /* 1 */ ".aaaaa." + /* 2 */ ".aaaaa." + /* 3 */ ".aaaaa." + /* 4 */ ".aaaaa." + /* 5 */ ".aaaaa." /* 6 */ "......." // Level 2 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".dfdgd." + /* 1 */ ".aaaea." + /* 2 */ ".a...a." + /* 3 */ ".a...a." + /* 4 */ ".a...a." + /* 5 */ ".aaaaa." + /* 6 */ "......." + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".afaga." /* 2 */ ".f...f." /* 3 */ ".f...f." /* 4 */ ".f...f." - /* 5 */ ".dfffd." + /* 5 */ ".afffa." /* 6 */ "......." - // Level 3 + // Level 4 /* z\x* 0123456 */ - /* 0 */ "bbbbbbb" - /* 1 */ "hdddddh" - /* 2 */ ".d.i.d." - /* 3 */ ".d...d." - /* 4 */ ".d...d." - /* 5 */ "jdddddj" + /* 0 */ "ccccccc" + /* 1 */ "haaaaah" + /* 2 */ ".a.i.a." + /* 3 */ ".a...a." + /* 4 */ ".a...a." + /* 5 */ "jaaaaaj" /* 6 */ "kkkkkkk" - // Level 4 + // Level 5 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ "bbbbbbb" - /* 2 */ "hdddddh" - /* 3 */ ".d...d." - /* 4 */ "jdddddj" + /* 1 */ "ccccccc" + /* 2 */ "haaaaah" + /* 3 */ ".a...a." + /* 4 */ "jaaaaaj" /* 5 */ "kkkkkkk" /* 6 */ "......." - // Level 5 + // Level 6 /* z\x* 0123456 */ /* 0 */ "......." /* 1 */ "......." - /* 2 */ "bbbbbbb" - /* 3 */ "ddddddd" + /* 2 */ "ccccccc" + /* 3 */ "aaaaaaa" /* 4 */ "kkkkkkk" /* 5 */ "......." /* 6 */ ".......", // Connectors: - "-1: 4, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1036,18 +1133,18 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 9, ID 113, created by xoft { // Size: - 9, 6, 7, // SizeX = 9, SizeY = 6, SizeZ = 7 + 9, 7, 7, // SizeX = 9, SizeY = 7, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 8, 5, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 9, 6, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ @@ -1061,66 +1158,76 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // Block data: // Level 0 /* z\x* 012345678 */ - /* 0 */ "...abc..." - /* 1 */ ".ddddddd." - /* 2 */ ".ddddddd." - /* 3 */ ".ddddddd." - /* 4 */ ".ddddddd." - /* 5 */ ".ddddddd." - /* 6 */ "........." + /* 0 */ "mmmaaammm" + /* 1 */ "maaaaaaam" + /* 2 */ "maaaaaaam" + /* 3 */ "maaaaaaam" + /* 4 */ "maaaaaaam" + /* 5 */ "maaaaaaam" + /* 6 */ "mmmmmmmmm" // Level 1 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ ".dddeddd." - /* 2 */ ".d.....d." - /* 3 */ ".d.....d." - /* 4 */ ".d.....d." - /* 5 */ ".ddddddd." + /* 0 */ "...bcd..." + /* 1 */ ".aaaaaaa." + /* 2 */ ".aaaaaaa." + /* 3 */ ".aaaaaaa." + /* 4 */ ".aaaaaaa." + /* 5 */ ".aaaaaaa." /* 6 */ "........." // Level 2 /* z\x* 012345678 */ /* 0 */ "........." - /* 1 */ ".dfdgdfd." + /* 1 */ ".aaaeaaa." + /* 2 */ ".a.....a." + /* 3 */ ".a.....a." + /* 4 */ ".a.....a." + /* 5 */ ".aaaaaaa." + /* 6 */ "........." + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".afagafa." /* 2 */ ".f.....f." /* 3 */ ".f.....f." /* 4 */ ".f.....f." - /* 5 */ ".dffdffd." + /* 5 */ ".affaffa." /* 6 */ "........." - // Level 3 + // Level 4 /* z\x* 012345678 */ - /* 0 */ "bbbbbbbbb" - /* 1 */ "hdddddddh" - /* 2 */ ".d.i.i.d." - /* 3 */ ".d.....d." - /* 4 */ ".d..j..d." - /* 5 */ "kdddddddk" + /* 0 */ "ccccccccc" + /* 1 */ "haaaaaaah" + /* 2 */ ".a.i.i.a." + /* 3 */ ".a.....a." + /* 4 */ ".a..j..a." + /* 5 */ "kaaaaaaak" /* 6 */ "lllllllll" - // Level 4 + // Level 5 /* z\x* 012345678 */ /* 0 */ "........." - /* 1 */ "bbbbbbbbb" - /* 2 */ "hdddddddh" - /* 3 */ ".d.....d." - /* 4 */ "kdddddddk" + /* 1 */ "ccccccccc" + /* 2 */ "haaaaaaah" + /* 3 */ ".a.....a." + /* 4 */ "kaaaaaaak" /* 5 */ "lllllllll" /* 6 */ "........." - // Level 5 + // Level 6 /* z\x* 012345678 */ /* 0 */ "........." /* 1 */ "........." - /* 2 */ "bbbbbbbbb" - /* 3 */ "ddddddddd" + /* 2 */ "ccccccccc" + /* 3 */ "aaaaaaaaa" /* 4 */ "lllllllll" /* 5 */ "........." /* 6 */ ".........", // Connectors: - "-1: 4, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1151,18 +1258,18 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 10, ID 114, created by xoft { // Size: - 9, 7, 9, // SizeX = 9, SizeY = 7, SizeZ = 9 + 9, 8, 9, // SizeX = 9, SizeY = 8, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 8, 6, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 9, 7, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 64: 7\n" /* wooddoorblock */ "f:102: 0\n" /* glasspane */ "g: 64:12\n" /* wooddoorblock */ @@ -1176,90 +1283,102 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // Block data: // Level 0 /* z\x* 012345678 */ - /* 0 */ "...abc..." - /* 1 */ ".ddddddd." - /* 2 */ ".ddddddd." - /* 3 */ ".ddddddd." - /* 4 */ ".ddddddd." - /* 5 */ ".ddddddd." - /* 6 */ ".ddddddd." - /* 7 */ ".ddddddd." - /* 8 */ "........." + /* 0 */ "mmmaaammm" + /* 1 */ "maaaaaaam" + /* 2 */ "maaaaaaam" + /* 3 */ "maaaaaaam" + /* 4 */ "maaaaaaam" + /* 5 */ "maaaaaaam" + /* 6 */ "maaaaaaam" + /* 7 */ "maaaaaaam" + /* 8 */ "mmmmmmmmm" // Level 1 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ ".dddeddd." - /* 2 */ ".d.....d." - /* 3 */ ".d.....d." - /* 4 */ ".d.....d." - /* 5 */ ".d.....d." - /* 6 */ ".d.....d." - /* 7 */ ".ddddddd." + /* 0 */ "...bcd..." + /* 1 */ ".aaaaaaa." + /* 2 */ ".aaaaaaa." + /* 3 */ ".aaaaaaa." + /* 4 */ ".aaaaaaa." + /* 5 */ ".aaaaaaa." + /* 6 */ ".aaaaaaa." + /* 7 */ ".aaaaaaa." /* 8 */ "........." // Level 2 /* z\x* 012345678 */ /* 0 */ "........." - /* 1 */ ".dfdgdfd." + /* 1 */ ".aaaeaaa." + /* 2 */ ".a.....a." + /* 3 */ ".a.....a." + /* 4 */ ".a.....a." + /* 5 */ ".a.....a." + /* 6 */ ".a.....a." + /* 7 */ ".aaaaaaa." + /* 8 */ "........." + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "........." + /* 1 */ ".afagafa." /* 2 */ ".f.....f." /* 3 */ ".f.....f." - /* 4 */ ".d.....d." + /* 4 */ ".a.....a." /* 5 */ ".f.....f." /* 6 */ ".f.....f." - /* 7 */ ".dffdffd." + /* 7 */ ".affaffa." /* 8 */ "........." - // Level 3 + // Level 4 /* z\x* 012345678 */ - /* 0 */ "bbbbbbbbb" - /* 1 */ "hdddddddh" - /* 2 */ ".d.i.i.d." - /* 3 */ ".d.....d." - /* 4 */ ".d.....d." - /* 5 */ ".d.....d." - /* 6 */ ".d..j..d." - /* 7 */ "kdddddddk" + /* 0 */ "ccccccccc" + /* 1 */ "haaaaaaah" + /* 2 */ ".a.i.i.a." + /* 3 */ ".a.....a." + /* 4 */ ".a.....a." + /* 5 */ ".a.....a." + /* 6 */ ".a..j..a." + /* 7 */ "kaaaaaaak" /* 8 */ "lllllllll" - // Level 4 + // Level 5 /* z\x* 012345678 */ /* 0 */ "........." - /* 1 */ "bbbbbbbbb" - /* 2 */ "hdddddddh" - /* 3 */ ".d.....d." - /* 4 */ ".d.....d." - /* 5 */ ".d.....d." - /* 6 */ "kdddddddk" + /* 1 */ "ccccccccc" + /* 2 */ "haaaaaaah" + /* 3 */ ".a.....a." + /* 4 */ ".a.....a." + /* 5 */ ".a.....a." + /* 6 */ "kaaaaaaak" /* 7 */ "lllllllll" /* 8 */ "........." - // Level 5 + // Level 6 /* z\x* 012345678 */ /* 0 */ "........." /* 1 */ "........." - /* 2 */ "bbbbbbbbb" - /* 3 */ "hdddddddh" - /* 4 */ ".d.....d." - /* 5 */ "kdddddddk" + /* 2 */ "ccccccccc" + /* 3 */ "haaaaaaah" + /* 4 */ ".a.....a." + /* 5 */ "kaaaaaaak" /* 6 */ "lllllllll" /* 7 */ "........." /* 8 */ "........." - // Level 6 + // Level 7 /* z\x* 012345678 */ /* 0 */ "........." /* 1 */ "........." /* 2 */ "........." - /* 3 */ "bbbbbbbbb" - /* 4 */ "ddddddddd" + /* 3 */ "ccccccccc" + /* 4 */ "aaaaaaaaa" /* 5 */ "lllllllll" /* 6 */ "........." /* 7 */ "........." /* 8 */ ".........", // Connectors: - "-1: 4, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1290,147 +1409,164 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 14, ID 124, created by Aloe_vera { // Size: - 14, 7, 12, // SizeX = 14, SizeY = 7, SizeZ = 12 + 14, 8, 12, // SizeX = 14, SizeY = 8, SizeZ = 12 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 13, 6, 11, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 14, 7, 12, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e:128: 3\n" /* sandstonestairs */ - "f: 64: 7\n" /* wooddoorblock */ - "g:102: 0\n" /* glasspane */ - "h: 64:12\n" /* wooddoorblock */ - "i:128: 7\n" /* sandstonestairs */ - "j: 50: 3\n" /* torch */ - "k: 50: 2\n" /* torch */ - "l: 50: 4\n" /* torch */ + "f: 64: 3\n" /* wooddoorblock */ + "g: 64: 1\n" /* wooddoorblock */ + "h:102: 0\n" /* glasspane */ + "i: 64: 8\n" /* wooddoorblock */ + "j:128: 7\n" /* sandstonestairs */ + "k: 50: 3\n" /* torch */ + "l: 50: 2\n" /* torch */ "m: 19: 0\n" /* sponge */ - "n:128: 6\n" /* sandstonestairs */ - "o: 50: 1\n" /* torch */ - "p:128: 5\n" /* sandstonestairs */ - "q:128: 4\n" /* sandstonestairs */, + "n: 50: 4\n" /* torch */ + "o:128: 6\n" /* sandstonestairs */ + "p: 50: 1\n" /* torch */ + "q:128: 5\n" /* sandstonestairs */ + "r:128: 4\n" /* sandstonestairs */, // Block data: // Level 0 /* z\x* 1111 */ /* * 01234567890123 */ - /* 0 */ "....abc......." - /* 1 */ ".dddddddddddd." - /* 2 */ ".dddddddddddd." - /* 3 */ ".dddddddddddd." - /* 4 */ ".dddddddddddd." - /* 5 */ ".dddddddddddd." - /* 6 */ ".dddddddddddd." - /* 7 */ ".dddddddddddd." - /* 8 */ "....aeddddddd." - /* 9 */ "mmmmm.ddddddd." - /* 10 */ "mmmmm.ddddddd." - /* 11 */ "mmmmm........." + /* 0 */ "mmmmaaammmmmmm" + /* 1 */ "maaaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaaam" + /* 6 */ "maaaaaaaaaaaam" + /* 7 */ "maaaaaaaaaaaam" + /* 8 */ "mmmmaaaaaaaaam" + /* 9 */ "mmmmmmaaaaaaam" + /* 10 */ "mmmmmmaaaaaaam" + /* 11 */ "mmmmmmmmmmmmmm" // Level 1 /* z\x* 1111 */ /* * 01234567890123 */ - /* 0 */ ".............." - /* 1 */ ".ddddfddddddd." - /* 2 */ ".d..........d." - /* 3 */ ".d..........d." - /* 4 */ ".d..........d." - /* 5 */ ".d..........d." - /* 6 */ ".d..........d." - /* 7 */ ".ddddfd.....d." - /* 8 */ "......d.....d." - /* 9 */ "mmmmm.d.....d." - /* 10 */ "mmmmm.ddddddd." + /* 0 */ "....bcd......." + /* 1 */ ".aaaaaaaaaaaa." + /* 2 */ ".aaaaaaaaaaaa." + /* 3 */ ".aaaaaaaaaaaa." + /* 4 */ ".aaaaaaaaaaaa." + /* 5 */ ".aaaaaaaaaaaa." + /* 6 */ ".aaaaaaaaaaaa." + /* 7 */ ".aaaaaaaaaaaa." + /* 8 */ "....beaaaaaaa." + /* 9 */ "mmmmm.aaaaaaa." + /* 10 */ "mmmmm.aaaaaaa." /* 11 */ "mmmmm........." // Level 2 /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ ".............." - /* 1 */ ".dggdhdggdggd." - /* 2 */ ".g..........g." - /* 3 */ ".g..........g." - /* 4 */ ".d..........d." - /* 5 */ ".g..........g." - /* 6 */ ".g..........g." - /* 7 */ ".dggdhd.....d." - /* 8 */ "......g.....g." - /* 9 */ "mmmmm.g.....g." - /* 10 */ "mmmmm.dggdggd." + /* 1 */ ".aaaafaaaaaaa." + /* 2 */ ".a..........a." + /* 3 */ ".a..........a." + /* 4 */ ".a..........a." + /* 5 */ ".a..........a." + /* 6 */ ".a..........a." + /* 7 */ ".aaaaga.....a." + /* 8 */ "......a.....a." + /* 9 */ "mmmmm.a.....a." + /* 10 */ "mmmmm.aaaaaaa." /* 11 */ "mmmmm........." // Level 3 /* z\x* 1111 */ /* * 01234567890123 */ - /* 0 */ "bbbbbbbbbbbbbb" - /* 1 */ "iddddddddddddc" - /* 2 */ ".d..j.j.....dc" - /* 3 */ ".d..........dc" - /* 4 */ ".d.........kdc" - /* 5 */ ".d..........dc" - /* 6 */ ".d..l.l.....dc" - /* 7 */ "nddddddo...kdc" - /* 8 */ "eeeeead.....dc" - /* 9 */ "mmmmmad.....dc" - /* 10 */ "mmmmmadddddddc" - /* 11 */ "mmmmmap.....qc" + /* 0 */ ".............." + /* 1 */ ".ahhaiahhahha." + /* 2 */ ".h..........h." + /* 3 */ ".h..........h." + /* 4 */ ".a..........a." + /* 5 */ ".h..........h." + /* 6 */ ".h..........h." + /* 7 */ ".ahhaia.....a." + /* 8 */ "......h.....h." + /* 9 */ "mmmmm.h.....h." + /* 10 */ "mmmmm.ahhahha." + /* 11 */ "mmmmm........." // Level 4 /* z\x* 1111 */ /* * 01234567890123 */ - /* 0 */ ".............." - /* 1 */ "bbbbbbbbbbbbc." - /* 2 */ "idddddddddddc." - /* 3 */ ".d.........dc." - /* 4 */ ".d.........dc." - /* 5 */ ".d.........dc." - /* 6 */ "nddddddd...dc." - /* 7 */ "eeeeeead...dc." - /* 8 */ "......ad...dc." - /* 9 */ "mmmmm.ad...dc." - /* 10 */ "mmmmm.adddddc." - /* 11 */ "mmmmm.ap...qc." + /* 0 */ "cccccccccccccc" + /* 1 */ "jaaaaaaaaaaaad" + /* 2 */ ".a..k.k.....ad" + /* 3 */ ".a..........ad" + /* 4 */ ".a.........lad" + /* 5 */ ".a..........ad" + /* 6 */ ".a..n.n.....ad" + /* 7 */ "oaaaaaap...lad" + /* 8 */ "eeeeeba.....ad" + /* 9 */ "mmmmmba.....ad" + /* 10 */ "mmmmmbaaaaaaad" + /* 11 */ "mmmmmbq.....rd" // Level 5 /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ ".............." - /* 1 */ ".............." - /* 2 */ "bbbbbbbbbbbb.." - /* 3 */ "iddddddddddc.." - /* 4 */ ".d........dc.." - /* 5 */ "ndddddddd.dc.." - /* 6 */ "eeeeeeeed.dc.." - /* 7 */ ".......ad.dc.." - /* 8 */ ".......ad.dc.." - /* 9 */ "mmmmm..ad.dc.." - /* 10 */ "mmmmm..adddc.." - /* 11 */ "mmmmm..ap.qc.." + /* 1 */ "ccccccccccccd." + /* 2 */ "jaaaaaaaaaaad." + /* 3 */ ".a.........ad." + /* 4 */ ".a.........ad." + /* 5 */ ".a.........ad." + /* 6 */ "oaaaaaaa...ad." + /* 7 */ "eeeeeeba...ad." + /* 8 */ "......ba...ad." + /* 9 */ "mmmmm.ba...ad." + /* 10 */ "mmmmm.baaaaad." + /* 11 */ "mmmmm.bq...rd." // Level 6 /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ ".............." /* 1 */ ".............." + /* 2 */ "cccccccccccc.." + /* 3 */ "jaaaaaaaaaad.." + /* 4 */ ".a........ad.." + /* 5 */ "oaaaaaaaa.ad.." + /* 6 */ "eeeeeeeea.ad.." + /* 7 */ ".......ba.ad.." + /* 8 */ ".......ba.ad.." + /* 9 */ "mmmmm..ba.ad.." + /* 10 */ "mmmmm..baaad.." + /* 11 */ "mmmmm..bq.rd.." + + // Level 7 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".............." /* 2 */ ".............." - /* 3 */ "bbbbbbbbbbb..." - /* 4 */ "ddddddddddc..." - /* 5 */ "eeeeeeeeadc..." - /* 6 */ "........adc..." - /* 7 */ "........adc..." - /* 8 */ "........adc..." - /* 9 */ "mmmmm...adc..." - /* 10 */ "mmmmm...adc..." - /* 11 */ "mmmmm...adc...", + /* 3 */ "ccccccccccc..." + /* 4 */ "aaaaaaaaaad..." + /* 5 */ "eeeeeeeebad..." + /* 6 */ "........bad..." + /* 7 */ "........bad..." + /* 8 */ "........bad..." + /* 9 */ "mmmmm...bad..." + /* 10 */ "mmmmm...bad..." + /* 11 */ "mmmmm...bad...", // Connectors: - "-1: 5, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1461,18 +1597,18 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 7, ID 82, created by Aloe_vera { // Size: - 14, 6, 12, // SizeX = 14, SizeY = 6, SizeZ = 12 + 14, 7, 12, // SizeX = 14, SizeY = 7, SizeZ = 12 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 13, 5, 11, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 14, 6, 12, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e:128: 3\n" /* sandstonestairs */ "f: 64: 7\n" /* wooddoorblock */ "g: 64: 5\n" /* wooddoorblock */ @@ -1491,101 +1627,117 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // Level 0 /* z\x* 1111 */ /* * 01234567890123 */ - /* 0 */ ".......abc...." - /* 1 */ ".dddddddddddd." - /* 2 */ ".dddddddddddd." - /* 3 */ ".dddddddddddd." - /* 4 */ ".dddddddddddd." - /* 5 */ ".dddddddddddd." - /* 6 */ "....aec.ddddd." - /* 7 */ "mmmmmmm.ddddd." - /* 8 */ "mmmmmmm.ddddd." - /* 9 */ "mmmmmmm.ddddd." - /* 10 */ "mmmmmmm.ddddd." - /* 11 */ "mmmmmmm......." + /* 0 */ "mmmmmmmaaammmm" + /* 1 */ "maaaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaaam" + /* 6 */ "mmmmaaamaaaaam" + /* 7 */ "mmmmmmmmaaaaam" + /* 8 */ "mmmmmmmmaaaaam" + /* 9 */ "mmmmmmmmaaaaam" + /* 10 */ "mmmmmmmmaaaaam" + /* 11 */ "mmmmmmmmmmmmmm" // Level 1 /* z\x* 1111 */ /* * 01234567890123 */ - /* 0 */ ".............." - /* 1 */ ".dddddddfdddd." - /* 2 */ ".d..........d." - /* 3 */ ".d..........d." - /* 4 */ ".d..........d." - /* 5 */ ".ddddgddd...d." - /* 6 */ "........d...d." - /* 7 */ "mmmmmmm.d...d." - /* 8 */ "mmmmmmm.d...d." - /* 9 */ "mmmmmmm.d...d." - /* 10 */ "mmmmmmm.ddddd." - /* 11 */ "mmmmmmm......." + /* 0 */ ".......bcd...." + /* 1 */ ".aaaaaaaaaaaa." + /* 2 */ ".aaaaaaaaaaaa." + /* 3 */ ".aaaaaaaaaaaa." + /* 4 */ ".aaaaaaaaaaaa." + /* 5 */ ".aaaaaaaaaaaa." + /* 6 */ "....bed.aaaaa." + /* 7 */ "........aaaaa." + /* 8 */ "........aaaaa." + /* 9 */ "........aaaaa." + /* 10 */ "........aaaaa." + /* 11 */ ".............." // Level 2 /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ ".............." - /* 1 */ ".dhhdhhdidhhd." + /* 1 */ ".aaaaaaafaaaa." + /* 2 */ ".a..........a." + /* 3 */ ".a..........a." + /* 4 */ ".a..........a." + /* 5 */ ".aaaagaaa...a." + /* 6 */ "........a...a." + /* 7 */ "........a...a." + /* 8 */ "........a...a." + /* 9 */ "........a...a." + /* 10 */ "........aaaaa." + /* 11 */ ".............." + + // Level 3 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".ahhahhaiahha." /* 2 */ ".h..........h." /* 3 */ ".h..........h." - /* 4 */ ".h..........d." - /* 5 */ ".dhhdidhh...h." + /* 4 */ ".h..........a." + /* 5 */ ".ahhaiahh...h." /* 6 */ "........h...h." - /* 7 */ "mmmmmmm.d...d." - /* 8 */ "mmmmmmm.h...h." - /* 9 */ "mmmmmmm.h...h." - /* 10 */ "mmmmmmm.dhhhd." - /* 11 */ "mmmmmmm......." + /* 7 */ "........a...a." + /* 8 */ "........h...h." + /* 9 */ "........h...h." + /* 10 */ "........ahhha." + /* 11 */ ".............." - // Level 3 + // Level 4 /* z\x* 1111 */ /* * 01234567890123 */ - /* 0 */ "bbbbbbbbbbbbbb" - /* 1 */ "jddddddddddddc" - /* 2 */ ".d.....k.k..dc" - /* 3 */ ".d..........dc" - /* 4 */ ".d..l.l.....dc" - /* 5 */ "ndddddddd...dc" - /* 6 */ "eeeeeeead...dc" - /* 7 */ "mmmmmmmad...dc" - /* 8 */ "mmmmmmmad...dc" - /* 9 */ "mmmmmmmad...dc" - /* 10 */ "mmmmmmmadddddc" - /* 11 */ "mmmmmmmao...pc" + /* 0 */ "cccccccccccccc" + /* 1 */ "jaaaaaaaaaaaad" + /* 2 */ ".a.....k.k..ad" + /* 3 */ ".a..........ad" + /* 4 */ ".a..l.l.....ad" + /* 5 */ "naaaaaaaa...ad" + /* 6 */ "eeeeeeeba...ad" + /* 7 */ ".......ba...ad" + /* 8 */ ".......ba...ad" + /* 9 */ ".......ba...ad" + /* 10 */ ".......baaaaad" + /* 11 */ ".......bo...pd" - // Level 4 + // Level 5 /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ ".............." - /* 1 */ "bbbbbbbbbbbbb." - /* 2 */ "jdddddddddddc." - /* 3 */ ".dq........dc." - /* 4 */ "nddddddddd.dc." - /* 5 */ "eeeeeeeead.dc." - /* 6 */ "........ad.dc." - /* 7 */ "mmmmmmm.ad.dc." - /* 8 */ "mmmmmmm.ad.dc." - /* 9 */ "mmmmmmm.adldc." - /* 10 */ "mmmmmmm.adddc." - /* 11 */ "mmmmmmm.ao.pc." + /* 1 */ "ccccccccccccc." + /* 2 */ "jaaaaaaaaaaad." + /* 3 */ ".aq........ad." + /* 4 */ "naaaaaaaaa.ad." + /* 5 */ "eeeeeeeeba.ad." + /* 6 */ "........ba.ad." + /* 7 */ "........ba.ad." + /* 8 */ "........ba.ad." + /* 9 */ "........balad." + /* 10 */ "........baaad." + /* 11 */ "........bo.pd." - // Level 5 + // Level 6 /* z\x* 1111 */ /* * 01234567890123 */ /* 0 */ ".............." /* 1 */ ".............." - /* 2 */ "bbbbbbbbbbbb.." - /* 3 */ "dddddddddddc.." - /* 4 */ "eeeeeeeeeadc.." - /* 5 */ ".........adc.." - /* 6 */ ".........adc.." - /* 7 */ "mmmmmmm..adc.." - /* 8 */ "mmmmmmm..adc.." - /* 9 */ "mmmmmmm..adc.." - /* 10 */ "mmmmmmm..adc.." - /* 11 */ "mmmmmmm..adc..", + /* 2 */ "cccccccccccc.." + /* 3 */ "aaaaaaaaaaad.." + /* 4 */ "eeeeeeeeebad.." + /* 5 */ ".........bad.." + /* 6 */ ".........bad.." + /* 7 */ ".........bad.." + /* 8 */ ".........bad.." + /* 9 */ ".........bad.." + /* 10 */ ".........bad.." + /* 11 */ ".........bad..", // Connectors: - "-1: 8, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 8, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1616,11 +1768,11 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 17, ID 127, created by Aloe_vera { // Size: - 10, 2, 7, // SizeX = 10, SizeY = 2, SizeZ = 7 + 10, 3, 7, // SizeX = 10, SizeY = 3, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 9, 1, 6, // MaxX, MaxY, MaxZ + 0, 0, -1, // MinX, MinY, MinZ + 10, 2, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1636,6 +1788,17 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* z\x* */ /* * 0123456789 */ /* 0 */ "aaaaaaaaaa" + /* 1 */ "aaaaaaaaaa" + /* 2 */ "aaaaaaaaaa" + /* 3 */ "aaaaaaaaaa" + /* 4 */ "aaaaaaaaaa" + /* 5 */ "aaaaaaaaaa" + /* 6 */ "aaaaaaaaaa" + + // Level 1 + /* z\x* */ + /* * 0123456789 */ + /* 0 */ "aaaaaaaaaa" /* 1 */ "abbbbbbbba" /* 2 */ "abbbbbbbba" /* 3 */ "acccccccca" @@ -1643,7 +1806,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 5 */ "abbbbbbbba" /* 6 */ "aaaaaaaaaa" - // Level 1 + // Level 2 /* z\x* */ /* * 0123456789 */ /* 0 */ "d........d" @@ -1655,7 +1818,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 6 */ "d........d", // Connectors: - "-1: 0, 0, 3: 4\n" /* Type -1, direction X- */, + "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1686,11 +1849,11 @@ const cPrefab::sDef g_SandVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 4, ID 68, created by tonibm1999 { // Size: - 5, 5, 6, // SizeX = 5, SizeY = 5, SizeZ = 6 + 5, 6, 6, // SizeX = 5, SizeY = 6, SizeZ = 6 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 4, 4, 5, // MaxX, MaxY, MaxZ + -1, 0, -1, // MinX, MinY, MinZ + 5, 5, 5, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1712,10 +1875,19 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 2 */ "aaaaa" /* 3 */ "aaaaa" /* 4 */ "aaaaa" - /* 5 */ "..b.." + /* 5 */ "mmamm" // Level 1 /* z\x* 01234 */ + /* 0 */ "aaaaa" + /* 1 */ "aaaaa" + /* 2 */ "aaaaa" + /* 3 */ "aaaaa" + /* 4 */ "aaaaa" + /* 5 */ "..b.." + + // Level 2 + /* z\x* 01234 */ /* 0 */ "accca" /* 1 */ "cdedc" /* 2 */ "c.f.c" @@ -1723,7 +1895,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 4 */ "acgca" /* 5 */ "....." - // Level 2 + // Level 3 /* z\x* 01234 */ /* 0 */ "ac.ca" /* 1 */ "c...c" @@ -1732,7 +1904,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 4 */ "achca" /* 5 */ "....." - // Level 3 + // Level 4 /* z\x* 01234 */ /* 0 */ "accca" /* 1 */ "c...c" @@ -1741,7 +1913,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 4 */ "accca" /* 5 */ "....." - // Level 4 + // Level 5 /* z\x* 01234 */ /* 0 */ ".aaa." /* 1 */ "aaaaa" @@ -1751,7 +1923,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = /* 5 */ ".....", // Connectors: - "-1: 2, 0, 5: 3\n" /* Type -1, direction Z+ */, + "-1: 2, 1, 5: 3\n" /* Type -1, direction Z+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1800,15 +1972,17 @@ const cPrefab::sDef g_SandVillageStartingPrefabs[] = "b: 24: 0\n" /* sandstone */ "c: 8: 0\n" /* water */ "d: 12: 0\n" /* sand */ - "e:118: 3\n" /* cauldronblock */ - "f: 85: 0\n" /* fence */ - "g:128: 2\n" /* sandstonestairs */ - "h:128: 7\n" /* sandstonestairs */ - "i:128: 4\n" /* sandstonestairs */ - "j:128: 5\n" /* sandstonestairs */ - "k:128: 6\n" /* sandstonestairs */ - "l:128: 3\n" /* sandstonestairs */ - "m: 19: 0\n" /* sponge */, + "e: 4: 0\n" /* cobblestone */ + "f: 13: 0\n" /* gravel */ + "g:118: 3\n" /* cauldronblock */ + "h: 85: 0\n" /* fence */ + "i:128: 2\n" /* sandstonestairs */ + "j:128: 7\n" /* sandstonestairs */ + "k:128: 4\n" /* sandstonestairs */ + "l:128: 5\n" /* sandstonestairs */ + "m: 19: 0\n" /* sponge */ + "n:128: 6\n" /* sandstonestairs */ + "o:128: 3\n" /* sandstonestairs */, // Block data: // Level 0 @@ -1873,30 +2047,30 @@ const cPrefab::sDef g_SandVillageStartingPrefabs[] = // Level 6 /* z\x* 0123456 */ - /* 0 */ "ddddddd" + /* 0 */ "ddeeedd" /* 1 */ "dbbbbbd" - /* 2 */ "dbcccbd" - /* 3 */ "dbcccbd" - /* 4 */ "dbcccbd" + /* 2 */ "ebcccbe" + /* 3 */ "ebcccbe" + /* 4 */ "ebcccbe" /* 5 */ "dbbbbbd" - /* 6 */ "ddddddd" + /* 6 */ "ddeeedd" // Level 7 /* z\x* 0123456 */ - /* 0 */ "ddbbbdd" + /* 0 */ "ddfffdd" /* 1 */ "dbbbbbd" - /* 2 */ "bbcccbb" - /* 3 */ "bbcccbb" - /* 4 */ "bbcccbb" + /* 2 */ "fbcccbf" + /* 3 */ "fbcccbf" + /* 4 */ "fbcccbf" /* 5 */ "dbbbbbd" - /* 6 */ "ddbbbdd" + /* 6 */ "ddfffdd" // Level 8 /* z\x* 0123456 */ /* 0 */ "......." /* 1 */ ".bbbbb." /* 2 */ ".b...b." - /* 3 */ ".b.e.b." + /* 3 */ ".b.g.b." /* 4 */ ".b...b." /* 5 */ ".bbbbb." /* 6 */ "......." @@ -1904,50 +2078,50 @@ const cPrefab::sDef g_SandVillageStartingPrefabs[] = // Level 9 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".f...f." + /* 1 */ ".h...h." /* 2 */ "......." - /* 3 */ "...f..." + /* 3 */ "...h..." /* 4 */ "......." - /* 5 */ ".f...f." + /* 5 */ ".h...h." /* 6 */ "......." // Level 10 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".f...f." + /* 1 */ ".h...h." /* 2 */ "......." - /* 3 */ "...f..." + /* 3 */ "...h..." /* 4 */ "......." - /* 5 */ ".f...f." + /* 5 */ ".h...h." /* 6 */ "......." // Level 11 /* z\x* 0123456 */ - /* 0 */ "ggggggg" - /* 1 */ "hbhhhbh" - /* 2 */ ".i...j." - /* 3 */ ".i.f.j." - /* 4 */ ".i...j." - /* 5 */ "kbkkkbk" - /* 6 */ "lllllll" + /* 0 */ "iiiiiii" + /* 1 */ "jbjjjbj" + /* 2 */ ".k...l." + /* 3 */ ".k.h.l." + /* 4 */ ".k...l." + /* 5 */ "nbnnnbn" + /* 6 */ "ooooooo" // Level 12 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ "ggggggg" - /* 2 */ "hb...bh" - /* 3 */ ".b.f.b." - /* 4 */ "kb...bk" - /* 5 */ "lllllll" + /* 1 */ "iiiiiii" + /* 2 */ "jb...bj" + /* 3 */ ".b.h.b." + /* 4 */ "nb...bn" + /* 5 */ "ooooooo" /* 6 */ "......." // Level 13 /* z\x* 0123456 */ /* 0 */ "......." /* 1 */ "......." - /* 2 */ "ggggggg" + /* 2 */ "iiiiiii" /* 3 */ "bbbbbbb" - /* 4 */ "lllllll" + /* 4 */ "ooooooo" /* 5 */ "......." /* 6 */ ".......", diff --git a/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp index 39748a223..691d8aa9d 100644 --- a/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp +++ b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp @@ -366,7 +366,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = true, // DefaultWeight: - 100, + 200, // DepthWeight: "", -- cgit v1.2.3 From 0e8c4ca5ab14c1f0b8f3bf8c1f4d96e3109860d9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 21 Jun 2014 15:02:40 +0200 Subject: Updated prefabs to the latest Gallery content. --- src/Generating/Prefabs/AlchemistVillagePrefabs.cpp | 3698 +++++++++++--------- src/Generating/Prefabs/JapaneseVillagePrefabs.cpp | 384 +- src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 431 +-- .../Prefabs/SandFlatRoofVillagePrefabs.cpp | 180 +- 4 files changed, 2644 insertions(+), 2049 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp index eb0d30fdf..5cb864d53 100644 --- a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp +++ b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp @@ -28,170 +28,172 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // Block definitions: ".: 0: 0\n" /* air */ - "A:171: 8\n" /* carpet */ - "B:101: 0\n" /* ironbars */ - "C: 64:12\n" /* wooddoorblock */ - "D:128: 2\n" /* sandstonestairs */ - "E: 24: 1\n" /* sandstone */ - "F: 44: 9\n" /* step */ - "G:126: 8\n" /* woodenslab */ - "H:128: 7\n" /* sandstonestairs */ - "I: 44: 1\n" /* step */ - "J: 64: 7\n" /* wooddoorblock */ - "K:128: 6\n" /* sandstonestairs */ - "a: 1: 0\n" /* stone */ - "b: 24: 0\n" /* sandstone */ - "c: 12: 0\n" /* sand */ - "d:134: 4\n" /* 134 */ - "e: 5: 1\n" /* wood */ - "f:134: 5\n" /* 134 */ - "g: 65: 5\n" /* ladder */ - "h: 17: 3\n" /* tree */ - "i: 69:11\n" /* lever */ - "j:134: 0\n" /* 134 */ - "k:134: 1\n" /* 134 */ - "l: 50: 4\n" /* torch */ + "A: 65: 3\n" /* ladder */ + "B: 50: 3\n" /* torch */ + "C:171: 8\n" /* carpet */ + "D:101: 0\n" /* ironbars */ + "E: 64: 8\n" /* wooddoorblock */ + "F:128: 2\n" /* sandstonestairs */ + "G: 24: 1\n" /* sandstone */ + "H: 44: 9\n" /* step */ + "I:126: 8\n" /* woodenslab */ + "J:128: 7\n" /* sandstonestairs */ + "K: 44: 1\n" /* step */ + "L: 64: 3\n" /* wooddoorblock */ + "M:128: 6\n" /* sandstonestairs */ + "a: 24: 2\n" /* sandstone */ + "b: 1: 0\n" /* stone */ + "c: 24: 0\n" /* sandstone */ + "d: 12: 0\n" /* sand */ + "e:134: 4\n" /* 134 */ + "f: 5: 1\n" /* wood */ + "g:134: 5\n" /* 134 */ + "h: 65: 5\n" /* ladder */ + "i: 17: 3\n" /* tree */ + "j: 69:11\n" /* lever */ + "k: 4: 0\n" /* cobblestone */ + "l:134: 0\n" /* 134 */ "m: 19: 0\n" /* sponge */ - "n: 5: 0\n" /* wood */ - "o: 96:12\n" /* trapdoor */ - "p: 24: 2\n" /* sandstone */ - "q:128: 5\n" /* sandstonestairs */ - "r:107: 6\n" /* fencegate */ - "s:128: 4\n" /* sandstonestairs */ - "t:134: 3\n" /* 134 */ - "u: 85: 0\n" /* fence */ - "v:134: 7\n" /* 134 */ - "w:107: 5\n" /* fencegate */ - "x: 64: 5\n" /* wooddoorblock */ - "y: 65: 3\n" /* ladder */ - "z: 50: 3\n" /* torch */, + "n:134: 1\n" /* 134 */ + "o: 50: 4\n" /* torch */ + "p: 13: 0\n" /* gravel */ + "q: 5: 0\n" /* wood */ + "r: 96:12\n" /* trapdoor */ + "s:128: 5\n" /* sandstonestairs */ + "t:107: 0\n" /* fencegate */ + "u:128: 4\n" /* sandstonestairs */ + "v:134: 3\n" /* 134 */ + "w: 85: 0\n" /* fence */ + "x:134: 7\n" /* 134 */ + "y:107: 5\n" /* fencegate */ + "z: 64: 1\n" /* wooddoorblock */, // Block data: // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "aaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaa" - /* 2 */ "aabbbbbbbaa" - /* 3 */ "aabbbbbbbaa" - /* 4 */ "aabbbbbbbaa" - /* 5 */ "aabbbbbbbaa" - /* 6 */ "aabbbbbbbaa" - /* 7 */ "aabbbbbbbaa" - /* 8 */ "aaaaaaaaaaa" - /* 9 */ "aaaaaaaaaaa" + /* 0 */ "mmmabbbammm" + /* 1 */ "mcccccccccm" + /* 2 */ "abcccccccba" + /* 3 */ "cbcccccccbc" + /* 4 */ "cbcccccccbc" + /* 5 */ "cbcccccccbc" + /* 6 */ "cbcccccccbc" + /* 7 */ "cbcccccccbc" + /* 8 */ "abbbbbbbbba" + /* 9 */ "mmmmmmmmmmm" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "ccccccccccc" - /* 1 */ "cbbbbbbbbbc" - /* 2 */ "cbdef.defbc" - /* 3 */ "cbdef.defbc" - /* 4 */ "cbdef.defbc" - /* 5 */ "cb.......bc" - /* 6 */ "cb.......bc" - /* 7 */ "cbg......bc" - /* 8 */ "cbbbbbbbbbc" - /* 9 */ "ccccccccccc" + /* 0 */ "mmmadddammm" + /* 1 */ "mcccccccccm" + /* 2 */ "acefg.efgca" + /* 3 */ "ccefg.efgcc" + /* 4 */ "ccefg.efgcc" + /* 5 */ "cc.......cc" + /* 6 */ "cc.......cc" + /* 7 */ "cch......cc" + /* 8 */ "accccccccca" + /* 9 */ "mmmmmmmmmmm" // Level 2 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "ccccccccccc" - /* 1 */ "cbbbbbbbbbc" - /* 2 */ "cbeee.eeebc" - /* 3 */ "cbeee.eeebc" - /* 4 */ "cbehe.ehebc" - /* 5 */ "cb.i...i.bc" - /* 6 */ "cb.......bc" - /* 7 */ "cbg......bc" - /* 8 */ "cbbbbbbbbbc" - /* 9 */ "ccccccccccc" + /* 0 */ "mmmadddammm" + /* 1 */ "mcccccccccm" + /* 2 */ "acfff.fffca" + /* 3 */ "ccfff.fffcc" + /* 4 */ "ccfif.fifcc" + /* 5 */ "cc.j...j.cc" + /* 6 */ "cc.......cc" + /* 7 */ "cch......cc" + /* 8 */ "accccccccca" + /* 9 */ "mmmmmmmmmmm" // Level 3 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "ccccccccccc" - /* 1 */ "cbbbbbbbbbc" - /* 2 */ "cbjek.jekbc" - /* 3 */ "cbjek.jekbc" - /* 4 */ "cbjek.jekbc" - /* 5 */ "cb.......bc" - /* 6 */ "cb.......bc" - /* 7 */ "cbg..l...bc" - /* 8 */ "cbbbbbbbbbc" - /* 9 */ "ccccccccccc" + /* 0 */ "mmmakkkammm" + /* 1 */ "mcccccccccm" + /* 2 */ "aclfn.lfnca" + /* 3 */ "cclfn.lfncc" + /* 4 */ "cclfn.lfncc" + /* 5 */ "cc.......cc" + /* 6 */ "cc.......cc" + /* 7 */ "cch..o...cc" + /* 8 */ "accccccccca" + /* 9 */ "mmmmmmmmmmm" // Level 4 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "ccccccccccc" - /* 1 */ "ccccccccccc" - /* 2 */ "ccnnnnnnncc" - /* 3 */ "cnnnnnnnnnc" - /* 4 */ "cnnnnnnnnnc" - /* 5 */ "cnnnnnnnnnc" - /* 6 */ "cnnnnnnnnnc" - /* 7 */ "cnonnnnnnnc" - /* 8 */ "cnccccccccc" - /* 9 */ "ccccccccccc" + /* 0 */ "mmmapppammm" + /* 1 */ "mmmmpppmmmm" + /* 2 */ "acccqqqccca" + /* 3 */ "cqqqqqqqqqc" + /* 4 */ "cqqqqqqqqqc" + /* 5 */ "cqqqqqqqqqc" + /* 6 */ "cqqqqqqqqqc" + /* 7 */ "cqrqqqqqqqc" + /* 8 */ "aqcccccccca" + /* 9 */ "mmmmmmmmmmm" // Level 5 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "...p...p..." - /* 1 */ "..........." - /* 2 */ "pbbbqrsbbbp" - /* 3 */ "bkt.....ttb" - /* 4 */ "bku.....ujb" - /* 5 */ "b.........b" - /* 6 */ "bfvvd.....b" - /* 7 */ "b...w..kujb" - /* 8 */ "pxbbbbbbbbp" - /* 9 */ "..y........" + /* 0 */ "mmma...ammm" + /* 1 */ "mmm.....mmm" + /* 2 */ "acccstuccca" + /* 3 */ "cnv.....vvc" + /* 4 */ "cnw.....wlc" + /* 5 */ "c.........c" + /* 6 */ "cgxxe.....c" + /* 7 */ "c...y..nwlc" + /* 8 */ "azcccccccca" + /* 9 */ "mmAmmmmmmmm" // Level 6 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "...p...p..." - /* 1 */ "..........." - /* 2 */ "pbbb...bbbp" - /* 3 */ "b..z...z..b" - /* 4 */ "b.A.....A.b" - /* 5 */ "B.........B" - /* 6 */ "b.........b" - /* 7 */ "b.......A.b" - /* 8 */ "pCbbBBBbbbp" - /* 9 */ "..y........" + /* 0 */ "mmma...ammm" + /* 1 */ "mmm.....mmm" + /* 2 */ "accc...ccca" + /* 3 */ "c..B...B..c" + /* 4 */ "c.C.....C.c" + /* 5 */ "D.........D" + /* 6 */ "c.........c" + /* 7 */ "c.......C.c" + /* 8 */ "aEccDDDccca" + /* 9 */ "mmAmmmmmmmm" // Level 7 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "...D...D..." - /* 1 */ "...E...b..." - /* 2 */ "pbbbqFsbbbp" - /* 3 */ "bGGGGGGGGGb" - /* 4 */ "bGGGGGGGGGb" - /* 5 */ "sGGGGGGGGGq" - /* 6 */ "bGGGGGGGGGb" - /* 7 */ "bGGGGGGGGGb" - /* 8 */ "pbbbHHHbbbp" - /* 9 */ "..y........" + /* 0 */ "mmmF...Fmmm" + /* 1 */ "mmmG...cmmm" + /* 2 */ "acccsHuccca" + /* 3 */ "cIIIIIIIIIc" + /* 4 */ "cIIIIIIIIIc" + /* 5 */ "uIIIIIIIIIs" + /* 6 */ "cIIIIIIIIIc" + /* 7 */ "cIIIIIIIIIc" + /* 8 */ "acccJJJccca" + /* 9 */ "mmAmmmmmmmm" // Level 8 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ "..........." - /* 2 */ "bIIIIbIIIIb" - /* 3 */ "IpbbbbbbbpI" - /* 4 */ "Ib.......bI" - /* 5 */ "bb.......bb" - /* 6 */ "Ib.......bI" - /* 7 */ "IpJbbbbbbpI" - /* 8 */ "bI.IIbIIIIb" - /* 9 */ "..........." + /* 0 */ "mmm.....mmm" + /* 1 */ "mmm.....mmm" + /* 2 */ "cKKKKcKKKKc" + /* 3 */ "KacccccccaK" + /* 4 */ "Kc.......cK" + /* 5 */ "cc.......cc" + /* 6 */ "Kc.......cK" + /* 7 */ "KaLccccccaK" + /* 8 */ "cK.KKcKKKKc" + /* 9 */ "mmmmmmmmmmm" // Level 9 /* z\x* 1 */ @@ -199,11 +201,11 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ ".pbbBBBbbp." - /* 4 */ ".b.......b." - /* 5 */ ".B.......B." - /* 6 */ ".b.......b." - /* 7 */ ".pCbBBBbbp." + /* 3 */ ".accDDDcca." + /* 4 */ ".c.......c." + /* 5 */ ".D.......D." + /* 6 */ ".c.......c." + /* 7 */ ".aEcDDDcca." /* 8 */ "..........." /* 9 */ "..........." @@ -213,11 +215,11 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ ".pbbKKKbbp." - /* 4 */ ".bGGGGGGGb." - /* 5 */ ".sGGGGGGGq." - /* 6 */ ".bGGGGGGGb." - /* 7 */ ".pbbHHHbbp." + /* 3 */ ".accMMMcca." + /* 4 */ ".cIIIIIIIc." + /* 5 */ ".uIIIIIIIs." + /* 6 */ ".cIIIIIIIc." + /* 7 */ ".accJJJcca." /* 8 */ "..........." /* 9 */ "..........." @@ -227,11 +229,11 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ ".bIIIbIIIb." - /* 4 */ ".I.......I." - /* 5 */ ".b.......b." - /* 6 */ ".I.......I." - /* 7 */ ".bIIIbIIIb." + /* 3 */ ".cKKKcKKKc." + /* 4 */ ".K.......K." + /* 5 */ ".c.......c." + /* 6 */ ".K.......K." + /* 7 */ ".cKKKcKKKc." /* 8 */ "..........." /* 9 */ "...........", @@ -267,161 +269,175 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 81, ID 597, created by STR_Warrior { // Size: - 11, 8, 10, // SizeX = 11, SizeY = 8, SizeZ = 10 + 11, 9, 10, // SizeX = 11, SizeY = 9, SizeZ = 10 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 11, 7, 10, // MaxX, MaxY, MaxZ + 11, 8, 10, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "A:128: 7\n" /* sandstonestairs */ - "B: 44: 1\n" /* step */ - "C: 64: 3\n" /* wooddoorblock */ - "D: 64: 8\n" /* wooddoorblock */ + "A:126: 8\n" /* woodenslab */ + "B:128: 7\n" /* sandstonestairs */ + "C: 44: 1\n" /* step */ + "D: 64: 3\n" /* wooddoorblock */ "E:128: 6\n" /* sandstonestairs */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c: 24: 2\n" /* sandstone */ - "d: 24: 0\n" /* sandstone */ - "e:128: 5\n" /* sandstonestairs */ - "f:107: 6\n" /* fencegate */ - "g:128: 4\n" /* sandstonestairs */ - "h:134: 1\n" /* 134 */ - "i:134: 3\n" /* 134 */ - "j: 85: 0\n" /* fence */ - "k:134: 0\n" /* 134 */ - "l:134: 5\n" /* 134 */ + "a: 24: 2\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ + "c: 24: 0\n" /* sandstone */ + "d: 13: 0\n" /* gravel */ + "e: 5: 0\n" /* wood */ + "f:128: 5\n" /* sandstonestairs */ + "g:107: 0\n" /* fencegate */ + "h:128: 4\n" /* sandstonestairs */ + "i:134: 1\n" /* 134 */ + "j:134: 3\n" /* 134 */ + "k: 85: 0\n" /* fence */ + "l:134: 0\n" /* 134 */ "m: 19: 0\n" /* sponge */ - "n:134: 7\n" /* 134 */ - "o:134: 4\n" /* 134 */ - "p:107: 5\n" /* fencegate */ - "q: 64: 5\n" /* wooddoorblock */ - "r: 65: 3\n" /* ladder */ - "s: 50: 3\n" /* torch */ - "t:171: 8\n" /* carpet */ - "u:101: 0\n" /* ironbars */ - "v: 64:12\n" /* wooddoorblock */ - "w:128: 2\n" /* sandstonestairs */ - "x: 24: 1\n" /* sandstone */ - "y: 44: 9\n" /* step */ - "z:126: 8\n" /* woodenslab */, + "n:134: 5\n" /* 134 */ + "o:134: 7\n" /* 134 */ + "p:134: 4\n" /* 134 */ + "q:107: 5\n" /* fencegate */ + "r: 64: 1\n" /* wooddoorblock */ + "s: 65: 3\n" /* ladder */ + "t: 50: 3\n" /* torch */ + "u:171: 8\n" /* carpet */ + "v:101: 0\n" /* ironbars */ + "w: 64: 8\n" /* wooddoorblock */ + "x:128: 2\n" /* sandstonestairs */ + "y: 24: 1\n" /* sandstone */ + "z: 44: 9\n" /* step */, // Block data: // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "aaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaa" - /* 2 */ "aaaabbbaaaa" - /* 3 */ "abbbbbbbbba" - /* 4 */ "abbbbbbbbba" - /* 5 */ "abbbbbbbbba" - /* 6 */ "abbbbbbbbba" - /* 7 */ "abbbbbbbbba" - /* 8 */ "abaaaaaaaaa" - /* 9 */ "aaaaaaaaaaa" + /* 0 */ "mmmabbbammm" + /* 1 */ "mmmmbbbmmmm" + /* 2 */ "accccccccca" + /* 3 */ "ccccccccccc" + /* 4 */ "ccccccccccc" + /* 5 */ "ccccccccccc" + /* 6 */ "ccccccccccc" + /* 7 */ "ccccccccccc" + /* 8 */ "accccccccca" + /* 9 */ "mmmmmmmmmmm" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "...c...c..." - /* 1 */ "..........." - /* 2 */ "cdddefgdddc" - /* 3 */ "dhi.....iid" - /* 4 */ "dhj.....jkd" - /* 5 */ "d.........d" - /* 6 */ "dlnno.....d" - /* 7 */ "d...p..hjkd" - /* 8 */ "cqddddddddc" - /* 9 */ "..r........" + /* 0 */ "mmmadddammm" + /* 1 */ "mmmmdddmmmm" + /* 2 */ "accceeeccca" + /* 3 */ "ceeeeeeeeec" + /* 4 */ "ceeeeeeeeec" + /* 5 */ "ceeeeeeeeec" + /* 6 */ "ceeeeeeeeec" + /* 7 */ "ceeeeeeeeec" + /* 8 */ "aecccccccca" + /* 9 */ "mmmmmmmmmmm" // Level 2 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "...c...c..." - /* 1 */ "..........." - /* 2 */ "cddd...dddc" - /* 3 */ "d..s...s..d" - /* 4 */ "d.t.....t.d" - /* 5 */ "u.........u" - /* 6 */ "d.........d" - /* 7 */ "d.......t.d" - /* 8 */ "cvdduuudddc" - /* 9 */ "..r........" + /* 0 */ "mmma...ammm" + /* 1 */ "mmm.....mmm" + /* 2 */ "acccfghccca" + /* 3 */ "cij.....jjc" + /* 4 */ "cik.....klc" + /* 5 */ "c.........c" + /* 6 */ "cnoop.....c" + /* 7 */ "c...q..iklc" + /* 8 */ "arcccccccca" + /* 9 */ "mmsmmmmmmmm" // Level 3 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "...w...w..." - /* 1 */ "...x...d..." - /* 2 */ "cdddeygdddc" - /* 3 */ "dzzzzzzzzzd" - /* 4 */ "dzzzzzzzzzd" - /* 5 */ "gzzzzzzzzze" - /* 6 */ "dzzzzzzzzzd" - /* 7 */ "dzzzzzzzzzd" - /* 8 */ "cdddAAAdddc" - /* 9 */ "..r........" + /* 0 */ "mmma...ammm" + /* 1 */ "mmm.....mmm" + /* 2 */ "accc...ccca" + /* 3 */ "c..t...t..c" + /* 4 */ "c.u.....u.c" + /* 5 */ "v.........v" + /* 6 */ "c.........c" + /* 7 */ "c.......u.c" + /* 8 */ "awccvvvccca" + /* 9 */ "mmsmmmmmmmm" // Level 4 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ "..........." - /* 2 */ "dBBBBdBBBBd" - /* 3 */ "BcdddddddcB" - /* 4 */ "Bd.......dB" - /* 5 */ "dd.......dd" - /* 6 */ "Bd.......dB" - /* 7 */ "BcCddddddcB" - /* 8 */ "dB.BBdBBBBd" - /* 9 */ "..........." + /* 0 */ "mmmx...xmmm" + /* 1 */ "mmmy...cmmm" + /* 2 */ "acccfzhccca" + /* 3 */ "cAAAAAAAAAc" + /* 4 */ "cAAAAAAAAAc" + /* 5 */ "hAAAAAAAAAf" + /* 6 */ "cAAAAAAAAAc" + /* 7 */ "cAAAAAAAAAc" + /* 8 */ "acccBBBccca" + /* 9 */ "mmsmmmmmmmm" // Level 5 /* z\x* 1 */ /* * 01234567890 */ + /* 0 */ "mmm.....mmm" + /* 1 */ "mmm.....mmm" + /* 2 */ "cCCCCcCCCCc" + /* 3 */ "CacccccccaC" + /* 4 */ "Cc.......cC" + /* 5 */ "cc.......cc" + /* 6 */ "Cc.......cC" + /* 7 */ "CaDccccccaC" + /* 8 */ "cC.CCcCCCCc" + /* 9 */ "mmmmmmmmmmm" + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ ".cdduuuddc." - /* 4 */ ".d.......d." - /* 5 */ ".u.......u." - /* 6 */ ".d.......d." - /* 7 */ ".cDduuuddc." + /* 3 */ ".accvvvcca." + /* 4 */ ".c.......c." + /* 5 */ ".v.......v." + /* 6 */ ".c.......c." + /* 7 */ ".awcvvvcca." /* 8 */ "..........." /* 9 */ "..........." - // Level 6 + // Level 7 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ ".cddEEEddc." - /* 4 */ ".dzzzzzzzd." - /* 5 */ ".gzzzzzzze." - /* 6 */ ".dzzzzzzzd." - /* 7 */ ".cddAAAddc." + /* 3 */ ".accEEEcca." + /* 4 */ ".cAAAAAAAc." + /* 5 */ ".hAAAAAAAf." + /* 6 */ ".cAAAAAAAc." + /* 7 */ ".accBBBcca." /* 8 */ "..........." /* 9 */ "..........." - // Level 7 + // Level 8 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." - /* 3 */ ".dBBBdBBBd." - /* 4 */ ".B.......B." - /* 5 */ ".d.......d." - /* 6 */ ".B.......B." - /* 7 */ ".dBBBdBBBd." + /* 3 */ ".cCCCcCCCc." + /* 4 */ ".C.......C." + /* 5 */ ".c.......c." + /* 6 */ ".C.......C." + /* 7 */ ".cCCCcCCCc." /* 8 */ "..........." /* 9 */ "...........", // Connectors: - "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -452,127 +468,146 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 97, ID 642, created by STR_Warrior { // Size: - 11, 5, 13, // SizeX = 11, SizeY = 5, SizeZ = 13 + 11, 6, 13, // SizeX = 11, SizeY = 6, SizeZ = 13 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 11, 4, 13, // MaxX, MaxY, MaxZ + 11, 5, 13, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ + "a: 24: 2\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ "c: 24: 0\n" /* sandstone */ - "d: 24: 2\n" /* sandstone */ - "e: 64: 7\n" /* wooddoorblock */ - "f: 43: 0\n" /* doubleslab */ - "g: 53: 5\n" /* woodstairs */ - "h: 53: 4\n" /* woodstairs */ - "i: 10: 0\n" /* lava */ - "j: 54: 5\n" /* chest */ - "k: 64:12\n" /* wooddoorblock */ - "l: 50: 3\n" /* torch */ + "d: 13: 0\n" /* gravel */ + "e: 5: 0\n" /* wood */ + "f: 12: 0\n" /* sand */ + "g: 64: 3\n" /* wooddoorblock */ + "h: 43: 0\n" /* doubleslab */ + "i: 53: 5\n" /* woodstairs */ + "j: 53: 4\n" /* woodstairs */ + "k: 10: 0\n" /* lava */ + "l: 54: 5\n" /* chest */ "m: 19: 0\n" /* sponge */ - "n:101: 0\n" /* ironbars */ - "o: 50: 1\n" /* torch */ - "p: 50: 2\n" /* torch */ - "q:128: 2\n" /* sandstonestairs */ - "r: 44: 9\n" /* step */ - "s:126: 8\n" /* woodenslab */ - "t:128: 4\n" /* sandstonestairs */ - "u:128: 5\n" /* sandstonestairs */ - "v:128: 7\n" /* sandstonestairs */ - "w: 44: 1\n" /* step */ - "x: 43: 1\n" /* doubleslab */, + "n: 64: 8\n" /* wooddoorblock */ + "o: 50: 3\n" /* torch */ + "p:101: 0\n" /* ironbars */ + "q: 50: 1\n" /* torch */ + "r: 50: 2\n" /* torch */ + "s:128: 2\n" /* sandstonestairs */ + "t: 44: 9\n" /* step */ + "u:126: 8\n" /* woodenslab */ + "v:128: 4\n" /* sandstonestairs */ + "w:128: 5\n" /* sandstonestairs */ + "x:128: 7\n" /* sandstonestairs */ + "y: 44: 1\n" /* step */ + "z: 43: 1\n" /* doubleslab */, // Block data: // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "aaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaa" - /* 2 */ "aaaaaaaabaa" - /* 3 */ "acacacabbba" - /* 4 */ "acaccaabbba" - /* 5 */ "acccccabbba" - /* 6 */ "acaadddbbba" - /* 7 */ "aaacdddbbba" - /* 8 */ "aaaadddbbba" - /* 9 */ "abbbbbbbbba" - /* 10 */ "abbbbbbbbba" - /* 11 */ "abbbbbbbbba" - /* 12 */ "aaaaaaaaaaa" + /* 0 */ "mmmmmmabbba" + /* 1 */ "mmmmmmbbbbm" + /* 2 */ "mmmmmmaccca" + /* 3 */ "maccccccccc" + /* 4 */ "mcccccccccc" + /* 5 */ "mcccccccccc" + /* 6 */ "mcccccacccc" + /* 7 */ "mcccccacccc" + /* 8 */ "acccaaacccc" + /* 9 */ "ccccccccccc" + /* 10 */ "ccccccccccc" + /* 11 */ "ccccccccccc" + /* 12 */ "accccccccca" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "......d...d" - /* 1 */ "..........." - /* 2 */ "......dcecd" - /* 3 */ ".d....c...c" - /* 4 */ "..f...c...c" - /* 5 */ "......c...c" - /* 6 */ "....ddc...c" - /* 7 */ ".gh.dic...c" - /* 8 */ "dcccccd...c" - /* 9 */ "cj........c" - /* 10 */ "c.........c" - /* 11 */ "c.........c" - /* 12 */ "dcccccccccd" + /* 0 */ "mmmmmmaddda" + /* 1 */ "mmmmmmddddm" + /* 2 */ "mmmmmmaceca" + /* 3 */ "mafcfcceeec" + /* 4 */ "mcfccfceeec" + /* 5 */ "mcccccceeec" + /* 6 */ "mcffaaaeeec" + /* 7 */ "mffcaaaeeec" + /* 8 */ "acccaaaeeec" + /* 9 */ "ceeeeeeeeec" + /* 10 */ "ceeeeeeeeec" + /* 11 */ "ceeeeeeeeec" + /* 12 */ "accccccccca" // Level 2 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "......d...d" - /* 1 */ "..........." - /* 2 */ "......dckcd" - /* 3 */ ".d....c..lc" - /* 4 */ "......n...c" - /* 5 */ "......c...c" - /* 6 */ "....nnc...n" - /* 7 */ "....n.c...n" - /* 8 */ "dcccccd...n" - /* 9 */ "co........c" - /* 10 */ "n.........c" - /* 11 */ "c........pc" - /* 12 */ "dcccnnncccd" + /* 0 */ "mmmmmma...a" + /* 1 */ "mmmmmm....." + /* 2 */ "mmmmmmacgca" + /* 3 */ "ma....c...c" + /* 4 */ "m.h...c...c" + /* 5 */ "m.....c...c" + /* 6 */ "m...aac...c" + /* 7 */ "mij.akc...c" + /* 8 */ "accccca...c" + /* 9 */ "cl........c" + /* 10 */ "c.........c" + /* 11 */ "c.........c" + /* 12 */ "accccccccca" // Level 3 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "......q...q" - /* 1 */ "......c...c" - /* 2 */ "......dcccd" - /* 3 */ ".drrrrcsssc" - /* 4 */ ".rsssstsssc" - /* 5 */ ".rsssscsssc" - /* 6 */ ".rssddcsssu" - /* 7 */ ".rssd.csssu" - /* 8 */ "dcccccdsssu" - /* 9 */ "csssssssssc" - /* 10 */ "tsssssssssc" - /* 11 */ "csssssssssc" - /* 12 */ "dcccvvvcccd" + /* 0 */ "mmmmmma...a" + /* 1 */ "mmmmmm....." + /* 2 */ "mmmmmmacnca" + /* 3 */ "ma....c..oc" + /* 4 */ "m.....p...c" + /* 5 */ "m.....c...c" + /* 6 */ "m...ppc...p" + /* 7 */ "m...p.c...p" + /* 8 */ "accccca...p" + /* 9 */ "cq........c" + /* 10 */ "p.........c" + /* 11 */ "c........rc" + /* 12 */ "acccpppccca" // Level 4 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "..........." - /* 1 */ "..........." - /* 2 */ "......cwwwc" - /* 3 */ ".w.w.ww...w" - /* 4 */ "......w...w" - /* 5 */ ".w....w...w" - /* 6 */ "....xwx...w" - /* 7 */ ".w..w.w...c" - /* 8 */ "cwwwxwc...w" - /* 9 */ "w.........w" - /* 10 */ "w.........w" - /* 11 */ "w.........w" - /* 12 */ "cwwwwcwwwwc", + /* 0 */ "mmmmmms...s" + /* 1 */ "mmmmmmc...c" + /* 2 */ "mmmmmmaccca" + /* 3 */ "mattttcuuuc" + /* 4 */ "mtuuuuvuuuc" + /* 5 */ "mtuuuucuuuc" + /* 6 */ "mtuuaacuuuw" + /* 7 */ "mtuua.cuuuw" + /* 8 */ "acccccauuuw" + /* 9 */ "cuuuuuuuuuc" + /* 10 */ "vuuuuuuuuuc" + /* 11 */ "cuuuuuuuuuc" + /* 12 */ "acccxxxccca" + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmmm....." + /* 1 */ "mmmmmm....." + /* 2 */ "mmmmmmcyyyc" + /* 3 */ "my.y.yy...y" + /* 4 */ "m.....y...y" + /* 5 */ "my....y...y" + /* 6 */ "m...zyz...y" + /* 7 */ "my..y.y...c" + /* 8 */ "cyyyzyc...y" + /* 9 */ "y.........y" + /* 10 */ "y.........y" + /* 11 */ "y.........y" + /* 12 */ "cyyyycyyyyc", // Connectors: - "-1: 8, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 8, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -603,180 +638,196 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 77, ID 577, created by STR_Warrior { // Size: - 15, 13, 11, // SizeX = 15, SizeY = 13, SizeZ = 11 + 15, 14, 11, // SizeX = 15, SizeY = 14, SizeZ = 11 // Hitbox (relative to bounding box): -1, 0, -1, // MinX, MinY, MinZ - 14, 12, 11, // MaxX, MaxY, MaxZ + 14, 13, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "A:128: 4\n" /* sandstonestairs */ - "B:128: 5\n" /* sandstonestairs */ - "C:128: 7\n" /* sandstonestairs */ - "D: 44: 1\n" /* step */ - "E:128: 2\n" /* sandstonestairs */ - "F:128: 0\n" /* sandstonestairs */ - "G: 87: 0\n" /* netherstone */ - "H:128: 3\n" /* sandstonestairs */ - "I: 51: 0\n" /* fire */ - "J: 44: 9\n" /* step */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c: 24: 2\n" /* sandstone */ - "d: 24: 0\n" /* sandstone */ - "e: 85: 0\n" /* fence */ - "f: 5: 1\n" /* wood */ - "g: 64: 6\n" /* wooddoorblock */ - "h: 64: 0\n" /* wooddoorblock */ - "i: 61: 2\n" /* furnace */ - "j:118: 0\n" /* cauldronblock */ - "k:134: 4\n" /* 134 */ - "l: 65: 2\n" /* ladder */ + "A: 96:10\n" /* trapdoor */ + "B:128: 4\n" /* sandstonestairs */ + "C:128: 5\n" /* sandstonestairs */ + "D:128: 7\n" /* sandstonestairs */ + "E: 44: 1\n" /* step */ + "F:128: 2\n" /* sandstonestairs */ + "G:128: 0\n" /* sandstonestairs */ + "H: 87: 0\n" /* netherstone */ + "I:128: 3\n" /* sandstonestairs */ + "J: 51: 0\n" /* fire */ + "K: 44: 9\n" /* step */ + "a: 24: 2\n" /* sandstone */ + "b: 24: 0\n" /* sandstone */ + "c: 12: 0\n" /* sand */ + "d: 4: 0\n" /* cobblestone */ + "e: 5: 0\n" /* wood */ + "f: 13: 0\n" /* gravel */ + "g: 85: 0\n" /* fence */ + "h: 5: 1\n" /* wood */ + "i: 64: 2\n" /* wooddoorblock */ + "j: 64: 0\n" /* wooddoorblock */ + "k: 61: 2\n" /* furnace */ + "l:118: 0\n" /* cauldronblock */ "m: 19: 0\n" /* sponge */ - "n:101: 0\n" /* ironbars */ - "o: 50: 1\n" /* torch */ - "p:140: 0\n" /* flowerpotblock */ - "q: 64:12\n" /* wooddoorblock */ - "r: 50: 3\n" /* torch */ + "n:134: 4\n" /* 134 */ + "o: 65: 2\n" /* ladder */ + "p:101: 0\n" /* ironbars */ + "q: 50: 1\n" /* torch */ + "r:140: 0\n" /* flowerpotblock */ "s: 64: 8\n" /* wooddoorblock */ - "t: 69:12\n" /* lever */ - "u: 50: 4\n" /* torch */ - "v:128: 6\n" /* sandstonestairs */ - "w: 44:10\n" /* step */ - "x:128: 1\n" /* sandstonestairs */ - "y: 47: 0\n" /* bookshelf */ - "z: 96:10\n" /* trapdoor */, + "t: 50: 3\n" /* torch */ + "u: 69:12\n" /* lever */ + "v: 50: 4\n" /* torch */ + "w:128: 6\n" /* sandstonestairs */ + "x: 44:10\n" /* step */ + "y:128: 1\n" /* sandstonestairs */ + "z: 47: 0\n" /* bookshelf */, // Block data: // Level 0 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "aaaaaaaaaaaaaaa" - /* 1 */ "aaaaabbbbbbbaaa" - /* 2 */ "aaaabbbbbbbbaaa" - /* 3 */ "aaaaabbbbbbbbaa" - /* 4 */ "aaaaabbbbbbbaaa" - /* 5 */ "aaaaabbbbbbbaaa" - /* 6 */ "aaaaabbbbbbbaaa" - /* 7 */ "aaaaabbbbbbbaaa" - /* 8 */ "aaaaabbbbbbbaaa" - /* 9 */ "aaaaabbbbbbbaaa" - /* 10 */ "aaaaaaaaaaaaaaa" + /* 0 */ "mmmmabbbbbbbamm" + /* 1 */ "ccccbbbbbbbbbma" + /* 2 */ "ccccbbbbbbbbbdd" + /* 3 */ "ccccbbbbbbbbbdd" + /* 4 */ "ccccbbbbbbbbbdd" + /* 5 */ "ccccbbbbbbbbbma" + /* 6 */ "ccccbbbbbbbbbmm" + /* 7 */ "mmmmbbbbbbbbbmm" + /* 8 */ "mmmmbbbbbbbbbmm" + /* 9 */ "mmmmbbbbbbbbbmm" + /* 10 */ "mmmmabbbbbbbamm" // Level 1 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "....cdddddddc.." - /* 1 */ "eeeed......fd.c" - /* 2 */ "e...g.......d.." - /* 3 */ "e...d.......h.." - /* 4 */ "e...dijk..l.d.." - /* 5 */ "e...dddd.dddd.c" - /* 6 */ "eeeed.......d.." - /* 7 */ "mmmmd.......d.." - /* 8 */ "mmmmd.......d.." - /* 9 */ "mmmmd.......d.." - /* 10 */ "mmmmcdddddddc.." + /* 0 */ "mmmmabbbbbbbamm" + /* 1 */ "ccccbeeeeeeebma" + /* 2 */ "cccceeeeeeeebff" + /* 3 */ "ccccbeeeeeeeeff" + /* 4 */ "ccccbeeeeeeebff" + /* 5 */ "ccccbeeeeeeebma" + /* 6 */ "ccccbeeeeeeebmm" + /* 7 */ "mmmmbeeeeeeebmm" + /* 8 */ "mmmmbeeeeeeebmm" + /* 9 */ "mmmmbeeeeeeebmm" + /* 10 */ "mmmmabbbbbbbamm" // Level 2 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "....cddnnnddc.." - /* 1 */ "....do.....pd.c" - /* 2 */ "....q.......d.r" - /* 3 */ "....d.......s.." - /* 4 */ "....d.t...l.d.u" - /* 5 */ "....dddd.dddd.c" - /* 6 */ "....n..r.r..n.." - /* 7 */ "mmmmn.......n.." - /* 8 */ "mmmmn.......n.." - /* 9 */ "mmmmd.......d.." - /* 10 */ "mmmmcddnnnddc.." + /* 0 */ "mmmmabbbbbbbamm" + /* 1 */ "ggggb......hb.a" + /* 2 */ "g...i.......b.." + /* 3 */ "g...b.......j.." + /* 4 */ "g...bkln..o.b.." + /* 5 */ "g...bbbb.bbbb.a" + /* 6 */ "ggggb.......bmm" + /* 7 */ "mmmmb.......bmm" + /* 8 */ "mmmmb.......bmm" + /* 9 */ "mmmmb.......bmm" + /* 10 */ "mmmmabbbbbbbamm" // Level 3 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "....cddvvvddc.." - /* 1 */ "....dwwwwwwwddx" - /* 2 */ "....dwwwwwwwd.." - /* 3 */ "....dwwwwwwwd.." - /* 4 */ "....dyyywwzwd.." - /* 5 */ "....ddddddddddx" - /* 6 */ "....AwwwwwwwB.." - /* 7 */ "mmmmAwwwwwwwB.." - /* 8 */ "mmmmAwwwwwwwB.." - /* 9 */ "mmmmdwwwwwwwd.." - /* 10 */ "mmmmcddCCCddc.." + /* 0 */ "mmmmabbpppbbamm" + /* 1 */ "....bq.....rb.a" + /* 2 */ "....s.......b.t" + /* 3 */ "....b.......s.." + /* 4 */ "....b.u...o.b.v" + /* 5 */ "....bbbb.bbbb.a" + /* 6 */ "....p..t.t..pmm" + /* 7 */ "mmmmp.......pmm" + /* 8 */ "mmmmp.......pmm" + /* 9 */ "mmmmb.......bmm" + /* 10 */ "mmmmabbpppbbamm" // Level 4 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "....dDDDdDDDd.." - /* 1 */ "....DcdddddcD.." - /* 2 */ "....Dd.....dD.." - /* 3 */ "....Dd.....dD.." - /* 4 */ "....Dd.....dD.." - /* 5 */ "....dcdd.ddcd.." - /* 6 */ "....D.......D.." - /* 7 */ "mmmmD.......D.." - /* 8 */ "mmmmD.......D.." - /* 9 */ "mmmmD.......D.." - /* 10 */ "mmmmdDDDdDDDd.." + /* 0 */ "mmmmabbwwwbbamm" + /* 1 */ "....bxxxxxxxbby" + /* 2 */ "....bxxxxxxxb.." + /* 3 */ "....bxxxxxxxb.." + /* 4 */ "....bzzzxxAxb.." + /* 5 */ "....bbbbbbbbbby" + /* 6 */ "....BxxxxxxxCmm" + /* 7 */ "mmmmBxxxxxxxCmm" + /* 8 */ "mmmmBxxxxxxxCmm" + /* 9 */ "mmmmbxxxxxxxbmm" + /* 10 */ "mmmmabbDDDbbamm" // Level 5 /* z\x* 11111 */ /* * 012345678901234 */ + /* 0 */ "mmmmbEEEbEEEbmm" + /* 1 */ "....EabbbbbaE.." + /* 2 */ "....Eb.....bE.." + /* 3 */ "....Eb.....bE.." + /* 4 */ "....Eb.....bE.." + /* 5 */ "....babb.bbab.." + /* 6 */ "....E.......Emm" + /* 7 */ "mmmmE.......Emm" + /* 8 */ "mmmmE.......Emm" + /* 9 */ "mmmmE.......Emm" + /* 10 */ "mmmmbEEEbEEEbmm" + + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".....cddnddc..." - /* 2 */ ".....n.....n..." - /* 3 */ ".....n.....n..." - /* 4 */ ".....n.....n..." - /* 5 */ ".....cdd.ddc..." + /* 1 */ ".....abbpbba..." + /* 2 */ ".....p.....p..." + /* 3 */ ".....p.....p..." + /* 4 */ ".....p.....p..." + /* 5 */ ".....abb.bba..." /* 6 */ "..............." /* 7 */ "..............." /* 8 */ "..............." /* 9 */ "..............." /* 10 */ "..............." - // Level 6 + // Level 7 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".....cddvddc..." - /* 2 */ ".....AwwwwwB..." - /* 3 */ ".....AwwwwwB..." - /* 4 */ ".....AwwwwwB..." - /* 5 */ ".....cdddddc..." + /* 1 */ ".....abbwbba..." + /* 2 */ ".....BxxxxxC..." + /* 3 */ ".....BxxxxxC..." + /* 4 */ ".....BxxxxxC..." + /* 5 */ ".....abbbbba..." /* 6 */ "..............." /* 7 */ "..............." /* 8 */ "..............." /* 9 */ "..............." /* 10 */ "..............." - // Level 7 + // Level 8 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".....dDDdDDd..." - /* 2 */ ".....D.ddd.D..." - /* 3 */ ".....d.ddd.d..." - /* 4 */ ".....D.ddd.D..." - /* 5 */ ".....dDDdDDd..." + /* 1 */ ".....bEEbEEb..." + /* 2 */ ".....E.bbb.E..." + /* 3 */ ".....b.bbb.b..." + /* 4 */ ".....E.bbb.E..." + /* 5 */ ".....bEEbEEb..." /* 6 */ "..............." /* 7 */ "..............." /* 8 */ "..............." /* 9 */ "..............." /* 10 */ "..............." - // Level 8 + // Level 9 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ ".......cEc....." - /* 3 */ ".......FGx....." - /* 4 */ ".......cHc....." + /* 2 */ ".......aFa....." + /* 3 */ ".......GHy....." + /* 4 */ ".......aIa....." /* 5 */ "..............." /* 6 */ "..............." /* 7 */ "..............." @@ -784,14 +835,14 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 9 */ "..............." /* 10 */ "..............." - // Level 9 + // Level 10 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ ".......c.c....." - /* 3 */ "........I......" - /* 4 */ ".......c.c....." + /* 2 */ ".......a.a....." + /* 3 */ "........J......" + /* 4 */ ".......a.a....." /* 5 */ "..............." /* 6 */ "..............." /* 7 */ "..............." @@ -799,14 +850,14 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 9 */ "..............." /* 10 */ "..............." - // Level 10 + // Level 11 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ ".......cvc....." - /* 3 */ ".......A.B....." - /* 4 */ ".......cCc....." + /* 2 */ ".......awa....." + /* 3 */ ".......B.C....." + /* 4 */ ".......aDa....." /* 5 */ "..............." /* 6 */ "..............." /* 7 */ "..............." @@ -814,14 +865,14 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 9 */ "..............." /* 10 */ "..............." - // Level 11 + // Level 12 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ ".......ddd....." - /* 3 */ ".......dJd....." - /* 4 */ ".......ddd....." + /* 2 */ ".......bbb....." + /* 3 */ ".......bKb....." + /* 4 */ ".......bbb....." /* 5 */ "..............." /* 6 */ "..............." /* 7 */ "..............." @@ -829,14 +880,14 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 9 */ "..............." /* 10 */ "..............." - // Level 12 + // Level 13 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." - /* 2 */ ".......D.D....." + /* 2 */ ".......E.E....." /* 3 */ "..............." - /* 4 */ ".......D.D....." + /* 4 */ ".......E.E....." /* 5 */ "..............." /* 6 */ "..............." /* 7 */ "..............." @@ -845,7 +896,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 10 */ "...............", // Connectors: - "-1: 14, 1, 3: 5\n" /* Type -1, direction X+ */, + "-1: 14, 2, 3: 5\n" /* Type -1, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -876,149 +927,162 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 80, ID 596, created by STR_Warrior { // Size: - 7, 11, 7, // SizeX = 7, SizeY = 11, SizeZ = 7 + 7, 12, 7, // SizeX = 7, SizeY = 12, SizeZ = 7 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 7, 10, 7, // MaxX, MaxY, MaxZ + 7, 11, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c:128: 2\n" /* sandstonestairs */ - "d:128: 0\n" /* sandstonestairs */ - "e: 24: 2\n" /* sandstone */ - "f: 24: 0\n" /* sandstone */ - "g: 71: 3\n" /* irondoorblock */ - "h:128: 1\n" /* sandstonestairs */ - "i:128: 3\n" /* sandstonestairs */ - "j: 77: 4\n" /* stonebutton */ - "k: 71: 8\n" /* irondoorblock */ - "l:128: 6\n" /* sandstonestairs */ + "a: 24: 0\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ + "c: 12: 0\n" /* sand */ + "d: 5: 0\n" /* wood */ + "e: 13: 0\n" /* gravel */ + "f:128: 2\n" /* sandstonestairs */ + "g:128: 0\n" /* sandstonestairs */ + "h: 24: 2\n" /* sandstone */ + "i: 71: 3\n" /* irondoorblock */ + "j:128: 1\n" /* sandstonestairs */ + "k:128: 3\n" /* sandstonestairs */ + "l: 77: 4\n" /* stonebutton */ "m: 19: 0\n" /* sponge */ - "n:128: 4\n" /* sandstonestairs */ - "o:128: 5\n" /* sandstonestairs */ - "p: 50: 4\n" /* torch */ - "q:128: 7\n" /* sandstonestairs */ - "r: 85: 0\n" /* fence */ - "s: 24: 1\n" /* sandstone */ - "t: 44: 1\n" /* step */ - "u: 89: 0\n" /* lightstone */, + "n: 71: 8\n" /* irondoorblock */ + "o: 77: 3\n" /* stonebutton */ + "p:128: 6\n" /* sandstonestairs */ + "q:128: 4\n" /* sandstonestairs */ + "r:128: 5\n" /* sandstonestairs */ + "s: 50: 4\n" /* torch */ + "t:128: 7\n" /* sandstonestairs */ + "u: 85: 0\n" /* fence */ + "v: 24: 1\n" /* sandstone */ + "w: 44: 1\n" /* step */ + "x: 89: 0\n" /* lightstone */, // Block data: // Level 0 /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "aaabaaa" - /* 2 */ "aabbbaa" - /* 3 */ "aabbbaa" - /* 4 */ "aabbbaa" + /* 0 */ "mabbbam" + /* 1 */ "aacdcaa" + /* 2 */ "madddam" + /* 3 */ "madddam" + /* 4 */ "madddam" /* 5 */ "aaaaaaa" - /* 6 */ "aaaaaaa" + /* 6 */ "mammmam" // Level 1 /* z\x* 0123456 */ - /* 0 */ "mc...cm" - /* 1 */ "defgfeh" - /* 2 */ ".f...f." - /* 3 */ ".f...f." - /* 4 */ ".f...f." - /* 5 */ "defffeh" - /* 6 */ "mi...im" + /* 0 */ "maeeeam" + /* 1 */ "aacdcaa" + /* 2 */ "madddam" + /* 3 */ "madddam" + /* 4 */ "madddam" + /* 5 */ "aaaaaaa" + /* 6 */ "mammmam" // Level 2 /* z\x* 0123456 */ - /* 0 */ "m.j...m" - /* 1 */ ".efkfe." - /* 2 */ ".f...f." - /* 3 */ ".f...f." - /* 4 */ ".f...f." - /* 5 */ ".efffe." - /* 6 */ "m.....m" + /* 0 */ "mf...fm" + /* 1 */ "ghaiahj" + /* 2 */ "ma...am" + /* 3 */ "ma...am" + /* 4 */ "ma...am" + /* 5 */ "ghaaahj" + /* 6 */ "mkmmmkm" // Level 3 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ "..lfl.." - /* 2 */ ".n...o." - /* 3 */ ".f...f." - /* 4 */ ".n.p.o." - /* 5 */ "..qfq.." - /* 6 */ "......." + /* 0 */ "m.l...m" + /* 1 */ ".hanah." + /* 2 */ ".ao..a." + /* 3 */ ".a...a." + /* 4 */ ".a...a." + /* 5 */ ".haaah." + /* 6 */ "m.....m" // Level 4 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ "..frf.." - /* 2 */ ".f...f." - /* 3 */ ".r...r." - /* 4 */ ".f...f." - /* 5 */ "..frf.." + /* 1 */ "..pap.." + /* 2 */ ".q...r." + /* 3 */ ".a...a." + /* 4 */ ".q.s.r." + /* 5 */ "..tat.." /* 6 */ "......." // Level 5 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ "..frf.." - /* 2 */ ".f...f." - /* 3 */ ".r...r." - /* 4 */ ".f...f." - /* 5 */ "..frf.." + /* 1 */ "..aua.." + /* 2 */ ".a...a." + /* 3 */ ".u...u." + /* 4 */ ".a...a." + /* 5 */ "..aua.." /* 6 */ "......." // Level 6 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ "..frf.." - /* 2 */ ".f...f." - /* 3 */ ".r...r." - /* 4 */ ".f...f." - /* 5 */ "..frf.." + /* 1 */ "..aua.." + /* 2 */ ".a...a." + /* 3 */ ".u...u." + /* 4 */ ".a...a." + /* 5 */ "..aua.." /* 6 */ "......." // Level 7 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ "..cfc.." - /* 2 */ ".d...h." - /* 3 */ ".f...f." - /* 4 */ ".d...h." - /* 5 */ "..ifi.." + /* 1 */ "..aua.." + /* 2 */ ".a...a." + /* 3 */ ".u...u." + /* 4 */ ".a...a." + /* 5 */ "..aua.." /* 6 */ "......." // Level 8 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ ".ffsff." - /* 2 */ ".f...f." - /* 3 */ ".s...s." - /* 4 */ ".f...f." - /* 5 */ ".ffsff." + /* 1 */ "..faf.." + /* 2 */ ".g...j." + /* 3 */ ".a...a." + /* 4 */ ".g...j." + /* 5 */ "..kak.." /* 6 */ "......." // Level 9 /* z\x* 0123456 */ - /* 0 */ "...l..." - /* 1 */ ".efffe." - /* 2 */ ".ftttf." - /* 3 */ "nftftfo" - /* 4 */ ".ftttf." - /* 5 */ ".efffe." - /* 6 */ "...q..." + /* 0 */ "......." + /* 1 */ ".aavaa." + /* 2 */ ".a...a." + /* 3 */ ".v...v." + /* 4 */ ".a...a." + /* 5 */ ".aavaa." + /* 6 */ "......." // Level 10 /* z\x* 0123456 */ - /* 0 */ "...t..." - /* 1 */ ".t...t." + /* 0 */ "...p..." + /* 1 */ ".haaah." + /* 2 */ ".awwwa." + /* 3 */ "qawawar" + /* 4 */ ".awwwa." + /* 5 */ ".haaah." + /* 6 */ "...t..." + + // Level 11 + /* z\x* 0123456 */ + /* 0 */ "...w..." + /* 1 */ ".w...w." /* 2 */ "......." - /* 3 */ "t..u..t" + /* 3 */ "w..x..w" /* 4 */ "......." - /* 5 */ ".t...t." - /* 6 */ "...t...", + /* 5 */ ".w...w." + /* 6 */ "...w...", // Connectors: - "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1049,86 +1113,97 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 65, ID 551, created by STR_Warrior { // Size: - 5, 5, 7, // SizeX = 5, SizeY = 5, SizeZ = 7 + 5, 6, 7, // SizeX = 5, SizeY = 6, SizeZ = 7 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 5, 4, 7, // MaxX, MaxY, MaxZ + 5, 5, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c: 24: 2\n" /* sandstone */ - "d: 24: 0\n" /* sandstone */ - "e: 64: 3\n" /* wooddoorblock */ - "f: 61: 2\n" /* furnace */ - "g: 65: 2\n" /* ladder */ - "h: 64: 8\n" /* wooddoorblock */ - "i:101: 0\n" /* ironbars */ - "j: 50: 4\n" /* torch */ - "k:128: 2\n" /* sandstonestairs */ - "l:126: 8\n" /* woodenslab */ + "a: 24: 2\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ + "c: 24: 0\n" /* sandstone */ + "d: 13: 0\n" /* gravel */ + "e: 5: 0\n" /* wood */ + "f: 64: 3\n" /* wooddoorblock */ + "g: 61: 2\n" /* furnace */ + "h: 65: 2\n" /* ladder */ + "i: 64: 8\n" /* wooddoorblock */ + "j:101: 0\n" /* ironbars */ + "k: 50: 4\n" /* torch */ + "l:128: 2\n" /* sandstonestairs */ "m: 19: 0\n" /* sponge */ - "n:128: 4\n" /* sandstonestairs */ - "o:128: 5\n" /* sandstonestairs */ - "p:128: 7\n" /* sandstonestairs */ - "q: 44: 1\n" /* step */ - "r: 96: 6\n" /* trapdoor */, + "n:126: 8\n" /* woodenslab */ + "o:128: 4\n" /* sandstonestairs */ + "p:128: 5\n" /* sandstonestairs */ + "q:128: 7\n" /* sandstonestairs */ + "r: 44: 1\n" /* step */ + "s: 96: 2\n" /* trapdoor */, // Block data: // Level 0 /* z\x* 01234 */ - /* 0 */ "aaaaa" - /* 1 */ "aaaaa" - /* 2 */ "aabaa" - /* 3 */ "abbba" - /* 4 */ "abbba" - /* 5 */ "abbba" - /* 6 */ "aaaaa" + /* 0 */ "abbba" + /* 1 */ "mbbbm" + /* 2 */ "accca" + /* 3 */ "ccccc" + /* 4 */ "ccccc" + /* 5 */ "ccccc" + /* 6 */ "accca" // Level 1 /* z\x* 01234 */ - /* 0 */ "c...c" - /* 1 */ "....." - /* 2 */ "cdedc" - /* 3 */ "d...d" - /* 4 */ "d...d" - /* 5 */ "df.gd" - /* 6 */ "cdddc" + /* 0 */ "addda" + /* 1 */ "mdddm" + /* 2 */ "aceca" + /* 3 */ "ceeec" + /* 4 */ "ceeec" + /* 5 */ "ceeec" + /* 6 */ "accca" // Level 2 /* z\x* 01234 */ - /* 0 */ "c...c" + /* 0 */ "a...a" /* 1 */ "....." - /* 2 */ "cdhdc" - /* 3 */ "d...d" - /* 4 */ "i...i" - /* 5 */ "dj.gd" - /* 6 */ "cdidc" + /* 2 */ "acfca" + /* 3 */ "c...c" + /* 4 */ "c...c" + /* 5 */ "cg.hc" + /* 6 */ "accca" // Level 3 /* z\x* 01234 */ - /* 0 */ "k...k" - /* 1 */ "d...d" - /* 2 */ "cdddc" - /* 3 */ "dllld" - /* 4 */ "nlllo" - /* 5 */ "dllgd" - /* 6 */ "cdpdc" + /* 0 */ "a...a" + /* 1 */ "....." + /* 2 */ "acica" + /* 3 */ "c...c" + /* 4 */ "j...j" + /* 5 */ "ck.hc" + /* 6 */ "acjca" // Level 4 /* z\x* 01234 */ + /* 0 */ "l...l" + /* 1 */ "c...c" + /* 2 */ "accca" + /* 3 */ "cnnnc" + /* 4 */ "onnnp" + /* 5 */ "cnnhc" + /* 6 */ "acqca" + + // Level 5 + /* z\x* 01234 */ /* 0 */ "....." /* 1 */ "....." - /* 2 */ "dqdqd" - /* 3 */ "q...q" - /* 4 */ "d...d" - /* 5 */ "q..rq" - /* 6 */ "dqdqd", + /* 2 */ "crcrc" + /* 3 */ "r...r" + /* 4 */ "c...c" + /* 5 */ "r..sr" + /* 6 */ "crcrc", // Connectors: - "-1: 2, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 2, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1159,107 +1234,123 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 72, ID 562, created by STR_Warrior { // Size: - 7, 5, 11, // SizeX = 7, SizeY = 5, SizeZ = 11 + 7, 6, 11, // SizeX = 7, SizeY = 6, SizeZ = 11 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 7, 4, 11, // MaxX, MaxY, MaxZ + 7, 5, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c: 24: 2\n" /* sandstone */ - "d: 24: 0\n" /* sandstone */ - "e: 64: 3\n" /* wooddoorblock */ - "f: 65: 5\n" /* ladder */ - "g: 85: 0\n" /* fence */ - "h:101: 0\n" /* ironbars */ - "i: 64: 8\n" /* wooddoorblock */ - "j: 50: 3\n" /* torch */ - "k:128: 2\n" /* sandstonestairs */ - "l:128: 6\n" /* sandstonestairs */ + "a: 24: 2\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ + "c: 24: 0\n" /* sandstone */ + "d: 12: 0\n" /* sand */ + "e: 13: 0\n" /* gravel */ + "f: 5: 0\n" /* wood */ + "g: 64: 3\n" /* wooddoorblock */ + "h: 65: 5\n" /* ladder */ + "i: 85: 0\n" /* fence */ + "j:101: 0\n" /* ironbars */ + "k: 64: 8\n" /* wooddoorblock */ + "l: 50: 3\n" /* torch */ "m: 19: 0\n" /* sponge */ - "n:126: 8\n" /* woodenslab */ - "o:128: 4\n" /* sandstonestairs */ - "p:128: 5\n" /* sandstonestairs */ - "q:128: 7\n" /* sandstonestairs */ - "r: 44: 1\n" /* step */ - "s: 96: 0\n" /* trapdoor */, + "n:128: 2\n" /* sandstonestairs */ + "o:128: 6\n" /* sandstonestairs */ + "p:126: 8\n" /* woodenslab */ + "q:128: 4\n" /* sandstonestairs */ + "r:128: 5\n" /* sandstonestairs */ + "s:128: 7\n" /* sandstonestairs */ + "t: 44: 1\n" /* step */ + "u: 96: 0\n" /* trapdoor */, // Block data: // Level 0 /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "aaaaaaa" - /* 2 */ "aaaabaa" - /* 3 */ "abbbbba" - /* 4 */ "abbbbba" - /* 5 */ "abbbbba" - /* 6 */ "aabaaaa" - /* 7 */ "aaaaaaa" - /* 8 */ "aaaaaaa" - /* 9 */ "aaaaaaa" - /* 10 */ "aaaaaaa" + /* 0 */ "mabbbam" + /* 1 */ "mmbbbmm" + /* 2 */ "accccca" + /* 3 */ "ccccccc" + /* 4 */ "ccccccc" + /* 5 */ "ccccccc" + /* 6 */ "accccca" + /* 7 */ "ddddddd" + /* 8 */ "ddddddd" + /* 9 */ "ddddddd" + /* 10 */ "ddddddd" // Level 1 /* z\x* 0123456 */ - /* 0 */ ".c...c." - /* 1 */ "......." - /* 2 */ "cdddedc" - /* 3 */ "d.....d" - /* 4 */ "d.....d" - /* 5 */ "df....d" - /* 6 */ "cd.dddc" - /* 7 */ "g.....g" - /* 8 */ "g.....g" - /* 9 */ "g.....g" - /* 10 */ "ggggggg" + /* 0 */ "maeeeam" + /* 1 */ "mmeeemm" + /* 2 */ "acccfca" + /* 3 */ "cfffffc" + /* 4 */ "cfffffc" + /* 5 */ "cfffffc" + /* 6 */ "acfccca" + /* 7 */ "ddddddd" + /* 8 */ "ddddddd" + /* 9 */ "ddddddd" + /* 10 */ "ddddddd" // Level 2 /* z\x* 0123456 */ - /* 0 */ ".c...c." - /* 1 */ "......." - /* 2 */ "cdhdidc" - /* 3 */ "d..j..d" - /* 4 */ "h.....h" - /* 5 */ "df....d" - /* 6 */ "cd.dhdc" + /* 0 */ "ma...am" + /* 1 */ "m.....m" + /* 2 */ "acccgca" + /* 3 */ "c.....c" + /* 4 */ "c.....c" + /* 5 */ "ch....c" + /* 6 */ "ac.ccca" + /* 7 */ "i.....i" + /* 8 */ "i.....i" + /* 9 */ "i.....i" + /* 10 */ "iiiiiii" + + // Level 3 + /* z\x* 0123456 */ + /* 0 */ "ma...am" + /* 1 */ "m.....m" + /* 2 */ "acjckca" + /* 3 */ "c..l..c" + /* 4 */ "j.....j" + /* 5 */ "ch....c" + /* 6 */ "ac.cjca" /* 7 */ "......." /* 8 */ "......." /* 9 */ "......." /* 10 */ "......." - // Level 3 + // Level 4 /* z\x* 0123456 */ - /* 0 */ ".k...k." - /* 1 */ ".d...d." - /* 2 */ "cdldddc" - /* 3 */ "dnnnnnd" - /* 4 */ "onnnnnp" - /* 5 */ "dfnnnnd" - /* 6 */ "cdddqdc" + /* 0 */ "mn...nm" + /* 1 */ "mc...cm" + /* 2 */ "acoccca" + /* 3 */ "cpppppc" + /* 4 */ "qpppppr" + /* 5 */ "chppppc" + /* 6 */ "acccsca" /* 7 */ "......." /* 8 */ "......." /* 9 */ "......." /* 10 */ "......." - // Level 4 + // Level 5 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ "......." - /* 2 */ "drrdrrd" - /* 3 */ "r.....r" - /* 4 */ "d.....d" - /* 5 */ "rs....r" - /* 6 */ "drrdrrd" + /* 0 */ "m.....m" + /* 1 */ "m.....m" + /* 2 */ "cttcttc" + /* 3 */ "t.....t" + /* 4 */ "c.....c" + /* 5 */ "tu....t" + /* 6 */ "cttcttc" /* 7 */ "......." /* 8 */ "......." /* 9 */ "......." /* 10 */ ".......", // Connectors: - "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 3, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1290,85 +1381,96 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 66, ID 553, created by STR_Warrior { // Size: - 9, 5, 7, // SizeX = 9, SizeY = 5, SizeZ = 7 + 9, 6, 7, // SizeX = 9, SizeY = 6, SizeZ = 7 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 9, 4, 7, // MaxX, MaxY, MaxZ + 9, 5, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c: 24: 2\n" /* sandstone */ - "d: 24: 0\n" /* sandstone */ - "e: 64: 7\n" /* wooddoorblock */ - "f: 65: 2\n" /* ladder */ - "g: 64:12\n" /* wooddoorblock */ - "h:101: 0\n" /* ironbars */ - "i: 50: 4\n" /* torch */ - "j:128: 2\n" /* sandstonestairs */ - "k:126: 8\n" /* woodenslab */ - "l:128: 4\n" /* sandstonestairs */ + "a: 24: 2\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ + "c: 24: 0\n" /* sandstone */ + "d: 13: 0\n" /* gravel */ + "e: 5: 0\n" /* wood */ + "f: 64: 3\n" /* wooddoorblock */ + "g: 65: 2\n" /* ladder */ + "h: 64: 8\n" /* wooddoorblock */ + "i:101: 0\n" /* ironbars */ + "j: 50: 4\n" /* torch */ + "k:128: 2\n" /* sandstonestairs */ + "l:126: 8\n" /* woodenslab */ "m: 19: 0\n" /* sponge */ - "n:128: 5\n" /* sandstonestairs */ - "o:128: 7\n" /* sandstonestairs */ - "p: 44: 1\n" /* step */ - "q: 96: 2\n" /* trapdoor */, + "n:128: 4\n" /* sandstonestairs */ + "o:128: 5\n" /* sandstonestairs */ + "p:128: 7\n" /* sandstonestairs */ + "q: 44: 1\n" /* step */ + "r: 96: 2\n" /* trapdoor */, // Block data: // Level 0 /* z\x* 012345678 */ - /* 0 */ "aaaaaaaaa" - /* 1 */ "aaaaaaaaa" - /* 2 */ "aaaabaaaa" - /* 3 */ "abbbbbbba" - /* 4 */ "abbbbbbba" - /* 5 */ "abbbbbbba" - /* 6 */ "aaaaaaaaa" + /* 0 */ "mmabbbamm" + /* 1 */ "mmmbbbmmm" + /* 2 */ "accccccca" + /* 3 */ "ccccccccc" + /* 4 */ "ccccccccc" + /* 5 */ "ccccccccc" + /* 6 */ "accccccca" // Level 1 /* z\x* 012345678 */ - /* 0 */ "..c...c.." - /* 1 */ "........." - /* 2 */ "cdddedddc" - /* 3 */ "d.......d" - /* 4 */ "d.......d" - /* 5 */ "d......fd" - /* 6 */ "cdddddddc" + /* 0 */ "mmadddamm" + /* 1 */ "mmmdddmmm" + /* 2 */ "accceccca" + /* 3 */ "ceeeeeeec" + /* 4 */ "ceeeeeeec" + /* 5 */ "ceeeeeeec" + /* 6 */ "accccccca" // Level 2 /* z\x* 012345678 */ - /* 0 */ "..c...c.." - /* 1 */ "........." - /* 2 */ "cdddgdddc" - /* 3 */ "d.......d" - /* 4 */ "h.......h" - /* 5 */ "d.i....fd" - /* 6 */ "cddhhhddc" + /* 0 */ "mma...amm" + /* 1 */ "mm.....mm" + /* 2 */ "acccfccca" + /* 3 */ "c.......c" + /* 4 */ "c.......c" + /* 5 */ "c......gc" + /* 6 */ "accccccca" // Level 3 /* z\x* 012345678 */ - /* 0 */ "..j...j.." - /* 1 */ "..d...d.." - /* 2 */ "cdddddddc" - /* 3 */ "dkkkkkkkd" - /* 4 */ "lkkkkkkkn" - /* 5 */ "dkkkkkkfd" - /* 6 */ "cddoooddc" + /* 0 */ "mma...amm" + /* 1 */ "mm.....mm" + /* 2 */ "accchccca" + /* 3 */ "c.......c" + /* 4 */ "i.......i" + /* 5 */ "c.j....gc" + /* 6 */ "acciiicca" // Level 4 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "dpppdpppd" - /* 3 */ "p.......p" - /* 4 */ "d.......d" - /* 5 */ "p......qp" - /* 6 */ "dpppdpppd", + /* 0 */ "mmk...kmm" + /* 1 */ "mmc...cmm" + /* 2 */ "accccccca" + /* 3 */ "clllllllc" + /* 4 */ "nlllllllo" + /* 5 */ "cllllllgc" + /* 6 */ "accpppcca" + + // Level 5 + /* z\x* 012345678 */ + /* 0 */ "mm.....mm" + /* 1 */ "mm.....mm" + /* 2 */ "cqqqcqqqc" + /* 3 */ "q.......q" + /* 4 */ "c.......c" + /* 5 */ "q......rq" + /* 6 */ "cqqqcqqqc", // Connectors: - "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 4, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1399,112 +1501,127 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 70, ID 560, created by STR_Warrior { // Size: - 5, 5, 11, // SizeX = 5, SizeY = 5, SizeZ = 11 + 5, 6, 11, // SizeX = 5, SizeY = 6, SizeZ = 11 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 5, 4, 11, // MaxX, MaxY, MaxZ + 5, 5, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c: 24: 2\n" /* sandstone */ - "d: 24: 0\n" /* sandstone */ - "e: 64: 7\n" /* wooddoorblock */ - "f: 65: 5\n" /* ladder */ - "g:134: 3\n" /* 134 */ - "h: 85: 0\n" /* fence */ - "i:134: 2\n" /* 134 */ - "j: 61: 2\n" /* furnace */ - "k:134: 6\n" /* 134 */ - "l:134: 4\n" /* 134 */ + "a: 24: 2\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ + "c: 24: 0\n" /* sandstone */ + "d: 13: 0\n" /* gravel */ + "e: 5: 0\n" /* wood */ + "f: 64: 3\n" /* wooddoorblock */ + "g: 65: 5\n" /* ladder */ + "h:134: 3\n" /* 134 */ + "i: 85: 0\n" /* fence */ + "j:134: 2\n" /* 134 */ + "k: 61: 2\n" /* furnace */ + "l:134: 6\n" /* 134 */ "m: 19: 0\n" /* sponge */ - "n: 64:12\n" /* wooddoorblock */ - "o: 50: 2\n" /* torch */ - "p:101: 0\n" /* ironbars */ - "q:171: 8\n" /* carpet */ - "r:128: 2\n" /* sandstonestairs */ - "s:126: 8\n" /* woodenslab */ - "t:128: 4\n" /* sandstonestairs */ - "u:128: 5\n" /* sandstonestairs */ - "v:128: 7\n" /* sandstonestairs */ - "w: 44: 1\n" /* step */ - "x: 96: 1\n" /* trapdoor */, + "n:134: 4\n" /* 134 */ + "o: 64: 8\n" /* wooddoorblock */ + "p: 50: 2\n" /* torch */ + "q:101: 0\n" /* ironbars */ + "r:171: 8\n" /* carpet */ + "s:128: 2\n" /* sandstonestairs */ + "t:126: 8\n" /* woodenslab */ + "u:128: 4\n" /* sandstonestairs */ + "v:128: 5\n" /* sandstonestairs */ + "w:128: 7\n" /* sandstonestairs */ + "x: 44: 1\n" /* step */ + "y: 96: 1\n" /* trapdoor */, // Block data: // Level 0 /* z\x* 01234 */ - /* 0 */ "aaaaa" - /* 1 */ "aaaaa" - /* 2 */ "aabaa" - /* 3 */ "abbba" - /* 4 */ "abbba" - /* 5 */ "abbba" - /* 6 */ "abbba" - /* 7 */ "abbba" - /* 8 */ "abbba" - /* 9 */ "abbba" - /* 10 */ "aaaaa" + /* 0 */ "abbba" + /* 1 */ "mbbbm" + /* 2 */ "accca" + /* 3 */ "ccccc" + /* 4 */ "ccccc" + /* 5 */ "ccccc" + /* 6 */ "ccccc" + /* 7 */ "ccccc" + /* 8 */ "ccccc" + /* 9 */ "ccccc" + /* 10 */ "accca" // Level 1 /* z\x* 01234 */ - /* 0 */ "c...c" - /* 1 */ "....." - /* 2 */ "cdedc" - /* 3 */ "df..d" - /* 4 */ "d...d" - /* 5 */ "d..gd" - /* 6 */ "d..hd" - /* 7 */ "d..id" - /* 8 */ "d...d" - /* 9 */ "djkld" - /* 10 */ "cdddc" + /* 0 */ "addda" + /* 1 */ "mdddm" + /* 2 */ "aceca" + /* 3 */ "ceeec" + /* 4 */ "ceeec" + /* 5 */ "ceeec" + /* 6 */ "ceeec" + /* 7 */ "ceeec" + /* 8 */ "ceeec" + /* 9 */ "ceeec" + /* 10 */ "accca" // Level 2 /* z\x* 01234 */ - /* 0 */ "c...c" + /* 0 */ "a...a" /* 1 */ "....." - /* 2 */ "cdndc" - /* 3 */ "df..d" - /* 4 */ "d..od" - /* 5 */ "p...p" - /* 6 */ "p..qp" - /* 7 */ "p...p" - /* 8 */ "d...d" - /* 9 */ "d...d" - /* 10 */ "cdpdc" + /* 2 */ "acfca" + /* 3 */ "cg..c" + /* 4 */ "c...c" + /* 5 */ "c..hc" + /* 6 */ "c..ic" + /* 7 */ "c..jc" + /* 8 */ "c...c" + /* 9 */ "cklnc" + /* 10 */ "accca" // Level 3 /* z\x* 01234 */ - /* 0 */ "r...r" - /* 1 */ "d...d" - /* 2 */ "cdddc" - /* 3 */ "dfssd" - /* 4 */ "dsssd" - /* 5 */ "tsssu" - /* 6 */ "tsssu" - /* 7 */ "tsssu" - /* 8 */ "dsssd" - /* 9 */ "dsssd" - /* 10 */ "cdvdc" + /* 0 */ "a...a" + /* 1 */ "....." + /* 2 */ "acoca" + /* 3 */ "cg..c" + /* 4 */ "c..pc" + /* 5 */ "q...q" + /* 6 */ "q..rq" + /* 7 */ "q...q" + /* 8 */ "c...c" + /* 9 */ "c...c" + /* 10 */ "acqca" // Level 4 /* z\x* 01234 */ + /* 0 */ "s...s" + /* 1 */ "c...c" + /* 2 */ "accca" + /* 3 */ "cgttc" + /* 4 */ "ctttc" + /* 5 */ "utttv" + /* 6 */ "utttv" + /* 7 */ "utttv" + /* 8 */ "ctttc" + /* 9 */ "ctttc" + /* 10 */ "acwca" + + // Level 5 + /* z\x* 01234 */ /* 0 */ "....." /* 1 */ "....." - /* 2 */ "dwdwd" - /* 3 */ "wx..w" - /* 4 */ "w...w" - /* 5 */ "w...w" - /* 6 */ "d...d" - /* 7 */ "w...w" - /* 8 */ "w...w" - /* 9 */ "w...w" - /* 10 */ "dwdwd", + /* 2 */ "cxcxc" + /* 3 */ "xy..x" + /* 4 */ "x...x" + /* 5 */ "x...x" + /* 6 */ "c...c" + /* 7 */ "x...x" + /* 8 */ "x...x" + /* 9 */ "x...x" + /* 10 */ "cxcxc", // Connectors: - "-1: 2, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 2, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1535,97 +1652,110 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 68, ID 558, created by STR_Warrior { // Size: - 9, 5, 9, // SizeX = 9, SizeY = 5, SizeZ = 9 + 9, 6, 9, // SizeX = 9, SizeY = 6, SizeZ = 9 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 9, 4, 9, // MaxX, MaxY, MaxZ + 9, 5, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c: 24: 2\n" /* sandstone */ - "d: 24: 0\n" /* sandstone */ - "e: 64: 7\n" /* wooddoorblock */ - "f: 65: 2\n" /* ladder */ - "g: 64:12\n" /* wooddoorblock */ - "h:101: 0\n" /* ironbars */ - "i: 50: 1\n" /* torch */ - "j: 50: 4\n" /* torch */ - "k:128: 2\n" /* sandstonestairs */ - "l:126: 8\n" /* woodenslab */ + "a: 24: 2\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ + "c: 24: 0\n" /* sandstone */ + "d: 13: 0\n" /* gravel */ + "e: 5: 0\n" /* wood */ + "f: 64: 3\n" /* wooddoorblock */ + "g: 65: 2\n" /* ladder */ + "h: 64: 8\n" /* wooddoorblock */ + "i:101: 0\n" /* ironbars */ + "j: 50: 1\n" /* torch */ + "k: 50: 4\n" /* torch */ + "l:128: 2\n" /* sandstonestairs */ "m: 19: 0\n" /* sponge */ - "n:128: 6\n" /* sandstonestairs */ - "o:128: 5\n" /* sandstonestairs */ - "p:128: 4\n" /* sandstonestairs */ - "q:128: 7\n" /* sandstonestairs */ - "r: 44: 1\n" /* step */ - "s: 96: 6\n" /* trapdoor */, + "n:126: 8\n" /* woodenslab */ + "o:128: 6\n" /* sandstonestairs */ + "p:128: 5\n" /* sandstonestairs */ + "q:128: 4\n" /* sandstonestairs */ + "r:128: 7\n" /* sandstonestairs */ + "s: 44: 1\n" /* step */ + "t: 96: 2\n" /* trapdoor */, // Block data: // Level 0 /* z\x* 012345678 */ - /* 0 */ "aaaaaaaaa" - /* 1 */ "aaaaaaaaa" - /* 2 */ "aaaaaabaa" - /* 3 */ "aaaaabbba" - /* 4 */ "aaaaabbba" - /* 5 */ "abbbbbbba" - /* 6 */ "abbbbbbba" - /* 7 */ "abbbbbbba" - /* 8 */ "aaaaaaaaa" + /* 0 */ "mmmmabbba" + /* 1 */ "mmmmmbbbm" + /* 2 */ "mmmmaccca" + /* 3 */ "mmmmccccc" + /* 4 */ "acccacccc" + /* 5 */ "ccccccccc" + /* 6 */ "ccccccccc" + /* 7 */ "ccccccccc" + /* 8 */ "accccccca" // Level 1 /* z\x* 012345678 */ - /* 0 */ "mmmmc...c" - /* 1 */ "mmmm....." - /* 2 */ "mmmmcdedc" - /* 3 */ "mmmmd...d" - /* 4 */ "cdddd...d" - /* 5 */ "d.......d" - /* 6 */ "d.......d" - /* 7 */ "d......fd" - /* 8 */ "cdddddddc" + /* 0 */ "mmmmaddda" + /* 1 */ "mmmmmdddm" + /* 2 */ "mmmmaceca" + /* 3 */ "mmmmceeec" + /* 4 */ "acccaeeec" + /* 5 */ "ceeeeeeec" + /* 6 */ "ceeeeeeec" + /* 7 */ "ceeeeeeec" + /* 8 */ "accccccca" // Level 2 /* z\x* 012345678 */ - /* 0 */ "mmmmc...c" + /* 0 */ "mmmma...a" /* 1 */ "mmmm....." - /* 2 */ "mmmmcdgdc" - /* 3 */ "mmmmd...d" - /* 4 */ "cdhdd...h" - /* 5 */ "d.......h" - /* 6 */ "h.......d" - /* 7 */ "di....jfd" - /* 8 */ "cddhhhddc" + /* 2 */ "mmmmacfca" + /* 3 */ "mmmmc...c" + /* 4 */ "accca...c" + /* 5 */ "c.......c" + /* 6 */ "c.......c" + /* 7 */ "c......gc" + /* 8 */ "accccccca" // Level 3 /* z\x* 012345678 */ - /* 0 */ "mmmmk...k" - /* 1 */ "mmmmd...d" - /* 2 */ "mmmmcdddc" - /* 3 */ "mmmmdllld" - /* 4 */ "cdnddlllo" - /* 5 */ "dlllllllo" - /* 6 */ "pllllllld" - /* 7 */ "dllllllfd" - /* 8 */ "cddqqqddc" + /* 0 */ "mmmma...a" + /* 1 */ "mmmm....." + /* 2 */ "mmmmachca" + /* 3 */ "mmmmc...c" + /* 4 */ "acica...i" + /* 5 */ "c.......i" + /* 6 */ "i.......i" + /* 7 */ "cj....kgc" + /* 8 */ "acciiicca" // Level 4 /* z\x* 012345678 */ + /* 0 */ "mmmml...l" + /* 1 */ "mmmmc...c" + /* 2 */ "mmmmaccca" + /* 3 */ "mmmmcnnnc" + /* 4 */ "acocannnp" + /* 5 */ "cnnnnnnnp" + /* 6 */ "qnnnnnnnp" + /* 7 */ "cnnnnnngc" + /* 8 */ "accrrrcca" + + // Level 5 + /* z\x* 012345678 */ /* 0 */ "mmmm....." /* 1 */ "mmmm....." - /* 2 */ "mmmmcrdrd" - /* 3 */ "mmmmr...r" - /* 4 */ "drrrd...d" - /* 5 */ "r.......r" - /* 6 */ "r.......r" - /* 7 */ "r......sr" - /* 8 */ "drrrdrrrd", + /* 2 */ "mmmmcscsc" + /* 3 */ "mmmms...s" + /* 4 */ "csssc...c" + /* 5 */ "s.......s" + /* 6 */ "s.......s" + /* 7 */ "s......ts" + /* 8 */ "cssscsssc", // Connectors: - "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 6, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1656,102 +1786,117 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 69, ID 559, created by STR_Warrior { // Size: - 9, 5, 9, // SizeX = 9, SizeY = 5, SizeZ = 9 + 9, 6, 9, // SizeX = 9, SizeY = 6, SizeZ = 9 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 9, 4, 9, // MaxX, MaxY, MaxZ + 9, 5, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ + "A: 96: 2\n" /* trapdoor */ "a: 12: 0\n" /* sand */ - "b: 2: 0\n" /* grass */ - "c: 5: 0\n" /* wood */ - "d: 85: 0\n" /* fence */ - "e: 24: 2\n" /* sandstone */ - "f: 24: 0\n" /* sandstone */ - "g: 64: 7\n" /* wooddoorblock */ - "h: 38: 1\n" /* rose */ - "i: 38: 2\n" /* rose */ - "j: 38: 5\n" /* rose */ - "k: 65: 2\n" /* ladder */ - "l: 64:12\n" /* wooddoorblock */ + "b: 24: 2\n" /* sandstone */ + "c: 4: 0\n" /* cobblestone */ + "d: 3: 0\n" /* dirt */ + "e: 24: 0\n" /* sandstone */ + "f: 13: 0\n" /* gravel */ + "g: 2: 0\n" /* grass */ + "h: 5: 0\n" /* wood */ + "i: 85: 0\n" /* fence */ + "j: 64: 3\n" /* wooddoorblock */ + "k: 38: 1\n" /* rose */ + "l: 38: 2\n" /* rose */ "m: 19: 0\n" /* sponge */ - "n:101: 0\n" /* ironbars */ - "o: 50: 1\n" /* torch */ - "p: 50: 4\n" /* torch */ - "q:128: 2\n" /* sandstonestairs */ - "r:126: 8\n" /* woodenslab */ - "s:128: 6\n" /* sandstonestairs */ - "t:128: 5\n" /* sandstonestairs */ - "u:128: 4\n" /* sandstonestairs */ - "v:128: 7\n" /* sandstonestairs */ - "w: 44: 1\n" /* step */ - "x: 96: 6\n" /* trapdoor */, + "n: 38: 5\n" /* rose */ + "o: 65: 2\n" /* ladder */ + "p: 64: 8\n" /* wooddoorblock */ + "q:101: 0\n" /* ironbars */ + "r: 50: 1\n" /* torch */ + "s: 50: 4\n" /* torch */ + "t:128: 2\n" /* sandstonestairs */ + "u:126: 8\n" /* woodenslab */ + "v:128: 6\n" /* sandstonestairs */ + "w:128: 5\n" /* sandstonestairs */ + "x:128: 4\n" /* sandstonestairs */ + "y:128: 7\n" /* sandstonestairs */ + "z: 44: 1\n" /* step */, // Block data: // Level 0 /* z\x* 012345678 */ - /* 0 */ "aaaaaaaaa" - /* 1 */ "abbbaaaaa" - /* 2 */ "abbbaacaa" - /* 3 */ "abbbaccca" - /* 4 */ "aaaaaccca" - /* 5 */ "accccccca" - /* 6 */ "accccccca" - /* 7 */ "accccccca" - /* 8 */ "aaaaaaaaa" + /* 0 */ "aaaabcccb" + /* 1 */ "adddccccm" + /* 2 */ "adddbeeeb" + /* 3 */ "adddeeeee" + /* 4 */ "beeebeeee" + /* 5 */ "eeeeeeeee" + /* 6 */ "eeeeeeeee" + /* 7 */ "eeeeeeeee" + /* 8 */ "beeeeeeeb" // Level 1 /* z\x* 012345678 */ - /* 0 */ "dddde...e" - /* 1 */ "d........" - /* 2 */ "d...efgfe" - /* 3 */ "dhijf...f" - /* 4 */ "effff...f" - /* 5 */ "f.......f" - /* 6 */ "f.......f" - /* 7 */ "f......kf" - /* 8 */ "efffffffe" + /* 0 */ "aaaabfffb" + /* 1 */ "agggffffm" + /* 2 */ "agggbeheb" + /* 3 */ "agggehhhe" + /* 4 */ "beeebhhhe" + /* 5 */ "ehhhhhhhe" + /* 6 */ "ehhhhhhhe" + /* 7 */ "ehhhhhhhe" + /* 8 */ "beeeeeeeb" // Level 2 /* z\x* 012345678 */ - /* 0 */ "....e...e" - /* 1 */ "........." - /* 2 */ "....eflfe" - /* 3 */ "....f...f" - /* 4 */ "efnff...n" - /* 5 */ "f.......n" - /* 6 */ "n.......f" - /* 7 */ "fo....pkf" - /* 8 */ "effnnnffe" + /* 0 */ "iiiib...b" + /* 1 */ "i........" + /* 2 */ "i...bejeb" + /* 3 */ "iklne...e" + /* 4 */ "beeeb...e" + /* 5 */ "e.......e" + /* 6 */ "e.......e" + /* 7 */ "e......oe" + /* 8 */ "beeeeeeeb" // Level 3 /* z\x* 012345678 */ - /* 0 */ "....q...q" - /* 1 */ "....f...f" - /* 2 */ "....efffe" - /* 3 */ "....frrrf" - /* 4 */ "efsffrrrt" - /* 5 */ "frrrrrrrt" - /* 6 */ "urrrrrrrf" - /* 7 */ "frrrrrrkf" - /* 8 */ "effvvvffe" + /* 0 */ "....b...b" + /* 1 */ "........." + /* 2 */ "....bepeb" + /* 3 */ "....e...e" + /* 4 */ "beqeb...q" + /* 5 */ "e.......q" + /* 6 */ "q.......q" + /* 7 */ "er....soe" + /* 8 */ "beeqqqeeb" // Level 4 /* z\x* 012345678 */ + /* 0 */ "....t...t" + /* 1 */ "....e...e" + /* 2 */ "....beeeb" + /* 3 */ "....euuue" + /* 4 */ "bevebuuuw" + /* 5 */ "euuuuuuuw" + /* 6 */ "xuuuuuuuw" + /* 7 */ "euuuuuuoe" + /* 8 */ "beeyyyeeb" + + // Level 5 + /* z\x* 012345678 */ /* 0 */ "........." /* 1 */ "........." - /* 2 */ "....ewfwf" - /* 3 */ "....w...w" - /* 4 */ "fwwwf...f" - /* 5 */ "w.......w" - /* 6 */ "w.......w" - /* 7 */ "w......xw" - /* 8 */ "fwwwfwwwf", + /* 2 */ "....ezeze" + /* 3 */ "....z...z" + /* 4 */ "ezzze...e" + /* 5 */ "z.......z" + /* 6 */ "z.......z" + /* 7 */ "z......Az" + /* 8 */ "ezzzezzze", // Connectors: - "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 6, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1782,107 +1927,122 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 73, ID 563, created by xoft { // Size: - 9, 5, 11, // SizeX = 9, SizeY = 5, SizeZ = 11 + 9, 6, 11, // SizeX = 9, SizeY = 6, SizeZ = 11 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 9, 4, 11, // MaxX, MaxY, MaxZ + 9, 5, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c: 24: 2\n" /* sandstone */ - "d: 24: 0\n" /* sandstone */ - "e: 64: 7\n" /* wooddoorblock */ - "f: 65: 2\n" /* ladder */ - "g:101: 0\n" /* ironbars */ - "h: 64:12\n" /* wooddoorblock */ - "i: 50: 1\n" /* torch */ - "j: 50: 2\n" /* torch */ - "k:128: 2\n" /* sandstonestairs */ - "l:128: 6\n" /* sandstonestairs */ + "a: 24: 2\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ + "c: 24: 0\n" /* sandstone */ + "d: 13: 0\n" /* gravel */ + "e: 5: 0\n" /* wood */ + "f: 64: 3\n" /* wooddoorblock */ + "g: 65: 2\n" /* ladder */ + "h:101: 0\n" /* ironbars */ + "i: 64: 8\n" /* wooddoorblock */ + "j: 50: 1\n" /* torch */ + "k: 50: 2\n" /* torch */ + "l:128: 2\n" /* sandstonestairs */ "m: 19: 0\n" /* sponge */ - "n:126: 8\n" /* woodenslab */ - "o:128: 4\n" /* sandstonestairs */ - "p:128: 5\n" /* sandstonestairs */ - "q:128: 7\n" /* sandstonestairs */ - "r: 44: 1\n" /* step */ - "s: 96: 6\n" /* trapdoor */, + "n:128: 6\n" /* sandstonestairs */ + "o:126: 8\n" /* woodenslab */ + "p:128: 4\n" /* sandstonestairs */ + "q:128: 5\n" /* sandstonestairs */ + "r:128: 7\n" /* sandstonestairs */ + "s: 44: 1\n" /* step */ + "t: 96: 2\n" /* trapdoor */, // Block data: // Level 0 /* z\x* 012345678 */ - /* 0 */ "aaaaaaaaa" - /* 1 */ "aaaaaaaaa" - /* 2 */ "aaaaaabaa" - /* 3 */ "abbbbbbba" - /* 4 */ "abbbbbbba" - /* 5 */ "abbbbbbba" - /* 6 */ "aaaaabbba" - /* 7 */ "aaaaabbba" - /* 8 */ "aaaaabbba" - /* 9 */ "aaaaabbba" - /* 10 */ "aaaaaaaaa" + /* 0 */ "mmmmabbba" + /* 1 */ "mmmmmbbbm" + /* 2 */ "accccccca" + /* 3 */ "ccccccccc" + /* 4 */ "ccccccccc" + /* 5 */ "ccccccccc" + /* 6 */ "acccacccc" + /* 7 */ "mmmmccccc" + /* 8 */ "mmmmccccc" + /* 9 */ "mmmmccccc" + /* 10 */ "mmmmaccca" // Level 1 /* z\x* 012345678 */ - /* 0 */ "....c...c" - /* 1 */ "........." - /* 2 */ "cdddddedc" - /* 3 */ "d.......d" - /* 4 */ "d.......d" - /* 5 */ "d.......d" - /* 6 */ "cdddd...d" - /* 7 */ "mmmmd...d" - /* 8 */ "mmmmd...d" - /* 9 */ "mmmmd..fd" - /* 10 */ "mmmmddddc" + /* 0 */ "mmmmaddda" + /* 1 */ "mmmmmdddm" + /* 2 */ "accccceca" + /* 3 */ "ceeeeeeec" + /* 4 */ "ceeeeeeec" + /* 5 */ "ceeeeeeec" + /* 6 */ "acccaeeec" + /* 7 */ "mmmmceeec" + /* 8 */ "mmmmceeec" + /* 9 */ "mmmmceeec" + /* 10 */ "mmmmaccca" // Level 2 /* z\x* 012345678 */ - /* 0 */ "....c...c" - /* 1 */ "........." - /* 2 */ "cdgdddhdc" - /* 3 */ "d.......d" - /* 4 */ "g.......d" - /* 5 */ "di......g" - /* 6 */ "cdgdd...g" - /* 7 */ "mmmmd...g" - /* 8 */ "mmmmg..jd" - /* 9 */ "mmmmd..fd" - /* 10 */ "mmmmddgdc" + /* 0 */ "mmmma...a" + /* 1 */ "mmmm....." + /* 2 */ "acccccfca" + /* 3 */ "c.......c" + /* 4 */ "c.......c" + /* 5 */ "c.......c" + /* 6 */ "accca...c" + /* 7 */ "mmmmc...c" + /* 8 */ "mmmmc...c" + /* 9 */ "mmmmc..gc" + /* 10 */ "mmmmaccca" // Level 3 /* z\x* 012345678 */ - /* 0 */ "....k...k" - /* 1 */ "....d...d" - /* 2 */ "cdldddddc" - /* 3 */ "dnnnnnnnd" - /* 4 */ "onnnnnnnd" - /* 5 */ "dnnnnnnnp" - /* 6 */ "cdqddnnnp" - /* 7 */ "mmmmdnnnp" - /* 8 */ "mmmmonnnd" - /* 9 */ "mmmmdnnfd" - /* 10 */ "mmmmddqdc" + /* 0 */ "mmmma...a" + /* 1 */ "mmmm....." + /* 2 */ "achcccica" + /* 3 */ "c.......c" + /* 4 */ "h.......c" + /* 5 */ "cj......h" + /* 6 */ "achca...h" + /* 7 */ "mmmmc...h" + /* 8 */ "mmmmh..kc" + /* 9 */ "mmmmc..gc" + /* 10 */ "mmmmachca" // Level 4 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "drrrdrdrd" - /* 3 */ "r.......r" - /* 4 */ "r.......r" - /* 5 */ "r.......r" - /* 6 */ "drrrd...d" - /* 7 */ "mmmmr...r" - /* 8 */ "mmmmr...r" - /* 9 */ "mmmmr..sr" - /* 10 */ "mmmmdrrrd", + /* 0 */ "mmmml...l" + /* 1 */ "mmmmc...c" + /* 2 */ "acnccccca" + /* 3 */ "coooooooc" + /* 4 */ "poooooooc" + /* 5 */ "coooooooq" + /* 6 */ "acrcaoooq" + /* 7 */ "mmmmcoooq" + /* 8 */ "mmmmpoooc" + /* 9 */ "mmmmcoogc" + /* 10 */ "mmmmacrca" + + // Level 5 + /* z\x* 012345678 */ + /* 0 */ "mmmm....." + /* 1 */ "mmmm....." + /* 2 */ "cssscscsc" + /* 3 */ "s.......s" + /* 4 */ "s.......s" + /* 5 */ "s.......s" + /* 6 */ "csssc...c" + /* 7 */ "mmmms...s" + /* 8 */ "mmmms...s" + /* 9 */ "mmmms..ts" + /* 10 */ "mmmmcsssc", // Connectors: - "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 6, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1909,120 +2069,263 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // LittleTower: - // The data has been exported from the gallery Desert, area index 79, ID 595, created by STR_Warrior + // LittleHouse8: + // The data has been exported from the gallery Desert, area index 99, ID 739, created by STR_Warrior { // Size: - 5, 8, 7, // SizeX = 5, SizeY = 8, SizeZ = 7 + 9, 6, 9, // SizeX = 9, SizeY = 6, SizeZ = 9 // Hitbox (relative to bounding box): - -1, 0, 0, // MinX, MinY, MinZ - 5, 7, 7, // MaxX, MaxY, MaxZ + 0, 0, -1, // MinX, MinY, MinZ + 9, 5, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c: 24: 2\n" /* sandstone */ - "d: 24: 0\n" /* sandstone */ - "e: 64: 7\n" /* wooddoorblock */ - "f: 65: 5\n" /* ladder */ - "g: 64:12\n" /* wooddoorblock */ + "a: 24: 2\n" /* sandstone */ + "b: 24: 0\n" /* sandstone */ + "c: 4: 0\n" /* cobblestone */ + "d: 13: 0\n" /* gravel */ + "e: 5: 0\n" /* wood */ + "f: 64: 2\n" /* wooddoorblock */ + "g: 65: 2\n" /* ladder */ "h:101: 0\n" /* ironbars */ - "i: 50: 4\n" /* torch */ - "j:128: 2\n" /* sandstonestairs */ - "k:126: 8\n" /* woodenslab */ - "l:128: 4\n" /* sandstonestairs */ + "i: 64: 8\n" /* wooddoorblock */ + "j: 50: 1\n" /* torch */ + "k:128: 6\n" /* sandstonestairs */ + "l:126: 8\n" /* woodenslab */ "m: 19: 0\n" /* sponge */ "n:128: 5\n" /* sandstonestairs */ - "o:128: 7\n" /* sandstonestairs */ - "p:128: 6\n" /* sandstonestairs */ + "o:128: 4\n" /* sandstonestairs */ + "p:128: 7\n" /* sandstonestairs */ "q: 44: 1\n" /* step */ - "r: 96: 5\n" /* trapdoor */, + "r: 96: 2\n" /* trapdoor */, + + // Block data: + // Level 0 + /* z\x* 012345678 */ + /* 0 */ "mmmmabbba" + /* 1 */ "ccccbbbbb" + /* 2 */ "ccccbbbbb" + /* 3 */ "ccccbbbbb" + /* 4 */ "abbbabbbb" + /* 5 */ "bbbbbbbbb" + /* 6 */ "bbbbbbbbb" + /* 7 */ "bbbbbbbbb" + /* 8 */ "abbbbbbba" + + // Level 1 + /* z\x* 012345678 */ + /* 0 */ "mmmmabbba" + /* 1 */ "ddddbeeeb" + /* 2 */ "ddddeeeeb" + /* 3 */ "ddddbeeeb" + /* 4 */ "abbbaeeeb" + /* 5 */ "beeeeeeeb" + /* 6 */ "beeeeeeeb" + /* 7 */ "beeeeeeeb" + /* 8 */ "abbbbbbba" + + // Level 2 + /* z\x* 012345678 */ + /* 0 */ "mmmmabbba" + /* 1 */ "....b...b" + /* 2 */ "....f...b" + /* 3 */ "....b...b" + /* 4 */ "abbba...b" + /* 5 */ "b.......b" + /* 6 */ "b.......b" + /* 7 */ "b......gb" + /* 8 */ "abbbbbbba" + + // Level 3 + /* z\x* 012345678 */ + /* 0 */ "mmmmabhba" + /* 1 */ "....b...b" + /* 2 */ "....i...b" + /* 3 */ "....b...h" + /* 4 */ "abhbaj..h" + /* 5 */ "b.......h" + /* 6 */ "h.......b" + /* 7 */ "b......gb" + /* 8 */ "abbhhhbba" + + // Level 4 + /* z\x* 012345678 */ + /* 0 */ "mmmmabkba" + /* 1 */ "....blllb" + /* 2 */ "....blllb" + /* 3 */ "....bllln" + /* 4 */ "abkballln" + /* 5 */ "bllllllln" + /* 6 */ "olllllllb" + /* 7 */ "bllllllgb" + /* 8 */ "abbpppbba" + + // Level 5 + /* z\x* 012345678 */ + /* 0 */ "mmmmbqbqb" + /* 1 */ "....q...q" + /* 2 */ "....q...q" + /* 3 */ "....q...q" + /* 4 */ "bqqqb...b" + /* 5 */ "q.......q" + /* 6 */ "b.......q" + /* 7 */ "q......rq" + /* 8 */ "bqqqbqqqb", + + // Connectors: + "-1: 0, 2, 2: 4\n" /* Type -1, direction X- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // LittleHouse8 + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // LittleTower: + // The data has been exported from the gallery Desert, area index 79, ID 595, created by STR_Warrior + { + // Size: + 5, 9, 7, // SizeX = 5, SizeY = 9, SizeZ = 7 + + // Hitbox (relative to bounding box): + -1, 0, 0, // MinX, MinY, MinZ + 5, 8, 7, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 24: 2\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ + "c: 24: 0\n" /* sandstone */ + "d: 13: 0\n" /* gravel */ + "e: 5: 0\n" /* wood */ + "f: 64: 3\n" /* wooddoorblock */ + "g: 65: 5\n" /* ladder */ + "h: 64: 8\n" /* wooddoorblock */ + "i:101: 0\n" /* ironbars */ + "j: 50: 4\n" /* torch */ + "k:128: 2\n" /* sandstonestairs */ + "l:126: 8\n" /* woodenslab */ + "m: 19: 0\n" /* sponge */ + "n:128: 4\n" /* sandstonestairs */ + "o:128: 5\n" /* sandstonestairs */ + "p:128: 7\n" /* sandstonestairs */ + "q:128: 6\n" /* sandstonestairs */ + "r: 44: 1\n" /* step */ + "s: 96: 1\n" /* trapdoor */, // Block data: // Level 0 /* z\x* 01234 */ - /* 0 */ "aaaaa" - /* 1 */ "aaaaa" - /* 2 */ "aabaa" - /* 3 */ "abbba" - /* 4 */ "abbba" - /* 5 */ "abbba" - /* 6 */ "aaaaa" + /* 0 */ "abbba" + /* 1 */ "mbbbm" + /* 2 */ "accca" + /* 3 */ "ccccc" + /* 4 */ "ccccc" + /* 5 */ "ccccc" + /* 6 */ "accca" // Level 1 /* z\x* 01234 */ - /* 0 */ "c...c" - /* 1 */ "....." - /* 2 */ "cdedc" - /* 3 */ "df..d" - /* 4 */ "d...d" - /* 5 */ "d...d" - /* 6 */ "cdddc" + /* 0 */ "addda" + /* 1 */ "mdddm" + /* 2 */ "aceca" + /* 3 */ "ceeec" + /* 4 */ "ceeec" + /* 5 */ "ceeec" + /* 6 */ "accca" // Level 2 /* z\x* 01234 */ - /* 0 */ "c...c" + /* 0 */ "a...a" /* 1 */ "....." - /* 2 */ "cdgdc" - /* 3 */ "df..d" - /* 4 */ "h...h" - /* 5 */ "d..id" - /* 6 */ "cdhdc" + /* 2 */ "acfca" + /* 3 */ "cg..c" + /* 4 */ "c...c" + /* 5 */ "c...c" + /* 6 */ "accca" // Level 3 /* z\x* 01234 */ - /* 0 */ "j...j" - /* 1 */ "d...d" - /* 2 */ "cdddc" - /* 3 */ "dfkkd" - /* 4 */ "lkkkn" - /* 5 */ "dkkkd" - /* 6 */ "cdodc" + /* 0 */ "a...a" + /* 1 */ "....." + /* 2 */ "achca" + /* 3 */ "cg..c" + /* 4 */ "i...i" + /* 5 */ "c..jc" + /* 6 */ "acica" // Level 4 /* z\x* 01234 */ - /* 0 */ "....." - /* 1 */ "....." - /* 2 */ "cdddc" - /* 3 */ "df..d" - /* 4 */ "d...d" - /* 5 */ "d...d" - /* 6 */ "cdddc" + /* 0 */ "k...k" + /* 1 */ "c...c" + /* 2 */ "accca" + /* 3 */ "cgllc" + /* 4 */ "nlllo" + /* 5 */ "clllc" + /* 6 */ "acpca" // Level 5 /* z\x* 01234 */ /* 0 */ "....." /* 1 */ "....." - /* 2 */ "cdhdc" - /* 3 */ "df..d" - /* 4 */ "h...h" - /* 5 */ "d..id" - /* 6 */ "cdhdc" + /* 2 */ "accca" + /* 3 */ "cg..c" + /* 4 */ "c...c" + /* 5 */ "c...c" + /* 6 */ "accca" // Level 6 /* z\x* 01234 */ /* 0 */ "....." /* 1 */ "....." - /* 2 */ "cdpdc" - /* 3 */ "dfkkd" - /* 4 */ "lkkkn" - /* 5 */ "dkkkd" - /* 6 */ "cdodc" + /* 2 */ "acica" + /* 3 */ "cg..c" + /* 4 */ "i...i" + /* 5 */ "c..jc" + /* 6 */ "acica" // Level 7 /* z\x* 01234 */ /* 0 */ "....." /* 1 */ "....." - /* 2 */ "dqdqd" - /* 3 */ "qr..q" - /* 4 */ "d...d" - /* 5 */ "q...q" - /* 6 */ "dqdqd", + /* 2 */ "acqca" + /* 3 */ "cgllc" + /* 4 */ "nlllo" + /* 5 */ "clllc" + /* 6 */ "acpca" + + // Level 8 + /* z\x* 01234 */ + /* 0 */ "....." + /* 1 */ "....." + /* 2 */ "crcrc" + /* 3 */ "rs..r" + /* 4 */ "c...c" + /* 5 */ "r...r" + /* 6 */ "crcrc", // Connectors: - "-1: 2, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 2, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2053,141 +2356,156 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 71, ID 561, created by STR_Warrior { // Size: - 15, 8, 9, // SizeX = 15, SizeY = 8, SizeZ = 9 + 15, 9, 9, // SizeX = 15, SizeY = 9, SizeZ = 9 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 15, 7, 9, // MaxX, MaxY, MaxZ + 15, 8, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c: 24: 2\n" /* sandstone */ - "d: 24: 0\n" /* sandstone */ - "e: 64: 3\n" /* wooddoorblock */ - "f: 85: 0\n" /* fence */ - "g: 64: 0\n" /* wooddoorblock */ - "h: 65: 5\n" /* ladder */ - "i: 64: 8\n" /* wooddoorblock */ - "j:101: 0\n" /* ironbars */ - "k: 50: 4\n" /* torch */ - "l:128: 2\n" /* sandstonestairs */ + "a: 24: 2\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ + "c: 24: 0\n" /* sandstone */ + "d: 12: 0\n" /* sand */ + "e: 13: 0\n" /* gravel */ + "f: 5: 0\n" /* wood */ + "g: 64: 3\n" /* wooddoorblock */ + "h: 85: 0\n" /* fence */ + "i: 64: 0\n" /* wooddoorblock */ + "j: 65: 5\n" /* ladder */ + "k: 64: 8\n" /* wooddoorblock */ + "l:101: 0\n" /* ironbars */ "m: 19: 0\n" /* sponge */ - "n:126: 8\n" /* woodenslab */ - "o:128: 4\n" /* sandstonestairs */ - "p:128: 7\n" /* sandstonestairs */ - "q: 44: 1\n" /* step */ - "r: 50: 3\n" /* torch */ - "s:128: 6\n" /* sandstonestairs */, + "n: 50: 4\n" /* torch */ + "o:128: 2\n" /* sandstonestairs */ + "p:126: 8\n" /* woodenslab */ + "q:128: 4\n" /* sandstonestairs */ + "r:128: 7\n" /* sandstonestairs */ + "s: 44: 1\n" /* step */ + "t: 50: 3\n" /* torch */ + "u:128: 6\n" /* sandstonestairs */, // Block data: // Level 0 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "aaaaaaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaaaaaa" - /* 2 */ "aaaaabaaaaaaaaa" - /* 3 */ "abbbbbbbbbaaaaa" - /* 4 */ "abbbbbbbbbaaaaa" - /* 5 */ "abbbbbbbbbbaaaa" - /* 6 */ "abbbbbbbbbaaaaa" - /* 7 */ "abbbbbbbbbaaaaa" - /* 8 */ "aaaaaaaaaaaaaaa" + /* 0 */ "mmmabbbammmmmmm" + /* 1 */ "mmmmbbbmmmmmmmm" + /* 2 */ "acccccccccadddd" + /* 3 */ "cccccccccccdddd" + /* 4 */ "cccccccccccdddd" + /* 5 */ "cccccccccccdddd" + /* 6 */ "cccccccccccdddd" + /* 7 */ "cccccccccccdddd" + /* 8 */ "acccccccccadddd" // Level 1 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "...c...c......." - /* 1 */ "..............." - /* 2 */ "cddddeddddcffff" - /* 3 */ "d.........d...f" - /* 4 */ "d.........d...f" - /* 5 */ "d.........g...f" - /* 6 */ "d.........d...f" - /* 7 */ "d.........dh..f" - /* 8 */ "cdddddddddcffff" + /* 0 */ "mmmaeeeammmmmmm" + /* 1 */ "mmmmeeemmmmmmmm" + /* 2 */ "accccfccccadddd" + /* 3 */ "cfffffffffcdddd" + /* 4 */ "cfffffffffcdddd" + /* 5 */ "cffffffffffdddd" + /* 6 */ "cfffffffffcdddd" + /* 7 */ "cfffffffffcdddd" + /* 8 */ "acccccccccadddd" // Level 2 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "...c...c......." - /* 1 */ "..............." - /* 2 */ "cddddiddddc...." - /* 3 */ "d.........d...." - /* 4 */ "j.........d...." - /* 5 */ "j.........i...." - /* 6 */ "j.........d...." - /* 7 */ "d..k...k..dh..." - /* 8 */ "cdddjjjdddc...." + /* 0 */ "mmma...ammmmmmm" + /* 1 */ "mmm.....mmmmmmm" + /* 2 */ "accccgccccahhhh" + /* 3 */ "c.........c...h" + /* 4 */ "c.........c...h" + /* 5 */ "c.........i...h" + /* 6 */ "c.........c...h" + /* 7 */ "c.........cj..h" + /* 8 */ "acccccccccahhhh" // Level 3 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "...l...l......." - /* 1 */ "...d...d......." - /* 2 */ "cdddddddddc...." - /* 3 */ "dnnnnnnnnnd...." - /* 4 */ "onnnnnnnnnd...." - /* 5 */ "onnnnnnnnnd...." - /* 6 */ "onnnnnnnnnd...." - /* 7 */ "dnnnnnnnnndh..." - /* 8 */ "cdddpppdddc...." + /* 0 */ "mmma...ammmmmmm" + /* 1 */ "mmm.....mmmmmmm" + /* 2 */ "acccckcccca...." + /* 3 */ "c.........c...." + /* 4 */ "l.........c...." + /* 5 */ "l.........k...." + /* 6 */ "l.........c...." + /* 7 */ "c..n...n..cj..." + /* 8 */ "accclllccca...." // Level 4 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ "..............." - /* 2 */ "dqqqqdqqqqd...." - /* 3 */ "q..cdddc..q...." - /* 4 */ "q..d...d..q...." - /* 5 */ "d.........d...." - /* 6 */ "q..d...d..q...." - /* 7 */ "q..cdddc..q...." - /* 8 */ "dqqqqdqqqqd...." + /* 0 */ "mmmo...ommmmmmm" + /* 1 */ "mmmc...cmmmmmmm" + /* 2 */ "accccccccca...." + /* 3 */ "cpppppppppc...." + /* 4 */ "qpppppppppc...." + /* 5 */ "qpppppppppc...." + /* 6 */ "qpppppppppc...." + /* 7 */ "cpppppppppcj..." + /* 8 */ "acccrrrccca...." // Level 5 /* z\x* 11111 */ /* * 012345678901234 */ + /* 0 */ "mmm.....mmmmmmm" + /* 1 */ "mmm.....mmmmmmm" + /* 2 */ "csssscssssc...." + /* 3 */ "s..accca..s...." + /* 4 */ "s..c...c..s...." + /* 5 */ "c.........c...." + /* 6 */ "s..c...c..s...." + /* 7 */ "s..accca..s...." + /* 8 */ "csssscssssc...." + + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." /* 2 */ "..............." - /* 3 */ "...cdjdc......." - /* 4 */ "...dr..d......." + /* 3 */ "...aclca......." + /* 4 */ "...ct..c......." /* 5 */ "..............." - /* 6 */ "...d...d......." - /* 7 */ "...cdjdc......." + /* 6 */ "...c...c......." + /* 7 */ "...aclca......." /* 8 */ "..............." - // Level 6 + // Level 7 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." /* 2 */ "..............." - /* 3 */ "...cdsdc......." - /* 4 */ "...dnnnd......." - /* 5 */ "...dnnnd......." - /* 6 */ "...dnnnd......." - /* 7 */ "...cdpdc......." + /* 3 */ "...acuca......." + /* 4 */ "...cpppc......." + /* 5 */ "...cpppc......." + /* 6 */ "...cpppc......." + /* 7 */ "...acrca......." /* 8 */ "..............." - // Level 7 + // Level 8 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." /* 1 */ "..............." /* 2 */ "..............." - /* 3 */ "...dqdqd......." - /* 4 */ "...q...q......." - /* 5 */ "...d...d......." - /* 6 */ "...q...q......." - /* 7 */ "...dqdqd......." + /* 3 */ "...cscsc......." + /* 4 */ "...s...s......." + /* 5 */ "...c...c......." + /* 6 */ "...s...s......." + /* 7 */ "...cscsc......." /* 8 */ "...............", // Connectors: - "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2218,130 +2536,145 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 74, ID 573, created by STR_Warrior { // Size: - 11, 9, 9, // SizeX = 11, SizeY = 9, SizeZ = 9 + 11, 10, 9, // SizeX = 11, SizeY = 10, SizeZ = 9 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 11, 8, 9, // MaxX, MaxY, MaxZ + 11, 9, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "A: 96: 3\n" /* trapdoor */ - "B: 96: 6\n" /* trapdoor */ - "C:128: 2\n" /* sandstonestairs */ - "D:128: 0\n" /* sandstonestairs */ - "E: 87: 0\n" /* netherstone */ - "F:128: 1\n" /* sandstonestairs */ - "G:128: 3\n" /* sandstonestairs */ - "H: 51: 0\n" /* fire */ - "I: 44: 9\n" /* step */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c: 24: 2\n" /* sandstone */ - "d: 24: 0\n" /* sandstone */ - "e: 65: 3\n" /* ladder */ - "f: 85: 0\n" /* fence */ - "g: 64: 7\n" /* wooddoorblock */ - "h:134: 1\n" /* 134 */ - "i:134: 2\n" /* 134 */ - "j: 61: 2\n" /* furnace */ - "k:134: 6\n" /* 134 */ - "l:134: 4\n" /* 134 */ + "A:128: 7\n" /* sandstonestairs */ + "B: 44: 1\n" /* step */ + "C: 96: 3\n" /* trapdoor */ + "D: 96: 2\n" /* trapdoor */ + "E:128: 2\n" /* sandstonestairs */ + "F:128: 0\n" /* sandstonestairs */ + "G: 87: 0\n" /* netherstone */ + "H:128: 1\n" /* sandstonestairs */ + "I:128: 3\n" /* sandstonestairs */ + "J: 51: 0\n" /* fire */ + "K: 44: 9\n" /* step */ + "a: 24: 2\n" /* sandstone */ + "b: 24: 0\n" /* sandstone */ + "c: 4: 0\n" /* cobblestone */ + "d: 12: 0\n" /* sand */ + "e: 13: 0\n" /* gravel */ + "f: 5: 0\n" /* wood */ + "g: 65: 3\n" /* ladder */ + "h: 85: 0\n" /* fence */ + "i: 64: 3\n" /* wooddoorblock */ + "j:134: 1\n" /* 134 */ + "k:134: 2\n" /* 134 */ + "l: 61: 2\n" /* furnace */ "m: 19: 0\n" /* sponge */ - "n: 65: 2\n" /* ladder */ - "o:101: 0\n" /* ironbars */ - "p: 50: 2\n" /* torch */ - "q: 47: 0\n" /* bookshelf */ - "r: 64:12\n" /* wooddoorblock */ - "s: 50: 3\n" /* torch */ - "t:171: 8\n" /* carpet */ - "u:128: 6\n" /* sandstonestairs */ - "v:126: 8\n" /* woodenslab */ - "w:128: 5\n" /* sandstonestairs */ - "x:128: 4\n" /* sandstonestairs */ - "y:128: 7\n" /* sandstonestairs */ - "z: 44: 1\n" /* step */, + "n:134: 6\n" /* 134 */ + "o:134: 4\n" /* 134 */ + "p: 65: 2\n" /* ladder */ + "q:101: 0\n" /* ironbars */ + "r: 50: 2\n" /* torch */ + "s: 47: 0\n" /* bookshelf */ + "t: 64: 8\n" /* wooddoorblock */ + "u: 50: 3\n" /* torch */ + "v:171: 8\n" /* carpet */ + "w:128: 6\n" /* sandstonestairs */ + "x:126: 8\n" /* woodenslab */ + "y:128: 5\n" /* sandstonestairs */ + "z:128: 4\n" /* sandstonestairs */, // Block data: // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "aaaaaaaaaaa" - /* 1 */ "abbbaaaaaaa" - /* 2 */ "abbbaaaaaaa" - /* 3 */ "abbbaaaaaaa" - /* 4 */ "abbbaaaabaa" - /* 5 */ "abbbbbbbbba" - /* 6 */ "abbbbbbbbba" - /* 7 */ "abbbbbbbbba" - /* 8 */ "aaaaaaaaaaa" + /* 0 */ "abbbammmcmm" + /* 1 */ "bbbbbdddcdm" + /* 2 */ "bbbbbmmmcdm" + /* 3 */ "bbbbbmmmcdm" + /* 4 */ "bbbbabbbbba" + /* 5 */ "bbbbbbbbbbb" + /* 6 */ "bbbbbbbbbbb" + /* 7 */ "bbbbbbbbbbb" + /* 8 */ "abbbbbbbbba" // Level 1 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "cdddc......" - /* 1 */ "de..dfff.f." - /* 2 */ "d...d....f." - /* 3 */ "d...d....f." - /* 4 */ "d...ddddgdc" - /* 5 */ "d.........d" - /* 6 */ "dhf.......d" - /* 7 */ "dhi.jkl..nd" - /* 8 */ "cdddddddddc" + /* 0 */ "abbbammmemm" + /* 1 */ "bfffbdddedm" + /* 2 */ "bfffbmmmedm" + /* 3 */ "bfffbmmmedm" + /* 4 */ "bfffabbbfba" + /* 5 */ "bfffffffffb" + /* 6 */ "bfffffffffb" + /* 7 */ "bfffffffffb" + /* 8 */ "abbbbbbbbba" // Level 2 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "cdodc......" - /* 1 */ "de..o......" - /* 2 */ "d...o......" - /* 3 */ "o..pd......" - /* 4 */ "o...qdodrdc" - /* 5 */ "o......s..d" - /* 6 */ "d.t.......o" - /* 7 */ "d........nd" - /* 8 */ "cdddooodddc" + /* 0 */ "abbba......" + /* 1 */ "bg..bhhh.h." + /* 2 */ "b...b....h." + /* 3 */ "b...b....h." + /* 4 */ "b...abbbiba" + /* 5 */ "b.........b" + /* 6 */ "bjh.......b" + /* 7 */ "bjk.lno..pb" + /* 8 */ "abbbbbbbbba" // Level 3 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "cdudc......" - /* 1 */ "devvw......" - /* 2 */ "dvvvw......" - /* 3 */ "xvvvd......" - /* 4 */ "xvvvddudddc" - /* 5 */ "xvvvvvvvvvd" - /* 6 */ "dvvvvvvvvvw" - /* 7 */ "dvvvqqqvvnd" - /* 8 */ "cdddyyydddc" + /* 0 */ "abqba......" + /* 1 */ "bg..q......" + /* 2 */ "b...q......" + /* 3 */ "q..rb......" + /* 4 */ "q...sbqbtba" + /* 5 */ "q......u..b" + /* 6 */ "b.v.......q" + /* 7 */ "b........pb" + /* 8 */ "abbbqqqbbba" // Level 4 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "dzzzd......" - /* 1 */ "zA..z......" - /* 2 */ "z...z......" - /* 3 */ "z...z......" - /* 4 */ "d...dzzzzzd" - /* 5 */ "zddd......z" - /* 6 */ "zddd......z" - /* 7 */ "zddd.....Bz" - /* 8 */ "dzzzzdzzzzd" + /* 0 */ "abwba......" + /* 1 */ "bgxxy......" + /* 2 */ "bxxxy......" + /* 3 */ "zxxxb......" + /* 4 */ "zxxxabwbbba" + /* 5 */ "zxxxxxxxxxb" + /* 6 */ "bxxxxxxxxxy" + /* 7 */ "bxxxsssxxpb" + /* 8 */ "abbbAAAbbba" // Level 5 /* z\x* 1 */ /* * 01234567890 */ + /* 0 */ "bBBBb......" + /* 1 */ "BC..B......" + /* 2 */ "B...B......" + /* 3 */ "B...B......" + /* 4 */ "b...bBBBBBb" + /* 5 */ "Bbbb......B" + /* 6 */ "Bbbb......B" + /* 7 */ "Bbbb.....DB" + /* 8 */ "bBBBBbBBBBb" + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ /* 0 */ "..........." /* 1 */ "..........." /* 2 */ "..........." /* 3 */ "..........." /* 4 */ "..........." - /* 5 */ ".cCc......." - /* 6 */ ".DEF......." - /* 7 */ ".cGc......." + /* 5 */ ".aEa......." + /* 6 */ ".FGH......." + /* 7 */ ".aIa......." /* 8 */ "..........." - // Level 6 + // Level 7 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." @@ -2349,12 +2682,12 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 2 */ "..........." /* 3 */ "..........." /* 4 */ "..........." - /* 5 */ ".c.c......." - /* 6 */ "..H........" - /* 7 */ ".c.c......." + /* 5 */ ".a.a......." + /* 6 */ "..J........" + /* 7 */ ".a.a......." /* 8 */ "..........." - // Level 7 + // Level 8 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." @@ -2362,12 +2695,12 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 2 */ "..........." /* 3 */ "..........." /* 4 */ "..........." - /* 5 */ ".ddd......." - /* 6 */ ".dId......." - /* 7 */ ".ddd......." + /* 5 */ ".bbb......." + /* 6 */ ".bKb......." + /* 7 */ ".bbb......." /* 8 */ "..........." - // Level 8 + // Level 9 /* z\x* 1 */ /* * 01234567890 */ /* 0 */ "..........." @@ -2375,13 +2708,13 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 2 */ "..........." /* 3 */ "..........." /* 4 */ "..........." - /* 5 */ ".z.z......." + /* 5 */ ".B.B......." /* 6 */ "..........." - /* 7 */ ".z.z......." + /* 7 */ ".B.B......." /* 8 */ "...........", // Connectors: - "-1: 8, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 8, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2420,30 +2753,30 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // Block definitions: ".: 0: 0\n" /* air */ - "a: 12: 0\n" /* sand */ - "b: 3: 0\n" /* dirt */ - "c: 2: 0\n" /* grass */ - "d: 5: 0\n" /* wood */ - "e: 24: 0\n" /* sandstone */ - "f: 24: 2\n" /* sandstone */ - "g: 85: 0\n" /* fence */ - "h: 64: 3\n" /* wooddoorblock */ - "i: 64: 6\n" /* wooddoorblock */ - "j: 65: 4\n" /* ladder */ - "k: 65: 2\n" /* ladder */ - "l: 50: 1\n" /* torch */ + "a: 24: 2\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ + "c: 3: 0\n" /* dirt */ + "d: 24: 0\n" /* sandstone */ + "e: 13: 0\n" /* gravel */ + "f: 2: 0\n" /* grass */ + "g: 5: 0\n" /* wood */ + "h: 85: 0\n" /* fence */ + "i: 64: 3\n" /* wooddoorblock */ + "j: 64: 2\n" /* wooddoorblock */ + "k: 65: 4\n" /* ladder */ + "l: 65: 2\n" /* ladder */ "m: 19: 0\n" /* sponge */ - "n: 50: 2\n" /* torch */ - "o:101: 0\n" /* ironbars */ - "p: 64: 8\n" /* wooddoorblock */ - "q: 64:12\n" /* wooddoorblock */ + "n: 50: 1\n" /* torch */ + "o: 50: 2\n" /* torch */ + "p:101: 0\n" /* ironbars */ + "q: 64: 8\n" /* wooddoorblock */ "r:128: 2\n" /* sandstonestairs */ "s:128: 6\n" /* sandstonestairs */ "t:126: 8\n" /* woodenslab */ "u:128: 5\n" /* sandstonestairs */ "v:128: 7\n" /* sandstonestairs */ "w: 44: 1\n" /* step */ - "x: 96: 4\n" /* trapdoor */ + "x: 96: 0\n" /* trapdoor */ "y:126: 0\n" /* woodenslab */ "z:128: 4\n" /* sandstonestairs */, @@ -2451,92 +2784,92 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // Level 0 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "aaaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaaa" - /* 2 */ "bbbbbaaaaaaa" - /* 3 */ "bbbbbaaaaaaa" - /* 4 */ "bbbbbaaaaaaa" - /* 5 */ "bbbbbaaaaaaa" - /* 6 */ "bbbaaaaaaaaa" - /* 7 */ "aaaaaaaaaaaa" - /* 8 */ "aaaaaaaaaaaa" - /* 9 */ "aaaaaaaaaaaa" - /* 10 */ "aaaaaaaaaaaa" + /* 0 */ "mmmmmammbbba" + /* 1 */ "mmmmmmmmbbbm" + /* 2 */ "cccccaddddda" + /* 3 */ "cccccddddddd" + /* 4 */ "cccccddddddd" + /* 5 */ "cccccddddddd" + /* 6 */ "cccddddddddd" + /* 7 */ "mmmddddddddd" + /* 8 */ "mmmdddddddda" + /* 9 */ "mmmdddddmmmm" + /* 10 */ "mmmadddammmm" // Level 1 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ "aaaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaaa" - /* 2 */ "cccccaaaadaa" - /* 3 */ "cccccaddddda" - /* 4 */ "cccccdddddda" - /* 5 */ "cccccaddddda" - /* 6 */ "cccaadddddda" - /* 7 */ "aaaaddddddda" - /* 8 */ "aaaadddaaaaa" - /* 9 */ "aaaadddaaaaa" - /* 10 */ "aaaaaaaaaaaa" + /* 0 */ "mmmmmammeeea" + /* 1 */ "mmmmmmmmeeem" + /* 2 */ "fffffadddgda" + /* 3 */ "fffffdgggggd" + /* 4 */ "fffffggggggd" + /* 5 */ "fffffdgggggd" + /* 6 */ "fffddggggggd" + /* 7 */ "mmmdgggggggd" + /* 8 */ "mmmdggggddda" + /* 9 */ "mmmdgggdmmmm" + /* 10 */ "mmmadddammmm" // Level 2 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ ".....e.....f" - /* 1 */ "............" - /* 2 */ "gggggfeeehef" - /* 3 */ "g....e.....e" - /* 4 */ "g....i.....e" - /* 5 */ "g....e.....e" - /* 6 */ "gggfe......e" - /* 7 */ "mmme......je" - /* 8 */ "mmme...eeeef" - /* 9 */ "mmme..kemmmm" - /* 10 */ "mmmfeeefmmmm" + /* 0 */ "mmmmma.....a" + /* 1 */ "mmmmm......." + /* 2 */ "hhhhhadddida" + /* 3 */ "h....d.....d" + /* 4 */ "h....j.....d" + /* 5 */ "h....d.....d" + /* 6 */ "hhhad......d" + /* 7 */ "mmmd......kd" + /* 8 */ "mmmd....ddda" + /* 9 */ "mmmd..ldmmmm" + /* 10 */ "mmmadddammmm" // Level 3 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ ".....el...nf" - /* 1 */ "............" - /* 2 */ ".....fooepef" - /* 3 */ ".....e.....e" - /* 4 */ ".....q.....e" - /* 5 */ ".....e.....o" - /* 6 */ "...ge......e" - /* 7 */ "mmme......je" - /* 8 */ "mmme...eeoof" - /* 9 */ "mmme..kemmmm" - /* 10 */ "mmmgeeegmmmm" + /* 0 */ "mmmmman...oa" + /* 1 */ "mmmmm......." + /* 2 */ ".....appdqda" + /* 3 */ ".....d.....d" + /* 4 */ ".....q.....d" + /* 5 */ ".....d.....p" + /* 6 */ "...hd......d" + /* 7 */ "mmmd......kd" + /* 8 */ "mmmd....dppa" + /* 9 */ "mmmd..ldmmmm" + /* 10 */ "mmmhdddhmmmm" // Level 4 /* z\x* 11 */ /* * 012345678901 */ - /* 0 */ ".....r.....r" - /* 1 */ ".....e.....e" - /* 2 */ ".....fsseeef" - /* 3 */ ".....ettttte" - /* 4 */ ".....ettttte" - /* 5 */ ".....etttttu" - /* 6 */ "...getttttte" - /* 7 */ "mmmettttttje" - /* 8 */ "mmmettteevvf" - /* 9 */ "mmmettkemmmm" - /* 10 */ "mmmgeeegmmmm" + /* 0 */ "mmmmmr.....r" + /* 1 */ "mmmmmd.....d" + /* 2 */ ".....assddda" + /* 3 */ ".....dtttttd" + /* 4 */ ".....dtttttd" + /* 5 */ ".....dtttttu" + /* 6 */ "...hdatttttd" + /* 7 */ "mmmdttttttkd" + /* 8 */ "mmmdtttadvva" + /* 9 */ "mmmdttldmmmm" + /* 10 */ "mmmhdddhmmmm" // Level 5 /* z\x* 11 */ /* * 012345678901 */ /* 0 */ "............" /* 1 */ "............" - /* 2 */ ".....ewwewwe" + /* 2 */ ".....dwwdwwd" /* 3 */ ".....w.....w" /* 4 */ ".....w.....w" - /* 5 */ ".....w.....e" - /* 6 */ "...geeeg...w" - /* 7 */ "mmme...e..xw" - /* 8 */ "mmme...ewwwe" - /* 9 */ "mmme..kemmmm" - /* 10 */ "mmmgeeegmmmm" + /* 5 */ ".....w.....d" + /* 6 */ "...hdadh...w" + /* 7 */ "mmmd...d..xw" + /* 8 */ "mmmd...awwwd" + /* 9 */ "mmmd..ldmmmm" + /* 10 */ "mmmhdddhmmmm" // Level 6 /* z\x* 11 */ @@ -2547,11 +2880,11 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 3 */ "............" /* 4 */ "............" /* 5 */ "............" - /* 6 */ "...ge.eg...." - /* 7 */ "mmme...e...." - /* 8 */ "mmmo........" - /* 9 */ "mmme..kemmmm" - /* 10 */ "mmmgeoegmmmm" + /* 6 */ "...hd.dh...." + /* 7 */ "mmmd...d...." + /* 8 */ "mmmp........" + /* 9 */ "mmmd..ldmmmm" + /* 10 */ "mmmhdpdhmmmm" // Level 7 /* z\x* 11 */ @@ -2562,11 +2895,11 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 3 */ "............" /* 4 */ "............" /* 5 */ "............" - /* 6 */ "...ge.eg...." - /* 7 */ "mmme...e...." - /* 8 */ "mmmo........" - /* 9 */ "mmmel.kemmmm" - /* 10 */ "mmmgeoegmmmm" + /* 6 */ "...hd.dh...." + /* 7 */ "mmmd...d...." + /* 8 */ "mmmp........" + /* 9 */ "mmmdn.ldmmmm" + /* 10 */ "mmmhdpdhmmmm" // Level 8 /* z\x* 11 */ @@ -2577,11 +2910,11 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* 3 */ "............" /* 4 */ "............" /* 5 */ "............" - /* 6 */ "...fesef...." - /* 7 */ "mmmeyyye...." + /* 6 */ "...adsda...." + /* 7 */ "mmmdyyyd...." /* 8 */ "mmmzyyyu...." - /* 9 */ "mmmeyykemmmm" - /* 10 */ "mmmfevefmmmm" + /* 9 */ "mmmdyyldmmmm" + /* 10 */ "mmmadvdammmm" // Level 9 /* z\x* 11 */ @@ -2630,107 +2963,122 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 67, ID 556, created by STR_Warrior { // Size: - 9, 5, 11, // SizeX = 9, SizeY = 5, SizeZ = 11 + 9, 6, 11, // SizeX = 9, SizeY = 6, SizeZ = 11 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 9, 4, 11, // MaxX, MaxY, MaxZ + 9, 5, 11, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c: 24: 2\n" /* sandstone */ - "d: 24: 0\n" /* sandstone */ - "e: 64: 7\n" /* wooddoorblock */ - "f: 65: 2\n" /* ladder */ - "g: 64:12\n" /* wooddoorblock */ - "h:101: 0\n" /* ironbars */ - "i: 50: 2\n" /* torch */ - "j: 50: 1\n" /* torch */ - "k:128: 2\n" /* sandstonestairs */ - "l:126: 8\n" /* woodenslab */ + "a: 24: 2\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ + "c: 24: 0\n" /* sandstone */ + "d: 13: 0\n" /* gravel */ + "e: 5: 0\n" /* wood */ + "f: 64: 3\n" /* wooddoorblock */ + "g: 65: 2\n" /* ladder */ + "h: 64: 8\n" /* wooddoorblock */ + "i:101: 0\n" /* ironbars */ + "j: 50: 2\n" /* torch */ + "k: 50: 1\n" /* torch */ + "l:128: 2\n" /* sandstonestairs */ "m: 19: 0\n" /* sponge */ - "n:128: 5\n" /* sandstonestairs */ - "o:128: 6\n" /* sandstonestairs */ - "p:128: 4\n" /* sandstonestairs */ - "q:128: 7\n" /* sandstonestairs */ - "r: 44: 1\n" /* step */ - "s: 96: 6\n" /* trapdoor */, + "n:126: 8\n" /* woodenslab */ + "o:128: 5\n" /* sandstonestairs */ + "p:128: 6\n" /* sandstonestairs */ + "q:128: 4\n" /* sandstonestairs */ + "r:128: 7\n" /* sandstonestairs */ + "s: 44: 1\n" /* step */ + "t: 96: 2\n" /* trapdoor */, // Block data: // Level 0 /* z\x* 012345678 */ - /* 0 */ "aaaaaaaaa" - /* 1 */ "aaaaaaaaa" - /* 2 */ "aaaaaabaa" - /* 3 */ "aaaaabbba" - /* 4 */ "aaaaabbba" - /* 5 */ "aaaaabbba" - /* 6 */ "aaaaabbba" - /* 7 */ "abbbbbbba" - /* 8 */ "abbbbbbba" - /* 9 */ "abbbbbbba" - /* 10 */ "aaaaaaaaa" + /* 0 */ "mmmmabbba" + /* 1 */ "mmmmmbbbm" + /* 2 */ "mmmmaccca" + /* 3 */ "mmmmccccc" + /* 4 */ "mmmmccccc" + /* 5 */ "mmmmccccc" + /* 6 */ "acccacccc" + /* 7 */ "ccccccccc" + /* 8 */ "ccccccccc" + /* 9 */ "ccccccccc" + /* 10 */ "accccccca" // Level 1 /* z\x* 012345678 */ - /* 0 */ "mmmmc...c" - /* 1 */ "mmmm....." - /* 2 */ "mmmmcdedc" - /* 3 */ "mmmmd...d" - /* 4 */ "mmmmd...d" - /* 5 */ "mmmmd...d" - /* 6 */ "cdddd...d" - /* 7 */ "d.......d" - /* 8 */ "d.......d" - /* 9 */ "d......fd" - /* 10 */ "cdddddddc" + /* 0 */ "mmmmaddda" + /* 1 */ "mmmmmdddm" + /* 2 */ "mmmmaceca" + /* 3 */ "mmmmceeec" + /* 4 */ "mmmmceeec" + /* 5 */ "mmmmceeec" + /* 6 */ "acccaeeec" + /* 7 */ "ceeeeeeec" + /* 8 */ "ceeeeeeec" + /* 9 */ "ceeeeeeec" + /* 10 */ "accccccca" // Level 2 /* z\x* 012345678 */ - /* 0 */ "mmmmc...c" + /* 0 */ "mmmma...a" /* 1 */ "mmmm....." - /* 2 */ "mmmmcdgdc" - /* 3 */ "mmmmd...d" - /* 4 */ "mmmmd...d" - /* 5 */ "mmmmd...h" - /* 6 */ "cdhdd...h" - /* 7 */ "d.......h" - /* 8 */ "h......id" - /* 9 */ "dj.....fd" - /* 10 */ "cddhhhddc" + /* 2 */ "mmmmacfca" + /* 3 */ "mmmmc...c" + /* 4 */ "mmmmc...c" + /* 5 */ "mmmmc...c" + /* 6 */ "accca...c" + /* 7 */ "c.......c" + /* 8 */ "c.......c" + /* 9 */ "c......gc" + /* 10 */ "accccccca" // Level 3 /* z\x* 012345678 */ - /* 0 */ "mmmmk...k" - /* 1 */ "mmmmd...d" - /* 2 */ "mmmmcdddc" - /* 3 */ "mmmmdllld" - /* 4 */ "mmmmdllld" - /* 5 */ "mmmmdllln" - /* 6 */ "cdoddllln" - /* 7 */ "dllllllln" - /* 8 */ "pllllllld" - /* 9 */ "dllllllfd" - /* 10 */ "cddqqqddc" + /* 0 */ "mmmma...a" + /* 1 */ "mmmm....." + /* 2 */ "mmmmachca" + /* 3 */ "mmmmc...c" + /* 4 */ "mmmmc...c" + /* 5 */ "mmmmc...i" + /* 6 */ "acica...i" + /* 7 */ "c.......i" + /* 8 */ "i......jc" + /* 9 */ "ck.....gc" + /* 10 */ "acciiicca" // Level 4 /* z\x* 012345678 */ + /* 0 */ "mmmml...l" + /* 1 */ "mmmmc...c" + /* 2 */ "mmmmaccca" + /* 3 */ "mmmmcnnnc" + /* 4 */ "mmmmcnnnc" + /* 5 */ "mmmmcnnno" + /* 6 */ "acpcannno" + /* 7 */ "cnnnnnnno" + /* 8 */ "qnnnnnnnc" + /* 9 */ "cnnnnnngc" + /* 10 */ "accrrrcca" + + // Level 5 + /* z\x* 012345678 */ /* 0 */ "mmmm....." /* 1 */ "mmmm....." - /* 2 */ "mmmmdrdrd" - /* 3 */ "mmmmr...r" - /* 4 */ "mmmmr...r" - /* 5 */ "mmmmr...r" - /* 6 */ "drrrd...d" - /* 7 */ "r.......r" - /* 8 */ "r.......r" - /* 9 */ "r......sr" - /* 10 */ "drrrdrrrd", + /* 2 */ "mmmmcscsc" + /* 3 */ "mmmms...s" + /* 4 */ "mmmms...s" + /* 5 */ "mmmms...s" + /* 6 */ "csssc...c" + /* 7 */ "s.......s" + /* 8 */ "s.......s" + /* 9 */ "s......ts" + /* 10 */ "cssscsssc", // Connectors: - "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 6, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2761,162 +3109,176 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 83, ID 599, created by STR_Warrior { // Size: - 13, 9, 9, // SizeX = 13, SizeY = 9, SizeZ = 9 + 13, 10, 9, // SizeX = 13, SizeY = 10, SizeZ = 9 // Hitbox (relative to bounding box): -1, 0, 0, // MinX, MinY, MinZ - 13, 8, 9, // MaxX, MaxY, MaxZ + 13, 9, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "A: 44: 9\n" /* step */ - "a: 12: 0\n" /* sand */ - "b: 5: 0\n" /* wood */ - "c: 24: 2\n" /* sandstone */ - "d: 24: 0\n" /* sandstone */ - "e: 64: 7\n" /* wooddoorblock */ - "f: 17: 0\n" /* tree */ - "g:128: 5\n" /* sandstonestairs */ - "h:128: 4\n" /* sandstonestairs */ - "i:128: 7\n" /* sandstonestairs */ - "j:128: 6\n" /* sandstonestairs */ - "k:118: 3\n" /* cauldronblock */ - "l:155: 1\n" /* quartzblock */ + "A: 51: 0\n" /* fire */ + "B: 44: 9\n" /* step */ + "a: 24: 2\n" /* sandstone */ + "b: 4: 0\n" /* cobblestone */ + "c: 24: 0\n" /* sandstone */ + "d: 13: 0\n" /* gravel */ + "e: 5: 0\n" /* wood */ + "f: 64: 3\n" /* wooddoorblock */ + "g: 17: 0\n" /* tree */ + "h:128: 5\n" /* sandstonestairs */ + "i:128: 4\n" /* sandstonestairs */ + "j:128: 7\n" /* sandstonestairs */ + "k:128: 6\n" /* sandstonestairs */ + "l:118: 3\n" /* cauldronblock */ "m: 19: 0\n" /* sponge */ - "n: 64:12\n" /* wooddoorblock */ - "o: 50: 3\n" /* torch */ - "p:101: 0\n" /* ironbars */ - "q:140: 0\n" /* flowerpotblock */ - "r: 24: 1\n" /* sandstone */ - "s:128: 2\n" /* sandstonestairs */ - "t:126: 8\n" /* woodenslab */ - "u: 44: 1\n" /* step */ - "v:128: 0\n" /* sandstonestairs */ - "w: 87: 0\n" /* netherstone */ - "x:128: 1\n" /* sandstonestairs */ - "y:128: 3\n" /* sandstonestairs */ - "z: 51: 0\n" /* fire */, + "n:155: 1\n" /* quartzblock */ + "o: 64: 8\n" /* wooddoorblock */ + "p: 50: 3\n" /* torch */ + "q:101: 0\n" /* ironbars */ + "r:140: 0\n" /* flowerpotblock */ + "s: 24: 1\n" /* sandstone */ + "t:128: 2\n" /* sandstonestairs */ + "u:126: 8\n" /* woodenslab */ + "v: 44: 1\n" /* step */ + "w:128: 0\n" /* sandstonestairs */ + "x: 87: 0\n" /* netherstone */ + "y:128: 1\n" /* sandstonestairs */ + "z:128: 3\n" /* sandstonestairs */, // Block data: // Level 0 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ "aaaaaaaaaaaaa" - /* 1 */ "aaaaaaaaaaaaa" - /* 2 */ "aaabbababbaaa" - /* 3 */ "abbbbbbbbbbba" - /* 4 */ "abbbbbbbbbbba" - /* 5 */ "abbbbbbbbbbba" - /* 6 */ "abbbbbbbbbbba" - /* 7 */ "abbbbbbbbbbba" - /* 8 */ "aaaaaaaaaaaaa" + /* 0 */ "mmmmabbbammmm" + /* 1 */ "mmmmmbbbmmmmm" + /* 2 */ "accccccccccca" + /* 3 */ "ccccccccccccc" + /* 4 */ "ccccccccccccc" + /* 5 */ "ccccccccccccc" + /* 6 */ "ccccccccccccc" + /* 7 */ "ccccccccccccc" + /* 8 */ "accccccccccca" // Level 1 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ "....c...c...." - /* 1 */ "............." - /* 2 */ "cdddddedddddc" - /* 3 */ "dfg.......hfd" - /* 4 */ "di.........id" - /* 5 */ "d...........d" - /* 6 */ "dj.........jd" - /* 7 */ "dfg.khlgk.hfd" - /* 8 */ "cdddddddddddc" + /* 0 */ "mmmmadddammmm" + /* 1 */ "mmmmmdddmmmmm" + /* 2 */ "accccceccccca" + /* 3 */ "ceeeeeeeeeeec" + /* 4 */ "ceeeeeeeeeeec" + /* 5 */ "ceeeeeeeeeeec" + /* 6 */ "ceeeeeeeeeeec" + /* 7 */ "ceeeeeeeeeeec" + /* 8 */ "accccccccccca" // Level 2 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ "....c...c...." - /* 1 */ "............." - /* 2 */ "cdddddndddddc" - /* 3 */ "df...o.o...fd" - /* 4 */ "d...........d" - /* 5 */ "p...........p" - /* 6 */ "d...........d" - /* 7 */ "df...qrq...fd" - /* 8 */ "cdpppdddpppdc" + /* 0 */ "mmmma...ammmm" + /* 1 */ "mmmm.....mmmm" + /* 2 */ "acccccfccccca" + /* 3 */ "cgh.......igc" + /* 4 */ "cj.........jc" + /* 5 */ "c...........c" + /* 6 */ "ck.........kc" + /* 7 */ "cgh.linhl.igc" + /* 8 */ "accccccccccca" // Level 3 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ "....s...s...." - /* 1 */ "....r...d...." - /* 2 */ "cdddddddddddc" - /* 3 */ "dftttttttttfd" - /* 4 */ "dtttttttttttd" - /* 5 */ "htttttttttttg" - /* 6 */ "dtttttttttttd" - /* 7 */ "dftttttttttfd" - /* 8 */ "cdiiidddiiidc" + /* 0 */ "mmmma...ammmm" + /* 1 */ "mmmm.....mmmm" + /* 2 */ "acccccoccccca" + /* 3 */ "cg...p.p...gc" + /* 4 */ "c...........c" + /* 5 */ "q...........q" + /* 6 */ "c...........c" + /* 7 */ "cg...rsr...gc" + /* 8 */ "acqqqcccqqqca" // Level 4 /* z\x* 111 */ /* * 0123456789012 */ - /* 0 */ "............." - /* 1 */ "............." - /* 2 */ "duuuuuduuuuud" - /* 3 */ "u...........u" - /* 4 */ "u.ddd...ddd.u" - /* 5 */ "d.ddd...ddd.d" - /* 6 */ "u.ddd...ddd.u" - /* 7 */ "u...........u" - /* 8 */ "duuuuuduuuuud" + /* 0 */ "mmmmt...tmmmm" + /* 1 */ "mmmms...cmmmm" + /* 2 */ "accccccccccca" + /* 3 */ "cguuuuuuuuugc" + /* 4 */ "cuuuuuuuuuuuc" + /* 5 */ "iuuuuuuuuuuuh" + /* 6 */ "cuuuuuuuuuuuc" + /* 7 */ "cguuuuuuuuugc" + /* 8 */ "acjjjcccjjjca" // Level 5 /* z\x* 111 */ /* * 0123456789012 */ + /* 0 */ "mmmm.....mmmm" + /* 1 */ "mmmm.....mmmm" + /* 2 */ "cvvvvvcvvvvvc" + /* 3 */ "v...........v" + /* 4 */ "v.ccc...ccc.v" + /* 5 */ "c.ccc...ccc.c" + /* 6 */ "v.ccc...ccc.v" + /* 7 */ "v...........v" + /* 8 */ "cvvvvvcvvvvvc" + + // Level 6 + /* z\x* 111 */ + /* * 0123456789012 */ /* 0 */ "............." /* 1 */ "............." /* 2 */ "............." /* 3 */ "............." - /* 4 */ "..csc...csc.." - /* 5 */ "..vwx...vwx.." - /* 6 */ "..cyc...cyc.." + /* 4 */ "..ata...ata.." + /* 5 */ "..wxy...wxy.." + /* 6 */ "..aza...aza.." /* 7 */ "............." /* 8 */ "............." - // Level 6 + // Level 7 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." /* 1 */ "............." /* 2 */ "............." /* 3 */ "............." - /* 4 */ "..c.c...c.c.." - /* 5 */ "...z.....z..." - /* 6 */ "..c.c...c.c.." + /* 4 */ "..a.a...a.a.." + /* 5 */ "...A.....A..." + /* 6 */ "..a.a...a.a.." /* 7 */ "............." /* 8 */ "............." - // Level 7 + // Level 8 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." /* 1 */ "............." /* 2 */ "............." /* 3 */ "............." - /* 4 */ "..ddd...ddd.." - /* 5 */ "..dAd...dAd.." - /* 6 */ "..ddd...ddd.." + /* 4 */ "..ccc...ccc.." + /* 5 */ "..cBc...cBc.." + /* 6 */ "..ccc...ccc.." /* 7 */ "............." /* 8 */ "............." - // Level 8 + // Level 9 /* z\x* 111 */ /* * 0123456789012 */ /* 0 */ "............." /* 1 */ "............." /* 2 */ "............." /* 3 */ "............." - /* 4 */ "..u.u...u.u.." + /* 4 */ "..v.v...v.v.." /* 5 */ "............." - /* 6 */ "..u.u...u.u.." + /* 6 */ "..v.v...v.v.." /* 7 */ "............." /* 8 */ ".............", // Connectors: - "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */, + "-1: 6, 2, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -2953,201 +3315,245 @@ const cPrefab::sDef g_AlchemistVillageStartingPrefabs[] = // The data has been exported from the gallery Desert, area index 90, ID 631, created by STR_Warrior { // Size: - 5, 21, 5, // SizeX = 5, SizeY = 21, SizeZ = 5 + 7, 21, 7, // SizeX = 7, SizeY = 21, SizeZ = 7 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 4, 20, 4, // MaxX, MaxY, MaxZ + 6, 20, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ "a: 1: 0\n" /* stone */ - "b: 24: 0\n" /* sandstone */ - "c: 8: 0\n" /* water */ - "d: 24: 2\n" /* sandstone */ - "e:128: 1\n" /* sandstonestairs */ - "f: 44: 1\n" /* step */ - "g:128: 0\n" /* sandstonestairs */ - "h:128: 3\n" /* sandstonestairs */ - "i:128: 2\n" /* sandstonestairs */ - "j: 44: 9\n" /* step */ - "k:126: 0\n" /* woodenslab */ - "m: 19: 0\n" /* sponge */, + "b: 24: 2\n" /* sandstone */ + "c: 24: 0\n" /* sandstone */ + "d: 8: 0\n" /* water */ + "e: 4: 0\n" /* cobblestone */ + "f: 13: 0\n" /* gravel */ + "g:128: 1\n" /* sandstonestairs */ + "h: 44: 1\n" /* step */ + "i:128: 0\n" /* sandstonestairs */ + "j:128: 3\n" /* sandstonestairs */ + "k:128: 2\n" /* sandstonestairs */ + "l: 44: 9\n" /* step */ + "m: 19: 0\n" /* sponge */ + "n:126: 0\n" /* woodenslab */, // Block data: // Level 0 - /* z\x* 01234 */ - /* 0 */ "aaaaa" - /* 1 */ "aaaaa" - /* 2 */ "aaaaa" - /* 3 */ "aaaaa" - /* 4 */ "aaaaa" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "maaaaam" + /* 2 */ "maaaaam" + /* 3 */ "maaaaam" + /* 4 */ "maaaaam" + /* 5 */ "maaaaam" + /* 6 */ "mmmmmmm" // Level 1 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mbcccbm" + /* 2 */ "mcdddcm" + /* 3 */ "mcdddcm" + /* 4 */ "mcdddcm" + /* 5 */ "mbcccbm" + /* 6 */ "mmmmmmm" // Level 2 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mbcccbm" + /* 2 */ "mcdddcm" + /* 3 */ "mcdddcm" + /* 4 */ "mcdddcm" + /* 5 */ "mbcccbm" + /* 6 */ "mmmmmmm" // Level 3 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mbcccbm" + /* 2 */ "mcdddcm" + /* 3 */ "mcdddcm" + /* 4 */ "mcdddcm" + /* 5 */ "mbcccbm" + /* 6 */ "mmmmmmm" // Level 4 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mbcccbm" + /* 2 */ "mcdddcm" + /* 3 */ "mcdddcm" + /* 4 */ "mcdddcm" + /* 5 */ "mbcccbm" + /* 6 */ "mmmmmmm" // Level 5 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mbcccbm" + /* 2 */ "mcdddcm" + /* 3 */ "mcdddcm" + /* 4 */ "mcdddcm" + /* 5 */ "mbcccbm" + /* 6 */ "mmmmmmm" // Level 6 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mbcccbm" + /* 2 */ "mcdddcm" + /* 3 */ "mcdddcm" + /* 4 */ "mcdddcm" + /* 5 */ "mbcccbm" + /* 6 */ "mmmmmmm" // Level 7 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mbcccbm" + /* 2 */ "mcdddcm" + /* 3 */ "mcdddcm" + /* 4 */ "mcdddcm" + /* 5 */ "mbcccbm" + /* 6 */ "mmmmmmm" // Level 8 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mbcccbm" + /* 2 */ "mcdddcm" + /* 3 */ "mcdddcm" + /* 4 */ "mcdddcm" + /* 5 */ "mbcccbm" + /* 6 */ "mmmmmmm" // Level 9 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mbcccbm" + /* 2 */ "mcdddcm" + /* 3 */ "mcdddcm" + /* 4 */ "mcdddcm" + /* 5 */ "mbcccbm" + /* 6 */ "mmmmmmm" // Level 10 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mbcccbm" + /* 2 */ "mcdddcm" + /* 3 */ "mcdddcm" + /* 4 */ "mcdddcm" + /* 5 */ "mbcccbm" + /* 6 */ "mmmmmmm" // Level 11 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mbcccbm" + /* 2 */ "mcdddcm" + /* 3 */ "mcdddcm" + /* 4 */ "mcdddcm" + /* 5 */ "mbcccbm" + /* 6 */ "mmmmmmm" // Level 12 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mbcccbm" + /* 2 */ "mcdddcm" + /* 3 */ "mcdddcm" + /* 4 */ "mcdddcm" + /* 5 */ "mbcccbm" + /* 6 */ "mmmmmmm" // Level 13 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmmmmmm" + /* 1 */ "mbcccbm" + /* 2 */ "mcdddcm" + /* 3 */ "mcdddcm" + /* 4 */ "mcdddcm" + /* 5 */ "mbcccbm" + /* 6 */ "mmmmmmm" // Level 14 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmeeemm" + /* 1 */ "mbcccbm" + /* 2 */ "ecdddce" + /* 3 */ "ecdddce" + /* 4 */ "ecdddce" + /* 5 */ "mbcccbm" + /* 6 */ "mmeeemm" // Level 15 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bcccb" - /* 2 */ "bcccb" - /* 3 */ "bcccb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mmfffmm" + /* 1 */ "mbcccbm" + /* 2 */ "fcdddcf" + /* 3 */ "fcdddcf" + /* 4 */ "fcdddcf" + /* 5 */ "mbcccbm" + /* 6 */ "mmfffmm" // Level 16 - /* z\x* 01234 */ - /* 0 */ "defgd" - /* 1 */ "h...h" - /* 2 */ "f...f" - /* 3 */ "i...i" - /* 4 */ "defgd" + /* z\x* 0123456 */ + /* 0 */ "mm...mm" + /* 1 */ "mbghibm" + /* 2 */ ".j...j." + /* 3 */ ".h...h." + /* 4 */ ".k...k." + /* 5 */ "mbghibm" + /* 6 */ "mm...mm" // Level 17 - /* z\x* 01234 */ - /* 0 */ "d...d" - /* 1 */ "....." - /* 2 */ "....." - /* 3 */ "....." - /* 4 */ "d...d" + /* z\x* 0123456 */ + /* 0 */ "mm...mm" + /* 1 */ "mb...bm" + /* 2 */ "......." + /* 3 */ "......." + /* 4 */ "......." + /* 5 */ "mb...bm" + /* 6 */ "mm...mm" // Level 18 - /* z\x* 01234 */ - /* 0 */ "djjjd" - /* 1 */ "j...j" - /* 2 */ "j...j" - /* 3 */ "j...j" - /* 4 */ "djjjd" + /* z\x* 0123456 */ + /* 0 */ "mm...mm" + /* 1 */ "mblllbm" + /* 2 */ ".l...l." + /* 3 */ ".l...l." + /* 4 */ ".l...l." + /* 5 */ "mblllbm" + /* 6 */ "mm...mm" // Level 19 - /* z\x* 01234 */ - /* 0 */ "bbbbb" - /* 1 */ "bkkkb" - /* 2 */ "bkkkb" - /* 3 */ "bkkkb" - /* 4 */ "bbbbb" + /* z\x* 0123456 */ + /* 0 */ "mm...mm" + /* 1 */ "mcccccm" + /* 2 */ ".cnnnc." + /* 3 */ ".cnnnc." + /* 4 */ ".cnnnc." + /* 5 */ "mcccccm" + /* 6 */ "mm...mm" // Level 20 - /* z\x* 01234 */ - /* 0 */ "f.f.f" - /* 1 */ "....." - /* 2 */ "f...f" - /* 3 */ "....." - /* 4 */ "f.f.f", + /* z\x* 0123456 */ + /* 0 */ "mm...mm" + /* 1 */ "mh.h.hm" + /* 2 */ "......." + /* 3 */ ".h...h." + /* 4 */ "......." + /* 5 */ "mh.h.hm" + /* 6 */ "mm...mm", // Connectors: - "2: 2, 16, 4: 3\n" /* Type 2, direction Z+ */ - "2: 0, 16, 2: 4\n" /* Type 2, direction X- */ - "2: 2, 16, 0: 2\n" /* Type 2, direction Z- */ - "2: 4, 16, 2: 5\n" /* Type 2, direction X+ */, + "2: 3, 16, 6: 3\n" /* Type 2, direction Z+ */ + "2: 0, 16, 3: 4\n" /* Type 2, direction X- */ + "2: 3, 16, 0: 2\n" /* Type 2, direction Z- */ + "2: 6, 16, 3: 5\n" /* Type 2, direction X+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ diff --git a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp index 5ec222f84..79f7a5272 100644 --- a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp +++ b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp @@ -129,6 +129,176 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Farm: + // The data has been exported from the gallery Plains, area index 166, ID 554, created by Aloe_vera + { + // Size: + 11, 7, 13, // SizeX = 11, SizeY = 7, SizeZ = 13 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 10, 6, 12, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 3: 0\n" /* dirt */ + "b: 60: 7\n" /* tilleddirt */ + "c: 8: 0\n" /* water */ + "d: 43: 0\n" /* doubleslab */ + "e: 44: 0\n" /* step */ + "f: 59: 7\n" /* crops */ + "g: 83: 0\n" /* reedblock */ + "h:113: 0\n" /* netherbrickfence */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmmmmmmmm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "maaaaaaaaam" + /* 3 */ "maaaaaaaaam" + /* 4 */ "maaaaaaaaam" + /* 5 */ "maaaaaaaaam" + /* 6 */ "maaaaaaaaam" + /* 7 */ "maaaaaaaaam" + /* 8 */ "maaaaaaaaam" + /* 9 */ "maaaaaaaaam" + /* 10 */ "maaaaaaaaam" + /* 11 */ "maaaaaaaaam" + /* 12 */ "mmmmmmmmmmm" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "mmmmmmmmmmm" + /* 1 */ "maaaaaaaaam" + /* 2 */ "mabbbbbbbam" + /* 3 */ "mabbbbbbbam" + /* 4 */ "mabbbbbbbam" + /* 5 */ "mabbbbbbbam" + /* 6 */ "mabcccccaam" + /* 7 */ "mabbbbbbbam" + /* 8 */ "mabbbbbbbam" + /* 9 */ "mabbbbbbbam" + /* 10 */ "mabbbbbbbam" + /* 11 */ "maaaaaaaaam" + /* 12 */ "mmmmmmmmmmm" + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".deeeeeeed." + /* 2 */ ".efffffffe." + /* 3 */ ".efffffffe." + /* 4 */ ".efffffffe." + /* 5 */ ".efgggggfe." + /* 6 */ ".eg.....ge." + /* 7 */ ".efgggggfe." + /* 8 */ ".efffffffe." + /* 9 */ ".efffffffe." + /* 10 */ ".efffffffe." + /* 11 */ ".deeeeeeed." + /* 12 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".h.......h." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "...ggggg..." + /* 6 */ "..g.....g.." + /* 7 */ "...ggggg..." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + /* 11 */ ".h.......h." + /* 12 */ "..........." + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".h.......h." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "...ggggg..." + /* 6 */ "..g.....g.." + /* 7 */ "...ggggg..." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + /* 11 */ ".h.......h." + /* 12 */ "..........." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".h.......h." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + /* 11 */ ".h.......h." + /* 12 */ "..........." + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ ".h.......h." + /* 1 */ "hhh.....hhh" + /* 2 */ ".h.......h." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ ".h.......h." + /* 11 */ "hhh.....hhh" + /* 12 */ ".h.......h.", + + // Connectors: + "-1: 10, 2, 6: 5\n" /* Type -1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // Farm + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Forge: // The data has been exported from the gallery Plains, area index 79, ID 145, created by Aloe_vera @@ -2025,12 +2195,12 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // Level 1 /* z\x* 0123456 */ - /* 0 */ "bbbbbbb" - /* 1 */ "bbbbbbb" - /* 2 */ "bbbbbbb" - /* 3 */ "bbbabbb" - /* 4 */ "bbbbbbb" - /* 5 */ "bbbbbbb" + /* 0 */ "bmmmmmm" + /* 1 */ "bmmmmmm" + /* 2 */ "bmmmmmm" + /* 3 */ "bmmmmmm" + /* 4 */ "bmmmmmm" + /* 5 */ "bmmmmmm" /* 6 */ "bbbbbbb" // Level 2 @@ -3005,159 +3175,157 @@ const cPrefab::sDef g_JapaneseVillageStartingPrefabs[] = "a: 1: 0\n" /* stone */ "b: 4: 0\n" /* cobblestone */ "c: 8: 0\n" /* water */ - "d: 3: 0\n" /* dirt */ - "e: 2: 0\n" /* grass */ - "f: 13: 0\n" /* gravel */ - "g: 67: 1\n" /* stairs */ - "h: 67: 2\n" /* stairs */ - "i: 67: 0\n" /* stairs */ - "j: 67: 3\n" /* stairs */ - "k: 85: 0\n" /* fence */ - "l: 44: 8\n" /* step */ - "m: 19: 0\n" /* sponge */ - "n: 44: 0\n" /* step */ - "o: 43: 0\n" /* doubleslab */, + "d: 13: 0\n" /* gravel */ + "e: 67: 1\n" /* stairs */ + "f: 67: 2\n" /* stairs */ + "g: 67: 0\n" /* stairs */ + "h: 67: 3\n" /* stairs */ + "i: 85: 0\n" /* fence */ + "j: 44: 8\n" /* step */ + "k: 44: 0\n" /* step */ + "l: 43: 0\n" /* doubleslab */ + "m: 19: 0\n" /* sponge */, // Block data: // Level 0 /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "aaaaaaa" - /* 2 */ "aaaaaaa" - /* 3 */ "aaaaaaa" - /* 4 */ "aaaaaaa" - /* 5 */ "aaaaaaa" - /* 6 */ "aaaaaaa" + /* 0 */ "mmmmmmm" + /* 1 */ "maaaaam" + /* 2 */ "maaaaam" + /* 3 */ "maaaaam" + /* 4 */ "maaaaam" + /* 5 */ "maaaaam" + /* 6 */ "mmmmmmm" // Level 1 /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "abbbbba" - /* 2 */ "abcc.ba" - /* 3 */ "abcccba" - /* 4 */ "abcccba" - /* 5 */ "abbbbba" - /* 6 */ "aaaaaaa" + /* 0 */ "mmmmmmm" + /* 1 */ "mbbbbbm" + /* 2 */ "mbcc.bm" + /* 3 */ "mbcccbm" + /* 4 */ "mbcccbm" + /* 5 */ "mbbbbbm" + /* 6 */ "mmmmmmm" // Level 2 /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "abbbbba" - /* 2 */ "abcccba" - /* 3 */ "abcccba" - /* 4 */ "abcccba" - /* 5 */ "abbbbba" - /* 6 */ "aaaaaaa" + /* 0 */ "mmmmmmm" + /* 1 */ "mbbbbbm" + /* 2 */ "mbcccbm" + /* 3 */ "mbcccbm" + /* 4 */ "mbcccbm" + /* 5 */ "mbbbbbm" + /* 6 */ "mmmmmmm" // Level 3 /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "abbbbba" - /* 2 */ "abcccba" - /* 3 */ "abcccba" - /* 4 */ "abcccba" - /* 5 */ "abbbbba" - /* 6 */ "aaaaaaa" + /* 0 */ "mmmmmmm" + /* 1 */ "mbbbbbm" + /* 2 */ "mbcccbm" + /* 3 */ "mbcccbm" + /* 4 */ "mbcccbm" + /* 5 */ "mbbbbbm" + /* 6 */ "mmmmmmm" // Level 4 /* z\x* 0123456 */ - /* 0 */ "aaaaaaa" - /* 1 */ "abbbbba" - /* 2 */ "abcccba" - /* 3 */ "abcccba" - /* 4 */ "abcccba" - /* 5 */ "abbbbba" - /* 6 */ "aaaaaaa" + /* 0 */ "mmmmmmm" + /* 1 */ "mbbbbbm" + /* 2 */ "mbcccbm" + /* 3 */ "mbcccbm" + /* 4 */ "mbcccbm" + /* 5 */ "mbbbbbm" + /* 6 */ "mmmmmmm" // Level 5 /* z\x* 0123456 */ - /* 0 */ "ddddddd" - /* 1 */ "dbbbbbd" - /* 2 */ "dbcccbd" - /* 3 */ "dbcccbd" - /* 4 */ "dbcccbd" - /* 5 */ "dbbbbbd" - /* 6 */ "ddddddd" + /* 0 */ "mmmmmmm" + /* 1 */ "mbbbbbm" + /* 2 */ "mbcccbm" + /* 3 */ "mbcccbm" + /* 4 */ "mbcccbm" + /* 5 */ "mbbbbbm" + /* 6 */ "mmmmmmm" // Level 6 /* z\x* 0123456 */ - /* 0 */ "ddddddd" - /* 1 */ "dbbbbbd" - /* 2 */ "dbcccbd" - /* 3 */ "dbcccbd" - /* 4 */ "dbcccbd" - /* 5 */ "dbbbbbd" - /* 6 */ "ddddddd" + /* 0 */ "mmmmmmm" + /* 1 */ "mbbbbbm" + /* 2 */ "mbcccbm" + /* 3 */ "mbcccbm" + /* 4 */ "mbcccbm" + /* 5 */ "mbbbbbm" + /* 6 */ "mmmmmmm" // Level 7 /* z\x* 0123456 */ - /* 0 */ "ddddddd" - /* 1 */ "dbbbbbd" - /* 2 */ "dbcccbd" - /* 3 */ "dbcccbd" - /* 4 */ "dbcccbd" - /* 5 */ "dbbbbbd" - /* 6 */ "ddddddd" + /* 0 */ "mmbbbmm" + /* 1 */ "mbbbbbm" + /* 2 */ "bbcccbb" + /* 3 */ "bbcccbb" + /* 4 */ "bbcccbb" + /* 5 */ "mbbbbbm" + /* 6 */ "mmbbbmm" // Level 8 /* z\x* 0123456 */ - /* 0 */ "eefffee" - /* 1 */ "ebbbbbe" - /* 2 */ "fbcccbf" - /* 3 */ "fbcccbf" - /* 4 */ "fbcccbf" - /* 5 */ "ebbbbbe" - /* 6 */ "eefffee" + /* 0 */ "mmdddmm" + /* 1 */ "mbbbbbm" + /* 2 */ "dbcccbd" + /* 3 */ "dbcccbd" + /* 4 */ "dbcccbd" + /* 5 */ "mbbbbbm" + /* 6 */ "mmdddmm" // Level 9 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".bghib." - /* 2 */ ".j...j." - /* 3 */ ".i...g." - /* 4 */ ".h...h." - /* 5 */ ".bgjib." - /* 6 */ "......." + /* 0 */ "mm...mm" + /* 1 */ "mbefgbm" + /* 2 */ ".h...h." + /* 3 */ ".g...e." + /* 4 */ ".f...f." + /* 5 */ "mbehgbm" + /* 6 */ "mm...mm" // Level 10 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".k...k." + /* 0 */ "mm...mm" + /* 1 */ "mi...im" /* 2 */ "......." /* 3 */ "......." /* 4 */ "......." - /* 5 */ ".k...k." - /* 6 */ "......." + /* 5 */ "mi...im" + /* 6 */ "mm...mm" // Level 11 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ ".k...k." + /* 0 */ "mm...mm" + /* 1 */ "mi...im" /* 2 */ "......." /* 3 */ "......." /* 4 */ "......." - /* 5 */ ".k...k." - /* 6 */ "......." + /* 5 */ "mi...im" + /* 6 */ "mm...mm" // Level 12 /* z\x* 0123456 */ - /* 0 */ ".lnnnl." - /* 1 */ "loooool" - /* 2 */ "nooooon" - /* 3 */ "nooooon" - /* 4 */ "nooooon" - /* 5 */ "loooool" - /* 6 */ ".lnnnl." + /* 0 */ "mjkkkjm" + /* 1 */ "jlllllj" + /* 2 */ "klllllk" + /* 3 */ "klllllk" + /* 4 */ "klllllk" + /* 5 */ "jlllllj" + /* 6 */ "mjkkkjm" // Level 13 /* z\x* 0123456 */ - /* 0 */ "n.....n" + /* 0 */ "k.....k" /* 1 */ "......." - /* 2 */ "..nnn.." - /* 3 */ "..non.." - /* 4 */ "..nnn.." + /* 2 */ "..kkk.." + /* 3 */ "..klk.." + /* 4 */ "..kkk.." /* 5 */ "......." - /* 6 */ "n.....n", + /* 6 */ "k.....k", // Connectors: "2: 0, 9, 3: 4\n" /* Type 2, direction X- */ diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index f5c5b7a20..9e5e06769 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -362,29 +362,29 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 0 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "aaaaaaaaaaaaaaa" + /* 0 */ "aaaaaaabaaaaaaa" /* 1 */ "aaaaaaaaaaaaaaa" /* 2 */ "aaaaaaaaaaaaaaa" /* 3 */ "aaaaaaaaaaaaaaa" /* 4 */ "aaaaaaaaaaaaaaa" - /* 5 */ "aaaaaaaaaaaaaaa" - /* 6 */ "aaaaaaaaaaaaaaa" - /* 7 */ "aaaaaaaaaaaaaaa" - /* 8 */ "aaaaaaaaaaaaaaa" - - // Level 1 - /* z\x* 11111 */ - /* * 012345678901234 */ - /* 0 */ "aaaaaaabaaaaaaa" - /* 1 */ "aaaaaaabaaaaaaa" - /* 2 */ "aaaaaaabaaaaaaa" - /* 3 */ "aaaaaaabaaaaaaa" - /* 4 */ "aaaaaaabaaaaaaa" /* 5 */ "aaaaaaabaaaaaaa" /* 6 */ "aaaaaaabaaaaaaa" /* 7 */ "aaaaaaabaaaaaaa" /* 8 */ "aaaaaaabaaaaaaa" + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "aaaaaaamaaaaaaa" + /* 1 */ "aaaaaaamaaaaaaa" + /* 2 */ "aaaaaaamaaaaaaa" + /* 3 */ "aaaaaaamaaaaaaa" + /* 4 */ "aaaaaaamaaaaaaa" + /* 5 */ "aaaaaaamaaaaaaa" + /* 6 */ "aaaaaaamaaaaaaa" + /* 7 */ "aaaaaaamaaaaaaa" + /* 8 */ "aaaaaaamaaaaaaa" + // Level 2 /* z\x* 11111 */ /* * 012345678901234 */ @@ -509,12 +509,12 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "d: 67: 1\n" /* stairs */ "e: 17: 0\n" /* tree */ "f: 5: 0\n" /* wood */ - "g: 64: 6\n" /* wooddoorblock */ + "g: 64: 2\n" /* wooddoorblock */ "h: 10: 0\n" /* lava */ "i: 54: 2\n" /* chest */ "j: 61: 2\n" /* furnace */ "k:102: 0\n" /* glasspane */ - "l: 64:12\n" /* wooddoorblock */ + "l: 64: 8\n" /* wooddoorblock */ "m: 19: 0\n" /* sponge */ "n:139: 0\n" /* cobblestonewall */ "o:101: 0\n" /* ironbars */ @@ -2544,7 +2544,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = true, // DefaultWeight: - 100, + 20, // DepthWeight: "", @@ -2746,8 +2746,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "d: 67: 1\n" /* stairs */ "e: 17: 0\n" /* tree */ "f: 5: 0\n" /* wood */ - "g: 64: 7\n" /* wooddoorblock */ - "h: 64:12\n" /* wooddoorblock */ + "g: 64: 3\n" /* wooddoorblock */ + "h: 64: 8\n" /* wooddoorblock */ "i:102: 0\n" /* glasspane */ "j: 53: 2\n" /* woodstairs */ "k: 53: 7\n" /* woodstairs */ @@ -3000,9 +3000,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "d: 67: 1\n" /* stairs */ "e: 17: 0\n" /* tree */ "f: 5: 0\n" /* wood */ - "g: 64: 7\n" /* wooddoorblock */ + "g: 64: 3\n" /* wooddoorblock */ "h:102: 0\n" /* glasspane */ - "i: 64:12\n" /* wooddoorblock */ + "i: 64: 8\n" /* wooddoorblock */ "j: 53: 2\n" /* woodstairs */ "k: 53: 7\n" /* woodstairs */ "l: 50: 3\n" /* torch */ @@ -3141,31 +3141,32 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "k: 85: 0\n" /* fence */ "l: 53: 0\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 64: 6\n" /* wooddoorblock */ + "n: 64: 2\n" /* wooddoorblock */ "o: 64: 4\n" /* wooddoorblock */ "p:102: 0\n" /* glasspane */ "q: 72: 0\n" /* woodplate */ - "r: 64:12\n" /* wooddoorblock */ - "s: 53: 5\n" /* woodstairs */ - "t: 53: 4\n" /* woodstairs */ - "u: 50: 1\n" /* torch */ - "v: 50: 2\n" /* torch */, + "r: 64: 8\n" /* wooddoorblock */ + "s: 64:12\n" /* wooddoorblock */ + "t: 53: 5\n" /* woodstairs */ + "u: 53: 4\n" /* woodstairs */ + "v: 50: 1\n" /* torch */ + "w: 50: 2\n" /* torch */, // Block data: // Level 0 /* z\x* */ /* * 0123456789 */ - /* 0 */ ".........." - /* 1 */ ".aaaaa...." - /* 2 */ ".aaaaa...." - /* 3 */ ".aaaaabbbb" + /* 0 */ "mmmmmmmmmm" + /* 1 */ "maaaaammmm" + /* 2 */ "maaaaammmm" + /* 3 */ "maaaaabbbb" /* 4 */ "aaaaaabbbb" /* 5 */ "aaaaaabbbb" /* 6 */ "aaaaaabbbb" - /* 7 */ ".aaaaabbbb" - /* 8 */ ".aaaaabbbb" - /* 9 */ ".aaaaa...." - /* 10 */ ".........." + /* 7 */ "maaaaabbbb" + /* 8 */ "maaaaabbbb" + /* 9 */ "maaaaammmm" + /* 10 */ "mmmmmmmmmm" // Level 1 /* z\x* */ @@ -3205,7 +3206,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 2 */ ".p.q.pmmmm" /* 3 */ ".p...p...." /* 4 */ ".c...c...." - /* 5 */ ".r...r...." + /* 5 */ ".r...s...." /* 6 */ ".c...c...." /* 7 */ ".p...p...." /* 8 */ ".p...p...." @@ -3215,47 +3216,47 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 4 /* z\x* */ /* * 0123456789 */ - /* 0 */ "ls...tjmmm" + /* 0 */ "lt...ujmmm" /* 1 */ "licccijmmm" /* 2 */ "lc...cjmmm" /* 3 */ "lc...cj..." - /* 4 */ "lcu.vcj..." + /* 4 */ "lcv.wcj..." /* 5 */ "lc...cj..." - /* 6 */ "lcu.vcj..." + /* 6 */ "lcv.wcj..." /* 7 */ "lc...cj..." /* 8 */ "lc...cj..." /* 9 */ "licccijmmm" - /* 10 */ "ls...tjmmm" + /* 10 */ "lt...ujmmm" // Level 5 /* z\x* */ /* * 0123456789 */ - /* 0 */ "mls.tjmmmm" - /* 1 */ "mlcccjmmmm" - /* 2 */ "mlc.cjmmmm" - /* 3 */ "mlc.cjm..." - /* 4 */ "mlc.cjm..." - /* 5 */ "mlc.cjm..." - /* 6 */ "mlc.cjm..." - /* 7 */ "mlc.cjm..." - /* 8 */ "mlc.cjm..." - /* 9 */ "mlcccjmmmm" - /* 10 */ "mls.tjmmmm" + /* 0 */ ".lt.uj.mmm" + /* 1 */ ".lcccj.mmm" + /* 2 */ ".lc.cj.mmm" + /* 3 */ ".lc.cj...." + /* 4 */ ".lc.cj...." + /* 5 */ ".lc.cj...." + /* 6 */ ".lc.cj...." + /* 7 */ ".lc.cj...." + /* 8 */ ".lc.cj...." + /* 9 */ ".lcccj.mmm" + /* 10 */ ".lt.uj.mmm" // Level 6 /* z\x* */ /* * 0123456789 */ - /* 0 */ "mmlcjmmmmm" - /* 1 */ "mmlcjmmmmm" - /* 2 */ "mmlcjmmmmm" - /* 3 */ "mmlcjmm..." - /* 4 */ "mmlcjmm..." - /* 5 */ "mmlcjmm..." - /* 6 */ "mmlcjmm..." - /* 7 */ "mmlcjmm..." - /* 8 */ "mmlcjmm..." - /* 9 */ "mmlcjmmmmm" - /* 10 */ "mmlcjmmmmm", + /* 0 */ "..lcj..mmm" + /* 1 */ "..lcj..mmm" + /* 2 */ "..lcj..mmm" + /* 3 */ "..lcj....." + /* 4 */ "..lcj....." + /* 5 */ "..lcj....." + /* 6 */ "..lcj....." + /* 7 */ "..lcj....." + /* 8 */ "..lcj....." + /* 9 */ "..lcj..mmm" + /* 10 */ "..lcj..mmm", // Connectors: "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */, @@ -3626,7 +3627,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "aaabbbbaaaa" + /* 0 */ "aaaabbbaaaa" /* 1 */ "abbbbbbbbba" /* 2 */ "abbbbbbbbba" /* 3 */ "abbbbbbbbba" @@ -4509,10 +4510,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 4 */ ".aaaaaaaaa." /* 5 */ ".aaaaaaaaa." /* 6 */ ".....aaaaa." - /* 7 */ ".....aaaaa." - /* 8 */ ".....aaaaa." - /* 9 */ ".....aaaaa." - /* 10 */ "..........." + /* 7 */ "mmmm.aaaaa." + /* 8 */ "mmmm.aaaaa." + /* 9 */ "mmmm.aaaaa." + /* 10 */ "mmmm......." // Level 2 /* z\x* 1 */ @@ -4524,10 +4525,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 4 */ ".f.......f." /* 5 */ ".efffe...f." /* 6 */ ".....f...f." - /* 7 */ ".....f...f." - /* 8 */ ".....f...f." - /* 9 */ ".....efffe." - /* 10 */ "..........." + /* 7 */ "mmmm.f...f." + /* 8 */ "mmmm.f...f." + /* 9 */ "mmmm.efffe." + /* 10 */ "mmmm......." // Level 3 /* z\x* 1 */ @@ -4539,10 +4540,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 4 */ ".h.......h." /* 5 */ ".ehhhe...f." /* 6 */ ".....h...h." - /* 7 */ ".....h...h." - /* 8 */ ".....h...h." - /* 9 */ ".....ehhhe." - /* 10 */ "..........." + /* 7 */ "mmmm.h...h." + /* 8 */ "mmmm.h...h." + /* 9 */ "mmmm.ehhhe." + /* 10 */ "mmmm......." // Level 4 /* z\x* 1 */ @@ -4554,10 +4555,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 4 */ ".f...o...fl" /* 5 */ "pfffffq.rfl" /* 6 */ "sssssf...fl" - /* 7 */ "....tf...fl" - /* 8 */ "....tf...fl" - /* 9 */ "....tfffffl" - /* 10 */ "....tu...vl" + /* 7 */ "mmmmtf...fl" + /* 8 */ "mmmmtf...fl" + /* 9 */ "mmmmtfffffl" + /* 10 */ "mmmmtu...vl" // Level 5 /* z\x* 1 */ @@ -4569,10 +4570,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 4 */ "pffffff.fl." /* 5 */ "ssssssf.fl." /* 6 */ ".....tf.fl." - /* 7 */ ".....tf.fl." - /* 8 */ ".....tf.fl." - /* 9 */ ".....tfffl." - /* 10 */ ".....tu.vl." + /* 7 */ "mmmm.tf.fl." + /* 8 */ "mmmm.tf.fl." + /* 9 */ "mmmm.tfffl." + /* 10 */ "mmmm.tu.vl." // Level 6 /* z\x* 1 */ @@ -4584,10 +4585,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 4 */ "sssssstfl.." /* 5 */ "......tfl.." /* 6 */ "......tfl.." - /* 7 */ "......tfl.." - /* 8 */ "......tfl.." - /* 9 */ "......tfl.." - /* 10 */ "......tfl..", + /* 7 */ "mmmm..tfl.." + /* 8 */ "mmmm..tfl.." + /* 9 */ "mmmm..tfl.." + /* 10 */ "mmmm..tfl..", // Connectors: "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */, @@ -4837,9 +4838,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 1 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." /* 3 */ "........." /* 4 */ ".aaaaa..." /* 5 */ ".aaaaab.." @@ -4847,15 +4848,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ ".aaaaad.." /* 8 */ ".aaaaa..." /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." // Level 2 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." /* 3 */ "........." /* 4 */ ".efffe..." /* 5 */ ".f...f..." @@ -4863,15 +4864,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ ".f...f..." /* 8 */ ".efffe..." /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." // Level 3 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." /* 3 */ "........." /* 4 */ ".ejjje..." /* 5 */ ".j...f..." @@ -4879,15 +4880,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ ".j...f..." /* 8 */ ".ejjje..." /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." // Level 4 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." /* 3 */ "........." /* 4 */ ".efffe..." /* 5 */ ".f..nf..." @@ -4895,15 +4896,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ ".f..nf..k" /* 8 */ ".efffe..o" /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." // Level 5 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." /* 3 */ "........." /* 4 */ ".epppe..." /* 5 */ ".q...q..." @@ -4911,15 +4912,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ ".q...q..k" /* 8 */ ".epppe..o" /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." // Level 6 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." /* 3 */ "........." /* 4 */ ".efffe..." /* 5 */ ".f...f..." @@ -4927,15 +4928,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ ".f...f..o" /* 8 */ ".efffe..o" /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." // Level 7 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." /* 3 */ "........." /* 4 */ ".ejjje..." /* 5 */ ".j...j..." @@ -4943,15 +4944,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ ".j...j..o" /* 8 */ ".ejjje..." /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." // Level 8 /* z\x* 012345678 */ - /* 0 */ "........o" - /* 1 */ "........o" - /* 2 */ "........o" + /* 0 */ "mmmmmmm.o" + /* 1 */ "mmmmmmm.o" + /* 2 */ "mmmmmmm.o" /* 3 */ "........." /* 4 */ ".efffe..." /* 5 */ ".f...f..k" @@ -4959,15 +4960,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ ".f...f..o" /* 8 */ ".efffe..." /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." // Level 9 /* z\x* 012345678 */ - /* 0 */ "........k" - /* 1 */ "........k" - /* 2 */ "........o" + /* 0 */ "mmmmmmm.k" + /* 1 */ "mmmmmmm.k" + /* 2 */ "mmmmmmm.o" /* 3 */ "........o" /* 4 */ ".epppe..o" /* 5 */ ".q...q..k" @@ -4975,15 +4976,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ ".q...q..k" /* 8 */ ".epppe..k" /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." // Level 10 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........k" + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.k" /* 3 */ "rrrrrrr.k" /* 4 */ "sfffffs.o" /* 5 */ ".f...f..o" @@ -4991,15 +4992,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ ".f...f..o" /* 8 */ "tffffft.o" /* 9 */ "uuuuuuu.k" - /* 10 */ "........k" - /* 11 */ "........." - /* 12 */ "........." + /* 10 */ "mmmmmmm.k" + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." // Level 11 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." /* 3 */ "........." /* 4 */ "rrrrrrr.k" /* 5 */ "sfffffs.k" @@ -5007,15 +5008,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ "tffffft.k" /* 8 */ "uuuuuuu.o" /* 9 */ "........o" - /* 10 */ "........o" - /* 11 */ "........k" - /* 12 */ "........k" + /* 10 */ "mmmmmmm.o" + /* 11 */ "mmmmmmm.k" + /* 12 */ "mmmmmmm.k" // Level 12 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." /* 3 */ "........." /* 4 */ "........." /* 5 */ "rrrrrrr.o" @@ -5023,15 +5024,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ "uuuuuuu.k" /* 8 */ "........." /* 9 */ "........." - /* 10 */ "........o" - /* 11 */ "........o" - /* 12 */ "........o" + /* 10 */ "mmmmmmm.o" + /* 11 */ "mmmmmmm.o" + /* 12 */ "mmmmmmm.o" // Level 13 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." /* 3 */ "........." /* 4 */ "........." /* 5 */ "........o" @@ -5039,15 +5040,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ "........." /* 8 */ "........." /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." // Level 14 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." /* 3 */ "........." /* 4 */ "........o" /* 5 */ "........o" @@ -5055,15 +5056,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ "........." /* 8 */ "........." /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." // Level 15 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." /* 3 */ "........." /* 4 */ "........o" /* 5 */ "........k" @@ -5071,15 +5072,15 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ "........." /* 8 */ "........." /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ "........." + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm.." // Level 16 /* z\x* 012345678 */ - /* 0 */ "........." - /* 1 */ "........." - /* 2 */ "........." + /* 0 */ "mmmmmmm.." + /* 1 */ "mmmmmmm.." + /* 2 */ "mmmmmmm.." /* 3 */ "........." /* 4 */ "........o" /* 5 */ "........k" @@ -5087,9 +5088,9 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 7 */ "........." /* 8 */ "........." /* 9 */ "........." - /* 10 */ "........." - /* 11 */ "........." - /* 12 */ ".........", + /* 10 */ "mmmmmmm.." + /* 11 */ "mmmmmmm.." + /* 12 */ "mmmmmmm..", // Connectors: "-1: 8, 1, 6: 5\n" /* Type -1, direction X+ */, @@ -5472,13 +5473,15 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = "l: 66: 7\n" /* tracks */ "m: 19: 0\n" /* sponge */ "n: 50: 2\n" /* torch */ - "o: 2: 0\n" /* grass */ - "p: 53: 2\n" /* woodstairs */ - "q: 77: 1\n" /* stonebutton */ - "r: 27: 0\n" /* poweredrail */ - "s: 53: 7\n" /* woodstairs */ - "t: 53: 6\n" /* woodstairs */ - "u: 53: 3\n" /* woodstairs */, + "o: 4: 0\n" /* cobblestone */ + "p: 2: 0\n" /* grass */ + "q: 13: 0\n" /* gravel */ + "r: 53: 2\n" /* woodstairs */ + "s: 77: 1\n" /* stonebutton */ + "t: 27: 0\n" /* poweredrail */ + "u: 53: 7\n" /* woodstairs */ + "v: 53: 6\n" /* woodstairs */ + "w: 53: 3\n" /* woodstairs */, // Block data: // Level 0 @@ -5783,28 +5786,28 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = // Level 30 /* z\x* 0123456 */ - /* 0 */ "mmmmmmm" + /* 0 */ "mmooomm" /* 1 */ "mmmammm" - /* 2 */ "mm...mm" - /* 3 */ "ma..aam" - /* 4 */ "mmfgamm" + /* 2 */ "om...mo" + /* 3 */ "oa..aao" + /* 4 */ "omfgamo" /* 5 */ "mmmammm" - /* 6 */ "mmmmmmm" + /* 6 */ "mmooomm" // Level 31 /* z\x* 0123456 */ - /* 0 */ "ooomooo" - /* 1 */ "oaaaaao" - /* 2 */ "oa.aaao" - /* 3 */ "oa..iao" - /* 4 */ "oa..jao" - /* 5 */ "oaaaaao" - /* 6 */ "ooooooo" + /* 0 */ "ppqqqpp" + /* 1 */ "paaaaap" + /* 2 */ "qa.aaaq" + /* 3 */ "qa..iaq" + /* 4 */ "qa..jaq" + /* 5 */ "paaaaap" + /* 6 */ "ppqqqpp" // Level 32 /* z\x* 0123456 */ - /* 0 */ "...p..." - /* 1 */ ".aqrba." + /* 0 */ "...r..." + /* 1 */ ".astba." /* 2 */ "...fl.." /* 3 */ "......." /* 4 */ "......." @@ -5833,31 +5836,31 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = // Level 35 /* z\x* 0123456 */ - /* 0 */ "ppppppp" - /* 1 */ "saaaaas" + /* 0 */ "rrrrrrr" + /* 1 */ "uaaaaau" /* 2 */ ".a...a." /* 3 */ ".a...a." /* 4 */ ".a...a." - /* 5 */ "taaaaat" - /* 6 */ "uuuuuuu" + /* 5 */ "vaaaaav" + /* 6 */ "wwwwwww" // Level 36 /* z\x* 0123456 */ /* 0 */ "......." - /* 1 */ "ppppppp" - /* 2 */ "saaaaas" + /* 1 */ "rrrrrrr" + /* 2 */ "uaaaaau" /* 3 */ ".aaaaa." - /* 4 */ "taaaaat" - /* 5 */ "uuuuuuu" + /* 4 */ "vaaaaav" + /* 5 */ "wwwwwww" /* 6 */ "......." // Level 37 /* z\x* 0123456 */ /* 0 */ "......." /* 1 */ "......." - /* 2 */ "ppppppp" + /* 2 */ "rrrrrrr" /* 3 */ "aaaaaaa" - /* 4 */ "uuuuuuu" + /* 4 */ "wwwwwww" /* 5 */ "......." /* 6 */ ".......", diff --git a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp index eb01cf59e..44e947952 100644 --- a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp +++ b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp @@ -23,8 +23,8 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = 12, 6, 10, // SizeX = 12, SizeY = 6, SizeZ = 10 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 11, 5, 9, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 12, 5, 10, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -170,8 +170,8 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = 13, 6, 9, // SizeX = 13, SizeY = 6, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 12, 5, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 13, 5, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -309,8 +309,8 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = 7, 6, 6, // SizeX = 7, SizeY = 6, SizeZ = 6 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 6, 5, 5, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 7, 5, 6, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -420,8 +420,8 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 6, 5, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 7, 5, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -538,8 +538,8 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = 9, 6, 7, // SizeX = 9, SizeY = 6, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 8, 5, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 9, 5, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -656,8 +656,8 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = 10, 6, 7, // SizeX = 10, SizeY = 6, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 9, 5, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 10, 5, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -780,8 +780,8 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = 10, 6, 9, // SizeX = 10, SizeY = 6, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 9, 5, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 10, 5, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -918,8 +918,8 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = 11, 6, 9, // SizeX = 11, SizeY = 6, SizeZ = 9 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 10, 5, 8, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 11, 5, 9, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1054,18 +1054,18 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // The data has been exported from the gallery Desert, area index 53, ID 345, created by jakibaki { // Size: - 15, 5, 14, // SizeX = 15, SizeY = 5, SizeZ = 14 + 15, 6, 14, // SizeX = 15, SizeY = 6, SizeZ = 14 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 14, 4, 13, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 15, 5, 14, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ - "a:128: 0\n" /* sandstonestairs */ - "b:128: 2\n" /* sandstonestairs */ - "c:128: 1\n" /* sandstonestairs */ - "d: 24: 0\n" /* sandstone */ + "a: 24: 0\n" /* sandstone */ + "b:128: 0\n" /* sandstonestairs */ + "c:128: 2\n" /* sandstonestairs */ + "d:128: 1\n" /* sandstonestairs */ "e: 43: 1\n" /* doubleslab */ "f: 64: 7\n" /* wooddoorblock */ "g:171: 0\n" /* carpet */ @@ -1088,43 +1088,61 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = // Level 0 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "...abc........." - /* 1 */ ".ddddddddddddd." - /* 2 */ ".ddddddddddddd." - /* 3 */ ".ddddddddddddd." - /* 4 */ ".ddddddddddddd." - /* 5 */ ".ddddddddddded." - /* 6 */ ".ddddddddddddd." - /* 7 */ ".ddddddddddddd." - /* 8 */ ".......deddddd." - /* 9 */ "mmmmmm.ddddddd." - /* 10 */ "mmmmmm.ddddddd." - /* 11 */ "mmmmmm.ddddddd." - /* 12 */ "mmmmmm.ddddddd." - /* 13 */ "..............." + /* 0 */ "mmmaaammmmmmmmm" + /* 1 */ "maaaaaaaaaaaaam" + /* 2 */ "maaaaaaaaaaaaam" + /* 3 */ "maaaaaaaaaaaaam" + /* 4 */ "maaaaaaaaaaaaam" + /* 5 */ "maaaaaaaaaaaaam" + /* 6 */ "maaaaaaaaaaaaam" + /* 7 */ "maaaaaaaaaaaaam" + /* 8 */ "mmmmmmmaaaaaaam" + /* 9 */ "mmmmmmmaaaaaaam" + /* 10 */ "mmmmmmmaaaaaaam" + /* 11 */ "mmmmmmmaaaaaaam" + /* 12 */ "mmmmmmmaaaaaaam" + /* 13 */ "mmmmmmmmmmmmmmm" // Level 1 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "..............." - /* 1 */ ".dddfddddddddd." - /* 2 */ ".dgghhhhhhhhgd." - /* 3 */ ".dghiiiiiiiihd." - /* 4 */ ".dghiggggggihd." - /* 5 */ ".dghiiiiiigihd." - /* 6 */ ".dgghhhhhigihd." - /* 7 */ ".dddddddhigihd." - /* 8 */ ".......dhigihd." - /* 9 */ "mmmmmm.dhiiihd." - /* 10 */ "mmmmmm.dghhhgd." - /* 11 */ "mmmmmm.dggggjd." - /* 12 */ "mmmmmm.ddddddd." + /* 0 */ "...bcd........." + /* 1 */ ".aaaaaaaaaaaaa." + /* 2 */ ".aaaaaaaaaaaaa." + /* 3 */ ".aaaaaaaaaaaaa." + /* 4 */ ".aaaaaaaaaaaaa." + /* 5 */ ".aaaaaaaaaaaea." + /* 6 */ ".aaaaaaaaaaaaa." + /* 7 */ ".aaaaaaaaaaaaa." + /* 8 */ ".......aeaaaaa." + /* 9 */ "mmmmmm.aaaaaaa." + /* 10 */ "mmmmmm.aaaaaaa." + /* 11 */ "mmmmmm.aaaaaaa." + /* 12 */ "mmmmmm.aaaaaaa." /* 13 */ "..............." // Level 2 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." + /* 1 */ ".aaafaaaaaaaaa." + /* 2 */ ".agghhhhhhhhga." + /* 3 */ ".aghiiiiiiiiha." + /* 4 */ ".aghiggggggiha." + /* 5 */ ".aghiiiiiigiha." + /* 6 */ ".agghhhhhigiha." + /* 7 */ ".aaaaaaahigiha." + /* 8 */ ".......ahigiha." + /* 9 */ "mmmmmm.ahiiiha." + /* 10 */ "mmmmmm.aghhhga." + /* 11 */ "mmmmmm.aggggja." + /* 12 */ "mmmmmm.aaaaaaa." + /* 13 */ "..............." + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "..............." /* 1 */ ".kkklkkkk.kkkk." /* 2 */ ".k...........k." /* 3 */ ".k...........k." @@ -1139,44 +1157,44 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = /* 12 */ "mmmmmm.kkk.kkk." /* 13 */ "..............." - // Level 3 + // Level 4 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "..............." - /* 1 */ ".ddddddddddddd." - /* 2 */ ".d......n....d." - /* 3 */ ".d...........d." - /* 4 */ ".do..........d." - /* 5 */ ".d...........d." - /* 6 */ ".d..........pd." - /* 7 */ ".ddddddd.....d." - /* 8 */ ".......d.....d." - /* 9 */ "mmmmmm.d.....d." - /* 10 */ "mmmmmm.d.....d." - /* 11 */ "mmmmmm.d..q..d." - /* 12 */ "mmmmmm.ddddddd." + /* 1 */ ".aaaaaaaaaaaaa." + /* 2 */ ".a......n....a." + /* 3 */ ".a...........a." + /* 4 */ ".ao..........a." + /* 5 */ ".a...........a." + /* 6 */ ".a..........pa." + /* 7 */ ".aaaaaaa.....a." + /* 8 */ ".......a.....a." + /* 9 */ "mmmmmm.a.....a." + /* 10 */ "mmmmmm.a.....a." + /* 11 */ "mmmmmm.a..q..a." + /* 12 */ "mmmmmm.aaaaaaa." /* 13 */ "..............." - // Level 4 + // Level 5 /* z\x* 11111 */ /* * 012345678901234 */ /* 0 */ "rrrrrrrrrrrrrrs" - /* 1 */ "tddddddddddddds" - /* 2 */ "tddddddddddddds" - /* 3 */ "tddddddddddddds" - /* 4 */ "tddddddddddddds" - /* 5 */ "tddddddddddddds" - /* 6 */ "tddddddddddddds" - /* 7 */ "tddddddddddddds" - /* 8 */ "tuuuuutddddddds" - /* 9 */ "mmmmmmtddddddds" - /* 10 */ "mmmmmmtddddddds" - /* 11 */ "mmmmmmtddddddds" - /* 12 */ "mmmmmmtddddddds" + /* 1 */ "taaaaaaaaaaaaas" + /* 2 */ "taaaaaaaaaaaaas" + /* 3 */ "taaaaaaaaaaaaas" + /* 4 */ "taaaaaaaaaaaaas" + /* 5 */ "taaaaaaaaaaaaas" + /* 6 */ "taaaaaaaaaaaaas" + /* 7 */ "taaaaaaaaaaaaas" + /* 8 */ "tuuuuutaaaaaaas" + /* 9 */ "mmmmmmtaaaaaaas" + /* 10 */ "mmmmmmtaaaaaaas" + /* 11 */ "mmmmmmtaaaaaaas" + /* 12 */ "mmmmmmtaaaaaaas" /* 13 */ "......tuuuuuuuu", // Connectors: - "-1: 4, 0, 0: 2\n" /* Type -1, direction Z- */, + "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -1210,8 +1228,8 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 6, 5, 6, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 7, 5, 7, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -1320,8 +1338,8 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = 14, 4, 16, // SizeX = 14, SizeY = 4, SizeZ = 16 // Hitbox (relative to bounding box): - 0, 0, 0, // MinX, MinY, MinZ - 13, 3, 15, // MaxX, MaxY, MaxZ + -1, 0, 0, // MinX, MinY, MinZ + 14, 3, 16, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ -- cgit v1.2.3 From 9a57c590cd99d7ff9871849fb8ce3017570c1c2a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 21 Jun 2014 20:17:17 +0200 Subject: Fixed a caching bug in GridStructGen. The elements in cache were queried wrong, so sometimes they wouldn't be used even if they were the ones to use. --- src/Generating/GridStructGen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp index 2931df3eb..95f8c38bc 100644 --- a/src/Generating/GridStructGen.cpp +++ b/src/Generating/GridStructGen.cpp @@ -88,8 +88,8 @@ void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructur for (cStructurePtrs::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end;) { if ( - ((*itr)->m_OriginX >= MinX) && ((*itr)->m_OriginX < MaxX) && - ((*itr)->m_OriginZ >= MinZ) && ((*itr)->m_OriginZ < MaxZ) + ((*itr)->m_GridX >= MinX) && ((*itr)->m_GridX < MaxX) && + ((*itr)->m_GridZ >= MinZ) && ((*itr)->m_GridZ < MaxZ) ) { // want -- cgit v1.2.3 From 0a95d04ab38b81f87d4fa421601d25f37df1f6a1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 21 Jun 2014 20:19:44 +0200 Subject: Added a TestRails generator. This is for debugging purposes only. --- src/Generating/ComposableGenerator.cpp | 5 + src/Generating/Prefabs/TestRailsPrefabs.cpp | 484 ++++++++++++++++++++++++++++ src/Generating/Prefabs/TestRailsPrefabs.h | 15 + src/Generating/TestRailsGen.cpp | 116 +++++++ src/Generating/TestRailsGen.h | 47 +++ 5 files changed, 667 insertions(+) create mode 100644 src/Generating/Prefabs/TestRailsPrefabs.cpp create mode 100644 src/Generating/Prefabs/TestRailsPrefabs.h create mode 100644 src/Generating/TestRailsGen.cpp create mode 100644 src/Generating/TestRailsGen.h (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 22941dcbe..7b6234161 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -26,6 +26,7 @@ #include "POCPieceGenerator.h" #include "RainbowRoadsGen.h" #include "Ravines.h" +#include "TestRailsGen.h" #include "UnderwaterBaseGen.h" #include "VillageGen.h" @@ -414,6 +415,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) { m_FinishGens.push_back(new cFinishGenSprinkleFoliage(Seed)); } + else if (NoCaseCompare(*itr, "TestRails") == 0) + { + m_FinishGens.push_back(new cTestRailsGen(Seed, 100, 1, 7, 50)); + } else if (NoCaseCompare(*itr, "Trees") == 0) { m_FinishGens.push_back(new cStructGenTrees(Seed, m_BiomeGen, m_HeightGen, m_CompositionGen)); diff --git a/src/Generating/Prefabs/TestRailsPrefabs.cpp b/src/Generating/Prefabs/TestRailsPrefabs.cpp new file mode 100644 index 000000000..3444cb1fa --- /dev/null +++ b/src/Generating/Prefabs/TestRailsPrefabs.cpp @@ -0,0 +1,484 @@ + +// TestRailsPrefabs.cpp + +// Defines the prefabs in the group TestRails + +// NOTE: This file has been generated automatically by GalExport! +// Any manual changes will be overwritten by the next automatic export! + +#include "Globals.h" +#include "TestRailsPrefabs.h" + + + + + +const cPrefab::sDef g_TestRailsPrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ActivatorRail: + // The data has been exported from the gallery Plains, area index 251, ID 746, created by Aloe_vera + { + // Size: + 7, 3, 7, // SizeX = 7, SizeY = 3, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 2, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 1: 0\n" /* stone */ + "b: 5: 0\n" /* wood */ + "c:157: 0\n" /* activatorrail */ + "d:157: 2\n" /* activatorrail */ + "e:157: 3\n" /* activatorrail */ + "f:157: 5\n" /* activatorrail */ + "g: 50: 5\n" /* torch */ + "h:157: 4\n" /* activatorrail */ + "i:157: 1\n" /* activatorrail */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "aaab..." + /* 1 */ "abbbbb." + /* 2 */ "abbb.b." + /* 3 */ "bbbb.bb" + /* 4 */ ".b...b." + /* 5 */ ".bbbbb." + /* 6 */ "...b..." + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".cdbec." + /* 2 */ ".fg..f." + /* 3 */ ".b.g.b." + /* 4 */ ".h...h." + /* 5 */ ".cdbec." + /* 6 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "...i..." + /* 2 */ "......." + /* 3 */ ".c...c." + /* 4 */ "......." + /* 5 */ "...i..." + /* 6 */ ".......", + + // Connectors: + "1: 6, 1, 3: 5\n" /* Type 1, direction X+ */ + "-1: 6, 1, 3: 5\n" /* Type -1, direction X+ */ + "1: 3, 1, 6: 3\n" /* Type 1, direction Z+ */ + "-1: 3, 1, 6: 3\n" /* Type -1, direction Z+ */ + "1: 0, 1, 3: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */ + "1: 3, 1, 0: 2\n" /* Type 1, direction Z- */ + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // ActivatorRail + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // DetectorRail: + // The data has been exported from the gallery Plains, area index 250, ID 745, created by Aloe_vera + { + // Size: + 7, 3, 7, // SizeX = 7, SizeY = 3, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 2, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 1: 0\n" /* stone */ + "b: 5: 0\n" /* wood */ + "c: 28: 0\n" /* detectorrail */ + "d: 28: 2\n" /* detectorrail */ + "e: 28: 3\n" /* detectorrail */ + "f: 28: 5\n" /* detectorrail */ + "g: 50: 5\n" /* torch */ + "h: 28: 4\n" /* detectorrail */ + "i: 28: 1\n" /* detectorrail */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "aaab..." + /* 1 */ "abbbbb." + /* 2 */ "abbb.b." + /* 3 */ "bbbb.bb" + /* 4 */ ".b...b." + /* 5 */ ".bbbbb." + /* 6 */ "...b..." + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".cdbec." + /* 2 */ ".fg..f." + /* 3 */ ".b.g.b." + /* 4 */ ".h...h." + /* 5 */ ".cdbec." + /* 6 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "...i..." + /* 2 */ "......." + /* 3 */ ".c...c." + /* 4 */ "......." + /* 5 */ "...i..." + /* 6 */ ".......", + + // Connectors: + "1: 6, 1, 3: 5\n" /* Type 1, direction X+ */ + "-1: 6, 1, 3: 5\n" /* Type -1, direction X+ */ + "1: 3, 1, 0: 2\n" /* Type 1, direction Z- */ + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */ + "1: 0, 1, 3: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */ + "1: 3, 1, 6: 3\n" /* Type 1, direction Z+ */ + "-1: 3, 1, 6: 3\n" /* Type -1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // DetectorRail + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // PowerRail: + // The data has been exported from the gallery Plains, area index 248, ID 743, created by Aloe_vera + { + // Size: + 7, 3, 7, // SizeX = 7, SizeY = 3, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 2, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 1: 0\n" /* stone */ + "b: 5: 0\n" /* wood */ + "c: 27: 0\n" /* poweredrail */ + "d: 27: 2\n" /* poweredrail */ + "e: 27: 3\n" /* poweredrail */ + "f: 27: 5\n" /* poweredrail */ + "g: 50: 5\n" /* torch */ + "h: 27: 4\n" /* poweredrail */ + "i: 27: 1\n" /* poweredrail */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "aaab..." + /* 1 */ "abbbbb." + /* 2 */ "abbb.b." + /* 3 */ "bbbb.bb" + /* 4 */ ".b...b." + /* 5 */ ".bbbbb." + /* 6 */ "...b..." + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".cdbec." + /* 2 */ ".fg..f." + /* 3 */ ".b.g.b." + /* 4 */ ".h...h." + /* 5 */ ".cdbec." + /* 6 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "...i..." + /* 2 */ "......." + /* 3 */ ".c...c." + /* 4 */ "......." + /* 5 */ "...i..." + /* 6 */ ".......", + + // Connectors: + "1: 6, 1, 3: 5\n" /* Type 1, direction X+ */ + "-1: 6, 1, 3: 5\n" /* Type -1, direction X+ */ + "1: 3, 1, 6: 3\n" /* Type 1, direction Z+ */ + "-1: 3, 1, 6: 3\n" /* Type -1, direction Z+ */ + "1: 0, 1, 3: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */ + "1: 3, 1, 0: 2\n" /* Type 1, direction Z- */ + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */ + "1: 6, 1, 3: 5\n" /* Type 1, direction X+ */ + "-1: 6, 1, 3: 5\n" /* Type -1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // PowerRail + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // RegularRail: + // The data has been exported from the gallery Plains, area index 247, ID 742, created by Aloe_vera + { + // Size: + 7, 3, 7, // SizeX = 7, SizeY = 3, SizeZ = 7 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 6, 2, 6, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 1: 0\n" /* stone */ + "b: 5: 0\n" /* wood */ + "c: 66: 6\n" /* tracks */ + "d: 66: 2\n" /* tracks */ + "e: 66: 3\n" /* tracks */ + "f: 66: 7\n" /* tracks */ + "g: 66: 5\n" /* tracks */ + "h: 50: 5\n" /* torch */ + "i: 66: 4\n" /* tracks */ + "j: 66: 9\n" /* tracks */ + "k: 66: 8\n" /* tracks */ + "l: 66: 1\n" /* tracks */ + "m: 19: 0\n" /* sponge */ + "n: 66: 0\n" /* tracks */, + + // Block data: + // Level 0 + /* z\x* 0123456 */ + /* 0 */ "aaab..." + /* 1 */ "abbbbb." + /* 2 */ "abbb.b." + /* 3 */ "bbbb.bb" + /* 4 */ ".b...b." + /* 5 */ ".bbbbb." + /* 6 */ "...b..." + + // Level 1 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ ".cdbef." + /* 2 */ ".gh..g." + /* 3 */ ".b.h.b." + /* 4 */ ".i...i." + /* 5 */ ".jdbek." + /* 6 */ "......." + + // Level 2 + /* z\x* 0123456 */ + /* 0 */ "......." + /* 1 */ "...l..." + /* 2 */ "......." + /* 3 */ ".n...n." + /* 4 */ "......." + /* 5 */ "...l..." + /* 6 */ ".......", + + // Connectors: + "1: 6, 1, 3: 5\n" /* Type 1, direction X+ */ + "-1: 6, 1, 3: 5\n" /* Type -1, direction X+ */ + "1: 3, 1, 6: 3\n" /* Type 1, direction Z+ */ + "-1: 3, 1, 6: 3\n" /* Type -1, direction Z+ */ + "1: 0, 1, 3: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */ + "1: 3, 1, 0: 2\n" /* Type 1, direction Z- */ + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // RegularRail +}; // g_TestRailsPrefabs + + + + + + +const cPrefab::sDef g_TestRailsStartingPrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CentralPiece: + // The data has been exported from the gallery Plains, area index 249, ID 744, created by Aloe_vera + { + // Size: + 6, 3, 6, // SizeX = 6, SizeY = 3, SizeZ = 6 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 5, 2, 5, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 1: 0\n" /* stone */ + "b: 5: 0\n" /* wood */ + "c: 66: 6\n" /* tracks */ + "d: 66: 2\n" /* tracks */ + "e: 66: 3\n" /* tracks */ + "f: 66: 7\n" /* tracks */ + "g: 66: 5\n" /* tracks */ + "h: 50: 5\n" /* torch */ + "i: 66: 4\n" /* tracks */ + "j: 66: 9\n" /* tracks */ + "k: 66: 8\n" /* tracks */ + "l: 66: 1\n" /* tracks */ + "m: 19: 0\n" /* sponge */ + "n: 66: 0\n" /* tracks */, + + // Block data: + // Level 0 + /* z\x* 012345 */ + /* 0 */ "aaab.." + /* 1 */ "abbbbb" + /* 2 */ "abbb.b" + /* 3 */ "bbbb.b" + /* 4 */ ".b...b" + /* 5 */ ".bbbbb" + + // Level 1 + /* z\x* 012345 */ + /* 0 */ "......" + /* 1 */ ".cdbef" + /* 2 */ ".gh..g" + /* 3 */ ".b.h.b" + /* 4 */ ".i...i" + /* 5 */ ".jdbek" + + // Level 2 + /* z\x* 012345 */ + /* 0 */ "......" + /* 1 */ "...l.." + /* 2 */ "......" + /* 3 */ ".n...n" + /* 4 */ "......" + /* 5 */ "...l..", + + // Connectors: + "1: 3, 1, 6: 3\n" /* Type 1, direction Z+ */ + "1: 0, 1, 3: 4\n" /* Type 1, direction X- */ + "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */ + "-1: 3, 1, 6: 3\n" /* Type -1, direction Z+ */ + "1: 6, 1, 3: 5\n" /* Type 1, direction X+ */ + "-1: 6, 1, 3: 5\n" /* Type -1, direction X+ */ + "1: 3, 1, 0: 2\n" /* Type 1, direction Z- */ + "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CentralPiece +}; + + + + + +// The prefab counts: + +const size_t g_TestRailsPrefabsCount = ARRAYCOUNT(g_TestRailsPrefabs); + +const size_t g_TestRailsStartingPrefabsCount = ARRAYCOUNT(g_TestRailsStartingPrefabs); + diff --git a/src/Generating/Prefabs/TestRailsPrefabs.h b/src/Generating/Prefabs/TestRailsPrefabs.h new file mode 100644 index 000000000..24b84de74 --- /dev/null +++ b/src/Generating/Prefabs/TestRailsPrefabs.h @@ -0,0 +1,15 @@ + +// TestRailsPrefabs.h + +// Declares the prefabs in the group TestRails + +#include "../Prefab.h" + + + + + +extern const cPrefab::sDef g_TestRailsPrefabs[]; +extern const cPrefab::sDef g_TestRailsStartingPrefabs[]; +extern const size_t g_TestRailsPrefabsCount; +extern const size_t g_TestRailsStartingPrefabsCount; diff --git a/src/Generating/TestRailsGen.cpp b/src/Generating/TestRailsGen.cpp new file mode 100644 index 000000000..c40c1a9b6 --- /dev/null +++ b/src/Generating/TestRailsGen.cpp @@ -0,0 +1,116 @@ + +// TestRailsGen.cpp + +// Implements the cTestRailsGen class representing the testing rails generator + +#include "Globals.h" +#include "TestRailsGen.h" +#include "Prefabs/TestRailsPrefabs.h" +#include "PieceGenerator.h" + + + + + +static cPrefabPiecePool g_TestRails(g_TestRailsPrefabs, g_TestRailsPrefabsCount, g_TestRailsStartingPrefabs, g_TestRailsStartingPrefabsCount); + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cTestRailsGen::cTestRails: + +class cTestRailsGen::cTestRails : + public cGridStructGen::cStructure +{ + typedef cGridStructGen::cStructure super; + +public: + cTestRails( + int a_Seed, + int a_GridX, int a_GridZ, + int a_OriginX, int a_OriginZ, + int a_MaxDepth, + int a_MaxSize + ) : + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), + m_Seed(a_Seed), + m_Noise(a_Seed), + m_MaxSize(a_MaxSize), + m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, 255, a_OriginZ + a_MaxSize) + { + // Generate the pieces for this test: + cBFSPieceGenerator pg(g_TestRails, a_Seed); + pg.PlacePieces(a_OriginX, 150, a_OriginZ, a_MaxDepth, m_Pieces); + if (m_Pieces.empty()) + { + return; + } + } + + ~cTestRails() + { + cPieceGenerator::FreePieces(m_Pieces); + } + +protected: + /** Seed for the random functions */ + int m_Seed; + + /** The noise used as a pseudo-random generator */ + cNoise m_Noise; + + /** Maximum size, in X/Z blocks, of the structure (radius from the origin) */ + int m_MaxSize; + + /** Borders of the structure - no item may reach out of this cuboid. */ + cCuboid m_Borders; + + /** The rails pieces, placed by the generator. */ + cPlacedPieces m_Pieces; + + + // cGridStructGen::cStructure overrides: + virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override + { + for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr) + { + cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece()); + Prefab.Draw(a_Chunk, *itr); + } // for itr - m_PlacedPieces[] + } +} ; + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cTestRailsGen: + + + + + +cTestRailsGen::cTestRailsGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 100), + m_Noise(a_Seed + 1000), + m_MaxDepth(a_MaxDepth), + m_MaxSize(a_MaxSize) +{ +} + + + + + +cGridStructGen::cStructurePtr cTestRailsGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) +{ + // Create a base based on the chosen prefabs: + return cStructurePtr(new cTestRails(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize)); +} + + + + diff --git a/src/Generating/TestRailsGen.h b/src/Generating/TestRailsGen.h new file mode 100644 index 000000000..5b0ce95f4 --- /dev/null +++ b/src/Generating/TestRailsGen.h @@ -0,0 +1,47 @@ + +// TestRailsGen.h + +// Declares the cTestRailsGen class representing the testing rails generator + + + + + +#pragma once + +#include "GridStructGen.h" +#include "PrefabPiecePool.h" + + + + + +class cTestRailsGen : + public cGridStructGen +{ + typedef cGridStructGen super; + +public: + cTestRailsGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize); + +protected: + class cTestRails; // fwd: TestRailsGen.cpp + + + /** The noise used for generating random numbers */ + cNoise m_Noise; + + /** Maximum depth of the generator tree*/ + int m_MaxDepth; + + /** Maximum size, in X/Z blocks, of the base (radius from the origin) */ + int m_MaxSize; + + + // cGridStructGen overrides: + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; +} ; + + + + -- cgit v1.2.3 From a908f39dde1dc8866bda1a85b8443ae4cdaaa2b4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 21 Jun 2014 20:33:23 +0100 Subject: Rewrote furnace recipe parser * Fixes #110 --- src/FurnaceRecipe.cpp | 252 +++++++++++++++++++++++++++++++------------------- src/FurnaceRecipe.h | 22 +++++ 2 files changed, 181 insertions(+), 93 deletions(-) (limited to 'src') diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index bd7fd8079..b4b3d34d9 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -5,7 +5,8 @@ #include "Item.h" #include -#include + +#define FURNACE_RECIPE_FILE "furnace.txt" @@ -53,128 +54,193 @@ void cFurnaceRecipe::ReloadRecipes(void) ClearRecipes(); LOGD("Loading furnace recipes..."); - std::ifstream f; - char a_File[] = "furnace.txt"; - f.open(a_File, std::ios::in); - - if (!f.good()) + std::ifstream F(FURNACE_RECIPE_FILE, std::ios::in); + if (!F.good()) { - f.close(); - LOG("Could not open the furnace recipes file \"%s\"", a_File); + F.close(); + LOG("Could not open the furnace recipes file \"%s\"", FURNACE_RECIPE_FILE); return; } + + AString SyntaxError; + unsigned int Line = 0; + AString ParsingLine; - // TODO: Replace this messy parse with a high-level-structured one (ReadLine / ProcessLine) - bool bSyntaxError = false; - while (f.good()) - { - char c; + ASSERT(ParsingLine.empty()); - ////////////////////////////////////////////////////////////////////////// - // comments - f >> c; - f.unget(); - if( c == '#' ) + while (std::getline(F, ParsingLine)) + { + Line++; + ParsingLine.erase(std::remove_if(ParsingLine.begin(), ParsingLine.end(), isspace), ParsingLine.end()); // Remove whitespace + if (ParsingLine.empty()) { - while( f.good() && c != '\n' ) - { - f.get( c ); - } continue; } - - ////////////////////////////////////////////////////////////////////////// - // Line breaks - f.get( c ); - while( f.good() && ( c == '\n' || c == '\r' ) ) { f.get( c ); } - if (f.eof()) + // Comments + if (ParsingLine[0] == '#') { - break; + continue; } - f.unget(); - ////////////////////////////////////////////////////////////////////////// - // Check for fuel - f >> c; - if( c == '!' ) // It's fuel :) + if (ParsingLine[0] == '!') // Fuels start with a bang :) { - // Read item - int IItemID = 0, IItemCount = 0, IItemHealth = 0; - f >> IItemID; - f >> c; if( c != ':' ) { bSyntaxError = true; break; } - f >> IItemCount; - - // Optional health - f >> c; - if( c != ':' ) - f.unget(); - else + int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0; + AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang) + + if ( + !ReadMandatoryNumber(BeginPos, ":", ParsingLine, SyntaxError, Line, IItemID) || // Read item ID + !ReadOptionalNumbers(BeginPos, ":", "=", ParsingLine, SyntaxError, Line, IItemCount, IItemHealth) || // Read item count (and optionally health) + !ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, SyntaxError, Line, IBurnTime, true) // Read item burn time - last value + ) { - f >> IItemHealth; + break; } - // Burn time - int BurnTime; - f >> c; if( c != '=' ) { bSyntaxError = true; break; } - f >> BurnTime; - // Add to fuel list Fuel F; - F.In = new cItem( (ENUM_ITEM_ID) IItemID, (char)IItemCount, (short)IItemHealth ); - F.BurnTime = BurnTime; - m_pState->Fuel.push_back( F ); + F.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth); + F.BurnTime = IBurnTime; + m_pState->Fuel.push_back(F); + printf("%i %i %i %i\n", IItemID, IItemCount, IItemHealth, IBurnTime); continue; } - f.unget(); - - ////////////////////////////////////////////////////////////////////////// - // Read items - int IItemID = 0, IItemCount = 0, IItemHealth = 0; - f >> IItemID; - f >> c; if( c != ':' ) { bSyntaxError = true; break; } - f >> IItemCount; - - // Optional health - f >> c; - if( c != ':' ) - f.unget(); - else + else if (isdigit(ParsingLine[0])) // Recipes start with a numeral :) { - f >> IItemHealth; + int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0; + int OItemID = 0, OItemCount = 0, OItemHealth = 0; + AString::size_type BeginPos = 0; // Begin at start of line + + if ( + !ReadMandatoryNumber(BeginPos, ":", ParsingLine, SyntaxError, Line, IItemID) || // Read item ID + !ReadOptionalNumbers(BeginPos, ":", "@", ParsingLine, SyntaxError, Line, IItemCount, IItemHealth) || // Read item count (and optionally health) + !ReadMandatoryNumber(BeginPos, "=", ParsingLine, SyntaxError, Line, IBurnTime) || // Read item burn time + !ReadMandatoryNumber(BeginPos, ":", ParsingLine, SyntaxError, Line, OItemID) || // Read result ID + !ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, SyntaxError, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value + ) + { + break; + } + + // Add to recipe list + Recipe R; + R.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth); + R.Out = new cItem((ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth); + R.CookTime = IBurnTime; + m_pState->Recipes.push_back(R); } + } + F.close(); - int CookTime; - f >> c; if( c != '@' ) { bSyntaxError = true; break; } - f >> CookTime; + if (!SyntaxError.empty()) + { + LOGWARN("Error parsing furnace recipes at %s", SyntaxError.c_str()); + } + else + { + LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size()); + } +} - int OItemID = 0, OItemCount = 0, OItemHealth = 0; - f >> c; if( c != '=' ) { bSyntaxError = true; break; } - f >> OItemID; - f >> c; if( c != ':' ) { bSyntaxError = true; break; } - f >> OItemCount; - // Optional health - f >> c; - if( c != ':' ) - f.unget(); - else + + + +void cFurnaceRecipe::SetParseError(AString & a_ErrorString, unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing) +{ + Printf(a_ErrorString, "line %i pos %i: missing '%s'", a_Line, a_Position, a_CharactersMissing.c_str()); +} + + + + + +bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_Value, bool a_IsLastValue) +{ + AString::size_type End; + if (a_IsLastValue) + { + End = a_Text.find_first_not_of(a_Delimiter, a_Begin); + } + else + { + End = a_Text.find_first_of(a_Delimiter, a_Begin); + if (End == AString::npos) { - f >> OItemHealth; + SetParseError(a_ErrorString, a_Line, a_Begin, a_Delimiter); + return false; } - - // Add to recipe list - Recipe R; - R.In = new cItem( (ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth ); - R.Out = new cItem( (ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth ); - R.CookTime = CookTime; - m_pState->Recipes.push_back( R ); } - if (bSyntaxError) + + // stoi won't throw an exception if the string is alphanumeric, we should check for this + if (!DoesStringContainOnlyNumbers(a_Text.substr(a_Begin, End - a_Begin))) { - LOGERROR("ERROR: FurnaceRecipe, syntax error" ); + SetParseError(a_ErrorString, a_Line, a_Begin, "number"); + return false; + } + a_Value = std::stoi(a_Text.substr(a_Begin, End - a_Begin)); + + a_Begin = End + 1; // Jump over delimiter + return true; +} + + + + + +bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue) +{ + unsigned int End, Begin = a_Begin; + + End = a_Text.find_first_of(a_DelimiterOne, Begin); + if (End != AString::npos) + { + if (DoesStringContainOnlyNumbers(a_Text.substr(Begin, End - Begin))) + { + a_ValueOne = std::stoi(a_Text.substr(Begin, End - Begin)); + Begin = End + 1; + + if (a_IsLastValue) + { + End = a_Text.find_first_not_of(a_DelimiterTwo, Begin); + } + else + { + End = a_Text.find_first_of(a_DelimiterTwo, Begin); + if (End == AString::npos) + { + SetParseError(a_ErrorString, a_Line, Begin, a_DelimiterTwo); + return false; + } + } + + // stoi won't throw an exception if the string is alphanumeric, we should check for this + if (!DoesStringContainOnlyNumbers(a_Text.substr(Begin, End - Begin))) + { + SetParseError(a_ErrorString, a_Line, Begin, "number"); + return false; + } + a_ValueTwo = std::stoi(a_Text.substr(Begin, End - Begin)); + + a_Begin = End + 1; // Jump over delimiter + return true; + } + else + { + return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_ErrorString, a_Line, a_ValueOne, a_IsLastValue); + } } - LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size()); + + return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_ErrorString, a_Line, a_ValueOne, a_IsLastValue); +} + + + + + +bool cFurnaceRecipe::DoesStringContainOnlyNumbers(const AString & a_String) +{ + return std::all_of(a_String.begin(), a_String.end(), isdigit); } diff --git a/src/FurnaceRecipe.h b/src/FurnaceRecipe.h index 2f91e9bcb..e0222f2fb 100644 --- a/src/FurnaceRecipe.h +++ b/src/FurnaceRecipe.h @@ -41,6 +41,28 @@ public: private: void ClearRecipes(void); + /** PrintFs the line, position, and error into an error string */ + inline static void SetParseError(AString & a_ErrorString, unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing); + + /** Reads a number from a string given, starting at a given position and ending at a delimiter given + Updates beginning position to the delimiter found + 1, and updates the value to the one read + If it encounters a substring that is not fully numeric, it will call SetParseError() and return false; the caller should abort processing + Otherwise, the function will return true + */ + static bool ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_Value, bool a_IsLastValue = false); + + /** Reads two numbers from a string given, starting at a given position and ending at the first delimiter given, then again (with an updated position) until the second delimiter given + Updates beginning position to the second delimiter found + 1, and updates the values to the ones read + If it encounters a substring that is not fully numeric whilst reading the second value, it will call SetParseError() and return false; the caller should abort processing + If this happens whilst reading the first value, it will call ReadMandatoryNumber() with the appropriate position, as this may legitimately occur with the optional value and AString::find_first_of finding the incorrect delimiter. It will return the result of ReadMandatoryNumber() + True will be returned definitively for an optional value that is valid + */ + static bool ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue = false); + + /** Uses std::all_of to determine if a string contains only digits */ + inline static bool DoesStringContainOnlyNumbers(const AString & a_String); + + struct sFurnaceRecipeState; sFurnaceRecipeState * m_pState; }; -- cgit v1.2.3 From 537467fe25386a67ef5cb9a33b9806ac2db0c894 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 21 Jun 2014 20:35:28 +0100 Subject: Removed debugging code --- src/FurnaceRecipe.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index b4b3d34d9..ce9233bcc 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -102,7 +102,6 @@ void cFurnaceRecipe::ReloadRecipes(void) F.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth); F.BurnTime = IBurnTime; m_pState->Fuel.push_back(F); - printf("%i %i %i %i\n", IItemID, IItemCount, IItemHealth, IBurnTime); continue; } else if (isdigit(ParsingLine[0])) // Recipes start with a numeral :) -- cgit v1.2.3 From 1296c5dce71f59f1d7b2bfd1791a22daa26f2cb3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 21 Jun 2014 20:42:10 +0100 Subject: More suggestions --- src/Entities/Entity.cpp | 2 +- src/Entities/Player.cpp | 2 +- src/Entities/Player.h | 6 ++++-- src/Mobs/Monster.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index d42c49abe..9110cd83b 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -869,7 +869,7 @@ void cEntity::TickBurning(cChunk & a_Chunk) // Remember the current burning state: bool HasBeenBurning = (m_TicksLeftBurning > 0); - if (IsBiomeNoDownfall(a_Chunk.GetBiomeAt(POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width, POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width)) || GetWorld()->IsWeatherWet()) + if (GetWorld()->IsWeatherWetAt(POSX_TOINT, POSZ_TOINT)) { if (POSY_TOINT > m_World->GetHeight(POSX_TOINT, POSZ_TOINT)) { diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index c26c18690..e975abdf5 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1599,7 +1599,7 @@ bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ m_ClientHandle->SendRespawn(World->GetDimension()); } - // Remove player from old world + // Remove player from the old world m_World->RemovePlayer(this); // Queue adding player to the new world, including all the necessary adjustments to the object diff --git a/src/Entities/Player.h b/src/Entities/Player.h index b1fef1b68..c72d1eb8d 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -350,7 +350,7 @@ public: void SendExperience(void); - /** In UI windows, the item that the player is dragging */ + /** In UI windows, get the item that the player is dragging */ cItem & GetDraggingItem(void) {return m_DraggingItem; } // In UI windows, when inventory-painting: @@ -398,7 +398,9 @@ public: /** If true the player can fly even when he's not in creative. */ void SetCanFly(bool a_CanFly); - /** Gets the last position that the player slept in */ + /** Gets the last position that the player slept in + This is initialised to the world spawn point if the player has not slept in a bed as of yet + */ Vector3i GetLastBedPos(void) const { return m_LastBedPos; } /** Sets the player's bed (home) position */ diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 0f030da2d..89329dace 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -1034,7 +1034,7 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk) (a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand (GetWorld()->GetTimeOfDay() < (12000 + 1000)) && // It is nighttime !IsOnFire() && // Not already burning - (IsBiomeNoDownfall(a_Chunk.GetBiomeAt(RelX, RelZ)) || !GetWorld()->IsWeatherWet()) // Not raining + GetWorld()->IsWeatherWetAt(POSX_TOINT, POSZ_TOINT) // Not raining ) { // Burn for 100 ticks, then decide again -- cgit v1.2.3 From 08fed2a213f40e963ef871664439d744faefffba Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 21 Jun 2014 22:13:35 +0200 Subject: Added cClientHandle::IsUUIDOnline function. Ref.: #771 --- src/ClientHandle.cpp | 29 +++++++++++++++++++++++++++++ src/ClientHandle.h | 11 +++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index ade7e20ac..46083a8f1 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -232,6 +232,9 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage AString cClientHandle::GenerateOfflineUUID(const AString & a_Username) { + // Online UUIDs are always version 4 (random) + // We use Version 3 (MD5 hash) UUIDs for the offline UUIDs + // This guarantees that they will never collide with an online UUID and can be distinguished. // Proper format for a version 3 UUID is: // xxxxxxxx-xxxx-3xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B @@ -254,6 +257,32 @@ AString cClientHandle::GenerateOfflineUUID(const AString & a_Username) +bool cClientHandle::IsUUIDOnline(const AString & a_UUID) +{ + // Online UUIDs are always version 4 (random) + // We use Version 3 (MD5 hash) UUIDs for the offline UUIDs + // This guarantees that they will never collide with an online UUID and can be distinguished. + // The version-specifying char is at pos #12 of raw UUID, pos #14 in dashed-UUID. + switch (a_UUID.size()) + { + case 32: + { + // This is the UUID format without dashes, the version char is at pos #12: + return (a_UUID[12] == '4'); + } + case 36: + { + // This is the UUID format with dashes, the version char is at pos #14: + return (a_UUID[14] == '4'); + } + } + return false; +} + + + + + void cClientHandle::Kick(const AString & a_Reason) { if (m_State >= csAuthenticating) // Don't log pings diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 0d883f3af..3e18cbdad 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -63,7 +63,7 @@ public: const AString & GetIPString(void) const { return m_IPString; } - cPlayer* GetPlayer() { return m_Player; } // tolua_export + cPlayer * GetPlayer(void) { return m_Player; } // tolua_export const AString & GetUUID(void) const { return m_UUID; } // tolua_export void SetUUID(const AString & a_UUID) { m_UUID = a_UUID; } @@ -76,9 +76,16 @@ public: /** Generates an UUID based on the player name provided. This is used for the offline (non-auth) mode, when there's no UUID source. - Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. */ + Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. + Returns a 36-char UUID (with dashes). */ static AString GenerateOfflineUUID(const AString & a_Username); // tolua_export + /** Returns true if the UUID is generated by online auth, false if it is an offline-generated UUID. + We use Version-3 UUIDs for offline UUIDs, online UUIDs are Version-4, thus we can tell them apart. + Accepts both 32-char and 36-char UUIDs (with and without dashes). + If the string given is not a valid UUID, returns false. */ + static bool IsUUIDOnline(const AString & a_UUID); // tolua_export + /** Formats the type of message with the proper color and prefix for sending to the client. **/ static AString FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData); -- cgit v1.2.3 From 6e681269d9dfb33b5b73f4f01a61def247b3aee7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 21 Jun 2014 22:07:38 +0100 Subject: Fixed invalid iterators --- src/Chunk.cpp | 33 ++++++++++----------------------- src/Chunk.h | 1 - src/Entities/Entity.cpp | 3 ++- src/Entities/Entity.h | 10 +++++++++- src/Entities/Player.cpp | 1 + src/World.cpp | 14 ++++---------- src/World.h | 3 --- 7 files changed, 26 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 8255fdcaf..727eb451d 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -71,7 +71,6 @@ cChunk::cChunk( m_IsDirty(false), m_IsSaving(false), m_HasLoadFailed(false), - m_EntityTickIteratorData(std::make_pair(false, m_Entities.end())), m_StayCount(0), m_PosX(a_ChunkX), m_PosY(a_ChunkY), @@ -577,44 +576,39 @@ void cChunk::Tick(float a_Dt) } // Tick all entities in this chunk (except mobs): - m_EntityTickIteratorData.first = true; - for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) + for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) { // Mobs are ticked inside cWorld::TickMobs() (as we don't have to tick them if they are far away from players) // Don't tick things queued to be removed if (!((*itr)->IsMob())) { - m_EntityTickIteratorData.second = itr; (*itr)->Tick(a_Dt, *this); - - if (itr != m_EntityTickIteratorData.second) - { - itr = m_EntityTickIteratorData.second; - } - else - { - ++itr; - } continue; } - ++itr; } // for itr - m_Entitites[] - m_EntityTickIteratorData.first = false; for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) { if ((*itr)->IsDestroyed()) // Remove all entities that were scheduled for removal: { LOGD("Destroying entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass()); + MarkDirty(); cEntity * ToDelete = *itr; itr = m_Entities.erase(itr); delete ToDelete; } + else if ((*itr)->IsTravellingThroughPortal()) + { + MarkDirty(); + (*itr)->SetIsTravellingThroughPortal(false); + itr = m_Entities.erase(itr); + } else if ( // If any entity moved out of the chunk, move it to the neighbor: ((*itr)->GetChunkX() != m_PosX) || ((*itr)->GetChunkZ() != m_PosZ) ) { + MarkDirty(); MoveEntityToNewChunk(*itr); itr = m_Entities.erase(itr); } @@ -1874,14 +1868,7 @@ void cChunk::AddEntity(cEntity * a_Entity) void cChunk::RemoveEntity(cEntity * a_Entity) { - if (m_EntityTickIteratorData.first) - { - m_EntityTickIteratorData.second = m_Entities.erase(m_EntityTickIteratorData.second); - } - else - { - m_Entities.remove(a_Entity); - } + m_Entities.remove(a_Entity); // Mark as dirty if it was a server-generated entity: if (!a_Entity->IsPlayer()) diff --git a/src/Chunk.h b/src/Chunk.h index 1619df333..dfdabea04 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -425,7 +425,6 @@ private: // A critical section is not needed, because all chunk access is protected by its parent ChunkMap's csLayers cClientHandleList m_LoadedByClient; cEntityList m_Entities; - std::pair m_EntityTickIteratorData; cBlockEntityList m_BlockEntities; /** Number of times the chunk has been requested to stay (by various cChunkStay objects); if zero, the chunk can be unloaded */ diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 9110cd83b..9a8c6586d 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -57,6 +57,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_Width(a_Width) , m_Height(a_Height) , m_InvulnerableTicks(0) + , m_IsTravellingThroughPortal(false) { cCSLock Lock(m_CSCount); m_EntityCount++; @@ -1183,7 +1184,7 @@ bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ } // Remove all links to the old world - GetWorld()->RemoveEntity(this); + SetIsTravellingThroughPortal(true); // cChunk handles entity removal GetWorld()->BroadcastDestroyEntity(*this); // Queue add to new world diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 8975803a2..0293968ab 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -374,6 +374,12 @@ public: virtual bool MoveToWorld(const AString & a_WorldName, cWorld * a_World = NULL, bool a_ShouldSendRespawn = true); // tolua_end + + /** Returns if the entity is travelling through a portal. Set to true by MoveToWorld and to false when the entity is removed by the old chunk */ + bool IsTravellingThroughPortal(void) const { return m_IsTravellingThroughPortal; } + + /** Sets if the entity has begun travelling through a portal or not */ + void SetIsTravellingThroughPortal(bool a_Flag) { m_IsTravellingThroughPortal = a_Flag; } /// Updates clients of changes in the entity. virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = NULL); @@ -470,6 +476,9 @@ protected: /** True when entity is initialised (Initialize()) and false when destroyed pending deletion (Destroy()) */ bool m_IsInitialized; + /** True when entity is being moved across worlds, false anytime else */ + bool m_IsTravellingThroughPortal; + eEntityType m_EntityType; cWorld * m_World; @@ -492,7 +501,6 @@ protected: /// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void. int m_TicksSinceLastVoidDamage; - virtual void Destroyed(void) {} // Called after the entity has been destroyed /** Called in each tick to handle air-related processing i.e. drowning */ diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index e975abdf5..b72f14f57 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1600,6 +1600,7 @@ bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ } // Remove player from the old world + SetIsTravellingThroughPortal(true); // cChunk handles entity removal m_World->RemovePlayer(this); // Queue adding player to the new world, including all the necessary adjustments to the object diff --git a/src/World.cpp b/src/World.cpp index 3ed2f5f13..c9199b6ba 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2417,7 +2417,10 @@ void cWorld::AddPlayer(cPlayer * a_Player) void cWorld::RemovePlayer(cPlayer * a_Player) { - m_ChunkMap->RemoveEntity(a_Player); + if (!a_Player->IsTravellingThroughPortal()) + { + m_ChunkMap->RemoveEntity(a_Player); + } { cCSLock Lock(m_CSPlayersToAdd); m_PlayersToAdd.remove(a_Player); @@ -2919,15 +2922,6 @@ bool cWorld::HasEntity(int a_UniqueID) -void cWorld::RemoveEntity(cEntity * a_Entity) -{ - m_ChunkMap->RemoveEntity(a_Entity); -} - - - - - /* unsigned int cWorld::GetNumPlayers(void) { diff --git a/src/World.h b/src/World.h index 0592c78fc..1d9026a5d 100644 --- a/src/World.h +++ b/src/World.h @@ -313,9 +313,6 @@ public: bool HasEntity(int a_UniqueID); - /** Removes the entity, the entity ptr ownership is assumed taken by the caller */ - void RemoveEntity(cEntity * a_Entity); - /** Calls the callback for each entity in the entire world; returns true if all entities processed, false if the callback aborted by returning true */ bool ForEachEntity(cEntityCallback & a_Callback); // Exported in ManualBindings.cpp -- cgit v1.2.3 From 4a01fba3aafef53ac8015bd5f6028fc677d6d245 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 22 Jun 2014 00:06:58 +0100 Subject: Suggestions --- src/FurnaceRecipe.cpp | 62 +++++++++++++++++++++------------------------------ src/FurnaceRecipe.h | 8 +++---- 2 files changed, 30 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index ce9233bcc..448a4bfa8 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -54,21 +54,18 @@ void cFurnaceRecipe::ReloadRecipes(void) ClearRecipes(); LOGD("Loading furnace recipes..."); - std::ifstream F(FURNACE_RECIPE_FILE, std::ios::in); - if (!F.good()) + std::ifstream f(FURNACE_RECIPE_FILE, std::ios::in); + if (!f.good()) { - F.close(); + f.close(); LOG("Could not open the furnace recipes file \"%s\"", FURNACE_RECIPE_FILE); return; } - AString SyntaxError; unsigned int Line = 0; AString ParsingLine; - ASSERT(ParsingLine.empty()); - - while (std::getline(F, ParsingLine)) + while (std::getline(f, ParsingLine)) { Line++; ParsingLine.erase(std::remove_if(ParsingLine.begin(), ParsingLine.end(), isspace), ParsingLine.end()); // Remove whitespace @@ -89,12 +86,12 @@ void cFurnaceRecipe::ReloadRecipes(void) AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang) if ( - !ReadMandatoryNumber(BeginPos, ":", ParsingLine, SyntaxError, Line, IItemID) || // Read item ID - !ReadOptionalNumbers(BeginPos, ":", "=", ParsingLine, SyntaxError, Line, IItemCount, IItemHealth) || // Read item count (and optionally health) - !ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, SyntaxError, Line, IBurnTime, true) // Read item burn time - last value + !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID + !ReadOptionalNumbers(BeginPos, ":", "=", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health) + !ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, Line, IBurnTime, true) // Read item burn time - last value ) { - break; + return; } // Add to fuel list @@ -111,14 +108,14 @@ void cFurnaceRecipe::ReloadRecipes(void) AString::size_type BeginPos = 0; // Begin at start of line if ( - !ReadMandatoryNumber(BeginPos, ":", ParsingLine, SyntaxError, Line, IItemID) || // Read item ID - !ReadOptionalNumbers(BeginPos, ":", "@", ParsingLine, SyntaxError, Line, IItemCount, IItemHealth) || // Read item count (and optionally health) - !ReadMandatoryNumber(BeginPos, "=", ParsingLine, SyntaxError, Line, IBurnTime) || // Read item burn time - !ReadMandatoryNumber(BeginPos, ":", ParsingLine, SyntaxError, Line, OItemID) || // Read result ID - !ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, SyntaxError, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value + !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID + !ReadOptionalNumbers(BeginPos, ":", "@", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health) + !ReadMandatoryNumber(BeginPos, "=", ParsingLine, Line, IBurnTime) || // Read item burn time + !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, OItemID) || // Read result ID + !ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value ) { - break; + return; } // Add to recipe list @@ -129,32 +126,25 @@ void cFurnaceRecipe::ReloadRecipes(void) m_pState->Recipes.push_back(R); } } - F.close(); + f.close(); - if (!SyntaxError.empty()) - { - LOGWARN("Error parsing furnace recipes at %s", SyntaxError.c_str()); - } - else - { - LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size()); - } + LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size()); } -void cFurnaceRecipe::SetParseError(AString & a_ErrorString, unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing) +void cFurnaceRecipe::PrintParseError(unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing) { - Printf(a_ErrorString, "line %i pos %i: missing '%s'", a_Line, a_Position, a_CharactersMissing.c_str()); + LOGWARN("Error parsing furnace recipes at line %i pos %i: missing '%s'", a_Line, a_Position, a_CharactersMissing.c_str()); } -bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_Value, bool a_IsLastValue) +bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, unsigned int a_Line, int & a_Value, bool a_IsLastValue) { AString::size_type End; if (a_IsLastValue) @@ -166,7 +156,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt End = a_Text.find_first_of(a_Delimiter, a_Begin); if (End == AString::npos) { - SetParseError(a_ErrorString, a_Line, a_Begin, a_Delimiter); + PrintParseError(a_Line, a_Begin, a_Delimiter); return false; } } @@ -174,7 +164,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt // stoi won't throw an exception if the string is alphanumeric, we should check for this if (!DoesStringContainOnlyNumbers(a_Text.substr(a_Begin, End - a_Begin))) { - SetParseError(a_ErrorString, a_Line, a_Begin, "number"); + PrintParseError(a_Line, a_Begin, "number"); return false; } a_Value = std::stoi(a_Text.substr(a_Begin, End - a_Begin)); @@ -187,7 +177,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt -bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue) +bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue) { unsigned int End, Begin = a_Begin; @@ -208,7 +198,7 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt End = a_Text.find_first_of(a_DelimiterTwo, Begin); if (End == AString::npos) { - SetParseError(a_ErrorString, a_Line, Begin, a_DelimiterTwo); + PrintParseError(a_Line, Begin, a_DelimiterTwo); return false; } } @@ -216,7 +206,7 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt // stoi won't throw an exception if the string is alphanumeric, we should check for this if (!DoesStringContainOnlyNumbers(a_Text.substr(Begin, End - Begin))) { - SetParseError(a_ErrorString, a_Line, Begin, "number"); + PrintParseError(a_Line, Begin, "number"); return false; } a_ValueTwo = std::stoi(a_Text.substr(Begin, End - Begin)); @@ -226,11 +216,11 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt } else { - return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_ErrorString, a_Line, a_ValueOne, a_IsLastValue); + return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_Line, a_ValueOne, a_IsLastValue); } } - return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_ErrorString, a_Line, a_ValueOne, a_IsLastValue); + return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_Line, a_ValueOne, a_IsLastValue); } diff --git a/src/FurnaceRecipe.h b/src/FurnaceRecipe.h index e0222f2fb..cddcc215f 100644 --- a/src/FurnaceRecipe.h +++ b/src/FurnaceRecipe.h @@ -41,15 +41,15 @@ public: private: void ClearRecipes(void); - /** PrintFs the line, position, and error into an error string */ - inline static void SetParseError(AString & a_ErrorString, unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing); + /** Calls LOGWARN with the line, position, and error */ + inline static void PrintParseError(unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing); /** Reads a number from a string given, starting at a given position and ending at a delimiter given Updates beginning position to the delimiter found + 1, and updates the value to the one read If it encounters a substring that is not fully numeric, it will call SetParseError() and return false; the caller should abort processing Otherwise, the function will return true */ - static bool ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_Value, bool a_IsLastValue = false); + static bool ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, unsigned int a_Line, int & a_Value, bool a_IsLastValue = false); /** Reads two numbers from a string given, starting at a given position and ending at the first delimiter given, then again (with an updated position) until the second delimiter given Updates beginning position to the second delimiter found + 1, and updates the values to the ones read @@ -57,7 +57,7 @@ private: If this happens whilst reading the first value, it will call ReadMandatoryNumber() with the appropriate position, as this may legitimately occur with the optional value and AString::find_first_of finding the incorrect delimiter. It will return the result of ReadMandatoryNumber() True will be returned definitively for an optional value that is valid */ - static bool ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue = false); + static bool ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue = false); /** Uses std::all_of to determine if a string contains only digits */ inline static bool DoesStringContainOnlyNumbers(const AString & a_String); -- cgit v1.2.3 From e709652257da1ba06a6642b4978365b14bc11a22 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 22 Jun 2014 00:21:39 +0100 Subject: Conforms to standards --- src/Entities/Entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index fadd12135..d4edc9144 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -37,6 +37,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_Gravity(-9.81f) , m_LastPos(a_X, a_Y, a_Z) , m_IsInitialized(false) + , m_IsTravellingThroughPortal(false) , m_EntityType(a_EntityType) , m_World(NULL) , m_IsFireproof(false) @@ -57,7 +58,6 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_Width(a_Width) , m_Height(a_Height) , m_InvulnerableTicks(0) - , m_IsTravellingThroughPortal(false) { cCSLock Lock(m_CSCount); m_EntityCount++; -- cgit v1.2.3 From 63ce2e8b37444f96d7892d555cb296947b3afbe5 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 22 Jun 2014 12:30:37 +0100 Subject: Fixed compile errors --- src/FurnaceRecipe.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index 448a4bfa8..8040552cc 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -137,7 +137,7 @@ void cFurnaceRecipe::ReloadRecipes(void) void cFurnaceRecipe::PrintParseError(unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing) { - LOGWARN("Error parsing furnace recipes at line %i pos %i: missing '%s'", a_Line, a_Position, a_CharactersMissing.c_str()); + LOGWARN("Error parsing furnace recipes at line %i pos " SIZE_T_FMT ": missing '%s'", a_Line, a_Position, a_CharactersMissing.c_str()); } @@ -179,7 +179,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue) { - unsigned int End, Begin = a_Begin; + AString::size_type End, Begin = a_Begin; End = a_Text.find_first_of(a_DelimiterOne, Begin); if (End != AString::npos) -- cgit v1.2.3 From 119ba562d50442ad78fc2dd573819759faadad44 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 22 Jun 2014 14:15:41 +0100 Subject: Fixed invalid iterator Fixes CID 60408 --- src/Simulator/IncrementalRedstoneSimulator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 183c527ca..ad4d1bee6 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -758,7 +758,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() { - for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end(); itr++) + for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end();) { if (itr->a_ElapsedTicks >= itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks? @@ -804,7 +804,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() { m_Chunk->SetBlock(RelBlockX, RelBlockY, RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, Meta); } - m_RepeatersDelayList->erase(itr); + itr = m_RepeatersDelayList->erase(itr); } else { @@ -813,6 +813,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() // I am confounded to say why. Perhaps optimisation failure. LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", itr->a_RelBlockPos.x, itr->a_RelBlockPos.y, itr->a_RelBlockPos.z, itr->a_ElapsedTicks, itr->a_DelayTicks); itr->a_ElapsedTicks++; + itr++; } } } -- cgit v1.2.3 From 3c0452ebef2c37f030ce252229555fa95a89ed0d Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 22 Jun 2014 14:17:07 +0100 Subject: Fixed missing break Fixes CID 68409 --- src/Simulator/IncrementalRedstoneSimulator.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index ad4d1bee6..9d0657dd6 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -343,6 +343,7 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int case E_BLOCK_REDSTONE_REPEATER_ON: { HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + break; } case E_BLOCK_REDSTONE_TORCH_OFF: case E_BLOCK_REDSTONE_TORCH_ON: -- cgit v1.2.3 From b2bf4661222f9dd8c234716ac2b81ccf6a09217c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 22 Jun 2014 14:47:05 +0100 Subject: Chests don't open if obstructed * Fixes FS383 --- src/BlockEntities/ChestEntity.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index dfbe6ae87..cb9cc89bf 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -122,6 +122,13 @@ void cChestEntity::UsedBy(cPlayer * a_Player) void cChestEntity::OpenNewWindow(void) { + // TODO: cats are an obstruction + if ((GetPosY() + 1 < cChunkDef::Height) && cBlockInfo::IsSolid(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ()))) + { + // Obstruction, don't open + return; + } + // Callback for opening together with neighbor chest: class cOpenDouble : public cChestCallback @@ -135,6 +142,12 @@ void cChestEntity::OpenNewWindow(void) virtual bool Item(cChestEntity * a_Chest) override { + if ((a_Chest->GetPosY() + 1 < cChunkDef::Height) && cBlockInfo::IsSolid(a_Chest->GetWorld()->GetBlock(a_Chest->GetPosX(), a_Chest->GetPosY() + 1, a_Chest->GetPosZ()))) + { + // Obstruction, don't open + return false; + } + // The primary chest should eb the one with lesser X or Z coord: cChestEntity * Primary = a_Chest; cChestEntity * Secondary = m_ThisChest; -- cgit v1.2.3 From 3ec8b33b7660e1ab503ac9369b7d909957c9690a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 22 Jun 2014 15:04:23 +0100 Subject: Fixed another daylight sensor bug Additionally fixed unpowering across chunks. --- src/Simulator/IncrementalRedstoneSimulator.cpp | 43 ++++++++++++++------------ 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 183c527ca..a54867171 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -59,21 +59,20 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, int RelZ = 0; BLOCKTYPE Block; NIBBLETYPE Meta; - cChunk * Chunk; + cChunk * OtherChunk = a_Chunk; if (a_OtherChunk != NULL) { RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width; RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width; a_OtherChunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta); - Chunk = a_OtherChunk; + OtherChunk = a_OtherChunk; } else { RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width; RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width; a_Chunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta); - Chunk = a_Chunk; } // Every time a block is changed (AddBlock called), we want to go through all lists and check to see if the coordiantes stored within are still valid @@ -92,7 +91,8 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list as it no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = PoweredBlocks->erase(itr); - Chunk->SetIsRedstoneDirty(true); + a_Chunk->SetIsRedstoneDirty(true); + OtherChunk->SetIsRedstoneDirty(true); continue; } else if ( @@ -107,21 +107,23 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = PoweredBlocks->erase(itr); - Chunk->SetIsRedstoneDirty(true); + a_Chunk->SetIsRedstoneDirty(true); + OtherChunk->SetIsRedstoneDirty(true); continue; } else if (Block == E_BLOCK_DAYLIGHT_SENSOR) { - if (!m_World.IsChunkLighted(Chunk->GetPosX(), Chunk->GetPosZ())) + if (!m_World.IsChunkLighted(OtherChunk->GetPosX(), OtherChunk->GetPosZ())) { - m_World.QueueLightChunk(Chunk->GetPosX(), Chunk->GetPosZ()); + m_World.QueueLightChunk(OtherChunk->GetPosX(), OtherChunk->GetPosZ()); } else { - if (Chunk->GetTimeAlteredLight(Chunk->GetSkyLight(RelX, a_BlockY + 1, RelZ)) <= 7) + if (OtherChunk->GetTimeAlteredLight(OtherChunk->GetSkyLight(RelX, a_BlockY + 1, RelZ)) <= 7) { itr = PoweredBlocks->erase(itr); - Chunk->SetIsRedstoneDirty(true); + a_Chunk->SetIsRedstoneDirty(true); + OtherChunk->SetIsRedstoneDirty(true); continue; } } @@ -139,7 +141,8 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); - Chunk->SetIsRedstoneDirty(true); + a_Chunk->SetIsRedstoneDirty(true); + OtherChunk->SetIsRedstoneDirty(true); continue; } else if ( @@ -153,7 +156,8 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); - Chunk->SetIsRedstoneDirty(true); + a_Chunk->SetIsRedstoneDirty(true); + OtherChunk->SetIsRedstoneDirty(true); continue; } } @@ -163,7 +167,8 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer powered through a valid middle block", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); - Chunk->SetIsRedstoneDirty(true); + a_Chunk->SetIsRedstoneDirty(true); + OtherChunk->SetIsRedstoneDirty(true); continue; } } @@ -1072,19 +1077,17 @@ void cIncrementalRedstoneSimulator::HandleNoteBlock(int a_RelBlockX, int a_RelBl void cIncrementalRedstoneSimulator::HandleDaylightSensor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - int a_ChunkX, a_ChunkZ; - cChunkDef::BlockToChunk(a_RelBlockX, a_RelBlockZ, a_ChunkX, a_ChunkZ); + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX, BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + int ChunkX, ChunkZ; + cChunkDef::BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ); - if (!m_World.IsChunkLighted(a_ChunkX, a_ChunkZ)) + if (!m_World.IsChunkLighted(ChunkX, ChunkZ)) { - m_World.QueueLightChunk(a_ChunkX, a_ChunkZ); + m_World.QueueLightChunk(ChunkX, ChunkZ); } else { - int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; - int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; - NIBBLETYPE SkyLight = m_Chunk->GetTimeAlteredLight(m_World.GetBlockSkyLight(BlockX, a_RelBlockY + 1, BlockZ)); - if (SkyLight > 8) + if (m_Chunk->GetTimeAlteredLight(m_World.GetBlockSkyLight(BlockX, a_RelBlockY + 1, BlockZ)) > 8) { SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); } -- cgit v1.2.3 From bebfb230daf5c4e185791b6fc60f48e6f3dcfdf7 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 22 Jun 2014 17:29:02 +0200 Subject: Changed 0xFFFFFFFB to ~0x04 --- src/Simulator/IncrementalRedstoneSimulator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index d65d4eb45..6056fa554 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -566,7 +566,7 @@ void cIncrementalRedstoneSimulator::HandleFenceGate(int a_RelBlockX, int a_RelBl { if ((MetaData & 0x4) != 0) { - m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MetaData & 0xFFFFFFFB); + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MetaData & ~0x04); m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); } SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false); -- cgit v1.2.3 From 33cc1f2a50d870b7d264ee5479068f8eee3aa458 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 22 Jun 2014 20:44:01 +0100 Subject: Fixed multiple issues with projectiles * Fixed arrows not being collectable/not truly hitting a block/not lodging into blocks/not going in far enough * Fixed projectiles not playing their block hit animation owning to being destroyed too quickly --- src/Entities/ArrowEntity.cpp | 33 +++++------------- src/Entities/ProjectileEntity.cpp | 61 ++++++++++++++++++--------------- src/Entities/ThrownEggEntity.cpp | 7 ++-- src/Entities/ThrownEggEntity.h | 18 ++++++++++ src/Entities/ThrownEnderPearlEntity.cpp | 9 ++--- src/Entities/ThrownEnderPearlEntity.h | 22 ++++++++++-- src/Entities/ThrownSnowballEntity.cpp | 7 ++-- src/Entities/ThrownSnowballEntity.h | 18 ++++++++++ 8 files changed, 112 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 8d2569125..db9dc781a 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -68,25 +68,16 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { - if (a_HitFace == BLOCK_FACE_NONE) { return; } - - super::OnHitSolidBlock(a_HitPos, a_HitFace); - int a_X = (int)a_HitPos.x, a_Y = (int)a_HitPos.y, a_Z = (int)a_HitPos.z; - - switch (a_HitFace) - { - case BLOCK_FACE_XM: // Strangely, bounding boxes / block tracers return the actual block for these two directions, so AddFace not needed - case BLOCK_FACE_YM: - { - break; - } - default: AddFaceDirection(a_X, a_Y, a_Z, a_HitFace, true); - } + Vector3d Hit = a_HitPos; + Hit += GetSpeed() / 700; // Make arrow sink into block a little + + super::OnHitSolidBlock(Hit, a_HitFace); + int X = (int)floor(Hit.x), Y = (int)floor(Hit.y), Z = (int)floor(Hit.z); - m_HitBlockPos = Vector3i(a_X, a_Y, a_Z); + m_HitBlockPos = Vector3i(X, Y, Z); // Broadcast arrow hit sound - m_World->BroadcastSoundEffect("random.bowhit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + m_World->BroadcastSoundEffect("random.bowhit", X * 8, Y * 8, Z * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); } @@ -94,13 +85,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) -{ - if (!a_EntityHit.IsMob() && !a_EntityHit.IsMinecart() && !a_EntityHit.IsPlayer() && !a_EntityHit.IsBoat()) - { - // Not an entity that interacts with an arrow - return; - } - +{ int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5); if (m_IsCritical) { @@ -165,7 +150,7 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk) if (!m_HasTeleported) // Sent a teleport already, don't do again { - if (m_HitGroundTimer > 1000.f) // Send after a second, could be less, but just in case + if (m_HitGroundTimer > 500.f) // Send after half a second, could be less, but just in case { m_World->BroadcastTeleportEntity(*this); m_HasTeleported = true; diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 95c494569..d45f1d212 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -67,16 +67,17 @@ protected: if (cBlockInfo::IsSolid(a_BlockType)) { - // The projectile hit a solid block - // Calculate the exact hit coords: - cBoundingBox bb(a_BlockX, a_BlockX + 1, a_BlockY, a_BlockY + 1, a_BlockZ, a_BlockZ + 1); - Vector3d Line1 = m_Projectile->GetPosition(); - Vector3d Line2 = Line1 + m_Projectile->GetSpeed(); - double LineCoeff = 0; - eBlockFace Face; - if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face)) + // The projectile hit a solid block, calculate the exact hit coords: + cBoundingBox bb(a_BlockX, a_BlockX + 1, a_BlockY, a_BlockY + 1, a_BlockZ, a_BlockZ + 1); // Bounding box of the block hit + const Vector3d LineStart = m_Projectile->GetPosition(); // Start point for the imaginary line that goes through the block hit + const Vector3d LineEnd = LineStart + m_Projectile->GetSpeed(); // End point for the imaginary line that goes through the block hit + double LineCoeff = 0; // Used to calculate where along the line an intersection with the bounding box occurs + eBlockFace Face; // Face hit + + if (bb.CalcLineIntersection(LineStart, LineEnd, LineCoeff, Face)) { - Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff; + Vector3d Intersection = LineStart + m_Projectile->GetSpeed() * LineCoeff; // Point where projectile goes into the hit block + if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, a_BlockX, a_BlockY, a_BlockZ, Face, &Intersection)) { return false; @@ -161,7 +162,12 @@ public: return false; } - // TODO: Some entities don't interact with the projectiles (pickups, falling blocks) + if (!a_Entity->IsMob() && !a_Entity->IsMinecart() && !a_Entity->IsPlayer() && !a_Entity->IsBoat()) + { + // Not an entity that interacts with a projectile + return false; + } + if (cPluginManager::Get()->CallHookProjectileHitEntity(*m_Projectile, *a_Entity)) { // A plugin disagreed. @@ -316,8 +322,9 @@ AString cProjectileEntity::GetMCAClassName(void) const void cProjectileEntity::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - - if (GetProjectileKind() != pkArrow) // See cArrow::Tick + + // TODO: see BroadcastMovementUpdate; RelativeMove packet jerkiness affects projectiles too (cause of sympton described in cArrowEntity::Tick()) + if (GetProjectileKind() != pkArrow) { BroadcastMovementUpdate(); } @@ -335,19 +342,10 @@ void cProjectileEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) return; } - Vector3d PerTickSpeed = GetSpeed() / 20; - Vector3d Pos = GetPosition(); - - // Trace the tick's worth of movement as a line: - Vector3d NextPos = Pos + PerTickSpeed; - cProjectileTracerCallback TracerCallback(this); - if (!cLineBlockTracer::Trace(*m_World, TracerCallback, Pos, NextPos)) - { - // Something has been hit, abort all other processing - return; - } - // The tracer also checks the blocks for slowdown blocks - water and lava - and stores it for later in its SlowdownCoeff - + const Vector3d PerTickSpeed = GetSpeed() / 20; + const Vector3d Pos = GetPosition(); + const Vector3d NextPos = Pos + PerTickSpeed; + // Test for entity collisions: cProjectileEntityCollisionCallback EntityCollisionCallback(this, Pos, NextPos); a_Chunk.ForEachEntity(EntityCollisionCallback); @@ -363,11 +361,20 @@ void cProjectileEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) EntityCollisionCallback.GetHitEntity()->GetClass(), HitPos.x, HitPos.y, HitPos.z, EntityCollisionCallback.GetMinCoeff() - ); - + ); + OnHitEntity(*(EntityCollisionCallback.GetHitEntity()), HitPos); } // TODO: Test the entities in the neighboring chunks, too + + // Trace the tick's worth of movement as a line: + cProjectileTracerCallback TracerCallback(this); + if (!cLineBlockTracer::Trace(*m_World, TracerCallback, Pos, NextPos)) + { + // Something has been hit, abort all other processing + return; + } + // The tracer also checks the blocks for slowdown blocks - water and lava - and stores it for later in its SlowdownCoeff // Update the position: SetPosition(NextPos); diff --git a/src/Entities/ThrownEggEntity.cpp b/src/Entities/ThrownEggEntity.cpp index 224019091..d7eed41e3 100644 --- a/src/Entities/ThrownEggEntity.cpp +++ b/src/Entities/ThrownEggEntity.cpp @@ -8,7 +8,8 @@ cThrownEggEntity::cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkEgg, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) + super(pkEgg, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), + m_DestroyTimer(-1) { SetSpeed(a_Speed); } @@ -21,7 +22,7 @@ void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_H { TrySpawnChicken(a_HitPos); - Destroy(); + m_DestroyTimer = 5; } @@ -36,7 +37,7 @@ void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hit TrySpawnChicken(a_HitPos); a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); - Destroy(true); + m_DestroyTimer = 5; } diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h index 5ba8f051b..894665428 100644 --- a/src/Entities/ThrownEggEntity.h +++ b/src/Entities/ThrownEggEntity.h @@ -30,8 +30,26 @@ protected: // cProjectileEntity overrides: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; + virtual void Tick (float a_Dt, cChunk & a_Chunk) override + { + if (m_DestroyTimer > 0) + { + m_DestroyTimer--; + if (m_DestroyTimer == 0) + { + Destroy(); + return; + } + } + else { super::Tick(a_Dt, a_Chunk); } + } // Randomly decides whether to spawn a chicken where the egg lands. void TrySpawnChicken(const Vector3d & a_HitPos); + +private: + + /** Time in ticks to wait for the hit animation to begin before destroying */ + int m_DestroyTimer; } ; // tolua_export diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp index c37161145..a3ee23389 100644 --- a/src/Entities/ThrownEnderPearlEntity.cpp +++ b/src/Entities/ThrownEnderPearlEntity.cpp @@ -7,7 +7,8 @@ cThrownEnderPearlEntity::cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkEnderPearl, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) + super(pkEnderPearl, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), + m_DestroyTimer(-1) { SetSpeed(a_Speed); } @@ -21,7 +22,7 @@ void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockF // TODO: Tweak a_HitPos based on block face. TeleportCreator(a_HitPos); - Destroy(); + m_DestroyTimer = 5; } @@ -36,7 +37,7 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d TeleportCreator(a_HitPos); a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); - Destroy(true); + m_DestroyTimer = 5; } @@ -48,7 +49,7 @@ void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos) // Teleport the creator here, make them take 5 damage: if (m_Creator != NULL) { - m_Creator->TeleportToCoords(a_HitPos.x + 0.5, a_HitPos.y + 1.7, a_HitPos.z + 0.5); + m_Creator->TeleportToCoords(a_HitPos.x, a_HitPos.y + 0.2, a_HitPos.z); m_Creator->TakeDamage(dtEnderPearl, this, 5, 0); } } diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h index ddee5babe..bfd9bd70d 100644 --- a/src/Entities/ThrownEnderPearlEntity.h +++ b/src/Entities/ThrownEnderPearlEntity.h @@ -30,8 +30,26 @@ protected: // cProjectileEntity overrides: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; - - // Teleports the creator where the ender pearl lands. + virtual void Tick (float a_Dt, cChunk & a_Chunk) override + { + if (m_DestroyTimer > 0) + { + m_DestroyTimer--; + if (m_DestroyTimer == 0) + { + Destroy(); + return; + } + } + else { super::Tick(a_Dt, a_Chunk); } + } + + /** Teleports the creator where the ender pearl lands */ void TeleportCreator(const Vector3d & a_HitPos); + +private: + + /** Time in ticks to wait for the hit animation to begin before destroying */ + int m_DestroyTimer; } ; // tolua_export diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp index cefc3433c..b82cd56db 100644 --- a/src/Entities/ThrownSnowballEntity.cpp +++ b/src/Entities/ThrownSnowballEntity.cpp @@ -8,7 +8,8 @@ cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkSnowball, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) + super(pkSnowball, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), + m_DestroyTimer(-1) { SetSpeed(a_Speed); } @@ -19,7 +20,7 @@ cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, do void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { - Destroy(); + m_DestroyTimer = 5; } @@ -40,5 +41,5 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & // TODO: If entity is Ender Crystal, destroy it a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); - Destroy(true); + m_DestroyTimer = 5; } diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h index a09512e37..e30971f0a 100644 --- a/src/Entities/ThrownSnowballEntity.h +++ b/src/Entities/ThrownSnowballEntity.h @@ -30,5 +30,23 @@ protected: // cProjectileEntity overrides: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; + virtual void Tick (float a_Dt, cChunk & a_Chunk) override + { + if (m_DestroyTimer > 0) + { + m_DestroyTimer--; + if (m_DestroyTimer == 0) + { + Destroy(); + return; + } + } + else { super::Tick(a_Dt, a_Chunk); } + } + +private: + + /** Time in ticks to wait for the hit animation to begin before destroying */ + int m_DestroyTimer; } ; // tolua_export -- cgit v1.2.3 From 4238b0ebe8d910186d4e160222f337b6e8b33cc8 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 22 Jun 2014 20:44:18 +0100 Subject: Some Entity.cpp style improvements --- src/Entities/Entity.cpp | 17 ++++++----------- src/Entities/Entity.h | 4 ++-- 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index ee7ce06ac..f4e89367b 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -255,8 +255,7 @@ void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_R void cEntity::SetYawFromSpeed(void) { - const double EPS = 0.0000001; - if ((abs(m_Speed.x) < EPS) && (abs(m_Speed.z) < EPS)) + if ((abs(m_Speed.x) < std::numeric_limits::epsilon()) && (abs(m_Speed.z) < std::numeric_limits::epsilon())) { // atan2() may overflow or is undefined, pick any number SetYaw(0); @@ -1236,7 +1235,7 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude) if (GetWorld()->GetWorldAge() % 2 == 0) { double SpeedSqr = GetSpeed().SqrLength(); - if (SpeedSqr == 0.0) + if (SpeedSqr < std::numeric_limits::epsilon()) { // Speed is zero, send this to clients once only as well as an absolute position if (!m_bHasSentNoSpeed) @@ -1476,8 +1475,7 @@ void cEntity::SetWidth(double a_Width) void cEntity::AddPosX(double a_AddPosX) { - m_Pos.x += a_AddPosX; - + m_Pos.x += a_AddPosX; } @@ -1485,8 +1483,7 @@ void cEntity::AddPosX(double a_AddPosX) void cEntity::AddPosY(double a_AddPosY) { - m_Pos.y += a_AddPosY; - + m_Pos.y += a_AddPosY; } @@ -1494,8 +1491,7 @@ void cEntity::AddPosY(double a_AddPosY) void cEntity::AddPosZ(double a_AddPosZ) { - m_Pos.z += a_AddPosZ; - + m_Pos.z += a_AddPosZ; } @@ -1505,8 +1501,7 @@ void cEntity::AddPosition(double a_AddPosX, double a_AddPosY, double a_AddPosZ) { m_Pos.x += a_AddPosX; m_Pos.y += a_AddPosY; - m_Pos.z += a_AddPosZ; - + m_Pos.z += a_AddPosZ; } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 2df66e353..f4080f8aa 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -237,9 +237,9 @@ public: void AddPosY (double a_AddPosY); void AddPosZ (double a_AddPosZ); void AddPosition(double a_AddPosX, double a_AddPosY, double a_AddPosZ); - void AddPosition(const Vector3d & a_AddPos) { AddPosition(a_AddPos.x,a_AddPos.y,a_AddPos.z);} + void AddPosition(const Vector3d & a_AddPos) { AddPosition(a_AddPos.x, a_AddPos.y, a_AddPos.z); } void AddSpeed (double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeedZ); - void AddSpeed (const Vector3d & a_AddSpeed) { AddSpeed(a_AddSpeed.x,a_AddSpeed.y,a_AddSpeed.z);} + void AddSpeed (const Vector3d & a_AddSpeed) { AddSpeed(a_AddSpeed.x, a_AddSpeed.y, a_AddSpeed.z); } void AddSpeedX (double a_AddSpeedX); void AddSpeedY (double a_AddSpeedY); void AddSpeedZ (double a_AddSpeedZ); -- cgit v1.2.3 From dad0037f987df594d6a1971af5b29f89c2d27901 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 22 Jun 2014 20:44:55 +0100 Subject: Bettered zombie and skeleton AI * Fixed potential issues with skylight detection --- src/Mobs/Skeleton.cpp | 5 ++--- src/Mobs/Zombie.cpp | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index e3357185d..0641a3d57 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -49,11 +49,10 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer) void cSkeleton::MoveToPosition(const Vector3f & a_Position) { - // If the destination is in the sun and if it is not night AND the skeleton isn't on fire then block the movement. + // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement if ( !IsOnFire() && - (m_World->GetTimeOfDay() < 13187) && - (m_World->GetBlockSkyLight((int) a_Position.x, (int) a_Position.y, (int) a_Position.z) == 15) + (m_World->GetBlockSkyLight((int)floor(a_Position.x), (int)floor(a_Position.y), (int)floor(a_Position.z)) - m_World->GetSkyDarkness() > 8) ) { m_bMovingToDestination = false; diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp index f19e096ee..725790ed9 100644 --- a/src/Mobs/Zombie.cpp +++ b/src/Mobs/Zombie.cpp @@ -44,11 +44,10 @@ void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer) void cZombie::MoveToPosition(const Vector3f & a_Position) { - // If the destination is in the sun and if it is not night AND the zombie isn't on fire then block the movement. + // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement if ( !IsOnFire() && - (m_World->GetTimeOfDay() < 13187) && - (m_World->GetBlockSkyLight((int)a_Position.x, (int)a_Position.y, (int)a_Position.z) == 15) + (m_World->GetBlockSkyLight((int)floor(a_Position.x), (int)floor(a_Position.y), (int)floor(a_Position.z)) - m_World->GetSkyDarkness() > 8) ) { m_bMovingToDestination = false; -- cgit v1.2.3 From c476fc3cf5a2bbdb27b61fcad290c84029721462 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 22 Jun 2014 21:49:37 +0100 Subject: Suggestions --- src/FurnaceRecipe.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index 448a4bfa8..90b478285 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -57,7 +57,6 @@ void cFurnaceRecipe::ReloadRecipes(void) std::ifstream f(FURNACE_RECIPE_FILE, std::ios::in); if (!f.good()) { - f.close(); LOG("Could not open the furnace recipes file \"%s\"", FURNACE_RECIPE_FILE); return; } @@ -126,7 +125,6 @@ void cFurnaceRecipe::ReloadRecipes(void) m_pState->Recipes.push_back(R); } } - f.close(); LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size()); } @@ -146,6 +144,7 @@ void cFurnaceRecipe::PrintParseError(unsigned int a_Line, size_t a_Position, con bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, unsigned int a_Line, int & a_Value, bool a_IsLastValue) { + // TODO: replace atoi with std::stoi AString::size_type End; if (a_IsLastValue) { @@ -167,7 +166,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt PrintParseError(a_Line, a_Begin, "number"); return false; } - a_Value = std::stoi(a_Text.substr(a_Begin, End - a_Begin)); + a_Value = atoi(a_Text.substr(a_Begin, End - a_Begin).c_str()); a_Begin = End + 1; // Jump over delimiter return true; @@ -179,6 +178,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue) { + // TODO: replace atoi with std::stoi unsigned int End, Begin = a_Begin; End = a_Text.find_first_of(a_DelimiterOne, Begin); @@ -186,7 +186,7 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt { if (DoesStringContainOnlyNumbers(a_Text.substr(Begin, End - Begin))) { - a_ValueOne = std::stoi(a_Text.substr(Begin, End - Begin)); + a_ValueOne = std::atoi(a_Text.substr(Begin, End - Begin).c_str()); Begin = End + 1; if (a_IsLastValue) @@ -209,7 +209,7 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt PrintParseError(a_Line, Begin, "number"); return false; } - a_ValueTwo = std::stoi(a_Text.substr(Begin, End - Begin)); + a_ValueTwo = atoi(a_Text.substr(Begin, End - Begin).c_str()); a_Begin = End + 1; // Jump over delimiter return true; @@ -229,7 +229,8 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt bool cFurnaceRecipe::DoesStringContainOnlyNumbers(const AString & a_String) { - return std::all_of(a_String.begin(), a_String.end(), isdigit); + // TODO: replace this with std::all_of(a_String.begin(), a_String.end(), isdigit) + return a_String.find_first_not_of("0123456789") == AString::npos; } -- cgit v1.2.3 From 82dcc0b4db030f2a463a990652e0d75b67bdf835 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 22 Jun 2014 21:30:06 +0200 Subject: Prefabs don't draw into chunk if they don't intersect. --- src/Generating/Prefab.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 2ab1455b9..7d876909a 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -211,6 +211,17 @@ void cPrefab::Draw(cChunkDesc & a_Dest, const Vector3i & a_Placement, int a_NumR int ChunkStartZ = a_Dest.GetChunkZ() * cChunkDef::Width; Placement.Move(-ChunkStartX, 0, -ChunkStartZ); const cBlockArea & Image = m_BlockArea[a_NumRotations]; + + // If the placement is outside this chunk, bail out: + if ( + (Placement.x > cChunkDef::Width) || (Placement.x + Image.GetSizeX() < 0) || + (Placement.z > cChunkDef::Width) || (Placement.z + Image.GetSizeZ() < 0) + ) + { + return; + } + + // Write the image: a_Dest.WriteBlockArea(Image, Placement.x, Placement.y, Placement.z, m_MergeStrategy); // If requested, draw the floor (from the bottom of the prefab down to the nearest non-air) -- cgit v1.2.3 From d61ff4da3b9b6581d22e2a1d068dfb09143b0ad6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 22 Jun 2014 21:51:34 +0200 Subject: Fixed sign and lever rotations. --- src/Blocks/BlockLever.h | 11 ++++++----- src/Blocks/BlockSign.h | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h index ad2ae29e5..f1d3ff6d2 100644 --- a/src/Blocks/BlockLever.h +++ b/src/Blocks/BlockLever.h @@ -7,12 +7,13 @@ class cBlockLeverHandler : - public cMetaRotator + public cMetaRotator { - typedef cMetaRotator super; + typedef cMetaRotator super; + public: - cBlockLeverHandler(BLOCKTYPE a_BlockType) - : cMetaRotator(a_BlockType) + cBlockLeverHandler(BLOCKTYPE a_BlockType) : + super(a_BlockType) { } @@ -132,7 +133,7 @@ public: case 0x05: return 0x06; // Ground rotation case 0x06: return 0x05; - default: return super::MetaRotateCCW(a_Meta); // Wall Rotation + default: return super::MetaRotateCW(a_Meta); // Wall Rotation } } } ; diff --git a/src/Blocks/BlockSign.h b/src/Blocks/BlockSign.h index 9d6fede21..f5630bdb0 100644 --- a/src/Blocks/BlockSign.h +++ b/src/Blocks/BlockSign.h @@ -75,13 +75,13 @@ public: virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override { - return (++a_Meta) & 0x0F; + return (a_Meta + 4) & 0x0f; } virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override { - return (--a_Meta) & 0x0F; + return (a_Meta + 12) & 0x0f; } virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override @@ -90,7 +90,7 @@ public: // There are 16 meta values which correspond to different directions. // These values are equated to angles on a circle; 0x08 = 180 degrees. - return (a_Meta < 0x08) ? 0x08 + a_Meta : 0x08 - a_Meta; + return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta); } -- cgit v1.2.3 From dd6a9f655958dd634fe1bdacadef51d84fac7e39 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 23 Jun 2014 00:15:22 +0200 Subject: Fixed the slab vertical mirroring. --- src/Blocks/BlockSlab.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index f3f2366fd..6c861be86 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -124,6 +124,12 @@ public: return E_BLOCK_AIR; } + + virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override + { + // Toggle the 4th bit - up / down: + return (a_Meta ^ 0x08); + } } ; @@ -167,15 +173,6 @@ public: ASSERT(!"Unhandled double slab type!"); return ""; } - - - virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override - { - NIBBLETYPE OtherMeta = a_Meta & 0x07; // Contains unrelated meta data. - - // 8th bit is up/down. 1 right-side-up, 0 is up-side-down. - return (a_Meta & 0x08) ? 0x00 + OtherMeta : 0x01 + OtherMeta; - } } ; -- cgit v1.2.3 From 6a77705d4e344fa23992c234db53015ce51d3028 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 23 Jun 2014 07:23:54 +0200 Subject: Added a (disabled) block meta mirror / rotate test code. This will perform basic sanity checks on block metadata mirroring and rotating. cMetaRotator must disable its asserts in order for this to work. --- src/Blocks/BlockHandler.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index a7b89fcb7..405c9bf43 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -85,6 +85,91 @@ +/* +// Tests the meta rotation and mirroring. +// Note that the cMetaRotator needs to have its assert paths disabled for this test to work! +static class cBlockHandlerRotationTester +{ +public: + cBlockHandlerRotationTester(void) + { + printf("Performing block handlers test...\n"); + for (BLOCKTYPE Type = 0; Type < E_BLOCK_MAX_TYPE_ID; Type++) + { + cBlockHandler * Handler = cBlockInfo::GetHandler(Type); + if (Handler == NULL) + { + printf("NULL handler for block type %d!\n", Type); + continue; + } + AString BlockName = ItemTypeToString(Type); + for (NIBBLETYPE Meta = 0; Meta < 16; Meta++) + { + // Test the CW / CCW rotations: + NIBBLETYPE TestMeta; + TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaRotateCW(Meta)))); + if (TestMeta != Meta) + { + // 4 CW rotations should produce no change in the meta + printf("Handler for blocktype %d (%s) fails CW 4-rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + } + TestMeta = Handler->MetaRotateCCW(Handler->MetaRotateCCW(Handler->MetaRotateCCW(Handler->MetaRotateCCW(Meta)))); + if (TestMeta != Meta) + { + // 4 CCW rotations should produce no change in the meta + printf("Handler for blocktype %d (%s) fails CCW 4-rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + } + TestMeta = Handler->MetaRotateCCW(Handler->MetaRotateCW(Meta)); + if (TestMeta != Meta) + { + // CCW rotation of a CW rotation should produce no change in the meta + printf("Handler for blocktype %d (%s) fails CCW(CW) rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + } + TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCCW(Meta)); + if (TestMeta != Meta) + { + // CW rotation of a CCW rotation should produce no change in the meta + printf("Handler for blocktype %d (%s) fails CW(CCW) rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + } + + // Test the mirroring: + TestMeta = Handler->MetaMirrorXY(Handler->MetaMirrorXY(Meta)); + if (TestMeta != Meta) + { + // Double-mirroring should produce the same meta: + printf("Handler for blocktype %d (%s) fails XY mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + } + TestMeta = Handler->MetaMirrorXZ(Handler->MetaMirrorXZ(Meta)); + if (TestMeta != Meta) + { + // Double-mirroring should produce the same meta: + printf("Handler for blocktype %d (%s) fails XZ mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + } + TestMeta = Handler->MetaMirrorYZ(Handler->MetaMirrorYZ(Meta)); + if (TestMeta != Meta) + { + // Double-mirroring should produce the same meta: + printf("Handler for blocktype %d (%s) fails YZ mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + } + + // Test mirror-rotating: + TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaMirrorXY(Handler->MetaMirrorYZ(Meta)))); + if (TestMeta != Meta) + { + // 2 CW rotations should be the same as XY, YZ mirroring: + printf("Handler for blocktype %d (%s) fails rotation-mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + } + } + } // for Type + printf("Block handlers test complete.\n"); + } +} g_BlockHandlerRotationTester; +//*/ + + + + + cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) { switch(a_BlockType) @@ -175,7 +260,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_QUARTZ_BLOCK: return new cBlockQuartzHandler (a_BlockType); case E_BLOCK_QUARTZ_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType); - case E_BLOCK_REDSTONE_LAMP_ON: return new cBlockRedstoneLampHandler (a_BlockType); // We need this to change pickups to an off lamp; else 1.7+ clients crash + case E_BLOCK_REDSTONE_LAMP_ON: return new cBlockRedstoneLampHandler (a_BlockType); case E_BLOCK_REDSTONE_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_REDSTONE_ORE_GLOWING: return new cBlockOreHandler (a_BlockType); case E_BLOCK_REDSTONE_REPEATER_OFF: return new cBlockRedstoneRepeaterHandler(a_BlockType); @@ -207,7 +292,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_TRAPDOOR: return new cBlockTrapdoorHandler (a_BlockType); case E_BLOCK_TNT: return new cBlockTNTHandler (a_BlockType); case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType); - case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType); + case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType); // TODO: This needs a special handler case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType); case E_BLOCK_WOODEN_BUTTON: return new cBlockButtonHandler (a_BlockType); case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (a_BlockType); -- cgit v1.2.3 From 59270fd44d7d2f0cf4857b80134827b81fce4116 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 23 Jun 2014 17:06:38 +0200 Subject: VoronoiMap: Added a missing initializer. Fixes CID 68410. --- src/VoronoiMap.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/VoronoiMap.cpp b/src/VoronoiMap.cpp index 9c3ca7e65..5efd09c01 100644 --- a/src/VoronoiMap.cpp +++ b/src/VoronoiMap.cpp @@ -14,7 +14,9 @@ cVoronoiMap::cVoronoiMap(int a_Seed, int a_CellSize) : m_Noise1(a_Seed + 1), m_Noise2(a_Seed + 2), m_Noise3(a_Seed + 3), - m_CellSize(a_CellSize) + m_CellSize(a_CellSize), + m_CurrentCellX(9999999), // Cell coords that are definitely out of the range for normal generator, so that the first query will overwrite them + m_CurrentCellZ(9999999) { } -- cgit v1.2.3 From 7a236921319c44de38246ff73d5343e174dd560f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 23 Jun 2014 17:40:51 +0100 Subject: Parenthesised comparison --- src/FurnaceRecipe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index d53854950..36dd2d5e9 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -230,7 +230,7 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt bool cFurnaceRecipe::DoesStringContainOnlyNumbers(const AString & a_String) { // TODO: replace this with std::all_of(a_String.begin(), a_String.end(), isdigit) - return a_String.find_first_not_of("0123456789") == AString::npos; + return (a_String.find_first_not_of("0123456789") == AString::npos); } -- cgit v1.2.3 From 742370497a4210bff18e4e2c65a3ef7772bc1cc5 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 24 Jun 2014 09:46:04 +0200 Subject: Fixed crashes in HopperEntity. Some of the coords were off and some functions were assuming too much. Fixes the crash reported in http://forum.mc-server.org/showthread.php?tid=1497 --- src/BlockEntities/HopperEntity.cpp | 77 ++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index 7f001c739..5856f20d1 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -294,23 +294,24 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick) return false; } - int bx, by, bz; + // Get the coords of the block where to output items: + int OutX, OutY, OutZ; NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ); - if (!GetOutputBlockPos(Meta, bx, by, bz)) + if (!GetOutputBlockPos(Meta, OutX, OutY, OutZ)) { // Not attached to another container return false; } - if (by < 0) + if (OutY < 0) { // Cannot output below the zero-th block level return false; } // Convert coords to relative: - int rx = bx - a_Chunk.GetPosX() * cChunkDef::Width; - int rz = bz - a_Chunk.GetPosZ() * cChunkDef::Width; - cChunk * DestChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(rx, rz); + int OutRelX = OutX - a_Chunk.GetPosX() * cChunkDef::Width; + int OutRelZ = OutZ - a_Chunk.GetPosZ() * cChunkDef::Width; + cChunk * DestChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(OutRelX, OutRelZ); if (DestChunk == NULL) { // The destination chunk has been unloaded, don't tick @@ -319,26 +320,32 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick) // Call proper moving function, based on the blocktype present at the coords: bool res = false; - switch (DestChunk->GetBlock(rx, by, rz)) + switch (DestChunk->GetBlock(OutRelX, OutY, OutRelZ)) { case E_BLOCK_CHEST: { // Chests have special handling because of double-chests - res = MoveItemsToChest(*DestChunk, bx, by, bz); + res = MoveItemsToChest(*DestChunk, OutX, OutY, OutZ); break; } case E_BLOCK_LIT_FURNACE: case E_BLOCK_FURNACE: { // Furnaces have special handling because of the direction-to-slot relation - res = MoveItemsToFurnace(*DestChunk, bx, by, bz, Meta); + res = MoveItemsToFurnace(*DestChunk, OutX, OutY, OutZ, Meta); break; } case E_BLOCK_DISPENSER: case E_BLOCK_DROPPER: case E_BLOCK_HOPPER: { - res = MoveItemsToGrid(*(cBlockEntityWithItems *)DestChunk->GetBlockEntity(bx, by, bz)); + cBlockEntityWithItems * BlockEntity = (cBlockEntityWithItems *)DestChunk->GetBlockEntity(OutX, OutY, OutZ); + if (BlockEntity == NULL) + { + LOGWARNING("%s: A block entity was not found where expected at {%d, %d, %d}", __FUNCTION__, OutX, OutY, OutZ); + return false; + } + res = MoveItemsToGrid(*BlockEntity); break; } } @@ -359,7 +366,13 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick) /// Moves items from a chest (dblchest) above the hopper into this hopper. Returns true if contents have changed. bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk) { - if (MoveItemsFromGrid(*(cChestEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ))) + cChestEntity * Chest = (cChestEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ); + if (Chest == NULL) + { + LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ); + return false; + } + if (MoveItemsFromGrid(*Chest)) { // Moved the item from the chest directly above the hopper return true; @@ -389,9 +402,17 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk) { continue; } - if (MoveItemsFromGrid(*(cChestEntity *)Neighbor->GetBlockEntity(x, m_PosY, z))) + Chest = (cChestEntity *)Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z); + if (Chest == NULL) { - return true; + LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z); + } + else + { + if (MoveItemsFromGrid(*Chest)) + { + return true; + } } return false; } @@ -408,7 +429,11 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk) bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk) { cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ); - ASSERT(Furnace != NULL); + if (Furnace == NULL) + { + LOGWARNING("%s: A furnace entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ); + return false; + } // Try move from the output slot: if (MoveItemsFromSlot(*Furnace, cFurnaceEntity::fsOutput, true)) @@ -517,7 +542,13 @@ bool cHopperEntity::MoveItemsFromSlot(cBlockEntityWithItems & a_Entity, int a_Sl bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ) { // Try the chest directly connected to the hopper: - if (MoveItemsToGrid(*(cChestEntity *)a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ))) + cChestEntity * Chest = (cChestEntity *)a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ); + if (Chest == NULL) + { + LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, a_BlockX, a_BlockY, a_BlockZ); + return false; + } + if (MoveItemsToGrid(*Chest)) { return true; } @@ -534,19 +565,27 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block {0, 1}, {0, -1}, } ; + int RelX = a_BlockX - a_Chunk.GetPosX() * cChunkDef::Width; + int RelZ = a_BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width; for (size_t i = 0; i < ARRAYCOUNT(Coords); i++) { - int x = m_RelX + Coords[i].x; - int z = m_RelZ + Coords[i].z; + int x = RelX + Coords[i].x; + int z = RelZ + Coords[i].z; cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z); if ( (Neighbor == NULL) || - (Neighbor->GetBlock(x, m_PosY + 1, z) != E_BLOCK_CHEST) + (Neighbor->GetBlock(x, a_BlockY, z) != E_BLOCK_CHEST) ) { continue; } - if (MoveItemsToGrid(*(cChestEntity *)Neighbor->GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ))) + Chest = (cChestEntity *)Neighbor->GetBlockEntity(a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z); + if (Chest == NULL) + { + LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d} (%d, %d)", __FUNCTION__, a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z, x, z); + continue; + } + if (MoveItemsToGrid(*Chest)) { return true; } -- cgit v1.2.3 From 1da39568a307db15ba2f03b717506dc1287986bf Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 24 Jun 2014 09:46:38 +0200 Subject: Added asserts for cChunk::GetBlockEntity() coords. --- src/Chunk.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 6ab49036d..1320d5ccd 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1616,6 +1616,12 @@ void cChunk::AddBlockEntity(cBlockEntity * a_BlockEntity) cBlockEntity * cChunk::GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ) { + // Check that the query coords are within chunk bounds: + ASSERT(a_BlockX >= m_PosX * cChunkDef::Width); + ASSERT(a_BlockX < m_PosX * cChunkDef::Width + cChunkDef::Width); + ASSERT(a_BlockZ >= m_PosZ * cChunkDef::Width); + ASSERT(a_BlockZ < m_PosZ * cChunkDef::Width + cChunkDef::Width); + for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr) { if ( -- cgit v1.2.3 From a1d2c114cf2e9f3a7e54c58d4073c87d0afa76af Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 24 Jun 2014 13:48:12 +0200 Subject: Fixed BlockInfo initialization. Now cBlockInfo is initialized in the getter, instead of "at any time during startup", which included "after it was already needed". --- src/BlockInfo.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 32fdec905..b084d0915 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -9,6 +9,7 @@ cBlockInfo cBlockInfo::ms_Info[256]; +static bool g_IsBlockInfoInitialized = false; @@ -43,6 +44,11 @@ cBlockInfo::~cBlockInfo() cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type) { + if (!g_IsBlockInfoInitialized) + { + cBlockInfo::Initialize(); + g_IsBlockInfoInitialized = true; + } return ms_Info[a_Type]; } @@ -448,18 +454,3 @@ void cBlockInfo::Initialize(void) - -// This is actually just some code that needs to run at program startup, so it is wrapped into a global var's constructor: -class cBlockInfoInitializer -{ -public: - cBlockInfoInitializer(void) - { - cBlockInfo::Initialize(); - } -} BlockInfoInitializer; - - - - - -- cgit v1.2.3 From 5ab01c4d4205b61b41855eaeee534ae15b816331 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 24 Jun 2014 15:27:19 +0200 Subject: Fix pickup combining over the maximum stack size. --- src/Entities/Pickup.cpp | 12 ++++++++---- src/Item.cpp | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index 0fd006485..88d961106 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -38,11 +38,15 @@ public: Vector3d EntityPos = a_Entity->GetPosition(); double Distance = (EntityPos - m_Position).Length(); - if ((Distance < 1.2) && ((cPickup *)a_Entity)->GetItem().IsEqual(m_Pickup->GetItem())) + cItem & Item = ((cPickup *)a_Entity)->GetItem(); + if ((Distance < 1.2) && Item.IsEqual(m_Pickup->GetItem())) { - m_Pickup->GetItem().AddCount(((cPickup *)a_Entity)->GetItem().m_ItemCount); - a_Entity->Destroy(); - m_FoundMatchingPickup = true; + if ((Item.m_ItemCount + m_Pickup->GetItem().m_ItemCount) <= Item.GetMaxStackSize()) + { + m_Pickup->GetItem().AddCount(Item.m_ItemCount); + a_Entity->Destroy(); + m_FoundMatchingPickup = true; + } } return false; } diff --git a/src/Item.cpp b/src/Item.cpp index d6e8b224a..56ceae0b7 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -1,4 +1,4 @@ - + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Item.h" -- cgit v1.2.3 From d4e1277724b8a7629fc0eb4d468319f7bd4a93b0 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 24 Jun 2014 16:06:26 +0200 Subject: Add entity health saving. --- src/WorldStorage/NBTChunkSerializer.cpp | 3 +-- src/WorldStorage/WSSAnvil.cpp | 21 +++++++-------------- 2 files changed, 8 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 8294d4a00..f35b38859 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -345,6 +345,7 @@ void cNBTChunkSerializer::AddBasicEntity(cEntity * a_Entity, const AString & a_C m_Writer.AddDouble("", a_Entity->GetYaw()); m_Writer.AddDouble("", a_Entity->GetPitch()); m_Writer.EndList(); + m_Writer.AddShort("Health", a_Entity->GetHealth()); } @@ -575,7 +576,6 @@ void cNBTChunkSerializer::AddPickupEntity(cPickup * a_Pickup) m_Writer.BeginCompound(""); AddBasicEntity(a_Pickup, "Item"); AddItem(a_Pickup->GetItem(), -1, "Item"); - m_Writer.AddShort("Health", (Int16)(unsigned char)a_Pickup->GetHealth()); m_Writer.AddShort("Age", (Int16)a_Pickup->GetAge()); m_Writer.EndCompound(); } @@ -678,7 +678,6 @@ void cNBTChunkSerializer::AddExpOrbEntity(cExpOrb * a_ExpOrb) { m_Writer.BeginCompound(""); AddBasicEntity(a_ExpOrb, "XPOrb"); - m_Writer.AddShort("Health", (Int16)(unsigned char)a_ExpOrb->GetHealth()); m_Writer.AddShort("Age", (Int16)a_ExpOrb->GetAge()); m_Writer.AddShort("Value", (Int16)a_ExpOrb->GetReward()); m_Writer.EndCompound(); diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 0f84a0eb1..9870c144a 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1461,13 +1461,6 @@ void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a { return; } - - // Load health: - int Health = a_NBT.FindChildByName(a_TagIdx, "Health"); - if (Health > 0) - { - Pickup->SetHealth((int) (a_NBT.GetShort(Health) & 0xFF)); - } // Load age: int Age = a_NBT.FindChildByName(a_TagIdx, "Age"); @@ -1513,13 +1506,6 @@ void cWSSAnvil::LoadExpOrbFromNBT(cEntityList & a_Entities, const cParsedNBT & a return; } - // Load Health: - int Health = a_NBT.FindChildByName(a_TagIdx, "Health"); - if (Health > 0) - { - ExpOrb->SetHealth((int) (a_NBT.GetShort(Health) & 0xFF)); - } - // Load Age: int Age = a_NBT.FindChildByName(a_TagIdx, "Age"); if (Age > 0) @@ -2437,6 +2423,13 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N } a_Entity.SetYaw(Rotation[0]); a_Entity.SetRoll(Rotation[1]); + + // Load health: + int Health = a_NBT.FindChildByName(a_TagIdx, "Health"); + if (Health > 0) + { + a_Entity.SetHealth(a_NBT.GetShort(Health)); + } return true; } -- cgit v1.2.3 From 2dd7a0373be83ab917c3c115af519b42ce30e2a9 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 24 Jun 2014 16:19:22 +0200 Subject: Better combining. --- src/Entities/Pickup.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index 88d961106..6cab79b91 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -41,12 +41,29 @@ public: cItem & Item = ((cPickup *)a_Entity)->GetItem(); if ((Distance < 1.2) && Item.IsEqual(m_Pickup->GetItem())) { - if ((Item.m_ItemCount + m_Pickup->GetItem().m_ItemCount) <= Item.GetMaxStackSize()) + char CombineCount = Item.m_ItemCount; + if ((CombineCount + m_Pickup->GetItem().m_ItemCount) > Item.GetMaxStackSize()) + { + CombineCount = Item.GetMaxStackSize() - m_Pickup->GetItem().m_ItemCount; + } + + if (CombineCount <= 0) + { + return false; + } + + m_Pickup->GetItem().AddCount(CombineCount); + Item.m_ItemCount -= CombineCount; + + if (Item.m_ItemCount <= 0) { - m_Pickup->GetItem().AddCount(Item.m_ItemCount); a_Entity->Destroy(); - m_FoundMatchingPickup = true; } + else + { + a_Entity->GetWorld()->BroadcastEntityMetadata(*a_Entity); + } + m_FoundMatchingPickup = true; } return false; } -- cgit v1.2.3 From dbcb7f819fc900164d644a1932d0cdc78b707ae0 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 24 Jun 2014 17:50:38 +0200 Subject: Optimize combining. --- src/Entities/Pickup.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index 6cab79b91..44a65412f 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -30,7 +30,7 @@ public: virtual bool Item(cEntity * a_Entity) override { - if (!a_Entity->IsPickup() || (a_Entity->GetUniqueID() == m_Pickup->GetUniqueID()) || a_Entity->IsDestroyed()) + if (!a_Entity->IsPickup() || (a_Entity->GetUniqueID() <= m_Pickup->GetUniqueID()) || a_Entity->IsDestroyed()) { return false; } @@ -150,7 +150,7 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk) } } - if (!IsDestroyed()) // Don't try to combine if someone has tried to combine me + if (!IsDestroyed() && (m_Item.m_ItemCount < m_Item.GetMaxStackSize())) // Don't try to combine if someone has tried to combine me { cPickupCombiningCallback PickupCombiningCallback(GetPosition(), this); m_World->ForEachEntity(PickupCombiningCallback); // Not ForEachEntityInChunk, otherwise pickups don't combine across chunk boundaries @@ -227,7 +227,7 @@ bool cPickup::CollectedBy(cPlayer * a_Dest) m_World->BroadcastCollectPickup(*this, *a_Dest); // Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;) m_World->BroadcastSoundEffect("random.pop",(int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); - if (m_Item.m_ItemCount == 0) + if (m_Item.m_ItemCount <= 0) { // All of the pickup has been collected, schedule the pickup for destroying m_bCollected = true; -- cgit v1.2.3 From e9aecfdf112601377ab6f640b77cb49c5a3a45bb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 25 Jun 2014 08:07:06 +0200 Subject: BlockInfo is now a proper C++ singleton. It is properly initialized before it is ever used. --- src/BlockInfo.cpp | 732 +++++++++++++++++++++++++++--------------------------- src/BlockInfo.h | 23 +- 2 files changed, 374 insertions(+), 381 deletions(-) (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index b084d0915..26525e264 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -8,13 +8,6 @@ -cBlockInfo cBlockInfo::ms_Info[256]; -static bool g_IsBlockInfoInitialized = false; - - - - - cBlockInfo::cBlockInfo() : m_LightValue(0x00) , m_SpreadLightFalloff(0x0f) @@ -42,12 +35,17 @@ cBlockInfo::~cBlockInfo() +/** This accessor makes sure that the cBlockInfo structures are properly initialized exactly once. +It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable. +It works only if it is called for the first time before the app spawns other threads. */ cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type) { - if (!g_IsBlockInfoInitialized) + static cBlockInfo ms_Info[256]; + static bool IsBlockInfoInitialized = false; + if (!IsBlockInfoInitialized) { - cBlockInfo::Initialize(); - g_IsBlockInfoInitialized = true; + cBlockInfo::Initialize(ms_Info); + IsBlockInfoInitialized = true; } return ms_Info[a_Type]; } @@ -56,399 +54,399 @@ cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type) -void cBlockInfo::Initialize(void) +void cBlockInfo::Initialize(cBlockInfoArray & a_Info) { for (unsigned int i = 0; i < 256; ++i) { - if (ms_Info[i].m_Handler == NULL) + if (a_Info[i].m_Handler == NULL) { - ms_Info[i].m_Handler = cBlockHandler::CreateBlockHandler((BLOCKTYPE) i); + a_Info[i].m_Handler = cBlockHandler::CreateBlockHandler((BLOCKTYPE) i); } } // Emissive blocks - ms_Info[E_BLOCK_FIRE ].m_LightValue = 15; - ms_Info[E_BLOCK_GLOWSTONE ].m_LightValue = 15; - ms_Info[E_BLOCK_JACK_O_LANTERN ].m_LightValue = 15; - ms_Info[E_BLOCK_LAVA ].m_LightValue = 15; - ms_Info[E_BLOCK_STATIONARY_LAVA ].m_LightValue = 15; - ms_Info[E_BLOCK_END_PORTAL ].m_LightValue = 15; - ms_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_LightValue = 15; - ms_Info[E_BLOCK_TORCH ].m_LightValue = 14; - ms_Info[E_BLOCK_BURNING_FURNACE ].m_LightValue = 13; - ms_Info[E_BLOCK_NETHER_PORTAL ].m_LightValue = 11; - ms_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_LightValue = 9; - ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_LightValue = 9; - ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_LightValue = 7; - ms_Info[E_BLOCK_BREWING_STAND ].m_LightValue = 1; - ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_LightValue = 1; - ms_Info[E_BLOCK_DRAGON_EGG ].m_LightValue = 1; + a_Info[E_BLOCK_FIRE ].m_LightValue = 15; + a_Info[E_BLOCK_GLOWSTONE ].m_LightValue = 15; + a_Info[E_BLOCK_JACK_O_LANTERN ].m_LightValue = 15; + a_Info[E_BLOCK_LAVA ].m_LightValue = 15; + a_Info[E_BLOCK_STATIONARY_LAVA ].m_LightValue = 15; + a_Info[E_BLOCK_END_PORTAL ].m_LightValue = 15; + a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_LightValue = 15; + a_Info[E_BLOCK_TORCH ].m_LightValue = 14; + a_Info[E_BLOCK_BURNING_FURNACE ].m_LightValue = 13; + a_Info[E_BLOCK_NETHER_PORTAL ].m_LightValue = 11; + a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_LightValue = 9; + a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_LightValue = 9; + a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_LightValue = 7; + a_Info[E_BLOCK_BREWING_STAND ].m_LightValue = 1; + a_Info[E_BLOCK_BROWN_MUSHROOM ].m_LightValue = 1; + a_Info[E_BLOCK_DRAGON_EGG ].m_LightValue = 1; // Spread blocks - ms_Info[E_BLOCK_AIR ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_CAKE ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_CHEST ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_COBWEB ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_CROPS ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_FENCE ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_FIRE ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_GLASS ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_GLASS_PANE ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_GLOWSTONE ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_IRON_BARS ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_IRON_DOOR ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_LEAVES ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_WALLSIGN ].m_SpreadLightFalloff = 1; - ms_Info[E_BLOCK_WOODEN_DOOR ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_AIR ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_CAKE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_CHEST ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_COBWEB ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_CROPS ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_FENCE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_FIRE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_GLASS ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_GLASS_PANE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_GLOWSTONE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_IRON_BARS ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_IRON_DOOR ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_LEAVES ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_WALLSIGN ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_WOODEN_DOOR ].m_SpreadLightFalloff = 1; // Light in water and lava dissapears faster: - ms_Info[E_BLOCK_LAVA ].m_SpreadLightFalloff = 3; - ms_Info[E_BLOCK_STATIONARY_LAVA ].m_SpreadLightFalloff = 3; - ms_Info[E_BLOCK_STATIONARY_WATER ].m_SpreadLightFalloff = 3; - ms_Info[E_BLOCK_WATER ].m_SpreadLightFalloff = 3; + a_Info[E_BLOCK_LAVA ].m_SpreadLightFalloff = 3; + a_Info[E_BLOCK_STATIONARY_LAVA ].m_SpreadLightFalloff = 3; + a_Info[E_BLOCK_STATIONARY_WATER ].m_SpreadLightFalloff = 3; + a_Info[E_BLOCK_WATER ].m_SpreadLightFalloff = 3; // Transparent blocks - ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_Transparent = true; - ms_Info[E_BLOCK_AIR ].m_Transparent = true; - ms_Info[E_BLOCK_ANVIL ].m_Transparent = true; - ms_Info[E_BLOCK_BIG_FLOWER ].m_Transparent = true; - ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_Transparent = true; - ms_Info[E_BLOCK_CAKE ].m_Transparent = true; - ms_Info[E_BLOCK_CARROTS ].m_Transparent = true; - ms_Info[E_BLOCK_CHEST ].m_Transparent = true; - ms_Info[E_BLOCK_COBBLESTONE_WALL ].m_Transparent = true; - ms_Info[E_BLOCK_COBWEB ].m_Transparent = true; - ms_Info[E_BLOCK_CROPS ].m_Transparent = true; - ms_Info[E_BLOCK_DANDELION ].m_Transparent = true; - ms_Info[E_BLOCK_DETECTOR_RAIL ].m_Transparent = true; - ms_Info[E_BLOCK_ENDER_CHEST ].m_Transparent = true; - ms_Info[E_BLOCK_FENCE ].m_Transparent = true; - ms_Info[E_BLOCK_FENCE_GATE ].m_Transparent = true; - ms_Info[E_BLOCK_FIRE ].m_Transparent = true; - ms_Info[E_BLOCK_FLOWER ].m_Transparent = true; - ms_Info[E_BLOCK_FLOWER_POT ].m_Transparent = true; - ms_Info[E_BLOCK_GLASS ].m_Transparent = true; - ms_Info[E_BLOCK_GLASS_PANE ].m_Transparent = true; - ms_Info[E_BLOCK_HEAD ].m_Transparent = true; - ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_Transparent = true; - ms_Info[E_BLOCK_ICE ].m_Transparent = true; - ms_Info[E_BLOCK_IRON_DOOR ].m_Transparent = true; - ms_Info[E_BLOCK_LADDER ].m_Transparent = true; - ms_Info[E_BLOCK_LAVA ].m_Transparent = true; - ms_Info[E_BLOCK_LEAVES ].m_Transparent = true; - ms_Info[E_BLOCK_LEVER ].m_Transparent = true; - ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_Transparent = true; - ms_Info[E_BLOCK_MELON_STEM ].m_Transparent = true; - ms_Info[E_BLOCK_NETHER_BRICK_FENCE ].m_Transparent = true; - ms_Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true; - ms_Info[E_BLOCK_POTATOES ].m_Transparent = true; - ms_Info[E_BLOCK_POWERED_RAIL ].m_Transparent = true; - ms_Info[E_BLOCK_PISTON_EXTENSION ].m_Transparent = true; - ms_Info[E_BLOCK_PUMPKIN_STEM ].m_Transparent = true; - ms_Info[E_BLOCK_RAIL ].m_Transparent = true; - ms_Info[E_BLOCK_RED_MUSHROOM ].m_Transparent = true; - ms_Info[E_BLOCK_SIGN_POST ].m_Transparent = true; - ms_Info[E_BLOCK_SNOW ].m_Transparent = true; - ms_Info[E_BLOCK_STAINED_GLASS ].m_Transparent = true; - ms_Info[E_BLOCK_STAINED_GLASS_PANE ].m_Transparent = true; - ms_Info[E_BLOCK_STATIONARY_LAVA ].m_Transparent = true; - ms_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true; - ms_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true; - ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true; - ms_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true; - ms_Info[E_BLOCK_TORCH ].m_Transparent = true; - ms_Info[E_BLOCK_VINES ].m_Transparent = true; - ms_Info[E_BLOCK_WALLSIGN ].m_Transparent = true; - ms_Info[E_BLOCK_WATER ].m_Transparent = true; - ms_Info[E_BLOCK_WOODEN_BUTTON ].m_Transparent = true; - ms_Info[E_BLOCK_WOODEN_DOOR ].m_Transparent = true; - ms_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_Transparent = true; + a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_Transparent = true; + a_Info[E_BLOCK_AIR ].m_Transparent = true; + a_Info[E_BLOCK_ANVIL ].m_Transparent = true; + a_Info[E_BLOCK_BIG_FLOWER ].m_Transparent = true; + a_Info[E_BLOCK_BROWN_MUSHROOM ].m_Transparent = true; + a_Info[E_BLOCK_CAKE ].m_Transparent = true; + a_Info[E_BLOCK_CARROTS ].m_Transparent = true; + a_Info[E_BLOCK_CHEST ].m_Transparent = true; + a_Info[E_BLOCK_COBBLESTONE_WALL ].m_Transparent = true; + a_Info[E_BLOCK_COBWEB ].m_Transparent = true; + a_Info[E_BLOCK_CROPS ].m_Transparent = true; + a_Info[E_BLOCK_DANDELION ].m_Transparent = true; + a_Info[E_BLOCK_DETECTOR_RAIL ].m_Transparent = true; + a_Info[E_BLOCK_ENDER_CHEST ].m_Transparent = true; + a_Info[E_BLOCK_FENCE ].m_Transparent = true; + a_Info[E_BLOCK_FENCE_GATE ].m_Transparent = true; + a_Info[E_BLOCK_FIRE ].m_Transparent = true; + a_Info[E_BLOCK_FLOWER ].m_Transparent = true; + a_Info[E_BLOCK_FLOWER_POT ].m_Transparent = true; + a_Info[E_BLOCK_GLASS ].m_Transparent = true; + a_Info[E_BLOCK_GLASS_PANE ].m_Transparent = true; + a_Info[E_BLOCK_HEAD ].m_Transparent = true; + a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_Transparent = true; + a_Info[E_BLOCK_ICE ].m_Transparent = true; + a_Info[E_BLOCK_IRON_DOOR ].m_Transparent = true; + a_Info[E_BLOCK_LADDER ].m_Transparent = true; + a_Info[E_BLOCK_LAVA ].m_Transparent = true; + a_Info[E_BLOCK_LEAVES ].m_Transparent = true; + a_Info[E_BLOCK_LEVER ].m_Transparent = true; + a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_Transparent = true; + a_Info[E_BLOCK_MELON_STEM ].m_Transparent = true; + a_Info[E_BLOCK_NETHER_BRICK_FENCE ].m_Transparent = true; + a_Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true; + a_Info[E_BLOCK_POTATOES ].m_Transparent = true; + a_Info[E_BLOCK_POWERED_RAIL ].m_Transparent = true; + a_Info[E_BLOCK_PISTON_EXTENSION ].m_Transparent = true; + a_Info[E_BLOCK_PUMPKIN_STEM ].m_Transparent = true; + a_Info[E_BLOCK_RAIL ].m_Transparent = true; + a_Info[E_BLOCK_RED_MUSHROOM ].m_Transparent = true; + a_Info[E_BLOCK_SIGN_POST ].m_Transparent = true; + a_Info[E_BLOCK_SNOW ].m_Transparent = true; + a_Info[E_BLOCK_STAINED_GLASS ].m_Transparent = true; + a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_Transparent = true; + a_Info[E_BLOCK_STATIONARY_LAVA ].m_Transparent = true; + a_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true; + a_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true; + a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true; + a_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true; + a_Info[E_BLOCK_TORCH ].m_Transparent = true; + a_Info[E_BLOCK_VINES ].m_Transparent = true; + a_Info[E_BLOCK_WALLSIGN ].m_Transparent = true; + a_Info[E_BLOCK_WATER ].m_Transparent = true; + a_Info[E_BLOCK_WOODEN_BUTTON ].m_Transparent = true; + a_Info[E_BLOCK_WOODEN_DOOR ].m_Transparent = true; + a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_Transparent = true; // TODO: Any other transparent blocks? // One hit break blocks: - ms_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_OneHitDig = true; - ms_Info[E_BLOCK_BIG_FLOWER ].m_OneHitDig = true; - ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_OneHitDig = true; - ms_Info[E_BLOCK_CARROTS ].m_OneHitDig = true; - ms_Info[E_BLOCK_CROPS ].m_OneHitDig = true; - ms_Info[E_BLOCK_DANDELION ].m_OneHitDig = true; - ms_Info[E_BLOCK_FIRE ].m_OneHitDig = true; - ms_Info[E_BLOCK_FLOWER ].m_OneHitDig = true; - ms_Info[E_BLOCK_FLOWER_POT ].m_OneHitDig = true; - ms_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_OneHitDig = true; - ms_Info[E_BLOCK_MELON_STEM ].m_OneHitDig = true; - ms_Info[E_BLOCK_POTATOES ].m_OneHitDig = true; - ms_Info[E_BLOCK_PUMPKIN_STEM ].m_OneHitDig = true; - ms_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_OneHitDig = true; - ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_OneHitDig = true; - ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_OneHitDig = true; - ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_OneHitDig = true; - ms_Info[E_BLOCK_REDSTONE_WIRE ].m_OneHitDig = true; - ms_Info[E_BLOCK_RED_MUSHROOM ].m_OneHitDig = true; - ms_Info[E_BLOCK_REEDS ].m_OneHitDig = true; - ms_Info[E_BLOCK_SAPLING ].m_OneHitDig = true; - ms_Info[E_BLOCK_TNT ].m_OneHitDig = true; - ms_Info[E_BLOCK_TALL_GRASS ].m_OneHitDig = true; - ms_Info[E_BLOCK_TORCH ].m_OneHitDig = true; + a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_OneHitDig = true; + a_Info[E_BLOCK_BIG_FLOWER ].m_OneHitDig = true; + a_Info[E_BLOCK_BROWN_MUSHROOM ].m_OneHitDig = true; + a_Info[E_BLOCK_CARROTS ].m_OneHitDig = true; + a_Info[E_BLOCK_CROPS ].m_OneHitDig = true; + a_Info[E_BLOCK_DANDELION ].m_OneHitDig = true; + a_Info[E_BLOCK_FIRE ].m_OneHitDig = true; + a_Info[E_BLOCK_FLOWER ].m_OneHitDig = true; + a_Info[E_BLOCK_FLOWER_POT ].m_OneHitDig = true; + a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_OneHitDig = true; + a_Info[E_BLOCK_MELON_STEM ].m_OneHitDig = true; + a_Info[E_BLOCK_POTATOES ].m_OneHitDig = true; + a_Info[E_BLOCK_PUMPKIN_STEM ].m_OneHitDig = true; + a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_OneHitDig = true; + a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_OneHitDig = true; + a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_OneHitDig = true; + a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_OneHitDig = true; + a_Info[E_BLOCK_REDSTONE_WIRE ].m_OneHitDig = true; + a_Info[E_BLOCK_RED_MUSHROOM ].m_OneHitDig = true; + a_Info[E_BLOCK_REEDS ].m_OneHitDig = true; + a_Info[E_BLOCK_SAPLING ].m_OneHitDig = true; + a_Info[E_BLOCK_TNT ].m_OneHitDig = true; + a_Info[E_BLOCK_TALL_GRASS ].m_OneHitDig = true; + a_Info[E_BLOCK_TORCH ].m_OneHitDig = true; // Blocks that break when pushed by piston: - ms_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_PistonBreakable = true; - ms_Info[E_BLOCK_AIR ].m_PistonBreakable = true; - ms_Info[E_BLOCK_BED ].m_PistonBreakable = true; - ms_Info[E_BLOCK_BIG_FLOWER ].m_PistonBreakable = true; - ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_PistonBreakable = true; - ms_Info[E_BLOCK_CAKE ].m_PistonBreakable = true; - ms_Info[E_BLOCK_COBWEB ].m_PistonBreakable = true; - ms_Info[E_BLOCK_CROPS ].m_PistonBreakable = true; - ms_Info[E_BLOCK_DANDELION ].m_PistonBreakable = true; - ms_Info[E_BLOCK_DEAD_BUSH ].m_PistonBreakable = true; - ms_Info[E_BLOCK_FIRE ].m_PistonBreakable = true; - ms_Info[E_BLOCK_FLOWER ].m_PistonBreakable = true; - ms_Info[E_BLOCK_HEAD ].m_PistonBreakable = true; - ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true; - ms_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_PistonBreakable = true; - ms_Info[E_BLOCK_IRON_DOOR ].m_PistonBreakable = true; - ms_Info[E_BLOCK_JACK_O_LANTERN ].m_PistonBreakable = true; - ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true; - ms_Info[E_BLOCK_LADDER ].m_PistonBreakable = true; - ms_Info[E_BLOCK_LAVA ].m_PistonBreakable = true; - ms_Info[E_BLOCK_LEVER ].m_PistonBreakable = true; - ms_Info[E_BLOCK_MELON ].m_PistonBreakable = true; - ms_Info[E_BLOCK_MELON_STEM ].m_PistonBreakable = true; - ms_Info[E_BLOCK_PUMPKIN ].m_PistonBreakable = true; - ms_Info[E_BLOCK_PUMPKIN_STEM ].m_PistonBreakable = true; - ms_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_PistonBreakable = true; - ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_PistonBreakable = true; - ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_PistonBreakable = true; - ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_PistonBreakable = true; - ms_Info[E_BLOCK_REDSTONE_WIRE ].m_PistonBreakable = true; - ms_Info[E_BLOCK_RED_MUSHROOM ].m_PistonBreakable = true; - ms_Info[E_BLOCK_REEDS ].m_PistonBreakable = true; - ms_Info[E_BLOCK_SNOW ].m_PistonBreakable = true; - ms_Info[E_BLOCK_STATIONARY_LAVA ].m_PistonBreakable = true; - ms_Info[E_BLOCK_STATIONARY_WATER ].m_PistonBreakable = true; - ms_Info[E_BLOCK_STONE_BUTTON ].m_PistonBreakable = true; - ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_PistonBreakable = true; - ms_Info[E_BLOCK_TALL_GRASS ].m_PistonBreakable = true; - ms_Info[E_BLOCK_TORCH ].m_PistonBreakable = true; - ms_Info[E_BLOCK_VINES ].m_PistonBreakable = true; - ms_Info[E_BLOCK_WATER ].m_PistonBreakable = true; - ms_Info[E_BLOCK_WOODEN_BUTTON ].m_PistonBreakable = true; - ms_Info[E_BLOCK_WOODEN_DOOR ].m_PistonBreakable = true; - ms_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_PistonBreakable = true; + a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_PistonBreakable = true; + a_Info[E_BLOCK_AIR ].m_PistonBreakable = true; + a_Info[E_BLOCK_BED ].m_PistonBreakable = true; + a_Info[E_BLOCK_BIG_FLOWER ].m_PistonBreakable = true; + a_Info[E_BLOCK_BROWN_MUSHROOM ].m_PistonBreakable = true; + a_Info[E_BLOCK_CAKE ].m_PistonBreakable = true; + a_Info[E_BLOCK_COBWEB ].m_PistonBreakable = true; + a_Info[E_BLOCK_CROPS ].m_PistonBreakable = true; + a_Info[E_BLOCK_DANDELION ].m_PistonBreakable = true; + a_Info[E_BLOCK_DEAD_BUSH ].m_PistonBreakable = true; + a_Info[E_BLOCK_FIRE ].m_PistonBreakable = true; + a_Info[E_BLOCK_FLOWER ].m_PistonBreakable = true; + a_Info[E_BLOCK_HEAD ].m_PistonBreakable = true; + a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true; + a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_PistonBreakable = true; + a_Info[E_BLOCK_IRON_DOOR ].m_PistonBreakable = true; + a_Info[E_BLOCK_JACK_O_LANTERN ].m_PistonBreakable = true; + a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true; + a_Info[E_BLOCK_LADDER ].m_PistonBreakable = true; + a_Info[E_BLOCK_LAVA ].m_PistonBreakable = true; + a_Info[E_BLOCK_LEVER ].m_PistonBreakable = true; + a_Info[E_BLOCK_MELON ].m_PistonBreakable = true; + a_Info[E_BLOCK_MELON_STEM ].m_PistonBreakable = true; + a_Info[E_BLOCK_PUMPKIN ].m_PistonBreakable = true; + a_Info[E_BLOCK_PUMPKIN_STEM ].m_PistonBreakable = true; + a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_PistonBreakable = true; + a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_PistonBreakable = true; + a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_PistonBreakable = true; + a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_PistonBreakable = true; + a_Info[E_BLOCK_REDSTONE_WIRE ].m_PistonBreakable = true; + a_Info[E_BLOCK_RED_MUSHROOM ].m_PistonBreakable = true; + a_Info[E_BLOCK_REEDS ].m_PistonBreakable = true; + a_Info[E_BLOCK_SNOW ].m_PistonBreakable = true; + a_Info[E_BLOCK_STATIONARY_LAVA ].m_PistonBreakable = true; + a_Info[E_BLOCK_STATIONARY_WATER ].m_PistonBreakable = true; + a_Info[E_BLOCK_STONE_BUTTON ].m_PistonBreakable = true; + a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_PistonBreakable = true; + a_Info[E_BLOCK_TALL_GRASS ].m_PistonBreakable = true; + a_Info[E_BLOCK_TORCH ].m_PistonBreakable = true; + a_Info[E_BLOCK_VINES ].m_PistonBreakable = true; + a_Info[E_BLOCK_WATER ].m_PistonBreakable = true; + a_Info[E_BLOCK_WOODEN_BUTTON ].m_PistonBreakable = true; + a_Info[E_BLOCK_WOODEN_DOOR ].m_PistonBreakable = true; + a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_PistonBreakable = true; // Blocks that cannot be snowed over: - ms_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_IsSnowable = false; - ms_Info[E_BLOCK_AIR ].m_IsSnowable = false; - ms_Info[E_BLOCK_BIG_FLOWER ].m_IsSnowable = false; - ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSnowable = false; - ms_Info[E_BLOCK_CACTUS ].m_IsSnowable = false; - ms_Info[E_BLOCK_CHEST ].m_IsSnowable = false; - ms_Info[E_BLOCK_CROPS ].m_IsSnowable = false; - ms_Info[E_BLOCK_COBBLESTONE_WALL ].m_IsSnowable = false; - ms_Info[E_BLOCK_DANDELION ].m_IsSnowable = false; - ms_Info[E_BLOCK_FIRE ].m_IsSnowable = false; - ms_Info[E_BLOCK_FLOWER ].m_IsSnowable = false; - ms_Info[E_BLOCK_GLASS ].m_IsSnowable = false; - ms_Info[E_BLOCK_ICE ].m_IsSnowable = false; - ms_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_IsSnowable = false; - ms_Info[E_BLOCK_LAVA ].m_IsSnowable = false; - ms_Info[E_BLOCK_LILY_PAD ].m_IsSnowable = false; - ms_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_IsSnowable = false; - ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_IsSnowable = false; - ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSnowable = false; - ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSnowable = false; - ms_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSnowable = false; - ms_Info[E_BLOCK_RED_MUSHROOM ].m_IsSnowable = false; - ms_Info[E_BLOCK_REEDS ].m_IsSnowable = false; - ms_Info[E_BLOCK_SAPLING ].m_IsSnowable = false; - ms_Info[E_BLOCK_SIGN_POST ].m_IsSnowable = false; - ms_Info[E_BLOCK_SNOW ].m_IsSnowable = false; - ms_Info[E_BLOCK_STAINED_GLASS ].m_IsSnowable = false; - ms_Info[E_BLOCK_STAINED_GLASS_PANE ].m_IsSnowable = false; - ms_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSnowable = false; - ms_Info[E_BLOCK_STATIONARY_WATER ].m_IsSnowable = false; - ms_Info[E_BLOCK_TALL_GRASS ].m_IsSnowable = false; - ms_Info[E_BLOCK_TNT ].m_IsSnowable = false; - ms_Info[E_BLOCK_TORCH ].m_IsSnowable = false; - ms_Info[E_BLOCK_VINES ].m_IsSnowable = false; - ms_Info[E_BLOCK_WALLSIGN ].m_IsSnowable = false; - ms_Info[E_BLOCK_WATER ].m_IsSnowable = false; - ms_Info[E_BLOCK_RAIL ].m_IsSnowable = false; - ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSnowable = false; - ms_Info[E_BLOCK_POWERED_RAIL ].m_IsSnowable = false; - ms_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSnowable = false; - ms_Info[E_BLOCK_COBWEB ].m_IsSnowable = false; - ms_Info[E_BLOCK_HEAD ].m_IsSnowable = false; + a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_IsSnowable = false; + a_Info[E_BLOCK_AIR ].m_IsSnowable = false; + a_Info[E_BLOCK_BIG_FLOWER ].m_IsSnowable = false; + a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSnowable = false; + a_Info[E_BLOCK_CACTUS ].m_IsSnowable = false; + a_Info[E_BLOCK_CHEST ].m_IsSnowable = false; + a_Info[E_BLOCK_CROPS ].m_IsSnowable = false; + a_Info[E_BLOCK_COBBLESTONE_WALL ].m_IsSnowable = false; + a_Info[E_BLOCK_DANDELION ].m_IsSnowable = false; + a_Info[E_BLOCK_FIRE ].m_IsSnowable = false; + a_Info[E_BLOCK_FLOWER ].m_IsSnowable = false; + a_Info[E_BLOCK_GLASS ].m_IsSnowable = false; + a_Info[E_BLOCK_ICE ].m_IsSnowable = false; + a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_IsSnowable = false; + a_Info[E_BLOCK_LAVA ].m_IsSnowable = false; + a_Info[E_BLOCK_LILY_PAD ].m_IsSnowable = false; + a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_IsSnowable = false; + a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_IsSnowable = false; + a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSnowable = false; + a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSnowable = false; + a_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSnowable = false; + a_Info[E_BLOCK_RED_MUSHROOM ].m_IsSnowable = false; + a_Info[E_BLOCK_REEDS ].m_IsSnowable = false; + a_Info[E_BLOCK_SAPLING ].m_IsSnowable = false; + a_Info[E_BLOCK_SIGN_POST ].m_IsSnowable = false; + a_Info[E_BLOCK_SNOW ].m_IsSnowable = false; + a_Info[E_BLOCK_STAINED_GLASS ].m_IsSnowable = false; + a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_IsSnowable = false; + a_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSnowable = false; + a_Info[E_BLOCK_STATIONARY_WATER ].m_IsSnowable = false; + a_Info[E_BLOCK_TALL_GRASS ].m_IsSnowable = false; + a_Info[E_BLOCK_TNT ].m_IsSnowable = false; + a_Info[E_BLOCK_TORCH ].m_IsSnowable = false; + a_Info[E_BLOCK_VINES ].m_IsSnowable = false; + a_Info[E_BLOCK_WALLSIGN ].m_IsSnowable = false; + a_Info[E_BLOCK_WATER ].m_IsSnowable = false; + a_Info[E_BLOCK_RAIL ].m_IsSnowable = false; + a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSnowable = false; + a_Info[E_BLOCK_POWERED_RAIL ].m_IsSnowable = false; + a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSnowable = false; + a_Info[E_BLOCK_COBWEB ].m_IsSnowable = false; + a_Info[E_BLOCK_HEAD ].m_IsSnowable = false; // Blocks that don't drop without a special tool: - ms_Info[E_BLOCK_BRICK ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_CAULDRON ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_COAL_ORE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_COBBLESTONE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_COBBLESTONE_WALL ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_COBWEB ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_DIAMOND_BLOCK ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_DIAMOND_ORE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_EMERALD_ORE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_END_STONE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_GOLD_BLOCK ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_GOLD_ORE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_IRON_BLOCK ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_IRON_ORE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_LAPIS_BLOCK ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_LAPIS_ORE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_NETHERRACK ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_NETHER_BRICK ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_OBSIDIAN ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_REDSTONE_ORE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_SANDSTONE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_SANDSTONE_STAIRS ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_SNOW ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_STONE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_STONE_BRICKS ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_STONE_SLAB ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_VINES ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_FURNACE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_LIT_FURNACE ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_ANVIL ].m_RequiresSpecialTool = true; - ms_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_BRICK ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_CAULDRON ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_COAL_ORE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_COBBLESTONE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_COBBLESTONE_WALL ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_COBWEB ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_DIAMOND_BLOCK ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_DIAMOND_ORE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_EMERALD_ORE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_END_STONE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_GOLD_BLOCK ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_GOLD_ORE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_IRON_BLOCK ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_IRON_ORE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_LAPIS_BLOCK ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_LAPIS_ORE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_NETHERRACK ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_NETHER_BRICK ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_OBSIDIAN ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_REDSTONE_ORE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_SANDSTONE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_SANDSTONE_STAIRS ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_SNOW ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_STONE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_STONE_BRICKS ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_STONE_SLAB ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_VINES ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_FURNACE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_LIT_FURNACE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_ANVIL ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_RequiresSpecialTool = true; // Nonsolid blocks: - ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false; - ms_Info[E_BLOCK_AIR ].m_IsSolid = false; - ms_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false; - ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false; - ms_Info[E_BLOCK_CAKE ].m_IsSolid = false; - ms_Info[E_BLOCK_CARROTS ].m_IsSolid = false; - ms_Info[E_BLOCK_COBWEB ].m_IsSolid = false; - ms_Info[E_BLOCK_CROPS ].m_IsSolid = false; - ms_Info[E_BLOCK_DANDELION ].m_IsSolid = false; - ms_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false; - ms_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false; - ms_Info[E_BLOCK_FENCE ].m_IsSolid = false; - ms_Info[E_BLOCK_FENCE_GATE ].m_IsSolid = false; - ms_Info[E_BLOCK_FIRE ].m_IsSolid = false; - ms_Info[E_BLOCK_FLOWER ].m_IsSolid = false; - ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false; - ms_Info[E_BLOCK_LAVA ].m_IsSolid = false; - ms_Info[E_BLOCK_LEVER ].m_IsSolid = false; - ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false; - ms_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false; - ms_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false; - ms_Info[E_BLOCK_PISTON_EXTENSION ].m_IsSolid = false; - ms_Info[E_BLOCK_POTATOES ].m_IsSolid = false; - ms_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false; - ms_Info[E_BLOCK_RAIL ].m_IsSolid = false; - ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSolid = false; - ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSolid = false; - ms_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSolid = false; - ms_Info[E_BLOCK_RED_MUSHROOM ].m_IsSolid = false; - ms_Info[E_BLOCK_REEDS ].m_IsSolid = false; - ms_Info[E_BLOCK_SAPLING ].m_IsSolid = false; - ms_Info[E_BLOCK_SIGN_POST ].m_IsSolid = false; - ms_Info[E_BLOCK_SNOW ].m_IsSolid = false; - ms_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSolid = false; - ms_Info[E_BLOCK_STATIONARY_WATER ].m_IsSolid = false; - ms_Info[E_BLOCK_STONE_BUTTON ].m_IsSolid = false; - ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_IsSolid = false; - ms_Info[E_BLOCK_TALL_GRASS ].m_IsSolid = false; - ms_Info[E_BLOCK_TORCH ].m_IsSolid = false; - ms_Info[E_BLOCK_TRIPWIRE ].m_IsSolid = false; - ms_Info[E_BLOCK_VINES ].m_IsSolid = false; - ms_Info[E_BLOCK_WALLSIGN ].m_IsSolid = false; - ms_Info[E_BLOCK_WATER ].m_IsSolid = false; - ms_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false; - ms_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false; - ms_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false; + a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false; + a_Info[E_BLOCK_AIR ].m_IsSolid = false; + a_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false; + a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false; + a_Info[E_BLOCK_CAKE ].m_IsSolid = false; + a_Info[E_BLOCK_CARROTS ].m_IsSolid = false; + a_Info[E_BLOCK_COBWEB ].m_IsSolid = false; + a_Info[E_BLOCK_CROPS ].m_IsSolid = false; + a_Info[E_BLOCK_DANDELION ].m_IsSolid = false; + a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false; + a_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false; + a_Info[E_BLOCK_FENCE ].m_IsSolid = false; + a_Info[E_BLOCK_FENCE_GATE ].m_IsSolid = false; + a_Info[E_BLOCK_FIRE ].m_IsSolid = false; + a_Info[E_BLOCK_FLOWER ].m_IsSolid = false; + a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false; + a_Info[E_BLOCK_LAVA ].m_IsSolid = false; + a_Info[E_BLOCK_LEVER ].m_IsSolid = false; + a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false; + a_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false; + a_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false; + a_Info[E_BLOCK_PISTON_EXTENSION ].m_IsSolid = false; + a_Info[E_BLOCK_POTATOES ].m_IsSolid = false; + a_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false; + a_Info[E_BLOCK_RAIL ].m_IsSolid = false; + a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSolid = false; + a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSolid = false; + a_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSolid = false; + a_Info[E_BLOCK_RED_MUSHROOM ].m_IsSolid = false; + a_Info[E_BLOCK_REEDS ].m_IsSolid = false; + a_Info[E_BLOCK_SAPLING ].m_IsSolid = false; + a_Info[E_BLOCK_SIGN_POST ].m_IsSolid = false; + a_Info[E_BLOCK_SNOW ].m_IsSolid = false; + a_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSolid = false; + a_Info[E_BLOCK_STATIONARY_WATER ].m_IsSolid = false; + a_Info[E_BLOCK_STONE_BUTTON ].m_IsSolid = false; + a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_IsSolid = false; + a_Info[E_BLOCK_TALL_GRASS ].m_IsSolid = false; + a_Info[E_BLOCK_TORCH ].m_IsSolid = false; + a_Info[E_BLOCK_TRIPWIRE ].m_IsSolid = false; + a_Info[E_BLOCK_VINES ].m_IsSolid = false; + a_Info[E_BLOCK_WALLSIGN ].m_IsSolid = false; + a_Info[E_BLOCK_WATER ].m_IsSolid = false; + a_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false; + a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false; + a_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false; // Blocks that fully occupy their voxel - used as a guide for torch placeable blocks, amongst other things: - ms_Info[E_BLOCK_NEW_LOG ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_BEDROCK ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_BLOCK_OF_COAL ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_BLOCK_OF_REDSTONE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_BOOKCASE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_BRICK ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_CLAY ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_COAL_ORE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_COBBLESTONE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_COMMAND_BLOCK ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_CRAFTING_TABLE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_DIAMOND_BLOCK ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_DIAMOND_ORE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_DIRT ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_DISPENSER ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_DROPPER ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_EMERALD_BLOCK ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_EMERALD_ORE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_END_STONE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_FURNACE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_GLOWSTONE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_GOLD_BLOCK ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_GOLD_ORE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_GRASS ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_GRAVEL ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_HARDENED_CLAY ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_HAY_BALE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_HUGE_BROWN_MUSHROOM ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_HUGE_RED_MUSHROOM ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_ICE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_IRON_BLOCK ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_IRON_ORE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_JACK_O_LANTERN ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_JUKEBOX ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_LAPIS_BLOCK ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_LAPIS_ORE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_LOG ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_MELON ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_MYCELIUM ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_NETHERRACK ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_NETHER_BRICK ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_NETHER_QUARTZ_ORE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_NOTE_BLOCK ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_OBSIDIAN ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_PACKED_ICE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_PLANKS ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_PUMPKIN ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_QUARTZ_BLOCK ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_REDSTONE_LAMP_OFF ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_REDSTONE_ORE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_SANDSTONE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_SAND ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_SILVERFISH_EGG ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_SPONGE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_STAINED_CLAY ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_WOOL ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_STONE ].m_FullyOccupiesVoxel = true; - ms_Info[E_BLOCK_STONE_BRICKS ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_NEW_LOG ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_BEDROCK ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_BLOCK_OF_COAL ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_BLOCK_OF_REDSTONE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_BOOKCASE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_BRICK ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_CLAY ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_COAL_ORE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_COBBLESTONE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_COMMAND_BLOCK ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_CRAFTING_TABLE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_DIAMOND_BLOCK ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_DIAMOND_ORE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_DIRT ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_DISPENSER ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_DROPPER ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_EMERALD_BLOCK ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_EMERALD_ORE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_END_STONE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_FURNACE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_GLOWSTONE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_GOLD_BLOCK ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_GOLD_ORE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_GRASS ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_GRAVEL ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_HARDENED_CLAY ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_HAY_BALE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_HUGE_BROWN_MUSHROOM ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_HUGE_RED_MUSHROOM ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_ICE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_IRON_BLOCK ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_IRON_ORE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_JACK_O_LANTERN ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_JUKEBOX ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_LAPIS_BLOCK ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_LAPIS_ORE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_LOG ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_MELON ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_MYCELIUM ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_NETHERRACK ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_NETHER_BRICK ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_NETHER_QUARTZ_ORE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_NOTE_BLOCK ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_OBSIDIAN ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_PACKED_ICE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_PLANKS ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_PUMPKIN ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_QUARTZ_BLOCK ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_REDSTONE_LAMP_OFF ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_REDSTONE_ORE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_SANDSTONE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_SAND ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_SILVERFISH_EGG ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_SPONGE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_STAINED_CLAY ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_WOOL ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_STONE ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_STONE_BRICKS ].m_FullyOccupiesVoxel = true; } diff --git a/src/BlockInfo.h b/src/BlockInfo.h index 40c1db867..d6d4e7430 100644 --- a/src/BlockInfo.h +++ b/src/BlockInfo.h @@ -16,18 +16,8 @@ class cBlockHandler; class cBlockInfo { public: - // tolua_end - - cBlockInfo(); - - ~cBlockInfo(); - - /** (Re-)Initializes the internal BlockInfo structures. */ - static void Initialize(void); - // tolua_begin - - /** Returns the associated BlockInfo structure. */ + /** Returns the associated BlockInfo structure for the specified block type. */ static cBlockInfo & Get(BLOCKTYPE a_Type); @@ -79,13 +69,18 @@ public: inline static cBlockHandler * GetHandler (BLOCKTYPE a_Type) { return Get(a_Type).m_Handler; } - protected: + /** Storage for all the BlockInfo structures. */ + typedef cBlockInfo cBlockInfoArray[256]; - // TODO xdot: Change to std::vector to support dynamic block IDs - static cBlockInfo ms_Info[256]; + /** Creates a default BlockInfo structure, initializes all values to their defaults */ + cBlockInfo(); + /** Cleans up the stored values */ + ~cBlockInfo(); + /** Initializes the specified BlockInfo structures with block-specific values. */ + static void Initialize(cBlockInfoArray & a_BlockInfos); }; // tolua_export -- cgit v1.2.3 From f96955496f4e53105b045fb7f3fa7d34ed82b147 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 26 Jun 2014 15:56:03 +0200 Subject: GameMode check --- src/Entities/ArrowEntity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index e46d21515..6d74b387a 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -134,7 +134,7 @@ void cArrowEntity::CollectedBy(cPlayer * a_Dest) { if (m_IsInGround && !m_bIsCollected && CanPickup(*a_Dest)) { - if (m_PickupState == psInSurvivalOrCreative) + if (!a_Dest->IsGameModeCreative()) { int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW); if (NumAdded == 0) -- cgit v1.2.3 From cba273dc7e381c00b214fa0806679170f4e4e2f3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 26 Jun 2014 17:20:48 +0200 Subject: Fixed a comment and changed CombineCount to short. --- src/Entities/Pickup.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index 44a65412f..969461a6a 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -41,7 +41,7 @@ public: cItem & Item = ((cPickup *)a_Entity)->GetItem(); if ((Distance < 1.2) && Item.IsEqual(m_Pickup->GetItem())) { - char CombineCount = Item.m_ItemCount; + short CombineCount = Item.m_ItemCount; if ((CombineCount + m_Pickup->GetItem().m_ItemCount) > Item.GetMaxStackSize()) { CombineCount = Item.GetMaxStackSize() - m_Pickup->GetItem().m_ItemCount; @@ -150,7 +150,7 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk) } } - if (!IsDestroyed() && (m_Item.m_ItemCount < m_Item.GetMaxStackSize())) // Don't try to combine if someone has tried to combine me + if (!IsDestroyed() && (m_Item.m_ItemCount < m_Item.GetMaxStackSize())) // Don't combine into an already full pickup { cPickupCombiningCallback PickupCombiningCallback(GetPosition(), this); m_World->ForEachEntity(PickupCombiningCallback); // Not ForEachEntityInChunk, otherwise pickups don't combine across chunk boundaries -- cgit v1.2.3 From bf3229867bc6a7d531fcb43c6519a951b043a732 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 26 Jun 2014 17:26:47 +0200 Subject: Add comment. --- src/Entities/ArrowEntity.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 6d74b387a..712ae3879 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -134,6 +134,7 @@ void cArrowEntity::CollectedBy(cPlayer * a_Dest) { if (m_IsInGround && !m_bIsCollected && CanPickup(*a_Dest)) { + // The arrow won't added to the inventory, when the player is creative if (!a_Dest->IsGameModeCreative()) { int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW); -- cgit v1.2.3 From b90b0a1dffff366df639f49445afb43ae1a8a73c Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 26 Jun 2014 17:51:19 +0200 Subject: FurnaceRecipe parser: Added an else branch, changed to a switch. --- src/FurnaceRecipe.cpp | 114 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 69 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index 92b52c6e8..f8949d45f 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -68,64 +68,88 @@ void cFurnaceRecipe::ReloadRecipes(void) while (std::getline(f, ParsingLine)) { Line++; - ParsingLine.erase(std::remove_if(ParsingLine.begin(), ParsingLine.end(), isspace), ParsingLine.end()); // Remove whitespace + TrimString(ParsingLine); if (ParsingLine.empty()) { continue; } - // Comments - if (ParsingLine[0] == '#') + switch (ParsingLine[0]) { - continue; - } - - if (ParsingLine[0] == '!') // Fuels start with a bang :) - { - int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0; - AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang) - - if ( - !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID - !ReadOptionalNumbers(BeginPos, ":", "=", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health) - !ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, Line, IBurnTime, true) // Read item burn time - last value - ) + case '#': { - return; + // Comment + break; } - // Add to fuel list - Fuel F; - F.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth); - F.BurnTime = IBurnTime; - m_pState->Fuel.push_back(F); - continue; - } - else if (isdigit(ParsingLine[0])) // Recipes start with a numeral :) - { - int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0; - int OItemID = 0, OItemCount = 0, OItemHealth = 0; - AString::size_type BeginPos = 0; // Begin at start of line - - if ( - !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID - !ReadOptionalNumbers(BeginPos, ":", "@", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health) - !ReadMandatoryNumber(BeginPos, "=", ParsingLine, Line, IBurnTime) || // Read item burn time - !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, OItemID) || // Read result ID - !ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value + case '!': + { + // Fuel + int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0; + AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang) + + if ( + !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID + !ReadOptionalNumbers(BeginPos, ":", "=", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health) + !ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, Line, IBurnTime, true) // Read item burn time - last value ) + { + return; + } + + // Add to fuel list: + Fuel F; + F.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth); + F.BurnTime = IBurnTime; + m_pState->Fuel.push_back(F); + break; + } + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': { - return; + // Recipe + int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0; + int OItemID = 0, OItemCount = 0, OItemHealth = 0; + AString::size_type BeginPos = 0; // Begin at start of line + + if ( + !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID + !ReadOptionalNumbers(BeginPos, ":", "@", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health) + !ReadMandatoryNumber(BeginPos, "=", ParsingLine, Line, IBurnTime) || // Read item burn time + !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, OItemID) || // Read result ID + !ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value + ) + { + return; + } + + // Add to recipe list + Recipe R; + R.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth); + R.Out = new cItem((ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth); + R.CookTime = IBurnTime; + m_pState->Recipes.push_back(R); + break; } - // Add to recipe list - Recipe R; - R.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth); - R.Out = new cItem((ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth); - R.CookTime = IBurnTime; - m_pState->Recipes.push_back(R); - } - } + default: + { + LOGWARNING("Error in furnace recipes at line %d: Unexpected text: \"%s\". Ignoring line.", + Line, ParsingLine.c_str() + ); + break; + } + } // switch (ParsingLine[0]) + } // while (getline(ParsingLine)) LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size()); } -- cgit v1.2.3 From 67e3c645d3a648ebd4d797019a993ed9c27cdb5e Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 26 Jun 2014 17:52:37 +0200 Subject: FurnaceRecipe parser: Made the parser more forgiving. Errors don't cause a stop in the parsing, but rather just skip the offending line. --- src/FurnaceRecipe.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index f8949d45f..eff09a8d3 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -94,7 +94,7 @@ void cFurnaceRecipe::ReloadRecipes(void) !ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, Line, IBurnTime, true) // Read item burn time - last value ) { - return; + break; } // Add to fuel list: @@ -129,7 +129,7 @@ void cFurnaceRecipe::ReloadRecipes(void) !ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value ) { - return; + break; } // Add to recipe list -- cgit v1.2.3 From 55bbdfa5d44a4bf7e66aa256ceba9ded3d2682dd Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 26 Jun 2014 18:18:41 +0200 Subject: FurnaceRecipe: Moved the parsing into separate functions for clarity. --- src/FurnaceRecipe.cpp | 120 +++++++++++++++++++++++++------------------------- src/FurnaceRecipe.h | 8 ++++ 2 files changed, 68 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index eff09a8d3..cc4098607 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -58,16 +58,16 @@ void cFurnaceRecipe::ReloadRecipes(void) std::ifstream f(FURNACE_RECIPE_FILE, std::ios::in); if (!f.good()) { - LOG("Could not open the furnace recipes file \"%s\"", FURNACE_RECIPE_FILE); + LOG("Could not open the furnace recipes file \"%s\". No furnace recipes are available.", FURNACE_RECIPE_FILE); return; } - unsigned int Line = 0; + unsigned int LineNum = 0; AString ParsingLine; while (std::getline(f, ParsingLine)) { - Line++; + LineNum++; TrimString(ParsingLine); if (ParsingLine.empty()) { @@ -84,68 +84,13 @@ void cFurnaceRecipe::ReloadRecipes(void) case '!': { - // Fuel - int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0; - AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang) - - if ( - !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID - !ReadOptionalNumbers(BeginPos, ":", "=", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health) - !ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, Line, IBurnTime, true) // Read item burn time - last value - ) - { - break; - } - - // Add to fuel list: - Fuel F; - F.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth); - F.BurnTime = IBurnTime; - m_pState->Fuel.push_back(F); - break; - } - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - // Recipe - int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0; - int OItemID = 0, OItemCount = 0, OItemHealth = 0; - AString::size_type BeginPos = 0; // Begin at start of line - - if ( - !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID - !ReadOptionalNumbers(BeginPos, ":", "@", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health) - !ReadMandatoryNumber(BeginPos, "=", ParsingLine, Line, IBurnTime) || // Read item burn time - !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, OItemID) || // Read result ID - !ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value - ) - { - break; - } - - // Add to recipe list - Recipe R; - R.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth); - R.Out = new cItem((ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth); - R.CookTime = IBurnTime; - m_pState->Recipes.push_back(R); + AddFuelFromLine(ParsingLine, LineNum); break; } default: { - LOGWARNING("Error in furnace recipes at line %d: Unexpected text: \"%s\". Ignoring line.", - Line, ParsingLine.c_str() - ); + AddRecipeFromLine(ParsingLine, LineNum); break; } } // switch (ParsingLine[0]) @@ -158,6 +103,61 @@ void cFurnaceRecipe::ReloadRecipes(void) +void cFurnaceRecipe::AddFuelFromLine(const AString & a_Line, int a_LineNum) +{ + // Fuel + int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0; + AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang) + + if ( + !ReadMandatoryNumber(BeginPos, ":", a_Line, a_LineNum, IItemID) || // Read item ID + !ReadOptionalNumbers(BeginPos, ":", "=", a_Line, a_LineNum, IItemCount, IItemHealth) || // Read item count (and optionally health) + !ReadMandatoryNumber(BeginPos, "0123456789", a_Line, a_LineNum, IBurnTime, true) // Read item burn time - last value + ) + { + return; + } + + // Add to fuel list: + Fuel F; + F.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth); + F.BurnTime = IBurnTime; + m_pState->Fuel.push_back(F); +} + + + + + +void cFurnaceRecipe::AddRecipeFromLine(const AString & a_Line, int a_LineNum) +{ + int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0; + int OItemID = 0, OItemCount = 0, OItemHealth = 0; + AString::size_type BeginPos = 0; // Begin at start of line + + if ( + !ReadMandatoryNumber(BeginPos, ":", a_Line, a_LineNum, IItemID) || // Read item ID + !ReadOptionalNumbers(BeginPos, ":", "@", a_Line, a_LineNum, IItemCount, IItemHealth) || // Read item count (and optionally health) + !ReadMandatoryNumber(BeginPos, "=", a_Line, a_LineNum, IBurnTime) || // Read item burn time + !ReadMandatoryNumber(BeginPos, ":", a_Line, a_LineNum, OItemID) || // Read result ID + !ReadOptionalNumbers(BeginPos, ":", "012456789", a_Line, a_LineNum, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value + ) + { + return; + } + + // Add to recipe list + Recipe R; + R.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth); + R.Out = new cItem((ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth); + R.CookTime = IBurnTime; + m_pState->Recipes.push_back(R); +} + + + + + void cFurnaceRecipe::PrintParseError(unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing) { LOGWARN("Error parsing furnace recipes at line %i pos " SIZE_T_FMT ": missing '%s'", a_Line, a_Position, a_CharactersMissing.c_str()); diff --git a/src/FurnaceRecipe.h b/src/FurnaceRecipe.h index ab78b6051..77ed35a57 100644 --- a/src/FurnaceRecipe.h +++ b/src/FurnaceRecipe.h @@ -41,6 +41,14 @@ public: private: void ClearRecipes(void); + /** Parses the fuel contained in the line, adds it to m_pState's fuels. + Logs a warning to the console on input error. */ + void AddFuelFromLine(const AString & a_Line, int a_LineNum); + + /** Parses the recipe contained in the line, adds it to m_pState's recipes. + Logs a warning to the console on input error. */ + void AddRecipeFromLine(const AString & a_Line, int a_LineNum); + /** Calls LOGWARN with the line, position, and error */ static void PrintParseError(unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing); -- cgit v1.2.3 From ec1015112c969798bae3efe87998c17d130b271a Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 26 Jun 2014 18:20:12 +0200 Subject: Fixed misformed trimming. --- src/FurnaceRecipe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index cc4098607..412402cbc 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -68,7 +68,7 @@ void cFurnaceRecipe::ReloadRecipes(void) while (std::getline(f, ParsingLine)) { LineNum++; - TrimString(ParsingLine); + ParsingLine = TrimString(ParsingLine); if (ParsingLine.empty()) { continue; -- cgit v1.2.3 From 0df644c9f7775862c6c359b238e3440536092e04 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 26 Jun 2014 18:28:10 +0200 Subject: FurnaceRecipe parsing: Fixed whitespace removing. --- src/FurnaceRecipe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index 412402cbc..8add9610c 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -68,7 +68,7 @@ void cFurnaceRecipe::ReloadRecipes(void) while (std::getline(f, ParsingLine)) { LineNum++; - ParsingLine = TrimString(ParsingLine); + ParsingLine.erase(std::remove_if(ParsingLine.begin(), ParsingLine.end(), isspace), ParsingLine.end()); // Remove ALL whitespace from the line if (ParsingLine.empty()) { continue; -- cgit v1.2.3 From b832a202ab052b0544ca26225c4fe771cf31ede7 Mon Sep 17 00:00:00 2001 From: worktycho Date: Thu, 26 Jun 2014 18:30:02 +0100 Subject: Add Null check to SendBlockTo Fixes CID 43611 --- src/ChunkMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index d2ccca94e..f0222c0f5 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1530,7 +1530,7 @@ void cChunkMap::SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player) cCSLock Lock(m_CSLayers); cChunkPtr Chunk = GetChunk(ChunkX, ZERO_CHUNK_Y, ChunkZ); - if (Chunk->IsValid()) + if (Chunk != NULL && Chunk->IsValid()) { Chunk->SendBlockTo(a_X, a_Y, a_Z, a_Player->GetClientHandle()); } -- cgit v1.2.3 From 25a0264cc46d97f52bd836280fa5d2908846ac02 Mon Sep 17 00:00:00 2001 From: worktycho Date: Thu, 26 Jun 2014 19:04:56 +0100 Subject: Check GridSize for 0 Fixes CID 68226 and CID 66437 --- src/Generating/GridStructGen.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp index 95f8c38bc..a3578de6f 100644 --- a/src/Generating/GridStructGen.cpp +++ b/src/Generating/GridStructGen.cpp @@ -53,6 +53,16 @@ cGridStructGen::cGridStructGen( m_MaxStructureSizeZ(a_MaxStructureSizeZ), m_MaxCacheSize(a_MaxCacheSize) { + if (m_GridSizeX == 0) + { + LOG("Grid Size cannot be zero, setting to 1"); + m_GridSizeX = 1; + } + if (m_GridSizeZ == 0) + { + LOG("Grid Size cannot be zero, setting to 1"); + m_GridSizeZ = 1; + } size_t NumStructuresPerQuery = (size_t)(((m_MaxStructureSizeX + m_MaxOffsetX) / m_GridSizeX + 1) * ((m_MaxStructureSizeZ + m_MaxOffsetZ) / m_GridSizeZ + 1)); if (NumStructuresPerQuery > m_MaxCacheSize) { -- cgit v1.2.3 From 563f706422554d1d8ff1121b9613ab9d34951a3b Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 27 Jun 2014 19:34:53 +0200 Subject: Removed the md5 library, obsoleted by PolarSSL. Fixes #1130. --- src/Bindings/ManualBindings.cpp | 11 ++++++----- src/CMakeLists.txt | 2 +- src/ClientHandle.cpp | 22 +++++++++------------- 3 files changed, 16 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index f52d970bf..3692851eb 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -4,7 +4,7 @@ #include "ManualBindings.h" #undef TOLUA_TEMPLATE_BIND #include "tolua++/include/tolua++.h" - +#include "polarssl\md5.h" #include "Plugin.h" #include "PluginLua.h" #include "PluginManager.h" @@ -25,7 +25,6 @@ #include "../BlockEntities/NoteEntity.h" #include "../BlockEntities/MobHeadEntity.h" #include "../BlockEntities/FlowerPotEntity.h" -#include "md5/md5.h" #include "../LineBlockTracer.h" #include "../WorldStorage/SchematicFileSerializer.h" #include "../CompositeChat.h" @@ -2001,9 +2000,11 @@ static int tolua_cPlugin_Call(lua_State * tolua_S) static int tolua_md5(lua_State* tolua_S) { - std::string SourceString = tolua_tostring(tolua_S, 1, 0); - std::string CryptedString = md5( SourceString ); - tolua_pushstring( tolua_S, CryptedString.c_str() ); + unsigned char Output[16]; + size_t len = 0; + const unsigned char * SourceString = (const unsigned char *)lua_tolstring(tolua_S, 1, &len); + md5(SourceString, len, Output); + lua_pushlstring(tolua_S, (const char *)Output, ARRAYCOUNT(Output)); return 1; } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 335ce8315..deea92aec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -260,4 +260,4 @@ endif () if (WIN32) target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib) endif() -target_link_libraries(${EXECUTABLE} md5 luaexpat iniFile jsoncpp polarssl zlib lua sqlite) +target_link_libraries(${EXECUTABLE} luaexpat iniFile jsoncpp polarssl zlib lua sqlite) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 46083a8f1..611995148 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -30,7 +30,7 @@ #include "CompositeChat.h" #include "Items/ItemSword.h" -#include "md5/md5.h" +#include "polarssl/md5.h" @@ -239,18 +239,14 @@ AString cClientHandle::GenerateOfflineUUID(const AString & a_Username) // xxxxxxxx-xxxx-3xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B // Generate an md5 checksum, and use it as base for the ID: - MD5 Checksum(a_Username); - AString UUID = Checksum.hexdigest(); - UUID[12] = '3'; // Version 3 UUID - UUID[16] = '8'; // Variant 1 UUID - - // Now the digest doesn't have the UUID slashes, but the client requires them, so add them into the appropriate positions: - UUID.insert(8, "-"); - UUID.insert(13, "-"); - UUID.insert(18, "-"); - UUID.insert(23, "-"); - - return UUID; + unsigned char MD5[16]; + md5((const unsigned char *)a_Username.c_str(), a_Username.length(), MD5); + return Printf("%02x%02x%02x%02x-%02x%02x-3%01x%02x-8%01x%02x-%02x%02x%02x%02x%02x%02x", + MD5[0], MD5[1], MD5[2], MD5[3], + MD5[4], MD5[5], MD5[6], MD5[7], + MD5[8], MD5[9], MD5[10], MD5[11], + MD5[12], MD5[13], MD5[14], MD5[15] + ); } -- cgit v1.2.3 From d7bc5c5bd32f8b5560403ecf6631040891fe9b9e Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 27 Jun 2014 20:23:05 +0200 Subject: Added PolarSSL dependency to Bindings. --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index deea92aec..4b78181ee 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -134,7 +134,7 @@ if (NOT MSVC) Bindings/WebPlugin ) - target_link_libraries(Bindings lua sqlite tolualib) + target_link_libraries(Bindings lua sqlite tolualib polarssl) #clear file file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependecies.txt) -- cgit v1.2.3 From 9926abd4f55d668dec9e06c2ba23fa3bb9209eeb Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 27 Jun 2014 20:56:29 +0200 Subject: Added generic entity-collecting. Now any cEntity can be collected, not only cPickups. This should help PR #1098. --- src/Chunk.cpp | 4 ++-- src/Chunk.h | 2 +- src/ChunkMap.cpp | 6 +++--- src/ChunkMap.h | 1 + src/ClientHandle.cpp | 4 ++-- src/ClientHandle.h | 2 +- src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.cpp | 4 ++-- src/Protocol/Protocol125.h | 2 +- src/Protocol/Protocol132.cpp | 8 ++++---- src/Protocol/Protocol132.h | 2 +- src/Protocol/Protocol17x.cpp | 4 ++-- src/Protocol/Protocol17x.h | 2 +- src/Protocol/ProtocolRecognizer.cpp | 4 ++-- src/Protocol/ProtocolRecognizer.h | 2 +- src/World.cpp | 11 ++++++++++- src/World.h | 1 + 17 files changed, 36 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 1320d5ccd..0fee40cac 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -2701,7 +2701,7 @@ void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClie -void cChunk::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude) +void cChunk::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude) { for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) { @@ -2709,7 +2709,7 @@ void cChunk::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_ { continue; } - (*itr)->SendCollectPickup(a_Pickup, a_Player); + (*itr)->SendCollectEntity(a_Entity, a_Player); } // for itr - LoadedByClient[] } diff --git a/src/Chunk.h b/src/Chunk.h index 7664a7afd..e9d964e05 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -279,7 +279,7 @@ public: void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL); void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); void BroadcastChunkData (cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL); - void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL); + void BroadcastCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL); void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL); void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL); diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index d2ccca94e..c9fb0b59e 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -419,16 +419,16 @@ void cChunkMap::BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSeriali -void cChunkMap::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude) +void cChunkMap::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude) { cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunkNoGen(a_Pickup.GetChunkX(), ZERO_CHUNK_Y, a_Pickup.GetChunkZ()); + cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ()); if (Chunk == NULL) { return; } // It's perfectly legal to broadcast packets even to invalid chunks! - Chunk->BroadcastCollectPickup(a_Pickup, a_Player, a_Exclude); + Chunk->BroadcastCollectEntity(a_Entity, a_Player, a_Exclude); } diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 3ee0bab3c..433516490 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -70,6 +70,7 @@ public: void BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude = NULL); void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude); void BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL); + void BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL); void BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL); void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL); diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 46083a8f1..16cfe1aec 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -2077,9 +2077,9 @@ void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializ -void cClientHandle::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player) +void cClientHandle::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player) { - m_Protocol->SendCollectPickup(a_Pickup, a_Player); + m_Protocol->SendCollectEntity(a_Entity, a_Player); } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 3e18cbdad..02bc0c719 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -123,7 +123,7 @@ public: void SendChat (const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData = ""); void SendChat (const cCompositeChat & a_Message); void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer); - void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player); + void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player); void SendDestroyEntity (const cEntity & a_Entity); void SendDisconnect (const AString & a_Reason); void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ); diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index c6e569919..e08a5a51b 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -64,7 +64,7 @@ public: virtual void SendChat (const AString & a_Message) = 0; virtual void SendChat (const cCompositeChat & a_Message) = 0; virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) = 0; - virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) = 0; + virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) = 0; virtual void SendDestroyEntity (const cEntity & a_Entity) = 0; virtual void SendDisconnect (const AString & a_Reason) = 0; virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) = 0; ///< Request the client to open up the sign editor for the sign (1.6+) diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 491058919..d53427bf7 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -274,11 +274,11 @@ void cProtocol125::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize -void cProtocol125::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player) +void cProtocol125::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player) { cCSLock Lock(m_CSPacket); WriteByte(PACKET_COLLECT_PICKUP); - WriteInt (a_Pickup.GetUniqueID()); + WriteInt (a_Entity.GetUniqueID()); WriteInt (a_Player.GetUniqueID()); Flush(); } diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 85418f71f..747bf512d 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -36,7 +36,7 @@ public: virtual void SendChat (const AString & a_Message) override; virtual void SendChat (const cCompositeChat & a_Message) override; virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override; - virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override; + virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override; virtual void SendDestroyEntity (const cEntity & a_Entity) override; virtual void SendDisconnect (const AString & a_Reason) override; virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+) diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index 1e3fc8de8..31cf99f53 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -188,19 +188,19 @@ void cProtocol132::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize -void cProtocol132::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player) +void cProtocol132::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player) { cCSLock Lock(m_CSPacket); WriteByte(PACKET_COLLECT_PICKUP); - WriteInt (a_Pickup.GetUniqueID()); + WriteInt (a_Entity.GetUniqueID()); WriteInt (a_Player.GetUniqueID()); Flush(); // Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;) SendSoundEffect( "random.pop", - (int)(a_Pickup.GetPosX() * 8), (int)(a_Pickup.GetPosY() * 8), (int)(a_Pickup.GetPosZ() * 8), - 0.5, (float)(0.75 + ((float)((a_Pickup.GetUniqueID() * 23) % 32)) / 64) + (int)(a_Entity.GetPosX() * 8), (int)(a_Entity.GetPosY() * 8), (int)(a_Entity.GetPosZ() * 8), + 0.5, (float)(0.75 + ((float)((a_Entity.GetUniqueID() * 23) % 32)) / 64) ); } diff --git a/src/Protocol/Protocol132.h b/src/Protocol/Protocol132.h index 32bc7d581..e5d3ee80c 100644 --- a/src/Protocol/Protocol132.h +++ b/src/Protocol/Protocol132.h @@ -48,7 +48,7 @@ public: virtual void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) override; virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override; - virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override; + virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override; virtual void SendDestroyEntity (const cEntity & a_Entity) override; virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override; virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 02c577dc8..49fef0b8e 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -351,12 +351,12 @@ void cProtocol172::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize -void cProtocol172::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player) +void cProtocol172::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player) { ASSERT(m_State == 3); // In game mode? cPacketizer Pkt(*this, 0x0d); // Collect Item packet - Pkt.WriteInt(a_Pickup.GetUniqueID()); + Pkt.WriteInt(a_Entity.GetUniqueID()); Pkt.WriteInt(a_Player.GetUniqueID()); } diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 8be1d9211..07c8c8459 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -68,7 +68,7 @@ public: virtual void SendChat (const AString & a_Message) override; virtual void SendChat (const cCompositeChat & a_Message) override; virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override; - virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override; + virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override; virtual void SendDestroyEntity (const cEntity & a_Entity) override; virtual void SendDisconnect (const AString & a_Reason) override; virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+) diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 80f5da25a..2436c49c3 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -181,10 +181,10 @@ void cProtocolRecognizer::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSe -void cProtocolRecognizer::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player) +void cProtocolRecognizer::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player) { ASSERT(m_Protocol != NULL); - m_Protocol->SendCollectPickup(a_Pickup, a_Player); + m_Protocol->SendCollectEntity(a_Entity, a_Player); } diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 5e178447c..a5a6c59b6 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -71,7 +71,7 @@ public: virtual void SendChat (const AString & a_Message) override; virtual void SendChat (const cCompositeChat & a_Message) override; virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override; - virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override; + virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override; virtual void SendDestroyEntity (const cEntity & a_Entity) override; virtual void SendDisconnect (const AString & a_Reason) override; virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+) diff --git a/src/World.cpp b/src/World.cpp index 5b067b386..bd7694e96 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1877,9 +1877,18 @@ void cWorld::BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer +void cWorld::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude) +{ + m_ChunkMap->BroadcastCollectEntity(a_Entity, a_Player, a_Exclude); +} + + + + + void cWorld::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude) { - m_ChunkMap->BroadcastCollectPickup(a_Pickup, a_Player, a_Exclude); + m_ChunkMap->BroadcastCollectEntity(a_Pickup, a_Player, a_Exclude); } diff --git a/src/World.h b/src/World.h index 2b7f78760..692d5a497 100644 --- a/src/World.h +++ b/src/World.h @@ -206,6 +206,7 @@ public: // tolua_end void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL); + void BroadcastCollectEntity (const cEntity & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL); void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL); void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL); -- cgit v1.2.3 From b6df30831d6b9b84bbb231dd8cfe4c1532666da4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 27 Jun 2014 23:13:26 +0100 Subject: Fixed server forcing players afloat * Fixes #1131 --- src/Entities/Entity.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index ee7ce06ac..2b256e766 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1090,7 +1090,10 @@ void cEntity::HandleAir(void) if (IsSubmerged()) { - SetSpeedY(1); // Float in the water + if (!IsPlayer()) // Players control themselves + { + SetSpeedY(1); // Float in the water + } // Either reduce air level or damage player if (m_AirLevel < 1) -- cgit v1.2.3 From 69befa9851e8957d9efa996b08217287a87dee8c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 27 Jun 2014 23:16:37 +0100 Subject: Fixed bad water/redstone simulator communication * Fixes #713 --- src/Simulator/FloodyFluidSimulator.cpp | 54 ++++++++++++++-------------------- 1 file changed, 22 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp index e95af3a1c..4ffda2365 100644 --- a/src/Simulator/FloodyFluidSimulator.cpp +++ b/src/Simulator/FloodyFluidSimulator.cpp @@ -217,14 +217,20 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i { ASSERT(a_NewMeta <= 8); // Invalid meta values ASSERT(a_NewMeta > 0); // Source blocks aren't spread - - BLOCKTYPE BlockType; - NIBBLETYPE BlockMeta; - if (!a_NearChunk->UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ, BlockType, BlockMeta)) + + a_NearChunk = a_NearChunk->GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ); + if ((a_NearChunk == NULL) || (!a_NearChunk->IsValid())) { // Chunk not available return; } + + const int BlockX = a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX; + const int BlockZ = a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ; + + BLOCKTYPE BlockType; + NIBBLETYPE BlockMeta; + a_NearChunk->GetBlockTypeMeta(a_RelX, a_RelY, a_RelZ, BlockType, BlockMeta); if (IsAllowedBlock(BlockType)) { @@ -246,15 +252,9 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str() ); - a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0); + a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0); - int BaseX = a_NearChunk->GetPosX() * cChunkDef::Width; - int BaseZ = a_NearChunk->GetPosZ() * cChunkDef::Width; - - BaseX += a_RelX; - BaseZ += a_RelZ; - - a_NearChunk->BroadcastSoundEffect("random.fizz", BaseX * 8, a_RelY * 8, BaseZ * 8, 0.5f, 1.5f); + a_NearChunk->BroadcastSoundEffect("random.fizz", BlockX * 8, a_RelY * 8, BlockZ * 8, 0.5f, 1.5f); return; } } @@ -267,15 +267,9 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i FLOG(" Water flowing into lava, turning lava at rel {%d, %d, %d} into %s", a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str() ); - a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0); - - int BaseX = a_NearChunk->GetPosX() * cChunkDef::Width; - int BaseZ = a_NearChunk->GetPosZ() * cChunkDef::Width; - - BaseX += a_RelX; - BaseZ += a_RelZ; + a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0); - a_NearChunk->BroadcastSoundEffect("random.fizz", BaseX * 8, a_RelY * 8, BaseZ * 8, 0.5f, 1.5f); + a_NearChunk->BroadcastSoundEffect("random.fizz", BlockX * 8, a_RelY * 8, BlockZ * 8, 0.5f, 1.5f); return; } } @@ -303,21 +297,17 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i m_World, PluginInterface, NULL, - a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX, + BlockX, a_RelY, - a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ + BlockZ ); } } // if (CanWashAway) - + // Spread: - FLOG(" Spreading to {%d, %d, %d} with meta %d", - a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX, - a_RelY, - a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ, - a_NewMeta - ); - a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta); + FLOG(" Spreading to {%d, %d, %d} with meta %d", BlockX, a_RelY, BlockZ, a_NewMeta); + a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta); + m_World.GetSimulatorManager()->WakeUp(BlockX, a_RelY, BlockZ, a_NearChunk); HardenBlock(a_NearChunk, a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta); } @@ -409,13 +399,13 @@ bool cFloodyFluidSimulator::HardenBlock(cChunk * a_Chunk, int a_RelX, int a_RelY if (a_Meta == 0) { // Source lava block - a_Chunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_OBSIDIAN, 0); + a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_OBSIDIAN, 0); return true; } // Ignore last lava level else if (a_Meta <= 4) { - a_Chunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_COBBLESTONE, 0); + a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_COBBLESTONE, 0); return true; } } -- cgit v1.2.3 From 0a20e19a64f88e66af68018cc46bc37dfdca7948 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 00:29:19 +0100 Subject: Minor change to buttons and levers + They now detect if the block they are on occupies its voxel, instead of just being solid --- src/Blocks/BlockButton.h | 2 +- src/Blocks/BlockLever.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index 4b2f6f618..7d9af207d 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -102,7 +102,7 @@ public: AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true); BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn); - return (a_RelY > 0) && (cBlockInfo::IsSolid(BlockIsOn)); + return (a_RelY > 0) && (cBlockInfo::FullyOccupiesVoxel(BlockIsOn)); } } ; diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h index f1d3ff6d2..afe43abf8 100644 --- a/src/Blocks/BlockLever.h +++ b/src/Blocks/BlockLever.h @@ -22,7 +22,7 @@ public: // Flip the ON bit on/off using the XOR bitwise operation NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08); - a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_LEVER, Meta); // SetMeta doesn't work for unpowering levers, so setblock + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta); a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f); } @@ -104,7 +104,7 @@ public: AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true); BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn); - return (a_RelY > 0) && cBlockInfo::IsSolid(BlockIsOn); + return (a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(BlockIsOn); } -- cgit v1.2.3 From de543ff73fa8bb846030ffc702ed4db9f2e89f7b Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 00:29:32 +0100 Subject: Added more block exceptions to torches --- src/Blocks/BlockTorch.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index 8ddec8de1..44c33c429 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -154,7 +154,11 @@ public: if ( (BlockInQuestion == E_BLOCK_GLASS) || + (BlockInQuestion == E_BLOCK_STAINED_GLASS) || (BlockInQuestion == E_BLOCK_FENCE) || + (BlockInQuestion == E_BLOCK_SOULSAND) || + (BlockInQuestion == E_BLOCK_MOB_SPAWNER) || + (BlockInQuestion == E_BLOCK_END_PORTAL_FRAME) || // Actual vanilla behaviour (BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) || (BlockInQuestion == E_BLOCK_COBBLESTONE_WALL) ) -- cgit v1.2.3 From 3e104c25e930eddedeb456c6cad456d7d01a38de Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 28 Jun 2014 12:49:08 +0200 Subject: Changed include folders to work for Bindings, too. --- src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4b78181ee..dab97003e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required (VERSION 2.8.2) project (MCServer) -include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/") -include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/jsoncpp/include") -include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/polarssl/include") +include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/") +include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/jsoncpp/include") +include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") set(FOLDERS OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++) set(FOLDERS ${FOLDERS} WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs) -- cgit v1.2.3 From bef84b4821724c7119a3cb007d9e1265a56a27f0 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 28 Jun 2014 12:59:09 +0200 Subject: Fix sheep color's, add shear sound. --- src/Mobs/Monster.cpp | 2 +- src/Mobs/Sheep.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- src/Mobs/Sheep.h | 2 +- 3 files changed, 42 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 5843ca5a6..5ffd645b3 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -900,7 +900,7 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) case mtMooshroom: toReturn = new cMooshroom(); break; case mtOcelot: toReturn = new cOcelot(); break; case mtPig: toReturn = new cPig(); break; - case mtSheep: toReturn = new cSheep (Random.NextInt(15)); break; // Colour parameter + case mtSheep: toReturn = new cSheep(); break; case mtSilverfish: toReturn = new cSilverfish(); break; case mtSnowGolem: toReturn = new cSnowGolem(); break; case mtSpider: toReturn = new cSpider(); break; diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index 5a6b760af..cc7315a86 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -5,6 +5,7 @@ #include "../BlockID.h" #include "../Entities/Player.h" #include "../World.h" +#include "FastRandom.h" @@ -16,6 +17,43 @@ cSheep::cSheep(int a_Color) : m_WoolColor(a_Color), m_TimeToStopEating(-1) { + // Generate random wool color. + if (m_WoolColor == -1) + { + cFastRandom Random; + int Chance = Random.NextInt(101); + + if (Chance <= 81) + { + // White + m_WoolColor = 0; + } + else if (Chance <= 86) + { + // Black + m_WoolColor = 15; + } + else if (Chance <= 91) + { + // Grey + m_WoolColor = 7; + } + else if (Chance <= 96) + { + // Light grey + m_WoolColor = 8; + } + else if (Chance <= 99) + { + // Brown + m_WoolColor = 12; + } + else + { + // Pink + m_WoolColor = 6; + } + } } @@ -37,7 +75,7 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer) void cSheep::OnRightClicked(cPlayer & a_Player) { const cItem & EquippedItem = a_Player.GetEquippedItem(); - if ((EquippedItem.m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared)) + if ((EquippedItem.m_ItemType == E_ITEM_SHEARS) && !IsSheared() && !IsBaby()) { m_IsSheared = true; m_World->BroadcastEntityMetadata(*this); @@ -51,6 +89,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player) int NumDrops = m_World->GetTickRandomNumber(2) + 1; Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); + m_World->BroadcastSoundEffect("mob.sheep.shear", POSX_TOINT * 8, POSY_TOINT * 8, POSZ_TOINT * 8, 1.0f, 1.0f); } else if ((EquippedItem.m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - EquippedItem.m_ItemDamage)) { diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h index 402e8e61c..14da81364 100644 --- a/src/Mobs/Sheep.h +++ b/src/Mobs/Sheep.h @@ -13,7 +13,7 @@ class cSheep : typedef cPassiveMonster super; public: - cSheep(int a_Color); + cSheep(int a_Color = -1); CLASS_PROTODEF(cSheep); -- cgit v1.2.3 From 11d02a447e45e96e4652f25afc6d040597ad2064 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 28 Jun 2014 13:19:32 +0200 Subject: Save IsSheared from Sheep. --- src/Mobs/Sheep.h | 3 +++ src/WorldStorage/WSSAnvil.cpp | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h index 14da81364..21dca7787 100644 --- a/src/Mobs/Sheep.h +++ b/src/Mobs/Sheep.h @@ -24,7 +24,10 @@ public: virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); } bool IsSheared(void) const { return m_IsSheared; } + void SetSheared(bool a_IsSheared) { m_IsSheared = a_IsSheared; } + int GetFurColor(void) const { return m_WoolColor; } + void SetFurColor(bool a_WoolColor) { m_WoolColor = a_WoolColor; } private: diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 9870c144a..5c209c7fa 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -2073,10 +2073,11 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { int ColorIdx = a_NBT.FindChildByName(a_TagIdx, "Color"); - - if (ColorIdx < 0) { return; } - - int Color = (int)a_NBT.GetByte(ColorIdx); + int Color = -1; + if (ColorIdx > 0) + { + Color = (int)a_NBT.GetByte(ColorIdx); + } std::auto_ptr Monster(new cSheep(Color)); if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) @@ -2089,6 +2090,12 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ return; } + int ShearedIdx = a_NBT.FindChildByName(a_TagIdx, "Sheared"); + if (ShearedIdx > 0) + { + Monster.get()->SetSheared((bool)a_NBT.GetByte(ShearedIdx)); + } + a_Entities.push_back(Monster.release()); } -- cgit v1.2.3 From 48639ee4d25268525d94b2da32924164ff055d82 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 28 Jun 2014 18:16:26 +0200 Subject: CMake: Added polarssl include dir as non-system. --- src/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dab97003e..2f4d6ea13 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -119,7 +119,8 @@ if (NOT MSVC) # lib dependencies are not included - + include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") + #add cpp files here add_library(Bindings Bindings/Bindings -- cgit v1.2.3 From 1495bba17c04a5c756ba3a8eb3e881ef59aa1adf Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 28 Jun 2014 18:20:46 +0200 Subject: Fixed a silly path error in #include. --- src/Bindings/ManualBindings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 3692851eb..88d40bfd9 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -4,7 +4,7 @@ #include "ManualBindings.h" #undef TOLUA_TEMPLATE_BIND #include "tolua++/include/tolua++.h" -#include "polarssl\md5.h" +#include "polarssl/md5.h" #include "Plugin.h" #include "PluginLua.h" #include "PluginManager.h" -- cgit v1.2.3 From 61cb08b54698e9b70f629858a6a9c5b389db8b3e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 20:44:34 +0100 Subject: Implemented tripwire(s) (hooks) * Fixes #944 --- src/BlockInfo.cpp | 9 ++ src/Blocks/BlockHandler.cpp | 4 + src/Blocks/BlockStone.h | 2 - src/Blocks/BlockTripwire.h | 32 +++++ src/Blocks/BlockTripwireHook.h | 82 +++++++++++++ src/Items/ItemHandler.cpp | 2 + src/Items/ItemString.h | 39 ++++++ src/Simulator/IncrementalRedstoneSimulator.cpp | 163 ++++++++++++++++++++++--- src/Simulator/IncrementalRedstoneSimulator.h | 8 ++ 9 files changed, 324 insertions(+), 17 deletions(-) create mode 100644 src/Blocks/BlockTripwire.h create mode 100644 src/Blocks/BlockTripwireHook.h create mode 100644 src/Items/ItemString.h (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 26525e264..16314290a 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -101,6 +101,8 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_TRIPWIRE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_WALLSIGN ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_WOODEN_DOOR ].m_SpreadLightFalloff = 1; @@ -160,6 +162,8 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true; a_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true; a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true; + a_Info[E_BLOCK_TRIPWIRE ].m_Transparent = true; + a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_Transparent = true; a_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true; a_Info[E_BLOCK_TORCH ].m_Transparent = true; a_Info[E_BLOCK_VINES ].m_Transparent = true; @@ -197,6 +201,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_TNT ].m_OneHitDig = true; a_Info[E_BLOCK_TALL_GRASS ].m_OneHitDig = true; a_Info[E_BLOCK_TORCH ].m_OneHitDig = true; + a_Info[E_BLOCK_TRIPWIRE ].m_OneHitDig = true; // Blocks that break when pushed by piston: @@ -239,6 +244,8 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_PistonBreakable = true; a_Info[E_BLOCK_TALL_GRASS ].m_PistonBreakable = true; a_Info[E_BLOCK_TORCH ].m_PistonBreakable = true; + a_Info[E_BLOCK_TRIPWIRE ].m_PistonBreakable = true; + a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_PistonBreakable = true; a_Info[E_BLOCK_VINES ].m_PistonBreakable = true; a_Info[E_BLOCK_WATER ].m_PistonBreakable = true; a_Info[E_BLOCK_WOODEN_BUTTON ].m_PistonBreakable = true; @@ -280,6 +287,8 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_TALL_GRASS ].m_IsSnowable = false; a_Info[E_BLOCK_TNT ].m_IsSnowable = false; a_Info[E_BLOCK_TORCH ].m_IsSnowable = false; + a_Info[E_BLOCK_TRIPWIRE ].m_IsSnowable = false; + a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_IsSnowable = false; a_Info[E_BLOCK_VINES ].m_IsSnowable = false; a_Info[E_BLOCK_WALLSIGN ].m_IsSnowable = false; a_Info[E_BLOCK_WATER ].m_IsSnowable = false; diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 405c9bf43..3ddb7531d 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -65,6 +65,8 @@ #include "BlockRedstoneRepeater.h" #include "BlockRedstoneTorch.h" #include "BlockTNT.h" +#include "BlockTripwire.h" +#include "BlockTripwireHook.h" #include "BlockSand.h" #include "BlockSapling.h" #include "BlockSideways.h" @@ -291,6 +293,8 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_TORCH: return new cBlockTorchHandler (a_BlockType); case E_BLOCK_TRAPDOOR: return new cBlockTrapdoorHandler (a_BlockType); case E_BLOCK_TNT: return new cBlockTNTHandler (a_BlockType); + case E_BLOCK_TRIPWIRE: return new cBlockTripwireHandler (a_BlockType); + case E_BLOCK_TRIPWIRE_HOOK: return new cBlockTripwireHookHandler (a_BlockType); case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType); case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType); // TODO: This needs a special handler case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType); diff --git a/src/Blocks/BlockStone.h b/src/Blocks/BlockStone.h index af4c6509a..cd5230f49 100644 --- a/src/Blocks/BlockStone.h +++ b/src/Blocks/BlockStone.h @@ -2,8 +2,6 @@ #pragma once #include "BlockHandler.h" -#include "../MersenneTwister.h" -#include "../World.h" diff --git a/src/Blocks/BlockTripwire.h b/src/Blocks/BlockTripwire.h new file mode 100644 index 000000000..3ab17bf4a --- /dev/null +++ b/src/Blocks/BlockTripwire.h @@ -0,0 +1,32 @@ + +#pragma once + +#include "BlockHandler.h" + + + + + +class cBlockTripwireHandler : + public cBlockHandler +{ +public: + cBlockTripwireHandler(BLOCKTYPE a_BlockType) + : cBlockHandler(a_BlockType) + { + } + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(E_ITEM_STRING, 1, 0)); + } + + virtual const char * GetStepSound(void) override + { + return ""; + } +}; + + + + diff --git a/src/Blocks/BlockTripwireHook.h b/src/Blocks/BlockTripwireHook.h new file mode 100644 index 000000000..f849fb8ad --- /dev/null +++ b/src/Blocks/BlockTripwireHook.h @@ -0,0 +1,82 @@ +#pragma once + +#include "BlockHandler.h" +#include "MetaRotator.h" + + + + + +class cBlockTripwireHookHandler : + public cMetaRotator +{ +public: + cBlockTripwireHookHandler(BLOCKTYPE a_BlockType) + : cMetaRotator(a_BlockType) + { + } + + virtual bool GetPlacementBlockTypeMeta( + cChunkInterface & a_ChunkInterface, cPlayer * a_Player, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_CursorX, int a_CursorY, int a_CursorZ, + BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta + ) override + { + a_BlockType = m_BlockType; + + a_BlockMeta = DirectionToMetadata(a_BlockFace); + + return true; + } + + inline static NIBBLETYPE DirectionToMetadata(eBlockFace a_Direction) + { + switch (a_Direction) + { + case BLOCK_FACE_XM: return 0x1; + case BLOCK_FACE_XP: return 0x3; + case BLOCK_FACE_ZM: return 0x2; + case BLOCK_FACE_ZP: return 0x0; + default: ASSERT(!"Unhandled tripwire hook direction!"); return 0x0; + } + } + + inline static eBlockFace MetadataToDirection(NIBBLETYPE a_Meta) + { + switch (a_Meta & 0x03) + { + case 0x1: return BLOCK_FACE_XM; + case 0x3: return BLOCK_FACE_XP; + case 0x2: return BLOCK_FACE_ZM; + case 0x0: return BLOCK_FACE_ZP; + default: ASSERT(!"Unhandled tripwire hook metadata!"); return BLOCK_FACE_NONE; + } + } + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + // Reset meta to 0 + a_Pickups.push_back(cItem(E_BLOCK_TRIPWIRE_HOOK, 1, 0)); + } + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override + { + NIBBLETYPE Meta; + a_Chunk.UnboundedRelGetBlockMeta(a_RelX, a_RelY, a_RelZ, Meta); + + AddFaceDirection(a_RelX, a_RelY, a_RelZ, MetadataToDirection(Meta), true); + BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn); + + return (a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(BlockIsOn); + } + + virtual const char * GetStepSound(void) override + { + return "step.wood"; + } +}; + + + + diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index f639423ae..a2fd4e3f8 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -44,6 +44,7 @@ #include "ItemSign.h" #include "ItemMobHead.h" #include "ItemSpawnEgg.h" +#include "ItemString.h" #include "ItemSugarcane.h" #include "ItemSword.h" @@ -129,6 +130,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) case E_ITEM_HEAD: return new cItemMobHeadHandler(a_ItemType); case E_ITEM_SNOWBALL: return new cItemSnowballHandler(); case E_ITEM_SPAWN_EGG: return new cItemSpawnEggHandler(a_ItemType); + case E_ITEM_STRING: return new cItemStringHandler(a_ItemType); case E_ITEM_SUGARCANE: return new cItemSugarcaneHandler(a_ItemType); case E_ITEM_WOODEN_HOE: diff --git a/src/Items/ItemString.h b/src/Items/ItemString.h new file mode 100644 index 000000000..a97fbe0ce --- /dev/null +++ b/src/Items/ItemString.h @@ -0,0 +1,39 @@ + +#pragma once + +#include "ItemHandler.h" + + + + + +class cItemStringHandler : + public cItemHandler +{ +public: + cItemStringHandler(int a_ItemType) : + cItemHandler(a_ItemType) + { + } + + virtual bool IsPlaceable(void) override + { + return true; + } + + virtual bool GetPlacementBlockTypeMeta( + cWorld * a_World, cPlayer * a_Player, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_CursorX, int a_CursorY, int a_CursorZ, + BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta + ) override + { + a_BlockType = E_BLOCK_TRIPWIRE; + a_BlockMeta = 0; + return true; + } +}; + + + + diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 10446a879..866a5b65a 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "IncrementalRedstoneSimulator.h" +#include "BoundingBox.h" #include "../BlockEntities/DropSpenserEntity.h" #include "../BlockEntities/NoteEntity.h" #include "../BlockEntities/CommandBlockEntity.h" @@ -12,10 +13,13 @@ #include "../Blocks/BlockButton.h" #include "../Blocks/BlockLever.h" #include "../Blocks/BlockPiston.h" +#include "../Blocks/BlockTripwireHook.h" + +#define WAKE_SIMULATOR_IF_DIRTY(a_Chunk, a_BlockX, a_BlockY, a_BlockZ) if (a_Chunk->IsRedstoneDirty()) WakeUp(a_BlockX, a_BlockY, a_BlockZ, a_Chunk); + - cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulator(cWorld & a_World) : super(a_World), @@ -99,10 +103,11 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, // Changeable sources ((Block == E_BLOCK_REDSTONE_WIRE) && (Meta == 0)) || ((Block == E_BLOCK_LEVER) && !IsLeverOn(Meta)) || - ((Block == E_BLOCK_DETECTOR_RAIL) && (Meta & 0x08) == 0) || + ((Block == E_BLOCK_DETECTOR_RAIL) && ((Meta & 0x08) == 0)) || (((Block == E_BLOCK_STONE_BUTTON) || (Block == E_BLOCK_WOODEN_BUTTON)) && (!IsButtonOn(Meta))) || (((Block == E_BLOCK_STONE_PRESSURE_PLATE) || (Block == E_BLOCK_WOODEN_PRESSURE_PLATE)) && (Meta == 0)) || - (((Block == E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE) || (Block == E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE)) && (Meta == 0)) + (((Block == E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE) || (Block == E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE)) && (Meta == 0)) || + ((Block == E_BLOCK_TRIPWIRE_HOOK) && ((Meta & 0x08) == 0)) ) { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); @@ -289,6 +294,9 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int switch (dataitr->Data) { case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_TRIPWIRE: HandleTripwire(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_TRIPWIRE_HOOK: HandleTripwireHook(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_WOODEN_PRESSURE_PLATE: case E_BLOCK_STONE_PRESSURE_PLATE: case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: @@ -1120,7 +1128,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R case E_BLOCK_STONE_PRESSURE_PLATE: { // MCS feature - stone pressure plates can only be triggered by players :D - cPlayer * a_Player = m_World.FindClosestPlayer(Vector3f(BlockX + 0.5f, (float)a_RelBlockY, BlockZ + 0.5f), 0.7f, false); + cPlayer * a_Player = m_World.FindClosestPlayer(Vector3f(BlockX + 0.5f, (float)a_RelBlockY, BlockZ + 0.5f), 0.5f, false); if (a_Player != NULL) { @@ -1131,7 +1139,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R else { m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x0); - m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ); + WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); } break; } @@ -1155,7 +1163,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f); double Distance = (EntityPos - BlockPos).Length(); - if (Distance <= 0.7) + if (Distance <= 0.5) { m_NumberOfEntities++; } @@ -1177,7 +1185,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R }; cPressurePlateCallback PressurePlateCallback(BlockX, a_RelBlockY, BlockZ); - m_World.ForEachEntity(PressurePlateCallback); + m_World.ForEachEntityInChunk(m_Chunk->GetPosX(), m_Chunk->GetPosZ(), PressurePlateCallback); unsigned char Power; NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); @@ -1198,7 +1206,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); - m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ); + WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); } break; @@ -1223,7 +1231,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f); double Distance = (EntityPos - BlockPos).Length(); - if (Distance <= 0.7) + if (Distance <= 0.5) { m_NumberOfEntities++; } @@ -1232,7 +1240,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R bool GetPowerLevel(unsigned char & a_PowerLevel) const { - a_PowerLevel = std::min((int)ceil(m_NumberOfEntities / (float)10), MAX_POWER_LEVEL); + a_PowerLevel = std::min((int)ceil(m_NumberOfEntities / 10.f), MAX_POWER_LEVEL); return (a_PowerLevel > 0); } @@ -1245,7 +1253,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R }; cPressurePlateCallback PressurePlateCallback(BlockX, a_RelBlockY, BlockZ); - m_World.ForEachEntity(PressurePlateCallback); + m_World.ForEachEntityInChunk(m_Chunk->GetPosX(), m_Chunk->GetPosZ(), PressurePlateCallback); unsigned char Power; NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); @@ -1266,7 +1274,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); - m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ); + WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); } break; @@ -1291,7 +1299,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f); double Distance = (EntityPos - BlockPos).Length(); - if (Distance <= 0.7) + if (Distance <= 0.5) { m_FoundEntity = true; return true; // Break out, we only need to know for plates that at least one entity is on top @@ -1313,7 +1321,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R } ; cPressurePlateCallback PressurePlateCallback(BlockX, a_RelBlockY, BlockZ); - m_World.ForEachEntity(PressurePlateCallback); + m_World.ForEachEntityInChunk(m_Chunk->GetPosX(), m_Chunk->GetPosZ(), PressurePlateCallback); NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); if (PressurePlateCallback.FoundEntity()) @@ -1333,7 +1341,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); - m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ); + WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); } break; } @@ -1349,6 +1357,131 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R +void cIncrementalRedstoneSimulator::HandleTripwireHook(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) +{ + int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX; + int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ; + int RelX = a_RelBlockX, RelZ = a_RelBlockZ; + bool FoundActivated = false; + eBlockFace FaceToGoTowards = cBlockTripwireHookHandler::MetadataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)); + + for (int i = 0; i < 40; ++i) // Tripwires can be connected up to 40 blocks + { + BLOCKTYPE Type; + NIBBLETYPE Meta; + + AddFaceDirection(RelX, a_RelBlockY, RelZ, FaceToGoTowards); + m_Chunk->UnboundedRelGetBlock(RelX, a_RelBlockY, RelZ, Type, Meta); + + if (Type == E_BLOCK_TRIPWIRE) + { + if (Meta == 0x1) + { + FoundActivated = true; + } + } + else if (Type == E_BLOCK_TRIPWIRE_HOOK) + { + if (ReverseBlockFace(cBlockTripwireHookHandler::MetadataToDirection(Meta)) == FaceToGoTowards) + { + // Other hook not facing in opposite direction + break; + } + else + { + // Tripwire hook not connected at all, AND away all the power state bits + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x3); + WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); + return; + } + } + else + { + // Tripwire hook not connected at all, AND away all the power state bits + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x3); + WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); + return; + } + } + + if (FoundActivated) + { + // Connected and activated, set the 3rd and 4th highest bits + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) | 0xC); + SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); + } + else + { + // Connected but not activated, AND away the highest bit + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, (m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x7) | 0x4); + WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); + } +} + + + + + +void cIncrementalRedstoneSimulator::HandleTripwire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) +{ + int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX; + int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ; + + class cTripwireCallback : + public cEntityCallback + { + public: + cTripwireCallback(int a_BlockX, int a_BlockY, int a_BlockZ) : + m_FoundEntity(false), + m_X(a_BlockX), + m_Y(a_BlockY), + m_Z(a_BlockZ) + { + } + + virtual bool Item(cEntity * a_Entity) override + { + cBoundingBox bbWire(m_X, m_X + 1, m_Y, m_Y + 0.1, m_Z, m_Z + 1); + cBoundingBox bbEntity(a_Entity->GetPosition(), a_Entity->GetWidth() / 2, a_Entity->GetHeight()); + + if (bbEntity.DoesIntersect(bbWire)) + { + m_FoundEntity = true; + return true; // One entity is sufficient to trigger the wire + } + return false; + } + + bool FoundEntity(void) const + { + return m_FoundEntity; + } + + protected: + bool m_FoundEntity; + + int m_X; + int m_Y; + int m_Z; + }; + + cTripwireCallback TripwireCallback(BlockX, a_RelBlockY, BlockZ); + m_World.ForEachEntityInChunk(m_Chunk->GetPosX(), m_Chunk->GetPosZ(), TripwireCallback); + + if (TripwireCallback.FoundEntity()) + { + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x1); + } + else + { + m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x0); + } +} + + + + + bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index 9c1f9460c..6cefdebf2 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -102,6 +102,11 @@ private: void HandleDaylightSensor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles pressure plates */ void HandlePressurePlate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyType); + /** Handles tripwire hooks + Performs correct meta and power setting for self by going in the direction it faces and looking for a continous line of tripwire bounded by another oppositely facing hook + If this line is complete, it verifies that at least on wire reports an entity is on top (via its meta), and performs its task + */ + void HandleTripwireHook(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /* ==================== */ /* ====== CARRIERS ====== */ @@ -134,6 +139,8 @@ private: void HandleFenceGate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles noteblocks */ void HandleNoteBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); + /** Handles tripwires */ + void HandleTripwire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /* ===================== */ /* ====== Helper functions ====== */ @@ -271,6 +278,7 @@ private: case E_BLOCK_TNT: case E_BLOCK_TRAPDOOR: case E_BLOCK_TRIPWIRE_HOOK: + case E_BLOCK_TRIPWIRE: case E_BLOCK_WOODEN_BUTTON: case E_BLOCK_WOODEN_DOOR: case E_BLOCK_WOODEN_PRESSURE_PLATE: -- cgit v1.2.3 From 5e66d9aeabcb759319c1045680443e72f0c1d75b Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 20:45:05 +0100 Subject: Fixed issue with breaking blocks at -1 coordinates --- src/ClientHandle.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 16cfe1aec..e7b876b24 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1085,12 +1085,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo void cClientHandle::FinishDigAnimation() { - if ( - !m_HasStartedDigging || // Hasn't received the DIG_STARTED packet - (m_LastDigBlockX == -1) || - (m_LastDigBlockY == -1) || - (m_LastDigBlockZ == -1) - ) + if (!m_HasStartedDigging) // Hasn't received the DIG_STARTED packet { return; } -- cgit v1.2.3 From 085cb4256ed9dd343ab4049b6f1e3d4ef53855e8 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 28 Jun 2014 21:55:21 +0200 Subject: Fixed doxycomments --- src/Bindings/PluginManager.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index e2bd9cd94..545f41107 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -253,10 +253,10 @@ public: // tolua_export /** Returns the permission needed for the specified command; empty string if command not found */ AString GetCommandPermission(const AString & a_Command); // tolua_export - /** Executes the command, as if it was requested by a_Player. Checks permissions first. Returns true if executed. */ + /** Executes the command, as if it was requested by a_Player. Checks permissions first. Returns crExecuted if executed. */ CommandResult ExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export - /** Executes the command, as if it was requested by a_Player. Permisssions are not checked. Returns true if executed (false if not found) */ + /** Executes the command, as if it was requested by a_Player. Permisssions are not checked. Returns crExecuted if executed. */ CommandResult ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export /** Removes all console command bindings that the specified plugin has made */ @@ -330,7 +330,7 @@ private: /** Adds the plugin into the internal list of plugins and initializes it. If initialization fails, the plugin is removed again. */ bool AddPlugin(cPlugin * a_Plugin); - /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns true if the command is executed. */ + /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns crExecuted if the command is executed. */ cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions); } ; // tolua_export -- cgit v1.2.3 From 35dc056f0350c5fda178d0c28230f0a6b0feabbc Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 21:10:59 +0100 Subject: Likely fixed too quick food depletion * Fixes FS427 properly, hopefully --- src/Entities/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 7b4fd219d..0abe50d11 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1913,7 +1913,7 @@ void cPlayer::HandleFood(void) { m_FoodTickTimer = 0; - if (m_FoodLevel >= 17) + if ((m_FoodLevel > 17) && (GetHealth() < GetMaxHealth())) { // Regenerate health from food, incur 3 pts of food exhaustion: Heal(1); -- cgit v1.2.3 From 536cb62f1c4ee47bf39a04240f9460953f3f8869 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 21:14:10 +0100 Subject: An unification of code style --- src/Entities/ProjectileEntity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index d45f1d212..76daca186 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -361,7 +361,7 @@ void cProjectileEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) EntityCollisionCallback.GetHitEntity()->GetClass(), HitPos.x, HitPos.y, HitPos.z, EntityCollisionCallback.GetMinCoeff() - ); + ); OnHitEntity(*(EntityCollisionCallback.GetHitEntity()), HitPos); } -- cgit v1.2.3 From 20b32fc44e69ef317dea7536eb8e31bc3fe6c562 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 29 Jun 2014 01:01:10 +0200 Subject: Code fixes. --- src/WorldStorage/WSSAnvil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 5c209c7fa..b22454cdf 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -2093,7 +2093,7 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ int ShearedIdx = a_NBT.FindChildByName(a_TagIdx, "Sheared"); if (ShearedIdx > 0) { - Monster.get()->SetSheared((bool)a_NBT.GetByte(ShearedIdx)); + Monster->SetSheared(a_NBT.GetByte(ShearedIdx) != 0); } a_Entities.push_back(Monster.release()); -- cgit v1.2.3 From 50e112788bc46460ec2c1972f811264c1a9b04cc Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 29 Jun 2014 01:40:15 +0200 Subject: Send statistics to the player, when he logged in. --- src/ClientHandle.cpp | 3 +++ src/Protocol/Protocol17x.cpp | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 95dfaffb2..abe9a86f5 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -361,6 +361,9 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID) // Send scoreboard data World->GetScoreBoard().SendTo(*this); + // Send statistics + SendStatistics(m_Player->GetStatManager()); + // Delay the first ping until the client "settles down" // This should fix #889, "BadCast exception, cannot convert bit to fm" error in client cTimer t1; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 49fef0b8e..98fabedb2 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1221,10 +1221,9 @@ void cProtocol172::SendStatistics(const cStatManager & a_Manager) cPacketizer Pkt(*this, 0x37); Pkt.WriteVarInt(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only - for (unsigned int i = 0; i < (unsigned int)statCount; ++i) + for (size_t i = 0; i < (size_t)statCount; ++i) { StatValue Value = a_Manager.GetValue((eStatistic) i); - const AString & StatName = cStatInfo::GetName((eStatistic) i); Pkt.WriteString(StatName); -- cgit v1.2.3 From dde641ce83de474187102f0efbbced826673f54d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 29 Jun 2014 11:36:38 +0100 Subject: Properly implemented enderchests --- src/BlockEntities/EnderChestEntity.cpp | 93 +++++++++++---------------------- src/BlockEntities/EnderChestEntity.h | 44 +++++----------- src/Entities/Player.cpp | 7 +++ src/Entities/Player.h | 11 +++- src/UI/SlotArea.cpp | 4 +- src/UI/Window.cpp | 4 +- src/WorldStorage/NBTChunkSerializer.cpp | 14 +++++ src/WorldStorage/NBTChunkSerializer.h | 2 + src/WorldStorage/WSSAnvil.cpp | 21 ++++++++ src/WorldStorage/WSSAnvil.h | 1 + 10 files changed, 102 insertions(+), 99 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/EnderChestEntity.cpp b/src/BlockEntities/EnderChestEntity.cpp index e53930798..17816d63e 100644 --- a/src/BlockEntities/EnderChestEntity.cpp +++ b/src/BlockEntities/EnderChestEntity.cpp @@ -12,9 +12,8 @@ cEnderChestEntity::cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) : - super(E_BLOCK_ENDER_CHEST, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World) + super(E_BLOCK_ENDER_CHEST, a_BlockX, a_BlockY, a_BlockZ, a_World) { - cBlockEntityWindowOwner::SetBlockEntity(this); } @@ -34,95 +33,63 @@ cEnderChestEntity::~cEnderChestEntity() -bool cEnderChestEntity::LoadFromJson(const Json::Value & a_Value) +void cEnderChestEntity::UsedBy(cPlayer * a_Player) { - m_PosX = a_Value.get("x", 0).asInt(); - m_PosY = a_Value.get("y", 0).asInt(); - m_PosZ = a_Value.get("z", 0).asInt(); - - Json::Value AllSlots = a_Value.get("Slots", 0); - int SlotIdx = 0; - for (Json::Value::iterator itr = AllSlots.begin(); itr != AllSlots.end(); ++itr) + // If the window is not created, open it anew: + cWindow * Window = GetWindow(); + if (Window == NULL) { - cItem Item; - Item.FromJson(*itr); - SetSlot(SlotIdx, Item); - SlotIdx++; + OpenNewWindow(); + Window = GetWindow(); } - return true; -} - - - - - -void cEnderChestEntity::SaveToJson(Json::Value & a_Value) -{ - a_Value["x"] = m_PosX; - a_Value["y"] = m_PosY; - a_Value["z"] = m_PosZ; - - Json::Value AllSlots; - for (int i = m_Contents.GetNumSlots() - 1; i >= 0; i--) + + // Open the window for the player: + if (Window != NULL) { - Json::Value Slot; - m_Contents.GetSlot(i).GetJson(Slot); - AllSlots.append(Slot); + if (a_Player->GetWindow() != Window) + { + a_Player->OpenWindow(Window); + } } - a_Value["Slots"] = AllSlots; } -void cEnderChestEntity::SendTo(cClientHandle & a_Client) +void cEnderChestEntity::OpenNewWindow() { - // The chest entity doesn't need anything sent to the client when it's created / gets in the viewdistance - // All the actual handling is in the cWindow UI code that gets called when the chest is rclked - - UNUSED(a_Client); + OpenWindow(new cEnderChestWindow(this)); } -void cEnderChestEntity::UsedBy(cPlayer * a_Player) +void cEnderChestEntity::LoadFromJson(const Json::Value & a_Value, cItemGrid & a_Grid) { - // If the window is not created, open it anew: - cWindow * Window = GetWindow(); - if (Window == NULL) - { - OpenNewWindow(); - Window = GetWindow(); - } - - // Open the window for the player: - if (Window != NULL) + int SlotIdx = 0; + for (Json::Value::iterator itr = a_Value.begin(); itr != a_Value.end(); ++itr) { - if (a_Player->GetWindow() != Window) - { - a_Player->OpenWindow(Window); - } + cItem Item; + Item.FromJson(*itr); + a_Grid.SetSlot(SlotIdx, Item); + SlotIdx++; } - - // This is rather a hack - // Instead of marking the chunk as dirty upon chest contents change, we mark it dirty now - // We cannot properly detect contents change, but such a change doesn't happen without a player opening the chest first. - // The few false positives aren't much to worry about - int ChunkX, ChunkZ; - cChunkDef::BlockToChunk(m_PosX, m_PosZ, ChunkX, ChunkZ); - m_World->MarkChunkDirty(ChunkX, ChunkZ); } -void cEnderChestEntity::OpenNewWindow(void) +void cEnderChestEntity::SaveToJson(Json::Value & a_Value, const cItemGrid & a_Grid) { - OpenWindow(new cEnderChestWindow(this)); + for (int i = 0; i < a_Grid.GetNumSlots(); i++) + { + Json::Value Slot; + a_Grid.GetSlot(i).GetJson(Slot); + a_Value.append(Slot); + } } diff --git a/src/BlockEntities/EnderChestEntity.h b/src/BlockEntities/EnderChestEntity.h index 45beee45f..04af67683 100644 --- a/src/BlockEntities/EnderChestEntity.h +++ b/src/BlockEntities/EnderChestEntity.h @@ -1,20 +1,9 @@ #pragma once -#include "BlockEntityWithItems.h" - - - - - -namespace Json -{ - class Value; -}; - -class cClientHandle; -class cServer; -class cNBTData; +#include "BlockEntity.h" +#include "UI/WindowOwner.h" +#include "json/json.h" @@ -22,33 +11,28 @@ class cNBTData; // tolua_begin class cEnderChestEntity : - public cBlockEntityWithItems + public cBlockEntity, + public cBlockEntityWindowOwner { - typedef cBlockEntityWithItems super; - -public: - enum { - ContentsHeight = 3, - ContentsWidth = 9, - } ; + typedef cBlockEntity super; +public: // tolua_end - /// Constructor used for normal operation - cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); - + cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); virtual ~cEnderChestEntity(); static const char * GetClassStatic(void) { return "cEnderChestEntity"; } - - bool LoadFromJson(const Json::Value & a_Value); // cBlockEntity overrides: - virtual void SaveToJson(Json::Value & a_Value) override; - virtual void SendTo(cClientHandle & a_Client) override; virtual void UsedBy(cPlayer * a_Player) override; + virtual void SaveToJson(Json::Value & a_Value) override { UNUSED(a_Value); } + virtual void SendTo(cClientHandle & a_Client) override { UNUSED(a_Client); } + + static void LoadFromJson(const Json::Value & a_Value, cItemGrid & a_Grid); + static void SaveToJson(Json::Value & a_Value, const cItemGrid & a_Grid); - /// Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate. + /** Opens a new enderchest window for this enderchest */ void OpenNewWindow(void); } ; // tolua_export diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 0abe50d11..aeeea3d07 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -8,6 +8,7 @@ #include "../World.h" #include "../Bindings/PluginManager.h" #include "../BlockEntities/BlockEntity.h" +#include "../BlockEntities/EnderChestEntity.h" #include "../GroupManager.h" #include "../Group.h" #include "../Root.h" @@ -46,6 +47,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) , m_bTouchGround(false) , m_Stance(0.0) , m_Inventory(*this) + , m_EnderChestContents(9, 3) , m_CurrentWindow(NULL) , m_InventoryWindow(NULL) , m_Color('-') @@ -1743,6 +1745,7 @@ bool cPlayer::LoadFromDisk() } m_Inventory.LoadFromJson(root["inventory"]); + cEnderChestEntity::LoadFromJson(root["enderchestinventory"], m_EnderChestContents); m_LoadedWorldName = root.get("world", "world").asString(); @@ -1780,10 +1783,14 @@ bool cPlayer::SaveToDisk() Json::Value JSON_Inventory; m_Inventory.SaveToJson(JSON_Inventory); + Json::Value JSON_EnderChestInventory; + cEnderChestEntity::SaveToJson(JSON_EnderChestInventory, m_EnderChestContents); + Json::Value root; root["position"] = JSON_PlayerPosition; root["rotation"] = JSON_PlayerRotation; root["inventory"] = JSON_Inventory; + root["enderchestinventory"] = JSON_EnderChestInventory; root["health"] = m_Health; root["xpTotal"] = m_LifetimeTotalXp; root["xpCurrent"] = m_CurrentXp; diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 2f7957f16..c70733c8c 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -124,6 +124,9 @@ public: inline double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc. inline cInventory & GetInventory(void) { return m_Inventory; } // tolua_export inline const cInventory & GetInventory(void) const { return m_Inventory; } + + /** Gets the contents of the player's associated enderchest */ + cItemGrid & GetEnderChestContents(void) { return m_EnderChestContents; } inline const cItem & GetEquippedItem(void) const { return GetInventory().GetEquippedItem(); } // tolua_export @@ -449,7 +452,13 @@ protected: float m_LastGroundHeight; bool m_bTouchGround; double m_Stance; + + /** Stores the player's inventory, consisting of crafting grid, hotbar, and main slots */ cInventory m_Inventory; + + /** An item grid that stores the player specific enderchest contents */ + cItemGrid m_EnderChestContents; + cWindow * m_CurrentWindow; cWindow * m_InventoryWindow; @@ -510,8 +519,6 @@ protected: cStatManager m_Stats; - - /** Sets the speed and sends it to the client, so that they are forced to move so. */ virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override; diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 728692f2a..a2661e49e 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1342,7 +1342,7 @@ cSlotAreaEnderChest::cSlotAreaEnderChest(cEnderChestEntity * a_EnderChest, cWind const cItem * cSlotAreaEnderChest::GetSlot(int a_SlotNum, cPlayer & a_Player) const { // a_SlotNum ranges from 0 to 26, use that to index the chest entity's inventory directly: - return &(m_EnderChest->GetSlot(a_SlotNum)); + return &(a_Player.GetEnderChestContents().GetSlot(a_SlotNum)); } @@ -1351,7 +1351,7 @@ const cItem * cSlotAreaEnderChest::GetSlot(int a_SlotNum, cPlayer & a_Player) co void cSlotAreaEnderChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) { - m_EnderChest->SetSlot(a_SlotNum, a_Item); + a_Player.GetEnderChestContents().SetSlot(a_SlotNum, a_Item); } diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 98a9a0cec..81f75cebb 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -145,8 +145,7 @@ void cWindow::GetSlots(cPlayer & a_Player, cItems & a_Slots) const { int NumSlots = (*itr)->GetNumSlots(); for (int i = 0; i < NumSlots; i++) - { - + { const cItem * Item = (*itr)->GetSlot(i, a_Player); if (Item == NULL) { @@ -1017,6 +1016,7 @@ cEnderChestWindow::~cEnderChestWindow() // Send out the chest-close packet: m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_ENDER_CHEST); + // Play the closing sound m_World->BroadcastSoundEffect("random.chestclosed", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1); } diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index f35b38859..baf74d830 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -11,6 +11,7 @@ #include "FastNBT.h" #include "../BlockEntities/ChestEntity.h" +#include "../BlockEntities/EnderChestEntity.h" #include "../BlockEntities/CommandBlockEntity.h" #include "../BlockEntities/DispenserEntity.h" #include "../BlockEntities/DropperEntity.h" @@ -189,6 +190,18 @@ void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity) +void cNBTChunkSerializer::AddEnderChestEntity(cEnderChestEntity * a_Entity) +{ + m_Writer.BeginCompound(""); + AddBasicTileEntity(a_Entity, "EnderChest"); + // No need to store anything more + m_Writer.EndCompound(); +} + + + + + void cNBTChunkSerializer::AddDispenserEntity(cDispenserEntity * a_Entity) { m_Writer.BeginCompound(""); @@ -820,6 +833,7 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity) case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity); break; case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break; case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break; + case E_BLOCK_ENDER_CHEST: AddEnderChestEntity ((cEnderChestEntity *) a_Entity); break; case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break; case E_BLOCK_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break; case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break; diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h index 112afc27e..a4c95f540 100644 --- a/src/WorldStorage/NBTChunkSerializer.h +++ b/src/WorldStorage/NBTChunkSerializer.h @@ -21,6 +21,7 @@ class cEntity; class cBlockEntity; class cBoat; class cChestEntity; +class cEnderChestEntity; class cCommandBlockEntity; class cDispenserEntity; class cDropperEntity; @@ -93,6 +94,7 @@ protected: // Block entities: void AddBasicTileEntity(cBlockEntity * a_Entity, const char * a_EntityTypeID); void AddChestEntity (cChestEntity * a_Entity); + void AddEnderChestEntity(cEnderChestEntity * a_Entity); void AddDispenserEntity(cDispenserEntity * a_Entity); void AddDropperEntity (cDropperEntity * a_Entity); void AddFurnaceEntity (cFurnaceEntity * a_Furnace); diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 9870c144a..e6170f8b7 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -16,6 +16,7 @@ #include "../StringCompression.h" #include "../BlockEntities/ChestEntity.h" +#include "../BlockEntities/EnderChestEntity.h" #include "../BlockEntities/CommandBlockEntity.h" #include "../BlockEntities/DispenserEntity.h" #include "../BlockEntities/DropperEntity.h" @@ -583,6 +584,10 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con if (strncmp(a_NBT.GetData(sID), "Chest", a_NBT.GetDataLength(sID)) == 0) { LoadChestFromNBT(a_BlockEntities, a_NBT, Child); + } + else if (strncmp(a_NBT.GetData(sID), "EnderChest", a_NBT.GetDataLength(sID)) == 0) + { + } else if (strncmp(a_NBT.GetData(sID), "Control", a_NBT.GetDataLength(sID)) == 0) { @@ -762,6 +767,22 @@ void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cPars +void cWSSAnvil::LoadEnderChestFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx) +{ + ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound); + int x, y, z; + if (!GetBlockEntityNBTPos(a_NBT, a_TagIdx, x, y, z)) + { + return; + } + std::auto_ptr EnderChest(new cEnderChestEntity(x, y, z, m_World)); + a_BlockEntities.push_back(EnderChest.release()); +} + + + + + void cWSSAnvil::LoadDispenserFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx) { ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound); diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h index 7542a828a..45fea70b6 100644 --- a/src/WorldStorage/WSSAnvil.h +++ b/src/WorldStorage/WSSAnvil.h @@ -134,6 +134,7 @@ protected: void LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a_NBT, int a_ItemsTagIdx, int s_SlotOffset = 0); void LoadChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadEnderChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadDispenserFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadDropperFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadFlowerPotFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); -- cgit v1.2.3 From 909e0ed95b508b0cc3779df342899e8661e6da96 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 29 Jun 2014 11:41:50 +0100 Subject: Removed bad comment --- src/UI/SlotArea.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index a2661e49e..48ebf489b 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1341,7 +1341,6 @@ cSlotAreaEnderChest::cSlotAreaEnderChest(cEnderChestEntity * a_EnderChest, cWind const cItem * cSlotAreaEnderChest::GetSlot(int a_SlotNum, cPlayer & a_Player) const { - // a_SlotNum ranges from 0 to 26, use that to index the chest entity's inventory directly: return &(a_Player.GetEnderChestContents().GetSlot(a_SlotNum)); } -- cgit v1.2.3 From 3c631fc0f95f383c53d18cd7760ab2e3a8609240 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 29 Jun 2014 18:27:41 +0200 Subject: Fixed offline UUID generator. It generated invalid UUIDs, too many hex chars. --- src/ClientHandle.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index abe9a86f5..662ee7927 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -241,9 +241,11 @@ AString cClientHandle::GenerateOfflineUUID(const AString & a_Username) // Generate an md5 checksum, and use it as base for the ID: unsigned char MD5[16]; md5((const unsigned char *)a_Username.c_str(), a_Username.length(), MD5); + MD5[6] &= 0x0f; // Need to trim to 4 bits only... + MD5[8] &= 0x0f; // ... otherwise %01x overflows into two chars return Printf("%02x%02x%02x%02x-%02x%02x-3%01x%02x-8%01x%02x-%02x%02x%02x%02x%02x%02x", - MD5[0], MD5[1], MD5[2], MD5[3], - MD5[4], MD5[5], MD5[6], MD5[7], + MD5[0], MD5[1], MD5[2], MD5[3], + MD5[4], MD5[5], MD5[6], MD5[7], MD5[8], MD5[9], MD5[10], MD5[11], MD5[12], MD5[13], MD5[14], MD5[15] ); -- cgit v1.2.3 From 428cfb5c21ec5a35252b967eb306d6ba9b8e11b3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 29 Jun 2014 22:41:31 +0100 Subject: Suggestions --- src/Entities/ArrowEntity.cpp | 4 +++- src/Entities/Entity.cpp | 5 +++-- src/Vector3.h | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index db9dc781a..c76c710ef 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -69,7 +69,9 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { Vector3d Hit = a_HitPos; - Hit += GetSpeed() / 700; // Make arrow sink into block a little + Vector3d SinkMovement = GetSpeed() / 800; + SinkMovement.Clamp(0.001, 0.001, 0.001, 0.05, 0.05, 0.05); + Hit += SinkMovement; // Make arrow sink into block a little super::OnHitSolidBlock(Hit, a_HitFace); int X = (int)floor(Hit.x), Y = (int)floor(Hit.y), Z = (int)floor(Hit.z); diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index f4e89367b..1683aa209 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -255,7 +255,8 @@ void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_R void cEntity::SetYawFromSpeed(void) { - if ((abs(m_Speed.x) < std::numeric_limits::epsilon()) && (abs(m_Speed.z) < std::numeric_limits::epsilon())) + const double EPS = 0.0000001; + if ((abs(m_Speed.x) < EPS) && (abs(m_Speed.z) < EPS)) { // atan2() may overflow or is undefined, pick any number SetYaw(0); @@ -1235,7 +1236,7 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude) if (GetWorld()->GetWorldAge() % 2 == 0) { double SpeedSqr = GetSpeed().SqrLength(); - if (SpeedSqr < std::numeric_limits::epsilon()) + if (SpeedSqr == 0.0) { // Speed is zero, send this to clients once only as well as an absolute position if (!m_bHasSentNoSpeed) diff --git a/src/Vector3.h b/src/Vector3.h index 5faac1457..762fdfd71 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -274,6 +274,14 @@ public: return (a_X - x) / (a_OtherEnd.x - x); } + /** Clamps each value in the vector to within a specified range */ + inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ) + { + x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x)); + y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y)); + z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z)); + } + /** The max difference between two coords for which the coords are assumed equal. */ static const double EPS; @@ -288,6 +296,12 @@ protected: { return (a_Value < 0) ? -a_Value : a_Value; } + + /** Clamp X to the specified range. */ + T Clamp(T a_Value, T a_Min, T a_Max) + { + return (a_Value < a_Min) ? a_Min : ((a_Value > a_Max) ? a_Max : a_Value); + } }; // tolua_end -- cgit v1.2.3 From b9d4431f6f2b60802d66da03f0b915bbd2c846cb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 29 Jun 2014 22:44:01 +0100 Subject: Fixed respawning * Fixes #1103 --- src/ClientHandle.cpp | 4 ++-- src/ClientHandle.h | 2 +- src/Entities/Player.cpp | 2 +- src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.cpp | 6 +++--- src/Protocol/Protocol125.h | 2 +- src/Protocol/Protocol16x.cpp | 4 ++-- src/Protocol/Protocol16x.h | 2 +- src/Protocol/Protocol17x.cpp | 6 +++--- src/Protocol/Protocol17x.h | 2 +- src/Protocol/ProtocolRecognizer.cpp | 4 ++-- src/Protocol/ProtocolRecognizer.h | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 662ee7927..6b71f0924 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -2397,9 +2397,9 @@ void cClientHandle::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effec -void cClientHandle::SendRespawn(const cWorld & a_World) +void cClientHandle::SendRespawn(const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks) { - m_Protocol->SendRespawn(a_World); + m_Protocol->SendRespawn(a_World, a_ShouldIgnoreDimensionChecks); } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 02bc0c719..6f2c86b27 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -156,7 +156,7 @@ public: void SendPlayerSpawn (const cPlayer & a_Player); void SendPluginMessage (const AString & a_Channel, const AString & a_Message); // Exported in ManualBindings.cpp void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID); - void SendRespawn (const cWorld & a_World); + void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false); void SendExperience (void); void SendExperienceOrb (const cExpOrb & a_ExpOrb); void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 0abe50d11..daf1ef2cc 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -976,7 +976,7 @@ void cPlayer::Respawn(void) m_LifetimeTotalXp = 0; // ToDo: send score to client? How? - m_ClientHandle->SendRespawn(*m_World); + m_ClientHandle->SendRespawn(*m_World, true); // Extinguish the fire: StopBurning(); diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index e08a5a51b..ac872a2f2 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -100,7 +100,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) = 0; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) = 0; - virtual void SendRespawn (const cWorld & a_World) = 0; + virtual void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false) = 0; virtual void SendExperience (void) = 0; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) = 0; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index d53427bf7..6dc2e918d 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -833,12 +833,12 @@ void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect -void cProtocol125::SendRespawn(const cWorld & a_World) +void cProtocol125::SendRespawn(const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks) { cCSLock Lock(m_CSPacket); - if (m_LastSentDimension == a_World.GetDimension()) + if ((m_LastSentDimension == a_World.GetDimension()) && !a_ShouldIgnoreDimensionChecks) { - // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do + // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do (unless we are respawning from death) return; } cPlayer * Player = m_Client->GetPlayer(); diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 747bf512d..9dbefd3a3 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -72,7 +72,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (const cWorld & a_World) override; + virtual void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp index 9e0f3f852..eba795f61 100644 --- a/src/Protocol/Protocol16x.cpp +++ b/src/Protocol/Protocol16x.cpp @@ -158,10 +158,10 @@ void cProtocol161::SendPlayerMaxSpeed(void) -void cProtocol161::SendRespawn(const cWorld & a_World) +void cProtocol161::SendRespawn(const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks) { // Besides sending the respawn, we need to also send the player max speed, otherwise the client reverts to super-fast - super::SendRespawn(a_World); + super::SendRespawn(a_World, a_ShouldIgnoreDimensionChecks); SendPlayerMaxSpeed(); } diff --git a/src/Protocol/Protocol16x.h b/src/Protocol/Protocol16x.h index e91dc8a1c..e6e79027e 100644 --- a/src/Protocol/Protocol16x.h +++ b/src/Protocol/Protocol16x.h @@ -42,7 +42,7 @@ protected: virtual void SendGameMode (eGameMode a_GameMode) override; virtual void SendHealth (void) override; virtual void SendPlayerMaxSpeed(void) override; - virtual void SendRespawn (const cWorld & a_World) override; + virtual void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false) override; virtual void SendWindowOpen (const cWindow & a_Window) override; virtual int ParseEntityAction (void) override; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 98fabedb2..df9c6b50d 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -986,11 +986,11 @@ void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect -void cProtocol172::SendRespawn(const cWorld & a_World) +void cProtocol172::SendRespawn(const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks) { - if (m_LastSentDimension == a_World.GetDimension()) + if ((m_LastSentDimension == a_World.GetDimension()) && !a_ShouldIgnoreDimensionChecks) { - // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do + // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do (unless we are respawning from death) return; } diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 07c8c8459..1a65cfa1c 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -104,7 +104,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (const cWorld & a_World) override; + virtual void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false) override; virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8 virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 2436c49c3..c0c9e08ee 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -556,10 +556,10 @@ void cProtocolRecognizer::SendRemoveEntityEffect(const cEntity & a_Entity, int a -void cProtocolRecognizer::SendRespawn(const cWorld & a_World) +void cProtocolRecognizer::SendRespawn(const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks) { ASSERT(m_Protocol != NULL); - m_Protocol->SendRespawn(a_World); + m_Protocol->SendRespawn(a_World, a_ShouldIgnoreDimensionChecks); } diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index a5a6c59b6..0a9a42e93 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -107,7 +107,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (const cWorld & a_World) override; + virtual void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; -- cgit v1.2.3 From 4ded58bfd1066d237588c542e511759e504c5c95 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 30 Jun 2014 14:19:31 +0200 Subject: Unnecessary return --- src/ClientHandle.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 6b71f0924..efa734b44 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1223,9 +1223,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e { // A plugin won't let us eat, abort (send the proper packets to the client, too): m_Player->AbortEating(); - return; } - return; } else { -- cgit v1.2.3 From aa753a92c092a4d35b2ff7d08259c3196abecf67 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 30 Jun 2014 15:12:56 +0200 Subject: Add new hook: HOOK_PLAYER_FOOD_LEVEL_CHANGE --- src/Bindings/Plugin.h | 1 + src/Bindings/PluginLua.cpp | 20 +++++++++++++++++ src/Bindings/PluginLua.h | 1 + src/Bindings/PluginManager.cpp | 19 ++++++++++++++++ src/Bindings/PluginManager.h | 2 ++ src/Entities/Player.cpp | 50 ++++++++++++++++++++---------------------- 6 files changed, 67 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index c6461c861..254209bd2 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -72,6 +72,7 @@ public: virtual bool OnPlayerEating (cPlayer & a_Player) = 0; virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) = 0; virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) = 0; + virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int & a_NewFoodLevel) = 0; virtual bool OnPlayerJoined (cPlayer & a_Player) = 0; virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) = 0; virtual bool OnPlayerMoved (cPlayer & a_Player) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 96c5ccde7..be27340ad 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -715,6 +715,26 @@ bool cPluginLua::OnPlayerEating(cPlayer & a_Player) +bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int & a_NewFoodLevel) +{ + cCSLock Lock(m_CriticalSection); + bool res = false; + cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FOOD_LEVEL_CHANGE]; + for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) + { + m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res); + if (res) + { + return true; + } + } + return false; +} + + + + + bool cPluginLua::OnPlayerFished(cPlayer & a_Player, const cItems & a_Reward) { cCSLock Lock(m_CriticalSection); diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 598e031c0..cf244f33d 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -95,6 +95,7 @@ public: virtual bool OnPlayerEating (cPlayer & a_Player) override; virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) override; virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) override; + virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int & a_NewFoodLevel) override; virtual bool OnPlayerJoined (cPlayer & a_Player) override; virtual bool OnPlayerMoved (cPlayer & a_Player) override; virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index c50100d6f..936c6b8a8 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -695,6 +695,25 @@ bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player) +bool cPluginManager::CallHookPlayerFoodLevelChange(cPlayer & a_Player, int & a_NewFoodLevel) +{ + FIND_HOOK(HOOK_PLAYER_FOOD_LEVEL_CHANGE); + VERIFY_HOOK; + + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnPlayerFoodLevelChange(a_Player, a_NewFoodLevel)) + { + return true; + } + } + return false; +} + + + + + bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Reward) { FIND_HOOK(HOOK_PLAYER_FISHED); diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index be40bd2f7..560a5c1d3 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -87,6 +87,7 @@ public: // tolua_export HOOK_PLAYER_EATING, HOOK_PLAYER_FISHED, HOOK_PLAYER_FISHING, + HOOK_PLAYER_FOOD_LEVEL_CHANGE, HOOK_PLAYER_JOINED, HOOK_PLAYER_LEFT_CLICK, HOOK_PLAYER_MOVING, @@ -188,6 +189,7 @@ public: // tolua_export bool CallHookPlayerEating (cPlayer & a_Player); bool CallHookPlayerFished (cPlayer & a_Player, const cItems a_Reward); bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward); + bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int & a_NewFoodLevel); bool CallHookPlayerJoined (cPlayer & a_Player); bool CallHookPlayerMoving (cPlayer & a_Player); bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index daf1ef2cc..ed18d2ab7 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -37,9 +37,9 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) : super(etPlayer, 0.6, 1.8) , m_bVisible(true) , m_FoodLevel(MAX_FOOD_LEVEL) - , m_FoodSaturationLevel(5) + , m_FoodSaturationLevel(5.0) , m_FoodTickTimer(0) - , m_FoodExhaustionLevel(0) + , m_FoodExhaustionLevel(0.0) , m_FoodPoisonedTicksRemaining(0) , m_LastJumpHeight(0) , m_LastGroundHeight(0) @@ -521,7 +521,15 @@ void cPlayer::Heal(int a_Health) void cPlayer::SetFoodLevel(int a_FoodLevel) { - m_FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL)); + a_FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL)); + + if (cRoot::Get()->GetPluginManager()->CallHookPlayerFoodLevelChange(*this, a_FoodLevel)) + { + m_FoodSaturationLevel = 5.0; + return; + } + + m_FoodLevel = a_FoodLevel; SendHealth(); } @@ -571,11 +579,9 @@ bool cPlayer::Feed(int a_Food, double a_Saturation) { return false; } - - m_FoodLevel = std::min(a_Food + m_FoodLevel, (int)MAX_FOOD_LEVEL); - m_FoodSaturationLevel = std::min(m_FoodSaturationLevel + a_Saturation, (double)m_FoodLevel); - - SendHealth(); + + SetFoodSaturationLevel(m_FoodSaturationLevel + a_Saturation); + SetFoodLevel(m_FoodLevel + a_Food); return true; } @@ -969,7 +975,7 @@ void cPlayer::Respawn(void) // Reset food level: m_FoodLevel = MAX_FOOD_LEVEL; - m_FoodSaturationLevel = 5; + m_FoodSaturationLevel = 5.0; // Reset Experience m_CurrentXp = 0; @@ -1895,16 +1901,13 @@ void cPlayer::TickBurning(cChunk & a_Chunk) void cPlayer::HandleFood(void) { // Ref.: http://www.minecraftwiki.net/wiki/Hunger - + if (IsGameModeCreative()) { // Hunger is disabled for Creative return; } - - // Remember the food level before processing, for later comparison - int LastFoodLevel = m_FoodLevel; - + // Heal or damage, based on the food level, using the m_FoodTickTimer: if ((m_FoodLevel > 17) || (m_FoodLevel <= 0)) { @@ -1917,7 +1920,7 @@ void cPlayer::HandleFood(void) { // Regenerate health from food, incur 3 pts of food exhaustion: Heal(1); - m_FoodExhaustionLevel += 3; + m_FoodExhaustionLevel += 3.0; } else if ((m_FoodLevel <= 0) && (m_Health > 1)) { @@ -1926,7 +1929,7 @@ void cPlayer::HandleFood(void) } } } - + // Apply food poisoning food exhaustion: if (m_FoodPoisonedTicksRemaining > 0) { @@ -1939,24 +1942,19 @@ void cPlayer::HandleFood(void) } // Apply food exhaustion that has accumulated: - if (m_FoodExhaustionLevel >= 4) + if (m_FoodExhaustionLevel >= 4.0) { - m_FoodExhaustionLevel -= 4; + m_FoodExhaustionLevel -= 4.0; - if (m_FoodSaturationLevel >= 1) + if (m_FoodSaturationLevel >= 1.0) { - m_FoodSaturationLevel -= 1; + m_FoodSaturationLevel -= 1.0; } else { - m_FoodLevel = std::max(m_FoodLevel - 1, 0); + SetFoodLevel(m_FoodLevel - 1); } } - - if (m_FoodLevel != LastFoodLevel) - { - SendHealth(); - } } -- cgit v1.2.3 From b94fef3089003b6b8958716cc8d12ffa03b5a779 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 30 Jun 2014 19:15:10 +0100 Subject: Removed unneeded code --- src/WorldStorage/NBTChunkSerializer.cpp | 15 +-------------- src/WorldStorage/NBTChunkSerializer.h | 2 -- src/WorldStorage/WSSAnvil.cpp | 21 --------------------- src/WorldStorage/WSSAnvil.h | 1 - 4 files changed, 1 insertion(+), 38 deletions(-) (limited to 'src') diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index baf74d830..bff515386 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -11,7 +11,6 @@ #include "FastNBT.h" #include "../BlockEntities/ChestEntity.h" -#include "../BlockEntities/EnderChestEntity.h" #include "../BlockEntities/CommandBlockEntity.h" #include "../BlockEntities/DispenserEntity.h" #include "../BlockEntities/DropperEntity.h" @@ -190,18 +189,6 @@ void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity) -void cNBTChunkSerializer::AddEnderChestEntity(cEnderChestEntity * a_Entity) -{ - m_Writer.BeginCompound(""); - AddBasicTileEntity(a_Entity, "EnderChest"); - // No need to store anything more - m_Writer.EndCompound(); -} - - - - - void cNBTChunkSerializer::AddDispenserEntity(cDispenserEntity * a_Entity) { m_Writer.BeginCompound(""); @@ -833,7 +820,7 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity) case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity); break; case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break; case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break; - case E_BLOCK_ENDER_CHEST: AddEnderChestEntity ((cEnderChestEntity *) a_Entity); break; + case E_BLOCK_ENDER_CHEST: /* No need to be saved */ break; case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break; case E_BLOCK_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break; case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break; diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h index a4c95f540..112afc27e 100644 --- a/src/WorldStorage/NBTChunkSerializer.h +++ b/src/WorldStorage/NBTChunkSerializer.h @@ -21,7 +21,6 @@ class cEntity; class cBlockEntity; class cBoat; class cChestEntity; -class cEnderChestEntity; class cCommandBlockEntity; class cDispenserEntity; class cDropperEntity; @@ -94,7 +93,6 @@ protected: // Block entities: void AddBasicTileEntity(cBlockEntity * a_Entity, const char * a_EntityTypeID); void AddChestEntity (cChestEntity * a_Entity); - void AddEnderChestEntity(cEnderChestEntity * a_Entity); void AddDispenserEntity(cDispenserEntity * a_Entity); void AddDropperEntity (cDropperEntity * a_Entity); void AddFurnaceEntity (cFurnaceEntity * a_Furnace); diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index e6170f8b7..9870c144a 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -16,7 +16,6 @@ #include "../StringCompression.h" #include "../BlockEntities/ChestEntity.h" -#include "../BlockEntities/EnderChestEntity.h" #include "../BlockEntities/CommandBlockEntity.h" #include "../BlockEntities/DispenserEntity.h" #include "../BlockEntities/DropperEntity.h" @@ -584,10 +583,6 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con if (strncmp(a_NBT.GetData(sID), "Chest", a_NBT.GetDataLength(sID)) == 0) { LoadChestFromNBT(a_BlockEntities, a_NBT, Child); - } - else if (strncmp(a_NBT.GetData(sID), "EnderChest", a_NBT.GetDataLength(sID)) == 0) - { - } else if (strncmp(a_NBT.GetData(sID), "Control", a_NBT.GetDataLength(sID)) == 0) { @@ -767,22 +762,6 @@ void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cPars -void cWSSAnvil::LoadEnderChestFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx) -{ - ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound); - int x, y, z; - if (!GetBlockEntityNBTPos(a_NBT, a_TagIdx, x, y, z)) - { - return; - } - std::auto_ptr EnderChest(new cEnderChestEntity(x, y, z, m_World)); - a_BlockEntities.push_back(EnderChest.release()); -} - - - - - void cWSSAnvil::LoadDispenserFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx) { ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound); diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h index 45fea70b6..7542a828a 100644 --- a/src/WorldStorage/WSSAnvil.h +++ b/src/WorldStorage/WSSAnvil.h @@ -134,7 +134,6 @@ protected: void LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a_NBT, int a_ItemsTagIdx, int s_SlotOffset = 0); void LoadChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); - void LoadEnderChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadDispenserFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadDropperFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadFlowerPotFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); -- cgit v1.2.3 From 85fae0e521d3a2ea4f083ee2bc54ac7fbb357768 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 30 Jun 2014 19:21:21 +0100 Subject: Implemented Vector3<>::Floor() --- src/Entities/ArrowEntity.cpp | 5 +++-- src/Vector3.h | 24 ++++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index c76c710ef..2d6683f0a 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -74,8 +74,9 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa Hit += SinkMovement; // Make arrow sink into block a little super::OnHitSolidBlock(Hit, a_HitFace); - int X = (int)floor(Hit.x), Y = (int)floor(Hit.y), Z = (int)floor(Hit.z); - + Hit.Floor(); + + int X = Hit.x, Y = Hit.y, Z = Hit.z; m_HitBlockPos = Vector3i(X, Y, Z); // Broadcast arrow hit sound diff --git a/src/Vector3.h b/src/Vector3.h index 762fdfd71..b5ddc705a 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -134,6 +134,22 @@ public: z += a_Diff.z; } + /** Runs each value of the vector through std::floor() */ + inline void Floor(void) + { + x = (T)floor(x); + y = (T)floor(y); + z = (T)floor(z); + } + + /** Clamps each value in the vector to within a specified range */ + inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ) + { + x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x)); + y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y)); + z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z)); + } + // tolua_end inline bool operator != (const Vector3 & a_Rhs) const @@ -274,14 +290,6 @@ public: return (a_X - x) / (a_OtherEnd.x - x); } - /** Clamps each value in the vector to within a specified range */ - inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ) - { - x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x)); - y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y)); - z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z)); - } - /** The max difference between two coords for which the coords are assumed equal. */ static const double EPS; -- cgit v1.2.3 From c3cde6232fae96a1c196d6bdf63b17ae996aee24 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 30 Jun 2014 20:23:17 +0200 Subject: Moved the random code to a function (cSheep::GenerateNaturalRandomColor()) --- src/Mobs/Sheep.cpp | 72 ++++++++++++++++++++++++++++++------------------------ src/Mobs/Sheep.h | 11 ++++++--- 2 files changed, 47 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index cc7315a86..e208aa891 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -20,39 +20,12 @@ cSheep::cSheep(int a_Color) : // Generate random wool color. if (m_WoolColor == -1) { - cFastRandom Random; - int Chance = Random.NextInt(101); + m_WoolColor = GenerateNaturalRandomColor(); + } - if (Chance <= 81) - { - // White - m_WoolColor = 0; - } - else if (Chance <= 86) - { - // Black - m_WoolColor = 15; - } - else if (Chance <= 91) - { - // Grey - m_WoolColor = 7; - } - else if (Chance <= 96) - { - // Light grey - m_WoolColor = 8; - } - else if (Chance <= 99) - { - // Brown - m_WoolColor = 12; - } - else - { - // Pink - m_WoolColor = 6; - } + if ((m_WoolColor < 0) || (m_WoolColor > 15)) + { + m_WoolColor = 0; } } @@ -148,3 +121,38 @@ void cSheep::Tick(float a_Dt, cChunk & a_Chunk) } } + + + + +NIBBLETYPE cSheep::GenerateNaturalRandomColor(void) +{ + cFastRandom Random; + int Chance = Random.NextInt(101); + + if (Chance <= 81) + { + return E_META_WOOL_WHITE; + } + else if (Chance <= 86) + { + return E_META_WOOL_BLACK; + } + else if (Chance <= 91) + { + return E_META_WOOL_GRAY; + } + else if (Chance <= 96) + { + return E_META_WOOL_LIGHTGRAY; + } + else if (Chance <= 99) + { + return E_META_WOOL_BROWN; + } + else + { + return E_META_WOOL_PINK; + } +} + diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h index 21dca7787..41de7924f 100644 --- a/src/Mobs/Sheep.h +++ b/src/Mobs/Sheep.h @@ -13,24 +13,27 @@ class cSheep : typedef cPassiveMonster super; public: + + /** Use -1 for random color. */ cSheep(int a_Color = -1); - + CLASS_PROTODEF(cSheep); - + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); } + static NIBBLETYPE GenerateNaturalRandomColor(void); + bool IsSheared(void) const { return m_IsSheared; } void SetSheared(bool a_IsSheared) { m_IsSheared = a_IsSheared; } int GetFurColor(void) const { return m_WoolColor; } - void SetFurColor(bool a_WoolColor) { m_WoolColor = a_WoolColor; } + void SetFurColor(int a_WoolColor) { m_WoolColor = a_WoolColor; } private: - bool m_IsSheared; int m_WoolColor; int m_TimeToStopEating; -- cgit v1.2.3 From a5a0533d793a64b76a84f23d4ca1754571ee0b40 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 30 Jun 2014 21:41:14 +0200 Subject: Fixed cFile compilation under MinGW. --- src/OSSupport/File.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp index 8c24fa541..addf8f928 100644 --- a/src/OSSupport/File.cpp +++ b/src/OSSupport/File.cpp @@ -7,6 +7,9 @@ #include "File.h" #include +#ifdef _WIN32 + #include // for _SH_DENYWRITE +#endif // _WIN32 -- cgit v1.2.3 From 8e11f7a1f64fd4d20495f1a4467ef168d18db92b Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 30 Jun 2014 21:50:40 +0200 Subject: Fixes. --- src/Bindings/PluginLua.cpp | 2 +- src/Entities/Player.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index be27340ad..2d485a117 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -722,7 +722,7 @@ bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int & a_NewFoodLeve cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FOOD_LEVEL_CHANGE]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res); + m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res, a_NewFoodLevel); if (res) { return true; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index ed18d2ab7..ab2dbc0cf 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -521,15 +521,15 @@ void cPlayer::Heal(int a_Health) void cPlayer::SetFoodLevel(int a_FoodLevel) { - a_FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL)); + int FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL)); - if (cRoot::Get()->GetPluginManager()->CallHookPlayerFoodLevelChange(*this, a_FoodLevel)) + if (cRoot::Get()->GetPluginManager()->CallHookPlayerFoodLevelChange(*this, FoodLevel)) { m_FoodSaturationLevel = 5.0; return; } - m_FoodLevel = a_FoodLevel; + m_FoodLevel = FoodLevel; SendHealth(); } -- cgit v1.2.3 From f9f3f7eac59c8de2bcb3f878849d355d5b9e3c9a Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 30 Jun 2014 21:58:23 +0200 Subject: Fixed size_t printfing under MinGW. --- src/Globals.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Globals.h b/src/Globals.h index c5768facf..0c11429bd 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -71,9 +71,24 @@ #define FORMATSTRING(formatIndex, va_argsIndex) __attribute__((format (printf, formatIndex, va_argsIndex))) - #define SIZE_T_FMT "%zu" - #define SIZE_T_FMT_PRECISION(x) "%" #x "zu" - #define SIZE_T_FMT_HEX "%zx" + #if defined(_WIN32) + // We're compiling on MinGW, which uses an old MSVCRT library that has no support for size_t printfing. + // We need direct size formats: + #if defined(_WIN64) + #define SIZE_T_FMT "%I64u" + #define SIZE_T_FMT_PRECISION(x) "%" #x "I64u" + #define SIZE_T_FMT_HEX "%I64x" + #else + #define SIZE_T_FMT "%u" + #define SIZE_T_FMT_PRECISION(x) "%" #x "u" + #define SIZE_T_FMT_HEX "%x" + #endif + #else + // We're compiling on Linux, so we can use libc's size_t printf format: + #define SIZE_T_FMT "%zu" + #define SIZE_T_FMT_PRECISION(x) "%" #x "zu" + #define SIZE_T_FMT_HEX "%zx" + #endif #define NORETURN __attribute((__noreturn__)) -- cgit v1.2.3 From 4f60f5aef4517d6d3eaf2ea9f7aae30e6a97da25 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 1 Jul 2014 06:40:38 +0200 Subject: Fixed linking order under MinGW. Ref.: #1044 --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f4d6ea13..b1b880b7b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -261,4 +261,4 @@ endif () if (WIN32) target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib) endif() -target_link_libraries(${EXECUTABLE} luaexpat iniFile jsoncpp polarssl zlib lua sqlite) +target_link_libraries(${EXECUTABLE} luaexpat iniFile jsoncpp polarssl zlib sqlite lua) -- cgit v1.2.3 From 64f6ddf1e2171dd7713f454c792916257e770f98 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 1 Jul 2014 14:47:49 +0200 Subject: Fix server-crash with non-existing items. --- src/Items/ItemHandler.cpp | 2 +- src/UI/Window.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index a2fd4e3f8..0f56b2b90 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -63,7 +63,7 @@ cItemHandler * cItemHandler::m_ItemHandler[2268]; cItemHandler * cItemHandler::GetItemHandler(int a_ItemType) { - if (a_ItemType < 0) + if ((a_ItemType < 0) || (a_ItemType >= ARRAYCOUNT(m_ItemHandler)) || (!IsValidBlock(a_ItemType) && !IsValidItem(a_ItemType))) { // Either nothing (-1), or bad value, both cases should return the air handler if (a_ItemType < -1) diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 98a9a0cec..af3e3e45c 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -170,7 +170,13 @@ void cWindow::Clicked( const cItem & a_ClickedItem ) { - cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); + if (!IsValidItem(a_ClickedItem.m_ItemType) && !IsValidBlock(a_ClickedItem.m_ItemType)) + { + LOGWARNING("%s: Player \"%s\" clicked to a non-existing item; ignoring click.", __FUNCTION__, a_Player.GetName().c_str()); + return; + } + + cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); if (a_WindowID != m_WindowID) { LOGWARNING("%s: Wrong window ID (exp %d, got %d) received from \"%s\"; ignoring click.", __FUNCTION__, m_WindowID, a_WindowID, a_Player.GetName().c_str()); -- cgit v1.2.3 From 64e66674355c84c091564197dcbdf26806e61659 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 1 Jul 2014 20:34:50 +0200 Subject: Only fixes the server crash. --- src/Items/ItemHandler.cpp | 2 +- src/UI/Window.cpp | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'src') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 0f56b2b90..423039cf4 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -63,7 +63,7 @@ cItemHandler * cItemHandler::m_ItemHandler[2268]; cItemHandler * cItemHandler::GetItemHandler(int a_ItemType) { - if ((a_ItemType < 0) || (a_ItemType >= ARRAYCOUNT(m_ItemHandler)) || (!IsValidBlock(a_ItemType) && !IsValidItem(a_ItemType))) + if ((a_ItemType < 0) || ((unsigned long)a_ItemType >= ARRAYCOUNT(m_ItemHandler))) { // Either nothing (-1), or bad value, both cases should return the air handler if (a_ItemType < -1) diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index af3e3e45c..e465b701a 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -170,12 +170,6 @@ void cWindow::Clicked( const cItem & a_ClickedItem ) { - if (!IsValidItem(a_ClickedItem.m_ItemType) && !IsValidBlock(a_ClickedItem.m_ItemType)) - { - LOGWARNING("%s: Player \"%s\" clicked to a non-existing item; ignoring click.", __FUNCTION__, a_Player.GetName().c_str()); - return; - } - cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); if (a_WindowID != m_WindowID) { -- cgit v1.2.3 From 68007ab3e5aba33fb3a8e34c0301401aef594737 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 1 Jul 2014 20:42:23 +0200 Subject: Add doxy-comments. --- src/Mobs/Sheep.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h index 41de7924f..36d7df826 100644 --- a/src/Mobs/Sheep.h +++ b/src/Mobs/Sheep.h @@ -14,7 +14,9 @@ class cSheep : public: - /** Use -1 for random color. */ + /** The number is the color of the sheep. + 0-15 are the normal colors, if you type -1 the server + automatically chooses the right color for the sheep when spawned. */ cSheep(int a_Color = -1); CLASS_PROTODEF(cSheep); @@ -25,6 +27,7 @@ public: virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); } + /** Generates a random color for the sheep, like Mojang it does. */ static NIBBLETYPE GenerateNaturalRandomColor(void); bool IsSheared(void) const { return m_IsSheared; } -- cgit v1.2.3 From 0dfaad4123bc50202f97fc0e5d9fc5d3a9c8670c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 1 Jul 2014 15:46:31 +0200 Subject: Fixed a possibly unused variable. --- src/Bindings/PluginLua.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 96c5ccde7..97366cc4c 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -1714,7 +1714,7 @@ bool cPluginLua::CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer ASSERT(a_FnRef != LUA_REFNIL); cCSLock Lock(m_CriticalSection); - bool res; + bool res = false; m_LuaState.Call(a_FnRef, &a_Window, &a_Player, a_CanRefuse, cLuaState::Return, res); return res; } -- cgit v1.2.3 From bb0e88fcf85846f5ff3cfb43d964657f14a1b6b7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 1 Jul 2014 21:28:45 +0200 Subject: Initial codegen for LuaState_Call.inc. --- src/Bindings/gen_LuaState_Call.lua | 196 +++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 src/Bindings/gen_LuaState_Call.lua (limited to 'src') diff --git a/src/Bindings/gen_LuaState_Call.lua b/src/Bindings/gen_LuaState_Call.lua new file mode 100644 index 000000000..fb1797dc0 --- /dev/null +++ b/src/Bindings/gen_LuaState_Call.lua @@ -0,0 +1,196 @@ + +-- gen_LuaState_Call.lua + +-- Generates the cLuaState::Call() function templates that are included from LuaState.h + +--[[ +The cLuaState::Call() family of functions provides a template-based system for calling any Lua function +either by name or by reference with almost any number of parameters and return values. This is done by +providing a number of overloads of the same name with variable number of template-type parameters. To +separate the arguments from the return values, a special type of cLuaState::cRet is used. +--]] + + + + +print("Generating LuaState_Call.inc...") + + + + +-- List of combinations (# params, # returns) to generate: +local Combinations = +{ + -- no return values: + {0, 0}, + {1, 0}, + {2, 0}, + {3, 0}, + {4, 0}, + + -- 1 return value: + {0, 1}, + {1, 1}, + {2, 1}, + {3, 1}, + {4, 1}, + {5, 1}, + {6, 1}, + {7, 1}, + {8, 1}, + {9, 1}, + {10, 1}, + + -- 2 return values: + {0, 2}, + {1, 2}, + {2, 2}, + {3, 2}, + {4, 2}, + {5, 2}, + {6, 2}, + {7, 2}, + {8, 2}, + {9, 2}, + + -- Special combinations: + {7, 3}, + {8, 3}, + {9, 5}, +} + + + + +--- Writes a single overloaded function definition for the specified number of params and returns into f +--[[ +The format for the generated function is this: +/** Call the specified 3-param 2-return Lua function: +Returns true if call succeeded, false if there was an error. */ +template +bool Call(FnT a_Function, ParamT1 a_Param1, ParamT2 a_Param2, ParamT3 a_Param3, const cLuaState::cRet & a_RetMark, RetT1 & a_Ret1, RetT2 & a_Ret2) +{ + UNUSED(a_RetMark); + if (!PushFunction(a_Function)) + { + return false; + } + Push(a_Param1); + Push(a_Param2); + Push(a_Param3); + if (!CallFunction(2)) + { + return false; + } + GetStackValue(-2, a_Ret1); + GetStackValue(-1, a_Ret2); + lua_pop(m_LuaState, 2); + return true; +} +Note especially the negative numbers in GetStackValue() calls. +--]] +local function WriteOverload(f, a_NumParams, a_NumReturns) + -- Write the function doxy-comments: + f:write("/** Call the specified ", a_NumParams, "-param ", a_NumReturns, "-return Lua function:\n") + f:write("Returns true if call succeeded, false if there was an error. */\n") + + -- Write the template <...> line: + f:write("template 0) then + for i = 1, a_NumReturns do + f:write(", typename RetT", i) + end + end + f:write(">\n") + + -- Write the function signature: + f:write("bool Call(") + f:write("FnT a_Function") + for i = 1, a_NumParams do + f:write(", ParamT", i, " a_Param", i) + end + if (a_NumReturns > 0) then + f:write(", const cLuaState::cRet & a_RetMark") + for i = 1, a_NumReturns do + f:write(", RetT", i, " & a_Ret", i) + end + end + f:write(")\n") + + -- Common code: + f:write("{\n") + if (a_NumReturns > 0) then + f:write("\tUNUSED(a_RetMark);\n") + end + f:write("\tif (!PushFunction(a_Function))\n") + f:write("\t{\n") + f:write("\t\treturn false;\n") + f:write("\t}\n") + + -- Push the params: + for i = 1, a_NumParams do + f:write("\tPush(a_Param", i, ");\n") + end + + -- Call the function: + f:write("\tif (!CallFunction(", a_NumReturns, "))\n") + f:write("\t{\n") + f:write("\t\treturn false;\n") + f:write("\t}\n") + + -- Get the return values: + for i = 1, a_NumReturns do + f:write("\tGetStackValue(", -1 - a_NumReturns + i, ", a_Ret", i, ");\n") + end + + -- Pop the returns off the stack, if needed: + if (a_NumReturns > 0) then + f:write("\tlua_pop(m_LuaState, ", a_NumReturns, ");\n") + end + + -- Everything ok: + f:write("\treturn true;\n") + f:write("}\n") + + -- Separate from the next function: + f:write("\n\n\n\n\n") +end + + + + + +local f = assert(io.open("LuaState_Call.inc", "w")) + +-- Write file header: +f:write([[ +// LuaState_Call.inc + +// This file is auto-generated by gen_LuaState_Call.lua +// Make changes to the generator instead of to this file! + +// This file contains the various overloads for the cLuaState::Call() function +// Each overload handles a different number of parameters / return values +]]) +f:write("\n\n\n\n\n") + +-- Write out a template function for each overload: +for _, combination in ipairs(Combinations) do + WriteOverload(f, combination[1], combination[2]) +end + +-- Close the generated file +f:close() + + + + + +print("LuaState_Call.inc generated") + + + + -- cgit v1.2.3 From b6d5d50b31e4fd0d34f42deb3aa51ebc8ae6f7f3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 1 Jul 2014 22:19:14 +0200 Subject: Tolua generates LuaState_Call.inc file. --- src/Bindings/.gitignore | 1 + src/Bindings/LuaState.h | 629 +--------------------------------- src/Bindings/virtual_method_hooks.lua | 14 + src/CMakeLists.txt | 11 +- 4 files changed, 31 insertions(+), 624 deletions(-) (limited to 'src') diff --git a/src/Bindings/.gitignore b/src/Bindings/.gitignore index af8aa76fa..0d00dd578 100644 --- a/src/Bindings/.gitignore +++ b/src/Bindings/.gitignore @@ -1 +1,2 @@ lua51.dll +LuaState_Call.inc diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index 066390e39..8aefa7c6b 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -9,10 +9,11 @@ Owned lua_State is created by calling Create() and the cLuaState automatically c Or, lua_State can be attached by calling Attach(), the cLuaState doesn't close such a state Attaching a state will automatically close an owned state. -Calling a Lua function is done by pushing the function, either by PushFunction() or PushFunctionFromRegistry(), -then pushing the arguments (PushString(), PushNumber(), PushUserData() etc.) and finally -executing CallFunction(). cLuaState automatically keeps track of the number of arguments and the name of the -function (for logging purposes), which makes the call less error-prone. +Calling a Lua function is done internally by pushing the function using PushFunction(), then pushing the +arguments and finally executing CallFunction(). cLuaState automatically keeps track of the number of +arguments and the name of the function (for logging purposes). After the call the return values are read from +the stack using GetStackValue(). All of this is wrapped in a templated function overloads cLuaState::Call(), +which is generated automatically by gen_LuaState_Call.lua script file into the LuaState_Call.inc file. Reference management is provided by the cLuaState::cRef class. This is used when you need to hold a reference to any Lua object across several function calls; usually this is used for callbacks. The class is RAII-like, with @@ -223,624 +224,8 @@ public: void GetStackValue(int a_StackPos, double & a_Value); - /** Call any 0-param 0-return Lua function in a single line: */ - template - bool Call(FnT a_FnName) - { - if (!PushFunction(a_FnName)) - { - return false; - } - return CallFunction(0); - } - - /** Call any 1-param 0-return Lua function in a single line: */ - template< - typename FnT, - typename ArgT1 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1) - { - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - return CallFunction(0); - } - - /** Call any 2-param 0-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2) - { - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - return CallFunction(0); - } - - /** Call any 3-param 0-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3) - { - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - return CallFunction(0); - } - - /** Call any 0-param 1-return Lua function in a single line: */ - template< - typename FnT, typename RetT1 - > - bool Call(FnT a_FnName, const cRet & a_Mark, RetT1 & a_Ret1) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - if (!CallFunction(1)) - { - return false; - } - GetStackValue(-1, a_Ret1); - lua_pop(m_LuaState, 1); - return true; - } - - /** Call any 1-param 1-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename RetT1 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1) - { - int InitialTop = lua_gettop(m_LuaState); - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - if (!CallFunction(1)) - { - return false; - } - GetStackValue(-1, a_Ret1); - lua_pop(m_LuaState, 1); - ASSERT(InitialTop == lua_gettop(m_LuaState)); - return true; - } - - /** Call any 2-param 1-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename RetT1 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - if (!CallFunction(1)) - { - return false; - } - GetStackValue(-1, a_Ret1); - lua_pop(m_LuaState, 1); - return true; - } - - /** Call any 3-param 1-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename RetT1 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - if (!CallFunction(1)) - { - return false; - } - GetStackValue(-1, a_Ret1); - lua_pop(m_LuaState, 1); - return true; - } - - /** Call any 4-param 1-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename RetT1 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - if (!CallFunction(1)) - { - return false; - } - GetStackValue(-1, a_Ret1); - lua_pop(m_LuaState, 1); - return true; - } - - /** Call any 5-param 1-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename RetT1 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - Push(a_Arg5); - if (!CallFunction(1)) - { - return false; - } - GetStackValue(-1, a_Ret1); - lua_pop(m_LuaState, 1); - return true; - } - - /** Call any 6-param 1-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, - typename RetT1 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - Push(a_Arg5); - Push(a_Arg6); - if (!CallFunction(1)) - { - return false; - } - GetStackValue(-1, a_Ret1); - lua_pop(m_LuaState, 1); - return true; - } - - /** Call any 7-param 1-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, - typename ArgT7, typename RetT1 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - Push(a_Arg5); - Push(a_Arg6); - Push(a_Arg7); - if (!CallFunction(1)) - { - return false; - } - GetStackValue(-1, a_Ret1); - lua_pop(m_LuaState, 1); - return true; - } - - /** Call any 8-param 1-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, - typename ArgT7, typename ArgT8, typename RetT1 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - Push(a_Arg5); - Push(a_Arg6); - Push(a_Arg7); - Push(a_Arg8); - if (!CallFunction(1)) - { - return false; - } - GetStackValue(-1, a_Ret1); - lua_pop(m_LuaState, 1); - return true; - } - - /** Call any 9-param 1-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, - typename ArgT7, typename ArgT8, typename ArgT9, typename RetT1 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - Push(a_Arg5); - Push(a_Arg6); - Push(a_Arg7); - Push(a_Arg8); - Push(a_Arg9); - if (!CallFunction(1)) - { - return false; - } - GetStackValue(-1, a_Ret1); - lua_pop(m_LuaState, 1); - return true; - } - - /** Call any 10-param 1-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, - typename ArgT7, typename ArgT8, typename ArgT9, typename ArgT10, typename RetT1 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, ArgT10 a_Arg10, const cRet & a_Mark, RetT1 & a_Ret1) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - Push(a_Arg5); - Push(a_Arg6); - Push(a_Arg7); - Push(a_Arg8); - Push(a_Arg9); - Push(a_Arg10); - if (!CallFunction(1)) - { - return false; - } - GetStackValue(-1, a_Ret1); - lua_pop(m_LuaState, 1); - return true; - } - - /** Call any 1-param 2-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename RetT1, typename RetT2 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - if (!CallFunction(2)) - { - return false; - } - GetStackValue(-2, a_Ret1); - GetStackValue(-1, a_Ret2); - lua_pop(m_LuaState, 2); - return true; - } - - /** Call any 2-param 2-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename RetT1, typename RetT2 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - if (!CallFunction(2)) - { - return false; - } - GetStackValue(-2, a_Ret1); - GetStackValue(-1, a_Ret2); - lua_pop(m_LuaState, 2); - return true; - } - - /** Call any 3-param 2-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, - typename RetT1, typename RetT2 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - if (!CallFunction(2)) - { - return false; - } - GetStackValue(-2, a_Ret1); - GetStackValue(-1, a_Ret2); - lua_pop(m_LuaState, 2); - return true; - } - - /** Call any 4-param 2-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, - typename RetT1, typename RetT2 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - if (!CallFunction(2)) - { - return false; - } - GetStackValue(-2, a_Ret1); - GetStackValue(-1, a_Ret2); - lua_pop(m_LuaState, 2); - return true; - } - - /** Call any 5-param 2-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, - typename RetT1, typename RetT2 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - Push(a_Arg5); - if (!CallFunction(2)) - { - return false; - } - GetStackValue(-2, a_Ret1); - GetStackValue(-1, a_Ret2); - lua_pop(m_LuaState, 2); - return true; - } - - /** Call any 6-param 2-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, - typename ArgT6, - typename RetT1, typename RetT2 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - Push(a_Arg5); - Push(a_Arg6); - if (!CallFunction(2)) - { - return false; - } - GetStackValue(-2, a_Ret1); - GetStackValue(-1, a_Ret2); - lua_pop(m_LuaState, 2); - return true; - } - - /** Call any 7-param 2-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, - typename ArgT6, typename ArgT7, - typename RetT1, typename RetT2 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - Push(a_Arg5); - Push(a_Arg6); - Push(a_Arg7); - if (!CallFunction(2)) - { - return false; - } - GetStackValue(-2, a_Ret1); - GetStackValue(-1, a_Ret2); - lua_pop(m_LuaState, 2); - return true; - } - - /** Call any 7-param 3-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, - typename ArgT6, typename ArgT7, - typename RetT1, typename RetT2, typename RetT3 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - Push(a_Arg5); - Push(a_Arg6); - Push(a_Arg7); - if (!CallFunction(3)) - { - return false; - } - GetStackValue(-3, a_Ret1); - GetStackValue(-2, a_Ret2); - GetStackValue(-1, a_Ret3); - lua_pop(m_LuaState, 3); - return true; - } - - /** Call any 8-param 3-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, - typename ArgT6, typename ArgT7, typename ArgT8, - typename RetT1, typename RetT2, typename RetT3 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - Push(a_Arg5); - Push(a_Arg6); - Push(a_Arg7); - Push(a_Arg8); - if (!CallFunction(3)) - { - return false; - } - GetStackValue(-3, a_Ret1); - GetStackValue(-2, a_Ret2); - GetStackValue(-1, a_Ret3); - lua_pop(m_LuaState, 3); - return true; - } - - /** Call any 9-param 5-return Lua function in a single line: */ - template< - typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, - typename ArgT6, typename ArgT7, typename ArgT8, typename ArgT9, - typename RetT1, typename RetT2, typename RetT3, typename RetT4, typename RetT5 - > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3, RetT4 & a_Ret4, RetT5 & a_Ret5) - { - UNUSED(a_Mark); - if (!PushFunction(a_FnName)) - { - return false; - } - Push(a_Arg1); - Push(a_Arg2); - Push(a_Arg3); - Push(a_Arg4); - Push(a_Arg5); - Push(a_Arg6); - Push(a_Arg7); - Push(a_Arg8); - Push(a_Arg9); - if (!CallFunction(5)) - { - return false; - } - GetStackValue(-5, a_Ret1); - GetStackValue(-4, a_Ret2); - GetStackValue(-3, a_Ret3); - GetStackValue(-2, a_Ret4); - GetStackValue(-1, a_Ret5); - lua_pop(m_LuaState, 5); - return true; - } + // Include the cLuaState::Call() overload implementation that is generated by the gen_LuaState_Call.lua script: + #include "LuaState_Call.inc" /** Returns true if the specified parameters on the stack are of the specified usertable type; also logs warning if not. Used for static functions */ diff --git a/src/Bindings/virtual_method_hooks.lua b/src/Bindings/virtual_method_hooks.lua index c610d424f..8ad30bf78 100644 --- a/src/Bindings/virtual_method_hooks.lua +++ b/src/Bindings/virtual_method_hooks.lua @@ -3,6 +3,20 @@ local disable_virtual_hooks = true local enable_pure_virtual = true local default_private_access = false + + + + +-- Code generators used by the build +-- Note that these are not exactly needed for the bindings, but rather we +-- misuse tolua's Lua engine to process files for us +dofile("gen_LuaState_Call.lua") + + + + + + local access = {public = 0, protected = 1, private = 2} function preparse_hook(p) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b1b880b7b..c40e5edff 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,6 +12,7 @@ set(BINDING_DEPENDECIES tolua ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/virtual_method_hooks.lua ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/AllToLua.pkg + Bindings/gen_LuaState_Call.lua Bindings/LuaFunctions.h Bindings/LuaWindow.h Bindings/Plugin.h @@ -79,13 +80,19 @@ set(BINDING_DEPENDECIES World.h ) +# List all the files that are generated as part of the Bindings build process +set (BINDING_OUTPUTS + ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h + ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/LuaState_Call.inc +) + include_directories(Bindings) include_directories(.) if (WIN32) ADD_CUSTOM_COMMAND( - # add any new generated bindings here - OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h + OUTPUT ${BINDING_OUTPUTS} # Copy the Lua DLL into the Bindings folder, so that tolua can run from there: COMMAND copy /y ..\\..\\MCServer\\lua51.dll . -- cgit v1.2.3 From 7177806d31a5c6df52a8439bee2f4d150fa0eb47 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 30 Jun 2014 22:37:26 +0200 Subject: Fixed printf formats for Win builds --- src/OSSupport/Event.cpp | 6 +++--- src/OSSupport/IsThread.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/OSSupport/Event.cpp b/src/OSSupport/Event.cpp index 6b8fccde2..72bce4c3c 100644 --- a/src/OSSupport/Event.cpp +++ b/src/OSSupport/Event.cpp @@ -18,7 +18,7 @@ cEvent::cEvent(void) m_Event = CreateEvent(NULL, FALSE, FALSE, NULL); if (m_Event == NULL) { - LOGERROR("cEvent: cannot create event, GLE = %d. Aborting server.", GetLastError()); + LOGERROR("cEvent: cannot create event, GLE = %u. Aborting server.", (unsigned)GetLastError()); abort(); } #else // *nix @@ -86,7 +86,7 @@ void cEvent::Wait(void) DWORD res = WaitForSingleObject(m_Event, INFINITE); if (res != WAIT_OBJECT_0) { - LOGWARN("cEvent: waiting for the event failed: %d, GLE = %d. Continuing, but server may be unstable.", res, GetLastError()); + LOGWARN("cEvent: waiting for the event failed: %u, GLE = %u. Continuing, but server may be unstable.", (unsigned)res, (unsigned)GetLastError()); } #else int res = sem_wait(m_Event); @@ -107,7 +107,7 @@ void cEvent::Set(void) #ifdef _WIN32 if (!SetEvent(m_Event)) { - LOGWARN("cEvent: Could not set cEvent: GLE = %d", GetLastError()); + LOGWARN("cEvent: Could not set cEvent: GLE = %u", (unsigned)GetLastError()); } #else int res = sem_post(m_Event); diff --git a/src/OSSupport/IsThread.cpp b/src/OSSupport/IsThread.cpp index 67f336c97..1a436623a 100644 --- a/src/OSSupport/IsThread.cpp +++ b/src/OSSupport/IsThread.cpp @@ -90,7 +90,7 @@ bool cIsThread::Start(void) m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &m_ThreadID); if (m_Handle == NULL) { - LOGERROR("ERROR: Could not create thread \"%s\", GLE = %d!", m_ThreadName.c_str(), GetLastError()); + LOGERROR("ERROR: Could not create thread \"%s\", GLE = %u!", m_ThreadName.c_str(), (unsigned)GetLastError()); return false; } ResumeThread(m_Handle); -- cgit v1.2.3 From 284c1c0514168e30338f2ad372b7e7f185dba0c4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 1 Jul 2014 22:39:37 +0100 Subject: Vector clamping fixes Thank you, @madmaxoft. --- src/Entities/ArrowEntity.cpp | 12 ++++++++---- src/Vector3.h | 33 ++++++++++++++++----------------- 2 files changed, 24 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 2d6683f0a..7e96a666d 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -69,14 +69,18 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { Vector3d Hit = a_HitPos; - Vector3d SinkMovement = GetSpeed() / 800; - SinkMovement.Clamp(0.001, 0.001, 0.001, 0.05, 0.05, 0.05); + Vector3d SinkMovement = GetSpeed() / 800; // Base value for arrow penetration + SinkMovement = Clamp( // Adjust the movement so that fast arrows don't go through blocks (though in reality they would, in addition to exploding into fragments :P) + SinkMovement, + (SinkMovement * 0.001) / SinkMovement.Length(), + (SinkMovement * 0.05) / SinkMovement.Length() + ); Hit += SinkMovement; // Make arrow sink into block a little super::OnHitSolidBlock(Hit, a_HitFace); - Hit.Floor(); + Vector3i BlockHit = Hit.Floor(); - int X = Hit.x, Y = Hit.y, Z = Hit.z; + int X = BlockHit.x, Y = BlockHit.y, Z = BlockHit.z; m_HitBlockPos = Vector3i(X, Y, Z); // Broadcast arrow hit sound diff --git a/src/Vector3.h b/src/Vector3.h index b5ddc705a..faf7fe43c 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -135,19 +135,13 @@ public: } /** Runs each value of the vector through std::floor() */ - inline void Floor(void) + inline Vector3 Floor(void) const { - x = (T)floor(x); - y = (T)floor(y); - z = (T)floor(z); - } - - /** Clamps each value in the vector to within a specified range */ - inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ) - { - x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x)); - y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y)); - z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z)); + return Vector3( + (T)floor(x), + (T)floor(y), + (T)floor(z) + ); } // tolua_end @@ -162,6 +156,16 @@ public: return Equals(a_Rhs); } + inline bool operator > (const Vector3 & a_Rhs) const + { + return (SqrLength() > a_Rhs.SqrLength()); + } + + inline bool operator < (const Vector3 & a_Rhs) const + { + return (SqrLength() < a_Rhs.SqrLength()); + } + inline void operator += (const Vector3 & a_Rhs) { x += a_Rhs.x; @@ -305,11 +309,6 @@ protected: return (a_Value < 0) ? -a_Value : a_Value; } - /** Clamp X to the specified range. */ - T Clamp(T a_Value, T a_Min, T a_Max) - { - return (a_Value < a_Min) ? a_Min : ((a_Value > a_Max) ? a_Max : a_Value); - } }; // tolua_end -- cgit v1.2.3 From 4a9002045b86406ffd4bb16f67d33ae4060e6bc7 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 2 Jul 2014 14:46:00 +0200 Subject: Removed foodlevel-change possibility. Plugins can cancel the event and use cPlayer:SetFoodLevel() --- src/Bindings/Plugin.h | 2 +- src/Bindings/PluginLua.cpp | 4 ++-- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 2 +- src/Bindings/PluginManager.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 254209bd2..8ba20c026 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -72,7 +72,7 @@ public: virtual bool OnPlayerEating (cPlayer & a_Player) = 0; virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) = 0; virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) = 0; - virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int & a_NewFoodLevel) = 0; + virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) = 0; virtual bool OnPlayerJoined (cPlayer & a_Player) = 0; virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) = 0; virtual bool OnPlayerMoved (cPlayer & a_Player) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 2d485a117..542ae3e56 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -715,14 +715,14 @@ bool cPluginLua::OnPlayerEating(cPlayer & a_Player) -bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int & a_NewFoodLevel) +bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel) { cCSLock Lock(m_CriticalSection); bool res = false; cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FOOD_LEVEL_CHANGE]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res, a_NewFoodLevel); + m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res); if (res) { return true; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index cf244f33d..9c9de95c6 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -95,7 +95,7 @@ public: virtual bool OnPlayerEating (cPlayer & a_Player) override; virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) override; virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) override; - virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int & a_NewFoodLevel) override; + virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) override; virtual bool OnPlayerJoined (cPlayer & a_Player) override; virtual bool OnPlayerMoved (cPlayer & a_Player) override; virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 936c6b8a8..3cb8c99a1 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -695,7 +695,7 @@ bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player) -bool cPluginManager::CallHookPlayerFoodLevelChange(cPlayer & a_Player, int & a_NewFoodLevel) +bool cPluginManager::CallHookPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel) { FIND_HOOK(HOOK_PLAYER_FOOD_LEVEL_CHANGE); VERIFY_HOOK; diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 560a5c1d3..72cedfae1 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -189,7 +189,7 @@ public: // tolua_export bool CallHookPlayerEating (cPlayer & a_Player); bool CallHookPlayerFished (cPlayer & a_Player, const cItems a_Reward); bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward); - bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int & a_NewFoodLevel); + bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel); bool CallHookPlayerJoined (cPlayer & a_Player); bool CallHookPlayerMoving (cPlayer & a_Player); bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status); -- cgit v1.2.3 From 1c16862ae522b2124e7fd3b1a2dce7807f33b503 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 2 Jul 2014 16:30:13 +0200 Subject: CMake: Use cmake for file-copying. This should enable MSYS builds. --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b1b880b7b..c905ebebe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -88,7 +88,7 @@ if (WIN32) OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h # Copy the Lua DLL into the Bindings folder, so that tolua can run from there: - COMMAND copy /y ..\\..\\MCServer\\lua51.dll . + COMMAND ${CMAKE_COMMAND} -E copy_if_different ..\\..\\MCServer\\lua51.dll .\\lua51.dll # Regenerate bindings: COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg -- cgit v1.2.3 From 19caba5125e457a9663102989ea717898e3c2827 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 2 Jul 2014 18:46:00 +0100 Subject: Redstone simulator is alerted to lever unpowering * Fixed the "fix" that broke the fix for #535, thereby fixing said issue * Fixed #535 --- src/Blocks/BlockButton.h | 1 + src/Blocks/BlockLever.h | 1 + src/Blocks/WorldInterface.h | 3 +++ src/World.h | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index 7d9af207d..ada7d58f7 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -23,6 +23,7 @@ public: NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) | 0x08); a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta); + a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ); a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f); // Queue a button reset (unpress) diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h index afe43abf8..4e745d413 100644 --- a/src/Blocks/BlockLever.h +++ b/src/Blocks/BlockLever.h @@ -23,6 +23,7 @@ public: NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08); a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta); + a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ); a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f); } diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h index 650a216c0..251b28d03 100644 --- a/src/Blocks/WorldInterface.h +++ b/src/Blocks/WorldInterface.h @@ -46,4 +46,7 @@ public: virtual void SetTimeOfDay(Int64 a_TimeOfDay) = 0; + /** Wakes up the simulators for the specified block */ + virtual void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) = 0; + }; diff --git a/src/World.h b/src/World.h index 692d5a497..32e64c8e0 100644 --- a/src/World.h +++ b/src/World.h @@ -486,7 +486,7 @@ public: double GetSpawnZ(void) const { return m_SpawnZ; } /** Wakes up the simulators for the specified block */ - void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ); + virtual void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) override; /** Wakes up the simulators for the specified area of blocks */ void WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ); -- cgit v1.2.3 From c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 2 Jul 2014 18:46:13 +0100 Subject: Fixed player teleport food drain --- src/Entities/Player.cpp | 10 +++++++++- src/Entities/Player.h | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index daf1ef2cc..66791eb7c 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -71,6 +71,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) , m_FloaterID(-1) , m_Team(NULL) , m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL) + , m_bIsTeleporting(false) { LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d", a_PlayerName.c_str(), a_Client->GetIPString().c_str(), @@ -225,7 +226,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) SendExperience(); } - if (GetPosition() != m_LastPos) // Change in position from last tick? + if (!GetPosition().EqualsEps(m_LastPos, 0.01)) // Non negligible change in position from last tick? { // Apply food exhaustion from movement: ApplyFoodExhaustionFromMovement(); @@ -970,6 +971,7 @@ void cPlayer::Respawn(void) // Reset food level: m_FoodLevel = MAX_FOOD_LEVEL; m_FoodSaturationLevel = 5; + m_FoodExhaustionLevel = 0; // Reset Experience m_CurrentXp = 0; @@ -1226,6 +1228,7 @@ void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) SetPosition(a_PosX, a_PosY, a_PosZ); m_LastGroundHeight = (float)a_PosY; m_LastJumpHeight = (float)a_PosY; + m_bIsTeleporting = true; m_World->BroadcastTeleportEntity(*this, GetClientHandle()); m_ClientHandle->SendPlayerMoveLook(); @@ -2079,6 +2082,11 @@ void cPlayer::ApplyFoodExhaustionFromMovement() { return; } + if (m_bIsTeleporting) + { + m_bIsTeleporting = false; + return; + } // If riding anything, apply no food exhaustion if (m_AttachedTo != NULL) diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 2f7957f16..9e443b468 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -546,6 +546,11 @@ protected: Default save interval is #defined in PLAYER_INVENTORY_SAVE_INTERVAL */ unsigned int m_TicksUntilNextSave; + /** Flag used by food handling system to determine whether a teleport has just happened + Will not apply food penalties if found to be true; will set to false after processing + */ + bool m_bIsTeleporting; + } ; // tolua_export -- cgit v1.2.3 From abb49d3f338de4078177d1b95e3ed8d195119b50 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 2 Jul 2014 18:51:37 +0100 Subject: Suggestion --- src/Entities/Player.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index aeeea3d07..f888af642 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1787,20 +1787,20 @@ bool cPlayer::SaveToDisk() cEnderChestEntity::SaveToJson(JSON_EnderChestInventory, m_EnderChestContents); Json::Value root; - root["position"] = JSON_PlayerPosition; - root["rotation"] = JSON_PlayerRotation; - root["inventory"] = JSON_Inventory; + root["position"] = JSON_PlayerPosition; + root["rotation"] = JSON_PlayerRotation; + root["inventory"] = JSON_Inventory; root["enderchestinventory"] = JSON_EnderChestInventory; - root["health"] = m_Health; - root["xpTotal"] = m_LifetimeTotalXp; - root["xpCurrent"] = m_CurrentXp; - root["air"] = m_AirLevel; - root["food"] = m_FoodLevel; - root["foodSaturation"] = m_FoodSaturationLevel; - root["foodTickTimer"] = m_FoodTickTimer; - root["foodExhaustion"] = m_FoodExhaustionLevel; - root["world"] = GetWorld()->GetName(); - root["isflying"] = IsFlying(); + root["health"] = m_Health; + root["xpTotal"] = m_LifetimeTotalXp; + root["xpCurrent"] = m_CurrentXp; + root["air"] = m_AirLevel; + root["food"] = m_FoodLevel; + root["foodSaturation"] = m_FoodSaturationLevel; + root["foodTickTimer"] = m_FoodTickTimer; + root["foodExhaustion"] = m_FoodExhaustionLevel; + root["world"] = GetWorld()->GetName(); + root["isflying"] = IsFlying(); if (m_GameMode == GetWorld()->GetGameMode()) { -- cgit v1.2.3 From 89a26cc786f3673cf7b5a100300d8aa595735cc3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 2 Jul 2014 21:07:34 +0100 Subject: Suggestions --- src/Entities/ArrowEntity.cpp | 16 ++++++++-------- src/Entities/ArrowEntity.h | 6 ++++++ src/WorldStorage/NBTChunkSerializer.cpp | 17 ++++++++--------- src/WorldStorage/WSSAnvil.cpp | 11 +++++++++-- 4 files changed, 31 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 7e96a666d..c039b0b3c 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -67,15 +67,15 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) -{ +{ + if (GetSpeed().SqrLength() == 0) + { + SetSpeed(GetLookVector().NormalizeCopy() * 0.1); // Ensure that no division by zero happens later + } + Vector3d Hit = a_HitPos; - Vector3d SinkMovement = GetSpeed() / 800; // Base value for arrow penetration - SinkMovement = Clamp( // Adjust the movement so that fast arrows don't go through blocks (though in reality they would, in addition to exploding into fragments :P) - SinkMovement, - (SinkMovement * 0.001) / SinkMovement.Length(), - (SinkMovement * 0.05) / SinkMovement.Length() - ); - Hit += SinkMovement; // Make arrow sink into block a little + Vector3d SinkMovement = (GetSpeed() / 800); + Hit += (SinkMovement * 0.01) / SinkMovement.Length(); // Make arrow sink into block a centimetre so it lodges (but not to far so it goes black clientside) super::OnHitSolidBlock(Hit, a_HitFace); Vector3i BlockHit = Hit.Floor(); diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h index 1fe3032ee..99b7bae31 100644 --- a/src/Entities/ArrowEntity.h +++ b/src/Entities/ArrowEntity.h @@ -58,8 +58,14 @@ public: /// Sets the IsCritical flag void SetIsCritical(bool a_IsCritical) { m_IsCritical = a_IsCritical; } + + /** Gets the block arrow is in */ + Vector3i GetBlockHit(void) const { return m_HitBlockPos; } // tolua_end + + /** Sets the block arrow is in */ + void SetBlockHit(const Vector3i & a_BlockHit) { m_HitBlockPos = a_BlockHit; } protected: diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 8294d4a00..e49042ff7 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -589,20 +589,19 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) m_Writer.BeginCompound(""); AddBasicEntity(a_Projectile, a_Projectile->GetMCAClassName()); Vector3d Pos = a_Projectile->GetPosition(); - m_Writer.AddShort("xTile", (Int16)floor(Pos.x)); - m_Writer.AddShort("yTile", (Int16)floor(Pos.y)); - m_Writer.AddShort("zTile", (Int16)floor(Pos.z)); - m_Writer.AddShort("inTile", 0); // TODO: Query the block type - m_Writer.AddShort("shake", 0); // TODO: Any shake? - m_Writer.AddByte ("inGround", a_Projectile->IsInGround() ? 1 : 0); + m_Writer.AddByte("inGround", a_Projectile->IsInGround() ? 1 : 0); switch (a_Projectile->GetProjectileKind()) { case cProjectileEntity::pkArrow: { - m_Writer.AddByte("inData", 0); // TODO: Query the block meta (is it needed?) - m_Writer.AddByte("pickup", ((cArrowEntity *)a_Projectile)->GetPickupState()); - m_Writer.AddDouble("damage", ((cArrowEntity *)a_Projectile)->GetDamageCoeff()); + cArrowEntity * Arrow = (cArrowEntity *)a_Projectile; + + m_Writer.AddInt("xTile", (Int16)Arrow->GetBlockHit().x); + m_Writer.AddInt("yTile", (Int16)Arrow->GetBlockHit().y); + m_Writer.AddInt("zTile", (Int16)Arrow->GetBlockHit().z); + m_Writer.AddByte("pickup", Arrow->GetPickupState()); + m_Writer.AddDouble("damage", Arrow->GetDamageCoeff()); break; } case cProjectileEntity::pkGhastFireball: diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 0f84a0eb1..1e9ce80cc 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1656,6 +1656,15 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ Arrow->SetDamageCoeff(a_NBT.GetDouble(DamageIdx)); } + // Load block hit: + int InBlockXIdx = a_NBT.FindChildByName(a_TagIdx, "xTile"); + int InBlockYIdx = a_NBT.FindChildByName(a_TagIdx, "yTile"); + int InBlockZIdx = a_NBT.FindChildByName(a_TagIdx, "zTile"); + if ((InBlockXIdx > 0) && (InBlockYIdx > 0) && (InBlockZIdx > 0)) + { + Arrow->SetBlockHit(Vector3i(a_NBT.GetInt(InBlockXIdx), a_NBT.GetInt(InBlockYIdx), a_NBT.GetInt(InBlockZIdx))); + } + // Store the new arrow in the entities list: a_Entities.push_back(Arrow.release()); } @@ -2481,8 +2490,6 @@ bool cWSSAnvil::LoadProjectileBaseFromNBT(cProjectileEntity & a_Entity, const cP } a_Entity.SetIsInGround(IsInGround); - // TODO: Load inTile, TileCoords - return true; } -- cgit v1.2.3 From 78dd02f0c7195d046bfd4c50f96c12d95ad92ae0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 3 Jul 2014 10:11:46 +0200 Subject: CMake: Changed slash format to support MSYS. Ref.: #1044 --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c905ebebe..55f3028ef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -88,7 +88,7 @@ if (WIN32) OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h # Copy the Lua DLL into the Bindings folder, so that tolua can run from there: - COMMAND ${CMAKE_COMMAND} -E copy_if_different ..\\..\\MCServer\\lua51.dll .\\lua51.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ../../MCServer/lua51.dll ./lua51.dll # Regenerate bindings: COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg -- cgit v1.2.3 From 2dbed03cbce873d8a6582bfdc5c4b826b6e7eade Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 3 Jul 2014 17:49:21 +0200 Subject: Changed OnWeatherChanging hook to always read the returned weather. Ref.: http://forum.mc-server.org/showthread.php?tid=1512 --- src/Bindings/LuaState.cpp | 12 ++++++++++++ src/Bindings/LuaState.h | 5 +++++ src/Bindings/PluginLua.cpp | 5 +---- 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 7a5ed1425..32638df96 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -811,6 +811,18 @@ void cLuaState::GetStackValue(int a_StackPos, double & a_ReturnedVal) +void cLuaState::GetStackValue(int a_StackPos, eWeather & a_ReturnedVal) +{ + if (lua_isnumber(m_LuaState, a_StackPos)) + { + a_ReturnedVal = (eWeather)Clamp((int)tolua_tonumber(m_LuaState, a_StackPos, a_ReturnedVal), (int)wSunny, (int)wThunderstorm); + } +} + + + + + bool cLuaState::CallFunction(int a_NumResults) { ASSERT (m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index 066390e39..723193ae7 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -30,6 +30,7 @@ extern "C" } #include "../Vector3.h" +#include "../Defines.h" @@ -222,6 +223,10 @@ public: /** Retrieve value at a_StackPos, if it is a valid number. If not, a_Value is unchanged */ void GetStackValue(int a_StackPos, double & a_Value); + /** Retrieve value at a_StackPos, if it is a valid number, converting and clamping it to eWeather. + If not, a_Value is unchanged. */ + void GetStackValue(int a_StackPos, eWeather & a_Value); + /** Call any 0-param 0-return Lua function in a single line: */ template diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 344031995..104380ea4 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -1347,18 +1347,15 @@ bool cPluginLua::OnWeatherChanging(cWorld & a_World, eWeather & a_NewWeather) { cCSLock Lock(m_CriticalSection); bool res = false; - int NewWeather = a_NewWeather; cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WEATHER_CHANGING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, NewWeather, cLuaState::Return, res, NewWeather); + m_LuaState.Call((int)(**itr), &a_World, a_NewWeather, cLuaState::Return, res, a_NewWeather); if (res) { - a_NewWeather = (eWeather)NewWeather; return true; } } - a_NewWeather = (eWeather)NewWeather; return false; } -- cgit v1.2.3 From 632e8680b181477ebf6713a593cc69d0193a425b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 4 Jul 2014 11:50:50 +0200 Subject: Removed world-saving log messages. Ref.: http://forum.mc-server.org/showthread.php?tid=1518 --- src/World.cpp | 2 -- src/WorldStorage/WorldStorage.cpp | 35 +++++------------------------------ src/WorldStorage/WorldStorage.h | 3 --- 3 files changed, 5 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/World.cpp b/src/World.cpp index bd7694e96..48c3448a3 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2776,10 +2776,8 @@ bool cWorld::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunk void cWorld::SaveAllChunks(void) { - LOGINFO("Saving all chunks..."); m_LastSave = m_WorldAge; m_ChunkMap->SaveAllChunks(); - m_Storage.QueueSavedMessage(); } diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index 6867ad5bc..d3f35384b 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -17,13 +17,6 @@ -/// If a chunk with this Y coord is de-queued, it is a signal to emit the saved-all message (cWorldStorage::QueueSavedMessage()) -#define CHUNK_Y_MESSAGE 2 - - - - - /// Example storage schema - forgets all chunks ;) class cWSSForgetful : public cWSSchema @@ -168,17 +161,6 @@ void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) -void cWorldStorage::QueueSavedMessage(void) -{ - // Pushes a special coord pair into the queue, signalizing a message instead - m_SaveQueue.EnqueueItem(cChunkCoords(0, CHUNK_Y_MESSAGE, 0)); - m_Event.Set(); -} - - - - - void cWorldStorage::UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ) { m_LoadQueue.Remove(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ,true)); @@ -286,19 +268,12 @@ bool cWorldStorage::SaveOneChunk(void) { cChunkCoords ToSave(0, 0, 0); bool ShouldSave = m_SaveQueue.TryDequeueItem(ToSave); - if(ShouldSave) { - if (ToSave.m_ChunkY == CHUNK_Y_MESSAGE) - { - LOGINFO("Saved all chunks in world %s", m_World->GetName().c_str()); - return ShouldSave; - } - if (ShouldSave && m_World->IsChunkValid(ToSave.m_ChunkX, ToSave.m_ChunkZ)) + if (ShouldSave && m_World->IsChunkValid(ToSave.m_ChunkX, ToSave.m_ChunkZ)) + { + m_World->MarkChunkSaving(ToSave.m_ChunkX, ToSave.m_ChunkZ); + if (m_SaveSchema->SaveChunk(ToSave)) { - m_World->MarkChunkSaving(ToSave.m_ChunkX, ToSave.m_ChunkZ); - if (m_SaveSchema->SaveChunk(ToSave)) - { - m_World->MarkChunkSaved(ToSave.m_ChunkX, ToSave.m_ChunkZ); - } + m_World->MarkChunkSaved(ToSave.m_ChunkX, ToSave.m_ChunkZ); } } return ShouldSave; diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index bb189b6c9..1204b4310 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -67,9 +67,6 @@ public: void QueueLoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Generate); // Queues the chunk for loading; if not loaded, the chunk will be generated if a_Generate is true void QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ); - /// Signals that a message should be output to the console when all the chunks have been saved - void QueueSavedMessage(void); - /// Loads the chunk specified; returns true on success, false on failure bool LoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ); -- cgit v1.2.3 From a0d2df93272a6108f8c568e1eed665a1da5cb7ed Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 10:55:09 +0100 Subject: Tailored death messages --- src/Bindings/Plugin.h | 2 +- src/Bindings/PluginLua.cpp | 4 ++-- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 4 ++-- src/Bindings/PluginManager.h | 2 +- src/Entities/EnderCrystal.cpp | 4 ++-- src/Entities/EnderCrystal.h | 2 +- src/Entities/Entity.cpp | 8 ++++---- src/Entities/Entity.h | 2 +- src/Entities/ItemFrame.cpp | 6 +++--- src/Entities/ItemFrame.h | 2 +- src/Entities/Painting.h | 4 ++-- src/Entities/Player.cpp | 35 ++++++++++++++++++++++++++++------- src/Entities/Player.h | 2 +- src/Mobs/Monster.cpp | 6 +++--- src/Mobs/Monster.h | 2 +- src/Mobs/Wither.cpp | 4 ++-- src/Mobs/Wither.h | 2 +- src/Mobs/ZombiePigman.cpp | 6 +++--- src/Mobs/ZombiePigman.h | 2 +- 20 files changed, 61 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 8ba20c026..160e83bde 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -63,7 +63,7 @@ public: virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) = 0; virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) = 0; virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) = 0; - virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer) = 0; + virtual bool OnKilling (cEntity & a_Victim, TakeDamageInfo & a_TDI) = 0; virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) = 0; virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) = 0; virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 344031995..078e48111 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -575,14 +575,14 @@ bool cPluginLua::OnHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper, -bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer) +bool cPluginLua::OnKilling(cEntity & a_Victim, TakeDamageInfo & a_TDI) { cCSLock Lock(m_CriticalSection); bool res = false; cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_KILLING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Victim, a_Killer, cLuaState::Return, res); + m_LuaState.Call((int)(**itr), &a_Victim, &a_TDI, cLuaState::Return, res); if (res) { return true; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 9c9de95c6..d1514a731 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -86,7 +86,7 @@ public: virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) override; virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) override; virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) override; - virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer) override; + virtual bool OnKilling (cEntity & a_Victim, TakeDamageInfo & a_TDI) override; virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) override; virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override; virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 3cb8c99a1..1ebe8dd68 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -562,14 +562,14 @@ bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity & -bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer) +bool cPluginManager::CallHookKilling(cEntity & a_Victim, TakeDamageInfo & a_TDI) { FIND_HOOK(HOOK_KILLING); VERIFY_HOOK; for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnKilling(a_Victim, a_Killer)) + if ((*itr)->OnKilling(a_Victim, a_TDI)) { return true; } diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 72cedfae1..7d63626bd 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -180,7 +180,7 @@ public: // tolua_export bool CallHookHandshake (cClientHandle * a_ClientHandle, const AString & a_Username); bool CallHookHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum); bool CallHookHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum); - bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer); + bool CallHookKilling (cEntity & a_Victim, TakeDamageInfo & a_TDI); bool CallHookLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username); bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation); bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); diff --git a/src/Entities/EnderCrystal.cpp b/src/Entities/EnderCrystal.cpp index a640b236c..bf86a6c42 100644 --- a/src/Entities/EnderCrystal.cpp +++ b/src/Entities/EnderCrystal.cpp @@ -42,9 +42,9 @@ void cEnderCrystal::Tick(float a_Dt, cChunk & a_Chunk) -void cEnderCrystal::KilledBy(cEntity * a_Killer) +void cEnderCrystal::KilledBy(TakeDamageInfo & a_TDI) { - super::KilledBy(a_Killer); + super::KilledBy(a_TDI); m_World->DoExplosionAt(6.0, GetPosX(), GetPosY(), GetPosZ(), true, esEnderCrystal, this); diff --git a/src/Entities/EnderCrystal.h b/src/Entities/EnderCrystal.h index 5b86df987..30211de13 100644 --- a/src/Entities/EnderCrystal.h +++ b/src/Entities/EnderCrystal.h @@ -24,7 +24,7 @@ private: // cEntity overrides: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - virtual void KilledBy(cEntity * a_Killer) override; + virtual void KilledBy(TakeDamageInfo & a_TDI) override; }; // tolua_export diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 2b256e766..56ef22280 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -368,7 +368,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) if (m_Health <= 0) { - KilledBy(a_TDI.Attacker); + KilledBy(a_TDI); if (a_TDI.Attacker != NULL) { @@ -524,11 +524,11 @@ double cEntity::GetKnockbackAmountAgainst(const cEntity & a_Receiver) -void cEntity::KilledBy(cEntity * a_Killer) +void cEntity::KilledBy(TakeDamageInfo & a_TDI) { m_Health = 0; - cRoot::Get()->GetPluginManager()->CallHookKilling(*this, a_Killer); + cRoot::Get()->GetPluginManager()->CallHookKilling(*this, a_TDI); if (m_Health > 0) { @@ -538,7 +538,7 @@ void cEntity::KilledBy(cEntity * a_Killer) // Drop loot: cItems Drops; - GetDrops(Drops, a_Killer); + GetDrops(Drops, a_TDI.Attacker); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ()); m_World->BroadcastEntityStatus(*this, esGenericDead); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 2df66e353..e34cf55d2 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -309,7 +309,7 @@ public: virtual cItem GetEquippedBoots(void) const { return cItem(); } /// Called when the health drops below zero. a_Killer may be NULL (environmental damage) - virtual void KilledBy(cEntity * a_Killer); + virtual void KilledBy(TakeDamageInfo & a_TDI); /// Called when the entity kills another entity virtual void Killed(cEntity * a_Victim) {} diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp index 7bc7bda8d..4cd707faa 100644 --- a/src/Entities/ItemFrame.cpp +++ b/src/Entities/ItemFrame.cpp @@ -51,17 +51,17 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player) -void cItemFrame::KilledBy(cEntity * a_Killer) +void cItemFrame::KilledBy(TakeDamageInfo & a_TDI) { if (m_Item.IsEmpty()) { SetHealth(0); - super::KilledBy(a_Killer); + super::KilledBy(a_TDI); Destroy(); return; } - if ((a_Killer != NULL) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative()) + if ((a_TDI.Attacker != NULL) && a_TDI.Attacker->IsPlayer() && !((cPlayer *)a_TDI.Attacker)->IsGameModeCreative()) { cItems Item; Item.push_back(m_Item); diff --git a/src/Entities/ItemFrame.h b/src/Entities/ItemFrame.h index 6577e7d94..9261e52cc 100644 --- a/src/Entities/ItemFrame.h +++ b/src/Entities/ItemFrame.h @@ -35,7 +35,7 @@ public: private: virtual void OnRightClicked(cPlayer & a_Player) override; - virtual void KilledBy(cEntity * a_Killer) override; + virtual void KilledBy(TakeDamageInfo & a_TDI) override; virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override; cItem m_Item; diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h index c1024bd1b..30af6d412 100644 --- a/src/Entities/Painting.h +++ b/src/Entities/Painting.h @@ -26,9 +26,9 @@ private: virtual void SpawnOn(cClientHandle & a_Client) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override; - virtual void KilledBy(cEntity * a_Killer) override + virtual void KilledBy(TakeDamageInfo & a_TDI) override { - super::KilledBy(a_Killer); + super::KilledBy(a_TDI); Destroy(); } diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index dbb8cd26c..3fffc4643 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -889,9 +889,9 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI) -void cPlayer::KilledBy(cEntity * a_Killer) +void cPlayer::KilledBy(TakeDamageInfo & a_TDI) { - super::KilledBy(a_Killer); + super::KilledBy(a_TDI); if (m_Health > 0) { @@ -915,19 +915,40 @@ void cPlayer::KilledBy(cEntity * a_Killer) m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10); SaveToDisk(); // Save it, yeah the world is a tough place ! - if (a_Killer == NULL) + if (a_TDI.Attacker == NULL) { - GetWorld()->BroadcastChatDeath(Printf("%s was killed by environmental damage", GetName().c_str())); + AString DamageText; + switch (a_TDI.DamageType) + { + case dtRangedAttack: DamageText = "was shot"; break; + case dtLightning: DamageText = "was plasmified by lightining"; break; + case dtFalling: DamageText = (GetWorld()->GetTickRandomNumber(10) % 2 == 0) ? "fell to death" : "hit the ground too hard"; break; + case dtDrowning: DamageText = "drowned"; break; + case dtSuffocating: DamageText = (GetWorld()->GetTickRandomNumber(10) % 2 == 0) ? "git merge'd into a block" : "fused with a block"; break; + case dtStarving: DamageText = "forgot the importance of food"; break; + case dtCactusContact: DamageText = "was impaled on a cactus"; break; + case dtLavaContact: DamageText = "was melted by lava"; break; + case dtPoisoning: DamageText = "died from septicaemia"; break; + case dtOnFire: DamageText = "forgot to stop, drop, and roll"; break; + case dtFireContact: DamageText = "burnt themselves to death"; break; + case dtInVoid: DamageText = "somehow fell out of the world"; break; + case dtPotionOfHarming: DamageText = "was magicked to death"; break; + case dtEnderPearl: DamageText = "misused an ender pearl"; break; + case dtAdmin: DamageText = "was administrator'd"; break; + case dtExplosion: DamageText = "blew up"; break; + default: DamageText = "died, somehow; we've no idea how though"; break; + } + GetWorld()->BroadcastChatDeath(Printf("%s %s", GetName().c_str(), DamageText.c_str())); } - else if (a_Killer->IsPlayer()) + else if (a_TDI.Attacker->IsPlayer()) { - cPlayer * Killer = (cPlayer *)a_Killer; + cPlayer * Killer = (cPlayer *)a_TDI.Attacker; GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str())); } else { - AString KillerClass = a_Killer->GetClass(); + AString KillerClass = a_TDI.Attacker->GetClass(); KillerClass.erase(KillerClass.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch") GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str())); diff --git a/src/Entities/Player.h b/src/Entities/Player.h index f247ac2f9..48bf00fb9 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -323,7 +323,7 @@ public: /** Aborts the current eating operation */ void AbortEating(void); - virtual void KilledBy(cEntity * a_Killer) override; + virtual void KilledBy(TakeDamageInfo & a_TDI) override; virtual void Killed(cEntity * a_Victim) override; diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 5843ca5a6..6ef90d489 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -492,9 +492,9 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI) -void cMonster::KilledBy(cEntity * a_Killer) +void cMonster::KilledBy(TakeDamageInfo & a_TDI) { - super::KilledBy(a_Killer); + super::KilledBy(a_TDI); if (m_SoundHurt != "") { m_World->BroadcastSoundEffect(m_SoundDeath, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f); @@ -558,7 +558,7 @@ void cMonster::KilledBy(cEntity * a_Killer) break; } } - if ((a_Killer != NULL) && (!IsBaby())) + if ((a_TDI.Attacker != NULL) && (!IsBaby())) { m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward); } diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 7d7e90eb2..8c9f006d3 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -90,7 +90,7 @@ public: virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; - virtual void KilledBy(cEntity * a_Killer) override; + virtual void KilledBy(TakeDamageInfo & a_TDI) override; virtual void MoveToPosition(const Vector3f & a_Position); virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp index da4cc7765..578b47995 100644 --- a/src/Mobs/Wither.cpp +++ b/src/Mobs/Wither.cpp @@ -103,9 +103,9 @@ void cWither::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cWither::KilledBy(cEntity * a_Killer) +void cWither::KilledBy(TakeDamageInfo & a_TDI) { - super::KilledBy(a_Killer); + super::KilledBy(a_TDI); class cPlayerCallback : public cPlayerListCallback { diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index 03a320788..7d76f70f5 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -29,7 +29,7 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - virtual void KilledBy(cEntity * a_Killer) override; + virtual void KilledBy(TakeDamageInfo & a_TDI) override; private: diff --git a/src/Mobs/ZombiePigman.cpp b/src/Mobs/ZombiePigman.cpp index c9d94face..05350f877 100644 --- a/src/Mobs/ZombiePigman.cpp +++ b/src/Mobs/ZombiePigman.cpp @@ -37,11 +37,11 @@ void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cZombiePigman::KilledBy(cEntity * a_Killer) +void cZombiePigman::KilledBy(TakeDamageInfo & a_TDI) { - super::KilledBy(a_Killer); + super::KilledBy(a_TDI); - if ((a_Killer != NULL) && (a_Killer->IsPlayer())) + if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer())) { // TODO: Anger all nearby zombie pigmen // TODO: In vanilla, if one player angers ZPs, do they attack any nearby player, or only that one attacker? diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h index ab3cebf6d..a2ebc87cb 100644 --- a/src/Mobs/ZombiePigman.h +++ b/src/Mobs/ZombiePigman.h @@ -17,7 +17,7 @@ public: CLASS_PROTODEF(cZombiePigman); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void KilledBy(cEntity * a_Killer) override; + virtual void KilledBy(TakeDamageInfo & a_TDI) override; } ; -- cgit v1.2.3 From ec2f576de69f2a6e73abb1aeadb173c0b2e12131 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 2 Jul 2014 22:25:18 +0100 Subject: Fixed c1deda5d8f01811efa5094e9375166acb69d50ed I keep on breaking stuff :P --- src/Simulator/IncrementalRedstoneSimulator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 866a5b65a..5af9a295d 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -1700,7 +1700,7 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc { continue; } - a_PowerLevel = itr->a_PowerLevel; + a_PowerLevel = std::max(itr->a_PowerLevel , a_PowerLevel); // Get the highest power level (a_PowerLevel is initialised already and there CAN be multiple levels for one block) } for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list @@ -1709,7 +1709,7 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc { continue; } - a_PowerLevel = itr->a_PowerLevel; + a_PowerLevel = std::max(itr->a_PowerLevel, a_PowerLevel); } return (a_PowerLevel != 0); // Answer the inital question: is the wire powered? -- cgit v1.2.3 From f6350662414044896e7971dcc792c83d5eaddbce Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 12:50:40 +0100 Subject: Eps comparison --- src/Entities/ArrowEntity.cpp | 2 +- src/Entities/ArrowEntity.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index c039b0b3c..1d539679c 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -68,7 +68,7 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { - if (GetSpeed().SqrLength() == 0) + if (GetSpeed().EqualsEps(Vector3d(0, 0, 0), 0.0000001)) { SetSpeed(GetLookVector().NormalizeCopy() * 0.1); // Ensure that no division by zero happens later } diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h index 99b7bae31..76cb24449 100644 --- a/src/Entities/ArrowEntity.h +++ b/src/Entities/ArrowEntity.h @@ -64,7 +64,7 @@ public: // tolua_end - /** Sets the block arrow is in */ + /** Sets the block arrow is in. To be used by the MCA loader only! */ void SetBlockHit(const Vector3i & a_BlockHit) { m_HitBlockPos = a_BlockHit; } protected: -- cgit v1.2.3 From 41747f05002821901afc05dd25eb9567eac56eb6 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 4 Jul 2014 15:07:41 +0200 Subject: Moved sending error messages to cPluginManager:CallHookChat --- src/Bindings/PluginManager.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 2cd514211..8a6ac26fa 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -257,9 +257,13 @@ bool cPluginManager::CallHookBlockToPickups( bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message) { - if (HandleCommand(a_Player, a_Message, true) != crUnknownCommand) // We use HandleCommand as opposed to ExecuteCommand to accomodate the need to the WasCommandForbidden bool + switch (HandleCommand(a_Player, a_Message, true)) { - return true; // Chat message was handled as command + case crExecuted: return true; + case crError: a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str())); return true; + case crBlocked: return true; // The plugin that blocked the command probably wants to send a message to the player. + case crNoPermission: a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", a_Message.c_str())); return true; + case crUnknownCommand: break; } // Check if it was a standard command (starts with a slash) @@ -1343,7 +1347,6 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player, !a_Player->HasPermission(cmd->second.m_Permission) ) { - a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", Split[0].c_str())); LOGINFO("Player %s tried to execute forbidden command: \"%s\"", a_Player->GetName().c_str(), Split[0].c_str()); return crNoPermission; } @@ -1352,7 +1355,6 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player, if (!cmd->second.m_Plugin->HandleCommand(Split, a_Player)) { - a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", Split[0].c_str())); return crError; } -- cgit v1.2.3 From c7a5347cd63f9e39e9732ee4720423824fb41175 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 4 Jul 2014 15:54:39 +0200 Subject: cPluginManager: Reformatted the switch statement. --- src/Bindings/PluginManager.cpp | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 45bcc61cd..7e6502515 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -257,17 +257,44 @@ bool cPluginManager::CallHookBlockToPickups( bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message) { + // Check if the message contains a command, execute it: switch (HandleCommand(a_Player, a_Message, true)) { - case crExecuted: return true; - case crError: a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str())); return true; - case crBlocked: return true; // The plugin that blocked the command probably wants to send a message to the player. - case crNoPermission: a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", a_Message.c_str())); return true; - case crUnknownCommand: break; + case crExecuted: + { + // The command has executed successfully + return true; + } + + case crBlocked: + { + // The command was blocked by a plugin using HOOK_EXECUTE_COMMAND + // The plugin has most likely sent a message to the player already + return true; + } + + case crError: + { + // An error in the plugin has prevented the command from executing. Report the error to the player: + a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str())); + return true; + } + + case crNoPermission: + { + // The player is not allowed to execute this command + a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", a_Message.c_str())); + return true; + } + + case crUnknownCommand: + { + // This was not a known command, keep processing as a message + break; + } } - // Check if it was a standard command (starts with a slash) - // If it was, we know that it was completely unrecognised + // Check if the message is a command (starts with a slash). If it is, we know that it wasn't recognised: if (!a_Message.empty() && (a_Message[0] == '/')) { AStringVector Split(StringSplit(a_Message, " ")); -- cgit v1.2.3 From f4e3c01a710a2cc5118807a65f8d27519a19ef37 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 16:49:24 +0100 Subject: Various fixed * Fixed potential invalid pointer dereferencing, fixes #1117 * Fixed ender pearls not being loaded properly --- src/Entities/ProjectileEntity.cpp | 75 +++++++++++++++++++++++++++++++-- src/Entities/ProjectileEntity.h | 34 +++++++++++++-- src/Entities/ThrownEnderPearlEntity.cpp | 8 ++-- src/WorldStorage/NBTChunkSerializer.cpp | 11 ++--- 4 files changed, 111 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 76daca186..ddcc0f7fd 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -21,6 +21,7 @@ #include "FireChargeEntity.h" #include "FireworkEntity.h" #include "GhastFireballEntity.h" +#include "Player.h" @@ -215,7 +216,7 @@ protected: cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height) : super(etProjectile, a_X, a_Y, a_Z, a_Width, a_Height), m_ProjectileKind(a_Kind), - m_Creator(a_Creator), + m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : ""), m_IsInGround(false) { } @@ -227,7 +228,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height) : super(etProjectile, a_Pos.x, a_Pos.y, a_Pos.z, a_Width, a_Height), m_ProjectileKind(a_Kind), - m_Creator(a_Creator), + m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : ""), m_IsInGround(false) { SetSpeed(a_Speed); @@ -295,6 +296,74 @@ void cProjectileEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_ +cEntity * cProjectileEntity::GetCreator() +{ + if (m_CreatorData.m_Name.empty()) + { + class cProjectileCreatorCallback : public cEntityCallback + { + public: + cProjectileCreatorCallback(void) : + m_Entity(NULL) + { + } + + virtual bool Item(cEntity * a_Entity) override + { + m_Entity = a_Entity; + return true; + } + + cEntity * GetEntity(void) + { + return m_Entity; + } + + private: + + cEntity * m_Entity; + }; + + cProjectileCreatorCallback PCC; + GetWorld()->DoWithEntityByID(m_CreatorData.m_UniqueID, PCC); + return PCC.GetEntity(); + } + else + { + class cProjectileCreatorCallbackForPlayers : public cPlayerListCallback + { + public: + cProjectileCreatorCallbackForPlayers(void) : + m_Entity(NULL) + { + } + + virtual bool Item(cPlayer * a_Entity) override + { + m_Entity = a_Entity; + return true; + } + + cPlayer * GetEntity(void) + { + return m_Entity; + } + + private: + + cPlayer * m_Entity; + }; + + cProjectileCreatorCallbackForPlayers PCCFP; + GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, PCCFP); + return PCCFP.GetEntity(); + } +} + + + + + AString cProjectileEntity::GetMCAClassName(void) const { switch (m_ProjectileKind) @@ -304,7 +373,7 @@ AString cProjectileEntity::GetMCAClassName(void) const case pkEgg: return "Egg"; case pkGhastFireball: return "Fireball"; case pkFireCharge: return "SmallFireball"; - case pkEnderPearl: return "ThrownEnderPearl"; + case pkEnderPearl: return "ThrownEnderpearl"; case pkExpBottle: return "ThrownExpBottle"; case pkSplashPotion: return "ThrownPotion"; case pkWitherSkull: return "WitherSkull"; diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index ae06b072f..e2ebe9f27 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -66,8 +66,15 @@ public: /// Returns the kind of the projectile (fast class identification) eKind GetProjectileKind(void) const { return m_ProjectileKind; } - /// Returns the entity who created this projectile; may be NULL - cEntity * GetCreator(void) { return m_Creator; } + /** Returns the entity who created this projectile through running its Unique ID through cWorld::DoWithEntityByID() + May return NULL; do not store the returned pointer outside the scope of the tick thread! + */ + cEntity * GetCreator(void); + + /** Returns the name of the player that created the projectile + Will be empty for non-player creators + */ + AString GetCreatorName(void) const { return m_CreatorData.m_Name; } /// Returns the string that is used as the entity type (class name) in MCA files AString GetMCAClassName(void) const; @@ -81,10 +88,29 @@ public: void SetIsInGround(bool a_IsInGround) { m_IsInGround = a_IsInGround; } protected: + + /** A structure that stores the Entity ID and Playername of the projectile's creator + Used to migitate invalid pointers caused by the creator being destroyed + */ + struct CreatorData + { + CreatorData(int a_UniqueID, AString & a_Name) : + m_UniqueID(a_UniqueID), + m_Name(a_Name) + { + } + + const int m_UniqueID; + AString m_Name; + }; + + /** The type of projectile I am */ eKind m_ProjectileKind; - /// The entity who has created this projectile; may be NULL (e. g. for dispensers) - cEntity * m_Creator; + /** The structure for containing the entity ID and name who has created this projectile + The ID and/or name may be NULL (e.g. for dispensers/mobs) + */ + CreatorData m_CreatorData; /// True if the projectile has hit the ground and is stuck there bool m_IsInGround; diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp index a3ee23389..96dd41ee6 100644 --- a/src/Entities/ThrownEnderPearlEntity.cpp +++ b/src/Entities/ThrownEnderPearlEntity.cpp @@ -46,10 +46,12 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos) { + cEntity * Creator = GetCreator(); + // Teleport the creator here, make them take 5 damage: - if (m_Creator != NULL) + if (Creator != NULL) { - m_Creator->TeleportToCoords(a_HitPos.x, a_HitPos.y + 0.2, a_HitPos.z); - m_Creator->TakeDamage(dtEnderPearl, this, 5, 0); + Creator->TeleportToCoords(a_HitPos.x, a_HitPos.y + 0.2, a_HitPos.z); + Creator->TakeDamage(dtEnderPearl, this, 5, 0); } } diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index e49042ff7..2dcae51ce 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -619,14 +619,11 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) { ASSERT(!"Unsaved projectile entity!"); } - } // switch (ProjectileKind) - cEntity * Creator = a_Projectile->GetCreator(); - if (Creator != NULL) + } // switch (ProjectileKind) + + if (!a_Projectile->GetCreatorName().empty()) { - if (Creator->GetEntityType() == cEntity::etPlayer) - { - m_Writer.AddString("ownerName", ((cPlayer *)Creator)->GetName()); - } + m_Writer.AddString("ownerName", a_Projectile->GetCreatorName()); } m_Writer.EndCompound(); } -- cgit v1.2.3 From 2ead2538b108c8bf6b6c43648310ad7cf7073adc Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 16:52:52 +0100 Subject: MCS WebAdmin sockets rebinds instantly * Fixes #272 * Fixes #1150 --- src/HTTPServer/HTTPServer.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp index d288c83c9..036b2e042 100644 --- a/src/HTTPServer/HTTPServer.cpp +++ b/src/HTTPServer/HTTPServer.cpp @@ -179,6 +179,8 @@ bool cHTTPServer::Initialize(const AString & a_PortsIPv4, const AString & a_Port // Open up requested ports: bool HasAnyPort; + m_ListenThreadIPv4.SetReuseAddr(true); + m_ListenThreadIPv6.SetReuseAddr(true); HasAnyPort = m_ListenThreadIPv4.Initialize(a_PortsIPv4); HasAnyPort = m_ListenThreadIPv6.Initialize(a_PortsIPv6) || HasAnyPort; if (!HasAnyPort) -- cgit v1.2.3 From 79e558be349c40ed40b5eefefd29f563a570e404 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 17:42:40 +0100 Subject: Suggestions --- src/Entities/ThrownEggEntity.cpp | 2 +- src/Entities/ThrownEggEntity.h | 5 ++++- src/Entities/ThrownEnderPearlEntity.cpp | 2 +- src/Entities/ThrownEnderPearlEntity.h | 5 ++++- src/Entities/ThrownSnowballEntity.cpp | 2 +- src/Entities/ThrownSnowballEntity.h | 5 ++++- src/Vector3.h | 10 +++++----- 7 files changed, 20 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Entities/ThrownEggEntity.cpp b/src/Entities/ThrownEggEntity.cpp index d7eed41e3..456083108 100644 --- a/src/Entities/ThrownEggEntity.cpp +++ b/src/Entities/ThrownEggEntity.cpp @@ -22,7 +22,7 @@ void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_H { TrySpawnChicken(a_HitPos); - m_DestroyTimer = 5; + m_DestroyTimer = 2; } diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h index 894665428..dc72c279f 100644 --- a/src/Entities/ThrownEggEntity.h +++ b/src/Entities/ThrownEggEntity.h @@ -41,7 +41,10 @@ protected: return; } } - else { super::Tick(a_Dt, a_Chunk); } + else + { + super::Tick(a_Dt, a_Chunk); + } } // Randomly decides whether to spawn a chicken where the egg lands. diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp index 96dd41ee6..aeb727205 100644 --- a/src/Entities/ThrownEnderPearlEntity.cpp +++ b/src/Entities/ThrownEnderPearlEntity.cpp @@ -22,7 +22,7 @@ void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockF // TODO: Tweak a_HitPos based on block face. TeleportCreator(a_HitPos); - m_DestroyTimer = 5; + m_DestroyTimer = 2; } diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h index bfd9bd70d..1cea5f7d9 100644 --- a/src/Entities/ThrownEnderPearlEntity.h +++ b/src/Entities/ThrownEnderPearlEntity.h @@ -41,7 +41,10 @@ protected: return; } } - else { super::Tick(a_Dt, a_Chunk); } + else + { + super::Tick(a_Dt, a_Chunk); + } } /** Teleports the creator where the ender pearl lands */ diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp index b82cd56db..d94e75898 100644 --- a/src/Entities/ThrownSnowballEntity.cpp +++ b/src/Entities/ThrownSnowballEntity.cpp @@ -20,7 +20,7 @@ cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, do void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { - m_DestroyTimer = 5; + m_DestroyTimer = 2; } diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h index e30971f0a..9a8770379 100644 --- a/src/Entities/ThrownSnowballEntity.h +++ b/src/Entities/ThrownSnowballEntity.h @@ -41,7 +41,10 @@ protected: return; } } - else { super::Tick(a_Dt, a_Chunk); } + else + { + super::Tick(a_Dt, a_Chunk); + } } private: diff --git a/src/Vector3.h b/src/Vector3.h index faf7fe43c..f350ede2a 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -135,12 +135,12 @@ public: } /** Runs each value of the vector through std::floor() */ - inline Vector3 Floor(void) const + inline Vector3 Floor(void) const { - return Vector3( - (T)floor(x), - (T)floor(y), - (T)floor(z) + return Vector3i( + (int)floor(x), + (int)floor(y), + (int)floor(z) ); } -- cgit v1.2.3 From 25e986220662247cfeefe4a496da959f409859e9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 17:49:44 +0100 Subject: Compile fix --- src/Vector3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Vector3.h b/src/Vector3.h index f350ede2a..9e855b8af 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -137,7 +137,7 @@ public: /** Runs each value of the vector through std::floor() */ inline Vector3 Floor(void) const { - return Vector3i( + return Vector3( (int)floor(x), (int)floor(y), (int)floor(z) -- cgit v1.2.3 From f4e11d194e9e4a2e85a9f9688312ad08ade45b83 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 22:07:26 +0100 Subject: Crash and compile fix --- src/Entities/ProjectileEntity.cpp | 11 ++++++++--- src/Entities/ProjectileEntity.h | 2 +- src/Protocol/Protocol17x.cpp | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index ddcc0f7fd..50f62b018 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -216,7 +216,10 @@ protected: cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height) : super(etProjectile, a_X, a_Y, a_Z, a_Width, a_Height), m_ProjectileKind(a_Kind), - m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : ""), + m_CreatorData( + ((a_Creator != NULL) ? a_Creator->GetUniqueID() : -1), + ((a_Creator != NULL) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : "") + ), m_IsInGround(false) { } @@ -298,7 +301,7 @@ void cProjectileEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_ cEntity * cProjectileEntity::GetCreator() { - if (m_CreatorData.m_Name.empty()) + if (m_CreatorData.m_Name.empty() && (m_CreatorData.m_UniqueID >= 1)) { class cProjectileCreatorCallback : public cEntityCallback { @@ -328,7 +331,7 @@ cEntity * cProjectileEntity::GetCreator() GetWorld()->DoWithEntityByID(m_CreatorData.m_UniqueID, PCC); return PCC.GetEntity(); } - else + else if (!m_CreatorData.m_Name.empty()) { class cProjectileCreatorCallbackForPlayers : public cPlayerListCallback { @@ -358,6 +361,8 @@ cEntity * cProjectileEntity::GetCreator() GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, PCCFP); return PCCFP.GetEntity(); } + + return NULL; } diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index e2ebe9f27..84eefb9ee 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -94,7 +94,7 @@ protected: */ struct CreatorData { - CreatorData(int a_UniqueID, AString & a_Name) : + CreatorData(int a_UniqueID, const AString & a_Name) : m_UniqueID(a_UniqueID), m_Name(a_Name) { diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 02c577dc8..109e5a67b 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -2334,7 +2334,7 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata) for (int loretag = NBT.GetFirstChild(displaytag); loretag >= 0; loretag = NBT.GetNextSibling(loretag)) // Loop through array of strings { - AppendPrintf(Lore, "%s`", NBT.GetString(loretag).c_str()); // Append the lore with a newline, used internally by MCS to display a new line in the client; don't forget to c_str ;) + AppendPrintf(Lore, "%s`", NBT.GetString(loretag).c_str()); // Append the lore with a grave accent/backtick, used internally by MCS to display a new line in the client; don't forget to c_str ;) } a_Item.m_Lore = Lore; -- cgit v1.2.3 From 7a78f23b4a03d36dc6db56a7e269f5c181c2a6fb Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 5 Jul 2014 14:00:04 +0200 Subject: Add middle click. --- src/UI/SlotArea.cpp | 102 ++++++++++++++++++++++++++++++++++++++++++---------- src/UI/SlotArea.h | 7 ++-- 2 files changed, 88 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 48ebf489b..3e171a444 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -15,6 +15,7 @@ #include "../Root.h" #include "../FastRandom.h" #include "../BlockArea.h" +#include "polarssl/camellia.h" @@ -60,12 +61,16 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA ShiftClicked(a_Player, a_SlotNum, a_ClickedItem); return; } - case caDblClick: { DblClicked(a_Player, a_SlotNum); return; } + case caMiddleClick: + { + MiddleClicked(a_Player, a_SlotNum); + return; + } default: { break; @@ -226,6 +231,24 @@ void cSlotArea::DblClicked(cPlayer & a_Player, int a_SlotNum) +void cSlotArea::MiddleClicked(cPlayer & a_Player, int a_SlotNum) +{ + cItem Slot(*GetSlot(a_SlotNum, a_Player)); + cItem & DraggingItem = a_Player.GetDraggingItem(); + + if (!a_Player.IsGameModeCreative() || Slot.IsEmpty() || !DraggingItem.IsEmpty()) + { + return; + } + + DraggingItem = Slot; + DraggingItem.m_ItemCount = DraggingItem.GetMaxStackSize(); +} + + + + + void cSlotArea::OnPlayerAdded(cPlayer & a_Player) { UNUSED(a_Player); @@ -410,6 +433,12 @@ cSlotAreaCrafting::cSlotAreaCrafting(int a_GridSize, cWindow & a_ParentWindow) : void cSlotAreaCrafting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) { + if (a_ClickAction == caMiddleClick) + { + MiddleClicked(a_Player, a_SlotNum); + return; + } + // Override for craft result slot if (a_SlotNum == 0) { @@ -423,6 +452,7 @@ void cSlotAreaCrafting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction } return; } + super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem); UpdateRecipe(a_Player); } @@ -651,15 +681,27 @@ void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C return; } - if (a_ClickAction == caDblClick) - { - return; - } - - if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick)) + switch (a_ClickAction) { - ShiftClicked(a_Player, a_SlotNum, a_ClickedItem); - return; + case caDblClick: + { + return; + } + case caShiftLeftClick: + case caShiftRightClick: + { + ShiftClicked(a_Player, a_SlotNum, a_ClickedItem); + return; + } + case caMiddleClick: + { + MiddleClicked(a_Player, a_SlotNum); + return; + } + default: + { + break; + } } cItem Slot(*GetSlot(a_SlotNum, a_Player)); @@ -1057,12 +1099,16 @@ void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickActio ShiftClicked(a_Player, a_SlotNum, a_ClickedItem); return; } - case caDblClick: { DblClicked(a_Player, a_SlotNum); return; } + case caMiddleClick: + { + MiddleClicked(a_Player, a_SlotNum); + return; + } default: { break; @@ -1414,6 +1460,12 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a return; } + if (a_ClickAction == caMiddleClick) + { + MiddleClicked(a_Player, a_SlotNum); + return; + } + cItem & DraggingItem = a_Player.GetDraggingItem(); if (!DraggingItem.IsEmpty()) { @@ -1676,16 +1728,28 @@ void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C return; } - if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick)) - { - ShiftClicked(a_Player, a_SlotNum, a_ClickedItem); - return; - } - - // Armors haven't a dbl click - if (a_ClickAction == caDblClick) + switch (a_ClickAction) { - return; + case caDblClick: + { + // Armors haven't a dbl click + return; + } + case caShiftLeftClick: + case caShiftRightClick: + { + ShiftClicked(a_Player, a_SlotNum, a_ClickedItem); + return; + } + case caMiddleClick: + { + MiddleClicked(a_Player, a_SlotNum); + return; + } + default: + { + break; + } } cItem Slot(*GetSlot(a_SlotNum, a_Player)); diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index b4b693cf6..b72450a58 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -46,10 +46,13 @@ public: /// Called from Clicked when the action is a shiftclick (left or right) virtual void ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem); - + /// Called from Clicked when the action is a caDblClick virtual void DblClicked(cPlayer & a_Player, int a_SlotNum); - + + /** Called from Clicked when the action is a middleclick */ + virtual void MiddleClicked(cPlayer & a_Player, int a_SlotNum); + /// Called when a new player opens the same parent window. The window already tracks the player. CS-locked. virtual void OnPlayerAdded(cPlayer & a_Player); -- cgit v1.2.3 From 460d6bd0cbb799a6e68f1bc264f55c3d89eb8206 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 5 Jul 2014 22:59:22 +0100 Subject: Changed everything to callbacks --- src/Entities/ProjectileEntity.cpp | 72 +-------------------------------- src/Entities/ProjectileEntity.h | 6 +-- src/Entities/ThrownEnderPearlEntity.cpp | 35 +++++++++++++--- src/Mobs/Creeper.cpp | 22 +++++++++- 4 files changed, 53 insertions(+), 82 deletions(-) (limited to 'src') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 50f62b018..334973833 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -142,7 +142,7 @@ public: { if ( (a_Entity == m_Projectile) || // Do not check collisions with self - (a_Entity == m_Projectile->GetCreator()) // Do not check whoever shot the projectile + (a_Entity->GetUniqueID() == m_Projectile->GetCreatorUniqueID()) // Do not check whoever shot the projectile ) { // TODO: Don't check creator only for the first 5 ticks @@ -299,76 +299,6 @@ void cProjectileEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_ -cEntity * cProjectileEntity::GetCreator() -{ - if (m_CreatorData.m_Name.empty() && (m_CreatorData.m_UniqueID >= 1)) - { - class cProjectileCreatorCallback : public cEntityCallback - { - public: - cProjectileCreatorCallback(void) : - m_Entity(NULL) - { - } - - virtual bool Item(cEntity * a_Entity) override - { - m_Entity = a_Entity; - return true; - } - - cEntity * GetEntity(void) - { - return m_Entity; - } - - private: - - cEntity * m_Entity; - }; - - cProjectileCreatorCallback PCC; - GetWorld()->DoWithEntityByID(m_CreatorData.m_UniqueID, PCC); - return PCC.GetEntity(); - } - else if (!m_CreatorData.m_Name.empty()) - { - class cProjectileCreatorCallbackForPlayers : public cPlayerListCallback - { - public: - cProjectileCreatorCallbackForPlayers(void) : - m_Entity(NULL) - { - } - - virtual bool Item(cPlayer * a_Entity) override - { - m_Entity = a_Entity; - return true; - } - - cPlayer * GetEntity(void) - { - return m_Entity; - } - - private: - - cPlayer * m_Entity; - }; - - cProjectileCreatorCallbackForPlayers PCCFP; - GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, PCCFP); - return PCCFP.GetEntity(); - } - - return NULL; -} - - - - - AString cProjectileEntity::GetMCAClassName(void) const { switch (m_ProjectileKind) diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index 84eefb9ee..7b38169e2 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -66,10 +66,10 @@ public: /// Returns the kind of the projectile (fast class identification) eKind GetProjectileKind(void) const { return m_ProjectileKind; } - /** Returns the entity who created this projectile through running its Unique ID through cWorld::DoWithEntityByID() - May return NULL; do not store the returned pointer outside the scope of the tick thread! + /** Returns the unique ID of the entity who created this projectile + May return an ID <0 */ - cEntity * GetCreator(void); + int GetCreatorUniqueID(void) { return m_CreatorData.m_UniqueID; } /** Returns the name of the player that created the projectile Will be empty for non-player creators diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp index aeb727205..c7407e6ae 100644 --- a/src/Entities/ThrownEnderPearlEntity.cpp +++ b/src/Entities/ThrownEnderPearlEntity.cpp @@ -1,6 +1,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "ThrownEnderPearlEntity.h" +#include "Player.h" @@ -46,12 +47,34 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos) { - cEntity * Creator = GetCreator(); - - // Teleport the creator here, make them take 5 damage: - if (Creator != NULL) + if (m_CreatorData.m_Name.empty()) { - Creator->TeleportToCoords(a_HitPos.x, a_HitPos.y + 0.2, a_HitPos.z); - Creator->TakeDamage(dtEnderPearl, this, 5, 0); + return; } + + class cProjectileCreatorCallbackForPlayers : public cPlayerListCallback + { + public: + cProjectileCreatorCallbackForPlayers(cEntity * a_Attacker, Vector3i a_HitPos) : + m_Attacker(a_Attacker), + m_HitPos(a_HitPos) + { + } + + virtual bool Item(cPlayer * a_Entity) override + { + // Teleport the creator here, make them take 5 damage: + a_Entity->TeleportToCoords(m_HitPos.x, m_HitPos.y + 0.2, m_HitPos.z); + a_Entity->TakeDamage(dtEnderPearl, m_Attacker, 5, 0); + return true; + } + + private: + + cEntity * m_Attacker; + Vector3i m_HitPos; + }; + + cProjectileCreatorCallbackForPlayers PCCFP(this, a_HitPos); + GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, PCCFP); } diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp index a7b97f604..b9041bd5a 100644 --- a/src/Mobs/Creeper.cpp +++ b/src/Mobs/Creeper.cpp @@ -67,9 +67,27 @@ void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer) } AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER); - if ((a_Killer != NULL) && (a_Killer->IsProjectile())) + if ((a_Killer != NULL) && a_Killer->IsProjectile() && (((cProjectileEntity *)a_Killer)->GetCreatorUniqueID() >= 0)) { - if (((cMonster *)((cProjectileEntity *)a_Killer)->GetCreator())->GetMobType() == mtSkeleton) + class cProjectileCreatorCallback : public cEntityCallback + { + public: + cProjectileCreatorCallback(void) + { + } + + virtual bool Item(cEntity * a_Entity) override + { + if (a_Entity->IsMob() && ((cMonster *)a_Entity)->GetMobType() == mtSkeleton) + { + return true; + } + return false; + } + }; + + cProjectileCreatorCallback PCC; + if (GetWorld()->DoWithEntityByID(((cProjectileEntity *)a_Killer)->GetCreatorUniqueID(), PCC)) { // 12 music discs. TickRand starts from 0 to 11. Disk IDs start at 2256, so add that. There. AddRandomDropItem(a_Drops, 1, 1, (short)m_World->GetTickRandomNumber(11) + 2256); -- cgit v1.2.3 From 9d7a59012c428e0207583f35c79938bcdab625b5 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 6 Jul 2014 00:40:59 +0200 Subject: Added drop window action. --- src/UI/SlotArea.cpp | 110 +++++++++++++++++++++++++++++++++++++++++++++++----- src/UI/SlotArea.h | 6 +++ src/UI/Window.cpp | 22 ++++------- 3 files changed, 113 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 3e171a444..68ec78930 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -71,6 +71,12 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA MiddleClicked(a_Player, a_SlotNum); return; } + case caDropKey: + case caCtrlDropKey: + { + DropClicked(a_Player, a_SlotNum, (a_ClickAction == caCtrlDropKey)); + return; + } default: { break; @@ -249,6 +255,34 @@ void cSlotArea::MiddleClicked(cPlayer & a_Player, int a_SlotNum) +void cSlotArea::DropClicked(cPlayer & a_Player, int a_SlotNum, bool a_DropStack) +{ + cItem Slot(*GetSlot(a_SlotNum, a_Player)); + if (Slot.IsEmpty()) + { + return; + } + + cItem ItemToDrop = Slot.CopyOne(); + if (a_DropStack) + { + ItemToDrop.m_ItemCount = Slot.m_ItemCount; + } + + Slot.m_ItemCount -= ItemToDrop.m_ItemCount; + if (Slot.m_ItemCount <= 0) + { + Slot.Empty(); + } + SetSlot(a_SlotNum, a_Player, Slot); + + a_Player.TossPickup(ItemToDrop); +} + + + + + void cSlotArea::OnPlayerAdded(cPlayer & a_Player) { UNUSED(a_Player); @@ -446,6 +480,10 @@ void cSlotAreaCrafting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction { ShiftClickedResult(a_Player); } + else if ((a_ClickAction == caDropKey) || (a_ClickAction == caCtrlDropKey)) + { + DropClickedResult(a_Player); + } else { ClickedResult(a_Player); @@ -594,6 +632,27 @@ void cSlotAreaCrafting::ShiftClickedResult(cPlayer & a_Player) +void cSlotAreaCrafting::DropClickedResult(cPlayer & a_Player) +{ + // Get the current recipe: + cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player); + const cItem & Result = Recipe.GetResult(); + + cItem * PlayerSlots = GetPlayerSlots(a_Player) + 1; + cCraftingGrid Grid(PlayerSlots, m_GridSize, m_GridSize); + + a_Player.TossPickup(Result); + Recipe.ConsumeIngredients(Grid); + Grid.CopyToItems(PlayerSlots); + + HandleCraftItem(Result, a_Player); + UpdateRecipe(a_Player); +} + + + + + void cSlotAreaCrafting::UpdateRecipe(cPlayer & a_Player) { cCraftingGrid Grid(GetPlayerSlots(a_Player) + 1, m_GridSize, m_GridSize); @@ -698,6 +757,16 @@ void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C MiddleClicked(a_Player, a_SlotNum); return; } + case caDropKey: + case caCtrlDropKey: + { + if (CanTakeResultItem(a_Player)) + { + DropClicked(a_Player, a_SlotNum, true); + OnTakeResult(a_Player); + } + return; + } default: { break; @@ -1453,17 +1522,32 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a bAsync = true; } - if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick)) + switch (a_ClickAction) { - HandleSmeltItem(Slot, a_Player); - ShiftClicked(a_Player, a_SlotNum, Slot); - return; - } - - if (a_ClickAction == caMiddleClick) - { - MiddleClicked(a_Player, a_SlotNum); - return; + case caShiftLeftClick: + case caShiftRightClick: + { + HandleSmeltItem(Slot, a_Player); + ShiftClicked(a_Player, a_SlotNum, Slot); + return; + } + case caMiddleClick: + { + MiddleClicked(a_Player, a_SlotNum); + return; + } + case caDropKey: + case caCtrlDropKey: + { + DropClicked(a_Player, a_SlotNum, (a_SlotNum == caCtrlDropKey)); + Slot.m_ItemCount = Slot.m_ItemCount - GetSlot(a_SlotNum, a_Player)->m_ItemCount; + HandleSmeltItem(Slot, a_Player); + return; + } + default: + { + break; + } } cItem & DraggingItem = a_Player.GetDraggingItem(); @@ -1641,6 +1725,12 @@ void cSlotAreaInventoryBase::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAc { if (a_Player.IsGameModeCreative() && (m_ParentWindow.GetWindowType() == cWindow::wtInventory)) { + if ((a_ClickAction == caDropKey) || (a_ClickAction == caCtrlDropKey)) + { + DropClicked(a_Player, a_SlotNum, (a_ClickAction == caCtrlDropKey)); + return; + } + // Creative inventory must treat a_ClickedItem as a DraggedItem instead, replacing the inventory slot with it SetSlot(a_SlotNum, a_Player, a_ClickedItem); return; diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index b72450a58..03f538956 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -53,6 +53,9 @@ public: /** Called from Clicked when the action is a middleclick */ virtual void MiddleClicked(cPlayer & a_Player, int a_SlotNum); + /** Called from Clicked when the action is a drop click. */ + virtual void DropClicked(cPlayer & a_Player, int a_SlotNum, bool a_DropStack); + /// Called when a new player opens the same parent window. The window already tracks the player. CS-locked. virtual void OnPlayerAdded(cPlayer & a_Player); @@ -251,6 +254,9 @@ protected: /// Handles a shift-click in the result slot. Crafts using the current recipe until it changes or no more space for result. void ShiftClickedResult(cPlayer & a_Player); + + /** Handles a drop-click in the result slot. */ + void DropClickedResult(cPlayer & a_Player); /// Updates the current recipe and result slot based on the ingredients currently in the crafting grid of the specified player void UpdateRecipe(cPlayer & a_Player); diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 381c6e121..ebdc1aea8 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -178,6 +178,7 @@ void cWindow::Clicked( switch (a_ClickAction) { + case caLeftClickOutside: case caRightClickOutside: { if (PlgMgr->CallHookPlayerTossingItem(a_Player)) @@ -190,25 +191,16 @@ void cWindow::Clicked( a_Player.TossPickup(a_ClickedItem); } - // Toss one of the dragged items: - a_Player.TossHeldItem(); - return; - } - case caLeftClickOutside: - { - if (PlgMgr->CallHookPlayerTossingItem(a_Player)) + if (a_ClickAction == caLeftClickOutside) { - // A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch) - return; + // Toss all dragged items: + a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount); } - - if (a_Player.IsGameModeCreative()) + else { - a_Player.TossPickup(a_ClickedItem); + // Toss one of the dragged items: + a_Player.TossHeldItem(); } - - // Toss all dragged items: - a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount); return; } case caLeftClickOutsideHoldNothing: -- cgit v1.2.3 From 66fa0155345f33a3be5661495af2f20d964b62b6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 5 Jul 2014 13:36:56 +0200 Subject: Fixed slime handling in cMonster::StringToMobType(). --- src/Mobs/Monster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 5843ca5a6..aaef7580d 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -46,8 +46,8 @@ static const struct {cMonster::mtSheep, "sheep"}, {cMonster::mtSilverfish, "silverfish"}, {cMonster::mtSkeleton, "skeleton"}, - {cMonster::mtSnowGolem, "snowgolem"}, {cMonster::mtSlime, "slime"}, + {cMonster::mtSnowGolem, "snowgolem"}, {cMonster::mtSpider, "spider"}, {cMonster::mtSquid, "squid"}, {cMonster::mtVillager, "villager"}, -- cgit v1.2.3 From 562d14e8ecd058b029a248ab42ff60e36f7e2e62 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 6 Jul 2014 14:42:28 +0200 Subject: Fixed crafting grid updating. Fixes #1152. --- src/UI/SlotArea.cpp | 22 ++++++++++++++++++++-- src/UI/SlotArea.h | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 48ebf489b..4df04c9e2 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -468,6 +468,20 @@ void cSlotAreaCrafting::OnPlayerRemoved(cPlayer & a_Player) +void cSlotAreaCrafting::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) +{ + // Update the recipe after setting the slot, if the slot is not the result slot: + super::SetSlot(a_SlotNum, a_Player, a_Item); + if (a_SlotNum != 0) + { + UpdateRecipe(a_Player); + } +} + + + + + void cSlotAreaCrafting::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) { UNUSED(a_ItemStack); @@ -545,16 +559,20 @@ void cSlotAreaCrafting::ShiftClickedResult(cPlayer & a_Player) // Distribute the result, this time for real: ResultCopy = Result; m_ParentWindow.DistributeStack(ResultCopy, a_Player, this, true); - + // Remove the ingredients from the crafting grid and update the recipe: cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player); cCraftingGrid Grid(PlayerSlots, m_GridSize, m_GridSize); Recipe.ConsumeIngredients(Grid); Grid.CopyToItems(PlayerSlots); UpdateRecipe(a_Player); + + // Broadcast the window, we sometimes move items to different locations than Vanilla, causing needless desyncs: + m_ParentWindow.BroadcastWholeWindow(); + + // If the recipe has changed, bail out: if (!Recipe.GetResult().IsEqual(Result)) { - // The recipe has changed, bail out return; } } diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index b4b693cf6..e271ea454 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -232,6 +232,7 @@ public: virtual void Clicked (cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override; virtual void DblClicked (cPlayer & a_Player, int a_SlotNum); virtual void OnPlayerRemoved(cPlayer & a_Player) override; + virtual void SetSlot (int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override; // Distributing items into this area is completely disabled virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override; -- cgit v1.2.3 From 9e44b0aae164f2456a452714f869cc9670732d8e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 6 Jul 2014 23:50:22 +0100 Subject: Implemented trapped chests & others + Added trapped chests * Fixed a bunch of bugs in the redstone simulator concerning wires and repeaters * Other potential bugfixes --- src/BlockEntities/BlockEntity.cpp | 3 +- src/BlockEntities/ChestEntity.cpp | 7 +- src/BlockEntities/ChestEntity.h | 13 +- src/BlockEntities/HopperEntity.cpp | 26 +++- src/BlockInfo.cpp | 3 + src/Blocks/BlockChest.h | 44 +++--- src/Blocks/BlockHandler.cpp | 1 + src/Blocks/BlockPiston.cpp | 2 +- src/Blocks/BlockPiston.h | 18 +-- src/Chunk.cpp | 8 +- src/ChunkMap.cpp | 21 ++- src/ChunkMap.h | 3 +- src/Entities/ExpOrb.h | 2 +- src/Map.cpp | 4 +- src/Protocol/Authenticator.cpp | 4 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 205 +++++++++++++++---------- src/Simulator/IncrementalRedstoneSimulator.h | 28 +++- src/UI/Window.cpp | 65 +++++++- src/UI/Window.h | 7 +- src/World.cpp | 17 +- src/World.h | 15 +- src/WorldStorage/NBTChunkSerializer.cpp | 7 +- src/WorldStorage/NBTChunkSerializer.h | 2 +- src/WorldStorage/WSSAnvil.cpp | 10 +- src/WorldStorage/WSSAnvil.h | 2 +- src/WorldStorage/WSSCompact.cpp | 2 +- 26 files changed, 340 insertions(+), 179 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp index 430f04551..1e2a176ef 100644 --- a/src/BlockEntities/BlockEntity.cpp +++ b/src/BlockEntities/BlockEntity.cpp @@ -28,7 +28,8 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE switch (a_BlockType) { case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_TRAPPED_CHEST: + case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType); case E_BLOCK_COMMAND_BLOCK: return new cCommandBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_DISPENSER: return new cDispenserEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index cb9cc89bf..8626f3cad 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -11,8 +11,9 @@ -cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) : - super(E_BLOCK_CHEST, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World) +cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type) : + super(a_Type, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World), + m_ActivePlayers(0) { cBlockEntityWindowOwner::SetBlockEntity(this); } @@ -113,7 +114,7 @@ void cChestEntity::UsedBy(cPlayer * a_Player) // The few false positives aren't much to worry about int ChunkX, ChunkZ; cChunkDef::BlockToChunk(m_PosX, m_PosZ, ChunkX, ChunkZ); - m_World->MarkChunkDirty(ChunkX, ChunkZ); + m_World->MarkChunkDirty(ChunkX, ChunkZ, true); } diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h index ce16f84d7..42cf7657c 100644 --- a/src/BlockEntities/ChestEntity.h +++ b/src/BlockEntities/ChestEntity.h @@ -35,7 +35,7 @@ public: // tolua_end /// Constructor used for normal operation - cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); + cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type); virtual ~cChestEntity(); @@ -50,6 +50,17 @@ public: /// Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate. void OpenNewWindow(void); + + /** Gets the number of players who currently have this chest open */ + int GetNumberOfPlayers(void) const { return m_ActivePlayers; } + + /** Gets the number of players who currently have this chest open */ + void SetNumberOfPlayers(int a_Amount) { m_ActivePlayers = a_Amount; } + +private: + + /** Holds the number of players who currently have this chest open */ + int m_ActivePlayers; } ; // tolua_export diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index 5856f20d1..bcaf26701 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -157,6 +157,7 @@ bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick) bool res = false; switch (a_Chunk.GetBlock(m_RelX, m_PosY + 1, m_RelZ)) { + case E_BLOCK_TRAPPED_CHEST: case E_BLOCK_CHEST: { // Chests have special handling because of double-chests @@ -322,6 +323,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick) bool res = false; switch (DestChunk->GetBlock(OutRelX, OutY, OutRelZ)) { + case E_BLOCK_TRAPPED_CHEST: case E_BLOCK_CHEST: { // Chests have special handling because of double-chests @@ -395,13 +397,17 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk) int x = m_RelX + Coords[i].x; int z = m_RelZ + Coords[i].z; cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z); - if ( - (Neighbor == NULL) || - (Neighbor->GetBlock(x, m_PosY + 1, z) != E_BLOCK_CHEST) - ) + if (Neighbor == NULL) { continue; } + + BLOCKTYPE Block = Neighbor->GetBlock(x, m_PosY + 1, z); + if ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST)) + { + continue; + } + Chest = (cChestEntity *)Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z); if (Chest == NULL) { @@ -572,13 +578,17 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block int x = RelX + Coords[i].x; int z = RelZ + Coords[i].z; cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z); - if ( - (Neighbor == NULL) || - (Neighbor->GetBlock(x, a_BlockY, z) != E_BLOCK_CHEST) - ) + if (Neighbor == NULL) { continue; } + + BLOCKTYPE Block = Neighbor->GetBlock(x, a_BlockY, z); + if ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST)) + { + continue; + } + Chest = (cChestEntity *)Neighbor->GetBlockEntity(a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z); if (Chest == NULL) { diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 16314290a..6ceb2c697 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -101,6 +101,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_TRAPPED_CHEST ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_TRIPWIRE ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1; @@ -162,6 +163,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true; a_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true; a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true; + a_Info[E_BLOCK_TRAPPED_CHEST ].m_Transparent = true; a_Info[E_BLOCK_TRIPWIRE ].m_Transparent = true; a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_Transparent = true; a_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true; @@ -287,6 +289,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_TALL_GRASS ].m_IsSnowable = false; a_Info[E_BLOCK_TNT ].m_IsSnowable = false; a_Info[E_BLOCK_TORCH ].m_IsSnowable = false; + a_Info[E_BLOCK_TRAPPED_CHEST ].m_IsSnowable = false; a_Info[E_BLOCK_TRIPWIRE ].m_IsSnowable = false; a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_IsSnowable = false; a_Info[E_BLOCK_VINES ].m_IsSnowable = false; diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h index c9a769c75..f899f4bcb 100644 --- a/src/Blocks/BlockChest.h +++ b/src/Blocks/BlockChest.h @@ -44,16 +44,16 @@ public: } double yaw = a_Player->GetYaw(); if ( - (Area.GetRelBlockType(0, 0, 1) == E_BLOCK_CHEST) || - (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST) + (Area.GetRelBlockType(0, 0, 1) == m_BlockType) || + (Area.GetRelBlockType(2, 0, 1) == m_BlockType) ) { a_BlockMeta = ((yaw >= -90) && (yaw < 90)) ? 2 : 3; return true; } if ( - (Area.GetRelBlockType(0, 0, 1) == E_BLOCK_CHEST) || - (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST) + (Area.GetRelBlockType(0, 0, 1) == m_BlockType) || + (Area.GetRelBlockType(2, 0, 1) == m_BlockType) ) { // FIXME: This is unreachable, as the condition is the same as the above one @@ -130,12 +130,12 @@ public: } int NumChestNeighbors = 0; - if (Area.GetRelBlockType(1, 0, 2) == E_BLOCK_CHEST) + if (Area.GetRelBlockType(1, 0, 2) == m_BlockType) { if ( - (Area.GetRelBlockType(0, 0, 2) == E_BLOCK_CHEST) || - (Area.GetRelBlockType(1, 0, 1) == E_BLOCK_CHEST) || - (Area.GetRelBlockType(1, 0, 3) == E_BLOCK_CHEST) + (Area.GetRelBlockType(0, 0, 2) == m_BlockType) || + (Area.GetRelBlockType(1, 0, 1) == m_BlockType) || + (Area.GetRelBlockType(1, 0, 3) == m_BlockType) ) { // Already a doublechest neighbor, disallow: @@ -143,12 +143,12 @@ public: } NumChestNeighbors += 1; } - if (Area.GetRelBlockType(3, 0, 2) == E_BLOCK_CHEST) + if (Area.GetRelBlockType(3, 0, 2) == m_BlockType) { if ( - (Area.GetRelBlockType(4, 0, 2) == E_BLOCK_CHEST) || - (Area.GetRelBlockType(3, 0, 1) == E_BLOCK_CHEST) || - (Area.GetRelBlockType(3, 0, 3) == E_BLOCK_CHEST) + (Area.GetRelBlockType(4, 0, 2) == m_BlockType) || + (Area.GetRelBlockType(3, 0, 1) == m_BlockType) || + (Area.GetRelBlockType(3, 0, 3) == m_BlockType) ) { // Already a doublechest neighbor, disallow: @@ -156,12 +156,12 @@ public: } NumChestNeighbors += 1; } - if (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST) + if (Area.GetRelBlockType(2, 0, 1) == m_BlockType) { if ( - (Area.GetRelBlockType(2, 0, 0) == E_BLOCK_CHEST) || - (Area.GetRelBlockType(1, 0, 1) == E_BLOCK_CHEST) || - (Area.GetRelBlockType(3, 0, 1) == E_BLOCK_CHEST) + (Area.GetRelBlockType(2, 0, 0) == m_BlockType) || + (Area.GetRelBlockType(1, 0, 1) == m_BlockType) || + (Area.GetRelBlockType(3, 0, 1) == m_BlockType) ) { // Already a doublechest neighbor, disallow: @@ -169,12 +169,12 @@ public: } NumChestNeighbors += 1; } - if (Area.GetRelBlockType(2, 0, 3) == E_BLOCK_CHEST) + if (Area.GetRelBlockType(2, 0, 3) == m_BlockType) { if ( - (Area.GetRelBlockType(2, 0, 4) == E_BLOCK_CHEST) || - (Area.GetRelBlockType(1, 0, 3) == E_BLOCK_CHEST) || - (Area.GetRelBlockType(3, 0, 3) == E_BLOCK_CHEST) + (Area.GetRelBlockType(2, 0, 4) == m_BlockType) || + (Area.GetRelBlockType(1, 0, 3) == m_BlockType) || + (Area.GetRelBlockType(3, 0, 3) == m_BlockType) ) { // Already a doublechest neighbor, disallow: @@ -217,7 +217,7 @@ public: /// If there's a chest in the a_Area in the specified coords, modifies its meta to a_NewMeta and returns true. bool CheckAndAdjustNeighbor(cChunkInterface & a_ChunkInterface, const cBlockArea & a_Area, int a_RelX, int a_RelZ, NIBBLETYPE a_NewMeta) { - if (a_Area.GetRelBlockType(a_RelX, 0, a_RelZ) != E_BLOCK_CHEST) + if (a_Area.GetRelBlockType(a_RelX, 0, a_RelZ) != m_BlockType) { return false; } @@ -228,7 +228,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.push_back(cItem(E_BLOCK_CHEST, 1, 0)); + a_Pickups.push_back(cItem(m_BlockType, 1, 0)); } } ; diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 3ddb7531d..4ec064d2b 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -191,6 +191,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType); case E_BLOCK_CARPET: return new cBlockCarpetHandler (a_BlockType); case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType); + case E_BLOCK_TRAPPED_CHEST: case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType); case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_COMMAND_BLOCK: return new cBlockCommandBlockHandler (a_BlockType); diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index faf639312..6f8d8be3e 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -85,7 +85,7 @@ int cBlockPistonHandler::FirstPassthroughBlock(int a_PistonX, int a_PistonY, int NIBBLETYPE currMeta; AddPistonDir(a_PistonX, a_PistonY, a_PistonZ, pistonmeta, 1); a_World->GetBlockTypeMeta(a_PistonX, a_PistonY, a_PistonZ, currBlock, currMeta); - if (CanBreakPush(currBlock)) + if (cBlockInfo::IsPistonBreakable(currBlock)) { // This block breaks when pushed, extend up to here return ret; diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index e6fa48e54..3913da320 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -104,6 +104,7 @@ private: case E_BLOCK_ENCHANTMENT_TABLE: case E_BLOCK_END_PORTAL: case E_BLOCK_END_PORTAL_FRAME: + // Ender chests can totally be pushed/pulled in MCS :) case E_BLOCK_FURNACE: case E_BLOCK_LIT_FURNACE: case E_BLOCK_HOPPER: @@ -113,6 +114,7 @@ private: case E_BLOCK_NOTE_BLOCK: case E_BLOCK_OBSIDIAN: case E_BLOCK_PISTON_EXTENSION: + case E_BLOCK_TRAPPED_CHEST: { return false; } @@ -126,24 +128,10 @@ private: return true; } - /// Returns true if the specified block can be pushed by a piston and broken / replaced - static inline bool CanBreakPush(BLOCKTYPE a_BlockType) { return cBlockInfo::IsPistonBreakable(a_BlockType); } - /// Returns true if the specified block can be pulled by a sticky piston static inline bool CanPull(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { - switch (a_BlockType) - { - case E_BLOCK_LAVA: - case E_BLOCK_STATIONARY_LAVA: - case E_BLOCK_STATIONARY_WATER: - case E_BLOCK_WATER: - { - return false; - } - } - - if (CanBreakPush(a_BlockType)) + if (cBlockInfo::IsPistonBreakable(a_BlockType)) { return false; // CanBreakPush returns true, but we need false to prevent pulling } diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 0fee40cac..c1f9dbfd6 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1297,6 +1297,7 @@ void cChunk::CreateBlockEntities(void) switch (BlockType) { case E_BLOCK_BEACON: + case E_BLOCK_TRAPPED_CHEST: case E_BLOCK_CHEST: case E_BLOCK_COMMAND_BLOCK: case E_BLOCK_DISPENSER: @@ -1427,6 +1428,7 @@ void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, switch (a_BlockType) { case E_BLOCK_BEACON: + case E_BLOCK_TRAPPED_CHEST: case E_BLOCK_CHEST: case E_BLOCK_COMMAND_BLOCK: case E_BLOCK_DISPENSER: @@ -2121,7 +2123,7 @@ bool cChunk::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallb { continue; } - if ((*itr)->GetBlockType() != E_BLOCK_CHEST) + if (((*itr)->GetBlockType() != E_BLOCK_CHEST) && ((*itr)->GetBlockType() != E_BLOCK_TRAPPED_CHEST) /* Trapped chests use normal chests' handlers */) { // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out return false; @@ -2501,8 +2503,8 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ) { int BlockX = m_PosX * cChunkDef::Width + a_RelX; int BlockZ = m_PosZ * cChunkDef::Width + a_RelZ; - int BlockY, ChunkX, ChunkZ; - AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ); + int ChunkX, ChunkZ; + BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ); return m_ChunkMap->GetChunkNoLoad(ChunkX, ZERO_CHUNK_Y, ChunkZ); } diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index c9fb0b59e..c53211b6b 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -847,7 +847,22 @@ void cChunkMap::WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_M -void cChunkMap::MarkChunkDirty (int a_ChunkX, int a_ChunkZ) +void cChunkMap::MarkRedstoneDirty(int a_ChunkX, int a_ChunkZ) +{ + cCSLock Lock(m_CSLayers); + cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ); + if ((Chunk == NULL) || !Chunk->IsValid()) + { + return; + } + Chunk->SetIsRedstoneDirty(true); +} + + + + + +void cChunkMap::MarkChunkDirty(int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty) { cCSLock Lock(m_CSLayers); cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ); @@ -856,6 +871,10 @@ void cChunkMap::MarkChunkDirty (int a_ChunkX, int a_ChunkZ) return; } Chunk->MarkDirty(); + if (a_MarkRedstoneDirty) + { + Chunk->SetIsRedstoneDirty(true); + } } diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 433516490..9453f090f 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -106,7 +106,8 @@ public: /** Wakes up the simulators for the specified area of blocks */ void WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ); - void MarkChunkDirty (int a_ChunkX, int a_ChunkZ); + void MarkRedstoneDirty (int a_ChunkX, int a_ChunkZ); + void MarkChunkDirty (int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty = false); void MarkChunkSaving (int a_ChunkX, int a_ChunkZ); void MarkChunkSaved (int a_ChunkX, int a_ChunkZ); diff --git a/src/Entities/ExpOrb.h b/src/Entities/ExpOrb.h index e76274ac9..2cd4ef31f 100644 --- a/src/Entities/ExpOrb.h +++ b/src/Entities/ExpOrb.h @@ -11,7 +11,7 @@ class cExpOrb : public cEntity { - typedef cExpOrb super; + typedef cEntity super; public: // tolua_end diff --git a/src/Map.cpp b/src/Map.cpp index 7721baa70..8f205a606 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -200,8 +200,8 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z) int BlockX = m_CenterX + ((a_X - (m_Width / 2)) * PixelWidth); int BlockZ = m_CenterZ + ((a_Z - (m_Height / 2)) * PixelWidth); - int ChunkX, ChunkY, ChunkZ; - m_World->BlockToChunk(BlockX, 0, BlockZ, ChunkX, ChunkY, ChunkZ); + int ChunkX, ChunkZ; + cChunkDef::BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ); int RelX = BlockX - (ChunkX * cChunkDef::Width); int RelZ = BlockZ - (ChunkZ * cChunkDef::Width); diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index 2050393c2..54b823e0f 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -262,7 +262,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S AString HexDump; if (Response.compare(0, prefix.size(), prefix)) { - LOGINFO("User \"%s\" failed to auth, bad http status line received", a_UserName.c_str()); + LOGINFO("User %s failed to auth, bad http status line received", a_UserName.c_str()); LOG("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str()); return false; } @@ -271,7 +271,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S size_t idxHeadersEnd = Response.find("\r\n\r\n"); if (idxHeadersEnd == AString::npos) { - LOGINFO("User \"%s\" failed to authenticate, bad http response header received", a_UserName.c_str()); + LOGINFO("User %s failed to authenticate, bad http response header received", a_UserName.c_str()); LOG("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str()); return false; } diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 5af9a295d..e46eb0429 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -5,6 +5,7 @@ #include "BoundingBox.h" #include "../BlockEntities/DropSpenserEntity.h" #include "../BlockEntities/NoteEntity.h" +#include "../BlockEntities/ChestEntity.h" #include "../BlockEntities/CommandBlockEntity.h" #include "../Entities/TNTEntity.h" #include "../Entities/Pickup.h" @@ -15,8 +16,6 @@ #include "../Blocks/BlockPiston.h" #include "../Blocks/BlockTripwireHook.h" -#define WAKE_SIMULATOR_IF_DIRTY(a_Chunk, a_BlockX, a_BlockY, a_BlockZ) if (a_Chunk->IsRedstoneDirty()) WakeUp(a_BlockX, a_BlockY, a_BlockZ, a_Chunk); - @@ -63,14 +62,13 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, int RelZ = 0; BLOCKTYPE Block; NIBBLETYPE Meta; - cChunk * OtherChunk = a_Chunk; if (a_OtherChunk != NULL) { RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width; RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width; a_OtherChunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta); - OtherChunk = a_OtherChunk; + a_Chunk->SetIsRedstoneDirty(true); // When the second paramter is present, it means that the first belongs to a neighbouring chunk of the coordinates - alert this chunk for changes } else { @@ -95,8 +93,6 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list as it no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = PoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); - OtherChunk->SetIsRedstoneDirty(true); continue; } else if ( @@ -112,27 +108,8 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = PoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); - OtherChunk->SetIsRedstoneDirty(true); continue; } - else if (Block == E_BLOCK_DAYLIGHT_SENSOR) - { - if (!m_World.IsChunkLighted(OtherChunk->GetPosX(), OtherChunk->GetPosZ())) - { - m_World.QueueLightChunk(OtherChunk->GetPosX(), OtherChunk->GetPosZ()); - } - else - { - if (OtherChunk->GetTimeAlteredLight(OtherChunk->GetSkyLight(RelX, a_BlockY + 1, RelZ)) <= 7) - { - itr = PoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); - OtherChunk->SetIsRedstoneDirty(true); - continue; - } - } - } ++itr; } @@ -146,8 +123,6 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); - OtherChunk->SetIsRedstoneDirty(true); continue; } else if ( @@ -161,8 +136,6 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); - OtherChunk->SetIsRedstoneDirty(true); continue; } } @@ -172,8 +145,6 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer powered through a valid middle block", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); - a_Chunk->SetIsRedstoneDirty(true); - OtherChunk->SetIsRedstoneDirty(true); continue; } } @@ -320,6 +291,7 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int case E_BLOCK_FENCE_GATE: HandleFenceGate(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_TNT: HandleTNT(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_TRAPDOOR: HandleTrapdoor(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_TRAPPED_CHEST: HandleTrappedChest(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_ACTIVATOR_RAIL: case E_BLOCK_DETECTOR_RAIL: @@ -382,18 +354,13 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int void cIncrementalRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) { - if ( - ((a_BlockX % cChunkDef::Width) <= 1) || - ((a_BlockX % cChunkDef::Width) >= 14) || - ((a_BlockZ % cChunkDef::Width) <= 1) || - ((a_BlockZ % cChunkDef::Width) >= 14) - ) // Are we on a chunk boundary? +- 2 because of LinkedPowered blocks + if (AreCoordsOnChunkBoundary(a_BlockX, a_BlockY, a_BlockZ)) { // On a chunk boundary, alert all four sides (i.e. at least one neighbouring chunk) AddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk); // Pass the original coordinates, because when adding things to our simulator lists, we get the chunk that they are in, and therefore any updates need to preseve their position - // RedstoneAddBlock to pass both the neighbouring chunk and the chunk which the coordiantes are in and +- 2 in GetNeighbour() to accomodate for LinkedPowered blocks being 2 away from chunk boundaries + // RedstoneAddBlock to pass both the neighbouring chunk and the chunk which the coordinates are in and +- 2 in GetNeighbour() to accomodate for LinkedPowered blocks being 2 away from chunk boundaries RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX - 2, a_BlockZ), a_Chunk); RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX + 2, a_BlockZ), a_Chunk); RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ - 2), a_Chunk); @@ -448,7 +415,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R if (i + 1 < ARRAYCOUNT(gCrossCoords)) // Sides of torch, not top (top is last) { if ( - ((IsMechanism(Type)) || (Type == E_BLOCK_REDSTONE_WIRE)) && // Is it a mechanism or wire? Not block/other torch etc. + IsMechanism(Type) && // Is it a mechanism? Not block/other torch etc. (!Vector3i(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z).Equals(Vector3i(X, Y, Z))) // CAN'T power block is that it is on ) { @@ -468,7 +435,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R { BLOCKTYPE Type = m_Chunk->GetBlock(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ); - if ((IsMechanism(Type)) || (Type == E_BLOCK_REDSTONE_WIRE)) // Still can't make a normal block powered though! + if (IsMechanism(Type)) // Still can't make a normal block powered though! { SetBlockPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); } @@ -780,17 +747,20 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() { for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end();) { - if (itr->a_ElapsedTicks >= itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks? { int RelBlockX = itr->a_RelBlockPos.x; int RelBlockY = itr->a_RelBlockPos.y; int RelBlockZ = itr->a_RelBlockPos.z; - NIBBLETYPE Meta = m_Chunk->GetMeta(RelBlockX, RelBlockY, RelBlockZ); + BLOCKTYPE Block; + NIBBLETYPE Meta; + m_Chunk->GetBlockTypeMeta(RelBlockX, RelBlockY, RelBlockZ, Block, Meta); if (itr->ShouldPowerOn) { - - m_Chunk->SetBlock(itr->a_RelBlockPos, E_BLOCK_REDSTONE_REPEATER_ON, Meta); // For performance + if (Block != E_BLOCK_REDSTONE_REPEATER_ON) // For performance + { + m_Chunk->SetBlock(itr->a_RelBlockPos, E_BLOCK_REDSTONE_REPEATER_ON, Meta); + } switch (Meta & 0x3) // We only want the direction (bottom) bits { @@ -820,17 +790,14 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() } } } - else + else if (Block != E_BLOCK_REDSTONE_REPEATER_OFF) { - m_Chunk->SetBlock(RelBlockX, RelBlockY, RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, Meta); + m_Chunk->SetBlock(RelBlockX, RelBlockY, RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, Meta); } itr = m_RepeatersDelayList->erase(itr); } else { - // Apparently, incrementing ticks only works reliably here, and not in SimChunk; - // With a world with lots of redstone, the repeaters simply do not delay - // I am confounded to say why. Perhaps optimisation failure. LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", itr->a_RelBlockPos.x, itr->a_RelBlockPos.y, itr->a_RelBlockPos.z, itr->a_ElapsedTicks, itr->a_DelayTicks); itr->a_ElapsedTicks++; itr++; @@ -1139,7 +1106,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R else { m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x0); - WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); + SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk); } break; } @@ -1206,7 +1173,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); - WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); + SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk); } break; @@ -1274,7 +1241,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); - WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); + SetSourceUnpowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk); } break; @@ -1341,7 +1308,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); - WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); + SetSourceUnpowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk); } break; } @@ -1384,14 +1351,14 @@ void cIncrementalRedstoneSimulator::HandleTripwireHook(int a_RelBlockX, int a_Re { if (ReverseBlockFace(cBlockTripwireHookHandler::MetadataToDirection(Meta)) == FaceToGoTowards) { - // Other hook not facing in opposite direction + // Other hook facing in opposite direction - circuit completed! break; } else { // Tripwire hook not connected at all, AND away all the power state bits m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x3); - WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); + SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk); return; } } @@ -1399,7 +1366,7 @@ void cIncrementalRedstoneSimulator::HandleTripwireHook(int a_RelBlockX, int a_Re { // Tripwire hook not connected at all, AND away all the power state bits m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x3); - WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); + SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk); return; } } @@ -1414,7 +1381,51 @@ void cIncrementalRedstoneSimulator::HandleTripwireHook(int a_RelBlockX, int a_Re { // Connected but not activated, AND away the highest bit m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, (m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x7) | 0x4); - WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ); + SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk); + } +} + + + + + +void cIncrementalRedstoneSimulator::HandleTrappedChest(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) +{ + class cGetTrappedChestPlayers : + public cChestCallback + { + public: + cGetTrappedChestPlayers(void) : + m_NumberOfPlayers(0) + { + } + + virtual bool Item(cChestEntity * a_Chest) override + { + ASSERT(a_Chest->GetBlockType() == E_BLOCK_TRAPPED_CHEST); + m_NumberOfPlayers = a_Chest->GetNumberOfPlayers(); + return (m_NumberOfPlayers <= 0); + } + + unsigned char GetPowerLevel(void) const + { + return std::min(m_NumberOfPlayers, MAX_POWER_LEVEL); + } + + private: + int m_NumberOfPlayers; + + } GTCP; + + int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX; + int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ; + if (m_Chunk->DoWithChestAt(BlockX, a_RelBlockY, BlockZ, GTCP)) + { + SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, GTCP.GetPowerLevel()); + } + else + { + SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk); } } @@ -1881,17 +1892,6 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl int SourceX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelSourceX; int SourceZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelSourceZ; - BLOCKTYPE Block = 0; - if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Block)) - { - return; - } - if (Block == E_BLOCK_AIR) - { - // Don't set air, fixes some bugs (wires powering themselves) - return; - } - cChunk * Neighbour = m_Chunk->GetNeighborChunk(BlockX, BlockZ); PoweredBlocksList * Powered = Neighbour->GetRedstoneSimulatorPoweredBlocksList(); for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr) // Check powered list @@ -1907,16 +1907,31 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl } } - PoweredBlocksList * OtherPowered = m_Chunk->GetNeighborChunk(SourceX, SourceZ)->GetRedstoneSimulatorPoweredBlocksList(); - for (PoweredBlocksList::const_iterator itr = OtherPowered->begin(); itr != OtherPowered->end(); ++itr) // Check powered list + for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list { - if ( + if ( itr->a_BlockPos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ)) && - itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)) + itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)) && + (m_Chunk->GetBlock(a_RelSourceX, a_RelSourceY, a_RelSourceZ) == E_BLOCK_REDSTONE_WIRE) ) { - // Powered wires try to power their source - don't let them! - return; + BLOCKTYPE Block; + NIBBLETYPE Meta; + Neighbour->GetBlockTypeMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Block, Meta); + + if (Block == E_BLOCK_REDSTONE_WIRE) + { + if (Meta < a_PowerLevel) + { + m_PoweredBlocks->erase(itr); // Powering source with higher power level, allow it + break; + } + else + { + // Powered wires try to power their source - don't let them! + return; + } + } } } @@ -1952,11 +1967,6 @@ void cIncrementalRedstoneSimulator::SetBlockLinkedPowered( { return; } - if (DestBlock == E_BLOCK_AIR) - { - // Don't set air, fixes some bugs (wires powering themselves) - return; - } if ((DestBlock == E_BLOCK_REDSTONE_WIRE) && (m_Chunk->GetBlock(a_RelSourceX, a_RelSourceY, a_RelSourceZ) == E_BLOCK_REDSTONE_WIRE)) { return; @@ -2066,6 +2076,43 @@ bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in +void cIncrementalRedstoneSimulator::SetSourceUnpowered(int a_SourceX, int a_SourceY, int a_SourceZ, cChunk * a_Chunk, bool a_IsFirstCall) +{ + for (PoweredBlocksList::iterator itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->end();) + { + if (itr->a_SourcePos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ))) + { + itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->erase(itr); + a_Chunk->SetIsRedstoneDirty(true); + continue; + } + ++itr; + } + for (LinkedBlocksList::iterator itr = a_Chunk->GetRedstoneSimulatorLinkedBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorLinkedBlocksList()->end();) + { + if (itr->a_SourcePos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ))) + { + itr = a_Chunk->GetRedstoneSimulatorLinkedBlocksList()->erase(itr); + a_Chunk->SetIsRedstoneDirty(true); + continue; + } + ++itr; + } + + if (a_IsFirstCall && AreCoordsOnChunkBoundary(a_SourceX, a_SourceY, a_SourceZ)) + { + // +- 2 to accomodate linked powered blocks + SetSourceUnpowered(a_SourceX, a_SourceY, a_SourceZ, a_Chunk->GetNeighborChunk(a_SourceX - 2, a_SourceZ), false); + SetSourceUnpowered(a_SourceX, a_SourceY, a_SourceZ, a_Chunk->GetNeighborChunk(a_SourceX + 2, a_SourceZ), false); + SetSourceUnpowered(a_SourceX, a_SourceY, a_SourceZ, a_Chunk->GetNeighborChunk(a_SourceX, a_SourceZ - 2), false); + SetSourceUnpowered(a_SourceX, a_SourceY, a_SourceZ, a_Chunk->GetNeighborChunk(a_SourceX, a_SourceZ + 2), false); + } +} + + + + + cIncrementalRedstoneSimulator::eRedstoneDirection cIncrementalRedstoneSimulator::GetWireDirection(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { int Dir = REDSTONE_NONE; diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index 6cefdebf2..ce987a60f 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -107,6 +107,8 @@ private: If this line is complete, it verifies that at least on wire reports an entity is on top (via its meta), and performs its task */ void HandleTripwireHook(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); + /** Handles trapped chests */ + void HandleTrappedChest(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /* ==================== */ /* ====== CARRIERS ====== */ @@ -114,8 +116,6 @@ private: void HandleRedstoneWire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles repeaters */ void HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState); - /** Handles delayed updates to Repeaters **/ - void HandleRedstoneRepeaterDelays(); /* ====================== */ /* ====== DEVICES ====== */ @@ -156,6 +156,10 @@ private: void SetAllDirsAsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char a_PowerLevel = MAX_POWER_LEVEL); /** Queues a repeater to be powered or unpowered and returns if the m_RepeatersDelayList iterators were invalidated */ bool QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn); + /** Removes a block from the Powered and LinkedPowered lists + Used for variable sources such as tripwire hooks, daylight sensors, and trapped chests + */ + void SetSourceUnpowered(int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, cChunk * a_Chunk, bool a_IsFirstCall = true); /** Returns if a coordinate is powered or linked powered */ bool AreCoordsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { return AreCoordsDirectlyPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ) || AreCoordsLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); } @@ -174,7 +178,8 @@ private: /** Returns if a wire is powered The only diffence between this and a normal AreCoordsPowered is that this function checks for a wire powering another wire */ bool IsWirePowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char & a_PowerLevel); - + /** Handles delayed updates to repeaters **/ + void HandleRedstoneRepeaterDelays(void); /** Returns if lever metadata marks it as emitting power */ bool IsLeverOn(NIBBLETYPE a_BlockMeta); @@ -186,7 +191,9 @@ private: /** Returns if a block is viable to be the MiddleBlock of a SetLinkedPowered operation */ inline static bool IsViableMiddleBlock(BLOCKTYPE Block) { return cBlockInfo::FullyOccupiesVoxel(Block); } - /** Returns if a block is a mechanism (something that accepts power and does something) */ + /** Returns if a block is a mechanism (something that accepts power and does something) + Used by torches to determine if they power a block whilst not standing on the ground + */ inline static bool IsMechanism(BLOCKTYPE Block) { switch (Block) @@ -209,6 +216,7 @@ private: case E_BLOCK_REDSTONE_REPEATER_OFF: case E_BLOCK_REDSTONE_REPEATER_ON: case E_BLOCK_POWERED_RAIL: + case E_BLOCK_REDSTONE_WIRE: { return true; } @@ -235,6 +243,7 @@ private: case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: case E_BLOCK_STONE_PRESSURE_PLATE: case E_BLOCK_WOODEN_PRESSURE_PLATE: + case E_BLOCK_TRAPPED_CHEST: { return true; } @@ -277,6 +286,7 @@ private: case E_BLOCK_STONE_PRESSURE_PLATE: case E_BLOCK_TNT: case E_BLOCK_TRAPDOOR: + case E_BLOCK_TRAPPED_CHEST: case E_BLOCK_TRIPWIRE_HOOK: case E_BLOCK_TRIPWIRE: case E_BLOCK_WOODEN_BUTTON: @@ -289,6 +299,16 @@ private: default: return false; } } + + inline static bool AreCoordsOnChunkBoundary(int a_BlockX, int a_BlockY, int a_BlockZ) + { + return ( // Are we on a chunk boundary? +- 2 because of LinkedPowered blocks + ((a_BlockX % cChunkDef::Width) <= 1) || + ((a_BlockX % cChunkDef::Width) >= 14) || + ((a_BlockZ % cChunkDef::Width) <= 1) || + ((a_BlockZ % cChunkDef::Width) >= 14) + ); + } }; diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 381c6e121..56e1d00e4 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -913,11 +913,13 @@ void cEnchantingWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ) // cChestWindow: cChestWindow::cChestWindow(cChestEntity * a_Chest) : - cWindow(wtChest, "Chest"), + cWindow(wtChest, (a_Chest->GetBlockType() == E_BLOCK_CHEST) ? "Chest" : "Trapped Chest"), m_World(a_Chest->GetWorld()), m_BlockX(a_Chest->GetPosX()), m_BlockY(a_Chest->GetPosY()), - m_BlockZ(a_Chest->GetPosZ()) + m_BlockZ(a_Chest->GetPosZ()), + m_PrimaryChest(a_Chest), + m_SecondaryChest(NULL) { m_SlotAreas.push_back(new cSlotAreaChest(a_Chest, *this)); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); @@ -927,7 +929,7 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) : m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1); // Send out the chest-open packet: - m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_CHEST); + m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_Chest->GetBlockType()); } @@ -935,11 +937,13 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) : cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_SecondaryChest) : - cWindow(wtChest, "Double Chest"), + cWindow(wtChest, (a_PrimaryChest->GetBlockType() == E_BLOCK_CHEST) ? "Double Chest" : "Double Trapped Chest"), m_World(a_PrimaryChest->GetWorld()), m_BlockX(a_PrimaryChest->GetPosX()), m_BlockY(a_PrimaryChest->GetPosY()), - m_BlockZ(a_PrimaryChest->GetPosZ()) + m_BlockZ(a_PrimaryChest->GetPosZ()), + m_PrimaryChest(a_PrimaryChest), + m_SecondaryChest(a_SecondaryChest) { m_SlotAreas.push_back(new cSlotAreaDoubleChest(a_PrimaryChest, a_SecondaryChest, *this)); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); @@ -951,7 +955,52 @@ cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_Secon m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1); // Send out the chest-open packet: - m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_CHEST); + m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_PrimaryChest->GetBlockType()); +} + + + + + +void cChestWindow::OpenedByPlayer(cPlayer & a_Player) +{ + int ChunkX, ChunkZ; + + m_PrimaryChest->SetNumberOfPlayers(m_PrimaryChest->GetNumberOfPlayers() + 1); + cChunkDef::BlockToChunk(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosZ(), ChunkX, ChunkZ); + m_PrimaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ); + + if (m_SecondaryChest != NULL) + { + m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() + 1); + cChunkDef::BlockToChunk(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosZ(), ChunkX, ChunkZ); + m_SecondaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ); + } + + cWindow::OpenedByPlayer(a_Player); +} + + + + + +bool cChestWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) +{ + int ChunkX, ChunkZ; + + m_PrimaryChest->SetNumberOfPlayers(m_PrimaryChest->GetNumberOfPlayers() - 1); + cChunkDef::BlockToChunk(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosZ(), ChunkX, ChunkZ); + m_PrimaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ); + + if (m_SecondaryChest != NULL) + { + m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() - 1); + cChunkDef::BlockToChunk(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosZ(), ChunkX, ChunkZ); + m_SecondaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ); + } + + cWindow::ClosedByPlayer(a_Player, a_CanRefuse); + return true; } @@ -961,7 +1010,7 @@ cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_Secon cChestWindow::~cChestWindow() { // Send out the chest-close packet: - m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_CHEST); + m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_CHEST /* Client apparently doesn't mind if we give this to trapped chests as well */); m_World->BroadcastSoundEffect("random.chestclosed", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1); } @@ -974,7 +1023,7 @@ cChestWindow::~cChestWindow() // cDropSpenserWindow: cDropSpenserWindow::cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserEntity * a_DropSpenser) : - cWindow(wtDropSpenser, "Dropspenser") + cWindow(wtDropSpenser, (a_DropSpenser->GetBlockType() == E_BLOCK_DISPENSER) ? "Dispenser" : "Dropper") { m_ShouldDistributeToHotbarFirst = false; m_SlotAreas.push_back(new cSlotAreaItemGrid(a_DropSpenser->GetContents(), *this)); diff --git a/src/UI/Window.h b/src/UI/Window.h index 542dccb88..b170a9d78 100644 --- a/src/UI/Window.h +++ b/src/UI/Window.h @@ -114,7 +114,7 @@ public: const cItem & a_ClickedItem ); - void OpenedByPlayer(cPlayer & a_Player); + virtual void OpenedByPlayer(cPlayer & a_Player); /// Called when a player closes this window; notifies all slot areas. Returns true if close accepted virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse); @@ -327,10 +327,15 @@ public: cChestWindow(cChestEntity * a_Chest); cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_SecondaryChest); ~cChestWindow(); + + virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) override; + virtual void OpenedByPlayer(cPlayer & a_Player) override; protected: cWorld * m_World; int m_BlockX, m_BlockY, m_BlockZ; // Position of the chest, for the window-close packet + cChestEntity * m_PrimaryChest; + cChestEntity * m_SecondaryChest; } ; diff --git a/src/World.cpp b/src/World.cpp index 48c3448a3..bc30f16e4 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -389,8 +389,8 @@ void cWorld::InitializeSpawn(void) IniFile.WriteFile(m_IniFileName); } - int ChunkX = 0, ChunkY = 0, ChunkZ = 0; - BlockToChunk((int)m_SpawnX, (int)m_SpawnY, (int)m_SpawnZ, ChunkX, ChunkY, ChunkZ); + int ChunkX = 0, ChunkZ = 0; + cChunkDef::BlockToChunk((int)m_SpawnX, (int)m_SpawnZ, ChunkX, ChunkZ); // For the debugging builds, don't make the server build too much world upon start: #if defined(_DEBUG) || defined(ANDROID_NDK) @@ -2191,9 +2191,18 @@ void cWorld::SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHa -void cWorld::MarkChunkDirty (int a_ChunkX, int a_ChunkZ) +void cWorld::MarkRedstoneDirty(int a_ChunkX, int a_ChunkZ) { - m_ChunkMap->MarkChunkDirty (a_ChunkX, a_ChunkZ); + m_ChunkMap->MarkRedstoneDirty(a_ChunkX, a_ChunkZ); +} + + + + + +void cWorld::MarkChunkDirty(int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty) +{ + m_ChunkMap->MarkChunkDirty(a_ChunkX, a_ChunkZ, a_MarkRedstoneDirty); } diff --git a/src/World.h b/src/World.h index 32e64c8e0..4f39ce231 100644 --- a/src/World.h +++ b/src/World.h @@ -242,7 +242,8 @@ public: /** If there is a block entity at the specified coords, sends it to the client specified */ void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client); - void MarkChunkDirty (int a_ChunkX, int a_ChunkZ); + void MarkRedstoneDirty(int a_ChunkX, int a_ChunkZ); + void MarkChunkDirty (int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty = false); void MarkChunkSaving(int a_ChunkX, int a_ChunkZ); void MarkChunkSaved (int a_ChunkX, int a_ChunkZ); @@ -635,18 +636,6 @@ public: // tolua_end - inline static void BlockToChunk( int a_X, int a_Y, int a_Z, int & a_ChunkX, int & a_ChunkY, int & a_ChunkZ ) - { - // TODO: Use floor() instead of weird if statements - // Also fix Y - (void)a_Y; // not unused anymore - a_ChunkX = a_X/cChunkDef::Width; - if(a_X < 0 && a_X % cChunkDef::Width != 0) a_ChunkX--; - a_ChunkY = 0; - a_ChunkZ = a_Z/cChunkDef::Width; - if(a_Z < 0 && a_Z % cChunkDef::Width != 0) a_ChunkZ--; - } - /** Saves all chunks immediately. Dangerous interface, may deadlock, use QueueSaveAllChunks() instead */ void SaveAllChunks(void); diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index bff515386..34c47e08d 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -175,10 +175,10 @@ void cNBTChunkSerializer::AddBasicTileEntity(cBlockEntity * a_Entity, const char -void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity) +void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity, BLOCKTYPE a_ChestType) { m_Writer.BeginCompound(""); - AddBasicTileEntity(a_Entity, "Chest"); + AddBasicTileEntity(a_Entity, (a_ChestType == E_BLOCK_CHEST) ? "Chest" : "TrappedChest"); m_Writer.BeginList("Items", TAG_Compound); AddItemGrid(a_Entity->GetContents()); m_Writer.EndList(); @@ -817,7 +817,8 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity) // Add tile-entity into NBT: switch (a_Entity->GetBlockType()) { - case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity); break; + case E_BLOCK_TRAPPED_CHEST: + case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break; case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break; case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break; case E_BLOCK_ENDER_CHEST: /* No need to be saved */ break; diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h index 112afc27e..f73f4ad7d 100644 --- a/src/WorldStorage/NBTChunkSerializer.h +++ b/src/WorldStorage/NBTChunkSerializer.h @@ -92,7 +92,7 @@ protected: // Block entities: void AddBasicTileEntity(cBlockEntity * a_Entity, const char * a_EntityTypeID); - void AddChestEntity (cChestEntity * a_Entity); + void AddChestEntity (cChestEntity * a_Entity, BLOCKTYPE a_ChestType); void AddDispenserEntity(cDispenserEntity * a_Entity); void AddDropperEntity (cDropperEntity * a_Entity); void AddFurnaceEntity (cFurnaceEntity * a_Furnace); diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 9870c144a..1e9fc651d 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -582,7 +582,7 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con } if (strncmp(a_NBT.GetData(sID), "Chest", a_NBT.GetDataLength(sID)) == 0) { - LoadChestFromNBT(a_BlockEntities, a_NBT, Child); + LoadChestFromNBT(a_BlockEntities, a_NBT, Child, E_BLOCK_CHEST); } else if (strncmp(a_NBT.GetData(sID), "Control", a_NBT.GetDataLength(sID)) == 0) { @@ -624,6 +624,10 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con { LoadDispenserFromNBT(a_BlockEntities, a_NBT, Child); } + else if (strncmp(a_NBT.GetData(sID), "TrappedChest", a_NBT.GetDataLength(sID)) == 0) + { + LoadChestFromNBT(a_BlockEntities, a_NBT, Child, E_BLOCK_TRAPPED_CHEST); + } // TODO: Other block entities } // for Child - tag children } @@ -740,7 +744,7 @@ void cWSSAnvil::LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a -void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx) +void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_ChestType) { ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound); int x, y, z; @@ -753,7 +757,7 @@ void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cPars { return; // Make it an empty chest - the chunk loader will provide an empty cChestEntity for this } - std::auto_ptr Chest(new cChestEntity(x, y, z, m_World)); + std::auto_ptr Chest(new cChestEntity(x, y, z, m_World, a_ChestType)); LoadItemGridFromNBT(Chest->GetContents(), a_NBT, Items); a_BlockEntities.push_back(Chest.release()); } diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h index 7542a828a..6f619fdb8 100644 --- a/src/WorldStorage/WSSAnvil.h +++ b/src/WorldStorage/WSSAnvil.h @@ -133,7 +133,7 @@ protected: */ void LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a_NBT, int a_ItemsTagIdx, int s_SlotOffset = 0); - void LoadChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_ChestType); void LoadDispenserFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadDropperFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadFlowerPotFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx); diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index a853f6ec9..a3ba443fd 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -273,7 +273,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En { for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr ) { - std::auto_ptr ChestEntity(new cChestEntity(0, 0, 0, a_World)); + std::auto_ptr ChestEntity(new cChestEntity(0, 0, 0, a_World, E_BLOCK_CHEST)); if (!ChestEntity->LoadFromJson(*itr)) { LOGWARNING("ERROR READING CHEST FROM JSON!" ); -- cgit v1.2.3 From 756c45d07bbf7e700caab660adf31bfd9f08b7e5 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 7 Jul 2014 21:12:25 +0100 Subject: Fixed compilation and pressure plates --- src/Simulator/IncrementalRedstoneSimulator.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index e46eb0429..d96c66c8b 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -101,8 +101,6 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, ((Block == E_BLOCK_LEVER) && !IsLeverOn(Meta)) || ((Block == E_BLOCK_DETECTOR_RAIL) && ((Meta & 0x08) == 0)) || (((Block == E_BLOCK_STONE_BUTTON) || (Block == E_BLOCK_WOODEN_BUTTON)) && (!IsButtonOn(Meta))) || - (((Block == E_BLOCK_STONE_PRESSURE_PLATE) || (Block == E_BLOCK_WOODEN_PRESSURE_PLATE)) && (Meta == 0)) || - (((Block == E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE) || (Block == E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE)) && (Meta == 0)) || ((Block == E_BLOCK_TRIPWIRE_HOOK) && ((Meta & 0x08) == 0)) ) { @@ -129,9 +127,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, // Things that can send power through a block but which depends on meta ((Block == E_BLOCK_REDSTONE_WIRE) && (Meta == 0)) || ((Block == E_BLOCK_LEVER) && !IsLeverOn(Meta)) || - (((Block == E_BLOCK_STONE_BUTTON) || (Block == E_BLOCK_WOODEN_BUTTON)) && (!IsButtonOn(Meta))) || - (((Block == E_BLOCK_STONE_PRESSURE_PLATE) || (Block == E_BLOCK_WOODEN_PRESSURE_PLATE)) && (Meta == 0)) || - (((Block == E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE) || (Block == E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE)) && (Meta == 0)) + (((Block == E_BLOCK_STONE_BUTTON) || (Block == E_BLOCK_WOODEN_BUTTON)) && (!IsButtonOn(Meta))) ) { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); @@ -1241,7 +1237,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); - SetSourceUnpowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk); + SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk); } break; @@ -1308,7 +1304,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); - SetSourceUnpowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk); + SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk); } break; } @@ -1907,7 +1903,7 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl } } - for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list + for (PoweredBlocksList::iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list { if ( itr->a_BlockPos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ)) && -- cgit v1.2.3 From 7c7501abc5345ec4eddd030ab4649b05354002c3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 7 Jul 2014 21:14:15 +0100 Subject: Added extra space before comments --- src/Entities/ProjectileEntity.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 334973833..0bb34019e 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -69,15 +69,15 @@ protected: if (cBlockInfo::IsSolid(a_BlockType)) { // The projectile hit a solid block, calculate the exact hit coords: - cBoundingBox bb(a_BlockX, a_BlockX + 1, a_BlockY, a_BlockY + 1, a_BlockZ, a_BlockZ + 1); // Bounding box of the block hit - const Vector3d LineStart = m_Projectile->GetPosition(); // Start point for the imaginary line that goes through the block hit - const Vector3d LineEnd = LineStart + m_Projectile->GetSpeed(); // End point for the imaginary line that goes through the block hit - double LineCoeff = 0; // Used to calculate where along the line an intersection with the bounding box occurs - eBlockFace Face; // Face hit + cBoundingBox bb(a_BlockX, a_BlockX + 1, a_BlockY, a_BlockY + 1, a_BlockZ, a_BlockZ + 1); // Bounding box of the block hit + const Vector3d LineStart = m_Projectile->GetPosition(); // Start point for the imaginary line that goes through the block hit + const Vector3d LineEnd = LineStart + m_Projectile->GetSpeed(); // End point for the imaginary line that goes through the block hit + double LineCoeff = 0; // Used to calculate where along the line an intersection with the bounding box occurs + eBlockFace Face; // Face hit if (bb.CalcLineIntersection(LineStart, LineEnd, LineCoeff, Face)) { - Vector3d Intersection = LineStart + m_Projectile->GetSpeed() * LineCoeff; // Point where projectile goes into the hit block + Vector3d Intersection = LineStart + m_Projectile->GetSpeed() * LineCoeff; // Point where projectile goes into the hit block if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, a_BlockX, a_BlockY, a_BlockZ, Face, &Intersection)) { -- cgit v1.2.3 From 164ffe50adbadd4bc123f11d585fef5c447d776e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 8 Jul 2014 12:34:39 +0100 Subject: Made things consistent --- src/BlockEntities/BlockEntity.cpp | 9 +++++---- src/WorldStorage/NBTChunkSerializer.cpp | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp index 1e2a176ef..1deddb0e9 100644 --- a/src/BlockEntities/BlockEntity.cpp +++ b/src/BlockEntities/BlockEntity.cpp @@ -27,22 +27,23 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE { switch (a_BlockType) { - case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_TRAPPED_CHEST: case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType); + case E_BLOCK_LIT_FURNACE: + case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); + + case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_COMMAND_BLOCK: return new cCommandBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_DISPENSER: return new cDispenserEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_ENDER_CHEST: return new cEnderChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_FLOWER_POT: return new cFlowerPotEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_HEAD: return new cMobHeadEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); - case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); + case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_HOPPER: return new cHopperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_SIGN_POST: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_WALLSIGN: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_NOTE_BLOCK: return new cNoteEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); } LOGD("%s: Requesting creation of an unknown block entity - block type %d (%s)", __FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str() diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 34c47e08d..1654153ff 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -818,12 +818,14 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity) switch (a_Entity->GetBlockType()) { case E_BLOCK_TRAPPED_CHEST: - case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break; + case E_BLOCK_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break; + case E_BLOCK_LIT_FURNACE: + case E_BLOCK_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break; + case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break; case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break; case E_BLOCK_ENDER_CHEST: /* No need to be saved */ break; case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break; - case E_BLOCK_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break; case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break; case E_BLOCK_SIGN_POST: case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break; -- cgit v1.2.3 From f2419afac5e138d64cbe968aad5a0838809f997c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 8 Jul 2014 23:11:06 +0200 Subject: Updated generator prefabs to current Gallery contents. --- src/Generating/Prefabs/AlchemistVillagePrefabs.cpp | 10 +++++----- src/Generating/Prefabs/JapaneseVillagePrefabs.cpp | 2 +- src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp index 5cb864d53..976f8490e 100644 --- a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp +++ b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp @@ -58,9 +58,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "o: 50: 4\n" /* torch */ "p: 13: 0\n" /* gravel */ "q: 5: 0\n" /* wood */ - "r: 96:12\n" /* trapdoor */ + "r: 96: 8\n" /* trapdoor */ "s:128: 5\n" /* sandstonestairs */ - "t:107: 0\n" /* fencegate */ + "t:107: 2\n" /* fencegate */ "u:128: 4\n" /* sandstonestairs */ "v:134: 3\n" /* 134 */ "w: 85: 0\n" /* fence */ @@ -288,7 +288,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "d: 13: 0\n" /* gravel */ "e: 5: 0\n" /* wood */ "f:128: 5\n" /* sandstonestairs */ - "g:107: 0\n" /* fencegate */ + "g:107: 2\n" /* fencegate */ "h:128: 4\n" /* sandstonestairs */ "i:134: 1\n" /* 134 */ "j:134: 3\n" /* 134 */ @@ -298,7 +298,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "n:134: 5\n" /* 134 */ "o:134: 7\n" /* 134 */ "p:134: 4\n" /* 134 */ - "q:107: 5\n" /* fencegate */ + "q:107: 1\n" /* fencegate */ "r: 64: 1\n" /* wooddoorblock */ "s: 65: 3\n" /* ladder */ "t: 50: 3\n" /* torch */ @@ -2195,7 +2195,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = 0, // MoveToGround: - false, + true, }, // LittleHouse8 diff --git a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp index 79f7a5272..d22153d87 100644 --- a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp +++ b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp @@ -294,7 +294,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = 0, // MoveToGround: - false, + true, }, // Farm diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index 9e5e06769..bba493bf1 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -356,6 +356,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "e: 8: 0\n" /* water */ "f: 50: 5\n" /* torch */ "g: 59: 7\n" /* crops */ + "h:111: 0\n" /* lilypad */ "m: 19: 0\n" /* sponge */, // Block data: @@ -407,7 +408,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 3 */ ".g.......gg.gg." /* 4 */ ".gg..g...gg.gg." /* 5 */ ".gg..g...gg.gg." - /* 6 */ "..g..g...gg.gg." + /* 6 */ "..g..g...gghgg." /* 7 */ "..g.g....gg.gg." /* 8 */ "f.....f.f.....f" -- cgit v1.2.3 From 3615bf825b53d3e192ad7fe6d047bd713bc00394 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 9 Jul 2014 14:30:06 +0200 Subject: Added inventory number click. --- src/UI/SlotArea.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/UI/SlotArea.h | 6 +++++- 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 68ec78930..93beca9c6 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -77,6 +77,19 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA DropClicked(a_Player, a_SlotNum, (a_ClickAction == caCtrlDropKey)); return; } + case caNumber1: + case caNumber2: + case caNumber3: + case caNumber4: + case caNumber5: + case caNumber6: + case caNumber7: + case caNumber8: + case caNumber9: + { + NumberClicked(a_Player, a_SlotNum, a_ClickAction); + return; + } default: { break; @@ -283,6 +296,31 @@ void cSlotArea::DropClicked(cPlayer & a_Player, int a_SlotNum, bool a_DropStack) +void cSlotArea::NumberClicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction) +{ + if ((a_ClickAction < caNumber1) || (a_ClickAction > caNumber9)) + { + return; + } + + int HotbarSlot = (int)a_ClickAction - (int)caNumber1; + cItem ItemInHotbar(a_Player.GetInventory().GetHotbarSlot(HotbarSlot)); + cItem ItemInSlot(*GetSlot(a_SlotNum, a_Player)); + + // The items are equal. Do nothing. + if (ItemInHotbar.IsEqual(ItemInSlot)) + { + return; + } + + a_Player.GetInventory().SetHotbarSlot(HotbarSlot, ItemInSlot); + SetSlot(a_SlotNum, a_Player, ItemInHotbar); +} + + + + + void cSlotArea::OnPlayerAdded(cPlayer & a_Player) { UNUSED(a_Player); diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index 03f538956..c40d65e0e 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -56,6 +56,9 @@ public: /** Called from Clicked when the action is a drop click. */ virtual void DropClicked(cPlayer & a_Player, int a_SlotNum, bool a_DropStack); + /** Called from Clicked when the action is a number click. */ + virtual void NumberClicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction); + /// Called when a new player opens the same parent window. The window already tracks the player. CS-locked. virtual void OnPlayerAdded(cPlayer & a_Player); @@ -242,6 +245,7 @@ public: // Distributing items into this area is completely disabled virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override; + protected: /// Maps player's EntityID -> current recipe; not a std::map because cCraftingGrid needs proper constructor params typedef std::list > cRecipeMap; @@ -257,7 +261,7 @@ protected: /** Handles a drop-click in the result slot. */ void DropClickedResult(cPlayer & a_Player); - + /// Updates the current recipe and result slot based on the ingredients currently in the crafting grid of the specified player void UpdateRecipe(cPlayer & a_Player); -- cgit v1.2.3 From 0d88e71d182e68af8e8c40b7993b0e08f78cf13a Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 9 Jul 2014 14:35:01 +0200 Subject: Removed unused include line. --- src/UI/SlotArea.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 93beca9c6..db05859d2 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -15,7 +15,6 @@ #include "../Root.h" #include "../FastRandom.h" #include "../BlockArea.h" -#include "polarssl/camellia.h" -- cgit v1.2.3 From 98950af634cca62af08ddf8c07b77f46165578a8 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Wed, 9 Jul 2014 16:53:01 +0200 Subject: Fixed Bucket placing --- src/Items/ItemBucket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 68c89dd85..fa98587ea 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -41,7 +41,7 @@ public: bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) { - if (a_BlockFace > 0) + if (a_BlockFace < 0) { return false; } -- cgit v1.2.3 From 74b6b398e7e5a2384f398b7dceaf45716bc70b6f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 9 Jul 2014 19:56:50 +0100 Subject: Fixed arrow collection animation * Fixed piston extension non-solidness --- src/BlockInfo.cpp | 1 - src/Entities/ArrowEntity.cpp | 24 +++--------------------- src/Entities/Pickup.cpp | 2 +- src/World.cpp | 9 --------- src/World.h | 1 - 5 files changed, 4 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 16314290a..9a953e396 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -365,7 +365,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false; a_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false; a_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false; - a_Info[E_BLOCK_PISTON_EXTENSION ].m_IsSolid = false; a_Info[E_BLOCK_POTATOES ].m_IsSolid = false; a_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false; a_Info[E_BLOCK_RAIL ].m_IsSolid = false; diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 47a0876fc..d59088e72 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -106,14 +106,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1); // Broadcast successful hit sound - m_World->BroadcastSoundEffect( - "random.successful_hit", - (int)std::floor(GetPosX() * 8.0), - (int)std::floor(GetPosY() * 8.0), - (int)std::floor(GetPosZ() * 8.0), - 0.5f, - 0.75f + ((float)((GetUniqueID() * 23) % 32)) / 64.0f - ); + GetWorld()->BroadcastSoundEffect("random.successful_hit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); Destroy(); } @@ -136,21 +129,10 @@ void cArrowEntity::CollectedBy(cPlayer * a_Dest) return; } } - - // TODO: BroadcastCollectPickup needs a cPickup, which we don't have - // m_World->BroadcastCollectPickup(*this, *a_Dest); + GetWorld()->BroadcastCollectEntity(*this, *a_Dest); + GetWorld()->BroadcastSoundEffect("random.pop", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); m_bIsCollected = true; - - cFastRandom Random; - m_World->BroadcastSoundEffect( - "random.pop", - (int)std::floor(GetPosX() * 8.0), - (int)std::floor(GetPosY() * 8), - (int)std::floor(GetPosZ() * 8), - 0.2F, - ((Random.NextFloat(1.0F) - Random.NextFloat(1.0F)) * 0.7F + 1.0F) * 2.0F - ); } } diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index 10b6bbd5c..24fa591da 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -224,7 +224,7 @@ bool cPickup::CollectedBy(cPlayer * a_Dest) } m_Item.m_ItemCount -= NumAdded; - m_World->BroadcastCollectPickup(*this, *a_Dest); + m_World->BroadcastCollectEntity(*this, *a_Dest); // Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;) m_World->BroadcastSoundEffect("random.pop",(int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); if (m_Item.m_ItemCount <= 0) diff --git a/src/World.cpp b/src/World.cpp index 48c3448a3..a6607de12 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1886,15 +1886,6 @@ void cWorld::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_ -void cWorld::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude) -{ - m_ChunkMap->BroadcastCollectEntity(a_Pickup, a_Player, a_Exclude); -} - - - - - void cWorld::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude) { m_ChunkMap->BroadcastDestroyEntity(a_Entity, a_Exclude); diff --git a/src/World.h b/src/World.h index 32e64c8e0..476a49739 100644 --- a/src/World.h +++ b/src/World.h @@ -207,7 +207,6 @@ public: void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL); void BroadcastCollectEntity (const cEntity & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL); - void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL); void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL); void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL); -- cgit v1.2.3 From da1d946b2b6cbb5d3e66c78adc09a4c472e04078 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 9 Jul 2014 22:04:26 +0100 Subject: Fixed bow charge --- src/Items/ItemBow.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index 940338d0f..185f17fee 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -55,7 +55,7 @@ public: // Too little force, ignore the shot return; } - Force = std::max(Force, 1.0); + Force = std::min(Force, 1.0); // Create the arrow entity: cArrowEntity * Arrow = new cArrowEntity(*a_Player, Force * 2); @@ -70,16 +70,7 @@ public: return; } - cFastRandom Random; - a_Player->GetWorld()->BroadcastSoundEffect( - "random.bow", - (int)std::floor(a_Player->GetPosX() * 8.0), - (int)std::floor(a_Player->GetPosY() * 8.0), - (int)std::floor(a_Player->GetPosZ() * 8.0), - 1.0F, - 1.0F / (Random.NextFloat(1.0F) * 0.4F + 1.2F) + (float)Force * 0.5F - ); - + a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)a_Player->GetPosX() * 8, (int)a_Player->GetPosY() * 8, (int)a_Player->GetPosZ() * 8, 0.5, (float)Force); if (!a_Player->IsGameModeCreative()) { a_Player->UseEquippedItem(); -- cgit v1.2.3 From a6d30a72544a626680eec6facf5b7a67ebb8fda5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 12:20:55 +0200 Subject: Removed lilypad from plains village prefabs. --- src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index bba493bf1..bad8dae74 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -356,7 +356,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "e: 8: 0\n" /* water */ "f: 50: 5\n" /* torch */ "g: 59: 7\n" /* crops */ - "h:111: 0\n" /* lilypad */ + "h: 59: 0\n" /* crops */ + "i: 59: 1\n" /* crops */ "m: 19: 0\n" /* sponge */, // Block data: @@ -404,12 +405,12 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* * 012345678901234 */ /* 0 */ "f.....f.f.....f" /* 1 */ ".gg.gg...gg.gg." - /* 2 */ ".g...g...gg.gg." - /* 3 */ ".g.......gg.gg." - /* 4 */ ".gg..g...gg.gg." - /* 5 */ ".gg..g...gg.gg." - /* 6 */ "..g..g...gghgg." - /* 7 */ "..g.g....gg.gg." + /* 2 */ ".gh.hg...gg.gg." + /* 3 */ ".gh.ih...gg.gg." + /* 4 */ ".gg.hg...gg.gg." + /* 5 */ ".gg.hg...gg.gg." + /* 6 */ ".ig.hg...gg.gg." + /* 7 */ ".hg.gh...gg.gg." /* 8 */ "f.....f.f.....f" // Level 4 -- cgit v1.2.3 From ce670accc9740ad5f096658be9b0a39b4aabf0cc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 12:37:21 +0200 Subject: Fixed Vector3.h compilation in MSVC2008. --- src/Vector3.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/Vector3.h b/src/Vector3.h index 9e855b8af..0a0968c59 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -316,6 +316,15 @@ protected: +template <> Vector3 Vector3::Floor(void) const +{ + return *this; +} + + + + + template const double Vector3::EPS = 0.000001; -- cgit v1.2.3 From db759891578c1cf4ce7f6d577b73fd1981ed502e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 12:46:09 +0200 Subject: Fixed a missing "inline" keyword. --- src/Vector3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Vector3.h b/src/Vector3.h index 0a0968c59..c175bf135 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -316,7 +316,7 @@ protected: -template <> Vector3 Vector3::Floor(void) const +template <> inline Vector3 Vector3::Floor(void) const { return *this; } -- cgit v1.2.3 From a11ad977ce9465c6c37050f7b9a82f1884645a34 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 10 Jul 2014 16:10:42 +0200 Subject: Fixed Bucket Placing --- src/Items/ItemBucket.h | 63 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index fa98587ea..41b7c82bc 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -41,7 +41,7 @@ public: bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) { - if (a_BlockFace < 0) + if (a_BlockFace > 0) { return false; } @@ -95,18 +95,24 @@ public: bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_FluidBlock) { - if (a_BlockFace < 0) + if (a_BlockFace > 0) { return false; } + + Vector3i BlockPos; + if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos)) + { + return false; + } - BLOCKTYPE CurrentBlock = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + BLOCKTYPE CurrentBlock = a_World->GetBlock(BlockPos); bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); if (!CanWashAway) { // The block pointed at cannot be washed away, so put fluid on top of it / on its sides - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - CurrentBlock = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + //AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace); + CurrentBlock = a_World->GetBlock(BlockPos); } if ( !CanWashAway && @@ -149,7 +155,7 @@ public: } } - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_FluidBlock, 0); + a_World->SetBlock(BlockPos.x, BlockPos.y, BlockPos.z, a_FluidBlock, 0); return true; } @@ -201,5 +207,50 @@ public: BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z); return true; } + + + bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & BlockPos) + { + class cCallbacks : + public cBlockTracer::cCallbacks + { + public: + Vector3i m_Pos; + bool m_HasHitLastBlock; + + + cCallbacks(void) : + m_HasHitLastBlock(false) + { + } + + virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override + { + if (a_BlockType != E_BLOCK_AIR) + { + m_HasHitLastBlock = true; + return true; + } + + m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); + + return false; + } + } Callbacks; + cLineBlockTracer Tracer(*a_World, Callbacks); + Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector()); + Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); + + Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z); + + if (!Callbacks.m_HasHitLastBlock) + { + return false; + } + + + BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z); + return true; + } }; -- cgit v1.2.3 From 47ceb9e79db2a30dd5b5e48dd28f9c6f14ed2fc3 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 10 Jul 2014 16:36:28 +0200 Subject: Maybe fixed whitespaces --- src/Items/ItemBucket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 41b7c82bc..5c8d5f741 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -105,7 +105,7 @@ public: { return false; } - + BLOCKTYPE CurrentBlock = a_World->GetBlock(BlockPos); bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); if (!CanWashAway) -- cgit v1.2.3 From 944c04a209492826365b3785ccf1ed1fc70e122c Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 10 Jul 2014 16:38:19 +0200 Subject: Maybe fixed whitespaces --- src/Items/ItemBucket.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 5c8d5f741..ab884ced6 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -99,13 +99,13 @@ public: { return false; } - - Vector3i BlockPos; - if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos)) - { - return false; - } - + + Vector3i BlockPos; + if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos)) + { + return false; + } + BLOCKTYPE CurrentBlock = a_World->GetBlock(BlockPos); bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); if (!CanWashAway) -- cgit v1.2.3 From a8efb620881cd744cfd3cc74316a39bfec80b897 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 10 Jul 2014 17:46:07 +0200 Subject: Changes --- src/Items/ItemBucket.h | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index ab884ced6..b31266f35 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -100,19 +100,19 @@ public: return false; } + BLOCKTYPE CurrentBlock; Vector3i BlockPos; - if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos)) + if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos, CurrentBlock)) { return false; } - BLOCKTYPE CurrentBlock = a_World->GetBlock(BlockPos); bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); if (!CanWashAway) { // The block pointed at cannot be washed away, so put fluid on top of it / on its sides - //AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace); - CurrentBlock = a_World->GetBlock(BlockPos); + // AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace); + // CurrentBlock = a_World->GetBlock(BlockPos); } if ( !CanWashAway && @@ -161,7 +161,7 @@ public: } - bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & BlockPos) + bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos) { class cCallbacks : public cBlockTracer::cCallbacks @@ -204,19 +204,20 @@ public: } - BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z); + a_BlockPos = Callbacks.m_Pos; return true; } - bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & BlockPos) + bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType) { class cCallbacks : public cBlockTracer::cCallbacks { public: - Vector3i m_Pos; - bool m_HasHitLastBlock; + Vector3i m_Pos; + bool m_HasHitLastBlock; + BLOCKTYPE m_LastBlock; cCallbacks(void) : @@ -226,15 +227,16 @@ public: virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override { - if (a_BlockType != E_BLOCK_AIR) - { - m_HasHitLastBlock = true; - return true; - } - - m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); - - return false; + if (a_BlockType != E_BLOCK_AIR) + { + m_HasHitLastBlock = true; + return true; + } + + m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); + m_LastBlock = a_BlockType; + + return false; } } Callbacks; @@ -249,8 +251,8 @@ public: return false; } - - BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z); + a_BlockPos = Callbacks.m_Pos; + a_BlockType = Callbacks.m_LastBlock; return true; } }; -- cgit v1.2.3 From 9e22f46b15d4c92bfbfdd5fb23d7530348f1d534 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 18:18:32 +0200 Subject: Implemented support for forced chunk ticking. Fixes #1160. --- src/Chunk.cpp | 30 ++++++++++++++++++++++++++++-- src/Chunk.h | 30 ++++++++++++++++++++++++++---- src/ChunkMap.cpp | 20 ++++++++++++++++++-- src/ChunkMap.h | 7 +++++++ src/World.cpp | 9 +++++++++ src/World.h | 7 +++++++ 6 files changed, 95 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 0fee40cac..3f5165b7b 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -87,7 +87,8 @@ cChunk::cChunk( m_NeighborZM(a_NeighborZM), m_NeighborZP(a_NeighborZP), m_WaterSimulatorData(a_World->GetWaterSimulator()->CreateChunkData()), - m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData()) + m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData()), + m_AlwaysTicked(0) { if (a_NeighborXM != NULL) { @@ -1641,6 +1642,31 @@ cBlockEntity * cChunk::GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ) +bool cChunk::ShouldBeTicked(void) const +{ + return (HasAnyClients() || (m_AlwaysTicked > 0)); +} + + + + + +void cChunk::SetAlwaysTicked(bool a_AlwaysTicked) +{ + if (a_AlwaysTicked) + { + m_AlwaysTicked += 1; + } + else + { + m_AlwaysTicked -= 1; + } +} + + + + + void cChunk::UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z) { cBlockEntity * be = GetBlockEntity(a_X, a_Y, a_Z); @@ -1852,7 +1878,7 @@ bool cChunk::HasClient( cClientHandle* a_Client ) -bool cChunk::HasAnyClients(void) +bool cChunk::HasAnyClients(void) const { return !m_LoadedByClient.empty(); } diff --git a/src/Chunk.h b/src/Chunk.h index e9d964e05..ededf62cd 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -200,11 +200,16 @@ public: void SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client); /** Adds a client to the chunk; returns true if added, false if already there */ - bool AddClient (cClientHandle* a_Client ); + bool AddClient(cClientHandle * a_Client); - void RemoveClient (cClientHandle* a_Client ); - bool HasClient (cClientHandle* a_Client ); - bool HasAnyClients(void); // Returns true if theres any client in the chunk; false otherwise + /** Removes the specified client from the chunk; ignored if client not in chunk. */ + void RemoveClient(cClientHandle * a_Client); + + /** Returns true if the specified client is present in this chunk. */ + bool HasClient(cClientHandle * a_Client); + + /** Returns true if theres any client in the chunk; false otherwise */ + bool HasAnyClients(void) const; void AddEntity(cEntity * a_Entity); void RemoveEntity(cEntity * a_Entity); @@ -390,6 +395,17 @@ public: cBlockEntity * GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ); cBlockEntity * GetBlockEntity(const Vector3i & a_BlockPos) { return GetBlockEntity(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z); } + + /** Returns true if the chunk should be ticked in the tick-thread. + Checks if there are any clients and if the always-tick flag is set */ + bool ShouldBeTicked(void) const; + + /** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter. + If the m_AlwaysTicked counter is greater than zero, the chunk is ticked in the tick-thread regardless of + whether it has any clients or not. + This function allows nesting and task-concurrency (multiple separate tasks can request ticking and as long + as at least one requests is active the chunk will be ticked). */ + void SetAlwaysTicked(bool a_AlwaysTicked); private: @@ -462,6 +478,12 @@ private: /** Indicates if simulate-once blocks should be updated by the redstone simulator */ bool m_IsRedstoneDirty; + + /** If greater than zero, the chunk is ticked even if it has no clients. + Manipulated by the SetAlwaysTicked() function, allows for nested calls of the function. + This is the support for plugin-accessible chunk tick forcing. */ + int m_AlwaysTicked; + // Pick up a random block of this chunk void getRandomBlockCoords(int& a_X, int& a_Y, int& a_Z); diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index c9fb0b59e..687c0824f 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2674,6 +2674,20 @@ void cChunkMap::QueueTickBlock(int a_BlockX, int a_BlockY, int a_BlockZ) +void cChunkMap::SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked) +{ + cCSLock Lock(m_CSLayers); + cChunkPtr Chunk = GetChunkNoLoad(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ); + if (Chunk != NULL) + { + Chunk->SetAlwaysTicked(a_AlwaysTicked); + } +} + + + + + //////////////////////////////////////////////////////////////////////////////// // cChunkMap::cChunkLayer: @@ -2788,12 +2802,14 @@ void cChunkMap::cChunkLayer::SpawnMobs(cMobSpawner& a_MobSpawner) + + void cChunkMap::cChunkLayer::Tick(float a_Dt) { for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++) { - // Only tick chunks that are valid and have clients: - if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->HasAnyClients()) + // Only tick chunks that are valid and should be ticked: + if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->ShouldBeTicked()) { m_Chunks[i]->Tick(a_Dt); } diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 433516490..b8870dfca 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -339,6 +339,13 @@ public: /** Returns the CS for locking the chunkmap; only cWorld::cLock may use this function! */ cCriticalSection & GetCS(void) { return m_CSLayers; } + + /** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter for the specified chunk. + If the m_AlwaysTicked counter is greater than zero, the chunk is ticked in the tick-thread regardless of + whether it has any clients or not. + This function allows nesting and task-concurrency (multiple separate tasks can request ticking and as long + as at least one requests is active the chunk will be ticked). */ + void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked); private: diff --git a/src/World.cpp b/src/World.cpp index a6607de12..f91a15260 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -3033,6 +3033,15 @@ void cWorld::TabCompleteUserName(const AString & a_Text, AStringVector & a_Resul +void cWorld::SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked) +{ + m_ChunkMap->SetChunkAlwaysTicked(a_ChunkX, a_ChunkZ, a_AlwaysTicked); +} + + + + + cRedstoneSimulator * cWorld::InitializeRedstoneSimulator(cIniFile & a_IniFile) { AString SimulatorName = a_IniFile.GetValueSet("Physics", "RedstoneSimulator", ""); diff --git a/src/World.h b/src/World.h index 476a49739..f903ff5be 100644 --- a/src/World.h +++ b/src/World.h @@ -772,6 +772,13 @@ public: /** Get the current darkness level based on the time */ NIBBLETYPE GetSkyDarkness() { return m_SkyDarkness; } + + /** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter for the specified chunk. + If the m_AlwaysTicked counter is greater than zero, the chunk is ticked in the tick-thread regardless of + whether it has any clients or not. + This function allows nesting and task-concurrency (multiple separate tasks can request ticking and as long + as at least one requests is active the chunk will be ticked). */ + void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked = true); // tolua_export private: -- cgit v1.2.3 From 729cc7f6ffd34724e6c9d5e3a4367ba6b2c48241 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 23:04:33 +0200 Subject: Fixed style consistency. --- src/Chunk.cpp | 121 ++++++++++++++++++++++++++++++---------------------------- src/Chunk.h | 4 +- 2 files changed, 64 insertions(+), 61 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 3f5165b7b..1e80eb61b 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -464,7 +464,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill) -void cChunk::getThreeRandomNumber(int& a_X, int& a_Y, int& a_Z,int a_MaxX, int a_MaxY, int a_MaxZ) +void cChunk::GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z,int a_MaxX, int a_MaxY, int a_MaxZ) { ASSERT(a_MaxX * a_MaxY * a_MaxZ * 8 < 0x00ffffff); int Random = m_World->GetTickRandomNumber(0x00ffffff); @@ -480,12 +480,12 @@ void cChunk::getThreeRandomNumber(int& a_X, int& a_Y, int& a_Z,int a_MaxX, int a -void cChunk::getRandomBlockCoords(int& a_X, int& a_Y, int& a_Z) +void cChunk::GetRandomBlockCoords(int & a_X, int & a_Y, int & a_Z) { // MG TODO : check if this kind of optimization (only one random call) is still needed // MG TODO : if so propagate it - getThreeRandomNumber(a_X, a_Y, a_Z, Width, Height-2, Width); + GetThreeRandomNumbers(a_X, a_Y, a_Z, Width, Height - 2, Width); a_Y++; } @@ -495,65 +495,68 @@ void cChunk::getRandomBlockCoords(int& a_X, int& a_Y, int& a_Z) void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) { - int Center_X,Center_Y,Center_Z; - getRandomBlockCoords(Center_X,Center_Y,Center_Z); - - BLOCKTYPE PackCenterBlock = GetBlock(Center_X, Center_Y, Center_Z); - if (a_MobSpawner.CheckPackCenter(PackCenterBlock)) - { - a_MobSpawner.NewPack(); - int NumberOfTries = 0; - int NumberOfSuccess = 0; - int MaxNbOfSuccess = 4; // this can be changed during the process for Wolves and Ghass - while (NumberOfTries < 12 && NumberOfSuccess < MaxNbOfSuccess) - { - const int HorizontalRange = 20; // MG TODO : relocate - const int VerticalRange = 0; // MG TODO : relocate - int Try_X, Try_Y, Try_Z; - getThreeRandomNumber(Try_X, Try_Y, Try_Z, 2*HorizontalRange+1 , 2*VerticalRange+1 , 2*HorizontalRange+1); - Try_X -= HorizontalRange; - Try_Y -= VerticalRange; - Try_Z -= HorizontalRange; - Try_X += Center_X; - Try_Y += Center_Y; - Try_Z += Center_Z; - - ASSERT(Try_Y > 0); - ASSERT(Try_Y < cChunkDef::Height-1); - - EMCSBiome Biome = m_ChunkMap->GetBiomeAt (Try_X, Try_Z); - // MG TODO : - // Moon cycle (for slime) - // check player and playerspawn presence < 24 blocks - // check mobs presence on the block - - // MG TODO : check that "Level" really means Y - - /* - NIBBLETYPE SkyLight = 0; - - NIBBLETYPE BlockLight = 0; - */ + int CenterX, CenterY, CenterZ; + GetRandomBlockCoords(CenterX, CenterY, CenterZ); - if (IsLightValid()) - { - cEntity* newMob = a_MobSpawner.TryToSpawnHere(this, Try_X, Try_Y, Try_Z, Biome, MaxNbOfSuccess); - if (newMob) - { - int WorldX, WorldY, WorldZ; - PositionToWorldPosition(Try_X, Try_Y, Try_Z, WorldX, WorldY, WorldZ); - double ActualX = WorldX + 0.5; - double ActualZ = WorldZ + 0.5; - newMob->SetPosition(ActualX, WorldY, ActualZ); - LOGD("Spawning %s #%i at %d,%d,%d",newMob->GetClass(),newMob->GetUniqueID(),WorldX, WorldY, WorldZ); - NumberOfSuccess++; - } - } - - NumberOfTries++; - } + BLOCKTYPE PackCenterBlock = GetBlock(CenterX, CenterY, CenterZ); + if (!a_MobSpawner.CheckPackCenter(PackCenterBlock)) + { + return; } + + a_MobSpawner.NewPack(); + int NumberOfTries = 0; + int NumberOfSuccess = 0; + int MaxNbOfSuccess = 4; // This can be changed during the process for Wolves and Ghasts + while ((NumberOfTries < 12) && (NumberOfSuccess < MaxNbOfSuccess)) + { + const int HorizontalRange = 20; // MG TODO : relocate + const int VerticalRange = 0; // MG TODO : relocate + int TryX, TryY, TryZ; + GetThreeRandomNumbers(TryX, TryY, TryZ, 2 * HorizontalRange + 1, 2 * VerticalRange + 1, 2 * HorizontalRange + 1); + TryX -= HorizontalRange; + TryY -= VerticalRange; + TryZ -= HorizontalRange; + TryX += CenterX; + TryY += CenterY; + TryZ += CenterZ; + + ASSERT(TryY > 0); + ASSERT(TryY < cChunkDef::Height - 1); + + EMCSBiome Biome = m_ChunkMap->GetBiomeAt(TryX, TryZ); + // MG TODO : + // Moon cycle (for slime) + // check player and playerspawn presence < 24 blocks + // check mobs presence on the block + // MG TODO : check that "Level" really means Y + + /* + NIBBLETYPE SkyLight = 0; + + NIBBLETYPE BlockLight = 0; + */ + + NumberOfTries++; + if (!IsLightValid()) + { + continue; + } + + cEntity * newMob = a_MobSpawner.TryToSpawnHere(this, TryX, TryY, TryZ, Biome, MaxNbOfSuccess); + if (newMob == NULL) + { + continue; + } + int WorldX, WorldY, WorldZ; + PositionToWorldPosition(TryX, TryY, TryZ, WorldX, WorldY, WorldZ); + double ActualX = WorldX + 0.5; + double ActualZ = WorldZ + 0.5; + newMob->SetPosition(ActualX, WorldY, ActualZ); + LOGD("Spawning %s #%i at {%d, %d, %d}", newMob->GetClass(), newMob->GetUniqueID(), WorldX, WorldY, WorldZ); + NumberOfSuccess++; + } // while (retry) } diff --git a/src/Chunk.h b/src/Chunk.h index ededf62cd..90664b513 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -486,8 +486,8 @@ private: // Pick up a random block of this chunk - void getRandomBlockCoords(int& a_X, int& a_Y, int& a_Z); - void getThreeRandomNumber(int& a_X, int& a_Y, int& a_Z,int a_MaxX, int a_MaxY, int a_MaxZ); + void GetRandomBlockCoords(int & a_X, int & a_Y, int & a_Z); + void GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z, int a_MaxX, int a_MaxY, int a_MaxZ); void RemoveBlockEntity(cBlockEntity * a_BlockEntity); void AddBlockEntity (cBlockEntity * a_BlockEntity); -- cgit v1.2.3 From 2bd486660ab4140c42da8f0f92304d64afc604e2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 11 Jul 2014 00:06:05 +0200 Subject: Preparation for player UUID-based storage: LoadFromFile() --- src/Entities/Player.cpp | 54 ++++++++++++++++++++++++++++++------------------- src/Entities/Player.h | 9 +++++++++ 2 files changed, 42 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index dbb8cd26c..2cd4d4b31 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -75,11 +75,6 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) , m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL) , m_bIsTeleporting(false) { - LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d", - a_PlayerName.c_str(), a_Client->GetIPString().c_str(), - this, GetUniqueID() - ); - m_InventoryWindow = new cInventoryWindow(*this); m_CurrentWindow = m_InventoryWindow; m_InventoryWindow->OpenedByPlayer(*this); @@ -1690,53 +1685,70 @@ void cPlayer::LoadPermissionsFromDisk() -bool cPlayer::LoadFromDisk() + +bool cPlayer::LoadFromDisk(void) { LoadPermissionsFromDisk(); AString SourceFile; - Printf(SourceFile, "players/%s.json", GetName().c_str() ); + Printf(SourceFile, "players/%s.json", GetName().c_str()); + + bool res = LoadFromFile(SourceFile); + if (res) + { + return true; + } +} + + + + +bool cPlayer::LoadFromFile(const AString & a_FileName) +{ + // Load the data from the file: cFile f; - if (!f.Open(SourceFile, cFile::fmRead)) + if (!f.Open(a_FileName, cFile::fmRead)) { // This is a new player whom we haven't seen yet, bail out, let them have the defaults return false; } - AString buffer; if (f.ReadRestOfFile(buffer) != f.GetSize()) { - LOGWARNING("Cannot read player data from file \"%s\"", SourceFile.c_str()); + LOGWARNING("Cannot read player data from file \"%s\"", a_FileName.c_str()); return false; } - f.Close(); //cool kids play nice + f.Close(); + // Parse the JSON format: Json::Value root; Json::Reader reader; if (!reader.parse(buffer, root, false)) { - LOGWARNING("Cannot parse player data in file \"%s\", player will be reset", SourceFile.c_str()); + LOGWARNING("Cannot parse player data in file \"%s\"", a_FileName.c_str()); + return false; } + // Load the player data: Json::Value & JSON_PlayerPosition = root["position"]; if (JSON_PlayerPosition.size() == 3) { - SetPosX(JSON_PlayerPosition[(unsigned int)0].asDouble()); - SetPosY(JSON_PlayerPosition[(unsigned int)1].asDouble()); - SetPosZ(JSON_PlayerPosition[(unsigned int)2].asDouble()); + SetPosX(JSON_PlayerPosition[(unsigned)0].asDouble()); + SetPosY(JSON_PlayerPosition[(unsigned)1].asDouble()); + SetPosZ(JSON_PlayerPosition[(unsigned)2].asDouble()); m_LastPos = GetPosition(); } Json::Value & JSON_PlayerRotation = root["rotation"]; if (JSON_PlayerRotation.size() == 3) { - SetYaw ((float)JSON_PlayerRotation[(unsigned int)0].asDouble()); - SetPitch ((float)JSON_PlayerRotation[(unsigned int)1].asDouble()); - SetRoll ((float)JSON_PlayerRotation[(unsigned int)2].asDouble()); + SetYaw ((float)JSON_PlayerRotation[(unsigned)0].asDouble()); + SetPitch ((float)JSON_PlayerRotation[(unsigned)1].asDouble()); + SetRoll ((float)JSON_PlayerRotation[(unsigned)2].asDouble()); } - m_Health = root.get("health", 0).asInt(); + m_Health = root.get("health", 0).asInt(); m_AirLevel = root.get("air", MAX_AIR_LEVEL).asInt(); m_FoodLevel = root.get("food", MAX_FOOD_LEVEL).asInt(); m_FoodSaturationLevel = root.get("foodSaturation", MAX_FOOD_LEVEL).asDouble(); @@ -1763,8 +1775,8 @@ bool cPlayer::LoadFromDisk() cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats); StatSerializer.Load(); - LOGD("Player \"%s\" was read from file, spawning at {%.2f, %.2f, %.2f} in world \"%s\"", - GetName().c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str() + LOGD("Player \"%s\" was read from file \"%s\", spawning at {%.2f, %.2f, %.2f} in world \"%s\"", + GetName().c_str(), a_FileName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str() ); return true; diff --git a/src/Entities/Player.h b/src/Entities/Player.h index f247ac2f9..7641b0c31 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -41,6 +41,7 @@ public: cPlayer(cClientHandle * a_Client, const AString & a_PlayerName); + virtual ~cPlayer(); virtual void SpawnOn(cClientHandle & a_Client) override; @@ -337,7 +338,15 @@ public: bool MoveToWorld(const char * a_WorldName); // tolua_export bool SaveToDisk(void); + + /** Loads the player data from the disk file. + Returns true on success, false on failure. */ bool LoadFromDisk(void); + + /** Loads the player data from the specified file. + Returns true on success, false on failure. */ + bool LoadFromFile(const AString & a_FileName); + void LoadPermissionsFromDisk(void); // tolua_export const AString & GetLoadedWorldName() { return m_LoadedWorldName; } -- cgit v1.2.3 From 6cea81e3833bafbf2916ab2a06edf31c0f9a536e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 11 Jul 2014 00:06:58 +0200 Subject: Fixed a missing return value. --- src/Entities/Player.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 2cd4d4b31..5a459d421 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1698,6 +1698,8 @@ bool cPlayer::LoadFromDisk(void) { return true; } + + return false; } -- cgit v1.2.3 From df65e8b7bb884fa67307073c0ef7010e3a8792b7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 11 Jul 2014 12:06:16 +0100 Subject: Improved LinkedPowering speed * Additionally fixed wires powering other wires through blocks --- src/Simulator/IncrementalRedstoneSimulator.cpp | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index d96c66c8b..dbadbbb2c 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -1698,8 +1698,8 @@ bool cIncrementalRedstoneSimulator::IsPistonPowered(int a_RelBlockX, int a_RelBl bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char & a_PowerLevel) { a_PowerLevel = 0; - int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; - int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; + int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX; + int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ; for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list { @@ -1716,6 +1716,14 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc { continue; } + + BLOCKTYPE Type = E_BLOCK_AIR; + int RelSourceX = itr->a_SourcePos.x - m_Chunk->GetPosX() * cChunkDef::Width; + int RelSourceZ = itr->a_SourcePos.z - m_Chunk->GetPosZ() * cChunkDef::Width; + if (!m_Chunk->UnboundedRelGetBlockType(RelSourceX, itr->a_SourcePos.y, RelSourceZ, Type) || (Type == E_BLOCK_REDSTONE_WIRE)) + { + continue; + } a_PowerLevel = std::max(itr->a_PowerLevel, a_PowerLevel); } @@ -1888,9 +1896,9 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl int SourceX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelSourceX; int SourceZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelSourceZ; - cChunk * Neighbour = m_Chunk->GetNeighborChunk(BlockX, BlockZ); - PoweredBlocksList * Powered = Neighbour->GetRedstoneSimulatorPoweredBlocksList(); - for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr) // Check powered list + cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelBlockX, a_RelBlockZ); // Adjust coordinates for the later call using these values + PoweredBlocksList * Powered = Neighbour->GetRedstoneSimulatorPoweredBlocksList(); // We need to insert the value into the chunk who owns the block position + for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr) { if ( itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)) && @@ -1903,7 +1911,8 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl } } - for (PoweredBlocksList::iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list + // No need to get neighbouring chunk as we can guarantee that when something is powering us, the entry will be in our chunk + for (PoweredBlocksList::iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) { if ( itr->a_BlockPos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ)) && @@ -1958,15 +1967,6 @@ void cIncrementalRedstoneSimulator::SetBlockLinkedPowered( int SourceX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelSourceX; int SourceZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelSourceZ; - BLOCKTYPE DestBlock = 0; - if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ, DestBlock)) - { - return; - } - if ((DestBlock == E_BLOCK_REDSTONE_WIRE) && (m_Chunk->GetBlock(a_RelSourceX, a_RelSourceY, a_RelSourceZ) == E_BLOCK_REDSTONE_WIRE)) - { - return; - } if (!IsViableMiddleBlock(a_MiddleBlock)) { return; -- cgit v1.2.3 From ebea2b7efc1775de66e0c6b6ee66da6f9ad04422 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 11 Jul 2014 13:13:10 +0200 Subject: Player data filenames are based on UUID. --- src/Entities/Player.cpp | 165 ++++++++++++++++++++++++++++++++---------------- src/Entities/Player.h | 34 ++++++---- src/Server.cpp | 3 + src/Server.h | 20 ++++++ 4 files changed, 155 insertions(+), 67 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 5a459d421..4e1314209 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -34,46 +34,47 @@ -cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) - : super(etPlayer, 0.6, 1.8) - , m_bVisible(true) - , m_FoodLevel(MAX_FOOD_LEVEL) - , m_FoodSaturationLevel(5.0) - , m_FoodTickTimer(0) - , m_FoodExhaustionLevel(0.0) - , m_FoodPoisonedTicksRemaining(0) - , m_LastJumpHeight(0) - , m_LastGroundHeight(0) - , m_bTouchGround(false) - , m_Stance(0.0) - , m_Inventory(*this) - , m_EnderChestContents(9, 3) - , m_CurrentWindow(NULL) - , m_InventoryWindow(NULL) - , m_Color('-') - , m_GameMode(eGameMode_NotSet) - , m_IP("") - , m_ClientHandle(a_Client) - , m_NormalMaxSpeed(1.0) - , m_SprintingMaxSpeed(1.3) - , m_FlyingMaxSpeed(1.0) - , m_IsCrouched(false) - , m_IsSprinting(false) - , m_IsFlying(false) - , m_IsSwimming(false) - , m_IsSubmerged(false) - , m_IsFishing(false) - , m_CanFly(false) - , m_EatingFinishTick(-1) - , m_LifetimeTotalXp(0) - , m_CurrentXp(0) - , m_bDirtyExperience(false) - , m_IsChargingBow(false) - , m_BowCharge(0) - , m_FloaterID(-1) - , m_Team(NULL) - , m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL) - , m_bIsTeleporting(false) +cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) : + super(etPlayer, 0.6, 1.8), + m_bVisible(true), + m_FoodLevel(MAX_FOOD_LEVEL), + m_FoodSaturationLevel(5.0), + m_FoodTickTimer(0), + m_FoodExhaustionLevel(0.0), + m_FoodPoisonedTicksRemaining(0), + m_LastJumpHeight(0), + m_LastGroundHeight(0), + m_bTouchGround(false), + m_Stance(0.0), + m_Inventory(*this), + m_EnderChestContents(9, 3), + m_CurrentWindow(NULL), + m_InventoryWindow(NULL), + m_Color('-'), + m_GameMode(eGameMode_NotSet), + m_IP(""), + m_ClientHandle(a_Client), + m_NormalMaxSpeed(1.0), + m_SprintingMaxSpeed(1.3), + m_FlyingMaxSpeed(1.0), + m_IsCrouched(false), + m_IsSprinting(false), + m_IsFlying(false), + m_IsSwimming(false), + m_IsSubmerged(false), + m_IsFishing(false), + m_CanFly(false), + m_EatingFinishTick(-1), + m_LifetimeTotalXp(0), + m_CurrentXp(0), + m_bDirtyExperience(false), + m_IsChargingBow(false), + m_BowCharge(0), + m_FloaterID(-1), + m_Team(NULL), + m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL), + m_bIsTeleporting(false), + m_UUID((a_Client != NULL) ? a_Client->GetUUID() : "") { m_InventoryWindow = new cInventoryWindow(*this); m_CurrentWindow = m_InventoryWindow; @@ -1690,15 +1691,42 @@ bool cPlayer::LoadFromDisk(void) { LoadPermissionsFromDisk(); - AString SourceFile; - Printf(SourceFile, "players/%s.json", GetName().c_str()); - - bool res = LoadFromFile(SourceFile); + // Load from the UUID file: + bool res = LoadFromFile(GetUUIDFileName(m_UUID)); if (res) { return true; } + // Load from the offline UUID file, if allowed: + AString OfflineUUID = cClientHandle::GenerateOfflineUUID(GetName()); + if (cRoot::Get()->GetServer()->ShouldLoadOfflinePlayerData()) + { + res = LoadFromFile(GetUUIDFileName(OfflineUUID)); + if (res) + { + return true; + } + } + + // Load from the old-style name-based file, if allowed: + if (cRoot::Get()->GetServer()->ShouldLoadNamedPlayerData()) + { + AString OldStyleFileName = Printf("players/%s.json", GetName().c_str()); + res = LoadFromFile(OldStyleFileName); + if (res) + { + // Save in new format and remove the old file + SaveToDisk(); + cFile::Delete(OldStyleFileName); + return true; + } + } + + // None of the files loaded successfully + LOGD("Player data file not found for %s (%s, offline %s), will be reset to defaults.", + GetName().c_str(), m_UUID.c_str(), OfflineUUID.c_str() + ); return false; } @@ -1791,6 +1819,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName) bool cPlayer::SaveToDisk() { cFile::CreateFolder(FILE_IO_PREFIX + AString("players")); + cFile::CreateFolder(FILE_IO_PREFIX + AString("players/") + m_UUID.substr(0, 2)); // create the JSON data Json::Value JSON_PlayerPosition; @@ -1822,33 +1851,45 @@ bool cPlayer::SaveToDisk() root["foodSaturation"] = m_FoodSaturationLevel; root["foodTickTimer"] = m_FoodTickTimer; root["foodExhaustion"] = m_FoodExhaustionLevel; - root["world"] = GetWorld()->GetName(); root["isflying"] = IsFlying(); - - if (m_GameMode == GetWorld()->GetGameMode()) + root["lastknownname"] = GetName(); + if (m_World != NULL) { - root["gamemode"] = (int) eGameMode_NotSet; + root["world"] = m_World->GetName(); + if (m_GameMode == m_World->GetGameMode()) + { + root["gamemode"] = (int) eGameMode_NotSet; + } + else + { + root["gamemode"] = (int) m_GameMode; + } } else { - root["gamemode"] = (int) m_GameMode; + // This happens if the player is saved to new format after loading from the old format + root["world"] = m_LoadedWorldName; + root["gamemode"] = (int) eGameMode_NotSet; } Json::StyledWriter writer; std::string JsonData = writer.write(root); - AString SourceFile; - Printf(SourceFile, "players/%s.json", GetName().c_str() ); + AString SourceFile = GetUUIDFileName(m_UUID); cFile f; if (!f.Open(SourceFile, cFile::fmWrite)) { - LOGERROR("ERROR WRITING PLAYER \"%s\" TO FILE \"%s\" - cannot open file", GetName().c_str(), SourceFile.c_str()); + LOGWARNING("Error writing player \"%s\" to file \"%s\" - cannot open file. Player will lose their progress.", + GetName().c_str(), SourceFile.c_str() + ); return false; } if (f.Write(JsonData.c_str(), JsonData.size()) != (int)JsonData.size()) { - LOGERROR("ERROR WRITING PLAYER JSON TO FILE \"%s\"", SourceFile.c_str()); + LOGWARNING("Error writing player \"%s\" to file \"%s\" - cannot save data. Player will lose their progress. ", + GetName().c_str(), SourceFile.c_str() + ); return false; } @@ -1857,7 +1898,7 @@ bool cPlayer::SaveToDisk() cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats); if (!StatSerializer.Save()) { - LOGERROR("Could not save stats for player %s", GetName().c_str()); + LOGWARNING("Could not save stats for player %s", GetName().c_str()); return false; } @@ -2170,3 +2211,19 @@ void cPlayer::Detach() + +AString cPlayer::GetUUIDFileName(const AString & a_UUID) +{ + ASSERT(a_UUID.size() == 36); + + AString res("players/"); + res.append(a_UUID, 0, 2); + res.push_back('/'); + res.append(a_UUID, 2, AString::npos); + res.append(".json"); + return res; +} + + + + diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 7641b0c31..8f9b46e0f 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -528,6 +528,24 @@ protected: cStatManager m_Stats; + /** Flag representing whether the player is currently in a bed + Set by a right click on unoccupied bed, unset by a time fast forward or teleport */ + bool m_bIsInBed; + + /** How long till the player's inventory will be saved + Default save interval is #defined in PLAYER_INVENTORY_SAVE_INTERVAL */ + unsigned int m_TicksUntilNextSave; + + /** Flag used by food handling system to determine whether a teleport has just happened + Will not apply food penalties if found to be true; will set to false after processing + */ + bool m_bIsTeleporting; + + /** The UUID of the player, as read from the ClientHandle. + If no ClientHandle is given, the UUID is initialized to empty. */ + AString m_UUID; + + /** Sets the speed and sends it to the client, so that they are forced to move so. */ virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override; @@ -554,19 +572,9 @@ protected: /** Adds food exhaustion based on the difference between Pos and LastPos, sprinting status and swimming (in water block) */ void ApplyFoodExhaustionFromMovement(); - /** Flag representing whether the player is currently in a bed - Set by a right click on unoccupied bed, unset by a time fast forward or teleport */ - bool m_bIsInBed; - - /** How long till the player's inventory will be saved - Default save interval is #defined in PLAYER_INVENTORY_SAVE_INTERVAL */ - unsigned int m_TicksUntilNextSave; - - /** Flag used by food handling system to determine whether a teleport has just happened - Will not apply food penalties if found to be true; will set to false after processing - */ - bool m_bIsTeleporting; - + /** Returns the filename for the player data based on the UUID given. + This can be used both for online and offline UUIDs. */ + AString GetUUIDFileName(const AString & a_UUID); } ; // tolua_export diff --git a/src/Server.cpp b/src/Server.cpp index 2c695cc70..5d1e51036 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -258,6 +258,9 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) m_ServerID.resize(16, '0'); } + m_ShouldLoadOfflinePlayerData = a_SettingsIni.GetValueSetB("PlayerData", "LoadOfflinePlayerData", false); + m_ShouldLoadNamedPlayerData = a_SettingsIni.GetValueSetB("PlayerData", "LoadNamedPlayerData", true); + m_ClientViewDistance = a_SettingsIni.GetValueSetI("Server", "DefaultViewDistance", cClientHandle::DEFAULT_VIEW_DISTANCE); if (m_ClientViewDistance < cClientHandle::MIN_VIEW_DISTANCE) { diff --git a/src/Server.h b/src/Server.h index 3d76c8ccf..5227799e8 100644 --- a/src/Server.h +++ b/src/Server.h @@ -112,8 +112,18 @@ public: // tolua_export cRsaPrivateKey & GetPrivateKey(void) { return m_PrivateKey; } const AString & GetPublicKeyDER(void) const { return m_PublicKeyDER; } + /** Returns true if authentication has been turned on in server settings. */ bool ShouldAuthenticate(void) const { return m_ShouldAuthenticate; } + /** Returns true if offline UUIDs should be used to load data for players whose normal UUIDs cannot be found. + Loaded from the settings.ini [PlayerData].LoadOfflinePlayerData setting. */ + bool ShouldLoadOfflinePlayerData(void) const { return m_ShouldLoadOfflinePlayerData; } + + /** Returns true if old-style playernames should be used to load data for players whose regular datafiles cannot be found. + This allows a seamless transition from name-based to UUID-based player storage. + Loaded from the settings.ini [PlayerData].LoadNamedPlayerData setting. */ + bool ShouldLoadNamedPlayerData(void) const { return m_ShouldLoadNamedPlayerData; } + private: friend class cRoot; // so cRoot can create and destroy cServer @@ -204,6 +214,16 @@ private: This setting is the same as the "online-mode" setting in Vanilla. */ bool m_ShouldAuthenticate; + /** True if offline UUIDs should be used to load data for players whose normal UUIDs cannot be found. + This allows transitions from an offline (no-auth) server to an online one. + Loaded from the settings.ini [PlayerData].LoadOfflinePlayerData setting. */ + bool m_ShouldLoadOfflinePlayerData; + + /** True if old-style playernames should be used to load data for players whose regular datafiles cannot be found. + This allows a seamless transition from name-based to UUID-based player storage. + Loaded from the settings.ini [PlayerData].LoadNamedPlayerData setting. */ + bool m_ShouldLoadNamedPlayerData; + cServer(void); -- cgit v1.2.3 From 6a33fa84ae03ada5ddeb5861094a4030e612f827 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 11 Jul 2014 12:43:24 +0100 Subject: Suggestions --- src/BlockEntities/BlockEntity.cpp | 8 ++++---- src/Blocks/BlockHandler.cpp | 11 ++++++----- src/Simulator/IncrementalRedstoneSimulator.cpp | 5 ++++- src/WorldStorage/NBTChunkSerializer.cpp | 8 ++++---- 4 files changed, 18 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp index 1deddb0e9..feef088a9 100644 --- a/src/BlockEntities/BlockEntity.cpp +++ b/src/BlockEntities/BlockEntity.cpp @@ -27,10 +27,10 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE { switch (a_BlockType) { - case E_BLOCK_TRAPPED_CHEST: - case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType); - case E_BLOCK_LIT_FURNACE: - case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); + case E_BLOCK_CHEST: + case E_BLOCK_TRAPPED_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType); + case E_BLOCK_FURNACE: + case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_COMMAND_BLOCK: return new cCommandBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_World); diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 4ec064d2b..bd48ece52 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -176,7 +176,12 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) { switch(a_BlockType) { - // Block handlers, alphabetically sorted: + // Block handlers, alphabetically sorted: + case E_BLOCK_CHEST: + case E_BLOCK_TRAPPED_CHEST: return new cBlockChestHandler(a_BlockType); + case E_BLOCK_FURNACE: + case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler(a_BlockType); + case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_ACTIVATOR_RAIL: return new cBlockRailHandler (a_BlockType); case E_BLOCK_ANVIL: return new cBlockAnvilHandler (a_BlockType); @@ -191,8 +196,6 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType); case E_BLOCK_CARPET: return new cBlockCarpetHandler (a_BlockType); case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType); - case E_BLOCK_TRAPPED_CHEST: - case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType); case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_COMMAND_BLOCK: return new cBlockCommandBlockHandler (a_BlockType); case E_BLOCK_ACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType); @@ -216,7 +219,6 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType); case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType); case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType); - case E_BLOCK_FURNACE: return new cBlockFurnaceHandler (a_BlockType); case E_BLOCK_GLOWSTONE: return new cBlockGlowstoneHandler (a_BlockType); case E_BLOCK_GOLD_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_GLASS: return new cBlockGlassHandler (a_BlockType); @@ -240,7 +242,6 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_LAVA: return new cBlockLavaHandler (a_BlockType); case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType); case E_BLOCK_LILY_PAD: return new cBlockLilypadHandler (a_BlockType); - case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType); case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler(a_BlockType); case E_BLOCK_LOG: return new cBlockSidewaysHandler (a_BlockType); case E_BLOCK_MELON: return new cBlockMelonHandler (a_BlockType); diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index dbadbbb2c..141904530 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -68,7 +68,10 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width; RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width; a_OtherChunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta); - a_Chunk->SetIsRedstoneDirty(true); // When the second paramter is present, it means that the first belongs to a neighbouring chunk of the coordinates - alert this chunk for changes + + // If a_OtherChunk is passed (not NULL), it is the chunk that had a block change, and a_Chunk will be the neighbouring chunk of that block + // Because said neighbouring chunk does not know of this change but still needs to update its redstone, we set it to dirty + a_Chunk->SetIsRedstoneDirty(true); } else { diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 1654153ff..a8d5ee02b 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -817,10 +817,10 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity) // Add tile-entity into NBT: switch (a_Entity->GetBlockType()) { - case E_BLOCK_TRAPPED_CHEST: - case E_BLOCK_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break; - case E_BLOCK_LIT_FURNACE: - case E_BLOCK_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break; + case E_BLOCK_CHEST: + case E_BLOCK_TRAPPED_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break; + case E_BLOCK_FURNACE: + case E_BLOCK_LIT_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break; case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break; case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break; -- cgit v1.2.3 From ca6bcacdb9216237a25c05b2887ea69c6066356b Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Fri, 11 Jul 2014 17:58:35 +0200 Subject: Changes --- src/Items/ItemBucket.h | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index b31266f35..e7214d852 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -41,7 +41,7 @@ public: bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) { - if (a_BlockFace > 0) + if (a_BlockFace != BLOCK_FACE_NONE) { return false; } @@ -95,38 +95,18 @@ public: bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_FluidBlock) { - if (a_BlockFace > 0) + if (a_BlockFace != BLOCK_FACE_NONE) { return false; } BLOCKTYPE CurrentBlock; Vector3i BlockPos; - if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos, CurrentBlock)) + if (!GetPlacementCoordsFromTrace(a_World, a_Player, BlockPos, CurrentBlock)) { return false; } - bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); - if (!CanWashAway) - { - // The block pointed at cannot be washed away, so put fluid on top of it / on its sides - // AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace); - // CurrentBlock = a_World->GetBlock(BlockPos); - } - if ( - !CanWashAway && - (CurrentBlock != E_BLOCK_AIR) && - (CurrentBlock != E_BLOCK_WATER) && - (CurrentBlock != E_BLOCK_STATIONARY_WATER) && - (CurrentBlock != E_BLOCK_LAVA) && - (CurrentBlock != E_BLOCK_STATIONARY_LAVA) - ) - { - // Cannot place water here - return false; - } - if (a_Player->GetGameMode() != gmCreative) { // Remove fluid bucket, add empty bucket: @@ -144,6 +124,7 @@ public: } // Wash away anything that was there prior to placing: + bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); if (CanWashAway) { cBlockHandler * Handler = BlockHandler(CurrentBlock); @@ -209,7 +190,7 @@ public: } - bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType) + bool GetPlacementCoordsFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType) { class cCallbacks : public cBlockTracer::cCallbacks @@ -229,6 +210,17 @@ public: { if (a_BlockType != E_BLOCK_AIR) { + bool CanWashAway = cFluidSimulator::CanWashAway(m_LastBlock); + if ( + !CanWashAway && + (m_LastBlock != E_BLOCK_AIR) && + !IsBlockWater(m_LastBlock) && + !IsBlockLava(m_LastBlock) + ) + { + return true; + } + m_HasHitLastBlock = true; return true; } -- cgit v1.2.3 From 416c160fb52b400e81e029a358c503053a2b93ec Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 11 Jul 2014 19:40:33 +0100 Subject: Suggestions --- src/Blocks/BlockHandler.cpp | 3 ++- src/Blocks/BlockPiston.h | 2 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index bd48ece52..fcd5e2b41 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -176,12 +176,13 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) { switch(a_BlockType) { - // Block handlers, alphabetically sorted: + // Duplicate block handlers (two blocks use one handler), alphabetically sorted: case E_BLOCK_CHEST: case E_BLOCK_TRAPPED_CHEST: return new cBlockChestHandler(a_BlockType); case E_BLOCK_FURNACE: case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler(a_BlockType); + // Block handlers, alphabetically sorted: case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_ACTIVATOR_RAIL: return new cBlockRailHandler (a_BlockType); case E_BLOCK_ANVIL: return new cBlockAnvilHandler (a_BlockType); diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index 3913da320..27a44d829 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -104,7 +104,7 @@ private: case E_BLOCK_ENCHANTMENT_TABLE: case E_BLOCK_END_PORTAL: case E_BLOCK_END_PORTAL_FRAME: - // Ender chests can totally be pushed/pulled in MCS :) + // Notice the lack of an E_BLOCK_ENDER_CHEST here; its because ender chests can totally be pushed/pulled in MCS :) case E_BLOCK_FURNACE: case E_BLOCK_LIT_FURNACE: case E_BLOCK_HOPPER: diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 141904530..ffaa02ef9 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -1915,6 +1915,7 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl } // No need to get neighbouring chunk as we can guarantee that when something is powering us, the entry will be in our chunk + // TODO: on C++11 support, change this to a llama function pased to a std::remove_if for (PoweredBlocksList::iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) { if ( @@ -2077,6 +2078,8 @@ bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in void cIncrementalRedstoneSimulator::SetSourceUnpowered(int a_SourceX, int a_SourceY, int a_SourceZ, cChunk * a_Chunk, bool a_IsFirstCall) { + // TODO: on C++11 support, change both of these to llama functions pased to a std::remove_if + for (PoweredBlocksList::iterator itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->end();) { if (itr->a_SourcePos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ))) -- cgit v1.2.3 From f73042fb02ead13aa870f061a08f56d84ed1dc99 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 11 Jul 2014 23:12:57 +0200 Subject: Simplified the player data loading. --- src/Entities/Player.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 4e1314209..944ed643e 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1692,8 +1692,7 @@ bool cPlayer::LoadFromDisk(void) LoadPermissionsFromDisk(); // Load from the UUID file: - bool res = LoadFromFile(GetUUIDFileName(m_UUID)); - if (res) + if (LoadFromFile(GetUUIDFileName(m_UUID))) { return true; } @@ -1702,8 +1701,7 @@ bool cPlayer::LoadFromDisk(void) AString OfflineUUID = cClientHandle::GenerateOfflineUUID(GetName()); if (cRoot::Get()->GetServer()->ShouldLoadOfflinePlayerData()) { - res = LoadFromFile(GetUUIDFileName(OfflineUUID)); - if (res) + if (LoadFromFile(GetUUIDFileName(OfflineUUID))) { return true; } @@ -1713,18 +1711,19 @@ bool cPlayer::LoadFromDisk(void) if (cRoot::Get()->GetServer()->ShouldLoadNamedPlayerData()) { AString OldStyleFileName = Printf("players/%s.json", GetName().c_str()); - res = LoadFromFile(OldStyleFileName); - if (res) + if (LoadFromFile(OldStyleFileName)) { // Save in new format and remove the old file - SaveToDisk(); - cFile::Delete(OldStyleFileName); + if (SaveToDisk()) + { + cFile::Delete(OldStyleFileName); + } return true; } } // None of the files loaded successfully - LOGD("Player data file not found for %s (%s, offline %s), will be reset to defaults.", + LOG("Player data file not found for %s (%s, offline %s), will be reset to defaults.", GetName().c_str(), m_UUID.c_str(), OfflineUUID.c_str() ); return false; -- cgit v1.2.3 From 4e6395d6ff9f34edb4dd36dc1f8e845c56b499f4 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 11 Jul 2014 17:27:29 -0700 Subject: For now, removed creator member from Entity Effect for pointer safety --- src/Bindings/Plugin.h | 2 +- src/Bindings/PluginLua.cpp | 4 +- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 4 +- src/Bindings/PluginManager.h | 2 +- src/Entities/EntityEffect.cpp | 62 +++++++++++---------- src/Entities/EntityEffect.h | 104 +++++++++++++++++------------------- src/Entities/Pawn.cpp | 7 +-- src/Entities/Pawn.h | 3 +- src/Entities/SplashPotionEntity.cpp | 2 +- src/Items/ItemPotion.h | 4 +- src/Mobs/CaveSpider.cpp | 2 +- 12 files changed, 94 insertions(+), 104 deletions(-) (limited to 'src') diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index dabe8debb..5196a03dc 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -57,7 +57,7 @@ public: virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) = 0; virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) = 0; - virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) = 0; + virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) = 0; virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) = 0; virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0; virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index e10cca708..a08803189 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -420,14 +420,14 @@ bool cPluginLua::OnDisconnect(cClientHandle & a_Client, const AString & a_Reason -bool cPluginLua::OnEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) +bool cPluginLua::OnEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) { cCSLock Lock(m_CriticalSection); bool res = false; cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_ADD_EFFECT]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Originator, a_DistanceModifier, cLuaState::Return, res); + m_LuaState.Call((int)(**itr), &a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier, cLuaState::Return, res); if (res) { return true; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 94371c830..0ea76ba24 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -80,7 +80,7 @@ public: virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) override; virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override; - virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) override; + virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) override; virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) override; virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override; virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index c80344c30..2264faf8b 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -474,7 +474,7 @@ bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString -bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) +bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) { HookMap::iterator Plugins = m_Hooks.find(HOOK_ENTITY_ADD_EFFECT); if (Plugins == m_Hooks.end()) @@ -483,7 +483,7 @@ bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectTyp } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnEntityAddEffect(a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Originator, a_DistanceModifier)) + if ((*itr)->OnEntityAddEffect(a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier)) { return true; } diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 4d5a350d4..2f0ec0e27 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -184,7 +184,7 @@ public: // tolua_export bool CallHookCollectingPickup (cPlayer * a_Player, cPickup & a_Pickup); bool CallHookCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason); - bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier); + bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier); bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == NULL, it is a console cmd bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData); bool CallHookExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData); diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp index 9881785cb..e68ded8b0 100644 --- a/src/Entities/EntityEffect.cpp +++ b/src/Entities/EntityEffect.cpp @@ -11,7 +11,6 @@ cEntityEffect::cEntityEffect(): m_Ticks(0), m_Duration(0), m_Intensity(0), - m_Creator(NULL), m_DistanceModifier(1) { @@ -21,11 +20,10 @@ cEntityEffect::cEntityEffect(): -cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_Creator, double a_DistanceModifier): +cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, double a_DistanceModifier): m_Ticks(0), m_Duration(a_Duration), m_Intensity(a_Intensity), - m_Creator(a_Creator), m_DistanceModifier(a_DistanceModifier) { @@ -44,35 +42,35 @@ cEntityEffect::~cEntityEffect() -cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier) +cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier) { switch (a_EffectType) { - case cEntityEffect::effNoEffect: return new cEntityEffect (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effNoEffect: return new cEntityEffect (a_Duration, a_Intensity, a_DistanceModifier); - case cEntityEffect::effAbsorption: return new cEntityEffectAbsorption (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effBlindness: return new cEntityEffectBlindness (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effFireResistance: return new cEntityEffectFireResistance(a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effHaste: return new cEntityEffectHaste (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effHealthBoost: return new cEntityEffectHealthBoost (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effHunger: return new cEntityEffectHunger (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effInstantDamage: return new cEntityEffectInstantDamage (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effInstantHealth: return new cEntityEffectInstantHealth (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effInvisibility: return new cEntityEffectInvisibility (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effJumpBoost: return new cEntityEffectJumpBoost (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effMiningFatigue: return new cEntityEffectMiningFatigue (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effNausea: return new cEntityEffectNausea (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effNightVision: return new cEntityEffectNightVision (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effPoison: return new cEntityEffectPoison (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effRegeneration: return new cEntityEffectRegeneration (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effResistance: return new cEntityEffectResistance (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effSaturation: return new cEntityEffectSaturation (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effSlowness: return new cEntityEffectSlowness (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effSpeed: return new cEntityEffectSpeed (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effStrength: return new cEntityEffectStrength (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effWaterBreathing: return new cEntityEffectWaterBreathing(a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effWeakness: return new cEntityEffectWeakness (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); - case cEntityEffect::effWither: return new cEntityEffectWither (a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + case cEntityEffect::effAbsorption: return new cEntityEffectAbsorption (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effBlindness: return new cEntityEffectBlindness (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effFireResistance: return new cEntityEffectFireResistance(a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effHaste: return new cEntityEffectHaste (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effHealthBoost: return new cEntityEffectHealthBoost (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effHunger: return new cEntityEffectHunger (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effInstantDamage: return new cEntityEffectInstantDamage (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effInstantHealth: return new cEntityEffectInstantHealth (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effInvisibility: return new cEntityEffectInvisibility (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effJumpBoost: return new cEntityEffectJumpBoost (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effMiningFatigue: return new cEntityEffectMiningFatigue (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effNausea: return new cEntityEffectNausea (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effNightVision: return new cEntityEffectNightVision (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effPoison: return new cEntityEffectPoison (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effRegeneration: return new cEntityEffectRegeneration (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effResistance: return new cEntityEffectResistance (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effSaturation: return new cEntityEffectSaturation (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effSlowness: return new cEntityEffectSlowness (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effSpeed: return new cEntityEffectSpeed (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effStrength: return new cEntityEffectStrength (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effWaterBreathing: return new cEntityEffectWaterBreathing(a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effWeakness: return new cEntityEffectWeakness (a_Duration, a_Intensity, a_DistanceModifier); + case cEntityEffect::effWither: return new cEntityEffectWither (a_Duration, a_Intensity, a_DistanceModifier); } ASSERT(!"Unhandled entity effect type!"); @@ -120,7 +118,7 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target) { if (((cMonster &) a_Target).IsUndead()) { - a_Target.TakeDamage(dtPotionOfHarming, m_Creator, amount, 0); + a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage return; } } @@ -147,7 +145,7 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target) return; } } - a_Target.TakeDamage(dtPotionOfHarming, m_Creator, amount, 0); + a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage } @@ -248,7 +246,7 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target) // Cannot take poison damage when health is at 1 if (a_Target.GetHealth() > 1) { - a_Target.TakeDamage(dtPoisoning, m_Creator, 1, 0); + a_Target.TakeDamage(dtPoisoning, NULL, 1, 0); } } } @@ -269,7 +267,7 @@ void cEntityEffectWither::OnTick(cPawn & a_Target) if (m_Ticks % frequency == 0) { - a_Target.TakeDamage(dtWither, m_Creator, 1, 0); + a_Target.TakeDamage(dtWither, NULL, 1, 0); } //TODO: " withered away> } diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index ae7958e11..c593fba81 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -42,9 +42,8 @@ public: /** Creates an entity effect of the specified type @param a_Duration How long this effect will last, in ticks @param a_Intensity How strong the effect will be applied - @param a_Creator The pawn that produced this entity effect @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ - cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1); + cEntityEffect(int a_Duration, short a_Intensity, double a_DistanceModifier = 1); virtual ~cEntityEffect(void); @@ -53,9 +52,8 @@ public: @param a_EffectType The effect type to create the effect from @param a_Duration How long this effect will last, in ticks @param a_Intensity How strong the effect will be applied - @param a_Creator The pawn that produced this entity effect @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ - static cEntityEffect * CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier); + static cEntityEffect * CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier); /** Returns how many ticks this effect has been active for */ int GetTicks() { return m_Ticks; } @@ -63,15 +61,12 @@ public: int GetDuration() { return m_Duration; } /** Returns how strong the effect will be applied */ short GetIntensity() { return m_Intensity; } - /** Returns the pawn that produced this entity effect */ - cPawn *GetCreator() { return m_Creator; } /** Returns the distance modifier for affecting potency */ double GetDistanceModifier() { return m_DistanceModifier; } void SetTicks(int a_Ticks) { m_Ticks = a_Ticks; } void SetDuration(int a_Duration) { m_Duration = a_Duration; } void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; } - void SetCreator(cPawn * a_Creator) { m_Creator = a_Creator; } void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; } virtual void OnTick(cPawn & a_Target); @@ -88,9 +83,6 @@ protected: /** How strong the effect will be applied */ short m_Intensity; - /** The pawn that produced this entity effect (threw the potion, etc) */ - cPawn *m_Creator; - /** The distance modifier for affecting potency */ double m_DistanceModifier; }; @@ -103,8 +95,8 @@ class cEntityEffectSpeed: { typedef cEntityEffect super; public: - cEntityEffectSpeed(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectSpeed(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -117,8 +109,8 @@ class cEntityEffectSlowness: { typedef cEntityEffect super; public: - cEntityEffectSlowness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectSlowness(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -131,8 +123,8 @@ class cEntityEffectHaste: { typedef cEntityEffect super; public: - cEntityEffectHaste(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectHaste(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -145,8 +137,8 @@ class cEntityEffectMiningFatigue: { typedef cEntityEffect super; public: - cEntityEffectMiningFatigue(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectMiningFatigue(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -159,8 +151,8 @@ class cEntityEffectStrength: { typedef cEntityEffect super; public: - cEntityEffectStrength(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectStrength(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -173,8 +165,8 @@ class cEntityEffectInstantHealth: { typedef cEntityEffect super; public: - cEntityEffectInstantHealth(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectInstantHealth(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -189,8 +181,8 @@ class cEntityEffectInstantDamage: { typedef cEntityEffect super; public: - cEntityEffectInstantDamage(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectInstantDamage(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -205,8 +197,8 @@ class cEntityEffectJumpBoost: { typedef cEntityEffect super; public: - cEntityEffectJumpBoost(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectJumpBoost(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -219,8 +211,8 @@ class cEntityEffectNausea: { typedef cEntityEffect super; public: - cEntityEffectNausea(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectNausea(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -233,8 +225,8 @@ class cEntityEffectRegeneration: { typedef cEntityEffect super; public: - cEntityEffectRegeneration(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectRegeneration(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -249,8 +241,8 @@ class cEntityEffectResistance: { typedef cEntityEffect super; public: - cEntityEffectResistance(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectResistance(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -263,8 +255,8 @@ class cEntityEffectFireResistance: { typedef cEntityEffect super; public: - cEntityEffectFireResistance(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectFireResistance(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -277,8 +269,8 @@ class cEntityEffectWaterBreathing: { typedef cEntityEffect super; public: - cEntityEffectWaterBreathing(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectWaterBreathing(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -291,8 +283,8 @@ class cEntityEffectInvisibility: { typedef cEntityEffect super; public: - cEntityEffectInvisibility(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectInvisibility(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -305,8 +297,8 @@ class cEntityEffectBlindness: { typedef cEntityEffect super; public: - cEntityEffectBlindness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectBlindness(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -319,8 +311,8 @@ class cEntityEffectNightVision: { typedef cEntityEffect super; public: - cEntityEffectNightVision(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectNightVision(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -333,8 +325,8 @@ class cEntityEffectHunger: { typedef cEntityEffect super; public: - cEntityEffectHunger(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectHunger(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -349,8 +341,8 @@ class cEntityEffectWeakness: { typedef cEntityEffect super; public: - cEntityEffectWeakness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectWeakness(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -365,8 +357,8 @@ class cEntityEffectPoison: { typedef cEntityEffect super; public: - cEntityEffectPoison(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectPoison(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -381,8 +373,8 @@ class cEntityEffectWither: { typedef cEntityEffect super; public: - cEntityEffectWither(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectWither(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -397,8 +389,8 @@ class cEntityEffectHealthBoost: { typedef cEntityEffect super; public: - cEntityEffectHealthBoost(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectHealthBoost(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -411,8 +403,8 @@ class cEntityEffectAbsorption: { typedef cEntityEffect super; public: - cEntityEffectAbsorption(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectAbsorption(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -425,8 +417,8 @@ class cEntityEffectSaturation: { typedef cEntityEffect super; public: - cEntityEffectSaturation(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectSaturation(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 62f71e20f..840736f6a 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -52,16 +52,17 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk) void cPawn::KilledBy(cEntity * a_Killer) { ClearEntityEffects(); + super::KilledBy(a_Killer); } -void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier) +void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier) { // Check if the plugins allow the addition: - if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_Duration, a_Intensity, a_Creator, a_DistanceModifier)) + if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_Duration, a_Intensity, a_DistanceModifier)) { // A plugin disallows the addition, bail out. return; @@ -74,7 +75,7 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, s } a_Duration = (int)(a_Duration * a_DistanceModifier); - m_EntityEffects[a_EffectType] = cEntityEffect::CreateEntityEffect(a_EffectType, a_Duration, a_Intensity, a_Creator, a_DistanceModifier); + m_EntityEffects[a_EffectType] = cEntityEffect::CreateEntityEffect(a_EffectType, a_Duration, a_Intensity, a_DistanceModifier); m_World->BroadcastEntityEffect(*this, a_EffectType, a_Intensity, a_Duration); m_EntityEffects[a_EffectType]->OnActivate(*this); } diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index 307e5db3d..252ec5edb 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -30,10 +30,9 @@ public: @param a_EffectType The entity effect to apply @param a_EffectDurationTicks The duration of the effect @param a_EffectIntensity The level of the effect (0 = Potion I, 1 = Potion II, etc) - @param a_Creator The pawn that produced the effect (e.g. threw the potion) @param a_DistanceModifier The scalar multiplied to the potion duration, only applies to splash potions) */ - void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_Creator, double a_DistanceModifier = 1); + void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier = 1); /** Removes a currently applied entity effect @param a_EffectType The entity effect to remove diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 3d2ef279f..e84f1c430 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -79,7 +79,7 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity) } m_EntityEffect.SetDistanceModifier(Reduction); - ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), m_EntityEffect.GetCreator(), Reduction); + ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction); } return false; } diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index 43b9f280d..5badeda94 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -123,7 +123,7 @@ public: Vector3d Speed = a_Player->GetLookVector() * 7; short potion_damage = a_Item.m_ItemDamage; - cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, GetEntityEffectType(potion_damage), cEntityEffect(GetEntityEffectDuration(potion_damage), GetEntityEffectIntensity(potion_damage), a_Player), GetPotionName(potion_damage)); + cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, GetEntityEffectType(potion_damage), cEntityEffect(GetEntityEffectDuration(potion_damage), GetEntityEffectIntensity(potion_damage)), GetPotionName(potion_damage)); if (Projectile == NULL) { return false; @@ -146,7 +146,7 @@ public: virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override { // Called when potion is a drinkable potion - a_Player->AddEntityEffect(GetEntityEffectType(a_Item->m_ItemDamage), GetEntityEffectDuration(a_Item->m_ItemDamage), GetEntityEffectIntensity(a_Item->m_ItemDamage), a_Player); + a_Player->AddEntityEffect(GetEntityEffectType(a_Item->m_ItemDamage), GetEntityEffectDuration(a_Item->m_ItemDamage), GetEntityEffectIntensity(a_Item->m_ItemDamage)); a_Player->GetInventory().RemoveOneEquippedItem(); a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE); return true; diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp index 34135714d..118a6e93b 100644 --- a/src/Mobs/CaveSpider.cpp +++ b/src/Mobs/CaveSpider.cpp @@ -34,7 +34,7 @@ void cCaveSpider::Attack(float a_Dt) if (m_Target->IsPawn()) { // TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds - ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0, this); + ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0); } } -- cgit v1.2.3 From 8cbd43e0434323dcb1ccba6e1b95a3ca16d35d44 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 11 Jul 2014 18:58:11 -0700 Subject: Added splash potions to NBT serialization and retrieval --- src/Entities/ProjectileEntity.cpp | 2 +- src/Entities/SplashPotionEntity.h | 8 ++++++++ src/WorldStorage/NBTChunkSerializer.cpp | 11 +++++++++++ src/WorldStorage/NBTChunkSerializer.h | 1 + src/WorldStorage/WSSAnvil.cpp | 28 ++++++++++++++++++++++++++++ src/WorldStorage/WSSAnvil.h | 1 + 6 files changed, 50 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index c2d97589f..9c1161ac3 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -312,7 +312,7 @@ AString cProjectileEntity::GetMCAClassName(void) const case pkFireCharge: return "SmallFireball"; case pkEnderPearl: return "ThrownEnderpearl"; case pkExpBottle: return "ThrownExpBottle"; - case pkSplashPotion: return "ThrownPotion"; + case pkSplashPotion: return "SplashPotion"; case pkWitherSkull: return "WitherSkull"; case pkFirework: return "Firework"; case pkFishingFloat: return ""; // Unknown, perhaps MC doesn't save this? diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 548ba3a3e..ad656d8ab 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -27,6 +27,14 @@ public: cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName); + cEntityEffect::eType GetEntityEffectType() { return m_EntityEffectType; } + cEntityEffect GetEntityEffect() { return m_EntityEffect; } + int GetPotionName() { return m_PotionName; } + + void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; } + void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; } + void SetPotionName(int a_PotionName) { m_PotionName = a_PotionName; } + protected: // cProjectileEntity overrides: diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 317ace795..fe65fa723 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -29,6 +29,7 @@ #include "../Entities/Minecart.h" #include "../Entities/Pickup.h" #include "../Entities/ArrowEntity.h" +#include "../Entities/SplashPotionEntity.h" #include "../Entities/TNTEntity.h" #include "../Entities/ExpOrb.h" #include "../Entities/HangingEntity.h" @@ -604,6 +605,16 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) m_Writer.AddDouble("damage", Arrow->GetDamageCoeff()); break; } + case cProjectileEntity::pkSplashPotion: + { + cSplashPotionEntity * Potion = (cSplashPotionEntity *)a_Projectile; + + m_Writer.AddInt("EffectType", (Int16)Potion->GetEntityEffectType()); + m_Writer.AddInt("EffectDuration", (Int16)Potion->GetEntityEffect().GetDuration()); + m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity()); + m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier()); + m_Writer.AddInt("PotionName", Potion->GetPotionName()); + } case cProjectileEntity::pkGhastFireball: { m_Writer.AddInt("ExplosionPower", 1); diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h index 112afc27e..9c87c11ca 100644 --- a/src/WorldStorage/NBTChunkSerializer.h +++ b/src/WorldStorage/NBTChunkSerializer.h @@ -46,6 +46,7 @@ class cTNTEntity; class cExpOrb; class cHangingEntity; class cItemFrame; +class cEntityEffect; diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index f13c4d4d2..3fac01614 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -36,6 +36,7 @@ #include "../Entities/Minecart.h" #include "../Entities/Pickup.h" #include "../Entities/ArrowEntity.h" +#include "../Entities/SplashPotionEntity.h" #include "../Entities/ThrownEggEntity.h" #include "../Entities/ThrownEnderPearlEntity.h" #include "../Entities/ThrownSnowballEntity.h" @@ -1152,6 +1153,10 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a { LoadArrowFromNBT(a_Entities, a_NBT, a_EntityTagIdx); } + else if (strncmp(a_IDTag, "SplashPotion", a_IDTagLength) == 0) + { + LoadSplashPotionFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + } else if (strncmp(a_IDTag, "Snowball", a_IDTagLength) == 0) { LoadSnowballFromNBT(a_Entities, a_NBT, a_EntityTagIdx); @@ -1658,6 +1663,29 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ +void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) +{ + std::auto_ptr SplashPotion(new cSplashPotionEntity(NULL, 0, 0, 0, Vector3d(0, 0, 0), cEntityEffect::effNoEffect, cEntityEffect(), 0)); + if (!LoadProjectileBaseFromNBT(*SplashPotion.get(), a_NBT, a_TagIdx)) + { + return; + } + + int EffectDuration = a_NBT.FindChildByName(a_TagIdx, "EffectDuration"); + int EffectIntensity = a_NBT.FindChildByName(a_TagIdx, "EffectIntensity"); + int EffectDistanceModifier = a_NBT.FindChildByName(a_TagIdx, "EffectDistanceModifier"); + + SplashPotion->SetEntityEffectType((cEntityEffect::eType) a_NBT.FindChildByName(a_TagIdx, "EffectType")); + SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, EffectIntensity, EffectDistanceModifier)); + SplashPotion->SetPotionName(a_NBT.FindChildByName(a_TagIdx, "PotionName")); + + // Store the new splash potion in the entities list: + a_Entities.push_back(SplashPotion.release()); +} + + + + void cWSSAnvil::LoadSnowballFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h index 7542a828a..545b00509 100644 --- a/src/WorldStorage/WSSAnvil.h +++ b/src/WorldStorage/WSSAnvil.h @@ -163,6 +163,7 @@ protected: void LoadMinecartHFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadArrowFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadSplashPotionFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadSnowballFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadEggFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadFireballFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); -- cgit v1.2.3 From 68668d7a6eb3a989fc331f68fb660fff19b2f069 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Sat, 12 Jul 2014 12:44:59 +0200 Subject: Changes --- src/Items/ItemBucket.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index e7214d852..b3f008229 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -124,8 +124,7 @@ public: } // Wash away anything that was there prior to placing: - bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); - if (CanWashAway) + if (cFluidSimulator::CanWashAway(CurrentBlock)) { cBlockHandler * Handler = BlockHandler(CurrentBlock); if (Handler->DoesDropOnUnsuitable()) @@ -188,9 +187,9 @@ public: a_BlockPos = Callbacks.m_Pos; return true; } - - - bool GetPlacementCoordsFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType) + + + bool GetPlacementCoordsFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType) { class cCallbacks : public cBlockTracer::cCallbacks -- cgit v1.2.3 From e71e432633a26d0ab24d2da7e3707e4ab7060296 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Jul 2014 22:06:25 +0100 Subject: Suggestions and bug fix * Fixed hoppers pushing/pulling to/from (trapped)chests that do not form a double-chest with the chest type directly connected to said hopper; thank you, @madmaxoft --- src/BlockEntities/BlockEntity.cpp | 11 +++++------ src/BlockEntities/HopperEntity.cpp | 17 +++++++++++++---- src/Blocks/BlockHandler.cpp | 12 +++++------- src/Chunk.cpp | 2 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 2 +- src/UI/Window.cpp | 2 +- src/WorldStorage/NBTChunkSerializer.cpp | 19 +++++++++---------- 7 files changed, 35 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp index feef088a9..2910c735e 100644 --- a/src/BlockEntities/BlockEntity.cpp +++ b/src/BlockEntities/BlockEntity.cpp @@ -27,21 +27,20 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE { switch (a_BlockType) { - case E_BLOCK_CHEST: - case E_BLOCK_TRAPPED_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType); - case E_BLOCK_FURNACE: - case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); - case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType); case E_BLOCK_COMMAND_BLOCK: return new cCommandBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_DISPENSER: return new cDispenserEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_ENDER_CHEST: return new cEnderChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_FLOWER_POT: return new cFlowerPotEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_FURNACE: return new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); case E_BLOCK_HEAD: return new cMobHeadEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_HOPPER: return new cHopperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); case E_BLOCK_SIGN_POST: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_TRAPPED_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType); case E_BLOCK_WALLSIGN: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_NOTE_BLOCK: return new cNoteEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); } diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index bcaf26701..181b6a2ce 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -380,7 +380,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk) return true; } - // Check if the chest is a double-chest, if so, try to move from there: + // Check if the chest is a double-chest (chest directly above was empty), if so, try to move from there: static const struct { int x, z; @@ -403,7 +403,11 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk) } BLOCKTYPE Block = Neighbor->GetBlock(x, m_PosY + 1, z); - if ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST)) + if ( + ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST)) || + ((Block == E_BLOCK_CHEST) && (Chest->GetBlockType() != E_BLOCK_CHEST)) || + ((Block == E_BLOCK_TRAPPED_CHEST) && (Chest->GetBlockType() != E_BLOCK_TRAPPED_CHEST)) + ) { continue; } @@ -556,10 +560,11 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block } if (MoveItemsToGrid(*Chest)) { + // Chest block directly connected was not full return true; } - // Check if the chest is a double-chest, if so, try to move into the other half: + // Check if the chest is a double-chest (chest block directly connected was full), if so, try to move into the other half: static const struct { int x, z; @@ -584,7 +589,11 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block } BLOCKTYPE Block = Neighbor->GetBlock(x, a_BlockY, z); - if ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST)) + if ( + ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST)) || + ((Block == E_BLOCK_CHEST) && (Chest->GetBlockType() != E_BLOCK_CHEST)) || + ((Block == E_BLOCK_TRAPPED_CHEST) && (Chest->GetBlockType() != E_BLOCK_TRAPPED_CHEST)) + ) { continue; } diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index fcd5e2b41..730774ab1 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -176,12 +176,6 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) { switch(a_BlockType) { - // Duplicate block handlers (two blocks use one handler), alphabetically sorted: - case E_BLOCK_CHEST: - case E_BLOCK_TRAPPED_CHEST: return new cBlockChestHandler(a_BlockType); - case E_BLOCK_FURNACE: - case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler(a_BlockType); - // Block handlers, alphabetically sorted: case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_ACTIVATOR_RAIL: return new cBlockRailHandler (a_BlockType); @@ -197,6 +191,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType); case E_BLOCK_CARPET: return new cBlockCarpetHandler (a_BlockType); case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType); + case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType); case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_COMMAND_BLOCK: return new cBlockCommandBlockHandler (a_BlockType); case E_BLOCK_ACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType); @@ -220,6 +215,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType); case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType); case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType); + case E_BLOCK_FURNACE: return new cBlockFurnaceHandler (a_BlockType); case E_BLOCK_GLOWSTONE: return new cBlockGlowstoneHandler (a_BlockType); case E_BLOCK_GOLD_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_GLASS: return new cBlockGlassHandler (a_BlockType); @@ -242,8 +238,9 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_LAPIS_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_LAVA: return new cBlockLavaHandler (a_BlockType); case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType); - case E_BLOCK_LILY_PAD: return new cBlockLilypadHandler (a_BlockType); case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler(a_BlockType); + case E_BLOCK_LILY_PAD: return new cBlockLilypadHandler (a_BlockType); + case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType); case E_BLOCK_LOG: return new cBlockSidewaysHandler (a_BlockType); case E_BLOCK_MELON: return new cBlockMelonHandler (a_BlockType); case E_BLOCK_MELON_STEM: return new cBlockStemsHandler (a_BlockType); @@ -296,6 +293,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_TORCH: return new cBlockTorchHandler (a_BlockType); case E_BLOCK_TRAPDOOR: return new cBlockTrapdoorHandler (a_BlockType); case E_BLOCK_TNT: return new cBlockTNTHandler (a_BlockType); + case E_BLOCK_TRAPPED_CHEST: return new cBlockChestHandler (a_BlockType); case E_BLOCK_TRIPWIRE: return new cBlockTripwireHandler (a_BlockType); case E_BLOCK_TRIPWIRE_HOOK: return new cBlockTripwireHookHandler (a_BlockType); case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType); diff --git a/src/Chunk.cpp b/src/Chunk.cpp index c1f9dbfd6..3c63a2dc9 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -2123,7 +2123,7 @@ bool cChunk::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallb { continue; } - if (((*itr)->GetBlockType() != E_BLOCK_CHEST) && ((*itr)->GetBlockType() != E_BLOCK_TRAPPED_CHEST) /* Trapped chests use normal chests' handlers */) + if (((*itr)->GetBlockType() != E_BLOCK_CHEST) && ((*itr)->GetBlockType() != E_BLOCK_TRAPPED_CHEST)) // Trapped chests use normal chests' handlers { // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out return false; diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index ffaa02ef9..3c037b6db 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -1918,7 +1918,7 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl // TODO: on C++11 support, change this to a llama function pased to a std::remove_if for (PoweredBlocksList::iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) { - if ( + if ( itr->a_BlockPos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ)) && itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)) && (m_Chunk->GetBlock(a_RelSourceX, a_RelSourceY, a_RelSourceZ) == E_BLOCK_REDSTONE_WIRE) diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 56e1d00e4..37d3c6bd6 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -1010,7 +1010,7 @@ bool cChestWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) cChestWindow::~cChestWindow() { // Send out the chest-close packet: - m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_CHEST /* Client apparently doesn't mind if we give this to trapped chests as well */); + m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, m_PrimaryChest->GetBlockType()); m_World->BroadcastSoundEffect("random.chestclosed", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1); } diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index a8d5ee02b..abe55156b 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -817,22 +817,21 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity) // Add tile-entity into NBT: switch (a_Entity->GetBlockType()) { - case E_BLOCK_CHEST: - case E_BLOCK_TRAPPED_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break; - case E_BLOCK_FURNACE: - case E_BLOCK_LIT_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break; - + case E_BLOCK_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break; + case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity((cCommandBlockEntity *)a_Entity); break; case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break; case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break; case E_BLOCK_ENDER_CHEST: /* No need to be saved */ break; case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break; - case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break; - case E_BLOCK_SIGN_POST: - case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break; + case E_BLOCK_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break; case E_BLOCK_HEAD: AddMobHeadEntity ((cMobHeadEntity *) a_Entity); break; + case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break; + case E_BLOCK_JUKEBOX: AddJukeboxEntity( (cJukeboxEntity *) a_Entity); break; + case E_BLOCK_LIT_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break; case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break; - case E_BLOCK_JUKEBOX: AddJukeboxEntity ((cJukeboxEntity *) a_Entity); break; - case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity((cCommandBlockEntity *) a_Entity); break; + case E_BLOCK_SIGN_POST: AddSignEntity ((cSignEntity *) a_Entity); break; + case E_BLOCK_TRAPPED_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break; + case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break; default: { -- cgit v1.2.3 From 9ab0f259c763d72f6af2560007d4f5cd7b5694cd Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Jul 2014 23:25:59 +0200 Subject: Fixed alignment. --- src/BlockEntities/BlockEntity.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp index 2910c735e..05ad03a3d 100644 --- a/src/BlockEntities/BlockEntity.cpp +++ b/src/BlockEntities/BlockEntity.cpp @@ -34,11 +34,11 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_ENDER_CHEST: return new cEnderChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_FLOWER_POT: return new cFlowerPotEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_FURNACE: return new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); + case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); case E_BLOCK_HEAD: return new cMobHeadEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_HOPPER: return new cHopperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); + case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); case E_BLOCK_SIGN_POST: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World); case E_BLOCK_TRAPPED_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType); case E_BLOCK_WALLSIGN: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World); @@ -47,6 +47,7 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE LOGD("%s: Requesting creation of an unknown block entity - block type %d (%s)", __FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str() ); + ASSERT(!"Requesting creation of an unknown block entity"); return NULL; } -- cgit v1.2.3 From c4f1284d9cca12f77184b7a0b9521e87f6533974 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Jul 2014 23:30:34 +0200 Subject: cChestEntity: Renamed a member to avoid confusion. --- src/BlockEntities/ChestEntity.cpp | 2 +- src/BlockEntities/ChestEntity.h | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index 8626f3cad..ca164464c 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -13,7 +13,7 @@ cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type) : super(a_Type, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World), - m_ActivePlayers(0) + m_NumActivePlayers(0) { cBlockEntityWindowOwner::SetBlockEntity(this); } diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h index 42cf7657c..310618504 100644 --- a/src/BlockEntities/ChestEntity.h +++ b/src/BlockEntities/ChestEntity.h @@ -34,7 +34,7 @@ public: // tolua_end - /// Constructor used for normal operation + /** Constructor used for normal operation */ cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type); virtual ~cChestEntity(); @@ -48,19 +48,20 @@ public: virtual void SendTo(cClientHandle & a_Client) override; virtual void UsedBy(cPlayer * a_Player) override; - /// Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate. + /** Opens a new chest window for this chest. + Scans for neighbors to open a double chest window, if appropriate. */ void OpenNewWindow(void); /** Gets the number of players who currently have this chest open */ - int GetNumberOfPlayers(void) const { return m_ActivePlayers; } + int GetNumberOfPlayers(void) const { return m_NumActivePlayers; } - /** Gets the number of players who currently have this chest open */ - void SetNumberOfPlayers(int a_Amount) { m_ActivePlayers = a_Amount; } + /** Sets the number of players who currently have this chest open */ + void SetNumberOfPlayers(int a_NumActivePlayers) { m_NumActivePlayers = a_NumActivePlayers; } private: - /** Holds the number of players who currently have this chest open */ - int m_ActivePlayers; + /** Number of players who currently have this chest open */ + int m_NumActivePlayers; } ; // tolua_export -- cgit v1.2.3 From d72a81cb8e135695b947bea4bac320e21c9af278 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Jul 2014 23:34:32 +0200 Subject: cHopperEntity: Simplified chest conditions. --- src/BlockEntities/HopperEntity.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index 181b6a2ce..aaf82d150 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -403,12 +403,9 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk) } BLOCKTYPE Block = Neighbor->GetBlock(x, m_PosY + 1, z); - if ( - ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST)) || - ((Block == E_BLOCK_CHEST) && (Chest->GetBlockType() != E_BLOCK_CHEST)) || - ((Block == E_BLOCK_TRAPPED_CHEST) && (Chest->GetBlockType() != E_BLOCK_TRAPPED_CHEST)) - ) + if (Block != Chest->GetBlockType()) { + // Not the same kind of chest continue; } @@ -589,12 +586,9 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block } BLOCKTYPE Block = Neighbor->GetBlock(x, a_BlockY, z); - if ( - ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST)) || - ((Block == E_BLOCK_CHEST) && (Chest->GetBlockType() != E_BLOCK_CHEST)) || - ((Block == E_BLOCK_TRAPPED_CHEST) && (Chest->GetBlockType() != E_BLOCK_TRAPPED_CHEST)) - ) + if (Block != Chest->GetBlockType()) { + // Not the same kind of chest continue; } -- cgit v1.2.3 From e2e0f52ecb8683a385066c2cc11d8544d8f93c60 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Jul 2014 23:48:39 +0200 Subject: cNBTChunkSerializer: Fixed alignment. --- src/WorldStorage/NBTChunkSerializer.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index abe55156b..f5ce06fcb 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -817,21 +817,21 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity) // Add tile-entity into NBT: switch (a_Entity->GetBlockType()) { - case E_BLOCK_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break; + case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break; case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity((cCommandBlockEntity *)a_Entity); break; - case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break; - case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break; - case E_BLOCK_ENDER_CHEST: /* No need to be saved */ break; - case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break; - case E_BLOCK_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break; - case E_BLOCK_HEAD: AddMobHeadEntity ((cMobHeadEntity *) a_Entity); break; - case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break; - case E_BLOCK_JUKEBOX: AddJukeboxEntity( (cJukeboxEntity *) a_Entity); break; - case E_BLOCK_LIT_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break; - case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break; - case E_BLOCK_SIGN_POST: AddSignEntity ((cSignEntity *) a_Entity); break; - case E_BLOCK_TRAPPED_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break; - case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break; + case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break; + case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break; + case E_BLOCK_ENDER_CHEST: /* No data to be saved */ break; + case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break; + case E_BLOCK_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break; + case E_BLOCK_HEAD: AddMobHeadEntity ((cMobHeadEntity *) a_Entity); break; + case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break; + case E_BLOCK_JUKEBOX: AddJukeboxEntity ((cJukeboxEntity *) a_Entity); break; + case E_BLOCK_LIT_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break; + case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break; + case E_BLOCK_SIGN_POST: AddSignEntity ((cSignEntity *) a_Entity); break; + case E_BLOCK_TRAPPED_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break; + case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break; default: { -- cgit v1.2.3 From 9f4348fb09ae77aebcf0cdcfc2139613756dbcdc Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Jul 2014 22:50:28 +0100 Subject: Simplified buckets code slightly --- src/Items/ItemBucket.h | 47 +++++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index b3f008229..20d955de4 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -196,54 +196,37 @@ public: { public: Vector3i m_Pos; - bool m_HasHitLastBlock; - BLOCKTYPE m_LastBlock; - - - cCallbacks(void) : - m_HasHitLastBlock(false) - { - } + BLOCKTYPE m_ReplacedBlock; virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override { if (a_BlockType != E_BLOCK_AIR) { - bool CanWashAway = cFluidSimulator::CanWashAway(m_LastBlock); - if ( - !CanWashAway && - (m_LastBlock != E_BLOCK_AIR) && - !IsBlockWater(m_LastBlock) && - !IsBlockLava(m_LastBlock) - ) + m_ReplacedBlock = a_BlockType; + if (!cFluidSimulator::CanWashAway(a_BlockType)) { - return true; + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, (eBlockFace)a_EntryFace); // Was a unwashawayable block, can't overwrite it! } - - m_HasHitLastBlock = true; - return true; - } - - m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); - m_LastBlock = a_BlockType; - + m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); // (Block could be washed away, replace it) + return true; // Abort tracing + } return false; } } Callbacks; cLineBlockTracer Tracer(*a_World, Callbacks); Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector()); - Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); - - Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z); + Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); - if (!Callbacks.m_HasHitLastBlock) + // cTracer::Trace returns true when whole line was traversed. By returning true when we hit something, we ensure that this never happens if liquid could be placed + // Use this to judge whether the position is valid + if (!Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z)) { - return false; + a_BlockPos = Callbacks.m_Pos; + a_BlockType = Callbacks.m_ReplacedBlock; + return true; } - a_BlockPos = Callbacks.m_Pos; - a_BlockType = Callbacks.m_LastBlock; - return true; + return false; } }; -- cgit v1.2.3 From 945dfe75d753271394ef4109b66b1a526e5b2c93 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Jul 2014 22:52:45 +0100 Subject: Comment grammar correction --- src/Items/ItemBucket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 20d955de4..5529b4e36 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -205,7 +205,7 @@ public: m_ReplacedBlock = a_BlockType; if (!cFluidSimulator::CanWashAway(a_BlockType)) { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, (eBlockFace)a_EntryFace); // Was a unwashawayable block, can't overwrite it! + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, (eBlockFace)a_EntryFace); // Was an unwashawayable block, can't overwrite it! } m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); // (Block could be washed away, replace it) return true; // Abort tracing -- cgit v1.2.3 From 905fed09a64667f6f9cebf353dc65e6f094fbc72 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 13 Jul 2014 00:51:42 +0200 Subject: Fixed wrong types. (BLOCKTYPE -> NIBBLETYPE) --- src/BlockArea.cpp | 2 +- src/ChunkMap.cpp | 4 ++-- src/ChunkMap.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 185582ba3..0e4c42f0f 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -59,7 +59,7 @@ void InternalMergeBlocks( } else { - BLOCKTYPE FakeDestMeta = 0; + NIBBLETYPE FakeDestMeta = 0; Combinator(a_DstTypes[DstIdx], a_SrcTypes[SrcIdx], FakeDestMeta, (NIBBLETYPE)0); } ++DstIdx; diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 35d55d396..4040fff9f 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1278,7 +1278,7 @@ void cChunkMap::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYP -void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients) +void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients) { cChunkInterface ChunkInterface(this); if (a_BlockType == E_BLOCK_AIR) @@ -1303,7 +1303,7 @@ void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a -void cChunkMap::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType) +void cChunkMap::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType) { int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ; cChunkDef::AbsoluteToRelative(X, Y, Z, ChunkX, ChunkZ); diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 4daa85ebd..973d0d219 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -154,9 +154,9 @@ public: NIBBLETYPE GetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ); NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ); NIBBLETYPE GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ); - void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockMeta); - void SetBlock (cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true); - void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType = E_BLOCK_AIR); + void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockMeta); + void SetBlock (cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true); + void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType = E_BLOCK_AIR); bool GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta); bool GetBlockInfo (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight); -- cgit v1.2.3 From dc5c43c0aa3ffb8ddaa0871ccf76d872d2393cdb Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 13 Jul 2014 01:04:43 +0200 Subject: Changed comments. --- src/Mobs/Sheep.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h index 36d7df826..5ffd3e4fe 100644 --- a/src/Mobs/Sheep.h +++ b/src/Mobs/Sheep.h @@ -15,8 +15,9 @@ class cSheep : public: /** The number is the color of the sheep. - 0-15 are the normal colors, if you type -1 the server - automatically chooses the right color for the sheep when spawned. */ + Use E_META_WOOL_* constants for the wool color. + If you type -1, the server will generate a random color + with the GenerateNaturalRandomColor() function. */ cSheep(int a_Color = -1); CLASS_PROTODEF(cSheep); @@ -27,7 +28,8 @@ public: virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); } - /** Generates a random color for the sheep, like Mojang it does. */ + /** Generates a random color for the sheep like the vanilla server. + The percent's where used are from the wiki: http://minecraft.gamepedia.com/Sheep#Breeding */ static NIBBLETYPE GenerateNaturalRandomColor(void); bool IsSheared(void) const { return m_IsSheared; } -- cgit v1.2.3 From e11f41d04821c9c00796066b45c4ace86415beb3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 13 Jul 2014 00:12:32 +0100 Subject: Revert failed fix for #31 This reverts commit 69dc9b4c9aea58ebd95e2dbd0205701dfc4ce54e. --- src/ClientHandle.cpp | 31 ++++--------------------------- src/ClientHandle.h | 4 ---- 2 files changed, 4 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index efa734b44..56275a9b2 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -40,9 +40,6 @@ /** Maximum number of block change interactions a player can perform per tick - exceeding this causes a kick */ #define MAX_BLOCK_CHANGE_INTERACTIONS 20 -/** How many ticks before the socket is closed after the client is destroyed (#31) */ -static const int TICKS_BEFORE_CLOSE = 20; - @@ -79,7 +76,6 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) : m_PingID(1), m_BlockDigAnimStage(-1), m_HasStartedDigging(false), - m_TicksSinceDestruction(0), m_State(csConnected), m_ShouldCheckDownloaded(false), m_NumExplosionsThisTick(0), @@ -104,7 +100,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) : cClientHandle::~cClientHandle() { - ASSERT(m_State >= csDestroyedWaiting); // Has Destroy() been called? + ASSERT(m_State == csDestroyed); // Has Destroy() been called? LOGD("Deleting client \"%s\" at %p", GetUsername().c_str(), this); @@ -169,7 +165,7 @@ void cClientHandle::Destroy(void) RemoveFromAllChunks(); m_Player->GetWorld()->RemoveClientFromChunkSender(this); } - m_State = csDestroyedWaiting; + m_State = csDestroyed; } @@ -1823,18 +1819,7 @@ bool cClientHandle::CheckBlockInteractionsRate(void) void cClientHandle::Tick(float a_Dt) -{ - // Handle clients that are waiting for final close while destroyed: - if (m_State == csDestroyedWaiting) - { - m_TicksSinceDestruction += 1; // This field is misused for the timeout counting - if (m_TicksSinceDestruction > TICKS_BEFORE_CLOSE) - { - m_State = csDestroyed; - } - return; - } - +{ // Process received network data: AString IncomingData; { @@ -1900,15 +1885,7 @@ void cClientHandle::Tick(float a_Dt) void cClientHandle::ServerTick(float a_Dt) -{ - // Handle clients that are waiting for final close while destroyed: - if (m_State == csDestroyedWaiting) - { - // Do not wait while the client is not in the world, simply cut them off. - m_State = csDestroyed; - return; - } - +{ // Process received network data: AString IncomingData; { diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 6f2c86b27..b0bbda19e 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -325,9 +325,6 @@ private: int m_LastDigBlockX; int m_LastDigBlockY; int m_LastDigBlockZ; - - /** Used while csDestroyedWaiting for counting the ticks until the connection is closed */ - int m_TicksSinceDestruction; enum eState { @@ -338,7 +335,6 @@ private: csConfirmingPos, ///< The client has been sent the position packet, waiting for them to repeat the position back csPlaying, ///< Normal gameplay csDestroying, ///< The client is being destroyed, don't queue any more packets / don't add to chunks - csDestroyedWaiting, ///< The client has been destroyed, but is still kept so that the Kick packet is delivered (#31) csDestroyed, ///< The client has been destroyed, the destructor is to be called from the owner thread // TODO: Add Kicking here as well -- cgit v1.2.3 From 6484e9814a3a540518606f552398e0b82f91ab4d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 13 Jul 2014 00:16:49 +0100 Subject: Only one instance of server can be started This disallows the UDP multicasting that the original code enabled. xoft deterrent, in PR #1151 you implied that this was unwanted behaviour (but comments gone now as I force pushed - check emails?). Revert at will if unsatisfactory :P --- src/Server.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/Server.cpp b/src/Server.cpp index 5d1e51036..9220731eb 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -221,14 +221,12 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) bool HasAnyPorts = false; AString Ports = a_SettingsIni.GetValueSet("Server", "Port", "25565"); - m_ListenThreadIPv4.SetReuseAddr(true); if (m_ListenThreadIPv4.Initialize(Ports)) { HasAnyPorts = true; } Ports = a_SettingsIni.GetValueSet("Server", "PortsIPv6", "25565"); - m_ListenThreadIPv6.SetReuseAddr(true); if (m_ListenThreadIPv6.Initialize(Ports)) { HasAnyPorts = true; -- cgit v1.2.3 From d529971e279609ae928d9077404b95bd595b5e52 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 13 Jul 2014 02:08:02 +0200 Subject: Changed BroadcastSoundEffect function to take floating pos. --- src/BlockEntities/NoteEntity.cpp | 2 +- src/Blocks/BlockButton.h | 2 +- src/Blocks/BlockLever.h | 2 +- src/Blocks/BlockPiston.cpp | 4 ++-- src/Blocks/BroadcastInterface.h | 2 +- src/Chunk.cpp | 4 ++-- src/Chunk.h | 2 +- src/ChunkMap.cpp | 6 +++--- src/ChunkMap.h | 2 +- src/ClientHandle.cpp | 6 +++--- src/ClientHandle.h | 2 +- src/Entities/ArrowEntity.cpp | 6 +++--- src/Entities/ExpOrb.cpp | 2 +- src/Entities/Floater.cpp | 2 +- src/Entities/Pickup.cpp | 2 +- src/Entities/Player.cpp | 2 +- src/Items/ItemBow.h | 2 +- src/Items/ItemLighter.h | 6 +++--- src/Items/ItemThrowable.h | 9 +-------- src/Mobs/Creeper.cpp | 4 ++-- src/Mobs/Monster.cpp | 4 ++-- src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.cpp | 2 +- src/Protocol/Protocol125.h | 2 +- src/Protocol/Protocol132.cpp | 19 ++++++++----------- src/Protocol/Protocol132.h | 2 +- src/Protocol/Protocol17x.cpp | 14 +++++++++----- src/Protocol/Protocol17x.h | 2 +- src/Protocol/ProtocolRecognizer.cpp | 4 ++-- src/Protocol/ProtocolRecognizer.h | 2 +- src/Simulator/FloodyFluidSimulator.cpp | 4 ++-- src/Simulator/IncrementalRedstoneSimulator.cpp | 14 +++++++------- src/Simulator/VaporizeFluidSimulator.cpp | 2 +- src/UI/Window.cpp | 10 +++++----- src/World.cpp | 6 +++--- src/World.h | 2 +- 36 files changed, 77 insertions(+), 83 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/NoteEntity.cpp b/src/BlockEntities/NoteEntity.cpp index 58b05a324..95145c117 100644 --- a/src/BlockEntities/NoteEntity.cpp +++ b/src/BlockEntities/NoteEntity.cpp @@ -91,7 +91,7 @@ void cNoteEntity::MakeSound(void) // TODO: instead of calculating the power function over and over, make a precalculated table - there's only 24 pitches after all float calcPitch = pow(2.0f, ((float)m_Pitch - 12.0f) / 12.0f); - m_World->BroadcastSoundEffect(sampleName, m_PosX * 8, m_PosY * 8, m_PosZ * 8, 3.0f, calcPitch); + m_World->BroadcastSoundEffect(sampleName, (double)m_PosX, (double)m_PosY, (double)m_PosZ, 3.0f, calcPitch); } diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index ada7d58f7..7f92681dc 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -24,7 +24,7 @@ public: a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta); a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ); - a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f); + a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f); // Queue a button reset (unpress) a_ChunkInterface.QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x07), m_BlockType == E_BLOCK_STONE_BUTTON ? 20 : 30, m_BlockType, a_WorldInterface); diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h index 4e745d413..7ce8d038e 100644 --- a/src/Blocks/BlockLever.h +++ b/src/Blocks/BlockLever.h @@ -24,7 +24,7 @@ public: a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta); a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ); - a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f); + a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f); } diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index 6f8d8be3e..ec480aaea 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -124,7 +124,7 @@ void cBlockPistonHandler::ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, } a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 0, pistonMeta, pistonBlock); - a_World->BroadcastSoundEffect("tile.piston.out", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.7f); + a_World->BroadcastSoundEffect("tile.piston.out", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, 0.7f); // Drop the breakable block in the line, if appropriate: AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, dist + 1); // "a_Block" now at the breakable / empty block @@ -198,7 +198,7 @@ void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1); a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta & ~(8)); a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 1, pistonMeta & ~(8), pistonBlock); - a_World->BroadcastSoundEffect("tile.piston.in", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.7f); + a_World->BroadcastSoundEffect("tile.piston.in", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, 0.7f); AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, 1); // Retract the extension, pull block if appropriate diff --git a/src/Blocks/BroadcastInterface.h b/src/Blocks/BroadcastInterface.h index b1b450690..fbe72e72f 100644 --- a/src/Blocks/BroadcastInterface.h +++ b/src/Blocks/BroadcastInterface.h @@ -7,6 +7,6 @@ public: virtual ~cBroadcastInterface() {} virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) = 0; - virtual void BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL) = 0; + virtual void BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL) = 0; virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) = 0; }; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index c004a6408..8a249ea53 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -2956,7 +2956,7 @@ void cChunk::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectI -void cChunk::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude) +void cChunk::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude) { for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) { @@ -2964,7 +2964,7 @@ void cChunk::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a { continue; } - (*itr)->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch); + (*itr)->SendSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch); } // for itr - LoadedByClient[] } diff --git a/src/Chunk.h b/src/Chunk.h index 90664b513..dfcfdab0f 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -298,7 +298,7 @@ public: void BroadcastEntityAnimation (const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL); void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL); void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL); - void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8 + void BroadcastSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 35d55d396..2253c5877 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -647,19 +647,19 @@ void cChunkMap::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_Effe -void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude) +void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude) { cCSLock Lock(m_CSLayers); int ChunkX, ChunkZ; - cChunkDef::BlockToChunk(a_SrcX / 8, a_SrcZ / 8, ChunkX, ChunkZ); + cChunkDef::BlockToChunk(std::floor(a_X), std::floor(a_Z), ChunkX, ChunkZ); cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ); if (Chunk == NULL) { return; } // It's perfectly legal to broadcast packets even to invalid chunks! - Chunk->BroadcastSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch, a_Exclude); + Chunk->BroadcastSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch, a_Exclude); } diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 4daa85ebd..a9ee006fd 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -85,7 +85,7 @@ public: void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL); void BroadcastParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL); void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL); - void BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8 + void BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); void BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 56275a9b2..340db6394 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1361,7 +1361,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e NewBlock->OnPlacedByPlayer(ChunkInterface,*World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta); // Step sound with 0.8f pitch is used as block placement sound - World->BroadcastSoundEffect(NewBlock->GetStepSound(), a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.8f); + World->BroadcastSoundEffect(NewBlock->GetStepSound(), (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.8f); cRoot::Get()->GetPluginManager()->CallHookPlayerPlacedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta); } @@ -2426,9 +2426,9 @@ void cClientHandle::SendDisplayObjective(const AString & a_Objective, cScoreboar -void cClientHandle::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) +void cClientHandle::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) { - m_Protocol->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch); + m_Protocol->SendSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch); } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index b0bbda19e..922740b11 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -162,7 +162,7 @@ public: void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode); void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode); void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display); - void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch); // a_Src coords are Block * 8 + void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch); // tolua_export void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data); void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock); void SendSpawnMob (const cMonster & a_Mob); diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index d59088e72..d5e41bd46 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -89,7 +89,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa m_HitBlockPos = Vector3i(X, Y, Z); // Broadcast arrow hit sound - m_World->BroadcastSoundEffect("random.bowhit", X * 8, Y * 8, Z * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + m_World->BroadcastSoundEffect("random.bowhit", (double)X, (double)Y, (double)Z, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); } @@ -106,7 +106,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1); // Broadcast successful hit sound - GetWorld()->BroadcastSoundEffect("random.successful_hit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + GetWorld()->BroadcastSoundEffect("random.successful_hit", GetPosX(), GetPosY(), GetPosZ(), 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); Destroy(); } @@ -131,7 +131,7 @@ void cArrowEntity::CollectedBy(cPlayer * a_Dest) } GetWorld()->BroadcastCollectEntity(*this, *a_Dest); - GetWorld()->BroadcastSoundEffect("random.pop", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + GetWorld()->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); m_bIsCollected = true; } } diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp index 10f79aedc..e437c24ef 100644 --- a/src/Entities/ExpOrb.cpp +++ b/src/Entities/ExpOrb.cpp @@ -56,7 +56,7 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk) LOGD("Player %s picked up an ExpOrb. His reward is %i", a_ClosestPlayer->GetName().c_str(), m_Reward); a_ClosestPlayer->DeltaExperience(m_Reward); - m_World->BroadcastSoundEffect("random.orb", (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + m_World->BroadcastSoundEffect("random.orb", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); Destroy(); } diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp index b910c3769..d49893020 100644 --- a/src/Entities/Floater.cpp +++ b/src/Entities/Floater.cpp @@ -134,7 +134,7 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk) { if (m_CountDownTime <= 0) { - m_World->BroadcastSoundEffect("random.splash", (int) floor(GetPosX() * 8), (int) floor(GetPosY() * 8), (int) floor(GetPosZ() * 8), 1, 1); + m_World->BroadcastSoundEffect("random.splash", GetPosX(), GetPosY(), GetPosZ(), 1, 1); SetPosY(GetPosY() - 1); m_CanPickupItem = true; m_PickupCountDown = 20; diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index 24fa591da..bae1485d4 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -226,7 +226,7 @@ bool cPickup::CollectedBy(cPlayer * a_Dest) m_Item.m_ItemCount -= NumAdded; m_World->BroadcastCollectEntity(*this, *a_Dest); // Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;) - m_World->BroadcastSoundEffect("random.pop",(int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + m_World->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); if (m_Item.m_ItemCount <= 0) { // All of the pickup has been collected, schedule the pickup for destroying diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 944ed643e..b1b7fc74e 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1937,7 +1937,7 @@ void cPlayer::UseEquippedItem(void) if (GetInventory().DamageEquippedItem()) { - m_World->BroadcastSoundEffect("random.break", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + m_World->BroadcastSoundEffect("random.break", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); } } diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index 185f17fee..e7a77dcbc 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -70,7 +70,7 @@ public: return; } - a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)a_Player->GetPosX() * 8, (int)a_Player->GetPosY() * 8, (int)a_Player->GetPosZ() * 8, 0.5, (float)Force); + a_Player->GetWorld()->BroadcastSoundEffect("random.bow", a_Player->GetPosX(), a_Player->GetPosY(), a_Player->GetPosZ(), 0.5, (float)Force); if (!a_Player->IsGameModeCreative()) { a_Player->UseEquippedItem(); diff --git a/src/Items/ItemLighter.h b/src/Items/ItemLighter.h index 32f49cab6..9f98bf85f 100644 --- a/src/Items/ItemLighter.h +++ b/src/Items/ItemLighter.h @@ -52,8 +52,8 @@ public: case E_BLOCK_TNT: { // Activate the TNT: - a_World->BroadcastSoundEffect("game.tnt.primed", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 1.0f); - a_World->SetBlock(a_BlockX,a_BlockY,a_BlockZ, E_BLOCK_AIR, 0); + a_World->BroadcastSoundEffect("game.tnt.primed", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 1.0f); + a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); a_World->SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5); // 80 ticks to boom break; } @@ -68,7 +68,7 @@ public: if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR) { a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0); - a_World->BroadcastSoundEffect("fire.ignite", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0F, 1.04F); + a_World->BroadcastSoundEffect("fire.ignite", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0F, 1.04F); break; } } diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h index 25935a1bc..fde7b8e67 100644 --- a/src/Items/ItemThrowable.h +++ b/src/Items/ItemThrowable.h @@ -33,14 +33,7 @@ public: // Play sound cFastRandom Random; - a_World->BroadcastSoundEffect( - "random.bow", - (int)std::floor(a_Player->GetPosX() * 8.0), - (int)std::floor((a_Player->GetPosY() - a_Player->GetHeight()) * 8.0), - (int)std::floor(a_Player->GetPosZ() * 8.0), - 0.5F, - 0.4F / (Random.NextFloat(1.0F) * 0.4F + 0.8F) - ); + a_World->BroadcastSoundEffect("random.bow", a_Player->GetPosX(), a_Player->GetPosY() - a_Player->GetHeight(), a_Player->GetPosZ(), 0.5f, 0.4f / (Random.NextFloat(1.0f) * 0.4f + 0.8f)); if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, a_Player->GetEquippedItem(), &Speed) < 0) { diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp index b9041bd5a..8ab09a4c5 100644 --- a/src/Mobs/Creeper.cpp +++ b/src/Mobs/Creeper.cpp @@ -125,7 +125,7 @@ void cCreeper::Attack(float a_Dt) if (!m_bIsBlowing) { - m_World->BroadcastSoundEffect("game.tnt.primed", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + m_World->BroadcastSoundEffect("game.tnt.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); m_bIsBlowing = true; m_World->BroadcastEntityMetadata(*this); } @@ -143,7 +143,7 @@ void cCreeper::OnRightClicked(cPlayer & a_Player) { a_Player.UseEquippedItem(); } - m_World->BroadcastSoundEffect("game.tnt.primed", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + m_World->BroadcastSoundEffect("game.tnt.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); m_bIsBlowing = true; m_World->BroadcastEntityMetadata(*this); m_BurnedWithFlintAndSteel = true; diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index aaef7580d..6d6364404 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -478,7 +478,7 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI) if (!m_SoundHurt.empty() && (m_Health > 0)) { - m_World->BroadcastSoundEffect(m_SoundHurt, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f); + m_World->BroadcastSoundEffect(m_SoundHurt, GetPosX(), GetPosY(), GetPosZ(), 1.0f, 0.8f); } if (a_TDI.Attacker != NULL) @@ -497,7 +497,7 @@ void cMonster::KilledBy(cEntity * a_Killer) super::KilledBy(a_Killer); if (m_SoundHurt != "") { - m_World->BroadcastSoundEffect(m_SoundDeath, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f); + m_World->BroadcastSoundEffect(m_SoundDeath, GetPosX(), GetPosY(), GetPosZ(), 1.0f, 0.8f); } int Reward; switch (m_MobType) diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index ac872a2f2..dc35a6653 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -106,7 +106,7 @@ public: virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) = 0; virtual void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) = 0; virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) = 0; - virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) = 0; // a_Src coords are Block * 8 + virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) = 0; virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) = 0; virtual void SendSpawnMob (const cMonster & a_Mob) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 6dc2e918d..28fdcf23a 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -899,7 +899,7 @@ void cProtocol125::SendScoreboardObjective(const AString & a_Name, const AString -void cProtocol125::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) +void cProtocol125::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) { // Not needed in this protocol version } diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 9dbefd3a3..86a49f3f6 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -78,7 +78,7 @@ public: virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; virtual void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) override {} // This protocol doesn't support such message virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override {} // This protocol doesn't support such message - virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8 + virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override; virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override; virtual void SendSpawnMob (const cMonster & a_Mob) override; diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index 31cf99f53..b2b84953c 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -195,13 +195,6 @@ void cProtocol132::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a WriteInt (a_Entity.GetUniqueID()); WriteInt (a_Player.GetUniqueID()); Flush(); - - // Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;) - SendSoundEffect( - "random.pop", - (int)(a_Entity.GetPosX() * 8), (int)(a_Entity.GetPosY() * 8), (int)(a_Entity.GetPosZ() * 8), - 0.5, (float)(0.75 + ((float)((a_Entity.GetUniqueID() * 23) % 32)) / 64) - ); } @@ -285,14 +278,18 @@ void cProtocol132::SendPlayerSpawn(const cPlayer & a_Player) -void cProtocol132::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) +void cProtocol132::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) { + int SrcX = std::floor(a_X * 8.0); + int SrcY = std::floor(a_Y * 8.0); + int SrcZ = std::floor(a_Z * 8.0); + cCSLock Lock(m_CSPacket); WriteByte (PACKET_SOUND_EFFECT); WriteString (a_SoundName); - WriteInt (a_SrcX); - WriteInt (a_SrcY); - WriteInt (a_SrcZ); + WriteInt (SrcX); + WriteInt (SrcY); + WriteInt (SrcZ); WriteFloat (a_Volume); WriteChar ((char)(a_Pitch * 63.0f)); Flush(); diff --git a/src/Protocol/Protocol132.h b/src/Protocol/Protocol132.h index e5d3ee80c..1124a7253 100644 --- a/src/Protocol/Protocol132.h +++ b/src/Protocol/Protocol132.h @@ -53,7 +53,7 @@ public: virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override; virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override; virtual void SendPlayerSpawn (const cPlayer & a_Player) override; - virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8 + virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override; virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; virtual void SendSpawnMob (const cMonster & a_Mob) override; virtual void SendTabCompletionResults(const AStringVector & a_Results) override; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 855687269..ae077d69e 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1084,15 +1084,19 @@ void cProtocol172::SendDisplayObjective(const AString & a_Objective, cScoreboard -void cProtocol172::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) // a_Src coords are Block * 8 +void cProtocol172::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) { ASSERT(m_State == 3); // In game mode? - + + int SrcX = std::floor(a_X * 8.0); + int SrcY = std::floor(a_Y * 8.0); + int SrcZ = std::floor(a_Z * 8.0); + cPacketizer Pkt(*this, 0x29); // Sound Effect packet Pkt.WriteString(a_SoundName); - Pkt.WriteInt(a_SrcX); - Pkt.WriteInt(a_SrcY); - Pkt.WriteInt(a_SrcZ); + Pkt.WriteInt(SrcX); + Pkt.WriteInt(SrcY); + Pkt.WriteInt(SrcZ); Pkt.WriteFloat(a_Volume); Pkt.WriteByte((Byte)(a_Pitch * 63)); } diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 1a65cfa1c..e635a62c1 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -105,7 +105,7 @@ public: virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; virtual void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false) override; - virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8 + virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index c0c9e08ee..29f4576cd 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -616,10 +616,10 @@ void cProtocolRecognizer::SendDisplayObjective(const AString & a_Objective, cSco -void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) +void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) { ASSERT(m_Protocol != NULL); - m_Protocol->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch); + m_Protocol->SendSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch); } diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 0a9a42e93..e5ec3ece2 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -113,7 +113,7 @@ public: virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; virtual void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) override; virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override; - virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; + virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override; virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override; virtual void SendSpawnMob (const cMonster & a_Mob) override; diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp index 4ffda2365..d8de19871 100644 --- a/src/Simulator/FloodyFluidSimulator.cpp +++ b/src/Simulator/FloodyFluidSimulator.cpp @@ -254,7 +254,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i ); a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0); - a_NearChunk->BroadcastSoundEffect("random.fizz", BlockX * 8, a_RelY * 8, BlockZ * 8, 0.5f, 1.5f); + a_NearChunk->BroadcastSoundEffect("random.fizz", (double)BlockX, (double)a_RelY, (double)BlockZ, 0.5f, 1.5f); return; } } @@ -269,7 +269,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i ); a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0); - a_NearChunk->BroadcastSoundEffect("random.fizz", BlockX * 8, a_RelY * 8, BlockZ * 8, 0.5f, 1.5f); + a_NearChunk->BroadcastSoundEffect("random.fizz", (double)BlockX, (double)a_RelY, (double)BlockZ, 0.5f, 1.5f); return; } } diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 3c037b6db..8b9d830cd 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -881,7 +881,7 @@ void cIncrementalRedstoneSimulator::HandleTNT(int a_RelBlockX, int a_RelBlockY, if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) { - m_Chunk->BroadcastSoundEffect("game.tnt.primed", BlockX * 8, a_RelBlockY * 8, BlockZ * 8, 0.5f, 0.6f); + m_Chunk->BroadcastSoundEffect("game.tnt.primed", (double)BlockX, (double)a_RelBlockY, (double)BlockZ, 0.5f, 0.6f); m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_AIR, 0); m_World.SpawnPrimedTNT(BlockX + 0.5, a_RelBlockY + 0.5, BlockZ + 0.5); // 80 ticks to boom } @@ -1159,7 +1159,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R { if (Meta == E_META_PRESSURE_PLATE_RAISED) { - m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.5F); + m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.5F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED); SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Power); @@ -1169,7 +1169,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R { if (Meta == E_META_PRESSURE_PLATE_DEPRESSED) { - m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); + m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.6F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk); @@ -1227,7 +1227,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R { if (Meta == E_META_PRESSURE_PLATE_RAISED) { - m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.5F); + m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.5F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED); SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Power); @@ -1237,7 +1237,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R { if (Meta == E_META_PRESSURE_PLATE_DEPRESSED) { - m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); + m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.6F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk); @@ -1294,7 +1294,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R { if (Meta == E_META_PRESSURE_PLATE_RAISED) { - m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.5F); + m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.5F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED); SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); @@ -1304,7 +1304,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R { if (Meta == E_META_PRESSURE_PLATE_DEPRESSED) { - m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F); + m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.6F); } m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED); SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk); diff --git a/src/Simulator/VaporizeFluidSimulator.cpp b/src/Simulator/VaporizeFluidSimulator.cpp index 4206c64d1..191770273 100644 --- a/src/Simulator/VaporizeFluidSimulator.cpp +++ b/src/Simulator/VaporizeFluidSimulator.cpp @@ -35,7 +35,7 @@ void cVaporizeFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, ) { a_Chunk->SetBlock(RelX, a_BlockY, RelZ, E_BLOCK_AIR, 0); - a_Chunk->BroadcastSoundEffect("random.fizz", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.6f); + a_Chunk->BroadcastSoundEffect("random.fizz", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.6f); } } diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 43d923fa5..19db01b7a 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -918,7 +918,7 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) : m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); // Play the opening sound: - m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1); + m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1); // Send out the chest-open packet: m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_Chest->GetBlockType()); @@ -944,7 +944,7 @@ cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_Secon m_ShouldDistributeToHotbarFirst = false; // Play the opening sound: - m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1); + m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1); // Send out the chest-open packet: m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_PrimaryChest->GetBlockType()); @@ -1004,7 +1004,7 @@ cChestWindow::~cChestWindow() // Send out the chest-close packet: m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, m_PrimaryChest->GetBlockType()); - m_World->BroadcastSoundEffect("random.chestclosed", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1); + m_World->BroadcastSoundEffect("random.chestclosed", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1); } @@ -1042,7 +1042,7 @@ cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) : m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); // Play the opening sound: - m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1); + m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1); // Send out the chest-open packet: m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_ENDER_CHEST); @@ -1058,7 +1058,7 @@ cEnderChestWindow::~cEnderChestWindow() m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_ENDER_CHEST); // Play the closing sound - m_World->BroadcastSoundEffect("random.chestclosed", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1); + m_World->BroadcastSoundEffect("random.chestclosed", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1); } diff --git a/src/World.cpp b/src/World.cpp index 64a629233..46a193d4f 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1088,7 +1088,7 @@ void cWorld::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_Blo Vector3d explosion_pos = Vector3d(a_BlockX, a_BlockY, a_BlockZ); cVector3iArray BlocksAffected; m_ChunkMap->DoExplosionAt(a_ExplosionSize, a_BlockX, a_BlockY, a_BlockZ, BlocksAffected); - BroadcastSoundEffect("random.explode", (int)floor(a_BlockX * 8), (int)floor(a_BlockY * 8), (int)floor(a_BlockZ * 8), 1.0f, 0.6f); + BroadcastSoundEffect("random.explode", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.6f); { cCSLock Lock(m_CSPlayers); for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) @@ -2074,9 +2074,9 @@ void cWorld::BroadcastDisplayObjective(const AString & a_Objective, cScoreboard: -void cWorld::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude) +void cWorld::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude) { - m_ChunkMap->BroadcastSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch, a_Exclude); + m_ChunkMap->BroadcastSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch, a_Exclude); } diff --git a/src/World.h b/src/World.h index 27dd81be3..be055f004 100644 --- a/src/World.h +++ b/src/World.h @@ -224,7 +224,7 @@ public: void BroadcastScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode); void BroadcastScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode); void BroadcastDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display); - void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // tolua_export a_Src coords are Block * 8 + void BroadcastSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // tolua_export void BroadcastSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); // tolua_export void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastTeleportEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); -- cgit v1.2.3 From 9b0b57bcbc9239f65ebfacf9df904d2bb77d2355 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 13 Jul 2014 11:11:40 +0200 Subject: Update. --- src/Mobs/Sheep.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index e208aa891..019f9e6a2 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -62,7 +62,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player) int NumDrops = m_World->GetTickRandomNumber(2) + 1; Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); - m_World->BroadcastSoundEffect("mob.sheep.shear", POSX_TOINT * 8, POSY_TOINT * 8, POSZ_TOINT * 8, 1.0f, 1.0f); + m_World->BroadcastSoundEffect("mob.sheep.shear", GetPosX(), GetPosY(), GetPosZ(), 1.0f, 1.0f); } else if ((EquippedItem.m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - EquippedItem.m_ItemDamage)) { -- cgit v1.2.3 From 31415aec63f03aeb92ec17ad3a3acb27aa6b2fc2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 13 Jul 2014 13:31:09 +0200 Subject: Fixed MSVC warnings in SoundEffect functions. --- src/ChunkMap.cpp | 2 +- src/Protocol/Protocol132.cpp | 10 +++------- src/Protocol/Protocol17x.cpp | 10 +++------- 3 files changed, 7 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 0a0a841cd..b24eead2d 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -652,7 +652,7 @@ void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, double a_X, do cCSLock Lock(m_CSLayers); int ChunkX, ChunkZ; - cChunkDef::BlockToChunk(std::floor(a_X), std::floor(a_Z), ChunkX, ChunkZ); + cChunkDef::BlockToChunk((int)std::floor(a_X), (int)std::floor(a_Z), ChunkX, ChunkZ); cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ); if (Chunk == NULL) { diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index b2b84953c..7a8c2221e 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -280,16 +280,12 @@ void cProtocol132::SendPlayerSpawn(const cPlayer & a_Player) void cProtocol132::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) { - int SrcX = std::floor(a_X * 8.0); - int SrcY = std::floor(a_Y * 8.0); - int SrcZ = std::floor(a_Z * 8.0); - cCSLock Lock(m_CSPacket); WriteByte (PACKET_SOUND_EFFECT); WriteString (a_SoundName); - WriteInt (SrcX); - WriteInt (SrcY); - WriteInt (SrcZ); + WriteInt ((int)(a_X * 8.0)); + WriteInt ((int)(a_Y * 8.0)); + WriteInt ((int)(a_Z * 8.0)); WriteFloat (a_Volume); WriteChar ((char)(a_Pitch * 63.0f)); Flush(); diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index ae077d69e..dc6a817a3 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1088,15 +1088,11 @@ void cProtocol172::SendSoundEffect(const AString & a_SoundName, double a_X, doub { ASSERT(m_State == 3); // In game mode? - int SrcX = std::floor(a_X * 8.0); - int SrcY = std::floor(a_Y * 8.0); - int SrcZ = std::floor(a_Z * 8.0); - cPacketizer Pkt(*this, 0x29); // Sound Effect packet Pkt.WriteString(a_SoundName); - Pkt.WriteInt(SrcX); - Pkt.WriteInt(SrcY); - Pkt.WriteInt(SrcZ); + Pkt.WriteInt((int)(a_X * 8.0)); + Pkt.WriteInt((int)(a_Y * 8.0)); + Pkt.WriteInt((int)(a_Z * 8.0)); Pkt.WriteFloat(a_Volume); Pkt.WriteByte((Byte)(a_Pitch * 63)); } -- cgit v1.2.3 From bfc485bfe2093dde665bc17588ea53218f964312 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 15:05:54 +0100 Subject: Fix CopyPaste error that ment a_MaxRelX wasdn't checked Fixes CID 70464 --- src/Generating/ChunkDesc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp index 7711723fc..570332615 100644 --- a/src/Generating/ChunkDesc.cpp +++ b/src/Generating/ChunkDesc.cpp @@ -290,7 +290,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX LOGWARNING("%s: MaxRelX less than zero, adjusting to zero", __FUNCTION__); a_MaxRelX = 0; } - else if (a_MinRelX >= cChunkDef::Width) + else if (a_MaxRelX >= cChunkDef::Width) { LOGWARNING("%s: MaxRelX more than chunk width, adjusting to chunk width", __FUNCTION__); a_MaxRelX = cChunkDef::Width - 1; -- cgit v1.2.3 From 4a6d606f7499582e6ec2953e663e98153a19a613 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 14:09:08 +0100 Subject: Made CreateProjectile a pointer --- src/Entities/ProjectileEntity.cpp | 7 ++++--- src/Entities/ProjectileEntity.h | 2 +- src/World.cpp | 2 +- src/World.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 0bb34019e..b5ef5c90a 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -243,7 +243,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Ve -cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item, const Vector3d * a_Speed) +cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed) { Vector3d Speed; if (a_Speed != NULL) @@ -262,12 +262,13 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator, case pkExpBottle: return new cExpBottleEntity (a_Creator, a_X, a_Y, a_Z, Speed); case pkFirework: { - if (a_Item.m_FireworkItem.m_Colours.empty()) + ASSERT(a_Item != NULL); + if (a_Item->m_FireworkItem.m_Colours.empty()) { return NULL; } - return new cFireworkEntity(a_Creator, a_X, a_Y, a_Z, a_Item); + return new cFireworkEntity(a_Creator, a_X, a_Y, a_Z, *a_Item); } } diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index 7b38169e2..14cee1272 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -46,7 +46,7 @@ public: cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height); cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height); - static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item, const Vector3d * a_Speed = NULL); + static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed = NULL); /// Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace); diff --git a/src/World.cpp b/src/World.cpp index 46a193d4f..ba8add8f0 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2998,7 +2998,7 @@ int cWorld::SpawnMobFinalize(cMonster * a_Monster) -int cWorld::CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem & a_Item, const Vector3d * a_Speed) +int cWorld::CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed) { cProjectileEntity * Projectile = cProjectileEntity::Create(a_Kind, a_Creator, a_PosX, a_PosY, a_PosZ, a_Item, a_Speed); if (Projectile == NULL) diff --git a/src/World.h b/src/World.h index be055f004..5bb0e640f 100644 --- a/src/World.h +++ b/src/World.h @@ -751,7 +751,7 @@ public: /** Creates a projectile of the specified type. Returns the projectile's EntityID if successful, <0 otherwise Item parameter used currently for Fireworks to correctly set entity metadata based on item metadata */ - int CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem & a_Item, const Vector3d * a_Speed = NULL); // tolua_export + int CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed = NULL); // tolua_export /** Returns a random number from the m_TickRand in range [0 .. a_Range]. To be used only in the tick thread! */ int GetTickRandomNumber(unsigned a_Range) { return (int)(m_TickRand.randInt(a_Range)); } -- cgit v1.2.3 From 2a0c041ad8eaa42e4293762df18d14c77e11ea49 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 13 Jul 2014 15:25:52 +0100 Subject: Adjusted calls to CreateProjectile that passed Items --- src/Items/ItemThrowable.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h index fde7b8e67..c151c5d3a 100644 --- a/src/Items/ItemThrowable.h +++ b/src/Items/ItemThrowable.h @@ -35,7 +35,7 @@ public: cFastRandom Random; a_World->BroadcastSoundEffect("random.bow", a_Player->GetPosX(), a_Player->GetPosY() - a_Player->GetHeight(), a_Player->GetPosZ(), 0.5f, 0.4f / (Random.NextFloat(1.0f) * 0.4f + 0.8f)); - if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, a_Player->GetEquippedItem(), &Speed) < 0) + if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, &a_Player->GetEquippedItem(), &Speed) < 0) { return false; } @@ -135,7 +135,7 @@ public: return false; } - if (a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, a_Player->GetEquippedItem()) < 0) + if (a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, &a_Player->GetEquippedItem()) < 0) { return false; } -- cgit v1.2.3 From 64697f0cabeeadf1d50717892f0815d8309f8b8a Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 15:29:43 +0100 Subject: Another COpyPaste Error Fixes CID 70461 --- src/Generating/ChunkDesc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp index 570332615..c63ca6689 100644 --- a/src/Generating/ChunkDesc.cpp +++ b/src/Generating/ChunkDesc.cpp @@ -332,7 +332,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX LOGWARNING("%s: MaxRelZ less than zero, adjusting to zero", __FUNCTION__); a_MaxRelZ = 0; } - else if (a_MinRelZ >= cChunkDef::Width) + else if (a_MaxRelZ >= cChunkDef::Width) { LOGWARNING("%s: MaxRelZ more than chunk width, adjusting to chunk width", __FUNCTION__); a_MaxRelZ = cChunkDef::Width - 1; -- cgit v1.2.3 From 132b367316b2723ef573476a9fb78bcba6f09294 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 15:32:44 +0100 Subject: CopyPaste Error Fixes CID 70460. --- src/Generating/ChunkDesc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp index c63ca6689..e4b305022 100644 --- a/src/Generating/ChunkDesc.cpp +++ b/src/Generating/ChunkDesc.cpp @@ -311,7 +311,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX LOGWARNING("%s: MaxRelY less than zero, adjusting to zero", __FUNCTION__); a_MaxRelY = 0; } - else if (a_MinRelY >= cChunkDef::Height) + else if (a_MaxRelY >= cChunkDef::Height) { LOGWARNING("%s: MaxRelY more than chunk height, adjusting to chunk height", __FUNCTION__); a_MaxRelY = cChunkDef::Height - 1; -- cgit v1.2.3 From e1a561286a47ab52f4402ae9d08f143d26c60402 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 15:01:49 +0100 Subject: Fixed Issue with Comparing agast the wrong chest, potentially causing crashes. --- src/BlockEntities/HopperEntity.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index aaf82d150..7af4b9d5d 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -368,13 +368,13 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick) /// Moves items from a chest (dblchest) above the hopper into this hopper. Returns true if contents have changed. bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk) { - cChestEntity * Chest = (cChestEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ); - if (Chest == NULL) + cChestEntity * MainChest = (cChestEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ); + if (MainChest == NULL) { LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ); return false; } - if (MoveItemsFromGrid(*Chest)) + if (MoveItemsFromGrid(*MainChest)) { // Moved the item from the chest directly above the hopper return true; @@ -403,20 +403,20 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk) } BLOCKTYPE Block = Neighbor->GetBlock(x, m_PosY + 1, z); - if (Block != Chest->GetBlockType()) + if (Block != MainChest->GetBlockType()) { // Not the same kind of chest continue; } - Chest = (cChestEntity *)Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z); - if (Chest == NULL) + cChestEntity * SideChest = (cChestEntity *)Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z); + if (SideChest == NULL) { LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z); } else { - if (MoveItemsFromGrid(*Chest)) + if (MoveItemsFromGrid(*SideChest)) { return true; } -- cgit v1.2.3 From 4315deb90b62a40a07bf4f3427b52a613738c102 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 16:07:35 +0100 Subject: Added parenthasies --- src/ChunkMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index f0222c0f5..164b7d37a 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1530,7 +1530,7 @@ void cChunkMap::SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player) cCSLock Lock(m_CSLayers); cChunkPtr Chunk = GetChunk(ChunkX, ZERO_CHUNK_Y, ChunkZ); - if (Chunk != NULL && Chunk->IsValid()) + if ((Chunk != NULL) && (Chunk->IsValid())) { Chunk->SendBlockTo(a_X, a_Y, a_Z, a_Player->GetClientHandle()); } -- cgit v1.2.3 From f77723128c6582e9c184706c7140c8bcf9c390c4 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 13 Jul 2014 15:23:23 -0700 Subject: Changed separating comment style from asterisks to slashes. --- src/Entities/EntityEffect.cpp | 48 +++++++-------- src/Entities/EntityEffect.h | 138 +++++++++++++++++++++--------------------- 2 files changed, 93 insertions(+), 93 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp index e68ded8b0..be501297c 100644 --- a/src/Entities/EntityEffect.cpp +++ b/src/Entities/EntityEffect.cpp @@ -106,9 +106,9 @@ void cEntityEffect::OnDeactivate(cPawn & a_Target) -/************************************************************************ - **** Instant Health - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Instant Health +///////////////////////////////////////////////////////////////////////// void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target) { // Base amount = 6, doubles for every increase in intensity @@ -129,9 +129,9 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target) -/************************************************************************ - **** Instant Damage - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Instant Damage +///////////////////////////////////////////////////////////////////////// void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target) { // Base amount = 6, doubles for every increase in intensity @@ -152,9 +152,9 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target) -/************************************************************************ - **** Regeneration - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Regeneration +///////////////////////////////////////////////////////////////////////// void cEntityEffectRegeneration::OnTick(cPawn & a_Target) { super::OnTick(a_Target); @@ -182,9 +182,9 @@ void cEntityEffectRegeneration::OnTick(cPawn & a_Target) -/************************************************************************ - **** Hunger - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Hunger +///////////////////////////////////////////////////////////////////////// void cEntityEffectHunger::OnTick(cPawn & a_Target) { super::OnTick(a_Target); @@ -200,9 +200,9 @@ void cEntityEffectHunger::OnTick(cPawn & a_Target) -/************************************************************************ - **** Weakness - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Weakness +///////////////////////////////////////////////////////////////////////// void cEntityEffectWeakness::OnTick(cPawn & a_Target) { super::OnTick(a_Target); @@ -218,9 +218,9 @@ void cEntityEffectWeakness::OnTick(cPawn & a_Target) -/************************************************************************ - **** Poison - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Poison +///////////////////////////////////////////////////////////////////////// void cEntityEffectPoison::OnTick(cPawn & a_Target) { super::OnTick(a_Target); @@ -255,9 +255,9 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target) -/************************************************************************ - **** Wither - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Wither +///////////////////////////////////////////////////////////////////////// void cEntityEffectWither::OnTick(cPawn & a_Target) { super::OnTick(a_Target); @@ -276,9 +276,9 @@ void cEntityEffectWither::OnTick(cPawn & a_Target) -/************************************************************************ - **** Saturation - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Saturation +///////////////////////////////////////////////////////////////////////// void cEntityEffectSaturation::OnTick(cPawn & a_Target) { if (a_Target.IsPlayer()) diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index c593fba81..6e53d83b8 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -87,9 +87,9 @@ protected: double m_DistanceModifier; }; -/************************************************************************ - **** Speed - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Speed +///////////////////////////////////////////////////////////////////////// class cEntityEffectSpeed: public cEntityEffect { @@ -101,9 +101,9 @@ public: } }; -/************************************************************************ - **** Slowness - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Slowness +///////////////////////////////////////////////////////////////////////// class cEntityEffectSlowness: public cEntityEffect { @@ -115,9 +115,9 @@ public: } }; -/************************************************************************ - **** Haste - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Haste +///////////////////////////////////////////////////////////////////////// class cEntityEffectHaste: public cEntityEffect { @@ -129,9 +129,9 @@ public: } }; -/************************************************************************ - **** Mining Fatigue - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Mining Fatigue +///////////////////////////////////////////////////////////////////////// class cEntityEffectMiningFatigue: public cEntityEffect { @@ -143,9 +143,9 @@ public: } }; -/************************************************************************ - **** Strength - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Strength +///////////////////////////////////////////////////////////////////////// class cEntityEffectStrength: public cEntityEffect { @@ -157,9 +157,9 @@ public: } }; -/************************************************************************ - **** Instant Health - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Instant Health +///////////////////////////////////////////////////////////////////////// class cEntityEffectInstantHealth: public cEntityEffect { @@ -173,9 +173,9 @@ public: virtual void OnActivate(cPawn & a_Target) override; }; -/************************************************************************ - **** Instant Damage - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Instant Damage +///////////////////////////////////////////////////////////////////////// class cEntityEffectInstantDamage: public cEntityEffect { @@ -189,9 +189,9 @@ public: virtual void OnActivate(cPawn & a_Target) override; }; -/************************************************************************ - **** Jump Boost - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Jump Boost +///////////////////////////////////////////////////////////////////////// class cEntityEffectJumpBoost: public cEntityEffect { @@ -203,9 +203,9 @@ public: } }; -/************************************************************************ - **** Nausea - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Nausea +///////////////////////////////////////////////////////////////////////// class cEntityEffectNausea: public cEntityEffect { @@ -217,9 +217,9 @@ public: } }; -/************************************************************************ - **** Regeneration - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Regeneration +///////////////////////////////////////////////////////////////////////// class cEntityEffectRegeneration: public cEntityEffect { @@ -233,9 +233,9 @@ public: virtual void OnTick(cPawn & a_Target) override; }; -/************************************************************************ - **** Resistance - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Resistance +///////////////////////////////////////////////////////////////////////// class cEntityEffectResistance: public cEntityEffect { @@ -247,9 +247,9 @@ public: } }; -/************************************************************************ - **** Fire Resistance - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Fire Resistance +///////////////////////////////////////////////////////////////////////// class cEntityEffectFireResistance: public cEntityEffect { @@ -261,9 +261,9 @@ public: } }; -/************************************************************************ - **** Water Breathing - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Water Breathing +///////////////////////////////////////////////////////////////////////// class cEntityEffectWaterBreathing: public cEntityEffect { @@ -275,9 +275,9 @@ public: } }; -/************************************************************************ - **** Invisibility - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Invisibility +///////////////////////////////////////////////////////////////////////// class cEntityEffectInvisibility: public cEntityEffect { @@ -289,9 +289,9 @@ public: } }; -/************************************************************************ - **** Blindness - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Blindness +///////////////////////////////////////////////////////////////////////// class cEntityEffectBlindness: public cEntityEffect { @@ -303,9 +303,9 @@ public: } }; -/************************************************************************ - **** Night Vision - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Night Vision +///////////////////////////////////////////////////////////////////////// class cEntityEffectNightVision: public cEntityEffect { @@ -317,9 +317,9 @@ public: } }; -/************************************************************************ - **** Hunger - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Hunger +///////////////////////////////////////////////////////////////////////// class cEntityEffectHunger: public cEntityEffect { @@ -333,9 +333,9 @@ public: virtual void OnTick(cPawn & a_Target) override; }; -/************************************************************************ - **** Weakness - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Weakness +///////////////////////////////////////////////////////////////////////// class cEntityEffectWeakness: public cEntityEffect { @@ -349,9 +349,9 @@ public: virtual void OnTick(cPawn & a_Target) override; }; -/************************************************************************ - **** Poison - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Poison +///////////////////////////////////////////////////////////////////////// class cEntityEffectPoison: public cEntityEffect { @@ -365,9 +365,9 @@ public: virtual void OnTick(cPawn & a_Target) override; }; -/************************************************************************ - **** Wither - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Wither +///////////////////////////////////////////////////////////////////////// class cEntityEffectWither: public cEntityEffect { @@ -381,9 +381,9 @@ public: virtual void OnTick(cPawn & a_Target) override; }; -/************************************************************************ - **** Health Boost - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Health Boost +///////////////////////////////////////////////////////////////////////// class cEntityEffectHealthBoost: public cEntityEffect { @@ -395,9 +395,9 @@ public: } }; -/************************************************************************ - **** Absorption - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Absorption +///////////////////////////////////////////////////////////////////////// class cEntityEffectAbsorption: public cEntityEffect { @@ -409,9 +409,9 @@ public: } }; -/************************************************************************ - **** Saturation - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Saturation +///////////////////////////////////////////////////////////////////////// class cEntityEffectSaturation: public cEntityEffect { -- cgit v1.2.3 From 0409daf7360d503e9e2b6258fa2582d7bdd7e5a0 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 13 Jul 2014 15:43:49 -0700 Subject: EntityEffect: Inlined functions, added explicit copy constructor and operator. --- src/Entities/EntityEffect.cpp | 35 ++++++++++++++++++----------------- src/Entities/EntityEffect.h | 14 +++++++++++--- 2 files changed, 29 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp index be501297c..852099b79 100644 --- a/src/Entities/EntityEffect.cpp +++ b/src/Entities/EntityEffect.cpp @@ -33,7 +33,11 @@ cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, double a_Distanc -cEntityEffect::~cEntityEffect() +cEntityEffect::cEntityEffect(const cEntityEffect & a_OtherEffect): + m_Ticks(a_OtherEffect.m_Ticks), + m_Duration(a_OtherEffect.m_Duration), + m_Intensity(a_OtherEffect.m_Intensity), + m_DistanceModifier(a_OtherEffect.m_DistanceModifier) { } @@ -42,6 +46,19 @@ cEntityEffect::~cEntityEffect() +cEntityEffect & cEntityEffect::operator=(cEntityEffect a_OtherEffect) +{ + std::swap(m_Ticks, a_OtherEffect.m_Ticks); + std::swap(m_Duration, a_OtherEffect.m_Duration); + std::swap(m_Intensity, a_OtherEffect.m_Intensity); + std::swap(m_DistanceModifier, a_OtherEffect.m_DistanceModifier); + return *this; +} + + + + + cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier) { switch (a_EffectType) @@ -90,22 +107,6 @@ void cEntityEffect::OnTick(cPawn & a_Target) -void cEntityEffect::OnActivate(cPawn & a_Target) -{ -} - - - - - -void cEntityEffect::OnDeactivate(cPawn & a_Target) -{ -} - - - - - ///////////////////////////////////////////////////////////////////////// // Instant Health ///////////////////////////////////////////////////////////////////////// diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index 6e53d83b8..c6532a9bd 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -45,7 +45,15 @@ public: @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ cEntityEffect(int a_Duration, short a_Intensity, double a_DistanceModifier = 1); - virtual ~cEntityEffect(void); + /** Creates an entity effect by copying another + @param a_OtherEffect The other effect to copy */ + cEntityEffect(const cEntityEffect & a_OtherEffect); + + /** Creates an entity effect by copying another + @param a_OtherEffect The other effect to copy */ + cEntityEffect & operator=(cEntityEffect a_OtherEffect); + + virtual ~cEntityEffect(void) {}; /** Creates a pointer to the proper entity effect from the effect type @warning This function creates raw pointers that must be manually managed. @@ -70,8 +78,8 @@ public: void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; } virtual void OnTick(cPawn & a_Target); - virtual void OnActivate(cPawn & a_Target); - virtual void OnDeactivate(cPawn & a_Target); + virtual void OnActivate(cPawn & a_Target) { } + virtual void OnDeactivate(cPawn & a_Target) { } protected: /** How many ticks this effect has been active for */ -- cgit v1.2.3 From 1c6c612f76d25909dd190e08dc9f32d3ab2c507a Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 14 Jul 2014 19:07:31 +0200 Subject: Reset meta to zero when the block explode. --- src/ChunkMap.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 0a0a841cd..d25f6d64b 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1837,7 +1837,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_ // Activate the TNT, with a random fuse between 10 to 30 game ticks int FuseTime = 10 + m_World->GetTickRandomNumber(20); m_World->SpawnPrimedTNT(a_BlockX + x + 0.5, a_BlockY + y + 0.5, a_BlockZ + z + 0.5, FuseTime); - area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_AIR); + area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_AIR, 0); a_BlocksAffected.push_back(Vector3i(bx + x, by + y, bz + z)); break; } @@ -1854,14 +1854,14 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_ case E_BLOCK_STATIONARY_WATER: { // Turn into simulated water: - area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_WATER); + area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_WATER, 0); break; } case E_BLOCK_STATIONARY_LAVA: { // Turn into simulated lava: - area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_LAVA); + area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_LAVA, 0); break; } @@ -1894,7 +1894,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_ m_World->SpawnFallingBlock(bx + x, by + y + 5, bz + z, Block, area.GetBlockMeta(bx + x, by + y, bz + z)); } - area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_AIR); + area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_AIR, 0); a_BlocksAffected.push_back(Vector3i(bx + x, by + y, bz + z)); break; -- cgit v1.2.3 From 4e24f711abd3d6a93f01ee7c297eb67c8aedbd37 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 14 Jul 2014 19:49:31 +0100 Subject: Player properties are now retrieved --- src/ClientHandle.cpp | 7 +- src/ClientHandle.h | 5 +- src/Entities/Player.cpp | 4 +- src/Protocol/Authenticator.cpp | 281 ++++++++++++++++++++++++++--------------- src/Protocol/Authenticator.h | 5 + src/Protocol/Protocol17x.cpp | 14 +- src/Root.cpp | 4 +- src/Root.h | 2 +- src/Server.cpp | 4 +- src/Server.h | 4 +- src/World.cpp | 2 +- 11 files changed, 216 insertions(+), 116 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 56275a9b2..fcd8d2bcd 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -290,17 +290,18 @@ void cClientHandle::Kick(const AString & a_Reason) -void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID) +void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, const AString & a_Properties) { if (m_State != csAuthenticating) { return; } - ASSERT( m_Player == NULL ); + ASSERT(m_Player == NULL); m_Username = a_Name; m_UUID = a_UUID; + m_Properties = a_Properties; // Send login success (if the protocol supports it): m_Protocol->SendLoginSuccess(); @@ -324,7 +325,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID) if (!cRoot::Get()->GetPluginManager()->CallHookPlayerJoined(*m_Player)) { cRoot::Get()->BroadcastChatJoin(Printf("%s has joined the game", GetUsername().c_str())); - LOGINFO("Player %s has joined the game.", m_Username.c_str()); + LOGINFO("Player %s has joined the game", m_Username.c_str()); } m_ConfirmPosition = m_Player->GetPosition(); diff --git a/src/ClientHandle.h b/src/ClientHandle.h index b0bbda19e..478da5b3c 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -67,6 +67,8 @@ public: const AString & GetUUID(void) const { return m_UUID; } // tolua_export void SetUUID(const AString & a_UUID) { m_UUID = a_UUID; } + + const AString & GetProperties(void) const { return m_Properties; } /** Generates an UUID based on the username stored for this client, and stores it in the m_UUID member. This is used for the offline (non-auth) mode, when there's no UUID source. @@ -92,7 +94,7 @@ public: static AString FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2); void Kick(const AString & a_Reason); // tolua_export - void Authenticate(const AString & a_Name, const AString & a_UUID); // Called by cAuthenticator when the user passes authentication + void Authenticate(const AString & a_Name, const AString & a_UUID, const AString & a_Properties); // Called by cAuthenticator when the user passes authentication void StreamChunks(void); @@ -280,6 +282,7 @@ private: AString m_Username; AString m_Password; + AString m_Properties; cCriticalSection m_CSChunkLists; cChunkCoordsList m_LoadedChunks; // Chunks that the player belongs to diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 944ed643e..6b792d766 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -130,7 +130,7 @@ cPlayer::~cPlayer(void) if (!cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this)) { cRoot::Get()->BroadcastChatLeave(Printf("%s has left the game", GetName().c_str())); - LOGINFO("Player %s has left the game.", GetName().c_str()); + LOGINFO("Player %s has left the game", GetName().c_str()); } LOGD("Deleting cPlayer \"%s\" at %p, ID %d", GetName().c_str(), this, GetUniqueID()); @@ -1804,7 +1804,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName) cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats); StatSerializer.Load(); - LOGD("Player \"%s\" was read from file \"%s\", spawning at {%.2f, %.2f, %.2f} in world \"%s\"", + LOGD("Player %s was read from file \"%s\", spawning at {%.2f, %.2f, %.2f} in world \"%s\"", GetName().c_str(), a_FileName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str() ); diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index 54b823e0f..8fd8952e8 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -11,15 +11,67 @@ #include "PolarSSL++/BlockingSslClientSocket.h" -#include -#include - #define DEFAULT_AUTH_SERVER "sessionserver.mojang.com" #define DEFAULT_AUTH_ADDRESS "/session/minecraft/hasJoined?username=%USERNAME%&serverId=%SERVERID%" +#define DEFAULT_PROPERTIES_ADDRESS "/session/minecraft/profile/%UUID%" + +/** This is the data of the root certs for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert: +Downloaded from http://certs.starfieldtech.com/repository/ */ +static const AString gStarfieldCACert( + // G2 cert + "-----BEGIN CERTIFICATE-----\n" + "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n" + "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n" + "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n" + "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n" + "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n" + "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" + "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n" + "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n" + "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n" + "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n" + "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n" + "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n" + "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" + "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" + "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" + "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" + "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" + "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" + "-----END CERTIFICATE-----\n\n" + // Original (G1) cert: + "-----BEGIN CERTIFICATE-----\n" + "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" + "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" + "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" + "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" + "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" + "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" + "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" + "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" + "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" + "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" + "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" + "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" + "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" + "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" + "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" + "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" + "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" + "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" + "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" + "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" + "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" + "-----END CERTIFICATE-----\n" +); @@ -29,6 +81,7 @@ cAuthenticator::cAuthenticator(void) : super("cAuthenticator"), m_Server(DEFAULT_AUTH_SERVER), m_Address(DEFAULT_AUTH_ADDRESS), + m_PropertiesAddress(DEFAULT_PROPERTIES_ADDRESS), m_ShouldAuthenticate(true) { } @@ -50,6 +103,7 @@ void cAuthenticator::ReadINI(cIniFile & IniFile) { m_Server = IniFile.GetValueSet("Authentication", "Server", DEFAULT_AUTH_SERVER); m_Address = IniFile.GetValueSet("Authentication", "Address", DEFAULT_AUTH_ADDRESS); + m_PropertiesAddress = IniFile.GetValueSet("Authentication", "PlayerPropertiesAddress", DEFAULT_PROPERTIES_ADDRESS); m_ShouldAuthenticate = IniFile.GetValueSetB("Authentication", "Authenticate", true); } @@ -123,8 +177,26 @@ void cAuthenticator::Execute(void) AString UUID; if (AuthWithYggdrasil(NewUserName, ServerID, UUID)) { - LOGINFO("User %s authenticated with UUID '%s'", NewUserName.c_str(), UUID.c_str()); - cRoot::Get()->AuthenticateUser(ClientID, NewUserName, UUID); + AString Properties; + if (!GetPlayerProperties(UUID, Properties)) + { + LOGINFO("User %s authenticated with UUID %s but property getting failed", NewUserName.c_str(), UUID.c_str()); + } + else + { + LOGINFO("User %s authenticated with UUID %s", NewUserName.c_str(), UUID.c_str()); + } + + // If the UUID doesn't contain the hashes, insert them at the proper places: + if (UUID.size() == 32) + { + UUID.insert(8, "-"); + UUID.insert(13, "-"); + UUID.insert(18, "-"); + UUID.insert(23, "-"); + } + + cRoot::Get()->AuthenticateUser(ClientID, NewUserName, UUID, Properties); } else { @@ -137,97 +209,27 @@ void cAuthenticator::Execute(void) -bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID) +bool cAuthenticator::ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response) { - LOGD("Trying to auth user %s", a_UserName.c_str()); - - int ret; - unsigned char buf[1024]; - - /* Initialize certificates */ - // This is the data of the root certs for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert: - // Downloaded from http://certs.starfieldtech.com/repository/ - static const AString StarfieldCACert( - // G2 cert - "-----BEGIN CERTIFICATE-----\n" - "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" - "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" - "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n" - "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n" - "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n" - "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n" - "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n" - "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" - "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n" - "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n" - "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n" - "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n" - "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n" - "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" - "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n" - "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" - "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" - "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" - "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" - "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" - "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" - "-----END CERTIFICATE-----\n\n" - // Original (G1) cert: - "-----BEGIN CERTIFICATE-----\n" - "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" - "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" - "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" - "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" - "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" - "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" - "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" - "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" - "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" - "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" - "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" - "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" - "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" - "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" - "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" - "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" - "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" - "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" - "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" - "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" - "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" - "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" - "-----END CERTIFICATE-----\n" - ); - // Connect the socket: cBlockingSslClientSocket Socket; - Socket.SetTrustedRootCertsFromString(StarfieldCACert, m_Server); - if (!Socket.Connect(m_Server, 443)) + Socket.SetTrustedRootCertsFromString(a_CACerts, a_ExpectedPeerName); + if (!Socket.Connect(a_ExpectedPeerName, 443)) { - LOGWARNING("cAuthenticator: Can't connect to %s: %s", m_Server.c_str(), Socket.GetLastErrorText().c_str()); + LOGWARNING("cAuthenticator: Can't connect to %s: %s", a_ExpectedPeerName.c_str(), Socket.GetLastErrorText().c_str()); return false; } - // Create the GET request: - AString ActualAddress = m_Address; - ReplaceString(ActualAddress, "%USERNAME%", a_UserName); - ReplaceString(ActualAddress, "%SERVERID%", a_ServerId); - - AString Request; - Request += "GET " + ActualAddress + " HTTP/1.0\r\n"; - Request += "Host: " + m_Server + "\r\n"; - Request += "User-Agent: MCServer\r\n"; - Request += "Connection: close\r\n"; - Request += "\r\n"; - - if (!Socket.Send(Request.c_str(), Request.size())) + if (!Socket.Send(a_Data.c_str(), a_Data.size())) { LOGWARNING("cAuthenticator: Writing SSL data failed: %s", Socket.GetLastErrorText().c_str()); return false; } // Read the HTTP response: - std::string Response; + int ret; + unsigned char buf[1024]; + for (;;) { ret = Socket.Receive(buf, sizeof(buf)); @@ -235,7 +237,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S if ((ret == POLARSSL_ERR_NET_WANT_READ) || (ret == POLARSSL_ERR_NET_WANT_WRITE)) { // This value should never be returned, it is handled internally by cBlockingSslClientSocket - LOGWARNING("cAuthenticator: SSL reading failed internally."); + LOGWARNING("cAuthenticator: SSL reading failed internally"); return false; } if (ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY) @@ -252,18 +254,46 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S break; } - Response.append((const char *)buf, (size_t)ret); + a_Response.append((const char *)buf, (size_t)ret); } Socket.Disconnect(); + return true; +} + + + + + +bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID) +{ + LOGD("Trying to authenticate user %s", a_UserName.c_str()); + + // Create the GET request: + AString ActualAddress = m_Address; + ReplaceString(ActualAddress, "%USERNAME%", a_UserName); + ReplaceString(ActualAddress, "%SERVERID%", a_ServerId); + + AString Request; + Request += "GET " + ActualAddress + " HTTP/1.0\r\n"; + Request += "Host: " + m_Server + "\r\n"; + Request += "User-Agent: MCServer\r\n"; + Request += "Connection: close\r\n"; + Request += "\r\n"; + + AString Response; + if (!ConnectSecurelyToAddress(gStarfieldCACert, m_Server, Request, Response)) + { + return false; + } // Check the HTTP status line: - AString prefix("HTTP/1.1 200 OK"); + const AString Prefix("HTTP/1.1 200 OK"); AString HexDump; - if (Response.compare(0, prefix.size(), prefix)) + if (Response.compare(0, Prefix.size(), Prefix)) { - LOGINFO("User %s failed to auth, bad http status line received", a_UserName.c_str()); - LOG("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str()); + LOGINFO("User %s failed to auth, bad HTTP status line received", a_UserName.c_str()); + LOGD("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str()); return false; } @@ -271,8 +301,8 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S size_t idxHeadersEnd = Response.find("\r\n\r\n"); if (idxHeadersEnd == AString::npos) { - LOGINFO("User %s failed to authenticate, bad http response header received", a_UserName.c_str()); - LOG("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str()); + LOGINFO("User %s failed to authenticate, bad HTTP response header received", a_UserName.c_str()); + LOGD("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str()); return false; } Response.erase(0, idxHeadersEnd + 4); @@ -286,20 +316,12 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S Json::Reader reader; if (!reader.parse(Response, root, false)) { - LOGWARNING("cAuthenticator: Cannot parse Received Data to json!"); + LOGWARNING("cAuthenticator: Cannot parse received data (authentication) to JSON!"); return false; } a_UserName = root.get("name", "Unknown").asString(); a_UUID = root.get("id", "").asString(); - - // If the UUID doesn't contain the hashes, insert them at the proper places: - if (a_UUID.size() == 32) - { - a_UUID.insert(8, "-"); - a_UUID.insert(13, "-"); - a_UUID.insert(18, "-"); - a_UUID.insert(23, "-"); - } + return true; } @@ -307,3 +329,60 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S +bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, AString & a_Properties) +{ + LOGD("Trying to get properties for user %s", a_UUID.c_str()); + + // Create the GET request: + AString ActualAddress = m_PropertiesAddress; + ReplaceString(ActualAddress, "%UUID%", a_UUID); + + AString Request; + Request += "GET " + ActualAddress + " HTTP/1.0\r\n"; + Request += "Host: " + m_Server + "\r\n"; + Request += "User-Agent: MCServer\r\n"; + Request += "Connection: close\r\n"; + Request += "\r\n"; + + AString Response; + if (!ConnectSecurelyToAddress(gStarfieldCACert, m_Server, Request, Response)) + { + return false; + } + + // Check the HTTP status line: + const AString Prefix("HTTP/1.1 200 OK"); + AString HexDump; + if (Response.compare(0, Prefix.size(), Prefix)) + { + LOGINFO("Failed to get properties for user %s, bad HTTP status line received", a_UUID.c_str()); + LOGD("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str()); + return false; + } + + // Erase the HTTP headers from the response: + size_t idxHeadersEnd = Response.find("\r\n\r\n"); + if (idxHeadersEnd == AString::npos) + { + LOGINFO("Failed to get properties for user %s, bad HTTP response header received", a_UUID.c_str()); + LOGD("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str()); + return false; + } + Response.erase(0, idxHeadersEnd + 4); + + // Parse the Json response: + if (Response.empty()) + { + return false; + } + Json::Value root; + Json::Reader reader; + if (!reader.parse(Response, root, false)) + { + LOGWARNING("cAuthenticator: Cannot parse received properties data to JSON!"); + return false; + } + + a_Properties = root["properties"].toStyledString(); + return true; +} \ No newline at end of file diff --git a/src/Protocol/Authenticator.h b/src/Protocol/Authenticator.h index 211f51394..04fa3e09c 100644 --- a/src/Protocol/Authenticator.h +++ b/src/Protocol/Authenticator.h @@ -73,13 +73,18 @@ private: AString m_Server; AString m_Address; + AString m_PropertiesAddress; bool m_ShouldAuthenticate; /** cIsThread override: */ virtual void Execute(void) override; + bool ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response); + /** Returns true if the user authenticated okay, false on error; iLevel is the recursion deptht (bails out if too deep) */ bool AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID); + + bool GetPlayerProperties(const AString & a_UUID, AString & a_Properties); }; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 855687269..ae800e9cf 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -3015,7 +3015,19 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player) Pkt.WriteVarInt(a_Player.GetUniqueID()); Pkt.WriteString(a_Player.GetClientHandle()->GetUUID()); Pkt.WriteString(a_Player.GetName()); - Pkt.WriteVarInt(0); // We have no data to send here + + Json::Value root; + Json::Reader reader; + reader.parse(m_Client->GetProperties(), root); + + Pkt.WriteVarInt(root.size()); + for (Json::Value::iterator itr = root.begin(); itr != root.end(); ++itr) + { + Pkt.WriteString(((Json::Value)*itr).get("name", "").toStyledString()); + Pkt.WriteString(((Json::Value)*itr).get("value", "").toStyledString()); + Pkt.WriteString(((Json::Value)*itr).get("signature", "").toStyledString()); + } + Pkt.WriteFPInt(a_Player.GetPosX()); Pkt.WriteFPInt(a_Player.GetPosY()); Pkt.WriteFPInt(a_Player.GetPosZ()); diff --git a/src/Root.cpp b/src/Root.cpp index c82b05a66..c578fe6a3 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -499,9 +499,9 @@ void cRoot::KickUser(int a_ClientID, const AString & a_Reason) -void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID) +void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties) { - m_Server->AuthenticateUser(a_ClientID, a_Name, a_UUID); + m_Server->AuthenticateUser(a_ClientID, a_Name, a_UUID, a_Properties); } diff --git a/src/Root.h b/src/Root.h index d2a4d1eed..a9e985656 100644 --- a/src/Root.h +++ b/src/Root.h @@ -89,7 +89,7 @@ public: void KickUser(int a_ClientID, const AString & a_Reason); /// Called by cAuthenticator to auth the specified user - void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID); + void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties = ""); /// Executes commands queued in the command queue void TickCommands(void); diff --git a/src/Server.cpp b/src/Server.cpp index 9220731eb..8b479292e 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -656,14 +656,14 @@ void cServer::KickUser(int a_ClientID, const AString & a_Reason) -void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID) +void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties) { cCSLock Lock(m_CSClients); for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr) { if ((*itr)->GetUniqueID() == a_ClientID) { - (*itr)->Authenticate(a_Name, a_UUID); + (*itr)->Authenticate(a_Name, a_UUID, a_Properties); return; } } // for itr - m_Clients[] diff --git a/src/Server.h b/src/Server.h index 5227799e8..672dc26c0 100644 --- a/src/Server.h +++ b/src/Server.h @@ -37,7 +37,7 @@ class cPlayer; class cClientHandle; class cIniFile; -class cCommandOutputCallback ; +class cCommandOutputCallback; typedef std::list cClientHandleList; @@ -83,7 +83,7 @@ public: // tolua_export void Shutdown(void); void KickUser(int a_ClientID, const AString & a_Reason); - void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID); // Called by cAuthenticator to auth the specified user + void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties); // Called by cAuthenticator to auth the specified user const AString & GetServerID(void) const { return m_ServerID; } // tolua_export diff --git a/src/World.cpp b/src/World.cpp index 64a629233..3c0db6da9 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2363,7 +2363,7 @@ void cWorld::RemovePlayer(cPlayer * a_Player) } { cCSLock Lock(m_CSPlayers); - LOGD("Removing player \"%s\" from world \"%s\".", a_Player->GetName().c_str(), m_WorldName.c_str()); + LOGD("Removing player %s from world \"%s\"", a_Player->GetName().c_str(), m_WorldName.c_str()); m_Players.remove(a_Player); } -- cgit v1.2.3 From 1929d16724de6f451c9485076b4091cbc457916c Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 14 Jul 2014 20:26:36 +0100 Subject: Added first implementation of cClearMetaOnDrop --- src/Blocks/BlockLadder.h | 5 +++-- src/Blocks/ClearMetaOnDrop.h | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/Blocks/ClearMetaOnDrop.h (limited to 'src') diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index a605edf3f..1af2be067 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -3,17 +3,18 @@ #include "BlockHandler.h" #include "../World.h" +#include "ClearMetaOnDrop.h" class cBlockLadderHandler : - public cMetaRotator + public cClearMetaOnDrop > { public: cBlockLadderHandler(BLOCKTYPE a_BlockType) - : cMetaRotator(a_BlockType) + : cClearMetaOnDrop >(a_BlockType) { } diff --git a/src/Blocks/ClearMetaOnDrop.h b/src/Blocks/ClearMetaOnDrop.h new file mode 100644 index 000000000..21b987f2c --- /dev/null +++ b/src/Blocks/ClearMetaOnDrop.h @@ -0,0 +1,18 @@ + +#pragma once + +template +class cClearMetaOnDrop : public Base +{ +public: + + cClearMetaOnDrop(BLOCKTYPE a_BlockType) : + Base(a_BlockType) + {} + + virtual ~cClearMetaOnDrop() {} + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(this->m_BlockType, 1, 0)); + } +}; -- cgit v1.2.3 From 515c3cbc67816fb770ff7e32bd593bd55c26788c Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 14 Jul 2014 20:28:16 +0100 Subject: Added cClearOnDrop Mixin to cPumpkin --- src/Blocks/BlockPumpkin.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h index ac2b9817a..f4022735b 100644 --- a/src/Blocks/BlockPumpkin.h +++ b/src/Blocks/BlockPumpkin.h @@ -6,11 +6,11 @@ class cBlockPumpkinHandler : - public cMetaRotator + public cClearMetaOnDrop > { public: cBlockPumpkinHandler(BLOCKTYPE a_BlockType) - : cMetaRotator(a_BlockType) + : cClearMetaOnDrop >(a_BlockType) { } -- cgit v1.2.3 From 093b5c6456fd2c635441630c87853a3a00008af8 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 14 Jul 2014 20:33:30 +0100 Subject: Simplified ClearMetaOnDrop --- src/Blocks/ClearMetaOnDrop.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Blocks/ClearMetaOnDrop.h b/src/Blocks/ClearMetaOnDrop.h index 21b987f2c..e6d26863a 100644 --- a/src/Blocks/ClearMetaOnDrop.h +++ b/src/Blocks/ClearMetaOnDrop.h @@ -13,6 +13,6 @@ public: virtual ~cClearMetaOnDrop() {} virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.push_back(cItem(this->m_BlockType, 1, 0)); + a_Pickups.push_back(cItem(this->m_BlockType)); } }; -- cgit v1.2.3 From 333f4f982cbd24ffcb376594eddef439b3f05e9e Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 14 Jul 2014 20:50:56 +0100 Subject: Converted some blockhandlers to use cClearMetaOnDrop --- src/Blocks/BlockBrewingStand.h | 10 +++------- src/Blocks/BlockCobWeb.h | 10 ++-------- src/Blocks/BlockFlowerPot.h | 9 ++------- src/Blocks/BlockLilypad.h | 9 ++------- src/Blocks/BlockMycelium.h | 8 ++------ src/Blocks/BlockRedstone.h | 11 ++--------- src/Blocks/BlockRedstoneLamp.h | 9 ++------- src/Blocks/BlockRedstoneRepeater.h | 13 +++---------- src/Blocks/BlockStone.h | 9 +++------ 9 files changed, 21 insertions(+), 67 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockBrewingStand.h b/src/Blocks/BlockBrewingStand.h index 57642bcb6..77e383b16 100644 --- a/src/Blocks/BlockBrewingStand.h +++ b/src/Blocks/BlockBrewingStand.h @@ -2,25 +2,21 @@ #pragma once #include "BlockHandler.h" +#include "ClearMetaOnDrop.h" class cBlockBrewingStandHandler : - public cBlockHandler + public cClearMetaOnDrop { public: cBlockBrewingStandHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + : cClearMetaOnDrop(a_BlockType) { } - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - a_Pickups.push_back(cItem(E_ITEM_BREWING_STAND, 1, 0)); - } - virtual bool IsUseable() override { return true; diff --git a/src/Blocks/BlockCobWeb.h b/src/Blocks/BlockCobWeb.h index 982bfaa30..29a6b8155 100644 --- a/src/Blocks/BlockCobWeb.h +++ b/src/Blocks/BlockCobWeb.h @@ -10,19 +10,13 @@ class cBlockCobWebHandler : - public cBlockHandler + public cClearMetaOnDrop { public: cBlockCobWebHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + : cClearMetaOnDrop(a_BlockType) { } - - - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override - { - a_Pickups.push_back(cItem(E_ITEM_STRING, 1, 0)); - } } ; diff --git a/src/Blocks/BlockFlowerPot.h b/src/Blocks/BlockFlowerPot.h index fc75ef638..39fbe1bd9 100644 --- a/src/Blocks/BlockFlowerPot.h +++ b/src/Blocks/BlockFlowerPot.h @@ -9,18 +9,13 @@ class cBlockFlowerPotHandler : - public cBlockEntityHandler + public cClearMetaOnDrop { public: cBlockFlowerPotHandler(BLOCKTYPE a_BlockType) : - cBlockEntityHandler(a_BlockType) + cClearMetaOnDrop(a_BlockType) { } - - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - a_Pickups.push_back(cItem(E_ITEM_FLOWER_POT, 1, 0)); - } } ; diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h index 2dd4ec768..fc37f360c 100644 --- a/src/Blocks/BlockLilypad.h +++ b/src/Blocks/BlockLilypad.h @@ -8,19 +8,14 @@ class cBlockLilypadHandler : - public cBlockHandler + public cClearMetaOnDrop { public: cBlockLilypadHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + : cClearMetaOnDrop(a_BlockType) { } - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - // Reset meta to zero - a_Pickups.push_back(cItem(E_BLOCK_LILY_PAD, 1, 0)); - } }; diff --git a/src/Blocks/BlockMycelium.h b/src/Blocks/BlockMycelium.h index 2a8ef5fca..4d4a0bb4f 100644 --- a/src/Blocks/BlockMycelium.h +++ b/src/Blocks/BlockMycelium.h @@ -8,20 +8,16 @@ class cBlockMyceliumHandler : - public cBlockHandler + public cClearMetaOnDrop { public: cBlockMyceliumHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + : cClearMetaOnDrop(a_BlockType) { } // TODO: Add Mycel Spread - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - a_Pickups.push_back(cItem(E_BLOCK_DIRT, 1, 0)); - } virtual const char * GetStepSound(void) override { diff --git a/src/Blocks/BlockRedstone.h b/src/Blocks/BlockRedstone.h index a898c9acb..6dbf46a57 100644 --- a/src/Blocks/BlockRedstone.h +++ b/src/Blocks/BlockRedstone.h @@ -9,11 +9,11 @@ class cBlockRedstoneHandler : - public cBlockHandler + public cClearMetaOnDrop { public: cBlockRedstoneHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + : cClearMetaOnDrop(a_BlockType) { } @@ -22,13 +22,6 @@ public: { return ((a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ))); } - - - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - // Reset meta to 0 - a_Pickups.push_back(cItem(E_ITEM_REDSTONE_DUST, 1)); - } } ; diff --git a/src/Blocks/BlockRedstoneLamp.h b/src/Blocks/BlockRedstoneLamp.h index 69a2b27c2..4b0ca5b34 100644 --- a/src/Blocks/BlockRedstoneLamp.h +++ b/src/Blocks/BlockRedstoneLamp.h @@ -8,18 +8,13 @@ class cBlockRedstoneLampHandler : - public cBlockHandler + public cClearMetaOnDrop { public: cBlockRedstoneLampHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + : cClearMetaOnDrop(a_BlockType) { } - - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - a_Pickups.push_back(cItem(E_BLOCK_REDSTONE_LAMP_OFF, 1, 0)); - } }; diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h index fe6cd21b9..1e9c00f2e 100644 --- a/src/Blocks/BlockRedstoneRepeater.h +++ b/src/Blocks/BlockRedstoneRepeater.h @@ -4,16 +4,16 @@ #include "BlockHandler.h" #include "Chunk.h" #include "MetaRotator.h" - +#include "ClearMetaOnDrop.h" class cBlockRedstoneRepeaterHandler : - public cMetaRotator + public cClearMetaOnDrop > { public: cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType) - : cMetaRotator(a_BlockType) + : cClearMetaOnDrop >(a_BlockType) { } @@ -44,13 +44,6 @@ public: } - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - // Reset meta to 0 - a_Pickups.push_back(cItem(E_ITEM_REDSTONE_REPEATER, 1, 0)); - } - - virtual bool IsUseable(void) override { return true; diff --git a/src/Blocks/BlockStone.h b/src/Blocks/BlockStone.h index cd5230f49..697ab0312 100644 --- a/src/Blocks/BlockStone.h +++ b/src/Blocks/BlockStone.h @@ -2,24 +2,21 @@ #pragma once #include "BlockHandler.h" +#include "ClearMetaOnDrop.h" class cBlockStoneHandler : - public cBlockHandler + public cClearMetaOnDrop { public: cBlockStoneHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + : cClearMetaOnDrop(a_BlockType) { } - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - a_Pickups.push_back(cItem(E_BLOCK_COBBLESTONE, 1, 0)); - } } ; -- cgit v1.2.3 From 2cd3443fbbb498f06227ed44db0c6a749cafdb76 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 14 Jul 2014 21:21:17 +0100 Subject: Added documentation --- src/Blocks/ClearMetaOnDrop.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/Blocks/ClearMetaOnDrop.h b/src/Blocks/ClearMetaOnDrop.h index e6d26863a..3f8c33819 100644 --- a/src/Blocks/ClearMetaOnDrop.h +++ b/src/Blocks/ClearMetaOnDrop.h @@ -1,6 +1,12 @@ #pragma once +// mixin for use to clear meta values when the block is converted to a pickup + +// Usage: inherit from this class, passing the parent class as the parameter Base +// For example to use in class Foo which should inherit Bar use +// class Foo : public cClearMetaOnDrop; + template class cClearMetaOnDrop : public Base { -- cgit v1.2.3 From 061010288a99fd11f91bf713ac68068c57f79be7 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 14 Jul 2014 13:46:15 -0700 Subject: Readability and clarity changes --- src/Entities/Entity.cpp | 9 ++++-- src/Entities/EntityEffect.cpp | 41 +++++++++-------------- src/Entities/EntityEffect.h | 2 +- src/Items/ItemPotion.h | 75 ++++++++++++++++++++++++++----------------- 4 files changed, 68 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 042c4b4c3..670e8420a 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -311,10 +311,13 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) // IsOnGround() only is false if the player is moving downwards // TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain) - if (!Player->IsOnGround() && (a_TDI.DamageType == dtAttack || a_TDI.DamageType == dtArrowAttack)) + if (!Player->IsOnGround()) { - a_TDI.FinalDamage += 2; - m_World->BroadcastEntityAnimation(*this, 4); // Critical hit + if ((a_TDI.DamageType == dtAttack) || (a_TDI.DamageType == dtArrowAttack)) + { + a_TDI.FinalDamage += 2; + m_World->BroadcastEntityAnimation(*this, 4); // Critical hit + } } Player->GetStatManager().AddValue(statDamageDealt, (StatValue)floor(a_TDI.FinalDamage * 10 + 0.5)); diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp index 852099b79..12dd17d72 100644 --- a/src/Entities/EntityEffect.cpp +++ b/src/Entities/EntityEffect.cpp @@ -113,15 +113,12 @@ void cEntityEffect::OnTick(cPawn & a_Target) void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target) { // Base amount = 6, doubles for every increase in intensity - int amount = (int)(6 * std::pow(2.0, m_Intensity) * m_DistanceModifier); + int amount = (int)(6 * (1 << m_Intensity) * m_DistanceModifier); - if (a_Target.IsMob()) + if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead()) { - if (((cMonster &) a_Target).IsUndead()) - { - a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage - return; - } + a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage + return; } a_Target.Heal(amount); } @@ -136,15 +133,12 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target) void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target) { // Base amount = 6, doubles for every increase in intensity - int amount = (int)(6 * std::pow(2.0, m_Intensity) * m_DistanceModifier); + int amount = (int)(6 * (1 << m_Intensity) * m_DistanceModifier); - if (a_Target.IsMob()) + if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead()) { - if (((cMonster &) a_Target).IsUndead()) - { - a_Target.Heal(amount); - return; - } + a_Target.Heal(amount); + return; } a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage } @@ -160,18 +154,15 @@ void cEntityEffectRegeneration::OnTick(cPawn & a_Target) { super::OnTick(a_Target); - if (a_Target.IsMob()) + if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead()) { - if (((cMonster &) a_Target).IsUndead()) - { - return; - } + return; } // Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks) int frequency = (int) std::floor(50.0 / (double)(m_Intensity + 1)); - if (m_Ticks % frequency != 0) + if ((m_Ticks % frequency) != 0) { return; } @@ -231,9 +222,9 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target) cMonster & Target = (cMonster &) a_Target; // Doesn't effect undead mobs, spiders - if (Target.IsUndead() - || Target.GetMobType() == cMonster::mtSpider - || Target.GetMobType() == cMonster::mtCaveSpider) + if ((Target.IsUndead()) + || (Target.GetMobType() == cMonster::mtSpider) + || (Target.GetMobType() == cMonster::mtCaveSpider)) { return; } @@ -242,7 +233,7 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target) // Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks) int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1)); - if (m_Ticks % frequency == 0) + if ((m_Ticks % frequency) == 0) { // Cannot take poison damage when health is at 1 if (a_Target.GetHealth() > 1) @@ -266,7 +257,7 @@ void cEntityEffectWither::OnTick(cPawn & a_Target) // Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks) int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1)); - if (m_Ticks % frequency == 0) + if ((m_Ticks % frequency) == 0) { a_Target.TakeDamage(dtWither, NULL, 1, 0); } diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index c6532a9bd..ea0716d59 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -220,7 +220,7 @@ class cEntityEffectNausea: typedef cEntityEffect super; public: cEntityEffectNausea(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_DistanceModifier) + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index 5badeda94..b72499431 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -11,33 +11,35 @@ class cItemPotionHandler: int GetPotionName(short a_ItemDamage) { - return a_ItemDamage & 63; + // First six bits (least significant) + return a_ItemDamage & 0x3F; } cEntityEffect::eType GetEntityEffectType(short a_ItemDamage) { + // First four bits (least significant) // Potion effect bits are different from entity effect values // For reference: http://minecraft.gamepedia.com/Data_values#.22Potion_effect.22_bits - switch (a_ItemDamage & 15) + switch (a_ItemDamage & 0xF) { - case 1: return cEntityEffect::effRegeneration; - case 2: return cEntityEffect::effSpeed; - case 3: return cEntityEffect::effFireResistance; - case 4: return cEntityEffect::effPoison; - case 5: return cEntityEffect::effInstantHealth; - case 6: return cEntityEffect::effNightVision; - case 8: return cEntityEffect::effWeakness; - case 9: return cEntityEffect::effStrength; - case 10: return cEntityEffect::effSlowness; - case 12: return cEntityEffect::effInstantDamage; - case 13: return cEntityEffect::effWaterBreathing; - case 14: return cEntityEffect::effInvisibility; + case 0x1: return cEntityEffect::effRegeneration; + case 0x2: return cEntityEffect::effSpeed; + case 0x3: return cEntityEffect::effFireResistance; + case 0x4: return cEntityEffect::effPoison; + case 0x5: return cEntityEffect::effInstantHealth; + case 0x6: return cEntityEffect::effNightVision; + case 0x8: return cEntityEffect::effWeakness; + case 0x9: return cEntityEffect::effStrength; + case 0xA: return cEntityEffect::effSlowness; + case 0xC: return cEntityEffect::effInstantDamage; + case 0xD: return cEntityEffect::effWaterBreathing; + case 0xE: return cEntityEffect::effInvisibility; // No effect potions - case 0: - case 7: - case 11: - case 15: + case 0x0: + case 0x7: + case 0xB: // Will be potion of leaping in 1.8 + case 0xF: { break; } @@ -48,9 +50,8 @@ class cItemPotionHandler: short GetEntityEffectIntensity(short a_ItemDamage) { - // Level II potion if fifth bit is set - if (a_ItemDamage & 32) return 1; - else return 0; + // Level II potion if fifth bit (from zero) is set + return (a_ItemDamage & 0x20) ? 1 : 0; } int GetEntityEffectDuration(short a_ItemDamage) @@ -91,8 +92,8 @@ class cItemPotionHandler: TierCoeff = (GetEntityEffectIntensity(a_ItemDamage) > 0) ? 0.5 : 1; // If potion is extended, multiply duration by 8/3. If not, stays the same - // Extended potion if sixth bit is set - ExtCoeff = (a_ItemDamage & 64) ? (8.0/3.0) : 1; + // Extended potion if sixth bit (from zero) is set + ExtCoeff = (a_ItemDamage & 0x40) ? (8.0/3.0) : 1; // If potion is splash potion, multiply duration by 3/4. If not, stays the same SplashCoeff = IsDrinkable(a_ItemDamage) ? 1 : 0.75; @@ -112,18 +113,26 @@ public: virtual bool IsDrinkable(short a_ItemDamage) override { - // Drinkable potion if 13th bit is set + // Drinkable potion if 13th bit (from zero) is set // For reference: http://minecraft.gamepedia.com/Potions#Data_value_table - return ((a_ItemDamage & 8192) != 0); + return ((a_ItemDamage & 0x2000) != 0); } virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { + short PotionDamage = a_Item.m_ItemDamage; + + // Only called when potion is a splash potion + if (IsDrinkable(PotionDamage)) + { + return false; + } + Vector3d Pos = a_Player->GetThrowStartPos(); Vector3d Speed = a_Player->GetLookVector() * 7; - short potion_damage = a_Item.m_ItemDamage; - cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, GetEntityEffectType(potion_damage), cEntityEffect(GetEntityEffectDuration(potion_damage), GetEntityEffectIntensity(potion_damage)), GetPotionName(potion_damage)); + cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, GetEntityEffectType(PotionDamage), cEntityEffect(GetEntityEffectDuration(PotionDamage), GetEntityEffectIntensity(PotionDamage)), GetPotionName(PotionDamage)); + if (Projectile == NULL) { return false; @@ -139,14 +148,20 @@ public: a_Player->GetInventory().RemoveOneEquippedItem(); } - // Called when potion is a splash potion return true; } virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override { - // Called when potion is a drinkable potion - a_Player->AddEntityEffect(GetEntityEffectType(a_Item->m_ItemDamage), GetEntityEffectDuration(a_Item->m_ItemDamage), GetEntityEffectIntensity(a_Item->m_ItemDamage)); + short PotionDamage = a_Item->m_ItemDamage; + + // Only called when potion is a drinkable potion + if (!IsDrinkable(a_Item->m_ItemDamage)) + { + return false; + } + + a_Player->AddEntityEffect(GetEntityEffectType(PotionDamage), GetEntityEffectDuration(PotionDamage), GetEntityEffectIntensity(PotionDamage)); a_Player->GetInventory().RemoveOneEquippedItem(); a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE); return true; -- cgit v1.2.3 From 40bb98510a820469184e4947db3de22088b55fc7 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 13 Jul 2014 16:54:42 -0700 Subject: ItemHandler.cpp: removed redundant food and drink checks --- src/Items/ItemHandler.cpp | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'src') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 7fae2d395..85406c826 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -474,32 +474,6 @@ bool cItemHandler::IsTool() bool cItemHandler::IsFood(void) { - switch (m_ItemType) - { - case E_ITEM_RED_APPLE: - case E_ITEM_GOLDEN_APPLE: - case E_ITEM_MUSHROOM_SOUP: - case E_ITEM_BREAD: - case E_ITEM_RAW_PORKCHOP: - case E_ITEM_COOKED_PORKCHOP: - case E_ITEM_RAW_FISH: - case E_ITEM_COOKED_FISH: - case E_ITEM_COOKIE: - case E_ITEM_MELON_SLICE: - case E_ITEM_RAW_BEEF: - case E_ITEM_STEAK: - case E_ITEM_RAW_CHICKEN: - case E_ITEM_COOKED_CHICKEN: - case E_ITEM_ROTTEN_FLESH: - case E_ITEM_SPIDER_EYE: - case E_ITEM_CARROT: - case E_ITEM_POTATO: - case E_ITEM_BAKED_POTATO: - case E_ITEM_POISONOUS_POTATO: - { - return true; - } - } // switch (m_ItemType) return false; } @@ -511,13 +485,6 @@ bool cItemHandler::IsDrinkable(short a_ItemDamage) { UNUSED(a_ItemDamage); - switch (m_ItemType) - { - case E_ITEM_MILK: - { - return true; - } - } // switch (m_ItemType) return false; } -- cgit v1.2.3 From f0187cc8f9922093b1e83687f869b813a8e90930 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 14 Jul 2014 21:55:46 +0100 Subject: Fixed placing liquids over liquids * Fixes #1182 --- src/Items/ItemBucket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 5529b4e36..84835c021 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -203,7 +203,7 @@ public: if (a_BlockType != E_BLOCK_AIR) { m_ReplacedBlock = a_BlockType; - if (!cFluidSimulator::CanWashAway(a_BlockType)) + if (!cFluidSimulator::CanWashAway(a_BlockType) && !IsBlockLiquid(a_BlockType)) { AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, (eBlockFace)a_EntryFace); // Was an unwashawayable block, can't overwrite it! } -- cgit v1.2.3 From ad6494fb36b1bb19f39796ad9d5ce4544a21f361 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 14 Jul 2014 21:56:40 +0100 Subject: Maybe improved arrow sinking --- src/Entities/ArrowEntity.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index d5e41bd46..a3a1667e4 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -79,8 +79,8 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa } Vector3d Hit = a_HitPos; - Vector3d SinkMovement = (GetSpeed() / 800); - Hit += (SinkMovement * 0.01) / SinkMovement.Length(); // Make arrow sink into block a centimetre so it lodges (but not to far so it goes black clientside) + Vector3d SinkMovement = (GetSpeed() / 1000); + Hit += SinkMovement * (0.0005 / SinkMovement.Length()); // Make arrow sink into block a centimetre so it lodges (but not to far so it goes black clientside) super::OnHitSolidBlock(Hit, a_HitFace); Vector3i BlockHit = Hit.Floor(); -- cgit v1.2.3 From 5b1552435f95887ba59c707e3635dcaf9cb358f4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 14 Jul 2014 21:57:44 +0100 Subject: Fixed some meta resetting bugs * Fixes #1174 * Fixes #1171 --- src/Blocks/BlockCloth.h | 7 ------- src/Blocks/BlockFarmland.h | 11 +++++++---- src/Blocks/BlockHandler.cpp | 2 +- src/Blocks/BlockHayBale.h | 1 - src/Blocks/BlockLadder.h | 22 ++++++++++++++-------- src/Blocks/BlockSideways.h | 12 ++++++------ 6 files changed, 28 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockCloth.h b/src/Blocks/BlockCloth.h index a136d3b9d..3c1ae7c25 100644 --- a/src/Blocks/BlockCloth.h +++ b/src/Blocks/BlockCloth.h @@ -16,13 +16,6 @@ public: { } - - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - a_Pickups.push_back(cItem(E_BLOCK_WOOL, 1, a_BlockMeta)); - } - - virtual const char * GetStepSound(void) override { return "step.cloth"; diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h index 3dd5bcd1d..390b6e5ee 100644 --- a/src/Blocks/BlockFarmland.h +++ b/src/Blocks/BlockFarmland.h @@ -19,15 +19,13 @@ class cBlockFarmlandHandler : public cBlockHandler { - typedef cBlockHandler super; public: - cBlockFarmlandHandler(void) : - super(E_BLOCK_FARMLAND) + cBlockFarmlandHandler(BLOCKTYPE a_BlockType) : + cBlockHandler(a_BlockType) { } - virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override { bool Found = false; @@ -105,6 +103,11 @@ public: } } } + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.Add(E_BLOCK_DIRT, 1, 0); // Reset meta + } } ; diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 730774ab1..cef1f5f09 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -211,7 +211,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_ENCHANTMENT_TABLE: return new cBlockEnchantmentTableHandler(a_BlockType); case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType); - case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler ( ); + case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler (a_BlockType); case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType); case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType); case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType); diff --git a/src/Blocks/BlockHayBale.h b/src/Blocks/BlockHayBale.h index 5b646e264..3c6472adb 100644 --- a/src/Blocks/BlockHayBale.h +++ b/src/Blocks/BlockHayBale.h @@ -1,7 +1,6 @@ #pragma once -#include "BlockHandler.h" #include "BlockSideways.h" diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index a605edf3f..7efd8e444 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -41,21 +41,27 @@ public: } - static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) // tolua_export - { // tolua_export + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.Add(m_BlockType, 1, 0); // Reset meta + } + + + static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) + { switch (a_Direction) { case BLOCK_FACE_ZM: return 0x2; case BLOCK_FACE_ZP: return 0x3; case BLOCK_FACE_XM: return 0x4; case BLOCK_FACE_XP: return 0x5; - default: return 0x2; + default: return 0x2; } - } // tolua_export + } - static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export - { // tolua_export + static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) + { switch (a_MetaData) { case 0x2: return BLOCK_FACE_ZM; @@ -64,10 +70,10 @@ public: case 0x5: return BLOCK_FACE_XP; default: return BLOCK_FACE_ZM; } - } // tolua_export + } - /// Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure + /** Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure */ static eBlockFace FindSuitableBlockFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { for (int FaceInt = BLOCK_FACE_ZM; FaceInt <= BLOCK_FACE_XP; FaceInt++) diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h index d67c3aa24..5b37efd75 100644 --- a/src/Blocks/BlockSideways.h +++ b/src/Blocks/BlockSideways.h @@ -32,36 +32,36 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3); + a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3); // Reset meta } - inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_WoodMeta) + inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_Meta) { switch (a_BlockFace) { case BLOCK_FACE_YM: case BLOCK_FACE_YP: { - return a_WoodMeta; // Top or bottom, just return original + return a_Meta; // Top or bottom, just return original } case BLOCK_FACE_ZP: case BLOCK_FACE_ZM: { - return a_WoodMeta | 0x8; // North or south + return a_Meta | 0x8; // North or south } case BLOCK_FACE_XP: case BLOCK_FACE_XM: { - return a_WoodMeta | 0x4; // East or west + return a_Meta | 0x4; // East or west } default: { ASSERT(!"Unhandled block face!"); - return a_WoodMeta | 0xC; // No idea, give a special meta (all sides bark) + return a_Meta | 0xC; // No idea, give a special meta } } } -- cgit v1.2.3 From 82fe5c05f0456a11fcb2079eaf44ee0565b0c3c7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 14 Jul 2014 23:03:30 +0100 Subject: Fixed redstone simulator crash * Fixes #1176 * Fixed #1186 --- src/Simulator/IncrementalRedstoneSimulator.cpp | 35 +++++++++++++++++++++----- src/Simulator/IncrementalRedstoneSimulator.h | 4 +-- 2 files changed, 31 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 8b9d830cd..fb5b01e17 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -396,7 +396,13 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R int X = a_RelBlockX; int Y = a_RelBlockY; int Z = a_RelBlockZ; AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on - if (AreCoordsDirectlyPowered(X, Y, Z)) + cChunk * Neighbour = m_Chunk->GetRelNeighborChunk(X, Z); + if ((Neighbour == NULL) || !Neighbour->IsValid()) + { + return; + } + + if (AreCoordsDirectlyPowered(X, Y, Z, Neighbour)) { // There was a match, torch goes off m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_TORCH_OFF, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)); @@ -445,9 +451,15 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R // Check if the block the torch is on is powered int X = a_RelBlockX; int Y = a_RelBlockY; int Z = a_RelBlockZ; AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on - + + cChunk * Neighbour = m_Chunk->GetRelNeighborChunk(X, Z); + if ((Neighbour == NULL) || !Neighbour->IsValid()) + { + return; + } + // See if off state torch can be turned on again - if (AreCoordsDirectlyPowered(X, Y, Z)) + if (AreCoordsDirectlyPowered(X, Y, Z, Neighbour)) { return; // Something matches, torch still powered } @@ -1492,13 +1504,14 @@ void cIncrementalRedstoneSimulator::HandleTripwire(int a_RelBlockX, int a_RelBlo -bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) +bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, cChunk * a_Chunk) { + // Torches want to access neighbour's data when on a wall, hence the extra chunk parameter + int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; - PoweredBlocksList * Powered = m_Chunk->GetNeighborChunk(BlockX, BlockZ)->GetRedstoneSimulatorPoweredBlocksList(); // Torches want to access neighbour's data when on a wall - for (PoweredBlocksList::const_iterator itr = Powered->begin(); itr != Powered->end(); ++itr) // Check powered list + for (PoweredBlocksList::const_iterator itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->end(); ++itr) // Check powered list { if (itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { @@ -1900,6 +1913,11 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl int SourceZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelSourceZ; cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelBlockX, a_RelBlockZ); // Adjust coordinates for the later call using these values + if ((Neighbour == NULL) || !Neighbour->IsValid()) + { + return; + } + PoweredBlocksList * Powered = Neighbour->GetRedstoneSimulatorPoweredBlocksList(); // We need to insert the value into the chunk who owns the block position for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr) { @@ -1977,6 +1995,11 @@ void cIncrementalRedstoneSimulator::SetBlockLinkedPowered( } cChunk * Neighbour = m_Chunk->GetNeighborChunk(BlockX, BlockZ); + if ((Neighbour == NULL) || !Neighbour->IsValid()) + { + return; + } + LinkedBlocksList * Linked = Neighbour->GetRedstoneSimulatorLinkedBlocksList(); for (LinkedBlocksList::iterator itr = Linked->begin(); itr != Linked->end(); ++itr) // Check linked powered list { diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index ce987a60f..1faf4187b 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -162,9 +162,9 @@ private: void SetSourceUnpowered(int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, cChunk * a_Chunk, bool a_IsFirstCall = true); /** Returns if a coordinate is powered or linked powered */ - bool AreCoordsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { return AreCoordsDirectlyPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ) || AreCoordsLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); } + bool AreCoordsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { return AreCoordsDirectlyPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk) || AreCoordsLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); } /** Returns if a coordinate is in the directly powered blocks list */ - bool AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); + bool AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, cChunk * a_Chunk); /** Returns if a coordinate is in the indirectly powered blocks list */ bool AreCoordsLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Returns if a coordinate was marked as simulated (for blocks toggleable by players) */ -- cgit v1.2.3 From 8fd636aa7235698263e3b85388a4f6373cbedb76 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 14 Jul 2014 23:59:24 +0100 Subject: Revert "Converted some blockhandlers to use cClearMetaOnDrop" This reverts commit 333f4f982cbd24ffcb376594eddef439b3f05e9e. --- src/Blocks/BlockBrewingStand.h | 10 +++++++--- src/Blocks/BlockCobWeb.h | 10 ++++++++-- src/Blocks/BlockFlowerPot.h | 9 +++++++-- src/Blocks/BlockLilypad.h | 9 +++++++-- src/Blocks/BlockMycelium.h | 8 ++++++-- src/Blocks/BlockRedstone.h | 11 +++++++++-- src/Blocks/BlockRedstoneLamp.h | 9 +++++++-- src/Blocks/BlockRedstoneRepeater.h | 13 ++++++++++--- src/Blocks/BlockStone.h | 9 ++++++--- 9 files changed, 67 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockBrewingStand.h b/src/Blocks/BlockBrewingStand.h index 77e383b16..57642bcb6 100644 --- a/src/Blocks/BlockBrewingStand.h +++ b/src/Blocks/BlockBrewingStand.h @@ -2,21 +2,25 @@ #pragma once #include "BlockHandler.h" -#include "ClearMetaOnDrop.h" class cBlockBrewingStandHandler : - public cClearMetaOnDrop + public cBlockHandler { public: cBlockBrewingStandHandler(BLOCKTYPE a_BlockType) - : cClearMetaOnDrop(a_BlockType) + : cBlockHandler(a_BlockType) { } + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(E_ITEM_BREWING_STAND, 1, 0)); + } + virtual bool IsUseable() override { return true; diff --git a/src/Blocks/BlockCobWeb.h b/src/Blocks/BlockCobWeb.h index 29a6b8155..982bfaa30 100644 --- a/src/Blocks/BlockCobWeb.h +++ b/src/Blocks/BlockCobWeb.h @@ -10,13 +10,19 @@ class cBlockCobWebHandler : - public cClearMetaOnDrop + public cBlockHandler { public: cBlockCobWebHandler(BLOCKTYPE a_BlockType) - : cClearMetaOnDrop(a_BlockType) + : cBlockHandler(a_BlockType) { } + + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override + { + a_Pickups.push_back(cItem(E_ITEM_STRING, 1, 0)); + } } ; diff --git a/src/Blocks/BlockFlowerPot.h b/src/Blocks/BlockFlowerPot.h index 39fbe1bd9..fc75ef638 100644 --- a/src/Blocks/BlockFlowerPot.h +++ b/src/Blocks/BlockFlowerPot.h @@ -9,13 +9,18 @@ class cBlockFlowerPotHandler : - public cClearMetaOnDrop + public cBlockEntityHandler { public: cBlockFlowerPotHandler(BLOCKTYPE a_BlockType) : - cClearMetaOnDrop(a_BlockType) + cBlockEntityHandler(a_BlockType) { } + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(E_ITEM_FLOWER_POT, 1, 0)); + } } ; diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h index fc37f360c..2dd4ec768 100644 --- a/src/Blocks/BlockLilypad.h +++ b/src/Blocks/BlockLilypad.h @@ -8,14 +8,19 @@ class cBlockLilypadHandler : - public cClearMetaOnDrop + public cBlockHandler { public: cBlockLilypadHandler(BLOCKTYPE a_BlockType) - : cClearMetaOnDrop(a_BlockType) + : cBlockHandler(a_BlockType) { } + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + // Reset meta to zero + a_Pickups.push_back(cItem(E_BLOCK_LILY_PAD, 1, 0)); + } }; diff --git a/src/Blocks/BlockMycelium.h b/src/Blocks/BlockMycelium.h index 4d4a0bb4f..2a8ef5fca 100644 --- a/src/Blocks/BlockMycelium.h +++ b/src/Blocks/BlockMycelium.h @@ -8,16 +8,20 @@ class cBlockMyceliumHandler : - public cClearMetaOnDrop + public cBlockHandler { public: cBlockMyceliumHandler(BLOCKTYPE a_BlockType) - : cClearMetaOnDrop(a_BlockType) + : cBlockHandler(a_BlockType) { } // TODO: Add Mycel Spread + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(E_BLOCK_DIRT, 1, 0)); + } virtual const char * GetStepSound(void) override { diff --git a/src/Blocks/BlockRedstone.h b/src/Blocks/BlockRedstone.h index 6dbf46a57..a898c9acb 100644 --- a/src/Blocks/BlockRedstone.h +++ b/src/Blocks/BlockRedstone.h @@ -9,11 +9,11 @@ class cBlockRedstoneHandler : - public cClearMetaOnDrop + public cBlockHandler { public: cBlockRedstoneHandler(BLOCKTYPE a_BlockType) - : cClearMetaOnDrop(a_BlockType) + : cBlockHandler(a_BlockType) { } @@ -22,6 +22,13 @@ public: { return ((a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ))); } + + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + // Reset meta to 0 + a_Pickups.push_back(cItem(E_ITEM_REDSTONE_DUST, 1)); + } } ; diff --git a/src/Blocks/BlockRedstoneLamp.h b/src/Blocks/BlockRedstoneLamp.h index 4b0ca5b34..69a2b27c2 100644 --- a/src/Blocks/BlockRedstoneLamp.h +++ b/src/Blocks/BlockRedstoneLamp.h @@ -8,13 +8,18 @@ class cBlockRedstoneLampHandler : - public cClearMetaOnDrop + public cBlockHandler { public: cBlockRedstoneLampHandler(BLOCKTYPE a_BlockType) - : cClearMetaOnDrop(a_BlockType) + : cBlockHandler(a_BlockType) { } + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(E_BLOCK_REDSTONE_LAMP_OFF, 1, 0)); + } }; diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h index 1e9c00f2e..fe6cd21b9 100644 --- a/src/Blocks/BlockRedstoneRepeater.h +++ b/src/Blocks/BlockRedstoneRepeater.h @@ -4,16 +4,16 @@ #include "BlockHandler.h" #include "Chunk.h" #include "MetaRotator.h" -#include "ClearMetaOnDrop.h" + class cBlockRedstoneRepeaterHandler : - public cClearMetaOnDrop > + public cMetaRotator { public: cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType) - : cClearMetaOnDrop >(a_BlockType) + : cMetaRotator(a_BlockType) { } @@ -44,6 +44,13 @@ public: } + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + // Reset meta to 0 + a_Pickups.push_back(cItem(E_ITEM_REDSTONE_REPEATER, 1, 0)); + } + + virtual bool IsUseable(void) override { return true; diff --git a/src/Blocks/BlockStone.h b/src/Blocks/BlockStone.h index 697ab0312..cd5230f49 100644 --- a/src/Blocks/BlockStone.h +++ b/src/Blocks/BlockStone.h @@ -2,21 +2,24 @@ #pragma once #include "BlockHandler.h" -#include "ClearMetaOnDrop.h" class cBlockStoneHandler : - public cClearMetaOnDrop + public cBlockHandler { public: cBlockStoneHandler(BLOCKTYPE a_BlockType) - : cClearMetaOnDrop(a_BlockType) + : cBlockHandler(a_BlockType) { } + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(E_BLOCK_COBBLESTONE, 1, 0)); + } } ; -- cgit v1.2.3 From 0e5fa2662aa2b559335a25ee78cd086f795be79e Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 15 Jul 2014 00:01:16 +0100 Subject: COnverted Lilypad back to mixin --- src/Blocks/BlockLilypad.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h index 2dd4ec768..c25f150c7 100644 --- a/src/Blocks/BlockLilypad.h +++ b/src/Blocks/BlockLilypad.h @@ -8,19 +8,13 @@ class cBlockLilypadHandler : - public cBlockHandler + public cClearMetaOnDrop { public: cBlockLilypadHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + : cClearMetaOnDrop(a_BlockType) { } - - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - // Reset meta to zero - a_Pickups.push_back(cItem(E_BLOCK_LILY_PAD, 1, 0)); - } }; -- cgit v1.2.3 From 7195c7dfe2d0cc927c2a065662eba9be99817f70 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 08:28:10 +0200 Subject: Added missing member initialization to cGridStructGen. Fixes CID 68228. --- src/Generating/GridStructGen.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp index a3578de6f..fd1d5e49f 100644 --- a/src/Generating/GridStructGen.cpp +++ b/src/Generating/GridStructGen.cpp @@ -44,6 +44,7 @@ cGridStructGen::cGridStructGen( int a_MaxStructureSizeX, int a_MaxStructureSizeZ, size_t a_MaxCacheSize ) : + m_Seed(a_Seed), m_Noise(a_Seed), m_GridSizeX(a_GridSizeX), m_GridSizeZ(a_GridSizeZ), -- cgit v1.2.3 From e2a1118f88a32bd2912fc8abc81db0dacbb42531 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 08:48:12 +0200 Subject: Pass cItem by reference. Fixes CID 66445. --- src/BlockEntities/FlowerPotEntity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/BlockEntities/FlowerPotEntity.h b/src/BlockEntities/FlowerPotEntity.h index da3fe9b7e..e3570eb9a 100644 --- a/src/BlockEntities/FlowerPotEntity.h +++ b/src/BlockEntities/FlowerPotEntity.h @@ -53,7 +53,7 @@ public: cItem GetItem(void) const { return m_Item; } /** Set the item in the flower pot */ - void SetItem(const cItem a_Item) { m_Item = a_Item; } + void SetItem(const cItem & a_Item) { m_Item = a_Item; } // tolua_end -- cgit v1.2.3 From d27485157847325c82fb93448f4ad05407abbd58 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 09:43:45 +0200 Subject: Fixed a MSVC warning in cEntityEffect::CreateEntityEffect(). --- src/Entities/EntityEffect.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp index 12dd17d72..d1f3e9026 100644 --- a/src/Entities/EntityEffect.cpp +++ b/src/Entities/EntityEffect.cpp @@ -91,6 +91,7 @@ cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectT } ASSERT(!"Unhandled entity effect type!"); + return NULL; } -- cgit v1.2.3 From 5193335efa1c0da08713715844801ee589dcfdf5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 09:48:11 +0200 Subject: Reformatted EntityEffect code. --- src/Entities/EntityEffect.cpp | 54 +++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp index d1f3e9026..761a4d651 100644 --- a/src/Entities/EntityEffect.cpp +++ b/src/Entities/EntityEffect.cpp @@ -109,8 +109,8 @@ void cEntityEffect::OnTick(cPawn & a_Target) ///////////////////////////////////////////////////////////////////////// -// Instant Health -///////////////////////////////////////////////////////////////////////// +// cEntityEffectInstantHealth: + void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target) { // Base amount = 6, doubles for every increase in intensity @@ -118,7 +118,7 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target) if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead()) { - a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage + a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage return; } a_Target.Heal(amount); @@ -129,8 +129,8 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target) ///////////////////////////////////////////////////////////////////////// -// Instant Damage -///////////////////////////////////////////////////////////////////////// +// cEntityEffectInstantDamage: + void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target) { // Base amount = 6, doubles for every increase in intensity @@ -141,7 +141,7 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target) a_Target.Heal(amount); return; } - a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage + a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage } @@ -149,8 +149,8 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target) ///////////////////////////////////////////////////////////////////////// -// Regeneration -///////////////////////////////////////////////////////////////////////// +// cEntityEffectRegeneration: + void cEntityEffectRegeneration::OnTick(cPawn & a_Target) { super::OnTick(a_Target); @@ -176,8 +176,8 @@ void cEntityEffectRegeneration::OnTick(cPawn & a_Target) ///////////////////////////////////////////////////////////////////////// -// Hunger -///////////////////////////////////////////////////////////////////////// +// cEntityEffectHunger: + void cEntityEffectHunger::OnTick(cPawn & a_Target) { super::OnTick(a_Target); @@ -185,7 +185,7 @@ void cEntityEffectHunger::OnTick(cPawn & a_Target) if (a_Target.IsPlayer()) { cPlayer & Target = (cPlayer &) a_Target; - Target.SetFoodExhaustionLevel(Target.GetFoodExhaustionLevel() + 0.025); // 0.5 per second = 0.025 per tick + Target.SetFoodExhaustionLevel(Target.GetFoodExhaustionLevel() + 0.025); // 0.5 per second = 0.025 per tick } } @@ -194,8 +194,8 @@ void cEntityEffectHunger::OnTick(cPawn & a_Target) ///////////////////////////////////////////////////////////////////////// -// Weakness -///////////////////////////////////////////////////////////////////////// +// cEntityEffectWeakness: + void cEntityEffectWeakness::OnTick(cPawn & a_Target) { super::OnTick(a_Target); @@ -212,8 +212,8 @@ void cEntityEffectWeakness::OnTick(cPawn & a_Target) ///////////////////////////////////////////////////////////////////////// -// Poison -///////////////////////////////////////////////////////////////////////// +// cEntityEffectPoison: + void cEntityEffectPoison::OnTick(cPawn & a_Target) { super::OnTick(a_Target); @@ -223,9 +223,10 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target) cMonster & Target = (cMonster &) a_Target; // Doesn't effect undead mobs, spiders - if ((Target.IsUndead()) - || (Target.GetMobType() == cMonster::mtSpider) - || (Target.GetMobType() == cMonster::mtCaveSpider)) + if (Target.IsUndead() || + (Target.GetMobType() == cMonster::mtSpider) || + (Target.GetMobType() == cMonster::mtCaveSpider) + ) { return; } @@ -249,20 +250,19 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target) ///////////////////////////////////////////////////////////////////////// -// Wither -///////////////////////////////////////////////////////////////////////// +// cEntityEffectWither: + void cEntityEffectWither::OnTick(cPawn & a_Target) { super::OnTick(a_Target); - // Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks) + // Damage frequency = 40 ticks, divided by effect level (Wither II = 20 ticks) int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1)); if ((m_Ticks % frequency) == 0) { a_Target.TakeDamage(dtWither, NULL, 1, 0); } - //TODO: " withered away> } @@ -270,13 +270,17 @@ void cEntityEffectWither::OnTick(cPawn & a_Target) ///////////////////////////////////////////////////////////////////////// -// Saturation -///////////////////////////////////////////////////////////////////////// +// cEntityEffectSaturation: + void cEntityEffectSaturation::OnTick(cPawn & a_Target) { if (a_Target.IsPlayer()) { cPlayer & Target = (cPlayer &) a_Target; - Target.SetFoodSaturationLevel(Target.GetFoodSaturationLevel() + (1 + m_Intensity)); // Increase saturation 1 per tick, adds 1 for every increase in level + Target.SetFoodSaturationLevel(Target.GetFoodSaturationLevel() + (1 + m_Intensity)); // Increase saturation 1 per tick, adds 1 for every increase in level } } + + + + -- cgit v1.2.3 From f5259d765147cecb44a40ce5308387aba60cef8f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 11:24:48 +0200 Subject: Only the cEntityEffect::effXXX constants are Lua-exported. The rest of the classes don't need exporting, there's no interface using them anyway. --- src/Entities/EntityEffect.cpp | 3 +- src/Entities/EntityEffect.h | 171 ++++++++++++++++++++++++------------------ 2 files changed, 102 insertions(+), 72 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp index 761a4d651..4da7cac85 100644 --- a/src/Entities/EntityEffect.cpp +++ b/src/Entities/EntityEffect.cpp @@ -223,7 +223,8 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target) cMonster & Target = (cMonster &) a_Target; // Doesn't effect undead mobs, spiders - if (Target.IsUndead() || + if ( + Target.IsUndead() || (Target.GetMobType() == cMonster::mtSpider) || (Target.GetMobType() == cMonster::mtCaveSpider) ) diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index ea0716d59..a06c1512d 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -36,6 +36,8 @@ public: effSaturation = 23, } ; + // tolua_end + /** Creates an empty entity effect */ cEntityEffect(void); @@ -93,11 +95,12 @@ protected: /** The distance modifier for affecting potency */ double m_DistanceModifier; -}; +}; // tolua_export + + + + -///////////////////////////////////////////////////////////////////////// -// Speed -///////////////////////////////////////////////////////////////////////// class cEntityEffectSpeed: public cEntityEffect { @@ -109,9 +112,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Slowness -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectSlowness: public cEntityEffect { @@ -123,9 +127,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Haste -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectHaste: public cEntityEffect { @@ -137,9 +142,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Mining Fatigue -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectMiningFatigue: public cEntityEffect { @@ -151,9 +157,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Strength -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectStrength: public cEntityEffect { @@ -165,9 +172,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Instant Health -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectInstantHealth: public cEntityEffect { @@ -181,9 +189,10 @@ public: virtual void OnActivate(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Instant Damage -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectInstantDamage: public cEntityEffect { @@ -197,9 +206,10 @@ public: virtual void OnActivate(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Jump Boost -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectJumpBoost: public cEntityEffect { @@ -211,9 +221,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Nausea -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectNausea: public cEntityEffect { @@ -225,9 +236,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Regeneration -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectRegeneration: public cEntityEffect { @@ -241,9 +253,10 @@ public: virtual void OnTick(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Resistance -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectResistance: public cEntityEffect { @@ -255,9 +268,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Fire Resistance -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectFireResistance: public cEntityEffect { @@ -269,9 +283,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Water Breathing -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectWaterBreathing: public cEntityEffect { @@ -283,9 +298,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Invisibility -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectInvisibility: public cEntityEffect { @@ -297,9 +313,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Blindness -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectBlindness: public cEntityEffect { @@ -311,9 +328,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Night Vision -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectNightVision: public cEntityEffect { @@ -325,9 +343,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Hunger -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectHunger: public cEntityEffect { @@ -338,12 +357,14 @@ public: { } + // cEntityEffect overrides: virtual void OnTick(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Weakness -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectWeakness: public cEntityEffect { @@ -354,12 +375,14 @@ public: { } + // cEntityEffect overrides: virtual void OnTick(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Poison -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectPoison: public cEntityEffect { @@ -370,12 +393,14 @@ public: { } + // cEntityEffect overrides: virtual void OnTick(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Wither -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectWither: public cEntityEffect { @@ -386,12 +411,14 @@ public: { } + // cEntityEffect overrides: virtual void OnTick(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Health Boost -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectHealthBoost: public cEntityEffect { @@ -403,9 +430,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Absorption -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectAbsorption: public cEntityEffect { @@ -417,9 +445,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Saturation -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectSaturation: public cEntityEffect { @@ -435,4 +464,4 @@ public: -// tolua_end + -- cgit v1.2.3 From 01a31a1872bb7c33d5a4d0a13dae083c4ef7792e Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 15 Jul 2014 12:27:36 +0100 Subject: Added super typedef --- src/Blocks/BlockLadder.h | 3 ++- src/Blocks/BlockLilypad.h | 3 ++- src/Blocks/BlockPumpkin.h | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index 1af2be067..211bbdd9e 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -12,9 +12,10 @@ class cBlockLadderHandler : public cClearMetaOnDrop > { + typedef cClearMetaOnDrop > super; public: cBlockLadderHandler(BLOCKTYPE a_BlockType) - : cClearMetaOnDrop >(a_BlockType) + : super(a_BlockType) { } diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h index c25f150c7..1320174fc 100644 --- a/src/Blocks/BlockLilypad.h +++ b/src/Blocks/BlockLilypad.h @@ -10,9 +10,10 @@ class cBlockLilypadHandler : public cClearMetaOnDrop { +typedef cClearMetaOnDrop super; public: cBlockLilypadHandler(BLOCKTYPE a_BlockType) - : cClearMetaOnDrop(a_BlockType) + : super(a_BlockType) { } }; diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h index f4022735b..d2e9d7843 100644 --- a/src/Blocks/BlockPumpkin.h +++ b/src/Blocks/BlockPumpkin.h @@ -8,9 +8,10 @@ class cBlockPumpkinHandler : public cClearMetaOnDrop > { +typedef cClearMetaOnDrop > super; public: cBlockPumpkinHandler(BLOCKTYPE a_BlockType) - : cClearMetaOnDrop >(a_BlockType) + : super(a_BlockType) { } -- cgit v1.2.3 From 2d245264b1b630dd9c6af6ffb6e6387e011a3198 Mon Sep 17 00:00:00 2001 From: Masy98 Date: Tue, 15 Jul 2014 13:34:45 +0200 Subject: Added various missing blocks in the lists in BlockInfo.cpp --- src/BlockInfo.cpp | 277 ++++++++++++++++++++++++++++++++++++----------- src/Blocks/BlockPiston.h | 1 - 2 files changed, 214 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 4fc1d602c..04859e586 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -14,7 +14,7 @@ cBlockInfo::cBlockInfo() , m_Transparent(false) , m_OneHitDig(false) , m_PistonBreakable(false) - , m_IsSnowable(true) + , m_IsSnowable(false) , m_RequiresSpecialTool(false) , m_IsSolid(true) , m_FullyOccupiesVoxel(false) @@ -65,48 +65,117 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) } // Emissive blocks + a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_LightValue = 9; + a_Info[E_BLOCK_BEACON ].m_LightValue = 15; + a_Info[E_BLOCK_BREWING_STAND ].m_LightValue = 1; + a_Info[E_BLOCK_BROWN_MUSHROOM ].m_LightValue = 1; + a_Info[E_BLOCK_BURNING_FURNACE ].m_LightValue = 13; + a_Info[E_BLOCK_DRAGON_EGG ].m_LightValue = 1; + a_Info[E_BLOCK_END_PORTAL ].m_LightValue = 15; + a_Info[E_BLOCK_END_PORTAL_FRAME ].m_LightValue = 1; + a_Info[E_BLOCK_ENDER_CHEST ].m_LightValue = 7; a_Info[E_BLOCK_FIRE ].m_LightValue = 15; a_Info[E_BLOCK_GLOWSTONE ].m_LightValue = 15; a_Info[E_BLOCK_JACK_O_LANTERN ].m_LightValue = 15; a_Info[E_BLOCK_LAVA ].m_LightValue = 15; - a_Info[E_BLOCK_STATIONARY_LAVA ].m_LightValue = 15; - a_Info[E_BLOCK_END_PORTAL ].m_LightValue = 15; - a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_LightValue = 15; - a_Info[E_BLOCK_TORCH ].m_LightValue = 14; - a_Info[E_BLOCK_BURNING_FURNACE ].m_LightValue = 13; a_Info[E_BLOCK_NETHER_PORTAL ].m_LightValue = 11; + a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_LightValue = 15; a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_LightValue = 9; a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_LightValue = 9; a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_LightValue = 7; - a_Info[E_BLOCK_BREWING_STAND ].m_LightValue = 1; - a_Info[E_BLOCK_BROWN_MUSHROOM ].m_LightValue = 1; - a_Info[E_BLOCK_DRAGON_EGG ].m_LightValue = 1; + a_Info[E_BLOCK_STATIONARY_LAVA ].m_LightValue = 15; + a_Info[E_BLOCK_TORCH ].m_LightValue = 14; // Spread blocks + a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_AIR ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_ANVIL ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_BEACON ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_BED ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_BIG_FLOWER ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_BROWN_MUSHROOM ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_BREWING_STAND ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_CACTUS ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_CAKE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_CARPET ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_CARROTS ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_CAULDRON ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_CHEST ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_COBBLESTONE_WALL ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_COCOA_POD ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_COBWEB ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_CROPS ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_DANDELION ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_DAYLIGHT_SENSOR ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_DEAD_BUSH ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_DETECTOR_RAIL ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_DRAGON_EGG ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_ENDER_CHEST ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_END_PORTAL ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_END_PORTAL_FRAME ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_FARMLAND ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_FENCE ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_FIRE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_FLOWER ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_FLOWER_POT ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_GLASS ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_GLASS_PANE ].m_SpreadLightFalloff = 1; - a_Info[E_BLOCK_GLOWSTONE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_HEAD ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_HOPPER ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_ICE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_IRON_BARS ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_IRON_DOOR ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_LADDER ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_LEAVES ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_LEVER ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_LILY_PAD ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_MELON_STEM ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_MOB_SPAWNER ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_NETHER_PORTAL ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_NETHER_WART ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_PISTON ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_PISTON_EXTENSION ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_PISTON_MOVED_BLOCK ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_POTATOES ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_POWERED_RAIL ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_PUMPKIN_STEM ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_RAIL ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_RED_MUSHROOM ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_REDSTONE_WIRE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_SAPLING ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_SNOW ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_STAINED_GLASS ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_STICKY_PISTON ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_STONE_BUTTON ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_STONE_SLAB ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_SUGARCANE ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_TALL_GRASS ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_TRAPDOOR ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_TRAPPED_CHEST ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_TRIPWIRE ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_WALLSIGN ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_WOODEN_BUTTON ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_WOODEN_DOOR ].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_SpreadLightFalloff = 1; + a_Info[E_BLOCK_WOODEN_SLAB ].m_SpreadLightFalloff = 1; // Light in water and lava dissapears faster: a_Info[E_BLOCK_LAVA ].m_SpreadLightFalloff = 3; @@ -117,19 +186,34 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) // Transparent blocks a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_Transparent = true; + a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_Transparent = true; a_Info[E_BLOCK_AIR ].m_Transparent = true; a_Info[E_BLOCK_ANVIL ].m_Transparent = true; + a_Info[E_BLOCK_BEACON ].m_Transparent = true; + a_Info[E_BLOCK_BED ].m_Transparent = true; a_Info[E_BLOCK_BIG_FLOWER ].m_Transparent = true; a_Info[E_BLOCK_BROWN_MUSHROOM ].m_Transparent = true; + a_Info[E_BLOCK_BREWING_STAND ].m_Transparent = true; + a_Info[E_BLOCK_CACTUS ].m_Transparent = true; a_Info[E_BLOCK_CAKE ].m_Transparent = true; + a_Info[E_BLOCK_CARPET ].m_Transparent = true; a_Info[E_BLOCK_CARROTS ].m_Transparent = true; + a_Info[E_BLOCK_CAULDRON ].m_Transparent = true; a_Info[E_BLOCK_CHEST ].m_Transparent = true; a_Info[E_BLOCK_COBBLESTONE_WALL ].m_Transparent = true; + a_Info[E_BLOCK_COCOA_POD ].m_Transparent = true; a_Info[E_BLOCK_COBWEB ].m_Transparent = true; a_Info[E_BLOCK_CROPS ].m_Transparent = true; a_Info[E_BLOCK_DANDELION ].m_Transparent = true; + a_Info[E_BLOCK_DAYLIGHT_SENSOR ].m_Transparent = true; + a_Info[E_BLOCK_DEAD_BUSH ].m_Transparent = true; a_Info[E_BLOCK_DETECTOR_RAIL ].m_Transparent = true; + a_Info[E_BLOCK_DRAGON_EGG ].m_Transparent = true; + a_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_Transparent = true; a_Info[E_BLOCK_ENDER_CHEST ].m_Transparent = true; + a_Info[E_BLOCK_END_PORTAL ].m_Transparent = true; + a_Info[E_BLOCK_END_PORTAL_FRAME ].m_Transparent = true; + a_Info[E_BLOCK_FARMLAND ].m_Transparent = true; a_Info[E_BLOCK_FENCE ].m_Transparent = true; a_Info[E_BLOCK_FENCE_GATE ].m_Transparent = true; a_Info[E_BLOCK_FIRE ].m_Transparent = true; @@ -139,43 +223,60 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_GLASS_PANE ].m_Transparent = true; a_Info[E_BLOCK_HEAD ].m_Transparent = true; a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_Transparent = true; + a_Info[E_BLOCK_HOPPER ].m_Transparent = true; a_Info[E_BLOCK_ICE ].m_Transparent = true; + a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_Transparent = true; + a_Info[E_BLOCK_IRON_BARS ].m_Transparent = true; a_Info[E_BLOCK_IRON_DOOR ].m_Transparent = true; a_Info[E_BLOCK_LADDER ].m_Transparent = true; a_Info[E_BLOCK_LAVA ].m_Transparent = true; a_Info[E_BLOCK_LEAVES ].m_Transparent = true; a_Info[E_BLOCK_LEVER ].m_Transparent = true; + a_Info[E_BLOCK_LILY_PAD ].m_Transparent = true; a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_Transparent = true; a_Info[E_BLOCK_MELON_STEM ].m_Transparent = true; - a_Info[E_BLOCK_NETHER_BRICK_FENCE ].m_Transparent = true; + a_Info[E_BLOCK_MOB_SPAWNER ].m_Transparent = true; + a_Info[E_BLOCK_NETHER_PORTAL ].m_Transparent = true; + a_Info[E_BLOCK_NETHER_WART ].m_Transparent = true; a_Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true; + a_Info[E_BLOCK_PISTON ].m_Transparent = true; + a_Info[E_BLOCK_PISTON_EXTENSION ].m_Transparent = true; + a_Info[E_BLOCK_PISTON_MOVED_BLOCK ].m_Transparent = true; a_Info[E_BLOCK_POTATOES ].m_Transparent = true; a_Info[E_BLOCK_POWERED_RAIL ].m_Transparent = true; - a_Info[E_BLOCK_PISTON_EXTENSION ].m_Transparent = true; a_Info[E_BLOCK_PUMPKIN_STEM ].m_Transparent = true; a_Info[E_BLOCK_RAIL ].m_Transparent = true; a_Info[E_BLOCK_RED_MUSHROOM ].m_Transparent = true; + a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_Transparent = true; + a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_Transparent = true; + a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_Transparent = true; + a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_Transparent = true; + a_Info[E_BLOCK_REDSTONE_WIRE ].m_Transparent = true; + a_Info[E_BLOCK_SAPLING ].m_Transparent = true; a_Info[E_BLOCK_SIGN_POST ].m_Transparent = true; a_Info[E_BLOCK_SNOW ].m_Transparent = true; a_Info[E_BLOCK_STAINED_GLASS ].m_Transparent = true; a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_Transparent = true; a_Info[E_BLOCK_STATIONARY_LAVA ].m_Transparent = true; a_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true; + a_Info[E_BLOCK_STICKY_PISTON ].m_Transparent = true; a_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true; a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true; + a_Info[E_BLOCK_STONE_SLAB ].m_Transparent = true; + a_Info[E_BLOCK_SUGARCANE ].m_Transparent = true; + a_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true; + a_Info[E_BLOCK_TORCH ].m_Transparent = true; + a_Info[E_BLOCK_TRAPDOOR ].m_Transparent = true; a_Info[E_BLOCK_TRAPPED_CHEST ].m_Transparent = true; a_Info[E_BLOCK_TRIPWIRE ].m_Transparent = true; a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_Transparent = true; - a_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true; - a_Info[E_BLOCK_TORCH ].m_Transparent = true; a_Info[E_BLOCK_VINES ].m_Transparent = true; a_Info[E_BLOCK_WALLSIGN ].m_Transparent = true; a_Info[E_BLOCK_WATER ].m_Transparent = true; a_Info[E_BLOCK_WOODEN_BUTTON ].m_Transparent = true; a_Info[E_BLOCK_WOODEN_DOOR ].m_Transparent = true; a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_Transparent = true; - - // TODO: Any other transparent blocks? + a_Info[E_BLOCK_WOODEN_SLAB ].m_Transparent = true; // One hit break blocks: @@ -185,10 +286,12 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_CARROTS ].m_OneHitDig = true; a_Info[E_BLOCK_CROPS ].m_OneHitDig = true; a_Info[E_BLOCK_DANDELION ].m_OneHitDig = true; + a_Info[E_BLOCK_DEAD_BUSH ].m_OneHitDig = true; a_Info[E_BLOCK_FIRE ].m_OneHitDig = true; a_Info[E_BLOCK_FLOWER ].m_OneHitDig = true; a_Info[E_BLOCK_FLOWER_POT ].m_OneHitDig = true; a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_OneHitDig = true; + a_Info[E_BLOCK_LILY_PAD ].m_OneHitDig = true; a_Info[E_BLOCK_MELON_STEM ].m_OneHitDig = true; a_Info[E_BLOCK_POTATOES ].m_OneHitDig = true; a_Info[E_BLOCK_PUMPKIN_STEM ].m_OneHitDig = true; @@ -212,24 +315,32 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_BED ].m_PistonBreakable = true; a_Info[E_BLOCK_BIG_FLOWER ].m_PistonBreakable = true; a_Info[E_BLOCK_BROWN_MUSHROOM ].m_PistonBreakable = true; + a_Info[E_BLOCK_CACTUS ].m_PistonBreakable = true; a_Info[E_BLOCK_CAKE ].m_PistonBreakable = true; + a_Info[E_BLOCK_CARROTS ].m_PistonBreakable = true; + a_Info[E_BLOCK_COCOA_POD ].m_PistonBreakable = true; a_Info[E_BLOCK_COBWEB ].m_PistonBreakable = true; a_Info[E_BLOCK_CROPS ].m_PistonBreakable = true; a_Info[E_BLOCK_DANDELION ].m_PistonBreakable = true; a_Info[E_BLOCK_DEAD_BUSH ].m_PistonBreakable = true; + a_Info[E_BLOCK_DRAGON_EGG ].m_PistonBreakable = true; a_Info[E_BLOCK_FIRE ].m_PistonBreakable = true; a_Info[E_BLOCK_FLOWER ].m_PistonBreakable = true; + a_Info[E_BLOCK_FLOWER_POT ].m_PistonBreakable = true; a_Info[E_BLOCK_HEAD ].m_PistonBreakable = true; a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true; a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_PistonBreakable = true; a_Info[E_BLOCK_IRON_DOOR ].m_PistonBreakable = true; a_Info[E_BLOCK_JACK_O_LANTERN ].m_PistonBreakable = true; a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true; + a_Info[E_BLOCK_LILY_PAD ].m_PistonBreakable = true; a_Info[E_BLOCK_LADDER ].m_PistonBreakable = true; a_Info[E_BLOCK_LAVA ].m_PistonBreakable = true; a_Info[E_BLOCK_LEVER ].m_PistonBreakable = true; a_Info[E_BLOCK_MELON ].m_PistonBreakable = true; a_Info[E_BLOCK_MELON_STEM ].m_PistonBreakable = true; + a_Info[E_BLOCK_NETHER_WART ].m_PistonBreakable = true; + a_Info[E_BLOCK_POTATOES ].m_PistonBreakable = true; a_Info[E_BLOCK_PUMPKIN ].m_PistonBreakable = true; a_Info[E_BLOCK_PUMPKIN_STEM ].m_PistonBreakable = true; a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_PistonBreakable = true; @@ -239,6 +350,8 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_REDSTONE_WIRE ].m_PistonBreakable = true; a_Info[E_BLOCK_RED_MUSHROOM ].m_PistonBreakable = true; a_Info[E_BLOCK_REEDS ].m_PistonBreakable = true; + a_Info[E_BLOCK_SAPLING ].m_PistonBreakable = true; + a_Info[E_BLOCK_SIGN_POST ].m_PistonBreakable = true; a_Info[E_BLOCK_SNOW ].m_PistonBreakable = true; a_Info[E_BLOCK_STATIONARY_LAVA ].m_PistonBreakable = true; a_Info[E_BLOCK_STATIONARY_WATER ].m_PistonBreakable = true; @@ -246,61 +359,85 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_PistonBreakable = true; a_Info[E_BLOCK_TALL_GRASS ].m_PistonBreakable = true; a_Info[E_BLOCK_TORCH ].m_PistonBreakable = true; + a_Info[E_BLOCK_TRAPDOOR ].m_PistonBreakable = true; a_Info[E_BLOCK_TRIPWIRE ].m_PistonBreakable = true; a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_PistonBreakable = true; a_Info[E_BLOCK_VINES ].m_PistonBreakable = true; + a_Info[E_BLOCK_WALLSIGN ].m_PistonBreakable = true; a_Info[E_BLOCK_WATER ].m_PistonBreakable = true; a_Info[E_BLOCK_WOODEN_BUTTON ].m_PistonBreakable = true; a_Info[E_BLOCK_WOODEN_DOOR ].m_PistonBreakable = true; a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_PistonBreakable = true; - // Blocks that cannot be snowed over: - a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_IsSnowable = false; - a_Info[E_BLOCK_AIR ].m_IsSnowable = false; - a_Info[E_BLOCK_BIG_FLOWER ].m_IsSnowable = false; - a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSnowable = false; - a_Info[E_BLOCK_CACTUS ].m_IsSnowable = false; - a_Info[E_BLOCK_CHEST ].m_IsSnowable = false; - a_Info[E_BLOCK_CROPS ].m_IsSnowable = false; - a_Info[E_BLOCK_COBBLESTONE_WALL ].m_IsSnowable = false; - a_Info[E_BLOCK_DANDELION ].m_IsSnowable = false; - a_Info[E_BLOCK_FIRE ].m_IsSnowable = false; - a_Info[E_BLOCK_FLOWER ].m_IsSnowable = false; - a_Info[E_BLOCK_GLASS ].m_IsSnowable = false; - a_Info[E_BLOCK_ICE ].m_IsSnowable = false; - a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_IsSnowable = false; - a_Info[E_BLOCK_LAVA ].m_IsSnowable = false; - a_Info[E_BLOCK_LILY_PAD ].m_IsSnowable = false; - a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_IsSnowable = false; - a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_IsSnowable = false; - a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSnowable = false; - a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSnowable = false; - a_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSnowable = false; - a_Info[E_BLOCK_RED_MUSHROOM ].m_IsSnowable = false; - a_Info[E_BLOCK_REEDS ].m_IsSnowable = false; - a_Info[E_BLOCK_SAPLING ].m_IsSnowable = false; - a_Info[E_BLOCK_SIGN_POST ].m_IsSnowable = false; - a_Info[E_BLOCK_SNOW ].m_IsSnowable = false; - a_Info[E_BLOCK_STAINED_GLASS ].m_IsSnowable = false; - a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_IsSnowable = false; - a_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSnowable = false; - a_Info[E_BLOCK_STATIONARY_WATER ].m_IsSnowable = false; - a_Info[E_BLOCK_TALL_GRASS ].m_IsSnowable = false; - a_Info[E_BLOCK_TNT ].m_IsSnowable = false; - a_Info[E_BLOCK_TORCH ].m_IsSnowable = false; - a_Info[E_BLOCK_TRAPPED_CHEST ].m_IsSnowable = false; - a_Info[E_BLOCK_TRIPWIRE ].m_IsSnowable = false; - a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_IsSnowable = false; - a_Info[E_BLOCK_VINES ].m_IsSnowable = false; - a_Info[E_BLOCK_WALLSIGN ].m_IsSnowable = false; - a_Info[E_BLOCK_WATER ].m_IsSnowable = false; - a_Info[E_BLOCK_RAIL ].m_IsSnowable = false; - a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSnowable = false; - a_Info[E_BLOCK_POWERED_RAIL ].m_IsSnowable = false; - a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSnowable = false; - a_Info[E_BLOCK_COBWEB ].m_IsSnowable = false; - a_Info[E_BLOCK_HEAD ].m_IsSnowable = false; + // Blocks that can be snowed over: + a_Info[E_BLOCK_BEDROCK ].m_IsSnowable = true; + a_Info[E_BLOCK_BLOCK_OF_COAL ].m_IsSnowable = true; + a_Info[E_BLOCK_BLOCK_OF_REDSTONE ].m_IsSnowable = true; + a_Info[E_BLOCK_BOOKCASE ].m_IsSnowable = true; + a_Info[E_BLOCK_BRICK ].m_IsSnowable = true; + a_Info[E_BLOCK_CLAY ].m_IsSnowable = true; + a_Info[E_BLOCK_CRAFTING_TABLE ].m_IsSnowable = true; + a_Info[E_BLOCK_COAL_ORE ].m_IsSnowable = true; + a_Info[E_BLOCK_COMMAND_BLOCK ].m_IsSnowable = true; + a_Info[E_BLOCK_COBBLESTONE ].m_IsSnowable = true; + a_Info[E_BLOCK_DIAMOND_BLOCK ].m_IsSnowable = true; + a_Info[E_BLOCK_DIAMOND_ORE ].m_IsSnowable = true; + a_Info[E_BLOCK_DIRT ].m_IsSnowable = true; + a_Info[E_BLOCK_DISPENSER ].m_IsSnowable = true; + a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_IsSnowable = true; + a_Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_IsSnowable = true; + a_Info[E_BLOCK_DROPPER ].m_IsSnowable = true; + a_Info[E_BLOCK_EMERALD_BLOCK ].m_IsSnowable = true; + a_Info[E_BLOCK_EMERALD_ORE ].m_IsSnowable = true; + a_Info[E_BLOCK_END_STONE ].m_IsSnowable = true; + a_Info[E_BLOCK_FURNACE ].m_IsSnowable = true; + a_Info[E_BLOCK_GLOWSTONE ].m_IsSnowable = true; + a_Info[E_BLOCK_GOLD_BLOCK ].m_IsSnowable = true; + a_Info[E_BLOCK_GOLD_ORE ].m_IsSnowable = true; + a_Info[E_BLOCK_GRASS ].m_IsSnowable = true; + a_Info[E_BLOCK_GRAVEL ].m_IsSnowable = true; + a_Info[E_BLOCK_HARDENED_CLAY ].m_IsSnowable = true; + a_Info[E_BLOCK_HAY_BALE ].m_IsSnowable = true; + a_Info[E_BLOCK_HUGE_BROWN_MUSHROOM ].m_IsSnowable = true; + a_Info[E_BLOCK_HUGE_RED_MUSHROOM ].m_IsSnowable = true; + a_Info[E_BLOCK_IRON_BLOCK ].m_IsSnowable = true; + a_Info[E_BLOCK_IRON_ORE ].m_IsSnowable = true; + a_Info[E_BLOCK_JACK_O_LANTERN ].m_IsSnowable = true; + a_Info[E_BLOCK_JUKEBOX ].m_IsSnowable = true; + a_Info[E_BLOCK_LAPIS_BLOCK ].m_IsSnowable = true; + a_Info[E_BLOCK_LAPIS_ORE ].m_IsSnowable = true; + a_Info[E_BLOCK_LEAVES ].m_IsSnowable = true; + a_Info[E_BLOCK_LIT_FURNACE ].m_IsSnowable = true; + a_Info[E_BLOCK_LOG ].m_IsSnowable = true; + a_Info[E_BLOCK_MELON ].m_IsSnowable = true; + a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_IsSnowable = true; + a_Info[E_BLOCK_MYCELIUM ].m_IsSnowable = true; + a_Info[E_BLOCK_NETHER_BRICK ].m_IsSnowable = true; + a_Info[E_BLOCK_NETHER_QUARTZ_ORE ].m_IsSnowable = true; + a_Info[E_BLOCK_NETHERRACK ].m_IsSnowable = true; + a_Info[E_BLOCK_NEW_LEAVES ].m_IsSnowable = true; + a_Info[E_BLOCK_NEW_LOG ].m_IsSnowable = true; + a_Info[E_BLOCK_NOTE_BLOCK ].m_IsSnowable = true; + a_Info[E_BLOCK_OBSIDIAN ].m_IsSnowable = true; + a_Info[E_BLOCK_PLANKS ].m_IsSnowable = true; + a_Info[E_BLOCK_PUMPKIN ].m_IsSnowable = true; + a_Info[E_BLOCK_QUARTZ_BLOCK ].m_IsSnowable = true; + a_Info[E_BLOCK_REDSTONE_LAMP_OFF ].m_IsSnowable = true; + a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_IsSnowable = true; + a_Info[E_BLOCK_REDSTONE_ORE ].m_IsSnowable = true; + a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_IsSnowable = true; + a_Info[E_BLOCK_SAND ].m_IsSnowable = true; + a_Info[E_BLOCK_SANDSTONE ].m_IsSnowable = true; + a_Info[E_BLOCK_SILVERFISH_EGG ].m_IsSnowable = true; + a_Info[E_BLOCK_SNOW_BLOCK ].m_IsSnowable = true; + a_Info[E_BLOCK_SOULSAND ].m_IsSnowable = true; + a_Info[E_BLOCK_SPONGE ].m_IsSnowable = true; + a_Info[E_BLOCK_STAINED_CLAY ].m_IsSnowable = true; + a_Info[E_BLOCK_STONE ].m_IsSnowable = true; + a_Info[E_BLOCK_STONE_BRICKS ].m_IsSnowable = true; + a_Info[E_BLOCK_TNT ].m_IsSnowable = true; + a_Info[E_BLOCK_WOOL ].m_IsSnowable = true; // Blocks that don't drop without a special tool: @@ -323,6 +460,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_IRON_ORE ].m_RequiresSpecialTool = true; a_Info[E_BLOCK_LAPIS_BLOCK ].m_RequiresSpecialTool = true; a_Info[E_BLOCK_LAPIS_ORE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_LEAVES ].m_RequiresSpecialTool = true; a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true; a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_RequiresSpecialTool = true; a_Info[E_BLOCK_NETHERRACK ].m_RequiresSpecialTool = true; @@ -347,15 +485,21 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) // Nonsolid blocks: + a_Info[E_BLOCK_ACACIA_WOOD_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false; a_Info[E_BLOCK_AIR ].m_IsSolid = false; a_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false; + a_Info[E_BLOCK_BIRCH_WOOD_STAIRS ].m_IsSolid = false; + a_Info[E_BLOCK_BRICK_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false; a_Info[E_BLOCK_CAKE ].m_IsSolid = false; + a_Info[E_BLOCK_CARPET ].m_IsSolid = false; a_Info[E_BLOCK_CARROTS ].m_IsSolid = false; + a_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_COBWEB ].m_IsSolid = false; a_Info[E_BLOCK_CROPS ].m_IsSolid = false; a_Info[E_BLOCK_DANDELION ].m_IsSolid = false; + a_Info[E_BLOCK_DARK_OAK_WOOD_STAIRS].m_IsSolid = false; a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false; a_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false; a_Info[E_BLOCK_FENCE ].m_IsSolid = false; @@ -363,24 +507,30 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_FIRE ].m_IsSolid = false; a_Info[E_BLOCK_FLOWER ].m_IsSolid = false; a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false; + a_Info[E_BLOCK_JUNGLE_WOOD_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_LAVA ].m_IsSolid = false; a_Info[E_BLOCK_LEVER ].m_IsSolid = false; a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false; a_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false; + a_Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false; a_Info[E_BLOCK_POTATOES ].m_IsSolid = false; a_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false; + a_Info[E_BLOCK_QUARTZ_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_RAIL ].m_IsSolid = false; a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSolid = false; a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSolid = false; a_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSolid = false; a_Info[E_BLOCK_RED_MUSHROOM ].m_IsSolid = false; a_Info[E_BLOCK_REEDS ].m_IsSolid = false; + a_Info[E_BLOCK_SANDSTONE_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_SAPLING ].m_IsSolid = false; a_Info[E_BLOCK_SIGN_POST ].m_IsSolid = false; a_Info[E_BLOCK_SNOW ].m_IsSolid = false; + a_Info[E_BLOCK_SPRUCE_WOOD_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSolid = false; a_Info[E_BLOCK_STATIONARY_WATER ].m_IsSolid = false; + a_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_STONE_BUTTON ].m_IsSolid = false; a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_IsSolid = false; a_Info[E_BLOCK_TALL_GRASS ].m_IsSolid = false; @@ -392,6 +542,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false; a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false; a_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false; + a_Info[E_BLOCK_WOODEN_STAIRS ].m_IsSolid = false; // Blocks that fully occupy their voxel - used as a guide for torch placeable blocks, amongst other things: @@ -455,9 +606,9 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_SILVERFISH_EGG ].m_FullyOccupiesVoxel = true; a_Info[E_BLOCK_SPONGE ].m_FullyOccupiesVoxel = true; a_Info[E_BLOCK_STAINED_CLAY ].m_FullyOccupiesVoxel = true; - a_Info[E_BLOCK_WOOL ].m_FullyOccupiesVoxel = true; a_Info[E_BLOCK_STONE ].m_FullyOccupiesVoxel = true; a_Info[E_BLOCK_STONE_BRICKS ].m_FullyOccupiesVoxel = true; + a_Info[E_BLOCK_WOOL ].m_FullyOccupiesVoxel = true; } diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index 27a44d829..1c8ac6a35 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -94,7 +94,6 @@ private: switch (a_BlockType) { case E_BLOCK_ANVIL: - case E_BLOCK_BED: case E_BLOCK_BEDROCK: case E_BLOCK_BREWING_STAND: case E_BLOCK_CHEST: -- cgit v1.2.3 From 57f4e871bb820beaf56ee48e762a1ee276aa8afe Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 15 Jul 2014 12:52:02 +0100 Subject: Fixed FindClosestPlayer --- src/World.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/World.cpp b/src/World.cpp index ba8add8f0..bd3613ce2 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2468,10 +2468,13 @@ cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, if (Distance < ClosestDistance) { - if (a_CheckLineOfSight && !LineOfSight.Trace(a_Pos,(Pos - a_Pos),(int)(Pos - a_Pos).Length())) + if (a_CheckLineOfSight) { - ClosestDistance = Distance; - ClosestPlayer = *itr; + if(!LineOfSight.Trace(a_Pos,(Pos - a_Pos),(int)(Pos - a_Pos).Length())) + { + ClosestDistance = Distance; + ClosestPlayer = *itr; + } } else { -- cgit v1.2.3 From 7f4029f8f4b9b0c0b711c631ce704a3bbcb6e990 Mon Sep 17 00:00:00 2001 From: Masy98 Date: Tue, 15 Jul 2014 14:06:03 +0200 Subject: Added Brick fence to m_Transparent --- src/BlockInfo.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 04859e586..d902ea4a6 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -236,6 +236,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_Transparent = true; a_Info[E_BLOCK_MELON_STEM ].m_Transparent = true; a_Info[E_BLOCK_MOB_SPAWNER ].m_Transparent = true; + a_Info[E_BLOCK_NETHER_BRICK_FENCE ].m_Transparent = true; a_Info[E_BLOCK_NETHER_PORTAL ].m_Transparent = true; a_Info[E_BLOCK_NETHER_WART ].m_Transparent = true; a_Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true; -- cgit v1.2.3 From 9a970479efaef781ea8f69e3d8b8a1e2aa367847 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 14:54:24 +0200 Subject: Fixed code formatting. --- src/Blocks/BlockLilypad.h | 7 ++++--- src/Blocks/BlockPumpkin.h | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h index 1320174fc..53277caa5 100644 --- a/src/Blocks/BlockLilypad.h +++ b/src/Blocks/BlockLilypad.h @@ -10,10 +10,11 @@ class cBlockLilypadHandler : public cClearMetaOnDrop { -typedef cClearMetaOnDrop super; + typedef cClearMetaOnDrop super; public: - cBlockLilypadHandler(BLOCKTYPE a_BlockType) - : super(a_BlockType) + + cBlockLilypadHandler(BLOCKTYPE a_BlockType) : + super(a_BlockType) { } }; diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h index d2e9d7843..4692a47df 100644 --- a/src/Blocks/BlockPumpkin.h +++ b/src/Blocks/BlockPumpkin.h @@ -8,12 +8,14 @@ class cBlockPumpkinHandler : public cClearMetaOnDrop > { -typedef cClearMetaOnDrop > super; + typedef cClearMetaOnDrop > super; public: - cBlockPumpkinHandler(BLOCKTYPE a_BlockType) - : super(a_BlockType) + + cBlockPumpkinHandler(BLOCKTYPE a_BlockType) : + super(a_BlockType) { } + virtual void OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override { -- cgit v1.2.3 From 74b6bf01a9932b12cb4ce6588086bfb00bf305a0 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 15 Jul 2014 18:33:28 +0200 Subject: Derp. --- src/ChunkMap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index d25f6d64b..9bc3e5c49 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1854,14 +1854,14 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_ case E_BLOCK_STATIONARY_WATER: { // Turn into simulated water: - area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_WATER, 0); + area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_WATER); break; } case E_BLOCK_STATIONARY_LAVA: { // Turn into simulated lava: - area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_LAVA, 0); + area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_LAVA); break; } -- cgit v1.2.3 From d272e468212b2956f419fd1b595329f994151944 Mon Sep 17 00:00:00 2001 From: Masy98 Date: Tue, 15 Jul 2014 20:32:49 +0200 Subject: Removed Stairs and carpet from the "isSolid" list to prevent mobs falling through them. --- src/BlockInfo.cpp | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index d902ea4a6..548b87ca8 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -486,21 +486,16 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) // Nonsolid blocks: - a_Info[E_BLOCK_ACACIA_WOOD_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false; a_Info[E_BLOCK_AIR ].m_IsSolid = false; a_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false; - a_Info[E_BLOCK_BIRCH_WOOD_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_BRICK_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false; a_Info[E_BLOCK_CAKE ].m_IsSolid = false; - a_Info[E_BLOCK_CARPET ].m_IsSolid = false; a_Info[E_BLOCK_CARROTS ].m_IsSolid = false; - a_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_COBWEB ].m_IsSolid = false; a_Info[E_BLOCK_CROPS ].m_IsSolid = false; a_Info[E_BLOCK_DANDELION ].m_IsSolid = false; - a_Info[E_BLOCK_DARK_OAK_WOOD_STAIRS].m_IsSolid = false; a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false; a_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false; a_Info[E_BLOCK_FENCE ].m_IsSolid = false; @@ -508,30 +503,24 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_FIRE ].m_IsSolid = false; a_Info[E_BLOCK_FLOWER ].m_IsSolid = false; a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false; - a_Info[E_BLOCK_JUNGLE_WOOD_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_LAVA ].m_IsSolid = false; a_Info[E_BLOCK_LEVER ].m_IsSolid = false; a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false; a_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false; - a_Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false; a_Info[E_BLOCK_POTATOES ].m_IsSolid = false; a_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false; - a_Info[E_BLOCK_QUARTZ_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_RAIL ].m_IsSolid = false; a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSolid = false; a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSolid = false; a_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSolid = false; a_Info[E_BLOCK_RED_MUSHROOM ].m_IsSolid = false; a_Info[E_BLOCK_REEDS ].m_IsSolid = false; - a_Info[E_BLOCK_SANDSTONE_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_SAPLING ].m_IsSolid = false; a_Info[E_BLOCK_SIGN_POST ].m_IsSolid = false; a_Info[E_BLOCK_SNOW ].m_IsSolid = false; - a_Info[E_BLOCK_SPRUCE_WOOD_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSolid = false; a_Info[E_BLOCK_STATIONARY_WATER ].m_IsSolid = false; - a_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_STONE_BUTTON ].m_IsSolid = false; a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_IsSolid = false; a_Info[E_BLOCK_TALL_GRASS ].m_IsSolid = false; @@ -543,7 +532,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false; a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false; a_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false; - a_Info[E_BLOCK_WOODEN_STAIRS ].m_IsSolid = false; // Blocks that fully occupy their voxel - used as a guide for torch placeable blocks, amongst other things: -- cgit v1.2.3 From b5794517315f3e08d847332111537068e2b8af53 Mon Sep 17 00:00:00 2001 From: Masy98 Date: Tue, 15 Jul 2014 20:34:49 +0200 Subject: Removed Stairs and carpet from the "isSolid" list to prevent mobs falling through them. --- src/BlockInfo.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 548b87ca8..b4b98a2f0 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -489,7 +489,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false; a_Info[E_BLOCK_AIR ].m_IsSolid = false; a_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false; - a_Info[E_BLOCK_BRICK_STAIRS ].m_IsSolid = false; a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false; a_Info[E_BLOCK_CAKE ].m_IsSolid = false; a_Info[E_BLOCK_CARROTS ].m_IsSolid = false; -- cgit v1.2.3 From cc452f51c8c4e1c886932d2f7965c7b3e4ab42fe Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 22:41:42 +0200 Subject: Restructured cSplashPotionEntity code. The callback doesn't need declaration in the header. Renamed PotionName to PotionParticleType. --- src/Entities/EntityEffect.h | 19 ++++-- src/Entities/SplashPotionEntity.cpp | 107 ++++++++++++++++++++------------ src/Entities/SplashPotionEntity.h | 46 ++++++-------- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- src/WorldStorage/WSSAnvil.cpp | 2 +- 5 files changed, 104 insertions(+), 72 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index a06c1512d..ebd611ff0 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -7,7 +7,7 @@ class cEntityEffect { public: - /** All types of entity effects (numbers correspond to IDs) */ + /** All types of entity effects (numbers correspond to protocol / storage types) */ enum eType { effNoEffect = 0, @@ -66,21 +66,30 @@ public: static cEntityEffect * CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier); /** Returns how many ticks this effect has been active for */ - int GetTicks() { return m_Ticks; } + int GetTicks(void) const { return m_Ticks; } + /** Returns the duration of the effect */ - int GetDuration() { return m_Duration; } + int GetDuration(void) const { return m_Duration; } + /** Returns how strong the effect will be applied */ - short GetIntensity() { return m_Intensity; } + short GetIntensity(void) const { return m_Intensity; } + /** Returns the distance modifier for affecting potency */ - double GetDistanceModifier() { return m_DistanceModifier; } + double GetDistanceModifier(void) const { return m_DistanceModifier; } void SetTicks(int a_Ticks) { m_Ticks = a_Ticks; } void SetDuration(int a_Duration) { m_Duration = a_Duration; } void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; } void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; } + /** Called on each tick. + By default increases the m_Ticks, descendants may override to provide additional processing. */ virtual void OnTick(cPawn & a_Target); + + /** Called when the effect is first added to an entity */ virtual void OnActivate(cPawn & a_Target) { } + + /** Called when the effect is removed from an entity */ virtual void OnDeactivate(cPawn & a_Target) { } protected: diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index e84f1c430..804026cc0 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -7,11 +7,77 @@ -cSplashPotionEntity::cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName) : +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cSplashPotionEntityCallback: + +/** Used to distribute the splashed potion effect among nearby entities */ +class cSplashPotionCallback : + public cEntityCallback +{ +public: + /** Creates the callback. + @param a_HitPos The position where the splash potion has splashed + @param a_EntityEffectType The effect type of the potion + @param a_EntityEffect The effect description */ + cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType a_EntityEffectType, const cEntityEffect & a_EntityEffect) : + m_HitPos(a_HitPos), + m_EntityEffectType(a_EntityEffectType), + m_EntityEffect(a_EntityEffect) + { + } + + /** Called by cWorld::ForEachEntity(), adds the stored entity effect to the entity, if it is close enough. */ + virtual bool Item(cEntity * a_Entity) override + { + double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length(); + if (SplashDistance >= 20) + { + // Too far away + return false; + } + if (!a_Entity->IsPawn()) + { + // Not an entity that can take effects + return false; + } + + // y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash. + // TODO: better equation + double Reduction = -0.25 * SplashDistance + 1.0; + if (Reduction < 0) + { + Reduction = 0; + } + + ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction); + return false; + } + +private: + const Vector3d & m_HitPos; + cEntityEffect::eType m_EntityEffectType; + const cEntityEffect & m_EntityEffect; +}; + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cSplashPotionEntity: + +cSplashPotionEntity::cSplashPotionEntity( + cEntity * a_Creator, + double a_X, double a_Y, double a_Z, + const Vector3d & a_Speed, + cEntityEffect::eType a_EntityEffectType, + cEntityEffect a_EntityEffect, + int a_PotionParticleType +) : super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), m_EntityEffectType(a_EntityEffectType), m_EntityEffect(a_EntityEffect), - m_PotionName(a_PotionName) + m_PotionParticleType(a_PotionParticleType) { SetSpeed(a_Speed); } @@ -46,42 +112,7 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect); m_World->ForEachEntity(Callback); - m_World->BroadcastSoundParticleEffect(2002, a_HitPos.x, a_HitPos.y, a_HitPos.z, m_PotionName); -} - - - - - -cSplashPotionEntity::cSplashPotionCallback::cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect): - m_HitPos(a_HitPos), - m_EntityEffectType(a_EntityEffectType), - m_EntityEffect(a_EntityEffect) -{ - -} - - - - - -bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity) -{ - double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length(); - if (SplashDistance < 20 && a_Entity->IsPawn()) - { - // y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash. - // TODO: better equation - double Reduction = -0.25 * SplashDistance + 1.0; - if (Reduction < 0) - { - Reduction = 0; - } - - m_EntityEffect.SetDistanceModifier(Reduction); - ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction); - } - return false; + m_World->BroadcastSoundParticleEffect(2002, a_HitPos.x, a_HitPos.y, a_HitPos.z, m_PotionParticleType); } diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index ad656d8ab..076e477da 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -25,43 +25,35 @@ public: CLASS_PROTODEF(cSplashPotionEntity); - cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName); - - cEntityEffect::eType GetEntityEffectType() { return m_EntityEffectType; } - cEntityEffect GetEntityEffect() { return m_EntityEffect; } - int GetPotionName() { return m_PotionName; } + cSplashPotionEntity( + cEntity * a_Creator, + double a_X, double a_Y, double a_Z, + const Vector3d & a_Speed, + cEntityEffect::eType a_EntityEffectType, + cEntityEffect a_EntityEffect, + int a_PotionParticleType + ); + + cEntityEffect::eType GetEntityEffectType (void) const { return m_EntityEffectType; } + cEntityEffect GetEntityEffect (void) const { return m_EntityEffect; } + int GetPotionParticleType(void) const { return m_PotionParticleType; } void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; } void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; } - void SetPotionName(int a_PotionName) { m_PotionName = a_PotionName; } + void SetPotionParticleType(int a_PotionParticleType) { m_PotionParticleType = a_PotionParticleType; } protected: + cEntityEffect::eType m_EntityEffectType; + cEntityEffect m_EntityEffect; + int m_PotionParticleType; + + // cProjectileEntity overrides: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; /** Splashes the potion, fires its particle effects and sounds - * @param a_HitPos The position where the potion will splash - */ + @param a_HitPos The position where the potion will splash */ void Splash(const Vector3d & a_HitPos); - - cEntityEffect::eType m_EntityEffectType; - cEntityEffect m_EntityEffect; - int m_PotionName; - - class cSplashPotionCallback : - public cEntityCallback - { - public: - cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect); - - virtual bool Item(cEntity *a_Entity) override; - - private: - const Vector3d &m_HitPos; - cEntityEffect::eType &m_EntityEffectType; - cEntityEffect &m_EntityEffect; - }; - } ; // tolua_export diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 82c8df947..6d0b60371 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -613,7 +613,7 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) m_Writer.AddInt("EffectDuration", (Int16)Potion->GetEntityEffect().GetDuration()); m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity()); m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier()); - m_Writer.AddInt("PotionName", Potion->GetPotionName()); + m_Writer.AddInt("PotionName", Potion->GetPotionParticleType()); } case cProjectileEntity::pkGhastFireball: { diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 0319173f8..1a43cf4ba 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1681,7 +1681,7 @@ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedN SplashPotion->SetEntityEffectType((cEntityEffect::eType) a_NBT.FindChildByName(a_TagIdx, "EffectType")); SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, EffectIntensity, EffectDistanceModifier)); - SplashPotion->SetPotionName(a_NBT.FindChildByName(a_TagIdx, "PotionName")); + SplashPotion->SetPotionParticleType(a_NBT.FindChildByName(a_TagIdx, "PotionName")); // Store the new splash potion in the entities list: a_Entities.push_back(SplashPotion.release()); -- cgit v1.2.3 From 1df5a1f237cd4b620ada8aa9706d052ec54f1519 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 15 Jul 2014 22:53:44 +0100 Subject: Fixed a DropSpenser AddFace bug --- src/BlockEntities/DropSpenserEntity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp index 0012742fb..108c2ce1b 100644 --- a/src/BlockEntities/DropSpenserEntity.cpp +++ b/src/BlockEntities/DropSpenserEntity.cpp @@ -42,7 +42,7 @@ cDropSpenserEntity::~cDropSpenserEntity() void cDropSpenserEntity::AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction) { - switch (a_Direction) + switch (a_Direction & 0x07) // Vanilla uses the 8th bit to determine power state - we don't { case E_META_DROPSPENSER_FACING_YM: a_BlockY--; return; case E_META_DROPSPENSER_FACING_YP: a_BlockY++; return; -- cgit v1.2.3 From 1f6854792cdd6792b27c4f9f3d7d857df9dd64bf Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 00:03:47 +0100 Subject: Store properties as Json::Value --- src/ClientHandle.cpp | 2 +- src/ClientHandle.h | 11 +++++++---- src/Protocol/Authenticator.cpp | 15 ++++++++++----- src/Protocol/Authenticator.h | 9 ++++++++- src/Protocol/Protocol17x.cpp | 8 ++------ src/Root.cpp | 2 +- src/Root.h | 7 ++++++- src/Server.cpp | 2 +- src/Server.h | 9 ++++++++- 9 files changed, 44 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index fcd8d2bcd..c749d41ab 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -290,7 +290,7 @@ void cClientHandle::Kick(const AString & a_Reason) -void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, const AString & a_Properties) +void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties) { if (m_State != csAuthenticating) { diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 478da5b3c..7bd286a05 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -20,6 +20,7 @@ #include "Map.h" #include "Enchantments.h" #include "UI/SlotArea.h" +#include "json/json.h" @@ -68,7 +69,7 @@ public: const AString & GetUUID(void) const { return m_UUID; } // tolua_export void SetUUID(const AString & a_UUID) { m_UUID = a_UUID; } - const AString & GetProperties(void) const { return m_Properties; } + const Json::Value & GetProperties(void) const { return m_Properties; } /** Generates an UUID based on the username stored for this client, and stores it in the m_UUID member. This is used for the offline (non-auth) mode, when there's no UUID source. @@ -93,8 +94,10 @@ public: static AString FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2); - void Kick(const AString & a_Reason); // tolua_export - void Authenticate(const AString & a_Name, const AString & a_UUID, const AString & a_Properties); // Called by cAuthenticator when the user passes authentication + void Kick(const AString & a_Reason); // tolua_export + + /** Authenticates the specified user, called by cAuthenticator */ + void Authenticate(const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties); void StreamChunks(void); @@ -282,7 +285,7 @@ private: AString m_Username; AString m_Password; - AString m_Properties; + Json::Value m_Properties; cCriticalSection m_CSChunkLists; cChunkCoordsList m_LoadedChunks; // Chunks that the player belongs to diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index 8fd8952e8..c01d748c6 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -115,7 +115,8 @@ void cAuthenticator::Authenticate(int a_ClientID, const AString & a_UserName, co { if (!m_ShouldAuthenticate) { - cRoot::Get()->AuthenticateUser(a_ClientID, a_UserName, cClientHandle::GenerateOfflineUUID(a_UserName)); + Json::Value Value; + cRoot::Get()->AuthenticateUser(a_ClientID, a_UserName, cClientHandle::GenerateOfflineUUID(a_UserName), Value); return; } @@ -177,7 +178,7 @@ void cAuthenticator::Execute(void) AString UUID; if (AuthWithYggdrasil(NewUserName, ServerID, UUID)) { - AString Properties; + Json::Value Properties; if (!GetPlayerProperties(UUID, Properties)) { LOGINFO("User %s authenticated with UUID %s but property getting failed", NewUserName.c_str(), UUID.c_str()); @@ -329,7 +330,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S -bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, AString & a_Properties) +bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties) { LOGD("Trying to get properties for user %s", a_UUID.c_str()); @@ -383,6 +384,10 @@ bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, AString & a_Pro return false; } - a_Properties = root["properties"].toStyledString(); + a_Properties = root["properties"]; return true; -} \ No newline at end of file +} + + + + diff --git a/src/Protocol/Authenticator.h b/src/Protocol/Authenticator.h index 04fa3e09c..9f6dd60ca 100644 --- a/src/Protocol/Authenticator.h +++ b/src/Protocol/Authenticator.h @@ -23,6 +23,11 @@ // fwd: "cRoot.h" class cRoot; +namespace Json +{ + class Value; +} + @@ -79,12 +84,14 @@ private: /** cIsThread override: */ virtual void Execute(void) override; + /** Connects to a hostname using SSL, sends given data, and sets the response, returning whether all was successful or not */ bool ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response); /** Returns true if the user authenticated okay, false on error; iLevel is the recursion deptht (bails out if too deep) */ bool AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID); - bool GetPlayerProperties(const AString & a_UUID, AString & a_Properties); + /** Gets the properties, such as skin, of a player based on their UUID via Mojang's API */ + bool GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties); }; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index ae800e9cf..d3b1cf946 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -3016,12 +3016,8 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player) Pkt.WriteString(a_Player.GetClientHandle()->GetUUID()); Pkt.WriteString(a_Player.GetName()); - Json::Value root; - Json::Reader reader; - reader.parse(m_Client->GetProperties(), root); - - Pkt.WriteVarInt(root.size()); - for (Json::Value::iterator itr = root.begin(); itr != root.end(); ++itr) + Pkt.WriteVarInt(m_Client->GetProperties().size()); + for (Json::Value::iterator itr = m_Client->GetProperties().begin(); itr != m_Client->GetProperties().end(); ++itr) { Pkt.WriteString(((Json::Value)*itr).get("name", "").toStyledString()); Pkt.WriteString(((Json::Value)*itr).get("value", "").toStyledString()); diff --git a/src/Root.cpp b/src/Root.cpp index c578fe6a3..ec1351ef1 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -499,7 +499,7 @@ void cRoot::KickUser(int a_ClientID, const AString & a_Reason) -void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties) +void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties) { m_Server->AuthenticateUser(a_ClientID, a_Name, a_UUID, a_Properties); } diff --git a/src/Root.h b/src/Root.h index a9e985656..4a3c205d3 100644 --- a/src/Root.h +++ b/src/Root.h @@ -26,6 +26,11 @@ class cCompositeChat; typedef cItemCallback cPlayerListCallback; typedef cItemCallback cWorldListCallback; +namespace Json +{ + class Value; +} + @@ -89,7 +94,7 @@ public: void KickUser(int a_ClientID, const AString & a_Reason); /// Called by cAuthenticator to auth the specified user - void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties = ""); + void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties); /// Executes commands queued in the command queue void TickCommands(void); diff --git a/src/Server.cpp b/src/Server.cpp index 8b479292e..17551eeb1 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -656,7 +656,7 @@ void cServer::KickUser(int a_ClientID, const AString & a_Reason) -void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties) +void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties) { cCSLock Lock(m_CSClients); for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr) diff --git a/src/Server.h b/src/Server.h index 672dc26c0..cf5fa524f 100644 --- a/src/Server.h +++ b/src/Server.h @@ -41,6 +41,11 @@ class cCommandOutputCallback; typedef std::list cClientHandleList; +namespace Json +{ + class Value; +} + @@ -83,7 +88,9 @@ public: // tolua_export void Shutdown(void); void KickUser(int a_ClientID, const AString & a_Reason); - void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties); // Called by cAuthenticator to auth the specified user + + /** Authenticates the specified user, called by cAuthenticator */ + void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties); const AString & GetServerID(void) const { return m_ServerID; } // tolua_export -- cgit v1.2.3 From f2c4f56ccd1862fb6d02f6f2dfb3230123f465cf Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 11:21:02 +0100 Subject: Unified functions Thanks @Howaner! --- src/Protocol/Authenticator.cpp | 51 +++++++++++++++++++----------------------- src/Protocol/Authenticator.h | 11 +++++---- 2 files changed, 28 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index c01d748c6..28df0f882 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -17,7 +17,6 @@ #define DEFAULT_AUTH_SERVER "sessionserver.mojang.com" #define DEFAULT_AUTH_ADDRESS "/session/minecraft/hasJoined?username=%USERNAME%&serverId=%SERVERID%" -#define DEFAULT_PROPERTIES_ADDRESS "/session/minecraft/profile/%UUID%" /** This is the data of the root certs for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert: Downloaded from http://certs.starfieldtech.com/repository/ */ @@ -81,7 +80,6 @@ cAuthenticator::cAuthenticator(void) : super("cAuthenticator"), m_Server(DEFAULT_AUTH_SERVER), m_Address(DEFAULT_AUTH_ADDRESS), - m_PropertiesAddress(DEFAULT_PROPERTIES_ADDRESS), m_ShouldAuthenticate(true) { } @@ -103,7 +101,6 @@ void cAuthenticator::ReadINI(cIniFile & IniFile) { m_Server = IniFile.GetValueSet("Authentication", "Server", DEFAULT_AUTH_SERVER); m_Address = IniFile.GetValueSet("Authentication", "Address", DEFAULT_AUTH_ADDRESS); - m_PropertiesAddress = IniFile.GetValueSet("Authentication", "PlayerPropertiesAddress", DEFAULT_PROPERTIES_ADDRESS); m_ShouldAuthenticate = IniFile.GetValueSetB("Authentication", "Authenticate", true); } @@ -176,27 +173,10 @@ void cAuthenticator::Execute(void) AString NewUserName = UserName; AString UUID; - if (AuthWithYggdrasil(NewUserName, ServerID, UUID)) + Json::Value Properties; + if (AuthWithYggdrasil(NewUserName, ServerID, UUID, Properties)) { - Json::Value Properties; - if (!GetPlayerProperties(UUID, Properties)) - { - LOGINFO("User %s authenticated with UUID %s but property getting failed", NewUserName.c_str(), UUID.c_str()); - } - else - { - LOGINFO("User %s authenticated with UUID %s", NewUserName.c_str(), UUID.c_str()); - } - - // If the UUID doesn't contain the hashes, insert them at the proper places: - if (UUID.size() == 32) - { - UUID.insert(8, "-"); - UUID.insert(13, "-"); - UUID.insert(18, "-"); - UUID.insert(23, "-"); - } - + LOGINFO("User %s authenticated with UUID %s", NewUserName.c_str(), UUID.c_str()); cRoot::Get()->AuthenticateUser(ClientID, NewUserName, UUID, Properties); } else @@ -266,7 +246,7 @@ bool cAuthenticator::ConnectSecurelyToAddress(const AString & a_CACerts, const A -bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID) +bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID, Json::Value & a_Properties) { LOGD("Trying to authenticate user %s", a_UserName.c_str()); @@ -322,6 +302,16 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S } a_UserName = root.get("name", "Unknown").asString(); a_UUID = root.get("id", "").asString(); + a_Properties = root["properties"]; + + // If the UUID doesn't contain the hashes, insert them at the proper places: + if (a_UUID.size() == 32) + { + a_UUID.insert(8, "-"); + a_UUID.insert(13, "-"); + a_UUID.insert(18, "-"); + a_UUID.insert(23, "-"); + } return true; } @@ -330,6 +320,13 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S +/* In case we want to export this function to the plugin API later - don't forget to add the relevant INI configuration lines for DEFAULT_PROPERTIES_ADDRESS + +#define DEFAULT_PROPERTIES_ADDRESS "/session/minecraft/profile/%UUID%" + +// Gets the properties, such as skin, of a player based on their UUID via Mojang's API +bool GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties); + bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties) { LOGD("Trying to get properties for user %s", a_UUID.c_str()); @@ -376,6 +373,7 @@ bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, Json::Value & a { return false; } + Json::Value root; Json::Reader reader; if (!reader.parse(Response, root, false)) @@ -387,7 +385,4 @@ bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, Json::Value & a a_Properties = root["properties"]; return true; } - - - - +*/ diff --git a/src/Protocol/Authenticator.h b/src/Protocol/Authenticator.h index 9f6dd60ca..9c2405315 100644 --- a/src/Protocol/Authenticator.h +++ b/src/Protocol/Authenticator.h @@ -85,13 +85,12 @@ private: virtual void Execute(void) override; /** Connects to a hostname using SSL, sends given data, and sets the response, returning whether all was successful or not */ - bool ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response); + bool ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Request, AString & a_Response); - /** Returns true if the user authenticated okay, false on error; iLevel is the recursion deptht (bails out if too deep) */ - bool AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID); - - /** Gets the properties, such as skin, of a player based on their UUID via Mojang's API */ - bool GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties); + /** Returns true if the user authenticated okay, false on error + Sets the username, UUID, and properties (i.e. skin) fields + */ + bool AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID, Json::Value & a_Properties); }; -- cgit v1.2.3 From ad247735fdd28f9dec6c8e86507bc7e75e50e448 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 11:23:26 +0100 Subject: Function rename --- src/Protocol/Authenticator.cpp | 4 ++-- src/Protocol/Authenticator.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index 28df0f882..001bc29cf 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -190,7 +190,7 @@ void cAuthenticator::Execute(void) -bool cAuthenticator::ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response) +bool cAuthenticator::SecureGetFromAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response) { // Connect the socket: cBlockingSslClientSocket Socket; @@ -263,7 +263,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S Request += "\r\n"; AString Response; - if (!ConnectSecurelyToAddress(gStarfieldCACert, m_Server, Request, Response)) + if (!SecureGetFromAddress(gStarfieldCACert, m_Server, Request, Response)) { return false; } diff --git a/src/Protocol/Authenticator.h b/src/Protocol/Authenticator.h index 9c2405315..244d94c0b 100644 --- a/src/Protocol/Authenticator.h +++ b/src/Protocol/Authenticator.h @@ -85,7 +85,7 @@ private: virtual void Execute(void) override; /** Connects to a hostname using SSL, sends given data, and sets the response, returning whether all was successful or not */ - bool ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Request, AString & a_Response); + bool SecureGetFromAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Request, AString & a_Response); /** Returns true if the user authenticated okay, false on error Sets the username, UUID, and properties (i.e. skin) fields -- cgit v1.2.3 From 2189f37c20198a5889d5477aa4abcc116437861d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 11:38:52 +0100 Subject: Resolved backwards compatibility issues --- src/Bindings/Plugin.h | 2 +- src/Bindings/PluginLua.cpp | 4 ++-- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 4 ++-- src/Bindings/PluginManager.h | 2 +- src/Entities/Entity.cpp | 2 +- src/Mobs/IronGolem.h | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 160e83bde..5c933e095 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -63,7 +63,7 @@ public: virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) = 0; virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) = 0; virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) = 0; - virtual bool OnKilling (cEntity & a_Victim, TakeDamageInfo & a_TDI) = 0; + virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) = 0; virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) = 0; virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) = 0; virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 078e48111..e65329f23 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -575,14 +575,14 @@ bool cPluginLua::OnHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper, -bool cPluginLua::OnKilling(cEntity & a_Victim, TakeDamageInfo & a_TDI) +bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) { cCSLock Lock(m_CriticalSection); bool res = false; cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_KILLING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Victim, &a_TDI, cLuaState::Return, res); + m_LuaState.Call((int)(**itr), &a_Victim, a_Killer, &a_TDI, cLuaState::Return, res); if (res) { return true; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index d1514a731..7a8a69b68 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -86,7 +86,7 @@ public: virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) override; virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) override; virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) override; - virtual bool OnKilling (cEntity & a_Victim, TakeDamageInfo & a_TDI) override; + virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) override; virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) override; virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override; virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 1ebe8dd68..11d8bf4f1 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -562,14 +562,14 @@ bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity & -bool cPluginManager::CallHookKilling(cEntity & a_Victim, TakeDamageInfo & a_TDI) +bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) { FIND_HOOK(HOOK_KILLING); VERIFY_HOOK; for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnKilling(a_Victim, a_TDI)) + if ((*itr)->OnKilling(a_Victim, a_Killer, a_TDI)) { return true; } diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 7d63626bd..cd6287e64 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -180,7 +180,7 @@ public: // tolua_export bool CallHookHandshake (cClientHandle * a_ClientHandle, const AString & a_Username); bool CallHookHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum); bool CallHookHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum); - bool CallHookKilling (cEntity & a_Victim, TakeDamageInfo & a_TDI); + bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI); bool CallHookLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username); bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation); bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 56ef22280..88900013d 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -528,7 +528,7 @@ void cEntity::KilledBy(TakeDamageInfo & a_TDI) { m_Health = 0; - cRoot::Get()->GetPluginManager()->CallHookKilling(*this, a_TDI); + cRoot::Get()->GetPluginManager()->CallHookKilling(*this, a_TDI.Attacker, a_TDI); if (m_Health > 0) { diff --git a/src/Mobs/IronGolem.h b/src/Mobs/IronGolem.h index 41c60438c..30f9bedff 100644 --- a/src/Mobs/IronGolem.h +++ b/src/Mobs/IronGolem.h @@ -19,7 +19,7 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - // Iron golems do not drown + // Iron golems do not drown nor float virtual void HandleAir(void) override {} virtual void SetSwimState(cChunk & a_Chunk) override {} } ; -- cgit v1.2.3 From c5d00f3ec5acec908cd54b194a0042e0681764a5 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 12:05:09 +0100 Subject: Suggestions --- src/Protocol/Protocol17x.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index d3b1cf946..6f46f8189 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -3016,8 +3016,11 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player) Pkt.WriteString(a_Player.GetClientHandle()->GetUUID()); Pkt.WriteString(a_Player.GetName()); - Pkt.WriteVarInt(m_Client->GetProperties().size()); - for (Json::Value::iterator itr = m_Client->GetProperties().begin(); itr != m_Client->GetProperties().end(); ++itr) + const Json::Value & Properties = m_Client->GetProperties(); + const Json::Value::const_iterator End = Properties.end(); + Pkt.WriteVarInt(Properties.size()); + + for (Json::Value::iterator itr = Properties.begin(); itr != End; ++itr) { Pkt.WriteString(((Json::Value)*itr).get("name", "").toStyledString()); Pkt.WriteString(((Json::Value)*itr).get("value", "").toStyledString()); -- cgit v1.2.3 From 9194438fb552dc2f112535e2420d94de7af40e17 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 22:21:00 +0100 Subject: Fixed another redstone simulator crash --- src/Simulator/IncrementalRedstoneSimulator.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index fb5b01e17..55c5cbd09 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -2101,6 +2101,13 @@ bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in void cIncrementalRedstoneSimulator::SetSourceUnpowered(int a_SourceX, int a_SourceY, int a_SourceZ, cChunk * a_Chunk, bool a_IsFirstCall) { + if (!a_IsFirstCall) // The neighbouring chunks passed when this parameter is false may be invalid + { + if ((a_Chunk == NULL) || !a_Chunk->IsValid()) + { + return; + } + } // TODO: on C++11 support, change both of these to llama functions pased to a std::remove_if for (PoweredBlocksList::iterator itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->end();) -- cgit v1.2.3 From 960fcaa90c3ba4d57ff2205259471799e0418d12 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 22:22:00 +0100 Subject: Fixed a bug with buckets * Additionally fixed cLineBlockTracer's EntryFace parameter when a block was hit on the first iteration along the projected line --- src/Items/ItemBucket.h | 2 +- src/LineBlockTracer.cpp | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 84835c021..a733bda19 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -215,7 +215,7 @@ public: } Callbacks; cLineBlockTracer Tracer(*a_World, Callbacks); - Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector()); + Vector3d Start(a_Player->GetEyePosition()); Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); // cTracer::Trace returns true when whole line was traversed. By returning true when we hit something, we ensure that this never happens if liquid could be placed diff --git a/src/LineBlockTracer.cpp b/src/LineBlockTracer.cpp index b03652bab..2395aa43e 100644 --- a/src/LineBlockTracer.cpp +++ b/src/LineBlockTracer.cpp @@ -203,6 +203,15 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk) m_Callbacks->OnNoChunk(); return false; } + + // Move to next block + if (!MoveToNextBlock()) + { + // We've reached the end + m_Callbacks->OnNoMoreHits(); + return true; + } + if (a_Chunk->IsValid()) { BLOCKTYPE BlockType; @@ -225,14 +234,6 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk) } } - // Move to next block - if (!MoveToNextBlock()) - { - // We've reached the end - m_Callbacks->OnNoMoreHits(); - return true; - } - // Update the current chunk if (a_Chunk != NULL) { -- cgit v1.2.3 From 174906efca7f81655a57fa0a30c1158a16e77117 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 22:22:45 +0100 Subject: Another fix for excessive food drain --- src/Entities/Player.cpp | 9 +++++++++ src/Entities/Player.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index f131a1829..7b3827f42 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -2141,6 +2141,8 @@ void cPlayer::ApplyFoodExhaustionFromMovement() { return; } + + // If we have just teleported, apply no exhaustion if (m_bIsTeleporting) { m_bIsTeleporting = false; @@ -2152,6 +2154,13 @@ void cPlayer::ApplyFoodExhaustionFromMovement() { return; } + + // Process exhaustion every two ticks as that is how frequently m_LastPos is updated + // Otherwise, we apply exhaustion for a 'movement' every tick, one of which is an already processed value + if (GetWorld()->GetWorldAge() % 2 != 0) + { + return; + } // Calculate the distance travelled, update the last pos: Vector3d Movement(GetPosition() - m_LastPos); diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 8f9b46e0f..b0fa01a7f 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -449,7 +449,7 @@ protected: double m_FoodSaturationLevel; /** Count-up to the healing or damaging action, based on m_FoodLevel */ - int m_FoodTickTimer; + int m_FoodTickTimer; /** A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel. Each action adds a little */ double m_FoodExhaustionLevel; -- cgit v1.2.3 From cd1e6f8ef028ea2a24e52190d305a62e6cfa62ab Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 10:24:29 +0200 Subject: Fixed formatting for cWitherSkullEntity --- src/Entities/WitherSkullEntity.cpp | 11 ++++++++++- src/Entities/WitherSkullEntity.h | 5 +++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/WitherSkullEntity.cpp b/src/Entities/WitherSkullEntity.cpp index 03e36a3f4..a7e774bba 100644 --- a/src/Entities/WitherSkullEntity.cpp +++ b/src/Entities/WitherSkullEntity.cpp @@ -1,3 +1,8 @@ + +// WitherSkullEntity.cpp + +// Implements the cWitherSkullEntity class representing the entity used by both blue and black wither skulls + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "WitherSkullEntity.h" @@ -8,7 +13,7 @@ cWitherSkullEntity::cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : -super(pkWitherSkull, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) + super(pkWitherSkull, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) { SetSpeed(a_Speed); } @@ -38,3 +43,7 @@ void cWitherSkullEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_H Destroy(true); } + + + + diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h index 85ba55d4d..8b3639802 100644 --- a/src/Entities/WitherSkullEntity.h +++ b/src/Entities/WitherSkullEntity.h @@ -1,6 +1,7 @@ -// + // WitherSkullEntity.h -// + +// Declares the cWitherSkullEntity class representing the entity used by both blue and black wither skulls #pragma once -- cgit v1.2.3 From 64c8b0d51b0ee8323dded6d22ac3b4754daa15d2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 10:51:44 +0200 Subject: Reformatted cItemPotionHandler. --- src/BlockID.h | 3 +- src/Items/ItemPotion.h | 124 ++++++++++++++++++++++++++++++------------------- 2 files changed, 79 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/BlockID.h b/src/BlockID.h index e3567b6fc..ba05e9e1a 100644 --- a/src/BlockID.h +++ b/src/BlockID.h @@ -319,7 +319,8 @@ enum ENUM_ITEM_ID E_ITEM_GHAST_TEAR = 370, E_ITEM_GOLD_NUGGET = 371, E_ITEM_NETHER_WART = 372, - E_ITEM_POTIONS = 373, + E_ITEM_POTION = 373, + E_ITEM_POTIONS = 373, // OBSOLETE, use E_ITEM_POTION instead E_ITEM_GLASS_BOTTLE = 374, E_ITEM_SPIDER_EYE = 375, E_ITEM_FERMENTED_SPIDER_EYE = 376, diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index b72499431..f3afbf99b 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -9,52 +9,67 @@ class cItemPotionHandler: { typedef cItemHandler super; - int GetPotionName(short a_ItemDamage) +public: + + cItemPotionHandler(): + super(E_ITEM_POTION) + { + } + + + /** Returns the potion particle type (used by the client for visuals), based on the potion's damage value */ + static int GetPotionParticleType(short a_ItemDamage) { - // First six bits (least significant) - return a_ItemDamage & 0x3F; + // Lowest six bits + return (a_ItemDamage & 0x3f); } - cEntityEffect::eType GetEntityEffectType(short a_ItemDamage) + + /** Translates the potion's damage value into the entity effect that the potion gives */ + static cEntityEffect::eType GetEntityEffectType(short a_ItemDamage) { - // First four bits (least significant) + // Lowest four bits // Potion effect bits are different from entity effect values // For reference: http://minecraft.gamepedia.com/Data_values#.22Potion_effect.22_bits - switch (a_ItemDamage & 0xF) + switch (a_ItemDamage & 0x0f) { - case 0x1: return cEntityEffect::effRegeneration; - case 0x2: return cEntityEffect::effSpeed; - case 0x3: return cEntityEffect::effFireResistance; - case 0x4: return cEntityEffect::effPoison; - case 0x5: return cEntityEffect::effInstantHealth; - case 0x6: return cEntityEffect::effNightVision; - case 0x8: return cEntityEffect::effWeakness; - case 0x9: return cEntityEffect::effStrength; - case 0xA: return cEntityEffect::effSlowness; - case 0xC: return cEntityEffect::effInstantDamage; - case 0xD: return cEntityEffect::effWaterBreathing; - case 0xE: return cEntityEffect::effInvisibility; + case 0x01: return cEntityEffect::effRegeneration; + case 0x02: return cEntityEffect::effSpeed; + case 0x03: return cEntityEffect::effFireResistance; + case 0x04: return cEntityEffect::effPoison; + case 0x05: return cEntityEffect::effInstantHealth; + case 0x06: return cEntityEffect::effNightVision; + case 0x08: return cEntityEffect::effWeakness; + case 0x09: return cEntityEffect::effStrength; + case 0x0a: return cEntityEffect::effSlowness; + case 0x0c: return cEntityEffect::effInstantDamage; + case 0x0d: return cEntityEffect::effWaterBreathing; + case 0x0e: return cEntityEffect::effInvisibility; // No effect potions - case 0x0: - case 0x7: - case 0xB: // Will be potion of leaping in 1.8 - case 0xF: + case 0x00: + case 0x07: + case 0x0b: // Will be potion of leaping in 1.8 + case 0x0f: { break; } } - return cEntityEffect::effNoEffect; } - - short GetEntityEffectIntensity(short a_ItemDamage) + + + /** Retrieves the intensity level from the potion's damage value. + Returns 0 for level I potions, 1 for level II potions. */ + static short GetEntityEffectIntensity(short a_ItemDamage) { - // Level II potion if fifth bit (from zero) is set - return (a_ItemDamage & 0x20) ? 1 : 0; + // Level II potion if the fifth lowest bit is set + return ((a_ItemDamage & 0x20) != 0) ? 1 : 0; } - int GetEntityEffectDuration(short a_ItemDamage) + + /** Returns the effect duration, in ticks, based on the potion's damage value */ + static int GetEntityEffectDuration(short a_ItemDamage) { // Base duration in ticks int base = 0; @@ -88,42 +103,49 @@ class cItemPotionHandler: } } - // If potion is level 2, half the duration. If not, stays the same + // If potion is level II, half the duration. If not, stays the same TierCoeff = (GetEntityEffectIntensity(a_ItemDamage) > 0) ? 0.5 : 1; // If potion is extended, multiply duration by 8/3. If not, stays the same - // Extended potion if sixth bit (from zero) is set - ExtCoeff = (a_ItemDamage & 0x40) ? (8.0/3.0) : 1; + // Extended potion if sixth lowest bit is set + ExtCoeff = (a_ItemDamage & 0x40) ? (8.0 / 3.0) : 1; // If potion is splash potion, multiply duration by 3/4. If not, stays the same - SplashCoeff = IsDrinkable(a_ItemDamage) ? 1 : 0.75; + SplashCoeff = IsPotionDrinkable(a_ItemDamage) ? 1 : 0.75; - // For reference: http://minecraft.gamepedia.com/Data_values#.22Tier.22_bit - // http://minecraft.gamepedia.com/Data_values#.22Extended_duration.22_bit - // http://minecraft.gamepedia.com/Data_values#.22Splash_potion.22_bit + // Ref.: + // http://minecraft.gamepedia.com/Data_values#.22Tier.22_bit + // http://minecraft.gamepedia.com/Data_values#.22Extended_duration.22_bit + // http://minecraft.gamepedia.com/Data_values#.22Splash_potion.22_bit return (int)(base * TierCoeff * ExtCoeff * SplashCoeff); } - -public: - cItemPotionHandler(): - super(E_ITEM_POTIONS) + + + /** Returns true if the potion with the given damage is drinkable */ + static bool IsPotionDrinkable(short a_ItemDamage) { + // Drinkable potion if 13th lowest bit is set + // Ref.: http://minecraft.gamepedia.com/Potions#Data_value_table + return ((a_ItemDamage & 0x2000) != 0); } + + // cItemHandler overrides: virtual bool IsDrinkable(short a_ItemDamage) override { - // Drinkable potion if 13th bit (from zero) is set - // For reference: http://minecraft.gamepedia.com/Potions#Data_value_table - return ((a_ItemDamage & 0x2000) != 0); + // Drinkable potion if 13th lowest bit is set + // Ref.: http://minecraft.gamepedia.com/Potions#Data_value_table + return IsPotionDrinkable(a_ItemDamage); } + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { short PotionDamage = a_Item.m_ItemDamage; - // Only called when potion is a splash potion - if (IsDrinkable(PotionDamage)) + // Do not throw non-splash potions: + if (IsPotionDrinkable(PotionDamage)) { return false; } @@ -131,8 +153,11 @@ public: Vector3d Pos = a_Player->GetThrowStartPos(); Vector3d Speed = a_Player->GetLookVector() * 7; - cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, GetEntityEffectType(PotionDamage), cEntityEffect(GetEntityEffectDuration(PotionDamage), GetEntityEffectIntensity(PotionDamage)), GetPotionName(PotionDamage)); - + cSplashPotionEntity * Projectile = new cSplashPotionEntity( + a_Player, Pos.x, Pos.y, Pos.z, Speed, + GetEntityEffectType(PotionDamage), cEntityEffect(GetEntityEffectDuration(PotionDamage), + GetEntityEffectIntensity(PotionDamage)), GetPotionParticleType(PotionDamage) + ); if (Projectile == NULL) { return false; @@ -151,11 +176,12 @@ public: return true; } + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override { short PotionDamage = a_Item->m_ItemDamage; - // Only called when potion is a drinkable potion + // Do not drink undrinkable potions: if (!IsDrinkable(a_Item->m_ItemDamage)) { return false; @@ -167,3 +193,7 @@ public: return true; } }; + + + + -- cgit v1.2.3 From 430d8b42a5b8889ff3c0bfaea84ede7e543e2b64 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 11:07:10 +0200 Subject: Updated cPawn::KilledBy signature for custom death messages. --- src/Entities/Pawn.cpp | 4 ++-- src/Entities/Pawn.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 840736f6a..fe6c24a7a 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -49,10 +49,10 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk) -void cPawn::KilledBy(cEntity * a_Killer) +void cPawn::KilledBy(TakeDamageInfo & a_TDI) { ClearEntityEffects(); - super::KilledBy(a_Killer); + super::KilledBy(a_TDI); } diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index 252ec5edb..63c7cfbb6 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -21,7 +21,7 @@ public: cPawn(eEntityType a_EntityType, double a_Width, double a_Height); virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - virtual void KilledBy(cEntity * a_Killer) override; + virtual void KilledBy(TakeDamageInfo & a_TDI) override; // tolua_begin -- cgit v1.2.3 From 70f304a96b48de5c31993d9ee87c4b661e3c615c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 11:07:33 +0200 Subject: Fixed 3 MSVC warnings in SplashPotionEntity. --- src/Entities/SplashPotionEntity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 804026cc0..ed5afaf11 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -112,7 +112,7 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect); m_World->ForEachEntity(Callback); - m_World->BroadcastSoundParticleEffect(2002, a_HitPos.x, a_HitPos.y, a_HitPos.z, m_PotionParticleType); + m_World->BroadcastSoundParticleEffect(2002, (int)a_HitPos.x, (int)a_HitPos.y, (int)a_HitPos.z, m_PotionParticleType); } -- cgit v1.2.3 From db36f1a9fad7a79d489c36abd6140e7b48f7d413 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 17 Jul 2014 13:54:28 +0100 Subject: Fixed crash with entities in unloaded chunks * Fixes #1190 --- src/ChunkMap.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index b9bb39aa8..e2cf50314 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1736,7 +1736,9 @@ void cChunkMap::RemoveEntity(cEntity * a_Entity) { cCSLock Lock(m_CSLayers); cChunkPtr Chunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ()); - if ((Chunk == NULL) || !Chunk->IsValid()) + + // Even if a chunk is not valid, it may still contain entities such as players; make sure to remove them (#1190) + if (Chunk == NULL) { return; } -- cgit v1.2.3 From 3dd9649665e88e27298d93fd3c08b76ac5b0befa Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 17 Jul 2014 14:32:52 +0100 Subject: Fixed mob knockback * Fixes #901 --- src/Entities/Entity.cpp | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index c6dc1fca3..4a6de25b7 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -334,36 +334,21 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs { - int KnockbackLevel = 0; - if (a_TDI.Attacker->GetEquippedWeapon().m_ItemType == E_ITEM_BOW) + int KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); // More common enchantment + if (KnockbackLevel < 1) { + // We support punch on swords and vice versa! :) KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPunch); } - else - { - KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); - } - Vector3d additionalSpeed(0, 0, 0); + Vector3d AdditionalSpeed(0, 0, 0); switch (KnockbackLevel) { - case 1: - { - additionalSpeed.Set(5, .3, 5); - break; - } - case 2: - { - additionalSpeed.Set(8, .3, 8); - break; - } - default: - { - additionalSpeed.Set(2, .3, 2); - break; - } + case 1: AdditionalSpeed.Set(5, 0.3, 5); break; + case 2: AdditionalSpeed.Set(8, 0.3, 8); break; + default: break; } - AddSpeed(a_TDI.Knockback * additionalSpeed); + AddSpeed(a_TDI.Knockback + AdditionalSpeed); } m_World->BroadcastEntityStatus(*this, esGenericHurt); -- cgit v1.2.3 From 993fd14ddfc881cf5be951df77da0338124d68cc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 16:33:09 +0200 Subject: Fixed basic whitespace problems. Indenting by spaces and alignment by spaces, as well as trailing whitespace on non-empty lines. --- src/AllocationPool.h | 8 +++-- src/BlockArea.cpp | 10 +++---- src/BlockArea.h | 4 +-- src/BlockID.cpp | 2 +- src/BlockID.h | 4 +-- src/BlockTracer.h | 16 +++++----- src/ChatColor.h | 2 +- src/Chunk.cpp | 28 +++++++++--------- src/Chunk.h | 4 +-- src/ChunkDataCallback.h | 4 +-- src/ChunkDef.h | 26 ++++++++--------- src/ChunkMap.cpp | 6 ++-- src/ChunkMap.h | 6 ++-- src/ChunkSender.h | 10 +++---- src/ClientHandle.cpp | 20 ++++++------- src/ClientHandle.h | 14 ++++----- src/CraftingRecipes.cpp | 8 ++--- src/Cuboid.h | 4 +-- src/Defines.h | 2 +- src/Globals.h | 10 +++---- src/Group.h | 26 ++++++++++------- src/Inventory.h | 2 +- src/Item.cpp | 14 ++++++++- src/Item.h | 8 ++--- src/LightingThread.cpp | 2 +- src/LightingThread.h | 8 ++--- src/Log.h | 4 +-- src/MCLogger.h | 9 +++--- src/Map.h | 20 ++++++------- src/MapManager.h | 19 +++++------- src/Matrix4.h | 2 +- src/MobCensus.cpp | 2 +- src/MobFamilyCollecter.h | 2 +- src/MobProximityCounter.cpp | 2 +- src/MobProximityCounter.h | 6 ++-- src/MobSpawner.cpp | 2 +- src/MobSpawner.h | 4 +-- src/Noise.cpp | 50 +++++++++++++++---------------- src/Noise.h | 2 +- src/Root.cpp | 8 ++--- src/Root.h | 28 ++++++++++-------- src/Scoreboard.cpp | 9 ++++-- src/Scoreboard.h | 23 +++++++-------- src/Server.h | 8 ++--- src/Statistics.h | 9 +++--- src/StringUtils.cpp | 71 ++++++++++++++++++++++----------------------- src/StringUtils.h | 10 +------ src/Tracer.h | 2 +- src/World.cpp | 10 +++---- src/World.h | 14 ++++----- src/XMLParser.h | 36 +++++++++++------------ src/main.cpp | 4 +-- 52 files changed, 306 insertions(+), 298 deletions(-) (limited to 'src') diff --git a/src/AllocationPool.h b/src/AllocationPool.h index 5d749a79e..3c9dbe8c9 100644 --- a/src/AllocationPool.h +++ b/src/AllocationPool.h @@ -61,7 +61,7 @@ class cListAllocationPool : public cAllocationPool free (m_FreeList.front()); m_FreeList.pop_front(); } - } + } virtual T * Allocate() override { @@ -90,7 +90,7 @@ class cListAllocationPool : public cAllocationPool } virtual void Free(T * a_ptr) override { - if (a_ptr == NULL) + if (a_ptr == NULL) { return; } @@ -107,3 +107,7 @@ class cListAllocationPool : public cAllocationPool std::list m_FreeList; std::auto_ptr::cStarvationCallbacks> m_Callbacks; }; + + + + diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 0e4c42f0f..1df60b099 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -28,10 +28,10 @@ typedef void (CombinatorFunc)(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLE // This wild construct allows us to pass a function argument and still have it inlined by the compiler :) /// Merges two blocktypes and blockmetas of the specified sizes and offsets using the specified combinator function -template +template void InternalMergeBlocks( BLOCKTYPE * a_DstTypes, const BLOCKTYPE * a_SrcTypes, - NIBBLETYPE * a_DstMetas, const NIBBLETYPE * a_SrcMetas, + NIBBLETYPE * a_DstMetas, const NIBBLETYPE * a_SrcMetas, int a_SizeX, int a_SizeY, int a_SizeZ, int a_SrcOffX, int a_SrcOffY, int a_SrcOffZ, int a_DstOffX, int a_DstOffY, int a_DstOffZ, @@ -136,7 +136,7 @@ void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE return; } - // Air is always hollowed out + // Air is always hollowed out if (a_SrcType == E_BLOCK_AIR) { a_DstType = E_BLOCK_AIR; @@ -781,7 +781,7 @@ void cBlockArea::Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_Block -void cBlockArea::FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ, +void cBlockArea::FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight ) @@ -2226,7 +2226,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel m_Size.x, m_Size.y, m_Size.z ); return; - } // case msDifference + } // case msDifference case cBlockArea::msMask: { diff --git a/src/BlockArea.h b/src/BlockArea.h index 2bd26facd..a95ba7788 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -175,7 +175,7 @@ public: void Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f); /** Fills a cuboid inside the block area with the specified data */ - void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ, + void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f ); @@ -357,7 +357,7 @@ protected: /** Sets the specified datatypes at the specified location. */ void RelSetData( - int a_RelX, int a_RelY, int a_RelZ, + int a_RelX, int a_RelY, int a_RelZ, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight ); diff --git a/src/BlockID.cpp b/src/BlockID.cpp index 8edc51664..023172ca1 100644 --- a/src/BlockID.cpp +++ b/src/BlockID.cpp @@ -286,7 +286,7 @@ int StringToMobType(const AString & a_MobString) {cMonster::mtMooshroom, "Mooshroom"}, {cMonster::mtSnowGolem, "SnowGolem"}, {cMonster::mtOcelot, "Ocelot"}, - {cMonster::mtIronGolem, "IronGolem"}, + {cMonster::mtIronGolem, "IronGolem"}, {cMonster::mtVillager, "Villager"}, }; for (size_t i = 0; i < ARRAYCOUNT(MobMap); i++) diff --git a/src/BlockID.h b/src/BlockID.h index ba05e9e1a..43f911ce3 100644 --- a/src/BlockID.h +++ b/src/BlockID.h @@ -176,7 +176,7 @@ enum ENUM_BLOCK_ID E_BLOCK_ACACIA_WOOD_STAIRS = 163, E_BLOCK_DARK_OAK_WOOD_STAIRS = 164, E_BLOCK_HAY_BALE = 170, - E_BLOCK_CARPET = 171, + E_BLOCK_CARPET = 171, E_BLOCK_HARDENED_CLAY = 172, E_BLOCK_BLOCK_OF_COAL = 173, E_BLOCK_PACKED_ICE = 174, @@ -187,7 +187,7 @@ enum ENUM_BLOCK_ID E_BLOCK_NUMBER_OF_TYPES, ///< Number of individual (different) blocktypes E_BLOCK_MAX_TYPE_ID = E_BLOCK_NUMBER_OF_TYPES - 1, ///< Maximum BlockType number used - // Synonym or ID compatibility + // Synonym or ID compatibility E_BLOCK_YELLOW_FLOWER = E_BLOCK_DANDELION, E_BLOCK_RED_ROSE = E_BLOCK_FLOWER, E_BLOCK_LOCKED_CHEST = E_BLOCK_STAINED_GLASS, diff --git a/src/BlockTracer.h b/src/BlockTracer.h index a18c8df4d..c569b4ec6 100644 --- a/src/BlockTracer.h +++ b/src/BlockTracer.h @@ -39,13 +39,13 @@ public: /** Called on each block encountered along the path, including the first block (path start), if chunk data is not loaded When this callback returns true, the tracing is aborted. */ - virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace) - { + virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace) + { UNUSED(a_BlockX); UNUSED(a_BlockY); UNUSED(a_BlockZ); UNUSED(a_EntryFace); - return false; + return false; } /** Called when the path goes out of world, either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height) @@ -54,8 +54,8 @@ public: Note that some paths can go out of the world and come back again (parabola), in such a case this callback is followed by OnIntoWorld() and further OnNextBlock() calls */ - virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) - { + virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) + { UNUSED(a_BlockX); UNUSED(a_BlockY); UNUSED(a_BlockZ); @@ -68,12 +68,12 @@ public: Note that some paths can go out of the world and come back again (parabola), in such a case this callback is followed by further OnNextBlock() calls */ - virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) - { + virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) + { UNUSED(a_BlockX); UNUSED(a_BlockY); UNUSED(a_BlockZ); - return false; + return false; } /** Called when the path is sure not to hit any more blocks. diff --git a/src/ChatColor.h b/src/ChatColor.h index 643c4d5d8..2189fd395 100644 --- a/src/ChatColor.h +++ b/src/ChatColor.h @@ -27,7 +27,7 @@ public: static const std::string Rose; static const std::string LightPurple; static const std::string Yellow; - static const std::string White; + static const std::string White; // Styles ( source: http://wiki.vg/Chat ) static const std::string Random; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 8a249ea53..b88952fa0 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -62,7 +62,7 @@ sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_Bloc // cChunk: cChunk::cChunk( - int a_ChunkX, int a_ChunkY, int a_ChunkZ, + int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkMap * a_ChunkMap, cWorld * a_World, cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP, cAllocationPool & a_Pool @@ -443,7 +443,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill) { currentPlayer = (*itr)->GetPlayer(); playerPositions.push_back(&(currentPlayer->GetPosition())); - } + } Vector3d currentPosition; for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) @@ -895,7 +895,7 @@ void cChunk::ApplyWeatherToTop() SetBlock(X, Height, Z, E_BLOCK_ICE, 0); } else if ( - (m_World->IsDeepSnowEnabled()) && + (m_World->IsDeepSnowEnabled()) && ( (TopBlock == E_BLOCK_RED_ROSE) || (TopBlock == E_BLOCK_YELLOW_FLOWER) || @@ -944,10 +944,10 @@ void cChunk::GrowMelonPumpkin(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Bl IsValid = IsValid && UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ + 1, BlockType[2], BlockMeta); IsValid = IsValid && UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ - 1, BlockType[3], BlockMeta); if ( - !IsValid || - (BlockType[0] == ProduceType) || - (BlockType[1] == ProduceType) || - (BlockType[2] == ProduceType) || + !IsValid || + (BlockType[0] == ProduceType) || + (BlockType[1] == ProduceType) || + (BlockType[2] == ProduceType) || (BlockType[3] == ProduceType) ) { @@ -1229,7 +1229,7 @@ bool cChunk::UnboundedRelSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE } Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta); return true; -} +} @@ -2294,7 +2294,7 @@ bool cChunk::DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceC } } // switch (BlockType) - // The correct block entity is here, + // The correct block entity is here, if (a_Callback.Item((cFurnaceEntity *)*itr)) { return false; @@ -2326,7 +2326,7 @@ bool cChunk::DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBl return false; } - // The correct block entity is here, + // The correct block entity is here if (a_Callback.Item((cNoteEntity *)*itr)) { return false; @@ -2358,7 +2358,7 @@ bool cChunk::DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCom return false; } - // The correct block entity is here, + // The correct block entity is here, if (a_Callback.Item((cCommandBlockEntity *)*itr)) { return false; @@ -2390,7 +2390,7 @@ bool cChunk::DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadC return false; } - // The correct block entity is here, + // The correct block entity is here, if (a_Callback.Item((cMobHeadEntity *)*itr)) { return false; @@ -2422,7 +2422,7 @@ bool cChunk::DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlower return false; } - // The correct block entity is here, + // The correct block entity is here if (a_Callback.Item((cFlowerPotEntity *)*itr)) { return false; @@ -2475,7 +2475,7 @@ bool cChunk::GetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_ BLOCKTYPE cChunk::GetBlock(int a_RelX, int a_RelY, int a_RelZ) const { if ( - (a_RelX < 0) || (a_RelX >= Width) || + (a_RelX < 0) || (a_RelX >= Width) || (a_RelY < 0) || (a_RelY >= Height) || (a_RelZ < 0) || (a_RelZ >= Width) ) diff --git a/src/Chunk.h b/src/Chunk.h index dfcfdab0f..f765bcdaf 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -87,7 +87,7 @@ public: 3. Mark the chunk as saved (MarkSaved() ) If anywhere inside this sequence another thread mmodifies the chunk, the chunk will not get marked as saved in MarkSaved() */ - void MarkSaving(void); // Marks the chunk as being saved. + void MarkSaving(void); // Marks the chunk as being saved. void MarkSaved(void); // Marks the chunk as saved, if it didn't change from the last call to MarkSaving() void MarkLoaded(void); // Marks the chunk as freshly loaded. Fails if the chunk is already valid void MarkLoadFailed(void); // Marks the chunk as failed to load. Ignored is the chunk is already valid @@ -97,7 +97,7 @@ public: /** Sets all chunk data */ void SetAllData( - const BLOCKTYPE * a_BlockTypes, + const BLOCKTYPE * a_BlockTypes, const NIBBLETYPE * a_BlockMeta, const NIBBLETYPE * a_BlockLight, const NIBBLETYPE * a_BlockSkyLight, diff --git a/src/ChunkDataCallback.h b/src/ChunkDataCallback.h index 0c8b1098f..53d44d038 100644 --- a/src/ChunkDataCallback.h +++ b/src/ChunkDataCallback.h @@ -25,8 +25,8 @@ public: virtual ~cChunkDataCallback() {} - /** Called before any other callbacks to inform of the current coords - (only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()). + /** Called before any other callbacks to inform of the current coords + (only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()). If false is returned, the chunk is skipped. */ virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; }; diff --git a/src/ChunkDef.h b/src/ChunkDef.h index f89e16ed1..bd6387b74 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -22,8 +22,8 @@ It will help us when the new chunk format comes out and we need to patch everyth #define ZERO_CHUNK_Y 0 // Used to smoothly convert to new axis ordering. One will be removed when deemed stable. -#define AXIS_ORDER_YZX 1 // Original (1.1-) -#define AXIS_ORDER_XZY 2 // New (1.2+) +#define AXIS_ORDER_YZX 1 // Original (1.1-) +#define AXIS_ORDER_XZY 2 // New (1.2+) #define AXIS_ORDER AXIS_ORDER_XZY @@ -72,7 +72,7 @@ public: /// The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the highest non-air block in the column typedef HEIGHTTYPE HeightMap[Width * Width]; - /** The type used for any biomemap operations and storage inside MCServer, + /** The type used for any biomemap operations and storage inside MCServer, using MCServer biomes (need not correspond to client representation!) idx = x + Width * z // Need to verify this with the protocol spec, currently unknown! */ @@ -148,17 +148,17 @@ public: inline static Vector3i IndexToCoordinate( unsigned int index ) { #if AXIS_ORDER == AXIS_ORDER_XZY - return Vector3i( // 1.2 - index % cChunkDef::Width, // X - index / (cChunkDef::Width * cChunkDef::Width), // Y - (index / cChunkDef::Width) % cChunkDef::Width // Z - ); + return Vector3i( // 1.2 + index % cChunkDef::Width, // X + index / (cChunkDef::Width * cChunkDef::Width), // Y + (index / cChunkDef::Width) % cChunkDef::Width // Z + ); #elif AXIS_ORDER == AXIS_ORDER_YZX - return Vector3i( // 1.1 - index / (cChunkDef::Height * cChunkDef::Width), // X - index % cChunkDef::Height, // Y - (index / cChunkDef::Height) % cChunkDef::Width // Z - ); + return Vector3i( // 1.1 + index / (cChunkDef::Height * cChunkDef::Width), // X + index % cChunkDef::Height, // Y + (index / cChunkDef::Height) % cChunkDef::Width // Z + ); #endif } diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index b9bb39aa8..a83828bed 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2711,7 +2711,7 @@ void cChunkMap::SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTi // cChunkMap::cChunkLayer: cChunkMap::cChunkLayer::cChunkLayer( - int a_LayerX, int a_LayerZ, + int a_LayerX, int a_LayerZ, cChunkMap * a_Parent, cAllocationPool & a_Pool ) @@ -2923,7 +2923,7 @@ int cChunkMap::cChunkLayer::GetNumChunksLoaded(void) const NumChunks++; } } // for i - m_Chunks[] - return NumChunks; + return NumChunks; } @@ -2994,7 +2994,7 @@ void cChunkMap::cChunkLayer::UnloadUnusedChunks(void) void cChunkMap::FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { cCSLock Lock(m_CSFastSetBlock); - m_FastSetBlockQueue.push_back(sSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta)); + m_FastSetBlockQueue.push_back(sSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta)); } diff --git a/src/ChunkMap.h b/src/ChunkMap.h index ef9b76e3f..0bbd3dab1 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -118,7 +118,7 @@ public: If a_MarkDirty is set, the chunk is set as dirty (used after generating) */ void SetChunkData( - int a_ChunkX, int a_ChunkZ, + int a_ChunkX, int a_ChunkZ, const BLOCKTYPE * a_BlockTypes, const NIBBLETYPE * a_BlockMeta, const NIBBLETYPE * a_BlockLight, @@ -361,7 +361,7 @@ private: { public: cChunkLayer( - int a_LayerX, int a_LayerZ, + int a_LayerX, int a_LayerZ, cChunkMap * a_Parent, cAllocationPool & a_Pool ); @@ -384,7 +384,7 @@ private: void UnloadUnusedChunks(void); /** Collect a mob census, of all mobs, their megatype, their chunk and their distance o closest player */ - void CollectMobCensus(cMobCensus& a_ToFill); + void CollectMobCensus(cMobCensus& a_ToFill); /** Try to Spawn Monsters inside all Chunks */ void SpawnMobs(cMobSpawner& a_MobSpawner); diff --git a/src/ChunkSender.h b/src/ChunkSender.h index 00565d7c3..095a99380 100644 --- a/src/ChunkSender.h +++ b/src/ChunkSender.h @@ -6,17 +6,17 @@ /* The whole thing is a thread that runs in a loop, waiting for either: "finished chunks" (ChunkReady()), or - "chunks to send" (QueueSendChunkTo() ) -to come to a queue. + "chunks to send" (QueueSendChunkTo() ) +to come to a queue. And once they do, it requests the chunk data and sends it all away, either broadcasting (ChunkReady), or sends to a specific client (QueueSendChunkTo) Chunk data is queried using the cChunkDataCallback interface. It is cached inside the ChunkSender object during the query and then processed after the query ends. -Note that the data needs to be compressed only *after* the query finishes, +Note that the data needs to be compressed only *after* the query finishes, because the query callbacks run with ChunkMap's CS locked. -A client may remove itself from all direct requests(QueueSendChunkTo()) by calling RemoveClient(); +A client may remove itself from all direct requests(QueueSendChunkTo()) by calling RemoveClient(); this ensures that the client's Send() won't be called anymore by ChunkSender. Note that it may be called by world's BroadcastToChunk() if the client is still in the chunk. */ @@ -110,7 +110,7 @@ protected: bool operator ==(const sSendChunk & a_Other) { return ( - (a_Other.m_ChunkX == m_ChunkX) && + (a_Other.m_ChunkX == m_ChunkX) && (a_Other.m_ChunkY == m_ChunkY) && (a_Other.m_ChunkZ == m_ChunkZ) && (a_Other.m_Client == m_Client) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index bd6fc1287..bf66e7db1 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -85,7 +85,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) : { m_Protocol = new cProtocolRecognizer(this); - s_ClientCount++; // Not protected by CS because clients are always constructed from the same thread + s_ClientCount++; // Not protected by CS because clients are always constructed from the same thread m_UniqueID = s_ClientCount; cTimer t1; @@ -531,7 +531,7 @@ void cClientHandle::HandlePing(void) AString Reply; const cServer & Server = *cRoot::Get()->GetServer(); - Printf(Reply, "%s%s%i%s%i", + Printf(Reply, "%s%s%i%s%i", Server.GetDescription().c_str(), cChatColor::Delimiter.c_str(), Server.GetNumPlayers(), @@ -1169,7 +1169,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e if ((Equipped.m_ItemType != a_HeldItem.m_ItemType) && (a_HeldItem.m_ItemType != -1)) { // Only compare ItemType, not meta (torches have different metas) - // The -1 check is there because sometimes the client sends -1 instead of the held item + // The -1 check is there because sometimes the client sends -1 instead of the held item // ( http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 ) LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)", m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType @@ -1390,7 +1390,7 @@ void cClientHandle::HandleChat(const AString & a_Message) Color = AString("@") + Color[2]; } else - { + { Color.clear(); } Msg.AddTextPart(AString("<") + m_Player->GetName() + "> ", Color); @@ -1449,7 +1449,7 @@ void cClientHandle::HandleAnimation(char a_Animation) a_Animation--; // Offset by -1 break; } - case 5: + case 5: case 6: case 7: { @@ -1517,8 +1517,8 @@ void cClientHandle::HandleWindowClick(char a_WindowID, short a_SlotNum, eClickAc void cClientHandle::HandleUpdateSign( - int a_BlockX, int a_BlockY, int a_BlockZ, - const AString & a_Line1, const AString & a_Line2, + int a_BlockX, int a_BlockY, int a_BlockZ, + const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4 ) { @@ -1821,7 +1821,7 @@ bool cClientHandle::CheckBlockInteractionsRate(void) void cClientHandle::Tick(float a_Dt) -{ +{ // Process received network data: AString IncomingData; { @@ -1887,7 +1887,7 @@ void cClientHandle::Tick(float a_Dt) void cClientHandle::ServerTick(float a_Dt) -{ +{ // Process received network data: AString IncomingData; { @@ -2345,7 +2345,7 @@ void cClientHandle::SendPlayerSpawn(const cPlayer & a_Player) return; } - LOGD("Spawning player \"%s\" on client \"%s\" @ %s", + LOGD("Spawning player \"%s\" on client \"%s\" @ %s", a_Player.GetName().c_str(), GetPlayer()->GetName().c_str(), GetIPString().c_str() ); diff --git a/src/ClientHandle.h b/src/ClientHandle.h index ca39a01cd..d02b83cfe 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -48,7 +48,7 @@ class cStatManager; class cClientHandle : // tolua_export public cSocketThreads::cCallback -{ // tolua_export +{ // tolua_export public: #if defined(ANDROID_NDK) @@ -64,9 +64,9 @@ public: const AString & GetIPString(void) const { return m_IPString; } - cPlayer * GetPlayer(void) { return m_Player; } // tolua_export + cPlayer * GetPlayer(void) { return m_Player; } // tolua_export - const AString & GetUUID(void) const { return m_UUID; } // tolua_export + const AString & GetUUID(void) const { return m_UUID; } // tolua_export void SetUUID(const AString & a_UUID) { m_UUID = a_UUID; } const Json::Value & GetProperties(void) const { return m_Properties; } @@ -246,8 +246,8 @@ public: void HandleSteerVehicle (float Forward, float Sideways); void HandleTabCompletion (const AString & a_Text); void HandleUpdateSign ( - int a_BlockX, int a_BlockY, int a_BlockZ, - const AString & a_Line1, const AString & a_Line2, + int a_BlockX, int a_BlockY, int a_BlockZ, + const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4 ); void HandleUnmount (void); @@ -338,7 +338,7 @@ private: csAuthenticating, ///< The client has logged in, waiting for external authentication csAuthenticated, ///< The client has been authenticated, will start streaming chunks in the next tick csDownloadingWorld, ///< The client is waiting for chunks, we're waiting for the loader to provide and send them - csConfirmingPos, ///< The client has been sent the position packet, waiting for them to repeat the position back + csConfirmingPos, ///< The client has been sent the position packet, waiting for them to repeat the position back csPlaying, ///< Normal gameplay csDestroying, ///< The client is being destroyed, don't queue any more packets / don't add to chunks csDestroyed, ///< The client has been destroyed, the destructor is to be called from the owner thread @@ -408,7 +408,7 @@ private: virtual bool DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client virtual void GetOutgoingData(AString & a_Data) override; // Data can be sent to client virtual void SocketClosed (void) override; // The socket has been closed for any reason -}; // tolua_export +}; // tolua_export diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index 0f1951351..a2ce359f3 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -135,7 +135,7 @@ void cCraftingGrid::ConsumeGrid(const cCraftingGrid & a_Grid) { if ((a_Grid.m_Width != m_Width) || (a_Grid.m_Height != m_Height)) { - LOGWARNING("Consuming a grid of different dimensions: (%d, %d) vs (%d, %d)", + LOGWARNING("Consuming a grid of different dimensions: (%d, %d) vs (%d, %d)", a_Grid.m_Width, a_Grid.m_Height, m_Width, m_Height ); } @@ -196,7 +196,7 @@ void cCraftingGrid::Dump(void) #ifdef _DEBUG int idx = x + m_Width * y; #endif - LOGD("Slot (%d, %d): Type %d, health %d, count %d", + LOGD("Slot (%d, %d): Type %d, health %d, count %d", x, y, m_Items[idx].m_ItemType, m_Items[idx].m_ItemDamage, m_Items[idx].m_ItemCount ); } @@ -250,7 +250,7 @@ void cCraftingRecipe::Dump(void) { LOGD("Recipe ingredients:"); m_Ingredients.Dump(); - LOGD("Result: Type %d, health %d, count %d", + LOGD("Result: Type %d, health %d, count %d", m_Result.m_ItemType, m_Result.m_ItemDamage, m_Result.m_ItemCount ); } @@ -665,7 +665,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti const cItem & Item = itrS->m_Item; if ( - (itrS->x >= a_GridWidth) || + (itrS->x >= a_GridWidth) || (itrS->y >= a_GridHeight) || (Item.m_ItemType != a_CraftingGrid[GridID].m_ItemType) || // same item type? (Item.m_ItemCount > a_CraftingGrid[GridID].m_ItemCount) || // not enough items diff --git a/src/Cuboid.h b/src/Cuboid.h index 3239c54fc..960af130b 100644 --- a/src/Cuboid.h +++ b/src/Cuboid.h @@ -38,7 +38,7 @@ public: Assumes both cuboids are sorted. */ bool DoesIntersect(const cCuboid & a_Other) const; - bool IsInside(const Vector3i & v) const + bool IsInside(const Vector3i & v) const { return ( (v.x >= p1.x) && (v.x <= p2.x) && @@ -47,7 +47,7 @@ public: ); } - bool IsInside(int a_X, int a_Y, int a_Z) const + bool IsInside(int a_X, int a_Y, int a_Z) const { return ( (a_X >= p1.x) && (a_X <= p2.x) && diff --git a/src/Defines.h b/src/Defines.h index ee91ee596..ba2e8f504 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -512,7 +512,7 @@ inline void VectorToEuler(double a_X, double a_Y, double a_Z, double & a_Pan, do } else { - a_Pan = atan2(a_Z, a_X) * 180 / PI - 90; + a_Pan = atan2(a_Z, a_X) * 180 / PI - 90; } a_Pitch = atan2(a_Y, r) * 180 / PI; diff --git a/src/Globals.h b/src/Globals.h index 998676fb1..62e0ad285 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -15,8 +15,8 @@ // Disable some warnings that we don't care about: #pragma warning(disable:4100) // Unreferenced formal parameter - - // Useful warnings from warning level 4: + + // Useful warnings from warning level 4: #pragma warning(3 : 4127) // Conditional expression is constant #pragma warning(3 : 4189) // Local variable is initialized but not referenced #pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch @@ -58,8 +58,8 @@ // override is part of c++11 #if __cplusplus < 201103L - #define override - #endif + #define override + #endif #define OBSOLETE __attribute__((deprecated)) @@ -145,7 +145,7 @@ class SizeChecker; template class SizeChecker { - T v; + T v; }; template class SizeChecker; diff --git a/src/Group.h b/src/Group.h index 47088d50d..95063a987 100644 --- a/src/Group.h +++ b/src/Group.h @@ -5,18 +5,22 @@ -class cGroup // tolua_export -{ // tolua_export -public: // tolua_export +// tolua_begin +class cGroup +{ +public: + // tolua_end cGroup() {} ~cGroup() {} - void SetName( const AString & a_Name ) { m_Name = a_Name; } // tolua_export - const AString & GetName() const { return m_Name; } // tolua_export - void SetColor( const AString & a_Color ) { m_Color = a_Color; } // tolua_export - void AddCommand( const AString & a_Command ); // tolua_export - void AddPermission( const AString & a_Permission ); // tolua_export - void InheritFrom( cGroup* a_Group ); // tolua_export + // tolua_begin + void SetName( const AString & a_Name ) { m_Name = a_Name; } + const AString & GetName() const { return m_Name; } + void SetColor( const AString & a_Color ) { m_Color = a_Color; } + void AddCommand( const AString & a_Command ); + void AddPermission( const AString & a_Permission ); + void InheritFrom( cGroup* a_Group ); + // tolua_end typedef std::map< AString, bool > PermissionMap; const PermissionMap & GetPermissions() const { return m_Permissions; } @@ -26,7 +30,7 @@ public: // tolua_export typedef std::map< AString, bool > CommandMap; const CommandMap & GetCommands() const { return m_Commands; } - const AString & GetColor() const { return m_Color; } // tolua_export + const AString & GetColor() const { return m_Color; } // tolua_export typedef std::list< cGroup* > GroupList; const GroupList & GetInherits() const { return m_Inherits; } @@ -37,4 +41,4 @@ private: PermissionMap m_Permissions; CommandMap m_Commands; GroupList m_Inherits; -};// tolua_export +}; // tolua_export diff --git a/src/Inventory.h b/src/Inventory.h index 39aef1538..e25fc4a8a 100644 --- a/src/Inventory.h +++ b/src/Inventory.h @@ -183,7 +183,7 @@ protected: // cItemGrid::cListener override: virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override; -}; // tolua_export +}; // tolua_export diff --git a/src/Item.cpp b/src/Item.cpp index 56ceae0b7..b3ce32336 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -193,17 +193,29 @@ void cItem::FromJson(const Json::Value & a_Value) bool cItem::IsEnchantable(short item) { if ((item >= 256) && (item <= 259)) + { return true; + } if ((item >= 267) && (item <= 279)) + { return true; - if ((item >= 283) && (item <= 286)) + } + if ((item >= 283) && (item <= 286)) + { return true; + } if ((item >= 290) && (item <= 294)) + { return true; + } if ((item >= 298) && (item <= 317)) + { return true; + } if ((item == 346) || (item == 359) || (item == 261)) + { return true; + } return false; } diff --git a/src/Item.h b/src/Item.h index acbc880dc..d8b9e78a0 100644 --- a/src/Item.h +++ b/src/Item.h @@ -150,7 +150,7 @@ public: bool IsCustomNameEmpty(void) const { return (m_CustomName.empty()); } - bool IsLoreEmpty(void) const { return (m_Lore.empty()); } + bool IsLoreEmpty(void) const { return (m_Lore.empty()); } /** Returns a copy of this item with m_ItemCount set to 1. Useful to preserve enchantments etc. on stacked items */ cItem CopyOne(void) const; @@ -184,14 +184,14 @@ public: void FromJson(const Json::Value & a_Value); /** Returns true if the specified item type is enchantable (as per 1.2.5 protocol requirements) */ - static bool IsEnchantable(short a_ItemType); // tolua_export + static bool IsEnchantable(short a_ItemType); // tolua_export /** Returns the enchantability of the item. When the item hasn't a enchantability, it will returns 0 */ - int GetEnchantability(); // tolua_export + int GetEnchantability(); // tolua_export /** Enchants the item using the specified number of XP levels. Returns true if item enchanted, false if not. */ - bool EnchantByXPLevels(int a_NumXPLevels); // tolua_export + bool EnchantByXPLevels(int a_NumXPLevels); // tolua_export // tolua_begin diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index 33bc08467..403a3e097 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -495,7 +495,7 @@ void cLightingThread::CalcLight(NIBBLETYPE * a_Light) void cLightingThread::CalcLightStep( - NIBBLETYPE * a_Light, + NIBBLETYPE * a_Light, int a_NumSeedsIn, unsigned char * a_IsSeedIn, unsigned int * a_SeedIdxIn, int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut ) diff --git a/src/LightingThread.h b/src/LightingThread.h index a484fcbed..f71d2cf1a 100644 --- a/src/LightingThread.h +++ b/src/LightingThread.h @@ -16,7 +16,7 @@ Lighting is calculated in a flood-fill fashion: The seeds need two fast operations: - Check if a block at [x, y, z] is already a seed - Get the next seed in the row -For that reason it is stored in two arrays, one stores a bool saying a seed is in that position, +For that reason it is stored in two arrays, one stores a bool saying a seed is in that position, the other is an array of seed coords, encoded as a single int. Step 2 needs two separate storages for old seeds and new seeds, so there are two actual storages for that purpose, their content is swapped after each full step-2-cycle. @@ -82,7 +82,7 @@ protected: cLightingChunkStay(cLightingThread & a_LightingThread, int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_CallbackAfter); protected: - virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override + virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); @@ -157,7 +157,7 @@ protected: /** Does one step in the light calculation - one seed propagation and seed recalculation */ void CalcLightStep( - NIBBLETYPE * a_Light, + NIBBLETYPE * a_Light, int a_NumSeedsIn, unsigned char * a_IsSeedIn, unsigned int * a_SeedIdxIn, int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut ); @@ -166,7 +166,7 @@ protected: void CompressLight(NIBBLETYPE * a_LightArray, NIBBLETYPE * a_ChunkLight); inline void PropagateLight( - NIBBLETYPE * a_Light, + NIBBLETYPE * a_Light, unsigned int a_SrcIdx, unsigned int a_DstIdx, int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut ) diff --git a/src/Log.h b/src/Log.h index d6a406154..dc88aa92f 100644 --- a/src/Log.h +++ b/src/Log.h @@ -6,7 +6,7 @@ class cLog -{ // tolua_export +{ private: FILE * m_File; static cLog * s_Log; @@ -23,7 +23,7 @@ public: void ClearLog(); static cLog* GetInstance(); }; -// tolua_end + diff --git a/src/MCLogger.h b/src/MCLogger.h index 114210f63..aa3a52d02 100644 --- a/src/MCLogger.h +++ b/src/MCLogger.h @@ -10,7 +10,6 @@ class cLog; -// tolua_begin class cMCLogger { public: @@ -27,9 +26,9 @@ public: cMCLogger(void); /** Creates a logger with the specified filename inside "logs" folder */ - cMCLogger(const AString & a_FileName); // tolua_export + cMCLogger(const AString & a_FileName); - ~cMCLogger(); // tolua_export + ~cMCLogger(); void Log (const char * a_Format, va_list a_ArgList) FORMATSTRING(2, 0); void Info (const char * a_Format, va_list a_ArgList) FORMATSTRING(2, 0); @@ -37,7 +36,7 @@ public: void Error(const char * a_Format, va_list a_ArgList) FORMATSTRING(2, 0); /** Logs the simple text message at the specified log level. */ - void LogSimple(const char * a_Text, eLogLevel a_LogLevel = llRegular); // tolua_export + void LogSimple(const char * a_Text, eLogLevel a_LogLevel = llRegular); static cMCLogger * GetInstance(); private: @@ -63,7 +62,7 @@ private: /// Common initialization for all constructors, creates a logfile with the specified name and assigns s_MCLogger to this void InitLog(const AString & a_FileName); -}; // tolua_export +}; diff --git a/src/Map.h b/src/Map.h index e23ca2c92..6bb2d62c6 100644 --- a/src/Map.h +++ b/src/Map.h @@ -29,13 +29,12 @@ class cMap; /** Encapsulates a map decorator. - * - * A map decorator represents an object drawn on the map that can move freely. - * (e.g. player trackers and item frame pointers) - * - * Excluding manually placed decorators, - * decorators are automatically managed (allocated and freed) by their parent cMap instance. - */ +A map decorator represents an object drawn on the map that can move freely. +(e.g. player trackers and item frame pointers) + +Excluding manually placed decorators, +decorators are automatically managed (allocated and freed) by their parent cMap instance. +*/ class cMapDecorator { public: @@ -194,10 +193,9 @@ public: protected: /** Encapsulates the state of a map client. - * - * In order to enhance performace, maps are streamed column-by-column to each client. - * This structure stores the state of the stream. - */ + In order to enhance performace, maps are streamed column-by-column to each client. + This structure stores the state of the stream. + */ struct cMapClient { cClientHandle * m_Handle; diff --git a/src/MapManager.h b/src/MapManager.h index ceab8f126..3cd6c08cd 100644 --- a/src/MapManager.h +++ b/src/MapManager.h @@ -32,25 +32,22 @@ public: cMapManager(cWorld * a_World); /** Returns the map with the specified ID, NULL if out of range. - * - * WARNING: The returned map object is not thread safe. - */ + WARNING: The returned map object is not thread safe. + */ cMap * GetMapData(unsigned int a_ID); /** Creates a new map. Returns NULL on error */ cMap * CreateMap(int a_CenterX, int a_CenterY, int a_Scale = 3); /** Calls the callback for the map with the specified ID. - * - * Returns true if the map was found and the callback called, false if map not found. - * Callback return ignored. - */ + Returns true if the map was found and the callback called, false if map not found. + Callback return value is ignored. + */ bool DoWithMap(int a_ID, cMapCallback & a_Callback); // Exported in ManualBindings.cpp - /** Calls the callback for each map. - * - * Returns true if all maps processed, false if the callback aborted by returning true. - */ + /** Calls the callback for each map. + Returns true if all maps processed, false if the callback aborted by returning true. + */ bool ForEachMap(cMapCallback & a_Callback); size_t GetNumMaps(void) const; // tolua_export diff --git a/src/Matrix4.h b/src/Matrix4.h index 456677f0f..557057aca 100644 --- a/src/Matrix4.h +++ b/src/Matrix4.h @@ -104,7 +104,7 @@ public: } inline void Translate(const Vector3 & a_Pos) - { + { cell[3] += a_Pos.x; cell[7] += a_Pos.y; cell[11] += a_Pos.z; diff --git a/src/MobCensus.cpp b/src/MobCensus.cpp index 23f74b59e..d5a341ef7 100644 --- a/src/MobCensus.cpp +++ b/src/MobCensus.cpp @@ -21,7 +21,7 @@ bool cMobCensus::IsCapped(cMonster::eFamily a_MobFamily) { const int ratio = 319; // this should be 256 as we are only supposed to take account from chunks that are in 17x17 from a player // but for now, we use all chunks loaded by players. that means 19 x 19 chunks. That's why we use 256 * (19*19) / (17*17) = 319 - // MG TODO : code the correct count + // MG TODO : code the correct count if ((GetCapMultiplier(a_MobFamily) * GetNumChunks()) / ratio >= m_MobFamilyCollecter.GetNumberOfCollectedMobs(a_MobFamily)) { return false; diff --git a/src/MobFamilyCollecter.h b/src/MobFamilyCollecter.h index 6cef133b5..362814c8f 100644 --- a/src/MobFamilyCollecter.h +++ b/src/MobFamilyCollecter.h @@ -29,7 +29,7 @@ public : // return the number of mobs for this family int GetNumberOfCollectedMobs(cMonster::eFamily a_Family); -protected : +protected : std::map > m_Mobs; } ; diff --git a/src/MobProximityCounter.cpp b/src/MobProximityCounter.cpp index ce20bf56b..35bf57380 100644 --- a/src/MobProximityCounter.cpp +++ b/src/MobProximityCounter.cpp @@ -8,7 +8,7 @@ void cMobProximityCounter::CollectMob(cEntity& a_Monster, cChunk& a_Chunk, double a_Distance) { -// LOGD("Collecting monster %s, with distance %f",a_Monster->GetClass(),a_Distance); + // LOGD("Collecting monster %s, with distance %f",a_Monster->GetClass(),a_Distance); tMonsterToDistance::iterator it = m_MonsterToDistance.find(&a_Monster); if (it == m_MonsterToDistance.end()) { diff --git a/src/MobProximityCounter.h b/src/MobProximityCounter.h index 79429eb60..cadfc48ae 100644 --- a/src/MobProximityCounter.h +++ b/src/MobProximityCounter.h @@ -27,11 +27,11 @@ protected : cChunk& m_Chunk; }; -public : +public : typedef std::map tMonsterToDistance; typedef std::multimap tDistanceToMonster; -protected : +protected : // this map is filled during collection phase, it will be later transformed into DistanceToMonster tMonsterToDistance m_MonsterToDistance; @@ -41,7 +41,7 @@ protected : // this are the collected chunks. Used to determinate the number of elligible chunk for spawning. std::set m_EligibleForSpawnChunks; -protected : +protected : // transform monsterToDistance map (that was usefull for collecting) into distanceToMonster // that will be usefull for picking up. void convertMaps(); diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index de8e01b8a..da3e7c406 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -91,7 +91,7 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome) addIfAllowed(cMonster::mtCow, allowedMobs); addIfAllowed(cMonster::mtChicken, allowedMobs); addIfAllowed(cMonster::mtEnderman, allowedMobs); - addIfAllowed(cMonster::mtSlime, allowedMobs); // MG TODO : much more complicated rule + addIfAllowed(cMonster::mtSlime, allowedMobs); // MG TODO : much more complicated rule if (a_Biome == biForest || a_Biome == biForestHills || a_Biome == biTaiga || a_Biome == biTaigaHills) { diff --git a/src/MobSpawner.h b/src/MobSpawner.h index ea6636310..aa2935916 100644 --- a/src/MobSpawner.h +++ b/src/MobSpawner.h @@ -51,7 +51,7 @@ public : typedef const std::set tSpawnedContainer; tSpawnedContainer & getSpawned(void); -protected : +protected : // return true if specified type of mob can spawn on specified block bool CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome); @@ -62,7 +62,7 @@ protected : // add toAdd inside toAddIn, if toAdd is in m_AllowedTypes void addIfAllowed(cMonster::eType toAdd, std::set & toAddIn); -protected : +protected : cMonster::eFamily m_MonsterFamily; std::set m_AllowedTypes; bool m_NewPack; diff --git a/src/Noise.cpp b/src/Noise.cpp index fbd2a1800..e7b055ead 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -487,8 +487,8 @@ NOISE_DATATYPE cNoise::SmoothNoise1D(int a_X) const NOISE_DATATYPE cNoise::CubicNoise2D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y) const { - const int BaseX = FAST_FLOOR(a_X); - const int BaseY = FAST_FLOOR(a_Y); + const int BaseX = FAST_FLOOR(a_X); + const int BaseY = FAST_FLOOR(a_Y); const NOISE_DATATYPE points[4][4] = { @@ -515,28 +515,28 @@ NOISE_DATATYPE cNoise::CubicNoise2D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y) cons NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOISE_DATATYPE a_Z) const { - const int BaseX = FAST_FLOOR(a_X); - const int BaseY = FAST_FLOOR(a_Y); - const int BaseZ = FAST_FLOOR(a_Z); + const int BaseX = FAST_FLOOR(a_X); + const int BaseY = FAST_FLOOR(a_Y); + const int BaseZ = FAST_FLOOR(a_Z); - const NOISE_DATATYPE points1[4][4] = { + const NOISE_DATATYPE points1[4][4] = { { IntNoise3D(BaseX - 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY - 1, BaseZ - 1), }, { IntNoise3D(BaseX - 1, BaseY, BaseZ - 1), IntNoise3D(BaseX, BaseY, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY, BaseZ - 1), }, { IntNoise3D(BaseX - 1, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY + 1, BaseZ - 1), }, { IntNoise3D(BaseX - 1, BaseY + 2, BaseZ - 1), IntNoise3D(BaseX, BaseY + 2, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY + 2, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY + 2, BaseZ - 1), }, }; - const NOISE_DATATYPE FracX = (a_X) - BaseX; + const NOISE_DATATYPE FracX = (a_X) - BaseX; const NOISE_DATATYPE x1interp1 = CubicInterpolate( points1[0][0], points1[0][1], points1[0][2], points1[0][3], FracX ); const NOISE_DATATYPE x1interp2 = CubicInterpolate( points1[1][0], points1[1][1], points1[1][2], points1[1][3], FracX ); const NOISE_DATATYPE x1interp3 = CubicInterpolate( points1[2][0], points1[2][1], points1[2][2], points1[2][3], FracX ); const NOISE_DATATYPE x1interp4 = CubicInterpolate( points1[3][0], points1[3][1], points1[3][2], points1[3][3], FracX ); - const NOISE_DATATYPE points2[4][4] = { - { IntNoise3D( BaseX-1, BaseY-1, BaseZ ), IntNoise3D( BaseX, BaseY-1, BaseZ ), IntNoise3D( BaseX+1, BaseY-1, BaseZ ), IntNoise3D( BaseX+2, BaseY-1, BaseZ ), }, - { IntNoise3D( BaseX-1, BaseY, BaseZ ), IntNoise3D( BaseX, BaseY, BaseZ ), IntNoise3D( BaseX+1, BaseY, BaseZ ), IntNoise3D( BaseX+2, BaseY, BaseZ ), }, - { IntNoise3D( BaseX-1, BaseY+1, BaseZ ), IntNoise3D( BaseX, BaseY+1, BaseZ ), IntNoise3D( BaseX+1, BaseY+1, BaseZ ), IntNoise3D( BaseX+2, BaseY+1, BaseZ ), }, - { IntNoise3D( BaseX-1, BaseY+2, BaseZ ), IntNoise3D( BaseX, BaseY+2, BaseZ ), IntNoise3D( BaseX+1, BaseY+2, BaseZ ), IntNoise3D( BaseX+2, BaseY+2, BaseZ ), }, + const NOISE_DATATYPE points2[4][4] = { + { IntNoise3D(BaseX - 1, BaseY - 1, BaseZ), IntNoise3D(BaseX, BaseY - 1, BaseZ), IntNoise3D(BaseX + 1, BaseY - 1, BaseZ), IntNoise3D(BaseX + 2, BaseY - 1, BaseZ), }, + { IntNoise3D(BaseX - 1, BaseY, BaseZ), IntNoise3D(BaseX, BaseY, BaseZ), IntNoise3D(BaseX + 1, BaseY, BaseZ), IntNoise3D(BaseX + 2, BaseY, BaseZ), }, + { IntNoise3D(BaseX - 1, BaseY + 1, BaseZ), IntNoise3D(BaseX, BaseY + 1, BaseZ), IntNoise3D(BaseX + 1, BaseY + 1, BaseZ), IntNoise3D(BaseX + 2, BaseY + 1, BaseZ), }, + { IntNoise3D(BaseX - 1, BaseY + 2, BaseZ), IntNoise3D(BaseX, BaseY + 2, BaseZ), IntNoise3D(BaseX + 1, BaseY + 2, BaseZ), IntNoise3D(BaseX + 2, BaseY + 2, BaseZ), }, }; const NOISE_DATATYPE x2interp1 = CubicInterpolate( points2[0][0], points2[0][1], points2[0][2], points2[0][3], FracX ); @@ -544,11 +544,11 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS const NOISE_DATATYPE x2interp3 = CubicInterpolate( points2[2][0], points2[2][1], points2[2][2], points2[2][3], FracX ); const NOISE_DATATYPE x2interp4 = CubicInterpolate( points2[3][0], points2[3][1], points2[3][2], points2[3][3], FracX ); - const NOISE_DATATYPE points3[4][4] = { - { IntNoise3D( BaseX-1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ + 1), }, - { IntNoise3D( BaseX-1, BaseY, BaseZ+1 ), IntNoise3D( BaseX, BaseY, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY, BaseZ + 1), }, - { IntNoise3D( BaseX-1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ + 1), }, - { IntNoise3D( BaseX-1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ + 1), }, + const NOISE_DATATYPE points3[4][4] = { + { IntNoise3D( BaseX-1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ + 1), }, + { IntNoise3D( BaseX-1, BaseY, BaseZ+1 ), IntNoise3D( BaseX, BaseY, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY, BaseZ + 1), }, + { IntNoise3D( BaseX-1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ + 1), }, + { IntNoise3D( BaseX-1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ + 1), }, }; const NOISE_DATATYPE x3interp1 = CubicInterpolate( points3[0][0], points3[0][1], points3[0][2], points3[0][3], FracX ); @@ -556,11 +556,11 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS const NOISE_DATATYPE x3interp3 = CubicInterpolate( points3[2][0], points3[2][1], points3[2][2], points3[2][3], FracX ); const NOISE_DATATYPE x3interp4 = CubicInterpolate( points3[3][0], points3[3][1], points3[3][2], points3[3][3], FracX ); - const NOISE_DATATYPE points4[4][4] = { - { IntNoise3D( BaseX-1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2 ), }, - { IntNoise3D( BaseX-1, BaseY, BaseZ+2 ), IntNoise3D( BaseX, BaseY, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY, BaseZ+2 ), }, - { IntNoise3D( BaseX-1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2 ), }, - { IntNoise3D( BaseX-1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ+2 ), }, + const NOISE_DATATYPE points4[4][4] = { + { IntNoise3D( BaseX-1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2 ), }, + { IntNoise3D( BaseX-1, BaseY, BaseZ+2 ), IntNoise3D( BaseX, BaseY, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY, BaseZ+2 ), }, + { IntNoise3D( BaseX-1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2 ), }, + { IntNoise3D( BaseX-1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ+2 ), }, }; const NOISE_DATATYPE x4interp1 = CubicInterpolate( points4[0][0], points4[0][1], points4[0][2], points4[0][3], FracX ); @@ -568,13 +568,13 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS const NOISE_DATATYPE x4interp3 = CubicInterpolate( points4[2][0], points4[2][1], points4[2][2], points4[2][3], FracX ); const NOISE_DATATYPE x4interp4 = CubicInterpolate( points4[3][0], points4[3][1], points4[3][2], points4[3][3], FracX ); - const NOISE_DATATYPE FracY = (a_Y) - BaseY; + const NOISE_DATATYPE FracY = (a_Y) - BaseY; const NOISE_DATATYPE yinterp1 = CubicInterpolate( x1interp1, x1interp2, x1interp3, x1interp4, FracY ); const NOISE_DATATYPE yinterp2 = CubicInterpolate( x2interp1, x2interp2, x2interp3, x2interp4, FracY ); const NOISE_DATATYPE yinterp3 = CubicInterpolate( x3interp1, x3interp2, x3interp3, x3interp4, FracY ); const NOISE_DATATYPE yinterp4 = CubicInterpolate( x4interp1, x4interp2, x4interp3, x4interp4, FracY ); - const NOISE_DATATYPE FracZ = (a_Z) - BaseZ; + const NOISE_DATATYPE FracZ = (a_Z) - BaseZ; return CubicInterpolate( yinterp1, yinterp2, yinterp3, yinterp4, FracZ ); } @@ -631,7 +631,7 @@ void cCubicNoise::Generate2D( Cell.InitWorkRnds(FloorX[0], FloorY[0]); #ifdef _DEBUG - // Statistics on the noise-space coords: + // Statistics on the noise-space coords: if (NumSameX == 1) { m_NumSingleX++; diff --git a/src/Noise.h b/src/Noise.h index 83af0cf08..014e43239 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -100,7 +100,7 @@ protected: cNoise m_Noise; // Used for integral rnd values #ifdef _DEBUG - // Statistics on the noise-space coords: + // Statistics on the noise-space coords: static int m_NumSingleX; static int m_NumSingleXY; static int m_NumSingleY; diff --git a/src/Root.cpp b/src/Root.cpp index ec1351ef1..235a1b108 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -84,7 +84,7 @@ void cRoot::InputThread(void * a_Params) AString Command; std::getline(std::cin, Command); if (!Command.empty()) - { + { self.ExecuteConsoleCommand(TrimString(Command), Output); } } @@ -194,7 +194,7 @@ void cRoot::Start(void) #if !defined(ANDROID_NDK) LOGD("Starting InputThread..."); m_InputThread = new cThread( InputThread, this, "cRoot::InputThread" ); - m_InputThread->Start( false ); // We should NOT wait? Otherwise we can't stop the server from other threads than the input thread + m_InputThread->Start( false ); // We should NOT wait? Otherwise we can't stop the server from other threads than the input thread #endif long long finishmseconds = Time.GetNowTime(); @@ -687,7 +687,7 @@ int cRoot::GetVirtualRAMUsage(void) &t_info_count )) { - return (int)(t_info.virtual_size / 1024); + return (int)(t_info.virtual_size / 1024); } return -1; #else @@ -739,7 +739,7 @@ int cRoot::GetPhysicalRAMUsage(void) &t_info_count )) { - return (int)(t_info.resident_size / 1024); + return (int)(t_info.resident_size / 1024); } return -1; #else diff --git a/src/Root.h b/src/Root.h index 4a3c205d3..acd3e9754 100644 --- a/src/Root.h +++ b/src/Root.h @@ -36,20 +36,24 @@ namespace Json /// The root of the object hierarchy -class cRoot // tolua_export -{ // tolua_export +// tolua_begin +class cRoot +{ public: - static cRoot * Get() { return s_Root; } // tolua_export + static cRoot * Get() { return s_Root; } + // tolua_end cRoot(void); ~cRoot(); void Start(void); - cServer * GetServer(void) { return m_Server; } // tolua_export - cWorld * GetDefaultWorld(void); // tolua_export - cWorld * GetWorld(const AString & a_WorldName); // tolua_export - cWorld * CreateAndInitializeWorld(const AString & a_WorldName); // tolua_export + // tolua_begin + cServer * GetServer(void) { return m_Server; } + cWorld * GetDefaultWorld(void); + cWorld * GetWorld(const AString & a_WorldName); + cWorld * CreateAndInitializeWorld(const AString & a_WorldName); + // tolua_end /// Calls the callback for each world; returns true if the callback didn't abort (return true) bool ForEachWorld(cWorldListCallback & a_Callback); // >> Exported in ManualBindings << @@ -106,13 +110,13 @@ public: void SaveAllChunks(void); // tolua_export /// Reloads all the groups - void ReloadGroups(void); // tolua_export + void ReloadGroups(void); // tolua_export /// Calls the callback for each player in all worlds - bool ForEachPlayer(cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << + bool ForEachPlayer(cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << /// Finds a player from a partial or complete player name and calls the callback - case-insensitive - bool FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << + bool FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << // tolua_begin @@ -202,8 +206,8 @@ private: static void InputThread(void* a_Params); - static cRoot* s_Root; -}; // tolua_export + static cRoot* s_Root; +}; // tolua_export diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp index 250f63aa9..8695f0fb7 100644 --- a/src/Scoreboard.cpp +++ b/src/Scoreboard.cpp @@ -197,15 +197,18 @@ void cObjective::SendTo(cClientHandle & a_Client) -cTeam::cTeam(const AString & a_Name, const AString & a_DisplayName, - const AString & a_Prefix, const AString & a_Suffix) +cTeam::cTeam( + const AString & a_Name, const AString & a_DisplayName, + const AString & a_Prefix, const AString & a_Suffix +) : m_AllowsFriendlyFire(true) , m_CanSeeFriendlyInvisible(false) , m_DisplayName(a_DisplayName) , m_Name(a_Name) , m_Prefix(a_Prefix) , m_Suffix(a_Suffix) -{} +{ +} diff --git a/src/Scoreboard.h b/src/Scoreboard.h index 1e1973a10..5f91535f8 100644 --- a/src/Scoreboard.h +++ b/src/Scoreboard.h @@ -259,25 +259,22 @@ public: /** Send this scoreboard to the specified client */ void SendTo(cClientHandle & a_Client); - cTeam * QueryPlayerTeam(const AString & a_Name); // WARNING: O(n logn) + cTeam * QueryPlayerTeam(const AString & a_Name); // WARNING: O(n logn) - /** Execute callback for each objective with the specified type - * - * Returns true if all objectives processed, false if the callback aborted by returning true. - */ + /** Execute callback for each objective with the specified type + Returns true if all objectives processed, false if the callback aborted by returning true. + */ bool ForEachObjectiveWith(cObjective::eType a_Type, cObjectiveCallback& a_Callback); /** Execute callback for each objective. - * - * Returns true if all objectives have been processed, false if the callback aborted by returning true. - */ - bool ForEachObjective(cObjectiveCallback& a_Callback); // Exported in ManualBindings.cpp + Returns true if all objectives have been processed, false if the callback aborted by returning true. + */ + bool ForEachObjective(cObjectiveCallback& a_Callback); // Exported in ManualBindings.cpp /** Execute callback for each team. - * - * Returns true if all teams have been processed, false if the callback aborted by returning true. - */ - bool ForEachTeam(cTeamCallback& a_Callback); // Exported in ManualBindings.cpp + Returns true if all teams have been processed, false if the callback aborted by returning true. + */ + bool ForEachTeam(cTeamCallback& a_Callback); // Exported in ManualBindings.cpp void SetDisplay(cObjective * a_Objective, eDisplaySlot a_Slot); diff --git a/src/Server.h b/src/Server.h index cf5fa524f..a6b7297e8 100644 --- a/src/Server.h +++ b/src/Server.h @@ -50,10 +50,10 @@ namespace Json -class cServer // tolua_export +class cServer // tolua_export : public cListenThread::cCallback -{ // tolua_export -public: // tolua_export +{ // tolua_export +public: // tolua_export virtual ~cServer() {} bool InitServer(cIniFile & a_SettingsIni); @@ -149,7 +149,7 @@ private: virtual void Execute(void); - public: + public: cNotifyWriteThread(void); ~cNotifyWriteThread(); diff --git a/src/Statistics.h b/src/Statistics.h index f37f32e1e..49750e8c0 100644 --- a/src/Statistics.h +++ b/src/Statistics.h @@ -62,7 +62,7 @@ enum eStatistic statDistDove, statDistMinecart, statDistBoat, - statDistPig, + statDistPig, statDistHorse, statJumps, statItemsDropped, @@ -143,10 +143,9 @@ public: /** Reset everything. */ void Reset(); - /** Increment the specified stat. - * - * Returns the new value. - */ + /** Increments the specified stat. + Returns the new value. + */ StatValue AddValue(const eStatistic a_Stat, const StatValue a_Delta = 1); // tolua_end diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 7488a3073..9429157a9 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -233,13 +233,13 @@ AString & StrToLower(AString & s) int NoCaseCompare(const AString & s1, const AString & s2) { #ifdef _MSC_VER - // MSVC has stricmp that compares case-insensitive: - return _stricmp(s1.c_str(), s2.c_str()); - #else - // Do it the hard way: - AString s1Copy(s1); - AString s2Copy(s2); - return StrToUpper(s1Copy).compare(StrToUpper(s2Copy)); + // MSVC has stricmp that compares case-insensitive: + return _stricmp(s1.c_str(), s2.c_str()); + #else + // Do it the hard way: + AString s1Copy(s1); + AString s2Copy(s2); + return StrToUpper(s1Copy).compare(StrToUpper(s2Copy)); #endif // else _MSC_VER } @@ -346,9 +346,9 @@ AString & RawBEToUTF8(const char * a_RawData, size_t a_NumShorts, AString & a_UT /* Notice from the original file: * Copyright 2001-2004 Unicode, Inc. -* +* * Disclaimer -* +* * This source code is provided as is by Unicode, Inc. No claims are * made as to fitness for any particular purpose. No warranties of any * kind are expressed or implied. The recipient agrees to determine @@ -356,9 +356,9 @@ Notice from the original file: * purchased on magnetic or optical media from Unicode, Inc., the * sole remedy for any claim will be exchange of defective media * within 90 days of receipt. -* +* * Limitations on Rights to Redistribute This Code -* +* * Unicode, Inc. hereby grants the right to freely use the information * supplied in this file in the creation of products supporting the * Unicode Standard, and to make copies of this file in any form @@ -378,13 +378,13 @@ Notice from the original file: static const char trailingBytesForUTF8[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 }; @@ -394,7 +394,7 @@ static const char trailingBytesForUTF8[256] = static const unsigned int offsetsFromUTF8[6] = { - 0x00000000UL, 0x00003080UL, 0x000E2080UL, + 0x00000000UL, 0x00003080UL, 0x000E2080UL, 0x03C82080UL, 0xFA082080UL, 0x82082080UL }; @@ -502,22 +502,21 @@ AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a return a_UTF16; } -/* --------------------------------------------------------------------- - - Note A. - The fall-through switches in UTF-8 reading code save a - temp variable, some decrements & conditionals. The switches - are equivalent to the following loop: - { - int tmpBytesToRead = extraBytesToRead+1; - do { - ch += *source++; - --tmpBytesToRead; - if (tmpBytesToRead) ch <<= 6; - } while (tmpBytesToRead > 0); - } - - --------------------------------------------------------------------- +/* +--------------------------------------------------------------------- +Note A. +The fall-through switches in UTF-8 reading code save a +temp variable, some decrements & conditionals. The switches +are equivalent to the following loop: +{ + int tmpBytesToRead = extraBytesToRead+1; + do { + ch += *source++; + --tmpBytesToRead; + if (tmpBytesToRead) ch <<= 6; + } while (tmpBytesToRead > 0); +} +--------------------------------------------------------------------- */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -761,7 +760,7 @@ AString Base64Decode(const AString & a_Base64String) { switch (o & 7) { - case 0: res[o >> 3] |= (c << 2); break; + case 0: res[o >> 3] |= (c << 2); break; case 6: res[o >> 3] |= (c >> 4); res[(o >> 3) + 1] |= (c << 4); break; case 4: res[o >> 3] |= (c >> 2); res[(o >> 3) + 1] |= (c << 6); break; case 2: res[o >> 3] |= c; break; diff --git a/src/StringUtils.h b/src/StringUtils.h index 87b574a34..30b9904d1 100644 --- a/src/StringUtils.h +++ b/src/StringUtils.h @@ -6,10 +6,7 @@ -#ifndef STRINGUTILS_H_INCLUDED -#define STRINGUTILS_H_INCLUDED - - +#pragma once #include @@ -101,8 +98,3 @@ extern void SetBEInt(char * a_Mem, Int32 a_Value); -#endif // STRINGUTILS_H_INCLUDED - - - - diff --git a/src/Tracer.h b/src/Tracer.h index bdb080f0d..4d932e460 100644 --- a/src/Tracer.h +++ b/src/Tracer.h @@ -53,7 +53,7 @@ private: /// Calculates where on the block a collision occured, if it does occur /// Returns 0 if no intersection occured /// Returns 1 if an intersection occured at a single point - /// Returns 2 if the line segment lies in the plane being checked + /// Returns 2 if the line segment lies in the plane being checked int intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal ); /// Determines which face on the block a collision occured, if it does occur diff --git a/src/World.cpp b/src/World.cpp index f7279e9bc..b3284942a 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -99,7 +99,7 @@ protected: { for (;;) { - LOG("" SIZE_T_FMT " chunks to load, %d chunks to generate", + LOG("" SIZE_T_FMT " chunks to load, %d chunks to generate", m_World->GetStorage().GetLoadQueueLength(), m_World->GetGenerator().GetQueueLength() ); @@ -2226,7 +2226,7 @@ void cWorld::SetChunkData( const NIBBLETYPE * a_BlockSkyLight, const cChunkDef::HeightMap * a_HeightMap, const cChunkDef::BiomeMap * a_BiomeMap, - cEntityList & a_Entities, + cEntityList & a_Entities, cBlockEntityList & a_BlockEntities, bool a_MarkDirty ) @@ -2242,7 +2242,7 @@ void cWorld::SetChunkData( } m_ChunkMap->SetChunkData( - a_ChunkX, a_ChunkZ, + a_ChunkX, a_ChunkZ, a_BlockTypes, a_BlockMeta, a_BlockLight, a_BlockSkyLight, a_HeightMap, *Biomes, a_BlockEntities, @@ -2872,7 +2872,7 @@ void cWorld::RemoveEntity(cEntity * a_Entity) unsigned int cWorld::GetNumPlayers(void) { cCSLock Lock(m_CSPlayers); - return m_Players.size(); + return m_Players.size(); } */ @@ -2920,7 +2920,7 @@ void cWorld::TickQueuedBlocks(void) } else { - m_BlockTickQueue.push_back(Block); // Keep the block in the queue + m_BlockTickQueue.push_back(Block); // Keep the block in the queue } } // for itr - m_BlockTickQueueCopy[] } diff --git a/src/World.h b/src/World.h index 5bb0e640f..a3b152a80 100644 --- a/src/World.h +++ b/src/World.h @@ -140,7 +140,7 @@ public: int GetTicksUntilWeatherChange(void) const { return m_WeatherInterval; } virtual Int64 GetWorldAge (void) const override { return m_WorldAge; } - virtual Int64 GetTimeOfDay(void) const override { return m_TimeOfDay; } + virtual Int64 GetTimeOfDay(void) const override { return m_TimeOfDay; } void SetTicksUntilWeatherChange(int a_WeatherInterval) { @@ -301,10 +301,10 @@ public: bool DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << /** Finds a player from a partial or complete player name and calls the callback - case-insensitive */ - bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << + bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << // TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action) - cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true); + cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true); void SendPlayerList(cPlayer * a_DestPlayer); // Sends playerlist to the player @@ -365,10 +365,10 @@ public: bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp /** Sets the sign text, asking plugins for permission first. a_Player is the player who this change belongs to, may be NULL. Returns true if sign text changed. Same as SetSignLines() */ - bool UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp + bool UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp /** Sets the command block command. Returns true if command changed. */ - bool SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Command); // tolua_export + bool SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Command); // tolua_export /** Is the trapdoor open? Returns false if there is no trapdoor at the specified coords. */ bool IsTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export @@ -377,10 +377,10 @@ public: bool SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open); // tolua_export /** Regenerate the given chunk: */ - void RegenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export + void RegenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export /** Generates the given chunk, if not already generated */ - void GenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export + void GenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export /** Queues a chunk for lighting; a_Callback is called after the chunk is lighted */ void QueueLightChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback = NULL); diff --git a/src/XMLParser.h b/src/XMLParser.h index f492d1a5d..28fa05579 100644 --- a/src/XMLParser.h +++ b/src/XMLParser.h @@ -61,7 +61,7 @@ protected: // It uses templates to remove the virtual function call penalty (both size and speed) for each callback /* Usage: -1, Declare a subclass: +1, Declare a subclass: class CMyParser : public CExpatImpl 2, Declare handlers that you want in that subclass: void CMyParser::OnEndElement(const XML_Char * iTagName); @@ -318,7 +318,7 @@ protected: void EnableEndDoctypeDeclHandler (bool fEnable = true) { assert (m_p != NULL); - XML_SetEndDoctypeDeclHandler (m_p, + XML_SetEndDoctypeDeclHandler (m_p, fEnable ? EndDoctypeDeclHandler : NULL); } @@ -336,7 +336,7 @@ public: // @cmember Get last error - enum XML_Error GetErrorCode () + enum XML_Error GetErrorCode () { assert (m_p != NULL); return XML_GetErrorCode (m_p); @@ -344,7 +344,7 @@ public: // @cmember Get the current byte index - long GetCurrentByteIndex () + long GetCurrentByteIndex () { assert (m_p != NULL); return XML_GetCurrentByteIndex (m_p); @@ -352,7 +352,7 @@ public: // @cmember Get the current line number - int GetCurrentLineNumber () + int GetCurrentLineNumber () { assert (m_p != NULL); return XML_GetCurrentLineNumber (m_p); @@ -360,7 +360,7 @@ public: // @cmember Get the current column number - int GetCurrentColumnNumber () + int GetCurrentColumnNumber () { assert (m_p != NULL); return XML_GetCurrentColumnNumber (m_p); @@ -368,7 +368,7 @@ public: // @cmember Get the current byte count - int GetCurrentByteCount () + int GetCurrentByteCount () { assert (m_p != NULL); return XML_GetCurrentByteCount (m_p); @@ -384,7 +384,7 @@ public: // @cmember Get last error string - const XML_LChar *GetErrorString () + const XML_LChar *GetErrorString () { return XML_ErrorString (GetErrorCode ()); } @@ -411,7 +411,7 @@ public: // @cmember Get last error string - static const XML_LChar *GetErrorString (enum XML_Error nError) + static const XML_LChar *GetErrorString (enum XML_Error nError) { return XML_ErrorString (nError); } @@ -443,7 +443,7 @@ public: // @cmember Processing instruction handler - void OnProcessingInstruction (const XML_Char *pszTarget, + void OnProcessingInstruction (const XML_Char *pszTarget, const XML_Char *pszData) { return; @@ -495,7 +495,7 @@ public: // @cmember Start namespace declaration handler - void OnStartNamespaceDecl (const XML_Char *pszPrefix, + void OnStartNamespaceDecl (const XML_Char *pszPrefix, const XML_Char *pszURI) { return; @@ -518,7 +518,7 @@ public: // @cmember Start DOCTYPE declaration handler - void OnStartDoctypeDecl (const XML_Char *pszDoctypeName, + void OnStartDoctypeDecl (const XML_Char *pszDoctypeName, const XML_Char *pszSysID, const XML_Char *pszPubID, bool fHasInternalSubset) { @@ -607,7 +607,7 @@ protected: // @cmember Default wrapper - static void __cdecl DefaultHandler (void *pUserData, + static void __cdecl DefaultHandler (void *pUserData, const XML_Char *pszData, int nLength) { _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData); @@ -616,12 +616,12 @@ protected: // @cmember External entity ref wrapper - static int __cdecl ExternalEntityRefHandler (void *pUserData, - const XML_Char *pszContext, const XML_Char *pszBase, + static int __cdecl ExternalEntityRefHandler (void *pUserData, + const XML_Char *pszContext, const XML_Char *pszBase, const XML_Char *pszSystemID, const XML_Char *pszPublicID) { _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData); - return pThis ->OnExternalEntityRef (pszContext, + return pThis ->OnExternalEntityRef (pszContext, pszBase, pszSystemID, pszPublicID) ? 1 : 0; } @@ -660,12 +660,12 @@ protected: // @cmember Start Doctype declaration wrapper static void __cdecl StartDoctypeDeclHandler ( - void *pUserData, const XML_Char *pszDoctypeName, const XML_Char *pszSysID, + void *pUserData, const XML_Char *pszDoctypeName, const XML_Char *pszSysID, const XML_Char *pszPubID, int nHasInternalSubset ) { _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData); - pThis ->OnStartDoctypeDecl (pszDoctypeName, pszSysID, + pThis ->OnStartDoctypeDecl (pszDoctypeName, pszSysID, pszPubID, nHasInternalSubset != 0); } diff --git a/src/main.cpp b/src/main.cpp index 6925d9ff1..c8ff31f07 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,7 +49,7 @@ bool g_ShouldLogCommOut; -void NonCtrlHandler(int a_Signal) +void NonCtrlHandler(int a_Signal) { LOGD("Terminate event raised from std::signal"); g_TERMINATE_EVENT_RAISED = true; @@ -277,7 +277,7 @@ int main( int argc, char **argv ) try #endif { - cRoot Root; + cRoot Root; Root.Start(); } #if !defined(ANDROID_NDK) -- cgit v1.2.3 From 7fff12bfacbb4bef1c02cea0ec10fdc9a6fb64e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 19:13:23 +0200 Subject: Fixed spaces around single-line comments. There should be at least two spaces in front and one space after //-style comments. --- src/BlockID.h | 2 +- src/BlockInfo.h | 2 +- src/Chunk.cpp | 22 +++++++++++----------- src/Chunk.h | 1 - src/ChunkDef.h | 4 ++-- src/ChunkMap.cpp | 23 ++++++++++++----------- src/ClientHandle.cpp | 24 +++++++++++++----------- src/ClientHandle.h | 16 +++++++++------- src/CraftingRecipes.cpp | 2 +- src/Defines.h | 2 +- src/FurnaceRecipe.cpp | 8 ++++---- src/Globals.h | 22 +++++++++++----------- src/GroupManager.cpp | 2 +- src/Inventory.cpp | 4 ++-- src/Log.cpp | 4 ++-- src/Map.h | 2 +- src/MapManager.h | 6 +++--- src/Matrix4.h | 2 +- src/MobCensus.cpp | 2 +- src/MobFamilyCollecter.h | 2 +- src/MobProximityCounter.cpp | 4 ++-- src/MobSpawner.h | 2 +- src/Root.cpp | 6 +++--- src/Scoreboard.h | 6 +++--- src/Server.cpp | 6 +++--- src/Server.h | 6 +++--- src/Statistics.h | 4 ++-- src/Tracer.cpp | 24 ++++++++++++------------ src/Vector3.h | 2 +- src/WebAdmin.cpp | 2 +- src/WebAdmin.h | 8 ++++---- src/World.cpp | 32 +++++++++++++++----------------- src/World.h | 8 ++++---- src/main.cpp | 18 +++++++++--------- 34 files changed, 141 insertions(+), 139 deletions(-) (limited to 'src') diff --git a/src/BlockID.h b/src/BlockID.h index 43f911ce3..4246c0bc9 100644 --- a/src/BlockID.h +++ b/src/BlockID.h @@ -171,7 +171,7 @@ enum ENUM_BLOCK_ID E_BLOCK_DROPPER = 158, E_BLOCK_STAINED_CLAY = 159, E_BLOCK_STAINED_GLASS_PANE = 160, - E_BLOCK_NEW_LEAVES = 161, // Acacia and Dark Oak IDs in Minecraft 1.7.x + E_BLOCK_NEW_LEAVES = 161, // Acacia and Dark Oak IDs in Minecraft 1.7.x E_BLOCK_NEW_LOG = 162, E_BLOCK_ACACIA_WOOD_STAIRS = 163, E_BLOCK_DARK_OAK_WOOD_STAIRS = 164, diff --git a/src/BlockInfo.h b/src/BlockInfo.h index d6d4e7430..ed6fd4754 100644 --- a/src/BlockInfo.h +++ b/src/BlockInfo.h @@ -81,7 +81,7 @@ protected: /** Initializes the specified BlockInfo structures with block-specific values. */ static void Initialize(cBlockInfoArray & a_BlockInfos); -}; // tolua_export +}; // tolua_export diff --git a/src/Chunk.cpp b/src/Chunk.cpp index b88952fa0..2d8ff7714 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -448,7 +448,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill) Vector3d currentPosition; for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) { - //LOGD("Counting entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass()); + // LOGD("Counting entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass()); if ((*itr)->IsMob()) { cMonster& Monster = (cMonster&)(**itr); @@ -698,13 +698,13 @@ void cChunk::ProcessQueuedSetBlocks(void) { if (itr->m_Tick <= CurrTick) { - if (itr->m_PreviousType != E_BLOCK_AIR) // PreviousType defaults to 0 if not specified + if (itr->m_PreviousType != E_BLOCK_AIR) // PreviousType defaults to 0 if not specified { if (GetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ) == itr->m_PreviousType) { // Current world age is bigger than/equal to target world age - delay time reached AND // Previous block type was the same as current block type (to prevent duplication) - SetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockType, itr->m_BlockMeta); // SetMeta doesn't send to client + SetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockType, itr->m_BlockMeta); // SetMeta doesn't send to client itr = m_SetBlockQueue.erase(itr); LOGD("Successfully set queued block - previous and current types matched"); } @@ -810,7 +810,7 @@ void cChunk::TickBlocks(void) if (m_BlockTickY > cChunkDef::GetHeight(m_HeightMap, m_BlockTickX, m_BlockTickZ)) { - continue; // It's all air up here + continue; // It's all air up here } cBlockHandler * Handler = BlockHandler(GetBlock(m_BlockTickX, m_BlockTickY, m_BlockTickZ)); @@ -1530,11 +1530,11 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT m_ChunkData.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType); - if ( // Queue block to be sent only if ... - a_SendToClients && // ... we are told to do so AND ... + if ( // Queue block to be sent only if ... + a_SendToClients && // ... we are told to do so AND ... ( - (OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ... - !( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them); see below for specifics: + (OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ... + !( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them); see below for specifics: ((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water ((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water ((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water @@ -1727,7 +1727,7 @@ void cChunk::CollectPickupsByPlayer(cPlayer * a_Player) { if ((!(*itr)->IsPickup()) && (!(*itr)->IsProjectile())) { - continue; // Only pickups and projectiles + continue; // Only pickups and projectiles can be picked up } float DiffX = (float)((*itr)->GetPosX() - PosX ); float DiffY = (float)((*itr)->GetPosY() - PosY ); @@ -2152,7 +2152,7 @@ bool cChunk::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallb { continue; } - if (((*itr)->GetBlockType() != E_BLOCK_CHEST) && ((*itr)->GetBlockType() != E_BLOCK_TRAPPED_CHEST)) // Trapped chests use normal chests' handlers + if (((*itr)->GetBlockType() != E_BLOCK_CHEST) && ((*itr)->GetBlockType() != E_BLOCK_TRAPPED_CHEST)) // Trapped chests use normal chests' handlers { // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out return false; @@ -2481,7 +2481,7 @@ BLOCKTYPE cChunk::GetBlock(int a_RelX, int a_RelY, int a_RelZ) const ) { ASSERT(!"GetBlock(x, y, z) out of bounds!"); - return 0; // Clip + return 0; // Clip } return m_ChunkData.GetBlock(a_RelX, a_RelY, a_RelZ); diff --git a/src/Chunk.h b/src/Chunk.h index f765bcdaf..2e2895c6e 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -274,7 +274,6 @@ public: void UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z); // [x, y, z] in world block coords - void CalculateLighting(); // Recalculate right now void CalculateHeightmap(const BLOCKTYPE * a_BlockTypes); // Broadcast various packets to all clients of this chunk: diff --git a/src/ChunkDef.h b/src/ChunkDef.h index bd6387b74..334f8a6b9 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -138,9 +138,9 @@ public: { #if AXIS_ORDER == AXIS_ORDER_XZY // For some reason, NOT using the Horner schema is faster. Weird. - return x + (z * cChunkDef::Width) + (y * cChunkDef::Width * cChunkDef::Width); // 1.2 is XZY + return x + (z * cChunkDef::Width) + (y * cChunkDef::Width * cChunkDef::Width); // 1.2 uses XZY #elif AXIS_ORDER == AXIS_ORDER_YZX - return y + (z * cChunkDef::Width) + (x * cChunkDef::Height * cChunkDef::Width); // 1.1 is YZX + return y + (z * cChunkDef::Width) + (x * cChunkDef::Height * cChunkDef::Width); // 1.1 uses YZX #endif } diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index a83828bed..de2016015 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -20,7 +20,7 @@ #include "Entities/Pickup.h" #ifndef _WIN32 - #include // abs + #include // abs #endif #include "zlib/zlib.h" @@ -33,14 +33,15 @@ //////////////////////////////////////////////////////////////////////////////// // cChunkMap: -cChunkMap::cChunkMap(cWorld * a_World ) - : m_World( a_World ), +cChunkMap::cChunkMap(cWorld * a_World) : + m_World(a_World), m_Pool( new cListAllocationPool( std::auto_ptr::cStarvationCallbacks>( - new cStarvationCallbacks()) + new cStarvationCallbacks() ) ) + ) { } @@ -1873,15 +1874,15 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_ default: { - if (m_World->GetTickRandomNumber(100) <= 25) // 25% chance of pickups + if (m_World->GetTickRandomNumber(100) <= 25) // 25% chance of pickups { cItems Drops; cBlockHandler * Handler = BlockHandler(Block); - Handler->ConvertToPickups(Drops, area.GetBlockMeta(bx + x, by + y, bz + z)); // Stone becomes cobblestone, coal ore becomes coal, etc. + Handler->ConvertToPickups(Drops, area.GetBlockMeta(bx + x, by + y, bz + z)); // Stone becomes cobblestone, coal ore becomes coal, etc. m_World->SpawnItemPickups(Drops, bx + x, by + y, bz + z); } - else if ((m_World->GetTNTShrapnelLevel() > slNone) && (m_World->GetTickRandomNumber(100) < 20)) // 20% chance of flinging stuff around + else if ((m_World->GetTNTShrapnelLevel() > slNone) && (m_World->GetTickRandomNumber(100) < 20)) // 20% chance of flinging stuff around { if (!cBlockInfo::FullyOccupiesVoxel(Block)) { @@ -1921,7 +1922,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_ { if (a_Entity->IsPickup()) { - if (((cPickup *)a_Entity)->GetAge() < 20) // If pickup age is smaller than one second, it is invincible (so we don't kill pickups that were just spawned) + if (((cPickup *)a_Entity)->GetAge() < 20) // If pickup age is smaller than one second, it is invincible (so we don't kill pickups that were just spawned) { return false; } @@ -1930,7 +1931,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_ Vector3d EntityPos = a_Entity->GetPosition(); cBoundingBox bbEntity(EntityPos, a_Entity->GetWidth() / 2, a_Entity->GetHeight()); - if (!m_bbTNT.IsInside(bbEntity)) // IsInside actually acts like DoesSurround + if (!m_bbTNT.IsInside(bbEntity)) // IsInside actually acts like DoesSurround { return false; } @@ -1953,7 +1954,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_ else if (FinalDamage < 0) FinalDamage = 0; - if (!a_Entity->IsTNT() && !a_Entity->IsFallingBlock()) // Don't apply damage to other TNT entities and falling blocks, they should be invincible + if (!a_Entity->IsTNT() && !a_Entity->IsFallingBlock()) // Don't apply damage to other TNT entities and falling blocks, they should be invincible { a_Entity->TakeDamage(dtExplosion, NULL, (int)FinalDamage, 0); } @@ -2733,7 +2734,7 @@ cChunkMap::cChunkLayer::~cChunkLayer() for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); ++i) { delete m_Chunks[i]; - m_Chunks[i] = NULL; // // Must zero out, because further chunk deletions query the chunkmap for entities and that would touch deleted data + m_Chunks[i] = NULL; // Must zero out, because further chunk deletions query the chunkmap for entities and that would touch deleted data } // for i - m_Chunks[] } diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index bf66e7db1..afa99008a 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -589,7 +589,7 @@ void cClientHandle::HandleCreativeInventory(short a_SlotNum, const cItem & a_Hel void cClientHandle::HandlePlayerAbilities(bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed) { - UNUSED(FlyingSpeed); // Ignore the client values for these + UNUSED(FlyingSpeed); // Ignore the client values for these UNUSED(WalkingSpeed); m_Player->SetCanFly(a_CanFly); @@ -668,7 +668,7 @@ void cClientHandle::HandlePluginMessage(const AString & a_Channel, const AString if (HasPluginChannel(a_Channel)) { SendPluginMessage("UNREGISTER", a_Channel); - return; // Can't register again if already taken - kinda defeats the point of plugin messaging! + return; // Can't register again if already taken - kinda defeats the point of plugin messaging! } RegisterPluginChannels(BreakApartPluginChannels(a_Message)); @@ -842,7 +842,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB } if ( - ((a_Status == DIG_STATUS_STARTED) || (a_Status == DIG_STATUS_FINISHED)) && // Only do a radius check for block destruction - things like pickup tossing send coordinates that are to be ignored + ((a_Status == DIG_STATUS_STARTED) || (a_Status == DIG_STATUS_FINISHED)) && // Only do a radius check for block destruction - things like pickup tossing send coordinates that are to be ignored ((Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6)) @@ -926,7 +926,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB // A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch) return; } - m_Player->TossEquippedItem(64); // Toss entire slot - if there aren't enough items, the maximum will be ejected + m_Player->TossEquippedItem(64); // Toss entire slot - if there aren't enough items, the maximum will be ejected return; } @@ -989,7 +989,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc int pY = a_BlockY; int pZ = a_BlockZ; - AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false) + AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false) cBlockHandler * Handler = cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(pX, pY, pZ)); if (Handler->IsClickedThrough()) @@ -1083,7 +1083,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo void cClientHandle::FinishDigAnimation() { - if (!m_HasStartedDigging) // Hasn't received the DIG_STARTED packet + if (!m_HasStartedDigging) // Hasn't received the DIG_STARTED packet { return; } @@ -1441,23 +1441,25 @@ void cClientHandle::HandleAnimation(char a_Animation) // Because the animation ID sent to servers by clients are different to those sent back, we need this switch (a_Animation) { - case 0: // No animation - wiki.vg doesn't say that client has something specific for it, so I suppose it will just become -1 + case 0: // No animation - wiki.vg doesn't say that client has something specific for it, so I suppose it will just become -1 case 1: case 2: case 3: { - a_Animation--; // Offset by -1 + a_Animation--; // Offset by -1 break; } case 5: case 6: case 7: { - a_Animation -= 2; // Offset by -2 + a_Animation -= 2; // Offset by -2 break; } - default: // Anything else is the same + default: // Anything else is the same + { break; + } } m_Player->GetWorld()->BroadcastEntityAnimation(*m_Player, a_Animation, this); @@ -2473,7 +2475,7 @@ void cClientHandle::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, -void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) // VehicleSubType is specific to Minecarts +void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) // VehicleSubType is specific to Minecarts { m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType, a_VehicleSubType); } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index d02b83cfe..539e24ef6 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -123,7 +123,7 @@ public: void SendAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle); void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType); void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage); - void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // tolua_export + void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // tolua_export void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes); void SendChat (const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData = ""); void SendChat (const cCompositeChat & a_Message); @@ -271,15 +271,14 @@ public: private: - /** Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) */ - void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler); - /** The type used for storing the names of registered plugin channels. */ typedef std::set cChannels; - int m_ViewDistance; // Number of chunks the player can see in each direction; 4 is the minimum ( http://wiki.vg/Protocol_FAQ#.E2.80.A6all_connecting_clients_spasm_and_jerk_uncontrollably.21 ) + /** Number of chunks the player can see in each direction; 4 is the minimum ( http://wiki.vg/Protocol_FAQ#.E2.80.A6all_connecting_clients_spasm_and_jerk_uncontrollably.21 ) */ + int m_ViewDistance; - static const int GENERATEDISTANCE = 2; // Server generates this many chunks AHEAD of player sight. 2 is the minimum, since foliage is generated 1 step behind chunk terrain generation + /** Server generates this many chunks AHEAD of player sight. */ + static const int GENERATEDISTANCE = 2; AString m_IPString; @@ -317,7 +316,7 @@ private: int m_PingID; long long m_PingStartTime; long long m_LastPingTime; - static const unsigned short PING_TIME_MS = 1000; //minecraft sends 1 per 20 ticks (1 second or every 1000 ms) + static const unsigned short PING_TIME_MS = 1000; // Vanilla sends 1 per 20 ticks (1 second or every 1000 ms) // Values required for block dig animation int m_BlockDigAnimStage; // Current stage of the animation; -1 if not digging @@ -374,6 +373,9 @@ private: cChannels m_PluginChannels; + /** Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) */ + void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler); + /** Returns true if the rate block interactions is within a reasonable limit (bot protection) */ bool CheckBlockInteractionsRate(void); diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index a2ce359f3..e9946160f 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -838,7 +838,7 @@ void cCraftingRecipes::HandleFireworks(const cItem * a_CraftingGrid, cCraftingRe case E_ITEM_GOLD_NUGGET: a_Recipe->m_Result.m_FireworkItem.m_Type = 2; break; case E_ITEM_FEATHER: a_Recipe->m_Result.m_FireworkItem.m_Type = 4; break; case E_ITEM_HEAD: a_Recipe->m_Result.m_FireworkItem.m_Type = 3; break; - default: LOG("Unexpected item in firework star recipe, was the crafting file's fireworks section changed?"); break; // ermahgerd BARD ardmins + default: LOG("Unexpected item in firework star recipe, was the crafting file's fireworks section changed?"); break; // ermahgerd BARD ardmins } } diff --git a/src/Defines.h b/src/Defines.h index ba2e8f504..877970ab8 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -22,7 +22,7 @@ typedef std::vector cSlotNums; /// Experience Orb setup enum { - //open to suggestion on naming convention here :) + // Open to suggestion on naming convention here :) MAX_EXPERIENCE_ORB_SIZE = 2000 } ; diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index 8add9610c..cf29e227f 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -107,7 +107,7 @@ void cFurnaceRecipe::AddFuelFromLine(const AString & a_Line, int a_LineNum) { // Fuel int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0; - AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang) + AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang) if ( !ReadMandatoryNumber(BeginPos, ":", a_Line, a_LineNum, IItemID) || // Read item ID @@ -133,7 +133,7 @@ void cFurnaceRecipe::AddRecipeFromLine(const AString & a_Line, int a_LineNum) { int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0; int OItemID = 0, OItemCount = 0, OItemHealth = 0; - AString::size_type BeginPos = 0; // Begin at start of line + AString::size_type BeginPos = 0; // Begin at start of line if ( !ReadMandatoryNumber(BeginPos, ":", a_Line, a_LineNum, IItemID) || // Read item ID @@ -193,7 +193,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt } a_Value = atoi(a_Text.substr(a_Begin, End - a_Begin).c_str()); - a_Begin = End + 1; // Jump over delimiter + a_Begin = End + 1; // Jump over delimiter return true; } @@ -236,7 +236,7 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt } a_ValueTwo = atoi(a_Text.substr(Begin, End - Begin).c_str()); - a_Begin = End + 1; // Jump over delimiter + a_Begin = End + 1; // Jump over delimiter return true; } else diff --git a/src/Globals.h b/src/Globals.h index 62e0ad285..9b2f25f36 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -14,18 +14,18 @@ #pragma warning(disable:4481) // Disable some warnings that we don't care about: - #pragma warning(disable:4100) // Unreferenced formal parameter + #pragma warning(disable:4100) // Unreferenced formal parameter // Useful warnings from warning level 4: - #pragma warning(3 : 4127) // Conditional expression is constant - #pragma warning(3 : 4189) // Local variable is initialized but not referenced - #pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch - #pragma warning(3 : 4310) // Cast truncates constant value - #pragma warning(3 : 4389) // Signed/unsigned mismatch - #pragma warning(3 : 4505) // Unreferenced local function has been removed - #pragma warning(3 : 4701) // Potentially unitialized local variable used - #pragma warning(3 : 4702) // Unreachable code - #pragma warning(3 : 4706) // Assignment within conditional expression + #pragma warning(3 : 4127) // Conditional expression is constant + #pragma warning(3 : 4189) // Local variable is initialized but not referenced + #pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch + #pragma warning(3 : 4310) // Cast truncates constant value + #pragma warning(3 : 4389) // Signed/unsigned mismatch + #pragma warning(3 : 4505) // Unreferenced local function has been removed + #pragma warning(3 : 4701) // Potentially unitialized local variable used + #pragma warning(3 : 4702) // Unreachable code + #pragma warning(3 : 4706) // Assignment within conditional expression // Disabling this warning, because we know what we're doing when we're doing this: #pragma warning(disable: 4355) // 'this' used in initializer list @@ -34,7 +34,7 @@ #pragma warning(disable: 4512) // 'class': assignment operator could not be generated - reported for each class that has a reference-type member // 2014_01_06 xoft: Disabled this warning because MSVC is stupid and reports it in obviously wrong places - // #pragma warning(3 : 4244) // Conversion from 'type1' to 'type2', possible loss of data + // #pragma warning(3 : 4244) // Conversion from 'type1' to 'type2', possible loss of data #define OBSOLETE __declspec(deprecated) diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index 11e62c223..ffba68200 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -145,7 +145,7 @@ bool cGroupManager::LoadGroups() AString KeyName = IniFile.GetKeyName(i); cGroup * Group = GetGroup(KeyName.c_str()); - Group->ClearPermission(); // Needed in case the groups are reloaded. + Group->ClearPermission(); // Needed in case the groups are reloaded. LOGD("Loading group %s", KeyName.c_str()); diff --git a/src/Inventory.cpp b/src/Inventory.cpp index bce882c88..38d3c886d 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -493,7 +493,7 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, if( NumFree >= a_Item.m_ItemCount ) { - //printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree ); + // printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree ); m_Slots[i + a_Offset].m_ItemCount += a_Item.m_ItemCount; a_Item.m_ItemCount = 0; a_bChangedSlots[i + a_Offset] = true; @@ -501,7 +501,7 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, } else { - //printf("2. Adding %i items\n", NumFree ); + // printf("2. Adding %i items\n", NumFree ); m_Slots[i + a_Offset].m_ItemCount += (char)NumFree; a_Item.m_ItemCount -= (char)NumFree; a_bChangedSlots[i + a_Offset] = true; diff --git a/src/Log.cpp b/src/Log.cpp index a7be04b1a..d96e3e9e4 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -130,9 +130,9 @@ void cLog::Log(const char * a_Format, va_list argList) // Print to console: #if defined(ANDROID_NDK) - //__android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList); + // __android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList); __android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str() ); - //CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line ); + // CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line ); #else printf("%s", Line.c_str()); #endif diff --git a/src/Map.h b/src/Map.h index 6bb2d62c6..fe324a5e7 100644 --- a/src/Map.h +++ b/src/Map.h @@ -256,7 +256,7 @@ private: friend class cMapSerializer; -}; // tolua_export +}; // tolua_export diff --git a/src/MapManager.h b/src/MapManager.h index 3cd6c08cd..a40ec2630 100644 --- a/src/MapManager.h +++ b/src/MapManager.h @@ -43,14 +43,14 @@ public: Returns true if the map was found and the callback called, false if map not found. Callback return value is ignored. */ - bool DoWithMap(int a_ID, cMapCallback & a_Callback); // Exported in ManualBindings.cpp + bool DoWithMap(int a_ID, cMapCallback & a_Callback); // Exported in ManualBindings.cpp /** Calls the callback for each map. Returns true if all maps processed, false if the callback aborted by returning true. */ bool ForEachMap(cMapCallback & a_Callback); - size_t GetNumMaps(void) const; // tolua_export + size_t GetNumMaps(void) const; // tolua_export /** Loads the map data from the disk */ void LoadMapData(void); @@ -69,7 +69,7 @@ private: cWorld * m_World; -}; // tolua_export +}; // tolua_export diff --git a/src/Matrix4.h b/src/Matrix4.h index 557057aca..081847b9f 100644 --- a/src/Matrix4.h +++ b/src/Matrix4.h @@ -3,7 +3,7 @@ -#define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC) +#define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC) #include diff --git a/src/MobCensus.cpp b/src/MobCensus.cpp index d5a341ef7..4109aff07 100644 --- a/src/MobCensus.cpp +++ b/src/MobCensus.cpp @@ -19,7 +19,7 @@ void cMobCensus::CollectMob(cMonster & a_Monster, cChunk & a_Chunk, double a_Dis bool cMobCensus::IsCapped(cMonster::eFamily a_MobFamily) { - const int ratio = 319; // this should be 256 as we are only supposed to take account from chunks that are in 17x17 from a player + const int ratio = 319; // This should be 256 as we are only supposed to take account from chunks that are in 17x17 from a player // but for now, we use all chunks loaded by players. that means 19 x 19 chunks. That's why we use 256 * (19*19) / (17*17) = 319 // MG TODO : code the correct count if ((GetCapMultiplier(a_MobFamily) * GetNumChunks()) / ratio >= m_MobFamilyCollecter.GetNumberOfCollectedMobs(a_MobFamily)) diff --git a/src/MobFamilyCollecter.h b/src/MobFamilyCollecter.h index 362814c8f..c4324bd68 100644 --- a/src/MobFamilyCollecter.h +++ b/src/MobFamilyCollecter.h @@ -4,7 +4,7 @@ #include #include #include "BlockID.h" -#include "Mobs/Monster.h" //this is a side-effect of keeping Mobfamily inside Monster class. I'd prefer to keep both (Mobfamily and Monster) inside a "Monster" namespace MG TODO : do it +#include "Mobs/Monster.h" // This is a side-effect of keeping Mobfamily inside Monster class. I'd prefer to keep both (Mobfamily and Monster) inside a "Monster" namespace MG TODO : do it diff --git a/src/MobProximityCounter.cpp b/src/MobProximityCounter.cpp index 35bf57380..a89fa72df 100644 --- a/src/MobProximityCounter.cpp +++ b/src/MobProximityCounter.cpp @@ -61,7 +61,7 @@ cMobProximityCounter::sIterablePair cMobProximityCounter::getMobWithinThosesDist { if ((a_DistanceMin == 1) || (itr->first > a_DistanceMin)) { - toReturn.m_Begin = itr; // this is the first one with distance > a_DistanceMin; + toReturn.m_Begin = itr; // This is the first one with distance > a_DistanceMin; } } @@ -69,7 +69,7 @@ cMobProximityCounter::sIterablePair cMobProximityCounter::getMobWithinThosesDist { if ((a_DistanceMax != 1) && (itr->first > a_DistanceMax)) { - toReturn.m_End = itr; // this is just after the last one with distance < a_DistanceMax + toReturn.m_End = itr; // This is just after the last one with distance < a_DistanceMax // Note : if we are not going through this, it's ok, toReturn.m_End will be end(); break; } diff --git a/src/MobSpawner.h b/src/MobSpawner.h index aa2935916..f3c56fe2d 100644 --- a/src/MobSpawner.h +++ b/src/MobSpawner.h @@ -6,7 +6,7 @@ #include "ChunkDef.h" #include "Chunk.h" #include "FastRandom.h" -#include "Mobs/Monster.h" //this is a side-effect of keeping Mobfamily inside Monster class. I'd prefer to keep both (Mobfamily and Monster) inside a "Monster" namespace MG TODO : do it +#include "Mobs/Monster.h" // This is a side-effect of keeping Mobfamily inside Monster class. I'd prefer to keep both (Mobfamily and Monster) inside a "Monster" namespace MG TODO : do it diff --git a/src/Root.cpp b/src/Root.cpp index 235a1b108..6347adcf0 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -105,7 +105,7 @@ void cRoot::Start(void) #ifdef _WIN32 HWND hwnd = GetConsoleWindow(); HMENU hmenu = GetSystemMenu(hwnd, FALSE); - EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED); // Disable close button when starting up; it causes problems with our CTRL-CLOSE handling + EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED); // Disable close button when starting up; it causes problems with our CTRL-CLOSE handling #endif cDeadlockDetect dd; @@ -202,7 +202,7 @@ void cRoot::Start(void) LOG("Startup complete, took %lld ms!", finishmseconds); #ifdef _WIN32 - EnableMenuItem(hmenu, SC_CLOSE, MF_ENABLED); // Re-enable close button + EnableMenuItem(hmenu, SC_CLOSE, MF_ENABLED); // Re-enable close button #endif while (!m_bStop && !m_bRestart && !g_TERMINATE_EVENT_RAISED) // These are modified by external threads @@ -607,7 +607,7 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac m_BestRating = Rating; ++m_NumMatches; } - if (Rating == m_NameLength) // Perfect match + if (Rating == m_NameLength) // Perfect match { return true; } diff --git a/src/Scoreboard.h b/src/Scoreboard.h index 5f91535f8..f53b8c803 100644 --- a/src/Scoreboard.h +++ b/src/Scoreboard.h @@ -118,7 +118,7 @@ private: friend class cScoreboardSerializer; -}; // tolua_export +}; // tolua_export @@ -197,7 +197,7 @@ private: friend class cScoreboardSerializer; -}; // tolua_export +}; // tolua_export @@ -301,7 +301,7 @@ private: friend class cScoreboardSerializer; -}; // tolua_export +}; // tolua_export diff --git a/src/Server.cpp b/src/Server.cpp index 17551eeb1..81ecd38b2 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -202,7 +202,7 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) m_PlayerCount = 0; m_PlayerCountDiff = 0; - m_FaviconData = Base64Encode(cFile::ReadWholeFile(FILE_IO_PREFIX + AString("favicon.png"))); // Will return empty string if file nonexistant; client doesn't mind + m_FaviconData = Base64Encode(cFile::ReadWholeFile(FILE_IO_PREFIX + AString("favicon.png"))); // Will return empty string if file nonexistant; client doesn't mind if (m_bIsConnected) { @@ -213,7 +213,7 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) LOGINFO("Compatible clients: %s", MCS_CLIENT_VERSIONS); LOGINFO("Compatible protocol versions %s", MCS_PROTOCOL_VERSIONS); - if (cSocket::WSAStartup() != 0) // Only does anything on Windows, but whatever + if (cSocket::WSAStartup() != 0) // Only does anything on Windows, but whatever { LOGERROR("WSAStartup() != 0"); return false; @@ -409,7 +409,7 @@ void cServer::TickClients(float a_Dt) for (cClientHandleList::iterator itr = RemoveClients.begin(); itr != RemoveClients.end(); ++itr) { delete *itr; - } // for itr - RemoveClients[] + } // for itr - RemoveClients[] } diff --git a/src/Server.h b/src/Server.h index a6b7297e8..b03359f03 100644 --- a/src/Server.h +++ b/src/Server.h @@ -133,7 +133,7 @@ public: // tolua_export private: - friend class cRoot; // so cRoot can create and destroy cServer + friend class cRoot; // so cRoot can create and destroy cServer /** When NotifyClientWrite() is called, it is queued for this thread to process (to avoid deadlocks between cSocketThreads, cClientHandle and cChunkMap) */ class cNotifyWriteThread : @@ -194,7 +194,7 @@ private: int m_ClientViewDistance; // The default view distance for clients; settable in Settings.ini - bool m_bIsConnected; // true - connected false - not connected + bool m_bIsConnected; // true - connected false - not connected bool m_bRestarting; @@ -244,7 +244,7 @@ private: // cListenThread::cCallback overrides: virtual void OnConnectionAccepted(cSocket & a_Socket) override; -}; // tolua_export +}; // tolua_export diff --git a/src/Statistics.h b/src/Statistics.h index 49750e8c0..d70a2aeab 100644 --- a/src/Statistics.h +++ b/src/Statistics.h @@ -118,7 +118,7 @@ private: /* Signed (?) integral value. */ -typedef int StatValue; // tolua_export +typedef int StatValue; // tolua_export @@ -157,7 +157,7 @@ private: // TODO 10-05-2014 xdot: Use, mine, craft statistics -}; // tolua_export +}; // tolua_export diff --git a/src/Tracer.cpp b/src/Tracer.cpp index be42430a5..d788d9e26 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -7,7 +7,7 @@ #include "Entities/Entity.h" #ifndef _WIN32 - #include // abs() + #include #endif @@ -247,7 +247,7 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int // return 1 = hit, other is not hit int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,float y3) { - //float linx, liny; + // float linx, liny; float d=(x1-x0)*(y3-y2)-(y1-y0)*(x3-x2); if (abs(d)<0.001) {return 0;} @@ -257,8 +257,8 @@ int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,fl float CD=((y0-y2)*(x1-x0)-(x0-x2)*(y1-y0))/d; if (CD>=0.0 && CD<=1.0) { - //linx=x0+AB*(x1-x0); - //liny=y0+AB*(y1-y0); + // linx=x0+AB*(x1-x0); + // liny=y0+AB*(y1-y0); return 1; } } @@ -291,7 +291,7 @@ int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f if (sI < 0 || sI > 1) return 0; // no intersection - //Vector3f I ( a_Ray->GetOrigin() + sI * u );//S.P0 + sI * u; // compute segment intersect point + // Vector3f I ( a_Ray->GetOrigin() + sI * u );//S.P0 + sI * u; // compute segment intersect point RealHit = a_Origin + u * sI; return 1; } @@ -310,8 +310,8 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve Vector3f Look = (end - start); Look.Normalize(); - float dot = Look.Dot( Vector3f(-1, 0, 0) ); // first face normal is x -1 - if(dot < 0) + float dot = Look.Dot( Vector3f(-1, 0, 0) ); // first face normal is x -1 + if (dot < 0) { int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1 ); if(Lines == 1) @@ -324,7 +324,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } } - dot = Look.Dot( Vector3f(0, 0, -1) ); // second face normal is z -1 + dot = Look.Dot( Vector3f(0, 0, -1) ); // second face normal is z -1 if(dot < 0) { int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1 ); @@ -338,7 +338,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } } - dot = Look.Dot( Vector3f(1, 0, 0) ); // third face normal is x 1 + dot = Look.Dot( Vector3f(1, 0, 0) ); // third face normal is x 1 if(dot < 0) { int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1 ); @@ -352,7 +352,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } } - dot = Look.Dot( Vector3f(0, 0, 1) ); // fourth face normal is z 1 + dot = Look.Dot( Vector3f(0, 0, 1) ); // fourth face normal is z 1 if(dot < 0) { int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1 ); @@ -366,7 +366,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } } - dot = Look.Dot( Vector3f(0, 1, 0) ); // fifth face normal is y 1 + dot = Look.Dot( Vector3f(0, 1, 0) ); // fifth face normal is y 1 if(dot < 0) { int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1 ); @@ -380,7 +380,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } } - dot = Look.Dot( Vector3f(0, -1, 0) ); // sixth face normal is y -1 + dot = Look.Dot( Vector3f(0, -1, 0) ); // sixth face normal is y -1 if(dot < 0) { int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1 ); diff --git a/src/Vector3.h b/src/Vector3.h index c175bf135..1dcb38f64 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -3,7 +3,7 @@ -#define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC) +#define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC) #include #include #include diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index d80849433..b3eab5659 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -391,7 +391,7 @@ AString cWebAdmin::GetDefaultPage(void) Content += "

Players:

    "; cPlayerAccum PlayerAccum; - cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players + cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players if( World != NULL ) { World->ForEachPlayer(PlayerAccum); diff --git a/src/WebAdmin.h b/src/WebAdmin.h index d5e45828f..d679a097c 100644 --- a/src/WebAdmin.h +++ b/src/WebAdmin.h @@ -60,11 +60,11 @@ struct HTTPRequest StringStringMap Params; // >> EXPORTED IN MANUALBINDINGS << /** Parameters posted as a part of a form - either in the URL (GET method) or in the body (POST method) */ - StringStringMap PostParams; // >> EXPORTED IN MANUALBINDINGS << + StringStringMap PostParams; // >> EXPORTED IN MANUALBINDINGS << /** Same as PostParams */ FormDataMap FormData; // >> EXPORTED IN MANUALBINDINGS << -} ; // tolua_export +} ; // tolua_export @@ -120,7 +120,7 @@ public: void RemovePlugin(cWebPlugin * a_Plugin); // TODO: Convert this to the auto-locking callback mechanism used for looping players in worlds and such - PluginList GetPlugins() const { return m_Plugins; } // >> EXPORTED IN MANUALBINDINGS << + PluginList GetPlugins() const { return m_Plugins; } // >> EXPORTED IN MANUALBINDINGS << // tolua_begin @@ -218,7 +218,7 @@ protected: virtual void OnRequestBegun (cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override; virtual void OnRequestBody (cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, size_t a_Size) override; virtual void OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override; -} ; // tolua_export +} ; // tolua_export diff --git a/src/World.cpp b/src/World.cpp index b3284942a..7f30f9b39 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -375,17 +375,15 @@ void cWorld::SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ) void cWorld::InitializeSpawn(void) { - if (!m_IsSpawnExplicitlySet) // Check if spawn position was already explicitly set or not + if (!m_IsSpawnExplicitlySet) { - GenerateRandomSpawn(); // Generate random solid-land coordinate and then write it to the world configuration - + // Spawn position wasn't already explicitly set, enerate random solid-land coordinate and then write it to the world configuration: + GenerateRandomSpawn(); cIniFile IniFile; IniFile.ReadFile(m_IniFileName); - IniFile.SetValueF("SpawnPosition", "X", m_SpawnX); IniFile.SetValueF("SpawnPosition", "Y", m_SpawnY); IniFile.SetValueF("SpawnPosition", "Z", m_SpawnZ); - IniFile.WriteFile(m_IniFileName); } @@ -648,7 +646,7 @@ void cWorld::GenerateRandomSpawn(void) while (IsBlockWaterOrIce(GetBlock((int)m_SpawnX, GetHeight((int)m_SpawnX, (int)m_SpawnZ), (int)m_SpawnZ))) { - if ((GetTickRandomNumber(4) % 2) == 0) // Randomise whether to increment X or Z coords + if ((GetTickRandomNumber(4) % 2) == 0) // Randomise whether to increment X or Z coords { m_SpawnX += cChunkDef::Width; } @@ -658,7 +656,7 @@ void cWorld::GenerateRandomSpawn(void) } } - m_SpawnY = (double)GetHeight((int)m_SpawnX, (int)m_SpawnZ) + 1.6f; // 1.6f to accomodate player height + m_SpawnY = (double)GetHeight((int)m_SpawnX, (int)m_SpawnZ) + 1.6f; // 1.6f to accomodate player height LOGD("Generated random spawnpoint %i %i %i", (int)m_SpawnX, (int)m_SpawnY, (int)m_SpawnZ); } @@ -770,12 +768,12 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec) m_ChunkMap->FastSetQueuedBlocks(); - if (m_WorldAge - m_LastSave > 60 * 5 * 20) // Save each 5 minutes + if (m_WorldAge - m_LastSave > 60 * 5 * 20) // Save each 5 minutes { SaveAllChunks(); } - if (m_WorldAge - m_LastUnload > 10 * 20) // Unload every 10 seconds + if (m_WorldAge - m_LastUnload > 10 * 20) // Unload every 10 seconds { UnloadUnusedChunks(); } @@ -861,8 +859,8 @@ void cWorld::TickMobs(float a_Dt) SpawnMobFinalize(*itr2); } } - } // for i - AllFamilies[] - } // if (Spawning enabled) + } // for i - AllFamilies[] + } // if (Spawning enabled) // move close mobs cMobProximityCounter::sIterablePair allCloseEnoughToMoveMobs = MobCensus.GetProximityCounter().getMobWithinThosesDistances(-1, 64 * 16);// MG TODO : deal with this magic number (the 16 is the size of a block) @@ -972,7 +970,7 @@ void cWorld::TickClients(float a_Dt) for (cClientHandleList::iterator itr = RemoveClients.begin(); itr != RemoveClients.end(); ++itr) { delete *itr; - } // for itr - RemoveClients[] + } // for itr - RemoveClients[] } @@ -3026,18 +3024,18 @@ void cWorld::TabCompleteUserName(const AString & a_Text, AStringVector & a_Resul cCSLock Lock(m_CSPlayers); for (cPlayerList::iterator itr = m_Players.begin(), end = m_Players.end(); itr != end; ++itr) { - size_t LastSpace = a_Text.find_last_of(" "); // Find the position of the last space + size_t LastSpace = a_Text.find_last_of(" "); // Find the position of the last space - AString LastWord = a_Text.substr(LastSpace + 1, a_Text.length()); // Find the last word + AString LastWord = a_Text.substr(LastSpace + 1, a_Text.length()); // Find the last word AString PlayerName ((*itr)->GetName()); - size_t Found = PlayerName.find(LastWord); // Try to find last word in playername + size_t Found = PlayerName.find(LastWord); // Try to find last word in playername if (Found == AString::npos) { - continue; // No match + continue; // No match } - a_Results.push_back(PlayerName); // Match! + a_Results.push_back(PlayerName); // Match! } } diff --git a/src/World.h b/src/World.h index a3b152a80..725e1eb71 100644 --- a/src/World.h +++ b/src/World.h @@ -218,14 +218,14 @@ public: void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL); void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) override; - void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL); // tolua_export + void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL); // tolua_export void BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude = NULL); void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL); void BroadcastScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode); void BroadcastScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode); void BroadcastDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display); void BroadcastSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // tolua_export - void BroadcastSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); // tolua_export + void BroadcastSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); // tolua_export void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastTeleportEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); @@ -859,7 +859,7 @@ private: Int64 m_LastTimeUpdate; // The tick in which the last time update has been sent. Int64 m_LastUnload; // The last WorldAge (in ticks) in which unloading was triggerred Int64 m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred - std::map m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed) + std::map m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed) NIBBLETYPE m_SkyDarkness; @@ -1011,7 +1011,7 @@ private: /** Adds the players queued in the m_PlayersToAdd queue into the m_Players list. Assumes it is called from the Tick thread. */ void AddQueuedPlayers(void); -}; // tolua_export +}; // tolua_export diff --git a/src/main.cpp b/src/main.cpp index c8ff31f07..f485d8f8f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,17 +3,17 @@ #include "Root.h" -#include //std::exception -#include //std::signal -#include //exit() +#include +#include +#include #ifdef _MSC_VER #include #endif // _MSC_VER // Here, we have some ALL CAPS variables, to give the impression that this is deeeep, gritty programming :P -bool g_TERMINATE_EVENT_RAISED = false; // If something has told the server to stop; checked periodically in cRoot -bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so our CTRL handler can then tell Windows to close the console +bool g_TERMINATE_EVENT_RAISED = false; // If something has told the server to stop; checked periodically in cRoot +bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so our CTRL handler can then tell Windows to close the console @@ -76,7 +76,7 @@ void NonCtrlHandler(int a_Signal) case SIGINT: case SIGTERM: { - std::signal(a_Signal, SIG_IGN); // Server is shutting down, wait for it... + std::signal(a_Signal, SIG_IGN); // Server is shutting down, wait for it... break; } default: break; @@ -158,9 +158,9 @@ BOOL CtrlHandler(DWORD fdwCtrlType) g_TERMINATE_EVENT_RAISED = true; LOGD("Terminate event raised from the Windows CtrlHandler"); - if (fdwCtrlType == CTRL_CLOSE_EVENT) // Console window closed via 'x' button, Windows will try to close immediately, therefore... + if (fdwCtrlType == CTRL_CLOSE_EVENT) // Console window closed via 'x' button, Windows will try to close immediately, therefore... { - while (!g_SERVER_TERMINATED) { cSleep::MilliSleep(100); } // Delay as much as possible to try to get the server to shut down cleanly + while (!g_SERVER_TERMINATED) { cSleep::MilliSleep(100); } // Delay as much as possible to try to get the server to shut down cleanly } return TRUE; @@ -233,7 +233,7 @@ int main( int argc, char **argv ) std::signal(SIGABRT, NonCtrlHandler); #ifdef SIGABRT_COMPAT std::signal(SIGABRT_COMPAT, NonCtrlHandler); - #endif // SIGABRT_COMPAT + #endif // SIGABRT_COMPAT #endif // DEBUG: test the dumpfile creation: -- cgit v1.2.3 From 68cc9c6f91bbbadedf3641099e0aa17352e4dde8 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 17 Jul 2014 21:35:34 +0200 Subject: Fix sapling drop. --- src/Blocks/BlockSapling.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Blocks/BlockSapling.h b/src/Blocks/BlockSapling.h index 3d925029a..3f443b734 100644 --- a/src/Blocks/BlockSapling.h +++ b/src/Blocks/BlockSapling.h @@ -21,7 +21,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { // Only the first 2 bits contain the display information, the others are for growing - a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3)); + a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x7)); } -- cgit v1.2.3 From 2423fbf2efa39e28cc348acc11b9269e573dcdef Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:15:34 +0200 Subject: Normalized comments. This was mostly done automatically and then visually inspected for obvious errors. All //-style comments should have a 2-space separation from the code, and 1 space after the comment sign. --- src/Bindings/DeprecatedBindings.cpp | 18 ++-- src/Bindings/LuaChunkStay.cpp | 2 +- src/Bindings/LuaState.cpp | 4 +- src/Bindings/LuaState.h | 2 +- src/Bindings/LuaWindow.cpp | 4 +- src/Bindings/ManualBindings.cpp | 4 +- src/Bindings/PluginLua.cpp | 4 +- src/Bindings/PluginManager.h | 2 +- src/Bindings/WebPlugin.cpp | 2 +- src/Bindings/WebPlugin.h | 2 +- src/BlockArea.cpp | 4 +- src/BlockEntities/BlockEntityWithItems.h | 2 +- src/BlockEntities/CommandBlockEntity.cpp | 2 +- src/BlockEntities/DropSpenserEntity.cpp | 8 +- src/BlockEntities/HopperEntity.cpp | 8 +- src/BlockID.h | 4 +- src/Blocks/BlockBed.cpp | 8 +- src/Blocks/BlockButton.h | 2 +- src/Blocks/BlockComparator.h | 2 +- src/Blocks/BlockDropSpenser.h | 4 +- src/Blocks/BlockEnderchest.h | 2 +- src/Blocks/BlockFarmland.h | 2 +- src/Blocks/BlockFire.h | 32 +++--- src/Blocks/BlockLadder.h | 2 +- src/Blocks/BlockLeaves.h | 2 +- src/Blocks/BlockPiston.cpp | 4 +- src/Blocks/BlockPiston.h | 2 +- src/Blocks/BlockPortal.h | 4 +- src/Blocks/BlockQuartz.h | 10 +- src/Blocks/BlockRail.h | 2 +- src/Blocks/BlockRedstoneRepeater.h | 2 +- src/Blocks/BlockSideways.h | 10 +- src/Blocks/BlockSnow.h | 4 +- src/Blocks/BlockStairs.h | 2 +- src/Blocks/BlockTorch.h | 12 +-- src/Blocks/MetaRotator.h | 2 +- src/ByteBuffer.cpp | 2 +- src/Chunk.cpp | 4 +- src/ChunkSender.cpp | 4 +- src/ClientHandle.cpp | 2 +- src/CommandOutput.cpp | 4 +- src/CompositeChat.cpp | 18 ++-- src/CraftingRecipes.cpp | 6 +- src/Cuboid.cpp | 2 +- src/Entities/ArrowEntity.cpp | 12 +-- src/Entities/ArrowEntity.h | 2 +- src/Entities/Boat.cpp | 2 +- src/Entities/Entity.cpp | 28 ++--- src/Entities/Entity.h | 2 +- src/Entities/EntityEffect.cpp | 16 +-- src/Entities/ExpBottleEntity.h | 2 +- src/Entities/FireChargeEntity.h | 2 +- src/Entities/FireworkEntity.h | 2 +- src/Entities/Floater.cpp | 18 ++-- src/Entities/Floater.h | 4 +- src/Entities/GhastFireballEntity.h | 2 +- src/Entities/HangingEntity.cpp | 4 +- src/Entities/ItemFrame.cpp | 2 +- src/Entities/Minecart.cpp | 92 ++++++++-------- src/Entities/Painting.h | 4 +- src/Entities/Pickup.cpp | 12 +-- src/Entities/Pickup.h | 4 +- src/Entities/Player.cpp | 42 ++++---- src/Entities/Player.h | 6 +- src/Entities/ProjectileEntity.cpp | 6 +- src/Entities/ProjectileEntity.h | 2 +- src/Entities/SplashPotionEntity.cpp | 4 +- src/Entities/SplashPotionEntity.h | 2 +- src/Entities/TNTEntity.h | 2 +- src/Entities/ThrownEggEntity.h | 2 +- src/Entities/ThrownEnderPearlEntity.h | 2 +- src/Entities/ThrownSnowballEntity.h | 2 +- src/Entities/WitherSkullEntity.h | 2 +- src/Generating/BioGen.cpp | 18 ++-- src/Generating/Caves.cpp | 10 +- src/Generating/ChunkGenerator.cpp | 4 +- src/Generating/CompoGen.cpp | 12 +-- src/Generating/ComposableGenerator.cpp | 4 +- src/Generating/DistortedHeightmap.cpp | 10 +- src/Generating/EndGen.cpp | 2 +- src/Generating/FinishGen.cpp | 22 ++-- src/Generating/GridStructGen.cpp | 2 +- src/Generating/HeiGen.cpp | 14 +-- src/Generating/MineShafts.cpp | 14 +-- src/Generating/NetherFortGen.cpp | 6 +- src/Generating/Noise3DGenerator.cpp | 4 +- src/Generating/POCPieceGenerator.cpp | 2 +- src/Generating/PieceGenerator.cpp | 16 +-- src/Generating/Prefabs/AlchemistVillagePrefabs.cpp | 40 +++---- src/Generating/Prefabs/JapaneseVillagePrefabs.cpp | 38 +++---- src/Generating/Prefabs/NetherFortPrefabs.cpp | 68 ++++++------ src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 72 ++++++------- src/Generating/Prefabs/RainbowRoadPrefabs.cpp | 24 ++--- .../Prefabs/SandFlatRoofVillagePrefabs.cpp | 24 ++--- src/Generating/Prefabs/SandVillagePrefabs.cpp | 32 +++--- src/Generating/Prefabs/TestRailsPrefabs.cpp | 10 +- src/Generating/Prefabs/UnderwaterBasePrefabs.cpp | 28 ++--- src/Generating/RainbowRoadsGen.cpp | 4 +- src/Generating/Ravines.cpp | 4 +- src/Generating/StructGen.cpp | 12 +-- src/Generating/TestRailsGen.cpp | 4 +- src/Generating/Trees.cpp | 10 +- src/Generating/UnderwaterBaseGen.cpp | 4 +- src/Generating/VillageGen.cpp | 2 +- src/HTTPServer/HTTPMessage.cpp | 6 +- src/HTTPServer/HTTPServer.cpp | 2 +- src/HTTPServer/MultipartParser.cpp | 4 +- src/HTTPServer/NameValueParser.cpp | 2 +- src/Item.cpp | 2 +- src/Items/ItemBucket.h | 4 +- src/Items/ItemFishingRod.h | 27 +++-- src/Items/ItemHandler.cpp | 4 +- src/Items/ItemHandler.h | 8 +- src/Items/ItemItemFrame.h | 4 +- src/Items/ItemLeaves.h | 2 +- src/Items/ItemLilypad.h | 4 +- src/Items/ItemPainting.h | 8 +- src/Items/ItemRedstoneDust.h | 2 +- src/Items/ItemSeeds.h | 2 +- src/LightingThread.cpp | 4 +- src/MCLogger.cpp | 2 +- src/Mobs/Creeper.cpp | 2 +- src/Mobs/Monster.cpp | 24 ++--- src/Mobs/Monster.h | 14 +-- src/Mobs/Sheep.cpp | 4 +- src/Mobs/Villager.cpp | 4 +- src/Mobs/Villager.h | 5 +- src/Mobs/Wolf.cpp | 8 +- src/Noise.cpp | 14 +-- src/Noise.h | 4 +- src/OSSupport/CriticalSection.cpp | 6 +- src/OSSupport/File.cpp | 4 +- src/OSSupport/Semaphore.cpp | 8 +- src/OSSupport/Semaphore.h | 2 +- src/OSSupport/Sleep.cpp | 2 +- src/OSSupport/SocketThreads.cpp | 2 +- src/OSSupport/Thread.cpp | 12 +-- src/PolarSSL++/Sha1Checksum.cpp | 2 +- src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.cpp | 74 ++++++------- src/Protocol/Protocol125.h | 4 +- src/Protocol/Protocol132.cpp | 4 +- src/Protocol/Protocol14x.cpp | 4 +- src/Protocol/Protocol15x.cpp | 2 +- src/Protocol/Protocol16x.cpp | 14 +-- src/Protocol/Protocol17x.cpp | 64 +++++------ src/Protocol/ProtocolRecognizer.h | 4 +- src/RCONServer.cpp | 6 +- src/Server.cpp | 6 +- src/Simulator/DelayedFluidSimulator.cpp | 6 +- src/Simulator/FireSimulator.cpp | 2 +- src/Simulator/FluidSimulator.cpp | 16 +-- src/Simulator/IncrementalRedstoneSimulator.cpp | 118 ++++++++++----------- src/Simulator/IncrementalRedstoneSimulator.h | 24 ++--- src/Simulator/NoopRedstoneSimulator.h | 2 +- src/StringUtils.cpp | 8 +- src/Tracer.cpp | 32 ++++-- src/UI/SlotArea.cpp | 32 +++--- src/UI/Window.cpp | 18 ++-- src/WebAdmin.cpp | 2 +- src/World.cpp | 20 ++-- src/World.h | 2 +- src/WorldStorage/FastNBT.cpp | 4 +- src/WorldStorage/FireworksSerializer.cpp | 4 +- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- src/WorldStorage/SchematicFileSerializer.cpp | 2 +- src/WorldStorage/ScoreboardSerializer.cpp | 10 +- src/WorldStorage/WSSAnvil.cpp | 8 +- src/WorldStorage/WSSCompact.cpp | 22 ++-- src/WorldStorage/WSSCompact.h | 6 +- src/WorldStorage/WorldStorage.cpp | 4 +- src/XMLParser.h | 2 +- src/main.cpp | 4 +- 173 files changed, 893 insertions(+), 867 deletions(-) (limited to 'src') diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp index d51ba2da3..d2e60945d 100644 --- a/src/Bindings/DeprecatedBindings.cpp +++ b/src/Bindings/DeprecatedBindings.cpp @@ -39,7 +39,7 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S) tolua_pushnumber(tolua_S,(lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -65,7 +65,7 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S) tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetSpreadLightFalloff((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -91,7 +91,7 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S) tolua_pushboolean(tolua_S, cBlockInfo::IsTransparent((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -117,7 +117,7 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S) tolua_pushboolean(tolua_S, cBlockInfo::IsOneHitDig((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -143,7 +143,7 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S) tolua_pushboolean(tolua_S, cBlockInfo::IsPistonBreakable((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -169,7 +169,7 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S) tolua_pushboolean(tolua_S, cBlockInfo::IsSnowable((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -195,7 +195,7 @@ static int tolua_get_AllToLua_g_BlockRequiresSpecialTool(lua_State* tolua_S) tolua_pushboolean(tolua_S, cBlockInfo::RequiresSpecialTool((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -221,7 +221,7 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S) tolua_pushboolean(tolua_S, (bool)cBlockInfo::IsSolid((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -247,7 +247,7 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S) tolua_pushboolean(tolua_S, (bool)cBlockInfo::FullyOccupiesVoxel((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE diff --git a/src/Bindings/LuaChunkStay.cpp b/src/Bindings/LuaChunkStay.cpp index 985a18a95..59b02d8f7 100644 --- a/src/Bindings/LuaChunkStay.cpp +++ b/src/Bindings/LuaChunkStay.cpp @@ -76,7 +76,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos) -void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index) +void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index) { // Check that the element has 2 coords: int NumCoords = luaL_getn(L, -1); diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 32638df96..7d918cf2b 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -40,7 +40,7 @@ const cLuaState::cRet cLuaState::Return = {}; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cLuaState: cLuaState::cLuaState(const AString & a_SubsystemName) : @@ -1371,7 +1371,7 @@ int cLuaState::ReportFnCallErrors(lua_State * a_LuaState) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cLuaState::cRef: cLuaState::cRef::cRef(void) : diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index b1ac3578a..afac77ce8 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -128,7 +128,7 @@ public: /** Creates a new instance. The LuaState is not initialized. - a_SubsystemName is used for reporting problems in the console, it is "plugin %s" for plugins, + a_SubsystemName is used for reporting problems in the console, it is "plugin %s" for plugins, or "LuaScript" for the cLuaScript template */ cLuaState(const AString & a_SubsystemName); diff --git a/src/Bindings/LuaWindow.cpp b/src/Bindings/LuaWindow.cpp index 733304eb2..1a2582ab0 100644 --- a/src/Bindings/LuaWindow.cpp +++ b/src/Bindings/LuaWindow.cpp @@ -7,13 +7,13 @@ #include "../UI/SlotArea.h" #include "PluginLua.h" #include "../Entities/Player.h" -#include "lua/src/lauxlib.h" // Needed for LUA_REFNIL +#include "lua/src/lauxlib.h" // Needed for LUA_REFNIL -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cLuaWindow: cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title) : diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 88d40bfd9..bb059193b 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -2065,7 +2065,7 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S) { lua_pushstring(tolua_S, it->first.c_str() ); tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData" ); - //lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size() ); // Might contain binary data + // lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size() ); // Might contain binary data lua_settable(tolua_S, top); } @@ -2114,7 +2114,7 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S) { const AString & FancyName = iter->first; const AString & WebName = iter->second; - tolua_pushstring( tolua_S, WebName.c_str() ); // Because the WebName is supposed to be unique, use it as key + tolua_pushstring( tolua_S, WebName.c_str() ); // Because the WebName is supposed to be unique, use it as key tolua_pushstring( tolua_S, FancyName.c_str() ); // lua_rawset(tolua_S, -3); diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index c36763c38..f69435370 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -25,7 +25,7 @@ extern "C" -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPluginLua: cPluginLua::cPluginLua(const AString & a_PluginDirectory) : @@ -1670,7 +1670,7 @@ AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request ) sWebPluginTab * Tab = 0; for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr) { - if ((*itr)->SafeTitle.compare(SafeTabName) == 0) // This is the one! Rawr + if ((*itr)->SafeTitle.compare(SafeTabName) == 0) // This is the one! Rawr { Tab = *itr; break; diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 94a366d33..bf181a55f 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -336,7 +336,7 @@ private: /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns crExecuted if the command is executed. */ cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions); -} ; // tolua_export +} ; // tolua_export diff --git a/src/Bindings/WebPlugin.cpp b/src/Bindings/WebPlugin.cpp index bf45405ba..bc1a9ac8c 100644 --- a/src/Bindings/WebPlugin.cpp +++ b/src/Bindings/WebPlugin.cpp @@ -71,7 +71,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest { for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) { - if( (*itr)->SafeTitle.compare( Split[2] ) == 0 ) // This is the one! Rawr + if( (*itr)->SafeTitle.compare( Split[2] ) == 0 ) // This is the one! Rawr { Tab = *itr; break; diff --git a/src/Bindings/WebPlugin.h b/src/Bindings/WebPlugin.h index 22587b892..3587ac637 100644 --- a/src/Bindings/WebPlugin.h +++ b/src/Bindings/WebPlugin.h @@ -36,7 +36,7 @@ public: TabList & GetTabs() { return m_Tabs; } typedef std::list< std::pair > TabNameList; - TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS << + TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS << std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request ); private: diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 1df60b099..a0dcb5ec8 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -269,7 +269,7 @@ void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBlockArea: cBlockArea::cBlockArea(void) : @@ -1759,7 +1759,7 @@ NIBBLETYPE cBlockArea::GetNibble(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBL -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBlockArea::cChunkReader: cBlockArea::cChunkReader::cChunkReader(cBlockArea & a_Area) : diff --git a/src/BlockEntities/BlockEntityWithItems.h b/src/BlockEntities/BlockEntityWithItems.h index 918781a00..5f1639d45 100644 --- a/src/BlockEntities/BlockEntityWithItems.h +++ b/src/BlockEntities/BlockEntityWithItems.h @@ -50,7 +50,7 @@ public: cItems Pickups; m_Contents.CopyToItems(Pickups); m_Contents.Clear(); - m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block + m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block } // tolua_begin diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index 146ad915b..45f8a3e4d 100644 --- a/src/BlockEntities/CommandBlockEntity.cpp +++ b/src/BlockEntities/CommandBlockEntity.cpp @@ -11,7 +11,7 @@ #include "../CommandOutput.h" #include "../Root.h" -#include "../Server.h" // ExecuteConsoleCommand() +#include "../Server.h" // ExecuteConsoleCommand() #include "../Chunk.h" diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp index 108c2ce1b..0fa6bbe69 100644 --- a/src/BlockEntities/DropSpenserEntity.cpp +++ b/src/BlockEntities/DropSpenserEntity.cpp @@ -42,7 +42,7 @@ cDropSpenserEntity::~cDropSpenserEntity() void cDropSpenserEntity::AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction) { - switch (a_Direction & 0x07) // Vanilla uses the 8th bit to determine power state - we don't + switch (a_Direction & 0x07) // Vanilla uses the 8th bit to determine power state - we don't { case E_META_DROPSPENSER_FACING_YM: a_BlockY--; return; case E_META_DROPSPENSER_FACING_YP: a_BlockY++; return; @@ -90,7 +90,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk) int SmokeDir = 0; switch (Meta) { - case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block) + case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block) case E_META_DROPSPENSER_FACING_YM: SmokeDir = 4; break; case E_META_DROPSPENSER_FACING_XM: SmokeDir = 3; break; case E_META_DROPSPENSER_FACING_XP: SmokeDir = 5; break; @@ -235,7 +235,7 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum) cItems Pickups; Pickups.push_back(m_Contents.RemoveOneItem(a_SlotNum)); - const int PickupSpeed = m_World->GetTickRandomNumber(4) + 2; // At least 2, at most 6 + const int PickupSpeed = m_World->GetTickRandomNumber(4) + 2; // At least 2, at most 6 int PickupSpeedX = 0, PickupSpeedY = 0, PickupSpeedZ = 0; switch (Meta) { @@ -249,7 +249,7 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum) double MicroX, MicroY, MicroZ; MicroX = DispX + 0.5; - MicroY = DispY + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser + MicroY = DispY + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser MicroZ = DispZ + 0.5; diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index 7af4b9d5d..48d3b8dcc 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -219,7 +219,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) } Vector3f EntityPos = a_Entity->GetPosition(); - Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards + Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards double Distance = (EntityPos - BlockPos).Length(); if (Distance < 0.5) @@ -243,7 +243,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) { m_bFoundPickupsAbove = true; m_Contents.SetSlot(i, Item); - a_Pickup->Destroy(); // Kill pickup + a_Pickup->Destroy(); // Kill pickup return true; } @@ -253,11 +253,11 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) int PreviousCount = m_Contents.GetSlot(i).m_ItemCount; - Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added + Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added if (Item.IsEmpty()) { - a_Pickup->Destroy(); // Kill pickup if all items were added + a_Pickup->Destroy(); // Kill pickup if all items were added } return true; } diff --git a/src/BlockID.h b/src/BlockID.h index 4246c0bc9..997ee2cf9 100644 --- a/src/BlockID.h +++ b/src/BlockID.h @@ -399,7 +399,7 @@ enum // Please keep this list alpha-sorted by the blocktype / itemtype part // then number-sorted for the same block / item - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Block metas: // E_BLOCK_BIG_FLOWER metas @@ -678,7 +678,7 @@ enum E_META_WOOL_RED = 14, E_META_WOOL_BLACK = 15, - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Item metas: // E_ITEM_COAL metas: diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index 6a3c6a55b..32b5133c7 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -122,16 +122,16 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface else { // Is foot end - VERIFY((Meta & 0x4) != 0x4); // Occupied flag should never be set, else our compilator (intended) is broken + VERIFY((Meta & 0x4) != 0x4); // Occupied flag should never be set, else our compilator (intended) is broken PillowDirection = MetaDataToDirection(Meta & 0x7); - if (a_ChunkInterface.GetBlock(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z) == E_BLOCK_BED) // Must always use pillow location for sleeping + if (a_ChunkInterface.GetBlock(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z) == E_BLOCK_BED) // Must always use pillow location for sleeping { a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z); } } - a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); // Where 0x4 = occupied bit + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); // Where 0x4 = occupied bit a_Player->SetIsInBed(true); cTimeFastForwardTester Tester; @@ -140,7 +140,7 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface cPlayerBedStateUnsetter Unsetter(Vector3i(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z), a_WorldInterface); a_WorldInterface.ForEachPlayer(Unsetter); a_WorldInterface.SetTimeOfDay(0); - a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xB); // Where 0xB = 1011, and zero is to make sure 'occupied' bit is always unset + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xB); // Where 0xB = 1011, and zero is to make sure 'occupied' bit is always unset } } } diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index 7f92681dc..9fc5e4626 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -74,7 +74,7 @@ public: default: { ASSERT(!"Unhandled block face!"); - return 0x0; // No idea, give a special meta (button in centre of block) + return 0x0; // No idea, give a special meta (button in centre of block) } } } diff --git a/src/Blocks/BlockComparator.h b/src/Blocks/BlockComparator.h index 4dd05366d..6caaaab13 100644 --- a/src/Blocks/BlockComparator.h +++ b/src/Blocks/BlockComparator.h @@ -22,7 +22,7 @@ public: virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR + Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta); } diff --git a/src/Blocks/BlockDropSpenser.h b/src/Blocks/BlockDropSpenser.h index e2b3039fd..cf240fa60 100644 --- a/src/Blocks/BlockDropSpenser.h +++ b/src/Blocks/BlockDropSpenser.h @@ -43,8 +43,8 @@ public: // Mirrors defined by by a table. (Source, mincraft.gamepedia.com) 0x07 == 0111 switch (a_Meta & 0x07) { - case 0x00: return 0x01 + OtherMeta; // Down -> Up - case 0x01: return 0x00 + OtherMeta; // Up -> Down + case 0x00: return 0x01 + OtherMeta; // Down -> Up + case 0x01: return 0x00 + OtherMeta; // Up -> Down } // Not Facing Up or Down; No change. return a_Meta; diff --git a/src/Blocks/BlockEnderchest.h b/src/Blocks/BlockEnderchest.h index 67955f8ce..4672f1459 100644 --- a/src/Blocks/BlockEnderchest.h +++ b/src/Blocks/BlockEnderchest.h @@ -18,7 +18,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - //todo: Drop Ender Chest if using silk touch pickaxe + // todo: Drop Ender Chest if using silk touch pickaxe a_Pickups.push_back(cItem(E_BLOCK_OBSIDIAN, 8, 0)); } diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h index 390b6e5ee..ed0592acd 100644 --- a/src/Blocks/BlockFarmland.h +++ b/src/Blocks/BlockFarmland.h @@ -106,7 +106,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.Add(E_BLOCK_DIRT, 1, 0); // Reset meta + a_Pickups.Add(E_BLOCK_DIRT, 1, 0); // Reset meta } } ; diff --git a/src/Blocks/BlockFire.h b/src/Blocks/BlockFire.h index 147e4b53e..f52825362 100644 --- a/src/Blocks/BlockFire.h +++ b/src/Blocks/BlockFire.h @@ -100,7 +100,7 @@ public: /// Evaluates if coords have a valid border on top, based on MaxY bool EvaluatePortalBorder(int X, int FoundObsidianY, int Z, int MaxY, cChunkInterface & a_ChunkInterface) { - for (int checkBorder = FoundObsidianY + 1; checkBorder <= MaxY - 1; checkBorder++) // FoundObsidianY + 1: FoundObsidianY has already been checked in FindObsidianCeiling; MaxY - 1: portal doesn't need corners + for (int checkBorder = FoundObsidianY + 1; checkBorder <= MaxY - 1; checkBorder++) // FoundObsidianY + 1: FoundObsidianY has already been checked in FindObsidianCeiling; MaxY - 1: portal doesn't need corners { if (a_ChunkInterface.GetBlock(X, checkBorder, Z) != E_BLOCK_OBSIDIAN) { @@ -115,10 +115,10 @@ public: /// Finds entire frame in any direction with the coordinates of a base block and fills hole with nether portal (START HERE) void FindAndSetPortalFrame(int X, int Y, int Z, cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface) { - int MaxY = FindObsidianCeiling(X, Y, Z, a_ChunkInterface); // Get topmost obsidian block as reference for all other checks - int X1 = X + 1, Z1 = Z + 1, X2 = X - 1, Z2 = Z - 1; // Duplicate XZ values, add/subtract one as we've checked the original already the line above + int MaxY = FindObsidianCeiling(X, Y, Z, a_ChunkInterface); // Get topmost obsidian block as reference for all other checks + int X1 = X + 1, Z1 = Z + 1, X2 = X - 1, Z2 = Z - 1; // Duplicate XZ values, add/subtract one as we've checked the original already the line above - if (MaxY == 0) // Oh noes! Not a portal coordinate :( + if (MaxY == 0) // Oh noes! Not a portal coordinate :( { return; } @@ -127,11 +127,11 @@ public: { if (!FindPortalSliceZ(X, Y, Z1, Z2, MaxY, a_ChunkInterface)) { - return; // No eligible portal construct, abort abort abort!! + return; // No eligible portal construct, abort abort abort!! } } - for (int Height = Y + 1; Height <= MaxY - 1; Height++) // Loop through boundary to set portal blocks + for (int Height = Y + 1; Height <= MaxY - 1; Height++) // Loop through boundary to set portal blocks { for (int Width = XZM; Width <= XZP; Width++) { @@ -153,23 +153,23 @@ public: /// Takes coordinates of base block and Y coord of target obsidian ceiling bool FindPortalSliceX(int X1, int X2, int Y, int Z, int MaxY, cChunkInterface & a_ChunkInterface) { - Dir = 1; // Set assumed direction (will change if portal turns out to be facing the other direction) + Dir = 1; // Set assumed direction (will change if portal turns out to be facing the other direction) bool FoundFrameXP = false, FoundFrameXM = false; - for (; ((a_ChunkInterface.GetBlock(X1, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X1, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X1++) // Check XP for obsidian blocks, exempting corners + for (; ((a_ChunkInterface.GetBlock(X1, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X1, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X1++) // Check XP for obsidian blocks, exempting corners { int Value = FindObsidianCeiling(X1, Y, Z, a_ChunkInterface, MaxY); - int ValueTwo = FindObsidianCeiling(X1, Y + 1, Z, a_ChunkInterface, MaxY); // For corners without obsidian - if ((Value == -1) || (ValueTwo == -1)) // FindObsidianCeiling returns -1 upon frame-find + int ValueTwo = FindObsidianCeiling(X1, Y + 1, Z, a_ChunkInterface, MaxY); // For corners without obsidian + if ((Value == -1) || (ValueTwo == -1)) // FindObsidianCeiling returns -1 upon frame-find { - FoundFrameXP = true; // Found a frame border in this direction, proceed in other direction (don't go further) + FoundFrameXP = true; // Found a frame border in this direction, proceed in other direction (don't go further) break; } - else if ((Value != MaxY) && (ValueTwo != MaxY)) // Make sure that there is a valid portal 'slice' + else if ((Value != MaxY) && (ValueTwo != MaxY)) // Make sure that there is a valid portal 'slice' { - return false; // Not valid slice, no portal can be formed + return false; // Not valid slice, no portal can be formed } - } XZP = X1 - 1; // Set boundary of frame interior - for (; ((a_ChunkInterface.GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM) + } XZP = X1 - 1; // Set boundary of frame interior + for (; ((a_ChunkInterface.GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM) { int Value = FindObsidianCeiling(X2, Y, Z, a_ChunkInterface, MaxY); int ValueTwo = FindObsidianCeiling(X2, Y + 1, Z, a_ChunkInterface, MaxY); @@ -182,7 +182,7 @@ public: { return false; } - } XZM = X2 + 1; // Set boundary, see previous + } XZM = X2 + 1; // Set boundary, see previous return (FoundFrameXP && FoundFrameXM); } diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index 120396c7d..2c41083e7 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -45,7 +45,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.Add(m_BlockType, 1, 0); // Reset meta + a_Pickups.Add(m_BlockType, 1, 0); // Reset meta } diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 495e849fa..260abefc7 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -76,7 +76,7 @@ public: virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay } diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index ec480aaea..6ffb56abd 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -235,7 +235,7 @@ void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBlockPistonHeadHandler: cBlockPistonHeadHandler::cBlockPistonHeadHandler(void) : @@ -262,7 +262,7 @@ void cBlockPistonHeadHandler::OnDestroyedByPlayer(cChunkInterface & a_ChunkInter a_ChunkInterface.DigBlock(a_WorldInterface, newX, newY, newZ); if (a_Player->IsGameModeCreative()) { - return; // No pickups if creative + return; // No pickups if creative } cItems Pickups; diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index 1c8ac6a35..307539476 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -132,7 +132,7 @@ private: { if (cBlockInfo::IsPistonBreakable(a_BlockType)) { - return false; // CanBreakPush returns true, but we need false to prevent pulling + return false; // CanBreakPush returns true, but we need false to prevent pulling } return CanPush(a_BlockType, a_BlockMeta); diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 3b8030028..d58b2f09d 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -36,7 +36,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - return; // No pickups + return; // No pickups } virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override @@ -57,7 +57,7 @@ public: { if ((a_RelY - 1 < 0) || (a_RelY + 1 > cChunkDef::Height)) { - return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1 + return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1 } switch (a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)) diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h index 9cc51490f..1b1f6f9f0 100644 --- a/src/Blocks/BlockQuartz.h +++ b/src/Blocks/BlockQuartz.h @@ -25,7 +25,7 @@ public: { a_BlockType = m_BlockType; NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage); - if (Meta != E_META_QUARTZ_PILLAR) // Check if the block is a pillar block. + if (Meta != E_META_QUARTZ_PILLAR) // Check if the block is a pillar block. { a_BlockMeta = Meta; return true; @@ -42,25 +42,25 @@ public: case BLOCK_FACE_YM: case BLOCK_FACE_YP: { - return a_QuartzMeta; // Top or bottom, just return original + return a_QuartzMeta; // Top or bottom, just return original } case BLOCK_FACE_ZP: case BLOCK_FACE_ZM: { - return 0x4; // North or south + return 0x4; // North or south } case BLOCK_FACE_XP: case BLOCK_FACE_XM: { - return 0x3; // East or west + return 0x3; // East or west } default: { ASSERT(!"Unhandled block face!"); - return a_QuartzMeta; // No idea, give a special meta (all sides the same) + return a_QuartzMeta; // No idea, give a special meta (all sides the same) } } } diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h index 358b5ca11..6f3fa1bd5 100644 --- a/src/Blocks/BlockRail.h +++ b/src/Blocks/BlockRail.h @@ -140,7 +140,7 @@ public: { NIBBLETYPE Meta = 0; char RailsCnt = 0; - bool Neighbors[8]; // 0 - EAST, 1 - WEST, 2 - NORTH, 3 - SOUTH, 4 - EAST UP, 5 - WEST UP, 6 - NORTH UP, 7 - SOUTH UP + bool Neighbors[8]; // 0 - EAST, 1 - WEST, 2 - NORTH, 3 - SOUTH, 4 - EAST UP, 5 - WEST UP, 6 - NORTH UP, 7 - SOUTH UP memset(Neighbors, 0, sizeof(Neighbors)); Neighbors[0] = (IsUnstable(a_ChunkInterface, a_BlockX + 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN)); Neighbors[1] = (IsUnstable(a_ChunkInterface, a_BlockX - 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN)); diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h index fe6cd21b9..4c8a6a087 100644 --- a/src/Blocks/BlockRedstoneRepeater.h +++ b/src/Blocks/BlockRedstoneRepeater.h @@ -71,7 +71,7 @@ public: inline static NIBBLETYPE RepeaterRotationToMetaData(double a_Rotation) { - a_Rotation += 90 + 45; // So its not aligned with axis + a_Rotation += 90 + 45; // So its not aligned with axis if (a_Rotation > 360) { a_Rotation -= 360; diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h index 5b37efd75..9cbd4cf97 100644 --- a/src/Blocks/BlockSideways.h +++ b/src/Blocks/BlockSideways.h @@ -32,7 +32,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3); // Reset meta + a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3); // Reset meta } @@ -43,25 +43,25 @@ public: case BLOCK_FACE_YM: case BLOCK_FACE_YP: { - return a_Meta; // Top or bottom, just return original + return a_Meta; // Top or bottom, just return original } case BLOCK_FACE_ZP: case BLOCK_FACE_ZM: { - return a_Meta | 0x8; // North or south + return a_Meta | 0x8; // North or south } case BLOCK_FACE_XP: case BLOCK_FACE_XM: { - return a_Meta | 0x4; // East or west + return a_Meta | 0x4; // East or west } default: { ASSERT(!"Unhandled block face!"); - return a_Meta | 0xC; // No idea, give a special meta + return a_Meta | 0xC; // No idea, give a special meta } } } diff --git a/src/Blocks/BlockSnow.h b/src/Blocks/BlockSnow.h index b21995d3c..c5ae4a5a6 100644 --- a/src/Blocks/BlockSnow.h +++ b/src/Blocks/BlockSnow.h @@ -47,12 +47,12 @@ public: { if ((a_Player->GetEquippedItem().m_ItemType == E_BLOCK_SNOW) && (a_Meta < 7)) { - return true; // If a player is holding a (thin) snow block and it's size can be increased, return collision ignored + return true; // If a player is holding a (thin) snow block and it's size can be increased, return collision ignored } if (a_Meta == 0) { - return true; // If at normal snowfall height (lowest), we ignore collision + return true; // If at normal snowfall height (lowest), we ignore collision } return false; diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h index a49fda5ae..e74ab0094 100644 --- a/src/Blocks/BlockStairs.h +++ b/src/Blocks/BlockStairs.h @@ -85,7 +85,7 @@ public: static NIBBLETYPE RotationToMetaData(double a_Rotation) { - a_Rotation += 90 + 45; // So its not aligned with axis + a_Rotation += 90 + 45; // So its not aligned with axis if (a_Rotation > 360) { a_Rotation -= 360; diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index 44c33c429..554ab8125 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -28,7 +28,7 @@ public: if ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM)) { - a_BlockFace = FindSuitableFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); // Top or bottom faces clicked, find a suitable face + a_BlockFace = FindSuitableFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); // Top or bottom faces clicked, find a suitable face if (a_BlockFace == BLOCK_FACE_NONE) { // Client wouldn't have sent anything anyway, but whatever @@ -38,10 +38,10 @@ public: else { // Not top or bottom faces, try to preserve whatever face was clicked - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true); // Set to clicked block + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true); // Set to clicked block if (!CanBePlacedOn(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ), a_BlockFace)) { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, false); // Reset to torch block + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, false); // Reset to torch block // Torch couldn't be placed on whatever face was clicked, last ditch resort - find another face a_BlockFace = FindSuitableFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); if (a_BlockFace == BLOCK_FACE_NONE) @@ -113,13 +113,13 @@ public: /// Finds a suitable face to place the torch, returning BLOCK_FACE_NONE on failure static eBlockFace FindSuitableFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - for (int i = BLOCK_FACE_YM; i <= BLOCK_FACE_XP; i++) // Loop through all directions + for (int i = BLOCK_FACE_YM; i <= BLOCK_FACE_XP; i++) // Loop through all directions { eBlockFace Face = static_cast(i); AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face, true); BLOCKTYPE BlockInQuestion = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); - if ( // If on a block that can only hold a torch if torch is standing on it, return that face + if ( // If on a block that can only hold a torch if torch is standing on it, return that face ((BlockInQuestion == E_BLOCK_GLASS) || (BlockInQuestion == E_BLOCK_FENCE) || (BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) || @@ -158,7 +158,7 @@ public: (BlockInQuestion == E_BLOCK_FENCE) || (BlockInQuestion == E_BLOCK_SOULSAND) || (BlockInQuestion == E_BLOCK_MOB_SPAWNER) || - (BlockInQuestion == E_BLOCK_END_PORTAL_FRAME) || // Actual vanilla behaviour + (BlockInQuestion == E_BLOCK_END_PORTAL_FRAME) || // Actual vanilla behaviour (BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) || (BlockInQuestion == E_BLOCK_COBBLESTONE_WALL) ) diff --git a/src/Blocks/MetaRotator.h b/src/Blocks/MetaRotator.h index 899c583e1..ad8f36183 100644 --- a/src/Blocks/MetaRotator.h +++ b/src/Blocks/MetaRotator.h @@ -6,7 +6,7 @@ // MSVC generates warnings for the templated AssertIfNotMatched parameter conditions, so disable it: #ifdef _MSC_VER - #pragma warning(disable: 4127) // Conditional expression is constant + #pragma warning(disable: 4127) // Conditional expression is constant #endif diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index 1a69c856f..64b31c60b 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -140,7 +140,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cByteBuffer: cByteBuffer::cByteBuffer(size_t a_BufferSize) : diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 2d8ff7714..6fb615f1c 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -41,7 +41,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // sSetBlock: sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) // absolute block position @@ -58,7 +58,7 @@ sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_Bloc -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cChunk: cChunk::cChunk( diff --git a/src/ChunkSender.cpp b/src/ChunkSender.cpp index 2425adf18..ebcf0e272 100644 --- a/src/ChunkSender.cpp +++ b/src/ChunkSender.cpp @@ -17,7 +17,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNotifyChunkSender: void cNotifyChunkSender::Call(int a_ChunkX, int a_ChunkZ) @@ -29,7 +29,7 @@ void cNotifyChunkSender::Call(int a_ChunkX, int a_ChunkZ) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cChunkSender: cChunkSender::cChunkSender(void) : diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index afa99008a..97466c331 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -60,7 +60,7 @@ int cClientHandle::s_ClientCount = 0; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cClientHandle: cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) : diff --git a/src/CommandOutput.cpp b/src/CommandOutput.cpp index 2c116b3d6..510461d81 100644 --- a/src/CommandOutput.cpp +++ b/src/CommandOutput.cpp @@ -10,7 +10,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCommandOutputCallback: void cCommandOutputCallback::Out(const char * a_Fmt, ...) @@ -28,7 +28,7 @@ void cCommandOutputCallback::Out(const char * a_Fmt, ...) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cLogCommandOutputCallback: void cLogCommandOutputCallback::Out(const AString & a_Text) diff --git a/src/CompositeChat.cpp b/src/CompositeChat.cpp index a3612983a..f1a797897 100644 --- a/src/CompositeChat.cpp +++ b/src/CompositeChat.cpp @@ -100,7 +100,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat: cCompositeChat::cCompositeChat(void) : @@ -399,7 +399,7 @@ void cCompositeChat::AddStyle(AString & a_Style, const AString & a_AddStyle) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cBasePart: cCompositeChat::cBasePart::cBasePart(cCompositeChat::ePartType a_PartType, const AString & a_Text, const AString & a_Style) : @@ -413,7 +413,7 @@ cCompositeChat::cBasePart::cBasePart(cCompositeChat::ePartType a_PartType, const -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cTextPart: cCompositeChat::cTextPart::cTextPart(const AString & a_Text, const AString &a_Style) : @@ -425,7 +425,7 @@ cCompositeChat::cTextPart::cTextPart(const AString & a_Text, const AString &a_St -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cClientTranslatedPart: cCompositeChat::cClientTranslatedPart::cClientTranslatedPart(const AString & a_TranslationID, const AStringVector & a_Parameters, const AString & a_Style) : @@ -438,7 +438,7 @@ cCompositeChat::cClientTranslatedPart::cClientTranslatedPart(const AString & a_T -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cUrlPart: cCompositeChat::cUrlPart::cUrlPart(const AString & a_Text, const AString & a_Url, const AString & a_Style) : @@ -451,7 +451,7 @@ cCompositeChat::cUrlPart::cUrlPart(const AString & a_Text, const AString & a_Url -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cCommandPart: cCompositeChat::cCommandPart::cCommandPart(ePartType a_PartType, const AString & a_Text, const AString & a_Command, const AString & a_Style) : @@ -464,7 +464,7 @@ cCompositeChat::cCommandPart::cCommandPart(ePartType a_PartType, const AString & -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cRunCommandPart: cCompositeChat::cRunCommandPart::cRunCommandPart(const AString & a_Text, const AString & a_Command, const AString & a_Style) : @@ -475,7 +475,7 @@ cCompositeChat::cRunCommandPart::cRunCommandPart(const AString & a_Text, const A -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cSuggestCommandPart: cCompositeChat::cSuggestCommandPart::cSuggestCommandPart(const AString & a_Text, const AString & a_Command, const AString & a_Style) : @@ -487,7 +487,7 @@ cCompositeChat::cSuggestCommandPart::cSuggestCommandPart(const AString & a_Text, -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cShowAchievementPart: cCompositeChat::cShowAchievementPart::cShowAchievementPart(const AString & a_PlayerName, const AString & a_Achievement, const AString & a_Style) : diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index e9946160f..e60c407d0 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -12,7 +12,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCraftingGrid: cCraftingGrid::cCraftingGrid(int a_Width, int a_Height) : @@ -206,7 +206,7 @@ void cCraftingGrid::Dump(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCraftingRecipe: cCraftingRecipe::cCraftingRecipe(const cCraftingGrid & a_CraftingGrid) : @@ -259,7 +259,7 @@ void cCraftingRecipe::Dump(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCraftingRecipes: cCraftingRecipes::cCraftingRecipes(void) diff --git a/src/Cuboid.cpp b/src/Cuboid.cpp index 3e5240248..d97447412 100644 --- a/src/Cuboid.cpp +++ b/src/Cuboid.cpp @@ -21,7 +21,7 @@ static bool DoIntervalsIntersect(int a_Min1, int a_Max1, int a_Min2, int a_Max2) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCuboid: void cCuboid::Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index a3a1667e4..c0e361fea 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -75,12 +75,12 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa { if (GetSpeed().EqualsEps(Vector3d(0, 0, 0), 0.0000001)) { - SetSpeed(GetLookVector().NormalizeCopy() * 0.1); // Ensure that no division by zero happens later + SetSpeed(GetLookVector().NormalizeCopy() * 0.1); // Ensure that no division by zero happens later } Vector3d Hit = a_HitPos; Vector3d SinkMovement = (GetSpeed() / 1000); - Hit += SinkMovement * (0.0005 / SinkMovement.Length()); // Make arrow sink into block a centimetre so it lodges (but not to far so it goes black clientside) + Hit += SinkMovement * (0.0005 / SinkMovement.Length()); // Make arrow sink into block a centimetre so it lodges (but not to far so it goes black clientside) super::OnHitSolidBlock(Hit, a_HitFace); Vector3i BlockHit = Hit.Floor(); @@ -166,9 +166,9 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk) // We can afford to do this because xoft's algorithm for trajectory is near perfect, so things are pretty close anyway without sync // Besides, this seems to be what the vanilla server does, note how arrows teleport half a second after they hit to the server position - if (!m_HasTeleported) // Sent a teleport already, don't do again + if (!m_HasTeleported) // Sent a teleport already, don't do again { - if (m_HitGroundTimer > 500.f) // Send after half a second, could be less, but just in case + if (m_HitGroundTimer > 500.f) // Send after half a second, could be less, but just in case { m_World->BroadcastTeleportEntity(*this); m_HasTeleported = true; @@ -189,9 +189,9 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk) return; } - if (Chunk->GetBlock(RelPosX, m_HitBlockPos.y, RelPosZ) == E_BLOCK_AIR) // Block attached to was destroyed? + if (Chunk->GetBlock(RelPosX, m_HitBlockPos.y, RelPosZ) == E_BLOCK_AIR) // Block attached to was destroyed? { - m_IsInGround = false; // Yes, begin simulating physics again + m_IsInGround = false; // Yes, begin simulating physics again } } } diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h index 76cb24449..ad93dba6c 100644 --- a/src/Entities/ArrowEntity.h +++ b/src/Entities/ArrowEntity.h @@ -99,4 +99,4 @@ protected: virtual void CollectedBy(cPlayer * a_Player) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; -}; // tolua_export +}; // tolua_export diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp index 31bfe3dc3..2e9e77b44 100644 --- a/src/Entities/Boat.cpp +++ b/src/Entities/Boat.cpp @@ -94,7 +94,7 @@ void cBoat::Tick(float a_Dt, cChunk & a_Chunk) super::Tick(a_Dt, a_Chunk); BroadcastMovementUpdate(); - SetSpeed(GetSpeed() * 0.97); // Slowly decrease the speed + SetSpeed(GetSpeed() * 0.97); // Slowly decrease the speed if ((POSY_TOINT < 0) || (POSY_TOINT > cChunkDef::Height)) { diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index c6dc1fca3..0a85537bf 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -272,7 +272,7 @@ void cEntity::SetYawFromSpeed(void) void cEntity::SetPitchFromSpeed(void) { const double EPS = 0.0000001; - double xz = sqrt(m_Speed.x * m_Speed.x + m_Speed.z * m_Speed.z); // Speed XZ-plane component + double xz = sqrt(m_Speed.x * m_Speed.x + m_Speed.z * m_Speed.z); // Speed XZ-plane component if ((abs(xz) < EPS) && (abs(m_Speed.y) < EPS)) { // atan2() may overflow or is undefined, pick any number @@ -316,7 +316,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) if ((a_TDI.DamageType == dtAttack) || (a_TDI.DamageType == dtArrowAttack)) { a_TDI.FinalDamage += 2; - m_World->BroadcastEntityAnimation(*this, 4); // Critical hit + m_World->BroadcastEntityAnimation(*this, 4); // Critical hit } } @@ -332,7 +332,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) m_Health = 0; } - if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs + if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs { int KnockbackLevel = 0; if (a_TDI.Attacker->GetEquippedWeapon().m_ItemType == E_ITEM_BOW) @@ -767,11 +767,11 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) NextSpeed.x *= 0.25; NextSpeed.z *= 0.25; } - - //Get water direction + + // Get water direction Direction WaterDir = m_World->GetWaterSimulator()->GetFlowingDirection(BlockX, BlockY, BlockZ); - m_WaterSpeed *= 0.9f; //Reduce speed each tick + m_WaterSpeed *= 0.9f; // Reduce speed each tick switch(WaterDir) { @@ -828,7 +828,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) if (Tracer.HitNormal.y != 0.f) NextSpeed.y = 0.f; if (Tracer.HitNormal.z != 0.f) NextSpeed.z = 0.f; - if (Tracer.HitNormal.y == 1) // Hit BLOCK_FACE_YP, we are on the ground + if (Tracer.HitNormal.y == 1) // Hit BLOCK_FACE_YP, we are on the ground { m_bOnGround = true; } @@ -1095,9 +1095,9 @@ void cEntity::HandleAir(void) if (IsSubmerged()) { - if (!IsPlayer()) // Players control themselves + if (!IsPlayer()) // Players control themselves { - SetSpeedY(1); // Float in the water + SetSpeedY(1); // Float in the water } // Either reduce air level or damage player @@ -1266,9 +1266,9 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude) int DiffY = (int)(floor(GetPosY() * 32.0) - floor(m_LastPos.y * 32.0)); int DiffZ = (int)(floor(GetPosZ() * 32.0) - floor(m_LastPos.z * 32.0)); - if ((DiffX != 0) || (DiffY != 0) || (DiffZ != 0)) // Have we moved? + if ((DiffX != 0) || (DiffY != 0) || (DiffZ != 0)) // Have we moved? { - if ((abs(DiffX) <= 127) && (abs(DiffY) <= 127) && (abs(DiffZ) <= 127)) // Limitations of a Byte + if ((abs(DiffX) <= 127) && (abs(DiffY) <= 127) && (abs(DiffZ) <= 127)) // Limitations of a Byte { // Difference within Byte limitations, use a relative move packet if (m_bDirtyOrientation) @@ -1288,7 +1288,7 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude) { // Too big a movement, do a teleport m_World->BroadcastTeleportEntity(*this, a_Exclude); - m_LastPos = GetPosition(); // See above + m_LastPos = GetPosition(); // See above m_bDirtyOrientation = false; } } @@ -1587,7 +1587,7 @@ void cEntity::SteerVehicle(float a_Forward, float a_Sideways) -////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Get look vector (this is NOT a rotation!) Vector3d cEntity::GetLookVector(void) const { @@ -1601,7 +1601,7 @@ Vector3d cEntity::GetLookVector(void) const -////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Set position void cEntity::SetPosition(double a_PosX, double a_PosY, double a_PosZ) { diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index ea44c2722..011293233 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -506,7 +506,7 @@ protected: overrides can provide further processing, such as forcing players to move at the given speed. */ virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ); - virtual void Destroyed(void) {} // Called after the entity has been destroyed + virtual void Destroyed(void) {} // Called after the entity has been destroyed /** Called in each tick to handle air-related processing i.e. drowning */ virtual void HandleAir(void); diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp index 4da7cac85..6c4b13a58 100644 --- a/src/Entities/EntityEffect.cpp +++ b/src/Entities/EntityEffect.cpp @@ -108,7 +108,7 @@ void cEntityEffect::OnTick(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectInstantHealth: void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target) @@ -128,7 +128,7 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectInstantDamage: void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target) @@ -148,7 +148,7 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectRegeneration: void cEntityEffectRegeneration::OnTick(cPawn & a_Target) @@ -175,7 +175,7 @@ void cEntityEffectRegeneration::OnTick(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectHunger: void cEntityEffectHunger::OnTick(cPawn & a_Target) @@ -193,7 +193,7 @@ void cEntityEffectHunger::OnTick(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectWeakness: void cEntityEffectWeakness::OnTick(cPawn & a_Target) @@ -211,7 +211,7 @@ void cEntityEffectWeakness::OnTick(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectPoison: void cEntityEffectPoison::OnTick(cPawn & a_Target) @@ -250,7 +250,7 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectWither: void cEntityEffectWither::OnTick(cPawn & a_Target) @@ -270,7 +270,7 @@ void cEntityEffectWither::OnTick(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectSaturation: void cEntityEffectSaturation::OnTick(cPawn & a_Target) diff --git a/src/Entities/ExpBottleEntity.h b/src/Entities/ExpBottleEntity.h index b2043d8f1..e9536452c 100644 --- a/src/Entities/ExpBottleEntity.h +++ b/src/Entities/ExpBottleEntity.h @@ -30,4 +30,4 @@ protected: // cProjectileEntity overrides: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; -}; // tolua_export +}; // tolua_export diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h index 3924c337c..42ecc7d74 100644 --- a/src/Entities/FireChargeEntity.h +++ b/src/Entities/FireChargeEntity.h @@ -33,4 +33,4 @@ protected: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/FireworkEntity.h b/src/Entities/FireworkEntity.h index c62ca9402..7dbdc49e1 100644 --- a/src/Entities/FireworkEntity.h +++ b/src/Entities/FireworkEntity.h @@ -37,4 +37,4 @@ private: int m_ExplodeTimer; cItem m_FireworkItem; -}; // tolua_export +}; // tolua_export diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp index d49893020..159429147 100644 --- a/src/Entities/Floater.cpp +++ b/src/Entities/Floater.cpp @@ -11,7 +11,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFloaterEntityCollisionCallback class cFloaterEntityCollisionCallback : public cEntityCallback @@ -75,7 +75,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFloaterCheckEntityExist class cFloaterCheckEntityExist : public cEntityCallback @@ -130,7 +130,7 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk) HandlePhysics(a_Dt, a_Chunk); if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())) && m_World->GetBlockMeta((int) GetPosX(), (int) GetPosY(), (int) GetPosZ()) == 0) { - if ((!m_CanPickupItem) && (m_AttachedMobID == -1)) // Check if you can't already pickup a fish and if the floater isn't attached to a mob. + if ((!m_CanPickupItem) && (m_AttachedMobID == -1)) // Check if you can't already pickup a fish and if the floater isn't attached to a mob. { if (m_CountDownTime <= 0) { @@ -141,7 +141,7 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk) m_CountDownTime = 100 + m_World->GetTickRandomNumber(800); LOGD("Floater %i can be picked up", GetUniqueID()); } - else if (m_CountDownTime == 20) // Calculate the position where the particles should spawn and start producing them. + else if (m_CountDownTime == 20) // Calculate the position where the particles should spawn and start producing them. { LOGD("Started producing particles for floater %i", GetUniqueID()); m_ParticlePos.Set(GetPosX() + (-4 + m_World->GetTickRandomNumber(8)), GetPosY(), GetPosZ() + (-4 + m_World->GetTickRandomNumber(8))); @@ -156,12 +156,12 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk) m_CountDownTime--; if (m_World->GetHeight((int) GetPosX(), (int) GetPosZ()) == (int) GetPosY()) { - if (m_World->IsWeatherWet() && m_World->GetTickRandomNumber(3) == 0) // 25% chance of an extra countdown when being rained on. + if (m_World->IsWeatherWet() && m_World->GetTickRandomNumber(3) == 0) // 25% chance of an extra countdown when being rained on. { m_CountDownTime--; } } - else // if the floater is underground it has a 50% chance of not decreasing the countdown. + else // if the floater is underground it has a 50% chance of not decreasing the countdown. { if (m_World->GetTickRandomNumber(1) == 0) { @@ -190,21 +190,21 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk) if (Callback.HasHit()) { AttachTo(Callback.GetHitEntity()); - Callback.GetHitEntity()->TakeDamage(*this); // TODO: the player attacked the mob not the floater. + Callback.GetHitEntity()->TakeDamage(*this); // TODO: the player attacked the mob not the floater. m_AttachedMobID = Callback.GetHitEntity()->GetUniqueID(); } } cFloaterCheckEntityExist EntityCallback; m_World->DoWithEntityByID(m_PlayerID, EntityCallback); - if (!EntityCallback.DoesExist()) // The owner doesn't exist anymore. Destroy the floater entity. + if (!EntityCallback.DoesExist()) // The owner doesn't exist anymore. Destroy the floater entity. { Destroy(true); } if (m_AttachedMobID != -1) { - m_World->DoWithEntityByID(m_AttachedMobID, EntityCallback); // The mob the floater was attached to doesn't exist anymore. + m_World->DoWithEntityByID(m_AttachedMobID, EntityCallback); // The mob the floater was attached to doesn't exist anymore. if (!EntityCallback.DoesExist()) { m_AttachedMobID = -1; diff --git a/src/Entities/Floater.h b/src/Entities/Floater.h index 547d503f1..5d2720b6a 100644 --- a/src/Entities/Floater.h +++ b/src/Entities/Floater.h @@ -14,7 +14,7 @@ class cFloater : typedef cEntity super; public: - //tolua_end + // tolua_end CLASS_PROTODEF(cFloater); @@ -43,4 +43,4 @@ protected: // Entity IDs int m_PlayerID; int m_AttachedMobID; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h index 9e4572c78..fa59fa642 100644 --- a/src/Entities/GhastFireballEntity.h +++ b/src/Entities/GhastFireballEntity.h @@ -35,4 +35,4 @@ protected: // TODO: Deflecting the fireballs by arrow- or sword- hits -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp index 41ac86268..d7a7ba943 100644 --- a/src/Entities/HangingEntity.cpp +++ b/src/Entities/HangingEntity.cpp @@ -28,14 +28,14 @@ void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle) // The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces switch (m_BlockFace) { - case BLOCK_FACE_ZP: break; // Initialised to zero + case BLOCK_FACE_ZP: break; // Initialised to zero case BLOCK_FACE_ZM: Dir = 2; break; case BLOCK_FACE_XM: Dir = 1; break; case BLOCK_FACE_XP: Dir = 3; break; default: ASSERT(!"Unhandled block face when trying to spawn item frame!"); return; } - if ((Dir == 0) || (Dir == 2)) // Probably a client bug, but two directions are flipped and contrary to the norm, so we do -180 + if ((Dir == 0) || (Dir == 2)) // Probably a client bug, but two directions are flipped and contrary to the norm, so we do -180 { SetYaw((Dir * 90) - 180); } diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp index 4cd707faa..144c6d5aa 100644 --- a/src/Entities/ItemFrame.cpp +++ b/src/Entities/ItemFrame.cpp @@ -43,7 +43,7 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player) } } - GetWorld()->BroadcastEntityMetadata(*this); // Update clients + GetWorld()->BroadcastEntityMetadata(*this); // Update clients } diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index 7bd440d6d..6502ae45a 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -117,7 +117,7 @@ void cMinecart::SpawnOn(cClientHandle & a_ClientHandle) return; } } - a_ClientHandle.SendSpawnVehicle(*this, 10, SubType); // 10 = Minecarts, SubType = What type of Minecart + a_ClientHandle.SendSpawnVehicle(*this, 10, SubType); // 10 = Minecarts, SubType = What type of Minecart a_ClientHandle.SendEntityMetadata(*this); } @@ -127,7 +127,7 @@ void cMinecart::SpawnOn(cClientHandle & a_ClientHandle) void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk) { - if (IsDestroyed()) // Mainly to stop detector rails triggering again after minecart is dead + if (IsDestroyed()) // Mainly to stop detector rails triggering again after minecart is dead { return; } @@ -156,8 +156,8 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk) if (!IsBlockRail(InsideType)) { - Chunk->GetBlockTypeMeta(RelPosX, PosY + 1, RelPosZ, InsideType, InsideMeta); // When an descending minecart hits a flat rail, it goes through the ground; check for this - if (IsBlockRail(InsideType)) AddPosY(1); // Push cart upwards + Chunk->GetBlockTypeMeta(RelPosX, PosY + 1, RelPosZ, InsideType, InsideMeta); // When an descending minecart hits a flat rail, it goes through the ground; check for this + if (IsBlockRail(InsideType)) AddPosY(1); // Push cart upwards } bool WasDetectorRail = false; @@ -186,12 +186,12 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk) default: VERIFY(!"Unhandled rail type despite checking if block was rail!"); break; } - AddPosition(GetSpeed() * (a_Dt / 1000)); // Commit changes; as we use our own engine when on rails, this needs to be done, whereas it is normally in Entity.cpp + AddPosition(GetSpeed() * (a_Dt / 1000)); // Commit changes; as we use our own engine when on rails, this needs to be done, whereas it is normally in Entity.cpp } else { // Not on rail, default physics - SetPosY(floor(GetPosY()) + 0.35); // HandlePhysics overrides this if minecart can fall, else, it is to stop ground clipping minecart bottom when off-rail + SetPosY(floor(GetPosY()) + 0.35); // HandlePhysics overrides this if minecart can fall, else, it is to stop ground clipping minecart bottom when off-rail super::HandlePhysics(a_Dt, *Chunk); } @@ -223,18 +223,18 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) switch (a_RailMeta) { - case E_META_RAIL_ZM_ZP: // NORTHSOUTH + case E_META_RAIL_ZM_ZP: // NORTHSOUTH { SetYaw(270); SetPosY(floor(GetPosY()) + 0.55); - SetSpeedY(0); // Don't move vertically as on ground - SetSpeedX(0); // Correct diagonal movement from curved rails + SetSpeedY(0); // Don't move vertically as on ground + SetSpeedX(0); // Correct diagonal movement from curved rails // Execute both the entity and block collision checks bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta); if (EntCol || BlckCol) return; - if (GetSpeedZ() != 0) // Don't do anything if cart is stationary + if (GetSpeedZ() != 0) // Don't do anything if cart is stationary { if (GetSpeedZ() > 0) { @@ -249,7 +249,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) } break; } - case E_META_RAIL_XM_XP: // EASTWEST + case E_META_RAIL_XM_XP: // EASTWEST { SetYaw(180); SetPosY(floor(GetPosY()) + 0.55); @@ -272,7 +272,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) } break; } - case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH + case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH { SetYaw(270); SetSpeedX(0); @@ -280,21 +280,21 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) if (GetSpeedZ() >= 0) { // SpeedZ POSITIVE, going SOUTH - if (GetSpeedZ() <= MAX_SPEED) // Speed limit + if (GetSpeedZ() <= MAX_SPEED) // Speed limit { - AddSpeedZ(0.5); // Speed up - SetSpeedY(-GetSpeedZ()); // Downward movement is negative (0 minus positive numbers is negative) + AddSpeedZ(0.5); // Speed up + SetSpeedY(-GetSpeedZ()); // Downward movement is negative (0 minus positive numbers is negative) } } else { // SpeedZ NEGATIVE, going NORTH - AddSpeedZ(1); // Slow down - SetSpeedY(-GetSpeedZ()); // Upward movement is positive (0 minus negative number is positive number) + AddSpeedZ(1); // Slow down + SetSpeedY(-GetSpeedZ()); // Upward movement is positive (0 minus negative number is positive number) } break; } - case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH + case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH { SetYaw(270); SetSpeedX(0); @@ -302,21 +302,21 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) if (GetSpeedZ() > 0) { // SpeedZ POSITIVE, going SOUTH - AddSpeedZ(-1); // Slow down - SetSpeedY(GetSpeedZ()); // Upward movement positive + AddSpeedZ(-1); // Slow down + SetSpeedY(GetSpeedZ()); // Upward movement positive } else { - if (GetSpeedZ() >= MAX_SPEED_NEGATIVE) // Speed limit + if (GetSpeedZ() >= MAX_SPEED_NEGATIVE) // Speed limit { // SpeedZ NEGATIVE, going NORTH - AddSpeedZ(-0.5); // Speed up - SetSpeedY(GetSpeedZ()); // Downward movement negative + AddSpeedZ(-0.5); // Speed up + SetSpeedY(GetSpeedZ()); // Downward movement negative } } break; } - case E_META_RAIL_ASCEND_XM: // ASCEND EAST + case E_META_RAIL_ASCEND_XM: // ASCEND EAST { SetYaw(180); SetSpeedZ(0); @@ -336,7 +336,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) } break; } - case E_META_RAIL_ASCEND_XP: // ASCEND WEST + case E_META_RAIL_ASCEND_XP: // ASCEND WEST { SetYaw(180); SetSpeedZ(0); @@ -356,10 +356,10 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) } break; } - case E_META_RAIL_CURVED_ZM_XM: // Ends pointing NORTH and WEST + case E_META_RAIL_CURVED_ZM_XM: // Ends pointing NORTH and WEST { - SetYaw(315); // Set correct rotation server side - SetPosY(floor(GetPosY()) + 0.55); // Levitate dat cart + SetYaw(315); // Set correct rotation server side + SetPosY(floor(GetPosY()) + 0.55); // Levitate dat cart SetSpeedY(0); TestBlockCollision(a_RailMeta); @@ -369,7 +369,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) break; } - case E_META_RAIL_CURVED_ZM_XP: // Curved NORTH EAST + case E_META_RAIL_CURVED_ZM_XP: // Curved NORTH EAST { SetYaw(225); SetPosY(floor(GetPosY()) + 0.55); @@ -380,7 +380,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) break; } - case E_META_RAIL_CURVED_ZP_XM: // Curved SOUTH WEST + case E_META_RAIL_CURVED_ZP_XM: // Curved SOUTH WEST { SetYaw(135); SetPosY(floor(GetPosY()) + 0.55); @@ -391,7 +391,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) break; } - case E_META_RAIL_CURVED_ZP_XP: // Curved SOUTH EAST + case E_META_RAIL_CURVED_ZP_XP: // Curved SOUTH EAST { SetYaw(45); SetPosY(floor(GetPosY()) + 0.55); @@ -404,7 +404,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) } default: { - ASSERT(!"Unhandled rail meta!"); // Dun dun DUN! + ASSERT(!"Unhandled rail meta!"); // Dun dun DUN! break; } } @@ -428,7 +428,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) switch (a_RailMeta & 0x07) { - case E_META_RAIL_ZM_ZP: // NORTHSOUTH + case E_META_RAIL_ZM_ZP: // NORTHSOUTH { SetYaw(270); SetPosY(floor(GetPosY()) + 0.55); @@ -451,7 +451,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) } break; } - case E_META_RAIL_XM_XP: // EASTWEST + case E_META_RAIL_XM_XP: // EASTWEST { SetYaw(180); SetPosY(floor(GetPosY()) + 0.55); @@ -474,7 +474,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) } break; } - case E_META_RAIL_ASCEND_XM: // ASCEND EAST + case E_META_RAIL_ASCEND_XM: // ASCEND EAST { SetYaw(180); SetSpeedZ(0); @@ -494,7 +494,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) } break; } - case E_META_RAIL_ASCEND_XP: // ASCEND WEST + case E_META_RAIL_ASCEND_XP: // ASCEND WEST { SetYaw(180); SetSpeedZ(0); @@ -514,7 +514,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) } break; } - case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH + case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH { SetYaw(270); SetSpeedX(0); @@ -534,7 +534,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) } break; } - case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH + case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH { SetYaw(270); SetSpeedX(0); @@ -907,7 +907,7 @@ bool cMinecart::DoTakeDamage(TakeDamageInfo & TDI) if ((TDI.Attacker != NULL) && TDI.Attacker->IsPlayer() && ((cPlayer *)TDI.Attacker)->IsGameModeCreative()) { Destroy(); - TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative + TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative SetInvulnerableTicks(0); return super::DoTakeDamage(TDI); // No drops for creative } @@ -980,7 +980,7 @@ void cMinecart::Destroyed() -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRideableMinecart: cRideableMinecart::cRideableMinecart(double a_X, double a_Y, double a_Z, const cItem & a_Content, int a_Height) : @@ -1023,7 +1023,7 @@ void cRideableMinecart::OnRightClicked(cPlayer & a_Player) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMinecartWithChest: cMinecartWithChest::cMinecartWithChest(double a_X, double a_Y, double a_Z) : @@ -1056,7 +1056,7 @@ void cMinecartWithChest::OnRightClicked(cPlayer & a_Player) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMinecartWithFurnace: cMinecartWithFurnace::cMinecartWithFurnace(double a_X, double a_Y, double a_Z) : @@ -1078,12 +1078,12 @@ void cMinecartWithFurnace::OnRightClicked(cPlayer & a_Player) { a_Player.GetInventory().RemoveOneEquippedItem(); } - if (!m_IsFueled) // We don't want to change the direction by right clicking it. + if (!m_IsFueled) // We don't want to change the direction by right clicking it. { AddSpeed(a_Player.GetLookVector().x, 0, a_Player.GetLookVector().z); } m_IsFueled = true; - m_FueledTimeLeft = m_FueledTimeLeft + 600; // The minecart will be active 600 more ticks. + m_FueledTimeLeft = m_FueledTimeLeft + 600; // The minecart will be active 600 more ticks. m_World->BroadcastEntityMetadata(*this); } } @@ -1118,7 +1118,7 @@ void cMinecartWithFurnace::Tick(float a_Dt, cChunk & a_Chunk) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMinecartWithTNT: cMinecartWithTNT::cMinecartWithTNT(double a_X, double a_Y, double a_Z) : @@ -1132,7 +1132,7 @@ cMinecartWithTNT::cMinecartWithTNT(double a_X, double a_Y, double a_Z) : -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMinecartWithHopper: cMinecartWithHopper::cMinecartWithHopper(double a_X, double a_Y, double a_Z) : diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h index 30af6d412..ce7c6f3de 100644 --- a/src/Entities/Painting.h +++ b/src/Entities/Painting.h @@ -18,8 +18,8 @@ public: CLASS_PROTODEF(cPainting); cPainting(const AString & a_Name, int a_Direction, double a_X, double a_Y, double a_Z); - const AString & GetName(void) const { return m_Name; } // tolua_export - int GetDirection(void) const { return m_Direction; } // tolua_export + const AString & GetName(void) const { return m_Name; } // tolua_export + int GetDirection(void) const { return m_Direction; } // tolua_export private: diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index bae1485d4..ab0f856dd 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -113,7 +113,7 @@ void cPickup::SpawnOn(cClientHandle & a_Client) void cPickup::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - BroadcastMovementUpdate(); //Notify clients of position + BroadcastMovementUpdate(); // Notify clients of position m_Timer += a_Dt; @@ -150,10 +150,10 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk) } } - if (!IsDestroyed() && (m_Item.m_ItemCount < m_Item.GetMaxStackSize())) // Don't combine into an already full pickup + if (!IsDestroyed() && (m_Item.m_ItemCount < m_Item.GetMaxStackSize())) // Don't combine into an already full pickup { cPickupCombiningCallback PickupCombiningCallback(GetPosition(), this); - m_World->ForEachEntity(PickupCombiningCallback); // Not ForEachEntityInChunk, otherwise pickups don't combine across chunk boundaries + m_World->ForEachEntity(PickupCombiningCallback); // Not ForEachEntityInChunk, otherwise pickups don't combine across chunk boundaries if (PickupCombiningCallback.FoundMatchingPickup()) { m_World->BroadcastEntityMetadata(*this); @@ -176,7 +176,7 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk) return; } - if (GetPosY() < VOID_BOUNDARY) // Out of this world and no more visible! + if (GetPosY() < VOID_BOUNDARY) // Out of this world and no more visible! { Destroy(true); return; @@ -194,14 +194,14 @@ bool cPickup::CollectedBy(cPlayer * a_Dest) if (m_bCollected) { // LOG("Pickup %d cannot be collected by \"%s\", because it has already been collected.", m_UniqueID, a_Dest->GetName().c_str()); - return false; // It's already collected! + return false; // It's already collected! } // Two seconds if player created the pickup (vomiting), half a second if anything else if (m_Timer < (m_bIsPlayerCreated ? 2000.f : 500.f)) { // LOG("Pickup %d cannot be collected by \"%s\", because it is not old enough.", m_UniqueID, a_Dest->GetName().c_str()); - return false; // Not old enough + return false; // Not old enough } if (cRoot::Get()->GetPluginManager()->CallHookCollectingPickup(a_Dest, *this)) diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h index 2dcbecaaf..d50941280 100644 --- a/src/Entities/Pickup.h +++ b/src/Entities/Pickup.h @@ -27,7 +27,7 @@ public: cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); - cItem & GetItem(void) {return m_Item; } // tolua_export + cItem & GetItem(void) {return m_Item; } // tolua_export const cItem & GetItem(void) const {return m_Item; } virtual void SpawnOn(cClientHandle & a_ClientHandle) override; @@ -46,7 +46,7 @@ public: bool IsCollected(void) const { return m_bCollected; } // tolua_export /** Returns true if created by player (i.e. vomiting), used for determining picking-up delay time */ - bool IsPlayerCreated(void) const { return m_bIsPlayerCreated; } // tolua_export + bool IsPlayerCreated(void) const { return m_bIsPlayerCreated; } // tolua_export private: diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index da50843b6..c4f9c59ab 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -223,7 +223,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) SendExperience(); } - if (!GetPosition().EqualsEps(m_LastPos, 0.01)) // Non negligible change in position from last tick? + if (!GetPosition().EqualsEps(m_LastPos, 0.01)) // Non negligible change in position from last tick? { // Apply food exhaustion from movement: ApplyFoodExhaustionFromMovement(); @@ -284,19 +284,19 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) short cPlayer::CalcLevelFromXp(short a_XpTotal) { - //level 0 to 15 + // level 0 to 15 if(a_XpTotal <= XP_TO_LEVEL15) { return a_XpTotal / XP_PER_LEVEL_TO15; } - //level 30+ + // level 30+ if(a_XpTotal > XP_TO_LEVEL30) { return (short) (151.5 + sqrt( 22952.25 - (14 * (2220 - a_XpTotal)))) / 7; } - //level 16 to 30 + // level 16 to 30 return (short) ( 29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal )))) / 3; } @@ -306,19 +306,19 @@ short cPlayer::CalcLevelFromXp(short a_XpTotal) short cPlayer::XpForLevel(short a_Level) { - //level 0 to 15 + // level 0 to 15 if(a_Level <= 15) { return a_Level * XP_PER_LEVEL_TO15; } - //level 30+ + // level 30+ if(a_Level >= 31) { return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220 ); } - //level 16 to 30 + // level 16 to 30 return (short) ( (1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360 ); } @@ -353,7 +353,7 @@ bool cPlayer::SetCurrentExperience(short int a_CurrentXp) if(!(a_CurrentXp >= 0) || (a_CurrentXp > (SHRT_MAX - m_LifetimeTotalXp))) { LOGWARNING("Tried to update experiece with an invalid Xp value: %d", a_CurrentXp); - return false; //oops, they gave us a dodgey number + return false; // oops, they gave us a dodgey number } m_CurrentXp = a_CurrentXp; @@ -375,7 +375,7 @@ short cPlayer::DeltaExperience(short a_Xp_delta) // Value was bad, abort and report LOGWARNING("Attempt was made to increment Xp by %d, which overflowed the short datatype. Ignoring.", a_Xp_delta); - return -1; // Should we instead just return the current Xp? + return -1; // Should we instead just return the current Xp? } m_CurrentXp += a_Xp_delta; @@ -477,7 +477,7 @@ void cPlayer::SetTouchGround(bool a_bTouchGround) { float Dist = (float)(m_LastGroundHeight - floor(GetPosY())); - if (Dist >= 2.0) // At least two blocks - TODO: Use m_LastJumpHeight instead of m_LastGroundHeight above + if (Dist >= 2.0) // At least two blocks - TODO: Use m_LastJumpHeight instead of m_LastGroundHeight above { // Increment statistic m_Stats.AddValue(statDistFallen, (StatValue)floor(Dist * 100 + 0.5)); @@ -623,7 +623,7 @@ void cPlayer::FinishEating(void) GetInventory().RemoveOneEquippedItem(); - //if the food is mushroom soup, return a bowl to the inventory + // if the food is mushroom soup, return a bowl to the inventory if( Item.m_ItemType == E_ITEM_MUSHROOM_SOUP ) { cItem emptyBowl(E_ITEM_BOWL, 1, 0, ""); GetInventory().AddItem(emptyBowl, true, true); @@ -871,10 +871,10 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) if (m_Health > 0) { - return; // not dead yet =] + return; // not dead yet =] } - m_bVisible = false; // So new clients don't see the player + m_bVisible = false; // So new clients don't see the player // Puke out all the items cItems Pickups; @@ -925,7 +925,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) else { AString KillerClass = a_TDI.Attacker->GetClass(); - KillerClass.erase(KillerClass.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch") + KillerClass.erase(KillerClass.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch") GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str())); } @@ -1338,7 +1338,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos ) void cPlayer::SetVisible(bool a_bVisible) { - if (a_bVisible && !m_bVisible) // Make visible + if (a_bVisible && !m_bVisible) // Make visible { m_bVisible = true; m_World->BroadcastSpawnEntity(*this); @@ -1420,7 +1420,7 @@ bool cPlayer::HasPermission(const AString & a_Permission) { if( OtherSplit[i].compare( Split[i] ) != 0 ) { - if( OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard! + if( OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard! break; } } @@ -1548,7 +1548,7 @@ void cPlayer::TossEquippedItem(char a_Amount) char NewAmount = a_Amount; if (NewAmount > GetInventory().GetEquippedItem().m_ItemCount) { - NewAmount = GetInventory().GetEquippedItem().m_ItemCount; // Drop only what's there + NewAmount = GetInventory().GetEquippedItem().m_ItemCount; // Drop only what's there } GetInventory().GetHotbarGrid().ChangeSlotCount(GetInventory().GetEquippedSlotNum() /* Returns hotbar subslot, which HotbarGrid takes */, -a_Amount); @@ -1610,7 +1610,7 @@ void cPlayer::TossItems(const cItems & a_Items) double vX = 0, vY = 0, vZ = 0; EulerToVector(-GetYaw(), GetPitch(), vZ, vX, vY); vY = -vY * 2 + 1.f; - m_World->SpawnItemPickups(a_Items, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player + m_World->SpawnItemPickups(a_Items, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player } @@ -1931,7 +1931,7 @@ cPlayer::StringList cPlayer::GetResolvedPermissions() void cPlayer::UseEquippedItem(void) { - if (IsGameModeCreative()) // No damage in creative + if (IsGameModeCreative()) // No damage in creative { return; } @@ -2074,7 +2074,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos) { if (IsClimbing()) { - if (a_DeltaPos.y > 0.0) // Going up + if (a_DeltaPos.y > 0.0) // Going up { m_Stats.AddValue(statDistClimbed, (StatValue)floor(a_DeltaPos.y * 100 + 0.5)); } @@ -2093,7 +2093,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos) } else { - if (Value >= 25) // Ignore small/slow movement + if (Value >= 25) // Ignore small/slow movement { m_Stats.AddValue(statDistFlown, Value); } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 793f11e57..171e9541b 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -174,7 +174,7 @@ public: AString GetIP(void) const { return m_IP; } // tolua_export /** Returns the associated team, NULL if none */ - cTeam * GetTeam(void) { return m_Team; } // tolua_export + cTeam * GetTeam(void) { return m_Team; } // tolua_export /** Sets the player team, NULL if none */ void SetTeam(cTeam * a_Team); @@ -200,7 +200,7 @@ public: /** Forces the player to move in the given direction. @deprecated Use SetSpeed instead. */ - void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export + void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export /** Tries to move to a new position, with attachment-related checks (y == -999) */ void MoveTo(const Vector3d & a_NewPos); // tolua_export @@ -570,7 +570,7 @@ protected: /** Returns the filename for the player data based on the UUID given. This can be used both for online and offline UUIDs. */ AString GetUUIDFileName(const AString & a_UUID); -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 019ebeaa5..a55c9b895 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -35,7 +35,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProjectileTracerCallback: class cProjectileTracerCallback : @@ -122,7 +122,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProjectileEntityCollisionCallback: class cProjectileEntityCollisionCallback : @@ -211,7 +211,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProjectileEntity: cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height) : diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index 14cee1272..7b045de76 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -120,4 +120,4 @@ protected: virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override; virtual void SpawnOn(cClientHandle & a_Client) override; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index ed5afaf11..3efb1f25d 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -7,7 +7,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSplashPotionEntityCallback: /** Used to distribute the splashed potion effect among nearby entities */ @@ -63,7 +63,7 @@ private: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSplashPotionEntity: cSplashPotionEntity::cSplashPotionEntity( diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 076e477da..2c78b55d2 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -56,4 +56,4 @@ protected: /** Splashes the potion, fires its particle effects and sounds @param a_HitPos The position where the potion will splash */ void Splash(const Vector3d & a_HitPos); -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h index 116f5a8cb..df61b14f5 100644 --- a/src/Entities/TNTEntity.h +++ b/src/Entities/TNTEntity.h @@ -38,7 +38,7 @@ public: protected: int m_FuseTicks; ///< How much ticks is left, while the tnt will explode -}; // tolua_export +}; // tolua_export diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h index dc72c279f..f93731256 100644 --- a/src/Entities/ThrownEggEntity.h +++ b/src/Entities/ThrownEggEntity.h @@ -55,4 +55,4 @@ private: /** Time in ticks to wait for the hit animation to begin before destroying */ int m_DestroyTimer; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h index 1cea5f7d9..549d8a3eb 100644 --- a/src/Entities/ThrownEnderPearlEntity.h +++ b/src/Entities/ThrownEnderPearlEntity.h @@ -55,4 +55,4 @@ private: /** Time in ticks to wait for the hit animation to begin before destroying */ int m_DestroyTimer; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h index 9a8770379..6f3efdd7e 100644 --- a/src/Entities/ThrownSnowballEntity.h +++ b/src/Entities/ThrownSnowballEntity.h @@ -52,4 +52,4 @@ private: /** Time in ticks to wait for the hit animation to begin before destroying */ int m_DestroyTimer; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h index 8b3639802..ebc1550e3 100644 --- a/src/Entities/WitherSkullEntity.h +++ b/src/Entities/WitherSkullEntity.h @@ -32,4 +32,4 @@ protected: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index a17555f37..d314fc13e 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -12,7 +12,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBiomeGen: cBiomeGen * cBiomeGen::CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a_CacheOffByDefault) @@ -78,7 +78,7 @@ cBiomeGen * cBiomeGen::CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenConstant: void cBioGenConstant::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) @@ -108,7 +108,7 @@ void cBioGenConstant::InitializeBiomeGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenCache: cBioGenCache::cBioGenCache(cBiomeGen * a_BioGenToCache, int a_CacheSize) : @@ -209,7 +209,7 @@ void cBioGenCache::InitializeBiomeGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBiomeGenList: void cBiomeGenList::InitializeBiomes(const AString & a_Biomes) @@ -290,7 +290,7 @@ void cBiomeGenList::InitializeBiomes(const AString & a_Biomes) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenCheckerboard: void cBioGenCheckerboard::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) @@ -324,7 +324,7 @@ void cBioGenCheckerboard::InitializeBiomeGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenVoronoi : void cBioGenVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) @@ -357,7 +357,7 @@ void cBioGenVoronoi::InitializeBiomeGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenDistortedVoronoi: void cBioGenDistortedVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) @@ -418,7 +418,7 @@ void cBioGenDistortedVoronoi::Distort(int a_BlockX, int a_BlockZ, int & a_Distor -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenMultiStepMap : cBioGenMultiStepMap::cBioGenMultiStepMap(int a_Seed) : @@ -739,7 +739,7 @@ void cBioGenMultiStepMap::FreezeWaterBiomes(cChunkDef::BiomeMap & a_BiomeMap, co -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenTwoLevel: cBioGenTwoLevel::cBioGenTwoLevel(int a_Seed) : diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index 6aa7fd4cb..f543846d2 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -151,7 +151,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCaveTunnel: cCaveTunnel::cCaveTunnel( @@ -571,7 +571,7 @@ AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) cons -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenWormNestCaves::cCaveSystem: cStructGenWormNestCaves::cCaveSystem::cCaveSystem(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise) : @@ -687,7 +687,7 @@ int cStructGenWormNestCaves::cCaveSystem::GetRadius(cNoise & a_Noise, int a_Orig -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenWormNestCaves: cGridStructGen::cStructurePtr cStructGenWormNestCaves::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) @@ -700,7 +700,7 @@ cGridStructGen::cStructurePtr cStructGenWormNestCaves::CreateStructure(int a_Gri -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenMarbleCaves: static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise ) @@ -752,7 +752,7 @@ void cStructGenMarbleCaves::GenFinish(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenDualRidgeCaves: void cStructGenDualRidgeCaves::GenFinish(cChunkDesc & a_ChunkDesc) diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp index 73f0223e8..3f8f77f09 100644 --- a/src/Generating/ChunkGenerator.cpp +++ b/src/Generating/ChunkGenerator.cpp @@ -22,7 +22,7 @@ const unsigned int QUEUE_SKIP_LIMIT = 500; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cChunkGenerator: cChunkGenerator::cChunkGenerator(void) : @@ -290,7 +290,7 @@ void cChunkGenerator::DoGenerate(int a_ChunkX, int a_ChunkY, int a_ChunkZ) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cChunkGenerator::cGenerator: cChunkGenerator::cGenerator::cGenerator(cChunkGenerator & a_ChunkGenerator) : diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 2da285d72..160d095ed 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -18,7 +18,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompoGenSameBlock: void cCompoGenSameBlock::ComposeTerrain(cChunkDesc & a_ChunkDesc) @@ -60,7 +60,7 @@ void cCompoGenSameBlock::InitializeCompoGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompoGenDebugBiomes: void cCompoGenDebugBiomes::ComposeTerrain(cChunkDesc & a_ChunkDesc) @@ -111,7 +111,7 @@ void cCompoGenDebugBiomes::ComposeTerrain(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompoGenClassic: cCompoGenClassic::cCompoGenClassic(void) : @@ -209,7 +209,7 @@ void cCompoGenClassic::InitializeCompoGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompoGenBiomal: void cCompoGenBiomal::ComposeTerrain(cChunkDesc & a_ChunkDesc) @@ -526,7 +526,7 @@ void cCompoGenBiomal::FillColumnPattern(int a_RelX, int a_RelZ, int a_Height, cC -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompoGenNether: cCompoGenNether::cCompoGenNether(int a_Seed) : @@ -645,7 +645,7 @@ void cCompoGenNether::InitializeCompoGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompoGenCache: cCompoGenCache::cCompoGenCache(cTerrainCompositionGen & a_Underlying, int a_CacheSize) : diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 7b6234161..167fbab37 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -34,7 +34,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cTerrainCompositionGen: cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile & a_IniFile, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen, int a_Seed) @@ -114,7 +114,7 @@ cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile & -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cComposableGenerator: cComposableGenerator::cComposableGenerator(cChunkGenerator & a_ChunkGenerator) : diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp index eb9fe92ba..b46850a81 100644 --- a/src/Generating/DistortedHeightmap.cpp +++ b/src/Generating/DistortedHeightmap.cpp @@ -14,7 +14,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPattern: /// This class is used to store a column pattern initialized at runtime, @@ -50,7 +50,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // The arrays to use for the top block pattern definitions: static cDistortedHeightmap::sBlockInfo tbGrass[] = @@ -119,7 +119,7 @@ static cDistortedHeightmap::sBlockInfo tbStone[] = -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Ocean floor pattern top-block definitions: static cDistortedHeightmap::sBlockInfo tbOFSand[] = @@ -151,7 +151,7 @@ static cDistortedHeightmap::sBlockInfo tbOFRedSand[] = -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Individual patterns to use: static cPattern patGrass (tbGrass, ARRAYCOUNT(tbGrass)); @@ -171,7 +171,7 @@ static cPattern patOFRedSand(tbOFRedSand, ARRAYCOUNT(tbOFRedSand)); -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cDistortedHeightmap: /** This table assigns a relative maximum overhang size in each direction to biomes. diff --git a/src/Generating/EndGen.cpp b/src/Generating/EndGen.cpp index f466039b9..abbf050f7 100644 --- a/src/Generating/EndGen.cpp +++ b/src/Generating/EndGen.cpp @@ -29,7 +29,7 @@ enum -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEndGen: cEndGen::cEndGen(int a_Seed) : diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index f2d66af70..dd1ab045d 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -40,12 +40,12 @@ static inline bool IsWater(BLOCKTYPE a_BlockType) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenNetherClumpFoliage: void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc) { - double ChunkX = a_ChunkDesc.GetChunkX() + 0.1; // We can't devide through 0 so lets add 0.1 to all the chunk coordinates. + double ChunkX = a_ChunkDesc.GetChunkX() + 0.1; // We can't devide through 0 so lets add 0.1 to all the chunk coordinates. double ChunkZ = a_ChunkDesc.GetChunkZ() + 0.1; NOISE_DATATYPE Val1 = m_Noise.CubicNoise2D((float) (ChunkX * ChunkZ * 0.01f), (float) (ChunkZ / ChunkX * 0.01f)); @@ -125,7 +125,7 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a float zz = (float) a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; for (int y = a_RelY - 2; y < a_RelY + 2; y++) { - if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks. + if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks. { continue; } @@ -136,7 +136,7 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a continue; } - if (IsFireBlock) // don't place fire on non-forever burning blocks. + if (IsFireBlock) // don't place fire on non-forever burning blocks. { if (!cFireSimulator::DoesBurnForever(BlockBelow)) { @@ -159,7 +159,7 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenSprinkleFoliage: bool cFinishGenSprinkleFoliage::TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ) @@ -309,7 +309,7 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenSnow: void cFinishGenSnow::GenFinish(cChunkDesc & a_ChunkDesc) @@ -345,7 +345,7 @@ void cFinishGenSnow::GenFinish(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenIce: void cFinishGenIce::GenFinish(cChunkDesc & a_ChunkDesc) @@ -385,7 +385,7 @@ void cFinishGenIce::GenFinish(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenLilypads: int cFinishGenSingleBiomeSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap) @@ -447,7 +447,7 @@ void cFinishGenSingleBiomeSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenBottomLava: void cFinishGenBottomLava::GenFinish(cChunkDesc & a_ChunkDesc) @@ -470,7 +470,7 @@ void cFinishGenBottomLava::GenFinish(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenPreSimulator: cFinishGenPreSimulator::cFinishGenPreSimulator(void) @@ -637,7 +637,7 @@ void cFinishGenPreSimulator::StationarizeFluid( -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenFluidSprings: cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cIniFile & a_IniFile, eDimension a_Dimension) : diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp index fd1d5e49f..7090f14b1 100644 --- a/src/Generating/GridStructGen.cpp +++ b/src/Generating/GridStructGen.cpp @@ -9,7 +9,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEmptyStructure: /** A cStructure descendant representing an empty structure. diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index 202f7db7e..537e30a31 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -16,7 +16,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cTerrainHeightGen: cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBiomeGen & a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault) @@ -91,7 +91,7 @@ cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBio -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHeiGenFlat: void cHeiGenFlat::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) @@ -115,7 +115,7 @@ void cHeiGenFlat::InitializeHeightGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHeiGenCache: cHeiGenCache::cHeiGenCache(cTerrainHeightGen & a_HeiGenToCache, int a_CacheSize) : @@ -234,7 +234,7 @@ bool cHeiGenCache::GetHeightAt(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_Rel -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHeiGenClassic: cHeiGenClassic::cHeiGenClassic(int a_Seed) : @@ -255,7 +255,7 @@ float cHeiGenClassic::GetNoise(float x, float y) float height = m_Noise.CubicNoise2D(x * 0.1f, y * 0.1f ) * 2; - float flatness = ((m_Noise.CubicNoise2D(x * 0.5f, y * 0.5f) + 1.f) * 0.5f) * 1.1f; // 0 ... 1.5 + float flatness = ((m_Noise.CubicNoise2D(x * 0.5f, y * 0.5f) + 1.f) * 0.5f) * 1.1f; // 0 ... 1.5 flatness *= flatness * flatness; return (oct1 + oct2 + oct3) * flatness + height; @@ -306,7 +306,7 @@ void cHeiGenClassic::InitializeHeightGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHeiGenMountains: cHeiGenMountains::cHeiGenMountains(int a_Seed) : @@ -368,7 +368,7 @@ void cHeiGenMountains::InitializeHeightGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHeiGenBiomal: const cHeiGenBiomal::sGenParam cHeiGenBiomal::m_GenParam[256] = diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index ab9b1aa29..e951b90fa 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -275,7 +275,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenMineShafts::cMineShaftSystem: cStructGenMineShafts::cMineShaftSystem::cMineShaftSystem( @@ -400,7 +400,7 @@ bool cStructGenMineShafts::cMineShaftSystem::CanAppend(const cCuboid & a_Boundin -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMineShaftDirtRoom: cMineShaftDirtRoom::cMineShaftDirtRoom(cStructGenMineShafts::cMineShaftSystem & a_Parent, cNoise & a_Noise) : @@ -492,7 +492,7 @@ void cMineShaftDirtRoom::ProcessChunk(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMineShaftCorridor: cMineShaftCorridor::cMineShaftCorridor( @@ -732,7 +732,7 @@ void cMineShaftCorridor::ProcessChunk(cChunkDesc & a_ChunkDesc) PlaceChest(a_ChunkDesc); PlaceTracks(a_ChunkDesc); - PlaceSpawner(a_ChunkDesc); // (must be after Tracks!) + PlaceSpawner(a_ChunkDesc); // (must be after Tracks!) PlaceTorches(a_ChunkDesc); } @@ -964,7 +964,7 @@ void cMineShaftCorridor::PlaceTorches(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMineShaftCrossing: cMineShaftCrossing::cMineShaftCrossing(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, const cCuboid & a_BoundingBox) : @@ -1100,7 +1100,7 @@ void cMineShaftCrossing::ProcessChunk(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMineShaftStaircase: cMineShaftStaircase::cMineShaftStaircase( @@ -1278,7 +1278,7 @@ void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenMineShafts: cStructGenMineShafts::cStructGenMineShafts( diff --git a/src/Generating/NetherFortGen.cpp b/src/Generating/NetherFortGen.cpp index 23fa56048..f35555efd 100644 --- a/src/Generating/NetherFortGen.cpp +++ b/src/Generating/NetherFortGen.cpp @@ -11,7 +11,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNetherFortGen::cNetherFort: class cNetherFortGen::cNetherFort : @@ -65,7 +65,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Performance test of the NetherFort generator: /* @@ -99,7 +99,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNetherFortGen: cPrefabPiecePool cNetherFortGen::m_PiecePool(g_NetherFortPrefabs, g_NetherFortPrefabsCount, g_NetherFortStartingPrefabs, g_NetherFortStartingPrefabsCount); diff --git a/src/Generating/Noise3DGenerator.cpp b/src/Generating/Noise3DGenerator.cpp index 15a588d45..b879349ee 100644 --- a/src/Generating/Noise3DGenerator.cpp +++ b/src/Generating/Noise3DGenerator.cpp @@ -61,7 +61,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNoise3DGenerator: cNoise3DGenerator::cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator) : @@ -342,7 +342,7 @@ void cNoise3DGenerator::ComposeTerrain(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNoise3DComposable: cNoise3DComposable::cNoise3DComposable(int a_Seed) : diff --git a/src/Generating/POCPieceGenerator.cpp b/src/Generating/POCPieceGenerator.cpp index 491f4d206..6e7e74d7a 100644 --- a/src/Generating/POCPieceGenerator.cpp +++ b/src/Generating/POCPieceGenerator.cpp @@ -150,7 +150,7 @@ static void DebugPieces(const cPlacedPieces & a_Pieces) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPOCPieceGenerator: cPOCPieceGenerator::cPOCPieceGenerator(int a_Seed) : diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index 5de231f75..fe1005dba 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -13,7 +13,7 @@ #ifdef SELF_TEST -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Self-test: static class cPieceGeneratorSelfTest : @@ -140,7 +140,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPiece: @@ -254,7 +254,7 @@ cCuboid cPiece::RotateMoveHitBox(int a_NumCCWRotations, int a_MoveX, int a_MoveY -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPiece::cConnector: cPiece::cConnector::cConnector(int a_X, int a_Y, int a_Z, int a_Type, eBlockFace a_Direction) : @@ -279,7 +279,7 @@ cPiece::cConnector::cConnector(const Vector3i & a_Pos, int a_Type, eBlockFace a_ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPlacedPiece: cPlacedPiece::cPlacedPiece(const cPlacedPiece * a_Parent, const cPiece & a_Piece, const Vector3i & a_Coords, int a_NumCCWRotations) : @@ -328,7 +328,7 @@ void cPlacedPiece::MoveToGroundBy(int a_OffsetY) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPieceGenerator: cPieceGenerator::cPieceGenerator(cPiecePool & a_PiecePool, int a_Seed) : @@ -578,7 +578,7 @@ void cPieceGenerator::DebugConnectorPool(const cPieceGenerator::cFreeConnectors -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPieceGenerator::cConnection: cPieceGenerator::cConnection::cConnection(cPiece & a_Piece, cPiece::cConnector & a_Connector, int a_NumCCWRotations, int a_Weight) : @@ -593,7 +593,7 @@ cPieceGenerator::cConnection::cConnection(cPiece & a_Piece, cPiece::cConnector & -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPieceGenerator::cFreeConnector: cPieceGenerator::cFreeConnector::cFreeConnector(cPlacedPiece * a_Piece, const cPiece::cConnector & a_Connector) : @@ -606,7 +606,7 @@ cPieceGenerator::cFreeConnector::cFreeConnector(cPlacedPiece * a_Piece, const cP -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBFSPieceGenerator: cBFSPieceGenerator::cBFSPieceGenerator(cPiecePool & a_PiecePool, int a_Seed) : diff --git a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp index 976f8490e..8c935c2a5 100644 --- a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp +++ b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BarWithBasement: // The data has been exported from the gallery Desert, area index 82, ID 598, created by STR_Warrior { @@ -264,7 +264,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BarWithoutBasement: // The data has been exported from the gallery Desert, area index 81, ID 597, created by STR_Warrior { @@ -463,7 +463,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BlackSmith: // The data has been exported from the gallery Desert, area index 97, ID 642, created by STR_Warrior { @@ -633,7 +633,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LargeHouse1: // The data has been exported from the gallery Desert, area index 77, ID 577, created by STR_Warrior { @@ -922,7 +922,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LargeTower: // The data has been exported from the gallery Desert, area index 80, ID 596, created by STR_Warrior { @@ -1108,7 +1108,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse: // The data has been exported from the gallery Desert, area index 65, ID 551, created by STR_Warrior { @@ -1229,7 +1229,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse2: // The data has been exported from the gallery Desert, area index 72, ID 562, created by STR_Warrior { @@ -1376,7 +1376,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse3: // The data has been exported from the gallery Desert, area index 66, ID 553, created by STR_Warrior { @@ -1496,7 +1496,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse4: // The data has been exported from the gallery Desert, area index 70, ID 560, created by STR_Warrior { @@ -1647,7 +1647,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse5: // The data has been exported from the gallery Desert, area index 68, ID 558, created by STR_Warrior { @@ -1781,7 +1781,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse6: // The data has been exported from the gallery Desert, area index 69, ID 559, created by STR_Warrior { @@ -1922,7 +1922,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse7: // The data has been exported from the gallery Desert, area index 73, ID 563, created by xoft { @@ -2068,7 +2068,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse8: // The data has been exported from the gallery Desert, area index 99, ID 739, created by STR_Warrior { @@ -2200,7 +2200,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleTower: // The data has been exported from the gallery Desert, area index 79, ID 595, created by STR_Warrior { @@ -2351,7 +2351,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MediumHouse1: // The data has been exported from the gallery Desert, area index 71, ID 561, created by STR_Warrior { @@ -2531,7 +2531,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MediumHouse2: // The data has been exported from the gallery Desert, area index 74, ID 573, created by STR_Warrior { @@ -2740,7 +2740,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MediumHouse3: // The data has been exported from the gallery Desert, area index 76, ID 575, created by STR_Warrior { @@ -2958,7 +2958,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SmallHouse9: // The data has been exported from the gallery Desert, area index 67, ID 556, created by STR_Warrior { @@ -3104,7 +3104,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Temple: // The data has been exported from the gallery Desert, area index 83, ID 599, created by STR_Warrior { @@ -3310,7 +3310,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = const cPrefab::sDef g_AlchemistVillageStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Well: // The data has been exported from the gallery Desert, area index 90, ID 631, created by STR_Warrior { diff --git a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp index d22153d87..c49015e36 100644 --- a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp +++ b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Arch: // The data has been exported from the gallery Plains, area index 144, ID 488, created by Aloe_vera { @@ -129,7 +129,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Farm: // The data has been exported from the gallery Plains, area index 166, ID 554, created by Aloe_vera { @@ -299,7 +299,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Forge: // The data has been exported from the gallery Plains, area index 79, ID 145, created by Aloe_vera { @@ -565,7 +565,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Garden2: // The data has been exported from the gallery Plains, area index 147, ID 491, created by Aloe_vera { @@ -717,7 +717,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseMid: // The data has been exported from the gallery Plains, area index 62, ID 119, created by Aloe_vera { @@ -893,7 +893,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseSmall: // The data has been exported from the gallery Plains, area index 68, ID 131, created by Aloe_vera { @@ -1004,7 +1004,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseSmallDblWithDoor: // The data has been exported from the gallery Plains, area index 113, ID 265, created by Aloe_vera { @@ -1128,7 +1128,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseSmallDouble: // The data has been exported from the gallery Plains, area index 72, ID 135, created by Aloe_vera { @@ -1249,7 +1249,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseSmallWithDoor: // The data has been exported from the gallery Plains, area index 112, ID 264, created by Aloe_vera { @@ -1362,7 +1362,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseWide: // The data has been exported from the gallery Plains, area index 64, ID 121, created by STR_Warrior { @@ -1510,7 +1510,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseWithGarden: // The data has been exported from the gallery Plains, area index 67, ID 130, created by Aloe_vera { @@ -1756,7 +1756,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseWithSakura1: // The data has been exported from the gallery Plains, area index 75, ID 141, created by Aloe_vera { @@ -1950,7 +1950,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseWithSpa: // The data has been exported from the gallery Plains, area index 73, ID 139, created by Aloe_vera { @@ -2158,7 +2158,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MediumSakuraTree: // The data has been exported from the gallery Plains, area index 146, ID 490, created by STR_Warrior { @@ -2312,7 +2312,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Restaurant: // The data has been exported from the gallery Plains, area index 61, ID 117, created by Aloe_vera { @@ -2566,7 +2566,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SakuraDouble: // The data has been exported from the gallery Plains, area index 76, ID 142, created by Aloe_vera { @@ -2697,7 +2697,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SakuraSmall: // The data has been exported from the gallery Plains, area index 145, ID 489, created by Aloe_vera { @@ -2808,7 +2808,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = const cPrefab::sDef g_JapaneseVillageStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HighTemple: // The data has been exported from the gallery Plains, area index 70, ID 133, created by Aloe_vera { @@ -3159,7 +3159,7 @@ const cPrefab::sDef g_JapaneseVillageStartingPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Well: // The data has been exported from the gallery Plains, area index 143, ID 487, created by STR_Warrior { diff --git a/src/Generating/Prefabs/NetherFortPrefabs.cpp b/src/Generating/Prefabs/NetherFortPrefabs.cpp index 2c97f28ea..ee3a8899b 100644 --- a/src/Generating/Prefabs/NetherFortPrefabs.cpp +++ b/src/Generating/Prefabs/NetherFortPrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BalconyCorridor: // The data has been exported from the gallery Nether, area index 37, ID 288, created by Aloe_vera { @@ -162,7 +162,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BalconyTee2: // The data has been exported from the gallery Nether, area index 38, ID 289, created by Aloe_vera { @@ -325,7 +325,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BlazePlatform: // The data has been exported from the gallery Nether, area index 26, ID 276, created by tonibm1999 { @@ -448,7 +448,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BlazePlatformOverhang: // The data has been exported from the gallery Nether, area index 20, ID 162, created by STR_Warrior { @@ -621,7 +621,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeCircleCrossing: // The data has been exported from the gallery Nether, area index 49, ID 308, created by Aloe_vera { @@ -824,7 +824,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeCrossing: // The data has been exported from the gallery Nether, area index 17, ID 159, created by Aloe_vera { @@ -1028,7 +1028,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeCrumble1: // The data has been exported from the gallery Nether, area index 19, ID 161, created by Aloe_vera { @@ -1125,7 +1125,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeCrumble2: // The data has been exported from the gallery Nether, area index 18, ID 160, created by Aloe_vera { @@ -1228,7 +1228,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeDoubleCrumble: // The data has been exported from the gallery Nether, area index 46, ID 305, created by STR_Warrior { @@ -1410,7 +1410,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeFunnelDown: // The data has been exported from the gallery Nether, area index 0, ID 2, created by Aloe_vera { @@ -1653,7 +1653,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeLevelCrossing: // The data has been exported from the gallery Nether, area index 61, ID 321, created by Aloe_vera { @@ -1985,7 +1985,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeSegment: // The data has been exported from the gallery Nether, area index 16, ID 158, created by Aloe_vera { @@ -2107,7 +2107,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeTee: // The data has been exported from the gallery Nether, area index 39, ID 290, created by STR_Warrior { @@ -2270,7 +2270,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Corridor11: // The data has been exported from the gallery Nether, area index 36, ID 287, created by Aloe_vera { @@ -2374,7 +2374,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Corridor13: // The data has been exported from the gallery Nether, area index 35, ID 286, created by Aloe_vera { @@ -2478,7 +2478,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Corridor5: // The data has been exported from the gallery Nether, area index 65, ID 330, created by xoft { @@ -2576,7 +2576,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorCorner5: // The data has been exported from the gallery Nether, area index 10, ID 40, created by xoft { @@ -2718,7 +2718,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorCornerChest5: // The data has been exported from the gallery Nether, area index 42, ID 293, created by STR_Warrior { @@ -2861,7 +2861,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorCrossing: // The data has been exported from the gallery Nether, area index 63, ID 328, created by xoft { @@ -2989,7 +2989,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorStairs: // The data has been exported from the gallery Nether, area index 12, ID 42, created by xoft { @@ -3144,7 +3144,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // DarkCorridor: // The data has been exported from the gallery Nether, area index 3, ID 30, created by STR_Warrior { @@ -3248,7 +3248,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LavaStaircase: // The data has been exported from the gallery Nether, area index 28, ID 278, created by Aloe_vera { @@ -3508,7 +3508,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LavaStaircaseBig: // The data has been exported from the gallery Nether, area index 31, ID 282, created by STR_Warrior { @@ -3842,7 +3842,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LavaStairsBridge: // The data has been exported from the gallery Nether, area index 30, ID 281, created by STR_Warrior { @@ -4123,7 +4123,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MidStaircase: // The data has been exported from the gallery Nether, area index 23, ID 165, created by Aloe_vera { @@ -4314,7 +4314,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // StairsToOpen1: // The data has been exported from the gallery Nether, area index 27, ID 277, created by Aloe_vera { @@ -4460,7 +4460,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // StairsToOpen2: // The data has been exported from the gallery Nether, area index 8, ID 35, created by xoft { @@ -4606,7 +4606,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Tee2x4: // The data has been exported from the gallery Nether, area index 40, ID 291, created by Aloe_vera { @@ -4726,7 +4726,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Tee4x4: // The data has been exported from the gallery Nether, area index 41, ID 292, created by Aloe_vera { @@ -4858,7 +4858,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // TinyCorridorCorner: // The data has been exported from the gallery Nether, area index 66, ID 331, created by xoft { @@ -4957,7 +4957,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // TinyCorridorCornerChest: // The data has been exported from the gallery Nether, area index 67, ID 332, created by Aloe_vera { @@ -5057,7 +5057,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // TinyCorridorCrossing: // The data has been exported from the gallery Nether, area index 64, ID 329, created by xoft { @@ -5159,7 +5159,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Turret: // The data has been exported from the gallery Nether, area index 7, ID 34, created by xoft { @@ -5283,7 +5283,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = const cPrefab::sDef g_NetherFortStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CentralRoom: // The data has been exported from the gallery Nether, area index 22, ID 164, created by Aloe_vera { diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index bad8dae74..714a66559 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BigPlantBed: // The data has been exported from the gallery Plains, area index 26, ID 70, created by Taugrammaton { @@ -195,7 +195,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CobbleHouse10x5Library: // The data has been exported from the gallery Plains, area index 23, ID 66, created by xoft { @@ -336,7 +336,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // DoublePlantBed: // The data has been exported from the gallery Plains, area index 5, ID 20, created by tonibm1999 { @@ -492,7 +492,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Forge: // The data has been exported from the gallery Plains, area index 51, ID 102, created by Aloe_vera { @@ -692,7 +692,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LampPost: // The data has been exported from the gallery Plains, area index 28, ID 73, created by STR_Warrior { @@ -784,7 +784,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftCorridor: // The data has been exported from the gallery Plains, area index 139, ID 447, created by STR_Warrior { @@ -861,7 +861,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftCrossing: // The data has been exported from the gallery Plains, area index 171, ID 578, created by Aloe_vera { @@ -946,7 +946,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftCrossing: // The data has been exported from the gallery Plains, area index 193, ID 657, created by Aloe_vera { @@ -1064,7 +1064,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftDoubleCrossing: // The data has been exported from the gallery Plains, area index 172, ID 579, created by Aloe_vera { @@ -1189,7 +1189,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftSpiral: // The data has been exported from the gallery Plains, area index 198, ID 662, created by Aloe_vera { @@ -1370,7 +1370,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftStairs: // The data has been exported from the gallery Plains, area index 195, ID 659, created by Aloe_vera { @@ -1469,7 +1469,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftStairsCrossing: // The data has been exported from the gallery Plains, area index 199, ID 663, created by Aloe_vera { @@ -1719,7 +1719,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftTee: // The data has been exported from the gallery Plains, area index 194, ID 658, created by Aloe_vera { @@ -1819,7 +1819,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftsCorridor5: // The data has been exported from the gallery Plains, area index 200, ID 664, created by Aloe_vera { @@ -1898,7 +1898,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Scarecrow: // The data has been exported from the gallery Plains, area index 150, ID 494, created by STR_Warrior { @@ -1983,7 +1983,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SinglePlantBed: // The data has been exported from the gallery Plains, area index 17, ID 60, created by Aloe_vera { @@ -2108,7 +2108,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenChurchMid: // The data has been exported from the gallery Plains, area index 58, ID 109, created by Aloe_vera { @@ -2418,7 +2418,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenGranary: // The data has been exported from the gallery Plains, area index 54, ID 105, created by Aloe_vera { @@ -2560,7 +2560,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse10x7Library: // The data has been exported from the gallery Plains, area index 47, ID 98, created by Aloe_vera { @@ -2729,7 +2729,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse5x5: // The data has been exported from the gallery Plains, area index 49, ID 100, created by Aloe_vera { @@ -2856,7 +2856,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse7x5: // The data has been exported from the gallery Plains, area index 40, ID 91, created by xoft { @@ -2983,7 +2983,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x5: // The data has been exported from the gallery Plains, area index 41, ID 92, created by xoft { @@ -3117,7 +3117,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x5Fence: // The data has been exported from the gallery Plains, area index 9, ID 26, created by Aloe_vera { @@ -3287,7 +3287,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x5Library: // The data has been exported from the gallery Plains, area index 46, ID 97, created by Aloe_vera { @@ -3428,7 +3428,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x7: // The data has been exported from the gallery Plains, area index 52, ID 103, created by Aloe_vera { @@ -3590,7 +3590,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x7Butcher: // The data has been exported from the gallery Plains, area index 48, ID 99, created by Aloe_vera { @@ -3806,7 +3806,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x7DoubleDoor: // The data has been exported from the gallery Plains, area index 38, ID 87, created by Aloe_vera { @@ -3971,7 +3971,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouseL13x14: // The data has been exported from the gallery Plains, area index 39, ID 90, created by STR_Warrior { @@ -4223,7 +4223,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouseL14x14: // The data has been exported from the gallery Plains, area index 0, ID 4, created by Aloe_vera { @@ -4450,7 +4450,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouseL9x9: // The data has been exported from the gallery Plains, area index 42, ID 93, created by xoft { @@ -4619,7 +4619,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouseU13x9: // The data has been exported from the gallery Plains, area index 43, ID 94, created by xoft { @@ -4786,7 +4786,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenMill5x5: // The data has been exported from the gallery Plains, area index 60, ID 111, created by Aloe_vera { @@ -5121,7 +5121,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenStables: // The data has been exported from the gallery Plains, area index 55, ID 106, created by Aloe_vera { @@ -5307,7 +5307,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CobbleWell4x4: // The data has been exported from the gallery Plains, area index 1, ID 5, created by Aloe_vera { @@ -5448,7 +5448,7 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineEntrance: // The data has been exported from the gallery Plains, area index 138, ID 446, created by STR_Warrior { @@ -5897,7 +5897,7 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // RoofedWell: // The data has been exported from the gallery Plains, area index 119, ID 271, created by STR_Warrior { diff --git a/src/Generating/Prefabs/RainbowRoadPrefabs.cpp b/src/Generating/Prefabs/RainbowRoadPrefabs.cpp index 1a3765c5a..bf7b1b096 100644 --- a/src/Generating/Prefabs/RainbowRoadPrefabs.cpp +++ b/src/Generating/Prefabs/RainbowRoadPrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CurveDouble: // The data has been exported from the gallery Cube, area index 89, ID 467, created by Aloe_vera { @@ -85,7 +85,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CurveDownFromTopSingle: // The data has been exported from the gallery Cube, area index 100, ID 478, created by Aloe_vera { @@ -255,7 +255,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CurveSingle: // The data has been exported from the gallery Cube, area index 84, ID 462, created by Aloe_vera { @@ -320,7 +320,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CurveSingleLeft: // The data has been exported from the gallery Cube, area index 97, ID 475, created by Aloe_vera { @@ -385,7 +385,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CurveUpDouble: // The data has been exported from the gallery Cube, area index 92, ID 470, created by Aloe_vera { @@ -581,7 +581,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CurveUpSingle: // The data has been exported from the gallery Cube, area index 87, ID 465, created by Aloe_vera { @@ -751,7 +751,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SlopeDownFromTopSingle: // The data has been exported from the gallery Cube, area index 98, ID 476, created by Aloe_vera { @@ -881,7 +881,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SlopeUpDouble: // The data has been exported from the gallery Cube, area index 90, ID 468, created by Aloe_vera { @@ -1061,7 +1061,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SlopeUpSingle: // The data has been exported from the gallery Cube, area index 85, ID 463, created by Aloe_vera { @@ -1191,7 +1191,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SplitTee: // The data has been exported from the gallery Cube, area index 93, ID 471, created by Aloe_vera { @@ -1261,7 +1261,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // StraightDouble: // The data has been exported from the gallery Cube, area index 88, ID 466, created by Aloe_vera { @@ -1335,7 +1335,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = const cPrefab::sDef g_RainbowRoadStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // StraightSingle: // The data has been exported from the gallery Cube, area index 83, ID 461, created by Aloe_vera { diff --git a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp index 44e947952..3328ee210 100644 --- a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp +++ b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Forge: // The data has been exported from the gallery Desert, area index 32, ID 173, created by Aloe_vera { @@ -162,7 +162,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House11x7: // The data has been exported from the gallery Desert, area index 31, ID 172, created by Aloe_vera { @@ -301,7 +301,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House5x4: // The data has been exported from the gallery Desert, area index 25, ID 166, created by Aloe_vera { @@ -412,7 +412,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House5x5: // The data has been exported from the gallery Desert, area index 26, ID 167, created by Aloe_vera { @@ -530,7 +530,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House7x5: // The data has been exported from the gallery Desert, area index 27, ID 168, created by Aloe_vera { @@ -648,7 +648,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House8x5: // The data has been exported from the gallery Desert, area index 28, ID 169, created by Aloe_vera { @@ -772,7 +772,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House8x7: // The data has been exported from the gallery Desert, area index 29, ID 170, created by Aloe_vera { @@ -910,7 +910,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House9x7: // The data has been exported from the gallery Desert, area index 30, ID 171, created by Aloe_vera { @@ -1049,7 +1049,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseL13x12: // The data has been exported from the gallery Desert, area index 53, ID 345, created by jakibaki { @@ -1220,7 +1220,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MarketStall: // The data has been exported from the gallery Desert, area index 34, ID 175, created by Aloe_vera { @@ -1330,7 +1330,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Marketplace: // The data has been exported from the gallery Desert, area index 38, ID 261, created by Aloe_vera { @@ -1472,7 +1472,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = const cPrefab::sDef g_SandFlatRoofVillageStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Well: // The data has been exported from the gallery Desert, area index 44, ID 275, created by Aloe_vera { diff --git a/src/Generating/Prefabs/SandVillagePrefabs.cpp b/src/Generating/Prefabs/SandVillagePrefabs.cpp index 72881a678..c63f8161b 100644 --- a/src/Generating/Prefabs/SandVillagePrefabs.cpp +++ b/src/Generating/Prefabs/SandVillagePrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // DoubleField: // The data has been exported from the gallery Desert, area index 5, ID 75, created by tonibm1999 { @@ -102,7 +102,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House11x7: // The data has been exported from the gallery Desert, area index 6, ID 81, created by Aloe_vera { @@ -236,7 +236,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House11x9: // The data has been exported from the gallery Desert, area index 11, ID 115, created by xoft { @@ -395,7 +395,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House13x7: // The data has been exported from the gallery Desert, area index 15, ID 125, created by Aloe_vera { @@ -527,7 +527,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House13x9: // The data has been exported from the gallery Desert, area index 12, ID 116, created by xoft { @@ -686,7 +686,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House15x9: // The data has been exported from the gallery Desert, area index 13, ID 118, created by xoft { @@ -845,7 +845,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House16x9: // The data has been exported from the gallery Desert, area index 16, ID 126, created by Aloe_vera { @@ -1004,7 +1004,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House7x7: // The data has been exported from the gallery Desert, area index 8, ID 112, created by Aloe_vera { @@ -1128,7 +1128,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House9x7: // The data has been exported from the gallery Desert, area index 9, ID 113, created by xoft { @@ -1253,7 +1253,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House9x9: // The data has been exported from the gallery Desert, area index 10, ID 114, created by xoft { @@ -1404,7 +1404,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseL14x12: // The data has been exported from the gallery Desert, area index 14, ID 124, created by Aloe_vera { @@ -1592,7 +1592,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseL14x12: // The data has been exported from the gallery Desert, area index 7, ID 82, created by Aloe_vera { @@ -1763,7 +1763,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SingleField: // The data has been exported from the gallery Desert, area index 17, ID 127, created by Aloe_vera { @@ -1844,7 +1844,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SmallHut: // The data has been exported from the gallery Desert, area index 4, ID 68, created by tonibm1999 { @@ -1955,7 +1955,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = const cPrefab::sDef g_SandVillageStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // RoofedWell: // The data has been exported from the gallery Desert, area index 43, ID 274, created by Aloe_vera { @@ -2155,7 +2155,7 @@ const cPrefab::sDef g_SandVillageStartingPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Well: // The data has been exported from the gallery Desert, area index 0, ID 1, created by Aloe_vera { diff --git a/src/Generating/Prefabs/TestRailsPrefabs.cpp b/src/Generating/Prefabs/TestRailsPrefabs.cpp index 3444cb1fa..f58b95225 100644 --- a/src/Generating/Prefabs/TestRailsPrefabs.cpp +++ b/src/Generating/Prefabs/TestRailsPrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_TestRailsPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ActivatorRail: // The data has been exported from the gallery Plains, area index 251, ID 746, created by Aloe_vera { @@ -104,7 +104,7 @@ const cPrefab::sDef g_TestRailsPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // DetectorRail: // The data has been exported from the gallery Plains, area index 250, ID 745, created by Aloe_vera { @@ -193,7 +193,7 @@ const cPrefab::sDef g_TestRailsPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // PowerRail: // The data has been exported from the gallery Plains, area index 248, ID 743, created by Aloe_vera { @@ -284,7 +284,7 @@ const cPrefab::sDef g_TestRailsPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // RegularRail: // The data has been exported from the gallery Plains, area index 247, ID 742, created by Aloe_vera { @@ -383,7 +383,7 @@ const cPrefab::sDef g_TestRailsPrefabs[] = const cPrefab::sDef g_TestRailsStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CentralPiece: // The data has been exported from the gallery Plains, area index 249, ID 744, created by Aloe_vera { diff --git a/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp index 691d8aa9d..1655f50b9 100644 --- a/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp +++ b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BrokenRoom: // The data has been exported from the gallery Water, area index 49, ID 680, created by STR_Warrior { @@ -178,7 +178,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Corridor16: // The data has been exported from the gallery Water, area index 25, ID 566, created by xoft { @@ -265,7 +265,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorCorner: // The data has been exported from the gallery Water, area index 26, ID 569, created by xoft { @@ -380,7 +380,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorCrossing: // The data has been exported from the gallery Water, area index 31, ID 581, created by LO1ZB { @@ -526,7 +526,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorStairs: // The data has been exported from the gallery Water, area index 32, ID 582, created by LO1ZB { @@ -656,7 +656,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorTee: // The data has been exported from the gallery Water, area index 29, ID 576, created by LO1ZB { @@ -775,7 +775,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ViewingCorner: // The data has been exported from the gallery Water, area index 40, ID 613, created by LO1ZB { @@ -958,7 +958,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ViewingCorridor: // The data has been exported from the gallery Water, area index 27, ID 571, created by LO1ZB { @@ -1065,7 +1065,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ViewingCorridorBulge: // The data has been exported from the gallery Water, area index 42, ID 615, created by LO1ZB { @@ -1280,7 +1280,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ViewingCrossing: // The data has been exported from the gallery Water, area index 38, ID 611, created by LO1ZB { @@ -1483,7 +1483,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ViewingEnd: // The data has been exported from the gallery Water, area index 41, ID 614, created by LO1ZB { @@ -1648,7 +1648,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ViewingTee: // The data has been exported from the gallery Water, area index 39, ID 612, created by LO1ZB { @@ -1850,7 +1850,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WaterfallRoom: // The data has been exported from the gallery Water, area index 50, ID 681, created by Aloe_vera { @@ -2059,7 +2059,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = const cPrefab::sDef g_UnderwaterBaseStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CentralRoom: // The data has been exported from the gallery Water, area index 24, ID 564, created by xoft { diff --git a/src/Generating/RainbowRoadsGen.cpp b/src/Generating/RainbowRoadsGen.cpp index 3b0ff7df8..c3c07cdec 100644 --- a/src/Generating/RainbowRoadsGen.cpp +++ b/src/Generating/RainbowRoadsGen.cpp @@ -18,7 +18,7 @@ static cPrefabPiecePool g_RainbowRoads(g_RainbowRoadPrefabs, g_RainbowRoadPrefab -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRainbowRoadsGen::cRainbowRoads: class cRainbowRoadsGen::cRainbowRoads : @@ -86,7 +86,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRainbowRoadsGen: diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index 24f2cc3ab..8f62669e7 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -77,7 +77,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenRavines: cStructGenRavines::cStructGenRavines(int a_Seed, int a_Size) : @@ -101,7 +101,7 @@ cGridStructGen::cStructurePtr cStructGenRavines::CreateStructure(int a_GridX, in -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenRavines::cRavine cStructGenRavines::cRavine::cRavine(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_Size, cNoise & a_Noise) : diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp index 636364e17..2e41243d6 100644 --- a/src/Generating/StructGen.cpp +++ b/src/Generating/StructGen.cpp @@ -12,7 +12,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenOreNests configuration: const int MAX_HEIGHT_COAL = 127; @@ -51,7 +51,7 @@ const int NEST_SIZE_GRAVEL = 32; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenTrees: void cStructGenTrees::GenFinish(cChunkDesc & a_ChunkDesc) @@ -303,7 +303,7 @@ int cStructGenTrees::GetNumTrees( -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenOreNests: void cStructGenOreNests::GenFinish(cChunkDesc & a_ChunkDesc) @@ -410,7 +410,7 @@ void cStructGenOreNests::GenerateOre(int a_ChunkX, int a_ChunkZ, BLOCKTYPE a_Ore -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenLakes: void cStructGenLakes::GenFinish(cChunkDesc & a_ChunkDesc) @@ -532,7 +532,7 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenDirectOverhangs: cStructGenDirectOverhangs::cStructGenDirectOverhangs(int a_Seed) : @@ -648,7 +648,7 @@ bool cStructGenDirectOverhangs::HasWantedBiome(cChunkDesc & a_ChunkDesc) const -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenDistortedMembraneOverhangs: cStructGenDistortedMembraneOverhangs::cStructGenDistortedMembraneOverhangs(int a_Seed) : diff --git a/src/Generating/TestRailsGen.cpp b/src/Generating/TestRailsGen.cpp index c40c1a9b6..66ab8b33f 100644 --- a/src/Generating/TestRailsGen.cpp +++ b/src/Generating/TestRailsGen.cpp @@ -18,7 +18,7 @@ static cPrefabPiecePool g_TestRails(g_TestRailsPrefabs, g_TestRailsPrefabsCount, -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cTestRailsGen::cTestRails: class cTestRailsGen::cTestRails : @@ -86,7 +86,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cTestRailsGen: diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index 522f45148..7478be69b 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -66,7 +66,7 @@ static const sCoords BigO3[] = {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3}, } ; -static const sCoords BigO4[] = // Part of Big Jungle tree +static const sCoords BigO4[] = // Part of Big Jungle tree { {-2, -4}, {-1, -4}, {0, -4}, {1, -4}, {2, -4}, {-3, -3}, {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3}, {3, -3}, @@ -773,10 +773,10 @@ void GetSmallJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_LogBlocks.reserve(Height); a_OtherBlocks.reserve( - 2 * ARRAYCOUNT(BigO3) + // O3 layer, 2x - 2 * ARRAYCOUNT(BigO2) + // O2 layer, 2x - ARRAYCOUNT(BigO1) + 1 + // Plus on the top - Height * ARRAYCOUNT(Vines) + // Vines + 2 * ARRAYCOUNT(BigO3) + // O3 layer, 2x + 2 * ARRAYCOUNT(BigO2) + // O2 layer, 2x + ARRAYCOUNT(BigO1) + 1 + // Plus on the top + Height * ARRAYCOUNT(Vines) + // Vines 50 // some safety ); diff --git a/src/Generating/UnderwaterBaseGen.cpp b/src/Generating/UnderwaterBaseGen.cpp index d3abae9b7..9278ea546 100644 --- a/src/Generating/UnderwaterBaseGen.cpp +++ b/src/Generating/UnderwaterBaseGen.cpp @@ -18,7 +18,7 @@ static cPrefabPiecePool g_UnderwaterBase(g_UnderwaterBasePrefabs, g_UnderwaterBa -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cUnderwaterBaseGen::cUnderwaterBase: class cUnderwaterBaseGen::cUnderwaterBase : @@ -86,7 +86,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cUnderwaterBaseGen: diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index 2b7ecc837..fdec2425d 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -333,7 +333,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cVillageGen: static cVillagePiecePool g_SandVillage(g_SandVillagePrefabs, g_SandVillagePrefabsCount, g_SandVillageStartingPrefabs, g_SandVillageStartingPrefabsCount); diff --git a/src/HTTPServer/HTTPMessage.cpp b/src/HTTPServer/HTTPMessage.cpp index 44feda469..f7e8f5f30 100644 --- a/src/HTTPServer/HTTPMessage.cpp +++ b/src/HTTPServer/HTTPMessage.cpp @@ -20,7 +20,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHTTPMessage: cHTTPMessage::cHTTPMessage(eKind a_Kind) : @@ -64,7 +64,7 @@ void cHTTPMessage::AddHeader(const AString & a_Key, const AString & a_Value) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHTTPRequest: cHTTPRequest::cHTTPRequest(void) : @@ -248,7 +248,7 @@ void cHTTPRequest::OnHeaderLine(const AString & a_Key, const AString & a_Value) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHTTPResponse: cHTTPResponse::cHTTPResponse(void) : diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp index 036b2e042..b7edf7829 100644 --- a/src/HTTPServer/HTTPServer.cpp +++ b/src/HTTPServer/HTTPServer.cpp @@ -118,7 +118,7 @@ class cDebugCallbacks : -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHTTPServer: cHTTPServer::cHTTPServer(void) : diff --git a/src/HTTPServer/MultipartParser.cpp b/src/HTTPServer/MultipartParser.cpp index 309495dd7..09732c5f7 100644 --- a/src/HTTPServer/MultipartParser.cpp +++ b/src/HTTPServer/MultipartParser.cpp @@ -21,7 +21,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // self-test: #if 0 @@ -87,7 +87,7 @@ ThisIsIgnoredEpilogue"; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMultipartParser: diff --git a/src/HTTPServer/NameValueParser.cpp b/src/HTTPServer/NameValueParser.cpp index f16ea1915..b345fef88 100644 --- a/src/HTTPServer/NameValueParser.cpp +++ b/src/HTTPServer/NameValueParser.cpp @@ -69,7 +69,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNameValueParser: cNameValueParser::cNameValueParser(bool a_AllowsKeyOnly) : diff --git a/src/Item.cpp b/src/Item.cpp index b3ce32336..876abafd0 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -375,7 +375,7 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cItems: cItem * cItems::Get(int a_Idx) diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index a733bda19..4cdfab0fe 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -49,7 +49,7 @@ public: Vector3i BlockPos; if (!GetBlockFromTrace(a_World, a_Player, BlockPos)) { - return false; // Nothing in range. + return false; // Nothing in range. } if (a_World->GetBlockMeta(BlockPos.x, BlockPos.y, BlockPos.z) != 0) @@ -160,7 +160,7 @@ public: { if (IsBlockWater(a_BlockType) || IsBlockLava(a_BlockType)) { - if (a_BlockMeta != 0) // GetBlockFromTrace is called for scooping up fluids; the hit block should be a source + if (a_BlockMeta != 0) // GetBlockFromTrace is called for scooping up fluids; the hit block should be a source { return false; } diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index 3b1ad1717..435d8ccf4 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -17,13 +17,15 @@ -///////////////////////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////////////////// // cFloaterCallback class cFloaterCallback : public cEntityCallback { public: - cFloaterCallback(void) : + cFloaterCallback(void) : m_CanPickup(false), m_AttachedMobID(-1) { @@ -49,8 +51,13 @@ protected: Vector3d m_Pos; } ; -//////////////////////////////////////////////////////////////////////////// -// cSweepEntityCallback + + + + +//////////////////////////////////////////////////////////////////////////////// +// cSweepEntityCallback: + class cSweepEntityCallback : public cEntityCallback { @@ -73,6 +80,8 @@ protected: + + class cItemFishingRodHandler : public cItemHandler { @@ -106,19 +115,19 @@ public: { cItems Drops; int ItemCategory = a_World->GetTickRandomNumber(99); - if (ItemCategory <= 4) // Treasures 5% + if (ItemCategory <= 4) // Treasures 5% { int Treasure = a_World->GetTickRandomNumber(5); switch (Treasure) { case 0: { - Drops.Add(cItem(E_ITEM_BOW)); // TODO: Enchantments + Drops.Add(cItem(E_ITEM_BOW)); // TODO: Enchantments break; } case 1: { - Drops.Add(cItem(E_ITEM_BOOK)); // TODO: Enchanted book + Drops.Add(cItem(E_ITEM_BOOK)); // TODO: Enchanted book break; } case 2: @@ -237,3 +246,7 @@ public: return true; } } ; + + + + diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 85406c826..c261ce0e8 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -362,7 +362,7 @@ char cItemHandler::GetMaxStackSize(void) return 64; } - switch (m_ItemType) //sorted by id + switch (m_ItemType) { case E_ITEM_ARROW: return 64; case E_ITEM_BAKED_POTATO: return 64; @@ -568,7 +568,7 @@ bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item) cFastRandom r1; if ((r1.NextInt(100, a_Player->GetUniqueID()) - Info.PoisonChance) <= 0) { - a_Player->FoodPoison(600); // Give the player food poisoning for 30 seconds. + a_Player->FoodPoison(600); // Give the player food poisoning for 30 seconds. } } diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index cffca11ab..b33671c2d 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -60,7 +60,7 @@ public: { double Saturation; int FoodLevel; - int PoisonChance; // 0 - 100, in percent. 0 = no chance of poisoning, 100 = sure poisoning + int PoisonChance; // 0 - 100, in percent. 0 = no chance of poisoning, 100 = sure poisoning FoodInfo(int a_FoodLevel, double a_Saturation, int a_PoisonChance = 0) : Saturation(a_Saturation), @@ -112,11 +112,11 @@ public: protected: int m_ItemType; - static cItemHandler *CreateItemHandler(int m_ItemType); + static cItemHandler * CreateItemHandler(int m_ItemType); static cItemHandler * m_ItemHandler[E_ITEM_LAST + 1]; - static bool m_HandlerInitialized; //used to detect if the itemhandlers are initialized + static bool m_HandlerInitialized; // used to detect if the itemhandlers are initialized }; -//Short function +// Short function inline cItemHandler *ItemHandler(int a_ItemType) { return cItemHandler::GetItemHandler(a_ItemType); } diff --git a/src/Items/ItemItemFrame.h b/src/Items/ItemItemFrame.h index b258b4aea..87e20ecf0 100644 --- a/src/Items/ItemItemFrame.h +++ b/src/Items/ItemItemFrame.h @@ -27,9 +27,9 @@ public: return false; } - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir); // Make sure block that will be occupied is free + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir); // Make sure block that will be occupied is free BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir, true); // We want the clicked block, so go back again + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir, true); // We want the clicked block, so go back again if (Block == E_BLOCK_AIR) { diff --git a/src/Items/ItemLeaves.h b/src/Items/ItemLeaves.h index 12cb45d1c..0ed6e5e0e 100644 --- a/src/Items/ItemLeaves.h +++ b/src/Items/ItemLeaves.h @@ -31,7 +31,7 @@ public: a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta ); - a_BlockMeta = a_BlockMeta | 0x4; //0x4 bit set means this is a player-placed leaves block, not to be decayed + a_BlockMeta = a_BlockMeta | 0x4; // 0x4 bit set means this is a player-placed leaves block, not to be decayed return res; } } ; diff --git a/src/Items/ItemLilypad.h b/src/Items/ItemLilypad.h index bc650cdbd..b9d837384 100644 --- a/src/Items/ItemLilypad.h +++ b/src/Items/ItemLilypad.h @@ -25,7 +25,7 @@ public: virtual bool IsPlaceable(void) override { - return false; // Set as not placeable so OnItemUse is called + return false; // Set as not placeable so OnItemUse is called } @@ -57,7 +57,7 @@ public: { if (IsBlockWater(a_CBBlockType)) { - if ((a_CBBlockMeta != 0) || (a_CBEntryFace == BLOCK_FACE_NONE)) // The hit block should be a source. The FACE_NONE check is clicking whilst submerged + if ((a_CBBlockMeta != 0) || (a_CBEntryFace == BLOCK_FACE_NONE)) // The hit block should be a source. The FACE_NONE check is clicking whilst submerged { return false; } diff --git a/src/Items/ItemPainting.h b/src/Items/ItemPainting.h index e4bb76ebe..a2a77ce21 100644 --- a/src/Items/ItemPainting.h +++ b/src/Items/ItemPainting.h @@ -27,9 +27,9 @@ public: return false; } - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir); // Make sure block that will be occupied is free + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir); // Make sure block that will be occupied is free BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir, true); // We want the clicked block, so go back again + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir, true); // We want the clicked block, so go back again if (Block == E_BLOCK_AIR) { @@ -38,14 +38,14 @@ public: // The client uses different values for painting directions and block faces. Our constants are for the block faces, so we convert them here to painting faces switch (a_Dir) { - case BLOCK_FACE_ZP: break; // Initialised to zero + case BLOCK_FACE_ZP: break; // Initialised to zero case BLOCK_FACE_ZM: Dir = 2; break; case BLOCK_FACE_XM: Dir = 1; break; case BLOCK_FACE_XP: Dir = 3; break; default: ASSERT(!"Unhandled block face when trying spawn painting!"); return false; } - static const struct // Define all the possible painting titles + static const struct // Define all the possible painting titles { AString Title; } gPaintingTitlesList[] = diff --git a/src/Items/ItemRedstoneDust.h b/src/Items/ItemRedstoneDust.h index 274d905a5..33e386b03 100644 --- a/src/Items/ItemRedstoneDust.h +++ b/src/Items/ItemRedstoneDust.h @@ -27,7 +27,7 @@ public: BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override { - if (!cBlockInfo::FullyOccupiesVoxel(a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))) // Some solid blocks, such as cocoa beans, are not suitable for dust + if (!cBlockInfo::FullyOccupiesVoxel(a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))) // Some solid blocks, such as cocoa beans, are not suitable for dust { return false; } diff --git a/src/Items/ItemSeeds.h b/src/Items/ItemSeeds.h index 7283edcee..53f5d51c3 100644 --- a/src/Items/ItemSeeds.h +++ b/src/Items/ItemSeeds.h @@ -25,7 +25,7 @@ public: virtual bool IsFood(void) override { - switch (m_ItemType) // Special cases, both a seed and food + switch (m_ItemType) // Special cases, both a seed and food { case E_ITEM_CARROT: case E_ITEM_POTATO: return true; diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index 403a3e097..3fbbee6b5 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -84,7 +84,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cLightingThread: cLightingThread::cLightingThread(void) : @@ -582,7 +582,7 @@ void cLightingThread::QueueChunkStay(cLightingChunkStay & a_ChunkStay) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cLightingThread::cLightingChunkStay: cLightingThread::cLightingChunkStay::cLightingChunkStay(cLightingThread & a_LightingThread, int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_CallbackAfter) : diff --git a/src/MCLogger.cpp b/src/MCLogger.cpp index ad2029589..78eb19f3e 100644 --- a/src/MCLogger.cpp +++ b/src/MCLogger.cpp @@ -227,7 +227,7 @@ void cMCLogger::ResetColor(void) -////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Global functions void LOG(const char* a_Format, ...) diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp index 8ab09a4c5..495f1dd25 100644 --- a/src/Mobs/Creeper.cpp +++ b/src/Mobs/Creeper.cpp @@ -43,7 +43,7 @@ void cCreeper::Tick(float a_Dt, cChunk & a_Chunk) if (m_ExplodingTimer == 30) { m_World->DoExplosionAt((m_bIsCharged ? 5 : 3), GetPosX(), GetPosY(), GetPosZ(), false, esMonster, this); - Destroy(); // Just in case we aren't killed by the explosion + Destroy(); // Just in case we aren't killed by the explosion } } } diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index e36634c73..9e53284b3 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -62,7 +62,7 @@ static const struct -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMonster: cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) @@ -120,7 +120,7 @@ void cMonster::TickPathFinding() std::vector m_PotentialCoordinates; m_TraversedCoordinates.push_back(Vector3i(PosX, PosY, PosZ)); - static const struct // Define which directions to try to move to + static const struct // Define which directions to try to move to { int x, z; } gCrossCoords[] = @@ -301,12 +301,12 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) if (DoesPosYRequireJump((int)floor(m_Destination.y))) { m_bOnGround = false; - AddSpeedY(5.2); // Jump!! + AddSpeedY(5.2); // Jump!! } } Vector3f Distance = m_Destination - GetPosition(); - if(!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move + if(!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move { Distance.y = 0; Distance.Normalize(); @@ -325,20 +325,20 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) AddSpeedZ(Distance.z); if (m_EMState == ESCAPING) - { //Runs Faster when escaping :D otherwise they just walk away + { // Runs Faster when escaping :D otherwise they just walk away SetSpeedX (GetSpeedX() * 2.f); SetSpeedZ (GetSpeedZ() * 2.f); } } else { - if (ReachedFinalDestination()) // If we have reached the ultimate, final destination, stop pathfinding and attack if appropriate + if (ReachedFinalDestination()) // If we have reached the ultimate, final destination, stop pathfinding and attack if appropriate { FinishPathFinding(); } else { - TickPathFinding(); // We have reached the next point in our path, calculate another point + TickPathFinding(); // We have reached the next point in our path, calculate another point } } } @@ -570,8 +570,8 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI) -//Checks to see if EventSeePlayer should be fired -//monster sez: Do I see the player +// Checks to see if EventSeePlayer should be fired +// monster sez: Do I see the player void cMonster::CheckEventSeePlayer(void) { // TODO: Rewrite this to use cWorld's DoWithPlayers() @@ -631,7 +631,7 @@ void cMonster::InStateIdle(float a_Dt) { if (m_bMovingToDestination) { - return; // Still getting there + return; // Still getting there } m_IdleInterval += a_Dt; @@ -640,7 +640,7 @@ void cMonster::InStateIdle(float a_Dt) { // At this interval the results are predictable int rem = m_World->GetTickRandomNumber(6) + 1; - m_IdleInterval -= 1; // So nothing gets dropped when the server hangs for a few seconds + m_IdleInterval -= 1; // So nothing gets dropped when the server hangs for a few seconds Vector3d Dist; Dist.x = (double)m_World->GetTickRandomNumber(10) - 5; @@ -928,7 +928,7 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) case mtWitch: toReturn = new cWitch(); break; case mtWither: toReturn = new cWither(); break; case mtWolf: toReturn = new cWolf(); break; - case mtZombie: toReturn = new cZombie(false); break; // TODO: Infected zombie parameter + case mtZombie: toReturn = new cZombie(false); break; // TODO: Infected zombie parameter case mtZombiePigman: toReturn = new cZombiePigman(); break; default: { diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 59bcdaa37..96e73b45b 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -61,13 +61,13 @@ public: enum eFamily { - mfHostile = 0, // Spider, Zombies ... - mfPassive = 1, // Cows, Pigs - mfAmbient = 2, // Bats - mfWater = 3, // Squid + mfHostile = 0, // Spider, Zombies ... + mfPassive = 1, // Cows, Pigs + mfAmbient = 2, // Bats + mfWater = 3, // Squid mfNoSpawn, - mfUnhandled, // Nothing. Be sure this is the last and the others are in order + mfUnhandled, // Nothing. Be sure this is the last and the others are in order } ; // tolua_end @@ -93,7 +93,7 @@ public: virtual void KilledBy(TakeDamageInfo & a_TDI) override; virtual void MoveToPosition(const Vector3f & a_Position); - virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export + virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export virtual bool ReachedDestination(void); // tolua_begin @@ -265,7 +265,7 @@ protected: void AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel); -} ; // tolua_export +} ; // tolua_export diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index 019f9e6a2..7335848b7 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -93,12 +93,12 @@ void cSheep::Tick(float a_Dt, cChunk & a_Chunk) if (m_TimeToStopEating > 0) { - m_bMovingToDestination = false; // The sheep should not move when he's eating + m_bMovingToDestination = false; // The sheep should not move when he's eating m_TimeToStopEating--; if (m_TimeToStopEating == 0) { - if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS) // Make sure grass hasn't been destroyed in the meantime + if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS) // Make sure grass hasn't been destroyed in the meantime { // The sheep ate the grass so we change it to dirt m_World->SetBlock(PosX, PosY, PosZ, E_BLOCK_DIRT, 0); diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index 41283acf4..d183a338f 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -138,8 +138,8 @@ void cVillager::HandleFarmerPrepareFarmCrops() m_CropsPos = Vector3i((int) GetPosX() + X - 5, (int) GetPosY() + Y - 3, (int) GetPosZ() + Z - 5); MoveToPosition(Vector3f((float) (m_CropsPos.x + 0.5), (float) m_CropsPos.y, (float) (m_CropsPos.z + 0.5))); return; - } // for Y loop. - } // Repeat the procces 5 times. + } // for Y loop. + } // Repeat the procces 5 times. } diff --git a/src/Mobs/Villager.h b/src/Mobs/Villager.h index abde48407..068dfd835 100644 --- a/src/Mobs/Villager.h +++ b/src/Mobs/Villager.h @@ -37,9 +37,8 @@ public: /** return true if the given blocktype are: crops, potatoes or carrots.*/ bool IsBlockFarmable(BLOCKTYPE a_BlockType); - ////////////////////////////////////////////////////////////////// // Farmer functions - /** It searches in a 11x7x11 area for crops. If it found some it will navigate to them.*/ + /** Searches in a 11x7x11 area for crops. If it found some it will navigate to them.*/ void HandleFarmerPrepareFarmCrops(); /** Looks if the farmer has reached it's destination, and if it's still crops and the destination is closer then 2 blocks it will harvest them.*/ @@ -49,7 +48,7 @@ public: void HandleFarmerPlaceCrops(); // Get and set functions. - int GetVilType(void) const { return m_Type; } + int GetVilType(void) const { return m_Type; } Vector3i GetCropsPos(void) const { return m_CropsPos; } bool DoesHaveActionActivated(void) const { return m_VillagerAction; } diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index e6268abc7..5bb97d30e 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -36,7 +36,7 @@ bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI) { m_IsAngry = true; } - m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face + m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face return true; } @@ -114,7 +114,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player) } case E_ITEM_DYE: { - if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog? + if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog? { SetCollarColor(15 - a_Player.GetEquippedItem().m_ItemDamage); if (!a_Player.IsGameModeCreative()) @@ -126,7 +126,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player) } default: { - if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog? + if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog? { SetIsSitting(!IsSitting()); } @@ -172,7 +172,7 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) m_World->BroadcastEntityMetadata(*this); } - m_FinalDestination = a_Closest_Player->GetPosition(); // So that we will look at a player holding food + m_FinalDestination = a_Closest_Player->GetPosition(); // So that we will look at a player holding food // Don't move to the player if the wolf is sitting. if (!IsSitting()) diff --git a/src/Noise.cpp b/src/Noise.cpp index e7b055ead..145bcc5dd 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -9,7 +9,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Globals: void Debug3DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, int a_SizeZ, const AString & a_FileNameBase) @@ -90,7 +90,7 @@ void Debug2DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, cons -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCubicCell2D: class cCubicCell2D @@ -239,7 +239,7 @@ void cCubicCell2D::Move(int a_NewFloorX, int a_NewFloorY) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCubicCell3D: class cCubicCell3D @@ -422,7 +422,7 @@ void cCubicCell3D::Move(int a_NewFloorX, int a_NewFloorY, int a_NewFloorZ) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNoise: cNoise::cNoise(int a_Seed) : @@ -582,7 +582,7 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCubicNoise: #ifdef _DEBUG @@ -782,7 +782,7 @@ void cCubicNoise::CalcFloorFrac( -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPerlinNoise: cPerlinNoise::cPerlinNoise(void) : @@ -952,7 +952,7 @@ void cPerlinNoise::Generate3D( -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRidgedMultiNoise: cRidgedMultiNoise::cRidgedMultiNoise(void) : diff --git a/src/Noise.h b/src/Noise.h index 014e43239..48a1c73f7 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -256,7 +256,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Inline function definitions: // These need to be in the header, otherwise linker error occur in MSVC @@ -361,7 +361,7 @@ NOISE_DATATYPE cNoise::LinearInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B, -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Global functions: extern void Debug2DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, const AString & a_FileNameBase); diff --git a/src/OSSupport/CriticalSection.cpp b/src/OSSupport/CriticalSection.cpp index bda97e3a1..6d4afce55 100644 --- a/src/OSSupport/CriticalSection.cpp +++ b/src/OSSupport/CriticalSection.cpp @@ -6,7 +6,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCriticalSection: cCriticalSection::cCriticalSection() @@ -105,7 +105,7 @@ bool cCriticalSection::IsLockedByCurrentThread(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCSLock cCSLock::cCSLock(cCriticalSection * a_CS) @@ -165,7 +165,7 @@ void cCSLock::Unlock(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCSUnlock: cCSUnlock::cCSUnlock(cCSLock & a_Lock) : diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp index addf8f928..ff6fb5898 100644 --- a/src/OSSupport/File.cpp +++ b/src/OSSupport/File.cpp @@ -81,7 +81,7 @@ bool cFile::Open(const AString & iFileName, eMode iMode) m_File = _fsopen((FILE_IO_PREFIX + iFileName).c_str(), Mode, _SH_DENYWR); #else m_File = fopen((FILE_IO_PREFIX + iFileName).c_str(), Mode); -#endif // _WIN32 +#endif // _WIN32 if ((m_File == NULL) && (iMode == fmReadWrite)) { @@ -94,7 +94,7 @@ bool cFile::Open(const AString & iFileName, eMode iMode) m_File = _fsopen((FILE_IO_PREFIX + iFileName).c_str(), "wb+", _SH_DENYWR); #else m_File = fopen((FILE_IO_PREFIX + iFileName).c_str(), "wb+"); -#endif // _WIN32 +#endif // _WIN32 } return (m_File != NULL); diff --git a/src/OSSupport/Semaphore.cpp b/src/OSSupport/Semaphore.cpp index 468de6858..60e5564e4 100644 --- a/src/OSSupport/Semaphore.cpp +++ b/src/OSSupport/Semaphore.cpp @@ -36,10 +36,10 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* } #else m_Handle = CreateSemaphore( - NULL, // security attribute - a_InitialCount, // initial count - a_MaxCount, // maximum count - 0 // name (optional) + NULL, // security attribute + a_InitialCount, // initial count + a_MaxCount, // maximum count + 0 // name (optional) ); #endif } diff --git a/src/OSSupport/Semaphore.h b/src/OSSupport/Semaphore.h index fbe8907f1..ac574e8a1 100644 --- a/src/OSSupport/Semaphore.h +++ b/src/OSSupport/Semaphore.h @@ -9,7 +9,7 @@ public: void Wait(); void Signal(); private: - void* m_Handle; // HANDLE pointer + void* m_Handle; // HANDLE pointer #ifndef _WIN32 bool m_bNamed; diff --git a/src/OSSupport/Sleep.cpp b/src/OSSupport/Sleep.cpp index 70fb06b40..b18d918fa 100644 --- a/src/OSSupport/Sleep.cpp +++ b/src/OSSupport/Sleep.cpp @@ -12,7 +12,7 @@ void cSleep::MilliSleep( unsigned int a_MilliSeconds ) { #ifdef _WIN32 - Sleep(a_MilliSeconds); // Don't tick too much + Sleep(a_MilliSeconds); // Don't tick too much #else usleep(a_MilliSeconds*1000); #endif diff --git a/src/OSSupport/SocketThreads.cpp b/src/OSSupport/SocketThreads.cpp index ca8b8438d..f436318a5 100644 --- a/src/OSSupport/SocketThreads.cpp +++ b/src/OSSupport/SocketThreads.cpp @@ -13,7 +13,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSocketThreads: cSocketThreads::cSocketThreads(void) diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp index 535784613..674e37757 100644 --- a/src/OSSupport/Thread.cpp +++ b/src/OSSupport/Thread.cpp @@ -91,12 +91,12 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ ) LOGERROR("ERROR: Could not create thread!"); #else DWORD ThreadID = 0; - HANDLE hThread = CreateThread( 0 // security - ,0 // stack size - , (LPTHREAD_START_ROUTINE) MyThread // function name - ,this // parameters - ,0 // flags - ,&ThreadID ); // thread id + HANDLE hThread = CreateThread( 0 // security + ,0 // stack size + , (LPTHREAD_START_ROUTINE) MyThread // function name + ,this // parameters + ,0 // flags + ,&ThreadID ); // thread id CloseHandle( hThread ); #ifdef _MSC_VER diff --git a/src/PolarSSL++/Sha1Checksum.cpp b/src/PolarSSL++/Sha1Checksum.cpp index a1ee9d7b9..e69ef236f 100644 --- a/src/PolarSSL++/Sha1Checksum.cpp +++ b/src/PolarSSL++/Sha1Checksum.cpp @@ -50,7 +50,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSha1Checksum: cSha1Checksum::cSha1Checksum(void) : diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index dc35a6653..00eeadd10 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -132,7 +132,7 @@ public: protected: cClientHandle * m_Client; - cCriticalSection m_CSPacket; //< Each SendXYZ() function must acquire this CS in order to send the whole packet at once + cCriticalSection m_CSPacket; // Each SendXYZ() function must acquire this CS in order to send the whole packet at once /// A generic data-sending routine, all outgoing packet data needs to be routed through this so that descendants may override it virtual void SendData(const char * a_Data, size_t a_Size) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 28fdcf23a..325218d88 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -473,7 +473,7 @@ void cProtocol125::SendEntityVelocity(const cEntity & a_Entity) cCSLock Lock(m_CSPacket); WriteByte(PACKET_ENTITY_VELOCITY); WriteInt (a_Entity.GetUniqueID()); - WriteShort((short) (a_Entity.GetSpeedX() * 400)); //400 = 8000 / 20 + WriteShort((short) (a_Entity.GetSpeedX() * 400)); // 400 = 8000 / 20 WriteShort((short) (a_Entity.GetSpeedY() * 400)); WriteShort((short) (a_Entity.GetSpeedZ() * 400)); Flush(); @@ -1426,11 +1426,11 @@ int cProtocol125::ParseEntityAction(void) switch (ActionID) { - case 1: m_Client->HandleEntityCrouch(EntityID, true); break; // Crouch - case 2: m_Client->HandleEntityCrouch(EntityID, false); break; // Uncrouch - case 3: m_Client->HandleEntityLeaveBed(EntityID); break; // Leave Bed - case 4: m_Client->HandleEntitySprinting(EntityID, true); break; // Start sprinting - case 5: m_Client->HandleEntitySprinting(EntityID, false); break; // Stop sprinting + case 1: m_Client->HandleEntityCrouch(EntityID, true); break; // Crouch + case 2: m_Client->HandleEntityCrouch(EntityID, false); break; // Uncrouch + case 3: m_Client->HandleEntityLeaveBed(EntityID); break; // Leave Bed + case 4: m_Client->HandleEntitySprinting(EntityID, true); break; // Start sprinting + case 5: m_Client->HandleEntitySprinting(EntityID, false); break; // Stop sprinting } return PARSE_OK; @@ -1444,7 +1444,7 @@ int cProtocol125::ParseHandshake(void) { HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Username); - AStringVector UserData = StringSplit(Username, ";"); // "FakeTruth;localhost:25565" + AStringVector UserData = StringSplit(Username, ";"); // "FakeTruth;localhost:25565" if (UserData.empty()) { m_Client->Kick("Did not receive username"); @@ -1456,7 +1456,7 @@ int cProtocol125::ParseHandshake(void) if (!m_Client->HandleHandshake( m_Username )) { - return PARSE_OK; // Player is not allowed into the server + return PARSE_OK; // Player is not allowed into the server } SendHandshake(cRoot::Get()->GetServer()->GetServerID()); @@ -1918,20 +1918,20 @@ void cProtocol125::WriteEntityMetadata(const cEntity & a_Entity) // No idea how Mojang makes their carts shakey shakey, so here is a complicated one-liner expression that does something similar WriteInt( (((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4 ); WriteByte(0x52); - WriteInt(1); // Shaking direction, doesn't seem to affect anything + WriteInt(1); // Shaking direction, doesn't seem to affect anything WriteByte(0x73); - WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer + WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer if (((cMinecart &)a_Entity).GetPayload() == cMinecart::mpFurnace) { WriteByte(0x10); - WriteByte(((const cMinecartWithFurnace &)a_Entity).IsFueled() ? 1 : 0); // Fueled? + WriteByte(((const cMinecartWithFurnace &)a_Entity).IsFueled() ? 1 : 0); // Fueled? } } else if ((a_Entity.IsProjectile() && ((cProjectileEntity &)a_Entity).GetProjectileKind() == cProjectileEntity::pkArrow)) { WriteByte(0x10); - WriteByte(((const cArrowEntity &)a_Entity).IsCritical() ? 1 : 0); // Critical hitting arrow? + WriteByte(((const cArrowEntity &)a_Entity).IsCritical() ? 1 : 0); // Critical hitting arrow? } } @@ -1946,43 +1946,43 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) case cMonster::mtCreeper: { WriteByte(0x10); - WriteChar(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1); // Blowing up? + WriteChar(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1); // Blowing up? WriteByte(0x11); - WriteByte(((const cCreeper &)a_Mob).IsCharged() ? 1 : 0); // Lightning-charged? + WriteByte(((const cCreeper &)a_Mob).IsCharged() ? 1 : 0); // Lightning-charged? break; } case cMonster::mtBat: { WriteByte(0x10); - WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0); // Upside down? + WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0); // Upside down? break; } case cMonster::mtPig: { WriteByte(0x10); - WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0); // Saddled? + WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0); // Saddled? break; } case cMonster::mtVillager: { WriteByte(0x50); - WriteInt(((const cVillager &)a_Mob).GetVilType()); // What sort of TESTIFICATE? + WriteInt(((const cVillager &)a_Mob).GetVilType()); // What sort of TESTIFICATE? break; } case cMonster::mtZombie: { WriteByte(0xC); - WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0); // Babby zombie? + WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0); // Baby zombie? WriteByte(0xD); - WriteByte(((const cZombie &)a_Mob).IsVillagerZombie() ? 1 : 0); // Converted zombie? + WriteByte(((const cZombie &)a_Mob).IsVillagerZombie() ? 1 : 0); // Converted zombie? WriteByte(0xE); - WriteByte(((const cZombie &)a_Mob).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager? + WriteByte(((const cZombie &)a_Mob).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager? break; } case cMonster::mtGhast: { WriteByte(0x10); - WriteByte(((const cGhast &)a_Mob).IsCharging()); // About to eject un flamé-bol? :P + WriteByte(((const cGhast &)a_Mob).IsCharging()); // About to spit a flameball? break; } case cMonster::mtWolf: @@ -2004,9 +2004,9 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) WriteByte(WolfStatus); WriteByte(0x72); - WriteFloat((float)(a_Mob.GetHealth())); // Tail health-o-meter (only shown when tamed, by the way) + WriteFloat((float)(a_Mob.GetHealth())); // Tail health-o-meter (only shown when tamed, by the way) WriteByte(0x13); - WriteByte(((const cWolf &)a_Mob).IsBegging() ? 1 : 0); // Ultra cute mode? + WriteByte(((const cWolf &)a_Mob).IsBegging() ? 1 : 0); // Ultra cute mode? break; } case cMonster::mtSheep: @@ -2028,30 +2028,30 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) case cMonster::mtEnderman: { WriteByte(0x10); - WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock())); // Block that he stole from your house + WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock())); // Block that he stole from your house WriteByte(0x11); - WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedMeta())); // Meta of block that he stole from your house + WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedMeta())); // Meta of block that he stole from your house WriteByte(0x12); - WriteByte(((const cEnderman &)a_Mob).IsScreaming() ? 1 : 0); // Screaming at your face? + WriteByte(((const cEnderman &)a_Mob).IsScreaming() ? 1 : 0); // Screaming at your face? break; } case cMonster::mtSkeleton: { WriteByte(0xD); - WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0); // It's a skeleton, but it's not + WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0); // It's a skeleton, but it's not break; } case cMonster::mtWitch: { WriteByte(0x15); - WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything + WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything break; } case cMonster::mtWither: { - WriteByte(0x54); // Int at index 20 + WriteByte(0x54); // Int at index 20 WriteInt((Int32)((const cWither &)a_Mob).GetWitherInvulnerableTicks()); - WriteByte(0x66); // Float at index 6 + WriteByte(0x66); // Float at index 6 WriteFloat((float)(a_Mob.GetHealth())); break; } @@ -2061,11 +2061,11 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) WriteByte(0x10); if (a_Mob.GetMobType() == cMonster::mtSlime) { - WriteByte((Byte)((const cSlime &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME + WriteByte((Byte)((const cSlime &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME } else { - WriteByte((Byte)((const cMagmaCube &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME + WriteByte((Byte)((const cMagmaCube &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME } break; } @@ -2086,7 +2086,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) } if (((const cHorse &)a_Mob).IsBaby()) { - Flags |= 0x10; // IsBred flag, according to wiki.vg - don't think it does anything in multiplayer + Flags |= 0x10; // IsBred flag, according to wiki.vg - don't think it does anything in multiplayer } if (((const cHorse &)a_Mob).IsEating()) { @@ -2104,16 +2104,16 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) WriteInt(Flags); WriteByte(0x13); - WriteByte((Byte)((const cHorse &)a_Mob).GetHorseType()); // Type of horse (donkey, chestnut, etc.) + WriteByte((Byte)((const cHorse &)a_Mob).GetHorseType()); // Type of horse (donkey, chestnut, etc.) WriteByte(0x54); int Appearance = 0; - Appearance = ((const cHorse &)a_Mob).GetHorseColor(); // Mask FF - Appearance |= ((const cHorse &)a_Mob).GetHorseStyle() * 256; // Mask FF00, so multiply by 256 + Appearance = ((const cHorse &)a_Mob).GetHorseColor(); // Mask FF + Appearance |= ((const cHorse &)a_Mob).GetHorseStyle() * 256; // Mask FF00, so multiply by 256 WriteInt(Appearance); WriteByte(0x56); - WriteInt(((const cHorse &)a_Mob).GetHorseArmour()); // Horshey armour + WriteInt(((const cHorse &)a_Mob).GetHorseArmour()); // Horshey armour break; } default: diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 86a49f3f6..c0696d206 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -76,8 +76,8 @@ public: virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; - virtual void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) override {} // This protocol doesn't support such message - virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override {} // This protocol doesn't support such message + virtual void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) override {} // This protocol doesn't support such message + virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override {} // This protocol doesn't support such message virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override; virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override; diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index 7a8c2221e..a92ae83da 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -71,7 +71,7 @@ enum -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol132: cProtocol132::cProtocol132(cClientHandle * a_Client) : @@ -476,7 +476,7 @@ int cProtocol132::ParseHandshake(void) if (!m_Client->HandleHandshake( m_Username )) { - return PARSE_OK; // Player is not allowed into the server + return PARSE_OK; // Player is not allowed into the server } // Send a 0xfd Encryption Key Request http://wiki.vg/Protocol#0xFD diff --git a/src/Protocol/Protocol14x.cpp b/src/Protocol/Protocol14x.cpp index f60e756fd..8b177ea48 100644 --- a/src/Protocol/Protocol14x.cpp +++ b/src/Protocol/Protocol14x.cpp @@ -66,7 +66,7 @@ enum -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol142: cProtocol142::cProtocol142(cClientHandle * a_Client) : @@ -144,7 +144,7 @@ void cProtocol142::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol146: cProtocol146::cProtocol146(cClientHandle * a_Client) : diff --git a/src/Protocol/Protocol15x.cpp b/src/Protocol/Protocol15x.cpp index 264a596b9..2b1f01b08 100644 --- a/src/Protocol/Protocol15x.cpp +++ b/src/Protocol/Protocol15x.cpp @@ -47,7 +47,7 @@ enum -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol150: cProtocol150::cProtocol150(cClientHandle * a_Client) : diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp index eba795f61..a163922c5 100644 --- a/src/Protocol/Protocol16x.cpp +++ b/src/Protocol/Protocol16x.cpp @@ -55,7 +55,7 @@ enum -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol161: cProtocol161::cProtocol161(cClientHandle * a_Client) : @@ -202,11 +202,11 @@ int cProtocol161::ParseEntityAction(void) switch (ActionID) { - case 1: m_Client->HandleEntityCrouch(EntityID, true); break; // Crouch - case 2: m_Client->HandleEntityCrouch(EntityID, false); break; // Uncrouch - case 3: m_Client->HandleEntityLeaveBed(EntityID); break; // Leave Bed - case 4: m_Client->HandleEntitySprinting(EntityID, true); break; // Start sprinting - case 5: m_Client->HandleEntitySprinting(EntityID, false); break; // Stop sprinting + case 1: m_Client->HandleEntityCrouch(EntityID, true); break; // Crouch + case 2: m_Client->HandleEntityCrouch(EntityID, false); break; // Uncrouch + case 3: m_Client->HandleEntityLeaveBed(EntityID); break; // Leave Bed + case 4: m_Client->HandleEntitySprinting(EntityID, true); break; // Start sprinting + case 5: m_Client->HandleEntitySprinting(EntityID, false); break; // Stop sprinting } return PARSE_OK; @@ -282,7 +282,7 @@ int cProtocol161::ParsePacket(unsigned char a_PacketType) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol162: cProtocol162::cProtocol162(cClientHandle * a_Client) : diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 50c2014c6..36d1f4af4 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -81,7 +81,7 @@ extern bool g_ShouldLogCommIn, g_ShouldLogCommOut; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol172: cProtocol172::cProtocol172(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : @@ -651,7 +651,7 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World) cServer * Server = cRoot::Get()->GetServer(); cPacketizer Pkt(*this, 0x01); // Join Game packet Pkt.WriteInt(a_Player.GetUniqueID()); - Pkt.WriteByte((Byte)a_Player.GetEffectiveGameMode() | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4 + Pkt.WriteByte((Byte)a_Player.GetEffectiveGameMode() | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4 Pkt.WriteChar((char)a_World.GetDimension()); Pkt.WriteByte(2); // TODO: Difficulty (set to Normal) Pkt.WriteByte(std::min(Server->GetMaxPlayers(), 60)); @@ -807,7 +807,7 @@ void cProtocol172::SendPlayerAbilities(void) if (Player->IsGameModeCreative()) { Flags |= 0x01; - Flags |= 0x08; // Godmode, used for creative + Flags |= 0x08; // Godmode, used for creative } if (Player->IsFlying()) { @@ -1130,7 +1130,7 @@ void cProtocol172::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) Pkt.WriteFPInt(a_FallingBlock.GetPosZ()); Pkt.WriteByteAngle(a_FallingBlock.GetYaw()); Pkt.WriteByteAngle(a_FallingBlock.GetPitch()); - Pkt.WriteInt(((int)a_FallingBlock.GetBlockType()) | (((int)a_FallingBlock.GetBlockMeta()) << 16)); // Or 0x10 + Pkt.WriteInt(((int)a_FallingBlock.GetBlockType()) | (((int)a_FallingBlock.GetBlockMeta()) << 16)); // Or 0x10 Pkt.WriteShort((short)(a_FallingBlock.GetSpeedX() * 400)); Pkt.WriteShort((short)(a_FallingBlock.GetSpeedY() * 400)); Pkt.WriteShort((short)(a_FallingBlock.GetSpeedZ() * 400)); @@ -1219,7 +1219,7 @@ void cProtocol172::SendStatistics(const cStatManager & a_Manager) ASSERT(m_State == 3); // In game mode? cPacketizer Pkt(*this, 0x37); - Pkt.WriteVarInt(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only + Pkt.WriteVarInt(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only for (size_t i = 0; i < (size_t)statCount; ++i) { @@ -1326,10 +1326,10 @@ void cProtocol172::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity) Byte Action = 0; switch (a_BlockEntity.GetBlockType()) { - case E_BLOCK_MOB_SPAWNER: Action = 1; break; // Update mob spawner spinny mob thing - case E_BLOCK_COMMAND_BLOCK: Action = 2; break; // Update command block text - case E_BLOCK_HEAD: Action = 4; break; // Update Mobhead entity - case E_BLOCK_FLOWER_POT: Action = 5; break; // Update flower pot + case E_BLOCK_MOB_SPAWNER: Action = 1; break; // Update mob spawner spinny mob thing + case E_BLOCK_COMMAND_BLOCK: Action = 2; break; // Update command block text + case E_BLOCK_HEAD: Action = 4; break; // Update Mobhead entity + case E_BLOCK_FLOWER_POT: Action = 5; break; // Update flower pot default: ASSERT(!"Unhandled or unimplemented BlockEntity update request!"); break; } Pkt.WriteByte(Action); @@ -1656,7 +1656,7 @@ bool cProtocol172::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) case 0x0c: HandlePacketSteerVehicle (a_ByteBuffer); return true; case 0x0d: HandlePacketWindowClose (a_ByteBuffer); return true; case 0x0e: HandlePacketWindowClick (a_ByteBuffer); return true; - case 0x0f: // Confirm transaction - not used in MCS + case 0x0f: // Confirm transaction - not used in MCS case 0x10: HandlePacketCreativeInventoryAction(a_ByteBuffer); return true; case 0x11: HandlePacketEnchantItem (a_ByteBuffer); return true; case 0x12: HandlePacketUpdateSign (a_ByteBuffer); return true; @@ -1950,11 +1950,11 @@ void cProtocol172::HandlePacketEntityAction(cByteBuffer & a_ByteBuffer) switch (Action) { - case 1: m_Client->HandleEntityCrouch(PlayerID, true); break; // Crouch - case 2: m_Client->HandleEntityCrouch(PlayerID, false); break; // Uncrouch - case 3: m_Client->HandleEntityLeaveBed(PlayerID); break; // Leave Bed - case 4: m_Client->HandleEntitySprinting(PlayerID, true); break; // Start sprinting - case 5: m_Client->HandleEntitySprinting(PlayerID, false); break; // Stop sprinting + case 1: m_Client->HandleEntityCrouch(PlayerID, true); break; // Crouch + case 2: m_Client->HandleEntityCrouch(PlayerID, false); break; // Uncrouch + case 3: m_Client->HandleEntityLeaveBed(PlayerID); break; // Leave Bed + case 4: m_Client->HandleEntitySprinting(PlayerID, true); break; // Start sprinting + case 5: m_Client->HandleEntitySprinting(PlayerID, false); break; // Stop sprinting } } @@ -2311,7 +2311,7 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata) { case TAG_List: { - if ((TagName == "ench") || (TagName == "StoredEnchantments")) // Enchantments tags + if ((TagName == "ench") || (TagName == "StoredEnchantments")) // Enchantments tags { EnchantmentSerializer::ParseFromNBT(a_Item.m_Enchantments, NBT, tag); } @@ -2319,21 +2319,21 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata) } case TAG_Compound: { - if (TagName == "display") // Custom name and lore tag + if (TagName == "display") // Custom name and lore tag { for (int displaytag = NBT.GetFirstChild(tag); displaytag >= 0; displaytag = NBT.GetNextSibling(displaytag)) { - if ((NBT.GetType(displaytag) == TAG_String) && (NBT.GetName(displaytag) == "Name")) // Custon name tag + if ((NBT.GetType(displaytag) == TAG_String) && (NBT.GetName(displaytag) == "Name")) // Custon name tag { a_Item.m_CustomName = NBT.GetString(displaytag); } - else if ((NBT.GetType(displaytag) == TAG_List) && (NBT.GetName(displaytag) == "Lore")) // Lore tag + else if ((NBT.GetType(displaytag) == TAG_List) && (NBT.GetName(displaytag) == "Lore")) // Lore tag { AString Lore; - for (int loretag = NBT.GetFirstChild(displaytag); loretag >= 0; loretag = NBT.GetNextSibling(loretag)) // Loop through array of strings + for (int loretag = NBT.GetFirstChild(displaytag); loretag >= 0; loretag = NBT.GetNextSibling(loretag)) // Loop through array of strings { - AppendPrintf(Lore, "%s`", NBT.GetString(loretag).c_str()); // Append the lore with a grave accent/backtick, used internally by MCS to display a new line in the client; don't forget to c_str ;) + AppendPrintf(Lore, "%s`", NBT.GetString(loretag).c_str()); // Append the lore with a grave accent/backtick, used internally by MCS to display a new line in the client; don't forget to c_str ;) } a_Item.m_Lore = Lore; @@ -2463,7 +2463,7 @@ void cProtocol172::AddChatPartStyle(Json::Value & a_Value, const AString & a_Par -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol172::cPacketizer: cProtocol172::cPacketizer::~cPacketizer() @@ -2585,7 +2585,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt { cCommandBlockEntity & CommandBlockEntity = (cCommandBlockEntity &)a_BlockEntity; - Writer.AddByte("TrackOutput", 1); // Neither I nor the MC wiki has any idea about this + Writer.AddByte("TrackOutput", 1); // Neither I nor the MC wiki has any idea about this Writer.AddInt("SuccessCount", CommandBlockEntity.GetResult()); Writer.AddInt("x", CommandBlockEntity.GetPosX()); Writer.AddInt("y", CommandBlockEntity.GetPosY()); @@ -2595,7 +2595,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt // For a command block, this would be the 'name' prepended to anything it outputs into global chat // MCS doesn't have this, so just leave it @ '@'. (geddit?) Writer.AddString("CustomName", "@"); - Writer.AddString("id", "Control"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though + Writer.AddString("id", "Control"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though if (!CommandBlockEntity.GetLastOutput().empty()) { @@ -2616,7 +2616,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt Writer.AddByte("SkullType", MobHeadEntity.GetType() & 0xFF); Writer.AddByte("Rot", MobHeadEntity.GetRotation() & 0xFF); Writer.AddString("ExtraType", MobHeadEntity.GetOwner().c_str()); - Writer.AddString("id", "Skull"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though + Writer.AddString("id", "Skull"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though break; } case E_BLOCK_FLOWER_POT: @@ -2628,7 +2628,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt Writer.AddInt("z", FlowerPotEntity.GetPosZ()); Writer.AddInt("Item", (Int32) FlowerPotEntity.GetItem().m_ItemType); Writer.AddInt("Data", (Int32) FlowerPotEntity.GetItem().m_ItemDamage); - Writer.AddString("id", "FlowerPot"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though + Writer.AddString("id", "FlowerPot"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though break; } default: break; @@ -2713,9 +2713,9 @@ void cProtocol172::cPacketizer::WriteEntityMetadata(const cEntity & a_Entity) */ WriteInt((((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4); WriteByte(0x52); - WriteInt(1); // Shaking direction, doesn't seem to affect anything + WriteInt(1); // Shaking direction, doesn't seem to affect anything WriteByte(0x73); - WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer + WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer if (((cMinecart &)a_Entity).GetPayload() == cMinecart::mpNone) { @@ -2903,9 +2903,9 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob) case cMonster::mtWither: { - WriteByte(0x54); // Int at index 20 + WriteByte(0x54); // Int at index 20 WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks()); - WriteByte(0x66); // Float at index 6 + WriteByte(0x66); // Float at index 6 WriteFloat((float)(a_Mob.GetHealth())); break; } @@ -2985,7 +2985,7 @@ void cProtocol172::cPacketizer::WriteEntityProperties(const cEntity & a_Entity) return; } - //const cMonster & Mob = (const cMonster &)a_Entity; + // const cMonster & Mob = (const cMonster &)a_Entity; // TODO: Send properties and modifiers based on the mob type @@ -2996,7 +2996,7 @@ void cProtocol172::cPacketizer::WriteEntityProperties(const cEntity & a_Entity) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol176: cProtocol176::cProtocol176(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index e5ec3ece2..25c60a72e 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -139,8 +139,8 @@ public: virtual void SendData(const char * a_Data, size_t a_Size) override; protected: - cProtocol * m_Protocol; //< The recognized protocol - cByteBuffer m_Buffer; //< Buffer for the incoming data until we recognize the protocol + cProtocol * m_Protocol; ///< The recognized protocol + cByteBuffer m_Buffer; ///< Buffer for the incoming data until we recognize the protocol /// Tries to recognize protocol based on m_Buffer contents; returns true if recognized bool TryRecognizeProtocol(void); diff --git a/src/RCONServer.cpp b/src/RCONServer.cpp index c511968be..28cb1e03b 100644 --- a/src/RCONServer.cpp +++ b/src/RCONServer.cpp @@ -38,7 +38,7 @@ enum -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRCONCommandOutput: class cRCONCommandOutput : @@ -73,7 +73,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRCONServer: cRCONServer::cRCONServer(cServer & a_Server) : @@ -154,7 +154,7 @@ void cRCONServer::OnConnectionAccepted(cSocket & a_Socket) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRCONServer::cConnection: cRCONServer::cConnection::cConnection(cRCONServer & a_RCONServer, cSocket & a_Socket) : diff --git a/src/Server.cpp b/src/Server.cpp index 81ecd38b2..bc9644804 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -60,7 +60,7 @@ typedef std::list< cClientHandle* > ClientList; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cServer::cTickThread: cServer::cTickThread::cTickThread(cServer & a_Server) : @@ -101,7 +101,7 @@ void cServer::cTickThread::Execute(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cServer: cServer::cServer(void) : @@ -673,7 +673,7 @@ void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const ASt -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cServer::cNotifyWriteThread: cServer::cNotifyWriteThread::cNotifyWriteThread(void) : diff --git a/src/Simulator/DelayedFluidSimulator.cpp b/src/Simulator/DelayedFluidSimulator.cpp index 5ff736231..884069b21 100644 --- a/src/Simulator/DelayedFluidSimulator.cpp +++ b/src/Simulator/DelayedFluidSimulator.cpp @@ -14,7 +14,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cDelayedFluidSimulatorChunkData::cSlot bool cDelayedFluidSimulatorChunkData::cSlot::Add(int a_RelX, int a_RelY, int a_RelZ) @@ -40,7 +40,7 @@ bool cDelayedFluidSimulatorChunkData::cSlot::Add(int a_RelX, int a_RelY, int a_R -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cDelayedFluidSimulatorChunkData: cDelayedFluidSimulatorChunkData::cDelayedFluidSimulatorChunkData(int a_TickDelay) : @@ -62,7 +62,7 @@ cDelayedFluidSimulatorChunkData::~cDelayedFluidSimulatorChunkData() -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cDelayedFluidSimulator: cDelayedFluidSimulator::cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay) : diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp index 311f8b4c4..1ad4f2654 100644 --- a/src/Simulator/FireSimulator.cpp +++ b/src/Simulator/FireSimulator.cpp @@ -63,7 +63,7 @@ static const struct -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFireSimulator: cFireSimulator::cFireSimulator(cWorld & a_World, cIniFile & a_IniFile) : diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp index f64955cb2..99aa11728 100644 --- a/src/Simulator/FluidSimulator.cpp +++ b/src/Simulator/FluidSimulator.cpp @@ -125,31 +125,31 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a return NONE; } BLOCKTYPE BlockID = m_World.GetBlock(a_X, a_Y, a_Z); - if (!IsAllowedBlock(BlockID)) // No Fluid -> No Flowing direction :D + if (!IsAllowedBlock(BlockID)) // No Fluid -> No Flowing direction :D { return NONE; } /* Disabled because of causing problems and being useless atm - char BlockBelow = m_World.GetBlock(a_X, a_Y - 1, a_Z); //If there is nothing or fluid below it -> dominating flow is down :D + char BlockBelow = m_World.GetBlock(a_X, a_Y - 1, a_Z); // If there is nothing or fluid below it -> dominating flow is down :D if (BlockBelow == E_BLOCK_AIR || IsAllowedBlock(BlockBelow)) return Y_MINUS; */ - NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); //Current Block Meta so only lower points will be counted - int X = 0, Z = 0; //Lowest Pos will be stored here + NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); // Current Block Meta so only lower points will be counted + int X = 0, Z = 0; // Lowest Pos will be stored here - if (IsAllowedBlock(m_World.GetBlock(a_X, a_Y + 1, a_Z)) && a_Over) //check for upper block to flow because this also affects the flowing direction + if (IsAllowedBlock(m_World.GetBlock(a_X, a_Y + 1, a_Z)) && a_Over) // check for upper block to flow because this also affects the flowing direction { return GetFlowingDirection(a_X, a_Y + 1, a_Z, false); } std::vector< Vector3i * > Points; - Points.reserve(4); //Already allocate 4 places :D + Points.reserve(4); // Already allocate 4 places :D - //add blocks around the checking pos + // add blocks around the checking pos Points.push_back(new Vector3i(a_X - 1, a_Y, a_Z)); Points.push_back(new Vector3i(a_X + 1, a_Y, a_Z)); Points.push_back(new Vector3i(a_X, a_Y, a_Z + 1)); @@ -172,7 +172,7 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a } else if(BlockID == E_BLOCK_AIR) { - LowestPoint = 9; //This always dominates + LowestPoint = 9; // This always dominates X = Pos->x; Z = Pos->z; diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 55c5cbd09..0d4815c00 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -190,16 +190,16 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, cRedstoneSimulatorChunkData * RedstoneSimulatorChunkData = a_Chunk->GetRedstoneSimulatorData(); for (cRedstoneSimulatorChunkData::iterator itr = RedstoneSimulatorChunkData->begin(); itr != RedstoneSimulatorChunkData->end(); ++itr) { - if ((itr->x == RelX) && (itr->y == a_BlockY) && (itr->z == RelZ)) // We are at an entry matching the current (changed) block + if ((itr->x == RelX) && (itr->y == a_BlockY) && (itr->z == RelZ)) // We are at an entry matching the current (changed) block { if (!IsAllowedBlock(Block)) { - itr->DataTwo = true; // The new blocktype is not redstone; it must be queued to be removed from this list + itr->DataTwo = true; // The new blocktype is not redstone; it must be queued to be removed from this list } else { itr->DataTwo = false; - itr->Data = Block; // Update block information + itr->Data = Block; // Update block information } return; } @@ -378,7 +378,7 @@ void cIncrementalRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_Blo void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState) { - static const struct // Define which directions the torch can power + static const struct // Define which directions the torch can power { int x, y, z; } gCrossCoords[] = @@ -394,7 +394,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R { // Check if the block the torch is on is powered int X = a_RelBlockX; int Y = a_RelBlockY; int Z = a_RelBlockZ; - AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on + AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on cChunk * Neighbour = m_Chunk->GetRelNeighborChunk(X, Z); if ((Neighbour == NULL) || !Neighbour->IsValid()) @@ -417,11 +417,11 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R { continue; } - if (i + 1 < ARRAYCOUNT(gCrossCoords)) // Sides of torch, not top (top is last) + if (i + 1 < ARRAYCOUNT(gCrossCoords)) // Sides of torch, not top (top is last) { if ( - IsMechanism(Type) && // Is it a mechanism? Not block/other torch etc. - (!Vector3i(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z).Equals(Vector3i(X, Y, Z))) // CAN'T power block is that it is on + IsMechanism(Type) && // Is it a mechanism? Not block/other torch etc. + (!Vector3i(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z).Equals(Vector3i(X, Y, Z))) // CAN'T power block is that it is on ) { SetBlockPowered(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ); @@ -436,11 +436,11 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R } } - if (m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) != 0x5) // Is torch standing on ground? If NOT (i.e. on wall), power block beneath + if (m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) != 0x5) // Is torch standing on ground? If NOT (i.e. on wall), power block beneath { BLOCKTYPE Type = m_Chunk->GetBlock(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ); - if (IsMechanism(Type)) // Still can't make a normal block powered though! + if (IsMechanism(Type)) // Still can't make a normal block powered though! { SetBlockPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); } @@ -450,7 +450,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R { // Check if the block the torch is on is powered int X = a_RelBlockX; int Y = a_RelBlockY; int Z = a_RelBlockZ; - AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on + AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on cChunk * Neighbour = m_Chunk->GetRelNeighborChunk(X, Z); if ((Neighbour == NULL) || !Neighbour->IsValid()) @@ -461,7 +461,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R // See if off state torch can be turned on again if (AreCoordsDirectlyPowered(X, Y, Z, Neighbour)) { - return; // Something matches, torch still powered + return; // Something matches, torch still powered } // Block torch on not powered, can be turned on again! @@ -476,7 +476,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R void cIncrementalRedstoneSimulator::HandleRedstoneBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); // Set self as powered + SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); // Set self as powered } @@ -557,7 +557,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneButton(int a_RelBlockX, int a_ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - static const struct // Define which directions the wire can receive power from + static const struct // Define which directions the wire can receive power from { int x, y, z; } gCrossCoords[] = @@ -576,7 +576,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re { 0,-1, -1}, /* Wires one lower, surrounding self stop */ } ; - static const struct // Define which directions the wire will check for repeater prescence + static const struct // Define which directions the wire will check for repeater prescence { int x, y, z; } gSideCoords[] = @@ -608,9 +608,9 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re MyPower--; - for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) // Loop through all directions to transfer or receive power + for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) // Loop through all directions to transfer or receive power { - if ((i >= 4) && (i <= 7)) // If we are currently checking for wire surrounding ourself one block above... + if ((i >= 4) && (i <= 7)) // If we are currently checking for wire surrounding ourself one block above... { BLOCKTYPE Type = 0; if (a_RelBlockY + 1 >= cChunkDef::Height) @@ -621,12 +621,12 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re { continue; } - if (cBlockInfo::IsSolid(Type)) // If there is something solid above us (wire cut off)... + if (cBlockInfo::IsSolid(Type)) // If there is something solid above us (wire cut off)... { - continue; // We don't receive power from that wire + continue; // We don't receive power from that wire } } - else if ((i >= 8) && (i <= 11)) // See above, but this is for wire below us + else if ((i >= 8) && (i <= 11)) // See above, but this is for wire below us { BLOCKTYPE Type = 0; if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY, a_RelBlockZ + gCrossCoords[i].z, Type)) @@ -650,7 +650,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re } } - for (size_t i = 0; i < ARRAYCOUNT(gSideCoords); i++) // Look for repeaters immediately surrounding self and try to power them + for (size_t i = 0; i < ARRAYCOUNT(gSideCoords); i++) // Look for repeaters immediately surrounding self and try to power them { BLOCKTYPE Type = 0; if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + gSideCoords[i].x, a_RelBlockY + gSideCoords[i].y, a_RelBlockZ + gSideCoords[i].z, Type)) @@ -740,14 +740,14 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int NIBBLETYPE a_Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); bool IsOn = (a_MyState == E_BLOCK_REDSTONE_REPEATER_ON); - if (!IsRepeaterLocked(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta)) // If we're locked, change nothing. Otherwise: + if (!IsRepeaterLocked(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta)) // If we're locked, change nothing. Otherwise: { bool IsSelfPowered = IsRepeaterPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta); - if (IsSelfPowered && !IsOn) // Queue a power change if powered, but not on and not locked. + if (IsSelfPowered && !IsOn) // Queue a power change if powered, but not on and not locked. { QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, true); } - else if (!IsSelfPowered && IsOn) // Queue a power change if unpowered, on, and not locked. + else if (!IsSelfPowered && IsOn) // Queue a power change if unpowered, on, and not locked. { QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false); } @@ -758,7 +758,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() { for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end();) { - if (itr->a_ElapsedTicks >= itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks? + if (itr->a_ElapsedTicks >= itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks? { int RelBlockX = itr->a_RelBlockPos.x; int RelBlockY = itr->a_RelBlockPos.y; @@ -768,12 +768,12 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() m_Chunk->GetBlockTypeMeta(RelBlockX, RelBlockY, RelBlockZ, Block, Meta); if (itr->ShouldPowerOn) { - if (Block != E_BLOCK_REDSTONE_REPEATER_ON) // For performance + if (Block != E_BLOCK_REDSTONE_REPEATER_ON) // For performance { m_Chunk->SetBlock(itr->a_RelBlockPos, E_BLOCK_REDSTONE_REPEATER_ON, Meta); } - switch (Meta & 0x3) // We only want the direction (bottom) bits + switch (Meta & 0x3) // We only want the direction (bottom) bits { case 0x0: { @@ -825,7 +825,7 @@ void cIncrementalRedstoneSimulator::HandlePiston(int a_RelBlockX, int a_RelBlock int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; - if (IsPistonPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x7)) // We only want the bottom three bits (4th controls extended-ness) + if (IsPistonPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x7)) // We only want the bottom three bits (4th controls extended-ness) { cBlockPistonHandler::ExtendPiston(BlockX, a_RelBlockY, BlockZ, &m_World); } @@ -1280,7 +1280,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R if (Distance <= 0.5) { m_FoundEntity = true; - return true; // Break out, we only need to know for plates that at least one entity is on top + return true; // Break out, we only need to know for plates that at least one entity is on top } return false; } @@ -1343,7 +1343,7 @@ void cIncrementalRedstoneSimulator::HandleTripwireHook(int a_RelBlockX, int a_Re bool FoundActivated = false; eBlockFace FaceToGoTowards = cBlockTripwireHookHandler::MetadataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)); - for (int i = 0; i < 40; ++i) // Tripwires can be connected up to 40 blocks + for (int i = 0; i < 40; ++i) // Tripwires can be connected up to 40 blocks { BLOCKTYPE Type; NIBBLETYPE Meta; @@ -1469,7 +1469,7 @@ void cIncrementalRedstoneSimulator::HandleTripwire(int a_RelBlockX, int a_RelBlo if (bbEntity.DoesIntersect(bbWire)) { m_FoundEntity = true; - return true; // One entity is sufficient to trigger the wire + return true; // One entity is sufficient to trigger the wire } return false; } @@ -1511,7 +1511,7 @@ bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_RelBlockX, in int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; - for (PoweredBlocksList::const_iterator itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->end(); ++itr) // Check powered list + for (PoweredBlocksList::const_iterator itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->end(); ++itr) // Check powered list { if (itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { @@ -1530,7 +1530,7 @@ bool cIncrementalRedstoneSimulator::AreCoordsLinkedPowered(int a_RelBlockX, int int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; - for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list + for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list { if (itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { @@ -1608,7 +1608,7 @@ bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_RelBlockX, int a_Rel } } } - return false; // Couldn't find power source behind repeater + return false; // Couldn't find power source behind repeater } @@ -1617,7 +1617,7 @@ bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_RelBlockX, int a_Rel bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta) { - switch (a_Meta & 0x3) // We only want the 'direction' part of our metadata + switch (a_Meta & 0x3) // We only want the 'direction' part of our metadata { // If the repeater is looking up or down (If parallel to the Z axis) case 0x0: @@ -1625,17 +1625,17 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelB { // Check if eastern(right) neighbor is a powered on repeater who is facing us BLOCKTYPE Block = 0; - if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) // Is right neighbor a powered repeater? + if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) // Is right neighbor a powered repeater? { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ) & 0x3; - if (OtherRepeaterDir == 0x3) { return true; } // If so, I am latched/locked + if (OtherRepeaterDir == 0x3) { return true; } // If so, I am latched/locked } // Check if western(left) neighbor is a powered on repeater who is facing us if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX -1, a_RelBlockY, a_RelBlockZ) & 0x3; - if (OtherRepeaterDir == 0x1) { return true; } // If so, I am latched/locked + if (OtherRepeaterDir == 0x1) { return true; } // If so, I am latched/locked } break; @@ -1650,21 +1650,21 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelB if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1) & 0x3; - if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked + if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked } // Check if northern(up) neighbor is a powered on repeater who is facing us if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1) & 0x3; - if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked + if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked } break; } } - return false; // None of the checks succeeded, I am not a locked repeater + return false; // None of the checks succeeded, I am not a locked repeater } @@ -1705,7 +1705,7 @@ bool cIncrementalRedstoneSimulator::IsPistonPowered(int a_RelBlockX, int a_RelBl AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face, true); } - return false; // Source was in front of the piston's front face + return false; // Source was in front of the piston's front face } @@ -1717,16 +1717,16 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX; int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ; - for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list + for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list { if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; } - a_PowerLevel = std::max(itr->a_PowerLevel , a_PowerLevel); // Get the highest power level (a_PowerLevel is initialised already and there CAN be multiple levels for one block) + a_PowerLevel = std::max(itr->a_PowerLevel , a_PowerLevel); // Get the highest power level (a_PowerLevel is initialised already and there CAN be multiple levels for one block) } - for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list + for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list { if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { @@ -1743,7 +1743,7 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc a_PowerLevel = std::max(itr->a_PowerLevel, a_PowerLevel); } - return (a_PowerLevel != 0); // Answer the inital question: is the wire powered? + return (a_PowerLevel != 0); // Answer the inital question: is the wire powered? } @@ -1756,17 +1756,17 @@ bool cIncrementalRedstoneSimulator::AreCoordsSimulated(int a_RelBlockX, int a_Re { if (itr->a_RelBlockPos.Equals(Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) { - if (itr->WasLastStatePowered != IsCurrentStatePowered) // Was the last power state different to the current? + if (itr->WasLastStatePowered != IsCurrentStatePowered) // Was the last power state different to the current? { - return false; // It was, coordinates are no longer simulated + return false; // It was, coordinates are no longer simulated } else { - return true; // It wasn't, don't resimulate block, and allow players to toggle + return true; // It wasn't, don't resimulate block, and allow players to toggle } } } - return false; // Block wasn't even in the list, not simulated + return false; // Block wasn't even in the list, not simulated } @@ -1870,7 +1870,7 @@ void cIncrementalRedstoneSimulator::SetDirectionLinkedPowered(int a_RelBlockX, i } default: { - ASSERT(!"Unhandled face direction when attempting to set blocks as linked powered!"); // Zombies, that wasn't supposed to happen... + ASSERT(!"Unhandled face direction when attempting to set blocks as linked powered!"); // Zombies, that wasn't supposed to happen... break; } } @@ -1895,7 +1895,7 @@ void cIncrementalRedstoneSimulator::SetAllDirsAsPowered(int a_RelBlockX, int a_R { 0, -1, 0 } }; - for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) // Loop through struct to power all directions + for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) // Loop through struct to power all directions { SetBlockPowered(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_PowerLevel); } @@ -1912,13 +1912,13 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl int SourceX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelSourceX; int SourceZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelSourceZ; - cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelBlockX, a_RelBlockZ); // Adjust coordinates for the later call using these values + cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelBlockX, a_RelBlockZ); // Adjust coordinates for the later call using these values if ((Neighbour == NULL) || !Neighbour->IsValid()) { return; } - PoweredBlocksList * Powered = Neighbour->GetRedstoneSimulatorPoweredBlocksList(); // We need to insert the value into the chunk who owns the block position + PoweredBlocksList * Powered = Neighbour->GetRedstoneSimulatorPoweredBlocksList(); // We need to insert the value into the chunk who owns the block position for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr) { if ( @@ -1950,7 +1950,7 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl { if (Meta < a_PowerLevel) { - m_PoweredBlocks->erase(itr); // Powering source with higher power level, allow it + m_PoweredBlocks->erase(itr); // Powering source with higher power level, allow it break; } else @@ -2068,13 +2068,13 @@ bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in { if (itr->a_RelBlockPos.Equals(Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) { - if (ShouldPowerOn == itr->ShouldPowerOn) // We are queued already for the same thing, don't replace entry + if (ShouldPowerOn == itr->ShouldPowerOn) // We are queued already for the same thing, don't replace entry { return false; } // Already in here (normal to allow repeater to continue on powering and updating blocks in front) - just update info and quit - itr->a_DelayTicks = (((a_Meta & 0xC) >> 0x2) + 1) * 2; // See below for description + itr->a_DelayTicks = (((a_Meta & 0xC) >> 0x2) + 1) * 2; // See below for description itr->a_ElapsedTicks = 0; itr->ShouldPowerOn = ShouldPowerOn; return false; @@ -2086,7 +2086,7 @@ bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in RC.a_RelBlockPos = Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ); // Gets the top two bits (delay time), shifts them into the lower two bits, and adds one (meta 0 = 1 tick; 1 = 2 etc.) - // * 2 because in MCS, 1 redstone tick = 1 world tick, but in Vanilla, 1 redstone tick = 2 world ticks, and we need to maintain compatibility + // Multiply by 2 because in MCS, 1 redstone tick = 1 world tick, but in Vanilla, 1 redstone tick = 2 world ticks, and we need to maintain compatibility RC.a_DelayTicks = (((a_Meta & 0xC) >> 0x2) + 1) * 2; RC.a_ElapsedTicks = 0; @@ -2101,7 +2101,7 @@ bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in void cIncrementalRedstoneSimulator::SetSourceUnpowered(int a_SourceX, int a_SourceY, int a_SourceZ, cChunk * a_Chunk, bool a_IsFirstCall) { - if (!a_IsFirstCall) // The neighbouring chunks passed when this parameter is false may be invalid + if (!a_IsFirstCall) // The neighbouring chunks passed when this parameter is false may be invalid { if ((a_Chunk == NULL) || !a_Chunk->IsValid()) { diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index 1faf4187b..878f88b71 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -38,33 +38,33 @@ private: #define MAX_POWER_LEVEL 15 - struct sPoweredBlocks // Define structure of the directly powered blocks list + struct sPoweredBlocks // Define structure of the directly powered blocks list { - Vector3i a_BlockPos; // Position of powered block - Vector3i a_SourcePos; // Position of source powering the block at a_BlockPos + Vector3i a_BlockPos; // Position of powered block + Vector3i a_SourcePos; // Position of source powering the block at a_BlockPos unsigned char a_PowerLevel; }; - struct sLinkedPoweredBlocks // Define structure of the indirectly powered blocks list (i.e. repeaters powering through a block to the block at the other side) + struct sLinkedPoweredBlocks // Define structure of the indirectly powered blocks list (i.e. repeaters powering through a block to the block at the other side) { Vector3i a_BlockPos; - Vector3i a_MiddlePos; // Position of block that is betwixt a source and the destination + Vector3i a_MiddlePos; // Position of block that is betwixt a source and the destination Vector3i a_SourcePos; unsigned char a_PowerLevel; }; - struct sSimulatedPlayerToggleableList // Define structure of the list containing simulate-on-update blocks (such as trapdoors that respond once to a block update, and can be toggled by a player) + struct sSimulatedPlayerToggleableList // Define structure of the list containing simulate-on-update blocks (such as trapdoors that respond once to a block update, and can be toggled by a player) { Vector3i a_RelBlockPos; - bool WasLastStatePowered; // Was the last state powered or not? Determines whether a source update has happened and if I should resimulate + bool WasLastStatePowered; // Was the last state powered or not? Determines whether a source update has happened and if I should resimulate }; - struct sRepeatersDelayList // Define structure of list containing repeaters' delay states + struct sRepeatersDelayList // Define structure of list containing repeaters' delay states { Vector3i a_RelBlockPos; - unsigned char a_DelayTicks; // For how many ticks should the repeater delay - unsigned char a_ElapsedTicks; // How much of the previous has been elapsed? - bool ShouldPowerOn; // What happens when the delay time is fulfilled? + unsigned char a_DelayTicks; // For how many ticks should the repeater delay + unsigned char a_ElapsedTicks; // How much of the previous has been elapsed? + bool ShouldPowerOn; // What happens when the delay time is fulfilled? }; public: @@ -302,7 +302,7 @@ private: inline static bool AreCoordsOnChunkBoundary(int a_BlockX, int a_BlockY, int a_BlockZ) { - return ( // Are we on a chunk boundary? +- 2 because of LinkedPowered blocks + return ( // Are we on a chunk boundary? +- 2 because of LinkedPowered blocks ((a_BlockX % cChunkDef::Width) <= 1) || ((a_BlockX % cChunkDef::Width) >= 14) || ((a_BlockZ % cChunkDef::Width) <= 1) || diff --git a/src/Simulator/NoopRedstoneSimulator.h b/src/Simulator/NoopRedstoneSimulator.h index fe3949198..e5338ad44 100644 --- a/src/Simulator/NoopRedstoneSimulator.h +++ b/src/Simulator/NoopRedstoneSimulator.h @@ -18,7 +18,7 @@ public: { } - //~cRedstoneNoopSimulator(); + // ~cRedstoneNoopSimulator(); virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 9429157a9..f60ed1248 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -339,9 +339,9 @@ AString & RawBEToUTF8(const char * a_RawData, size_t a_NumShorts, AString & a_UT // UTF-8 conversion code adapted from: // http://stackoverflow.com/questions/2867123/convert-utf-16-to-utf-8-under-windows-and-linux-in-c -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Begin of Unicode, Inc.'s code / information -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// /* Notice from the original file: @@ -519,9 +519,9 @@ are equivalent to the following loop: --------------------------------------------------------------------- */ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // End of Unicode, Inc.'s code / information -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/Tracer.cpp b/src/Tracer.cpp index d788d9e26..54b4716e3 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -273,36 +273,50 @@ int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,fl // 2 = the segment lies in the plane int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal ) { - Vector3f u = a_End - a_Origin;//a_Ray.P1 - S.P0; - Vector3f w = a_Origin - a_PlanePos;//S.P0 - Pn.V0; + Vector3f u = a_End - a_Origin; // a_Ray.P1 - S.P0; + Vector3f w = a_Origin - a_PlanePos; // S.P0 - Pn.V0; - float D = a_PlaneNormal.Dot( u );//dot(Pn.n, u); - float N = -(a_PlaneNormal.Dot( w ) );//-dot(a_Plane.n, w); + float D = a_PlaneNormal.Dot( u ); // dot(Pn.n, u); + float N = -(a_PlaneNormal.Dot( w ) ); // -dot(a_Plane.n, w); const float EPSILON = 0.0001f; - if (fabs(D) < EPSILON) { // segment is parallel to plane - if (N == 0) // segment lies in plane + if (fabs(D) < EPSILON) + { + // segment is parallel to plane + if (N == 0) + { + // segment lies in plane return 2; - return 0; // no intersection + } + return 0; // no intersection } + // they are not parallel // compute intersect param float sI = N / D; if (sI < 0 || sI > 1) - return 0; // no intersection + { + return 0; // no intersection + } - // Vector3f I ( a_Ray->GetOrigin() + sI * u );//S.P0 + sI * u; // compute segment intersect point + // Vector3f I ( a_Ray->GetOrigin() + sI * u );// S.P0 + sI * u; // compute segment intersect point RealHit = a_Origin + u * sI; return 1; } + + + + int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos) { Vector3i SmallBlockPos = a_BlockPos; char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z ); if( BlockID == E_BLOCK_AIR || IsBlockWater(BlockID)) + { return 0; + } Vector3f BlockPos; BlockPos = Vector3f(SmallBlockPos); diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index e220960ff..0a9502491 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -20,7 +20,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotArea: cSlotArea::cSlotArea(int a_NumSlots, cWindow & a_ParentWindow) : @@ -108,9 +108,9 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA { case caRightClick: { - if (DraggingItem.m_ItemType <= 0) // Empty-handed? + if (DraggingItem.m_ItemType <= 0) // Empty-handed? { - DraggingItem = Slot.CopyOne(); // Obtain copy of slot to preserve lore, enchantments, etc. + DraggingItem = Slot.CopyOne(); // Obtain copy of slot to preserve lore, enchantments, etc. DraggingItem.m_ItemCount = (char)(((float)Slot.m_ItemCount) / 2.f + 0.5f); Slot.m_ItemCount -= DraggingItem.m_ItemCount; @@ -128,7 +128,7 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA { char OldSlotCount = Slot.m_ItemCount; - Slot = DraggingItem.CopyOne(); // See above + Slot = DraggingItem.CopyOne(); // See above OldSlotCount++; Slot.m_ItemCount = OldSlotCount; @@ -409,7 +409,7 @@ bool cSlotArea::CollectItemsToHand(cItem & a_Dragging, cPlayer & a_Player, bool -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaChest: cSlotAreaChest::cSlotAreaChest(cChestEntity * a_Chest, cWindow & a_ParentWindow) : @@ -441,7 +441,7 @@ void cSlotAreaChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaDoubleChest: cSlotAreaDoubleChest::cSlotAreaDoubleChest(cChestEntity * a_TopChest, cChestEntity * a_BottomChest, cWindow & a_ParentWindow) : @@ -488,7 +488,7 @@ void cSlotAreaDoubleChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cIte -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaCrafting: cSlotAreaCrafting::cSlotAreaCrafting(int a_GridSize, cWindow & a_ParentWindow) : @@ -764,7 +764,7 @@ void cSlotAreaCrafting::HandleCraftItem(const cItem & a_Result, cPlayer & a_Play -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaAnvil: cSlotAreaAnvil::cSlotAreaAnvil(cAnvilWindow & a_ParentWindow) : @@ -1191,7 +1191,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaEnchanting: cSlotAreaEnchanting::cSlotAreaEnchanting(cEnchantingWindow & a_ParentWindow) : @@ -1496,7 +1496,7 @@ int cSlotAreaEnchanting::GetBookshelvesCount(cWorld * a_World) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaEnderChest: cSlotAreaEnderChest::cSlotAreaEnderChest(cEnderChestEntity * a_EnderChest, cWindow & a_ParentWindow) : @@ -1527,7 +1527,7 @@ void cSlotAreaEnderChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaFurnace: cSlotAreaFurnace::cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow) : @@ -1763,7 +1763,7 @@ void cSlotAreaFurnace::HandleSmeltItem(const cItem & a_Result, cPlayer & a_Playe -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaInventoryBase: cSlotAreaInventoryBase::cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow & a_ParentWindow) : @@ -1819,7 +1819,7 @@ void cSlotAreaInventoryBase::SetSlot(int a_SlotNum, cPlayer & a_Player, const cI -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaArmor: void cSlotAreaArmor::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) @@ -1948,7 +1948,7 @@ bool cSlotAreaArmor::CanPlaceInSlot(int a_SlotNum, const cItem & a_Item) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaItemGrid: cSlotAreaItemGrid::cSlotAreaItemGrid(cItemGrid & a_ItemGrid, cWindow & a_ParentWindow) : @@ -1999,7 +1999,7 @@ void cSlotAreaItemGrid::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaTemporary: cSlotAreaTemporary::cSlotAreaTemporary(int a_NumSlots, cWindow & a_ParentWindow) : @@ -2104,7 +2104,7 @@ void cSlotAreaTemporary::TossItems(cPlayer & a_Player, int a_Begin, int a_End) double vX = 0, vY = 0, vZ = 0; EulerToVector(-a_Player.GetYaw(), a_Player.GetPitch(), vZ, vX, vY); vY = -vY * 2 + 1.f; - a_Player.GetWorld()->SpawnItemPickups(Drops, a_Player.GetPosX(), a_Player.GetPosY() + 1.6f, a_Player.GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because player created + a_Player.GetWorld()->SpawnItemPickups(Drops, a_Player.GetPosX(), a_Player.GetPosY() + 1.6f, a_Player.GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because player created } diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 19db01b7a..b550068b1 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -763,7 +763,7 @@ void cWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Player) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cInventoryWindow: cInventoryWindow::cInventoryWindow(cPlayer & a_Player) : @@ -780,7 +780,7 @@ cInventoryWindow::cInventoryWindow(cPlayer & a_Player) : -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCraftingWindow: cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : @@ -795,7 +795,7 @@ cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cAnvilWindow: cAnvilWindow::cAnvilWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : @@ -840,7 +840,7 @@ void cAnvilWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEnchantingWindow: cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : @@ -901,7 +901,7 @@ void cEnchantingWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cChestWindow: cChestWindow::cChestWindow(cChestEntity * a_Chest) : @@ -1011,7 +1011,7 @@ cChestWindow::~cChestWindow() -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cDropSpenserWindow: cDropSpenserWindow::cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserEntity * a_DropSpenser) : @@ -1027,7 +1027,7 @@ cDropSpenserWindow::cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEnderChestWindow: cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) : @@ -1065,7 +1065,7 @@ cEnderChestWindow::~cEnderChestWindow() -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHopperWindow: cHopperWindow::cHopperWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cHopperEntity * a_Hopper) : @@ -1081,7 +1081,7 @@ cHopperWindow::cHopperWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cHopperEn -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFurnaceWindow: cFurnaceWindow::cFurnaceWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceEntity * a_Furnace) : diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index b3eab5659..be72f2d5a 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -531,7 +531,7 @@ void cWebAdmin::OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWebAdmin::cWebadminRequestData void cWebAdmin::cWebadminRequestData::OnBody(const char * a_Data, size_t a_Size) diff --git a/src/World.cpp b/src/World.cpp index 7f30f9b39..186842b20 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -70,7 +70,7 @@ const int TIME_SPAWN_DIVISOR = 148; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorldLoadProgress: /// A simple thread that displays the progress of world loading / saving in cWorld::InitializeSpawn() @@ -122,7 +122,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorldLightingProgress: /// A simple thread that displays the progress of world lighting in cWorld::InitializeSpawn() @@ -172,7 +172,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld::cLock: cWorld::cLock::cLock(cWorld & a_World) : @@ -184,7 +184,7 @@ cWorld::cLock::cLock(cWorld & a_World) : -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld::cTickThread: cWorld::cTickThread::cTickThread(cWorld & a_World) : @@ -226,7 +226,7 @@ void cWorld::cTickThread::Execute(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld: cWorld::cWorld(const AString & a_WorldName) : @@ -2914,7 +2914,7 @@ void cWorld::TickQueuedBlocks(void) { // TODO: Handle the case when the chunk is already unloaded m_ChunkMap->TickBlock(Block->X, Block->Y, Block->Z); - delete Block; // We don't have to remove it from the vector, this will happen automatically on the next tick + delete Block; // We don't have to remove it from the vector, this will happen automatically on the next tick } else { @@ -3200,7 +3200,7 @@ void cWorld::AddQueuedPlayers(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld::cTaskSaveAllChunks: void cWorld::cTaskSaveAllChunks::Run(cWorld & a_World) @@ -3212,7 +3212,7 @@ void cWorld::cTaskSaveAllChunks::Run(cWorld & a_World) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld::cTaskUnloadUnusedChunks void cWorld::cTaskUnloadUnusedChunks::Run(cWorld & a_World) @@ -3224,7 +3224,7 @@ void cWorld::cTaskUnloadUnusedChunks::Run(cWorld & a_World) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld::cTaskSendBlockTo cWorld::cTaskSendBlockToAllPlayers::cTaskSendBlockToAllPlayers(std::vector & a_SendQueue) : @@ -3267,7 +3267,7 @@ void cWorld::cTaskSendBlockToAllPlayers::Run(cWorld & a_World) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld::cChunkGeneratorCallbacks: cWorld::cChunkGeneratorCallbacks::cChunkGeneratorCallbacks(cWorld & a_World) : diff --git a/src/World.h b/src/World.h index 725e1eb71..f0e8d5cf3 100644 --- a/src/World.h +++ b/src/World.h @@ -870,7 +870,7 @@ private: bool m_VillagersShouldHarvestCrops; std::vector m_BlockTickQueue; - std::vector m_BlockTickQueueCopy; // Second is for safely removing the objects from the queue + std::vector m_BlockTickQueueCopy; // Second is for safely removing the objects from the queue cSimulatorManager * m_SimulatorManager; cSandSimulator * m_SandSimulator; diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index a047d67c7..8e7247aab 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -25,7 +25,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cParsedNBT: #define NEEDBYTES(N) \ @@ -329,7 +329,7 @@ int cParsedNBT::FindTagByPath(int a_Tag, const AString & a_Path) const -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFastNBTWriter: cFastNBTWriter::cFastNBTWriter(const AString & a_RootTagName) : diff --git a/src/WorldStorage/FireworksSerializer.cpp b/src/WorldStorage/FireworksSerializer.cpp index 181cfde0d..5a2be8867 100644 --- a/src/WorldStorage/FireworksSerializer.cpp +++ b/src/WorldStorage/FireworksSerializer.cpp @@ -72,7 +72,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB for (int explosiontag = a_NBT.GetFirstChild(a_TagIdx); explosiontag >= 0; explosiontag = a_NBT.GetNextSibling(explosiontag)) { eTagType TagType = a_NBT.GetType(explosiontag); - if (TagType == TAG_Byte) // Custon name tag + if (TagType == TAG_Byte) // Custon name tag { AString ExplosionName = a_NBT.GetName(explosiontag); @@ -135,7 +135,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB for (int fireworkstag = a_NBT.GetFirstChild(a_TagIdx); fireworkstag >= 0; fireworkstag = a_NBT.GetNextSibling(fireworkstag)) { eTagType TagType = a_NBT.GetType(fireworkstag); - if (TagType == TAG_Byte) // Custon name tag + if (TagType == TAG_Byte) // Custon name tag { if (a_NBT.GetName(fireworkstag) == "Flight") { diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 6d0b60371..3f79a6572 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -279,7 +279,7 @@ void cNBTChunkSerializer::AddCommandBlockEntity(cCommandBlockEntity * a_CmdBlock m_Writer.AddString("Command", a_CmdBlock->GetCommand()); m_Writer.AddInt ("SuccessCount", a_CmdBlock->GetResult()); m_Writer.AddString("LastOutput", a_CmdBlock->GetLastOutput()); - m_Writer.AddByte ("TrackOutput", 1); // TODO 2014-01-18 xdot: Figure out what TrackOutput is and save it. + m_Writer.AddByte ("TrackOutput", 1); // TODO 2014-01-18 xdot: Figure out what TrackOutput is and save it. m_Writer.EndCompound(); } diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp index 1cf99efd9..64f4cb00d 100644 --- a/src/WorldStorage/SchematicFileSerializer.cpp +++ b/src/WorldStorage/SchematicFileSerializer.cpp @@ -44,7 +44,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSchematicFileSerializer: bool cSchematicFileSerializer::LoadFromSchematicFile(cBlockArea & a_BlockArea, const AString & a_FileName) diff --git a/src/WorldStorage/ScoreboardSerializer.cpp b/src/WorldStorage/ScoreboardSerializer.cpp index 6c885bb45..da8236e0d 100644 --- a/src/WorldStorage/ScoreboardSerializer.cpp +++ b/src/WorldStorage/ScoreboardSerializer.cpp @@ -117,7 +117,7 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer) a_Writer.EndCompound(); } - a_Writer.EndList(); // Objectives + a_Writer.EndList(); // Objectives a_Writer.BeginList("PlayerScores", TAG_Compound); @@ -138,7 +138,7 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer) } } - a_Writer.EndList(); // PlayerScores + a_Writer.EndList(); // PlayerScores a_Writer.BeginList("Teams", TAG_Compound); @@ -169,7 +169,7 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer) a_Writer.EndCompound(); } - a_Writer.EndList(); // Teams + a_Writer.EndList(); // Teams a_Writer.BeginCompound("DisplaySlots"); @@ -182,9 +182,9 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer) Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::dsName); a_Writer.AddString("slot_2", (Objective == NULL) ? "" : Objective->GetName()); - a_Writer.EndCompound(); // DisplaySlots + a_Writer.EndCompound(); // DisplaySlots - a_Writer.EndCompound(); // Data + a_Writer.EndCompound(); // Data } diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 1a43cf4ba..388ad0332 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -69,7 +69,7 @@ Since only the header is actually in the memory, this number can be high, but st -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWSSAnvil: cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) : @@ -1356,7 +1356,7 @@ void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedN void cWSSAnvil::LoadMinecartRFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { - std::auto_ptr Minecart(new cRideableMinecart(0, 0, 0, cItem(), 1)); // TODO: Load the block and the height + std::auto_ptr Minecart(new cRideableMinecart(0, 0, 0, cItem(), 1)); // TODO: Load the block and the height if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx)) { return; @@ -1465,7 +1465,7 @@ void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a return; } - std::auto_ptr Pickup(new cPickup(0, 0, 0, Item, false)); // Pickup delay doesn't matter, just say false + std::auto_ptr Pickup(new cPickup(0, 0, 0, Item, false)); // Pickup delay doesn't matter, just say false if (!LoadEntityBaseFromNBT(*Pickup.get(), a_NBT, a_TagIdx)) { return; @@ -2592,7 +2592,7 @@ bool cWSSAnvil::GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, int -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWSSAnvil::cMCAFile: cWSSAnvil::cMCAFile::cMCAFile(const AString & a_FileName, int a_RegionX, int a_RegionZ) : diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index a3ba443fd..3b08c5ac5 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -48,7 +48,7 @@ const int MAX_DIRTY_CHUNKS = 16; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cJsonChunkSerializer: cJsonChunkSerializer::cJsonChunkSerializer(void) : @@ -120,7 +120,7 @@ void cJsonChunkSerializer::LightIsValid(bool a_IsLightValid) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWSSCompact: cWSSCompact::~cWSSCompact() @@ -411,7 +411,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWSSCompact::cPAKFile #define READ(Var) \ @@ -427,7 +427,7 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ m_LayerX(a_LayerX), m_LayerZ(a_LayerZ), m_NumDirty(0), - m_ChunkVersion( CHUNK_VERSION ), // Init with latest version + m_ChunkVersion( CHUNK_VERSION ), // Init with latest version m_PakVersion( PAK_VERSION ) { cFile f; @@ -486,12 +486,12 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ return; } - if( m_ChunkVersion == 1 ) // Convert chunks to version 2 + if( m_ChunkVersion == 1 ) // Convert chunks to version 2 { UpdateChunk1To2(); } #if AXIS_ORDER == AXIS_ORDER_XZY - if( m_ChunkVersion == 2 ) // Convert chunks to version 3 + if( m_ChunkVersion == 2 ) // Convert chunks to version 3 { UpdateChunk2To3(); } @@ -586,7 +586,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Offset += Header->m_CompressedSize; // Crude data integrity check: - int ExpectedSize = (16*128*16)*2 + (16*128*16)/2; // For version 1 + int ExpectedSize = (16*128*16)*2 + (16*128*16)/2; // For version 1 if (UncompressedSize < ExpectedSize) { LOGWARNING("Chunk [%d, %d] has too short decompressed data (%d bytes out of %d needed), erasing", @@ -638,7 +638,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 128; } InChunkOffset += (16 * 128 * 16); - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Metadata + for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Metadata { for( int y = 0; y < 64; ++y ) { @@ -648,7 +648,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16 * 128 * 16) / 2; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Block light + for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Block light { for( int y = 0; y < 64; ++y ) { @@ -658,7 +658,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16*128*16)/2; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Sky light + for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Sky light { for( int y = 0; y < 64; ++y ) { @@ -774,7 +774,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() #define MAKE_3_INDEX( x, y, z ) ( x + (z * 16) + (y * 16 * 16) ) unsigned int InChunkOffset = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X + for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X { ConvertedData[ MAKE_3_INDEX(x, y, z) ] = UncompressedData[InChunkOffset]; ++InChunkOffset; diff --git a/src/WorldStorage/WSSCompact.h b/src/WorldStorage/WSSCompact.h index b148005f6..83e9cb49f 100644 --- a/src/WorldStorage/WSSCompact.h +++ b/src/WorldStorage/WSSCompact.h @@ -105,15 +105,15 @@ protected: int m_NumDirty; // Number of chunks that were written into m_DataContents but not into the file - Vector3i m_ChunkSize; // Is related to m_ChunkVersion + Vector3i m_ChunkSize; // Is related to m_ChunkVersion char m_ChunkVersion; char m_PakVersion; bool SaveChunkToData(const cChunkCoords & a_Chunk, cWorld * a_World); // Saves the chunk to m_DataContents, updates headers and m_NumDirty void SynchronizeFile(void); // Writes m_DataContents along with the headers to file, resets m_NumDirty - void UpdateChunk1To2(void); // Height from 128 to 256 - void UpdateChunk2To3(void); // Axis order from YZX to XZY + void UpdateChunk1To2(void); // Height from 128 to 256 + void UpdateChunk2To3(void); // Axis order from YZX to XZY } ; typedef std::list cPAKFiles; diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index d3f35384b..b6d572f3e 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -35,7 +35,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorldStorage: cWorldStorage::cWorldStorage(void) : @@ -96,7 +96,7 @@ void cWorldStorage::WaitForFinish(void) // Wait for the thread to finish: m_ShouldTerminate = true; - m_Event.Set(); // Wake up the thread if waiting + m_Event.Set(); // Wake up the thread if waiting super::Wait(); LOG("World storage thread finished"); } diff --git a/src/XMLParser.h b/src/XMLParser.h index 28fa05579..e39405529 100644 --- a/src/XMLParser.h +++ b/src/XMLParser.h @@ -55,7 +55,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // The following template has been modified from code available at // http://www.codeproject.com/Articles/1847/C-Wrappers-for-the-Expat-XML-Parser // It uses templates to remove the virtual function call penalty (both size and speed) for each callback diff --git a/src/main.cpp b/src/main.cpp index f485d8f8f..0ff9361be 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -88,7 +88,7 @@ void NonCtrlHandler(int a_Signal) #if defined(_WIN32) && !defined(_WIN64) && defined(_MSC_VER) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Windows 32-bit stuff: when the server crashes, create a "dump file" containing the callstack of each thread and some variables; let the user send us that crash file for analysis typedef BOOL (WINAPI *pMiniDumpWriteDump)( @@ -171,7 +171,7 @@ BOOL CtrlHandler(DWORD fdwCtrlType) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // main: int main( int argc, char **argv ) -- cgit v1.2.3 From a02509ff4b29a03fd396ff62a2b19ac96f71ef39 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:19:52 +0200 Subject: Initial version of a script to check basic style. This script reports basic violations of the style, such as indentation using spaces, alignment using tabs, trailing whitespace etc. Passing this script does NOT mean that the style is clean, it's only for fast-checking purposes. --- src/CheckBasicStyle.lua | 188 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 src/CheckBasicStyle.lua (limited to 'src') diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua new file mode 100644 index 000000000..f9bb41975 --- /dev/null +++ b/src/CheckBasicStyle.lua @@ -0,0 +1,188 @@ + +-- CheckBasicStyle.lua + +--[[ +Checks that all source files (*.cpp, *.h) use the basic style requirements of the project: + - Tabs for indentation, spaces for alignment + - Trailing whitespace on non-empty lines + - Two spaces between code and line-end comment ("//") + - (TODO) Spaces around +, -, (cannot check /, * or & due to their other usage - comment, ptr deref, address-of) + - (TODO) Spaces before *, /, & + - (TODO) Spaces after , + - (TODO) Hex numbers with even digit length + - (TODO) Hex numbers in lowercase + - (TODO) Braces not on the end of line + - (TODO) Line dividers (////...) exactly 80 slashes + +Reports all violations on stdout in a form that is readable by Visual Studio's parser, so that dblclicking +the line brings the editor directly to the violation. + +Returns 0 on success, 1 on internal failure, 2 if any violations found + +This script requires LuaFileSystem to be available in the current Lua interpreter. +--]] + + + + + +-- Check that LFS is installed: +local hasLfs = pcall(require, "lfs") +if not(hasLfs) then + print("This script requires LuaFileSystem to be installed") + os.exit(1) +end +local lfs = require("lfs") +assert(lfs ~= nil) + + + + + +-- The list of file extensions that are processed: +local g_ShouldProcessExt = +{ + ["h"] = true, + ["cpp"] = true, +} + +--- The list of files not to be processed: +local g_IgnoredFiles = +{ + "./Bindings/Bindings.cpp", + "./Bindings/DeprecatedBindings.cpp", + "./LeakFinder.cpp", + "./LeakFinder.h", + "./MersenneTwister.h", + "./StackWalker.cpp", + "./StackWalker.h", +} + +--- The list of files not to be processed, as a dictionary (filename => true), built from g_IgnoredFiles +local g_ShouldIgnoreFile = {} + +-- Initialize the g_ShouldIgnoreFile map: +for _, fnam in ipairs(g_IgnoredFiles) do + g_ShouldIgnoreFile[fnam] = true +end + +--- Keeps track of the number of violations for this folder +local g_NumViolations = 0 + + + + + +--- Reports one violation +-- Pretty-prints the message +-- Also increments g_NumViolations +local function ReportViolation(a_FileName, a_LineNumber, a_Message) + print(a_FileName .. "(" .. a_LineNumber .. "): " .. a_Message) + g_NumViolations = g_NumViolations + 1 +end + + + + + +--- Processes one file +local function ProcessFile(a_FileName) + assert(type(a_FileName) == "string") + + -- Read the whole file: + local f, err = io.open(a_FileName, "r") + if (f == nil) then + print("Cannot open file \"" .. a_FileName .. "\": " .. err) + print("Aborting") + os.exit(1) + end + local all = f:read("*all") + + -- Check that the last line is empty - otherwise processing won't work properly: + local lastChar = string.byte(all, string.len(all)) + if ((lastChar ~= 13) and (lastChar ~= 10)) then + local numLines = 1 + string.gsub(all, "\n", function() numLines = numLines + 1 end) -- Count the number of line-ends + ReportViolation(a_FileName, numLines, "Missing empty line at file end") + return + end + + -- Process each line separately: + -- Ref.: http://stackoverflow.com/questions/10416869/iterate-over-possibly-empty-lines-in-a-way-that-matches-the-expectations-of-exis + local lineCounter = 1 + all:gsub("\r\n", "\n") -- normalize CRLF into LF-only + string.gsub(all .. "\n", "[^\n]*\n", -- Iterate over each line, while preserving empty lines + function(a_Line) + -- Check against indenting using spaces: + if (a_Line:find("^\t* +")) then -- Find any number of tabs at the start of line (incl 0), followed by a space + ReportViolation(a_FileName, lineCounter, "Indenting with a space") + end + -- Check against alignment using tabs: + if (a_Line:find("[^%s]\t+[^%s]")) then -- Find any number of tabs after non-whitespace followed by non-whitespace + ReportViolation(a_FileName, lineCounter, "Aligning with a tab") + end + -- Check against trailing whitespace: + if (a_Line:find("[^%s]%s+\n")) then -- Find any whitespace after non-whitespace at the end of line + ReportViolation(a_FileName, lineCounter, "Trailing whitespace") + end + -- Check that all "//"-style comments have at least two spaces in front (unless alone on line): + if (a_Line:find("[^%s] //")) then + ReportViolation(a_FileName, lineCounter, "Needs at least two spaces in front of a \"//\"-style comment") + end + -- Check that all "//"-style comments have at least one spaces after: + if (a_Line:find("%s//[^%s/*<]")) then + ReportViolation(a_FileName, lineCounter, "Needs a space after a \"//\"-style comment") + end + lineCounter = lineCounter + 1 + end + ) +end + + + + + +--- Processes one item - a file or a folder +local function ProcessItem(a_ItemName) + assert(type(a_ItemName) == "string") + + -- Skip files / folders that should be ignored + if (g_ShouldIgnoreFile[a_ItemName]) then + return + end + + -- If the item is a folder, recurse: + local attrs = lfs.attributes(a_ItemName) + if (attrs and (attrs.mode == "directory")) then + for fnam in lfs.dir(a_ItemName) do + if ((fnam ~= ".") and (fnam ~= "..")) then + ProcessItem(a_ItemName .. "/" .. fnam) + end + end + return + end + + local ext = a_ItemName:match("%.([^/%.]-)$") + if (g_ShouldProcessExt[ext]) then + ProcessFile(a_ItemName) + end +end + + + + + +-- Process the entire current folder: +ProcessItem(".") + +-- Report final verdict: +print("Number of violations found: " .. g_NumViolations) +if (g_NumViolations > 0) then + os.exit(2) +else + os.exit(0) +end + + + + -- cgit v1.2.3 From 52d4c49d5cd2c15078c84a18821761b723833584 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 17 Jul 2014 22:32:23 +0200 Subject: Fixed many slime bugs. - Fixed slime hurt/death sound - Added slime spawning on death. - Fixed the max health. - Fixed the attack damage. - Little slimes should not attack players. --- src/Entities/Entity.cpp | 5 +--- src/Mobs/Slime.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++++- src/Mobs/Slime.h | 8 ++++-- 3 files changed, 74 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 4a6de25b7..3433258fd 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1146,10 +1146,7 @@ void cEntity::SetMaxHealth(int a_MaxHealth) m_MaxHealth = a_MaxHealth; // Reset health, if too high: - if (m_Health > a_MaxHealth) - { - m_Health = a_MaxHealth; - } + m_Health = std::min(m_Health, a_MaxHealth); } diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp index 52a52bb39..d74b66e5b 100644 --- a/src/Mobs/Slime.cpp +++ b/src/Mobs/Slime.cpp @@ -2,6 +2,8 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Slime.h" +#include "FastRandom.h" +#include "World.h" @@ -9,9 +11,11 @@ /// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest cSlime::cSlime(int a_Size) : - super("Slime", mtSlime, "mob.slime.attack", "mob.slime.attack", 0.6 * a_Size, 0.6 * a_Size), + super("Slime", mtSlime, Printf("mob.slime.%s", GetSizeName(a_Size).c_str()), Printf("mob.slime.%s", GetSizeName(a_Size).c_str()), 0.6 * a_Size, 0.6 * a_Size), m_Size(a_Size) { + SetMaxHealth(a_Size * a_Size); + SetAttackDamage(a_Size); } @@ -25,6 +29,7 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); } + if (GetSize() == 1) { AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SLIMEBALL); @@ -34,3 +39,64 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer) + +void cSlime::Attack(float a_Dt) +{ + if (m_Size != 1) + { + // Only slimes with the size 2 and 3 attacks a player. + super::Attack(a_Dt); + } +} + + + + + +void cSlime::KilledBy(TakeDamageInfo & a_TDI) +{ + if (GetHealth() > 0) + { + return; + } + + if (m_Size != 1) + { + cFastRandom Random; + int SpawnAmount = 2 + Random.NextInt(3); + + for (int i = 0; i < SpawnAmount; ++i) + { + double AddX = (i % 2 - 0.5) * m_Size / 4.0; + double AddZ = (i / 2 - 0.5) * m_Size / 4.0; + + cSlime * NewSlime = new cSlime(m_Size / 2); + NewSlime->SetPosition(GetPosX() + AddX, GetPosY() + 0.5, GetPosZ() + AddZ); + NewSlime->SetYaw(Random.NextFloat(2.0f) * 360.0f); + NewSlime->SetPitch(0.0f); + + m_World->SpawnMobFinalize(NewSlime); + } + } + super::KilledBy(a_TDI); +} + + + + + +const AString & cSlime::GetSizeName(int a_Size) +{ + if (a_Size > 1) + { + return "big"; + } + else + { + return "small"; + } +} + + + + diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h index 782c3113f..1f66d9afb 100644 --- a/src/Mobs/Slime.h +++ b/src/Mobs/Slime.h @@ -13,17 +13,21 @@ class cSlime : typedef cAggressiveMonster super; public: - /// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest + /** Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest */ cSlime(int a_Size); CLASS_PROTODEF(cSlime); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + virtual void Attack(float a_Dt) override; + virtual void KilledBy(TakeDamageInfo & a_TDI) override; + int GetSize(void) const { return m_Size; } + const AString & GetSizeName(int a_Size); protected: - /// Size of the slime, 1 .. 3, with 1 being the smallest + /** Size of the slime, 1 .. 3, with 1 being the smallest */ int m_Size; } ; -- cgit v1.2.3 From 5e198c673009cf8ca9d92cf59848999bc96bbc37 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:50:58 +0200 Subject: Basic style fixes. --- src/Bindings/ManualBindings.cpp | 27 +++++++++++------------ src/Bindings/Plugin.h | 7 ++---- src/Bindings/PluginLua.cpp | 14 ++++++------ src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 2 +- src/Bindings/PluginManager.h | 24 ++++++++++++--------- src/Bindings/WebPlugin.cpp | 20 ++++++++++------- src/BlockEntities/BeaconEntity.cpp | 2 +- src/BlockEntities/ChestEntity.cpp | 2 +- src/BlockEntities/CommandBlockEntity.h | 2 +- src/BlockEntities/DropSpenserEntity.cpp | 2 +- src/BlockEntities/EnderChestEntity.h | 4 ++-- src/BlockEntities/FlowerPotEntity.h | 2 +- src/BlockEntities/JukeboxEntity.h | 2 +- src/BlockEntities/MobHeadEntity.h | 2 +- src/BlockEntities/NoteEntity.h | 2 +- src/BlockEntities/SignEntity.h | 2 +- src/Blocks/BlockAnvil.h | 2 +- src/Blocks/BlockBed.cpp | 4 ++-- src/Blocks/BlockBigFlower.h | 4 ++-- src/Blocks/BlockButton.h | 2 +- src/Blocks/BlockCarpet.h | 2 +- src/Blocks/BlockChest.h | 4 ++-- src/Blocks/BlockCrops.h | 2 +- src/Blocks/BlockDoor.cpp | 4 ++-- src/Blocks/BlockDoor.h | 2 +- src/Blocks/BlockDropSpenser.h | 2 +- src/Blocks/BlockFenceGate.h | 2 +- src/Blocks/BlockFluid.h | 2 +- src/Blocks/BlockFurnace.h | 4 ++-- src/Blocks/BlockHandler.cpp | 4 ++-- src/Blocks/BlockHandler.h | 22 +++++++++---------- src/Blocks/BlockHopper.h | 2 +- src/Blocks/BlockIce.h | 2 +- src/Blocks/BlockLeaves.h | 8 +++---- src/Blocks/BlockLever.h | 2 +- src/Blocks/BlockMobHead.h | 4 ++-- src/Blocks/BlockPiston.cpp | 2 +- src/Blocks/BlockPiston.h | 4 ++-- src/Blocks/BlockPlanks.h | 2 +- src/Blocks/BlockPortal.h | 2 +- src/Blocks/BlockPumpkin.h | 4 ++-- src/Blocks/BlockQuartz.h | 2 +- src/Blocks/BlockRail.h | 22 +++++++++---------- src/Blocks/BlockSideways.h | 2 +- src/Blocks/BlockSign.h | 2 +- src/Blocks/BlockSlab.h | 2 +- src/Blocks/BlockSnow.h | 2 +- src/Blocks/BlockStairs.h | 2 +- src/Blocks/BlockTorch.h | 2 +- src/Blocks/BlockVine.h | 2 +- src/Blocks/BroadcastInterface.h | 2 +- src/Blocks/ChunkInterface.h | 2 +- src/Blocks/ClearMetaOnDrop.h | 2 +- src/Blocks/MetaRotator.h | 6 +++--- src/Blocks/WorldInterface.h | 2 +- src/Entities/ArrowEntity.cpp | 4 ++-- src/Entities/Boat.cpp | 2 +- src/Entities/Entity.cpp | 30 +++++++++++++------------- src/Entities/Entity.h | 2 +- src/Entities/Minecart.h | 2 +- src/Entities/Player.cpp | 10 ++++----- src/Entities/Player.h | 4 ++-- src/Entities/ProjectileEntity.h | 4 ++-- src/Generating/ChunkDesc.h | 2 +- src/Generating/CompoGen.cpp | 4 ++-- src/Generating/ComposableGenerator.cpp | 6 +++--- src/Generating/FinishGen.cpp | 4 ++-- src/Generating/HeiGen.cpp | 2 +- src/Generating/PieceGenerator.cpp | 2 +- src/Generating/PieceGenerator.h | 4 ++-- src/Generating/Prefab.cpp | 2 +- src/Generating/Prefab.h | 2 +- src/Generating/StructGen.cpp | 14 ++++++------ src/Generating/Trees.cpp | 8 +++---- src/HTTPServer/HTTPMessage.cpp | 2 +- src/Items/ItemBed.h | 2 +- src/Items/ItemBrewingStand.h | 2 +- src/Items/ItemCake.h | 2 +- src/Items/ItemCauldron.h | 2 +- src/Items/ItemComparator.h | 2 +- src/Items/ItemDoor.h | 6 +++--- src/Items/ItemFishingRod.h | 2 +- src/Items/ItemFlowerPot.h | 2 +- src/Items/ItemHandler.cpp | 6 +++--- src/Items/ItemHandler.h | 4 ++-- src/Items/ItemLeaves.h | 2 +- src/Items/ItemMobHead.h | 2 +- src/Items/ItemNetherWart.h | 2 +- src/Items/ItemRedstoneDust.h | 2 +- src/Items/ItemRedstoneRepeater.h | 2 +- src/Items/ItemSapling.h | 2 +- src/Items/ItemSeeds.h | 4 ++-- src/Items/ItemSign.h | 2 +- src/Items/ItemSugarcane.h | 2 +- src/Mobs/AggressiveMonster.cpp | 2 +- src/Mobs/Monster.cpp | 6 +++--- src/Mobs/Monster.h | 8 +++---- src/Mobs/Villager.cpp | 2 +- src/OSSupport/CriticalSection.cpp | 4 ++-- src/OSSupport/CriticalSection.h | 2 +- src/OSSupport/Queue.h | 4 ++-- src/OSSupport/Socket.cpp | 4 ++-- src/Protocol/Authenticator.cpp | 2 +- src/Protocol/Protocol125.cpp | 4 ++-- src/Protocol/Protocol132.cpp | 2 +- src/Protocol/Protocol17x.cpp | 2 +- src/Protocol/ProtocolRecognizer.cpp | 6 +++--- src/Protocol/ProtocolRecognizer.h | 2 +- src/Simulator/DelayedFluidSimulator.cpp | 2 +- src/Simulator/DelayedFluidSimulator.h | 2 +- src/Simulator/FireSimulator.cpp | 4 ++-- src/Simulator/FloodyFluidSimulator.cpp | 10 ++++----- src/Simulator/IncrementalRedstoneSimulator.cpp | 14 ++++++------ src/Simulator/NoopFluidSimulator.h | 2 +- src/Simulator/NoopRedstoneSimulator.h | 2 +- src/Simulator/SandSimulator.h | 2 +- src/Simulator/Simulator.h | 2 +- src/Simulator/VaporizeFluidSimulator.cpp | 2 +- src/UI/SlotArea.cpp | 6 +++--- src/UI/Window.cpp | 2 +- src/UI/Window.h | 6 +++--- src/UI/WindowOwner.h | 2 +- src/WorldStorage/FastNBT.cpp | 4 ++-- src/WorldStorage/FastNBT.h | 6 +++--- src/WorldStorage/FireworksSerializer.cpp | 4 ++-- src/WorldStorage/WSSAnvil.cpp | 12 +++++------ src/WorldStorage/WSSCompact.cpp | 12 +++++------ src/WorldStorage/WorldStorage.cpp | 2 +- src/WorldStorage/WorldStorage.h | 4 ++-- 130 files changed, 290 insertions(+), 286 deletions(-) (limited to 'src') diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index bb059193b..530101d47 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -33,9 +33,7 @@ -/**************************** - * Better error reporting for Lua - **/ +// Better error reporting for Lua static int tolua_do_error(lua_State* L, const char * a_pMsg, tolua_Error * a_pToLuaError) { // Retrieve current function name @@ -81,10 +79,7 @@ static int lua_do_error(lua_State* L, const char * a_pFormat, ...) -/**************************** - * Lua bound functions with special return types - **/ - +// Lua bound functions with special return types static int tolua_StringSplit(lua_State * tolua_S) { cLuaState LuaState(tolua_S); @@ -557,10 +552,12 @@ static int tolua_DoWithXYZ(lua_State* tolua_S) -template< class Ty1, - class Ty2, - bool (Ty1::*Func1)(int, int, cItemCallback &) > -static int tolua_ForEachInChunk(lua_State* tolua_S) +template< + class Ty1, + class Ty2, + bool (Ty1::*Func1)(int, int, cItemCallback &) +> +static int tolua_ForEachInChunk(lua_State * tolua_S) { int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */ if ((NumArgs != 3) && (NumArgs != 4)) @@ -651,9 +648,11 @@ static int tolua_ForEachInChunk(lua_State* tolua_S) -template< class Ty1, - class Ty2, - bool (Ty1::*Func1)(cItemCallback &) > +template< + class Ty1, + class Ty2, + bool (Ty1::*Func1)(cItemCallback &) +> static int tolua_ForEach(lua_State * tolua_S) { int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */ diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 0a0534724..fc8aa1cdb 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -42,10 +42,7 @@ public: // Called each tick virtual void Tick(float a_Dt) = 0; - /** - * On all these functions, return true if you want to override default behavior and not call other plugins on that callback. - * You can also return false, so default behavior is used. - **/ + /** Calls the specified hook with the params given. Returns the bool that the hook callback returns.*/ virtual bool OnBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) = 0; virtual bool OnBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) = 0; virtual bool OnChat (cPlayer * a_Player, AString & a_Message) = 0; @@ -152,7 +149,7 @@ private: int m_Version; AString m_Directory; -}; // tolua_export +}; // tolua_export diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index f69435370..5fa8adc66 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -78,7 +78,7 @@ bool cPluginLua::Initialize(void) { cCSLock Lock(m_CriticalSection); if (!m_LuaState.IsValid()) - { + { m_LuaState.Create(); m_LuaState.RegisterAPILibs(); @@ -1015,7 +1015,7 @@ bool cPluginLua::OnPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, int a_Block -bool cPluginLua::OnPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) +bool cPluginLua::OnPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { cCSLock Lock(m_CriticalSection); bool res = false; @@ -1294,8 +1294,8 @@ bool cPluginLua::OnTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a_TDI) bool cPluginLua::OnUpdatedSign( - cWorld * a_World, - int a_BlockX, int a_BlockY, int a_BlockZ, + cWorld * a_World, + int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player ) @@ -1319,8 +1319,8 @@ bool cPluginLua::OnUpdatedSign( bool cPluginLua::OnUpdatingSign( - cWorld * a_World, - int a_BlockX, int a_BlockY, int a_BlockZ, + cWorld * a_World, + int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player ) @@ -1517,7 +1517,7 @@ bool cPluginLua::CanAddOldStyleHook(int a_HookType) return true; } - LOGWARNING("Plugin %s wants to add a hook (%d), but it doesn't provide the callback function \"%s\" for it. The plugin need not work properly.", + LOGWARNING("Plugin %s wants to add a hook (%d), but it doesn't provide the callback function \"%s\" for it. The plugin need not work properly.", GetName().c_str(), a_HookType, FnName ); m_LuaState.LogStackTrace(); diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 4a9634c09..b2979a210 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -145,7 +145,7 @@ public: // cWebPlugin and WebAdmin stuff virtual AString HandleWebRequest(const HTTPRequest * a_Request ) override; - bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // >> EXPORTED IN MANUALBINDINGS << + bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // >> EXPORTED IN MANUALBINDINGS << /** Binds the command to call the function specified by a Lua function reference. Simply adds to CommandMap. */ void BindCommand(const AString & a_Command, int a_FnRef); diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 6b5e60dcc..2c0ce701b 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1486,7 +1486,7 @@ bool cPluginManager::DisablePlugin(const AString & a_PluginName) if (itr->first.compare(a_PluginName) == 0) // _X 2013_02_01: wtf? Isn't this supposed to be what find() does? { m_DisablePluginList.push_back(itr->second); - itr->second = NULL; // Get rid of this thing right away + itr->second = NULL; // Get rid of this thing right away return true; } return false; diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index bf181a55f..cffd8d04b 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -51,10 +51,12 @@ class cBlockEntityWithItems; -class cPluginManager // tolua_export -{ // tolua_export -public: // tolua_export - +// tolua_begin +class cPluginManager +{ +public: + // tolua_end + // Called each tick virtual void Tick(float a_Dt); @@ -157,15 +159,17 @@ public: // tolua_export /** Returns the instance of the Plugin Manager (there is only ever one) */ - static cPluginManager * Get(void); // tolua_export + static cPluginManager * Get(void); // tolua_export typedef std::map< AString, cPlugin * > PluginMap; typedef std::list< cPlugin * > PluginList; - cPlugin * GetPlugin( const AString & a_Plugin ) const; // tolua_export - const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS << + cPlugin * GetPlugin( const AString & a_Plugin ) const; // tolua_export + const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS << - void FindPlugins(); // tolua_export - void ReloadPlugins(); // tolua_export + // tolua_begin + void FindPlugins(); + void ReloadPlugins(); + // tolua_end /** Adds the plugin to the list of plugins called for the specified hook type. Handles multiple adds as a single add */ void AddHook(cPlugin * a_Plugin, int a_HookType); @@ -335,7 +339,7 @@ private: bool AddPlugin(cPlugin * a_Plugin); /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns crExecuted if the command is executed. */ - cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions); + cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions); } ; // tolua_export diff --git a/src/Bindings/WebPlugin.cpp b/src/Bindings/WebPlugin.cpp index bc1a9ac8c..57ed9f6a4 100644 --- a/src/Bindings/WebPlugin.cpp +++ b/src/Bindings/WebPlugin.cpp @@ -64,27 +64,27 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest std::pair< AString, AString > Names; AStringVector Split = StringSplit(a_Request->Path, "/"); - if( Split.size() > 1 ) + if (Split.size() > 1) { - sWebPluginTab* Tab = 0; - if( Split.size() > 2 ) // If we got the tab name, show that page + sWebPluginTab * Tab = NULL; + if (Split.size() > 2) // If we got the tab name, show that page { for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) { - if( (*itr)->SafeTitle.compare( Split[2] ) == 0 ) // This is the one! Rawr + if ((*itr)->SafeTitle.compare(Split[2]) == 0) // This is the one! { Tab = *itr; break; } } } - else // Otherwise show the first tab + else // Otherwise show the first tab { if( GetTabs().size() > 0 ) Tab = *GetTabs().begin(); } - if( Tab ) + if (Tab != NULL) { Names.first = Tab->Title; Names.second = Tab->SafeTitle; @@ -97,13 +97,13 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest -AString cWebPlugin::SafeString( const AString & a_String ) +AString cWebPlugin::SafeString(const AString & a_String) { AString RetVal; for( unsigned int i = 0; i < a_String.size(); ++i ) { char c = a_String[i]; - if( c == ' ' ) + if( c == ' ' ) { c = '_'; } @@ -111,3 +111,7 @@ AString cWebPlugin::SafeString( const AString & a_String ) } return RetVal; } + + + + diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index 0914353eb..9a6d85f1d 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -32,7 +32,7 @@ int cBeaconEntity::GetPyramidLevel(void) } Area.Read( - m_World, + m_World, GetPosX() - 4, GetPosX() + 4, MinY, MaxY, GetPosZ() - 4, GetPosZ() + 4, diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index ca164464c..9f50365e9 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -177,7 +177,7 @@ void cChestEntity::OpenNewWindow(void) return; } - // There is no chest neighbor, open a single-chest window: + // There is no chest neighbor, open a single-chest window: OpenWindow(new cChestWindow(this)); } diff --git a/src/BlockEntities/CommandBlockEntity.h b/src/BlockEntities/CommandBlockEntity.h index 12157670f..d7c4eaabe 100644 --- a/src/BlockEntities/CommandBlockEntity.h +++ b/src/BlockEntities/CommandBlockEntity.h @@ -26,7 +26,7 @@ namespace Json // tolua_begin -class cCommandBlockEntity : +class cCommandBlockEntity : public cBlockEntity { typedef cBlockEntity super; diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp index 0fa6bbe69..dc38e3e9b 100644 --- a/src/BlockEntities/DropSpenserEntity.cpp +++ b/src/BlockEntities/DropSpenserEntity.cpp @@ -99,7 +99,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk) } m_World->BroadcastSoundParticleEffect(2000, m_PosX, m_PosY, m_PosZ, SmokeDir); m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f); -} +} diff --git a/src/BlockEntities/EnderChestEntity.h b/src/BlockEntities/EnderChestEntity.h index 04af67683..ed178f6fc 100644 --- a/src/BlockEntities/EnderChestEntity.h +++ b/src/BlockEntities/EnderChestEntity.h @@ -16,10 +16,10 @@ class cEnderChestEntity : { typedef cBlockEntity super; -public: +public: // tolua_end - cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); + cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); virtual ~cEnderChestEntity(); static const char * GetClassStatic(void) { return "cEnderChestEntity"; } diff --git a/src/BlockEntities/FlowerPotEntity.h b/src/BlockEntities/FlowerPotEntity.h index e3570eb9a..85cb810ad 100644 --- a/src/BlockEntities/FlowerPotEntity.h +++ b/src/BlockEntities/FlowerPotEntity.h @@ -27,7 +27,7 @@ namespace Json // tolua_begin -class cFlowerPotEntity : +class cFlowerPotEntity : public cBlockEntity { typedef cBlockEntity super; diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h index 3d1d604f7..8bb3009eb 100644 --- a/src/BlockEntities/JukeboxEntity.h +++ b/src/BlockEntities/JukeboxEntity.h @@ -19,7 +19,7 @@ namespace Json // tolua_begin -class cJukeboxEntity : +class cJukeboxEntity : public cBlockEntity { typedef cBlockEntity super; diff --git a/src/BlockEntities/MobHeadEntity.h b/src/BlockEntities/MobHeadEntity.h index 367eb15e7..2bc072d69 100644 --- a/src/BlockEntities/MobHeadEntity.h +++ b/src/BlockEntities/MobHeadEntity.h @@ -25,7 +25,7 @@ namespace Json // tolua_begin -class cMobHeadEntity : +class cMobHeadEntity : public cBlockEntity { typedef cBlockEntity super; diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h index b698899c0..07b8fd259 100644 --- a/src/BlockEntities/NoteEntity.h +++ b/src/BlockEntities/NoteEntity.h @@ -28,7 +28,7 @@ enum ENUM_NOTE_INSTRUMENTS // tolua_begin -class cNoteEntity : +class cNoteEntity : public cBlockEntity { typedef cBlockEntity super; diff --git a/src/BlockEntities/SignEntity.h b/src/BlockEntities/SignEntity.h index 80c7bbfdf..16e0e23bc 100644 --- a/src/BlockEntities/SignEntity.h +++ b/src/BlockEntities/SignEntity.h @@ -25,7 +25,7 @@ namespace Json // tolua_begin -class cSignEntity : +class cSignEntity : public cBlockEntity { typedef cBlockEntity super; diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h index 35a356678..5c4661c11 100644 --- a/src/Blocks/BlockAnvil.h +++ b/src/Blocks/BlockAnvil.h @@ -34,7 +34,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index 32b5133c7..fbf98044c 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -116,7 +116,7 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface if (Meta & 0x8) { - // Is pillow + // Is pillow a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX, a_BlockY, a_BlockZ); } else @@ -142,7 +142,7 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface a_WorldInterface.SetTimeOfDay(0); a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xB); // Where 0xB = 1011, and zero is to make sure 'occupied' bit is always unset } - } + } } else { diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h index 39fd3cac8..ff9825a83 100644 --- a/src/Blocks/BlockBigFlower.h +++ b/src/Blocks/BlockBigFlower.h @@ -86,8 +86,8 @@ public: virtual void OnPlacedByPlayer( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) override diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index 9fc5e4626..3b45afff8 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -46,7 +46,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockCarpet.h b/src/Blocks/BlockCarpet.h index 33dc1da6c..d1aa52687 100644 --- a/src/Blocks/BlockCarpet.h +++ b/src/Blocks/BlockCarpet.h @@ -32,7 +32,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h index f899f4bcb..28adbed4f 100644 --- a/src/Blocks/BlockChest.h +++ b/src/Blocks/BlockChest.h @@ -22,7 +22,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -68,7 +68,7 @@ public: virtual void OnPlacedByPlayer( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, + cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta diff --git a/src/Blocks/BlockCrops.h b/src/Blocks/BlockCrops.h index 8606cf3f3..ae6e490e1 100644 --- a/src/Blocks/BlockCrops.h +++ b/src/Blocks/BlockCrops.h @@ -71,7 +71,7 @@ public: } } } - } + } virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp index 934a01994..e80473cb5 100644 --- a/src/Blocks/BlockDoor.cpp +++ b/src/Blocks/BlockDoor.cpp @@ -152,7 +152,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta) // Return a_Meta if panel is a top panel (0x08 bit is set to 1) // Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored - // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time, + // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time, // so the function can only see either the hinge position or orientation, but not both, at any given time. The class itself // needs extra datamembers. if (a_Meta & 0x08) return a_Meta; @@ -179,7 +179,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta) // Return a_Meta if panel is a top panel (0x08 bit is set to 1) // Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored - // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time, + // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time, // so the function can only see either the hinge position or orientation, but not both, at any given time.The class itself // needs extra datamembers. diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index 049c4a334..c86fe829b 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -28,7 +28,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockDropSpenser.h b/src/Blocks/BlockDropSpenser.h index cf240fa60..ba96c716a 100644 --- a/src/Blocks/BlockDropSpenser.h +++ b/src/Blocks/BlockDropSpenser.h @@ -24,7 +24,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockFenceGate.h b/src/Blocks/BlockFenceGate.h index e992870d4..433531275 100644 --- a/src/Blocks/BlockFenceGate.h +++ b/src/Blocks/BlockFenceGate.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockFluid.h b/src/Blocks/BlockFluid.h index d0c4ea55b..8c0aae041 100644 --- a/src/Blocks/BlockFluid.h +++ b/src/Blocks/BlockFluid.h @@ -17,7 +17,7 @@ public: : cBlockHandler(a_BlockType) { - } + } virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override diff --git a/src/Blocks/BlockFurnace.h b/src/Blocks/BlockFurnace.h index 74582c3b3..2c7310ac9 100644 --- a/src/Blocks/BlockFurnace.h +++ b/src/Blocks/BlockFurnace.h @@ -13,7 +13,7 @@ class cBlockFurnaceHandler : public cMetaRotator { public: - cBlockFurnaceHandler(BLOCKTYPE a_BlockType) + cBlockFurnaceHandler(BLOCKTYPE a_BlockType) : cMetaRotator(a_BlockType) { } @@ -27,7 +27,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index cef1f5f09..97762f9bd 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -176,7 +176,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) { switch(a_BlockType) { - // Block handlers, alphabetically sorted: + // Block handlers, alphabetically sorted: case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_ACTIVATOR_RAIL: return new cBlockRailHandler (a_BlockType); case E_BLOCK_ANVIL: return new cBlockAnvilHandler (a_BlockType); @@ -327,7 +327,7 @@ cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType) bool cBlockHandler::GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index fb6cae729..7f23fc6ff 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -30,14 +30,14 @@ public: /// Note that the coords are chunk-relative! virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ); - /** Called before a block is placed into a world. + /** Called before a block is placed into a world. The handler should return true to allow placement, false to refuse. Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block. Called by cItemHandler::GetPlacementBlockTypeMeta() if the item is a block */ virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ); @@ -47,8 +47,8 @@ public: /// Called by cClientHandle::HandlePlaceBlock() after the player has placed a new block. Called after OnPlaced(). virtual void OnPlacedByPlayer( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ); @@ -90,7 +90,7 @@ public: virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta); /** Checks if the block can be placed at this point. - Default: CanBeAt(...) + Default: CanBeAt(...) NOTE: This call doesn't actually place the block */ // virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir); @@ -98,27 +98,27 @@ public: /// Called to check whether this block supports a rclk action. If it returns true, OnUse() is called virtual bool IsUseable(void); - /** Indicates whether the client will click through this block. + /** Indicates whether the client will click through this block. For example digging a fire will hit the block below the fire so fire is clicked through */ virtual bool IsClickedThrough(void); - /** Checks if the player can build "inside" this block. + /** Checks if the player can build "inside" this block. For example blocks placed "on" snow will be placed at the same position. So: Snow ignores Build collision */ virtual bool DoesIgnoreBuildCollision(void); /// Similar to DoesIgnoreBuildCollision(void), but is used for cases where block meta/player item-in-hand is needed to determine collision (thin snow) - virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE a_Meta) - { + virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE a_Meta) + { UNUSED(a_Meta); - return DoesIgnoreBuildCollision(); + return DoesIgnoreBuildCollision(); } /// Returns if this block drops if it gets destroyed by an unsuitable situation. Default: true virtual bool DoesDropOnUnsuitable(void); - /** Called when one of the neighbors gets set; equivalent to MC block update. + /** Called when one of the neighbors gets set; equivalent to MC block update. By default drops if position no more suitable (CanBeAt(), DoesDropOnUnsuitable(), Drop()), and wakes up all simulators on the block. */ diff --git a/src/Blocks/BlockHopper.h b/src/Blocks/BlockHopper.h index a882bb077..4a5d32dd5 100644 --- a/src/Blocks/BlockHopper.h +++ b/src/Blocks/BlockHopper.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockIce.h b/src/Blocks/BlockIce.h index 8dfe7ddac..c50623594 100644 --- a/src/Blocks/BlockIce.h +++ b/src/Blocks/BlockIce.h @@ -29,7 +29,7 @@ public: // TODO: Ice destroyed with air below it should turn into air instead of water a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_WATER, 0); // This is called later than the real destroying of this ice block - } + } } ; diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 260abefc7..d0baab013 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -100,10 +100,10 @@ public: int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width; cBlockArea Area; if (!Area.Read( - a_Chunk.GetWorld(), - BlockX - LEAVES_CHECK_DISTANCE, BlockX + LEAVES_CHECK_DISTANCE, - a_RelY - LEAVES_CHECK_DISTANCE, a_RelY + LEAVES_CHECK_DISTANCE, - BlockZ - LEAVES_CHECK_DISTANCE, BlockZ + LEAVES_CHECK_DISTANCE, + a_Chunk.GetWorld(), + BlockX - LEAVES_CHECK_DISTANCE, BlockX + LEAVES_CHECK_DISTANCE, + a_RelY - LEAVES_CHECK_DISTANCE, a_RelY + LEAVES_CHECK_DISTANCE, + BlockZ - LEAVES_CHECK_DISTANCE, BlockZ + LEAVES_CHECK_DISTANCE, cBlockArea::baTypes) ) { diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h index 7ce8d038e..4316fd06b 100644 --- a/src/Blocks/BlockLever.h +++ b/src/Blocks/BlockLever.h @@ -43,7 +43,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index 301386568..ff1ef97bf 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -193,8 +193,8 @@ public: } virtual void OnPlacedByPlayer( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) override diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index 6ffb56abd..164967621 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -62,7 +62,7 @@ void cBlockPistonHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorld bool cBlockPistonHandler::GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index 307539476..bbb8af75b 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -17,7 +17,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override; @@ -75,7 +75,7 @@ public: return BLOCK_FACE_NONE; } } - } + } static void ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); static void RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); diff --git a/src/Blocks/BlockPlanks.h b/src/Blocks/BlockPlanks.h index 2a99a455e..de84ed319 100644 --- a/src/Blocks/BlockPlanks.h +++ b/src/Blocks/BlockPlanks.h @@ -18,7 +18,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index d58b2f09d..9ee5d69e2 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h index 4692a47df..15ac80fd7 100644 --- a/src/Blocks/BlockPumpkin.h +++ b/src/Blocks/BlockPumpkin.h @@ -76,14 +76,14 @@ public: a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0); // Spawn the golem: - a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem); + a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem); } } virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h index 1b1f6f9f0..2ce7e71e4 100644 --- a/src/Blocks/BlockQuartz.h +++ b/src/Blocks/BlockQuartz.h @@ -18,7 +18,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h index 6f3fa1bd5..87ce069ab 100644 --- a/src/Blocks/BlockRail.h +++ b/src/Blocks/BlockRail.h @@ -31,7 +31,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -223,7 +223,7 @@ public: case E_META_RAIL_ZM_ZP: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_DOWN) ) { @@ -235,7 +235,7 @@ public: case E_META_RAIL_XM_XP: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN) ) { @@ -247,7 +247,7 @@ public: case E_META_RAIL_ASCEND_XP: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_EAST) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_EAST) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST) ) { @@ -259,7 +259,7 @@ public: case E_META_RAIL_ASCEND_XM: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_WEST) ) { @@ -271,7 +271,7 @@ public: case E_META_RAIL_ASCEND_ZM: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ) { @@ -283,7 +283,7 @@ public: case E_META_RAIL_ASCEND_ZP: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_SOUTH) ) { @@ -295,7 +295,7 @@ public: case E_META_RAIL_CURVED_ZP_XP: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) ) { @@ -307,7 +307,7 @@ public: case E_META_RAIL_CURVED_ZP_XM: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST) ) { @@ -319,7 +319,7 @@ public: case E_META_RAIL_CURVED_ZM_XM: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST) ) { @@ -331,7 +331,7 @@ public: case E_META_RAIL_CURVED_ZM_XP: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) ) { diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h index 9cbd4cf97..f5f10899d 100644 --- a/src/Blocks/BlockSideways.h +++ b/src/Blocks/BlockSideways.h @@ -18,7 +18,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockSign.h b/src/Blocks/BlockSign.h index f5630bdb0..5aa8ade3d 100644 --- a/src/Blocks/BlockSign.h +++ b/src/Blocks/BlockSign.h @@ -59,7 +59,7 @@ public: } } return 0x2; - } + } virtual void OnPlacedByPlayer( diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 6c861be86..214445eda 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -33,7 +33,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockSnow.h b/src/Blocks/BlockSnow.h index c5ae4a5a6..27fc17e7f 100644 --- a/src/Blocks/BlockSnow.h +++ b/src/Blocks/BlockSnow.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h index e74ab0094..a7ccf1714 100644 --- a/src/Blocks/BlockStairs.h +++ b/src/Blocks/BlockStairs.h @@ -20,7 +20,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index 554ab8125..73f2bf9a8 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h index 7bb9dc484..c2d82eb4d 100644 --- a/src/Blocks/BlockVine.h +++ b/src/Blocks/BlockVine.h @@ -18,7 +18,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BroadcastInterface.h b/src/Blocks/BroadcastInterface.h index fbe72e72f..c8593c76a 100644 --- a/src/Blocks/BroadcastInterface.h +++ b/src/Blocks/BroadcastInterface.h @@ -1,7 +1,7 @@ #pragma once -class cBroadcastInterface +class cBroadcastInterface { public: virtual ~cBroadcastInterface() {} diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h index be7c2e0e5..f9cbe3a2d 100644 --- a/src/Blocks/ChunkInterface.h +++ b/src/Blocks/ChunkInterface.h @@ -21,7 +21,7 @@ public: return m_ChunkMap->GetBlock(a_BlockX,a_BlockY,a_BlockZ); } BLOCKTYPE GetBlock(const Vector3i & a_Pos) - { + { return GetBlock(a_Pos.x, a_Pos.y, a_Pos.z); } NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ) diff --git a/src/Blocks/ClearMetaOnDrop.h b/src/Blocks/ClearMetaOnDrop.h index 3f8c33819..f2afbc6ea 100644 --- a/src/Blocks/ClearMetaOnDrop.h +++ b/src/Blocks/ClearMetaOnDrop.h @@ -4,7 +4,7 @@ // mixin for use to clear meta values when the block is converted to a pickup // Usage: inherit from this class, passing the parent class as the parameter Base -// For example to use in class Foo which should inherit Bar use +// For example to use in class Foo which should inherit Bar use // class Foo : public cClearMetaOnDrop; template diff --git a/src/Blocks/MetaRotator.h b/src/Blocks/MetaRotator.h index ad8f36183..599aa7ef9 100644 --- a/src/Blocks/MetaRotator.h +++ b/src/Blocks/MetaRotator.h @@ -47,8 +47,8 @@ NIBBLETYPE cMetaRotatorGetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT))) { if (GetSpeedY() < 2) - { + { AddSpeedY(0.2); } } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index bb584cb9e..0ff3ff102 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -74,7 +74,7 @@ cEntity::~cEntity() /* // DEBUG: - LOGD("Deleting entity %d at pos {%.2f, %.2f, %.2f} ~ [%d, %d]; ptr %p", + LOGD("Deleting entity %d at pos {%.2f, %.2f, %.2f} ~ [%d, %d]; ptr %p", m_UniqueID, m_Pos.x, m_Pos.y, m_Pos.z, (int)(m_Pos.x / cChunkDef::Width), (int)(m_Pos.z / cChunkDef::Width), @@ -1090,7 +1090,7 @@ void cEntity::HandleAir(void) { if (m_AirTickTimer < 1) { - // Damage player + // Damage player TakeDamage(dtDrowning, NULL, 1, 1, 0); // Reset timer m_AirTickTimer = DROWNING_TICKS; @@ -1382,8 +1382,8 @@ void cEntity::SetMass(double a_Mass) } else { - // Make sure that mass is not zero. 1g is the default because we - // have to choose a number. It's perfectly legal to have a mass + // Make sure that mass is not zero. 1g is the default because we + // have to choose a number. It's perfectly legal to have a mass // less than 1g as long as is NOT equal or less than zero. m_Mass = 0.001; } @@ -1469,7 +1469,7 @@ void cEntity::SetWidth(double a_Width) void cEntity::AddPosX(double a_AddPosX) { - m_Pos.x += a_AddPosX; + m_Pos.x += a_AddPosX; } @@ -1477,7 +1477,7 @@ void cEntity::AddPosX(double a_AddPosX) void cEntity::AddPosY(double a_AddPosY) { - m_Pos.y += a_AddPosY; + m_Pos.y += a_AddPosY; } @@ -1485,7 +1485,7 @@ void cEntity::AddPosY(double a_AddPosY) void cEntity::AddPosZ(double a_AddPosZ) { - m_Pos.z += a_AddPosZ; + m_Pos.z += a_AddPosZ; } @@ -1495,7 +1495,7 @@ void cEntity::AddPosition(double a_AddPosX, double a_AddPosY, double a_AddPosZ) { m_Pos.x += a_AddPosX; m_Pos.y += a_AddPosY; - m_Pos.z += a_AddPosZ; + m_Pos.z += a_AddPosZ; } @@ -1505,7 +1505,7 @@ void cEntity::AddSpeed(double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeed { m_Speed.x += a_AddSpeedX; m_Speed.y += a_AddSpeedY; - m_Speed.z += a_AddSpeedZ; + m_Speed.z += a_AddSpeedZ; WrapSpeed(); } @@ -1515,7 +1515,7 @@ void cEntity::AddSpeed(double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeed void cEntity::AddSpeedX(double a_AddSpeedX) { - m_Speed.x += a_AddSpeedX; + m_Speed.x += a_AddSpeedX; WrapSpeed(); } @@ -1525,7 +1525,7 @@ void cEntity::AddSpeedX(double a_AddSpeedX) void cEntity::AddSpeedY(double a_AddSpeedY) { - m_Speed.y += a_AddSpeedY; + m_Speed.y += a_AddSpeedY; WrapSpeed(); } @@ -1535,7 +1535,7 @@ void cEntity::AddSpeedY(double a_AddSpeedY) void cEntity::AddSpeedZ(double a_AddSpeedZ) { - m_Speed.z += a_AddSpeedZ; + m_Speed.z += a_AddSpeedZ; WrapSpeed(); } @@ -1590,7 +1590,7 @@ Vector3d cEntity::GetLookVector(void) const // Set position void cEntity::SetPosition(double a_PosX, double a_PosY, double a_PosZ) { - m_Pos.Set(a_PosX, a_PosY, a_PosZ); + m_Pos.Set(a_PosX, a_PosY, a_PosZ); } @@ -1599,7 +1599,7 @@ void cEntity::SetPosition(double a_PosX, double a_PosY, double a_PosZ) void cEntity::SetPosX(double a_PosX) { - m_Pos.x = a_PosX; + m_Pos.x = a_PosX; } @@ -1608,7 +1608,7 @@ void cEntity::SetPosX(double a_PosX) void cEntity::SetPosY(double a_PosY) { - m_Pos.y = a_PosY; + m_Pos.y = a_PosY; } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 011293233..7abe5db37 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -428,7 +428,7 @@ public: virtual void OnRightClicked(cPlayer &) {}; /// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy(). - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) { UNUSED(a_Drops); UNUSED(a_Killer); diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h index 1e60f091c..798f844ce 100644 --- a/src/Entities/Minecart.h +++ b/src/Entities/Minecart.h @@ -99,7 +99,7 @@ public: protected: cItem m_Content; - int m_Height; + int m_Height; } ; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index c4f9c59ab..7d9f6d67f 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -340,7 +340,7 @@ float cPlayer::GetXpPercentage() short int currentLevel = CalcLevelFromXp(m_CurrentXp); short int currentLevel_XpBase = XpForLevel(currentLevel); - return (float)(m_CurrentXp - currentLevel_XpBase) / + return (float)(m_CurrentXp - currentLevel_XpBase) / (float)(XpForLevel(1+currentLevel) - currentLevel_XpBase); } @@ -392,7 +392,7 @@ short cPlayer::DeltaExperience(short a_Xp_delta) m_LifetimeTotalXp += a_Xp_delta; } - LOGD("Player \"%s\" gained/lost %d experience, total is now: %d", + LOGD("Player \"%s\" gained/lost %d experience, total is now: %d", GetName().c_str(), a_Xp_delta, m_CurrentXp); // Set experience to be updated @@ -1278,7 +1278,7 @@ Vector3d cPlayer::GetThrowSpeed(double a_SpeedCoeff) const // TODO: Add a slight random change (+-0.0075 in each direction) return res * a_SpeedCoeff; -} +} @@ -1311,7 +1311,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos ) { // When attached to an entity, the client sends position packets with weird coords: // Y = -999 and X, Z = attempting to create speed, usually up to 0.03 - // We cannot test m_AttachedTo, because when deattaching, the server thinks the client is already deattached while + // We cannot test m_AttachedTo, because when deattaching, the server thinks the client is already deattached while // the client may still send more of these nonsensical packets. if (m_AttachedTo != NULL) { @@ -1889,7 +1889,7 @@ bool cPlayer::SaveToDisk() { LOGWARNING("Error writing player \"%s\" to file \"%s\" - cannot save data. Player will lose their progress. ", GetName().c_str(), SourceFile.c_str() - ); + ); return false; } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 171e9541b..0eef3e6e1 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -198,7 +198,7 @@ public: // Sets the current gamemode, doesn't check validity, doesn't send update packets to client void LoginSetGameMode(eGameMode a_GameMode); - /** Forces the player to move in the given direction. + /** Forces the player to move in the given direction. @deprecated Use SetSpeed instead. */ void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export @@ -430,7 +430,7 @@ protected: AString m_LoadedWorldName; /** Xp Level stuff */ - enum + enum { XP_TO_LEVEL15 = 255, XP_PER_LEVEL_TO15 = 17, diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index 7b045de76..e6b05714e 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -52,7 +52,7 @@ public: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace); /// Called by the physics blocktracer when the entity hits another entity - virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) + virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) { UNUSED(a_EntityHit); UNUSED(a_HitPos); @@ -89,7 +89,7 @@ public: protected: - /** A structure that stores the Entity ID and Playername of the projectile's creator + /** A structure that stores the Entity ID and Playername of the projectile's creator Used to migitate invalid pointers caused by the creator being destroyed */ struct CreatorData diff --git a/src/Generating/ChunkDesc.h b/src/Generating/ChunkDesc.h index 8edc2800b..b306b1ee5 100644 --- a/src/Generating/ChunkDesc.h +++ b/src/Generating/ChunkDesc.h @@ -186,7 +186,7 @@ public: // Accessors used by cChunkGenerator::Generator descendants: inline cChunkDef::BiomeMap & GetBiomeMap (void) { return m_BiomeMap; } inline cChunkDef::BlockTypes & GetBlockTypes (void) { return *((cChunkDef::BlockTypes *)m_BlockArea.GetBlockTypes()); } - // CANNOT, different compression! + // CANNOT, different compression! // inline cChunkDef::BlockNibbles & GetBlockMetas (void) { return *((cChunkDef::BlockNibbles *)m_BlockArea.GetBlockMetas()); } inline BlockNibbleBytes & GetBlockMetasUncompressed(void) { return *((BlockNibbleBytes *)m_BlockArea.GetBlockMetas()); } inline cChunkDef::HeightMap & GetHeightMap (void) { return m_HeightMap; } diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 160d095ed..faf2ac243 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -68,7 +68,7 @@ void cCompoGenDebugBiomes::ComposeTerrain(cChunkDesc & a_ChunkDesc) static BLOCKTYPE Blocks[] = { E_BLOCK_STONE, - E_BLOCK_COBBLESTONE, + E_BLOCK_COBBLESTONE, E_BLOCK_LOG, E_BLOCK_PLANKS, E_BLOCK_SANDSTONE, @@ -563,7 +563,7 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) { //* FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = - m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) * + m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) * m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) / 256; //*/ diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 167fbab37..09921abb0 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -234,7 +234,7 @@ void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile) { if (CacheSize < 4) { - LOGWARNING("Biomegen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d", + LOGWARNING("Biomegen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d", CacheSize, 4 ); CacheSize = 4; @@ -252,7 +252,7 @@ void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile) void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile) { bool CacheOffByDefault = false; - m_HeightGen = cTerrainHeightGen::CreateHeightGen(a_IniFile, *m_BiomeGen, m_ChunkGenerator.GetSeed(), CacheOffByDefault); + m_HeightGen = cTerrainHeightGen::CreateHeightGen(a_IniFile, *m_BiomeGen, m_ChunkGenerator.GetSeed(), CacheOffByDefault); // Add a cache, if requested: int CacheSize = a_IniFile.GetValueSetI("Generator", "HeightGenCacheSize", CacheOffByDefault ? 0 : 64); @@ -260,7 +260,7 @@ void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile) { if (CacheSize < 4) { - LOGWARNING("Heightgen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d", + LOGWARNING("Heightgen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d", CacheSize, 4 ); CacheSize = 4; diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index dd1ab045d..13871bbd8 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -214,7 +214,7 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc) // Generate small foliage (1-block): // TODO: Update heightmap with 1-block-tall foliage - for (int z = 0; z < cChunkDef::Width; z++) + for (int z = 0; z < cChunkDef::Width; z++) { int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; const float zz = (float)BlockZ; @@ -678,7 +678,7 @@ cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cI AString HeightDistribution = a_IniFile.GetValueSet(SectionName, "HeightDistribution", DefaultHeightDistribution); if (!m_HeightDistribution.SetDefString(HeightDistribution) || (m_HeightDistribution.GetSum() <= 0)) { - LOGWARNING("[%sSprings]: HeightDistribution is invalid, using the default of \"%s\".", + LOGWARNING("[%sSprings]: HeightDistribution is invalid, using the default of \"%s\".", (a_Fluid == E_BLOCK_WATER) ? "Water" : "Lava", DefaultHeightDistribution.c_str() ); diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index 537e30a31..b02e06951 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -267,7 +267,7 @@ float cHeiGenClassic::GetNoise(float x, float y) void cHeiGenClassic::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) { - for (int z = 0; z < cChunkDef::Width; z++) + for (int z = 0; z < cChunkDef::Width; z++) { const float zz = (float)(a_ChunkZ * cChunkDef::Width + z); for (int x = 0; x < cChunkDef::Width; x++) diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index fe1005dba..ae4b6e36c 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -1,7 +1,7 @@ // PieceGenerator.cpp -// Implements the cBFSPieceGenerator class and cDFSPieceGenerator class +// Implements the cBFSPieceGenerator class and cDFSPieceGenerator class // representing base classes for generating structures composed of individual "pieces" #include "Globals.h" diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index fd8576706..f06029280 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -1,7 +1,7 @@ // PieceGenerator.h -// Declares the cBFSPieceGenerator class and cDFSPieceGenerator class +// Declares the cBFSPieceGenerator class and cDFSPieceGenerator class // representing base classes for generating structures composed of individual "pieces" /* @@ -251,7 +251,7 @@ protected: const cPiece::cConnector & a_ExistingConnector, // The existing connector const Vector3i & a_ToPos, // The position on which the new connector should be placed const cPiece & a_Piece, // The new piece - const cPiece::cConnector & a_NewConnector, // The connector of the new piece + const cPiece::cConnector & a_NewConnector, // The connector of the new piece int a_NumCCWRotations, // Number of rotations for the new piece to align the connector const cPlacedPieces & a_OutPieces // All the already-placed pieces to check ); diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 7d876909a..6da3c3d10 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -181,7 +181,7 @@ void cPrefab::AddRotatedBlockAreas(void) m_BlockArea[2].CopyFrom(m_BlockArea[0]); m_BlockArea[2].MirrorXY(); m_BlockArea[2].MirrorYZ(); - } + } // 3 CCW rotations = 1 CW rotation: if ((m_AllowedRotations & 0x04) != 0) diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index 8b4e4b4ef..eb905e78e 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -183,7 +183,7 @@ protected: bool m_MoveToGround; - // cPiece overrides: + // cPiece overrides: virtual cConnectors GetConnectors(void) const override; virtual Vector3i GetSize(void) const override; virtual cCuboid GetHitBox(void) const override; diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp index 2e41243d6..5deded17d 100644 --- a/src/Generating/StructGen.cpp +++ b/src/Generating/StructGen.cpp @@ -151,7 +151,7 @@ void cStructGenTrees::GenerateSingleTree( sSetBlockVector TreeLogs, TreeOther; GetTreeImageByBiome( a_ChunkX * cChunkDef::Width + x, Height + 1, a_ChunkZ * cChunkDef::Width + z, - m_Noise, a_Seq, + m_Noise, a_Seq, a_ChunkDesc.GetBiome(x, z), TreeLogs, TreeOther ); @@ -181,7 +181,7 @@ void cStructGenTrees::GenerateSingleTree( } ApplyTreeImage(a_ChunkX, a_ChunkZ, a_ChunkDesc, TreeOther, a_OutsideOther); - ApplyTreeImage(a_ChunkX, a_ChunkZ, a_ChunkDesc, TreeLogs, a_OutsideLogs); + ApplyTreeImage(a_ChunkX, a_ChunkZ, a_ChunkDesc, TreeLogs, a_OutsideLogs); } @@ -500,7 +500,7 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a continue; } int IdxYZ = BubbleX + IdxY + (BubbleZ + z) * 16; - for (int x = -BubbleR; x <= BubbleR; x++) + for (int x = -BubbleR; x <= BubbleR; x++) { if (x * x + DistYZ < RSquared) { @@ -511,10 +511,10 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a } // for y } // for i - bubbles - // Turn air in the bottom half into liquid: + // Turn air in the bottom half into liquid: for (int y = 0; y < 4; y++) { - for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++) + for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++) { if (BlockTypes[x + z * 16 + y * 16 * 16] == E_BLOCK_AIR) { @@ -573,8 +573,8 @@ void cStructGenDirectOverhangs::GenFinish(cChunkDesc & a_ChunkDesc) // Interpolate the lowest floor: for (int z = 0; z <= 16 / INTERPOL_Z; z++) for (int x = 0; x <= 16 / INTERPOL_X; x++) { - FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = - m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, BaseY, BaseZ + INTERPOL_Z * z) * + FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = + m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, BaseY, BaseZ + INTERPOL_Z * z) * m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, BaseY, BaseZ + INTERPOL_Z * z) / 256; } // for x, z - FloorLo[] diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index 7478be69b..eac086de6 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -83,7 +83,7 @@ static const sCoords BigO4[] = // Part of Big Jungle tree -typedef struct +typedef struct { const sCoords * Coords; size_t Count; @@ -203,7 +203,7 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No { GetAppleBushImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks); } - else + else { GetJungleTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks); } @@ -598,11 +598,11 @@ void GetPineTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise } int h = a_BlockY + TrunkHeight + 2; - // Top layer - just a single leaves block: + // Top layer - just a single leaves block: a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_CONIFER)); h--; - // One more layer is above the trunk, push the central leaves: + // One more layer is above the trunk, push the central leaves: a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_CONIFER)); // Layers expanding in size, then collapsing again: diff --git a/src/HTTPServer/HTTPMessage.cpp b/src/HTTPServer/HTTPMessage.cpp index f7e8f5f30..4226352e9 100644 --- a/src/HTTPServer/HTTPMessage.cpp +++ b/src/HTTPServer/HTTPMessage.cpp @@ -139,7 +139,7 @@ AString cHTTPRequest::GetBareURL(void) const size_t cHTTPRequest::ParseRequestLine(const char * a_Data, size_t a_Size) -{ +{ m_IncomingHeaderData.append(a_Data, a_Size); size_t IdxEnd = m_IncomingHeaderData.size(); diff --git a/src/Items/ItemBed.h b/src/Items/ItemBed.h index f23d69731..94a14cf16 100644 --- a/src/Items/ItemBed.h +++ b/src/Items/ItemBed.h @@ -26,7 +26,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemBrewingStand.h b/src/Items/ItemBrewingStand.h index d5eefb855..7be57763c 100644 --- a/src/Items/ItemBrewingStand.h +++ b/src/Items/ItemBrewingStand.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemCake.h b/src/Items/ItemCake.h index 48e23ed59..d1cb091b6 100644 --- a/src/Items/ItemCake.h +++ b/src/Items/ItemCake.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemCauldron.h b/src/Items/ItemCauldron.h index 07ae12660..9617c30ef 100644 --- a/src/Items/ItemCauldron.h +++ b/src/Items/ItemCauldron.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemComparator.h b/src/Items/ItemComparator.h index 60d9c3648..fc843c186 100644 --- a/src/Items/ItemComparator.h +++ b/src/Items/ItemComparator.h @@ -24,7 +24,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemDoor.h b/src/Items/ItemDoor.h index f3677c28c..c1b439024 100644 --- a/src/Items/ItemDoor.h +++ b/src/Items/ItemDoor.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -33,8 +33,8 @@ public: a_BlockType = (m_ItemType == E_ITEM_WOODEN_DOOR) ? E_BLOCK_WOODEN_DOOR : E_BLOCK_IRON_DOOR; cChunkInterface ChunkInterface(a_World->GetChunkMap()); bool Meta = BlockHandler(a_BlockType)->GetPlacementBlockTypeMeta( - ChunkInterface, a_Player, - a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, + ChunkInterface, a_Player, + a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta ); diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index 435d8ccf4..0c07cd422 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -210,7 +210,7 @@ public: if (FishType <= 1) // Clownfish has a 2% chance of spawning { Drops.Add(cItem(E_ITEM_RAW_FISH, 1, E_META_RAW_FISH_CLOWNFISH)); - } + } else if (FishType <= 12) // Pufferfish has a 13% chance of spawning { Drops.Add(cItem(E_ITEM_RAW_FISH, 1, E_META_RAW_FISH_CLOWNFISH)); diff --git a/src/Items/ItemFlowerPot.h b/src/Items/ItemFlowerPot.h index 60bf87985..320dce997 100644 --- a/src/Items/ItemFlowerPot.h +++ b/src/Items/ItemFlowerPot.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index c261ce0e8..3e02a43fa 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -458,7 +458,7 @@ char cItemHandler::GetMaxStackSize(void) bool cItemHandler::IsTool() { // TODO: Rewrite this to list all tools specifically - return + return (m_ItemType >= 256 && m_ItemType <= 259) || (m_ItemType == 261) || (m_ItemType >= 267 && m_ItemType <= 279) @@ -525,7 +525,7 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) bool cItemHandler::GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) @@ -542,7 +542,7 @@ bool cItemHandler::GetPlacementBlockTypeMeta( cChunkInterface ChunkInterface(a_World->GetChunkMap()); return BlockH->GetPlacementBlockTypeMeta( ChunkInterface, a_Player, - a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, + a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta ); diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index b33671c2d..3ea04d1cb 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -28,7 +28,7 @@ public: virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir); /** Called when the client sends the SHOOT status in the lclk packet */ - virtual void OnItemShoot(cPlayer *, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) + virtual void OnItemShoot(cPlayer *, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) { UNUSED(a_BlockX); UNUSED(a_BlockY); @@ -97,7 +97,7 @@ public: */ virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ); diff --git a/src/Items/ItemLeaves.h b/src/Items/ItemLeaves.h index 0ed6e5e0e..f48126dc5 100644 --- a/src/Items/ItemLeaves.h +++ b/src/Items/ItemLeaves.h @@ -20,7 +20,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemMobHead.h b/src/Items/ItemMobHead.h index 5ae040282..4c36fe8d8 100644 --- a/src/Items/ItemMobHead.h +++ b/src/Items/ItemMobHead.h @@ -26,7 +26,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemNetherWart.h b/src/Items/ItemNetherWart.h index a6a9a286a..10a0864b5 100644 --- a/src/Items/ItemNetherWart.h +++ b/src/Items/ItemNetherWart.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemRedstoneDust.h b/src/Items/ItemRedstoneDust.h index 33e386b03..a2289239c 100644 --- a/src/Items/ItemRedstoneDust.h +++ b/src/Items/ItemRedstoneDust.h @@ -22,7 +22,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemRedstoneRepeater.h b/src/Items/ItemRedstoneRepeater.h index c5fb5d566..13a797d00 100644 --- a/src/Items/ItemRedstoneRepeater.h +++ b/src/Items/ItemRedstoneRepeater.h @@ -24,7 +24,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemSapling.h b/src/Items/ItemSapling.h index 61b1a32be..dbcb12be5 100644 --- a/src/Items/ItemSapling.h +++ b/src/Items/ItemSapling.h @@ -20,7 +20,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemSeeds.h b/src/Items/ItemSeeds.h index 53f5d51c3..4c9e82ae0 100644 --- a/src/Items/ItemSeeds.h +++ b/src/Items/ItemSeeds.h @@ -30,7 +30,7 @@ public: case E_ITEM_CARROT: case E_ITEM_POTATO: return true; default: return false; - } + } } virtual FoodInfo GetFoodInfo(void) override @@ -45,7 +45,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemSign.h b/src/Items/ItemSign.h index 60cf0f5f8..235a4fa93 100644 --- a/src/Items/ItemSign.h +++ b/src/Items/ItemSign.h @@ -27,7 +27,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemSugarcane.h b/src/Items/ItemSugarcane.h index e891cc367..dd2e2ece3 100644 --- a/src/Items/ItemSugarcane.h +++ b/src/Items/ItemSugarcane.h @@ -23,7 +23,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index de881f4eb..5f5b1853d 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -42,7 +42,7 @@ void cAggressiveMonster::InStateChasing(float a_Dt) MoveToPosition(m_Target->GetPosition()); } } -} +} diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 9e53284b3..df2572976 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -353,13 +353,13 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) // If enemy passive we ignore checks for player visibility InStateIdle(a_Dt); break; - } + } case CHASING: { // If we do not see a player anymore skip chasing action InStateChasing(a_Dt); break; - } + } case ESCAPING: { InStateEscaping(a_Dt); @@ -588,7 +588,7 @@ void cMonster::CheckEventSeePlayer(void) void cMonster::CheckEventLostPlayer(void) -{ +{ if (m_Target != NULL) { if ((m_Target->GetPosition() - GetPosition()).Length() > m_SightDistance) diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 96e73b45b..750040468 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -233,7 +233,7 @@ protected: AString m_SoundHurt; AString m_SoundDeath; - float m_AttackRate; + float m_AttackRate; int m_AttackDamage; int m_AttackRange; float m_AttackInterval; @@ -250,13 +250,13 @@ protected: bool m_BurnsInDaylight; /** Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops*/ - void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0); + void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0); /** Adds a item a_Item with the chance of a_Chance (in percent) to itemdrops a_Drops*/ - void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0); + void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0); /** Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel(I-III or custom) to the itemdrop a_Drops*/ - void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel); + void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel); /** Adds armor that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if piccked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop*/ void AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel); diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index d183a338f..1cdac7c74 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -55,7 +55,7 @@ void cVillager::Tick(float a_Dt, cChunk & a_Chunk) { switch (m_Type) { - case vtFarmer: + case vtFarmer: { HandleFarmerPlaceCrops(); } diff --git a/src/OSSupport/CriticalSection.cpp b/src/OSSupport/CriticalSection.cpp index 6d4afce55..5dfc8b5f9 100644 --- a/src/OSSupport/CriticalSection.cpp +++ b/src/OSSupport/CriticalSection.cpp @@ -108,7 +108,7 @@ bool cCriticalSection::IsLockedByCurrentThread(void) //////////////////////////////////////////////////////////////////////////////// // cCSLock -cCSLock::cCSLock(cCriticalSection * a_CS) +cCSLock::cCSLock(cCriticalSection * a_CS) : m_CS(a_CS) , m_IsLocked(false) { @@ -119,7 +119,7 @@ cCSLock::cCSLock(cCriticalSection * a_CS) -cCSLock::cCSLock(cCriticalSection & a_CS) +cCSLock::cCSLock(cCriticalSection & a_CS) : m_CS(&a_CS) , m_IsLocked(false) { diff --git a/src/OSSupport/CriticalSection.h b/src/OSSupport/CriticalSection.h index 73a71f5e1..c3c6e57f0 100644 --- a/src/OSSupport/CriticalSection.h +++ b/src/OSSupport/CriticalSection.h @@ -47,7 +47,7 @@ class cCSLock cCriticalSection * m_CS; // Unlike a cCriticalSection, this object should be used from a single thread, therefore access to m_IsLocked is not threadsafe - // In Windows, it is an error to call cCriticalSection::Unlock() multiple times if the lock is not held, + // In Windows, it is an error to call cCriticalSection::Unlock() multiple times if the lock is not held, // therefore we need to check this value whether we are locked or not. bool m_IsLocked; diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index beb6a63f1..269f9db41 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -21,7 +21,7 @@ cQueueFuncs and is used as the default behavior. /// This empty struct allows for the callback functions to be inlined template -struct cQueueFuncs +struct cQueueFuncs { public: @@ -88,7 +88,7 @@ public: cCSLock Lock(m_CS); if (m_Contents.size() == 0) { - return false; + return false; } item = m_Contents.front(); m_Contents.pop_front(); diff --git a/src/OSSupport/Socket.cpp b/src/OSSupport/Socket.cpp index 56835b518..7d4d9e598 100644 --- a/src/OSSupport/Socket.cpp +++ b/src/OSSupport/Socket.cpp @@ -244,7 +244,7 @@ cSocket cSocket::AcceptIPv6(void) // Windows XP doesn't have inet_ntop, so we need to improvise. And MSVC has different headers than GCC #ifdef _MSC_VER // MSVC version - Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x", + Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x", from.sin6_addr.u.Word[0], from.sin6_addr.u.Word[1], from.sin6_addr.u.Word[2], @@ -256,7 +256,7 @@ cSocket cSocket::AcceptIPv6(void) ); #else // _MSC_VER // MinGW - Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x", + Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x", from.sin6_addr.s6_addr16[0], from.sin6_addr.s6_addr16[1], from.sin6_addr.s6_addr16[2], diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index 001bc29cf..18924db2f 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -248,7 +248,7 @@ bool cAuthenticator::SecureGetFromAddress(const AString & a_CACerts, const AStri bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID, Json::Value & a_Properties) { - LOGD("Trying to authenticate user %s", a_UserName.c_str()); + LOGD("Trying to authenticate user %s", a_UserName.c_str()); // Create the GET request: AString ActualAddress = m_Address; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 325218d88..e2960d0c3 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -398,7 +398,7 @@ void cProtocol125::SendEntityMetadata(const cEntity & a_Entity) else { WriteEntityMetadata(a_Entity); - } + } WriteByte(0x7f); Flush(); @@ -2110,7 +2110,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) int Appearance = 0; Appearance = ((const cHorse &)a_Mob).GetHorseColor(); // Mask FF Appearance |= ((const cHorse &)a_Mob).GetHorseStyle() * 256; // Mask FF00, so multiply by 256 - WriteInt(Appearance); + WriteInt(Appearance); WriteByte(0x56); WriteInt(((const cHorse &)a_Mob).GetHorseArmour()); // Horshey armour diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index a92ae83da..8502702e8 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -382,7 +382,7 @@ void cProtocol132::SendUnloadChunk(int a_ChunkX, int a_ChunkZ) void cProtocol132::SendWholeInventory(const cWindow & a_Window) { - // 1.3.2 requires player inventory slots to be sent as SetSlot packets, + // 1.3.2 requires player inventory slots to be sent as SetSlot packets, // otherwise it sometimes fails to update the window // Send the entire window: diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 36d1f4af4..45cda944b 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1026,7 +1026,7 @@ void cProtocol172::SendExperienceOrb(const cExpOrb & a_ExpOrb) { ASSERT(m_State == 3); // In game mode? - cPacketizer Pkt(*this, 0x11); + cPacketizer Pkt(*this, 0x11); Pkt.WriteVarInt(a_ExpOrb.GetUniqueID()); Pkt.WriteInt((int) a_ExpOrb.GetPosX()); Pkt.WriteInt((int) a_ExpOrb.GetPosY()); diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 29f4576cd..d3aae65fe 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -1,7 +1,7 @@ // ProtocolRecognizer.cpp -// Implements the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple +// Implements the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple // protocol versions and redirects everything to them #include "Globals.h" @@ -828,7 +828,7 @@ void cProtocolRecognizer::SendData(const char * a_Data, size_t a_Size) bool cProtocolRecognizer::TryRecognizeProtocol(void) { - // NOTE: If a new protocol is added or an old one is removed, adjust MCS_CLIENT_VERSIONS and + // NOTE: If a new protocol is added or an old one is removed, adjust MCS_CLIENT_VERSIONS and // MCS_PROTOCOL_VERSIONS macros in the header file, as well as PROTO_VERSION_LATEST macro // The first packet should be a Handshake, 0x02: @@ -1021,7 +1021,7 @@ void cProtocolRecognizer::SendLengthlessServerPing(void) case PROTO_VERSION_1_3_2: { // http://wiki.vg/wiki/index.php?title=Protocol&oldid=3099#Server_List_Ping_.280xFE.29 - Printf(Reply, "%s%s%i%s%i", + Printf(Reply, "%s%s%i%s%i", Server->GetDescription().c_str(), cChatColor::Delimiter.c_str(), Server->GetNumPlayers(), diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 25c60a72e..6bfd73d74 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -1,7 +1,7 @@ // ProtocolRecognizer.h -// Interfaces to the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple +// Interfaces to the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple // protocol versions and redirects everything to them diff --git a/src/Simulator/DelayedFluidSimulator.cpp b/src/Simulator/DelayedFluidSimulator.cpp index 884069b21..59ea51aa0 100644 --- a/src/Simulator/DelayedFluidSimulator.cpp +++ b/src/Simulator/DelayedFluidSimulator.cpp @@ -131,7 +131,7 @@ void cDelayedFluidSimulator::Simulate(float a_Dt) void cDelayedFluidSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) -{ +{ void * ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData(); cDelayedFluidSimulatorChunkData * ChunkData = (cDelayedFluidSimulatorChunkData *)ChunkDataRaw; cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_SimSlotNum]; diff --git a/src/Simulator/DelayedFluidSimulator.h b/src/Simulator/DelayedFluidSimulator.h index c81500741..fe59f6dd6 100644 --- a/src/Simulator/DelayedFluidSimulator.h +++ b/src/Simulator/DelayedFluidSimulator.h @@ -50,7 +50,7 @@ class cDelayedFluidSimulator : { typedef cFluidSimulator super; -public: +public: cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay); // cSimulator overrides: diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp index 1ad4f2654..9433a8c68 100644 --- a/src/Simulator/FireSimulator.cpp +++ b/src/Simulator/FireSimulator.cpp @@ -306,14 +306,14 @@ void cFireSimulator::TrySpreadFire(cChunk * a_Chunk, int a_RelX, int a_RelY, int // No need to check the coords for equality with the parent block, // it cannot catch fire anyway (because it's not an air block) - if (m_World.GetTickRandomNumber(MAX_CHANCE_FLAMMABILITY) > m_Flammability) + if (m_World.GetTickRandomNumber(MAX_CHANCE_FLAMMABILITY) > m_Flammability) { continue; } // Start the fire in the neighbor {x, y, z} /* - FLOG("FS: Trying to start fire at {%d, %d, %d}.", + FLOG("FS: Trying to start fire at {%d, %d, %d}.", x + a_Chunk->GetPosX() * cChunkDef::Width, y, z + a_Chunk->GetPosZ() * cChunkDef::Width ); */ diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp index d8de19871..2c5c4b658 100644 --- a/src/Simulator/FloodyFluidSimulator.cpp +++ b/src/Simulator/FloodyFluidSimulator.cpp @@ -48,7 +48,7 @@ cFloodyFluidSimulator::cFloodyFluidSimulator( void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ) { - FLOG("Simulating block {%d, %d, %d}: block %d, meta %d", + FLOG("Simulating block {%d, %d, %d}: block %d, meta %d", a_Chunk->GetPosX() * cChunkDef::Width + a_RelX, a_RelY, a_Chunk->GetPosZ() * cChunkDef::Width + a_RelZ, a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ), a_Chunk->GetMeta(a_RelX, a_RelY, a_RelZ) @@ -248,7 +248,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i { // Lava flowing into water, change to stone / cobblestone based on direction: BLOCKTYPE NewBlock = (a_NewMeta == 8) ? E_BLOCK_STONE : E_BLOCK_COBBLESTONE; - FLOG(" Lava flowing into water, turning water at rel {%d, %d, %d} into stone", + FLOG(" Lava flowing into water, turning water at rel {%d, %d, %d} into stone", a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str() ); @@ -264,7 +264,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i { // Water flowing into lava, change to cobblestone / obsidian based on dest block: BLOCKTYPE NewBlock = (BlockMeta == 0) ? E_BLOCK_OBSIDIAN : E_BLOCK_COBBLESTONE; - FLOG(" Water flowing into lava, turning lava at rel {%d, %d, %d} into %s", + FLOG(" Water flowing into lava, turning lava at rel {%d, %d, %d} into %s", a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str() ); a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0); @@ -296,8 +296,8 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i ChunkInterface, m_World, PluginInterface, - NULL, - BlockX, + NULL, + BlockX, a_RelY, BlockZ ); diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 0d4815c00..6249e0cdd 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -59,7 +59,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, // Use that Chunk pointer to get a relative position int RelX = 0; - int RelZ = 0; + int RelZ = 0; BLOCKTYPE Block; NIBBLETYPE Meta; @@ -821,7 +821,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() void cIncrementalRedstoneSimulator::HandlePiston(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) -{ +{ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; @@ -1518,7 +1518,7 @@ bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_RelBlockX, in return true; } } - return false; + return false; } @@ -1616,7 +1616,7 @@ bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_RelBlockX, int a_Rel bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta) -{ +{ switch (a_Meta & 0x3) // We only want the 'direction' part of our metadata { // If the repeater is looking up or down (If parallel to the Z axis) @@ -1648,14 +1648,14 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelB // Check if southern(down) neighbor is a powered on repeater who is facing us BLOCKTYPE Block = 0; if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) - { + { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1) & 0x3; if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked } // Check if northern(up) neighbor is a powered on repeater who is facing us if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) - { + { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1) & 0x3; if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked } @@ -2082,7 +2082,7 @@ bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in } // Self not in list, add self to list - sRepeatersDelayList RC; + sRepeatersDelayList RC; RC.a_RelBlockPos = Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ); // Gets the top two bits (delay time), shifts them into the lower two bits, and adds one (meta 0 = 1 tick; 1 = 2 etc.) diff --git a/src/Simulator/NoopFluidSimulator.h b/src/Simulator/NoopFluidSimulator.h index 9113aec3c..9fe2f9040 100644 --- a/src/Simulator/NoopFluidSimulator.h +++ b/src/Simulator/NoopFluidSimulator.h @@ -27,7 +27,7 @@ public: } // cSimulator overrides: - virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override + virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override { UNUSED(a_BlockX); UNUSED(a_BlockY); diff --git a/src/Simulator/NoopRedstoneSimulator.h b/src/Simulator/NoopRedstoneSimulator.h index e5338ad44..4301b8aae 100644 --- a/src/Simulator/NoopRedstoneSimulator.h +++ b/src/Simulator/NoopRedstoneSimulator.h @@ -21,7 +21,7 @@ public: // ~cRedstoneNoopSimulator(); virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used - virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override + virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override { UNUSED(a_Dt); UNUSED(a_ChunkX); diff --git a/src/Simulator/SandSimulator.h b/src/Simulator/SandSimulator.h index 6e64aa425..1262f2792 100644 --- a/src/Simulator/SandSimulator.h +++ b/src/Simulator/SandSimulator.h @@ -37,7 +37,7 @@ public: based on the block currently present in the world at the dest specified coords */ static void FinishFalling( - cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, + cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_FallingBlockType, NIBBLETYPE a_FallingBlockMeta ); diff --git a/src/Simulator/Simulator.h b/src/Simulator/Simulator.h index a2e2a5742..171eba91c 100644 --- a/src/Simulator/Simulator.h +++ b/src/Simulator/Simulator.h @@ -26,7 +26,7 @@ public: /// Called in each tick for each chunk, a_Dt is the time passed since the last tick, in msec; direct access to chunk data available virtual void SimulateChunk(float a_Dt, int a_ChunkX, - int a_ChunkZ, cChunk * a_Chunk) + int a_ChunkZ, cChunk * a_Chunk) { UNUSED(a_Dt); UNUSED(a_ChunkX); diff --git a/src/Simulator/VaporizeFluidSimulator.cpp b/src/Simulator/VaporizeFluidSimulator.cpp index 191770273..484cac334 100644 --- a/src/Simulator/VaporizeFluidSimulator.cpp +++ b/src/Simulator/VaporizeFluidSimulator.cpp @@ -27,7 +27,7 @@ void cVaporizeFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, return; } int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width; - int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width; + int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width; BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ); if ( (BlockType == m_FluidBlock) || diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 0a9502491..21b6ed0c8 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -36,8 +36,8 @@ cSlotArea::cSlotArea(int a_NumSlots, cWindow & a_ParentWindow) : void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) { /* - LOGD("Slot area with %d slots clicked at slot number %d, clicked item %s, slot item %s", - GetNumSlots(), a_SlotNum, + LOGD("Slot area with %d slots clicked at slot number %d, clicked item %s, slot item %s", + GetNumSlots(), a_SlotNum, ItemToFullString(a_ClickedItem).c_str(), ItemToFullString(*GetSlot(a_SlotNum, a_Player)).c_str() ); @@ -1280,7 +1280,7 @@ void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickActio } case caLeftClick: - { + { // Left-clicked if (DraggingItem.IsEmpty()) { diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index b550068b1..6606beda2 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -164,7 +164,7 @@ void cWindow::GetSlots(cPlayer & a_Player, cItems & a_Slots) const void cWindow::Clicked( - cPlayer & a_Player, + cPlayer & a_Player, int a_WindowID, short a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem ) diff --git a/src/UI/Window.h b/src/UI/Window.h index b170a9d78..1872b2c20 100644 --- a/src/UI/Window.h +++ b/src/UI/Window.h @@ -36,12 +36,12 @@ typedef std::vector cSlotAreas; // tolua_begin -/** +/** Represents a UI window. Each window has a list of players that are currently using it When there's no player using a window, it is destroyed. -A window consists of several areas of slots with similar functionality - for example the crafting grid area, or +A window consists of several areas of slots with similar functionality - for example the crafting grid area, or the inventory area. Each area knows what its slots are (GetSlot() function) and can handle mouse clicks. The window acts only as a top-level container for those areas, redirecting the click events to the correct areas. Inventory painting, introduced in 1.5, is handled by the window, too @@ -109,7 +109,7 @@ public: /// Handles a click event from a player void Clicked( - cPlayer & a_Player, int a_WindowID, + cPlayer & a_Player, int a_WindowID, short a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem ); diff --git a/src/UI/WindowOwner.h b/src/UI/WindowOwner.h index e3c73edc4..7a7941e37 100644 --- a/src/UI/WindowOwner.h +++ b/src/UI/WindowOwner.h @@ -6,7 +6,7 @@ #include "Window.h" /* -Being a descendant of cWindowOwner means that the class can own one window. That window can be +Being a descendant of cWindowOwner means that the class can own one window. That window can be queried, opened by other players, closed by players and finally destroyed. Also, a cWindowOwner can be queried for the block coords where the window is displayed. That will be used for entities / players in motion to close their windows when they get too far away from the window "source". diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index 8e7247aab..c6294b99c 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -10,7 +10,7 @@ -// The number of NBT tags that are reserved when an NBT parsing is started. +// The number of NBT tags that are reserved when an NBT parsing is started. // You can override this by using a cmdline define #ifndef NBT_RESERVE_SIZE #define NBT_RESERVE_SIZE 200 @@ -69,7 +69,7 @@ bool cParsedNBT::Parse(void) m_Pos = 1; - RETURN_FALSE_IF_FALSE(ReadString(m_Tags.back().m_NameStart, m_Tags.back().m_NameLength)); + RETURN_FALSE_IF_FALSE(ReadString(m_Tags.back().m_NameStart, m_Tags.back().m_NameLength)); RETURN_FALSE_IF_FALSE(ReadCompound()); return true; diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h index fe28005ac..7aa83fc24 100644 --- a/src/WorldStorage/FastNBT.h +++ b/src/WorldStorage/FastNBT.h @@ -5,11 +5,11 @@ /* The fast parser parses the data into a vector of cFastNBTTag structures. These structures describe the NBT tree, -but themselves are allocated in a vector, thus minimizing reallocation. +but themselves are allocated in a vector, thus minimizing reallocation. The structures have a minimal constructor, setting all member "pointers" to "invalid". The fast writer doesn't need a NBT tree structure built beforehand, it is commanded to open, append and close tags -(just like XML); it keeps the internal tag stack and reports errors in usage. +(just like XML); it keeps the internal tag stack and reports errors in usage. It directly outputs a string containing the serialized NBT data. */ @@ -173,7 +173,7 @@ public: } /** Returns the value stored in a Byte tag. Not valid for any other tag type. */ - inline unsigned char GetByte(int a_Tag) const + inline unsigned char GetByte(int a_Tag) const { ASSERT(m_Tags[(size_t)a_Tag].m_Type == TAG_Byte); return (unsigned char)(m_Data[(size_t)m_Tags[(size_t)a_Tag].m_DataStart]); diff --git a/src/WorldStorage/FireworksSerializer.cpp b/src/WorldStorage/FireworksSerializer.cpp index 5a2be8867..ecb600483 100644 --- a/src/WorldStorage/FireworksSerializer.cpp +++ b/src/WorldStorage/FireworksSerializer.cpp @@ -98,7 +98,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB // Divide by four as data length returned in bytes size_t DataLength = a_NBT.GetDataLength(explosiontag); // round to the next highest multiple of four - DataLength -= DataLength % 4; + DataLength -= DataLength % 4; if (DataLength == 0) { continue; @@ -114,7 +114,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB { size_t DataLength = a_NBT.GetDataLength(explosiontag) / 4; // round to the next highest multiple of four - DataLength -= DataLength % 4; + DataLength -= DataLength % 4; if (DataLength == 0) { continue; diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 388ad0332..b4048b097 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -56,7 +56,7 @@ thus making skylight visible in Minutor's Lighting mode */ // #define DEBUG_SKYLIGHT -/** Maximum number of MCA files that are cached in memory. +/** Maximum number of MCA files that are cached in memory. Since only the header is actually in the memory, this number can be high, but still, each file means an OS FS handle. */ #define MAX_MCA_FILES 32 @@ -393,7 +393,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT m_World->SetChunkData( a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, - BlockTypes, MetaData, + BlockTypes, MetaData, IsLightValid ? BlockLight : NULL, IsLightValid ? SkyLight : NULL, NULL, Biomes, @@ -449,7 +449,7 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_ const char * BlockLight = (const char *)(Serializer.m_BlockSkyLight); #else const char * BlockLight = (const char *)(Serializer.m_BlockLight); - #endif + #endif const char * BlockSkyLight = (const char *)(Serializer.m_BlockSkyLight); for (int Y = 0; Y < 16; Y++) { @@ -463,7 +463,7 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_ } a_Writer.EndList(); // "Sections" - // Store the information that the lighting is valid. + // Store the information that the lighting is valid. // For compatibility reason, the default is "invalid" (missing) - this means older data is re-lighted upon loading. if (Serializer.IsLightValid()) { @@ -2363,8 +2363,8 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N return; } int OwnerIdx = a_NBT.FindChildByName(a_TagIdx, "Owner"); - if (OwnerIdx > 0) - { + if (OwnerIdx > 0) + { AString OwnerName = a_NBT.GetString(OwnerIdx); if (OwnerName != "") { diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index 3b08c5ac5..ff43b6905 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -603,7 +603,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, (size_t)UncompressedSize); if (errorcode != Z_OK) { - LOGERROR("Error %d decompressing data for chunk [%d, %d]", + LOGERROR("Error %d decompressing data for chunk [%d, %d]", errorcode, Header->m_ChunkX, Header->m_ChunkZ ); @@ -627,7 +627,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() char ConvertedData[cChunkDef::BlockDataSize]; int Index = 0; unsigned int InChunkOffset = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) + for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) { for( int y = 0; y < 128; ++y ) { @@ -683,7 +683,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData, m_CompressionFactor); if (errorcode != Z_OK) { - LOGERROR("Error %d compressing data for chunk [%d, %d]", + LOGERROR("Error %d compressing data for chunk [%d, %d]", errorcode, Header->m_ChunkX, Header->m_ChunkZ ); @@ -747,7 +747,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, (size_t)UncompressedSize); if (errorcode != Z_OK) { - LOGERROR("Error %d decompressing data for chunk [%d, %d]", + LOGERROR("Error %d decompressing data for chunk [%d, %d]", errorcode, Header->m_ChunkX, Header->m_ChunkZ ); @@ -819,7 +819,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData, m_CompressionFactor); if (errorcode != Z_OK) { - LOGERROR("Error %d compressing data for chunk [%d, %d]", + LOGERROR("Error %d compressing data for chunk [%d, %d]", errorcode, Header->m_ChunkX, Header->m_ChunkZ ); @@ -863,7 +863,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre int errorcode = UncompressString(a_Data.data(), a_Data.size(), UncompressedData, (size_t)a_UncompressedSize); if (errorcode != Z_OK) { - LOGERROR("Error %d decompressing data for chunk [%d, %d]", + LOGERROR("Error %d decompressing data for chunk [%d, %d]", errorcode, a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ ); diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index b6d572f3e..155aa6b14 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -202,7 +202,7 @@ void cWorldStorage::InitSchemas(int a_StorageCompressionFactor) } // for itr - m_Schemas[] // Unknown schema selected, let the admin know: - LOGWARNING("Unknown storage schema name \"%s\". Using default (\"%s\"). Available schemas:", + LOGWARNING("Unknown storage schema name \"%s\". Using default (\"%s\"). Available schemas:", m_StorageSchemaName.c_str(), m_SaveSchema->GetName().c_str() ); for (cWSSchemaList::iterator itr = m_Schemas.begin(); itr != m_Schemas.end(); ++itr) diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index 1204b4310..bf764a539 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -95,7 +95,7 @@ protected: bool operator==(const sChunkLoad other) const { - return this->m_ChunkX == other.m_ChunkX && + return this->m_ChunkX == other.m_ChunkX && this->m_ChunkY == other.m_ChunkY && this->m_ChunkZ == other.m_ChunkZ; } @@ -103,7 +103,7 @@ protected: struct FuncTable { static void Delete(sChunkLoad) {}; - static void Combine(sChunkLoad& a_orig, const sChunkLoad a_new) + static void Combine(sChunkLoad& a_orig, const sChunkLoad a_new) { a_orig.m_Generate |= a_new.m_Generate; }; -- cgit v1.2.3 From 5c0789e15e56d0342af57c4e8d821dfba46c9227 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 14:08:21 -0700 Subject: Player.cpp: Added Wither death message --- src/Entities/Player.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 7d9f6d67f..b11fd9440 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -905,6 +905,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) case dtCactusContact: DamageText = "was impaled on a cactus"; break; case dtLavaContact: DamageText = "was melted by lava"; break; case dtPoisoning: DamageText = "died from septicaemia"; break; + case dtWithering: DamageText = "is a husk of their former selves" case dtOnFire: DamageText = "forgot to stop, drop, and roll"; break; case dtFireContact: DamageText = "burnt themselves to death"; break; case dtInVoid: DamageText = "somehow fell out of the world"; break; -- cgit v1.2.3 From 488ecb6912dfd279509de2bec79b2f461c01056a Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 14:08:54 -0700 Subject: Player.cpp: Fixed compile error --- src/Entities/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index b11fd9440..a1dfed39c 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -905,7 +905,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) case dtCactusContact: DamageText = "was impaled on a cactus"; break; case dtLavaContact: DamageText = "was melted by lava"; break; case dtPoisoning: DamageText = "died from septicaemia"; break; - case dtWithering: DamageText = "is a husk of their former selves" + case dtWithering: DamageText = "is a husk of their former selves"; break; case dtOnFire: DamageText = "forgot to stop, drop, and roll"; break; case dtFireContact: DamageText = "burnt themselves to death"; break; case dtInVoid: DamageText = "somehow fell out of the world"; break; -- cgit v1.2.3 From d0cc9aedb3e63d39324c52b6385406f362ab41b7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:59:02 +0200 Subject: More trailing whitespace fixes. --- src/Blocks/BlockLadder.h | 6 +++--- src/Entities/Entity.cpp | 4 ++-- src/Entities/Minecart.cpp | 8 ++++---- src/Entities/Pickup.cpp | 2 +- src/Entities/Player.cpp | 2 +- src/Items/ItemBucket.h | 8 ++++---- src/Items/ItemHandler.h | 2 +- src/Items/ItemSeeds.h | 2 +- src/Mobs/Creeper.cpp | 2 +- src/Mobs/Horse.cpp | 2 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 8 ++++---- src/UI/Window.cpp | 2 +- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- 13 files changed, 25 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index 2c41083e7..72acced41 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -12,17 +12,17 @@ class cBlockLadderHandler : public cClearMetaOnDrop > { - typedef cClearMetaOnDrop > super; + typedef cClearMetaOnDrop > super; public: cBlockLadderHandler(BLOCKTYPE a_BlockType) : super(a_BlockType) { - } + } virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 0ff3ff102..7d130aa47 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -640,7 +640,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) if ((BlockY >= cChunkDef::Height) || (BlockY < 0)) { - // Outside of the world + // Outside of the world AddSpeedY(m_Gravity * a_Dt); AddPosition(GetSpeed() * a_Dt); return; @@ -858,7 +858,7 @@ void cEntity::TickBurning(cChunk & a_Chunk) if (POSY_TOINT > m_World->GetHeight(POSX_TOINT, POSZ_TOINT)) { m_TicksLeftBurning = 0; - } + } } // Do the burning damage: diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index 6502ae45a..03850c8a7 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -493,7 +493,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) SetSpeedY(-GetSpeedX()); } break; - } + } case E_META_RAIL_ASCEND_XP: // ASCEND WEST { SetYaw(180); @@ -513,7 +513,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) } } break; - } + } case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH { SetYaw(270); @@ -787,7 +787,7 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta) } } break; - } + } case E_META_RAIL_CURVED_ZM_XM: case E_META_RAIL_CURVED_ZM_XP: case E_META_RAIL_CURVED_ZP_XM: @@ -883,7 +883,7 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta) } } return true; - } + } case E_META_RAIL_CURVED_ZM_XM: case E_META_RAIL_CURVED_ZM_XP: case E_META_RAIL_CURVED_ZP_XM: diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index ab0f856dd..18df1a210 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -143,7 +143,7 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk) m_bCollected = true; m_Timer = 0; // We have to reset the timer. m_Timer += a_Dt; // In case we have to destroy the pickup in the same tick. - if (m_Timer > 500.f) + if (m_Timer > 500.f) { Destroy(true); return; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index a1dfed39c..6e7623f4a 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -497,7 +497,7 @@ void cPlayer::SetTouchGround(bool a_bTouchGround) // Fall particles GetWorld()->BroadcastSoundParticleEffect(2006, POSX_TOINT, (int)GetPosY() - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */); - } + } m_LastGroundHeight = (float)GetPosY(); } diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 4cdfab0fe..6d7926fa4 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -94,7 +94,7 @@ public: bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_FluidBlock) - { + { if (a_BlockFace != BLOCK_FACE_NONE) { return false; @@ -209,14 +209,14 @@ public: } m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); // (Block could be washed away, replace it) return true; // Abort tracing - } + } return false; } } Callbacks; cLineBlockTracer Tracer(*a_World, Callbacks); Vector3d Start(a_Player->GetEyePosition()); - Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); + Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); // cTracer::Trace returns true when whole line was traversed. By returning true when we hit something, we ensure that this never happens if liquid could be placed // Use this to judge whether the position is valid @@ -227,6 +227,6 @@ public: return true; } - return false; + return false; } }; diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index 3ea04d1cb..c7362c5f4 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -91,7 +91,7 @@ public: /** Can the anvil repair this item, when a_Item is the second input? */ virtual bool CanRepairWithRawMaterial(short a_ItemType); - /** Called before a block is placed into a world. + /** Called before a block is placed into a world. The handler should return true to allow placement, false to refuse. Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block. */ diff --git a/src/Items/ItemSeeds.h b/src/Items/ItemSeeds.h index 4c9e82ae0..54a1183d7 100644 --- a/src/Items/ItemSeeds.h +++ b/src/Items/ItemSeeds.h @@ -40,7 +40,7 @@ public: case E_ITEM_CARROT: return FoodInfo(4, 4.8); case E_ITEM_POTATO: return FoodInfo(1, 0.6); default: return FoodInfo(0, 0); - } + } } virtual bool GetPlacementBlockTypeMeta( diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp index 495f1dd25..02718edf8 100644 --- a/src/Mobs/Creeper.cpp +++ b/src/Mobs/Creeper.cpp @@ -37,7 +37,7 @@ void cCreeper::Tick(float a_Dt, cChunk & a_Chunk) { if (m_bIsBlowing) { - m_ExplodingTimer += 1; + m_ExplodingTimer += 1; } if (m_ExplodingTimer == 30) diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp index 9d130301f..67a09d4ab 100644 --- a/src/Mobs/Horse.cpp +++ b/src/Mobs/Horse.cpp @@ -63,7 +63,7 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk) m_Attachee->Detach(); m_bIsRearing = true; } - } + } else { m_bIsTame = true; diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 6249e0cdd..eb12c08e0 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -281,7 +281,7 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int if (ShouldUpdateSimulateOnceBlocks) { switch (dataitr->Data) - { + { case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_COMMAND_BLOCK: HandleCommandBlock(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(dataitr->x, dataitr->y, dataitr->z); break; @@ -392,7 +392,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R if (a_MyState == E_BLOCK_REDSTONE_TORCH_ON) { - // Check if the block the torch is on is powered + // Check if the block the torch is on is powered int X = a_RelBlockX; int Y = a_RelBlockY; int Z = a_RelBlockZ; AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on @@ -448,7 +448,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R } else { - // Check if the block the torch is on is powered + // Check if the block the torch is on is powered int X = a_RelBlockX; int Y = a_RelBlockY; int Z = a_RelBlockZ; AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on @@ -803,7 +803,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() } else if (Block != E_BLOCK_REDSTONE_REPEATER_OFF) { - m_Chunk->SetBlock(RelBlockX, RelBlockY, RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, Meta); + m_Chunk->SetBlock(RelBlockX, RelBlockY, RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, Meta); } itr = m_RepeatersDelayList->erase(itr); } diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 6606beda2..2558d15b8 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -145,7 +145,7 @@ void cWindow::GetSlots(cPlayer & a_Player, cItems & a_Slots) const { int NumSlots = (*itr)->GetNumSlots(); for (int i = 0; i < NumSlots; i++) - { + { const cItem * Item = (*itr)->GetSlot(i, a_Player); if (Item == NULL) { diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 3f79a6572..e68903b26 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -630,7 +630,7 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) { ASSERT(!"Unsaved projectile entity!"); } - } // switch (ProjectileKind) + } // switch (ProjectileKind) if (!a_Projectile->GetCreatorName().empty()) { -- cgit v1.2.3 From c03161f75d22a7965aea20fb9843ae580a07079a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 23:15:53 +0200 Subject: Fixed tabs used for alignment. --- src/Blocks/BlockSnow.h | 4 +-- src/Entities/Entity.cpp | 2 +- src/Entities/Entity.h | 2 +- src/Entities/ExpOrb.cpp | 4 +-- src/Entities/HangingEntity.cpp | 2 +- src/Entities/ItemFrame.cpp | 2 +- src/Entities/Pickup.cpp | 2 +- src/Entities/Pickup.h | 2 +- src/Entities/Player.cpp | 8 ++--- src/Entities/Player.h | 26 +++++++------- src/Generating/Caves.cpp | 12 +++---- src/Generating/ChunkGenerator.cpp | 6 ++-- src/Generating/FinishGen.h | 2 +- src/Generating/Ravines.cpp | 22 ++++++------ src/Generating/VillageGen.cpp | 2 +- src/Items/ItemFishingRod.h | 2 +- src/Items/ItemHandler.cpp | 14 ++++---- src/Mobs/Monster.cpp | 2 +- src/OSSupport/Semaphore.cpp | 50 +++++++++++++++++--------- src/OSSupport/Sleep.cpp | 2 +- src/OSSupport/Thread.cpp | 2 +- src/Protocol/Protocol125.cpp | 18 +++++----- src/Protocol/Protocol17x.cpp | 7 ++-- src/Simulator/DelayedFluidSimulator.h | 2 +- src/Simulator/FluidSimulator.cpp | 2 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 2 +- src/Simulator/IncrementalRedstoneSimulator.h | 2 +- src/UI/SlotArea.h | 4 +-- src/WorldStorage/MapSerializer.h | 7 ++-- 29 files changed, 115 insertions(+), 99 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockSnow.h b/src/Blocks/BlockSnow.h index 27fc17e7f..977f19a16 100644 --- a/src/Blocks/BlockSnow.h +++ b/src/Blocks/BlockSnow.h @@ -33,8 +33,8 @@ public: if ((BlockBeforePlacement == E_BLOCK_SNOW) && (MetaBeforePlacement < 7)) { // Only increment if: - // A snow block was already there (not first time placement) AND - // Height is smaller than 7, the maximum possible height + // - A snow block was already there (not first time placement) AND + // - Height is smaller than 7, the maximum possible height MetaBeforePlacement++; } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 7d130aa47..28817428f 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -345,7 +345,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) switch (KnockbackLevel) { case 1: AdditionalSpeed.Set(5, 0.3, 5); break; - case 2: AdditionalSpeed.Set(8, 0.3, 8); break; + case 2: AdditionalSpeed.Set(8, 0.3, 8); break; default: break; } AddSpeed(a_TDI.Knockback + AdditionalSpeed); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 7abe5db37..88f8528e9 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -485,7 +485,7 @@ protected: /// Whether the entity is capable of taking fire or lava damage. bool m_IsFireproof; - + /// Time, in ticks, since the last damage dealt by being on fire. Valid only if on fire (IsOnFire()) int m_TicksSinceLastBurnDamage; diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp index e437c24ef..ed225b8e6 100644 --- a/src/Entities/ExpOrb.cpp +++ b/src/Entities/ExpOrb.cpp @@ -6,7 +6,7 @@ cExpOrb::cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward) - : cEntity(etExpOrb, a_X, a_Y, a_Z, 0.98, 0.98) + : cEntity(etExpOrb, a_X, a_Y, a_Z, 0.98, 0.98) , m_Reward(a_Reward) , m_Timer(0.f) { @@ -19,7 +19,7 @@ cExpOrb::cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward) cExpOrb::cExpOrb(const Vector3d & a_Pos, int a_Reward) - : cEntity(etExpOrb, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98) + : cEntity(etExpOrb, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98) , m_Reward(a_Reward) , m_Timer(0.f) { diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp index d7a7ba943..32d2b226d 100644 --- a/src/Entities/HangingEntity.cpp +++ b/src/Entities/HangingEntity.cpp @@ -10,7 +10,7 @@ cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z) - : cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8) + : cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8) , m_BlockFace(a_BlockFace) { SetMaxHealth(1); diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp index 144c6d5aa..f0b0c8c65 100644 --- a/src/Entities/ItemFrame.cpp +++ b/src/Entities/ItemFrame.cpp @@ -10,7 +10,7 @@ cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z) - : cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z) + : cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z) , m_Item(E_BLOCK_AIR) , m_Rotation(0) { diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index 18df1a210..aab534f41 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -85,7 +85,7 @@ protected: cPickup::cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */) - : cEntity(etPickup, a_PosX, a_PosY, a_PosZ, 0.2, 0.2) + : cEntity(etPickup, a_PosX, a_PosY, a_PosZ, 0.2, 0.2) , m_Timer(0.f) , m_Item(a_Item) , m_bCollected(false) diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h index d50941280..d7c5d2b26 100644 --- a/src/Entities/Pickup.h +++ b/src/Entities/Pickup.h @@ -32,7 +32,7 @@ public: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; - bool CollectedBy(cPlayer * a_Dest); // tolua_export + bool CollectedBy(cPlayer * a_Dest); // tolua_export virtual void Tick(float a_Dt, cChunk & a_Chunk) override; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 6e7623f4a..a356ebba7 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1347,7 +1347,7 @@ void cPlayer::SetVisible(bool a_bVisible) if (!a_bVisible && m_bVisible) { m_bVisible = false; - m_World->BroadcastDestroyEntity(*this, m_ClientHandle); // Destroy on all clients + m_World->BroadcastDestroyEntity(*this, m_ClientHandle); // Destroy on all clients } } @@ -1455,7 +1455,7 @@ bool cPlayer::IsInGroup( const AString & a_Group ) void cPlayer::ResolvePermissions() { - m_ResolvedPermissions.clear(); // Start with an empty map yo~ + m_ResolvedPermissions.clear(); // Start with an empty map // Copy all player specific permissions into the resolved permissions map for( PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr ) @@ -1483,7 +1483,7 @@ void cPlayer::ResolveGroups() m_ResolvedGroups.clear(); // Get a complete resolved list of all groups the player is in - std::map< cGroup*, bool > AllGroups; // Use a map, because it's faster than iterating through a list to find duplicates + std::map< cGroup*, bool > AllGroups; // Use a map, because it's faster than iterating through a list to find duplicates GroupList ToIterate; for( GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr ) { @@ -1501,7 +1501,7 @@ void cPlayer::ResolveGroups() else { AllGroups[ CurrentGroup ] = true; - m_ResolvedGroups.push_back( CurrentGroup ); // Add group to resolved list + m_ResolvedGroups.push_back( CurrentGroup ); // Add group to resolved list const cGroup::GroupList & Inherits = CurrentGroup->GetInherits(); for( cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr ) { diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 0eef3e6e1..7c287d41b 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -119,11 +119,11 @@ public: void SetTouchGround( bool a_bTouchGround ); inline void SetStance( const double a_Stance ) { m_Stance = a_Stance; } - double GetEyeHeight(void) const; // tolua_export - Vector3d GetEyePosition(void) const; // tolua_export + double GetEyeHeight(void) const; // tolua_export + Vector3d GetEyePosition(void) const; // tolua_export inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export inline double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc. - inline cInventory & GetInventory(void) { return m_Inventory; } // tolua_export + inline cInventory & GetInventory(void) { return m_Inventory; } // tolua_export inline const cInventory & GetInventory(void) const { return m_Inventory; } /** Gets the contents of the player's associated enderchest */ @@ -239,15 +239,15 @@ public: typedef std::list< std::string > StringList; /** Adds a player to existing group or creates a new group when it doesn't exist */ - void AddToGroup( const AString & a_GroupName ); // tolua_export + void AddToGroup( const AString & a_GroupName ); // tolua_export /** Removes a player from the group, resolves permissions and group inheritance (case sensitive) */ - void RemoveFromGroup( const AString & a_GroupName ); // tolua_export + void RemoveFromGroup( const AString & a_GroupName ); // tolua_export - bool HasPermission( const AString & a_Permission ); // tolua_export - const GroupList & GetGroups() { return m_Groups; } // >> EXPORTED IN MANUALBINDINGS << - StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS << - bool IsInGroup( const AString & a_Group ); // tolua_export + bool HasPermission( const AString & a_Permission ); // tolua_export + const GroupList & GetGroups() { return m_Groups; } // >> EXPORTED IN MANUALBINDINGS << + StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS << + bool IsInGroup( const AString & a_Group ); // tolua_export // tolua_begin @@ -326,10 +326,10 @@ public: virtual void Killed(cEntity * a_Victim) override; - void Respawn(void); // tolua_export + void Respawn(void); // tolua_export - void SetVisible( bool a_bVisible ); // tolua_export - bool IsVisible(void) const { return m_bVisible; } // tolua_export + void SetVisible( bool a_bVisible ); // tolua_export + bool IsVisible(void) const { return m_bVisible; } // tolua_export /** Moves the player to the specified world. Returns true if successful, false on failure (world not found). */ @@ -345,7 +345,7 @@ public: Returns true on success, false on failure. */ bool LoadFromFile(const AString & a_FileName); - void LoadPermissionsFromDisk(void); // tolua_export + void LoadPermissionsFromDisk(void); // tolua_export const AString & GetLoadedWorldName() { return m_LoadedWorldName; } diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index f543846d2..3571b29d4 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -555,14 +555,14 @@ AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) cons { AString SVG; SVG.reserve(m_Points.size() * 20 + 200); - AppendPrintf(SVG, "m_BlockX, a_OffsetZ + itr->m_BlockZ); Prefix = 'L'; - } - SVG.append("\"/>\n"); + } + SVG.append("\"/>\n"); return SVG; } #endif // _DEBUG diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp index 3f8f77f09..0947eeae5 100644 --- a/src/Generating/ChunkGenerator.cpp +++ b/src/Generating/ChunkGenerator.cpp @@ -228,10 +228,10 @@ void cChunkGenerator::Execute(void) continue; } - cChunkCoords coords = m_Queue.front(); // Get next coord from queue - m_Queue.erase( m_Queue.begin() ); // Remove coordinate from queue + cChunkCoords coords = m_Queue.front(); // Get next coord from queue + m_Queue.erase( m_Queue.begin() ); // Remove coordinate from queue bool SkipEnabled = (m_Queue.size() > QUEUE_SKIP_LIMIT); - Lock.Unlock(); // Unlock ASAP + Lock.Unlock(); // Unlock ASAP m_evtRemoved.Set(); // Display perf info once in a while: diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 2e5732929..fdeb86e73 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -199,7 +199,7 @@ protected: // cFinishGen override: virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; - /// Tries to place a spring at the specified coords, checks neighbors. Returns true if successful + /// Tries to place a spring at the specified coords, checks neighbors. Returns true if successful bool TryPlaceSpring(cChunkDesc & a_ChunkDesc, int x, int y, int z); } ; diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index 8f62669e7..86e27d8ed 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -283,25 +283,25 @@ void cStructGenRavines::cRavine::FinishLinear(void) AString cStructGenRavines::cRavine::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const { AString SVG; - AppendPrintf(SVG, "m_BlockX, a_OffsetZ + itr->m_BlockZ); Prefix = 'L'; - } - SVG.append("\"/>\n"); - - // Base point highlight: - AppendPrintf(SVG, "\n", + } + SVG.append("\"/>\n"); + + // Base point highlight: + AppendPrintf(SVG, "\n", a_OffsetX + m_OriginX - 5, a_OffsetZ + m_OriginZ, a_OffsetX + m_OriginX + 5, a_OffsetZ + m_OriginZ ); - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ - 5, a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ + 5 ); // A gray line from the base point to the first point of the ravine, for identification: - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ, a_OffsetX + m_Points.front().m_BlockX, a_OffsetZ + m_Points.front().m_BlockZ ); diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index fdec2425d..cade923c9 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -95,7 +95,7 @@ public: return ((const cPrefab &)a_NewPiece).GetPieceWeight(a_PlacedPiece, a_ExistingConnector); } -} ; +}; diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index 0c07cd422..6350a38ba 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -63,7 +63,7 @@ class cSweepEntityCallback : { public: cSweepEntityCallback(Vector3d a_PlayerPos) : - m_PlayerPos(a_PlayerPos) + m_PlayerPos(a_PlayerPos) { } diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 3e02a43fa..178bc2fca 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -459,13 +459,13 @@ bool cItemHandler::IsTool() { // TODO: Rewrite this to list all tools specifically return - (m_ItemType >= 256 && m_ItemType <= 259) - || (m_ItemType == 261) - || (m_ItemType >= 267 && m_ItemType <= 279) - || (m_ItemType >= 283 && m_ItemType <= 286) - || (m_ItemType >= 290 && m_ItemType <= 294) - || (m_ItemType == 325) - || (m_ItemType == 346); + ((m_ItemType >= 256) && (m_ItemType <= 259)) || + (m_ItemType == 261) || + ((m_ItemType >= 267) && (m_ItemType <= 279)) || + ((m_ItemType >= 283) && (m_ItemType <= 286)) || + ((m_ItemType >= 290) && (m_ItemType <= 294)) || + (m_ItemType == 325) || + (m_ItemType == 346); } diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index df2572976..ba901df4e 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -325,7 +325,7 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) AddSpeedZ(Distance.z); if (m_EMState == ESCAPING) - { // Runs Faster when escaping :D otherwise they just walk away + { // Runs Faster when escaping :D otherwise they just walk away SetSpeedX (GetSpeedX() * 2.f); SetSpeedZ (GetSpeedZ() * 2.f); } diff --git a/src/OSSupport/Semaphore.cpp b/src/OSSupport/Semaphore.cpp index 60e5564e4..d919c4744 100644 --- a/src/OSSupport/Semaphore.cpp +++ b/src/OSSupport/Semaphore.cpp @@ -44,48 +44,64 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* #endif } + + + + cSemaphore::~cSemaphore() { #ifdef _WIN32 CloseHandle( m_Handle ); #else - if( m_bNamed ) - { - if( sem_close( (sem_t*)m_Handle ) != 0 ) - { - LOG("ERROR: Could not close cSemaphore. (%i)", errno); - } - } - else - { - sem_destroy( (sem_t*)m_Handle ); - delete (sem_t*)m_Handle; - } + if( m_bNamed ) + { + if( sem_close( (sem_t*)m_Handle ) != 0 ) + { + LOG("ERROR: Could not close cSemaphore. (%i)", errno); + } + } + else + { + sem_destroy( (sem_t*)m_Handle ); + delete (sem_t*)m_Handle; + } m_Handle = 0; #endif } + + + + void cSemaphore::Wait() { #ifndef _WIN32 - if( sem_wait( (sem_t*)m_Handle ) != 0) - { - LOG("ERROR: Could not wait for cSemaphore. (%i)", errno); - } + if( sem_wait( (sem_t*)m_Handle ) != 0) + { + LOG("ERROR: Could not wait for cSemaphore. (%i)", errno); + } #else WaitForSingleObject( m_Handle, INFINITE); #endif } + + + + void cSemaphore::Signal() { #ifndef _WIN32 if( sem_post( (sem_t*)m_Handle ) != 0 ) { - LOG("ERROR: Could not signal cSemaphore. (%i)", errno); + LOG("ERROR: Could not signal cSemaphore. (%i)", errno); } #else ReleaseSemaphore( m_Handle, 1, NULL ); #endif } + + + + diff --git a/src/OSSupport/Sleep.cpp b/src/OSSupport/Sleep.cpp index b18d918fa..223a8b855 100644 --- a/src/OSSupport/Sleep.cpp +++ b/src/OSSupport/Sleep.cpp @@ -14,6 +14,6 @@ void cSleep::MilliSleep( unsigned int a_MilliSeconds ) #ifdef _WIN32 Sleep(a_MilliSeconds); // Don't tick too much #else - usleep(a_MilliSeconds*1000); + usleep(a_MilliSeconds*1000); #endif } diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp index 674e37757..084e0810e 100644 --- a/src/OSSupport/Thread.cpp +++ b/src/OSSupport/Thread.cpp @@ -91,7 +91,7 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ ) LOGERROR("ERROR: Could not create thread!"); #else DWORD ThreadID = 0; - HANDLE hThread = CreateThread( 0 // security + HANDLE hThread = CreateThread(NULL // security ,0 // stack size , (LPTHREAD_START_ROUTINE) MyThread // function name ,this // parameters diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index e2960d0c3..1ac035e26 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -760,7 +760,7 @@ void cProtocol125::SendPlayerMoveLook(void) ); */ - WriteByte (PACKET_PLAYER_MOVE_LOOK); + WriteByte(PACKET_PLAYER_MOVE_LOOK); cPlayer * Player = m_Client->GetPlayer(); WriteDouble(Player->GetPosX()); WriteDouble(Player->GetStance() + 0.03); // Add a small amount so that the player doesn't start inside a block @@ -1005,10 +1005,10 @@ void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp void cProtocol125::SendStatistics(const cStatManager & a_Manager) { /* NOTE: - * Versions prior to minecraft 1.7 use an incremental statistic sync - * method. The current setup does not allow us to implement that, because - * of performance considerations. - */ + Versions prior to minecraft 1.7 use an incremental statistic sync + method. The current setup does not allow us to implement that, because + of performance considerations. + */ #if 0 for (unsigned int i = 0; i < (unsigned int)statCount; ++i) { @@ -1121,7 +1121,7 @@ void cProtocol125::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_Bloc cCSLock Lock(m_CSPacket); WriteByte(PACKET_USE_BED); WriteInt (a_Entity.GetUniqueID()); - WriteByte(0); // Unknown byte only 0 has been observed + WriteByte(0); // Unknown byte only 0 has been observed WriteInt (a_BlockX); WriteByte((Byte)a_BlockY); WriteInt (a_BlockZ); @@ -1344,11 +1344,11 @@ int cProtocol125::ParseArmAnim(void) int cProtocol125::ParseBlockDig(void) { - HANDLE_PACKET_READ(ReadChar, char, Status); + HANDLE_PACKET_READ(ReadChar, char, Status); HANDLE_PACKET_READ(ReadBEInt, int, PosX); - HANDLE_PACKET_READ(ReadByte, Byte, PosY); + HANDLE_PACKET_READ(ReadByte, Byte, PosY); HANDLE_PACKET_READ(ReadBEInt, int, PosZ); - HANDLE_PACKET_READ(ReadChar, char, BlockFace); + HANDLE_PACKET_READ(ReadChar, char, BlockFace); m_Client->HandleLeftClick(PosX, PosY, PosZ, static_cast(BlockFace), Status); return PARSE_OK; } diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 45cda944b..37a9fdf47 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -2707,9 +2707,10 @@ void cProtocol172::cPacketizer::WriteEntityMetadata(const cEntity & a_Entity) // The following expression makes Minecarts shake more with less health or higher damage taken // It gets half the maximum health, and takes it away from the current health minus the half health: - /* Health: 5 | 3 - (5 - 3) = 1 (shake power) - Health: 3 | 3 - (3 - 3) = 3 - Health: 1 | 3 - (1 - 3) = 5 + /* + Health: 5 | 3 - (5 - 3) = 1 (shake power) + Health: 3 | 3 - (3 - 3) = 3 + Health: 1 | 3 - (1 - 3) = 5 */ WriteInt((((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4); WriteByte(0x52); diff --git a/src/Simulator/DelayedFluidSimulator.h b/src/Simulator/DelayedFluidSimulator.h index fe59f6dd6..8a6c26c7a 100644 --- a/src/Simulator/DelayedFluidSimulator.h +++ b/src/Simulator/DelayedFluidSimulator.h @@ -70,7 +70,7 @@ protected: /* Slots: | 0 | 1 | ... | m_AddSlotNum | m_SimSlotNum | ... | m_TickDelay - 1 | - adding blocks here ^ | ^ simulating here + | adding blocks here ^ | ^ simulating here */ /// Called from SimulateChunk() to simulate each block in one slot of blocks. Descendants override this method to provide custom simulation. diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp index 99aa11728..499e204a1 100644 --- a/src/Simulator/FluidSimulator.cpp +++ b/src/Simulator/FluidSimulator.cpp @@ -137,7 +137,7 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a return Y_MINUS; */ - NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); // Current Block Meta so only lower points will be counted + NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); // Current Block Meta so only lower points will be counted int X = 0, Z = 0; // Lowest Pos will be stored here if (IsAllowedBlock(m_World.GetBlock(a_X, a_Y + 1, a_Z)) && a_Over) // check for upper block to flow because this also affects the flowing direction diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index eb12c08e0..8e5e40fb5 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -739,7 +739,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int // Create a variable holding my meta to avoid multiple lookups. NIBBLETYPE a_Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); bool IsOn = (a_MyState == E_BLOCK_REDSTONE_REPEATER_ON); - + if (!IsRepeaterLocked(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta)) // If we're locked, change nothing. Otherwise: { bool IsSelfPowered = IsRepeaterPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta); diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index 878f88b71..79740a8f6 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -294,7 +294,7 @@ private: case E_BLOCK_WOODEN_PRESSURE_PLATE: case E_BLOCK_PISTON: { - return true; + return true; } default: return false; } diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index 3dc5c3849..7f37159b7 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -135,7 +135,7 @@ class cSlotAreaHotBar : typedef cSlotAreaInventoryBase super; public: - cSlotAreaHotBar(cWindow & a_ParentWindow) : + cSlotAreaHotBar(cWindow & a_ParentWindow) : cSlotAreaInventoryBase(cInventory::invHotbarCount, cInventory::invHotbarOffset, a_ParentWindow) { } @@ -150,7 +150,7 @@ class cSlotAreaArmor : public cSlotAreaInventoryBase { public: - cSlotAreaArmor(cWindow & a_ParentWindow) : + cSlotAreaArmor(cWindow & a_ParentWindow) : cSlotAreaInventoryBase(cInventory::invArmorCount, cInventory::invArmorOffset, a_ParentWindow) { } diff --git a/src/WorldStorage/MapSerializer.h b/src/WorldStorage/MapSerializer.h index eb7678a08..4fa40f6f9 100644 --- a/src/WorldStorage/MapSerializer.h +++ b/src/WorldStorage/MapSerializer.h @@ -52,10 +52,9 @@ private: /** Utility class used to serialize item ID counts. - * - * In order to perform bounds checking (while loading), - * the last registered ID of each item is serialized to an NBT file. - */ +In order to perform bounds checking (while loading), +the last registered ID of each item is serialized to an NBT file. +*/ class cIDCountSerializer { public: -- cgit v1.2.3 From b2716c720eb237b961470c569ef491558fcc34d3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 23:25:21 +0200 Subject: Fixed code style in Trees.cpp. The src folder now has zero BasicStyle violations. --- src/Generating/Trees.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index eac086de6..b7a08999d 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -41,42 +41,42 @@ static const sCoords Corners[] = static const sCoords BigO1[] = { - {0, -1}, - {-1, 0}, {1, 0}, - {0, 1}, + /* -1 */ {0, -1}, + /* 0 */ {-1, 0}, {1, 0}, + /* 1 */ {0, 1}, } ; static const sCoords BigO2[] = { - {-1, -2}, {0, -2}, {1, -2}, - {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, - {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, - {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, - {-1, 2}, {0, 2}, {1, 2}, + /* -2 */ {-1, -2}, {0, -2}, {1, -2}, + /* -1 */ {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, + /* 0 */ {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, + /* 1 */ {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, + /* 2 */ {-1, 2}, {0, 2}, {1, 2}, } ; static const sCoords BigO3[] = { - {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3}, - {-3, -2}, {-2, -2}, {-1, -2}, {0, -2}, {1, -2}, {2, -2}, {3, -2}, - {-3, -1}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, {3, -1}, - {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, {3, 0}, - {-3, 1}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, {3, 1}, - {-3, 2}, {-2, 2}, {-1, 2}, {0, 2}, {1, 2}, {2, 2}, {3, 2}, - {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3}, + /* -3 */ {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3}, + /* -2 */ {-3, -2}, {-2, -2}, {-1, -2}, {0, -2}, {1, -2}, {2, -2}, {3, -2}, + /* -1 */ {-3, -1}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, {3, -1}, + /* 0 */ {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, {3, 0}, + /* 1 */ {-3, 1}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, {3, 1}, + /* 2 */ {-3, 2}, {-2, 2}, {-1, 2}, {0, 2}, {1, 2}, {2, 2}, {3, 2}, + /* 3 */ {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3}, } ; static const sCoords BigO4[] = // Part of Big Jungle tree { - {-2, -4}, {-1, -4}, {0, -4}, {1, -4}, {2, -4}, - {-3, -3}, {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3}, {3, -3}, - {-4, -2}, {-3, -2}, {-2, -2}, {-1, -2}, {0, -2}, {1, -2}, {2, -2}, {3, -2}, {4, -2}, - {-4, -1}, {-3, -1}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, {3, -1}, {4, -1}, - {-4, 0}, {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, - {-4, 1}, {-3, 1}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, - {-4, 2}, {-3, 2}, {-2, 2}, {-1, 2}, {0, 2}, {1, 2}, {2, 2}, {3, 2}, {4, 2}, - {-3, 3}, {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3}, {3, 3}, - {-2, 4}, {-1, 4}, {0, 4}, {1, 4}, {2, 4}, + /* -4 */ {-2, -4}, {-1, -4}, {0, -4}, {1, -4}, {2, -4}, + /* -3 */ {-3, -3}, {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3}, {3, -3}, + /* -2 */ {-4, -2}, {-3, -2}, {-2, -2}, {-1, -2}, {0, -2}, {1, -2}, {2, -2}, {3, -2}, {4, -2}, + /* -1 */ {-4, -1}, {-3, -1}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, {3, -1}, {4, -1}, + /* 0 */ {-4, 0}, {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, + /* 1 */ {-4, 1}, {-3, 1}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, + /* 2 */ {-4, 2}, {-3, 2}, {-2, 2}, {-1, 2}, {0, 2}, {1, 2}, {2, 2}, {3, 2}, {4, 2}, + /* 3 */ {-3, 3}, {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3}, {3, 3}, + /* 4 */ {-2, 4}, {-1, 4}, {0, 4}, {1, 4}, {2, 4}, } ; -- cgit v1.2.3 From 0f8c24e04d60aa1642a5fe7346941ccd7697977e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 17 Jul 2014 22:26:53 +0100 Subject: Fixed issues relating to saplings and leaves - Removed cBlockInfo::RequiresSpecialTool * Fixes #1195 * Fixes #1201 --- src/Bindings/DeprecatedBindings.cpp | 27 ---------------------- src/BlockInfo.cpp | 46 ------------------------------------- src/BlockInfo.h | 4 ---- src/Blocks/BlockBigFlower.h | 6 ++--- src/Blocks/BlockHandler.cpp | 46 +++++++++---------------------------- src/Blocks/BlockHandler.h | 10 ++++---- src/Blocks/BlockLeaves.h | 10 ++++++-- src/Blocks/BlockSapling.h | 4 ++-- src/Defines.h | 9 -------- src/Items/ItemHandler.cpp | 9 +++----- 10 files changed, 32 insertions(+), 139 deletions(-) (limited to 'src') diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp index d51ba2da3..5bba1ea7a 100644 --- a/src/Bindings/DeprecatedBindings.cpp +++ b/src/Bindings/DeprecatedBindings.cpp @@ -175,32 +175,6 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S) -/* get function: g_BlockRequiresSpecialTool */ -#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockRequiresSpecialTool -static int tolua_get_AllToLua_g_BlockRequiresSpecialTool(lua_State* tolua_S) -{ - int BlockType; - #ifndef TOLUA_RELEASE - { - tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); - } - #endif - BlockType = (int)tolua_tonumber(tolua_S, 2, 0); - if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) - { - tolua_error(tolua_S, "array indexing out of range.", NULL); - } - tolua_pushboolean(tolua_S, cBlockInfo::RequiresSpecialTool((BLOCKTYPE)BlockType)); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - - - - - /* get function: g_BlockIsSolid */ #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockIsSolid static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S) @@ -263,7 +237,6 @@ void DeprecatedBindings::Bind(lua_State * tolua_S) tolua_array(tolua_S, "g_BlockOneHitDig", tolua_get_AllToLua_g_BlockOneHitDig, NULL); tolua_array(tolua_S, "g_BlockPistonBreakable", tolua_get_AllToLua_g_BlockPistonBreakable, NULL); tolua_array(tolua_S, "g_BlockIsSnowable", tolua_get_AllToLua_g_BlockIsSnowable, NULL); - tolua_array(tolua_S, "g_BlockRequiresSpecialTool", tolua_get_AllToLua_g_BlockRequiresSpecialTool, NULL); tolua_array(tolua_S, "g_BlockIsSolid", tolua_get_AllToLua_g_BlockIsSolid, NULL); tolua_array(tolua_S, "g_BlockFullyOccupiesVoxel", tolua_get_AllToLua_g_BlockFullyOccupiesVoxel, NULL); diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index b4b98a2f0..524d39b67 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -15,7 +15,6 @@ cBlockInfo::cBlockInfo() , m_OneHitDig(false) , m_PistonBreakable(false) , m_IsSnowable(false) - , m_RequiresSpecialTool(false) , m_IsSolid(true) , m_FullyOccupiesVoxel(false) , m_Handler(NULL) @@ -440,51 +439,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_TNT ].m_IsSnowable = true; a_Info[E_BLOCK_WOOL ].m_IsSnowable = true; - - // Blocks that don't drop without a special tool: - a_Info[E_BLOCK_BRICK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_CAULDRON ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_COAL_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_COBBLESTONE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_COBBLESTONE_WALL ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_COBWEB ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_DIAMOND_BLOCK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_DIAMOND_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_EMERALD_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_END_STONE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_GOLD_BLOCK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_GOLD_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_IRON_BLOCK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_IRON_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_LAPIS_BLOCK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_LAPIS_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_LEAVES ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_NETHERRACK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_NETHER_BRICK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_OBSIDIAN ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_REDSTONE_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_SANDSTONE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_SANDSTONE_STAIRS ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_SNOW ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_STONE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_STONE_BRICKS ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_STONE_SLAB ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_VINES ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_FURNACE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_LIT_FURNACE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_ANVIL ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_RequiresSpecialTool = true; - - // Nonsolid blocks: a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false; a_Info[E_BLOCK_AIR ].m_IsSolid = false; diff --git a/src/BlockInfo.h b/src/BlockInfo.h index d6d4e7430..e10ca9e68 100644 --- a/src/BlockInfo.h +++ b/src/BlockInfo.h @@ -39,9 +39,6 @@ public: /** Can this block hold snow atop? */ bool m_IsSnowable; - /** Does this block require a tool to drop? */ - bool m_RequiresSpecialTool; - /** Is this block solid (player cannot walk through)? */ bool m_IsSolid; @@ -61,7 +58,6 @@ public: inline static bool IsOneHitDig (BLOCKTYPE a_Type) { return Get(a_Type).m_OneHitDig; } inline static bool IsPistonBreakable (BLOCKTYPE a_Type) { return Get(a_Type).m_PistonBreakable; } inline static bool IsSnowable (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSnowable; } - inline static bool RequiresSpecialTool (BLOCKTYPE a_Type) { return Get(a_Type).m_RequiresSpecialTool; } inline static bool IsSolid (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSolid; } inline static bool FullyOccupiesVoxel (BLOCKTYPE a_Type) { return Get(a_Type).m_FullyOccupiesVoxel; } diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h index 39fd3cac8..0ba997a68 100644 --- a/src/Blocks/BlockBigFlower.h +++ b/src/Blocks/BlockBigFlower.h @@ -19,16 +19,16 @@ public: } - virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ) override + virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim) override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); if (Meta & 0x8) { - super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ); + super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ, a_DropVerbatim); } else { - super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ); + super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_DropVerbatim); } } diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index cef1f5f09..233070b14 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -407,39 +407,6 @@ void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, int a_Bl - -void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) -{ -} - - - - - -void cBlockHandler::OnDigging(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) -{ -} - - - - - -void cBlockHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) -{ -} - - - - - -void cBlockHandler::OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) -{ -} - - - - - void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) { // Setting the meta to a_BlockMeta keeps most textures. The few other blocks have to override this. @@ -450,11 +417,20 @@ void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) -void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ) +void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim) { cItems Pickups; NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - ConvertToPickups(Pickups, Meta); + + if (!a_DropVerbatim) + { + ConvertToPickups(Pickups, Meta); + } + else + { + // TODO: Add a proper overridable function for this + Pickups.Add(m_BlockType, 1, Meta); + } // Allow plugins to modify the pickups: a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups); diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index fb6cae729..ee4d4a6fe 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -60,25 +60,25 @@ public: virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ); /// Called when a direct neighbor of this block has been changed (The position is the own position, not the neighbor position) - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ); + virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {}; /// Notifies all neighbors of the given block about a change static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ); /// Called while the player diggs the block. - virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ); + virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {}; /// Called if the user right clicks the block and the block is useable - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ); + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) {}; /** Called when a Right Click to this Block is cancelled */ - virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace); + virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}; /// Called when the item is mined to convert it into pickups. Pickups may specify multiple items. Appends items to a_Pickups, preserves its original contents virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta); /// Handles the dropping of a block based on what ConvertToDrops() returns. This will not destroy the block. a_Digger is the entity causing the drop; it may be NULL - virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ); + virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim = false); /// Returns step sound name of block virtual const char * GetStepSound(void); diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 495e849fa..67c4535b8 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -43,11 +43,17 @@ public: // Only the first 2 bits contain the display information, the others are for growing if (rand.NextInt(6) == 0) { - a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3)); + a_Pickups.push_back( + cItem( + E_BLOCK_SAPLING, + 1, + (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01)) // Old leaves - 3 bits contain display; new leaves - 1st bit, shifted left two for saplings to understand + ) + ); } // 1 % chance of dropping an apple, if the leaves' type is Apple Leaves - if ((a_BlockMeta & 3) == E_META_LEAVES_APPLE) + if ((m_BlockType == E_BLOCK_LEAVES) && ((a_BlockMeta & 0x03) == E_META_LEAVES_APPLE)) { if (rand.NextInt(101) == 0) { diff --git a/src/Blocks/BlockSapling.h b/src/Blocks/BlockSapling.h index 3d925029a..e965809a3 100644 --- a/src/Blocks/BlockSapling.h +++ b/src/Blocks/BlockSapling.h @@ -20,8 +20,8 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - // Only the first 2 bits contain the display information, the others are for growing - a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3)); + // Only the first 5 bits contain the display information, 8th bit for growth indicator (but we use 0x07 for forward compatibility) + a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x07)); } diff --git a/src/Defines.h b/src/Defines.h index ee91ee596..4fde6800a 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -727,14 +727,5 @@ namespace ItemCategory // tolua_end -inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType) -{ - if(!IsValidBlock(a_BlockType)) return false; - return cBlockInfo::RequiresSpecialTool(a_BlockType); -} - - - - diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 85406c826..604cce729 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -328,12 +328,9 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const if (a_Player->IsGameModeSurvival()) { - if (!BlockRequiresSpecialTool(Block) || CanHarvestBlock(Block)) - { - cChunkInterface ChunkInterface(a_World->GetChunkMap()); - cBlockInServerPluginInterface PluginInterface(*a_World); - Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ); - } + cChunkInterface ChunkInterface(a_World->GetChunkMap()); + cBlockInServerPluginInterface PluginInterface(*a_World); + Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block)); } a_Player->UseEquippedItem(); -- cgit v1.2.3 From fba93aac2aa90fa654fef9fe4252042aae53893f Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 17 Jul 2014 23:32:01 +0200 Subject: Split into more lines. --- src/Mobs/Slime.cpp | 14 +++++++++----- src/Mobs/Slime.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp index d74b66e5b..4e12fca51 100644 --- a/src/Mobs/Slime.cpp +++ b/src/Mobs/Slime.cpp @@ -11,7 +11,13 @@ /// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest cSlime::cSlime(int a_Size) : - super("Slime", mtSlime, Printf("mob.slime.%s", GetSizeName(a_Size).c_str()), Printf("mob.slime.%s", GetSizeName(a_Size).c_str()), 0.6 * a_Size, 0.6 * a_Size), + super("Slime", + mtSlime, + Printf("mob.slime.%s", GetSizeName(a_Size).c_str()), + Printf("mob.slime.%s", GetSizeName(a_Size).c_str()), + 0.6 * a_Size, + 0.6 * a_Size + ), m_Size(a_Size) { SetMaxHealth(a_Size * a_Size); @@ -72,9 +78,7 @@ void cSlime::KilledBy(TakeDamageInfo & a_TDI) cSlime * NewSlime = new cSlime(m_Size / 2); NewSlime->SetPosition(GetPosX() + AddX, GetPosY() + 0.5, GetPosZ() + AddZ); - NewSlime->SetYaw(Random.NextFloat(2.0f) * 360.0f); - NewSlime->SetPitch(0.0f); - + NewSlime->SetYaw(Random.NextFloat(1.0f) * 360.0f); m_World->SpawnMobFinalize(NewSlime); } } @@ -85,7 +89,7 @@ void cSlime::KilledBy(TakeDamageInfo & a_TDI) -const AString & cSlime::GetSizeName(int a_Size) +const AString cSlime::GetSizeName(int a_Size) const { if (a_Size > 1) { diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h index 1f66d9afb..87c5a8e5e 100644 --- a/src/Mobs/Slime.h +++ b/src/Mobs/Slime.h @@ -23,7 +23,7 @@ public: virtual void KilledBy(TakeDamageInfo & a_TDI) override; int GetSize(void) const { return m_Size; } - const AString & GetSizeName(int a_Size); + const AString GetSizeName(int a_Size) const; protected: -- cgit v1.2.3 From bc94ad4b5ae089fe5ee984a827a0575926102bdc Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 14:34:58 -0700 Subject: Fixed NULL being passed instead of a double to AddEntityEffect --- src/Entities/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index a356ebba7..5c3303cb2 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -580,7 +580,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation) void cPlayer::FoodPoison(int a_NumTicks) { - AddEntityEffect(cEntityEffect::effHunger, a_NumTicks, 0, NULL); + AddEntityEffect(cEntityEffect::effHunger, a_NumTicks, 0, 1); } -- cgit v1.2.3 From 9c32e31edf7c283d939910f23b9f59edba0d2db6 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 01:02:25 +0200 Subject: Items should first added to the first slot, not the latest. --- src/ItemGrid.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp index cd36b1f2a..395547545 100644 --- a/src/ItemGrid.cpp +++ b/src/ItemGrid.cpp @@ -269,7 +269,7 @@ int cItemGrid::AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, i int cItemGrid::AddItem(cItem & a_ItemStack, bool a_AllowNewStacks, int a_PrioritarySlot) { int NumLeft = a_ItemStack.m_ItemCount; - int MaxStack = ItemHandler(a_ItemStack.m_ItemType)->GetMaxStackSize(); + int MaxStack = a_ItemStack.GetMaxStackSize(); // Try prioritarySlot first: if ( @@ -284,7 +284,7 @@ int cItemGrid::AddItem(cItem & a_ItemStack, bool a_AllowNewStacks, int a_Priorit } // Scan existing stacks: - for (int i = m_NumSlots - 1; i >= 0; i--) + for (int i = 0; i < m_NumSlots; i++) { if (m_Slots[i].IsEqual(a_ItemStack)) { @@ -302,7 +302,7 @@ int cItemGrid::AddItem(cItem & a_ItemStack, bool a_AllowNewStacks, int a_Priorit return (a_ItemStack.m_ItemCount - NumLeft); } - for (int i = m_NumSlots - 1; i >= 0; i--) + for (int i = 0; i < m_NumSlots; i++) { if (m_Slots[i].IsEmpty()) { -- cgit v1.2.3 From 2e9aed793a5d4cde9fc93913ca0769fb1a913346 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 01:16:49 +0200 Subject: Fixed the armor slot in creative mode. Also removed that armor get directly to the armor slot. It is extremely buggy and unnecessary. --- src/Inventory.cpp | 9 --------- src/UI/SlotArea.cpp | 13 +++++++++++++ 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 38d3c886d..18154bafd 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -102,15 +102,6 @@ int cInventory::AddItem(const cItem & a_Item, bool a_AllowNewStacks, bool a_tryT { cItem ToAdd(a_Item); int res = 0; - if (ItemCategory::IsArmor(a_Item.m_ItemType)) - { - res = m_ArmorSlots.AddItem(ToAdd, a_AllowNewStacks); - ToAdd.m_ItemCount -= res; - if (ToAdd.m_ItemCount == 0) - { - return res; - } - } res += m_HotbarSlots.AddItem(ToAdd, a_AllowNewStacks, a_tryToFillEquippedFirst ? m_EquippedSlotNum : -1); ToAdd.m_ItemCount = a_Item.m_ItemCount - res; diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 21b6ed0c8..f331c2fc2 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1866,6 +1866,19 @@ void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C { ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots())); + if (a_Player.IsGameModeCreative() && (m_ParentWindow.GetWindowType() == cWindow::wtInventory)) + { + if ((a_ClickAction == caDropKey) || (a_ClickAction == caCtrlDropKey)) + { + DropClicked(a_Player, a_SlotNum, (a_ClickAction == caCtrlDropKey)); + return; + } + + // Creative inventory must treat a_ClickedItem as a DraggedItem instead, replacing the inventory slot with it + SetSlot(a_SlotNum, a_Player, a_ClickedItem); + return; + } + bool bAsync = false; if (GetSlot(a_SlotNum, a_Player) == NULL) { -- cgit v1.2.3 From 33bd78dcdd1f080ef5d3b47b0e24099227a8a5d5 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 01:26:27 +0200 Subject: Skeletons should spawn with a bow in the hand. Fixes #1184 --- src/Mobs/Skeleton.cpp | 15 +++++++++++++++ src/Mobs/Skeleton.h | 2 ++ 2 files changed, 17 insertions(+) (limited to 'src') diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index 0641a3d57..2f57bedeb 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -4,6 +4,7 @@ #include "Skeleton.h" #include "../World.h" #include "../Entities/ArrowEntity.h" +#include "ClientHandle.h" @@ -90,3 +91,17 @@ void cSkeleton::Attack(float a_Dt) m_AttackInterval = 0.0; } } + + + + + +void cSkeleton::SpawnOn(cClientHandle & a_ClientHandle) +{ + super::SpawnOn(a_ClientHandle); + a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_BOW)); +} + + + + diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h index 8f31b42e1..229462d63 100644 --- a/src/Mobs/Skeleton.h +++ b/src/Mobs/Skeleton.h @@ -20,6 +20,8 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void MoveToPosition(const Vector3f & a_Position) override; virtual void Attack(float a_Dt) override; + virtual void SpawnOn(cClientHandle & a_ClientHandle) override; + bool IsWither(void) const { return m_bIsWither; }; private: -- cgit v1.2.3 From eeacb6f2223f88a64ce877458c58fa60194e45a6 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 02:19:30 +0200 Subject: Added a extra wall sign handler. Fixes #1119 --- src/Blocks/BlockHandler.cpp | 7 +-- src/Blocks/BlockSign.h | 109 -------------------------------------------- src/Blocks/BlockSignPost.h | 103 +++++++++++++++++++++++++++++++++++++++++ src/Blocks/BlockWallSign.h | 62 +++++++++++++++++++++++++ src/Items/ItemSign.h | 7 +-- 5 files changed, 173 insertions(+), 115 deletions(-) delete mode 100644 src/Blocks/BlockSign.h create mode 100644 src/Blocks/BlockSignPost.h create mode 100644 src/Blocks/BlockWallSign.h (limited to 'src') diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 97762f9bd..8ab4116f4 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -70,7 +70,7 @@ #include "BlockSand.h" #include "BlockSapling.h" #include "BlockSideways.h" -#include "BlockSign.h" +#include "BlockSignPost.h" #include "BlockSlab.h" #include "BlockSnow.h" #include "BlockStairs.h" @@ -81,6 +81,7 @@ #include "BlockTorch.h" #include "BlockTrapdoor.h" #include "BlockVine.h" +#include "BlockWallSign.h" #include "BlockWorkbench.h" @@ -275,7 +276,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_SAND: return new cBlockSandHandler (a_BlockType); case E_BLOCK_SANDSTONE_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_SAPLING: return new cBlockSaplingHandler (a_BlockType); - case E_BLOCK_SIGN_POST: return new cBlockSignHandler (a_BlockType); + case E_BLOCK_SIGN_POST: return new cBlockSignPostHandler (a_BlockType); case E_BLOCK_SNOW: return new cBlockSnowHandler (a_BlockType); case E_BLOCK_SPRUCE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_STAINED_GLASS: return new cBlockGlassHandler (a_BlockType); @@ -297,7 +298,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_TRIPWIRE: return new cBlockTripwireHandler (a_BlockType); case E_BLOCK_TRIPWIRE_HOOK: return new cBlockTripwireHookHandler (a_BlockType); case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType); - case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType); // TODO: This needs a special handler + case E_BLOCK_WALLSIGN: return new cBlockWallSignHandler (a_BlockType); case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType); case E_BLOCK_WOODEN_BUTTON: return new cBlockButtonHandler (a_BlockType); case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (a_BlockType); diff --git a/src/Blocks/BlockSign.h b/src/Blocks/BlockSign.h deleted file mode 100644 index 5aa8ade3d..000000000 --- a/src/Blocks/BlockSign.h +++ /dev/null @@ -1,109 +0,0 @@ - -#pragma once - -#include "BlockHandler.h" -#include "../Entities/Player.h" -#include "Chunk.h" - - - - - -class cBlockSignHandler : - public cBlockHandler -{ -public: - cBlockSignHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) - { - } - - - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0)); - } - - - virtual const char * GetStepSound(void) override - { - return "step.wood"; - } - - - static NIBBLETYPE RotationToMetaData(double a_Rotation) - { - a_Rotation += 180 + (180 / 16); // So it's not aligned with axis - if (a_Rotation > 360) - { - a_Rotation -= 360; - } - - a_Rotation = (a_Rotation / 360) * 16; - - return ((char)a_Rotation) % 16; - } - - - static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) - { - switch (a_Direction) - { - case 0x2: return 0x2; - case 0x3: return 0x3; - case 0x4: return 0x4; - case 0x5: return 0x5; - default: - { - break; - } - } - return 0x2; - } - - - virtual void OnPlacedByPlayer( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, - int a_CursorX, int a_CursorY, int a_CursorZ, - BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta - ) override - { - a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ); - } - - - virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override - { - return (a_Meta + 4) & 0x0f; - } - - - virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override - { - return (a_Meta + 12) & 0x0f; - } - - virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override - { - // Mirrors signs over the XY plane (North-South Mirroring) - - // There are 16 meta values which correspond to different directions. - // These values are equated to angles on a circle; 0x08 = 180 degrees. - return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta); - } - - - virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override - { - // Mirrors signs over the YZ plane (East-West Mirroring) - - // There are 16 meta values which correspond to different directions. - // These values are equated to angles on a circle; 0x10 = 360 degrees. - return 0x10 - a_Meta; - } -} ; - - - - diff --git a/src/Blocks/BlockSignPost.h b/src/Blocks/BlockSignPost.h new file mode 100644 index 000000000..d5b0c0b5f --- /dev/null +++ b/src/Blocks/BlockSignPost.h @@ -0,0 +1,103 @@ + +#pragma once + +#include "BlockHandler.h" +#include "../Entities/Player.h" +#include "Chunk.h" + + + + + +class cBlockSignPostHandler : + public cBlockHandler +{ +public: + cBlockSignPostHandler(BLOCKTYPE a_BlockType) + : cBlockHandler(a_BlockType) + { + } + + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0)); + } + + + virtual const char * GetStepSound(void) override + { + return "step.wood"; + } + + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override + { + if (a_RelY <= 0) + { + return false; + } + + return (cBlockInfo::IsSolid(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ))); + } + + + static NIBBLETYPE RotationToMetaData(double a_Rotation) + { + a_Rotation += 180 + (180 / 16); // So it's not aligned with axis + if (a_Rotation > 360) + { + a_Rotation -= 360; + } + + a_Rotation = (a_Rotation / 360) * 16; + + return ((char)a_Rotation) % 16; + } + + + virtual void OnPlacedByPlayer( + cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_CursorX, int a_CursorY, int a_CursorZ, + BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta + ) override + { + a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ); + } + + + virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override + { + return (a_Meta + 4) & 0x0f; + } + + + virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override + { + return (a_Meta + 12) & 0x0f; + } + + virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override + { + // Mirrors signs over the XY plane (North-South Mirroring) + + // There are 16 meta values which correspond to different directions. + // These values are equated to angles on a circle; 0x08 = 180 degrees. + return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta); + } + + + virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override + { + // Mirrors signs over the YZ plane (East-West Mirroring) + + // There are 16 meta values which correspond to different directions. + // These values are equated to angles on a circle; 0x10 = 360 degrees. + return 0x10 - a_Meta; + } +} ; + + + + diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h new file mode 100644 index 000000000..037a7bd19 --- /dev/null +++ b/src/Blocks/BlockWallSign.h @@ -0,0 +1,62 @@ + +#pragma once + +#include "Chunk.h" + + + + + +class cBlockWallSignHandler : + public cBlockSignPostHandler +{ +public: + cBlockWallSignHandler(BLOCKTYPE a_BlockType) + : cBlockSignPostHandler(a_BlockType) + { + } + + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override + { + int BlockX = (a_Chunk.GetPosX() * cChunkDef::Width) + a_RelX; + int BlockZ = (a_Chunk.GetPosZ() * cChunkDef::Width) + a_RelZ; + GetBlockCoordsBehindTheSign(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ), BlockX, BlockZ); + + return (cBlockInfo::IsSolid(a_ChunkInterface.GetBlock(BlockX, a_RelY, BlockZ))); + } + + + virtual void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ) + { + switch (a_BlockMeta) + { + case 2: a_BlockZ++; break; + case 3: a_BlockZ--; break; + case 4: a_BlockX++; break; + case 5: a_BlockX--; break; + default: break; + } + } + + + static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) + { + switch (a_Direction) + { + case 0x2: return 0x2; + case 0x3: return 0x3; + case 0x4: return 0x4; + case 0x5: return 0x5; + default: + { + break; + } + } + return 0x2; + } +} ; + + + + diff --git a/src/Items/ItemSign.h b/src/Items/ItemSign.h index 235a4fa93..0fa0fa0be 100644 --- a/src/Items/ItemSign.h +++ b/src/Items/ItemSign.h @@ -3,7 +3,8 @@ #include "ItemHandler.h" #include "../World.h" -#include "../Blocks/BlockSign.h" +#include "../Blocks/BlockSignPost.h" +#include "../Blocks/BlockWallSign.h" @@ -34,12 +35,12 @@ public: { if (a_BlockFace == BLOCK_FACE_TOP) { - a_BlockMeta = cBlockSignHandler::RotationToMetaData(a_Player->GetYaw()); + a_BlockMeta = cBlockSignPostHandler::RotationToMetaData(a_Player->GetYaw()); a_BlockType = E_BLOCK_SIGN_POST; } else { - a_BlockMeta = cBlockSignHandler::DirectionToMetaData(a_BlockFace); + a_BlockMeta = cBlockWallSignHandler::DirectionToMetaData(a_BlockFace); a_BlockType = E_BLOCK_WALLSIGN; } return true; -- cgit v1.2.3 From 32b25ec7f799ca15fdcdc3e9e9535c798d0cc523 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 18:34:47 -0700 Subject: Generator: removed rnd definitions that are never read --- src/Generating/MineShafts.cpp | 1 - src/Generating/StructGen.cpp | 1 - 2 files changed, 2 deletions(-) (limited to 'src') diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index e951b90fa..0532aff39 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -997,7 +997,6 @@ cMineShaft * cMineShaftCrossing::CreateAndFit( BoundingBox.p2.y -= 4; } } - rnd >>= 2; switch (a_Direction) { case dirXP: BoundingBox.p2.x += 4; BoundingBox.p1.z -= 2; BoundingBox.p2.z += 2; break; diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp index 5deded17d..054eec345 100644 --- a/src/Generating/StructGen.cpp +++ b/src/Generating/StructGen.cpp @@ -484,7 +484,6 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a const int BubbleY = 4 + (Rnd & 0x01); // 4 .. 5 Rnd >>= 1; const int BubbleZ = BubbleR + (Rnd % Range); - Rnd >>= 4; const int HalfR = BubbleR / 2; // 1 .. 2 const int RSquared = BubbleR * BubbleR; for (int y = -HalfR; y <= HalfR; y++) -- cgit v1.2.3 From 33b0a719da8ed8f76397f6003a5a9afa7079c090 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 18:39:44 -0700 Subject: ProtocolRecognizer.cpp: removed unused NumBytesRead --- src/Protocol/ProtocolRecognizer.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index d3aae65fe..3991b84de 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -953,7 +953,6 @@ bool cProtocolRecognizer::TryRecognizeLengthlessProtocol(void) bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRemaining) { UInt32 PacketType; - UInt32 NumBytesRead = (UInt32)m_Buffer.GetReadableSpace(); if (!m_Buffer.ReadVarInt(PacketType)) { return false; @@ -972,7 +971,6 @@ bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRema { return false; } - NumBytesRead -= (UInt32)m_Buffer.GetReadableSpace(); switch (ProtocolVersion) { case PROTO_VERSION_1_7_2: -- cgit v1.2.3 From ffe44c13d0ce037efb01544b96fe0756d64b8517 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 23:25:14 -0700 Subject: Moved ChatColor.h out of defines where it was not needed --- src/Defines.h | 1 - src/Entities/Player.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Defines.h b/src/Defines.h index 877970ab8..f57e63c7f 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -1,7 +1,6 @@ #pragma once -#include "ChatColor.h" #include #include diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 5c3303cb2..ea11926b8 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Player.h" +#include "../ChatColor.h" #include "../Server.h" #include "../UI/Window.h" #include "../UI/WindowOwner.h" -- cgit v1.2.3 From d52a51f7b6530d2a63682798472840d7261ebad4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 09:18:00 +0200 Subject: Removed duplicate IPvX labels. --- src/HTTPServer/HTTPServer.cpp | 4 ++-- src/RCONServer.cpp | 4 ++-- src/Server.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp index b7edf7829..8eabe5cb2 100644 --- a/src/HTTPServer/HTTPServer.cpp +++ b/src/HTTPServer/HTTPServer.cpp @@ -122,8 +122,8 @@ class cDebugCallbacks : // cHTTPServer: cHTTPServer::cHTTPServer(void) : - m_ListenThreadIPv4(*this, cSocket::IPv4, "WebServer IPv4"), - m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer IPv6"), + m_ListenThreadIPv4(*this, cSocket::IPv4, "WebServer"), + m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer"), m_Callbacks(NULL) { } diff --git a/src/RCONServer.cpp b/src/RCONServer.cpp index 28cb1e03b..141c67d1b 100644 --- a/src/RCONServer.cpp +++ b/src/RCONServer.cpp @@ -78,8 +78,8 @@ protected: cRCONServer::cRCONServer(cServer & a_Server) : m_Server(a_Server), - m_ListenThread4(*this, cSocket::IPv4, "RCON IPv4"), - m_ListenThread6(*this, cSocket::IPv6, "RCON IPv6") + m_ListenThread4(*this, cSocket::IPv4, "RCON"), + m_ListenThread6(*this, cSocket::IPv6, "RCON") { } diff --git a/src/Server.cpp b/src/Server.cpp index bc9644804..10a354a36 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -105,8 +105,8 @@ void cServer::cTickThread::Execute(void) // cServer: cServer::cServer(void) : - m_ListenThreadIPv4(*this, cSocket::IPv4, "Client IPv4"), - m_ListenThreadIPv6(*this, cSocket::IPv6, "Client IPv6"), + m_ListenThreadIPv4(*this, cSocket::IPv4, "Client"), + m_ListenThreadIPv6(*this, cSocket::IPv6, "Client"), m_PlayerCount(0), m_PlayerCountDiff(0), m_ClientViewDistance(0), -- cgit v1.2.3 From 2df5e26d3b7f08ef7d120511705fa0b75a44783e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 09:57:34 +0200 Subject: Fixed spaces before commas. --- src/BiomeDef.cpp | 2 +- src/BlockEntities/ChestEntity.cpp | 4 ++-- src/ChunkMap.cpp | 4 ++-- src/Generating/FinishGen.cpp | 4 ++-- src/Generating/HeiGen.cpp | 4 ++-- src/Mobs/Monster.h | 6 +++--- src/Simulator/IncrementalRedstoneSimulator.cpp | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index 9852b3dd9..d680377e2 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -15,7 +15,7 @@ static struct { const char * m_String; } g_BiomeMap[] = { - {biOcean, "Ocean"} , + {biOcean, "Ocean"}, {biPlains, "Plains"}, {biDesert, "Desert"}, {biExtremeHills, "ExtremeHills"}, diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index 9f50365e9..21e1f6ba2 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -169,8 +169,8 @@ void cChestEntity::OpenNewWindow(void) if ( m_World->DoWithChestAt(m_PosX - 1, m_PosY, m_PosZ, OpenDbl) || m_World->DoWithChestAt(m_PosX + 1, m_PosY, m_PosZ, OpenDbl) || - m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ - 1, OpenDbl) || - m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ + 1, OpenDbl) + m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ - 1, OpenDbl) || + m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ + 1, OpenDbl) ) { // The double-chest window has been opened in the callback diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 9f280f1c5..e91f77d27 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2762,8 +2762,8 @@ cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_Ch { cChunk * neixm = (LocalX > 0) ? m_Chunks[Index - 1] : m_Parent->FindChunk(a_ChunkX - 1, a_ChunkZ); cChunk * neixp = (LocalX < LAYER_SIZE - 1) ? m_Chunks[Index + 1] : m_Parent->FindChunk(a_ChunkX + 1, a_ChunkZ); - cChunk * neizm = (LocalZ > 0) ? m_Chunks[Index - LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ - 1); - cChunk * neizp = (LocalZ < LAYER_SIZE - 1) ? m_Chunks[Index + LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ + 1); + cChunk * neizm = (LocalZ > 0) ? m_Chunks[Index - LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX, a_ChunkZ - 1); + cChunk * neizp = (LocalZ < LAYER_SIZE - 1) ? m_Chunks[Index + LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX, a_ChunkZ + 1); m_Chunks[Index] = new cChunk(a_ChunkX, 0, a_ChunkZ, m_Parent, m_Parent->GetWorld(), neixm, neixp, neizm, neizp, m_Pool); } return m_Chunks[Index]; diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 13871bbd8..00a93023d 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -193,8 +193,8 @@ bool cFinishGenSprinkleFoliage::TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_ if ( !IsWater(a_ChunkDesc.GetBlockType(a_RelX - 1, a_RelY, a_RelZ)) && !IsWater(a_ChunkDesc.GetBlockType(a_RelX + 1, a_RelY, a_RelZ)) && - !IsWater(a_ChunkDesc.GetBlockType(a_RelX , a_RelY, a_RelZ - 1)) && - !IsWater(a_ChunkDesc.GetBlockType(a_RelX , a_RelY, a_RelZ + 1)) + !IsWater(a_ChunkDesc.GetBlockType(a_RelX, a_RelY, a_RelZ - 1)) && + !IsWater(a_ChunkDesc.GetBlockType(a_RelX, a_RelY, a_RelZ + 1)) ) { return false; diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index b02e06951..3df1a90ff 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -283,7 +283,7 @@ void cHeiGenClassic::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightM { hei = 250; } - cChunkDef::SetHeight(a_HeightMap, x , z, hei); + cChunkDef::SetHeight(a_HeightMap, x, z, hei); } // for x } // for z } @@ -345,7 +345,7 @@ void cHeiGenMountains::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::Heigh { hei = 250; } - cChunkDef::SetHeight(a_HeightMap, x , z, hei); + cChunkDef::SetHeight(a_HeightMap, x, z, hei); } // for x } // for z } diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 750040468..6e14e3b18 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -76,9 +76,9 @@ public: enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality; /** Creates the mob object. - * If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig() - * a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs , 2012_12_22)) - * a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively + If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig() + a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs 2012_12_22)) + a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively */ cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 8e5e40fb5..3dd6417dc 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -724,7 +724,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int X Axis ----> - Repeater directions, values from a cWorld::GetBlockMeta(a_RelBlockX , a_RelBlockY, a_RelBlockZ) lookup: + Repeater directions, values from a cWorld::GetBlockMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) lookup: East (Right) (X+): 0x1 West (Left) (X-): 0x3 @@ -1723,7 +1723,7 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc { continue; } - a_PowerLevel = std::max(itr->a_PowerLevel , a_PowerLevel); // Get the highest power level (a_PowerLevel is initialised already and there CAN be multiple levels for one block) + a_PowerLevel = std::max(itr->a_PowerLevel, a_PowerLevel); // Get the highest power level (a_PowerLevel is initialised already and there CAN be multiple levels for one block) } for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list -- cgit v1.2.3 From 204b59117225268a569fb68614bb59add4d53a03 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 09:58:29 +0200 Subject: CheckBasicStyle: Proper spaces with commas. --- src/CheckBasicStyle.lua | 69 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index f9bb41975..6aad4125d 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -6,13 +6,16 @@ Checks that all source files (*.cpp, *.h) use the basic style requirements of th - Tabs for indentation, spaces for alignment - Trailing whitespace on non-empty lines - Two spaces between code and line-end comment ("//") - - (TODO) Spaces around +, -, (cannot check /, * or & due to their other usage - comment, ptr deref, address-of) + - Spaces after comma, not before (except in #define argument list) - (TODO) Spaces before *, /, & - - (TODO) Spaces after , - (TODO) Hex numbers with even digit length - (TODO) Hex numbers in lowercase - (TODO) Braces not on the end of line - (TODO) Line dividers (////...) exactly 80 slashes + - (TODO) Not using "* "-style doxy comments continuation lines + +Violations that cannot be checked easily: + - Spaces around "+" (there are things like "a++", "++a", "a += 1", "X+", "stack +1" and ascii-drawn tables) Reports all violations on stdout in a form that is readable by Visual Studio's parser, so that dblclicking the line brings the editor directly to the violation. @@ -85,6 +88,45 @@ end +--- Searches for the specified pattern, if found, reports it as a violation with the given message +local function ReportViolationIfFound(a_Line, a_FileName, a_LineNum, a_Pattern, a_Message) + local patStart, patEnd = a_Line:find(a_Pattern) + if not(patStart) then + return + end + ReportViolation(a_FileName, a_LineNum, a_Message .. "(" .. patStart .. " .. " .. patEnd .. ")") +end + + + + + +local g_ViolationPatterns = +{ + -- Check against indenting using spaces: + {"^\t* +", "Indenting with a space"}, + + -- Check against alignment using tabs: + {"[^%s]\t+[^%s]", "Aligning with a tab"}, + + -- Check against trailing whitespace: + {"[^%s]%s+\n", "Trailing whitespace"}, + + -- Check that all "//"-style comments have at least two spaces in front (unless alone on line): + {"[^%s] //", "Needs at least two spaces in front of a \"//\"-style comment"}, + + -- Check that all "//"-style comments have at least one spaces after: + {"%s//[^%s/*<]", "Needs a space after a \"//\"-style comment"}, + + -- Check that all commas have spaces after them and not in front of them: + {" ,", "Extra space before a \",\""}, + {"^\t*[^#].*,[^%s]", "Needs a space after a \",\""}, -- Anywhere except lines starting with "#" - avoid #define params +} + + + + + --- Processes one file local function ProcessFile(a_FileName) assert(type(a_FileName) == "string") @@ -113,26 +155,11 @@ local function ProcessFile(a_FileName) all:gsub("\r\n", "\n") -- normalize CRLF into LF-only string.gsub(all .. "\n", "[^\n]*\n", -- Iterate over each line, while preserving empty lines function(a_Line) - -- Check against indenting using spaces: - if (a_Line:find("^\t* +")) then -- Find any number of tabs at the start of line (incl 0), followed by a space - ReportViolation(a_FileName, lineCounter, "Indenting with a space") - end - -- Check against alignment using tabs: - if (a_Line:find("[^%s]\t+[^%s]")) then -- Find any number of tabs after non-whitespace followed by non-whitespace - ReportViolation(a_FileName, lineCounter, "Aligning with a tab") - end - -- Check against trailing whitespace: - if (a_Line:find("[^%s]%s+\n")) then -- Find any whitespace after non-whitespace at the end of line - ReportViolation(a_FileName, lineCounter, "Trailing whitespace") - end - -- Check that all "//"-style comments have at least two spaces in front (unless alone on line): - if (a_Line:find("[^%s] //")) then - ReportViolation(a_FileName, lineCounter, "Needs at least two spaces in front of a \"//\"-style comment") - end - -- Check that all "//"-style comments have at least one spaces after: - if (a_Line:find("%s//[^%s/*<]")) then - ReportViolation(a_FileName, lineCounter, "Needs a space after a \"//\"-style comment") + -- Check against each violation pattern: + for _, pat in ipairs(g_ViolationPatterns) do + ReportViolationIfFound(a_Line, a_FileName, lineCounter, pat[1], pat[2]) end + lineCounter = lineCounter + 1 end ) -- cgit v1.2.3 From 9529a4255999efc0970d82385ef1ff07c62a7a02 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 01:56:26 -0700 Subject: Fixed creative players not being able to drink Fixes #1215 --- src/ClientHandle.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 97466c331..58247a836 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1209,11 +1209,12 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e { HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); } - else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage)) && !m_Player->IsGameModeCreative()) + else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage))) { - if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(EquippedDamage)) + if ((m_Player->IsSatiated() || m_Player->IsGameModeCreative()) && + ItemHandler->IsFood()) { - // The player is satiated, they cannot eat + // The player is satiated or in creative, and trying to eat return; } m_Player->StartEating(); -- cgit v1.2.3 From f1be1eb6743700515de3a522898ba99680cf24c0 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 18 Jul 2014 10:47:00 +0100 Subject: Monster fixes * Fixes #1203 * Fixes #627 --- src/BlockInfo.cpp | 4 ---- src/Mobs/Monster.cpp | 27 +-------------------------- src/Mobs/Monster.h | 1 - src/Mobs/Skeleton.cpp | 2 +- src/Mobs/Skeleton.h | 2 +- src/Mobs/Zombie.cpp | 2 +- src/Mobs/Zombie.h | 2 +- 7 files changed, 5 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index b4b98a2f0..97e89359f 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -496,9 +496,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_CROPS ].m_IsSolid = false; a_Info[E_BLOCK_DANDELION ].m_IsSolid = false; a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false; - a_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false; - a_Info[E_BLOCK_FENCE ].m_IsSolid = false; - a_Info[E_BLOCK_FENCE_GATE ].m_IsSolid = false; a_Info[E_BLOCK_FIRE ].m_IsSolid = false; a_Info[E_BLOCK_FLOWER ].m_IsSolid = false; a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false; @@ -530,7 +527,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_WATER ].m_IsSolid = false; a_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false; a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false; - a_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false; // Blocks that fully occupy their voxel - used as a guide for torch placeable blocks, amongst other things: diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index ba901df4e..1369746df 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -115,8 +115,6 @@ void cMonster::TickPathFinding() const int PosY = POSY_TOINT; const int PosZ = POSZ_TOINT; - m_FinalDestination.y = (double)FindFirstNonAirBlockPosition(m_FinalDestination.x, m_FinalDestination.z); - std::vector m_PotentialCoordinates; m_TraversedCoordinates.push_back(Vector3i(PosX, PosY, PosZ)); @@ -201,19 +199,6 @@ void cMonster::TickPathFinding() -void cMonster::MoveToPosition(const Vector3f & a_Position) -{ - FinishPathFinding(); - - m_FinalDestination = a_Position; - m_bMovingToDestination = true; - TickPathFinding(); -} - - - - - void cMonster::MoveToPosition(const Vector3d & a_Position) { FinishPathFinding(); @@ -227,15 +212,7 @@ void cMonster::MoveToPosition(const Vector3d & a_Position) bool cMonster::IsCoordinateInTraversedList(Vector3i a_Coords) { - for (std::vector::const_iterator itr = m_TraversedCoordinates.begin(); itr != m_TraversedCoordinates.end(); ++itr) - { - if (itr->Equals(a_Coords)) - { - return true; - } - } - - return false; + return (std::find(m_TraversedCoordinates.begin(), m_TraversedCoordinates.end(), a_Coords) != m_TraversedCoordinates.end()); } @@ -296,8 +273,6 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) { if (m_bOnGround) { - m_Destination.y = FindFirstNonAirBlockPosition(m_Destination.x, m_Destination.z); - if (DoesPosYRequireJump((int)floor(m_Destination.y))) { m_bOnGround = false; diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 6e14e3b18..4af7cf4f1 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -92,7 +92,6 @@ public: virtual void KilledBy(TakeDamageInfo & a_TDI) override; - virtual void MoveToPosition(const Vector3f & a_Position); virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export virtual bool ReachedDestination(void); diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index 2f57bedeb..cd707f4bb 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -48,7 +48,7 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cSkeleton::MoveToPosition(const Vector3f & a_Position) +void cSkeleton::MoveToPosition(const Vector3d & a_Position) { // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement if ( diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h index 229462d63..efb670c83 100644 --- a/src/Mobs/Skeleton.h +++ b/src/Mobs/Skeleton.h @@ -18,7 +18,7 @@ public: CLASS_PROTODEF(cSkeleton); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void MoveToPosition(const Vector3f & a_Position) override; + virtual void MoveToPosition(const Vector3d & a_Position) override; virtual void Attack(float a_Dt) override; virtual void SpawnOn(cClientHandle & a_ClientHandle) override; diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp index 725790ed9..30225c32d 100644 --- a/src/Mobs/Zombie.cpp +++ b/src/Mobs/Zombie.cpp @@ -42,7 +42,7 @@ void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cZombie::MoveToPosition(const Vector3f & a_Position) +void cZombie::MoveToPosition(const Vector3d & a_Position) { // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement if ( diff --git a/src/Mobs/Zombie.h b/src/Mobs/Zombie.h index 1ba368f9c..c56409570 100644 --- a/src/Mobs/Zombie.h +++ b/src/Mobs/Zombie.h @@ -17,7 +17,7 @@ public: CLASS_PROTODEF(cZombie); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void MoveToPosition(const Vector3f & a_Position) override; + virtual void MoveToPosition(const Vector3d & a_Position) override; bool IsVillagerZombie(void) const {return m_IsVillagerZombie; } bool IsConverting (void) const {return m_IsConverting; } -- cgit v1.2.3 From e32b0ce4fa1e81c48a5036bc4c43112fda7ffada Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 16:38:59 +0200 Subject: Moved comment. --- src/UI/SlotArea.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index f331c2fc2..6f4f65ca3 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1866,6 +1866,7 @@ void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C { ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots())); + // Creative inventory must treat a_ClickedItem as a DraggedItem instead, replacing the inventory slot with it if (a_Player.IsGameModeCreative() && (m_ParentWindow.GetWindowType() == cWindow::wtInventory)) { if ((a_ClickAction == caDropKey) || (a_ClickAction == caCtrlDropKey)) @@ -1874,7 +1875,6 @@ void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C return; } - // Creative inventory must treat a_ClickedItem as a DraggedItem instead, replacing the inventory slot with it SetSlot(a_SlotNum, a_Player, a_ClickedItem); return; } -- cgit v1.2.3 From 509d3d3b62c2dc5b328cf122c0fc5f0595b73721 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 16:55:28 +0200 Subject: Slime sizes are 1, 2 or 4 and not 1, 2 or 3. --- src/Mobs/Monster.cpp | 2 +- src/Mobs/Slime.cpp | 4 ++-- src/Mobs/Slime.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index e36634c73..2a796e8eb 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -867,7 +867,7 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) } case mtSlime: { - toReturn = new cSlime(Random.NextInt(2) + 1); + toReturn = new cSlime(1 << Random.NextInt(3)); break; } case mtSkeleton: diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp index 4e12fca51..4b123df12 100644 --- a/src/Mobs/Slime.cpp +++ b/src/Mobs/Slime.cpp @@ -9,7 +9,6 @@ -/// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest cSlime::cSlime(int a_Size) : super("Slime", mtSlime, @@ -36,7 +35,8 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer) LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); } - if (GetSize() == 1) + // Only slimes with the size 1 can drop slimeballs. + if (m_Size == 1) { AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SLIMEBALL); } diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h index 87c5a8e5e..b0e2f627c 100644 --- a/src/Mobs/Slime.h +++ b/src/Mobs/Slime.h @@ -13,7 +13,7 @@ class cSlime : typedef cAggressiveMonster super; public: - /** Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest */ + /** Creates a slime of the specified size; size can be 1, 2 or 4, with 1 is the smallest and 4 is the tallest. */ cSlime(int a_Size); CLASS_PROTODEF(cSlime); -- cgit v1.2.3 From 44c944716b4fd933547d76d09bccce72e8959abb Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 17:04:01 +0200 Subject: Removed cBlockSignPostHandler descend. --- src/Blocks/BlockWallSign.h | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h index 037a7bd19..b0f4015b6 100644 --- a/src/Blocks/BlockWallSign.h +++ b/src/Blocks/BlockWallSign.h @@ -1,6 +1,8 @@ #pragma once +#include "BlockHandler.h" +#include "../Entities/Player.h" #include "Chunk.h" @@ -8,15 +10,39 @@ class cBlockWallSignHandler : - public cBlockSignPostHandler + public cBlockHandler { + typedef cBlockHandler super; public: cBlockWallSignHandler(BLOCKTYPE a_BlockType) - : cBlockSignPostHandler(a_BlockType) + : cBlockHandler(a_BlockType) { } + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0)); + } + + + virtual const char * GetStepSound(void) override + { + return "step.wood"; + } + + + virtual void OnPlacedByPlayer( + cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_CursorX, int a_CursorY, int a_CursorZ, + BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta + ) override + { + a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ); + } + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { int BlockX = (a_Chunk.GetPosX() * cChunkDef::Width) + a_RelX; -- cgit v1.2.3 From 719551c31f5ed0d3cbad9797dd81a6bf1ae4e5a2 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 18 Jul 2014 20:12:27 +0100 Subject: Fix failed merge and other issues --- src/ClientHandle.cpp | 4 ++-- src/ClientHandle.h | 2 +- src/Entities/Entity.cpp | 6 +++--- src/Entities/Player.cpp | 40 ++++++++------------------------------- src/Entities/Player.h | 11 +---------- src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.cpp | 2 +- src/Protocol/Protocol125.h | 2 +- src/Protocol/Protocol16x.h | 2 +- src/Protocol/Protocol17x.cpp | 2 +- src/Protocol/Protocol17x.h | 2 +- src/Protocol/ProtocolRecognizer.h | 2 +- src/World.cpp | 16 ++++++---------- src/World.h | 12 ------------ 14 files changed, 28 insertions(+), 77 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 1a18649c9..f90da94dd 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -2375,9 +2375,9 @@ void cClientHandle::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effec -void cClientHandle::SendRespawn(eDimension a_Dimension) +void cClientHandle::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) { - m_Protocol->SendRespawn(a_Dimension); + m_Protocol->SendRespawn(a_Dimension, a_ShouldIgnoreDimensionChecks); } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index cb0471421..e3c2b590f 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -161,7 +161,7 @@ public: void SendPlayerSpawn (const cPlayer & a_Player); void SendPluginMessage (const AString & a_Channel, const AString & a_Message); // Exported in ManualBindings.cpp void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID); - void SendRespawn (eDimension a_Dimension); + void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks = false); void SendExperience (void); void SendExperienceOrb (const cExpOrb & a_ExpOrb); void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode); diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index e5e4cf4cb..bd1839580 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1028,7 +1028,7 @@ void cEntity::DetectCacti(void) void cEntity::DetectPortal() { - if (!GetWorld()->AreNetherPortalsEnabled() && !GetWorld()->AreEndPortalsEnabled()) + if (!GetWorld()->GetNetherWorldName().empty() && !GetWorld()->GetEndWorldName().empty()) { return; } @@ -1040,7 +1040,7 @@ void cEntity::DetectPortal() { case E_BLOCK_NETHER_PORTAL: { - if (!GetWorld()->AreNetherPortalsEnabled() || m_PortalCooldownData.second) + if (GetWorld()->GetNetherWorldName().empty() || m_PortalCooldownData.second) { return; } @@ -1085,7 +1085,7 @@ void cEntity::DetectPortal() } case E_BLOCK_END_PORTAL: { - if (!GetWorld()->AreEndPortalsEnabled() || m_PortalCooldownData.second) + if (GetWorld()->GetNetherWorldName().empty() || m_PortalCooldownData.second) { return; } diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 1acc8a962..2a91600e7 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1695,12 +1695,7 @@ void cPlayer::LoadPermissionsFromDisk() -<<<<<<< HEAD bool cPlayer::LoadFromDisk(cWorldPtr & a_World) -======= - -bool cPlayer::LoadFromDisk(void) ->>>>>>> master { a_World = cRoot::Get()->GetWorld(GetLoadedWorldName()); if (a_World == NULL) @@ -1711,7 +1706,7 @@ bool cPlayer::LoadFromDisk(void) LoadPermissionsFromDisk(); // Load from the UUID file: - if (LoadFromFile(GetUUIDFileName(m_UUID))) + if (LoadFromFile(GetUUIDFileName(m_UUID), a_World)) { return true; } @@ -1720,7 +1715,7 @@ bool cPlayer::LoadFromDisk(void) AString OfflineUUID = cClientHandle::GenerateOfflineUUID(GetName()); if (cRoot::Get()->GetServer()->ShouldLoadOfflinePlayerData()) { - if (LoadFromFile(GetUUIDFileName(OfflineUUID))) + if (LoadFromFile(GetUUIDFileName(OfflineUUID), a_World)) { return true; } @@ -1730,7 +1725,7 @@ bool cPlayer::LoadFromDisk(void) if (cRoot::Get()->GetServer()->ShouldLoadNamedPlayerData()) { AString OldStyleFileName = Printf("players/%s.json", GetName().c_str()); - if (LoadFromFile(OldStyleFileName)) + if (LoadFromFile(OldStyleFileName, a_World)) { // Save in new format and remove the old file if (SaveToDisk()) @@ -1752,7 +1747,7 @@ bool cPlayer::LoadFromDisk(void) -bool cPlayer::LoadFromFile(const AString & a_FileName) +bool cPlayer::LoadFromFile(const AString & a_FileName, cWorld * a_World) { // Load the data from the file: cFile f; @@ -1860,28 +1855,6 @@ bool cPlayer::SaveToDisk() cEnderChestEntity::SaveToJson(JSON_EnderChestInventory, m_EnderChestContents); Json::Value root; -<<<<<<< HEAD - root["position"] = JSON_PlayerPosition; - root["rotation"] = JSON_PlayerRotation; - root["inventory"] = JSON_Inventory; - root["health"] = m_Health; - root["xpTotal"] = m_LifetimeTotalXp; - root["xpCurrent"] = m_CurrentXp; - root["air"] = m_AirLevel; - root["food"] = m_FoodLevel; - root["foodSaturation"] = m_FoodSaturationLevel; - root["foodTickTimer"] = m_FoodTickTimer; - root["foodExhaustion"] = m_FoodExhaustionLevel; - root["world"] = GetWorld()->GetName(); - root["isflying"] = IsFlying(); - root["SpawnX"] = GetLastBedPos().x; - root["SpawnY"] = GetLastBedPos().y; - root["SpawnZ"] = GetLastBedPos().z; - - if (m_GameMode == GetWorld()->GetGameMode()) - { - root["gamemode"] = (int) eGameMode_NotSet; -======= root["position"] = JSON_PlayerPosition; root["rotation"] = JSON_PlayerRotation; root["inventory"] = JSON_Inventory; @@ -1896,6 +1869,10 @@ bool cPlayer::SaveToDisk() root["foodExhaustion"] = m_FoodExhaustionLevel; root["isflying"] = IsFlying(); root["lastknownname"] = GetName(); + root["SpawnX"] = GetLastBedPos().x; + root["SpawnY"] = GetLastBedPos().y; + root["SpawnZ"] = GetLastBedPos().z; + if (m_World != NULL) { root["world"] = m_World->GetName(); @@ -1907,7 +1884,6 @@ bool cPlayer::SaveToDisk() { root["gamemode"] = (int) m_GameMode; } ->>>>>>> master } else { diff --git a/src/Entities/Player.h b/src/Entities/Player.h index f84cc5f55..ad434f036 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -326,11 +326,6 @@ public: virtual void Killed(cEntity * a_Victim) override; - void Respawn(void); // tolua_export - - void SetVisible(bool a_bVisible); // tolua_export - bool IsVisible(void) const { return m_bVisible; } // tolua_export - void Respawn(void); // tolua_export void SetVisible( bool a_bVisible ); // tolua_export @@ -352,7 +347,7 @@ Takes a (NULL) cWorld pointer which it will assign a value to based on either th /** Loads the player data from the specified file. Returns true on success, false on failure. */ - bool LoadFromFile(const AString & a_FileName); + bool LoadFromFile(const AString & a_FileName, cWorld * a_World); void LoadPermissionsFromDisk(void); // tolua_export @@ -544,8 +539,6 @@ protected: cStatManager m_Stats; -<<<<<<< HEAD -======= /** Flag representing whether the player is currently in a bed Set by a right click on unoccupied bed, unset by a time fast forward or teleport */ bool m_bIsInBed; @@ -563,8 +556,6 @@ protected: If no ClientHandle is given, the UUID is initialized to empty. */ AString m_UUID; - ->>>>>>> master /** Sets the speed and sends it to the client, so that they are forced to move so. */ virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override; diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index 7e9eed402..58dbfeff5 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -100,7 +100,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) = 0; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) = 0; - virtual void SendRespawn (eDimension a_Dimension) = 0; + virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) = 0; virtual void SendExperience (void) = 0; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) = 0; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 8cb34c128..320c1212c 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -836,7 +836,7 @@ void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect void cProtocol125::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) { cCSLock Lock(m_CSPacket); - if ((m_LastSentDimension == a_World.GetDimension()) && !a_ShouldIgnoreDimensionChecks) + if ((m_LastSentDimension == a_Dimension) && !a_ShouldIgnoreDimensionChecks) { // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do (unless we are respawning from death) return; diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 955e3e741..d1ed00b54 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -72,7 +72,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks = false) override; + virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; diff --git a/src/Protocol/Protocol16x.h b/src/Protocol/Protocol16x.h index 13866801a..add761d1e 100644 --- a/src/Protocol/Protocol16x.h +++ b/src/Protocol/Protocol16x.h @@ -42,7 +42,7 @@ protected: virtual void SendGameMode (eGameMode a_GameMode) override; virtual void SendHealth (void) override; virtual void SendPlayerMaxSpeed(void) override; - virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks = false) override; + virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) override; virtual void SendWindowOpen (const cWindow & a_Window) override; virtual int ParseEntityAction (void) override; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index a421e4da6..0ff0d0357 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -988,7 +988,7 @@ void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect void cProtocol172::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) { - if ((m_LastSentDimension == a_World.GetDimension()) && !a_ShouldIgnoreDimensionChecks) + if ((m_LastSentDimension == a_Dimension) && !a_ShouldIgnoreDimensionChecks) { // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do (unless we are respawning from death) return; diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 2d4005f57..be41abd64 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -104,7 +104,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks = false) override; + virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) override; virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index b78528e29..9c6c898ab 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -107,7 +107,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks = false) override; + virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; diff --git a/src/World.cpp b/src/World.cpp index e32771353..924d5adbb 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -527,7 +527,7 @@ void cWorld::Start(bool a_WasDimensionSet) AString Dimension = IniFile.GetValueSet("General", "Dimension", a_WasDimensionSet ? DimensionToString(GetDimension()) : "Overworld"); m_Dimension = StringToDimension(Dimension); - m_OverworldName = IniFile.GetValue("General", "OverworldName", a_WasDimensionSet ? m_OverworldName : ""); + m_OverworldName = IniFile.GetValue("LinkedWorlds", "OverworldName", a_WasDimensionSet ? m_OverworldName : ""); // Try to find the "SpawnPosition" key and coord values in the world configuration, set the flag if found int KeyNum = IniFile.FindKey("SpawnPosition"); @@ -577,10 +577,8 @@ void cWorld::Start(bool a_WasDimensionSet) if ((GetDimension() != dimNether) && (GetDimension() != dimEnd)) { - m_bNetherPortalsEnabled = IniFile.GetValueSetB("General", "NetherPortalsEnabled", true); - m_NetherWorldName = IniFile.GetValueSet("General", "NetherWorldName", DEFAULT_NETHER_NAME); - m_bEndPortalsEnabled = IniFile.GetValueSetB("General", "EndPortalsEnabled", true); - m_EndWorldName = IniFile.GetValueSet("General", "EndWorldName", DEFAULT_END_NAME); + m_NetherWorldName = IniFile.GetValueSet("LinkedWorlds", "NetherWorldName", DEFAULT_NETHER_NAME); + m_EndWorldName = IniFile.GetValueSet("LinkedWorlds", "EndWorldName", DEFAULT_END_NAME); } // Adjust the enum-backed variables into their respective bounds: @@ -757,14 +755,12 @@ void cWorld::Stop(void) IniFile.ReadFile(m_IniFileName); if ((GetDimension() != dimNether) && (GetDimension() != dimEnd)) { - IniFile.SetValueB("General", "NetherPortalsEnabled", m_bNetherPortalsEnabled); - IniFile.SetValue("General", "NetherWorldName", m_NetherWorldName); - IniFile.SetValueB("General", "EndPortalsEnabled", m_bEndPortalsEnabled); - IniFile.SetValue("General", "EndWorldName", m_EndWorldName); + IniFile.SetValue("LinkedWorlds", "NetherWorldName", m_NetherWorldName); + IniFile.SetValue("LinkedWorlds", "EndWorldName", m_EndWorldName); } else { - IniFile.SetValue("General", "OverworldName", m_OverworldName); + IniFile.SetValue("LinkedWorlds", "OverworldName", m_OverworldName); } IniFile.SetValueI("Physics", "TNTShrapnelLevel", (int)m_TNTShrapnelLevel); IniFile.SetValueB("Mechanics", "CommandBlocksEnabled", m_bCommandBlocksEnabled); diff --git a/src/World.h b/src/World.h index 92376b4a0..73b8b81b0 100644 --- a/src/World.h +++ b/src/World.h @@ -630,12 +630,6 @@ public: bool ShouldUseChatPrefixes(void) const { return m_bUseChatPrefixes; } void SetShouldUseChatPrefixes(bool a_Flag) { m_bUseChatPrefixes = a_Flag; } - bool AreNetherPortalsEnabled(void) const { return m_bNetherPortalsEnabled; } - void SetNetherPortalsEnabled(bool a_Flag) { m_bNetherPortalsEnabled = a_Flag; } - - bool AreEndPortalsEnabled(void) const { return m_bEndPortalsEnabled; } - void SetEndPortalsEnabled(bool a_Flag) { m_bEndPortalsEnabled = a_Flag; } - AString GetNetherWorldName(void) const { return m_NetherWorldName; } void SetNetherWorldName(const AString & a_Name) { m_NetherWorldName = a_Name; } @@ -938,12 +932,6 @@ private: */ eShrapnelLevel m_TNTShrapnelLevel; - /** Whether nether portals teleport entities */ - bool m_bNetherPortalsEnabled; - - /** Whether end portals teleport entities */ - bool m_bEndPortalsEnabled; - /** Name of the nether world */ AString m_NetherWorldName; -- cgit v1.2.3 From 23037ce7ec1f7ff290bd18f30d5fb25b91b5e61c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 22:41:48 +0200 Subject: Normalized code style for both sign handlers. --- src/Blocks/BlockSignPost.h | 19 +++++++++++-------- src/Blocks/BlockWallSign.h | 17 +++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockSignPost.h b/src/Blocks/BlockSignPost.h index d5b0c0b5f..ee65d099a 100644 --- a/src/Blocks/BlockSignPost.h +++ b/src/Blocks/BlockSignPost.h @@ -12,9 +12,11 @@ class cBlockSignPostHandler : public cBlockHandler { + typedef cBlockHandler super; + public: - cBlockSignPostHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + cBlockSignPostHandler(BLOCKTYPE a_BlockType) : + super(a_BlockType) { } @@ -78,22 +80,23 @@ public: return (a_Meta + 12) & 0x0f; } + virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override { - // Mirrors signs over the XY plane (North-South Mirroring) + // Mirrors signs over the XY plane (North-South Mirroring) - // There are 16 meta values which correspond to different directions. - // These values are equated to angles on a circle; 0x08 = 180 degrees. + // There are 16 meta values which correspond to different directions. + // These values are equated to angles on a circle; 0x08 = 180 degrees. return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta); } virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override { - // Mirrors signs over the YZ plane (East-West Mirroring) + // Mirrors signs over the YZ plane (East-West Mirroring) - // There are 16 meta values which correspond to different directions. - // These values are equated to angles on a circle; 0x10 = 360 degrees. + // There are 16 meta values which correspond to different directions. + // These values are equated to angles on a circle; 0x10 = 360 degrees. return 0x10 - a_Meta; } } ; diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h index b0f4015b6..e837b315e 100644 --- a/src/Blocks/BlockWallSign.h +++ b/src/Blocks/BlockWallSign.h @@ -13,9 +13,10 @@ class cBlockWallSignHandler : public cBlockHandler { typedef cBlockHandler super; + public: - cBlockWallSignHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + cBlockWallSignHandler(BLOCKTYPE a_BlockType) : + super(a_BlockType) { } @@ -53,15 +54,15 @@ public: } - virtual void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ) + static void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ) { switch (a_BlockMeta) { - case 2: a_BlockZ++; break; - case 3: a_BlockZ--; break; - case 4: a_BlockX++; break; - case 5: a_BlockX--; break; - default: break; + case 2: a_BlockZ++; break; + case 3: a_BlockZ--; break; + case 4: a_BlockX++; break; + case 5: a_BlockX--; break; + default: break; } } -- cgit v1.2.3 From 51b91befbd26b630cd2cecaec081edd03edfb5f3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 23:11:59 +0200 Subject: Added RemoveItem() function to the player inventory. --- src/Inventory.cpp | 18 ++++++++++++++++++ src/Inventory.h | 3 +++ src/ItemGrid.cpp | 33 +++++++++++++++++++++++++++++++++ src/ItemGrid.h | 3 +++ 4 files changed, 57 insertions(+) (limited to 'src') diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 38d3c886d..5f7c24b60 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -151,6 +151,24 @@ int cInventory::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, bool a +int cInventory::RemoveItem(const cItem & a_ItemStack) +{ + int RemovedItems = m_HotbarSlots.RemoveItem(a_ItemStack); + + if (RemovedItems < a_ItemStack.m_ItemCount) + { + cItem Temp(a_ItemStack); + Temp.m_ItemCount -= RemovedItems; + RemovedItems += m_InventorySlots.RemoveItem(Temp); + } + + return RemovedItems; +} + + + + + bool cInventory::RemoveOneEquippedItem(void) { if (m_HotbarSlots.GetSlot(m_EquippedSlotNum).IsEmpty()) diff --git a/src/Inventory.h b/src/Inventory.h index e25fc4a8a..6e32536b3 100644 --- a/src/Inventory.h +++ b/src/Inventory.h @@ -86,6 +86,9 @@ public: */ int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, bool a_tryToFillEquippedFirst); + /** Remove the specified item with the specified amount from the inventory. Returns the amount from the items were was removed. */ + int RemoveItem(const cItem & a_ItemStack); + /** Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed */ bool RemoveOneEquippedItem(void); diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp index cd36b1f2a..38829cbf8 100644 --- a/src/ItemGrid.cpp +++ b/src/ItemGrid.cpp @@ -345,6 +345,39 @@ int cItemGrid::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, int a_P +int cItemGrid::RemoveItem(const cItem & a_ItemStack) +{ + int NumLeft = a_ItemStack.m_ItemCount; + + for (int i = 0; i < m_NumSlots; i++) + { + if (NumLeft <= 0) + { + break; + } + + if (m_Slots[i].IsEqual(a_ItemStack)) + { + int NumToRemove = std::min(NumLeft, (int)m_Slots[i].m_ItemCount); + NumLeft -= NumToRemove; + m_Slots[i].m_ItemCount -= NumToRemove; + + if (m_Slots[i].m_ItemCount <= 0) + { + m_Slots[i].Empty(); + } + + TriggerListeners(i); + } + } + + return (a_ItemStack.m_ItemCount - NumLeft); +} + + + + + int cItemGrid::ChangeSlotCount(int a_SlotNum, int a_AddToCount) { if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots)) diff --git a/src/ItemGrid.h b/src/ItemGrid.h index c34d5e9e2..6731b0065 100644 --- a/src/ItemGrid.h +++ b/src/ItemGrid.h @@ -96,6 +96,9 @@ public: Returns the total number of items that fit. */ int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks = true, int a_PrioritarySlot = -1); + + /** Remove the specified item with the specified amount from the inventory. Returns the amount from the items were was removed. */ + int RemoveItem(const cItem & a_ItemStack); /** Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot. If the slot is empty, ignores the call. -- cgit v1.2.3 From 19d012c96ec13498d97d8e43136cc09eca3dca2e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 23:20:42 +0200 Subject: Fixed slime-related comments. --- src/Mobs/Monster.cpp | 4 ++-- src/Mobs/Slime.cpp | 4 ++-- src/Mobs/Slime.h | 7 ++++++- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 2a796e8eb..19851e064 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -867,13 +867,13 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) } case mtSlime: { - toReturn = new cSlime(1 << Random.NextInt(3)); + toReturn = new cSlime(1 << Random.NextInt(3)); // Size 1, 2 or 4 break; } case mtSkeleton: { // TODO: Actual detection of spawning in Nether - toReturn = new cSkeleton(Random.NextInt(1) == 0 ? false : true); + toReturn = new cSkeleton((Random.NextInt(1) == 0) ? false : true); break; } case mtVillager: diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp index 4b123df12..b709ec664 100644 --- a/src/Mobs/Slime.cpp +++ b/src/Mobs/Slime.cpp @@ -48,9 +48,9 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer) void cSlime::Attack(float a_Dt) { - if (m_Size != 1) + if (m_Size > 1) { - // Only slimes with the size 2 and 3 attacks a player. + // Only slimes larger than size 1 attack a player. super::Attack(a_Dt); } } diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h index b0e2f627c..15ae113dc 100644 --- a/src/Mobs/Slime.h +++ b/src/Mobs/Slime.h @@ -18,16 +18,21 @@ public: CLASS_PROTODEF(cSlime); + // cAggressiveMonster overrides: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void Attack(float a_Dt) override; virtual void KilledBy(TakeDamageInfo & a_TDI) override; int GetSize(void) const { return m_Size; } + + /** Returns the text describing the slime's size, as used by the client's resource subsystem for sounds. + Returns either "big" or "small". */ const AString GetSizeName(int a_Size) const; protected: - /** Size of the slime, 1 .. 3, with 1 being the smallest */ + /** Size of the slime, with 1 being the smallest. + Vanilla uses sizes 1, 2 and 4 only. */ int m_Size; } ; -- cgit v1.2.3 From 13311c700ffbd94f28fe38654bda4bf026d2a8ce Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 23:47:46 +0200 Subject: Clarified RemoveItem()'s comments. --- src/Inventory.h | 3 ++- src/ItemGrid.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Inventory.h b/src/Inventory.h index 6e32536b3..5175afd14 100644 --- a/src/Inventory.h +++ b/src/Inventory.h @@ -86,7 +86,8 @@ public: */ int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, bool a_tryToFillEquippedFirst); - /** Remove the specified item with the specified amount from the inventory. Returns the amount from the items were was removed. */ + /** Removes the specified item from the inventory, as many as possible, up to a_ItemStack.m_ItemCount. + Returns the number of items that were removed. */ int RemoveItem(const cItem & a_ItemStack); /** Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed */ diff --git a/src/ItemGrid.h b/src/ItemGrid.h index 6731b0065..8d6544792 100644 --- a/src/ItemGrid.h +++ b/src/ItemGrid.h @@ -97,7 +97,8 @@ public: */ int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks = true, int a_PrioritarySlot = -1); - /** Remove the specified item with the specified amount from the inventory. Returns the amount from the items were was removed. */ + /** Removes the specified item from the grid, as many as possible, up to a_ItemStack.m_ItemCount. + Returns the number of items that were removed. */ int RemoveItem(const cItem & a_ItemStack); /** Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot. -- cgit v1.2.3 From 2f811fc6a2cf2ddacdcb443049a44ad6481f135a Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 23:55:34 -0700 Subject: Mobs/CMakeLists.txt: Replaced glob with list of files --- src/Mobs/CMakeLists.txt | 74 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt index 53c265803..d73a7aafd 100644 --- a/src/Mobs/CMakeLists.txt +++ b/src/Mobs/CMakeLists.txt @@ -4,9 +4,73 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + AggressiveMonster.cpp + Bat.cpp + Blaze.cpp + CaveSpider.cpp + Chicken.cpp + Cow.cpp + Creeper.cpp + EnderDragon.cpp + Enderman.cpp + Ghast.cpp + Giant.cpp + Horse.cpp + IronGolem.cpp + MagmaCube.cpp + Monster.cpp + Mooshroom.cpp + PassiveAggressiveMonster.cpp + PassiveMonster.cpp + Pig.cpp + Sheep.cpp + Skeleton.cpp + Slime.cpp + SnowGolem.cpp + Spider.cpp + Squid.cpp + Villager.cpp + Witch.cpp + Wither.cpp + Wolf.cpp + Zombie.cpp + ZombiePigman.cpp) + +SET (HDRS + AggressiveMonster.h + Bat.h + Blaze.h + CaveSpider.h + Chicken.h + Cow.h + Creeper.h + EnderDragon.h + Enderman.h + Ghast.h + Giant.h + Horse.h + IncludeAllMonsters.h + IronGolem.h + MagmaCube.h + Monster.h + Mooshroom.h + Ocelot.h + PassiveAggressiveMonster.h + PassiveMonster.h + Pig.h + Sheep.h + Silverfish.h + Skeleton.h + Slime.h + SnowGolem.h + Spider.h + Squid.h + Villager.h + Witch.h + Wither.h + Wolf.h + Zombie.h + ZombiePigman.h) -add_library(Mobs ${SOURCE}) +add_library(Mobs ${SRCS} ${HDRS}) -- cgit v1.2.3 From 1d8e3e2bb8ca66e83b395e0131d4e5ededb385d0 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 23:57:35 -0700 Subject: Entities/CMakeLists.txt: Replaced glob with list of files --- src/Entities/CMakeLists.txt | 61 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Entities/CMakeLists.txt b/src/Entities/CMakeLists.txt index 205cb2cca..64752d13c 100644 --- a/src/Entities/CMakeLists.txt +++ b/src/Entities/CMakeLists.txt @@ -4,11 +4,62 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + ArrowEntity.cpp + Boat.cpp + EnderCrystal.cpp + Entity.cpp + EntityEffect.cpp + ExpBottleEntity.cpp + ExpOrb.cpp + FallingBlock.cpp + FireChargeEntity.cpp + FireworkEntity.cpp + Floater.cpp + GhastFireballEntity.cpp + HangingEntity.cpp + ItemFrame.cpp + Minecart.cpp + Painting.cpp + Pawn.cpp + Pickup.cpp + Player.cpp + ProjectileEntity.cpp + SplashPotionEntity.cpp + TNTEntity.cpp + ThrownEggEntity.cpp + ThrownEnderPearlEntity.cpp + ThrownSnowballEntity.cpp + WitherSkullEntity.cpp) -add_library(Entities ${SOURCE}) +SET (HDRS + ArrowEntity.h + Boat.h + EnderCrystal.h + Entity.h + EntityEffect.h + ExpBottleEntity.h + ExpOrb.h + FallingBlock.h + FireChargeEntity.h + FireworkEntity.h + Floater.h + GhastFireballEntity.h + HangingEntity.h + ItemFrame.h + Minecart.h + Painting.h + Pawn.h + Pickup.h + Player.h + ProjectileEntity.h + SplashPotionEntity.h + TNTEntity.h + ThrownEggEntity.h + ThrownEnderPearlEntity.h + ThrownSnowballEntity.h + WitherSkullEntity.h) + +add_library(Entities ${SRCS} ${HDRS}) target_link_libraries(Entities WorldStorage) -- cgit v1.2.3 From 465743757a4847b860d932a20c3a7570aec6bec5 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 23:59:33 -0700 Subject: Items/CMakeLists.txt: Replaced glob with list of files --- src/Items/CMakeLists.txt | 52 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt index a6fe6ea70..0c15a6944 100644 --- a/src/Items/CMakeLists.txt +++ b/src/Items/CMakeLists.txt @@ -4,9 +4,51 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + ItemHandler.cpp) -add_library(Items ${SOURCE}) +SET (HDRS + ItemArmor.h + ItemBed.h + ItemBoat.h + ItemBow.h + ItemBrewingStand.h + ItemBucket.h + ItemCake.h + ItemCauldron.h + ItemCloth.h + ItemComparator.h + ItemDoor.h + ItemDye.h + ItemEmptyMap.h + ItemFishingRod.h + ItemFlowerPot.h + ItemFood.h + ItemHandler.h + ItemHoe.h + ItemItemFrame.h + ItemLeaves.h + ItemLighter.h + ItemLilypad.h + ItemMap.h + ItemMilk.h + ItemMinecart.h + ItemMobHead.h + ItemNetherWart.h + ItemPainting.h + ItemPickaxe.h + ItemPotion.h + ItemRedstoneDust.h + ItemRedstoneRepeater.h + ItemSapling.h + ItemSeeds.h + ItemShears.h + ItemShovel.h + ItemSign.h + ItemSpawnEgg.h + ItemString.h + ItemSugarcane.h + ItemSword.h + ItemThrowable.h) + +add_library(Items ${SRCS} ${HDRS}) -- cgit v1.2.3 From 61c4e2e5cbe93592a5dc1d704ca29a405ac61428 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:01:26 -0700 Subject: Blocks/CMakeLists.txt: Replaced glob with list of files --- src/Blocks/CMakeLists.txt | 97 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index 4b8c745ad..d356d151b 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -4,9 +4,96 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + BlockBed.cpp + BlockDoor.cpp + BlockHandler.cpp + BlockPiston.cpp + ChunkInterface.cpp) -add_library(Blocks ${SOURCE}) +SET (HDRS + BlockAnvil.h + BlockBed.h + BlockBigFlower.h + BlockBrewingStand.h + BlockButton.h + BlockCactus.h + BlockCake.h + BlockCarpet.h + BlockCauldron.h + BlockChest.h + BlockCloth.h + BlockCobWeb.h + BlockCommandBlock.h + BlockComparator.h + BlockCrops.h + BlockDeadBush.h + BlockDirt.h + BlockDoor.h + BlockDropSpenser.h + BlockEnchantmentTable.h + BlockEnderchest.h + BlockEntity.h + BlockFarmland.h + BlockFenceGate.h + BlockFire.h + BlockFlower.h + BlockFlowerPot.h + BlockFluid.h + BlockFurnace.h + BlockGlass.h + BlockGlowstone.h + BlockGravel.h + BlockHandler.h + BlockHayBale.h + BlockHopper.h + BlockIce.h + BlockLadder.h + BlockLeaves.h + BlockLever.h + BlockLilypad.h + BlockMelon.h + BlockMobHead.h + BlockMushroom.h + BlockMycelium.h + BlockNetherWart.h + BlockNewLeaves.h + BlockNote.h + BlockOre.h + BlockPiston.h + BlockPlanks.h + BlockPluginInterface.h + BlockPortal.h + BlockPressurePlate.h + BlockPumpkin.h + BlockQuartz.h + BlockRail.h + BlockRedstone.h + BlockRedstoneLamp.h + BlockRedstoneRepeater.h + BlockRedstoneTorch.h + BlockSand.h + BlockSapling.h + BlockSideways.h + BlockSign.h + BlockSlab.h + BlockSnow.h + BlockStairs.h + BlockStems.h + BlockStone.h + BlockSugarcane.h + BlockTNT.h + BlockTallGrass.h + BlockTorch.h + BlockTrapdoor.h + BlockTripwire.h + BlockTripwireHook.h + BlockVine.h + BlockWorkbench.h + BroadcastInterface.h + ChunkInterface.h + ClearMetaOnDrop.h + MetaRotator.h + WorldInterface.h) + +add_library(Blocks ${SRCS} ${HDRS}) -- cgit v1.2.3 From 15aacc24a5e4adfb00cc0bf10703c83a60a0735b Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:03:19 -0700 Subject: Protocol/CMakeLists.txt: Replaced glob with list of files --- src/Protocol/CMakeLists.txt | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Protocol/CMakeLists.txt b/src/Protocol/CMakeLists.txt index 849ec27ca..21d49c516 100644 --- a/src/Protocol/CMakeLists.txt +++ b/src/Protocol/CMakeLists.txt @@ -4,9 +4,27 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + Authenticator.cpp + ChunkDataSerializer.cpp + Protocol125.cpp + Protocol132.cpp + Protocol14x.cpp + Protocol15x.cpp + Protocol16x.cpp + Protocol17x.cpp + ProtocolRecognizer.cpp) -add_library(Protocol ${SOURCE}) +SET (HDRS + Authenticator.h + ChunkDataSerializer.h + Protocol.h + Protocol125.h + Protocol132.h + Protocol14x.h + Protocol15x.h + Protocol16x.h + Protocol17x.h + ProtocolRecognizer.h) + +add_library(Protocol ${SRCS} ${HDRS}) -- cgit v1.2.3 From 5890d04f212e83bdc2e2305e006e6091471802fc Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:05:50 -0700 Subject: UI/CMakeLists.txt: Replaced glob with list of files --- src/UI/CMakeLists.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt index 5b5b8cc18..c41123318 100644 --- a/src/UI/CMakeLists.txt +++ b/src/UI/CMakeLists.txt @@ -4,9 +4,13 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + SlotArea.cpp + Window.cpp) -add_library(UI ${SOURCE}) +SET (HDRS + SlotArea.h + Window.h + WindowOwner.h) + +add_library(UI ${SRCS} ${HDRS}) -- cgit v1.2.3 From 1a05b7c5d70f1a57dd09d6ae9d35d4c1fb10128e Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:14:15 -0700 Subject: BlockEntities/CMakeLists.txt: Replaced glob with list of files --- src/BlockEntities/CMakeLists.txt | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/CMakeLists.txt b/src/BlockEntities/CMakeLists.txt index 3e3d17f86..4cd49c52d 100644 --- a/src/BlockEntities/CMakeLists.txt +++ b/src/BlockEntities/CMakeLists.txt @@ -4,9 +4,39 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + BeaconEntity.cpp + BlockEntity.cpp + ChestEntity.cpp + CommandBlockEntity.cpp + DispenserEntity.cpp + DropSpenserEntity.cpp + DropperEntity.cpp + EnderChestEntity.cpp + FlowerPotEntity.cpp + FurnaceEntity.cpp + HopperEntity.cpp + JukeboxEntity.cpp + MobHeadEntity.cpp + NoteEntity.cpp + SignEntity.cpp) -add_library(BlockEntities ${SOURCE}) +SET (HDRS + BeaconEntity.h + BlockEntity.h + BlockEntityWithItems.h + ChestEntity.h + CommandBlockEntity.h + DispenserEntity.h + DropSpenserEntity.h + DropperEntity.h + EnderChestEntity.h + FlowerPotEntity.h + FurnaceEntity.h + HopperEntity.h + JukeboxEntity.h + MobHeadEntity.h + NoteEntity.h + SignEntity.h) + +add_library(BlockEntities ${SRCS} ${HDRS}) -- cgit v1.2.3 From 06bef093bf3a035e03bf22808e82f8d82638dbfc Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:20:38 -0700 Subject: Generating/CMakeLists.txt: Replaced glob with list of files --- src/Generating/CMakeLists.txt | 59 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt index 3dacb5066..b3960914c 100644 --- a/src/Generating/CMakeLists.txt +++ b/src/Generating/CMakeLists.txt @@ -4,11 +4,60 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + BioGen.cpp + Caves.cpp + ChunkDesc.cpp + ChunkGenerator.cpp + CompoGen.cpp + ComposableGenerator.cpp + DistortedHeightmap.cpp + EndGen.cpp + FinishGen.cpp + GridStructGen.cpp + HeiGen.cpp + MineShafts.cpp + NetherFortGen.cpp + Noise3DGenerator.cpp + POCPieceGenerator.cpp + PieceGenerator.cpp + Prefab.cpp + PrefabPiecePool.cpp + RainbowRoadsGen.cpp + Ravines.cpp + StructGen.cpp + TestRailsGen.cpp + Trees.cpp + UnderwaterBaseGen.cpp + VillageGen.cpp) -add_library(Generating ${SOURCE}) +SET (HDRS + BioGen.h + Caves.h + ChunkDesc.h + ChunkGenerator.h + CompoGen.h + ComposableGenerator.h + DistortedHeightmap.h + EndGen.h + FinishGen.h + GridStructGen.h + HeiGen.h + MineShafts.h + NetherFortGen.h + Noise3DGenerator.h + POCPieceGenerator.h + PieceGenerator.h + Prefab.h + PrefabPiecePool.h + RainbowRoadsGen.h + Ravines.h + StructGen.h + TestRailsGen.h + Trees.h + UnderwaterBaseGen.h + VillageGen.h) + +add_library(Generating ${SRCS} ${HDRS}) target_link_libraries(Generating OSSupport iniFile Blocks) -- cgit v1.2.3 From 9fe4b61df35ebad8df7b928af73bc798ebaf731f Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:26:55 -0700 Subject: WorldStorage/CMakeLists.txt: Replaced glob with list of files --- src/WorldStorage/CMakeLists.txt | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt index 2844f7fe5..212581400 100644 --- a/src/WorldStorage/CMakeLists.txt +++ b/src/WorldStorage/CMakeLists.txt @@ -4,11 +4,32 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + EnchantmentSerializer.cpp + FastNBT.cpp + FireworksSerializer.cpp + MapSerializer.cpp + NBTChunkSerializer.cpp + SchematicFileSerializer.cpp + ScoreboardSerializer.cpp + StatSerializer.cpp + WSSAnvil.cpp + WSSCompact.cpp + WorldStorage.cpp) -add_library(WorldStorage ${SOURCE}) +SET (HDRS + EnchantmentSerializer.h + FastNBT.h + FireworksSerializer.h + MapSerializer.h + NBTChunkSerializer.h + SchematicFileSerializer.h + ScoreboardSerializer.h + StatSerializer.h + WSSAnvil.h + WSSCompact.h + WorldStorage.h) + +add_library(WorldStorage ${SRCS} ${HDRS}) target_link_libraries(WorldStorage OSSupport) -- cgit v1.2.3 From 0859ee3995d0cc80d80b328af920911d1cfb25d3 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:28:40 -0700 Subject: Simulator/CMakeLists.txt: Replaced glob with list of files --- src/Simulator/CMakeLists.txt | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Simulator/CMakeLists.txt b/src/Simulator/CMakeLists.txt index b2a29d45c..f56fb0079 100644 --- a/src/Simulator/CMakeLists.txt +++ b/src/Simulator/CMakeLists.txt @@ -4,9 +4,32 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + DelayedFluidSimulator.cpp + FireSimulator.cpp + FloodyFluidSimulator.cpp + FluidSimulator.cpp + IncrementalRedstoneSimulator.cpp + RedstoneSimulator.cpp + SandSimulator.cpp + Simulator.cpp + SimulatorManager.cpp + VanillaFluidSimulator.cpp + VaporizeFluidSimulator.cpp) -add_library(Simulator ${SOURCE}) +SET (HDRS + DelayedFluidSimulator.h + FireSimulator.h + FloodyFluidSimulator.h + FluidSimulator.h + IncrementalRedstoneSimulator.h + NoopFluidSimulator.h + NoopRedstoneSimulator.h + RedstoneSimulator.h + SandSimulator.h + Simulator.h + SimulatorManager.h + VanillaFluidSimulator.h + VaporizeFluidSimulator.h) + +add_library(Simulator ${SRCS} ${HDRS}) -- cgit v1.2.3 From de48688fdbca822a09a9b8abad2010768ab36a20 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:34:21 -0700 Subject: Generating/Prefabs/CMakeLists.txt: Replaced glob with list of files --- src/Generating/Prefabs/CMakeLists.txt | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/CMakeLists.txt b/src/Generating/Prefabs/CMakeLists.txt index a1f09112d..d53098b4e 100644 --- a/src/Generating/Prefabs/CMakeLists.txt +++ b/src/Generating/Prefabs/CMakeLists.txt @@ -4,11 +4,28 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + AlchemistVillagePrefabs.cpp + JapaneseVillagePrefabs.cpp + NetherFortPrefabs.cpp + PlainsVillagePrefabs.cpp + RainbowRoadPrefabs.cpp + SandFlatRoofVillagePrefabs.cpp + SandVillagePrefabs.cpp + TestRailsPrefabs.cpp + UnderwaterBasePrefabs.cpp) -add_library(Generating_Prefabs ${SOURCE}) +SET (HDRS + AlchemistVillagePrefabs.h + JapaneseVillagePrefabs.h + NetherFortPrefabs.h + PlainsVillagePrefabs.h + RainbowRoadPrefabs.h + SandFlatRoofVillagePrefabs.h + SandVillagePrefabs.h + TestRailsPrefabs.h + UnderwaterBasePrefabs.h) + +add_library(Generating_Prefabs ${SRCS} ${HDRS}) target_link_libraries(Generating_Prefabs OSSupport iniFile Blocks) -- cgit v1.2.3 From 5d966be741eef68749412d706de05d963628abc9 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:46:39 -0700 Subject: HTTPServer/CMakeLists.txt: Replaced glob with list of files --- src/HTTPServer/CMakeLists.txt | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/HTTPServer/CMakeLists.txt b/src/HTTPServer/CMakeLists.txt index dc894368d..a15b2494f 100644 --- a/src/HTTPServer/CMakeLists.txt +++ b/src/HTTPServer/CMakeLists.txt @@ -4,9 +4,24 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + EnvelopeParser.cpp + HTTPConnection.cpp + HTTPFormParser.cpp + HTTPMessage.cpp + HTTPServer.cpp + MultipartParser.cpp + NameValueParser.cpp + SslHTTPConnection.cpp) -add_library(HTTPServer ${SOURCE}) +SET (HDRS + EnvelopeParser.h + HTTPConnection.h + HTTPFormParser.h + HTTPMessage.h + HTTPServer.h + MultipartParser.h + NameValueParser.h + SslHTTPConnection.h) + +add_library(HTTPServer ${SRCS} ${HDRS}) -- cgit v1.2.3 From dcaa3262a2b085fa3ea9769c7eee21d3cd48c834 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:48:22 -0700 Subject: OSSupport/CMakeLists.txt: Replaced glob with list of files --- src/OSSupport/CMakeLists.txt | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/OSSupport/CMakeLists.txt b/src/OSSupport/CMakeLists.txt index dee60b450..8004d4094 100644 --- a/src/OSSupport/CMakeLists.txt +++ b/src/OSSupport/CMakeLists.txt @@ -3,12 +3,39 @@ cmake_minimum_required (VERSION 2.6) project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) -add_library(OSSupport ${SOURCE}) +SET (SRCS + CriticalSection.cpp + Errors.cpp + Event.cpp + File.cpp + GZipFile.cpp + IsThread.cpp + ListenThread.cpp + Semaphore.cpp + Sleep.cpp + Socket.cpp + SocketThreads.cpp + Thread.cpp + Timer.cpp) + +SET (HDRS + CriticalSection.h + Errors.h + Event.h + File.h + GZipFile.h + IsThread.h + ListenThread.h + Queue.h + Semaphore.h + Sleep.h + Socket.h + SocketThreads.h + Thread.h + Timer.h) + +add_library(OSSupport ${SRCS} ${HDRS}) if(UNIX) target_link_libraries(OSSupport pthread) -- cgit v1.2.3 From 34c8ff7b24171f9712ce3156013187257bb45327 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 01:40:01 -0700 Subject: src/CMakeLists: Small changes for increased readability --- src/CMakeLists.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fdc33cd82..c33b0983a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,8 +5,10 @@ include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/") include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/jsoncpp/include") include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") -set(FOLDERS OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++) -set(FOLDERS ${FOLDERS} WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs) +set(FOLDERS + OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++ + WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs +) set(BINDING_DEPENDECIES tolua @@ -261,9 +263,11 @@ endif () if (NOT MSVC) - target_link_libraries(${EXECUTABLE} OSSupport HTTPServer Bindings Items Blocks) - target_link_libraries(${EXECUTABLE} Protocol Generating Generating_Prefabs WorldStorage) - target_link_libraries(${EXECUTABLE} Mobs Entities Simulator UI BlockEntities PolarSSL++) + target_link_libraries(${EXECUTABLE} + OSSupport HTTPServer Bindings Items Blocks + Protocol Generating Generating_Prefabs WorldStorage + Mobs Entities Simulator UI BlockEntities PolarSSL++ + ) endif () if (WIN32) target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib) -- cgit v1.2.3 From 725d1fd1e2995b1720673c280fea1125ac338b3c Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 13:26:43 -0700 Subject: Subdirs: Only add_library if not using MSVC --- src/BlockEntities/CMakeLists.txt | 4 +++- src/Blocks/CMakeLists.txt | 4 +++- src/Entities/CMakeLists.txt | 6 ++++-- src/Generating/CMakeLists.txt | 6 ++++-- src/Generating/Prefabs/CMakeLists.txt | 6 ++++-- src/HTTPServer/CMakeLists.txt | 4 +++- src/Items/CMakeLists.txt | 4 +++- src/Mobs/CMakeLists.txt | 4 +++- src/OSSupport/CMakeLists.txt | 8 +++++--- src/Protocol/CMakeLists.txt | 4 +++- src/Simulator/CMakeLists.txt | 4 +++- src/UI/CMakeLists.txt | 4 +++- src/WorldStorage/CMakeLists.txt | 6 ++++-- 13 files changed, 45 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/BlockEntities/CMakeLists.txt b/src/BlockEntities/CMakeLists.txt index 4cd49c52d..d87594b0d 100644 --- a/src/BlockEntities/CMakeLists.txt +++ b/src/BlockEntities/CMakeLists.txt @@ -39,4 +39,6 @@ SET (HDRS NoteEntity.h SignEntity.h) -add_library(BlockEntities ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(BlockEntities ${SRCS} ${HDRS}) +endif() diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index d356d151b..d7edf7f29 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -96,4 +96,6 @@ SET (HDRS MetaRotator.h WorldInterface.h) -add_library(Blocks ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Blocks ${SRCS} ${HDRS}) +endif() diff --git a/src/Entities/CMakeLists.txt b/src/Entities/CMakeLists.txt index 64752d13c..5d10e1680 100644 --- a/src/Entities/CMakeLists.txt +++ b/src/Entities/CMakeLists.txt @@ -60,6 +60,8 @@ SET (HDRS ThrownSnowballEntity.h WitherSkullEntity.h) -add_library(Entities ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Entities ${SRCS} ${HDRS}) -target_link_libraries(Entities WorldStorage) + target_link_libraries(Entities WorldStorage) +endif() diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt index b3960914c..9063abd97 100644 --- a/src/Generating/CMakeLists.txt +++ b/src/Generating/CMakeLists.txt @@ -58,6 +58,8 @@ SET (HDRS UnderwaterBaseGen.h VillageGen.h) -add_library(Generating ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Generating ${SRCS} ${HDRS}) -target_link_libraries(Generating OSSupport iniFile Blocks) + target_link_libraries(Generating OSSupport iniFile Blocks) +endif() diff --git a/src/Generating/Prefabs/CMakeLists.txt b/src/Generating/Prefabs/CMakeLists.txt index d53098b4e..2c62aa73d 100644 --- a/src/Generating/Prefabs/CMakeLists.txt +++ b/src/Generating/Prefabs/CMakeLists.txt @@ -26,6 +26,8 @@ SET (HDRS TestRailsPrefabs.h UnderwaterBasePrefabs.h) -add_library(Generating_Prefabs ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Generating_Prefabs ${SRCS} ${HDRS}) -target_link_libraries(Generating_Prefabs OSSupport iniFile Blocks) + target_link_libraries(Generating_Prefabs OSSupport iniFile Blocks) +endif() diff --git a/src/HTTPServer/CMakeLists.txt b/src/HTTPServer/CMakeLists.txt index a15b2494f..b0efc810d 100644 --- a/src/HTTPServer/CMakeLists.txt +++ b/src/HTTPServer/CMakeLists.txt @@ -24,4 +24,6 @@ SET (HDRS NameValueParser.h SslHTTPConnection.h) -add_library(HTTPServer ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(HTTPServer ${SRCS} ${HDRS}) +endif() diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt index 0c15a6944..12a467672 100644 --- a/src/Items/CMakeLists.txt +++ b/src/Items/CMakeLists.txt @@ -51,4 +51,6 @@ SET (HDRS ItemSword.h ItemThrowable.h) -add_library(Items ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Items ${SRCS} ${HDRS}) +endif() diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt index d73a7aafd..2c092c15f 100644 --- a/src/Mobs/CMakeLists.txt +++ b/src/Mobs/CMakeLists.txt @@ -73,4 +73,6 @@ SET (HDRS Zombie.h ZombiePigman.h) -add_library(Mobs ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Mobs ${SRCS} ${HDRS}) +endif() diff --git a/src/OSSupport/CMakeLists.txt b/src/OSSupport/CMakeLists.txt index 8004d4094..a42fcbed4 100644 --- a/src/OSSupport/CMakeLists.txt +++ b/src/OSSupport/CMakeLists.txt @@ -35,8 +35,10 @@ SET (HDRS Thread.h Timer.h) -add_library(OSSupport ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(OSSupport ${SRCS} ${HDRS}) -if(UNIX) - target_link_libraries(OSSupport pthread) + if(UNIX) + target_link_libraries(OSSupport pthread) + endif() endif() diff --git a/src/Protocol/CMakeLists.txt b/src/Protocol/CMakeLists.txt index 21d49c516..ae447ce54 100644 --- a/src/Protocol/CMakeLists.txt +++ b/src/Protocol/CMakeLists.txt @@ -27,4 +27,6 @@ SET (HDRS Protocol17x.h ProtocolRecognizer.h) -add_library(Protocol ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Protocol ${SRCS} ${HDRS}) +endif() diff --git a/src/Simulator/CMakeLists.txt b/src/Simulator/CMakeLists.txt index f56fb0079..521b145b6 100644 --- a/src/Simulator/CMakeLists.txt +++ b/src/Simulator/CMakeLists.txt @@ -32,4 +32,6 @@ SET (HDRS VanillaFluidSimulator.h VaporizeFluidSimulator.h) -add_library(Simulator ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Simulator ${SRCS} ${HDRS}) +endif() diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt index c41123318..2b094ef1d 100644 --- a/src/UI/CMakeLists.txt +++ b/src/UI/CMakeLists.txt @@ -13,4 +13,6 @@ SET (HDRS Window.h WindowOwner.h) -add_library(UI ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(UI ${SRCS} ${HDRS}) +endif() diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt index 212581400..a00ff3b2f 100644 --- a/src/WorldStorage/CMakeLists.txt +++ b/src/WorldStorage/CMakeLists.txt @@ -30,6 +30,8 @@ SET (HDRS WSSCompact.h WorldStorage.h) -add_library(WorldStorage ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(WorldStorage ${SRCS} ${HDRS}) -target_link_libraries(WorldStorage OSSupport) + target_link_libraries(WorldStorage OSSupport) +endif() -- cgit v1.2.3 From 84fef3c1569b941e747c471b06b290876baa131e Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 14:08:49 -0700 Subject: src/CMakeLists.txt: Replaced glob with list of files On MSVC, CMake will traverse all the CMakeLists and add their source and header files to one conglomerate SOURCE list. --- src/Bindings/CMakeLists.txt | 32 +++++++++ src/CMakeLists.txt | 168 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 180 insertions(+), 20 deletions(-) create mode 100644 src/Bindings/CMakeLists.txt (limited to 'src') diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt new file mode 100644 index 000000000..fd6223469 --- /dev/null +++ b/src/Bindings/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required (VERSION 2.6) +project (MCServer) + +include_directories ("${PROJECT_SOURCE_DIR}/../") + +SET (SRCS + Bindings.cpp + DeprecatedBindings.cpp + LuaChunkStay.cpp + LuaState.cpp + LuaWindow.cpp + ManualBindings.cpp + Plugin.cpp + PluginLua.cpp + PluginManager.cpp + WebPlugin.cpp +) + +SET (HDRS + Bindings.h + DeprecatedBindings.h + LuaChunkStay.h + LuaFunctions.h + LuaState.h + LuaWindow.h + ManualBindings.h + Plugin.h + PluginLua.h + PluginManager.h + WebPlugin.h + tolua++.h +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c33b0983a..dc6fec02f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -82,6 +82,131 @@ set(BINDING_DEPENDECIES World.h ) +SET (SRCS + BiomeDef.cpp + BlockArea.cpp + BlockID.cpp + BlockInfo.cpp + BoundingBox.cpp + ByteBuffer.cpp + ChatColor.cpp + Chunk.cpp + ChunkData.cpp + ChunkMap.cpp + ChunkSender.cpp + ChunkStay.cpp + ClientHandle.cpp + CommandOutput.cpp + CompositeChat.cpp + CraftingRecipes.cpp + Cuboid.cpp + DeadlockDetect.cpp + Enchantments.cpp + FastRandom.cpp + FurnaceRecipe.cpp + Globals.cpp + Group.cpp + GroupManager.cpp + Inventory.cpp + Item.cpp + ItemGrid.cpp + LightingThread.cpp + LineBlockTracer.cpp + LinearInterpolation.cpp + Log.cpp + MCLogger.cpp + Map.cpp + MapManager.cpp + MobCensus.cpp + MobFamilyCollecter.cpp + MobProximityCounter.cpp + MobSpawner.cpp + MonsterConfig.cpp + Noise.cpp + ProbabDistrib.cpp + RCONServer.cpp + Root.cpp + Scoreboard.cpp + Server.cpp + Statistics.cpp + StringCompression.cpp + StringUtils.cpp + Tracer.cpp + VoronoiMap.cpp + WebAdmin.cpp + World.cpp + main.cpp) + +SET (HDRS + AllocationPool.h + BiomeDef.h + BlockArea.h + BlockID.h + BlockInServerPluginInterface.h + BlockInfo.h + BlockTracer.h + BoundingBox.h + ByteBuffer.h + ChatColor.h + Chunk.h + ChunkData.h + ChunkDataCallback.h + ChunkDef.h + ChunkMap.h + ChunkSender.h + ChunkStay.h + ClientHandle.h + CommandOutput.h + CompositeChat.h + CraftingRecipes.h + Cuboid.h + DeadlockDetect.h + Defines.h + Enchantments.h + Endianness.h + FastRandom.h + ForEachChunkProvider.h + FurnaceRecipe.h + Globals.h + Group.h + GroupManager.h + Inventory.h + Item.h + ItemGrid.h + LeakFinder.h + LightingThread.h + LineBlockTracer.h + LinearInterpolation.h + LinearUpscale.h + Log.h + MCLogger.h + Map.h + MapManager.h + Matrix4.h + MemoryLeak.h + MersenneTwister.h + MobCensus.h + MobFamilyCollecter.h + MobProximityCounter.h + MobSpawner.h + MonsterConfig.h + Noise.h + ProbabDistrib.h + RCONServer.h + Root.h + Scoreboard.h + Server.h + StackWalker.h + Statistics.h + StringCompression.h + StringUtils.h + Tracer.h + Vector3.h + VoronoiMap.h + WebAdmin.h + World.h + XMLParser.h) + # List all the files that are generated as part of the Bindings build process set (BINDING_OUTPUTS ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp @@ -159,38 +284,21 @@ if (NOT MSVC) add_subdirectory(${folder}) endforeach(folder) - file(GLOB SOURCE - "*.cpp" - "*.h" - ) - - list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/StackWalker.cpp" "${PROJECT_SOURCE_DIR}/LeakFinder.cpp") + list(APPEND SOURCE "${SRCS}") + list(APPEND SOURCE "${HDRS}") # If building a windows version, but not using MSVC, add the resources directly to the makefile: if (WIN32) - FILE(GLOB ResourceFiles - "Resources/*.rc" - ) - list(APPEND SOURCE "${ResourceFiles}") + list(APPEND SOURCE "Resources/MCServer.rc") endif() else () # MSVC-specific handling: Put all files into one project, separate by the folders: - # Get all files in this folder: - file(GLOB_RECURSE SOURCE - "*.cpp" - "*.h" - "*.pkg" - ) - source_group("" FILES ${SOURCE}) - - LIST(APPEND SOURCE "Bindings/Bindings.cpp" "Bindings/Bindings.h") source_group(Bindings FILES "Bindings/Bindings.cpp" "Bindings/Bindings.h") # Add all subfolders as solution-folders: - list(APPEND FOLDERS "Resources") list(APPEND FOLDERS "Bindings") function(includefolder PATH) FILE(GLOB FOLDER_FILES @@ -204,9 +312,29 @@ else () endfunction(includefolder) foreach(folder ${FOLDERS}) + add_subdirectory(${folder}) includefolder(${folder}) + + # Get all source files in this folder: + get_directory_property(FOLDER_SRCS DIRECTORY ${folder} DEFINITION SRCS) + foreach (src ${FOLDER_SRCS}) + list(APPEND SOURCE "${folder}/${src}") + endforeach(src) + + # Get all headers in this folder: + get_directory_property(FOLDER_HDRS DIRECTORY ${folder} DEFINITION HDRS) + foreach (hdr ${FOLDER_HDRS}) + list(APPEND SOURCE "${folder}/${hdr}") + endforeach(hdr) endforeach(folder) + list(APPEND SOURCE "${SRCS}") + list(APPEND SOURCE "${HDRS}") + list(APPEND SOURCE "Bindings/AllToLua.pkg") + + includefolder("Resources") + source_group("" FILES ${SOURCE}) + include_directories("${PROJECT_SOURCE_DIR}") # Precompiled headers (1st part) -- cgit v1.2.3 From 832530469360020d5cc1bd0a4142c3450d4cd8f9 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 15:27:50 -0700 Subject: CMake: Add Bindings library from subdirectory --- src/Bindings/CMakeLists.txt | 6 ++++++ src/CMakeLists.txt | 29 ++++++----------------------- 2 files changed, 12 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index fd6223469..da6a6919a 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -30,3 +30,9 @@ SET (HDRS WebPlugin.h tolua++.h ) + +if(NOT MSVC) + add_library(Bindings ${SRCS} ${HDRS}) + + target_link_libraries(Bindings lua sqlite tolualib polarssl) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dc6fec02f..afe766f13 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,7 @@ include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/jsoncpp/include" include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") set(FOLDERS - OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++ + OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++ Bindings WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs ) @@ -250,26 +250,14 @@ set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE) if (NOT MSVC) # Bindings need to reference other folders, so they are done here instead - + # lib dependencies are not included - - include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") - #add cpp files here - add_library(Bindings - Bindings/Bindings - Bindings/DeprecatedBindings - Bindings/LuaChunkStay - Bindings/LuaState - Bindings/LuaWindow - Bindings/ManualBindings - Bindings/Plugin - Bindings/PluginLua - Bindings/PluginManager - Bindings/WebPlugin - ) + include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") - target_link_libraries(Bindings lua sqlite tolualib polarssl) + foreach(folder ${FOLDERS}) + add_subdirectory(${folder}) + endforeach(folder) #clear file file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependecies.txt) @@ -280,10 +268,6 @@ if (NOT MSVC) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "Bindings.cpp Bindings.h") - foreach(folder ${FOLDERS}) - add_subdirectory(${folder}) - endforeach(folder) - list(APPEND SOURCE "${SRCS}") list(APPEND SOURCE "${HDRS}") @@ -299,7 +283,6 @@ else () source_group(Bindings FILES "Bindings/Bindings.cpp" "Bindings/Bindings.h") # Add all subfolders as solution-folders: - list(APPEND FOLDERS "Bindings") function(includefolder PATH) FILE(GLOB FOLDER_FILES "${PATH}/*.cpp" -- cgit v1.2.3 From 3d368b015e2032f86130b8a3f4d05ca72287c63a Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 15:41:42 -0700 Subject: Blocks/CMakeLists.txt: Fixed header list after merge of master --- src/Blocks/CMakeLists.txt | 3 ++- src/CMakeLists.txt | 13 ++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index d7edf7f29..05b7bfab4 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -75,7 +75,7 @@ SET (HDRS BlockSand.h BlockSapling.h BlockSideways.h - BlockSign.h + BlockSignPost.h BlockSlab.h BlockSnow.h BlockStairs.h @@ -89,6 +89,7 @@ SET (HDRS BlockTripwire.h BlockTripwireHook.h BlockVine.h + BlockWallSign.h BlockWorkbench.h BroadcastInterface.h ChunkInterface.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index afe766f13..2fe436125 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -248,17 +248,10 @@ set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE) set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE) if (NOT MSVC) - # Bindings need to reference other folders, so they are done here instead - # lib dependencies are not included - include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") - foreach(folder ${FOLDERS}) - add_subdirectory(${folder}) - endforeach(folder) - #clear file file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependecies.txt) foreach(dependecy ${BINDING_DEPENDECIES}) @@ -268,6 +261,10 @@ if (NOT MSVC) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "Bindings.cpp Bindings.h") + foreach(folder ${FOLDERS}) + add_subdirectory(${folder}) + endforeach(folder) + list(APPEND SOURCE "${SRCS}") list(APPEND SOURCE "${HDRS}") @@ -275,8 +272,6 @@ if (NOT MSVC) if (WIN32) list(APPEND SOURCE "Resources/MCServer.rc") endif() - - else () # MSVC-specific handling: Put all files into one project, separate by the folders: -- cgit v1.2.3 From 135dc333c131a9bde32609351e2b495c80b49f53 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 16:04:07 -0700 Subject: CMakeLists: Moved Bindings-specific code to subdir --- src/Bindings/CMakeLists.txt | 111 ++++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 122 +++--------------------------------------- src/PolarSSL++/CMakeLists.txt | 12 +++-- 3 files changed, 125 insertions(+), 120 deletions(-) (limited to 'src') diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index da6a6919a..723487ff0 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 2.6) project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") +include_directories (".") SET (SRCS Bindings.cpp @@ -31,6 +32,116 @@ SET (HDRS tolua++.h ) +# List all the files that are generated as part of the Bindings build process +set (BINDING_OUTPUTS + ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h + ${CMAKE_CURRENT_SOURCE_DIR}/LuaState_Call.inc +) + +set(BINDING_DEPENDECIES + tolua + ../Bindings/virtual_method_hooks.lua + ../Bindings/AllToLua.pkg + ../Bindings/gen_LuaState_Call.lua + ../Bindings/LuaFunctions.h + ../Bindings/LuaState_Call.inc + ../Bindings/LuaWindow.h + ../Bindings/Plugin.h + ../Bindings/PluginLua.h + ../Bindings/PluginManager.h + ../Bindings/WebPlugin.h + ../BiomeDef.h + ../BlockArea.h + ../BlockEntities/BlockEntity.h + ../BlockEntities/BlockEntityWithItems.h + ../BlockEntities/ChestEntity.h + ../BlockEntities/DispenserEntity.h + ../BlockEntities/DropSpenserEntity.h + ../BlockEntities/DropperEntity.h + ../BlockEntities/FurnaceEntity.h + ../BlockEntities/HopperEntity.h + ../BlockEntities/JukeboxEntity.h + ../BlockEntities/NoteEntity.h + ../BlockEntities/SignEntity.h + ../BlockEntities/MobHeadEntity.h + ../BlockEntities/FlowerPotEntity.h + ../BlockID.h + ../BoundingBox.h + ../ChatColor.h + ../ChunkDef.h + ../ClientHandle.h + ../CraftingRecipes.h + ../Cuboid.h + ../Defines.h + ../Enchantments.h + ../Entities/EntityEffect.h + ../Entities/Entity.h + ../Entities/Floater.h + ../Entities/Pawn.h + ../Entities/Painting.h + ../Entities/Pickup.h + ../Entities/Player.h + ../Entities/ProjectileEntity.h + ../Entities/ArrowEntity.h + ../Entities/ThrownEggEntity.h + ../Entities/ThrownEnderPearlEntity.h + ../Entities/ExpBottleEntity.h + ../Entities/ThrownSnowballEntity.h + ../Entities/FireChargeEntity.h + ../Entities/FireworkEntity.h + ../Entities/GhastFireballEntity.h + ../Entities/TNTEntity.h + ../Entities/ExpOrb.h + ../Entities/HangingEntity.h + ../Entities/ItemFrame.h + ../Generating/ChunkDesc.h + ../Group.h + ../Inventory.h + ../Item.h + ../ItemGrid.h + ../Mobs/Monster.h + ../OSSupport/File.h + ../Root.h + ../Server.h + ../StringUtils.h + ../Tracer.h + ../UI/Window.h + ../Vector3.h + ../WebAdmin.h + ../World.h +) + +if (WIN32) + ADD_CUSTOM_COMMAND( + OUTPUT ${BINDING_OUTPUTS} + + # Copy the Lua DLL into the Bindings folder, so that tolua can run from there: + COMMAND ${CMAKE_COMMAND} -E copy_if_different ../../MCServer/lua51.dll ./lua51.dll + + # Regenerate bindings: + COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + + # add any new generation dependencies here + DEPENDS ${BINDING_DEPENDECIES} + ) +else () + ADD_CUSTOM_COMMAND( + # add any new generated bindings here + OUTPUT ${BINDING_OUTPUTS} + + # Regenerate bindings: + COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + + # add any new generation dependencies here + DEPENDS ${BINDING_DEPENDECIES} + ) +endif () +set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE) +set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE) + if(NOT MSVC) add_library(Bindings ${SRCS} ${HDRS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2fe436125..6008d3174 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,78 +10,6 @@ set(FOLDERS WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs ) -set(BINDING_DEPENDECIES - tolua - ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/virtual_method_hooks.lua - ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/AllToLua.pkg - Bindings/gen_LuaState_Call.lua - Bindings/LuaFunctions.h - Bindings/LuaWindow.h - Bindings/Plugin.h - Bindings/PluginLua.h - Bindings/PluginManager.h - Bindings/WebPlugin.h - BiomeDef.h - BlockArea.h - BlockEntities/BlockEntity.h - BlockEntities/BlockEntityWithItems.h - BlockEntities/ChestEntity.h - BlockEntities/DispenserEntity.h - BlockEntities/DropSpenserEntity.h - BlockEntities/DropperEntity.h - BlockEntities/FurnaceEntity.h - BlockEntities/HopperEntity.h - BlockEntities/JukeboxEntity.h - BlockEntities/NoteEntity.h - BlockEntities/SignEntity.h - BlockEntities/MobHeadEntity.h - BlockEntities/FlowerPotEntity.h - BlockID.h - BoundingBox.h - ChatColor.h - ChunkDef.h - ClientHandle.h - CraftingRecipes.h - Cuboid.h - Defines.h - Enchantments.h - Entities/EntityEffect.h - Entities/Entity.h - Entities/Floater.h - Entities/Pawn.h - Entities/Painting.h - Entities/Pickup.h - Entities/Player.h - Entities/ProjectileEntity.h - Entities/ArrowEntity.h - Entities/ThrownEggEntity.h - Entities/ThrownEnderPearlEntity.h - Entities/ExpBottleEntity.h - Entities/ThrownSnowballEntity.h - Entities/FireChargeEntity.h - Entities/FireworkEntity.h - Entities/GhastFireballEntity.h - Entities/TNTEntity.h - Entities/ExpOrb.h - Entities/HangingEntity.h - Entities/ItemFrame.h - Generating/ChunkDesc.h - Group.h - Inventory.h - Item.h - ItemGrid.h - Mobs/Monster.h - OSSupport/File.h - Root.h - Server.h - StringUtils.h - Tracer.h - UI/Window.h - Vector3.h - WebAdmin.h - World.h -) - SET (SRCS BiomeDef.cpp BlockArea.cpp @@ -207,51 +135,19 @@ SET (HDRS World.h XMLParser.h) -# List all the files that are generated as part of the Bindings build process -set (BINDING_OUTPUTS - ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h - ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/LuaState_Call.inc -) - -include_directories(Bindings) -include_directories(.) - -if (WIN32) - ADD_CUSTOM_COMMAND( - OUTPUT ${BINDING_OUTPUTS} - - # Copy the Lua DLL into the Bindings folder, so that tolua can run from there: - COMMAND ${CMAKE_COMMAND} -E copy_if_different ../../MCServer/lua51.dll ./lua51.dll - - # Regenerate bindings: - COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/ - - # add any new generation dependencies here - DEPENDS ${BINDING_DEPENDECIES} - ) -else () - ADD_CUSTOM_COMMAND( - # add any new generated bindings here - OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h - - # Regenerate bindings: - COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/ - - # add any new generation dependencies here - DEPENDS ${BINDING_DEPENDECIES} - ) -endif () -set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE) -set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE) +include_directories(".") if (NOT MSVC) # Bindings need to reference other folders, so they are done here instead # lib dependencies are not included include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") + foreach(folder ${FOLDERS}) + add_subdirectory(${folder}) + endforeach(folder) + + get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES) + #clear file file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependecies.txt) foreach(dependecy ${BINDING_DEPENDECIES}) @@ -261,10 +157,6 @@ if (NOT MSVC) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "Bindings.cpp Bindings.h") - foreach(folder ${FOLDERS}) - add_subdirectory(${folder}) - endforeach(folder) - list(APPEND SOURCE "${SRCS}") list(APPEND SOURCE "${HDRS}") diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt index 9a59cdb2c..39d41292d 100644 --- a/src/PolarSSL++/CMakeLists.txt +++ b/src/PolarSSL++/CMakeLists.txt @@ -3,7 +3,7 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -set(SOURCES +set(SRCS AesCfb128Decryptor.cpp AesCfb128Encryptor.cpp BlockingSslClientSocket.cpp @@ -18,7 +18,7 @@ set(SOURCES X509Cert.cpp ) -set(HEADERS +set(HDRS AesCfb128Decryptor.h AesCfb128Encryptor.h BlockingSslClientSocket.h @@ -33,8 +33,10 @@ set(HEADERS X509Cert.h ) -add_library(PolarSSL++ ${SOURCES} ${HEADERS}) +if(NOT MSVC) + add_library(PolarSSL++ ${SRCS} ${HDRS}) -if (UNIX) - target_link_libraries(PolarSSL++ polarssl) + if (UNIX) + target_link_libraries(PolarSSL++ polarssl) + endif() endif() -- cgit v1.2.3 From 0960e6ae8ffe329ecd78b2f0f433fcb9e817a696 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 19:25:15 -0700 Subject: Moved Windows custom command to src/CMakeLists.txt --- src/Bindings/CMakeLists.txt | 16 +--------------- src/CMakeLists.txt | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index 723487ff0..4726eea23 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -112,21 +112,7 @@ set(BINDING_DEPENDECIES ../World.h ) -if (WIN32) - ADD_CUSTOM_COMMAND( - OUTPUT ${BINDING_OUTPUTS} - - # Copy the Lua DLL into the Bindings folder, so that tolua can run from there: - COMMAND ${CMAKE_COMMAND} -E copy_if_different ../../MCServer/lua51.dll ./lua51.dll - - # Regenerate bindings: - COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - - # add any new generation dependencies here - DEPENDS ${BINDING_DEPENDECIES} - ) -else () +if (NOT WIN32) ADD_CUSTOM_COMMAND( # add any new generated bindings here OUTPUT ${BINDING_OUTPUTS} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6008d3174..168c576e2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -230,6 +230,25 @@ endif() set(EXECUTABLE MCServer) +if (WIN32) + get_directory_property(BINDING_OUTPUTS DIRECTORY "Bindings" DEFINITION BINDING_OUTPUTS) + get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES) + + ADD_CUSTOM_COMMAND( + OUTPUT ${BINDING_OUTPUTS} + + # Copy the Lua DLL into the Bindings folder, so that tolua can run from there: + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/MCServer/lua51.dll ./lua51.dll + + # Regenerate bindings: + COMMAND tolua -L Bindings/virtual_method_hooks.lua -o Bindings/Bindings.cpp -H Bindings/Bindings.h Bindings/AllToLua.pkg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + + # add any new generation dependencies here + DEPENDS ${BINDING_DEPENDECIES} + ) +endif() + add_executable(${EXECUTABLE} ${SOURCE}) -- cgit v1.2.3 From f94cf4998040428c2940b5f0d4dd27d740838d6f Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 21:38:55 -0700 Subject: Authenticator.cpp: Killed a global destructor warning --- src/Protocol/Authenticator.cpp | 109 +++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index 18924db2f..2a7cbc7bc 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -20,57 +20,60 @@ /** This is the data of the root certs for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert: Downloaded from http://certs.starfieldtech.com/repository/ */ -static const AString gStarfieldCACert( - // G2 cert - "-----BEGIN CERTIFICATE-----\n" - "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" - "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" - "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n" - "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n" - "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n" - "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n" - "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n" - "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" - "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n" - "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n" - "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n" - "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n" - "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n" - "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" - "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n" - "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" - "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" - "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" - "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" - "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" - "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" - "-----END CERTIFICATE-----\n\n" - // Original (G1) cert: - "-----BEGIN CERTIFICATE-----\n" - "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" - "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" - "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" - "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" - "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" - "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" - "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" - "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" - "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" - "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" - "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" - "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" - "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" - "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" - "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" - "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" - "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" - "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" - "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" - "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" - "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" - "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" - "-----END CERTIFICATE-----\n" -); +static const AString StarfieldCACert() +{ + return AString( + // G2 cert + "-----BEGIN CERTIFICATE-----\n" + "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n" + "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n" + "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n" + "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n" + "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n" + "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" + "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n" + "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n" + "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n" + "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n" + "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n" + "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n" + "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" + "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" + "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" + "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" + "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" + "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" + "-----END CERTIFICATE-----\n\n" + // Original (G1) cert: + "-----BEGIN CERTIFICATE-----\n" + "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" + "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" + "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" + "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" + "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" + "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" + "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" + "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" + "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" + "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" + "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" + "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" + "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" + "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" + "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" + "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" + "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" + "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" + "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" + "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" + "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" + "-----END CERTIFICATE-----\n" + ); +} @@ -263,7 +266,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S Request += "\r\n"; AString Response; - if (!SecureGetFromAddress(gStarfieldCACert, m_Server, Request, Response)) + if (!SecureGetFromAddress(StarfieldCACert(), m_Server, Request, Response)) { return false; } @@ -343,7 +346,7 @@ bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, Json::Value & a Request += "\r\n"; AString Response; - if (!ConnectSecurelyToAddress(gStarfieldCACert, m_Server, Request, Response)) + if (!ConnectSecurelyToAddress(StarfieldCACert(), m_Server, Request, Response)) { return false; } -- cgit v1.2.3 From c7b7938c04eb5bd801274f93465afdb2f63053c0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 09:57:03 +0200 Subject: Renamed AllToLua_lua script. Fixes #1222. --- src/Bindings/AllToLua_lua.bat | 27 +++++++++++++++++++++++++++ src/Bindings/AllToLua_lua.bat.bat | 27 --------------------------- 2 files changed, 27 insertions(+), 27 deletions(-) create mode 100644 src/Bindings/AllToLua_lua.bat delete mode 100644 src/Bindings/AllToLua_lua.bat.bat (limited to 'src') diff --git a/src/Bindings/AllToLua_lua.bat b/src/Bindings/AllToLua_lua.bat new file mode 100644 index 000000000..81c738f32 --- /dev/null +++ b/src/Bindings/AllToLua_lua.bat @@ -0,0 +1,27 @@ + +:: AllToLua_Lua.bat +:: This scripts updates the automatically-generates Lua bindings in Bindings.cpp / Bindings.h +:: When called without any parameters, it will pause for a keypress at the end +:: Call with any parameter to disable the wait (for buildserver use) +:: This script assumes "lua" executable to be in PATH, it uses a pure-lua implementation of the ToLua processor + +@echo off + + + + + +:: Regenerate the files: +echo Regenerating LUA bindings . . . +lua ..\..\lib\tolua++\src\bin\lua\_driver.lua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + + + + +: Wait for keypress, if no param given: +echo. +if %ALLTOLUA_WAIT%N == N pause + + + + diff --git a/src/Bindings/AllToLua_lua.bat.bat b/src/Bindings/AllToLua_lua.bat.bat deleted file mode 100644 index 81c738f32..000000000 --- a/src/Bindings/AllToLua_lua.bat.bat +++ /dev/null @@ -1,27 +0,0 @@ - -:: AllToLua_Lua.bat -:: This scripts updates the automatically-generates Lua bindings in Bindings.cpp / Bindings.h -:: When called without any parameters, it will pause for a keypress at the end -:: Call with any parameter to disable the wait (for buildserver use) -:: This script assumes "lua" executable to be in PATH, it uses a pure-lua implementation of the ToLua processor - -@echo off - - - - - -:: Regenerate the files: -echo Regenerating LUA bindings . . . -lua ..\..\lib\tolua++\src\bin\lua\_driver.lua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg - - - - -: Wait for keypress, if no param given: -echo. -if %ALLTOLUA_WAIT%N == N pause - - - - -- cgit v1.2.3 From 041bfd5860cd8ef51db42eb6fb4b50b45549feba Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 01:40:29 -0700 Subject: Fixed clamping issues --- src/ChunkMap.cpp | 5 +---- src/Defines.h | 13 +------------ src/Entities/Entity.cpp | 5 +---- src/Entities/Player.cpp | 5 +---- src/Entities/SplashPotionEntity.cpp | 5 +---- src/Mobs/Monster.cpp | 6 +----- 6 files changed, 6 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index e91f77d27..49e9245d2 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1951,10 +1951,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_ double FinalDamage = (((1 / AbsoluteEntityPos.x) + (1 / AbsoluteEntityPos.y) + (1 / AbsoluteEntityPos.z)) * 2) * m_ExplosionSize; // Clip damage values - if (FinalDamage > a_Entity->GetMaxHealth()) - FinalDamage = a_Entity->GetMaxHealth(); - else if (FinalDamage < 0) - FinalDamage = 0; + FinalDamage = Clamp(FinalDamage, 0.0, (double)a_Entity->GetMaxHealth()); if (!a_Entity->IsTNT() && !a_Entity->IsFallingBlock()) // Don't apply damage to other TNT entities and falling blocks, they should be invincible { diff --git a/src/Defines.h b/src/Defines.h index f57e63c7f..f7c8d0fc5 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -470,18 +470,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B { int Y = a_BlockY; AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse); - if (Y < 0) - { - a_BlockY = 0; - } - else if (Y > 255) - { - a_BlockY = 255; - } - else - { - a_BlockY = (unsigned char)Y; - } + a_BlockY = Clamp(Y, 0, 255); } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 61b28ec70..f9331ede8 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -327,10 +327,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) // TODO: Apply damage to armor - if (m_Health < 0) - { - m_Health = 0; - } + m_Health = std::max(m_Health, 0); if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs { diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index ea11926b8..7376441b4 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -382,10 +382,7 @@ short cPlayer::DeltaExperience(short a_Xp_delta) m_CurrentXp += a_Xp_delta; // Make sure they didn't subtract too much - if (m_CurrentXp < 0) - { - m_CurrentXp = 0; - } + m_CurrentXp = std::max(m_CurrentXp, 0); // Update total for score calculation if (a_Xp_delta > 0) diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 3efb1f25d..ccadf9c8e 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -44,10 +44,7 @@ public: // y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash. // TODO: better equation double Reduction = -0.25 * SplashDistance + 1.0; - if (Reduction < 0) - { - Reduction = 0; - } + Reduction = std::max(Reduction, 0.0); ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction); return false; diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index e6c82a448..8d612fbaa 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -414,11 +414,7 @@ void cMonster::HandleFalling() int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ) { int PosY = POSY_TOINT; - - if (PosY < 0) - PosY = 0; - else if (PosY > cChunkDef::Height) - PosY = cChunkDef::Height; + PosY = Clamp(PosY, 0, cChunkDef::Height); if (!cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ)))) { -- cgit v1.2.3 From 93c6520e1e6fa957c5d7b7aee71b7ae7e462d77d Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:46:31 -0700 Subject: Fixed splash potion color on toss --- src/Entities/SplashPotionEntity.cpp | 14 ++++++++++++++ src/Entities/SplashPotionEntity.h | 2 ++ 2 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 3efb1f25d..c379ab3fb 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -2,11 +2,15 @@ #include "SplashPotionEntity.h" #include "Pawn.h" +#include "../ClientHandle.h" +/// Converts an angle in radians into a byte representation used by the network protocol +#define ANGLE_TO_PROTO(X) (Byte)(X * 255 / 360) + //////////////////////////////////////////////////////////////////////////////// // cSplashPotionEntityCallback: @@ -118,3 +122,13 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) + +void cSplashPotionEntity::SpawnOn(cClientHandle & a_Client) +{ + a_Client.SendSpawnObject(*this, 73, m_PotionParticleType, ANGLE_TO_PROTO(GetYaw()), ANGLE_TO_PROTO(GetPitch())); + a_Client.SendEntityMetadata(*this); +} + + + + diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 2c78b55d2..1e056de68 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -56,4 +56,6 @@ protected: /** Splashes the potion, fires its particle effects and sounds @param a_HitPos The position where the potion will splash */ void Splash(const Vector3d & a_HitPos); + + virtual void SpawnOn(cClientHandle & a_Client) override; } ; // tolua_export -- cgit v1.2.3 From f5bcfdc58c7b5d69abbb222787bb2229c0b54088 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:51:39 -0700 Subject: Splash potions: Renamed PotionParticleType to PotionColor for clarity --- src/Entities/SplashPotionEntity.cpp | 8 ++++---- src/Entities/SplashPotionEntity.h | 12 ++++++------ src/Items/ItemPotion.h | 6 +++--- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- src/WorldStorage/WSSAnvil.cpp | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index c379ab3fb..056700629 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -76,12 +76,12 @@ cSplashPotionEntity::cSplashPotionEntity( const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, - int a_PotionParticleType + int a_PotionColor ) : super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), m_EntityEffectType(a_EntityEffectType), m_EntityEffect(a_EntityEffect), - m_PotionParticleType(a_PotionParticleType) + m_PotionColor(a_PotionColor) { SetSpeed(a_Speed); } @@ -116,7 +116,7 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect); m_World->ForEachEntity(Callback); - m_World->BroadcastSoundParticleEffect(2002, (int)a_HitPos.x, (int)a_HitPos.y, (int)a_HitPos.z, m_PotionParticleType); + m_World->BroadcastSoundParticleEffect(2002, (int)a_HitPos.x, (int)a_HitPos.y, (int)a_HitPos.z, m_PotionColor); } @@ -125,7 +125,7 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) void cSplashPotionEntity::SpawnOn(cClientHandle & a_Client) { - a_Client.SendSpawnObject(*this, 73, m_PotionParticleType, ANGLE_TO_PROTO(GetYaw()), ANGLE_TO_PROTO(GetPitch())); + a_Client.SendSpawnObject(*this, 73, m_PotionColor, ANGLE_TO_PROTO(GetYaw()), ANGLE_TO_PROTO(GetPitch())); a_Client.SendEntityMetadata(*this); } diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 1e056de68..a33b06990 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -31,22 +31,22 @@ public: const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, - int a_PotionParticleType + int a_PotionColor ); - cEntityEffect::eType GetEntityEffectType (void) const { return m_EntityEffectType; } - cEntityEffect GetEntityEffect (void) const { return m_EntityEffect; } - int GetPotionParticleType(void) const { return m_PotionParticleType; } + cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; } + cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; } + int GetPotionColor(void) const { return m_PotionColor; } void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; } void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; } - void SetPotionParticleType(int a_PotionParticleType) { m_PotionParticleType = a_PotionParticleType; } + void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; } protected: cEntityEffect::eType m_EntityEffectType; cEntityEffect m_EntityEffect; - int m_PotionParticleType; + int m_PotionColor; // cProjectileEntity overrides: diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index f3afbf99b..f16d89b39 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -17,8 +17,8 @@ public: } - /** Returns the potion particle type (used by the client for visuals), based on the potion's damage value */ - static int GetPotionParticleType(short a_ItemDamage) + /** Returns the potion color (used by the client for visuals), based on the potion's damage value */ + static int GetPotionColor(short a_ItemDamage) { // Lowest six bits return (a_ItemDamage & 0x3f); @@ -156,7 +156,7 @@ public: cSplashPotionEntity * Projectile = new cSplashPotionEntity( a_Player, Pos.x, Pos.y, Pos.z, Speed, GetEntityEffectType(PotionDamage), cEntityEffect(GetEntityEffectDuration(PotionDamage), - GetEntityEffectIntensity(PotionDamage)), GetPotionParticleType(PotionDamage) + GetEntityEffectIntensity(PotionDamage)), GetPotionColor(PotionDamage) ); if (Projectile == NULL) { diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index e68903b26..62db302ef 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -613,7 +613,7 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) m_Writer.AddInt("EffectDuration", (Int16)Potion->GetEntityEffect().GetDuration()); m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity()); m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier()); - m_Writer.AddInt("PotionName", Potion->GetPotionParticleType()); + m_Writer.AddInt("PotionName", Potion->GetPotionColor()); } case cProjectileEntity::pkGhastFireball: { diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index b4048b097..663d489bc 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1681,7 +1681,7 @@ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedN SplashPotion->SetEntityEffectType((cEntityEffect::eType) a_NBT.FindChildByName(a_TagIdx, "EffectType")); SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, EffectIntensity, EffectDistanceModifier)); - SplashPotion->SetPotionParticleType(a_NBT.FindChildByName(a_TagIdx, "PotionName")); + SplashPotion->SetPotionColor(a_NBT.FindChildByName(a_TagIdx, "PotionName")); // Store the new splash potion in the entities list: a_Entities.push_back(SplashPotion.release()); -- cgit v1.2.3 From f86eefa2ae07c32772f4353f14de9625dc9c20de Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:54:44 -0700 Subject: Trees.cpp: removed unused "debug" fields --- src/Generating/Trees.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src') diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index b7a08999d..c40322630 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -10,13 +10,6 @@ -// DEBUG: -int gTotalLargeJungleTrees = 0; -int gOversizeLargeJungleTrees = 0; - - - - typedef struct { @@ -113,6 +106,7 @@ inline void PushCoordBlocks(int a_BlockX, int a_Height, int a_BlockZ, sSetBlockV + inline void PushCornerBlocks(int a_BlockX, int a_Height, int a_BlockZ, int a_Seq, cNoise & a_Noise, int a_Chance, sSetBlockVector & a_Blocks, int a_CornersDist, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) { for (size_t i = 0; i < ARRAYCOUNT(Corners); i++) -- cgit v1.2.3 From 7c861f98a2933e125f100f239d0ae5e977d1a719 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:55:36 -0700 Subject: Minecart: slimmed down SpawnOn by keeping subtype in the payload enum --- src/Entities/Minecart.cpp | 16 +--------------- src/Entities/Minecart.h | 11 ++++++----- 2 files changed, 7 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index 03850c8a7..d4eadc5d5 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -103,21 +103,7 @@ cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) : void cMinecart::SpawnOn(cClientHandle & a_ClientHandle) { - char SubType = 0; - switch (m_Payload) - { - case mpNone: SubType = 0; break; - case mpChest: SubType = 1; break; - case mpFurnace: SubType = 2; break; - case mpTNT: SubType = 3; break; - case mpHopper: SubType = 5; break; - default: - { - ASSERT(!"Unknown payload, cannot spawn on client"); - return; - } - } - a_ClientHandle.SendSpawnVehicle(*this, 10, SubType); // 10 = Minecarts, SubType = What type of Minecart + a_ClientHandle.SendSpawnVehicle(*this, 10, (char)m_Payload); // 10 = Minecarts a_ClientHandle.SendEntityMetadata(*this); } diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h index 798f844ce..c585cfab0 100644 --- a/src/Entities/Minecart.h +++ b/src/Entities/Minecart.h @@ -23,13 +23,14 @@ class cMinecart : public: CLASS_PROTODEF(cMinecart); + /** Minecart payload, values correspond to packet subtype */ enum ePayload { - mpNone, // Empty minecart, ridable by player or mobs - mpChest, // Minecart-with-chest, can store a grid of 3*8 items - mpFurnace, // Minecart-with-furnace, can be powered - mpTNT, // Minecart-with-TNT, can be blown up with activator rail - mpHopper, // Minecart-with-hopper, can be hopper + mpNone = 0, // Empty minecart, ridable by player or mobs + mpChest = 1, // Minecart-with-chest, can store a grid of 3*8 items + mpFurnace = 2, // Minecart-with-furnace, can be powered + mpTNT = 3, // Minecart-with-TNT, can be blown up with activator rail + mpHopper = 5, // Minecart-with-hopper, can be hopper // TODO: Spawner minecarts, (and possibly any block in a minecart with NBT editing) } ; -- cgit v1.2.3 From 11f8198a8054e2b50df3fdbd8a59a876d7db87f0 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:56:46 -0700 Subject: World.cpp: fixed not all enum fields being used in m_Dimension switch --- src/World.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/World.cpp b/src/World.cpp index 186842b20..c27fd462b 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -570,12 +570,13 @@ void cWorld::Start(void) m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll); // Load allowed mobs: - const char * DefaultMonsters = ""; + AString DefaultMonsters; switch (m_Dimension) { case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, enderman, horse, mooshroom, ocelot, pig, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break; case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break; case dimEnd: DefaultMonsters = "enderman"; break; + case dimNotSet: break; } m_bAnimals = IniFile.GetValueSetB("Monsters", "AnimalsOn", true); AString AllMonsters = IniFile.GetValueSet("Monsters", "Types", DefaultMonsters); -- cgit v1.2.3 From 9e7958e7fbb5a2477e04d30724730e15335b969f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 13:22:16 +0200 Subject: Fixed MSVC bindings generation. --- src/Bindings/CMakeLists.txt | 2 +- src/CMakeLists.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index 4726eea23..95b858f5d 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -112,7 +112,7 @@ set(BINDING_DEPENDECIES ../World.h ) -if (NOT WIN32) +if (NOT MSVC) ADD_CUSTOM_COMMAND( # add any new generated bindings here OUTPUT ${BINDING_OUTPUTS} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 168c576e2..9feaf64fe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -230,7 +230,7 @@ endif() set(EXECUTABLE MCServer) -if (WIN32) +if (MSVC) get_directory_property(BINDING_OUTPUTS DIRECTORY "Bindings" DEFINITION BINDING_OUTPUTS) get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES) @@ -241,8 +241,8 @@ if (WIN32) COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/MCServer/lua51.dll ./lua51.dll # Regenerate bindings: - COMMAND tolua -L Bindings/virtual_method_hooks.lua -o Bindings/Bindings.cpp -H Bindings/Bindings.h Bindings/AllToLua.pkg - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/ # add any new generation dependencies here DEPENDS ${BINDING_DEPENDECIES} -- cgit v1.2.3 From 00c524519ef6c7ceaf4ac91307617cfd65d7cf21 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 14:53:41 +0200 Subject: Fixed style: spaces after commas. --- src/Bindings/DeprecatedBindings.cpp | 38 +++++++++++++------------- src/Bindings/LuaState.cpp | 3 +- src/Bindings/ManualBindings.cpp | 26 +++++++++--------- src/Blocks/BlockBed.cpp | 2 +- src/Blocks/BlockBed.h | 2 +- src/Blocks/BlockLadder.h | 2 +- src/Blocks/BlockLeaves.h | 2 +- src/Blocks/BlockPortal.h | 4 +-- src/Blocks/ChunkInterface.h | 2 +- src/BoundingBox.cpp | 2 +- src/BoundingBox.h | 2 +- src/Chunk.cpp | 6 ++-- src/ClientHandle.cpp | 4 +-- src/CraftingRecipes.h | 2 +- src/Entities/TNTEntity.cpp | 2 +- src/Generating/Caves.cpp | 2 +- src/Generating/ChunkGenerator.cpp | 2 +- src/Generating/Ravines.cpp | 12 ++++---- src/Generating/Trees.h | 2 +- src/Globals.h | 2 +- src/GroupManager.cpp | 4 +-- src/Items/ItemBucket.h | 2 +- src/Items/ItemShovel.h | 2 +- src/Log.cpp | 2 +- src/MobProximityCounter.cpp | 8 +++--- src/MobProximityCounter.h | 4 +-- src/MobSpawner.cpp | 2 +- src/Mobs/Monster.cpp | 2 +- src/Mobs/Monster.h | 2 +- src/OSSupport/Socket.cpp | 2 +- src/OSSupport/Thread.cpp | 8 +++--- src/Protocol/Protocol17x.cpp | 2 +- src/Protocol/ProtocolRecognizer.cpp | 2 +- src/Simulator/FireSimulator.cpp | 2 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 10 +++---- src/StringUtils.cpp | 8 +++--- src/Tracer.cpp | 6 ++-- src/World.cpp | 2 +- src/World.h | 2 +- src/WorldStorage/WSSAnvil.h | 2 +- src/WorldStorage/WorldStorage.cpp | 6 ++-- src/WorldStorage/WorldStorage.h | 2 +- 42 files changed, 100 insertions(+), 101 deletions(-) (limited to 'src') diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp index d2e60945d..07b1a29fd 100644 --- a/src/Bindings/DeprecatedBindings.cpp +++ b/src/Bindings/DeprecatedBindings.cpp @@ -25,9 +25,9 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) { - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } } #endif @@ -36,7 +36,7 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S) { tolua_error(tolua_S, "array indexing out of range.", NULL); } - tolua_pushnumber(tolua_S,(lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType)); + tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType)); return 1; } #endif // #ifndef TOLUA_DISABLE @@ -53,8 +53,8 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -79,8 +79,8 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -105,8 +105,8 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -131,8 +131,8 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -157,8 +157,8 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -183,8 +183,8 @@ static int tolua_get_AllToLua_g_BlockRequiresSpecialTool(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -209,8 +209,8 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -235,8 +235,8 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 7d918cf2b..e123a87c9 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1336,9 +1336,8 @@ void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header) { UNUSED(a_Header); // The param seems unused when compiling for release, so the compiler warns - // Format string consisting only of %s is used to appease the compiler - LOGD("%s",(a_Header != NULL) ? a_Header : "Lua C API Stack contents:"); + LOGD("%s", (a_Header != NULL) ? a_Header : "Lua C API Stack contents:"); for (int i = lua_gettop(a_LuaState); i > 0; i--) { AString Value; diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 530101d47..4047adc3a 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -958,7 +958,7 @@ tolua_lerror: static int tolua_cWorld_TryGetHeight(lua_State * tolua_S) { // Exported manually, because tolua would require the out-only param a_Height to be used when calling - // Takes (a_World,) a_BlockX, a_BlockZ + // Takes a_World, a_BlockX, a_BlockZ // Returns Height, IsValid #ifndef TOLUA_RELEASE tolua_Error tolua_err; @@ -1926,12 +1926,12 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S) int Reference = LUA_REFNIL; if ( - tolua_isstring(tolua_S, 2, 0, &tolua_err ) && - lua_isfunction(tolua_S, 3 ) + tolua_isstring(tolua_S, 2, 0, &tolua_err) && + lua_isfunction(tolua_S, 3) ) { Reference = luaL_ref(tolua_S, LUA_REGISTRYINDEX); - Title = ((std::string) tolua_tocppstring(tolua_S,2,0)); + Title = ((std::string)tolua_tocppstring(tolua_S, 2, 0)); } else { @@ -2591,7 +2591,7 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S) } AString Filename = tolua_tostring(tolua_S, 2, 0); - bool res = cSchematicFileSerializer::LoadFromSchematicFile(*self,Filename); + bool res = cSchematicFileSerializer::LoadFromSchematicFile(*self, Filename); tolua_pushboolean(tolua_S, res); return 1; } @@ -2651,7 +2651,7 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S) return 0; } AString Filename = tolua_tostring(tolua_S, 2, 0); - bool res = cSchematicFileSerializer::SaveToSchematicFile(*self,Filename); + bool res = cSchematicFileSerializer::SaveToSchematicFile(*self, Filename); tolua_pushboolean(tolua_S, res); return 1; } @@ -3065,13 +3065,13 @@ void ManualBindings::Bind(lua_State * tolua_S) tolua_function(tolua_S, "AddWebTab", tolua_cPluginLua_AddWebTab); tolua_endmodule(tolua_S); - tolua_cclass(tolua_S,"HTTPRequest","HTTPRequest","",NULL); - tolua_beginmodule(tolua_S,"HTTPRequest"); - // tolua_variable(tolua_S,"Method",tolua_get_HTTPRequest_Method,tolua_set_HTTPRequest_Method); - // tolua_variable(tolua_S,"Path",tolua_get_HTTPRequest_Path,tolua_set_HTTPRequest_Path); - tolua_variable(tolua_S,"FormData",tolua_get_HTTPRequest_FormData,0); - tolua_variable(tolua_S,"Params",tolua_get_HTTPRequest_Params,0); - tolua_variable(tolua_S,"PostParams",tolua_get_HTTPRequest_PostParams,0); + tolua_cclass(tolua_S, "HTTPRequest", "HTTPRequest", "", NULL); + tolua_beginmodule(tolua_S, "HTTPRequest"); + // tolua_variable(tolua_S, "Method", tolua_get_HTTPRequest_Method, tolua_set_HTTPRequest_Method); + // tolua_variable(tolua_S, "Path", tolua_get_HTTPRequest_Path, tolua_set_HTTPRequest_Path); + tolua_variable(tolua_S, "FormData", tolua_get_HTTPRequest_FormData, 0); + tolua_variable(tolua_S, "Params", tolua_get_HTTPRequest_Params, 0); + tolua_variable(tolua_S, "PostParams", tolua_get_HTTPRequest_PostParams, 0); tolua_endmodule(tolua_S); tolua_beginmodule(tolua_S, "cWebAdmin"); diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index fbf98044c..fbc82b440 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -15,7 +15,7 @@ void cBlockBedHandler::OnPlacedByPlayer( if (a_BlockMeta < 8) { Vector3i Direction = MetaDataToDirection(a_BlockMeta); - a_ChunkInterface.SetBlock(a_WorldInterface,a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8); } } diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h index 51e79b888..bf9d9c01d 100644 --- a/src/Blocks/BlockBed.h +++ b/src/Blocks/BlockBed.h @@ -16,7 +16,7 @@ class cBlockBedHandler : { public: cBlockBedHandler(BLOCKTYPE a_BlockType) - : cMetaRotator(a_BlockType) + : cMetaRotator(a_BlockType) { } diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index 72acced41..284d1d732 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -103,7 +103,7 @@ public: } - virtual bool CanBeAt(cChunkInterface & a_ChunkInterface,int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { // TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison eBlockFace BlockFace = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)); diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index d0baab013..797824506 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -11,7 +11,7 @@ // Leaves can be this many blocks that away (inclusive) from the log not to decay #define LEAVES_CHECK_DISTANCE 6 -#define PROCESS_NEIGHBOR(x,y,z) \ +#define PROCESS_NEIGHBOR(x, y, z) \ switch (a_Area.GetBlockType(x, y, z)) \ { \ case E_BLOCK_LEAVES: a_Area.SetBlockType(x, y, z, (BLOCKTYPE)(E_BLOCK_SPONGE + i + 1)); break; \ diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 9ee5d69e2..fc74e89d0 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -70,7 +70,7 @@ public: } PortalCheck[] = { { 0, 1, 0}, - { 0,-1, 0}, + { 0, -1, 0}, { 1, 0, 0}, {-1, 0, 0}, } ; @@ -95,7 +95,7 @@ public: } PortalCheck[] = { { 0, 1, 0}, - { 0,-1, 0}, + { 0, -1, 0}, { 0, 0, -1}, { 0, 0, 1}, } ; diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h index f9cbe3a2d..3bab60be6 100644 --- a/src/Blocks/ChunkInterface.h +++ b/src/Blocks/ChunkInterface.h @@ -18,7 +18,7 @@ public: BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ) { - return m_ChunkMap->GetBlock(a_BlockX,a_BlockY,a_BlockZ); + return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ); } BLOCKTYPE GetBlock(const Vector3i & a_Pos) { diff --git a/src/BoundingBox.cpp b/src/BoundingBox.cpp index ce831c200..6b163b01e 100644 --- a/src/BoundingBox.cpp +++ b/src/BoundingBox.cpp @@ -191,7 +191,7 @@ bool cBoundingBox::IsInside(const Vector3d & a_Point) -bool cBoundingBox::IsInside(double a_X, double a_Y,double a_Z) +bool cBoundingBox::IsInside(double a_X, double a_Y, double a_Z) { return IsInside(m_Min, m_Max, a_X, a_Y, a_Z); } diff --git a/src/BoundingBox.h b/src/BoundingBox.h index a7c6c3eea..793466302 100644 --- a/src/BoundingBox.h +++ b/src/BoundingBox.h @@ -49,7 +49,7 @@ public: bool IsInside(const Vector3d & a_Point); /// Returns true if the point is inside the bounding box - bool IsInside(double a_X, double a_Y,double a_Z); + bool IsInside(double a_X, double a_Y, double a_Z); /// Returns true if a_Other is inside this bounding box bool IsInside(cBoundingBox & a_Other); diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 6fb615f1c..6e2d3509d 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -455,7 +455,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill) currentPosition = Monster.GetPosition(); for (std::list::const_iterator itr2 = playerPositions.begin(); itr2 != playerPositions.end(); ++itr2) { - toFill.CollectMob(Monster,*this,(currentPosition-**itr2).SqrLength()); + toFill.CollectMob(Monster, *this, (currentPosition - **itr2).SqrLength()); } } } // for itr - m_Entitites[] @@ -464,7 +464,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill) -void cChunk::GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z,int a_MaxX, int a_MaxY, int a_MaxZ) +void cChunk::GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z, int a_MaxX, int a_MaxY, int a_MaxZ) { ASSERT(a_MaxX * a_MaxY * a_MaxZ * 8 < 0x00ffffff); int Random = m_World->GetTickRandomNumber(0x00ffffff); @@ -638,7 +638,7 @@ void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ) ASSERT(Handler != NULL); // Happenned on server restart, FS #243 cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap()); cBlockInServerPluginInterface PluginInterface(*this->GetWorld()); - Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface,*this, a_RelX, a_RelY, a_RelZ); + Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, a_RelX, a_RelY, a_RelZ); } diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 58247a836..cf78b19c5 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1070,7 +1070,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo ItemHandler->OnBlockDestroyed(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ); // The ItemHandler is also responsible for spawning the pickups cChunkInterface ChunkInterface(World->GetChunkMap()); - BlockHandler(a_OldBlock)->OnDestroyedByPlayer(ChunkInterface,*World, m_Player, a_BlockX, a_BlockY, a_BlockZ); + BlockHandler(a_OldBlock)->OnDestroyedByPlayer(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ); World->BroadcastSoundParticleEffect(2001, a_BlockX, a_BlockY, a_BlockZ, a_OldBlock, this); World->DigBlock(a_BlockX, a_BlockY, a_BlockZ); @@ -1361,7 +1361,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e m_Player->GetInventory().RemoveOneEquippedItem(); } cChunkInterface ChunkInterface(World->GetChunkMap()); - NewBlock->OnPlacedByPlayer(ChunkInterface,*World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta); + NewBlock->OnPlacedByPlayer(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta); // Step sound with 0.8f pitch is used as block placement sound World->BroadcastSoundEffect(NewBlock->GetStepSound(), (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.8f); diff --git a/src/CraftingRecipes.h b/src/CraftingRecipes.h index 90e41eddc..0250d2f68 100644 --- a/src/CraftingRecipes.h +++ b/src/CraftingRecipes.h @@ -127,7 +127,7 @@ protected: typedef std::vector cRecipeSlots; /** A single recipe, stored. Each recipe is normalized right after parsing (NormalizeIngredients()) - A normalized recipe starts at (0,0) + A normalized recipe starts at (0, 0) */ struct cRecipe { diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp index fd9a4e7ac..53af446cc 100644 --- a/src/Entities/TNTEntity.cpp +++ b/src/Entities/TNTEntity.cpp @@ -42,7 +42,7 @@ void cTNTEntity::Explode(void) { m_FuseTicks = 0; Destroy(true); - LOGD("BOOM at {%f,%f,%f}", GetPosX(), GetPosY(), GetPosZ()); + LOGD("BOOM at {%f, %f, %f}", GetPosX(), GetPosY(), GetPosZ()); m_World->DoExplosionAt(4.0, GetPosX() + 0.49, GetPosY() + 0.49, GetPosZ() + 0.49, true, esPrimedTNT, this); } diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index 3571b29d4..21bfd98b8 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -559,7 +559,7 @@ AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) cons char Prefix = 'M'; // The first point needs "M" prefix, all the others need "L" for (cCaveDefPoints::const_iterator itr = m_Points.begin(); itr != m_Points.end(); ++itr) { - AppendPrintf(SVG, "%c %d,%d ", Prefix, a_OffsetX + itr->m_BlockX, a_OffsetZ + itr->m_BlockZ); + AppendPrintf(SVG, "%c %d, %d ", Prefix, a_OffsetX + itr->m_BlockX, a_OffsetZ + itr->m_BlockZ); Prefix = 'L'; } SVG.append("\"/>\n"); diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp index 0947eeae5..9383a3adf 100644 --- a/src/Generating/ChunkGenerator.cpp +++ b/src/Generating/ChunkGenerator.cpp @@ -180,7 +180,7 @@ BLOCKTYPE cChunkGenerator::GetIniBlock(cIniFile & a_IniFile, const AString & a_S BLOCKTYPE Block = BlockStringToType(BlockType); if (Block < 0) { - LOGWARN("[%s].%s Could not parse block value \"%s\". Using default: \"%s\".", a_SectionName.c_str(), a_ValueName.c_str(), BlockType.c_str(),a_Default.c_str()); + LOGWARN("[%s].%s Could not parse block value \"%s\". Using default: \"%s\".", a_SectionName.c_str(), a_ValueName.c_str(), BlockType.c_str(), a_Default.c_str()); return BlockStringToType(a_Default); } return Block; diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index 86e27d8ed..70b9d0b62 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -287,34 +287,34 @@ AString cStructGenRavines::cRavine::ExportAsSVG(int a_Color, int a_OffsetX, int char Prefix = 'M'; // The first point needs "M" prefix, all the others need "L" for (cRavDefPoints::const_iterator itr = m_Points.begin(); itr != m_Points.end(); ++itr) { - AppendPrintf(SVG, "%c %d,%d ", Prefix, a_OffsetX + itr->m_BlockX, a_OffsetZ + itr->m_BlockZ); + AppendPrintf(SVG, "%c %d, %d ", Prefix, a_OffsetX + itr->m_BlockX, a_OffsetZ + itr->m_BlockZ); Prefix = 'L'; } SVG.append("\"/>\n"); // Base point highlight: - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetX + m_OriginX - 5, a_OffsetZ + m_OriginZ, a_OffsetX + m_OriginX + 5, a_OffsetZ + m_OriginZ ); - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ - 5, a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ + 5 ); // A gray line from the base point to the first point of the ravine, for identification: - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ, a_OffsetX + m_Points.front().m_BlockX, a_OffsetZ + m_Points.front().m_BlockZ ); // Offset guides: if (a_OffsetX > 0) { - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetX, a_OffsetX ); } if (a_OffsetZ > 0) { - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetZ, a_OffsetZ ); } diff --git a/src/Generating/Trees.h b/src/Generating/Trees.h index 00f343a3d..1f6ac4dff 100644 --- a/src/Generating/Trees.h +++ b/src/Generating/Trees.h @@ -70,7 +70,7 @@ void GetAcaciaTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noi void GetDarkoakTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks); /// Generates an image of a random large birch tree -void GetTallBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks,sSetBlockVector & a_OtherBlocks); +void GetTallBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks); /// Generates an image of a random conifer tree void GetConiferTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks); diff --git a/src/Globals.h b/src/Globals.h index 9b2f25f36..932040ec2 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -252,7 +252,7 @@ template class SizeChecker; #include "MCLogger.h" #else // Logging functions -void inline LOGERROR(const char* a_Format, ...) FORMATSTRING(1,2); +void inline LOGERROR(const char* a_Format, ...) FORMATSTRING(1, 2); void inline LOGERROR(const char* a_Format, ...) { diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index ffba68200..135a1636a 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -125,7 +125,7 @@ bool cGroupManager::LoadGroups() IniFile.SetValue("Owner", "Permissions", "*", true); IniFile.SetValue("Owner", "Color", "2", true); - IniFile.SetValue("Moderator", "Permissions", "core.time,core.item,core.tpa,core.tpaccept,core.ban,core.unban,core.save-all,core.toggledownfall"); + IniFile.SetValue("Moderator", "Permissions", "core.time, core.item, core.tpa, core.tpaccept, core.ban, core.unban, core.save-all, core.toggledownfall"); IniFile.SetValue("Moderator", "Color", "2", true); IniFile.SetValue("Moderator", "Inherits", "Player", true); @@ -133,7 +133,7 @@ bool cGroupManager::LoadGroups() IniFile.SetValue("Player", "Color", "f", true); IniFile.SetValue("Player", "Inherits", "Default", true); - IniFile.SetValue("Default", "Permissions", "core.help,core.plugins,core.spawn,core.worlds,core.back,core.motd,core.build,core.locate,core.viewdistance", true); + IniFile.SetValue("Default", "Permissions", "core.help, core.plugins, core.spawn, core.worlds, core.back, core.motd, core.build, core.locate, core.viewdistance", true); IniFile.SetValue("Default", "Color", "f", true); IniFile.WriteFile("groups.ini"); diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 6d7926fa4..a17c4838b 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -117,7 +117,7 @@ public: return false; } cItem Item(E_ITEM_BUCKET, 1); - if (!a_Player->GetInventory().AddItem(Item,true,true)) + if (!a_Player->GetInventory().AddItem(Item, true, true)) { return false; } diff --git a/src/Items/ItemShovel.h b/src/Items/ItemShovel.h index 333ba46e8..78cfe26fe 100644 --- a/src/Items/ItemShovel.h +++ b/src/Items/ItemShovel.h @@ -28,7 +28,7 @@ public: { cChunkInterface ChunkInterface(a_World->GetChunkMap()); cBlockInServerPluginInterface PluginInterface(*a_World); - BlockHandler(Block)->DropBlock(ChunkInterface,*a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ); + BlockHandler(Block)->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ); a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); a_Player->UseEquippedItem(); diff --git a/src/Log.cpp b/src/Log.cpp index d96e3e9e4..69b9c13a2 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -130,7 +130,7 @@ void cLog::Log(const char * a_Format, va_list argList) // Print to console: #if defined(ANDROID_NDK) - // __android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList); + // __android_log_vprint(ANDROID_LOG_ERROR, "MCServer", a_Format, argList); __android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str() ); // CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line ); #else diff --git a/src/MobProximityCounter.cpp b/src/MobProximityCounter.cpp index a89fa72df..f5d3e970c 100644 --- a/src/MobProximityCounter.cpp +++ b/src/MobProximityCounter.cpp @@ -8,12 +8,12 @@ void cMobProximityCounter::CollectMob(cEntity& a_Monster, cChunk& a_Chunk, double a_Distance) { - // LOGD("Collecting monster %s, with distance %f",a_Monster->GetClass(),a_Distance); + // LOGD("Collecting monster %s, with distance %f", a_Monster->GetClass(), a_Distance); tMonsterToDistance::iterator it = m_MonsterToDistance.find(&a_Monster); if (it == m_MonsterToDistance.end()) { - sDistanceAndChunk newDistanceAndChunk(a_Distance,a_Chunk); - std::pair result = m_MonsterToDistance.insert(tMonsterToDistance::value_type(&a_Monster,newDistanceAndChunk)); + sDistanceAndChunk newDistanceAndChunk(a_Distance, a_Chunk); + std::pair result = m_MonsterToDistance.insert(tMonsterToDistance::value_type(&a_Monster, newDistanceAndChunk)); if (!result.second) { ASSERT(!"A collected Monster was not found inside distance map using find(), but insert() said there already is a key for it"); @@ -36,7 +36,7 @@ void cMobProximityCounter::convertMaps() { for(tMonsterToDistance::const_iterator itr = m_MonsterToDistance.begin(); itr != m_MonsterToDistance.end(); ++itr) { - m_DistanceToMonster.insert(tDistanceToMonster::value_type(itr->second.m_Distance,sMonsterAndChunk(*itr->first,*itr->second.m_Chunk))); + m_DistanceToMonster.insert(tDistanceToMonster::value_type(itr->second.m_Distance, sMonsterAndChunk(*itr->first, *itr->second.m_Chunk))); } } diff --git a/src/MobProximityCounter.h b/src/MobProximityCounter.h index cadfc48ae..8c6c11d68 100644 --- a/src/MobProximityCounter.h +++ b/src/MobProximityCounter.h @@ -28,8 +28,8 @@ protected : }; public : - typedef std::map tMonsterToDistance; - typedef std::multimap tDistanceToMonster; + typedef std::map tMonsterToDistance; + typedef std::multimap tDistanceToMonster; protected : // this map is filled during collection phase, it will be later transformed into DistanceToMonster diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index da3e7c406..ce1187452 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -8,7 +8,7 @@ -cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily,const std::set& a_AllowedTypes) : +cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily, const std::set& a_AllowedTypes) : m_MonsterFamily(a_MonsterFamily), m_NewPack(true), m_MobType(cMonster::mtInvalidType) diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 8d612fbaa..db45db5b9 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -126,7 +126,7 @@ void cMonster::TickPathFinding() { 1, 0}, {-1, 0}, { 0, 1}, - { 0,-1}, + { 0, -1}, } ; if ((PosY - 1 < 0) || (PosY + 2 > cChunkDef::Height) /* PosY + 1 will never be true if PosY + 2 is not */) diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 4af7cf4f1..bbc3ebd35 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -73,7 +73,7 @@ public: // tolua_end enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState; - enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality; + enum MPersonality{PASSIVE, AGGRESSIVE, COWARDLY} m_EMPersonality; /** Creates the mob object. If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig() diff --git a/src/OSSupport/Socket.cpp b/src/OSSupport/Socket.cpp index 7d4d9e598..47d9f331d 100644 --- a/src/OSSupport/Socket.cpp +++ b/src/OSSupport/Socket.cpp @@ -138,7 +138,7 @@ int cSocket::WSAStartup(void) #ifdef _WIN32 WSADATA wsaData; memset(&wsaData, 0, sizeof(wsaData)); - return ::WSAStartup(MAKEWORD(2, 2),&wsaData); + return ::WSAStartup(MAKEWORD(2, 2), &wsaData); #else return 0; #endif diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp index 084e0810e..163c9b0c9 100644 --- a/src/OSSupport/Thread.cpp +++ b/src/OSSupport/Thread.cpp @@ -92,11 +92,11 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ ) #else DWORD ThreadID = 0; HANDLE hThread = CreateThread(NULL // security - ,0 // stack size + , 0 // stack size , (LPTHREAD_START_ROUTINE) MyThread // function name - ,this // parameters - ,0 // flags - ,&ThreadID ); // thread id + , this // parameters + , 0 // flags + , &ThreadID ); // thread id CloseHandle( hThread ); #ifdef _MSC_VER diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 37a9fdf47..67a5e97b1 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -2533,7 +2533,7 @@ void cProtocol172::cPacketizer::WriteItem(const cItem & a_Item) if (!a_Item.m_Enchantments.IsEmpty()) { const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench"; - EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments,Writer, TagName); + EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments, Writer, TagName); } if (!a_Item.IsBothNameAndLoreEmpty()) { diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 3991b84de..e62f9d216 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -331,7 +331,7 @@ void cProtocolRecognizer::SendEntityVelocity(const cEntity & a_Entity) void cProtocolRecognizer::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) { ASSERT(m_Protocol != NULL); - m_Protocol->SendExplosion(a_BlockX,a_BlockY,a_BlockZ,a_Radius, a_BlocksAffected, a_PlayerMotion); + m_Protocol->SendExplosion(a_BlockX, a_BlockY, a_BlockZ, a_Radius, a_BlocksAffected, a_PlayerMotion); } diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp index 9433a8c68..2164b6b10 100644 --- a/src/Simulator/FireSimulator.cpp +++ b/src/Simulator/FireSimulator.cpp @@ -98,7 +98,7 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun int x = itr->x; int y = itr->y; int z = itr->z; - BLOCKTYPE BlockType = a_Chunk->GetBlock(x,y,z); + BLOCKTYPE BlockType = a_Chunk->GetBlock(x, y, z); if (!IsAllowedBlock(BlockType)) { diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 3dd6417dc..ada8de4b8 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -570,10 +570,10 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re {-1, 1, 0}, { 0, 1, 1}, { 0, 1, -1}, /* Wires one higher, surrounding self stop */ - { 1,-1, 0}, /* Wires one lower, surrounding self start */ - {-1,-1, 0}, - { 0,-1, 1}, - { 0,-1, -1}, /* Wires one lower, surrounding self stop */ + { 1, -1, 0}, /* Wires one lower, surrounding self start */ + {-1, -1, 0}, + { 0, -1, 1}, + { 0, -1, -1}, /* Wires one lower, surrounding self stop */ } ; static const struct // Define which directions the wire will check for repeater prescence @@ -584,7 +584,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re { 1, 0, 0 }, {-1, 0, 0 }, { 0, 0, 1 }, - { 0, 0,-1 }, + { 0, 0, -1 }, { 0, 1, 0 }, }; diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index f60ed1248..9074ac7c2 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -785,10 +785,10 @@ AString Base64Decode(const AString & a_Base64String) AString Base64Encode(const AString & a_Input) { static const char BASE64[64] = { - 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', - 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', - 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', - 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; AString output; diff --git a/src/Tracer.cpp b/src/Tracer.cpp index 54b4716e3..fd8a297c0 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -18,11 +18,11 @@ cTracer::cTracer(cWorld * a_World) : m_World(a_World) { m_NormalTable[0].Set(-1, 0, 0); - m_NormalTable[1].Set( 0, 0,-1); + m_NormalTable[1].Set( 0, 0, -1); m_NormalTable[2].Set( 1, 0, 0); m_NormalTable[3].Set( 0, 0, 1); m_NormalTable[4].Set( 0, 1, 0); - m_NormalTable[5].Set( 0,-1, 0); + m_NormalTable[5].Set( 0, -1, 0); } @@ -245,7 +245,7 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int // return 1 = hit, other is not hit -int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,float y3) +int LinesCross(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) { // float linx, liny; diff --git a/src/World.cpp b/src/World.cpp index c27fd462b..d90383884 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2469,7 +2469,7 @@ cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, { if (a_CheckLineOfSight) { - if(!LineOfSight.Trace(a_Pos,(Pos - a_Pos),(int)(Pos - a_Pos).Length())) + if(!LineOfSight.Trace(a_Pos, (Pos - a_Pos), (int)(Pos - a_Pos).Length())) { ClosestDistance = Distance; ClosestPlayer = *itr; diff --git a/src/World.h b/src/World.h index f0e8d5cf3..5e0af6340 100644 --- a/src/World.h +++ b/src/World.h @@ -859,7 +859,7 @@ private: Int64 m_LastTimeUpdate; // The tick in which the last time update has been sent. Int64 m_LastUnload; // The last WorldAge (in ticks) in which unloading was triggerred Int64 m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred - std::map m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed) + std::map m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed) NIBBLETYPE m_SkyDarkness; diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h index 5b629f017..9f8714404 100644 --- a/src/WorldStorage/WSSAnvil.h +++ b/src/WorldStorage/WSSAnvil.h @@ -153,7 +153,7 @@ protected: void LoadPickupFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadTNTFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadExpOrbFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); - void LoadHangingFromNBT (cHangingEntity & a_Hanging,const cParsedNBT & a_NBT, int a_TagIdx); + void LoadHangingFromNBT (cHangingEntity & a_Hanging, const cParsedNBT & a_NBT, int a_TagIdx); void LoadItemFrameFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadMinecartRFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index 155aa6b14..d0b2acf3b 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -163,7 +163,7 @@ void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) void cWorldStorage::UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ) { - m_LoadQueue.Remove(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ,true)); + m_LoadQueue.Remove(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ, true)); } @@ -182,8 +182,8 @@ void cWorldStorage::UnqueueSave(const cChunkCoords & a_Chunk) void cWorldStorage::InitSchemas(int a_StorageCompressionFactor) { // The first schema added is considered the default - m_Schemas.push_back(new cWSSAnvil (m_World,a_StorageCompressionFactor)); - m_Schemas.push_back(new cWSSCompact (m_World,a_StorageCompressionFactor)); + m_Schemas.push_back(new cWSSAnvil (m_World, a_StorageCompressionFactor)); + m_Schemas.push_back(new cWSSCompact (m_World, a_StorageCompressionFactor)); m_Schemas.push_back(new cWSSForgetful(m_World)); // Add new schemas here diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index bf764a539..4d4c46a71 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -109,7 +109,7 @@ protected: }; }; - typedef cQueue sChunkLoadQueue; + typedef cQueue sChunkLoadQueue; cWorld * m_World; AString m_StorageSchemaName; -- cgit v1.2.3 From 1cb26bda8e3377fd092a348faeb39f7185f60934 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 15:07:28 +0200 Subject: Fixed spaces after commas in protocol data. The JSON data is well-formatted with spaces, too; we can afford to waste the few bytes. --- src/Protocol/Protocol17x.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 67a5e97b1..2707fbf9f 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1712,16 +1712,16 @@ void cProtocol172::HandlePacketStatusPing(cByteBuffer & a_ByteBuffer) void cProtocol172::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) { // Send the response: - AString Response = "{\"version\":{\"name\":\"1.7.2\",\"protocol\":4},\"players\":{"; + AString Response = "{\"version\":{\"name\":\"1.7.2\", \"protocol\":4}, \"players\":{"; cServer * Server = cRoot::Get()->GetServer(); - AppendPrintf(Response, "\"max\":%u,\"online\":%u,\"sample\":[]},", + AppendPrintf(Response, "\"max\":%u, \"online\":%u, \"sample\":[]},", Server->GetMaxPlayers(), Server->GetNumPlayers() ); AppendPrintf(Response, "\"description\":{\"text\":\"%s\"},", Server->GetDescription().c_str() ); - AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"", + AppendPrintf(Response, "\"favicon\": \"data:image/png;base64,%s\"", Server->GetFaviconData().c_str() ); Response.append("}"); @@ -3047,15 +3047,15 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player) void cProtocol176::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) { // Send the response: - AString Response = "{\"version\":{\"name\":\"1.7.6\",\"protocol\":5},\"players\":{"; - AppendPrintf(Response, "\"max\":%u,\"online\":%u,\"sample\":[]},", + AString Response = "{\"version\": {\"name\": \"1.7.6\", \"protocol\":5}, \"players\": {"; + AppendPrintf(Response, "\"max\": %u, \"online\": %u, \"sample\": []},", cRoot::Get()->GetServer()->GetMaxPlayers(), cRoot::Get()->GetServer()->GetNumPlayers() ); - AppendPrintf(Response, "\"description\":{\"text\":\"%s\"},", + AppendPrintf(Response, "\"description\": {\"text\": \"%s\"},", cRoot::Get()->GetServer()->GetDescription().c_str() ); - AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"", + AppendPrintf(Response, "\"favicon\": \"data:image/png;base64,%s\"", cRoot::Get()->GetServer()->GetFaviconData().c_str() ); Response.append("}"); -- cgit v1.2.3 From 822d83009d9ccc698e930907a707ba2451e95a20 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 15:08:49 +0200 Subject: CheckBasicStyle: Check spaces around commas. We want no space in front of and at least one space after a comma. --- src/CheckBasicStyle.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index 6aad4125d..14e3caa26 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -6,13 +6,13 @@ Checks that all source files (*.cpp, *.h) use the basic style requirements of th - Tabs for indentation, spaces for alignment - Trailing whitespace on non-empty lines - Two spaces between code and line-end comment ("//") - - Spaces after comma, not before (except in #define argument list) + - Spaces after comma, not before - (TODO) Spaces before *, /, & - (TODO) Hex numbers with even digit length - (TODO) Hex numbers in lowercase - (TODO) Braces not on the end of line - (TODO) Line dividers (////...) exactly 80 slashes - - (TODO) Not using "* "-style doxy comments continuation lines + - (TODO) Not using "* "-style doxy comment continuation lines Violations that cannot be checked easily: - Spaces around "+" (there are things like "a++", "++a", "a += 1", "X+", "stack +1" and ascii-drawn tables) @@ -79,8 +79,8 @@ local g_NumViolations = 0 --- Reports one violation -- Pretty-prints the message -- Also increments g_NumViolations -local function ReportViolation(a_FileName, a_LineNumber, a_Message) - print(a_FileName .. "(" .. a_LineNumber .. "): " .. a_Message) +local function ReportViolation(a_FileName, a_LineNumber, a_PatStart, a_PatEnd, a_Message) + print(a_FileName .. "(" .. a_LineNumber .. "): " .. a_PatStart .. " .. " .. a_PatEnd .. ": " .. a_Message) g_NumViolations = g_NumViolations + 1 end @@ -94,7 +94,7 @@ local function ReportViolationIfFound(a_Line, a_FileName, a_LineNum, a_Pattern, if not(patStart) then return end - ReportViolation(a_FileName, a_LineNum, a_Message .. "(" .. patStart .. " .. " .. patEnd .. ")") + ReportViolation(a_FileName, a_LineNum, patStart, patEnd, a_Message) end @@ -120,7 +120,7 @@ local g_ViolationPatterns = -- Check that all commas have spaces after them and not in front of them: {" ,", "Extra space before a \",\""}, - {"^\t*[^#].*,[^%s]", "Needs a space after a \",\""}, -- Anywhere except lines starting with "#" - avoid #define params + {",[^%s\"%%]", "Needs a space after a \",\""}, -- Report all except >> "," << needed for splitting and >>,%s<< needed for formatting } -- cgit v1.2.3 From 08748bafe26145cd61a179abd131a9dba6065450 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 15:23:40 +0200 Subject: Code style: Fixed braces on separate lines. --- src/BiomeDef.cpp | 3 ++- src/BlockEntities/ChestEntity.h | 3 ++- src/BlockEntities/DropSpenserEntity.h | 3 ++- src/BlockEntities/HopperEntity.h | 3 ++- src/BlockID.cpp | 3 ++- src/Entities/Player.cpp | 3 ++- src/MobProximityCounter.h | 3 ++- src/Noise.cpp | 12 ++++++++---- src/Protocol/Protocol125.h | 3 ++- src/Scoreboard.cpp | 3 ++- src/Server.cpp | 3 ++- src/Statistics.cpp | 3 ++- src/StringUtils.cpp | 8 +++++--- src/WorldStorage/WorldStorage.h | 5 +++-- 14 files changed, 38 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index d680377e2..02f8c2232 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -10,7 +10,8 @@ // The "map" used for biome <-> string conversions: -static struct { +static struct +{ EMCSBiome m_Biome; const char * m_String; } g_BiomeMap[] = diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h index 310618504..cd06b3e2c 100644 --- a/src/BlockEntities/ChestEntity.h +++ b/src/BlockEntities/ChestEntity.h @@ -27,7 +27,8 @@ class cChestEntity : typedef cBlockEntityWithItems super; public: - enum { + enum + { ContentsHeight = 3, ContentsWidth = 9, } ; diff --git a/src/BlockEntities/DropSpenserEntity.h b/src/BlockEntities/DropSpenserEntity.h index 47d3bd492..9f58d0b07 100644 --- a/src/BlockEntities/DropSpenserEntity.h +++ b/src/BlockEntities/DropSpenserEntity.h @@ -35,7 +35,8 @@ class cDropSpenserEntity : typedef cBlockEntityWithItems super; public: - enum { + enum + { ContentsHeight = 3, ContentsWidth = 3, } ; diff --git a/src/BlockEntities/HopperEntity.h b/src/BlockEntities/HopperEntity.h index 6ef98f43a..8e856fcda 100644 --- a/src/BlockEntities/HopperEntity.h +++ b/src/BlockEntities/HopperEntity.h @@ -22,7 +22,8 @@ class cHopperEntity : typedef cBlockEntityWithItems super; public: - enum { + enum + { ContentsHeight = 1, ContentsWidth = 5, TICKS_PER_TRANSFER = 8, ///< How many ticks at minimum between two item transfers to or from the hopper diff --git a/src/BlockID.cpp b/src/BlockID.cpp index 023172ca1..af96b4414 100644 --- a/src/BlockID.cpp +++ b/src/BlockID.cpp @@ -255,7 +255,8 @@ AString ItemToFullString(const cItem & a_Item) int StringToMobType(const AString & a_MobString) { - static struct { + static struct + { int m_MobType; const char * m_String; } MobMap [] = diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 7376441b4..698f77bf6 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -622,7 +622,8 @@ void cPlayer::FinishEating(void) GetInventory().RemoveOneEquippedItem(); // if the food is mushroom soup, return a bowl to the inventory - if( Item.m_ItemType == E_ITEM_MUSHROOM_SOUP ) { + if (Item.m_ItemType == E_ITEM_MUSHROOM_SOUP) + { cItem emptyBowl(E_ITEM_BOWL, 1, 0, ""); GetInventory().AddItem(emptyBowl, true, true); } diff --git a/src/MobProximityCounter.h b/src/MobProximityCounter.h index 8c6c11d68..2dabeaa21 100644 --- a/src/MobProximityCounter.h +++ b/src/MobProximityCounter.h @@ -55,7 +55,8 @@ public : // return the mobs that are within the range of distance of the closest player they are // that means that if a mob is 30 m from a player and 150 m from another one. It will be // in the range [0..50] but not in [100..200] - struct sIterablePair{ + struct sIterablePair + { tDistanceToMonster::const_iterator m_Begin; tDistanceToMonster::const_iterator m_End; int m_Count; diff --git a/src/Noise.cpp b/src/Noise.cpp index 145bcc5dd..a30661fe0 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -519,7 +519,8 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS const int BaseY = FAST_FLOOR(a_Y); const int BaseZ = FAST_FLOOR(a_Z); - const NOISE_DATATYPE points1[4][4] = { + const NOISE_DATATYPE points1[4][4] = + { { IntNoise3D(BaseX - 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY - 1, BaseZ - 1), }, { IntNoise3D(BaseX - 1, BaseY, BaseZ - 1), IntNoise3D(BaseX, BaseY, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY, BaseZ - 1), }, { IntNoise3D(BaseX - 1, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY + 1, BaseZ - 1), }, @@ -532,7 +533,8 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS const NOISE_DATATYPE x1interp3 = CubicInterpolate( points1[2][0], points1[2][1], points1[2][2], points1[2][3], FracX ); const NOISE_DATATYPE x1interp4 = CubicInterpolate( points1[3][0], points1[3][1], points1[3][2], points1[3][3], FracX ); - const NOISE_DATATYPE points2[4][4] = { + const NOISE_DATATYPE points2[4][4] = + { { IntNoise3D(BaseX - 1, BaseY - 1, BaseZ), IntNoise3D(BaseX, BaseY - 1, BaseZ), IntNoise3D(BaseX + 1, BaseY - 1, BaseZ), IntNoise3D(BaseX + 2, BaseY - 1, BaseZ), }, { IntNoise3D(BaseX - 1, BaseY, BaseZ), IntNoise3D(BaseX, BaseY, BaseZ), IntNoise3D(BaseX + 1, BaseY, BaseZ), IntNoise3D(BaseX + 2, BaseY, BaseZ), }, { IntNoise3D(BaseX - 1, BaseY + 1, BaseZ), IntNoise3D(BaseX, BaseY + 1, BaseZ), IntNoise3D(BaseX + 1, BaseY + 1, BaseZ), IntNoise3D(BaseX + 2, BaseY + 1, BaseZ), }, @@ -544,7 +546,8 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS const NOISE_DATATYPE x2interp3 = CubicInterpolate( points2[2][0], points2[2][1], points2[2][2], points2[2][3], FracX ); const NOISE_DATATYPE x2interp4 = CubicInterpolate( points2[3][0], points2[3][1], points2[3][2], points2[3][3], FracX ); - const NOISE_DATATYPE points3[4][4] = { + const NOISE_DATATYPE points3[4][4] = + { { IntNoise3D( BaseX-1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ + 1), }, { IntNoise3D( BaseX-1, BaseY, BaseZ+1 ), IntNoise3D( BaseX, BaseY, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY, BaseZ + 1), }, { IntNoise3D( BaseX-1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ + 1), }, @@ -556,7 +559,8 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS const NOISE_DATATYPE x3interp3 = CubicInterpolate( points3[2][0], points3[2][1], points3[2][2], points3[2][3], FracX ); const NOISE_DATATYPE x3interp4 = CubicInterpolate( points3[3][0], points3[3][1], points3[3][2], points3[3][3], FracX ); - const NOISE_DATATYPE points4[4][4] = { + const NOISE_DATATYPE points4[4][4] = + { { IntNoise3D( BaseX-1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2 ), }, { IntNoise3D( BaseX-1, BaseY, BaseZ+2 ), IntNoise3D( BaseX, BaseY, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY, BaseZ+2 ), }, { IntNoise3D( BaseX-1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2 ), }, diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index c0696d206..588dd3473 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -103,7 +103,8 @@ public: protected: /// Results of packet-parsing: - enum { + enum + { PARSE_OK = 1, PARSE_ERROR = -1, PARSE_UNKNOWN = -2, diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp index 8695f0fb7..def952029 100644 --- a/src/Scoreboard.cpp +++ b/src/Scoreboard.cpp @@ -45,7 +45,8 @@ AString cObjective::TypeToString(eType a_Type) cObjective::eType cObjective::StringToType(const AString & a_Name) { - static struct { + static struct + { eType m_Type; const char * m_String; } TypeMap [] = diff --git a/src/Server.cpp b/src/Server.cpp index 10a354a36..367d507bf 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -30,7 +30,8 @@ #include #include -extern "C" { +extern "C" +{ #include "zlib/zlib.h" } diff --git a/src/Statistics.cpp b/src/Statistics.cpp index 5c0524f9e..e0c0dd925 100644 --- a/src/Statistics.cpp +++ b/src/Statistics.cpp @@ -7,7 +7,8 @@ -cStatInfo cStatInfo::ms_Info[statCount] = { +cStatInfo cStatInfo::ms_Info[statCount] = +{ // The order must match the order of enum eStatistic // http://minecraft.gamepedia.com/Achievements diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 9074ac7c2..b0e5a4ffe 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -509,8 +509,9 @@ The fall-through switches in UTF-8 reading code save a temp variable, some decrements & conditionals. The switches are equivalent to the following loop: { - int tmpBytesToRead = extraBytesToRead+1; - do { + int tmpBytesToRead = extraBytesToRead + 1; + do + { ch += *source++; --tmpBytesToRead; if (tmpBytesToRead) ch <<= 6; @@ -784,7 +785,8 @@ AString Base64Decode(const AString & a_Base64String) AString Base64Encode(const AString & a_Input) { - static const char BASE64[64] = { + static const char BASE64[64] = + { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index 4d4c46a71..2d5d9c830 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -101,9 +101,10 @@ protected: } } ; - struct FuncTable { + struct FuncTable + { static void Delete(sChunkLoad) {}; - static void Combine(sChunkLoad& a_orig, const sChunkLoad a_new) + static void Combine(sChunkLoad & a_orig, const sChunkLoad a_new) { a_orig.m_Generate |= a_new.m_Generate; }; -- cgit v1.2.3 From e612d07eeae351cbdb413dbb8fb543284ea46628 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 15:25:28 +0200 Subject: CheckBasicStyle: Checks for braces not on separate lines. Only the opening braces at the end of a line are checked, others (such as inline getters and setters or initializers) are valid. --- src/CheckBasicStyle.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index 14e3caa26..e4597a426 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -7,10 +7,11 @@ Checks that all source files (*.cpp, *.h) use the basic style requirements of th - Trailing whitespace on non-empty lines - Two spaces between code and line-end comment ("//") - Spaces after comma, not before + - Opening braces not at the end of a code line + - (TODO) Spaces after if, for, while - (TODO) Spaces before *, /, & - (TODO) Hex numbers with even digit length - (TODO) Hex numbers in lowercase - - (TODO) Braces not on the end of line - (TODO) Line dividers (////...) exactly 80 slashes - (TODO) Not using "* "-style doxy comment continuation lines @@ -121,6 +122,9 @@ local g_ViolationPatterns = -- Check that all commas have spaces after them and not in front of them: {" ,", "Extra space before a \",\""}, {",[^%s\"%%]", "Needs a space after a \",\""}, -- Report all except >> "," << needed for splitting and >>,%s<< needed for formatting + + -- Check that opening braces are not at the end of a code line: + {"[^%s].-{\n?$", "Brace should be on a separate line"}, } @@ -145,7 +149,7 @@ local function ProcessFile(a_FileName) if ((lastChar ~= 13) and (lastChar ~= 10)) then local numLines = 1 string.gsub(all, "\n", function() numLines = numLines + 1 end) -- Count the number of line-ends - ReportViolation(a_FileName, numLines, "Missing empty line at file end") + ReportViolation(a_FileName, numLines, 1, 1, "Missing empty line at file end") return end -- cgit v1.2.3 From dd7df288448230fa6becee18e4259ce19976e367 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 20:11:33 -0700 Subject: Refactored cChatColor - Changed std::string fields to const char-pointers in order to wipe out potential issues with static initialization and global destructors - Deprecated cChatColor::Color() because the name does not match the value --- src/ChatColor.cpp | 48 ++++++++++++++++++++++++------------------------ src/ChatColor.h | 52 +++++++++++++++++++++++++++------------------------- 2 files changed, 51 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/ChatColor.cpp b/src/ChatColor.cpp index 72a0a6928..e1317c287 100644 --- a/src/ChatColor.cpp +++ b/src/ChatColor.cpp @@ -2,31 +2,31 @@ #include "ChatColor.h" -const std::string cChatColor::Color = "\xc2\xa7"; // or in other words: "§" in UTF-8 -const std::string cChatColor::Delimiter = "\xc2\xa7"; // or in other words: "§" in UTF-8 -const std::string cChatColor::Black = cChatColor::Color + "0"; -const std::string cChatColor::Navy = cChatColor::Color + "1"; -const std::string cChatColor::Green = cChatColor::Color + "2"; -const std::string cChatColor::Blue = cChatColor::Color + "3"; -const std::string cChatColor::Red = cChatColor::Color + "4"; -const std::string cChatColor::Purple = cChatColor::Color + "5"; -const std::string cChatColor::Gold = cChatColor::Color + "6"; -const std::string cChatColor::LightGray = cChatColor::Color + "7"; -const std::string cChatColor::Gray = cChatColor::Color + "8"; -const std::string cChatColor::DarkPurple = cChatColor::Color + "9"; -const std::string cChatColor::LightGreen = cChatColor::Color + "a"; -const std::string cChatColor::LightBlue = cChatColor::Color + "b"; -const std::string cChatColor::Rose = cChatColor::Color + "c"; -const std::string cChatColor::LightPurple = cChatColor::Color + "d"; -const std::string cChatColor::Yellow = cChatColor::Color + "e"; -const std::string cChatColor::White = cChatColor::Color + "f"; +const char * cChatColor::Color = "\xc2\xa7"; // or in other words: "§" in UTF-8 +const char * cChatColor::Delimiter = "\xc2\xa7"; // or in other words: "§" in UTF-8 +const char * cChatColor::Black = "\xc2\xa7""0"; +const char * cChatColor::Navy = "\xc2\xa7""1"; +const char * cChatColor::Green = "\xc2\xa7""2"; +const char * cChatColor::Blue = "\xc2\xa7""3"; +const char * cChatColor::Red = "\xc2\xa7""4"; +const char * cChatColor::Purple = "\xc2\xa7""5"; +const char * cChatColor::Gold = "\xc2\xa7""6"; +const char * cChatColor::LightGray = "\xc2\xa7""7"; +const char * cChatColor::Gray = "\xc2\xa7""8"; +const char * cChatColor::DarkPurple = "\xc2\xa7""9"; +const char * cChatColor::LightGreen = "\xc2\xa7""a"; +const char * cChatColor::LightBlue = "\xc2\xa7""b"; +const char * cChatColor::Rose = "\xc2\xa7""c"; +const char * cChatColor::LightPurple = "\xc2\xa7""d"; +const char * cChatColor::Yellow = "\xc2\xa7""e"; +const char * cChatColor::White = "\xc2\xa7""f"; -const std::string cChatColor::Random = cChatColor::Color + "k"; -const std::string cChatColor::Bold = cChatColor::Color + "l"; -const std::string cChatColor::Strikethrough = cChatColor::Color + "m"; -const std::string cChatColor::Underlined = cChatColor::Color + "n"; -const std::string cChatColor::Italic = cChatColor::Color + "o"; -const std::string cChatColor::Plain = cChatColor::Color + "r"; +const char * cChatColor::Random = "\xc2\xa7""k"; +const char * cChatColor::Bold = "\xc2\xa7""l"; +const char * cChatColor::Strikethrough = "\xc2\xa7""m"; +const char * cChatColor::Underlined = "\xc2\xa7""n"; +const char * cChatColor::Italic = "\xc2\xa7""o"; +const char * cChatColor::Plain = "\xc2\xa7""r"; diff --git a/src/ChatColor.h b/src/ChatColor.h index 2189fd395..5a81c7edd 100644 --- a/src/ChatColor.h +++ b/src/ChatColor.h @@ -9,33 +9,35 @@ class cChatColor { public: - static const std::string Color; - static const std::string Delimiter; - - static const std::string Black; - static const std::string Navy; - static const std::string Green; - static const std::string Blue; - static const std::string Red; - static const std::string Purple; - static const std::string Gold; - static const std::string LightGray; - static const std::string Gray; - static const std::string DarkPurple; - static const std::string LightGreen; - static const std::string LightBlue; - static const std::string Rose; - static const std::string LightPurple; - static const std::string Yellow; - static const std::string White; + static const char * Color; + + /** @deprecated use ChatColor::Delimiter instead */ + static const char * Delimiter; + + static const char * Black; + static const char * Navy; + static const char * Green; + static const char * Blue; + static const char * Red; + static const char * Purple; + static const char * Gold; + static const char * LightGray; + static const char * Gray; + static const char * DarkPurple; + static const char * LightGreen; + static const char * LightBlue; + static const char * Rose; + static const char * LightPurple; + static const char * Yellow; + static const char * White; // Styles ( source: http://wiki.vg/Chat ) - static const std::string Random; - static const std::string Bold; - static const std::string Strikethrough; - static const std::string Underlined; - static const std::string Italic; - static const std::string Plain; + static const char * Random; + static const char * Bold; + static const char * Strikethrough; + static const char * Underlined; + static const char * Italic; + static const char * Plain; }; -- cgit v1.2.3 From d5b163bd3d731ac88780e9042c39eed28982edc2 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 11:12:34 -0700 Subject: Removed references to deprecated cChatColor::Color --- src/Entities/Player.cpp | 2 +- src/GroupManager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 698f77bf6..808b74023 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1524,7 +1524,7 @@ AString cPlayer::GetColor(void) const { if ( m_Color != '-' ) { - return cChatColor::Color + m_Color; + return cChatColor::Delimiter + m_Color; } if ( m_Groups.size() < 1 ) diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index 135a1636a..a1cc396cf 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -153,7 +153,7 @@ bool cGroupManager::LoadGroups() AString Color = IniFile.GetValue(KeyName, "Color", "-"); if ((Color != "-") && (Color.length() >= 1)) { - Group->SetColor(cChatColor::Color + Color[0]); + Group->SetColor(cChatColor::Delimiter + Color[0]); } else { -- cgit v1.2.3 From 52add840cf7fb25ff31da21265fa41bab5682020 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 11:15:21 -0700 Subject: Fixed attempts to call c_str on ChatColors --- src/ClientHandle.cpp | 8 ++++---- src/Protocol/ProtocolRecognizer.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index cf78b19c5..de4245b40 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -210,11 +210,11 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage { if (ShouldAppendChatPrefixes) { - return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue.c_str(), a_AdditionalData.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str()); + return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue, a_AdditionalData.c_str(), cChatColor::White, cChatColor::Italic); } else { - return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue.c_str()); + return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue); } } } @@ -533,9 +533,9 @@ void cClientHandle::HandlePing(void) Printf(Reply, "%s%s%i%s%i", Server.GetDescription().c_str(), - cChatColor::Delimiter.c_str(), + cChatColor::Delimiter, Server.GetNumPlayers(), - cChatColor::Delimiter.c_str(), + cChatColor::Delimiter, Server.GetMaxPlayers() ); Kick(Reply); diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index e62f9d216..205407a5b 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -1021,9 +1021,9 @@ void cProtocolRecognizer::SendLengthlessServerPing(void) // http://wiki.vg/wiki/index.php?title=Protocol&oldid=3099#Server_List_Ping_.280xFE.29 Printf(Reply, "%s%s%i%s%i", Server->GetDescription().c_str(), - cChatColor::Delimiter.c_str(), + cChatColor::Delimiter, Server->GetNumPlayers(), - cChatColor::Delimiter.c_str(), + cChatColor::Delimiter, Server->GetMaxPlayers() ); break; -- cgit v1.2.3 From ada88a58053e74c910982f7c3ebdfb791161c110 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 14:35:35 -0700 Subject: Monsters: Made IsUndead overridable by the respective mob classes --- src/Mobs/Monster.cpp | 10 ---------- src/Mobs/Monster.h | 2 +- src/Mobs/Skeleton.h | 2 ++ src/Mobs/Wither.h | 2 ++ src/Mobs/Zombie.h | 6 ++++-- src/Mobs/ZombiePigman.h | 2 ++ 6 files changed, 11 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index db45db5b9..753a44914 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -680,16 +680,6 @@ void cMonster::GetMonsterConfig(const AString & a_Name) bool cMonster::IsUndead(void) { - switch (GetMobType()) - { - case mtZombie: - case mtZombiePigman: - case mtSkeleton: - case mtWither: - { - return true; - } - } return false; } diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index bbc3ebd35..ffd078505 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -107,7 +107,7 @@ public: void GetMonsterConfig(const AString & a_Name); /** Returns whether this mob is undead (skeleton, zombie, etc.) */ - bool IsUndead(void); + virtual bool IsUndead(void); virtual void EventLosePlayer(void); virtual void CheckEventLostPlayer(void); diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h index efb670c83..9a121ef48 100644 --- a/src/Mobs/Skeleton.h +++ b/src/Mobs/Skeleton.h @@ -22,6 +22,8 @@ public: virtual void Attack(float a_Dt) override; virtual void SpawnOn(cClientHandle & a_ClientHandle) override; + virtual bool IsUndead(void) override { return true; } + bool IsWither(void) const { return m_bIsWither; }; private: diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index 7d76f70f5..cc8d1459b 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -30,6 +30,8 @@ public: virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void KilledBy(TakeDamageInfo & a_TDI) override; + + virtual bool IsUndead(void) override { return true; } private: diff --git a/src/Mobs/Zombie.h b/src/Mobs/Zombie.h index c56409570..082573d8b 100644 --- a/src/Mobs/Zombie.h +++ b/src/Mobs/Zombie.h @@ -19,8 +19,10 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void MoveToPosition(const Vector3d & a_Position) override; - bool IsVillagerZombie(void) const {return m_IsVillagerZombie; } - bool IsConverting (void) const {return m_IsConverting; } + virtual bool IsUndead(void) override { return true; } + + bool IsVillagerZombie(void) const { return m_IsVillagerZombie; } + bool IsConverting (void) const { return m_IsConverting; } private: diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h index a2ebc87cb..a4bad7efb 100644 --- a/src/Mobs/ZombiePigman.h +++ b/src/Mobs/ZombiePigman.h @@ -18,6 +18,8 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void KilledBy(TakeDamageInfo & a_TDI) override; + + virtual bool IsUndead(void) override { return true; } } ; -- cgit v1.2.3 From ed01e12ed732fc9e3516ed263ebb73978b6f82f6 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 14:50:01 -0700 Subject: main.cpp: Fixed warnings with g_TERMINATE_EVENT_RAISED and g_SERVER_TERMINATED --- src/Root.cpp | 2 -- src/Root.h | 2 ++ src/main.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Root.cpp b/src/Root.cpp index 6347adcf0..d727e34a3 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -30,8 +30,6 @@ #include #endif -extern bool g_TERMINATE_EVENT_RAISED; - diff --git a/src/Root.h b/src/Root.h index acd3e9754..b31059e71 100644 --- a/src/Root.h +++ b/src/Root.h @@ -40,6 +40,8 @@ namespace Json class cRoot { public: + static bool g_TERMINATE_EVENT_RAISED; + static cRoot * Get() { return s_Root; } // tolua_end diff --git a/src/main.cpp b/src/main.cpp index 0ff9361be..d8b14cacc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,8 +12,8 @@ #endif // _MSC_VER // Here, we have some ALL CAPS variables, to give the impression that this is deeeep, gritty programming :P -bool g_TERMINATE_EVENT_RAISED = false; // If something has told the server to stop; checked periodically in cRoot -bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so our CTRL handler can then tell Windows to close the console +bool cRoot::g_TERMINATE_EVENT_RAISED = false; // If something has told the server to stop; checked periodically in cRoot +static bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so our CTRL handler can then tell the OS to close the console @@ -52,7 +52,7 @@ bool g_ShouldLogCommOut; void NonCtrlHandler(int a_Signal) { LOGD("Terminate event raised from std::signal"); - g_TERMINATE_EVENT_RAISED = true; + cRoot::g_TERMINATE_EVENT_RAISED = true; switch (a_Signal) { @@ -155,7 +155,7 @@ LONG WINAPI LastChanceExceptionFilter(__in struct _EXCEPTION_POINTERS * a_Except // Handle CTRL events in windows, including console window close BOOL CtrlHandler(DWORD fdwCtrlType) { - g_TERMINATE_EVENT_RAISED = true; + cRoot::g_TERMINATE_EVENT_RAISED = true; LOGD("Terminate event raised from the Windows CtrlHandler"); if (fdwCtrlType == CTRL_CLOSE_EVENT) // Console window closed via 'x' button, Windows will try to close immediately, therefore... -- cgit v1.2.3 From 1831c2e652a3cbcfb13a72cd1334d0959cb607a3 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 14:50:31 -0700 Subject: Socket: removed unused Socket destructor --- src/OSSupport/Socket.cpp | 9 --------- src/OSSupport/Socket.h | 1 - 2 files changed, 10 deletions(-) (limited to 'src') diff --git a/src/OSSupport/Socket.cpp b/src/OSSupport/Socket.cpp index 47d9f331d..c07d31c8b 100644 --- a/src/OSSupport/Socket.cpp +++ b/src/OSSupport/Socket.cpp @@ -25,15 +25,6 @@ cSocket::cSocket(xSocket a_Socket) -cSocket::~cSocket() -{ - // Do NOT close the socket; this class is an API wrapper, not a RAII! -} - - - - - cSocket::operator cSocket::xSocket() const { return m_Socket; diff --git a/src/OSSupport/Socket.h b/src/OSSupport/Socket.h index 35ecadfa0..e4ec895cb 100644 --- a/src/OSSupport/Socket.h +++ b/src/OSSupport/Socket.h @@ -41,7 +41,6 @@ public: cSocket(void) : m_Socket(INVALID_SOCKET) {} cSocket(xSocket a_Socket); - ~cSocket(); bool IsValid(void) const { return IsValidSocket(m_Socket); } void CloseSocket(void); -- cgit v1.2.3 From 638ea10027f0e01a37d2592185e735e4c6f28338 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 15:28:55 -0700 Subject: ChatColor.h: The @deprecated tag slipped. Oops. --- src/ChatColor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ChatColor.h b/src/ChatColor.h index 5a81c7edd..74eb7d5dc 100644 --- a/src/ChatColor.h +++ b/src/ChatColor.h @@ -9,10 +9,10 @@ class cChatColor { public: - static const char * Color; + static const char * Delimiter; /** @deprecated use ChatColor::Delimiter instead */ - static const char * Delimiter; + static const char * Color; static const char * Black; static const char * Navy; -- cgit v1.2.3 From 14826b660649c87c002b4ba23a255007f141dab4 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 15:44:19 -0700 Subject: main.cpp: field style fixes --- src/Root.cpp | 8 ++++---- src/Root.h | 2 +- src/main.cpp | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/Root.cpp b/src/Root.cpp index d727e34a3..ba25b97eb 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -77,7 +77,7 @@ void cRoot::InputThread(void * a_Params) cLogCommandOutputCallback Output; - while (!self.m_bStop && !self.m_bRestart && !g_TERMINATE_EVENT_RAISED && std::cin.good()) + while (!self.m_bStop && !self.m_bRestart && !m_TerminateEventRaised && std::cin.good()) { AString Command; std::getline(std::cin, Command); @@ -87,7 +87,7 @@ void cRoot::InputThread(void * a_Params) } } - if (g_TERMINATE_EVENT_RAISED || !std::cin.good()) + if (m_TerminateEventRaised || !std::cin.good()) { // We have come here because the std::cin has received an EOF / a terminate signal has been sent, and the server is still running; stop the server: self.m_bStop = true; @@ -203,12 +203,12 @@ void cRoot::Start(void) EnableMenuItem(hmenu, SC_CLOSE, MF_ENABLED); // Re-enable close button #endif - while (!m_bStop && !m_bRestart && !g_TERMINATE_EVENT_RAISED) // These are modified by external threads + while (!m_bStop && !m_bRestart && !m_TerminateEventRaised) // These are modified by external threads { cSleep::MilliSleep(1000); } - if (g_TERMINATE_EVENT_RAISED) + if (m_TerminateEventRaised) { m_bStop = true; } diff --git a/src/Root.h b/src/Root.h index b31059e71..08aafe3c9 100644 --- a/src/Root.h +++ b/src/Root.h @@ -40,7 +40,7 @@ namespace Json class cRoot { public: - static bool g_TERMINATE_EVENT_RAISED; + static bool m_TerminateEventRaised; static cRoot * Get() { return s_Root; } // tolua_end diff --git a/src/main.cpp b/src/main.cpp index d8b14cacc..3e91149af 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,9 +11,9 @@ #include #endif // _MSC_VER -// Here, we have some ALL CAPS variables, to give the impression that this is deeeep, gritty programming :P -bool cRoot::g_TERMINATE_EVENT_RAISED = false; // If something has told the server to stop; checked periodically in cRoot -static bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so our CTRL handler can then tell the OS to close the console + +bool cRoot::m_TerminateEventRaised = false; // If something has told the server to stop; checked periodically in cRoot +static bool g_ServerTerminated = false; // Set to true when the server terminates, so our CTRL handler can then tell the OS to close the console @@ -52,7 +52,7 @@ bool g_ShouldLogCommOut; void NonCtrlHandler(int a_Signal) { LOGD("Terminate event raised from std::signal"); - cRoot::g_TERMINATE_EVENT_RAISED = true; + cRoot::m_TerminateEventRaised = true; switch (a_Signal) { @@ -155,12 +155,12 @@ LONG WINAPI LastChanceExceptionFilter(__in struct _EXCEPTION_POINTERS * a_Except // Handle CTRL events in windows, including console window close BOOL CtrlHandler(DWORD fdwCtrlType) { - cRoot::g_TERMINATE_EVENT_RAISED = true; + cRoot::m_TerminateEventRaised = true; LOGD("Terminate event raised from the Windows CtrlHandler"); if (fdwCtrlType == CTRL_CLOSE_EVENT) // Console window closed via 'x' button, Windows will try to close immediately, therefore... { - while (!g_SERVER_TERMINATED) { cSleep::MilliSleep(100); } // Delay as much as possible to try to get the server to shut down cleanly + while (!g_ServerTerminated) { cSleep::MilliSleep(100); } // Delay as much as possible to try to get the server to shut down cleanly } return TRUE; @@ -296,7 +296,7 @@ int main( int argc, char **argv ) DeinitLeakFinder(); #endif - g_SERVER_TERMINATED = true; + g_ServerTerminated = true; return EXIT_SUCCESS; } -- cgit v1.2.3 From 897d68dc35620f0e6c33fe4a6083a76ab43a9a57 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 20 Jul 2014 01:22:58 +0200 Subject: Add armor items directly to the armor slots. --- src/Inventory.cpp | 13 +++++++++++++ src/UI/SlotArea.cpp | 4 ++-- src/UI/SlotArea.h | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 18154bafd..fff6e4a4e 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -103,6 +103,19 @@ int cInventory::AddItem(const cItem & a_Item, bool a_AllowNewStacks, bool a_tryT cItem ToAdd(a_Item); int res = 0; + // When the item is a armor, try to set it directly to the armor slot. + if (ItemCategory::IsArmor(a_Item.m_ItemType)) + { + for (size_t i = 0; i < (size_t)m_ArmorSlots.GetNumSlots(); i++) + { + if (m_ArmorSlots.GetSlot(i).IsEmpty() && cSlotAreaArmor::CanPlaceArmorInSlot(i, a_Item)) + { + m_ArmorSlots.SetSlot(i, a_Item); + return a_Item.m_ItemCount; + } + } + } + res += m_HotbarSlots.AddItem(ToAdd, a_AllowNewStacks, a_tryToFillEquippedFirst ? m_EquippedSlotNum : -1); ToAdd.m_ItemCount = a_Item.m_ItemCount - res; if (ToAdd.m_ItemCount == 0) diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 6f4f65ca3..e9b1ef8e0 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1926,7 +1926,7 @@ void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C return; } - if (DraggingItem.IsEmpty() || CanPlaceInSlot(a_SlotNum, DraggingItem)) + if (DraggingItem.IsEmpty() || CanPlaceArmorInSlot(a_SlotNum, DraggingItem)) { // Swap contents cItem tmp(DraggingItem); @@ -1945,7 +1945,7 @@ void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C -bool cSlotAreaArmor::CanPlaceInSlot(int a_SlotNum, const cItem & a_Item) +bool cSlotAreaArmor::CanPlaceArmorInSlot(int a_SlotNum, const cItem & a_Item) { switch (a_SlotNum) { diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index 7f37159b7..fa842bb81 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -161,7 +161,7 @@ public: /** Called when a player clicks in the window. Parameters taken from the click packet. */ virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override; - bool CanPlaceInSlot(int a_SlotNum, const cItem & a_Item); + static bool CanPlaceArmorInSlot(int a_SlotNum, const cItem & a_Item); } ; -- cgit v1.2.3 From 9e155c6add9a6108ee86d775910e9a396466ee7b Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 01:38:36 -0700 Subject: Added destroy-timer system to splash potion entities --- src/Entities/SplashPotionEntity.cpp | 7 ++++--- src/Entities/SplashPotionEntity.h | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 13cbcb0fc..c1623845f 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -78,7 +78,8 @@ cSplashPotionEntity::cSplashPotionEntity( super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), m_EntityEffectType(a_EntityEffectType), m_EntityEffect(a_EntityEffect), - m_PotionColor(a_PotionColor) + m_PotionColor(a_PotionColor), + m_DestroyTimer(-1) { SetSpeed(a_Speed); } @@ -90,7 +91,7 @@ cSplashPotionEntity::cSplashPotionEntity( void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { Splash(a_HitPos); - Destroy(); + m_DestroyTimer = 2; } @@ -101,7 +102,7 @@ void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_ { a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1); Splash(a_HitPos); - Destroy(true); + m_DestroyTimer = 5; } diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index a33b06990..290dd81d4 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -52,10 +52,30 @@ protected: // cProjectileEntity overrides: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; + virtual void Tick (float a_Dt, cChunk & a_Chunk) override + { + if (m_DestroyTimer > 0) + { + m_DestroyTimer--; + if (m_DestroyTimer == 0) + { + Destroy(); + return; + } + } + else + { + super::Tick(a_Dt, a_Chunk); + } + } /** Splashes the potion, fires its particle effects and sounds @param a_HitPos The position where the potion will splash */ void Splash(const Vector3d & a_HitPos); virtual void SpawnOn(cClientHandle & a_Client) override; + +private: + /** Time in ticks to wait for the hit animation to begin before destroying */ + int m_DestroyTimer; } ; // tolua_export -- cgit v1.2.3 From 726312602d293117fc4999897ef56869f2fef534 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 01:43:07 -0700 Subject: Added m_TicksAlive to entities, allows projectiles to hit their creators --- src/Entities/Entity.cpp | 3 +++ src/Entities/Entity.h | 6 ++++++ src/Entities/ProjectileEntity.cpp | 8 +++++--- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index f9331ede8..5a3bbcdc4 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -49,6 +49,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_IsSubmerged(false) , m_AirLevel(0) , m_AirTickTimer(0) + , m_TicksAlive(0) , m_HeadYaw(0.0) , m_Rot(0.0, 0.0, 0.0) , m_Pos(a_X, a_Y, a_Z) @@ -559,6 +560,8 @@ void cEntity::SetHealth(int a_Health) void cEntity::Tick(float a_Dt, cChunk & a_Chunk) { + m_TicksAlive++; + if (m_InvulnerableTicks > 0) { m_InvulnerableTicks--; diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 88f8528e9..83fe76e7e 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -416,6 +416,9 @@ public: /** Gets remaining air of a monster */ int GetAirLevel(void) const { return m_AirLevel; } + /** Gets number of ticks this entity has existed for */ + long int GetTicksAlive(void) const { return m_TicksAlive; } + /** Gets the invulnerable ticks from the entity */ int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; } @@ -521,6 +524,9 @@ protected: int m_AirLevel; int m_AirTickTimer; + /** The number of ticks this entity has been alive for */ + long int m_TicksAlive; + private: /** Measured in degrees, [-180, +180) */ double m_HeadYaw; diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index a55c9b895..b5e81bc0c 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -146,9 +146,11 @@ public: (a_Entity->GetUniqueID() == m_Projectile->GetCreatorUniqueID()) // Do not check whoever shot the projectile ) { - // TODO: Don't check creator only for the first 5 ticks - // so that arrows stuck in ground and dug up can hurt the player - return false; + // Don't check creator only for the first 5 ticks so that projectiles can collide with the creator + if (m_Projectile->GetTicksAlive() <= 5) + { + return false; + } } cBoundingBox EntBox(a_Entity->GetPosition(), a_Entity->GetWidth() / 2, a_Entity->GetHeight()); -- cgit v1.2.3 From 6ab9afd0fd808fad99cd8387c72ce461c37aef80 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 20 Jul 2014 10:46:45 +0100 Subject: Bug and crash fixes * Fixes end portals' solidity * Fixed crashes to do with multithreading and removing an entity from the wrong world * Fixed crashes due to bad merge * Fixed crashes due to an object being deleted twice * Simplified cWorld::Start() and added comments to configuration files --- src/BlockInfo.cpp | 1 + src/Chunk.cpp | 5 ++--- src/ClientHandle.cpp | 2 ++ src/Entities/Entity.cpp | 48 ++++++++++++++++++++++++++++++------------------ src/Entities/Entity.h | 15 +++++++++------ src/Entities/Player.cpp | 35 +++++++++++++++++------------------ src/Entities/Player.h | 15 +++++++++------ src/MobSpawner.cpp | 3 ++- src/Root.cpp | 9 +++++++-- src/Root.h | 13 +++++++++++-- src/World.cpp | 24 ++++++++++++++++-------- src/World.h | 2 +- 12 files changed, 107 insertions(+), 65 deletions(-) (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 97e89359f..0882d2740 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -496,6 +496,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_CROPS ].m_IsSolid = false; a_Info[E_BLOCK_DANDELION ].m_IsSolid = false; a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false; + a_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false; a_Info[E_BLOCK_FIRE ].m_IsSolid = false; a_Info[E_BLOCK_FLOWER ].m_IsSolid = false; a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 2f3bdff81..4588de9f3 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -591,7 +591,6 @@ void cChunk::Tick(float a_Dt) if (!((*itr)->IsMob())) { (*itr)->Tick(a_Dt, *this); - continue; } } // for itr - m_Entitites[] @@ -605,10 +604,10 @@ void cChunk::Tick(float a_Dt) itr = m_Entities.erase(itr); delete ToDelete; } - else if ((*itr)->IsTravellingThroughPortal()) // Remove all entities that are travelling to another world + else if ((*itr)->IsWorldTravellingFrom(m_World)) // Remove all entities that are travelling to another world { MarkDirty(); - (*itr)->SetIsTravellingThroughPortal(false); + (*itr)->SetWorldTravellingFrom(NULL); itr = m_Entities.erase(itr); } else if ( // If any entity moved out of the chunk, move it to the neighbor: diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index f90da94dd..8caaae917 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -120,6 +120,8 @@ cClientHandle::~cClientHandle() } if (World != NULL) { + m_Player->SetWorldTravellingFrom(NULL); // Make sure that the player entity is actually removed + World->RemovePlayer(m_Player); // Must be called before cPlayer::Destroy() as otherwise cChunk tries to delete the player, and then we do it again m_Player->Destroy(); } delete m_Player; diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index bd1839580..4768d38ae 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -37,7 +37,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_Gravity(-9.81f) , m_LastPos(a_X, a_Y, a_Z) , m_IsInitialized(false) - , m_IsTravellingThroughPortal(false) + , m_WorldTravellingFrom(NULL) , m_EntityType(a_EntityType) , m_World(NULL) , m_IsFireproof(false) @@ -1028,10 +1028,11 @@ void cEntity::DetectCacti(void) void cEntity::DetectPortal() { - if (!GetWorld()->GetNetherWorldName().empty() && !GetWorld()->GetEndWorldName().empty()) + if (GetWorld()->GetDimension() == dimOverworld) { - return; + if (GetWorld()->GetNetherWorldName().empty() && GetWorld()->GetEndWorldName().empty()) { return; } } + else if (GetWorld()->GetLinkedOverworldName().empty()) { return; } int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; if ((Y > 0) && (Y < cChunkDef::Height)) @@ -1040,7 +1041,7 @@ void cEntity::DetectPortal() { case E_BLOCK_NETHER_PORTAL: { - if (GetWorld()->GetNetherWorldName().empty() || m_PortalCooldownData.second) + if (m_PortalCooldownData.second) { return; } @@ -1054,8 +1055,13 @@ void cEntity::DetectPortal() switch (GetWorld()->GetDimension()) { - case dimNether: + case dimNether: { + if (GetWorld()->GetLinkedOverworldName().empty()) + { + return; + } + m_PortalCooldownData.second = true; // Stop portals from working on respawn if (IsPlayer()) @@ -1068,6 +1074,11 @@ void cEntity::DetectPortal() } case dimOverworld: { + if (GetWorld()->GetNetherWorldName().empty()) + { + return; + } + m_PortalCooldownData.second = true; // Stop portals from working on respawn if (IsPlayer()) @@ -1079,28 +1090,25 @@ void cEntity::DetectPortal() return; } - default: break; + default: return; } - return; } case E_BLOCK_END_PORTAL: { - if (GetWorld()->GetNetherWorldName().empty() || m_PortalCooldownData.second) - { - return; - } - - if (m_PortalCooldownData.first != 80) + if (m_PortalCooldownData.second) { - m_PortalCooldownData.first++; return; } - m_PortalCooldownData.first = 0; switch (GetWorld()->GetDimension()) { case dimEnd: { + if (GetWorld()->GetLinkedOverworldName().empty()) + { + return; + } + m_PortalCooldownData.second = true; // Stop portals from working on respawn if (IsPlayer()) @@ -1115,6 +1123,11 @@ void cEntity::DetectPortal() } case dimOverworld: { + if (GetWorld()->GetEndWorldName().empty()) + { + return; + } + m_PortalCooldownData.second = true; // Stop portals from working on respawn if (IsPlayer()) @@ -1126,9 +1139,8 @@ void cEntity::DetectPortal() return; } - default: break; + default: return; } - return; } default: break; } @@ -1169,7 +1181,7 @@ bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ } // Remove all links to the old world - SetIsTravellingThroughPortal(true); // cChunk handles entity removal + SetWorldTravellingFrom(GetWorld()); // cChunk handles entity removal GetWorld()->BroadcastDestroyEntity(*this); // Queue add to new world diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 8b6fc05f7..eea48a12f 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -387,11 +387,11 @@ public: // tolua_end - /** Returns if the entity is travelling through a portal. Set to true by MoveToWorld and to false when the entity is removed by the old chunk */ - bool IsTravellingThroughPortal(void) const { return m_IsTravellingThroughPortal; } + /** Returns if the entity is travelling away from a specified world */ + bool IsWorldTravellingFrom(cWorld * a_World) const { return (m_WorldTravellingFrom == a_World); } - /** Sets if the entity has begun travelling through a portal or not */ - void SetIsTravellingThroughPortal(bool a_Flag) { m_IsTravellingThroughPortal = a_Flag; } + /** Sets the world the entity will be leaving */ + void SetWorldTravellingFrom(cWorld * a_World) { (m_WorldTravellingFrom = a_World); } /// Updates clients of changes in the entity. virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = NULL); @@ -491,8 +491,11 @@ protected: /** True when entity is initialised (Initialize()) and false when destroyed pending deletion (Destroy()) */ bool m_IsInitialized; - /** True when entity is being moved across worlds, false anytime else */ - bool m_IsTravellingThroughPortal; + /** World entity is travelling from + Set by MoveToWorld and back to NULL when the entity is removed by the old chunk + Can't be a simple boolean as context switches between worlds may leave the new chunk processing (and therefore immediately removing) the entity before the old chunk could remove it + */ + cWorld * m_WorldTravellingFrom; eEntityType m_EntityType; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 2a91600e7..0b1b4ce5f 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -88,7 +88,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) : m_PlayerName = a_PlayerName; - cWorld * World; + cWorld * World = NULL; if (!LoadFromDisk(World)) { m_Inventory.Clear(); @@ -136,8 +136,6 @@ cPlayer::~cPlayer(void) SaveToDisk(); - m_World->RemovePlayer(this); - m_ClientHandle = NULL; delete m_InventoryWindow; @@ -979,7 +977,7 @@ void cPlayer::Respawn(void) m_LifetimeTotalXp = 0; // ToDo: send score to client? How? - m_ClientHandle->SendRespawn(GetWorld()->GetDimension()); + m_ClientHandle->SendRespawn(GetWorld()->GetDimension(), true); // Extinguish the fire: StopBurning(); @@ -1643,11 +1641,12 @@ bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ } // Remove player from the old world - SetIsTravellingThroughPortal(true); // cChunk handles entity removal - m_World->RemovePlayer(this); + SetWorldTravellingFrom(GetWorld()); // cChunk handles entity removal + GetWorld()->RemovePlayer(this); // Queue adding player to the new world, including all the necessary adjustments to the object World->AddPlayer(this); + SetWorld(World); return true; } @@ -1697,12 +1696,6 @@ void cPlayer::LoadPermissionsFromDisk() bool cPlayer::LoadFromDisk(cWorldPtr & a_World) { - a_World = cRoot::Get()->GetWorld(GetLoadedWorldName()); - if (a_World == NULL) - { - a_World = cRoot::Get()->GetDefaultWorld(); - } - LoadPermissionsFromDisk(); // Load from the UUID file: @@ -1740,6 +1733,11 @@ bool cPlayer::LoadFromDisk(cWorldPtr & a_World) LOG("Player data file not found for %s (%s, offline %s), will be reset to defaults.", GetName().c_str(), m_UUID.c_str(), OfflineUUID.c_str() ); + + if (a_World == NULL) + { + a_World = cRoot::Get()->GetDefaultWorld(); + } return false; } @@ -1747,7 +1745,7 @@ bool cPlayer::LoadFromDisk(cWorldPtr & a_World) -bool cPlayer::LoadFromFile(const AString & a_FileName, cWorld * a_World) +bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World) { // Load the data from the file: cFile f; @@ -1800,9 +1798,6 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorld * a_World) m_LifetimeTotalXp = (short) root.get("xpTotal", 0).asInt(); m_CurrentXp = (short) root.get("xpCurrent", 0).asInt(); m_IsFlying = root.get("isflying", 0).asBool(); - m_LastBedPos.x = root.get("SpawnX", a_World->GetSpawnX()).asInt(); - m_LastBedPos.y = root.get("SpawnY", a_World->GetSpawnY()).asInt(); - m_LastBedPos.z = root.get("SpawnZ", a_World->GetSpawnZ()).asInt(); m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt(); @@ -1815,6 +1810,11 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorld * a_World) cEnderChestEntity::LoadFromJson(root["enderchestinventory"], m_EnderChestContents); m_LoadedWorldName = root.get("world", "world").asString(); + a_World = cRoot::Get()->GetWorld(GetLoadedWorldName(), true); + + m_LastBedPos.x = root.get("SpawnX", a_World->GetSpawnX()).asInt(); + m_LastBedPos.y = root.get("SpawnY", a_World->GetSpawnY()).asInt(); + m_LastBedPos.z = root.get("SpawnZ", a_World->GetSpawnZ()).asInt(); // Load the player stats. // We use the default world name (like bukkit) because stats are shared between dimensions/worlds. @@ -1822,7 +1822,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorld * a_World) StatSerializer.Load(); LOGD("Player %s was read from file \"%s\", spawning at {%.2f, %.2f, %.2f} in world \"%s\"", - GetName().c_str(), a_FileName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str() + GetName().c_str(), a_FileName.c_str(), GetPosX(), GetPosY(), GetPosZ(), a_World->GetName().c_str() ); return true; @@ -1834,7 +1834,6 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorld * a_World) bool cPlayer::SaveToDisk() { - cFile::CreateFolder(FILE_IO_PREFIX + AString("players")); cFile::CreateFolder(FILE_IO_PREFIX + AString("players/") + m_UUID.substr(0, 2)); // create the JSON data diff --git a/src/Entities/Player.h b/src/Entities/Player.h index ad434f036..226ec5e68 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -340,14 +340,17 @@ public: typedef cWorld * cWorldPtr; - /** Loads the player data from the disk file. -Takes a (NULL) cWorld pointer which it will assign a value to based on either the loaded world or default world - Returns true on success, false on failure. */ + /** Loads the player data from the disk file + Takes a (NULL) cWorld pointer which it will assign a value to based on either the loaded world or default world by calling LoadFromFile() + Returns true on success, false on failure + */ bool LoadFromDisk(cWorldPtr & a_World); - /** Loads the player data from the specified file. - Returns true on success, false on failure. */ - bool LoadFromFile(const AString & a_FileName, cWorld * a_World); + /** Loads the player data from the specified file + Takes a (NULL) cWorld pointer which it will assign a value to based on either the loaded world or default world + Returns true on success, false on failure + */ + bool LoadFromFile(const AString & a_FileName, cWorldPtr & a_World); void LoadPermissionsFromDisk(void); // tolua_export diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index da3e7c406..d09bbc943 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -241,7 +241,8 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R (m_Random.NextInt(2, a_Biome) == 0) ); } - + + case cMonster::mtMagmaCube: case cMonster::mtSlime: { return ( diff --git a/src/Root.cpp b/src/Root.cpp index 822be92ff..e1eebb711 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -322,7 +322,7 @@ cWorld * cRoot::CreateAndInitializeWorld(const AString & a_WorldName, eDimension } cWorld * NewWorld = new cWorld(a_WorldName.c_str(), a_Dimension, a_OverworldName); m_WorldsByName[a_WorldName] = NewWorld; - NewWorld->Start(!a_OverworldName.empty()); + NewWorld->Start(); NewWorld->InitializeSpawn(); m_PluginManager->CallHookWorldStarted(*NewWorld); return NewWorld; @@ -381,13 +381,18 @@ cWorld * cRoot::GetDefaultWorld() -cWorld * cRoot::GetWorld(const AString & a_WorldName) +cWorld * cRoot::GetWorld(const AString & a_WorldName, bool a_SearchForFolder) { WorldMap::iterator itr = m_WorldsByName.find(a_WorldName); if (itr != m_WorldsByName.end()) { return itr->second; } + + if (a_SearchForFolder && cFile::IsFolder(FILE_IO_PREFIX + a_WorldName)) + { + return CreateAndInitializeWorld(a_WorldName); + } return NULL; } diff --git a/src/Root.h b/src/Root.h index c3aca37f9..4e3fcf080 100644 --- a/src/Root.h +++ b/src/Root.h @@ -51,8 +51,17 @@ public: // tolua_begin cServer * GetServer(void) { return m_Server; } cWorld * GetDefaultWorld(void); - cWorld * GetWorld(const AString & a_WorldName); - cWorld * CreateAndInitializeWorld(const AString & a_WorldName, eDimension a_Dimension = dimOverworld, const AString & a_OverworldName = ""); + + /** Returns a pointer to the world specified + If no world of that name was currently loaded and a_SearchForFolder was true, it will consult cFile::IsFolder() to see if a world folder of that name exists and if so, initialise a world based on that name + */ + cWorld * GetWorld(const AString & a_WorldName, bool a_SearchForFolder = false); + + /** Returns a pointer to a world of specified name - will search loaded worlds first, then create anew if not found + The dimension parameter is used to create a world with a specific dimension + a_OverworldName should be set for non-overworld dimensions if one wishes that world to link back to an overworld via portals + */ + cWorld * CreateAndInitializeWorld(const AString & a_WorldName, eDimension a_Dimension = dimOverworld, const AString & a_OverworldName = ""); // tolua_end /// Calls the callback for each world; returns true if the callback didn't abort (return true) diff --git a/src/World.cpp b/src/World.cpp index 924d5adbb..d27ad1eb4 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -512,7 +512,7 @@ void cWorld::InitializeSpawn(void) -void cWorld::Start(bool a_WasDimensionSet) +void cWorld::Start() { m_SpawnX = 0; m_SpawnY = cChunkDef::Height; @@ -523,11 +523,15 @@ void cWorld::Start(bool a_WasDimensionSet) if (!IniFile.ReadFile(m_IniFileName)) { LOGWARNING("Cannot read world settings from \"%s\", defaults will be used.", m_IniFileName.c_str()); + + // TODO: More descriptions for each key + IniFile.AddHeaderComment(" This is the per-world configuration file, managing settings such as generators, simulators, and spawn points"); + IniFile.AddKeyComment("LinkedWorlds", "This section governs portal world linkage; leave a value blank to disabled that associated method of teleportation"); } - AString Dimension = IniFile.GetValueSet("General", "Dimension", a_WasDimensionSet ? DimensionToString(GetDimension()) : "Overworld"); - m_Dimension = StringToDimension(Dimension); - m_OverworldName = IniFile.GetValue("LinkedWorlds", "OverworldName", a_WasDimensionSet ? m_OverworldName : ""); + // The presence of a configuration value overrides everything + // If no configuration value is found, GetDimension() is written to file and the variable is written to again to ensure that cosmic rays haven't sneakily changed its value + m_Dimension = StringToDimension(IniFile.GetValueSet("General", "Dimension", DimensionToString(GetDimension()))); // Try to find the "SpawnPosition" key and coord values in the world configuration, set the flag if found int KeyNum = IniFile.FindKey("SpawnPosition"); @@ -535,8 +539,8 @@ void cWorld::Start(bool a_WasDimensionSet) ( (KeyNum >= 0) && ( - (IniFile.FindValue(KeyNum, "X") >= 0) || - (IniFile.FindValue(KeyNum, "Y") >= 0) || + (IniFile.FindValue(KeyNum, "X") >= 0) && + (IniFile.FindValue(KeyNum, "Y") >= 0) && (IniFile.FindValue(KeyNum, "Z") >= 0) ) ); @@ -575,11 +579,15 @@ void cWorld::Start(bool a_WasDimensionSet) int Weather = IniFile.GetValueSetI("General", "Weather", (int)m_Weather); m_TimeOfDay = IniFile.GetValueSetI("General", "TimeInTicks", m_TimeOfDay); - if ((GetDimension() != dimNether) && (GetDimension() != dimEnd)) + if (GetDimension() == dimOverworld) { m_NetherWorldName = IniFile.GetValueSet("LinkedWorlds", "NetherWorldName", DEFAULT_NETHER_NAME); m_EndWorldName = IniFile.GetValueSet("LinkedWorlds", "EndWorldName", DEFAULT_END_NAME); } + else + { + m_OverworldName = IniFile.GetValueSet("LinkedWorlds", "OverworldName", GetLinkedOverworldName()); + } // Adjust the enum-backed variables into their respective bounds: m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmAdventure); @@ -2420,7 +2428,7 @@ void cWorld::AddPlayer(cPlayer * a_Player) void cWorld::RemovePlayer(cPlayer * a_Player) { - if (!a_Player->IsTravellingThroughPortal()) + if (!a_Player->IsWorldTravellingFrom(this)) { m_ChunkMap->RemoveEntity(a_Player); } diff --git a/src/World.h b/src/World.h index 73b8b81b0..09cbc6b48 100644 --- a/src/World.h +++ b/src/World.h @@ -669,7 +669,7 @@ public: void InitializeSpawn(void); /** Starts threads that belong to this world */ - void Start(bool a_WasDimensionSet = true); + void Start(); /** Stops threads that belong to this world (part of deinit) */ void Stop(void); -- cgit v1.2.3 From e8262373e1608c5527779953c9a677dac7b020d8 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 03:19:46 -0700 Subject: NBTChunkSerializer.cpp: Added break after serializing the splash potion --- src/WorldStorage/NBTChunkSerializer.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 62db302ef..4857da1b6 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -614,6 +614,7 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity()); m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier()); m_Writer.AddInt("PotionName", Potion->GetPotionColor()); + break; } case cProjectileEntity::pkGhastFireball: { -- cgit v1.2.3 From f68b04e0294e5bc854fa6daad061e0280e5bb4f6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 20 Jul 2014 12:00:20 +0100 Subject: Proper comment for DropBlock() --- src/Blocks/BlockHandler.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index ee4d4a6fe..a6810933c 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -71,13 +71,16 @@ public: /// Called if the user right clicks the block and the block is useable virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) {}; - /** Called when a Right Click to this Block is cancelled */ + /** Called when a right click to this block is cancelled */ virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}; /// Called when the item is mined to convert it into pickups. Pickups may specify multiple items. Appends items to a_Pickups, preserves its original contents virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta); - /// Handles the dropping of a block based on what ConvertToDrops() returns. This will not destroy the block. a_Digger is the entity causing the drop; it may be NULL + /** Handles the dropping, but not destruction, of a block based on what ConvertTo(Verbatim)Pickups() returns, including the spawning of pickups and alertion of plugins + @param a_Digger The entity causing the drop; it may be NULL + @param a_DropVerbatim Calls ConvertToVerbatimPickups() instead of its counterpart, meaning the block itself is dropped by default (due to a speical tool or enchantment) + */ virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim = false); /// Returns step sound name of block -- cgit v1.2.3 From ba24f50e5ec36c4f4a119900e2dce9ff4b037ca9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 20 Jul 2014 13:39:14 +0100 Subject: Line tracer invalid chunk fix * Fixes #1230 * Additionally improved speed in some scenarios --- src/Entities/SplashPotionEntity.cpp | 13 ++++++------ src/LineBlockTracer.cpp | 40 ++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index c1623845f..6d874e957 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -33,15 +33,16 @@ public: /** Called by cWorld::ForEachEntity(), adds the stored entity effect to the entity, if it is close enough. */ virtual bool Item(cEntity * a_Entity) override { - double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length(); - if (SplashDistance >= 20) + if (!a_Entity->IsPawn()) { - // Too far away + // Not an entity that can take effects return false; } - if (!a_Entity->IsPawn()) + + double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length(); + if (SplashDistance >= 20) { - // Not an entity that can take effects + // Too far away return false; } @@ -114,7 +115,7 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect); m_World->ForEachEntity(Callback); - m_World->BroadcastSoundParticleEffect(2002, (int)a_HitPos.x, (int)a_HitPos.y, (int)a_HitPos.z, m_PotionColor); + m_World->BroadcastSoundParticleEffect(2002, (int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z), m_PotionColor); } diff --git a/src/LineBlockTracer.cpp b/src/LineBlockTracer.cpp index 2395aa43e..f03e796d1 100644 --- a/src/LineBlockTracer.cpp +++ b/src/LineBlockTracer.cpp @@ -212,6 +212,26 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk) return true; } + if ((m_CurrentY < 0) || (m_CurrentY >= cChunkDef::Height)) + { + // We've gone out of the world, that's the end of this trace + double IntersectX, IntersectZ; + CalcXZIntersection(m_CurrentY, IntersectX, IntersectZ); + if (m_Callbacks->OnOutOfWorld(IntersectX, m_CurrentY, IntersectZ)) + { + // The callback terminated the trace + return false; + } + m_Callbacks->OnNoMoreHits(); + return true; + } + + // Update the current chunk + if (a_Chunk != NULL) + { + a_Chunk = a_Chunk->GetNeighborChunk(m_CurrentX, m_CurrentZ); + } + if (a_Chunk->IsValid()) { BLOCKTYPE BlockType; @@ -233,26 +253,6 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk) return false; } } - - // Update the current chunk - if (a_Chunk != NULL) - { - a_Chunk = a_Chunk->GetNeighborChunk(m_CurrentX, m_CurrentZ); - } - - if ((m_CurrentY < 0) || (m_CurrentY >= cChunkDef::Height)) - { - // We've gone out of the world, that's the end of this trace - double IntersectX, IntersectZ; - CalcXZIntersection(m_CurrentY, IntersectX, IntersectZ); - if (m_Callbacks->OnOutOfWorld(IntersectX, m_CurrentY, IntersectZ)) - { - // The callback terminated the trace - return false; - } - m_Callbacks->OnNoMoreHits(); - return true; - } } } -- cgit v1.2.3 From 2823ee9026e32eac068389bc3dcd439d905c87b3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 20 Jul 2014 13:49:15 +0100 Subject: Revert "Only one instance of server can be started" This reverts commit 6484e9814a3a540518606f552398e0b82f91ab4d. * Fixes #1200 --- src/Server.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/Server.cpp b/src/Server.cpp index 367d507bf..180ec2ca6 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -222,12 +222,14 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) bool HasAnyPorts = false; AString Ports = a_SettingsIni.GetValueSet("Server", "Port", "25565"); + m_ListenThreadIPv4.SetReuseAddr(true); if (m_ListenThreadIPv4.Initialize(Ports)) { HasAnyPorts = true; } Ports = a_SettingsIni.GetValueSet("Server", "PortsIPv6", "25565"); + m_ListenThreadIPv6.SetReuseAddr(true); if (m_ListenThreadIPv6.Initialize(Ports)) { HasAnyPorts = true; -- cgit v1.2.3 From 7bf9da74413c69cbd79a9db81ba098e13b847904 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 20 Jul 2014 16:23:45 +0200 Subject: First attempt for a new foliage finisher --- src/Generating/ComposableGenerator.cpp | 4 ++++ src/Generating/FinishGen.cpp | 32 ++++++++++++++++++++++++++++ src/Generating/FinishGen.h | 38 ++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 7b6234161..21626e76b 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -338,6 +338,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) float Threshold = (float)a_IniFile.GetValueSetF("Generator", "DualRidgeCavesThreshold", 0.3); m_FinishGens.push_back(new cStructGenDualRidgeCaves(Seed, Threshold)); } + else if (NoCaseCompare(*itr, "Foliage") == 0) + { + m_FinishGens.push_back(new cFinishGenFoliage(Seed)); + } else if (NoCaseCompare(*itr, "Ice") == 0) { m_FinishGens.push_back(new cFinishGenIce); diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index f2d66af70..06c1dcbbe 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -159,6 +159,38 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cFinishGenFoliage: + +void cFinishGenFoliage::GenFinish(cChunkDesc & a_ChunkDesc) +{ + for (int x = 1; x < cChunkDef::Width; x++) + { + int xx = x + a_ChunkDesc.GetChunkX(); + for (int z = 1; z < cChunkDef::Width; z++) + { + int zz = z + a_ChunkDesc.GetChunkZ(); + //if (true) + if (m_Noise.CubicNoise2D((float) xx + m_Noise.CubicNoise1D(xx), zz + m_Noise.CubicNoise1D(zz)) < GetBiomeDensity(a_ChunkDesc.GetBiome(x, z))) + { + for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--) + { + if ( + (a_ChunkDesc.GetBlockType(x, y, z) == E_BLOCK_AIR) && + (a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_GRASS) + ) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, m_Noise.CubicNoise2D(xx * 100, zz * 100) > -0.2 ? 1 : 2); + } + } + } + } + } +} + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFinishGenSprinkleFoliage: diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 2e5732929..ea322c7ae 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -69,6 +69,44 @@ protected: +class cFinishGenFoliage : + public cFinishGen +{ +public: + cFinishGenFoliage(int a_Seed) : m_Noise(a_Seed), m_Seed(a_Seed) {} + +protected: + cNoise m_Noise; + int m_Seed; + + // cFinishGen override: + virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; + + float GetBiomeDensity(EMCSBiome a_Biome) + { + switch (a_Biome) + { + case biSavanna: + case biSavannaM: + case biSavannaPlateau: + case biSavannaPlateauM: + case biPlains: + { + return 0.0; + } + default: + { + return -0.4; + } + } + return -0.3; + } +}; + + + + + class cFinishGenSprinkleFoliage : public cFinishGen { -- cgit v1.2.3 From 51ad6cd1b22914aecd7e27d6a4a35853459fdb94 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 20 Jul 2014 16:31:28 +0200 Subject: Fixed warnings --- src/Generating/FinishGen.cpp | 3 +-- src/Generating/FinishGen.h | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 06c1dcbbe..86f5711a7 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -170,8 +170,7 @@ void cFinishGenFoliage::GenFinish(cChunkDesc & a_ChunkDesc) for (int z = 1; z < cChunkDef::Width; z++) { int zz = z + a_ChunkDesc.GetChunkZ(); - //if (true) - if (m_Noise.CubicNoise2D((float) xx + m_Noise.CubicNoise1D(xx), zz + m_Noise.CubicNoise1D(zz)) < GetBiomeDensity(a_ChunkDesc.GetBiome(x, z))) + if (m_Noise.CubicNoise2D((float) xx + m_Noise.CubicNoise1D(xx), (float) zz + m_Noise.CubicNoise1D(zz)) < GetBiomeDensity(a_ChunkDesc.GetBiome(x, z))) { for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--) { diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index ea322c7ae..d2968e592 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -92,14 +92,14 @@ protected: case biSavannaPlateauM: case biPlains: { - return 0.0; + return 0.0f; } default: { - return -0.4; + return -0.4f; } } - return -0.3; + return -0.3f; } }; -- cgit v1.2.3 From 76b79b51adfd8e71312cf777595483bb1ec68910 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 20 Jul 2014 19:22:41 +0200 Subject: Renamed cFinishGenFoliage to cFinishGenTallGrass Better grass density Added double tall grass. --- src/Generating/ComposableGenerator.cpp | 8 ++++---- src/Generating/FinishGen.cpp | 34 ++++++++++++++++++++++++++-------- src/Generating/FinishGen.h | 9 ++++----- 3 files changed, 34 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 21626e76b..2717f4e41 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -338,10 +338,6 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) float Threshold = (float)a_IniFile.GetValueSetF("Generator", "DualRidgeCavesThreshold", 0.3); m_FinishGens.push_back(new cStructGenDualRidgeCaves(Seed, Threshold)); } - else if (NoCaseCompare(*itr, "Foliage") == 0) - { - m_FinishGens.push_back(new cFinishGenFoliage(Seed)); - } else if (NoCaseCompare(*itr, "Ice") == 0) { m_FinishGens.push_back(new cFinishGenIce); @@ -419,6 +415,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) { m_FinishGens.push_back(new cFinishGenSprinkleFoliage(Seed)); } + else if (NoCaseCompare(*itr, "TallGrass") == 0) + { + m_FinishGens.push_back(new cFinishGenTallGrass(Seed)); + } else if (NoCaseCompare(*itr, "TestRails") == 0) { m_FinishGens.push_back(new cTestRailsGen(Seed, 100, 1, 7, 50)); diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 86f5711a7..3ee657e38 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -162,24 +162,42 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFinishGenFoliage: -void cFinishGenFoliage::GenFinish(cChunkDesc & a_ChunkDesc) +void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc) { - for (int x = 1; x < cChunkDef::Width; x++) + for (int x = 0; x < cChunkDef::Width; x++) { - int xx = x + a_ChunkDesc.GetChunkX(); - for (int z = 1; z < cChunkDef::Width; z++) + float xx = (float) x + a_ChunkDesc.GetChunkX(); + for (int z = 0; z < cChunkDef::Width; z++) { - int zz = z + a_ChunkDesc.GetChunkZ(); - if (m_Noise.CubicNoise2D((float) xx + m_Noise.CubicNoise1D(xx), (float) zz + m_Noise.CubicNoise1D(zz)) < GetBiomeDensity(a_ChunkDesc.GetBiome(x, z))) + float zz = (float) z + a_ChunkDesc.GetChunkZ(); + float BiomeDensity = GetBiomeDensity(a_ChunkDesc.GetBiome(x, z)); + if (m_Noise.CubicNoise2D(xx + m_Noise.CubicNoise1D(xx), zz + m_Noise.CubicNoise1D(zz)) < BiomeDensity) { for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--) { if ( (a_ChunkDesc.GetBlockType(x, y, z) == E_BLOCK_AIR) && - (a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_GRASS) + ((a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_GRASS) || (a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_DIRT)) ) { - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, m_Noise.CubicNoise2D(xx * 100, zz * 100) > -0.2 ? 1 : 2); + float GrassType = m_Noise.CubicNoise2D(xx * 50, zz * 50); + if (GrassType < 0.2f) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1); + } + else if (GrassType < 0.8f) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2); + } + else + { + if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR) + { + NIBBLETYPE Meta = m_Noise.CubicNoise2D(xx * 100, zz * 100) > -0.5f ? 2 : 3; + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta); + a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8); + } + } } } } diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index d2968e592..17a807e9b 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -69,11 +69,11 @@ protected: -class cFinishGenFoliage : +class cFinishGenTallGrass : public cFinishGen { public: - cFinishGenFoliage(int a_Seed) : m_Noise(a_Seed), m_Seed(a_Seed) {} + cFinishGenTallGrass(int a_Seed) : m_Noise(a_Seed), m_Seed(a_Seed) {} protected: cNoise m_Noise; @@ -92,14 +92,13 @@ protected: case biSavannaPlateauM: case biPlains: { - return 0.0f; + return 0.4f; } default: { - return -0.4f; + return -0.6f; } } - return -0.3f; } }; -- cgit v1.2.3 From a4470da876f8588fb71733a961701461f320e084 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 20 Jul 2014 22:43:31 +0200 Subject: Changed CubicNoiseXX to IntNoiseXX Added some comments --- src/Generating/FinishGen.cpp | 63 +++++++++++++++++++++++++------------------- src/Generating/FinishGen.h | 26 +++++++++--------- 2 files changed, 49 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 3ee657e38..b332c4f9b 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -166,38 +166,47 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc) { for (int x = 0; x < cChunkDef::Width; x++) { - float xx = (float) x + a_ChunkDesc.GetChunkX(); + int xx = x + a_ChunkDesc.GetChunkX() * cChunkDef::Width; for (int z = 0; z < cChunkDef::Width; z++) { - float zz = (float) z + a_ChunkDesc.GetChunkZ(); - float BiomeDensity = GetBiomeDensity(a_ChunkDesc.GetBiome(x, z)); - if (m_Noise.CubicNoise2D(xx + m_Noise.CubicNoise1D(xx), zz + m_Noise.CubicNoise1D(zz)) < BiomeDensity) + int zz = z + a_ChunkDesc.GetChunkZ() * cChunkDef::Width; + int BiomeDensity = GetBiomeDensity(a_ChunkDesc.GetBiome(x, z)); + + // Choose if we want to place long grass here. If not then bail out. + if ((m_Noise.IntNoise2DInt(xx + m_Noise.IntNoise1DInt(xx), zz + m_Noise.IntNoise1DInt(zz)) / 7 % 100) > BiomeDensity) { - for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--) - { - if ( - (a_ChunkDesc.GetBlockType(x, y, z) == E_BLOCK_AIR) && - ((a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_GRASS) || (a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_DIRT)) + continue; + } + + for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--) + { + // Check if long grass can be placed. + if ( + (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) || + ((a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_GRASS) && (a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_DIRT)) ) + { + continue; + } + + // Choose what long grass meta we should use. + int GrassType = m_Noise.IntNoise2DInt(xx * 50, zz * 50) / 7 % 100; + if (GrassType < 60) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1); + } + else if (GrassType < 90) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2); + } + else + { + // If double long grass we have to choose what type we should use. + if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR) { - float GrassType = m_Noise.CubicNoise2D(xx * 50, zz * 50); - if (GrassType < 0.2f) - { - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1); - } - else if (GrassType < 0.8f) - { - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2); - } - else - { - if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR) - { - NIBBLETYPE Meta = m_Noise.CubicNoise2D(xx * 100, zz * 100) > -0.5f ? 2 : 3; - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta); - a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8); - } - } + NIBBLETYPE Meta = (m_Noise.IntNoise2DInt(xx * 100, zz * 100) / 7 % 100) > 25 ? 2 : 3; + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta); + a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8); } } } diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 17a807e9b..f673ac2c2 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -82,22 +82,22 @@ protected: // cFinishGen override: virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; - float GetBiomeDensity(EMCSBiome a_Biome) + int GetBiomeDensity(EMCSBiome a_Biome) { switch (a_Biome) { - case biSavanna: - case biSavannaM: - case biSavannaPlateau: - case biSavannaPlateauM: - case biPlains: - { - return 0.4f; - } - default: - { - return -0.6f; - } + case biSavanna: + case biSavannaM: + case biSavannaPlateau: + case biSavannaPlateauM: + case biPlains: + { + return 70; + } + default: + { + return 20; + } } } }; -- cgit v1.2.3 From 8593d485799e04abd8d5a30bed5131f2608a915d Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 15:01:15 -0700 Subject: Cuboid: added explicit copy assignment operator --- src/Cuboid.cpp | 11 +++++++++++ src/Cuboid.h | 2 ++ 2 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/Cuboid.cpp b/src/Cuboid.cpp index d97447412..26e86c77b 100644 --- a/src/Cuboid.cpp +++ b/src/Cuboid.cpp @@ -24,6 +24,17 @@ static bool DoIntervalsIntersect(int a_Min1, int a_Max1, int a_Min2, int a_Max2) //////////////////////////////////////////////////////////////////////////////// // cCuboid: +cCuboid & cCuboid::operator=(cCuboid a_Other) +{ + std::swap(p1, a_Other.p1); + std::swap(p2, a_Other.p2); + return *this; +} + + + + + void cCuboid::Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) { p1.x = a_X1; diff --git a/src/Cuboid.h b/src/Cuboid.h index 960af130b..7bdb21b00 100644 --- a/src/Cuboid.h +++ b/src/Cuboid.h @@ -19,6 +19,8 @@ public: cCuboid(const Vector3i & a_p1, const Vector3i & a_p2) : p1(a_p1), p2(a_p2) {} cCuboid(int a_X1, int a_Y1, int a_Z1) : p1(a_X1, a_Y1, a_Z1), p2(a_X1, a_Y1, a_Z1) {} cCuboid(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) : p1(a_X1, a_Y1, a_Z1), p2(a_X2, a_Y2, a_Z2) {} + + cCuboid & operator=(cCuboid a_Other); void Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2); void Assign(const cCuboid & a_SrcCuboid); -- cgit v1.2.3 From 0c816dd6973ea15863b3e6f0a842b9b1e5fe2f3d Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 21 Jul 2014 10:58:13 +0200 Subject: Fixed indentation --- src/Generating/FinishGen.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index f673ac2c2..0688e1162 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -86,18 +86,18 @@ protected: { switch (a_Biome) { - case biSavanna: - case biSavannaM: - case biSavannaPlateau: - case biSavannaPlateauM: - case biPlains: - { - return 70; - } - default: - { - return 20; - } + case biSavanna: + case biSavannaM: + case biSavannaPlateau: + case biSavannaPlateauM: + case biPlains: + { + return 70; + } + default: + { + return 20; + } } } }; -- cgit v1.2.3 From ce956bcdf276daa288c35d702885bba90f6ce283 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 21 Jul 2014 16:01:16 +0200 Subject: Removed y for-loop. Only the top block now gets long grass. --- src/Generating/FinishGen.cpp | 54 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index b332c4f9b..26149f363 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -178,36 +178,36 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc) continue; } - for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--) + // Get the top block + 1. This is the place where the grass would finaly be placed. + int y = a_ChunkDesc.GetHeight(x, z) + 1; + + // Check if long grass can be placed. + if ( + (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) || + ((a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_GRASS) && (a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_DIRT)) + ) { - // Check if long grass can be placed. - if ( - (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) || - ((a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_GRASS) && (a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_DIRT)) - ) - { - continue; - } + continue; + } - // Choose what long grass meta we should use. - int GrassType = m_Noise.IntNoise2DInt(xx * 50, zz * 50) / 7 % 100; - if (GrassType < 60) - { - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1); - } - else if (GrassType < 90) - { - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2); - } - else + // Choose what long grass meta we should use. + int GrassType = m_Noise.IntNoise2DInt(xx * 50, zz * 50) / 7 % 100; + if (GrassType < 60) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1); + } + else if (GrassType < 90) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2); + } + else + { + // If double long grass we have to choose what type we should use. + if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR) { - // If double long grass we have to choose what type we should use. - if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR) - { - NIBBLETYPE Meta = (m_Noise.IntNoise2DInt(xx * 100, zz * 100) / 7 % 100) > 25 ? 2 : 3; - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta); - a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8); - } + NIBBLETYPE Meta = (m_Noise.IntNoise2DInt(xx * 100, zz * 100) / 7 % 100) > 25 ? 2 : 3; + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta); + a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8); } } } -- cgit v1.2.3 From 39623251c4e41e882abba767123f21b49a181ffc Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 21 Jul 2014 16:34:35 +0200 Subject: Fixed a missing enter. --- src/Generating/FinishGen.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 26149f363..e6c31e43f 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -217,6 +217,7 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc) + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFinishGenSprinkleFoliage: -- cgit v1.2.3 From 6be79575fd50e37ac275bd0cb9d16f9e51e8a225 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Jul 2014 23:10:31 +0200 Subject: Style: Normalized spaces after if, for and while. --- src/Bindings/ManualBindings.cpp | 22 ++++++++-------- src/Bindings/PluginManager.cpp | 2 +- src/Bindings/WebPlugin.cpp | 10 +++---- src/Blocks/BlockTorch.h | 7 ++--- src/Chunk.cpp | 5 ++-- src/CraftingRecipes.cpp | 2 +- src/Defines.h | 2 +- src/Entities/Player.cpp | 56 ++++++++++++++++++++-------------------- src/Globals.h | 2 +- src/GroupManager.cpp | 4 +-- src/Inventory.cpp | 14 +++++----- src/Items/ItemHandler.cpp | 2 +- src/Log.cpp | 8 +++--- src/MobProximityCounter.cpp | 4 +-- src/MobSpawner.cpp | 2 +- src/Mobs/Monster.cpp | 2 +- src/OSSupport/Errors.cpp | 4 +-- src/OSSupport/Semaphore.cpp | 12 ++++----- src/OSSupport/Thread.cpp | 10 +++---- src/Protocol/Protocol17x.cpp | 2 +- src/Root.cpp | 6 ++--- src/Server.cpp | 2 +- src/Simulator/FireSimulator.cpp | 2 +- src/Simulator/FluidSimulator.cpp | 6 ++--- src/Tracer.cpp | 40 ++++++++++++++-------------- src/WebAdmin.cpp | 2 +- src/World.cpp | 6 ++--- src/WorldStorage/WSSCompact.cpp | 36 +++++++++++++------------- 28 files changed, 137 insertions(+), 135 deletions(-) (limited to 'src') diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 4047adc3a..5e9e7349d 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -656,12 +656,12 @@ template< static int tolua_ForEach(lua_State * tolua_S) { int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */ - if( NumArgs != 1 && NumArgs != 2) + if ((NumArgs != 1) && (NumArgs != 2)) { return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 1 or 2 arguments, got %i", NumArgs); } - Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL); + Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, NULL); if (self == NULL) { return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance"); @@ -1360,7 +1360,7 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S) static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S) { int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */ - if( NumArgs != 1) + if (NumArgs != 1) { LOGWARN("Error in function call 'ForEachCommand': Requires 1 argument, got %i", NumArgs); return 0; @@ -1437,7 +1437,7 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S) static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S) { int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */ - if( NumArgs != 1) + if (NumArgs != 1) { LOGWARN("Error in function call 'ForEachConsoleCommand': Requires 1 argument, got %i", NumArgs); return 0; @@ -1938,16 +1938,16 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S) return tolua_do_error(tolua_S, "#ferror calling function '#funcname#'", &tolua_err); } - if( Reference != LUA_REFNIL ) + if (Reference != LUA_REFNIL) { - if( !self->AddWebTab( Title.c_str(), tolua_S, Reference ) ) + if (!self->AddWebTab(Title.c_str(), tolua_S, Reference)) { - luaL_unref( tolua_S, LUA_REGISTRYINDEX, Reference ); + luaL_unref(tolua_S, LUA_REGISTRYINDEX, Reference); } } else { - LOGERROR("ERROR: cPluginLua:AddWebTab invalid function reference in 2nd argument (Title: \"%s\")", Title.c_str() ); + LOGWARNING("cPluginLua:AddWebTab: invalid function reference in 2nd argument (Title: \"%s\")", Title.c_str()); } return 0; @@ -2016,7 +2016,7 @@ static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string, lua_newtable(tolua_S); int top = lua_gettop(tolua_S); - for( std::map< std::string, std::string >::iterator it = a_StringStringMap.begin(); it != a_StringStringMap.end(); ++it ) + for (std::map::iterator it = a_StringStringMap.begin(); it != a_StringStringMap.end(); ++it) { const char* key = it->first.c_str(); const char* value = it->second.c_str(); @@ -2060,7 +2060,7 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S) lua_newtable(tolua_S); int top = lua_gettop(tolua_S); - for( std::map< std::string, HTTPFormData >::iterator it = FormData.begin(); it != FormData.end(); ++it ) + for (std::map::iterator it = FormData.begin(); it != FormData.end(); ++it) { lua_pushstring(tolua_S, it->first.c_str() ); tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData" ); @@ -2109,7 +2109,7 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S) lua_newtable(tolua_S); int index = 1; cWebPlugin::TabNameList::const_iterator iter = TabNames.begin(); - while(iter != TabNames.end()) + while (iter != TabNames.end()) { const AString & FancyName = iter->first; const AString & WebName = iter->second; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 2c0ce701b..33ecb95ad 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1434,7 +1434,7 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player, cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin ) const { - for( PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr ) + for (PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr) { if (itr->second == NULL ) continue; if (itr->second->GetName().compare(a_Plugin) == 0) diff --git a/src/Bindings/WebPlugin.cpp b/src/Bindings/WebPlugin.cpp index 57ed9f6a4..a22826d1b 100644 --- a/src/Bindings/WebPlugin.cpp +++ b/src/Bindings/WebPlugin.cpp @@ -45,7 +45,7 @@ cWebPlugin::~cWebPlugin() std::list > cWebPlugin::GetTabNames(void) { std::list< std::pair< AString, AString > > NameList; - for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) + for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) { std::pair< AString, AString > StringPair; StringPair.first = (*itr)->Title; @@ -69,7 +69,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest sWebPluginTab * Tab = NULL; if (Split.size() > 2) // If we got the tab name, show that page { - for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) + for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) { if ((*itr)->SafeTitle.compare(Split[2]) == 0) // This is the one! { @@ -80,7 +80,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest } else // Otherwise show the first tab { - if( GetTabs().size() > 0 ) + if (GetTabs().size() > 0 ) Tab = *GetTabs().begin(); } @@ -100,10 +100,10 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest AString cWebPlugin::SafeString(const AString & a_String) { AString RetVal; - for( unsigned int i = 0; i < a_String.size(); ++i ) + for (unsigned int i = 0; i < a_String.size(); ++i ) { char c = a_String[i]; - if( c == ' ' ) + if (c == ' ' ) { c = '_'; } diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index 73f2bf9a8..b62268187 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -99,7 +99,7 @@ public: static bool CanBePlacedOn(BLOCKTYPE a_BlockType, eBlockFace a_BlockFace) { - if ( !cBlockInfo::FullyOccupiesVoxel(a_BlockType) ) + if (!cBlockInfo::FullyOccupiesVoxel(a_BlockType) ) { return (a_BlockFace == BLOCK_FACE_TOP); // Allow placement only when torch upright (for glass, etc.); exceptions won't even be sent by client, no need to handle } @@ -119,7 +119,8 @@ public: AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face, true); BLOCKTYPE BlockInQuestion = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); - if ( // If on a block that can only hold a torch if torch is standing on it, return that face + // If on a block that can only hold a torch if torch is standing on it, return that face + if ( ((BlockInQuestion == E_BLOCK_GLASS) || (BlockInQuestion == E_BLOCK_FENCE) || (BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) || @@ -167,7 +168,7 @@ public: // No need to check for upright orientation, it was done when the torch was placed return true; } - else if ( !cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) ) + else if (!cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) ) { return false; } diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 6e2d3509d..25a58458e 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1530,11 +1530,12 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT m_ChunkData.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType); - if ( // Queue block to be sent only if ... + // Queue block to be sent only if ... + if ( a_SendToClients && // ... we are told to do so AND ... ( (OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ... - !( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them); see below for specifics: + !( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them): ((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water ((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water ((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index e60c407d0..85a373279 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -582,7 +582,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::FindRecipe(const cItem * a_Craftin // Get the real bounds of the crafting grid: int GridLeft = MAX_GRID_WIDTH, GridTop = MAX_GRID_HEIGHT; int GridRight = 0, GridBottom = 0; - for (int y = 0; y < a_GridHeight; y++ ) for(int x = 0; x < a_GridWidth; x++) + for (int y = 0; y < a_GridHeight; y++ ) for (int x = 0; x < a_GridWidth; x++) { if (!a_CraftingGrid[x + y * a_GridWidth].IsEmpty()) { diff --git a/src/Defines.h b/src/Defines.h index f7c8d0fc5..f4ebbd9ff 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -717,7 +717,7 @@ namespace ItemCategory inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType) { - if(!IsValidBlock(a_BlockType)) return false; + if (!IsValidBlock(a_BlockType)) return false; return cBlockInfo::RequiresSpecialTool(a_BlockType); } diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 808b74023..6a52d8e29 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -286,13 +286,13 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) short cPlayer::CalcLevelFromXp(short a_XpTotal) { // level 0 to 15 - if(a_XpTotal <= XP_TO_LEVEL15) + if (a_XpTotal <= XP_TO_LEVEL15) { return a_XpTotal / XP_PER_LEVEL_TO15; } // level 30+ - if(a_XpTotal > XP_TO_LEVEL30) + if (a_XpTotal > XP_TO_LEVEL30) { return (short) (151.5 + sqrt( 22952.25 - (14 * (2220 - a_XpTotal)))) / 7; } @@ -308,13 +308,13 @@ short cPlayer::CalcLevelFromXp(short a_XpTotal) short cPlayer::XpForLevel(short a_Level) { // level 0 to 15 - if(a_Level <= 15) + if (a_Level <= 15) { return a_Level * XP_PER_LEVEL_TO15; } // level 30+ - if(a_Level >= 31) + if (a_Level >= 31) { return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220 ); } @@ -351,7 +351,7 @@ float cPlayer::GetXpPercentage() bool cPlayer::SetCurrentExperience(short int a_CurrentXp) { - if(!(a_CurrentXp >= 0) || (a_CurrentXp > (SHRT_MAX - m_LifetimeTotalXp))) + if (!(a_CurrentXp >= 0) || (a_CurrentXp > (SHRT_MAX - m_LifetimeTotalXp))) { LOGWARNING("Tried to update experiece with an invalid Xp value: %d", a_CurrentXp); return false; // oops, they gave us a dodgey number @@ -1370,9 +1370,9 @@ void cPlayer::AddToGroup( const AString & a_GroupName ) void cPlayer::RemoveFromGroup( const AString & a_GroupName ) { bool bRemoved = false; - for( GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr ) + for (GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr ) { - if( (*itr)->GetName().compare(a_GroupName ) == 0 ) + if ((*itr)->GetName().compare(a_GroupName ) == 0 ) { m_Groups.erase( itr ); bRemoved = true; @@ -1380,7 +1380,7 @@ void cPlayer::RemoveFromGroup( const AString & a_GroupName ) } } - if( bRemoved ) + if (bRemoved ) { LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str() ); ResolveGroups(); @@ -1407,24 +1407,24 @@ bool cPlayer::HasPermission(const AString & a_Permission) AStringVector Split = StringSplit( a_Permission, "." ); PermissionMap Possibilities = m_ResolvedPermissions; // Now search the namespaces - while( Possibilities.begin() != Possibilities.end() ) + while (Possibilities.begin() != Possibilities.end() ) { PermissionMap::iterator itr = Possibilities.begin(); - if( itr->second ) + if (itr->second ) { AStringVector OtherSplit = StringSplit( itr->first, "." ); - if( OtherSplit.size() <= Split.size() ) + if (OtherSplit.size() <= Split.size() ) { unsigned int i; - for( i = 0; i < OtherSplit.size(); ++i ) + for (i = 0; i < OtherSplit.size(); ++i ) { - if( OtherSplit[i].compare( Split[i] ) != 0 ) + if (OtherSplit[i].compare( Split[i] ) != 0 ) { - if( OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard! + if (OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard! break; } } - if( i == Split.size() ) return true; + if (i == Split.size() ) return true; } } Possibilities.erase( itr ); @@ -1440,9 +1440,9 @@ bool cPlayer::HasPermission(const AString & a_Permission) bool cPlayer::IsInGroup( const AString & a_Group ) { - for( GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr ) + for (GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr ) { - if( a_Group.compare( (*itr)->GetName().c_str() ) == 0 ) + if (a_Group.compare( (*itr)->GetName().c_str() ) == 0 ) return true; } return false; @@ -1457,15 +1457,15 @@ void cPlayer::ResolvePermissions() m_ResolvedPermissions.clear(); // Start with an empty map // Copy all player specific permissions into the resolved permissions map - for( PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr ) + for (PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr ) { m_ResolvedPermissions[ itr->first ] = itr->second; } - for( GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr ) + for (GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr ) { const cGroup::PermissionMap & Permissions = (*GroupItr)->GetPermissions(); - for( cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr ) + for (cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr ) { m_ResolvedPermissions[ itr->first ] = itr->second; } @@ -1484,14 +1484,14 @@ void cPlayer::ResolveGroups() // Get a complete resolved list of all groups the player is in std::map< cGroup*, bool > AllGroups; // Use a map, because it's faster than iterating through a list to find duplicates GroupList ToIterate; - for( GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr ) + for (GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr ) { ToIterate.push_back( *GroupItr ); } - while( ToIterate.begin() != ToIterate.end() ) + while (ToIterate.begin() != ToIterate.end() ) { cGroup* CurrentGroup = *ToIterate.begin(); - if( AllGroups.find( CurrentGroup ) != AllGroups.end() ) + if (AllGroups.find( CurrentGroup ) != AllGroups.end() ) { LOGWARNING("ERROR: Player \"%s\" is in the group multiple times (\"%s\"). Please fix your settings in users.ini!", GetName().c_str(), CurrentGroup->GetName().c_str() @@ -1502,9 +1502,9 @@ void cPlayer::ResolveGroups() AllGroups[ CurrentGroup ] = true; m_ResolvedGroups.push_back( CurrentGroup ); // Add group to resolved list const cGroup::GroupList & Inherits = CurrentGroup->GetInherits(); - for( cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr ) + for (cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr ) { - if( AllGroups.find( *itr ) != AllGroups.end() ) + if (AllGroups.find( *itr ) != AllGroups.end() ) { LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", GetName().c_str(), (*itr)->GetName().c_str() ); continue; @@ -1522,12 +1522,12 @@ void cPlayer::ResolveGroups() AString cPlayer::GetColor(void) const { - if ( m_Color != '-' ) + if (m_Color != '-' ) { return cChatColor::Delimiter + m_Color; } - if ( m_Groups.size() < 1 ) + if (m_Groups.size() < 1 ) { return cChatColor::White; } @@ -1914,7 +1914,7 @@ cPlayer::StringList cPlayer::GetResolvedPermissions() StringList Permissions; const PermissionMap& ResolvedPermissions = m_ResolvedPermissions; - for( PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr ) + for (PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr ) { if (itr->second) { diff --git a/src/Globals.h b/src/Globals.h index 932040ec2..007fa10d0 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -309,7 +309,7 @@ void inline LOGERROR(const char* a_Format, ...) } #endif #define ASSERT(x) do { if (!(x)) { throw cAssertFailure();} } while (0) - #define testassert(x) do { if(!(x)) { REPORT_ERROR("Test failure: %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } } while (0) + #define testassert(x) do { if (!(x)) { REPORT_ERROR("Test failure: %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } } while (0) #define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } REPORT_ERROR("Test failure: assert didn't fire for %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } while (0) #else diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index a1cc396cf..685aece5a 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -27,7 +27,7 @@ struct cGroupManager::sGroupManagerState cGroupManager::~cGroupManager() { - for( GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr ) + for (GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr ) { delete itr->second; itr->second = NULL; @@ -211,7 +211,7 @@ bool cGroupManager::ExistsGroup( const AString & a_Name ) cGroup* cGroupManager::GetGroup( const AString & a_Name ) { GroupMap::iterator itr = m_pState->Groups.find( a_Name ); - if( itr != m_pState->Groups.end() ) + if (itr != m_pState->Groups.end() ) { return itr->second; } diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 5f7c24b60..93b2c8eee 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -500,15 +500,15 @@ int cInventory::ArmorSlotNumToEntityEquipmentID(short a_ArmorSlotNum) bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode /* = 0 */ ) { // Fill already present stacks - if( a_Mode < 2 ) + if (a_Mode < 2 ) { int MaxStackSize = cItemHandler::GetItemHandler(a_Item.m_ItemType)->GetMaxStackSize(); - for(int i = 0; i < a_Size; i++) + for (int i = 0; i < a_Size; i++) { - if( m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage ) + if (m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage ) { int NumFree = MaxStackSize - m_Slots[i + a_Offset].m_ItemCount; - if( NumFree >= a_Item.m_ItemCount ) + if (NumFree >= a_Item.m_ItemCount ) { // printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree ); @@ -528,12 +528,12 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, } } - if( a_Mode > 0 ) + if (a_Mode > 0 ) { // If we got more left, find first empty slot - for(int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++) + for (int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++) { - if( m_Slots[i + a_Offset].m_ItemType == -1 ) + if (m_Slots[i + a_Offset].m_ItemType == -1 ) { m_Slots[i + a_Offset] = a_Item; a_Item.m_ItemCount = 0; diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 178bc2fca..0a8638f3a 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -263,7 +263,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) void cItemHandler::Deinit() { - for(int i = 0; i < 2267; i++) + for (int i = 0; i < 2267; i++) { delete m_ItemHandler[i]; m_ItemHandler[i] = NULL; diff --git a/src/Log.cpp b/src/Log.cpp index 69b9c13a2..a70b09103 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -59,7 +59,7 @@ cLog * cLog::GetInstance() void cLog::CloseLog() { - if( m_File ) + if (m_File ) fclose (m_File); m_File = 0; } @@ -70,7 +70,7 @@ void cLog::CloseLog() void cLog::OpenLog( const char* a_FileName ) { - if(m_File) fclose (m_File); + if (m_File) fclose (m_File); #ifdef _MSC_VER fopen_s( &m_File, a_FileName, "a+" ); #else @@ -85,11 +85,11 @@ void cLog::OpenLog( const char* a_FileName ) void cLog::ClearLog() { #ifdef _MSC_VER - if( fopen_s( &m_File, "log.txt", "w" ) == 0) + if (fopen_s( &m_File, "log.txt", "w" ) == 0) fclose (m_File); #else m_File = fopen("log.txt", "w" ); - if( m_File ) + if (m_File ) fclose (m_File); #endif m_File = NULL; diff --git a/src/MobProximityCounter.cpp b/src/MobProximityCounter.cpp index f5d3e970c..82ba771ff 100644 --- a/src/MobProximityCounter.cpp +++ b/src/MobProximityCounter.cpp @@ -34,7 +34,7 @@ void cMobProximityCounter::CollectMob(cEntity& a_Monster, cChunk& a_Chunk, doubl void cMobProximityCounter::convertMaps() { - for(tMonsterToDistance::const_iterator itr = m_MonsterToDistance.begin(); itr != m_MonsterToDistance.end(); ++itr) + for (tMonsterToDistance::const_iterator itr = m_MonsterToDistance.begin(); itr != m_MonsterToDistance.end(); ++itr) { m_DistanceToMonster.insert(tDistanceToMonster::value_type(itr->second.m_Distance, sMonsterAndChunk(*itr->first, *itr->second.m_Chunk))); } @@ -55,7 +55,7 @@ cMobProximityCounter::sIterablePair cMobProximityCounter::getMobWithinThosesDist convertMaps(); } - for(tDistanceToMonster::const_iterator itr = m_DistanceToMonster.begin(); itr != m_DistanceToMonster.end(); ++itr) + for (tDistanceToMonster::const_iterator itr = m_DistanceToMonster.begin(); itr != m_DistanceToMonster.end(); ++itr) { if (toReturn.m_Begin == m_DistanceToMonster.end()) { diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index ce1187452..53c83f166 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -208,7 +208,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R bool HasFloor = false; for (int x = 0; x < 2; ++x) { - for(int z = 0; z < 2; ++z) + for (int z = 0; z < 2; ++z) { CanSpawn = a_Chunk->UnboundedRelGetBlockType(a_RelX + x, a_RelY, a_RelZ + z, TargetBlock); CanSpawn = CanSpawn && (TargetBlock == E_BLOCK_AIR); diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 753a44914..c1247c1f8 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -281,7 +281,7 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) } Vector3f Distance = m_Destination - GetPosition(); - if(!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move + if (!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move { Distance.y = 0; Distance.Normalize(); diff --git a/src/OSSupport/Errors.cpp b/src/OSSupport/Errors.cpp index 6072b6ac6..02de28e4e 100644 --- a/src/OSSupport/Errors.cpp +++ b/src/OSSupport/Errors.cpp @@ -25,7 +25,7 @@ AString GetOSErrorString( int a_ErrNo ) #if !defined(__APPLE__) && ( _GNU_SOURCE ) && !defined(ANDROID_NDK) // GNU version of strerror_r() char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) ); - if( res != NULL ) + if (res != NULL ) { Printf(Out, "%d: %s", a_ErrNo, res); return Out; @@ -34,7 +34,7 @@ AString GetOSErrorString( int a_ErrNo ) #else // XSI version of strerror_r(): int res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) ); - if( res == 0 ) + if (res == 0 ) { Printf(Out, "%d: %s", a_ErrNo, buffer); return Out; diff --git a/src/OSSupport/Semaphore.cpp b/src/OSSupport/Semaphore.cpp index d919c4744..cb9ccc83b 100644 --- a/src/OSSupport/Semaphore.cpp +++ b/src/OSSupport/Semaphore.cpp @@ -22,13 +22,13 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* AString Name; Printf(Name, "cSemaphore%p", this ); m_Handle = sem_open(Name.c_str(), O_CREAT, 777, a_InitialCount); - if( m_Handle == SEM_FAILED ) + if (m_Handle == SEM_FAILED ) { LOG("ERROR: Could not create Semaphore. (%i)", errno ); } else { - if( sem_unlink(Name.c_str()) != 0 ) + if (sem_unlink(Name.c_str()) != 0 ) { LOG("ERROR: Could not unlink cSemaphore. (%i)", errno); } @@ -53,9 +53,9 @@ cSemaphore::~cSemaphore() #ifdef _WIN32 CloseHandle( m_Handle ); #else - if( m_bNamed ) + if (m_bNamed ) { - if( sem_close( (sem_t*)m_Handle ) != 0 ) + if (sem_close( (sem_t*)m_Handle ) != 0 ) { LOG("ERROR: Could not close cSemaphore. (%i)", errno); } @@ -77,7 +77,7 @@ cSemaphore::~cSemaphore() void cSemaphore::Wait() { #ifndef _WIN32 - if( sem_wait( (sem_t*)m_Handle ) != 0) + if (sem_wait( (sem_t*)m_Handle ) != 0) { LOG("ERROR: Could not wait for cSemaphore. (%i)", errno); } @@ -93,7 +93,7 @@ void cSemaphore::Wait() void cSemaphore::Signal() { #ifndef _WIN32 - if( sem_post( (sem_t*)m_Handle ) != 0 ) + if (sem_post( (sem_t*)m_Handle ) != 0 ) { LOG("ERROR: Could not signal cSemaphore. (%i)", errno); } diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp index 163c9b0c9..811e7cb21 100644 --- a/src/OSSupport/Thread.cpp +++ b/src/OSSupport/Thread.cpp @@ -53,7 +53,7 @@ cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_Thre , m_Event( new cEvent() ) , m_StopEvent( 0 ) { - if( a_ThreadName ) + if (a_ThreadName ) { m_ThreadName.assign(a_ThreadName); } @@ -68,7 +68,7 @@ cThread::~cThread() delete m_Event; m_Event = NULL; - if( m_StopEvent ) + if (m_StopEvent ) { m_StopEvent->Wait(); delete m_StopEvent; @@ -82,12 +82,12 @@ cThread::~cThread() void cThread::Start( bool a_bWaitOnDelete /* = true */ ) { - if( a_bWaitOnDelete ) + if (a_bWaitOnDelete ) m_StopEvent = new cEvent(); #ifndef _WIN32 pthread_t SndThread; - if( pthread_create( &SndThread, NULL, MyThread, this) ) + if (pthread_create( &SndThread, NULL, MyThread, this) ) LOGERROR("ERROR: Could not create thread!"); #else DWORD ThreadID = 0; @@ -132,6 +132,6 @@ void *cThread::MyThread( void *a_Param ) ThreadFunction( ThreadParam ); - if( StopEvent ) StopEvent->Set(); + if (StopEvent ) StopEvent->Set(); return 0; } diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 2707fbf9f..dadf82716 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1587,7 +1587,7 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size) ASSERT(!"Read wrong number of bytes!"); m_Client->PacketError(PacketType); } - } // for(ever) + } // for (ever) // Log any leftover bytes into the logfile: if (g_ShouldLogCommIn && (m_ReceivedData.GetReadableSpace() > 0)) diff --git a/src/Root.cpp b/src/Root.cpp index ba25b97eb..e195b59ff 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -359,7 +359,7 @@ void cRoot::StopWorlds(void) void cRoot::UnloadWorlds(void) { m_pDefaultWorld = NULL; - for( WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) + for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) { delete itr->second; } @@ -382,7 +382,7 @@ cWorld* cRoot::GetDefaultWorld() cWorld* cRoot::GetWorld( const AString & a_WorldName ) { WorldMap::iterator itr = m_WorldsByName.find( a_WorldName ); - if( itr != m_WorldsByName.end() ) + if (itr != m_WorldsByName.end() ) return itr->second; return 0; } @@ -509,7 +509,7 @@ void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AStri int cRoot::GetTotalChunkCount(void) { int res = 0; - for ( WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) + for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) { res += itr->second->GetNumChunks(); } diff --git a/src/Server.cpp b/src/Server.cpp index 180ec2ca6..0990fc398 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -631,7 +631,7 @@ void cServer::Shutdown(void) cRoot::Get()->SaveAllChunks(); cCSLock Lock(m_CSClients); - for( ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr ) + for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr ) { (*itr)->Destroy(); delete *itr; diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp index 2164b6b10..69dc7164e 100644 --- a/src/Simulator/FireSimulator.cpp +++ b/src/Simulator/FireSimulator.cpp @@ -140,7 +140,7 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun continue; } - if((itr->y > 0) && (!DoesBurnForever(a_Chunk->GetBlock(itr->x, itr->y - 1, itr->z)))) + if ((itr->y > 0) && (!DoesBurnForever(a_Chunk->GetBlock(itr->x, itr->y - 1, itr->z)))) { a_Chunk->SetMeta(x, y, z, BlockMeta + 1); } diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp index 499e204a1..58501326f 100644 --- a/src/Simulator/FluidSimulator.cpp +++ b/src/Simulator/FluidSimulator.cpp @@ -159,18 +159,18 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a { Vector3i *Pos = (*it); char BlockID = m_World.GetBlock(Pos->x, Pos->y, Pos->z); - if(IsAllowedBlock(BlockID)) + if (IsAllowedBlock(BlockID)) { char Meta = m_World.GetBlockMeta(Pos->x, Pos->y, Pos->z); - if(Meta > LowestPoint) + if (Meta > LowestPoint) { LowestPoint = Meta; X = Pos->x; Z = Pos->z; } } - else if(BlockID == E_BLOCK_AIR) + else if (BlockID == E_BLOCK_AIR) { LowestPoint = 9; // This always dominates X = Pos->x; diff --git a/src/Tracer.cpp b/src/Tracer.cpp index fd8a297c0..df01e9129 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -59,7 +59,7 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction) step.z = (int) SigNum(dir.z); // normalize the direction vector - if( dir.SqrLength() > 0.f ) dir.Normalize(); + if (dir.SqrLength() > 0.f ) dir.Normalize(); // how far we must move in the ray direction before // we encounter a new voxel in x-direction @@ -192,7 +192,7 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int if (step.y > 0.0f) { - if(pos.y >= end1.y) + if (pos.y >= end1.y) { reachedY = true; } @@ -313,7 +313,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve Vector3i SmallBlockPos = a_BlockPos; char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z ); - if( BlockID == E_BLOCK_AIR || IsBlockWater(BlockID)) + if (BlockID == E_BLOCK_AIR || IsBlockWater(BlockID)) { return 0; } @@ -328,10 +328,10 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve if (dot < 0) { int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1 ); - if(Lines == 1) + if (Lines == 1) { Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x, BlockPos.z, BlockPos.x, BlockPos.z + 1 ); - if(Lines == 1) + if (Lines == 1) { intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(-1, 0, 0) ); return 1; @@ -339,13 +339,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } dot = Look.Dot( Vector3f(0, 0, -1) ); // second face normal is z -1 - if(dot < 0) + if (dot < 0) { int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1 ); - if(Lines == 1) + if (Lines == 1) { Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z, BlockPos.x, BlockPos.z, BlockPos.x + 1 ); - if(Lines == 1) + if (Lines == 1) { intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, 0, -1) ); return 2; @@ -353,13 +353,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } dot = Look.Dot( Vector3f(1, 0, 0) ); // third face normal is x 1 - if(dot < 0) + if (dot < 0) { int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1 ); - if(Lines == 1) + if (Lines == 1) { Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x + 1, BlockPos.z, BlockPos.x + 1, BlockPos.z + 1 ); - if(Lines == 1) + if (Lines == 1) { intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(1, 0, 0), Vector3f(1, 0, 0) ); return 3; @@ -367,13 +367,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } dot = Look.Dot( Vector3f(0, 0, 1) ); // fourth face normal is z 1 - if(dot < 0) + if (dot < 0) { int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1 ); - if(Lines == 1) + if (Lines == 1) { Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z + 1, BlockPos.x, BlockPos.z + 1, BlockPos.x + 1 ); - if(Lines == 1) + if (Lines == 1) { intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 0, 1), Vector3f(0, 0, 1) ); return 4; @@ -381,13 +381,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } dot = Look.Dot( Vector3f(0, 1, 0) ); // fifth face normal is y 1 - if(dot < 0) + if (dot < 0) { int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1 ); - if(Lines == 1) + if (Lines == 1) { Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y + 1, BlockPos.z, BlockPos.y + 1, BlockPos.z + 1 ); - if(Lines == 1) + if (Lines == 1) { intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 1, 0), Vector3f(0, 1, 0) ); return 5; @@ -395,13 +395,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } dot = Look.Dot( Vector3f(0, -1, 0) ); // sixth face normal is y -1 - if(dot < 0) + if (dot < 0) { int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1 ); - if(Lines == 1) + if (Lines == 1) { Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y, BlockPos.z, BlockPos.y, BlockPos.z + 1 ); - if(Lines == 1) + if (Lines == 1) { intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, -1, 0) ); return 6; diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index be72f2d5a..d8347e2b9 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -392,7 +392,7 @@ AString cWebAdmin::GetDefaultPage(void) cPlayerAccum PlayerAccum; cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players - if( World != NULL ) + if (World != NULL ) { World->ForEachPlayer(PlayerAccum); Content.append(PlayerAccum.m_Contents); diff --git a/src/World.cpp b/src/World.cpp index d90383884..c146338d7 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -865,14 +865,14 @@ void cWorld::TickMobs(float a_Dt) // move close mobs cMobProximityCounter::sIterablePair allCloseEnoughToMoveMobs = MobCensus.GetProximityCounter().getMobWithinThosesDistances(-1, 64 * 16);// MG TODO : deal with this magic number (the 16 is the size of a block) - for(cMobProximityCounter::tDistanceToMonster::const_iterator itr = allCloseEnoughToMoveMobs.m_Begin; itr != allCloseEnoughToMoveMobs.m_End; ++itr) + for (cMobProximityCounter::tDistanceToMonster::const_iterator itr = allCloseEnoughToMoveMobs.m_Begin; itr != allCloseEnoughToMoveMobs.m_End; ++itr) { itr->second.m_Monster.Tick(a_Dt, itr->second.m_Chunk); } // remove too far mobs cMobProximityCounter::sIterablePair allTooFarMobs = MobCensus.GetProximityCounter().getMobWithinThosesDistances(128 * 16, -1);// MG TODO : deal with this magic number (the 16 is the size of a block) - for(cMobProximityCounter::tDistanceToMonster::const_iterator itr = allTooFarMobs.m_Begin; itr != allTooFarMobs.m_End; ++itr) + for (cMobProximityCounter::tDistanceToMonster::const_iterator itr = allTooFarMobs.m_Begin; itr != allTooFarMobs.m_End; ++itr) { itr->second.m_Monster.Destroy(true); } @@ -2469,7 +2469,7 @@ cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, { if (a_CheckLineOfSight) { - if(!LineOfSight.Trace(a_Pos, (Pos - a_Pos), (int)(Pos - a_Pos).Length())) + if (!LineOfSight.Trace(a_Pos, (Pos - a_Pos), (int)(Pos - a_Pos).Length())) { ClosestDistance = Distance; ClosestPlayer = *itr; diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index ff43b6905..aae94141c 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -486,12 +486,12 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ return; } - if( m_ChunkVersion == 1 ) // Convert chunks to version 2 + if (m_ChunkVersion == 1 ) // Convert chunks to version 2 { UpdateChunk1To2(); } #if AXIS_ORDER == AXIS_ORDER_XZY - if( m_ChunkVersion == 2 ) // Convert chunks to version 3 + if (m_ChunkVersion == 2 ) // Convert chunks to version 3 { UpdateChunk2To3(); } @@ -574,7 +574,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() { sChunkHeader * Header = *itr; - if( ChunksConverted % 32 == 0 ) + if (ChunksConverted % 32 == 0 ) { LOGINFO("Updating \"%s\" version 1 to version 2: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() ); } @@ -627,9 +627,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() char ConvertedData[cChunkDef::BlockDataSize]; int Index = 0; unsigned int InChunkOffset = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) { - for( int y = 0; y < 128; ++y ) + for (int y = 0; y < 128; ++y ) { ConvertedData[Index++] = UncompressedData[y + z * 128 + x * 128 * 16 + InChunkOffset]; } @@ -638,9 +638,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 128; } InChunkOffset += (16 * 128 * 16); - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Metadata + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Metadata { - for( int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y ) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -648,9 +648,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16 * 128 * 16) / 2; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Block light + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Block light { - for( int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y ) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -658,9 +658,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16*128*16)/2; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Sky light + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Sky light { - for( int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y ) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -718,7 +718,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() { sChunkHeader * Header = *itr; - if( ChunksConverted % 32 == 0 ) + if (ChunksConverted % 32 == 0 ) { LOGINFO("Updating \"%s\" version 2 to version 3: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() ); } @@ -774,7 +774,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() #define MAKE_3_INDEX( x, y, z ) ( x + (z * 16) + (y * 16 * 16) ) unsigned int InChunkOffset = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X { ConvertedData[ MAKE_3_INDEX(x, y, z) ] = UncompressedData[InChunkOffset]; ++InChunkOffset; @@ -782,7 +782,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() unsigned int index2 = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) { ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); ++index2; @@ -790,7 +790,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() InChunkOffset += index2 / 2; index2 = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) { ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); ++index2; @@ -798,7 +798,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() InChunkOffset += index2 / 2; index2 = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) { ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); ++index2; @@ -887,7 +887,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre { Json::Value root; // will contain the root value after parsing. Json::Reader reader; - if ( !reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false ) ) + if (!reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false ) ) { LOGERROR("Failed to parse trailing JSON in chunk [%d, %d]!", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ @@ -970,7 +970,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld // Compress the data: AString CompressedData; int errorcode = CompressString(Data.data(), Data.size(), CompressedData, m_CompressionFactor); - if ( errorcode != Z_OK ) + if (errorcode != Z_OK ) { LOGERROR("Error %i compressing data for chunk [%d, %d, %d]", errorcode, a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ); return false; -- cgit v1.2.3 From 93d29555e58df172bafba530afbc593c16ec66a3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 15:19:48 +0200 Subject: Style: Normalized to no spaces before closing parenthesis. --- src/Bindings/DeprecatedBindings.h | 2 +- src/Bindings/LuaFunctions.h | 2 +- src/Bindings/ManualBindings.cpp | 60 +++++++++--------- src/Bindings/ManualBindings.h | 2 +- src/Bindings/Plugin.h | 4 +- src/Bindings/PluginLua.cpp | 2 +- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 6 +- src/Bindings/PluginManager.h | 2 +- src/Bindings/WebPlugin.cpp | 14 ++--- src/Bindings/WebPlugin.h | 6 +- src/BlockEntities/BeaconEntity.cpp | 2 +- src/BlockEntities/BeaconEntity.h | 2 +- src/BlockEntities/BlockEntity.h | 2 +- src/BlockEntities/CommandBlockEntity.h | 4 +- src/BlockEntities/FlowerPotEntity.h | 4 +- src/BlockEntities/FurnaceEntity.cpp | 2 +- src/BlockEntities/MobHeadEntity.h | 4 +- src/BlockEntities/SignEntity.h | 4 +- src/Blocks/BlockBed.cpp | 4 +- src/Blocks/BlockHandler.cpp | 4 +- src/Blocks/BlockTorch.h | 4 +- src/Blocks/BlockVine.h | 2 +- src/Blocks/BroadcastInterface.h | 2 +- src/Blocks/ChunkInterface.h | 4 +- src/ChatColor.h | 4 +- src/Chunk.cpp | 86 +++++++++++++------------- src/Chunk.h | 12 ++-- src/ChunkDef.h | 8 +-- src/ChunkMap.cpp | 72 +++++++++++----------- src/ChunkMap.h | 8 +-- src/ChunkSender.h | 2 +- src/ClientHandle.cpp | 6 +- src/ClientHandle.h | 6 +- src/CraftingRecipes.cpp | 2 +- src/Cuboid.h | 4 +- src/Defines.h | 18 +++--- src/Enchantments.h | 2 +- src/Endianness.h | 10 +-- src/Entities/Entity.cpp | 4 +- src/Entities/ExpOrb.cpp | 6 +- src/Entities/Player.cpp | 108 ++++++++++++++++----------------- src/Entities/Player.h | 14 ++--- src/FurnaceRecipe.cpp | 2 +- src/Generating/Caves.cpp | 6 +- src/Generating/ChunkGenerator.cpp | 2 +- src/Generating/FinishGen.cpp | 8 +-- src/Generating/HeiGen.cpp | 2 +- src/Globals.h | 8 +-- src/Group.cpp | 10 +-- src/Group.h | 10 +-- src/GroupManager.cpp | 16 ++--- src/HTTPServer/HTTPConnection.cpp | 2 +- src/Inventory.cpp | 16 ++--- src/Inventory.h | 2 +- src/Item.cpp | 6 +- src/Items/ItemFood.h | 2 +- src/Items/ItemHandler.cpp | 2 +- src/Items/ItemPickaxe.h | 4 +- src/Log.cpp | 28 ++++----- src/MCLogger.cpp | 8 +-- src/MobSpawner.cpp | 2 +- src/Mobs/SnowGolem.cpp | 2 +- src/MonsterConfig.cpp | 2 +- src/Noise.cpp | 58 +++++++++--------- src/OSSupport/Errors.cpp | 12 ++-- src/OSSupport/Event.cpp | 4 +- src/OSSupport/Semaphore.cpp | 26 ++++---- src/OSSupport/Semaphore.h | 2 +- src/OSSupport/Sleep.cpp | 2 +- src/OSSupport/Sleep.h | 2 +- src/OSSupport/Thread.cpp | 32 +++++----- src/OSSupport/Thread.h | 8 +-- src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.cpp | 8 +-- src/Protocol/Protocol125.h | 4 +- src/Protocol/Protocol132.cpp | 2 +- src/Protocol/Protocol17x.h | 2 +- src/Protocol/ProtocolRecognizer.cpp | 2 +- src/Protocol/ProtocolRecognizer.h | 2 +- src/Root.cpp | 24 ++++---- src/Server.cpp | 4 +- src/Simulator/NoopRedstoneSimulator.h | 2 +- src/Simulator/SimulatorManager.cpp | 6 +- src/Tracer.cpp | 64 +++++++++---------- src/Tracer.h | 6 +- src/UI/Window.cpp | 4 +- src/UI/Window.h | 4 +- src/WebAdmin.cpp | 6 +- src/World.cpp | 2 +- src/World.h | 8 +-- src/WorldStorage/WSSCompact.cpp | 108 +++++++++++++++++---------------- src/WorldStorage/WorldStorage.cpp | 2 +- src/main.cpp | 10 +-- 94 files changed, 541 insertions(+), 535 deletions(-) (limited to 'src') diff --git a/src/Bindings/DeprecatedBindings.h b/src/Bindings/DeprecatedBindings.h index 5fc3cfa80..037d50489 100644 --- a/src/Bindings/DeprecatedBindings.h +++ b/src/Bindings/DeprecatedBindings.h @@ -4,5 +4,5 @@ struct lua_State; class DeprecatedBindings { public: - static void Bind( lua_State* tolua_S ); + static void Bind( lua_State* tolua_S); }; diff --git a/src/Bindings/LuaFunctions.h b/src/Bindings/LuaFunctions.h index 629e2d77d..2ea37d7a4 100644 --- a/src/Bindings/LuaFunctions.h +++ b/src/Bindings/LuaFunctions.h @@ -9,7 +9,7 @@ inline unsigned int GetTime() return (unsigned int)time(0); } -inline std::string GetChar( std::string & a_Str, unsigned int a_Idx ) +inline std::string GetChar( std::string & a_Str, unsigned int a_Idx) { return std::string(1, a_Str[ a_Idx ]); } diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 5e9e7349d..df9687fc0 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -319,9 +319,9 @@ static int tolua_DoWith(lua_State* tolua_S) { public: cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef) - : LuaState( a_LuaState ) - , FuncRef( a_FuncRef ) - , TableRef( a_TableRef ) + : LuaState( a_LuaState) + , FuncRef( a_FuncRef) + , TableRef( a_TableRef) {} private: @@ -358,7 +358,7 @@ static int tolua_DoWith(lua_State* tolua_S) luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef); /* Push return value on stack */ - tolua_pushboolean(tolua_S, bRetVal ); + tolua_pushboolean(tolua_S, bRetVal); return 1; } @@ -448,7 +448,7 @@ static int tolua_DoWithID(lua_State* tolua_S) luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef); /* Push return value on stack */ - tolua_pushboolean(tolua_S, bRetVal ); + tolua_pushboolean(tolua_S, bRetVal); return 1; } @@ -478,7 +478,7 @@ static int tolua_DoWithXYZ(lua_State* tolua_S) int ItemX = ((int)tolua_tonumber(tolua_S, 2, 0)); int ItemY = ((int)tolua_tonumber(tolua_S, 3, 0)); int ItemZ = ((int)tolua_tonumber(tolua_S, 4, 0)); - LOG("x %i y %i z %i", ItemX, ItemY, ItemZ ); + LOG("x %i y %i z %i", ItemX, ItemY, ItemZ); if (!lua_isfunction( tolua_S, 5)) { return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a function for parameter #4"); @@ -506,9 +506,9 @@ static int tolua_DoWithXYZ(lua_State* tolua_S) { public: cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef) - : LuaState( a_LuaState ) - , FuncRef( a_FuncRef ) - , TableRef( a_TableRef ) + : LuaState( a_LuaState) + , FuncRef( a_FuncRef) + , TableRef( a_TableRef) {} private: @@ -544,7 +544,7 @@ static int tolua_DoWithXYZ(lua_State* tolua_S) luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef); /* Push return value on stack */ - tolua_pushboolean(tolua_S, bRetVal ); + tolua_pushboolean(tolua_S, bRetVal); return 1; } @@ -601,9 +601,9 @@ static int tolua_ForEachInChunk(lua_State * tolua_S) { public: cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef) - : LuaState( a_LuaState ) - , FuncRef( a_FuncRef ) - , TableRef( a_TableRef ) + : LuaState( a_LuaState) + , FuncRef( a_FuncRef) + , TableRef( a_TableRef) {} private: @@ -640,7 +640,7 @@ static int tolua_ForEachInChunk(lua_State * tolua_S) luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef); /* Push return value on stack */ - tolua_pushboolean(tolua_S, bRetVal ); + tolua_pushboolean(tolua_S, bRetVal); return 1; } @@ -694,16 +694,16 @@ static int tolua_ForEach(lua_State * tolua_S) { public: cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef) - : LuaState( a_LuaState ) - , FuncRef( a_FuncRef ) - , TableRef( a_TableRef ) + : LuaState( a_LuaState) + , FuncRef( a_FuncRef) + , TableRef( a_TableRef) {} private: virtual bool Item(Ty2 * a_Item) override { lua_rawgeti( LuaState, LUA_REGISTRYINDEX, FuncRef); /* Push function reference */ - tolua_pushusertype( LuaState, a_Item, Ty2::GetClassStatic() ); + tolua_pushusertype( LuaState, a_Item, Ty2::GetClassStatic()); if (TableRef != LUA_REFNIL) { lua_rawgeti( LuaState, LUA_REGISTRYINDEX, TableRef); /* Push table reference */ @@ -733,7 +733,7 @@ static int tolua_ForEach(lua_State * tolua_S) luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef); /* Push return value on stack */ - tolua_pushboolean(tolua_S, bRetVal ); + tolua_pushboolean(tolua_S, bRetVal); return 1; } @@ -1390,8 +1390,8 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S) { public: cLuaCallback(lua_State * a_LuaState, int a_FuncRef) - : LuaState( a_LuaState ) - , FuncRef( a_FuncRef ) + : LuaState( a_LuaState) + , FuncRef( a_FuncRef) {} private: @@ -1467,8 +1467,8 @@ static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S) { public: cLuaCallback(lua_State * a_LuaState, int a_FuncRef) - : LuaState( a_LuaState ) - , FuncRef( a_FuncRef ) + : LuaState( a_LuaState) + , FuncRef( a_FuncRef) {} private: @@ -1963,7 +1963,7 @@ static int tolua_cPluginLua_AddTab(lua_State* tolua_S) LOGWARN("WARNING: Using deprecated function AddTab()! Use AddWebTab() instead. (plugin \"%s\" in folder \"%s\")", self->GetName().c_str(), self->GetDirectory().c_str() ); - return tolua_cPluginLua_AddWebTab( tolua_S ); + return tolua_cPluginLua_AddWebTab( tolua_S); } @@ -2011,7 +2011,7 @@ static int tolua_md5(lua_State* tolua_S) -static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string, std::string >& a_StringStringMap ) +static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string, std::string >& a_StringStringMap) { lua_newtable(tolua_S); int top = lua_gettop(tolua_S); @@ -2062,9 +2062,9 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S) for (std::map::iterator it = FormData.begin(); it != FormData.end(); ++it) { - lua_pushstring(tolua_S, it->first.c_str() ); - tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData" ); - // lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size() ); // Might contain binary data + lua_pushstring(tolua_S, it->first.c_str()); + tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData"); + // lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size()); // Might contain binary data lua_settable(tolua_S, top); } @@ -2113,8 +2113,8 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S) { const AString & FancyName = iter->first; const AString & WebName = iter->second; - tolua_pushstring( tolua_S, WebName.c_str() ); // Because the WebName is supposed to be unique, use it as key - tolua_pushstring( tolua_S, FancyName.c_str() ); + tolua_pushstring( tolua_S, WebName.c_str()); // Because the WebName is supposed to be unique, use it as key + tolua_pushstring( tolua_S, FancyName.c_str()); // lua_rawset(tolua_S, -3); ++iter; diff --git a/src/Bindings/ManualBindings.h b/src/Bindings/ManualBindings.h index f38e26267..36161c6a2 100644 --- a/src/Bindings/ManualBindings.h +++ b/src/Bindings/ManualBindings.h @@ -4,5 +4,5 @@ struct lua_State; class ManualBindings { public: - static void Bind( lua_State* tolua_S ); + static void Bind( lua_State* tolua_S); }; diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index fc8aa1cdb..3882b7474 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -33,7 +33,7 @@ class cPlugin public: // tolua_end - cPlugin( const AString & a_PluginDirectory ); + cPlugin( const AString & a_PluginDirectory); virtual ~cPlugin(); virtual void OnDisable(void) {} @@ -141,7 +141,7 @@ public: E_SQUIRREL, // OBSOLETE, but kept in place to remind us of the horrors lurking in the history }; PluginLanguage GetLanguage() { return m_Language; } - void SetLanguage( PluginLanguage a_Language ) { m_Language = a_Language; } + void SetLanguage( PluginLanguage a_Language) { m_Language = a_Language; } private: PluginLanguage m_Language; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 5fa8adc66..0f3f25d75 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -1655,7 +1655,7 @@ int cPluginLua::CallFunctionFromForeignState( -AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request ) +AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request) { cCSLock Lock(m_CriticalSection); std::string RetVal = ""; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index b2979a210..2cea644c1 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -144,7 +144,7 @@ public: virtual const AString GetWebTitle(void) const {return GetName(); } // cWebPlugin and WebAdmin stuff - virtual AString HandleWebRequest(const HTTPRequest * a_Request ) override; + virtual AString HandleWebRequest(const HTTPRequest * a_Request) override; bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // >> EXPORTED IN MANUALBINDINGS << /** Binds the command to call the function specified by a Lua function reference. Simply adds to CommandMap. */ diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 33ecb95ad..088b92a6d 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -72,7 +72,7 @@ void cPluginManager::FindPlugins(void) { PluginMap::iterator thiz = itr; ++thiz; - m_Plugins.erase( itr ); + m_Plugins.erase( itr); itr = thiz; continue; } @@ -1432,11 +1432,11 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player, -cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin ) const +cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin) const { for (PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr) { - if (itr->second == NULL ) continue; + if (itr->second == NULL) continue; if (itr->second->GetName().compare(a_Plugin) == 0) { return itr->second; diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index cffd8d04b..44a94e316 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -163,7 +163,7 @@ public: typedef std::map< AString, cPlugin * > PluginMap; typedef std::list< cPlugin * > PluginList; - cPlugin * GetPlugin( const AString & a_Plugin ) const; // tolua_export + cPlugin * GetPlugin( const AString & a_Plugin) const; // tolua_export const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS << // tolua_begin diff --git a/src/Bindings/WebPlugin.cpp b/src/Bindings/WebPlugin.cpp index a22826d1b..1178c127a 100644 --- a/src/Bindings/WebPlugin.cpp +++ b/src/Bindings/WebPlugin.cpp @@ -45,12 +45,12 @@ cWebPlugin::~cWebPlugin() std::list > cWebPlugin::GetTabNames(void) { std::list< std::pair< AString, AString > > NameList; - for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) + for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr) { std::pair< AString, AString > StringPair; StringPair.first = (*itr)->Title; StringPair.second = (*itr)->SafeTitle; - NameList.push_back( StringPair ); + NameList.push_back( StringPair); } return NameList; } @@ -69,7 +69,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest sWebPluginTab * Tab = NULL; if (Split.size() > 2) // If we got the tab name, show that page { - for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) + for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr) { if ((*itr)->SafeTitle.compare(Split[2]) == 0) // This is the one! { @@ -80,7 +80,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest } else // Otherwise show the first tab { - if (GetTabs().size() > 0 ) + if (GetTabs().size() > 0) Tab = *GetTabs().begin(); } @@ -100,14 +100,14 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest AString cWebPlugin::SafeString(const AString & a_String) { AString RetVal; - for (unsigned int i = 0; i < a_String.size(); ++i ) + for (unsigned int i = 0; i < a_String.size(); ++i) { char c = a_String[i]; - if (c == ' ' ) + if (c == ' ') { c = '_'; } - RetVal.push_back( c ); + RetVal.push_back( c); } return RetVal; } diff --git a/src/Bindings/WebPlugin.h b/src/Bindings/WebPlugin.h index 3587ac637..46bc0cd2d 100644 --- a/src/Bindings/WebPlugin.h +++ b/src/Bindings/WebPlugin.h @@ -19,9 +19,9 @@ public: // tolua_begin virtual const AString GetWebTitle(void) const = 0; - virtual AString HandleWebRequest(const HTTPRequest * a_Request ) = 0; + virtual AString HandleWebRequest(const HTTPRequest * a_Request) = 0; - static AString SafeString( const AString & a_String ); + static AString SafeString( const AString & a_String); // tolua_end struct sWebPluginTab @@ -37,7 +37,7 @@ public: typedef std::list< std::pair > TabNameList; TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS << - std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request ); + std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request); private: TabList m_Tabs; diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index 9a6d85f1d..4b9662797 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -66,7 +66,7 @@ int cBeaconEntity::GetPyramidLevel(void) bool cBeaconEntity::IsMineralBlock(BLOCKTYPE a_BlockType) { - switch(a_BlockType) + switch (a_BlockType) { case E_BLOCK_DIAMOND_BLOCK: case E_BLOCK_GOLD_BLOCK: diff --git a/src/BlockEntities/BeaconEntity.h b/src/BlockEntities/BeaconEntity.h index b1df68bc4..ee1eda391 100644 --- a/src/BlockEntities/BeaconEntity.h +++ b/src/BlockEntities/BeaconEntity.h @@ -33,7 +33,7 @@ public: static bool IsMineralBlock(BLOCKTYPE a_BlockType); // cBlockEntity overrides: - virtual void SaveToJson(Json::Value& a_Value ) override; + virtual void SaveToJson(Json::Value& a_Value) override; virtual void SendTo(cClientHandle & a_Client) override; virtual void UsedBy(cPlayer * a_Player) override; virtual bool Tick(float a_Dt, cChunk & /* a_Chunk */) override; diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h index 7c6688f8d..24c25e729 100644 --- a/src/BlockEntities/BlockEntity.h +++ b/src/BlockEntities/BlockEntity.h @@ -79,7 +79,7 @@ public: virtual void SaveToJson (Json::Value & a_Value) = 0; /// Called when a player uses this entity; should open the UI window - virtual void UsedBy( cPlayer * a_Player ) = 0; + virtual void UsedBy( cPlayer * a_Player) = 0; /** Sends the packet defining the block entity to the client specified. To send to all eligible clients, use cWorld::BroadcastBlockEntity() diff --git a/src/BlockEntities/CommandBlockEntity.h b/src/BlockEntities/CommandBlockEntity.h index d7c4eaabe..d02bf7d7b 100644 --- a/src/BlockEntities/CommandBlockEntity.h +++ b/src/BlockEntities/CommandBlockEntity.h @@ -38,8 +38,8 @@ public: /// Creates a new empty command block entity cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World); - bool LoadFromJson( const Json::Value& a_Value ); - virtual void SaveToJson(Json::Value& a_Value ) override; + bool LoadFromJson( const Json::Value& a_Value); + virtual void SaveToJson(Json::Value& a_Value) override; virtual bool Tick(float a_Dt, cChunk & a_Chunk) override; virtual void SendTo(cClientHandle & a_Client) override; diff --git a/src/BlockEntities/FlowerPotEntity.h b/src/BlockEntities/FlowerPotEntity.h index 85cb810ad..89901cf2d 100644 --- a/src/BlockEntities/FlowerPotEntity.h +++ b/src/BlockEntities/FlowerPotEntity.h @@ -39,8 +39,8 @@ public: /** Creates a new flowerpot entity at the specified block coords. a_World may be NULL */ cFlowerPotEntity(int a_BlocX, int a_BlockY, int a_BlockZ, cWorld * a_World); - bool LoadFromJson( const Json::Value& a_Value ); - virtual void SaveToJson(Json::Value& a_Value ) override; + bool LoadFromJson( const Json::Value& a_Value); + virtual void SaveToJson(Json::Value& a_Value) override; virtual void Destroy(void) override; diff --git a/src/BlockEntities/FurnaceEntity.cpp b/src/BlockEntities/FurnaceEntity.cpp index 1b1741713..72fd7f2b3 100644 --- a/src/BlockEntities/FurnaceEntity.cpp +++ b/src/BlockEntities/FurnaceEntity.cpp @@ -160,7 +160,7 @@ bool cFurnaceEntity::LoadFromJson(const Json::Value & a_Value) -void cFurnaceEntity::SaveToJson( Json::Value& a_Value ) +void cFurnaceEntity::SaveToJson( Json::Value& a_Value) { a_Value["x"] = m_PosX; a_Value["y"] = m_PosY; diff --git a/src/BlockEntities/MobHeadEntity.h b/src/BlockEntities/MobHeadEntity.h index 2bc072d69..f91a3cc9e 100644 --- a/src/BlockEntities/MobHeadEntity.h +++ b/src/BlockEntities/MobHeadEntity.h @@ -37,8 +37,8 @@ public: /** Creates a new mob head entity at the specified block coords. a_World may be NULL */ cMobHeadEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); - bool LoadFromJson( const Json::Value& a_Value ); - virtual void SaveToJson(Json::Value& a_Value ) override; + bool LoadFromJson( const Json::Value& a_Value); + virtual void SaveToJson(Json::Value& a_Value) override; // tolua_begin diff --git a/src/BlockEntities/SignEntity.h b/src/BlockEntities/SignEntity.h index 16e0e23bc..33af100a4 100644 --- a/src/BlockEntities/SignEntity.h +++ b/src/BlockEntities/SignEntity.h @@ -37,8 +37,8 @@ public: /// Creates a new empty sign entity at the specified block coords and block type (wall or standing). a_World may be NULL cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World); - bool LoadFromJson( const Json::Value& a_Value ); - virtual void SaveToJson(Json::Value& a_Value ) override; + bool LoadFromJson( const Json::Value& a_Value); + virtual void SaveToJson(Json::Value& a_Value) override; // tolua_begin diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index fbc82b440..80ac18560 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -27,8 +27,8 @@ void cBlockBedHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInt { NIBBLETYPE OldMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ ); - Vector3i Direction = MetaDataToDirection( OldMeta & 0x7 ); + Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ); + Vector3i Direction = MetaDataToDirection( OldMeta & 0x7); if (OldMeta & 0x8) { // Was pillow diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 8ab4116f4..b6ef23cb9 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -175,7 +175,7 @@ public: cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) { - switch(a_BlockType) + switch (a_BlockType) { // Block handlers, alphabetically sorted: case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); @@ -254,7 +254,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType); case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType); case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType); - case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler ( ); + case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler; case E_BLOCK_PLANKS: return new cBlockPlanksHandler (a_BlockType); case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType); case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType); diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index b62268187..c73118870 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -99,7 +99,7 @@ public: static bool CanBePlacedOn(BLOCKTYPE a_BlockType, eBlockFace a_BlockFace) { - if (!cBlockInfo::FullyOccupiesVoxel(a_BlockType) ) + if (!cBlockInfo::FullyOccupiesVoxel(a_BlockType)) { return (a_BlockFace == BLOCK_FACE_TOP); // Allow placement only when torch upright (for glass, etc.); exceptions won't even be sent by client, no need to handle } @@ -168,7 +168,7 @@ public: // No need to check for upright orientation, it was done when the torch was placed return true; } - else if (!cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) ) + else if (!cBlockInfo::FullyOccupiesVoxel(BlockInQuestion)) { return false; } diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h index c2d82eb4d..61092af3e 100644 --- a/src/Blocks/BlockVine.h +++ b/src/Blocks/BlockVine.h @@ -59,7 +59,7 @@ public: static char MetaDataToDirection(NIBBLETYPE a_MetaData) { - switch(a_MetaData) + switch (a_MetaData) { case 0x1: return BLOCK_FACE_NORTH; case 0x4: return BLOCK_FACE_SOUTH; diff --git a/src/Blocks/BroadcastInterface.h b/src/Blocks/BroadcastInterface.h index c8593c76a..cf332b153 100644 --- a/src/Blocks/BroadcastInterface.h +++ b/src/Blocks/BroadcastInterface.h @@ -6,7 +6,7 @@ class cBroadcastInterface public: virtual ~cBroadcastInterface() {} - virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) = 0; + virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) = 0; virtual void BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL) = 0; virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) = 0; }; diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h index 3bab60be6..dea9d7c7e 100644 --- a/src/Blocks/ChunkInterface.h +++ b/src/Blocks/ChunkInterface.h @@ -61,9 +61,9 @@ public: m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); } - void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) + void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { - FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta ); + FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta); } void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) diff --git a/src/ChatColor.h b/src/ChatColor.h index 74eb7d5dc..21377e27f 100644 --- a/src/ChatColor.h +++ b/src/ChatColor.h @@ -31,14 +31,14 @@ public: static const char * Yellow; static const char * White; - // Styles ( source: http://wiki.vg/Chat ) + // Styles + // source: http://wiki.vg/Chat static const char * Random; static const char * Bold; static const char * Strikethrough; static const char * Underlined; static const char * Italic; static const char * Plain; - }; // tolua_end diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 25a58458e..60987b070 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -44,12 +44,12 @@ //////////////////////////////////////////////////////////////////////////////// // sSetBlock: -sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) // absolute block position - : x( a_BlockX ) - , y( a_BlockY ) - , z( a_BlockZ ) - , BlockType( a_BlockType ) - , BlockMeta( a_BlockMeta ) +sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) // absolute block position + : x( a_BlockX) + , y( a_BlockY) + , z( a_BlockZ) + , BlockType( a_BlockType) + , BlockMeta( a_BlockMeta) { cChunkDef::AbsoluteToRelative(x, y, z, ChunkX, ChunkZ); } @@ -116,7 +116,7 @@ cChunk::~cChunk() { cPluginManager::Get()->CallHookChunkUnloaded(m_World, m_PosX, m_PosZ); - // LOGINFO("### delete cChunk() (%i, %i) from %p, thread 0x%x ###", m_PosX, m_PosZ, this, GetCurrentThreadId() ); + // LOGINFO("### delete cChunk() (%i, %i) from %p, thread 0x%x ###", m_PosX, m_PosZ, this, GetCurrentThreadId()); for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr) { @@ -781,7 +781,7 @@ void cChunk::CheckBlocks() void cChunk::TickBlocks(void) { // Tick dem blocks - // _X: We must limit the random number or else we get a nasty int overflow bug ( http://forum.mc-server.org/showthread.php?tid=457 ) + // _X: We must limit the random number or else we get a nasty int overflow bug - http://forum.mc-server.org/showthread.php?tid=457 int RandomX = m_World->GetTickRandomNumber(0x00ffffff); int RandomY = m_World->GetTickRandomNumber(0x00ffffff); int RandomZ = m_World->GetTickRandomNumber(0x00ffffff); @@ -1394,7 +1394,7 @@ void cChunk::CalculateHeightmap(const BLOCKTYPE * a_BlockTypes) { for (int y = Height - 1; y > -1; y--) { - int index = MakeIndex( x, y, z ); + int index = MakeIndex( x, y, z); if (a_BlockTypes[index] != E_BLOCK_AIR) { m_HeightMap[x + z * Width] = (HEIGHTTYPE)y; @@ -1730,9 +1730,9 @@ void cChunk::CollectPickupsByPlayer(cPlayer * a_Player) { continue; // Only pickups and projectiles can be picked up } - float DiffX = (float)((*itr)->GetPosX() - PosX ); - float DiffY = (float)((*itr)->GetPosY() - PosY ); - float DiffZ = (float)((*itr)->GetPosZ() - PosZ ); + float DiffX = (float)((*itr)->GetPosX() - PosX); + float DiffY = (float)((*itr)->GetPosY() - PosY); + float DiffZ = (float)((*itr)->GetPosZ() - PosZ); float SqrDist = DiffX * DiffX + DiffY * DiffY + DiffZ * DiffZ; if (SqrDist < 1.5f * 1.5f) // 1.5 block { @@ -1794,7 +1794,7 @@ bool cChunk::SetSignLines(int a_PosX, int a_PosY, int a_PosZ, const AString & a_ -void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity ) +void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity) { MarkDirty(); m_BlockEntities.remove(a_BlockEntity); @@ -1814,9 +1814,9 @@ bool cChunk::AddClient(cClientHandle* a_Client) return false; } } - m_LoadedByClient.push_back( a_Client ); + m_LoadedByClient.push_back( a_Client); - for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr ) + for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) { /* // DEBUG: @@ -1835,7 +1835,7 @@ bool cChunk::AddClient(cClientHandle* a_Client) -void cChunk::RemoveClient( cClientHandle* a_Client ) +void cChunk::RemoveClient( cClientHandle* a_Client) { for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { @@ -1848,7 +1848,7 @@ void cChunk::RemoveClient( cClientHandle* a_Client ) if (!a_Client->IsDestroyed()) { - for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr ) + for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) { /* // DEBUG: @@ -1868,7 +1868,7 @@ void cChunk::RemoveClient( cClientHandle* a_Client ) -bool cChunk::HasClient( cClientHandle* a_Client ) +bool cChunk::HasClient( cClientHandle* a_Client) { for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { @@ -2653,7 +2653,7 @@ cChunk * cChunk::GetRelNeighborChunkAdjustCoords(int & a_RelX, int & a_RelZ) con void cChunk::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { (*itr)->SendAttachEntity(a_Entity, a_Vehicle); } // for itr - LoadedByClient[] @@ -2665,7 +2665,7 @@ void cChunk::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_V void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2681,7 +2681,7 @@ void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char void cChunk::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2703,7 +2703,7 @@ void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cons { return; } - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2719,7 +2719,7 @@ void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cons void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2735,7 +2735,7 @@ void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClie void cChunk::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2751,7 +2751,7 @@ void cChunk::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_ void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2767,7 +2767,7 @@ void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandl void cChunk::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2783,7 +2783,7 @@ void cChunk::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2799,7 +2799,7 @@ void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, void cChunk::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2815,7 +2815,7 @@ void cChunk::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHand void cChunk::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2831,7 +2831,7 @@ void cChunk::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * void cChunk::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2847,7 +2847,7 @@ void cChunk::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHand void cChunk::BroadcastEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2863,7 +2863,7 @@ void cChunk::BroadcastEntityRelMove(const cEntity & a_Entity, char a_RelX, char void cChunk::BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2879,7 +2879,7 @@ void cChunk::BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, c void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2895,7 +2895,7 @@ void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, cons void cChunk::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2911,7 +2911,7 @@ void cChunk::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHand void cChunk::BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2927,7 +2927,7 @@ void cChunk::BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation void cChunk::BroadcastParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2943,7 +2943,7 @@ void cChunk::BroadcastParticleEffect(const AString & a_ParticleName, float a_Src void cChunk::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2959,7 +2959,7 @@ void cChunk::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectI void cChunk::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2975,7 +2975,7 @@ void cChunk::BroadcastSoundEffect(const AString & a_SoundName, double a_X, doubl void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2991,7 +2991,7 @@ void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY void cChunk::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -3007,7 +3007,7 @@ void cChunk::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Ex void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -3021,9 +3021,9 @@ void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, cons -void cChunk::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) +void cChunk::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { (*itr)->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ); } // for itr - LoadedByClient[] diff --git a/src/Chunk.h b/src/Chunk.h index 2e2895c6e..9ab39a0a2 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -82,9 +82,9 @@ public: /* To save a chunk, the WSSchema must: - 1. Mark the chunk as being saved (MarkSaving() ) + 1. Mark the chunk as being saved (MarkSaving()) 2. Get the chunk's data using GetAllData() - 3. Mark the chunk as saved (MarkSaved() ) + 3. Mark the chunk as saved (MarkSaved()) If anywhere inside this sequence another thread mmodifies the chunk, the chunk will not get marked as saved in MarkSaved() */ void MarkSaving(void); // Marks the chunk as being saved. @@ -144,7 +144,7 @@ public: void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true); // SetBlock() does a lot of work (heightmap, tickblocks, blockentities) so a BlockIdx version doesn't make sense - void SetBlock( const Vector3i & a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) { SetBlock( a_RelBlockPos.x, a_RelBlockPos.y, a_RelBlockPos.z, a_BlockType, a_BlockMeta ); } + void SetBlock( const Vector3i & a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { SetBlock( a_RelBlockPos.x, a_RelBlockPos.y, a_RelBlockPos.z, a_BlockType, a_BlockMeta); } /** Queues a block change till the specified world tick */ void QueueSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType = E_BLOCK_AIR); @@ -195,7 +195,7 @@ public: /** Sets the sign text. Returns true if successful. Also sends update packets to all clients in the chunk */ bool SetSignLines(int a_RelX, int a_RelY, int a_RelZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4); - int GetHeight( int a_X, int a_Z ); + int GetHeight( int a_X, int a_Z); void SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client); @@ -301,7 +301,7 @@ public: void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); - void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ); + void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ); void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client); @@ -311,7 +311,7 @@ public: } void PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ, int & a_BlockX, int & a_BlockY, int & a_BlockZ); - Vector3i PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ ); + Vector3i PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ); inline void MarkDirty(void) { diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 334f8a6b9..dbb782d26 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -92,7 +92,7 @@ public: /// Converts absolute block coords into relative (chunk + block) coords: - inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ ) + inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ) { UNUSED(a_Y); BlockToChunk(a_X, a_Z, a_ChunkX, a_ChunkZ); @@ -118,7 +118,7 @@ public: } - inline static int MakeIndex(int x, int y, int z ) + inline static int MakeIndex(int x, int y, int z) { if ( (x < Width) && (x > -1) && @@ -145,7 +145,7 @@ public: } - inline static Vector3i IndexToCoordinate( unsigned int index ) + inline static Vector3i IndexToCoordinate( unsigned int index) { #if AXIS_ORDER == AXIS_ORDER_XZY return Vector3i( // 1.2 @@ -357,7 +357,7 @@ struct sSetBlock BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; - sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ); // absolute block position + sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // absolute block position sSetBlock(int a_ChunkX, int a_ChunkZ, int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) : x(a_X), y(a_Y), z(a_Z), ChunkX(a_ChunkX), ChunkZ(a_ChunkZ), diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 49e9245d2..3ef981e94 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -64,7 +64,7 @@ cChunkMap::~cChunkMap() -void cChunkMap::RemoveLayer( cChunkLayer* a_Layer ) +void cChunkMap::RemoveLayer( cChunkLayer* a_Layer) { cCSLock Lock(m_CSLayers); m_Layers.remove(a_Layer); @@ -147,7 +147,7 @@ cChunkPtr cChunkMap::GetChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) // No need to lock m_CSLayers, since it's already locked by the operation that called us ASSERT(m_CSLayers.IsLockedByCurrentThread()); - cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ ); + cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ); if (Layer == NULL) { // An error must have occurred, since layers are automatically created if they don't exist @@ -170,10 +170,10 @@ cChunkPtr cChunkMap::GetChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) -cChunkPtr cChunkMap::GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ ) +cChunkPtr cChunkMap::GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ) { // No need to lock m_CSLayers, since it's already locked by the operation that called us - cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ ); + cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ); if (Layer == NULL) { // An error must have occurred, since layers are automatically created if they don't exist @@ -197,10 +197,10 @@ cChunkPtr cChunkMap::GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ ) -cChunkPtr cChunkMap::GetChunkNoLoad( int a_ChunkX, int a_ChunkY, int a_ChunkZ ) +cChunkPtr cChunkMap::GetChunkNoLoad( int a_ChunkX, int a_ChunkY, int a_ChunkZ) { // No need to lock m_CSLayers, since it's already locked by the operation that called us - cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ ); + cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ); if (Layer == NULL) { // An error must have occurred, since layers are automatically created if they don't exist @@ -720,7 +720,7 @@ void cChunkMap::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, c -void cChunkMap::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) +void cChunkMap::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) { cCSLock Lock(m_CSLayers); int ChunkX, ChunkZ; @@ -1154,9 +1154,9 @@ void cChunkMap::CollectPickupsByPlayer(cPlayer * a_Player) GetChunkNoLoad(ChunkX, ChunkY, ChunkZ)->CollectPickupsByPlayer(a_Player); // Check the neighboring chunks as well: - GetChunkNoLoad(OtherChunkX, ChunkY, ChunkZ )->CollectPickupsByPlayer(a_Player); + GetChunkNoLoad(OtherChunkX, ChunkY, ChunkZ)->CollectPickupsByPlayer (a_Player); GetChunkNoLoad(OtherChunkX, ChunkY, OtherChunkZ)->CollectPickupsByPlayer(a_Player); - GetChunkNoLoad(ChunkX, ChunkY, ChunkZ )->CollectPickupsByPlayer(a_Player); + GetChunkNoLoad(ChunkX, ChunkY, ChunkZ)->CollectPickupsByPlayer (a_Player); GetChunkNoLoad(ChunkX, ChunkY, OtherChunkZ)->CollectPickupsByPlayer(a_Player); } @@ -1181,7 +1181,7 @@ BLOCKTYPE cChunkMap::GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ) } // for itr - m_FastSetBlockQueue[] } int ChunkX, ChunkZ; - cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); cChunkPtr Chunk = GetChunk(ChunkX, ZERO_CHUNK_Y, ChunkZ); @@ -1210,11 +1210,11 @@ NIBBLETYPE cChunkMap::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ) } // for itr - m_FastSetBlockQueue[] } int ChunkX, ChunkZ; - cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); - if ((Chunk != NULL) && Chunk->IsValid() ) + cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); + if ((Chunk != NULL) && Chunk->IsValid()) { return Chunk->GetMeta(a_BlockX, a_BlockY, a_BlockZ); } @@ -1228,11 +1228,11 @@ NIBBLETYPE cChunkMap::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ) NIBBLETYPE cChunkMap::GetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ) { int ChunkX, ChunkZ; - cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); - if ((Chunk != NULL) && Chunk->IsValid() ) + cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); + if ((Chunk != NULL) && Chunk->IsValid()) { return Chunk->GetSkyLight(a_BlockX, a_BlockY, a_BlockZ); } @@ -1246,11 +1246,11 @@ NIBBLETYPE cChunkMap::GetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ) NIBBLETYPE cChunkMap::GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ) { int ChunkX, ChunkZ; - cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); - if ((Chunk != NULL) && Chunk->IsValid() ) + cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); + if ((Chunk != NULL) && Chunk->IsValid()) { return Chunk->GetBlockLight(a_BlockX, a_BlockY, a_BlockZ); } @@ -1288,10 +1288,10 @@ void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a } int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ; - cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); + cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); if ((Chunk != NULL) && Chunk->IsValid()) { Chunk->SetBlock(X, Y, Z, a_BlockType, a_BlockMeta, a_SendToClients); @@ -1324,10 +1324,10 @@ void cChunkMap::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYP bool cChunkMap::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) { int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ; - cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); + cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); if ((Chunk != NULL) && Chunk->IsValid()) { Chunk->GetBlockTypeMeta(X, Y, Z, a_BlockType, a_BlockMeta); @@ -1343,10 +1343,10 @@ bool cChunkMap::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCK bool cChunkMap::GetBlockInfo(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight) { int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ; - cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); + cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); if ((Chunk != NULL) && Chunk->IsValid()) { Chunk->GetBlockInfo(X, Y, Z, a_BlockType, a_Meta, a_SkyLight, a_BlockLight); @@ -1364,7 +1364,7 @@ void cChunkMap::ReplaceBlocks(const sSetBlockVector & a_Blocks, BLOCKTYPE a_Filt cCSLock Lock(m_CSLayers); for (sSetBlockVector::const_iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr) { - cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ ); + cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ); if ((Chunk == NULL) || !Chunk->IsValid()) { continue; @@ -1385,7 +1385,7 @@ void cChunkMap::ReplaceTreeBlocks(const sSetBlockVector & a_Blocks) cCSLock Lock(m_CSLayers); for (sSetBlockVector::const_iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr) { - cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ ); + cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ); if ((Chunk == NULL) || !Chunk->IsValid()) { continue; @@ -1498,7 +1498,7 @@ bool cChunkMap::GetBlocks(sSetBlockVector & a_Blocks, bool a_ContinueOnFailure) cCSLock Lock(m_CSLayers); for (sSetBlockVector::iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr) { - cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ ); + cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ); if ((Chunk == NULL) || !Chunk->IsValid()) { if (!a_ContinueOnFailure) @@ -1522,17 +1522,17 @@ bool cChunkMap::DigBlock(int a_X, int a_Y, int a_Z) { int PosX = a_X, PosY = a_Y, PosZ = a_Z, ChunkX, ChunkZ; - cChunkDef::AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkZ); { cCSLock Lock(m_CSLayers); - cChunkPtr DestChunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); + cChunkPtr DestChunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); if ((DestChunk == NULL) || !DestChunk->IsValid()) { return false; } - DestChunk->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0 ); + DestChunk->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0); m_World->GetSimulatorManager()->WakeUp(a_X, a_Y, a_Z, DestChunk); } @@ -2715,10 +2715,10 @@ cChunkMap::cChunkLayer::cChunkLayer( cChunkMap * a_Parent, cAllocationPool & a_Pool ) - : m_LayerX( a_LayerX ) - , m_LayerZ( a_LayerZ ) - , m_Parent( a_Parent ) - , m_NumChunksLoaded( 0 ) + : m_LayerX( a_LayerX) + , m_LayerZ( a_LayerZ) + , m_Parent( a_Parent) + , m_NumChunksLoaded( 0) , m_Pool(a_Pool) { memset(m_Chunks, 0, sizeof(m_Chunks)); @@ -2741,7 +2741,7 @@ cChunkMap::cChunkLayer::~cChunkLayer() -cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ ) +cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ) { // Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 0bbd3dab1..4be1a4752 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -60,7 +60,7 @@ public: static const int LAYER_SIZE = 32; - cChunkMap(cWorld* a_World ); + cChunkMap(cWorld* a_World); ~cChunkMap(); // Broadcast respective packets to all clients of the chunk where the event is taking place @@ -89,7 +89,7 @@ public: void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); void BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); - void BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ); + void BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ); /** Sends the block entity, if it is at the coords specified, to a_Client */ void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client); @@ -289,7 +289,7 @@ public: /** Sets the sign text. Returns true if sign text changed. */ bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4); - /** Marks the chunk as being regenerated - all its clients want that chunk again (used by cWorld::RegenerateChunk() ) */ + /** Marks the chunk as being regenerated - all its clients want that chunk again (used by cWorld::RegenerateChunk()) */ void MarkChunkRegenerating(int a_ChunkX, int a_ChunkZ); bool IsChunkLighted(int a_ChunkX, int a_ChunkZ); @@ -368,7 +368,7 @@ private: ~cChunkLayer(); /** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */ - cChunkPtr GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ ); + cChunkPtr GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ); /** Returns the specified chunk, or NULL if not created yet */ cChunk * FindChunk(int a_ChunkX, int a_ChunkZ); diff --git a/src/ChunkSender.h b/src/ChunkSender.h index 095a99380..624a3a0bd 100644 --- a/src/ChunkSender.h +++ b/src/ChunkSender.h @@ -6,7 +6,7 @@ /* The whole thing is a thread that runs in a loop, waiting for either: "finished chunks" (ChunkReady()), or - "chunks to send" (QueueSendChunkTo() ) + "chunks to send" (QueueSendChunkTo()) to come to a queue. And once they do, it requests the chunk data and sends it all away, either broadcasting (ChunkReady), or diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index de4245b40..e4ad218a2 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1170,7 +1170,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e { // Only compare ItemType, not meta (torches have different metas) // The -1 check is there because sometimes the client sends -1 instead of the held item - // ( http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 ) + // Ref.: http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)", m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType ); @@ -2562,7 +2562,7 @@ void cClientHandle::SendUpdateSign( -void cClientHandle::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) +void cClientHandle::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) { m_Protocol->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ); } @@ -2624,7 +2624,7 @@ const AString & cClientHandle::GetUsername(void) const -void cClientHandle::SetUsername( const AString & a_Username ) +void cClientHandle::SetUsername( const AString & a_Username) { m_Username = a_Username; } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 539e24ef6..538ecdad7 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -181,7 +181,7 @@ public: void SendUnloadChunk (int a_ChunkX, int a_ChunkZ); void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity); void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4); - void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ); + void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ); void SendWeather (eWeather a_Weather); void SendWholeInventory (const cWindow & a_Window); void SendWindowClose (const cWindow & a_Window); @@ -190,7 +190,7 @@ public: // tolua_begin const AString & GetUsername(void) const; - void SetUsername( const AString & a_Username ); + void SetUsername( const AString & a_Username); inline short GetPing(void) const { return m_Ping; } @@ -274,7 +274,7 @@ private: /** The type used for storing the names of registered plugin channels. */ typedef std::set cChannels; - /** Number of chunks the player can see in each direction; 4 is the minimum ( http://wiki.vg/Protocol_FAQ#.E2.80.A6all_connecting_clients_spasm_and_jerk_uncontrollably.21 ) */ + /** Number of chunks the player can see in each direction */ int m_ViewDistance; /** Server generates this many chunks AHEAD of player sight. */ diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index 85a373279..1a31a6e90 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -582,7 +582,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::FindRecipe(const cItem * a_Craftin // Get the real bounds of the crafting grid: int GridLeft = MAX_GRID_WIDTH, GridTop = MAX_GRID_HEIGHT; int GridRight = 0, GridBottom = 0; - for (int y = 0; y < a_GridHeight; y++ ) for (int x = 0; x < a_GridWidth; x++) + for (int y = 0; y < a_GridHeight; y++) for (int x = 0; x < a_GridWidth; x++) { if (!a_CraftingGrid[x + y * a_GridWidth].IsEmpty()) { diff --git a/src/Cuboid.h b/src/Cuboid.h index 7bdb21b00..d62cf8063 100644 --- a/src/Cuboid.h +++ b/src/Cuboid.h @@ -15,7 +15,7 @@ public: Vector3i p1, p2; cCuboid(void) {} - cCuboid(const cCuboid & a_Cuboid ) : p1(a_Cuboid.p1), p2(a_Cuboid.p2) {} + cCuboid(const cCuboid & a_Cuboid) : p1(a_Cuboid.p1), p2(a_Cuboid.p2) {} cCuboid(const Vector3i & a_p1, const Vector3i & a_p2) : p1(a_p1), p2(a_p2) {} cCuboid(int a_X1, int a_Y1, int a_Z1) : p1(a_X1, a_Y1, a_Z1), p2(a_X1, a_Y1, a_Z1) {} cCuboid(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) : p1(a_X1, a_Y1, a_Z1), p2(a_X2, a_Y2, a_Z2) {} @@ -58,7 +58,7 @@ public: ); } - bool IsInside( const Vector3d & v ) const + bool IsInside( const Vector3d & v) const { return ( (v.x >= p1.x) && (v.x <= p2.x) && diff --git a/src/Defines.h b/src/Defines.h index f4ebbd9ff..f095069d9 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -479,9 +479,9 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a_Y, double & a_Z) { - // a_X = sinf ( a_Pan / 180 * PI ) * cosf ( a_Pitch / 180 * PI ); - // a_Y = -sinf ( a_Pitch / 180 * PI ); - // a_Z = -cosf ( a_Pan / 180 * PI ) * cosf ( a_Pitch / 180 * PI ); + // a_X = sinf ( a_Pan / 180 * PI) * cosf ( a_Pitch / 180 * PI); + // a_Y = -sinf ( a_Pitch / 180 * PI); + // a_Z = -cosf ( a_Pan / 180 * PI) * cosf ( a_Pitch / 180 * PI); a_X = cos(a_Pan / 180 * PI) * cos(a_Pitch / 180 * PI); a_Y = sin(a_Pan / 180 * PI) * cos(a_Pitch / 180 * PI); a_Z = sin(a_Pitch / 180 * PI); @@ -519,7 +519,7 @@ inline float GetSignf(float a_Val) -inline float GetSpecialSignf( float a_Val ) +inline float GetSpecialSignf( float a_Val) { return (a_Val <= 0.f) ? -1.f : 1.f; } @@ -640,11 +640,11 @@ namespace ItemCategory inline bool IsTool(short a_ItemID) { - return IsPickaxe( a_ItemID ) - || IsAxe ( a_ItemID ) - || IsSword ( a_ItemID ) - || IsHoe ( a_ItemID ) - || IsShovel ( a_ItemID ); + return IsPickaxe( a_ItemID) + || IsAxe ( a_ItemID) + || IsSword ( a_ItemID) + || IsHoe ( a_ItemID) + || IsShovel ( a_ItemID); } diff --git a/src/Enchantments.h b/src/Enchantments.h index 85a316414..98d7c0d36 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -40,7 +40,7 @@ Serialization will never put zero-level enchantments into the stringspec and wil class cEnchantments { public: - /** Individual enchantment IDs, corresponding to their NBT IDs ( http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs ) + /** Individual enchantment IDs, corresponding to their NBT IDs: http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs */ enum diff --git a/src/Endianness.h b/src/Endianness.h index 78f9a5d99..5997086e0 100644 --- a/src/Endianness.h +++ b/src/Endianness.h @@ -11,8 +11,8 @@ inline UInt64 HostToNetwork8(const void * a_Value) { unsigned long long __HostToNetwork8; - memcpy( &__HostToNetwork8, a_Value, sizeof( __HostToNetwork8 ) ); - __HostToNetwork8 = (( ( (unsigned long long)htonl((u_long)__HostToNetwork8) ) << 32) + htonl(__HostToNetwork8 >> 32)); + memcpy( &__HostToNetwork8, a_Value, sizeof( __HostToNetwork8)); + __HostToNetwork8 = (( ( (unsigned long long)htonl((u_long)__HostToNetwork8)) << 32) + htonl(__HostToNetwork8 >> 32)); return __HostToNetwork8; } @@ -20,11 +20,11 @@ inline UInt64 HostToNetwork8(const void * a_Value) -inline UInt32 HostToNetwork4(const void* a_Value ) +inline UInt32 HostToNetwork4(const void* a_Value) { unsigned int __HostToNetwork4; - memcpy( &__HostToNetwork4, a_Value, sizeof( __HostToNetwork4 ) ); - __HostToNetwork4 = ntohl( __HostToNetwork4 ); + memcpy( &__HostToNetwork4, a_Value, sizeof( __HostToNetwork4)); + __HostToNetwork4 = ntohl( __HostToNetwork4); return __HostToNetwork4; } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 5a3bbcdc4..db0fd0fd6 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -648,7 +648,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) int RelBlockX = BlockX - (NextChunk->GetPosX() * cChunkDef::Width); int RelBlockZ = BlockZ - (NextChunk->GetPosZ() * cChunkDef::Width); - BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ ); + BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ); BLOCKTYPE BlockBelow = (BlockY > 0) ? NextChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR; if (!cBlockInfo::IsSolid(BlockIn)) // Making sure we are not inside a solid block { @@ -758,7 +758,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) m_WaterSpeed *= 0.9f; // Reduce speed each tick - switch(WaterDir) + switch (WaterDir) { case X_PLUS: m_WaterSpeed.x = 0.2f; diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp index ed225b8e6..73d5cbfed 100644 --- a/src/Entities/ExpOrb.cpp +++ b/src/Entities/ExpOrb.cpp @@ -62,9 +62,9 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk) } a_Distance.Normalize(); a_Distance *= ((float) (5.5 - Distance)); - SetSpeedX( a_Distance.x ); - SetSpeedY( a_Distance.y ); - SetSpeedZ( a_Distance.z ); + SetSpeedX( a_Distance.x); + SetSpeedY( a_Distance.y); + SetSpeedZ( a_Distance.z); BroadcastMovementUpdate(); } HandlePhysics(a_Dt, a_Chunk); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 6a52d8e29..fcc8eb9a0 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -140,7 +140,7 @@ cPlayer::~cPlayer(void) SaveToDisk(); - m_World->RemovePlayer( this ); + m_World->RemovePlayer( this); m_ClientHandle = NULL; @@ -173,11 +173,11 @@ void cPlayer::SpawnOn(cClientHandle & a_Client) } a_Client.SendPlayerSpawn(*this); a_Client.SendEntityHeadLook(*this); - a_Client.SendEntityEquipment(*this, 0, m_Inventory.GetEquippedItem() ); - a_Client.SendEntityEquipment(*this, 1, m_Inventory.GetEquippedBoots() ); - a_Client.SendEntityEquipment(*this, 2, m_Inventory.GetEquippedLeggings() ); - a_Client.SendEntityEquipment(*this, 3, m_Inventory.GetEquippedChestplate() ); - a_Client.SendEntityEquipment(*this, 4, m_Inventory.GetEquippedHelmet() ); + a_Client.SendEntityEquipment(*this, 0, m_Inventory.GetEquippedItem()); + a_Client.SendEntityEquipment(*this, 1, m_Inventory.GetEquippedBoots()); + a_Client.SendEntityEquipment(*this, 2, m_Inventory.GetEquippedLeggings()); + a_Client.SendEntityEquipment(*this, 3, m_Inventory.GetEquippedChestplate()); + a_Client.SendEntityEquipment(*this, 4, m_Inventory.GetEquippedHelmet()); } @@ -298,7 +298,7 @@ short cPlayer::CalcLevelFromXp(short a_XpTotal) } // level 16 to 30 - return (short) ( 29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal )))) / 3; + return (short) ( 29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal)))) / 3; } @@ -316,11 +316,11 @@ short cPlayer::XpForLevel(short a_Level) // level 30+ if (a_Level >= 31) { - return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220 ); + return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220); } // level 16 to 30 - return (short) ( (1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360 ); + return (short) ( (1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360); } @@ -1007,7 +1007,7 @@ double cPlayer::GetEyeHeight(void) const Vector3d cPlayer::GetEyePosition(void) const { - return Vector3d( GetPosX(), m_Stance, GetPosZ() ); + return Vector3d( GetPosX(), m_Stance, GetPosZ()); } @@ -1169,7 +1169,7 @@ void cPlayer::SetGameMode(eGameMode a_GameMode) -void cPlayer::LoginSetGameMode( eGameMode a_GameMode ) +void cPlayer::LoginSetGameMode( eGameMode a_GameMode) { m_GameMode = a_GameMode; } @@ -1305,7 +1305,7 @@ void cPlayer::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) -void cPlayer::MoveTo( const Vector3d & a_NewPos ) +void cPlayer::MoveTo( const Vector3d & a_NewPos) { if ((a_NewPos.y < -990) && (GetPosY() > -100)) { @@ -1328,7 +1328,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos ) Vector3d DeltaPos = a_NewPos - GetPosition(); UpdateMovementStats(DeltaPos); - SetPosition( a_NewPos ); + SetPosition( a_NewPos); SetStance(a_NewPos.y + 1.62); } @@ -1354,11 +1354,11 @@ void cPlayer::SetVisible(bool a_bVisible) -void cPlayer::AddToGroup( const AString & a_GroupName ) +void cPlayer::AddToGroup( const AString & a_GroupName) { - cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName ); - m_Groups.push_back( Group ); - LOGD("Added %s to group %s", GetName().c_str(), a_GroupName.c_str() ); + cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName); + m_Groups.push_back( Group); + LOGD("Added %s to group %s", GetName().c_str(), a_GroupName.c_str()); ResolveGroups(); ResolvePermissions(); } @@ -1367,28 +1367,28 @@ void cPlayer::AddToGroup( const AString & a_GroupName ) -void cPlayer::RemoveFromGroup( const AString & a_GroupName ) +void cPlayer::RemoveFromGroup( const AString & a_GroupName) { bool bRemoved = false; - for (GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr ) + for (GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr) { - if ((*itr)->GetName().compare(a_GroupName ) == 0 ) + if ((*itr)->GetName().compare(a_GroupName) == 0) { - m_Groups.erase( itr ); + m_Groups.erase( itr); bRemoved = true; break; } } - if (bRemoved ) + if (bRemoved) { - LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str() ); + LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str()); ResolveGroups(); ResolvePermissions(); } else { - LOGWARN("Tried to remove %s from group %s but was not in that group", GetName().c_str(), a_GroupName.c_str() ); + LOGWARN("Tried to remove %s from group %s but was not in that group", GetName().c_str(), a_GroupName.c_str()); } } @@ -1404,30 +1404,30 @@ bool cPlayer::HasPermission(const AString & a_Permission) return true; } - AStringVector Split = StringSplit( a_Permission, "." ); + AStringVector Split = StringSplit( a_Permission, "."); PermissionMap Possibilities = m_ResolvedPermissions; // Now search the namespaces - while (Possibilities.begin() != Possibilities.end() ) + while (Possibilities.begin() != Possibilities.end()) { PermissionMap::iterator itr = Possibilities.begin(); - if (itr->second ) + if (itr->second) { - AStringVector OtherSplit = StringSplit( itr->first, "." ); - if (OtherSplit.size() <= Split.size() ) + AStringVector OtherSplit = StringSplit( itr->first, "."); + if (OtherSplit.size() <= Split.size()) { unsigned int i; - for (i = 0; i < OtherSplit.size(); ++i ) + for (i = 0; i < OtherSplit.size(); ++i) { - if (OtherSplit[i].compare( Split[i] ) != 0 ) + if (OtherSplit[i].compare( Split[i]) != 0) { - if (OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard! + if (OtherSplit[i].compare("*") == 0) return true; // WildCard man!! WildCard! break; } } - if (i == Split.size() ) return true; + if (i == Split.size()) return true; } } - Possibilities.erase( itr ); + Possibilities.erase( itr); } // Nothing that matched :( @@ -1438,11 +1438,11 @@ bool cPlayer::HasPermission(const AString & a_Permission) -bool cPlayer::IsInGroup( const AString & a_Group ) +bool cPlayer::IsInGroup( const AString & a_Group) { - for (GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr ) + for (GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr) { - if (a_Group.compare( (*itr)->GetName().c_str() ) == 0 ) + if (a_Group.compare( (*itr)->GetName().c_str()) == 0) return true; } return false; @@ -1457,15 +1457,15 @@ void cPlayer::ResolvePermissions() m_ResolvedPermissions.clear(); // Start with an empty map // Copy all player specific permissions into the resolved permissions map - for (PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr ) + for (PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr) { m_ResolvedPermissions[ itr->first ] = itr->second; } - for (GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr ) + for (GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr) { const cGroup::PermissionMap & Permissions = (*GroupItr)->GetPermissions(); - for (cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr ) + for (cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr) { m_ResolvedPermissions[ itr->first ] = itr->second; } @@ -1484,14 +1484,14 @@ void cPlayer::ResolveGroups() // Get a complete resolved list of all groups the player is in std::map< cGroup*, bool > AllGroups; // Use a map, because it's faster than iterating through a list to find duplicates GroupList ToIterate; - for (GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr ) + for (GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr) { - ToIterate.push_back( *GroupItr ); + ToIterate.push_back( *GroupItr); } - while (ToIterate.begin() != ToIterate.end() ) + while (ToIterate.begin() != ToIterate.end()) { cGroup* CurrentGroup = *ToIterate.begin(); - if (AllGroups.find( CurrentGroup ) != AllGroups.end() ) + if (AllGroups.find( CurrentGroup) != AllGroups.end()) { LOGWARNING("ERROR: Player \"%s\" is in the group multiple times (\"%s\"). Please fix your settings in users.ini!", GetName().c_str(), CurrentGroup->GetName().c_str() @@ -1500,19 +1500,19 @@ void cPlayer::ResolveGroups() else { AllGroups[ CurrentGroup ] = true; - m_ResolvedGroups.push_back( CurrentGroup ); // Add group to resolved list + m_ResolvedGroups.push_back( CurrentGroup); // Add group to resolved list const cGroup::GroupList & Inherits = CurrentGroup->GetInherits(); - for (cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr ) + for (cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr) { - if (AllGroups.find( *itr ) != AllGroups.end() ) + if (AllGroups.find( *itr) != AllGroups.end()) { - LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", GetName().c_str(), (*itr)->GetName().c_str() ); + LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", GetName().c_str(), (*itr)->GetName().c_str()); continue; } - ToIterate.push_back( *itr ); + ToIterate.push_back( *itr); } } - ToIterate.erase( ToIterate.begin() ); + ToIterate.erase( ToIterate.begin()); } } @@ -1522,12 +1522,12 @@ void cPlayer::ResolveGroups() AString cPlayer::GetColor(void) const { - if (m_Color != '-' ) + if (m_Color != '-') { return cChatColor::Delimiter + m_Color; } - if (m_Groups.size() < 1 ) + if (m_Groups.size() < 1) { return cChatColor::White; } @@ -1914,11 +1914,11 @@ cPlayer::StringList cPlayer::GetResolvedPermissions() StringList Permissions; const PermissionMap& ResolvedPermissions = m_ResolvedPermissions; - for (PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr ) + for (PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr) { if (itr->second) { - Permissions.push_back( itr->first ); + Permissions.push_back( itr->first); } } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 7c287d41b..26db2050b 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -117,8 +117,8 @@ public: /** Returns true if the player is currently charging the bow */ bool IsChargingBow(void) const { return m_IsChargingBow; } - void SetTouchGround( bool a_bTouchGround ); - inline void SetStance( const double a_Stance ) { m_Stance = a_Stance; } + void SetTouchGround( bool a_bTouchGround); + inline void SetStance( const double a_Stance) { m_Stance = a_Stance; } double GetEyeHeight(void) const; // tolua_export Vector3d GetEyePosition(void) const; // tolua_export inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export @@ -239,15 +239,15 @@ public: typedef std::list< std::string > StringList; /** Adds a player to existing group or creates a new group when it doesn't exist */ - void AddToGroup( const AString & a_GroupName ); // tolua_export + void AddToGroup( const AString & a_GroupName); // tolua_export /** Removes a player from the group, resolves permissions and group inheritance (case sensitive) */ - void RemoveFromGroup( const AString & a_GroupName ); // tolua_export + void RemoveFromGroup( const AString & a_GroupName); // tolua_export - bool HasPermission( const AString & a_Permission ); // tolua_export + bool HasPermission( const AString & a_Permission); // tolua_export const GroupList & GetGroups() { return m_Groups; } // >> EXPORTED IN MANUALBINDINGS << StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS << - bool IsInGroup( const AString & a_Group ); // tolua_export + bool IsInGroup( const AString & a_Group); // tolua_export // tolua_begin @@ -328,7 +328,7 @@ public: void Respawn(void); // tolua_export - void SetVisible( bool a_bVisible ); // tolua_export + void SetVisible( bool a_bVisible); // tolua_export bool IsVisible(void) const { return m_bVisible; } // tolua_export /** Moves the player to the specified world. diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index cf29e227f..ab772e97b 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -30,7 +30,7 @@ struct cFurnaceRecipe::sFurnaceRecipeState cFurnaceRecipe::cFurnaceRecipe() - : m_pState( new sFurnaceRecipeState ) + : m_pState( new sFurnaceRecipeState) { ReloadRecipes(); } diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index 21bfd98b8..3b71efb57 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -703,10 +703,10 @@ cGridStructGen::cStructurePtr cStructGenWormNestCaves::CreateStructure(int a_Gri //////////////////////////////////////////////////////////////////////////////// // cStructGenMarbleCaves: -static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise ) +static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise) { static const float PI_2 = 1.57079633f; - float oct1 = (a_Noise.CubicNoise3D(x * 0.1f, y * 0.1f, z * 0.1f )) * 4; + float oct1 = (a_Noise.CubicNoise3D(x * 0.1f, y * 0.1f, z * 0.1f)) * 4; oct1 = oct1 * oct1 * oct1; if (oct1 < 0.f) oct1 = PI_2; @@ -730,7 +730,7 @@ void cStructGenMarbleCaves::GenFinish(cChunkDesc & a_ChunkDesc) const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x); int Top = a_ChunkDesc.GetHeight(x, z); - for (int y = 1; y < Top; ++y ) + for (int y = 1; y < Top; ++y) { if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_STONE) { diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp index 9383a3adf..0baf1e991 100644 --- a/src/Generating/ChunkGenerator.cpp +++ b/src/Generating/ChunkGenerator.cpp @@ -229,7 +229,7 @@ void cChunkGenerator::Execute(void) } cChunkCoords coords = m_Queue.front(); // Get next coord from queue - m_Queue.erase( m_Queue.begin() ); // Remove coordinate from queue + m_Queue.erase( m_Queue.begin()); // Remove coordinate from queue bool SkipEnabled = (m_Queue.size() > QUEUE_SKIP_LIMIT); Lock.Unlock(); // Unlock ASAP m_evtRemoved.Set(); diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 00a93023d..dca346e52 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -239,14 +239,14 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc) } const float xx = (float)BlockX; - float val1 = m_Noise.CubicNoise2D(xx * 0.1f, zz * 0.1f ); - float val2 = m_Noise.CubicNoise2D(xx * 0.01f, zz * 0.01f ); + float val1 = m_Noise.CubicNoise2D(xx * 0.1f, zz * 0.1f); + float val2 = m_Noise.CubicNoise2D(xx * 0.01f, zz * 0.01f); switch (a_ChunkDesc.GetBlockType(x, Top, z)) { case E_BLOCK_GRASS: { - float val3 = m_Noise.CubicNoise2D(xx * 0.01f + 10, zz * 0.01f + 10 ); - float val4 = m_Noise.CubicNoise2D(xx * 0.05f + 20, zz * 0.05f + 20 ); + float val3 = m_Noise.CubicNoise2D(xx * 0.01f + 10, zz * 0.01f + 10); + float val4 = m_Noise.CubicNoise2D(xx * 0.05f + 20, zz * 0.05f + 20); if (val1 + val2 > 0.2f) { a_ChunkDesc.SetBlockType(x, ++Top, z, E_BLOCK_YELLOW_FLOWER); diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index 3df1a90ff..870ceef7f 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -253,7 +253,7 @@ float cHeiGenClassic::GetNoise(float x, float y) float oct2 = m_Noise.CubicNoise2D(x * m_HeightFreq2, y * m_HeightFreq2) * m_HeightAmp2; float oct3 = m_Noise.CubicNoise2D(x * m_HeightFreq3, y * m_HeightFreq3) * m_HeightAmp3; - float height = m_Noise.CubicNoise2D(x * 0.1f, y * 0.1f ) * 2; + float height = m_Noise.CubicNoise2D(x * 0.1f, y * 0.1f) * 2; float flatness = ((m_Noise.CubicNoise2D(x * 0.5f, y * 0.5f) + 1.f) * 0.5f) * 1.1f; // 0 ... 1.5 flatness *= flatness * flatness; diff --git a/src/Globals.h b/src/Globals.h index 007fa10d0..b35af9604 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -272,12 +272,12 @@ void inline LOGERROR(const char* a_Format, ...) /// Evaluates to the number of elements in an array (compile-time!) #define ARRAYCOUNT(X) (sizeof(X) / sizeof(*(X))) -/// Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)" ) +/// Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)") #define KiB * 1024 #define MiB * 1024 * 1024 /// Faster than (int)floorf((float)x / (float)div) -#define FAST_FLOOR_DIV( x, div ) (((x) - (((x) < 0) ? ((div) - 1) : 0)) / (div)) +#define FAST_FLOOR_DIV( x, div) (((x) - (((x) < 0) ? ((div) - 1) : 0)) / (div)) // Own version of assert() that writes failed assertions to the log for review #ifdef TEST_GLOBALS @@ -314,14 +314,14 @@ void inline LOGERROR(const char* a_Format, ...) #else #ifdef _DEBUG - #define ASSERT( x ) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), assert(0), 0 ) ) + #define ASSERT( x) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__), assert(0), 0)) #else #define ASSERT(x) ((void)(x)) #endif #endif // Pretty much the same as ASSERT() but stays in Release builds -#define VERIFY( x ) ( !!(x) || ( LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), exit(1), 0 ) ) +#define VERIFY( x) ( !!(x) || ( LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__), exit(1), 0)) // Same as assert but in all Self test builds #ifdef SELF_TEST diff --git a/src/Group.cpp b/src/Group.cpp index 725740905..def585618 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -7,7 +7,7 @@ -void cGroup::AddCommand( const AString & a_Command ) +void cGroup::AddCommand( const AString & a_Command) { m_Commands[ a_Command ] = true; } @@ -16,7 +16,7 @@ void cGroup::AddCommand( const AString & a_Command ) -void cGroup::AddPermission( const AString & a_Permission ) +void cGroup::AddPermission( const AString & a_Permission) { m_Permissions[ a_Permission ] = true; } @@ -25,10 +25,10 @@ void cGroup::AddPermission( const AString & a_Permission ) -void cGroup::InheritFrom( cGroup* a_Group ) +void cGroup::InheritFrom( cGroup* a_Group) { - m_Inherits.remove( a_Group ); - m_Inherits.push_back( a_Group ); + m_Inherits.remove( a_Group); + m_Inherits.push_back( a_Group); } diff --git a/src/Group.h b/src/Group.h index 95063a987..5816f8a06 100644 --- a/src/Group.h +++ b/src/Group.h @@ -14,12 +14,12 @@ public: ~cGroup() {} // tolua_begin - void SetName( const AString & a_Name ) { m_Name = a_Name; } + void SetName( const AString & a_Name) { m_Name = a_Name; } const AString & GetName() const { return m_Name; } - void SetColor( const AString & a_Color ) { m_Color = a_Color; } - void AddCommand( const AString & a_Command ); - void AddPermission( const AString & a_Permission ); - void InheritFrom( cGroup* a_Group ); + void SetColor( const AString & a_Color) { m_Color = a_Color; } + void AddCommand( const AString & a_Command); + void AddPermission( const AString & a_Permission); + void InheritFrom( cGroup* a_Group); // tolua_end typedef std::map< AString, bool > PermissionMap; diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index 685aece5a..32c2f1c97 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -27,7 +27,7 @@ struct cGroupManager::sGroupManagerState cGroupManager::~cGroupManager() { - for (GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr ) + for (GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr) { delete itr->second; itr->second = NULL; @@ -43,7 +43,7 @@ cGroupManager::~cGroupManager() cGroupManager::cGroupManager() - : m_pState( new sGroupManagerState ) + : m_pState( new sGroupManagerState) { LOGD("-- Loading Groups --"); @@ -198,20 +198,20 @@ bool cGroupManager::LoadGroups() -bool cGroupManager::ExistsGroup( const AString & a_Name ) +bool cGroupManager::ExistsGroup( const AString & a_Name) { - GroupMap::iterator itr = m_pState->Groups.find( a_Name ); - return ( itr != m_pState->Groups.end() ); + GroupMap::iterator itr = m_pState->Groups.find( a_Name); + return ( itr != m_pState->Groups.end()); } -cGroup* cGroupManager::GetGroup( const AString & a_Name ) +cGroup* cGroupManager::GetGroup( const AString & a_Name) { - GroupMap::iterator itr = m_pState->Groups.find( a_Name ); - if (itr != m_pState->Groups.end() ) + GroupMap::iterator itr = m_pState->Groups.find( a_Name); + if (itr != m_pState->Groups.end()) { return itr->second; } diff --git a/src/HTTPServer/HTTPConnection.cpp b/src/HTTPServer/HTTPConnection.cpp index 21ff14373..b9c762e7c 100644 --- a/src/HTTPServer/HTTPConnection.cpp +++ b/src/HTTPServer/HTTPConnection.cpp @@ -100,7 +100,7 @@ void cHTTPConnection::AwaitNextRequest(void) { case wcsRecvHeaders: { - // Nothing has been received yet, or a special response was given (SendStatusAndReason() or SendNeedAuth() ) + // Nothing has been received yet, or a special response was given (SendStatusAndReason() or SendNeedAuth()) break; } diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 93b2c8eee..0f9716d89 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -497,21 +497,21 @@ int cInventory::ArmorSlotNumToEntityEquipmentID(short a_ArmorSlotNum) #if 0 -bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode /* = 0 */ ) +bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode /* = 0 */) { // Fill already present stacks - if (a_Mode < 2 ) + if (a_Mode < 2) { int MaxStackSize = cItemHandler::GetItemHandler(a_Item.m_ItemType)->GetMaxStackSize(); for (int i = 0; i < a_Size; i++) { - if (m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage ) + if (m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage) { int NumFree = MaxStackSize - m_Slots[i + a_Offset].m_ItemCount; - if (NumFree >= a_Item.m_ItemCount ) + if (NumFree >= a_Item.m_ItemCount) { - // printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree ); + // printf("1. Adding %i items ( free: %i)\n", a_Item.m_ItemCount, NumFree); m_Slots[i + a_Offset].m_ItemCount += a_Item.m_ItemCount; a_Item.m_ItemCount = 0; a_bChangedSlots[i + a_Offset] = true; @@ -519,7 +519,7 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, } else { - // printf("2. Adding %i items\n", NumFree ); + // printf("2. Adding %i items\n", NumFree); m_Slots[i + a_Offset].m_ItemCount += (char)NumFree; a_Item.m_ItemCount -= (char)NumFree; a_bChangedSlots[i + a_Offset] = true; @@ -528,12 +528,12 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, } } - if (a_Mode > 0 ) + if (a_Mode > 0) { // If we got more left, find first empty slot for (int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++) { - if (m_Slots[i + a_Offset].m_ItemType == -1 ) + if (m_Slots[i + a_Offset].m_ItemType == -1) { m_Slots[i + a_Offset] = a_Item; a_Item.m_ItemCount = 0; diff --git a/src/Inventory.h b/src/Inventory.h index 5175afd14..ed134aee4 100644 --- a/src/Inventory.h +++ b/src/Inventory.h @@ -169,7 +169,7 @@ public: bool LoadFromJson(Json::Value & a_Value); protected: - bool AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode = 0 ); + bool AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode = 0); cItemGrid m_ArmorSlots; cItemGrid m_InventorySlots; diff --git a/src/Item.cpp b/src/Item.cpp index 876abafd0..b44472e38 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -162,11 +162,11 @@ void cItem::GetJson(Json::Value & a_OutValue) const void cItem::FromJson(const Json::Value & a_Value) { - m_ItemType = (ENUM_ITEM_ID)a_Value.get("ID", -1 ).asInt(); + m_ItemType = (ENUM_ITEM_ID)a_Value.get("ID", -1).asInt(); if (m_ItemType > 0) { - m_ItemCount = (char)a_Value.get("Count", -1 ).asInt(); - m_ItemDamage = (short)a_Value.get("Health", -1 ).asInt(); + m_ItemCount = (char)a_Value.get("Count", -1).asInt(); + m_ItemDamage = (short)a_Value.get("Health", -1).asInt(); m_Enchantments.Clear(); m_Enchantments.AddFromString(a_Value.get("ench", "").asString()); m_CustomName = a_Value.get("Name", "").asString(); diff --git a/src/Items/ItemFood.h b/src/Items/ItemFood.h index 961cf482d..ff1d7991b 100644 --- a/src/Items/ItemFood.h +++ b/src/Items/ItemFood.h @@ -26,7 +26,7 @@ public: virtual FoodInfo GetFoodInfo(void) override { - switch(m_ItemType) + switch (m_ItemType) { // Please keep alpha-sorted. case E_ITEM_BAKED_POTATO: return FoodInfo(6, 7.2); diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 0a8638f3a..bf1d4e4cb 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -94,7 +94,7 @@ cItemHandler * cItemHandler::GetItemHandler(int a_ItemType) cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) { - switch(a_ItemType) + switch (a_ItemType) { default: return new cItemHandler(a_ItemType); diff --git a/src/Items/ItemPickaxe.h b/src/Items/ItemPickaxe.h index 82bec52d4..647d59b5c 100644 --- a/src/Items/ItemPickaxe.h +++ b/src/Items/ItemPickaxe.h @@ -17,7 +17,7 @@ public: char PickaxeLevel() { - switch(m_ItemType) + switch (m_ItemType) { case E_ITEM_WOODEN_PICKAXE: return 1; case E_ITEM_GOLD_PICKAXE: return 1; @@ -31,7 +31,7 @@ public: virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override { - switch(a_BlockType) + switch (a_BlockType) { case E_BLOCK_OBSIDIAN: { diff --git a/src/Log.cpp b/src/Log.cpp index a70b09103..7686a0fb4 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -17,7 +17,7 @@ cLog* cLog::s_Log = NULL; -cLog::cLog(const AString & a_FileName ) +cLog::cLog(const AString & a_FileName) : m_File(NULL) { s_Log = this; @@ -25,7 +25,7 @@ cLog::cLog(const AString & a_FileName ) // create logs directory cFile::CreateFolder(FILE_IO_PREFIX + AString("logs")); - OpenLog((FILE_IO_PREFIX + AString("logs/") + a_FileName).c_str() ); + OpenLog((FILE_IO_PREFIX + AString("logs/") + a_FileName).c_str()); } @@ -59,7 +59,7 @@ cLog * cLog::GetInstance() void cLog::CloseLog() { - if (m_File ) + if (m_File) fclose (m_File); m_File = 0; } @@ -68,13 +68,13 @@ void cLog::CloseLog() -void cLog::OpenLog( const char* a_FileName ) +void cLog::OpenLog( const char* a_FileName) { if (m_File) fclose (m_File); #ifdef _MSC_VER - fopen_s( &m_File, a_FileName, "a+" ); + fopen_s( &m_File, a_FileName, "a+"); #else - m_File = fopen(a_FileName, "a+" ); + m_File = fopen(a_FileName, "a+"); #endif } @@ -85,11 +85,11 @@ void cLog::OpenLog( const char* a_FileName ) void cLog::ClearLog() { #ifdef _MSC_VER - if (fopen_s( &m_File, "log.txt", "w" ) == 0) + if (fopen_s( &m_File, "log.txt", "w") == 0) fclose (m_File); #else - m_File = fopen("log.txt", "w" ); - if (m_File ) + m_File = fopen("log.txt", "w"); + if (m_File) fclose (m_File); #endif m_File = NULL; @@ -105,15 +105,15 @@ void cLog::Log(const char * a_Format, va_list argList) AppendVPrintf(Message, a_Format, argList); time_t rawtime; - time ( &rawtime ); + time ( &rawtime); struct tm* timeinfo; #ifdef _MSC_VER struct tm timeinforeal; timeinfo = &timeinforeal; - localtime_s(timeinfo, &rawtime ); + localtime_s(timeinfo, &rawtime); #else - timeinfo = localtime( &rawtime ); + timeinfo = localtime( &rawtime); #endif AString Line; @@ -131,8 +131,8 @@ void cLog::Log(const char * a_Format, va_list argList) // Print to console: #if defined(ANDROID_NDK) // __android_log_vprint(ANDROID_LOG_ERROR, "MCServer", a_Format, argList); - __android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str() ); - // CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line ); + __android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str()); + // CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line); #else printf("%s", Line.c_str()); #endif diff --git a/src/MCLogger.cpp b/src/MCLogger.cpp index 78eb19f3e..044e83937 100644 --- a/src/MCLogger.cpp +++ b/src/MCLogger.cpp @@ -234,7 +234,7 @@ void LOG(const char* a_Format, ...) { va_list argList; va_start(argList, a_Format); - cMCLogger::GetInstance()->Log( a_Format, argList ); + cMCLogger::GetInstance()->Log( a_Format, argList); va_end(argList); } @@ -242,7 +242,7 @@ void LOGINFO(const char* a_Format, ...) { va_list argList; va_start(argList, a_Format); - cMCLogger::GetInstance()->Info( a_Format, argList ); + cMCLogger::GetInstance()->Info( a_Format, argList); va_end(argList); } @@ -250,7 +250,7 @@ void LOGWARN(const char* a_Format, ...) { va_list argList; va_start(argList, a_Format); - cMCLogger::GetInstance()->Warn( a_Format, argList ); + cMCLogger::GetInstance()->Warn( a_Format, argList); va_end(argList); } @@ -258,7 +258,7 @@ void LOGERROR(const char* a_Format, ...) { va_list argList; va_start(argList, a_Format); - cMCLogger::GetInstance()->Error( a_Format, argList ); + cMCLogger::GetInstance()->Error( a_Format, argList); va_end(argList); } diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index 53c83f166..454fabce8 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -141,7 +141,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R SkyLight = a_Chunk->GetTimeAlteredLight(SkyLight); - switch(a_MobType) + switch (a_MobType) { case cMonster::mtSquid: { diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp index c1979a495..76334d970 100644 --- a/src/Mobs/SnowGolem.cpp +++ b/src/Mobs/SnowGolem.cpp @@ -30,7 +30,7 @@ void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer) void cSnowGolem::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ())) )) + if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ())))) { TakeDamage(*this); } diff --git a/src/MonsterConfig.cpp b/src/MonsterConfig.cpp index f5e746ce8..f5e078213 100644 --- a/src/MonsterConfig.cpp +++ b/src/MonsterConfig.cpp @@ -35,7 +35,7 @@ struct cMonsterConfig::sMonsterConfigState cMonsterConfig::cMonsterConfig(void) - : m_pState( new sMonsterConfigState ) + : m_pState( new sMonsterConfigState) { Initialize(); } diff --git a/src/Noise.cpp b/src/Noise.cpp index a30661fe0..507d05ea5 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -528,10 +528,10 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS }; const NOISE_DATATYPE FracX = (a_X) - BaseX; - const NOISE_DATATYPE x1interp1 = CubicInterpolate( points1[0][0], points1[0][1], points1[0][2], points1[0][3], FracX ); - const NOISE_DATATYPE x1interp2 = CubicInterpolate( points1[1][0], points1[1][1], points1[1][2], points1[1][3], FracX ); - const NOISE_DATATYPE x1interp3 = CubicInterpolate( points1[2][0], points1[2][1], points1[2][2], points1[2][3], FracX ); - const NOISE_DATATYPE x1interp4 = CubicInterpolate( points1[3][0], points1[3][1], points1[3][2], points1[3][3], FracX ); + const NOISE_DATATYPE x1interp1 = CubicInterpolate( points1[0][0], points1[0][1], points1[0][2], points1[0][3], FracX); + const NOISE_DATATYPE x1interp2 = CubicInterpolate( points1[1][0], points1[1][1], points1[1][2], points1[1][3], FracX); + const NOISE_DATATYPE x1interp3 = CubicInterpolate( points1[2][0], points1[2][1], points1[2][2], points1[2][3], FracX); + const NOISE_DATATYPE x1interp4 = CubicInterpolate( points1[3][0], points1[3][1], points1[3][2], points1[3][3], FracX); const NOISE_DATATYPE points2[4][4] = { @@ -541,45 +541,45 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS { IntNoise3D(BaseX - 1, BaseY + 2, BaseZ), IntNoise3D(BaseX, BaseY + 2, BaseZ), IntNoise3D(BaseX + 1, BaseY + 2, BaseZ), IntNoise3D(BaseX + 2, BaseY + 2, BaseZ), }, }; - const NOISE_DATATYPE x2interp1 = CubicInterpolate( points2[0][0], points2[0][1], points2[0][2], points2[0][3], FracX ); - const NOISE_DATATYPE x2interp2 = CubicInterpolate( points2[1][0], points2[1][1], points2[1][2], points2[1][3], FracX ); - const NOISE_DATATYPE x2interp3 = CubicInterpolate( points2[2][0], points2[2][1], points2[2][2], points2[2][3], FracX ); - const NOISE_DATATYPE x2interp4 = CubicInterpolate( points2[3][0], points2[3][1], points2[3][2], points2[3][3], FracX ); + const NOISE_DATATYPE x2interp1 = CubicInterpolate( points2[0][0], points2[0][1], points2[0][2], points2[0][3], FracX); + const NOISE_DATATYPE x2interp2 = CubicInterpolate( points2[1][0], points2[1][1], points2[1][2], points2[1][3], FracX); + const NOISE_DATATYPE x2interp3 = CubicInterpolate( points2[2][0], points2[2][1], points2[2][2], points2[2][3], FracX); + const NOISE_DATATYPE x2interp4 = CubicInterpolate( points2[3][0], points2[3][1], points2[3][2], points2[3][3], FracX); const NOISE_DATATYPE points3[4][4] = { - { IntNoise3D( BaseX-1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ + 1), }, - { IntNoise3D( BaseX-1, BaseY, BaseZ+1 ), IntNoise3D( BaseX, BaseY, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY, BaseZ + 1), }, - { IntNoise3D( BaseX-1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ + 1), }, - { IntNoise3D( BaseX-1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ + 1), }, + { IntNoise3D( BaseX-1, BaseY-1, BaseZ+1), IntNoise3D( BaseX, BaseY-1, BaseZ+1), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1), IntNoise3D( BaseX+2, BaseY-1, BaseZ + 1), }, + { IntNoise3D( BaseX-1, BaseY, BaseZ+1), IntNoise3D( BaseX, BaseY, BaseZ+1), IntNoise3D( BaseX+1, BaseY, BaseZ+1), IntNoise3D( BaseX+2, BaseY, BaseZ + 1), }, + { IntNoise3D( BaseX-1, BaseY+1, BaseZ+1), IntNoise3D( BaseX, BaseY+1, BaseZ+1), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1), IntNoise3D( BaseX+2, BaseY+1, BaseZ + 1), }, + { IntNoise3D( BaseX-1, BaseY+2, BaseZ+1), IntNoise3D( BaseX, BaseY+2, BaseZ+1), IntNoise3D( BaseX+1, BaseY+2, BaseZ+1), IntNoise3D( BaseX+2, BaseY+2, BaseZ + 1), }, }; - const NOISE_DATATYPE x3interp1 = CubicInterpolate( points3[0][0], points3[0][1], points3[0][2], points3[0][3], FracX ); - const NOISE_DATATYPE x3interp2 = CubicInterpolate( points3[1][0], points3[1][1], points3[1][2], points3[1][3], FracX ); - const NOISE_DATATYPE x3interp3 = CubicInterpolate( points3[2][0], points3[2][1], points3[2][2], points3[2][3], FracX ); - const NOISE_DATATYPE x3interp4 = CubicInterpolate( points3[3][0], points3[3][1], points3[3][2], points3[3][3], FracX ); + const NOISE_DATATYPE x3interp1 = CubicInterpolate( points3[0][0], points3[0][1], points3[0][2], points3[0][3], FracX); + const NOISE_DATATYPE x3interp2 = CubicInterpolate( points3[1][0], points3[1][1], points3[1][2], points3[1][3], FracX); + const NOISE_DATATYPE x3interp3 = CubicInterpolate( points3[2][0], points3[2][1], points3[2][2], points3[2][3], FracX); + const NOISE_DATATYPE x3interp4 = CubicInterpolate( points3[3][0], points3[3][1], points3[3][2], points3[3][3], FracX); const NOISE_DATATYPE points4[4][4] = { - { IntNoise3D( BaseX-1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2 ), }, - { IntNoise3D( BaseX-1, BaseY, BaseZ+2 ), IntNoise3D( BaseX, BaseY, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY, BaseZ+2 ), }, - { IntNoise3D( BaseX-1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2 ), }, - { IntNoise3D( BaseX-1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ+2 ), }, + { IntNoise3D( BaseX-1, BaseY-1, BaseZ+2), IntNoise3D( BaseX, BaseY-1, BaseZ+2), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2), }, + { IntNoise3D( BaseX-1, BaseY, BaseZ+2), IntNoise3D( BaseX, BaseY, BaseZ+2), IntNoise3D( BaseX+1, BaseY, BaseZ+2), IntNoise3D( BaseX+2, BaseY, BaseZ+2), }, + { IntNoise3D( BaseX-1, BaseY+1, BaseZ+2), IntNoise3D( BaseX, BaseY+1, BaseZ+2), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2), }, + { IntNoise3D( BaseX-1, BaseY+2, BaseZ+2), IntNoise3D( BaseX, BaseY+2, BaseZ+2), IntNoise3D( BaseX+1, BaseY+2, BaseZ+2), IntNoise3D( BaseX+2, BaseY+2, BaseZ+2), }, }; - const NOISE_DATATYPE x4interp1 = CubicInterpolate( points4[0][0], points4[0][1], points4[0][2], points4[0][3], FracX ); - const NOISE_DATATYPE x4interp2 = CubicInterpolate( points4[1][0], points4[1][1], points4[1][2], points4[1][3], FracX ); - const NOISE_DATATYPE x4interp3 = CubicInterpolate( points4[2][0], points4[2][1], points4[2][2], points4[2][3], FracX ); - const NOISE_DATATYPE x4interp4 = CubicInterpolate( points4[3][0], points4[3][1], points4[3][2], points4[3][3], FracX ); + const NOISE_DATATYPE x4interp1 = CubicInterpolate( points4[0][0], points4[0][1], points4[0][2], points4[0][3], FracX); + const NOISE_DATATYPE x4interp2 = CubicInterpolate( points4[1][0], points4[1][1], points4[1][2], points4[1][3], FracX); + const NOISE_DATATYPE x4interp3 = CubicInterpolate( points4[2][0], points4[2][1], points4[2][2], points4[2][3], FracX); + const NOISE_DATATYPE x4interp4 = CubicInterpolate( points4[3][0], points4[3][1], points4[3][2], points4[3][3], FracX); const NOISE_DATATYPE FracY = (a_Y) - BaseY; - const NOISE_DATATYPE yinterp1 = CubicInterpolate( x1interp1, x1interp2, x1interp3, x1interp4, FracY ); - const NOISE_DATATYPE yinterp2 = CubicInterpolate( x2interp1, x2interp2, x2interp3, x2interp4, FracY ); - const NOISE_DATATYPE yinterp3 = CubicInterpolate( x3interp1, x3interp2, x3interp3, x3interp4, FracY ); - const NOISE_DATATYPE yinterp4 = CubicInterpolate( x4interp1, x4interp2, x4interp3, x4interp4, FracY ); + const NOISE_DATATYPE yinterp1 = CubicInterpolate( x1interp1, x1interp2, x1interp3, x1interp4, FracY); + const NOISE_DATATYPE yinterp2 = CubicInterpolate( x2interp1, x2interp2, x2interp3, x2interp4, FracY); + const NOISE_DATATYPE yinterp3 = CubicInterpolate( x3interp1, x3interp2, x3interp3, x3interp4, FracY); + const NOISE_DATATYPE yinterp4 = CubicInterpolate( x4interp1, x4interp2, x4interp3, x4interp4, FracY); const NOISE_DATATYPE FracZ = (a_Z) - BaseZ; - return CubicInterpolate( yinterp1, yinterp2, yinterp3, yinterp4, FracZ ); + return CubicInterpolate( yinterp1, yinterp2, yinterp3, yinterp4, FracZ); } diff --git a/src/OSSupport/Errors.cpp b/src/OSSupport/Errors.cpp index 02de28e4e..9401ec257 100644 --- a/src/OSSupport/Errors.cpp +++ b/src/OSSupport/Errors.cpp @@ -3,7 +3,7 @@ #include "Errors.h" -AString GetOSErrorString( int a_ErrNo ) +AString GetOSErrorString( int a_ErrNo) { char buffer[ 1024 ]; AString Out; @@ -22,10 +22,10 @@ AString GetOSErrorString( int a_ErrNo ) // According to http://linux.die.net/man/3/strerror_r there are two versions of strerror_r(): - #if !defined(__APPLE__) && ( _GNU_SOURCE ) && !defined(ANDROID_NDK) // GNU version of strerror_r() + #if !defined(__APPLE__) && ( _GNU_SOURCE) && !defined(ANDROID_NDK) // GNU version of strerror_r() - char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) ); - if (res != NULL ) + char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer)); + if (res != NULL) { Printf(Out, "%d: %s", a_ErrNo, res); return Out; @@ -33,8 +33,8 @@ AString GetOSErrorString( int a_ErrNo ) #else // XSI version of strerror_r(): - int res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) ); - if (res == 0 ) + int res = strerror_r( errno, buffer, ARRAYCOUNT(buffer)); + if (res == 0) { Printf(Out, "%d: %s", a_ErrNo, buffer); return Out; diff --git a/src/OSSupport/Event.cpp b/src/OSSupport/Event.cpp index 72bce4c3c..74f823216 100644 --- a/src/OSSupport/Event.cpp +++ b/src/OSSupport/Event.cpp @@ -32,7 +32,7 @@ cEvent::cEvent(void) AString EventName; Printf(EventName, "cEvent%p", this); - m_Event = sem_open(EventName.c_str(), O_CREAT, 777, 0 ); + m_Event = sem_open(EventName.c_str(), O_CREAT, 777, 0); if (m_Event == SEM_FAILED) { AString error = GetOSErrorString(errno); @@ -90,7 +90,7 @@ void cEvent::Wait(void) } #else int res = sem_wait(m_Event); - if (res != 0 ) + if (res != 0) { AString error = GetOSErrorString(errno); LOGWARN("cEvent: waiting for the event failed: %i, err = %s. Continuing, but server may be unstable.", res, error.c_str()); diff --git a/src/OSSupport/Semaphore.cpp b/src/OSSupport/Semaphore.cpp index cb9ccc83b..c1fc7d9c7 100644 --- a/src/OSSupport/Semaphore.cpp +++ b/src/OSSupport/Semaphore.cpp @@ -5,9 +5,9 @@ -cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* = 0 */ ) +cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* = 0 */) #ifndef _WIN32 - : m_bNamed( false ) + : m_bNamed( false) #endif { #ifndef _WIN32 @@ -20,15 +20,15 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* m_bNamed = true; AString Name; - Printf(Name, "cSemaphore%p", this ); + Printf(Name, "cSemaphore%p", this); m_Handle = sem_open(Name.c_str(), O_CREAT, 777, a_InitialCount); - if (m_Handle == SEM_FAILED ) + if (m_Handle == SEM_FAILED) { - LOG("ERROR: Could not create Semaphore. (%i)", errno ); + LOG("ERROR: Could not create Semaphore. (%i)", errno); } else { - if (sem_unlink(Name.c_str()) != 0 ) + if (sem_unlink(Name.c_str()) != 0) { LOG("ERROR: Could not unlink cSemaphore. (%i)", errno); } @@ -51,18 +51,18 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* cSemaphore::~cSemaphore() { #ifdef _WIN32 - CloseHandle( m_Handle ); + CloseHandle( m_Handle); #else - if (m_bNamed ) + if (m_bNamed) { - if (sem_close( (sem_t*)m_Handle ) != 0 ) + if (sem_close( (sem_t*)m_Handle) != 0) { LOG("ERROR: Could not close cSemaphore. (%i)", errno); } } else { - sem_destroy( (sem_t*)m_Handle ); + sem_destroy( (sem_t*)m_Handle); delete (sem_t*)m_Handle; } m_Handle = 0; @@ -77,7 +77,7 @@ cSemaphore::~cSemaphore() void cSemaphore::Wait() { #ifndef _WIN32 - if (sem_wait( (sem_t*)m_Handle ) != 0) + if (sem_wait( (sem_t*)m_Handle) != 0) { LOG("ERROR: Could not wait for cSemaphore. (%i)", errno); } @@ -93,12 +93,12 @@ void cSemaphore::Wait() void cSemaphore::Signal() { #ifndef _WIN32 - if (sem_post( (sem_t*)m_Handle ) != 0 ) + if (sem_post( (sem_t*)m_Handle) != 0) { LOG("ERROR: Could not signal cSemaphore. (%i)", errno); } #else - ReleaseSemaphore( m_Handle, 1, NULL ); + ReleaseSemaphore( m_Handle, 1, NULL); #endif } diff --git a/src/OSSupport/Semaphore.h b/src/OSSupport/Semaphore.h index ac574e8a1..adc531ed8 100644 --- a/src/OSSupport/Semaphore.h +++ b/src/OSSupport/Semaphore.h @@ -3,7 +3,7 @@ class cSemaphore { public: - cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount = 0 ); + cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount = 0); ~cSemaphore(); void Wait(); diff --git a/src/OSSupport/Sleep.cpp b/src/OSSupport/Sleep.cpp index 223a8b855..297d668d7 100644 --- a/src/OSSupport/Sleep.cpp +++ b/src/OSSupport/Sleep.cpp @@ -9,7 +9,7 @@ -void cSleep::MilliSleep( unsigned int a_MilliSeconds ) +void cSleep::MilliSleep( unsigned int a_MilliSeconds) { #ifdef _WIN32 Sleep(a_MilliSeconds); // Don't tick too much diff --git a/src/OSSupport/Sleep.h b/src/OSSupport/Sleep.h index 0ec0adf9d..57d29682c 100644 --- a/src/OSSupport/Sleep.h +++ b/src/OSSupport/Sleep.h @@ -3,5 +3,5 @@ class cSleep { public: - static void MilliSleep( unsigned int a_MilliSeconds ); + static void MilliSleep( unsigned int a_MilliSeconds); }; diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp index 811e7cb21..faaccce96 100644 --- a/src/OSSupport/Thread.cpp +++ b/src/OSSupport/Thread.cpp @@ -47,13 +47,13 @@ static void SetThreadName(DWORD dwThreadID, const char * threadName) -cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName /* = 0 */ ) - : m_ThreadFunction( a_ThreadFunction ) - , m_Param( a_Param ) - , m_Event( new cEvent() ) - , m_StopEvent( 0 ) +cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName /* = 0 */) + : m_ThreadFunction( a_ThreadFunction) + , m_Param( a_Param) + , m_Event( new cEvent()) + , m_StopEvent( 0) { - if (a_ThreadName ) + if (a_ThreadName) { m_ThreadName.assign(a_ThreadName); } @@ -68,7 +68,7 @@ cThread::~cThread() delete m_Event; m_Event = NULL; - if (m_StopEvent ) + if (m_StopEvent) { m_StopEvent->Wait(); delete m_StopEvent; @@ -80,14 +80,14 @@ cThread::~cThread() -void cThread::Start( bool a_bWaitOnDelete /* = true */ ) +void cThread::Start( bool a_bWaitOnDelete /* = true */) { - if (a_bWaitOnDelete ) + if (a_bWaitOnDelete) m_StopEvent = new cEvent(); #ifndef _WIN32 pthread_t SndThread; - if (pthread_create( &SndThread, NULL, MyThread, this) ) + if (pthread_create( &SndThread, NULL, MyThread, this)) LOGERROR("ERROR: Could not create thread!"); #else DWORD ThreadID = 0; @@ -96,8 +96,8 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ ) , (LPTHREAD_START_ROUTINE) MyThread // function name , this // parameters , 0 // flags - , &ThreadID ); // thread id - CloseHandle( hThread ); + , &ThreadID); // thread id + CloseHandle( hThread); #ifdef _MSC_VER if (!m_ThreadName.empty()) @@ -116,9 +116,9 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ ) #ifdef _WIN32 -unsigned long cThread::MyThread(void* a_Param ) +unsigned long cThread::MyThread(void* a_Param) #else -void *cThread::MyThread( void *a_Param ) +void *cThread::MyThread( void *a_Param) #endif { cThread* self = (cThread*)a_Param; @@ -130,8 +130,8 @@ void *cThread::MyThread( void *a_Param ) // Set event to let other thread know this thread has been created and it's safe to delete the cThread object self->m_Event->Set(); - ThreadFunction( ThreadParam ); + ThreadFunction( ThreadParam); - if (StopEvent ) StopEvent->Set(); + if (StopEvent) StopEvent->Set(); return 0; } diff --git a/src/OSSupport/Thread.h b/src/OSSupport/Thread.h index 4153b2427..7ee352c82 100644 --- a/src/OSSupport/Thread.h +++ b/src/OSSupport/Thread.h @@ -4,18 +4,18 @@ class cThread { public: typedef void (ThreadFunc)(void*); - cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName = 0 ); + cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName = 0); ~cThread(); - void Start( bool a_bWaitOnDelete = true ); + void Start( bool a_bWaitOnDelete = true); void WaitForThread(); private: ThreadFunc* m_ThreadFunction; #ifdef _WIN32 - static unsigned long MyThread(void* a_Param ); + static unsigned long MyThread(void* a_Param); #else - static void *MyThread( void *lpParam ); + static void *MyThread( void *lpParam); #endif void* m_Param; diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index 00eeadd10..c5ba7a679 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -120,7 +120,7 @@ public: virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) = 0; virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) = 0; virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) = 0; - virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) = 0; + virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) = 0; virtual void SendWeather (eWeather a_Weather) = 0; virtual void SendWholeInventory (const cWindow & a_Window) = 0; virtual void SendWindowClose (const cWindow & a_Window) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 1ac035e26..cad47e6c2 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -1116,7 +1116,7 @@ void cProtocol125::SendUpdateSign( -void cProtocol125::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) +void cProtocol125::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) { cCSLock Lock(m_CSPacket); WriteByte(PACKET_USE_BED); @@ -1135,7 +1135,7 @@ void cProtocol125::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_Bloc void cProtocol125::SendWeather(eWeather a_Weather) { cCSLock Lock(m_CSPacket); - switch( a_Weather ) + switch (a_Weather) { case eWeather_Sunny: { @@ -1454,7 +1454,7 @@ int cProtocol125::ParseHandshake(void) LOGD("HANDSHAKE %s", Username.c_str()); - if (!m_Client->HandleHandshake( m_Username )) + if (!m_Client->HandleHandshake( m_Username)) { return PARSE_OK; // Player is not allowed into the server } @@ -1916,7 +1916,7 @@ void cProtocol125::WriteEntityMetadata(const cEntity & a_Entity) { WriteByte(0x51); // No idea how Mojang makes their carts shakey shakey, so here is a complicated one-liner expression that does something similar - WriteInt( (((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4 ); + WriteInt( (((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4); WriteByte(0x52); WriteInt(1); // Shaking direction, doesn't seem to affect anything WriteByte(0x73); diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 588dd3473..d7ebf535b 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -92,7 +92,7 @@ public: virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override; virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override {}; virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override; - virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) override; + virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void SendWeather (eWeather a_Weather) override; virtual void SendWholeInventory (const cWindow & a_Window) override; virtual void SendWindowClose (const cWindow & a_Window) override; @@ -124,7 +124,7 @@ protected: /// Sends the Handshake packet void SendHandshake(const AString & a_ConnectionHash); - /// Parse the packet of the specified type from m_ReceivedData (switch into ParseXYZ() ) + /// Parse the packet of the specified type from m_ReceivedData (switch into ParseXYZ()) virtual int ParsePacket(unsigned char a_PacketType); // Specific packet parsers: diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index 8502702e8..5c58ab0ba 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -474,7 +474,7 @@ int cProtocol132::ParseHandshake(void) HANDLE_PACKET_READ(ReadBEInt, int, ServerPort); m_Username = Username; - if (!m_Client->HandleHandshake( m_Username )) + if (!m_Client->HandleHandshake( m_Username)) { return PARSE_OK; // Player is not allowed into the server } diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index e635a62c1..1a91d5203 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -124,7 +124,7 @@ public: virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override; virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override; virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override; - virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) override; + virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void SendWeather (eWeather a_Weather) override; virtual void SendWholeInventory (const cWindow & a_Window) override; virtual void SendWindowClose (const cWindow & a_Window) override; diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 205407a5b..bf46a15ef 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -756,7 +756,7 @@ void cProtocolRecognizer::SendUpdateSign(int a_BlockX, int a_BlockY, int a_Block -void cProtocolRecognizer::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) +void cProtocolRecognizer::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) { ASSERT(m_Protocol != NULL); m_Protocol->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ); diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 6bfd73d74..02143f17f 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -127,7 +127,7 @@ public: virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override; virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override; virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override; - virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) override; + virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void SendWeather (eWeather a_Weather) override; virtual void SendWholeInventory (const cWindow & a_Window) override; virtual void SendWindowClose (const cWindow & a_Window) override; diff --git a/src/Root.cpp b/src/Root.cpp index e195b59ff..b03a13382 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -191,8 +191,8 @@ void cRoot::Start(void) #if !defined(ANDROID_NDK) LOGD("Starting InputThread..."); - m_InputThread = new cThread( InputThread, this, "cRoot::InputThread" ); - m_InputThread->Start( false ); // We should NOT wait? Otherwise we can't stop the server from other threads than the input thread + m_InputThread = new cThread( InputThread, this, "cRoot::InputThread"); + m_InputThread->Start( false); // We should NOT wait? Otherwise we can't stop the server from other threads than the input thread #endif long long finishmseconds = Time.GetNowTime(); @@ -269,12 +269,12 @@ void cRoot::LoadWorlds(cIniFile & IniFile) { // First get the default world AString DefaultWorldName = IniFile.GetValueSet("Worlds", "DefaultWorld", "world"); - m_pDefaultWorld = new cWorld( DefaultWorldName.c_str() ); + m_pDefaultWorld = new cWorld( DefaultWorldName.c_str()); m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld; // Then load the other worlds unsigned int KeyNum = IniFile.FindKey("Worlds"); - unsigned int NumWorlds = IniFile.GetNumValues( KeyNum ); + unsigned int NumWorlds = IniFile.GetNumValues( KeyNum); if (NumWorlds <= 0) { return; @@ -283,18 +283,18 @@ void cRoot::LoadWorlds(cIniFile & IniFile) bool FoundAdditionalWorlds = false; for (unsigned int i = 0; i < NumWorlds; i++) { - AString ValueName = IniFile.GetValueName(KeyNum, i ); + AString ValueName = IniFile.GetValueName(KeyNum, i); if (ValueName.compare("World") != 0) { continue; } - AString WorldName = IniFile.GetValue(KeyNum, i ); + AString WorldName = IniFile.GetValue(KeyNum, i); if (WorldName.empty()) { continue; } FoundAdditionalWorlds = true; - cWorld* NewWorld = new cWorld( WorldName.c_str() ); + cWorld* NewWorld = new cWorld( WorldName.c_str()); m_WorldsByName[ WorldName ] = NewWorld; } // for i - Worlds @@ -359,7 +359,7 @@ void cRoot::StopWorlds(void) void cRoot::UnloadWorlds(void) { m_pDefaultWorld = NULL; - for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) + for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr) { delete itr->second; } @@ -379,10 +379,10 @@ cWorld* cRoot::GetDefaultWorld() -cWorld* cRoot::GetWorld( const AString & a_WorldName ) +cWorld* cRoot::GetWorld( const AString & a_WorldName) { - WorldMap::iterator itr = m_WorldsByName.find( a_WorldName ); - if (itr != m_WorldsByName.end() ) + WorldMap::iterator itr = m_WorldsByName.find( a_WorldName); + if (itr != m_WorldsByName.end()) return itr->second; return 0; } @@ -509,7 +509,7 @@ void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AStri int cRoot::GetTotalChunkCount(void) { int res = 0; - for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) + for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr) { res += itr->second->GetNumChunks(); } diff --git a/src/Server.cpp b/src/Server.cpp index 0990fc398..42ad133f1 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -398,7 +398,7 @@ void cServer::TickClients(float a_Dt) { if ((*itr)->IsDestroyed()) { - // Remove the client later, when CS is not held, to avoid deadlock ( http://forum.mc-server.org/showthread.php?tid=374 ) + // Remove the client later, when CS is not held, to avoid deadlock: http://forum.mc-server.org/showthread.php?tid=374 RemoveClients.push_back(*itr); itr = m_Clients.erase(itr); continue; @@ -631,7 +631,7 @@ void cServer::Shutdown(void) cRoot::Get()->SaveAllChunks(); cCSLock Lock(m_CSClients); - for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr ) + for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr) { (*itr)->Destroy(); delete *itr; diff --git a/src/Simulator/NoopRedstoneSimulator.h b/src/Simulator/NoopRedstoneSimulator.h index 4301b8aae..f9ed47982 100644 --- a/src/Simulator/NoopRedstoneSimulator.h +++ b/src/Simulator/NoopRedstoneSimulator.h @@ -28,7 +28,7 @@ public: UNUSED(a_ChunkZ); UNUSED(a_Chunk); } - virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) override { return false; } + virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType) override { return false; } virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override { UNUSED(a_BlockX); diff --git a/src/Simulator/SimulatorManager.cpp b/src/Simulator/SimulatorManager.cpp index 2bc483cbd..918bac7a1 100644 --- a/src/Simulator/SimulatorManager.cpp +++ b/src/Simulator/SimulatorManager.cpp @@ -29,7 +29,7 @@ cSimulatorManager::~cSimulatorManager() void cSimulatorManager::Simulate(float a_Dt) { m_Ticks++; - for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr ) + for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr) { if ((m_Ticks % itr->second) == 0) { @@ -45,7 +45,7 @@ void cSimulatorManager::Simulate(float a_Dt) void cSimulatorManager::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) { // m_Ticks has already been increased in Simulate() - for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr ) + for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr) { if ((m_Ticks % itr->second) == 0) { @@ -60,7 +60,7 @@ void cSimulatorManager::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cC void cSimulatorManager::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) { - for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr ) + for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr) { itr->first->WakeUp(a_BlockX, a_BlockY, a_BlockZ, a_Chunk); } diff --git a/src/Tracer.cpp b/src/Tracer.cpp index df01e9129..756147a7b 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -37,7 +37,7 @@ cTracer::~cTracer() -float cTracer::SigNum( float a_Num ) +float cTracer::SigNum( float a_Num) { if (a_Num < 0.f) return -1.f; if (a_Num > 0.f) return 1.f; @@ -59,7 +59,7 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction) step.z = (int) SigNum(dir.z); // normalize the direction vector - if (dir.SqrLength() > 0.f ) dir.Normalize(); + if (dir.SqrLength() > 0.f) dir.Normalize(); // how far we must move in the ray direction before // we encounter a new voxel in x-direction @@ -229,7 +229,7 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int if ((!a_LineOfSight && cBlockInfo::IsSolid(BlockID)) || (a_LineOfSight && (BlockID != E_BLOCK_AIR) && !IsBlockWater(BlockID))) { BlockHitPosition = pos; - int Normal = GetHitNormal(a_Start, End, pos ); + int Normal = GetHitNormal(a_Start, End, pos); if (Normal > 0) { HitNormal = m_NormalTable[Normal-1]; @@ -271,13 +271,13 @@ int LinesCross(float x0, float y0, float x1, float y1, float x2, float y2, float // Return: 0 = disjoint (no intersection) // 1 = intersection in the unique point *I0 // 2 = the segment lies in the plane -int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal ) +int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal) { Vector3f u = a_End - a_Origin; // a_Ray.P1 - S.P0; Vector3f w = a_Origin - a_PlanePos; // S.P0 - Pn.V0; - float D = a_PlaneNormal.Dot( u ); // dot(Pn.n, u); - float N = -(a_PlaneNormal.Dot( w ) ); // -dot(a_Plane.n, w); + float D = a_PlaneNormal.Dot( u); // dot(Pn.n, u); + float N = -(a_PlaneNormal.Dot( w)); // -dot(a_Plane.n, w); const float EPSILON = 0.0001f; if (fabs(D) < EPSILON) @@ -299,7 +299,7 @@ int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f return 0; // no intersection } - // Vector3f I ( a_Ray->GetOrigin() + sI * u );// S.P0 + sI * u; // compute segment intersect point + // Vector3f I ( a_Ray->GetOrigin() + sI * u);// S.P0 + sI * u; // compute segment intersect point RealHit = a_Origin + u * sI; return 1; } @@ -311,7 +311,7 @@ int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos) { Vector3i SmallBlockPos = a_BlockPos; - char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z ); + char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z); if (BlockID == E_BLOCK_AIR || IsBlockWater(BlockID)) { @@ -324,86 +324,86 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve Vector3f Look = (end - start); Look.Normalize(); - float dot = Look.Dot( Vector3f(-1, 0, 0) ); // first face normal is x -1 + float dot = Look.Dot( Vector3f(-1, 0, 0)); // first face normal is x -1 if (dot < 0) { - int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1 ); + int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1); if (Lines == 1) { - Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x, BlockPos.z, BlockPos.x, BlockPos.z + 1 ); + Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x, BlockPos.z, BlockPos.x, BlockPos.z + 1); if (Lines == 1) { - intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(-1, 0, 0) ); + intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(-1, 0, 0)); return 1; } } } - dot = Look.Dot( Vector3f(0, 0, -1) ); // second face normal is z -1 + dot = Look.Dot( Vector3f(0, 0, -1)); // second face normal is z -1 if (dot < 0) { - int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1 ); + int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1); if (Lines == 1) { - Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z, BlockPos.x, BlockPos.z, BlockPos.x + 1 ); + Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z, BlockPos.x, BlockPos.z, BlockPos.x + 1); if (Lines == 1) { - intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, 0, -1) ); + intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, 0, -1)); return 2; } } } - dot = Look.Dot( Vector3f(1, 0, 0) ); // third face normal is x 1 + dot = Look.Dot( Vector3f(1, 0, 0)); // third face normal is x 1 if (dot < 0) { - int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1 ); + int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1); if (Lines == 1) { - Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x + 1, BlockPos.z, BlockPos.x + 1, BlockPos.z + 1 ); + Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x + 1, BlockPos.z, BlockPos.x + 1, BlockPos.z + 1); if (Lines == 1) { - intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(1, 0, 0), Vector3f(1, 0, 0) ); + intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(1, 0, 0), Vector3f(1, 0, 0)); return 3; } } } - dot = Look.Dot( Vector3f(0, 0, 1) ); // fourth face normal is z 1 + dot = Look.Dot( Vector3f(0, 0, 1)); // fourth face normal is z 1 if (dot < 0) { - int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1 ); + int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1); if (Lines == 1) { - Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z + 1, BlockPos.x, BlockPos.z + 1, BlockPos.x + 1 ); + Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z + 1, BlockPos.x, BlockPos.z + 1, BlockPos.x + 1); if (Lines == 1) { - intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 0, 1), Vector3f(0, 0, 1) ); + intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 0, 1), Vector3f(0, 0, 1)); return 4; } } } - dot = Look.Dot( Vector3f(0, 1, 0) ); // fifth face normal is y 1 + dot = Look.Dot( Vector3f(0, 1, 0)); // fifth face normal is y 1 if (dot < 0) { - int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1 ); + int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1); if (Lines == 1) { - Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y + 1, BlockPos.z, BlockPos.y + 1, BlockPos.z + 1 ); + Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y + 1, BlockPos.z, BlockPos.y + 1, BlockPos.z + 1); if (Lines == 1) { - intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 1, 0), Vector3f(0, 1, 0) ); + intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 1, 0), Vector3f(0, 1, 0)); return 5; } } } - dot = Look.Dot( Vector3f(0, -1, 0) ); // sixth face normal is y -1 + dot = Look.Dot( Vector3f(0, -1, 0)); // sixth face normal is y -1 if (dot < 0) { - int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1 ); + int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1); if (Lines == 1) { - Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y, BlockPos.z, BlockPos.y, BlockPos.z + 1 ); + Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y, BlockPos.z, BlockPos.y, BlockPos.z + 1); if (Lines == 1) { - intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, -1, 0) ); + intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, -1, 0)); return 6; } } diff --git a/src/Tracer.h b/src/Tracer.h index 4d932e460..ec87d449e 100644 --- a/src/Tracer.h +++ b/src/Tracer.h @@ -48,20 +48,20 @@ public: private: /// Preps Tracer object for call of Trace function. Only used internally. - void SetValues( const Vector3f & a_Start, const Vector3f & a_Direction ); + void SetValues( const Vector3f & a_Start, const Vector3f & a_Direction); /// Calculates where on the block a collision occured, if it does occur /// Returns 0 if no intersection occured /// Returns 1 if an intersection occured at a single point /// Returns 2 if the line segment lies in the plane being checked - int intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal ); + int intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal); /// Determines which face on the block a collision occured, if it does occur /// Returns 0 if the block is air, water or no collision occured /// Return 1 through 6 for the following block faces, repectively: -x, -z, x, z, y, -y int GetHitNormal( const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos); - float SigNum( float a_Num ); + float SigNum( float a_Num); cWorld* m_World; Vector3f m_NormalTable[6]; diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 2558d15b8..2c22b41bd 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -319,9 +319,9 @@ void cWindow::OwnerDestroyed() // Close window for each player. Note that the last one needs special handling while (m_OpenedBy.size() > 1) { - (*m_OpenedBy.begin() )->CloseWindow(); + (*m_OpenedBy.begin())->CloseWindow(); } - (*m_OpenedBy.begin() )->CloseWindow(); + (*m_OpenedBy.begin())->CloseWindow(); } diff --git a/src/UI/Window.h b/src/UI/Window.h index 1872b2c20..97db0ca88 100644 --- a/src/UI/Window.h +++ b/src/UI/Window.h @@ -77,7 +77,7 @@ public: int GetWindowType(void) const { return m_WindowType; } // tolua_export cWindowOwner * GetOwner(void) { return m_Owner; } - void SetOwner( cWindowOwner * a_Owner ) { m_Owner = a_Owner; } + void SetOwner( cWindowOwner * a_Owner) { m_Owner = a_Owner; } /// Returns the total number of slots int GetNumSlots(void) const; @@ -134,7 +134,7 @@ public: // tolua_begin const AString & GetWindowTitle() const { return m_WindowTitle; } - void SetWindowTitle(const AString & a_WindowTitle ) { m_WindowTitle = a_WindowTitle; } + void SetWindowTitle(const AString & a_WindowTitle) { m_WindowTitle = a_WindowTitle; } /// Sends the UpdateWindowProperty (0x69) packet to all clients of the window virtual void SetProperty(int a_Property, int a_Value); diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index d8347e2b9..f5dc6fde7 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -374,7 +374,7 @@ AString cWebAdmin::GetDefaultPage(void) { AString Content; Content += "

    Server Name:

    "; - Content += "

    " + AString( cRoot::Get()->GetServer()->GetServerID() ) + "

    "; + Content += "

    " + AString( cRoot::Get()->GetServer()->GetServerID()) + "

    "; Content += "

    Plugins:

      "; cPluginManager * PM = cPluginManager::Get(); @@ -392,7 +392,7 @@ AString cWebAdmin::GetDefaultPage(void) cPlayerAccum PlayerAccum; cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players - if (World != NULL ) + if (World != NULL) { World->ForEachPlayer(PlayerAccum); Content.append(PlayerAccum.m_Contents); @@ -404,7 +404,7 @@ AString cWebAdmin::GetDefaultPage(void) -AString cWebAdmin::GetBaseURL( const AString& a_URL ) +AString cWebAdmin::GetBaseURL( const AString& a_URL) { return GetBaseURL(StringSplit(a_URL, "/")); } diff --git a/src/World.cpp b/src/World.cpp index c146338d7..4ddd11f59 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -617,7 +617,7 @@ void cWorld::Start(void) m_SimulatorManager->RegisterSimulator(m_FireSimulator, 1); m_Lighting.Start(this); - m_Storage.Start(this, m_StorageSchema, m_StorageCompressionFactor ); + m_Storage.Start(this, m_StorageSchema, m_StorageCompressionFactor); m_Generator.Start(m_GeneratorCallbacks, m_GeneratorCallbacks, IniFile); m_ChunkSender.Start(this); m_TickThread.Start(); diff --git a/src/World.h b/src/World.h index 5e0af6340..c78bc8c8c 100644 --- a/src/World.h +++ b/src/World.h @@ -436,10 +436,10 @@ public: // tolua_begin // Vector3i variants: - void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) { FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta ); } - BLOCKTYPE GetBlock (const Vector3i & a_Pos ) { return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z ); } - NIBBLETYPE GetBlockMeta(const Vector3i & a_Pos ) { return GetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z ); } - void SetBlockMeta(const Vector3i & a_Pos, NIBBLETYPE a_MetaData ) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData ); } + void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta); } + BLOCKTYPE GetBlock (const Vector3i & a_Pos) { return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z); } + NIBBLETYPE GetBlockMeta(const Vector3i & a_Pos) { return GetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z); } + void SetBlockMeta(const Vector3i & a_Pos, NIBBLETYPE a_MetaData) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData); } // tolua_end /** Writes the block area into the specified coords. diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index aae94141c..5382a3e01 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -196,7 +196,7 @@ cWSSCompact::cPAKFile * cWSSCompact::LoadPAKFile(const cChunkCoords & a_Chunk) // Load it anew: AString FileName; - Printf(FileName, "%s/X%i_Z%i.pak", m_World->GetName().c_str(), LayerX, LayerZ ); + Printf(FileName, "%s/X%i_Z%i.pak", m_World->GetName().c_str(), LayerX, LayerZ); cPAKFile * f = new cPAKFile(FileName, LayerX, LayerZ, m_CompressionFactor); if (f == NULL) { @@ -271,12 +271,12 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En Json::Value AllChests = a_Value.get("Chests", Json::nullValue); if (!AllChests.empty()) { - for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr ) + for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr) { std::auto_ptr ChestEntity(new cChestEntity(0, 0, 0, a_World, E_BLOCK_CHEST)); if (!ChestEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING CHEST FROM JSON!" ); + LOGWARNING("ERROR READING CHEST FROM JSON!"); } else { @@ -292,7 +292,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr DispenserEntity(new cDispenserEntity(0, 0, 0, a_World)); if (!DispenserEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING DISPENSER FROM JSON!" ); + LOGWARNING("ERROR READING DISPENSER FROM JSON!"); } else { @@ -307,7 +307,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr FlowerPotEntity(new cFlowerPotEntity(0, 0, 0, a_World)); if (!FlowerPotEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING FLOWERPOT FROM JSON!" ); + LOGWARNING("ERROR READING FLOWERPOT FROM JSON!"); } else { @@ -323,7 +323,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr FurnaceEntity(new cFurnaceEntity(0, 0, 0, E_BLOCK_FURNACE, 0, a_World)); if (!FurnaceEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING FURNACE FROM JSON!" ); + LOGWARNING("ERROR READING FURNACE FROM JSON!"); } else { @@ -353,7 +353,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr NoteEntity(new cNoteEntity(0, 0, 0, a_World)); if (!NoteEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING NOTE BLOCK FROM JSON!" ); + LOGWARNING("ERROR READING NOTE BLOCK FROM JSON!"); } else { @@ -368,7 +368,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr JukeboxEntity(new cJukeboxEntity(0, 0, 0, a_World)); if (!JukeboxEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING JUKEBOX FROM JSON!" ); + LOGWARNING("ERROR READING JUKEBOX FROM JSON!"); } else { @@ -383,7 +383,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr CommandBlockEntity(new cCommandBlockEntity(0, 0, 0, a_World)); if (!CommandBlockEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING COMMAND BLOCK FROM JSON!" ); + LOGWARNING("ERROR READING COMMAND BLOCK FROM JSON!"); } else { @@ -398,7 +398,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr MobHeadEntity(new cMobHeadEntity(0, 0, 0, a_World)); if (!MobHeadEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING MOB HEAD FROM JSON!" ); + LOGWARNING("ERROR READING MOB HEAD FROM JSON!"); } else { @@ -427,8 +427,8 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ m_LayerX(a_LayerX), m_LayerZ(a_LayerZ), m_NumDirty(0), - m_ChunkVersion( CHUNK_VERSION ), // Init with latest version - m_PakVersion( PAK_VERSION ) + m_ChunkVersion( CHUNK_VERSION), // Init with latest version + m_PakVersion( PAK_VERSION) { cFile f; if (!f.Open(m_FileName, cFile::fmRead)) @@ -445,18 +445,24 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ } READ(m_ChunkVersion); - switch( m_ChunkVersion ) + switch (m_ChunkVersion) { - case 1: - m_ChunkSize.Set(16, 128, 16); - break; - case 2: - case 3: - m_ChunkSize.Set(16, 256, 16); - break; - default: - LOGERROR("File \"%s\" is in an unknown chunk format (%d)", m_FileName.c_str(), m_ChunkVersion); - return; + case 1: + { + m_ChunkSize.Set(16, 128, 16); + break; + } + case 2: + case 3: + { + m_ChunkSize.Set(16, 256, 16); + break; + } + default: + { + LOGERROR("File \"%s\" is in an unknown chunk format (%d)", m_FileName.c_str(), m_ChunkVersion); + return; + } }; short NumChunks = 0; @@ -486,12 +492,12 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ return; } - if (m_ChunkVersion == 1 ) // Convert chunks to version 2 + if (m_ChunkVersion == 1) // Convert chunks to version 2 { UpdateChunk1To2(); } #if AXIS_ORDER == AXIS_ORDER_XZY - if (m_ChunkVersion == 2 ) // Convert chunks to version 3 + if (m_ChunkVersion == 2) // Convert chunks to version 3 { UpdateChunk2To3(); } @@ -574,9 +580,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() { sChunkHeader * Header = *itr; - if (ChunksConverted % 32 == 0 ) + if (ChunksConverted % 32 == 0) { - LOGINFO("Updating \"%s\" version 1 to version 2: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() ); + LOGINFO("Updating \"%s\" version 1 to version 2: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size()); } ChunksConverted++; @@ -627,9 +633,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() char ConvertedData[cChunkDef::BlockDataSize]; int Index = 0; unsigned int InChunkOffset = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) { - for (int y = 0; y < 128; ++y ) + for (int y = 0; y < 128; ++y) { ConvertedData[Index++] = UncompressedData[y + z * 128 + x * 128 * 16 + InChunkOffset]; } @@ -638,9 +644,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 128; } InChunkOffset += (16 * 128 * 16); - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Metadata + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) // Metadata { - for (int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -648,9 +654,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16 * 128 * 16) / 2; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Block light + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) // Block light { - for (int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -658,9 +664,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16*128*16)/2; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Sky light + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) // Sky light { - for (int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -674,7 +680,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() // Add JSON data afterwards if (UncompressedData.size() > InChunkOffset) { - Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end() ); + Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end()); } // Re-compress data @@ -702,7 +708,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() m_ChunkVersion = 2; SynchronizeFile(); - LOGINFO("Updated \"%s\" version 1 to version 2", m_FileName.c_str() ); + LOGINFO("Updated \"%s\" version 1 to version 2", m_FileName.c_str()); } @@ -718,9 +724,9 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() { sChunkHeader * Header = *itr; - if (ChunksConverted % 32 == 0 ) + if (ChunksConverted % 32 == 0) { - LOGINFO("Updating \"%s\" version 2 to version 3: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() ); + LOGINFO("Updating \"%s\" version 2 to version 3: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size()); } ChunksConverted++; @@ -771,10 +777,10 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() // Cannot use cChunk::MakeIndex because it might change again????????? // For compatibility, use what we know is current - #define MAKE_3_INDEX( x, y, z ) ( x + (z * 16) + (y * 16 * 16) ) + #define MAKE_3_INDEX( x, y, z) ( x + (z * 16) + (y * 16 * 16)) unsigned int InChunkOffset = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y) // YZX Loop order is important, in 1.1 Y was first then Z then X { ConvertedData[ MAKE_3_INDEX(x, y, z) ] = UncompressedData[InChunkOffset]; ++InChunkOffset; @@ -782,25 +788,25 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() unsigned int index2 = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y) { - ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); + ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4)) & 0x0f) << ((x&1)*4); ++index2; } InChunkOffset += index2 / 2; index2 = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y) { - ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); + ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4)) & 0x0f) << ((x&1)*4); ++index2; } InChunkOffset += index2 / 2; index2 = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y) { - ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); + ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4)) & 0x0f) << ((x&1)*4); ++index2; } InChunkOffset += index2 / 2; @@ -810,7 +816,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() // Add JSON data afterwards if (UncompressedData.size() > InChunkOffset) { - Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end() ); + Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end()); } // Re-compress data @@ -838,7 +844,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() m_ChunkVersion = 3; SynchronizeFile(); - LOGINFO("Updated \"%s\" version 2 to version 3", m_FileName.c_str() ); + LOGINFO("Updated \"%s\" version 2 to version 3", m_FileName.c_str()); } @@ -887,7 +893,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre { Json::Value root; // will contain the root value after parsing. Json::Reader reader; - if (!reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false ) ) + if (!reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false)) { LOGERROR("Failed to parse trailing JSON in chunk [%d, %d]!", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ @@ -970,7 +976,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld // Compress the data: AString CompressedData; int errorcode = CompressString(Data.data(), Data.size(), CompressedData, m_CompressionFactor); - if (errorcode != Z_OK ) + if (errorcode != Z_OK) { LOGERROR("Error %i compressing data for chunk [%d, %d, %d]", errorcode, a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ); return false; diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index d0b2acf3b..707e8f929 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -61,7 +61,7 @@ cWorldStorage::~cWorldStorage() -bool cWorldStorage::Start(cWorld * a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor ) +bool cWorldStorage::Start(cWorld * a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor) { m_World = a_World; m_StorageSchemaName = a_StorageSchemaName; diff --git a/src/main.cpp b/src/main.cpp index 3e91149af..93fa6af91 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -174,7 +174,7 @@ BOOL CtrlHandler(DWORD fdwCtrlType) //////////////////////////////////////////////////////////////////////////////// // main: -int main( int argc, char **argv ) +int main( int argc, char **argv) { UNUSED(argc); UNUSED(argv); @@ -218,7 +218,7 @@ int main( int argc, char **argv ) #endif #if defined(_DEBUG) && defined(_MSC_VER) - _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); + _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); // _X: The simple built-in CRT leak finder - simply break when allocating the Nth block ({N} is listed in the leak output) // Only useful when the leak is in the same sequence all the time @@ -281,11 +281,11 @@ int main( int argc, char **argv ) Root.Start(); } #if !defined(ANDROID_NDK) - catch( std::exception& e ) + catch( std::exception& e) { - LOGERROR("Standard exception: %s", e.what() ); + LOGERROR("Standard exception: %s", e.what()); } - catch( ... ) + catch( ...) { LOGERROR("Unknown exception!"); } -- cgit v1.2.3 From fe6a3b5d7229ae07b536afa794fdb5bedbeb37e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 15:20:27 +0200 Subject: CheckBasicStyle: Checks spaces after keywords, no space before ")". --- src/CheckBasicStyle.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index e4597a426..ddc552fa4 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -8,7 +8,7 @@ Checks that all source files (*.cpp, *.h) use the basic style requirements of th - Two spaces between code and line-end comment ("//") - Spaces after comma, not before - Opening braces not at the end of a code line - - (TODO) Spaces after if, for, while + - Spaces after if, for, while - (TODO) Spaces before *, /, & - (TODO) Hex numbers with even digit length - (TODO) Hex numbers in lowercase @@ -125,6 +125,21 @@ local g_ViolationPatterns = -- Check that opening braces are not at the end of a code line: {"[^%s].-{\n?$", "Brace should be on a separate line"}, + + -- Space after keywords: + {"[^_]if%(", "Needs a space after \"if\""}, + {"for%(", "Needs a space after \"for\""}, + {"while%(", "Needs a space after \"while\""}, + {"switch%(", "Needs a space after \"switch\""}, + + -- No space after keyword's parenthesis: + {"[^%a#]if %( ", "Remove the space after \"(\""}, + {"for %( ", "Remove the space after \"(\""}, + {"while %( ", "Remove the space after \"(\""}, + {"switch %( ", "Remove the space after \"(\""}, + + -- No space before a closing parenthesis: + {" %)", "Remove the space before \")\""}, } -- cgit v1.2.3 From 9e7b9a4ebe815bd631d8b124e81f017fc7fa35a2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 15:21:54 +0200 Subject: Normalized spaces after "catch". --- src/CheckBasicStyle.lua | 3 ++- src/main.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index ddc552fa4..fba30ea98 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -131,12 +131,13 @@ local g_ViolationPatterns = {"for%(", "Needs a space after \"for\""}, {"while%(", "Needs a space after \"while\""}, {"switch%(", "Needs a space after \"switch\""}, + {"catch%(", "Needs a space after \"catch\""}, -- No space after keyword's parenthesis: {"[^%a#]if %( ", "Remove the space after \"(\""}, {"for %( ", "Remove the space after \"(\""}, {"while %( ", "Remove the space after \"(\""}, - {"switch %( ", "Remove the space after \"(\""}, + {"catch %( ", "Remove the space after \"(\""}, -- No space before a closing parenthesis: {" %)", "Remove the space before \")\""}, diff --git a/src/main.cpp b/src/main.cpp index 93fa6af91..106233342 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -281,11 +281,11 @@ int main( int argc, char **argv) Root.Start(); } #if !defined(ANDROID_NDK) - catch( std::exception& e) + catch (std::exception & e) { LOGERROR("Standard exception: %s", e.what()); } - catch( ...) + catch (...) { LOGERROR("Unknown exception!"); } -- cgit v1.2.3 From 5194eef07d4fdb166af295bd5e6360d95175ff32 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 17:35:09 +0200 Subject: CMake: generates a list of all source files. This will be used for the style-checking script. --- src/CMakeLists.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9feaf64fe..f494b52e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -228,6 +228,26 @@ else () set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /DEBUG") endif() + +# Generate a list of all source files: +set(ALLFILES "") +foreach(folder ${FOLDERS}) + get_directory_property(FOLDER_SRCS DIRECTORY ${folder} DEFINITION SRCS) + foreach (src ${FOLDER_SRCS}) + list(APPEND ALLFILES "${folder}/${src}") + endforeach(src) + + get_directory_property(FOLDER_HDRS DIRECTORY ${folder} DEFINITION HDRS) + foreach (hdr ${FOLDER_HDRS}) + list(APPEND ALLFILES "${folder}/${hdr}") + endforeach(hdr) +endforeach(folder) +foreach(arg ${ALLFILES}) + set(ALLFILESLINES "${ALLFILESLINES}${arg}\n") +endforeach() +FILE(WRITE "AllFiles.lst" "${ALLFILESLINES}") + + set(EXECUTABLE MCServer) if (MSVC) -- cgit v1.2.3 From 26ad3dbee4aacef035e2d085fecdc5610469fc7d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 17:38:36 +0200 Subject: CheckBasicStyle: Doesn't require LuaFileSystem. Instead it uses the list of files generated by CMake. --- src/CheckBasicStyle.lua | 44 ++++++++++---------------------------------- 1 file changed, 10 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index fba30ea98..e85c074dc 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -23,26 +23,12 @@ the line brings the editor directly to the violation. Returns 0 on success, 1 on internal failure, 2 if any violations found -This script requires LuaFileSystem to be available in the current Lua interpreter. --]] --- Check that LFS is installed: -local hasLfs = pcall(require, "lfs") -if not(hasLfs) then - print("This script requires LuaFileSystem to be installed") - os.exit(1) -end -local lfs = require("lfs") -assert(lfs ~= nil) - - - - - -- The list of file extensions that are processed: local g_ShouldProcessExt = { @@ -53,13 +39,12 @@ local g_ShouldProcessExt = --- The list of files not to be processed: local g_IgnoredFiles = { - "./Bindings/Bindings.cpp", - "./Bindings/DeprecatedBindings.cpp", - "./LeakFinder.cpp", - "./LeakFinder.h", - "./MersenneTwister.h", - "./StackWalker.cpp", - "./StackWalker.h", + "Bindings/Bindings.cpp", + "LeakFinder.cpp", + "LeakFinder.h", + "MersenneTwister.h", + "StackWalker.cpp", + "StackWalker.h", } --- The list of files not to be processed, as a dictionary (filename => true), built from g_IgnoredFiles @@ -198,17 +183,6 @@ local function ProcessItem(a_ItemName) return end - -- If the item is a folder, recurse: - local attrs = lfs.attributes(a_ItemName) - if (attrs and (attrs.mode == "directory")) then - for fnam in lfs.dir(a_ItemName) do - if ((fnam ~= ".") and (fnam ~= "..")) then - ProcessItem(a_ItemName .. "/" .. fnam) - end - end - return - end - local ext = a_ItemName:match("%.([^/%.]-)$") if (g_ShouldProcessExt[ext]) then ProcessFile(a_ItemName) @@ -219,8 +193,10 @@ end --- Process the entire current folder: -ProcessItem(".") +-- Process all files in the AllFiles.lst file (generated by cmake): +for fnam in io.lines("AllFiles.lst") do + ProcessItem(fnam) +end -- Report final verdict: print("Number of violations found: " .. g_NumViolations) -- cgit v1.2.3 From 63cc008340a13428eb254e82acf886035c728025 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 17:57:50 +0200 Subject: CheckBasicStyle: Added a lua shebang. --- src/CheckBasicStyle.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index e85c074dc..13a6d15d2 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -1,3 +1,4 @@ +#!/usr/bin/env lua -- CheckBasicStyle.lua -- cgit v1.2.3 From dd0ab044810d87dc4233a652087808638c696d94 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 18:07:51 +0200 Subject: Defines.h: Fixed a warning. --- src/Defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Defines.h b/src/Defines.h index f095069d9..9f66cbf9b 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -470,7 +470,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B { int Y = a_BlockY; AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse); - a_BlockY = Clamp(Y, 0, 255); + a_BlockY = Clamp((unsigned char)Y, 0, 255); } -- cgit v1.2.3 From bea574bf5425215bbed49ad4b3814804fd8757fc Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 21 Jul 2014 18:53:56 +0200 Subject: ExtremeHillsPlus and ExtremeHills spawn with grass only Turns out only the M variants have stone and gravel in them. --- src/Generating/DistortedHeightmap.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp index b46850a81..74d30c327 100644 --- a/src/Generating/DistortedHeightmap.cpp +++ b/src/Generating/DistortedHeightmap.cpp @@ -675,6 +675,8 @@ void cDistortedHeightmap::ComposeColumn(cChunkDesc & a_ChunkDesc, int a_RelX, in case biForestHills: case biTaigaHills: case biExtremeHillsEdge: + case biExtremeHillsPlus: + case biExtremeHills: case biJungle: case biJungleHills: case biJungleEdge: @@ -750,18 +752,6 @@ void cDistortedHeightmap::ComposeColumn(cChunkDesc & a_ChunkDesc, int a_RelX, in return; } - case biExtremeHillsPlus: - case biExtremeHills: - { - // Select the pattern to use - stone or grass: - NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width + a_RelX)) / FrequencyX; - NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width + a_RelZ)) / FrequencyZ; - NOISE_DATATYPE Val = m_OceanFloorSelect.CubicNoise2D(NoiseX, NoiseY); - const sBlockInfo * Pattern = (Val < -0.1) ? patStone.Get() : patGrass.Get(); - FillColumnPattern(a_ChunkDesc, a_RelX, a_RelZ, Pattern); - return; - } - case biExtremeHillsPlusM: case biExtremeHillsM: { -- cgit v1.2.3 From 8050a5b98a3003c2a4bed39b896b4a3a4c1068c0 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 21 Jul 2014 22:49:06 +0100 Subject: Suggestions --- src/BlockID.h | 2 +- src/Chunk.cpp | 6 +-- src/ChunkMap.cpp | 1 - src/Entities/Entity.cpp | 78 +++++++++++++++------------- src/Entities/Entity.h | 30 +++++++---- src/Entities/Player.cpp | 25 ++------- src/Entities/Player.h | 2 +- src/World.cpp | 135 ++++++++++++++++++++++++++++-------------------- src/World.h | 7 +++ 9 files changed, 160 insertions(+), 126 deletions(-) (limited to 'src') diff --git a/src/BlockID.h b/src/BlockID.h index 37eed8eda..08c576886 100644 --- a/src/BlockID.h +++ b/src/BlockID.h @@ -924,7 +924,7 @@ extern int StringToMobType(const AString & a_MobString); extern eDimension StringToDimension(const AString & a_DimensionString); /** Translates a dimension enum to dimension string. -Takes a string and returns "Overworld" on failure +Takes an eDimension enum value and returns "Overworld" on failure */ extern AString DimensionToString(eDimension a_Dimension); diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 4588de9f3..7850b7e31 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -596,7 +596,7 @@ void cChunk::Tick(float a_Dt) for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) { - if ((*itr)->IsDestroyed()) // Remove all entities that were scheduled for removal: + if ((*itr)->IsDestroyed()) // Remove all entities that were scheduled for removal: { LOGD("Destroying entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass()); MarkDirty(); @@ -604,13 +604,13 @@ void cChunk::Tick(float a_Dt) itr = m_Entities.erase(itr); delete ToDelete; } - else if ((*itr)->IsWorldTravellingFrom(m_World)) // Remove all entities that are travelling to another world + else if ((*itr)->IsWorldTravellingFrom(m_World)) // Remove all entities that are travelling to another world { MarkDirty(); (*itr)->SetWorldTravellingFrom(NULL); itr = m_Entities.erase(itr); } - else if ( // If any entity moved out of the chunk, move it to the neighbor: + else if ( // If any entity moved out of the chunk, move it to the neighbor: ((*itr)->GetChunkX() != m_PosX) || ((*itr)->GetChunkZ() != m_PosZ) ) diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 3cfa5c3f5..e91f77d27 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2427,7 +2427,6 @@ bool cChunkMap::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinCh { for (int x = a_MinChunkX; x <= a_MaxChunkX; x++) { - LOG("Request %i %i", x, z); cChunkPtr Chunk = GetChunkNoLoad(x, ZERO_CHUNK_Y, z); if ((Chunk == NULL) || (!Chunk->IsValid())) { diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 4768d38ae..1254541ed 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1030,9 +1030,15 @@ void cEntity::DetectPortal() { if (GetWorld()->GetDimension() == dimOverworld) { - if (GetWorld()->GetNetherWorldName().empty() && GetWorld()->GetEndWorldName().empty()) { return; } + if (GetWorld()->GetNetherWorldName().empty() && GetWorld()->GetEndWorldName().empty()) + { + return; + } + } + else if (GetWorld()->GetLinkedOverworldName().empty()) + { + return; } - else if (GetWorld()->GetLinkedOverworldName().empty()) { return; } int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; if ((Y > 0) && (Y < cChunkDef::Height)) @@ -1041,17 +1047,17 @@ void cEntity::DetectPortal() { case E_BLOCK_NETHER_PORTAL: { - if (m_PortalCooldownData.second) + if (m_PortalCooldownData.m_ShouldPreventTeleportation) { return; } - if (m_PortalCooldownData.first != 80) + if (IsPlayer() && !((cPlayer *)this)->IsGameModeCreative() && m_PortalCooldownData.m_TicksDelayed != 80) { - m_PortalCooldownData.first++; + m_PortalCooldownData.m_TicksDelayed++; return; } - m_PortalCooldownData.first = 0; + m_PortalCooldownData.m_TicksDelayed = 0; switch (GetWorld()->GetDimension()) { @@ -1062,13 +1068,13 @@ void cEntity::DetectPortal() return; } - m_PortalCooldownData.second = true; // Stop portals from working on respawn + m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn if (IsPlayer()) { ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimOverworld); } - MoveToWorld(GetWorld()->GetLinkedOverworldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false); + MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false); return; } @@ -1079,14 +1085,14 @@ void cEntity::DetectPortal() return; } - m_PortalCooldownData.second = true; // Stop portals from working on respawn + m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn if (IsPlayer()) { ((cPlayer *)this)->AwardAchievement(achEnterPortal); ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimNether); } - MoveToWorld(GetWorld()->GetNetherWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetNetherWorldName(), dimNether, GetWorld()->GetName()), false); + MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetNetherWorldName(), dimNether, GetWorld()->GetName()), false); return; } @@ -1095,7 +1101,7 @@ void cEntity::DetectPortal() } case E_BLOCK_END_PORTAL: { - if (m_PortalCooldownData.second) + if (m_PortalCooldownData.m_ShouldPreventTeleportation) { return; } @@ -1109,7 +1115,7 @@ void cEntity::DetectPortal() return; } - m_PortalCooldownData.second = true; // Stop portals from working on respawn + m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn if (IsPlayer()) { @@ -1117,7 +1123,7 @@ void cEntity::DetectPortal() Player->TeleportToCoords(Player->GetLastBedPos().x, Player->GetLastBedPos().y, Player->GetLastBedPos().z); Player->GetClientHandle()->SendRespawn(dimOverworld); } - MoveToWorld(GetWorld()->GetLinkedOverworldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false); + MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false); return; } @@ -1128,14 +1134,14 @@ void cEntity::DetectPortal() return; } - m_PortalCooldownData.second = true; // Stop portals from working on respawn + m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn if (IsPlayer()) { ((cPlayer *)this)->AwardAchievement(achEnterTheEnd); ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimEnd); } - MoveToWorld(GetWorld()->GetEndWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetEndWorldName(), dimEnd, GetWorld()->GetName()), false); + MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetEndWorldName(), dimEnd, GetWorld()->GetName()), false); return; } @@ -1147,34 +1153,20 @@ void cEntity::DetectPortal() } // Allow portals to work again - m_PortalCooldownData.second = false; - m_PortalCooldownData.first = 0; + m_PortalCooldownData.m_ShouldPreventTeleportation = false; + m_PortalCooldownData.m_ShouldPreventTeleportation = 0; } -bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ShouldSendRespawn) +bool cEntity::MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) { UNUSED(a_ShouldSendRespawn); + ASSERT(a_World == NULL); - cWorld * World; - if (a_World == NULL) - { - World = cRoot::Get()->GetWorld(a_WorldName); - if (World == NULL) - { - LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName.c_str()); - return false; - } - } - else - { - World = a_World; - } - - if (GetWorld() == World) + if (GetWorld() == a_World) { // Don't move to same world return false; @@ -1185,7 +1177,7 @@ bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ GetWorld()->BroadcastDestroyEntity(*this); // Queue add to new world - World->AddEntity(this); + a_World->AddEntity(this); return true; } @@ -1194,6 +1186,22 @@ bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ +bool cEntity::MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn) +{ + cWorld * World = cRoot::Get()->GetWorld(a_WorldName); + if (World == NULL) + { + LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName.c_str()); + return false; + } + + return MoveToWorld(World, a_ShouldSendRespawn); +} + + + + + void cEntity::SetSwimState(cChunk & a_Chunk) { int RelY = (int)floor(GetPosY() + 0.1); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index eea48a12f..58254a493 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -382,16 +382,19 @@ public: /// Teleports to the coordinates specified virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ); - /** Moves entity to specified world */ - virtual bool MoveToWorld(const AString & a_WorldName, cWorld * a_World = NULL, bool a_ShouldSendRespawn = true); + /** Moves entity to specified world, taking a world pointer */ + virtual bool MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn = true); + + /** Moves entity to specified world, taking a world name */ + bool MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn = true); // tolua_end /** Returns if the entity is travelling away from a specified world */ - bool IsWorldTravellingFrom(cWorld * a_World) const { return (m_WorldTravellingFrom == a_World); } + bool IsWorldTravellingFrom(cWorld * a_World) const { return m_WorldTravellingFrom == a_World; } /** Sets the world the entity will be leaving */ - void SetWorldTravellingFrom(cWorld * a_World) { (m_WorldTravellingFrom = a_World); } + void SetWorldTravellingFrom(cWorld * a_World) { m_WorldTravellingFrom = a_World; } /// Updates clients of changes in the entity. virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = NULL); @@ -538,11 +541,20 @@ protected: int m_AirLevel; int m_AirTickTimer; - /** Portal delay timer and cooldown boolean - First value is to delay sending the respawn packet (which triggers the Entering the {Dimension} screen). - Second value is to prevent a teleportation loop by ensuring we do not reenter a portal that we came out of. - */ - std::pair m_PortalCooldownData; + /** Structure storing the portal delay timer and cooldown boolean */ + struct sPortalCooldownData + { + /** Ticks since entry of portal, used to delay teleportation */ + unsigned short m_TicksDelayed; + + /** Whether the entity has just exited the portal, and should therefore not be teleported again + This prevents teleportation loops, and is reset when the entity has moved out of the portal + */ + bool m_ShouldPreventTeleportation; + }; + + /** Portal delay timer and cooldown boolean data */ + sPortalCooldownData m_PortalCooldownData; private: /** Measured in degrees, [-180, +180) */ diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 0b1b4ce5f..1159891cd 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1611,24 +1611,9 @@ void cPlayer::TossItems(const cItems & a_Items) -bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ShouldSendRespawn) +bool cPlayer::MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) { - cWorld * World; - if (a_World == NULL) - { - World = cRoot::Get()->GetWorld(a_WorldName); - if (World == NULL) - { - LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName.c_str()); - return false; - } - } - else - { - World = a_World; - } - - if (GetWorld() == World) + if (GetWorld() == a_World) { // Don't move to same world return false; @@ -1637,7 +1622,7 @@ bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ // Send the respawn packet: if (a_ShouldSendRespawn && (m_ClientHandle != NULL)) { - m_ClientHandle->SendRespawn(World->GetDimension()); + m_ClientHandle->SendRespawn(a_World->GetDimension()); } // Remove player from the old world @@ -1645,8 +1630,8 @@ bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World, bool a_ GetWorld()->RemovePlayer(this); // Queue adding player to the new world, including all the necessary adjustments to the object - World->AddPlayer(this); - SetWorld(World); + a_World->AddPlayer(this); + SetWorld(a_World); // Chunks may be streamed before cWorld::AddPlayer() sets the world to the new value return true; } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 226ec5e68..f972063bb 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -333,7 +333,7 @@ public: /** Moves the player to the specified world. Returns true if successful, false on failure (world not found). */ - virtual bool MoveToWorld(const AString & a_WorldName, cWorld * a_World = NULL, bool a_ShouldSendRespawn = true) override; // tolua_export + virtual bool MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn = true) override; // tolua_export /** Saves all player data, such as inventory, to JSON */ bool SaveToDisk(void); diff --git a/src/World.cpp b/src/World.cpp index d27ad1eb4..2af8fc59e 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -512,7 +512,7 @@ void cWorld::InitializeSpawn(void) -void cWorld::Start() +void cWorld::Start(void) { m_SpawnX = 0; m_SpawnY = cChunkDef::Height; @@ -594,61 +594,8 @@ void cWorld::Start() m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll); m_Weather = (eWeather) Clamp(Weather, (int)wSunny, (int)wStorm); - switch (GetDimension()) - { - case dimEnd: - { - IniFile.GetValueSet("Generator", "BiomeGen", "Constant"); - IniFile.GetValueSet("Generator", "ConstantBiome", "End"); - IniFile.GetValueSet("Generator", "HeightGen", "Biomal"); - IniFile.GetValueSet("Generator", "CompositionGen", "End"); - break; - } - case dimOverworld: - { - IniFile.GetValueSet("Generator", "BiomeGen", "MultiStepMap"); - IniFile.GetValueSet("Generator", "HeightGen", "DistortedHeightmap"); - IniFile.GetValueSet("Generator", "CompositionGen", "DistortedHeightmap"); - IniFile.GetValueSet("Generator", "Finishers", "Ravines, WormNestCaves, WaterLakes, WaterSprings, LavaLakes, LavaSprings, OreNests, Mineshafts, Trees, SprinkleFoliage, Ice, Snow, Lilypads, BottomLava, DeadBushes, PreSimulator"); - break; - } - case dimNether: - { - IniFile.GetValueSet("Generator", "BiomeGen", "Constant"); - IniFile.GetValueSet("Generator", "ConstantBiome", "Nether"); - IniFile.GetValueSet("Generator", "HeightGen", "Flat"); - IniFile.GetValueSet("Generator", "FlatHeight", "128"); - IniFile.GetValueSet("Generator", "CompositionGen", "Nether"); - IniFile.GetValueSet("Generator", "Finishers", "WormNestCaves, BottomLava, LavaSprings, NetherClumpFoliage, NetherForts, PreSimulator"); - IniFile.GetValueSet("Generator", "BottomLavaHeight", "30"); - break; - } - } - - // Load allowed mobs: - const char * DefaultMonsters = ""; - switch (m_Dimension) - { - case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, enderman, horse, mooshroom, ocelot, pig, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break; - case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break; - case dimEnd: DefaultMonsters = "enderman"; break; - } - m_bAnimals = IniFile.GetValueSetB("Monsters", "AnimalsOn", true); - AString AllMonsters = IniFile.GetValueSet("Monsters", "Types", DefaultMonsters); - AStringVector SplitList = StringSplitAndTrim(AllMonsters, ","); - for (AStringVector::const_iterator itr = SplitList.begin(), end = SplitList.end(); itr != end; ++itr) - { - cMonster::eType ToAdd = cMonster::StringToMobType(*itr); - if (ToAdd != cMonster::mtInvalidType) - { - m_AllowedMobs.insert(ToAdd); - LOGD("Allowed mob: %s", itr->c_str()); - } - else - { - LOG("World \"%s\": Unknown mob type: %s", m_WorldName.c_str(), itr->c_str()); - } - } + InitialiseGeneratorDefaults(IniFile); + InitialiseAndLoadMobSpawningValues(IniFile); m_ChunkMap = new cChunkMap(this); @@ -745,6 +692,82 @@ eWeather cWorld::ChooseNewWeather() +void cWorld::InitialiseGeneratorDefaults(cIniFile & a_IniFile) +{ + switch (GetDimension()) + { + case dimEnd: + { + a_IniFile.GetValueSet("Generator", "BiomeGen", "Constant"); + a_IniFile.GetValueSet("Generator", "ConstantBiome", "End"); + a_IniFile.GetValueSet("Generator", "HeightGen", "Biomal"); + a_IniFile.GetValueSet("Generator", "CompositionGen", "End"); + break; + } + case dimOverworld: + { + a_IniFile.GetValueSet("Generator", "BiomeGen", "MultiStepMap"); + a_IniFile.GetValueSet("Generator", "HeightGen", "DistortedHeightmap"); + a_IniFile.GetValueSet("Generator", "CompositionGen", "DistortedHeightmap"); + a_IniFile.GetValueSet("Generator", "Finishers", "Ravines, WormNestCaves, WaterLakes, WaterSprings, LavaLakes, LavaSprings, OreNests, Mineshafts, Trees, SprinkleFoliage, Ice, Snow, Lilypads, BottomLava, DeadBushes, PreSimulator"); + break; + } + case dimNether: + { + a_IniFile.GetValueSet("Generator", "BiomeGen", "Constant"); + a_IniFile.GetValueSet("Generator", "ConstantBiome", "Nether"); + a_IniFile.GetValueSet("Generator", "HeightGen", "Flat"); + a_IniFile.GetValueSet("Generator", "FlatHeight", "128"); + a_IniFile.GetValueSet("Generator", "CompositionGen", "Nether"); + a_IniFile.GetValueSet("Generator", "Finishers", "WormNestCaves, BottomLava, LavaSprings, NetherClumpFoliage, NetherForts, PreSimulator"); + a_IniFile.GetValueSet("Generator", "BottomLavaHeight", "30"); + break; + } + } +} + + + + + +void cWorld::InitialiseAndLoadMobSpawningValues(cIniFile & a_IniFile) +{ + AString DefaultMonsters; + switch (m_Dimension) + { + case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, enderman, horse, mooshroom, ocelot, pig, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break; + case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break; + case dimEnd: DefaultMonsters = "enderman"; break; + } + + m_bAnimals = a_IniFile.GetValueSetB("Monsters", "AnimalsOn", true); + AString AllMonsters = a_IniFile.GetValueSet("Monsters", "Types", DefaultMonsters); + + if (!m_bAnimals) + { + return; + } + + AStringVector SplitList = StringSplitAndTrim(AllMonsters, ","); + for (AStringVector::const_iterator itr = SplitList.begin(), end = SplitList.end(); itr != end; ++itr) + { + cMonster::eType ToAdd = cMonster::StringToMobType(*itr); + if (ToAdd != cMonster::mtInvalidType) + { + m_AllowedMobs.insert(ToAdd); + LOGD("Allowed mob: %s", itr->c_str()); + } + else + { + LOG("World \"%s\": Unknown mob type: %s", m_WorldName.c_str(), itr->c_str()); + } + } +} + + + + + void cWorld::Stop(void) { // Delete the clients that have been in this world: diff --git a/src/World.h b/src/World.h index 09cbc6b48..879da3cb9 100644 --- a/src/World.h +++ b/src/World.h @@ -1030,6 +1030,13 @@ private: /** Adds the players queued in the m_PlayersToAdd queue into the m_Players list. Assumes it is called from the Tick thread. */ void AddQueuedPlayers(void); + + /** Sets generator values to dimension specific defaults, if those values do not exist */ + void InitialiseGeneratorDefaults(cIniFile & a_IniFile); + + /** Sets mob spawning values if nonexistant to their dimension specific defaults */ + void InitialiseAndLoadMobSpawningValues(cIniFile & a_IniFile); + }; // tolua_export -- cgit v1.2.3 From 31b22e14b719e84d2e828ae474d9c6f596024a37 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 22 Jul 2014 10:04:53 +0200 Subject: Updated prefabs to current Gallery content. --- src/Generating/Prefabs/AlchemistVillagePrefabs.cpp | 38 +- src/Generating/Prefabs/JapaneseVillagePrefabs.cpp | 48 ++- src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 383 ++++++++++----------- 3 files changed, 243 insertions(+), 226 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp index 8c935c2a5..c08e53ef6 100644 --- a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp +++ b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp @@ -2367,9 +2367,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "a: 24: 2\n" /* sandstone */ "b: 4: 0\n" /* cobblestone */ "c: 24: 0\n" /* sandstone */ - "d: 12: 0\n" /* sand */ - "e: 13: 0\n" /* gravel */ - "f: 5: 0\n" /* wood */ + "d: 13: 0\n" /* gravel */ + "e: 5: 0\n" /* wood */ + "f: 12: 0\n" /* sand */ "g: 64: 3\n" /* wooddoorblock */ "h: 85: 0\n" /* fence */ "i: 64: 0\n" /* wooddoorblock */ @@ -2392,26 +2392,26 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* * 012345678901234 */ /* 0 */ "mmmabbbammmmmmm" /* 1 */ "mmmmbbbmmmmmmmm" - /* 2 */ "acccccccccadddd" - /* 3 */ "cccccccccccdddd" - /* 4 */ "cccccccccccdddd" - /* 5 */ "cccccccccccdddd" - /* 6 */ "cccccccccccdddd" - /* 7 */ "cccccccccccdddd" - /* 8 */ "acccccccccadddd" + /* 2 */ "acccccccccacccc" + /* 3 */ "ccccccccccccccc" + /* 4 */ "ccccccccccccccc" + /* 5 */ "ccccccccccccccc" + /* 6 */ "ccccccccccccccc" + /* 7 */ "ccccccccccccccc" + /* 8 */ "acccccccccacccc" // Level 1 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "mmmaeeeammmmmmm" - /* 1 */ "mmmmeeemmmmmmmm" - /* 2 */ "accccfccccadddd" - /* 3 */ "cfffffffffcdddd" - /* 4 */ "cfffffffffcdddd" - /* 5 */ "cffffffffffdddd" - /* 6 */ "cfffffffffcdddd" - /* 7 */ "cfffffffffcdddd" - /* 8 */ "acccccccccadddd" + /* 0 */ "mmmadddammmmmmm" + /* 1 */ "mmmmdddmmmmmmmm" + /* 2 */ "acccceccccaffff" + /* 3 */ "ceeeeeeeeecffff" + /* 4 */ "ceeeeeeeeecffff" + /* 5 */ "ceeeeeeeeeeffff" + /* 6 */ "ceeeeeeeeecffff" + /* 7 */ "ceeeeeeeeecffff" + /* 8 */ "acccccccccaffff" // Level 2 /* z\x* 11111 */ diff --git a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp index c49015e36..0362c9406 100644 --- a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp +++ b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp @@ -134,11 +134,11 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 166, ID 554, created by Aloe_vera { // Size: - 11, 7, 13, // SizeX = 11, SizeY = 7, SizeZ = 13 + 11, 8, 13, // SizeX = 11, SizeY = 8, SizeZ = 13 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 10, 6, 12, // MaxX, MaxY, MaxZ + 10, 7, 12, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -150,6 +150,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = "f: 59: 7\n" /* crops */ "g: 83: 0\n" /* reedblock */ "h:113: 0\n" /* netherbrickfence */ + "i: 50: 5\n" /* torch */ "m: 19: 0\n" /* sponge */, // Block data: @@ -270,7 +271,24 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = /* 9 */ "..........." /* 10 */ ".h.......h." /* 11 */ "hhh.....hhh" - /* 12 */ ".h.......h.", + /* 12 */ ".h.......h." + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ ".i.......i." + /* 1 */ "i.i.....i.i" + /* 2 */ ".i.......i." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ ".i.......i." + /* 11 */ "i.i.....i.i" + /* 12 */ ".i.......i.", // Connectors: "-1: 10, 2, 6: 5\n" /* Type -1, direction X+ */, @@ -2195,33 +2213,33 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // Level 1 /* z\x* 0123456 */ - /* 0 */ "bmmmmmm" - /* 1 */ "bmmmmmm" - /* 2 */ "bmmmmmm" - /* 3 */ "bmmmmmm" - /* 4 */ "bmmmmmm" - /* 5 */ "bmmmmmm" + /* 0 */ "bbbbbbb" + /* 1 */ "bbbbbbb" + /* 2 */ "bbbbbbb" + /* 3 */ "bbbabbb" + /* 4 */ "bbbbbbb" + /* 5 */ "bbbbbbb" /* 6 */ "bbbbbbb" // Level 2 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ "..c.c.." + /* 0 */ "mm...mm" + /* 1 */ "m.c...m" /* 2 */ ".dccdc." /* 3 */ "..cefc." /* 4 */ ".ccfgh." - /* 5 */ "..ccc.." - /* 6 */ "......." + /* 5 */ "m.ccc.m" + /* 6 */ "mm...mm" // Level 3 /* z\x* 0123456 */ - /* 0 */ "......." + /* 0 */ "m.....m" /* 1 */ "......." /* 2 */ "......." /* 3 */ "...e..." /* 4 */ "......." /* 5 */ "......." - /* 6 */ "......." + /* 6 */ "m.....m" // Level 4 /* z\x* 0123456 */ diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index 714a66559..4613f76e2 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -356,8 +356,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "e: 8: 0\n" /* water */ "f: 50: 5\n" /* torch */ "g: 59: 7\n" /* crops */ - "h: 59: 0\n" /* crops */ - "i: 59: 1\n" /* crops */ + "h: 59: 3\n" /* crops */ + "i: 59: 5\n" /* crops */ "m: 19: 0\n" /* sponge */, // Block data: @@ -368,7 +368,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 1 */ "aaaaaaaaaaaaaaa" /* 2 */ "aaaaaaaaaaaaaaa" /* 3 */ "aaaaaaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaaaaaa" + /* 4 */ "aaaaaaabaaaaaaa" /* 5 */ "aaaaaaabaaaaaaa" /* 6 */ "aaaaaaabaaaaaaa" /* 7 */ "aaaaaaabaaaaaaa" @@ -405,12 +405,12 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* * 012345678901234 */ /* 0 */ "f.....f.f.....f" /* 1 */ ".gg.gg...gg.gg." - /* 2 */ ".gh.hg...gg.gg." - /* 3 */ ".gh.ih...gg.gg." - /* 4 */ ".gg.hg...gg.gg." - /* 5 */ ".gg.hg...gg.gg." - /* 6 */ ".ig.hg...gg.gg." - /* 7 */ ".hg.gh...gg.gg." + /* 2 */ ".gg.hg...gg.gg." + /* 3 */ ".gg.gi...gg.gg." + /* 4 */ ".gg.gg...gg.gg." + /* 5 */ ".gg.gg...gg.gg." + /* 6 */ ".gg.gg...gg.gg." + /* 7 */ ".gg.gg...gg.gg." /* 8 */ "f.....f.f.....f" // Level 4 @@ -3603,8 +3603,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Block definitions: ".: 0: 0\n" /* air */ - "a: 2: 0\n" /* grass */ - "b: 3: 0\n" /* dirt */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ "c: 4: 0\n" /* cobblestone */ "d: 67: 0\n" /* stairs */ "e: 67: 2\n" /* stairs */ @@ -3629,19 +3629,19 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "aaaabbbaaaa" - /* 1 */ "abbbbbbbbba" - /* 2 */ "abbbbbbbbba" - /* 3 */ "abbbbbbbbba" - /* 4 */ "abbbbbbbbba" - /* 5 */ "abbbbbbbbba" - /* 6 */ "abbbbbbbbba" - /* 7 */ "abbbbbbbbba" - /* 8 */ "aabbbbbbbaa" - /* 9 */ "aabbbbbbbaa" - /* 10 */ "aabbbbbbbaa" - /* 11 */ "aabbbbbbbaa" - /* 12 */ "aabbbbbbbaa" + /* 0 */ "aaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaa" + /* 4 */ "aaaaaaaaaab" + /* 5 */ "baaaaaaaaab" + /* 6 */ "aaaaaaaaaaa" + /* 7 */ "baaaaaaaaaa" + /* 8 */ "baaaaaaaaaa" + /* 9 */ "baaaaaaaaab" + /* 10 */ "aaaaaaaaaaa" + /* 11 */ "aaaaaaaaaba" + /* 12 */ "aaaaaaaaaba" // Level 1 /* z\x* 1 */ @@ -3654,11 +3654,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 5 */ "mcccccccccm" /* 6 */ "mcccccccccm" /* 7 */ "mcccccccccm" - /* 8 */ "mmbbbbbbbmm" - /* 9 */ "mmbbbbbbbmm" - /* 10 */ "mmbbbbbbbmm" - /* 11 */ "mmbbbbbbbmm" - /* 12 */ "mmbbbbbbbmm" + /* 8 */ "mmaaaaaaamm" + /* 9 */ "mmaaaaaaamm" + /* 10 */ "mmaaaaaaamm" + /* 11 */ "mmaaaaaaamm" + /* 12 */ "mmaaaaaaamm" // Level 2 /* z\x* 1 */ @@ -3671,11 +3671,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 5 */ ".cggggcccc." /* 6 */ ".cggggcccc." /* 7 */ ".ccccccccc." - /* 8 */ "..aaaaaaa.." - /* 9 */ "..aaaaaaa.." - /* 10 */ "..aaaaaaa.." - /* 11 */ "..aaaaaaa.." - /* 12 */ "..aaaaaaa.." + /* 8 */ "..bbbbbbb.." + /* 9 */ "mmbbbbbbbmm" + /* 10 */ "mmbbbbbbbmm" + /* 11 */ "mmbbbbbbbmm" + /* 12 */ "mmbbbbbbbmm" // Level 3 /* z\x* 1 */ @@ -3689,10 +3689,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ ".i.......i." /* 7 */ ".hiiijiiih." /* 8 */ "..l.....l.." - /* 9 */ "..l.....l.." - /* 10 */ "..l.....l.." - /* 11 */ "..l.....l.." - /* 12 */ "..lllllll.." + /* 9 */ "mml.....lmm" + /* 10 */ "mml.....lmm" + /* 11 */ "mml.....lmm" + /* 12 */ "mmlllllllmm" // Level 4 /* z\x* 1 */ @@ -3706,10 +3706,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ ".o.......o." /* 7 */ ".hooipiooh." /* 8 */ "..........." - /* 9 */ "..........." - /* 10 */ "..........." - /* 11 */ "..........." - /* 12 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" // Level 5 /* z\x* 1 */ @@ -3723,10 +3723,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ ".i.......i." /* 7 */ "uiiiiiiiiiu" /* 8 */ "kkkkkkkkkkk" - /* 9 */ "..........." - /* 10 */ "..........." - /* 11 */ "..........." - /* 12 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" // Level 6 /* z\x* 1 */ @@ -3740,10 +3740,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ "uiiiiiiiiiu" /* 7 */ "kkkkkkkkkkk" /* 8 */ "..........." - /* 9 */ "..........." - /* 10 */ "..........." - /* 11 */ "..........." - /* 12 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" // Level 7 /* z\x* 1 */ @@ -3757,10 +3757,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ "kkkkkkkkkkk" /* 7 */ "..........." /* 8 */ "..........." - /* 9 */ "..........." - /* 10 */ "..........." - /* 11 */ "..........." - /* 12 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" // Level 8 /* z\x* 1 */ @@ -3774,10 +3774,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ "..........." /* 7 */ "..........." /* 8 */ "..........." - /* 9 */ "..........." - /* 10 */ "..........." - /* 11 */ "..........." - /* 12 */ "...........", + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm", // Connectors: "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, @@ -4237,30 +4237,29 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Block definitions: ".: 0: 0\n" /* air */ "a: 4: 0\n" /* cobblestone */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 5: 0\n" /* wood */ - "g: 67: 3\n" /* stairs */ - "h: 17: 0\n" /* tree */ - "i: 64: 7\n" /* wooddoorblock */ - "j: 64: 5\n" /* wooddoorblock */ - "k:102: 0\n" /* glasspane */ - "l: 64:12\n" /* wooddoorblock */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 5: 0\n" /* wood */ + "f: 67: 3\n" /* stairs */ + "g: 17: 0\n" /* tree */ + "h: 64: 7\n" /* wooddoorblock */ + "i: 64: 5\n" /* wooddoorblock */ + "j:102: 0\n" /* glasspane */ + "k: 64:12\n" /* wooddoorblock */ + "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 2\n" /* woodstairs */ - "o: 53: 1\n" /* woodstairs */ - "p: 53: 7\n" /* woodstairs */ - "q: 53: 6\n" /* woodstairs */ - "r: 53: 3\n" /* woodstairs */ - "s: 53: 0\n" /* woodstairs */ - "t: 53: 5\n" /* woodstairs */ - "u: 53: 4\n" /* woodstairs */ - "v: 50: 3\n" /* torch */ - "w: 50: 2\n" /* torch */ - "x: 50: 4\n" /* torch */ - "y: 50: 1\n" /* torch */, + "n: 53: 1\n" /* woodstairs */ + "o: 53: 7\n" /* woodstairs */ + "p: 53: 6\n" /* woodstairs */ + "q: 53: 3\n" /* woodstairs */ + "r: 53: 0\n" /* woodstairs */ + "s: 53: 5\n" /* woodstairs */ + "t: 53: 4\n" /* woodstairs */ + "u: 50: 3\n" /* torch */ + "v: 50: 2\n" /* torch */ + "w: 50: 4\n" /* torch */ + "x: 50: 1\n" /* torch */, // Block data: // Level 0 @@ -4274,134 +4273,134 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 5 */ "maaaaaaaaaaaaaam" /* 6 */ "maaaaaaaaaaaaaam" /* 7 */ "maaaaaaaaaaaaaam" - /* 8 */ "bbbbbaaaaaaaaaam" - /* 9 */ "bbbbbbbbaaaaaaam" - /* 10 */ "bbbbbbbbaaaaaaam" - /* 11 */ "bbbbbbbbaaaaaaam" - /* 12 */ "bbbbbbbbaaaaaaam" - /* 13 */ "bbbbbbbbaaaaaaam" - /* 14 */ "bbbbbbbbaaaaaaam" - /* 15 */ "bbbbbbbbmmmmmmmm" + /* 8 */ "mmmmmaaaaaaaaaam" + /* 9 */ "mmmmmmmmaaaaaaam" + /* 10 */ "mmmmmmmmaaaaaaam" + /* 11 */ "mmmmmmmmaaaaaaam" + /* 12 */ "mmmmmmmmaaaaaaam" + /* 13 */ "mmmmmmmmaaaaaaam" + /* 14 */ "mmmmmmmmaaaaaaam" + /* 15 */ "mmmmmmmmmmmmmmmm" // Level 1 /* z\x* 111111 */ /* * 0123456789012345 */ - /* 0 */ "........cde....." + /* 0 */ "........bcd....." /* 1 */ ".aaaaaaaaaaaaaa." - /* 2 */ ".affffffffffffa." - /* 3 */ ".affffffffffffa." - /* 4 */ ".affffffffffffa." - /* 5 */ ".affffffffffffa." - /* 6 */ ".affffffffffffa." - /* 7 */ ".aaaaaaaafffffa." - /* 8 */ ".....cgeafffffa." - /* 9 */ "........afffffa." - /* 10 */ "........afffffa." - /* 11 */ "........afffffa." - /* 12 */ "........afffffa." - /* 13 */ "........afffffa." - /* 14 */ "........aaaaaaa." - /* 15 */ "................" + /* 2 */ ".aeeeeeeeeeeeea." + /* 3 */ ".aeeeeeeeeeeeea." + /* 4 */ ".aeeeeeeeeeeeea." + /* 5 */ ".aeeeeeeeeeeeea." + /* 6 */ ".aeeeeeeeeeeeea." + /* 7 */ ".aaaaaaaaeeeeea." + /* 8 */ ".....bfdaeeeeea." + /* 9 */ "mmmm....aeeeeea." + /* 10 */ "mmmmmmm.aeeeeea." + /* 11 */ "mmmmmmm.aeeeeea." + /* 12 */ "mmmmmmm.aeeeeea." + /* 13 */ "mmmmmmm.aeeeeea." + /* 14 */ "mmmmmmm.aaaaaaa." + /* 15 */ "mmmmmmm........." // Level 2 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" - /* 1 */ ".hffffffhihfffh." - /* 2 */ ".f............f." - /* 3 */ ".f............f." - /* 4 */ ".f............f." - /* 5 */ ".f............f." - /* 6 */ ".f............f." - /* 7 */ ".hffffjfh.....f." - /* 8 */ "........f.....f." - /* 9 */ "........f.....f." - /* 10 */ "........f.....f." - /* 11 */ "........f.....f." - /* 12 */ "........f.....f." - /* 13 */ "........f.....f." - /* 14 */ "........hfffffh." - /* 15 */ "................" + /* 1 */ ".geeeeeeghgeeeg." + /* 2 */ ".e............e." + /* 3 */ ".e............e." + /* 4 */ ".e............e." + /* 5 */ ".e............e." + /* 6 */ ".e............e." + /* 7 */ ".geeeeieg.....e." + /* 8 */ "........e.....e." + /* 9 */ "mmmm....e.....e." + /* 10 */ "mmmmmmm.e.....e." + /* 11 */ "mmmmmmm.e.....e." + /* 12 */ "mmmmmmm.e.....e." + /* 13 */ "mmmmmmm.e.....e." + /* 14 */ "mmmmmmm.geeeeeg." + /* 15 */ "mmmmmmm........." // Level 3 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" - /* 1 */ ".hfkkfkkhlhkkfh." - /* 2 */ ".k............f." - /* 3 */ ".k............k." - /* 4 */ ".k............k." - /* 5 */ ".k............f." - /* 6 */ ".k............k." - /* 7 */ ".hfkkflfh.....k." - /* 8 */ "........f.....f." - /* 9 */ "........k.....k." - /* 10 */ "........k.....k." - /* 11 */ "........f.....f." - /* 12 */ "........k.....k." - /* 13 */ "........k.....k." - /* 14 */ "........hkkkkkh." - /* 15 */ "................" + /* 1 */ ".gejjejjgkgjjeg." + /* 2 */ ".j............e." + /* 3 */ ".j............j." + /* 4 */ ".j............j." + /* 5 */ ".j............e." + /* 6 */ ".j............j." + /* 7 */ ".gejjekeg.....j." + /* 8 */ "........e.....e." + /* 9 */ "mmmm....j.....j." + /* 10 */ "mmmmmmm.j.....j." + /* 11 */ "mmmmmmm.e.....e." + /* 12 */ "mmmmmmm.j.....j." + /* 13 */ "mmmmmmm.j.....j." + /* 14 */ "mmmmmmm.gjjjjjg." + /* 15 */ "mmmmmmm........." // Level 4 /* z\x* 111111 */ /* * 0123456789012345 */ - /* 0 */ "nnnnnnnnnnnnnnno" - /* 1 */ "phffffffhfhfffho" - /* 2 */ ".f............fo" - /* 3 */ ".f............fo" - /* 4 */ ".f............fo" - /* 5 */ ".f............fo" - /* 6 */ ".f............fo" - /* 7 */ "qhffffffh.....fo" - /* 8 */ "rrrrrrrsf.....fo" - /* 9 */ ".......sf.....fo" - /* 10 */ ".......sf.....fo" - /* 11 */ ".......sf.....fo" - /* 12 */ ".......sf.....fo" - /* 13 */ ".......sf.....fo" - /* 14 */ ".......shfffffho" - /* 15 */ ".......st.....uo" + /* 0 */ "llllllllllllllln" + /* 1 */ "ogeeeeeegegeeegn" + /* 2 */ ".e............en" + /* 3 */ ".e............en" + /* 4 */ ".e............en" + /* 5 */ ".e............en" + /* 6 */ ".e............en" + /* 7 */ "pgeeeeeeg.....en" + /* 8 */ "qqqqqqqre.....en" + /* 9 */ "mmmm...re.....en" + /* 10 */ "mmmmmmmre.....en" + /* 11 */ "mmmmmmmre.....en" + /* 12 */ "mmmmmmmre.....en" + /* 13 */ "mmmmmmmre.....en" + /* 14 */ "mmmmmmmrgeeeeegn" + /* 15 */ "mmmmmmmrs.....tn" // Level 5 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" - /* 1 */ "nnnnnnnnnnnnnnn." - /* 2 */ "pfffffffffffffo." - /* 3 */ ".f.........v.fo." - /* 4 */ ".f..........wfo." - /* 5 */ ".f......x....fo." - /* 6 */ "qfffffffff...fo." - /* 7 */ "rrrrrrrrsfy..fo." - /* 8 */ "........sf...fo." - /* 9 */ "........sf...fo." - /* 10 */ "........sf...fo." - /* 11 */ "........sf...fo." - /* 12 */ "........sf...fo." - /* 13 */ "........sf...fo." - /* 14 */ "........sfffffo." - /* 15 */ "........st...uo." + /* 1 */ "lllllllllllllll." + /* 2 */ "oeeeeeeeeeeeeen." + /* 3 */ ".e.........u.en." + /* 4 */ ".e..........ven." + /* 5 */ ".e......w....en." + /* 6 */ "peeeeeeeee...en." + /* 7 */ "qqqqqqqqrex..en." + /* 8 */ "........re...en." + /* 9 */ "mmmm....re...en." + /* 10 */ "mmmmmmm.re...en." + /* 11 */ "mmmmmmm.re...en." + /* 12 */ "mmmmmmm.re...en." + /* 13 */ "mmmmmmm.re...en." + /* 14 */ "mmmmmmm.reeeeen." + /* 15 */ "mmmmmmm.rs...tn." // Level 6 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" /* 1 */ "................" - /* 2 */ "nnnnnnnnnnnnno.." - /* 3 */ "pffffffffffffo.." - /* 4 */ ".fy.........fo.." - /* 5 */ "qffffffffff.fo.." - /* 6 */ "rrrrrrrrrsf.fo.." - /* 7 */ ".........sf.fo.." - /* 8 */ ".........sf.fo.." - /* 9 */ ".........sf.fo.." - /* 10 */ ".........sf.fo.." - /* 11 */ ".........sf.fo.." - /* 12 */ ".........sf.fo.." - /* 13 */ ".........sfxfo.." - /* 14 */ ".........sfffo.." - /* 15 */ ".........st.uo.." + /* 2 */ "llllllllllllln.." + /* 3 */ "oeeeeeeeeeeeen.." + /* 4 */ ".ex.........en.." + /* 5 */ "peeeeeeeeee.en.." + /* 6 */ "qqqqqqqqqre.en.." + /* 7 */ ".........re.en.." + /* 8 */ ".........re.en.." + /* 9 */ "mmmm.....re.en.." + /* 10 */ "mmmmmmm..re.en.." + /* 11 */ "mmmmmmm..re.en.." + /* 12 */ "mmmmmmm..re.en.." + /* 13 */ "mmmmmmm..rewen.." + /* 14 */ "mmmmmmm..reeen.." + /* 15 */ "mmmmmmm..rs.tn.." // Level 7 /* z\x* 111111 */ @@ -4409,19 +4408,19 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 0 */ "................" /* 1 */ "................" /* 2 */ "................" - /* 3 */ "nnnnnnnnnnnnn..." - /* 4 */ "ffffffffffffo..." - /* 5 */ "rrrrrrrrrrsfo..." - /* 6 */ "..........sfo..." - /* 7 */ "..........sfo..." - /* 8 */ "..........sfo..." - /* 9 */ "..........sfo..." - /* 10 */ "..........sfo..." - /* 11 */ "..........sfo..." - /* 12 */ "..........sfo..." - /* 13 */ "..........sfo..." - /* 14 */ "..........sfo..." - /* 15 */ "..........sfo...", + /* 3 */ "lllllllllllll..." + /* 4 */ "eeeeeeeeeeeen..." + /* 5 */ "qqqqqqqqqqren..." + /* 6 */ "..........ren..." + /* 7 */ "..........ren..." + /* 8 */ "..........ren..." + /* 9 */ "mmmm......ren..." + /* 10 */ "mmmmmmm...ren..." + /* 11 */ "mmmmmmm...ren..." + /* 12 */ "mmmmmmm...ren..." + /* 13 */ "mmmmmmm...ren..." + /* 14 */ "mmmmmmm...ren..." + /* 15 */ "mmmmmmm...ren...", // Connectors: "-1: 9, 1, 0: 2\n" /* Type -1, direction Z- */, -- cgit v1.2.3 From 0a15e1f420402e797397ea447b1df96f6ea2106f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 22 Jul 2014 10:33:16 +0100 Subject: Suggestion and failed merge fix --- src/Blocks/BlockPortal.h | 2 +- src/World.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 6f41f96df..fc74e89d0 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -55,7 +55,7 @@ public: virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { - if ((a_RelY == 0) || (a_RelY == cChunkDef::Height)) // Y can't be < 0 or > Height; (Fast)SetBlock won't allow it + if ((a_RelY - 1 < 0) || (a_RelY + 1 > cChunkDef::Height)) { return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1 } diff --git a/src/World.cpp b/src/World.cpp index 9dc28afea..2736e77d3 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -579,6 +579,11 @@ void cWorld::Start(void) int Weather = IniFile.GetValueSetI("General", "Weather", (int)m_Weather); m_TimeOfDay = IniFile.GetValueSetI("General", "TimeInTicks", m_TimeOfDay); + if (GetDimension() == dimOverworld) + { + m_NetherWorldName = IniFile.GetValueSet("LinkedWorlds", "NetherWorldName", DEFAULT_NETHER_NAME); + m_EndWorldName = IniFile.GetValueSet("LinkedWorlds", "EndWorldName", DEFAULT_END_NAME); + } else { m_OverworldName = IniFile.GetValueSet("LinkedWorlds", "OverworldName", GetLinkedOverworldName()); -- cgit v1.2.3 From 5b148c30f71874d62b55a5134fd4c7897ebe106a Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 22 Jul 2014 14:44:26 +0200 Subject: Extreme Hills M variant only spawn with grass and stone Removed gravel. --- src/Generating/DistortedHeightmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp index 74d30c327..1337896ab 100644 --- a/src/Generating/DistortedHeightmap.cpp +++ b/src/Generating/DistortedHeightmap.cpp @@ -759,7 +759,7 @@ void cDistortedHeightmap::ComposeColumn(cChunkDesc & a_ChunkDesc, int a_RelX, in NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width + a_RelX)) / FrequencyX; NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width + a_RelZ)) / FrequencyZ; NOISE_DATATYPE Val = m_OceanFloorSelect.CubicNoise2D(NoiseX, NoiseY); - const sBlockInfo * Pattern = (Val < -0.9) ? patStone.Get() : ((Val > 0) ? patGravel.Get() : patGrass.Get()); + const sBlockInfo * Pattern = (Val < 0.0) ? patStone.Get() : patGrass.Get(); FillColumnPattern(a_ChunkDesc, a_RelX, a_RelZ, Pattern); return; } -- cgit v1.2.3 From a28b0dc1201dca7c34d9a6c33232157e45a6d4f8 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 22 Jul 2014 17:26:48 +0100 Subject: Speed improvements, crash fixes, & self-suggestions --- src/Chunk.cpp | 19 ++++++---------- src/Entities/Entity.cpp | 59 ++++++++++++++++++++++++------------------------- src/Entities/Entity.h | 6 +++-- src/Entities/Player.cpp | 6 +++-- src/Entities/Player.h | 1 - src/Root.cpp | 6 +++-- src/World.cpp | 17 +++++--------- src/World.h | 2 +- 8 files changed, 55 insertions(+), 61 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 9b9646b0c..0be61f753 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -583,19 +583,14 @@ void cChunk::Tick(float a_Dt) m_IsDirty = (*itr)->Tick(a_Dt, *this) | m_IsDirty; } - // Tick all entities in this chunk (except mobs): - for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) - { - // Mobs are ticked inside cWorld::TickMobs() (as we don't have to tick them if they are far away from players) - // Don't tick things queued to be removed - if (!((*itr)->IsMob())) + for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) + { + if (!((*itr)->IsMob())) // Mobs are ticked inside cWorld::TickMobs() (as we don't have to tick them if they are far away from players) { + // Tick all entities in this chunk (except mobs): (*itr)->Tick(a_Dt, *this); } - } // for itr - m_Entitites[] - - for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) - { + if ((*itr)->IsDestroyed()) // Remove all entities that were scheduled for removal: { LOGD("Destroying entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass()); @@ -604,7 +599,7 @@ void cChunk::Tick(float a_Dt) itr = m_Entities.erase(itr); delete ToDelete; } - else if ((*itr)->IsWorldTravellingFrom(m_World)) // Remove all entities that are travelling to another world + else if ((*itr)->IsWorldTravellingFrom(m_World)) // Remove all entities that are travelling to another world: { MarkDirty(); (*itr)->SetWorldTravellingFrom(NULL); @@ -1899,7 +1894,7 @@ void cChunk::AddEntity(cEntity * a_Entity) MarkDirty(); } - ASSERT(std::find(m_Entities.begin(), m_Entities.end(), a_Entity) == m_Entities.end()); + ASSERT(std::find(m_Entities.begin(), m_Entities.end(), a_Entity) == m_Entities.end()); // Not there already m_Entities.push_back(a_Entity); } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index a7340a29c..68bfabb30 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -614,11 +614,13 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk) // Handle drowning HandleAir(); + } + + if (!DetectPortal()) // Our chunk is invalid if we have moved to another world + { + // None of the above functions changed position, we remain in the chunk of NextChunk + HandlePhysics(a_Dt, *NextChunk); } - DetectPortal(); - - // None of the above functions change position, we remain in the chunk of NextChunk - HandlePhysics(a_Dt, *NextChunk); } } @@ -1026,18 +1028,18 @@ void cEntity::DetectCacti(void) -void cEntity::DetectPortal() +bool cEntity::DetectPortal() { if (GetWorld()->GetDimension() == dimOverworld) { if (GetWorld()->GetNetherWorldName().empty() && GetWorld()->GetEndWorldName().empty()) { - return; + return false; } } else if (GetWorld()->GetLinkedOverworldName().empty()) { - return; + return false; } int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; @@ -1049,13 +1051,13 @@ void cEntity::DetectPortal() { if (m_PortalCooldownData.m_ShouldPreventTeleportation) { - return; + return false; } if (IsPlayer() && !((cPlayer *)this)->IsGameModeCreative() && m_PortalCooldownData.m_TicksDelayed != 80) { m_PortalCooldownData.m_TicksDelayed++; - return; + return false; } m_PortalCooldownData.m_TicksDelayed = 0; @@ -1065,7 +1067,7 @@ void cEntity::DetectPortal() { if (GetWorld()->GetLinkedOverworldName().empty()) { - return; + return false; } m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn @@ -1074,15 +1076,14 @@ void cEntity::DetectPortal() { ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimOverworld); } - MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false); - - return; + + return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false); } case dimOverworld: { if (GetWorld()->GetNetherWorldName().empty()) { - return; + return false; } m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn @@ -1092,18 +1093,17 @@ void cEntity::DetectPortal() ((cPlayer *)this)->AwardAchievement(achEnterPortal); ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimNether); } - MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetNetherWorldName(), dimNether, GetWorld()->GetName()), false); - - return; + + return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetNetherWorldName(), dimNether, GetWorld()->GetName()), false); } - default: return; + default: return false; } } case E_BLOCK_END_PORTAL: { if (m_PortalCooldownData.m_ShouldPreventTeleportation) { - return; + return false; } switch (GetWorld()->GetDimension()) @@ -1112,7 +1112,7 @@ void cEntity::DetectPortal() { if (GetWorld()->GetLinkedOverworldName().empty()) { - return; + return false; } m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn @@ -1122,16 +1122,15 @@ void cEntity::DetectPortal() cPlayer * Player = (cPlayer *)this; Player->TeleportToCoords(Player->GetLastBedPos().x, Player->GetLastBedPos().y, Player->GetLastBedPos().z); Player->GetClientHandle()->SendRespawn(dimOverworld); - } - MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false); + } - return; + return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false); } case dimOverworld: { if (GetWorld()->GetEndWorldName().empty()) { - return; + return false; } m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn @@ -1140,12 +1139,11 @@ void cEntity::DetectPortal() { ((cPlayer *)this)->AwardAchievement(achEnterTheEnd); ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimEnd); - } - MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetEndWorldName(), dimEnd, GetWorld()->GetName()), false); + } - return; + return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetEndWorldName(), dimEnd, GetWorld()->GetName()), false); } - default: return; + default: return false; } } default: break; @@ -1155,6 +1153,7 @@ void cEntity::DetectPortal() // Allow portals to work again m_PortalCooldownData.m_ShouldPreventTeleportation = false; m_PortalCooldownData.m_ShouldPreventTeleportation = 0; + return false; } @@ -1164,7 +1163,7 @@ void cEntity::DetectPortal() bool cEntity::MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) { UNUSED(a_ShouldSendRespawn); - ASSERT(a_World == NULL); + ASSERT(a_World != NULL); if (GetWorld() == a_World) { @@ -1173,7 +1172,7 @@ bool cEntity::MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) } // Remove all links to the old world - SetWorldTravellingFrom(GetWorld()); // cChunk handles entity removal + SetWorldTravellingFrom(GetWorld()); // cChunk handles entity removal GetWorld()->BroadcastDestroyEntity(*this); // Queue add to new world diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 1679b00d6..62a4097f3 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -337,8 +337,10 @@ public: /** Detects the time for application of cacti damage */ virtual void DetectCacti(void); - /** Detects whether we are in a portal block and begins teleportation procedures if so */ - virtual void DetectPortal(void); + /** Detects whether we are in a portal block and begins teleportation procedures if so + Returns true if MoveToWorld() was called, false if not + */ + virtual bool DetectPortal(void); /// Handles when the entity is in the void virtual void TickInVoid(cChunk & a_Chunk); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index e54e10a08..087ac448f 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -95,7 +95,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) : SetPosX(World->GetSpawnX()); SetPosY(World->GetSpawnY()); SetPosZ(World->GetSpawnZ()); - SetBedPos(Vector3i(World->GetSpawnX(), World->GetSpawnY(), World->GetSpawnZ())); + SetBedPos(Vector3i((int)World->GetSpawnX(), (int)World->GetSpawnY(), (int)World->GetSpawnZ())); LOGD("Player \"%s\" is connecting for the first time, spawning at default world spawn {%.2f, %.2f, %.2f}", a_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ() @@ -1611,6 +1611,8 @@ void cPlayer::TossItems(const cItems & a_Items) bool cPlayer::MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) { + ASSERT(a_World != NULL); + if (GetWorld() == a_World) { // Don't move to same world @@ -1624,7 +1626,7 @@ bool cPlayer::MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) } // Remove player from the old world - SetWorldTravellingFrom(GetWorld()); // cChunk handles entity removal + SetWorldTravellingFrom(GetWorld()); // cChunk handles entity removal GetWorld()->RemovePlayer(this); // Queue adding player to the new world, including all the necessary adjustments to the object diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 400377381..d1b3a0339 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -424,7 +424,6 @@ public: /** Returns wheter the player can fly or not. */ virtual bool CanFly(void) const { return m_CanFly; } - // tolua_end // cEntity overrides: diff --git a/src/Root.cpp b/src/Root.cpp index b793cb154..b65e9b067 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -314,10 +314,12 @@ void cRoot::LoadWorlds(cIniFile & IniFile) cWorld * cRoot::CreateAndInitializeWorld(const AString & a_WorldName, eDimension a_Dimension, const AString & a_OverworldName) { - if (m_WorldsByName[a_WorldName] != NULL) + cWorld * World = m_WorldsByName[a_WorldName]; + if (World != NULL) { - return NULL; + return World; } + cWorld * NewWorld = new cWorld(a_WorldName.c_str(), a_Dimension, a_OverworldName); m_WorldsByName[a_WorldName] = NewWorld; NewWorld->Start(); diff --git a/src/World.cpp b/src/World.cpp index 2736e77d3..9cbaf48fb 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -255,8 +255,7 @@ cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AStrin m_Scoreboard(this), m_MapManager(this), m_GeneratorCallbacks(*this), - m_TickThread(*this) - + m_TickThread(*this) { LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str()); @@ -526,7 +525,7 @@ void cWorld::Start(void) // TODO: More descriptions for each key IniFile.AddHeaderComment(" This is the per-world configuration file, managing settings such as generators, simulators, and spawn points"); - IniFile.AddKeyComment("LinkedWorlds", "This section governs portal world linkage; leave a value blank to disabled that associated method of teleportation"); + IniFile.AddKeyComment(" LinkedWorlds", "This section governs portal world linkage; leave a value blank to disabled that associated method of teleportation"); } // The presence of a configuration value overrides everything @@ -784,7 +783,7 @@ void cWorld::Stop(void) // Write settings to file; these are all plugin changeable values - keep updated! cIniFile IniFile; IniFile.ReadFile(m_IniFileName); - if ((GetDimension() != dimNether) && (GetDimension() != dimEnd)) + if (GetDimension() == dimOverworld) { IniFile.SetValue("LinkedWorlds", "NetherWorldName", m_NetherWorldName); IniFile.SetValue("LinkedWorlds", "EndWorldName", m_EndWorldName); @@ -1040,11 +1039,7 @@ void cWorld::TickClients(float a_Dt) // Add clients scheduled for adding: for (cClientHandleList::iterator itr = m_ClientsToAdd.begin(), end = m_ClientsToAdd.end(); itr != end; ++itr) { - if (std::find(m_Clients.begin(), m_Clients.end(), *itr) != m_Clients.end()) - { - ASSERT(!"Adding a client that is already in the clientlist"); - continue; - } + ASSERT(std::find(m_Clients.begin(), m_Clients.end(), *itr) == m_Clients.end()); m_Clients.push_back(*itr); } // for itr - m_ClientsToRemove[] m_ClientsToAdd.clear(); @@ -3253,9 +3248,9 @@ void cWorld::AddQueuedPlayers(void) cCSLock Lock(m_CSPlayers); for (cPlayerList::iterator itr = PlayersToAdd.begin(), end = PlayersToAdd.end(); itr != end; ++itr) { - ASSERT(std::find(m_Players.begin(), m_Players.end(), *itr) == m_Players.end()); // Is it already in the list? HOW? - + ASSERT(std::find(m_Players.begin(), m_Players.end(), *itr) == m_Players.end()); // Is it already in the list? HOW? LOGD("Adding player %s to world \"%s\".", (*itr)->GetName().c_str(), m_WorldName.c_str()); + m_Players.push_back(*itr); (*itr)->SetWorld(this); diff --git a/src/World.h b/src/World.h index 771cf51bf..f6c1437f1 100644 --- a/src/World.h +++ b/src/World.h @@ -669,7 +669,7 @@ public: void InitializeSpawn(void); /** Starts threads that belong to this world */ - void Start(); + void Start(void); /** Stops threads that belong to this world (part of deinit) */ void Stop(void); -- cgit v1.2.3 From 9045246e74e70ae711c85a88df63f007029e2849 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 22 Jul 2014 13:02:28 -0700 Subject: Export BroadcastEntityAnimation with ToLua Fixes #752 --- src/World.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/World.h b/src/World.h index c78bc8c8c..2346ac523 100644 --- a/src/World.h +++ b/src/World.h @@ -217,7 +217,7 @@ public: void BroadcastEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL); void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); - virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) override; + virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) override; // tolua_export void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL); // tolua_export void BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude = NULL); void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL); -- cgit v1.2.3 From bc5db3274fe101afcd9081857bd9b66c12e19906 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 22 Jul 2014 21:09:37 +0100 Subject: Fix misguided comment on bits... ...obviously written by someone very confused, also known as me --- src/Blocks/BlockSapling.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Blocks/BlockSapling.h b/src/Blocks/BlockSapling.h index e965809a3..de28273d5 100644 --- a/src/Blocks/BlockSapling.h +++ b/src/Blocks/BlockSapling.h @@ -20,7 +20,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - // Only the first 5 bits contain the display information, 8th bit for growth indicator (but we use 0x07 for forward compatibility) + // Only the first 2 bits contain the display information and the 4th bit is for the growth indicator, but, we use 0x07 for forward compatibility a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x07)); } -- cgit v1.2.3 From 4044d0a6e6c586aa483ae19d986c8f12c474d057 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 22 Jul 2014 13:10:12 -0700 Subject: Export SendEntityAnimation to ToLua --- src/ClientHandle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 538ecdad7..c1c4cdff9 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -151,7 +151,7 @@ public: void SendMapInfo (int a_ID, unsigned int a_Scale); void SendPaintingSpawn (const cPainting & a_Painting); void SendPickupSpawn (const cPickup & a_Pickup); - void SendEntityAnimation (const cEntity & a_Entity, char a_Animation); + void SendEntityAnimation (const cEntity & a_Entity, char a_Animation); // tolua_export void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount); void SendPlayerAbilities (void); void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline); -- cgit v1.2.3 From e171285408028e858ec3a921bbfd97e8a5dcf6ca Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 22 Jul 2014 23:29:04 +0200 Subject: Fixed Bindings generation in MSVC. The bindings weren't regenerated because of the typo in the dependencies cmake variable. --- src/Bindings/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index 95b858f5d..2ea2fa8c0 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -39,7 +39,7 @@ set (BINDING_OUTPUTS ${CMAKE_CURRENT_SOURCE_DIR}/LuaState_Call.inc ) -set(BINDING_DEPENDECIES +set(BINDING_DEPENDENCIES tolua ../Bindings/virtual_method_hooks.lua ../Bindings/AllToLua.pkg @@ -122,7 +122,7 @@ if (NOT MSVC) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} # add any new generation dependencies here - DEPENDS ${BINDING_DEPENDECIES} + DEPENDS ${BINDING_DEPENDENCIES} ) endif () set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE) -- cgit v1.2.3 From ba8cb3b0a69be8db848e1feac4b05edb7953b1c6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 22 Jul 2014 23:33:08 +0200 Subject: Fixed MSVC bindings regeneration. Still one typo had been left in the cmake file. --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f494b52e5..b8780e8a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -265,7 +265,7 @@ if (MSVC) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/ # add any new generation dependencies here - DEPENDS ${BINDING_DEPENDECIES} + DEPENDS ${BINDING_DEPENDENCIES} ) endif() -- cgit v1.2.3 From dfadcf745384f574e751e78bc3e2ddb262fe1fdf Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 23 Jul 2014 09:11:42 +0200 Subject: BlockLeaves: Fixed comment style. --- src/Blocks/BlockLeaves.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 1635eba08..e426c89e0 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -40,14 +40,14 @@ public: { cFastRandom rand; - // Only the first 2 bits contain the display information, the others are for growing + // Old leaves - 3 bits contain display; new leaves - 1st bit, shifted left two for saplings to understand if (rand.NextInt(6) == 0) { a_Pickups.push_back( cItem( E_BLOCK_SAPLING, 1, - (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01)) // Old leaves - 3 bits contain display; new leaves - 1st bit, shifted left two for saplings to understand + (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01)) ) ); } -- cgit v1.2.3 From 9080f14dc2a1010d4169ba690c4bda8da1188ae9 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 23 Jul 2014 11:02:42 +0200 Subject: Fixed possible crash in the NetherClumpFoliage finisher. --- src/Generating/FinishGen.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 444af5022..c67cc574e 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -125,6 +125,11 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a float zz = (float) a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; for (int y = a_RelY - 2; y < a_RelY + 2; y++) { + if ((y < 1) || (y > cChunkDef::Height)) + { + continue; + } + if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks. { continue; -- cgit v1.2.3 From 7e38c123fcce1956f04aec2a57ee86c882e7840a Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 23 Jul 2014 11:23:35 +0200 Subject: TallGrass: Less grass on mountains. --- src/Generating/FinishGen.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index a8a0e1e3b..810bb4a91 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -94,6 +94,17 @@ protected: { return 70; } + + case biExtremeHillsEdge: + case biExtremeHillsPlus: + case biExtremeHills: + case biExtremeHillsPlusM: + case biExtremeHillsM: + case biIceMountains: + { + return 3; + } + default: { return 20; -- cgit v1.2.3 From 396739cc0faf01a099acbe669c5a9def98d3aaae Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 23 Jul 2014 16:32:09 +0200 Subject: Fix item durability. Fixes #1181 --- src/BlockInfo.cpp | 1 + src/Blocks/BlockLeaves.h | 16 ---------------- src/Blocks/BlockTallGrass.h | 3 ++- src/Blocks/BlockVine.h | 7 +++++++ src/Entities/Entity.cpp | 13 ++++++++----- src/Entities/Player.cpp | 4 ++-- src/Entities/Player.h | 2 +- src/FastRandom.h | 3 +++ src/Inventory.cpp | 16 ++++++++++------ src/Item.cpp | 46 ++++++++++++++++++++++----------------------- src/Items/ItemHandler.cpp | 32 +++++++++++++++++++++++++++++-- src/Items/ItemHandler.h | 17 +++++++++++++++-- src/Items/ItemHoe.h | 10 +++++++--- src/Items/ItemShears.h | 25 +++++++++++++++++++++++- src/Items/ItemSword.h | 17 +++++++++++++++-- src/Mobs/Sheep.cpp | 6 +----- 16 files changed, 149 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 97e89359f..c4510fe6d 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -454,6 +454,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_RequiresSpecialTool = true; a_Info[E_BLOCK_EMERALD_ORE ].m_RequiresSpecialTool = true; a_Info[E_BLOCK_END_STONE ].m_RequiresSpecialTool = true; + a_Info[E_BLOCK_VINES ].m_RequiresSpecialTool = true; a_Info[E_BLOCK_GOLD_BLOCK ].m_RequiresSpecialTool = true; a_Info[E_BLOCK_GOLD_ORE ].m_RequiresSpecialTool = true; a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true; diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 797824506..18f336225 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -55,22 +55,6 @@ public: } } } - - - void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override - { - cBlockHandler::OnDestroyed(a_ChunkInterface, a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ); - - // 0.5% chance of dropping an apple, if the leaves' type is Apple Leaves: - NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - cFastRandom rand; - if (((Meta & 3) == E_META_LEAVES_APPLE) && (rand.NextInt(201) == 100)) - { - cItems Drops; - Drops.push_back(cItem(E_ITEM_RED_APPLE, 1, 0)); - a_WorldInterface.SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ); - } - } virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override diff --git a/src/Blocks/BlockTallGrass.h b/src/Blocks/BlockTallGrass.h index ba1f2e0f6..9c008f793 100644 --- a/src/Blocks/BlockTallGrass.h +++ b/src/Blocks/BlockTallGrass.h @@ -43,8 +43,9 @@ public: cItems Pickups; Pickups.Add(E_BLOCK_TALL_GRASS, 1, Meta); a_WorldInterface.SpawnItemPickups(Pickups, a_BlockX, a_BlockY, a_BlockZ); + + a_Player->UseEquippedItem(); } - a_Player->UseEquippedItem(); } diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h index 61092af3e..1e1f6d8d2 100644 --- a/src/Blocks/BlockVine.h +++ b/src/Blocks/BlockVine.h @@ -44,6 +44,13 @@ public: } + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + // Reset meta to 0 + a_Pickups.push_back(cItem(E_BLOCK_VINES, 1, 0)); + } + + static NIBBLETYPE DirectionToMetaData(char a_BlockFace) { switch (a_BlockFace) diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index db0fd0fd6..6c3d7b40c 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -12,6 +12,7 @@ #include "../Bindings/PluginManager.h" #include "../Tracer.h" #include "Player.h" +#include "Items/ItemHandler.h" @@ -289,11 +290,6 @@ void cEntity::SetPitchFromSpeed(void) bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) { - if (cRoot::Get()->GetPluginManager()->CallHookTakeDamage(*this, a_TDI)) - { - return false; - } - if (m_Health <= 0) { // Can't take damage if already dead @@ -306,10 +302,17 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) return false; } + if (cRoot::Get()->GetPluginManager()->CallHookTakeDamage(*this, a_TDI)) + { + return false; + } + if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer())) { cPlayer * Player = (cPlayer *)a_TDI.Attacker; + Player->GetEquippedItem().GetHandler()->OnEntityAttack(Player, this); + // IsOnGround() only is false if the player is moving downwards // TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain) if (!Player->IsOnGround()) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index fcc8eb9a0..afe5965aa 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1929,14 +1929,14 @@ cPlayer::StringList cPlayer::GetResolvedPermissions() -void cPlayer::UseEquippedItem(void) +void cPlayer::UseEquippedItem(int a_Amount) { if (IsGameModeCreative()) // No damage in creative { return; } - if (GetInventory().DamageEquippedItem()) + if (GetInventory().DamageEquippedItem(a_Amount)) { m_World->BroadcastSoundEffect("random.break", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 26db2050b..e89d9f48f 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -349,7 +349,7 @@ public: const AString & GetLoadedWorldName() { return m_LoadedWorldName; } - void UseEquippedItem(void); + void UseEquippedItem(int a_Amount = 1); void SendHealth(void); diff --git a/src/FastRandom.h b/src/FastRandom.h index 567198a31..2061a3958 100644 --- a/src/FastRandom.h +++ b/src/FastRandom.h @@ -44,6 +44,9 @@ public: /// Returns a random float in the range [0 .. a_Range]; a_Range must be less than 1M; a_Salt is additional source of randomness float NextFloat(float a_Range, int a_Salt); + /** Returns a random float between 0 and 1. */ + float NextFloat(void) { return NextFloat(1); }; + /** Returns a random int in the range [a_Begin .. a_End] */ int GenerateRandomInteger(int a_Begin, int a_End); diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 0f9716d89..a34d51993 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -222,12 +222,6 @@ void cInventory::SetSlot(int a_SlotNum, const cItem & a_Item) return; } Grid->SetSlot(GridSlotNum, a_Item); - - // Broadcast the Equipped Item, if the Slot is changed. - if ((Grid == &m_HotbarSlots) && (m_EquippedSlotNum == (a_SlotNum - invHotbarOffset))) - { - m_Owner.GetWorld()->BroadcastEntityEquipment(m_Owner, 0, a_Item, m_Owner.GetClientHandle()); - } } @@ -393,6 +387,10 @@ bool cInventory::DamageItem(int a_SlotNum, short a_Amount) LOGWARNING("%s: requesting an invalid slot index: %d out of %d", __FUNCTION__, a_SlotNum, invNumSlots - 1); return false; } + if (a_Amount <= 0) + { + return false; + } int GridSlotNum = 0; cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum); @@ -713,6 +711,12 @@ void cInventory::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) m_ArmorSlots.GetSlot(a_SlotNum), m_Owner.GetClientHandle() ); } + + // Broadcast the Equipped Item, if the Slot is changed. + if ((a_ItemGrid == &m_HotbarSlots) && (m_EquippedSlotNum == a_SlotNum)) + { + m_Owner.GetWorld()->BroadcastEntityEquipment(m_Owner, 0, GetEquippedItem(), m_Owner.GetClientHandle()); + } // Convert the grid-local a_SlotNum to our global SlotNum: int Base = 0; diff --git a/src/Item.cpp b/src/Item.cpp index b44472e38..2c5deaddf 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -41,33 +41,33 @@ short cItem::GetMaxDamage(void) const switch (m_ItemType) { case E_ITEM_BOW: return 384; - case E_ITEM_DIAMOND_AXE: return 1563; - case E_ITEM_DIAMOND_HOE: return 1563; - case E_ITEM_DIAMOND_PICKAXE: return 1563; - case E_ITEM_DIAMOND_SHOVEL: return 1563; - case E_ITEM_DIAMOND_SWORD: return 1563; - case E_ITEM_FLINT_AND_STEEL: return 65; + case E_ITEM_DIAMOND_AXE: return 1561; + case E_ITEM_DIAMOND_HOE: return 1561; + case E_ITEM_DIAMOND_PICKAXE: return 1561; + case E_ITEM_DIAMOND_SHOVEL: return 1561; + case E_ITEM_DIAMOND_SWORD: return 1561; + case E_ITEM_FLINT_AND_STEEL: return 64; case E_ITEM_GOLD_AXE: return 32; case E_ITEM_GOLD_HOE: return 32; case E_ITEM_GOLD_PICKAXE: return 32; case E_ITEM_GOLD_SHOVEL: return 32; case E_ITEM_GOLD_SWORD: return 32; - case E_ITEM_IRON_AXE: return 251; - case E_ITEM_IRON_HOE: return 251; - case E_ITEM_IRON_PICKAXE: return 251; - case E_ITEM_IRON_SHOVEL: return 251; - case E_ITEM_IRON_SWORD: return 251; - case E_ITEM_SHEARS: return 251; - case E_ITEM_STONE_AXE: return 132; - case E_ITEM_STONE_HOE: return 132; - case E_ITEM_STONE_PICKAXE: return 132; - case E_ITEM_STONE_SHOVEL: return 132; - case E_ITEM_STONE_SWORD: return 132; - case E_ITEM_WOODEN_AXE: return 60; - case E_ITEM_WOODEN_HOE: return 60; - case E_ITEM_WOODEN_PICKAXE: return 60; - case E_ITEM_WOODEN_SHOVEL: return 60; - case E_ITEM_WOODEN_SWORD: return 60; + case E_ITEM_IRON_AXE: return 250; + case E_ITEM_IRON_HOE: return 250; + case E_ITEM_IRON_PICKAXE: return 250; + case E_ITEM_IRON_SHOVEL: return 250; + case E_ITEM_IRON_SWORD: return 250; + case E_ITEM_SHEARS: return 250; + case E_ITEM_STONE_AXE: return 131; + case E_ITEM_STONE_HOE: return 131; + case E_ITEM_STONE_PICKAXE: return 131; + case E_ITEM_STONE_SHOVEL: return 131; + case E_ITEM_STONE_SWORD: return 131; + case E_ITEM_WOODEN_AXE: return 59; + case E_ITEM_WOODEN_HOE: return 59; + case E_ITEM_WOODEN_PICKAXE: return 59; + case E_ITEM_WOODEN_SHOVEL: return 59; + case E_ITEM_WOODEN_SWORD: return 59; } return 0; } @@ -86,7 +86,7 @@ bool cItem::DamageItem(short a_Amount) } m_ItemDamage += a_Amount; - return (m_ItemDamage >= MaxDamage); + return (m_ItemDamage > MaxDamage); } diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index bf1d4e4cb..f0a91214d 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -335,8 +335,21 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ); } } - - a_Player->UseEquippedItem(); + + if (!cBlockInfo::IsOneHitDig(Block)) + { + a_Player->UseEquippedItem(GetDurabilityLostWithThatAction(dlaBreakBlock)); + } +} + + + + + +void cItemHandler::OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity) +{ + UNUSED(a_AttackedEntity); + a_Attacker->UseEquippedItem(GetDurabilityLostWithThatAction(dlaAttackEntity)); } @@ -354,6 +367,20 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I +short cItemHandler::GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action) +{ + switch (a_Action) + { + case dlaAttackEntity: return 2; + case dlaBreakBlock: return 1; + } + return 0; +} + + + + + char cItemHandler::GetMaxStackSize(void) { if (m_ItemType < 256) @@ -505,6 +532,7 @@ bool cItemHandler::IsPlaceable(void) bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType) { + UNUSED(a_ItemType); return false; } diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index c7362c5f4..28b1dd13b 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -19,6 +19,13 @@ class cPlayer; class cItemHandler { public: + + enum eDurabilityLostAction + { + dlaBreakBlock, + dlaAttackEntity, + }; + cItemHandler(int a_ItemType); /** Force virtual destructor */ @@ -48,11 +55,17 @@ public: virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace); /** Called when the player destroys a block using this item. This also calls the drop function for the destroyed block */ - virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_X, int a_Y, int a_Z); + virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ); + + /** Called when a player attacks a other entity. */ + virtual void OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity); /** Called after the player has eaten this item. */ virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item); - + + /** Get the durability lost which the item will get, when a specified action was performed. */ + virtual short GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action); + /** Returns the maximum stack size for a given item */ virtual char GetMaxStackSize(void); diff --git a/src/Items/ItemHoe.h b/src/Items/ItemHoe.h index 29f7c83d5..6523b36d9 100644 --- a/src/Items/ItemHoe.h +++ b/src/Items/ItemHoe.h @@ -16,7 +16,6 @@ public: cItemHoeHandler(int a_ItemType) : cItemHandler(a_ItemType) { - } virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override @@ -26,13 +25,18 @@ public: if ((Block == E_BLOCK_DIRT) || (Block == E_BLOCK_GRASS)) { a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FARMLAND, 0); - a_Player->UseEquippedItem(); return true; - } + return false; } + + + virtual short GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action) override + { + return 0; + } } ; diff --git a/src/Items/ItemShears.h b/src/Items/ItemShears.h index 39d2776fa..f1b6cafc3 100644 --- a/src/Items/ItemShears.h +++ b/src/Items/ItemShears.h @@ -12,6 +12,7 @@ class cItemShearsHandler : public cItemHandler { + typedef cItemHandler super; public: cItemShearsHandler(int a_ItemType) : cItemHandler(a_ItemType) @@ -30,8 +31,12 @@ public: BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); if ((Block == E_BLOCK_LEAVES) || (Block == E_BLOCK_NEW_LEAVES)) { + NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); + cBlockHandler * Handler = cBlockInfo::GetHandler(Block); + cItems Drops; - Drops.push_back(cItem(Block, 1, a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x03)); + Handler->ConvertToPickups(Drops, Meta); + Drops.push_back(cItem(Block, 1, Meta & 3)); a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ); a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); @@ -56,6 +61,24 @@ public: } // switch (a_BlockType) return false; } + + + virtual short GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action) override + { + return 0; + } + + + virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ) override + { + super::OnBlockDestroyed(a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ); + + BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + if ((Block == E_BLOCK_TRIPWIRE) || (Block == E_BLOCK_VINES)) + { + a_Player->UseEquippedItem(); + } + } } ; diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h index 44feb2d83..8fd70bd7b 100644 --- a/src/Items/ItemSword.h +++ b/src/Items/ItemSword.h @@ -12,18 +12,20 @@ class cItemSwordHandler : public cItemHandler { + typedef cItemHandler super; public: cItemSwordHandler(int a_ItemType) : cItemHandler(a_ItemType) { - } - + + virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override { return (a_BlockType == E_BLOCK_COBWEB); } + virtual bool CanRepairWithRawMaterial(short a_ItemType) override { switch (m_ItemType) @@ -36,6 +38,17 @@ public: } return false; } + + + virtual short GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action) override + { + switch (a_Action) + { + case dlaAttackEntity: return 1; + case dlaBreakBlock: return 2; + } + return 0; + } } ; diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index 7335848b7..9fb47201d 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -52,11 +52,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player) { m_IsSheared = true; m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.UseEquippedItem(); - } + a_Player.UseEquippedItem(); cItems Drops; int NumDrops = m_World->GetTickRandomNumber(2) + 1; -- cgit v1.2.3 From 997a643977ea901a3cd3a3d1d7171d65b82a828c Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Wed, 23 Jul 2014 20:28:56 +0200 Subject: Moar view distance! Let's blow up our computers! :D --- src/ClientHandle.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.h b/src/ClientHandle.h index c1c4cdff9..50ed596d5 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -56,8 +56,8 @@ public: #else static const int DEFAULT_VIEW_DISTANCE = 10; #endif - static const int MAX_VIEW_DISTANCE = 15; - static const int MIN_VIEW_DISTANCE = 3; + static const int MAX_VIEW_DISTANCE = 32; + static const int MIN_VIEW_DISTANCE = 1; cClientHandle(const cSocket * a_Socket, int a_ViewDistance); virtual ~cClientHandle(); -- cgit v1.2.3 From 1156914dd60b4949116e57ec1480f81c39b6f292 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 23 Jul 2014 21:12:59 +0100 Subject: Suggestions --- src/ClientHandle.cpp | 4 ++-- src/Entities/Entity.cpp | 23 ++++++++++++++--------- src/Entities/Entity.h | 8 +++++--- src/Entities/Player.cpp | 2 +- src/Entities/Player.h | 6 +++--- src/World.cpp | 9 +++------ 6 files changed, 28 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index af53d3623..aaed483e2 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -120,8 +120,8 @@ cClientHandle::~cClientHandle() } if (World != NULL) { - m_Player->SetWorldTravellingFrom(NULL); // Make sure that the player entity is actually removed - World->RemovePlayer(m_Player); // Must be called before cPlayer::Destroy() as otherwise cChunk tries to delete the player, and then we do it again + m_Player->SetWorldTravellingFrom(NULL); // Make sure that the player entity is actually removed + World->RemovePlayer(m_Player); // Must be called before cPlayer::Destroy() as otherwise cChunk tries to delete the player, and then we do it again m_Player->Destroy(); } delete m_Player; diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 68bfabb30..45c347aeb 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1034,11 +1034,13 @@ bool cEntity::DetectPortal() { if (GetWorld()->GetNetherWorldName().empty() && GetWorld()->GetEndWorldName().empty()) { + // Teleportation to either dimension not enabled, don't bother proceeding return false; } } else if (GetWorld()->GetLinkedOverworldName().empty()) { + // Overworld teleportation disabled, abort return false; } @@ -1051,11 +1053,13 @@ bool cEntity::DetectPortal() { if (m_PortalCooldownData.m_ShouldPreventTeleportation) { + // Just exited a portal, don't teleport again return false; } if (IsPlayer() && !((cPlayer *)this)->IsGameModeCreative() && m_PortalCooldownData.m_TicksDelayed != 80) { + // Delay teleportation for four seconds if the entity is a non-creative player m_PortalCooldownData.m_TicksDelayed++; return false; } @@ -1070,11 +1074,11 @@ bool cEntity::DetectPortal() return false; } - m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn + m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn if (IsPlayer()) { - ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimOverworld); + ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimOverworld); // Send a respawn packet before world is loaded/generated so the client isn't left in limbo } return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false); @@ -1086,7 +1090,7 @@ bool cEntity::DetectPortal() return false; } - m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn + m_PortalCooldownData.m_ShouldPreventTeleportation = true; if (IsPlayer()) { @@ -1115,7 +1119,7 @@ bool cEntity::DetectPortal() return false; } - m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn + m_PortalCooldownData.m_ShouldPreventTeleportation = true; if (IsPlayer()) { @@ -1133,7 +1137,7 @@ bool cEntity::DetectPortal() return false; } - m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn + m_PortalCooldownData.m_ShouldPreventTeleportation = true; if (IsPlayer()) { @@ -1152,7 +1156,7 @@ bool cEntity::DetectPortal() // Allow portals to work again m_PortalCooldownData.m_ShouldPreventTeleportation = false; - m_PortalCooldownData.m_ShouldPreventTeleportation = 0; + m_PortalCooldownData.m_TicksDelayed = 0; return false; } @@ -1160,7 +1164,7 @@ bool cEntity::DetectPortal() -bool cEntity::MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) +bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) { UNUSED(a_ShouldSendRespawn); ASSERT(a_World != NULL); @@ -1172,11 +1176,12 @@ bool cEntity::MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) } // Remove all links to the old world - SetWorldTravellingFrom(GetWorld()); // cChunk handles entity removal + SetWorldTravellingFrom(GetWorld()); // cChunk::Tick() handles entity removal GetWorld()->BroadcastDestroyEntity(*this); // Queue add to new world a_World->AddEntity(this); + SetWorld(a_World); return true; } @@ -1194,7 +1199,7 @@ bool cEntity::MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn) return false; } - return MoveToWorld(World, a_ShouldSendRespawn); + return DoMoveToWorld(World, a_ShouldSendRespawn); } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 62a4097f3..4b096b475 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -385,15 +385,17 @@ public: virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ); /** Moves entity to specified world, taking a world pointer */ - virtual bool MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn = true); + bool MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn = true) { return DoMoveToWorld(a_World, a_ShouldSendRespawn); } /** Moves entity to specified world, taking a world name */ bool MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn = true); // tolua_end + virtual bool DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn); + /** Returns if the entity is travelling away from a specified world */ - bool IsWorldTravellingFrom(cWorld * a_World) const { return m_WorldTravellingFrom == a_World; } + bool IsWorldTravellingFrom(cWorld * a_World) const { return (m_WorldTravellingFrom == a_World); } /** Sets the world the entity will be leaving */ void SetWorldTravellingFrom(cWorld * a_World) { m_WorldTravellingFrom = a_World; } @@ -500,7 +502,7 @@ protected: bool m_IsInitialized; /** World entity is travelling from - Set by MoveToWorld and back to NULL when the entity is removed by the old chunk + Set to a valid world pointer by MoveToWorld; reset to NULL when the entity is removed from the old world Can't be a simple boolean as context switches between worlds may leave the new chunk processing (and therefore immediately removing) the entity before the old chunk could remove it */ cWorld * m_WorldTravellingFrom; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 087ac448f..406da8baa 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1609,7 +1609,7 @@ void cPlayer::TossItems(const cItems & a_Items) -bool cPlayer::MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) +bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) { ASSERT(a_World != NULL); diff --git a/src/Entities/Player.h b/src/Entities/Player.h index d1b3a0339..c28802eec 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -333,7 +333,7 @@ public: /** Moves the player to the specified world. Returns true if successful, false on failure (world not found). */ - virtual bool MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn = true) override; // tolua_export + virtual bool DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) override; /** Saves all player data, such as inventory, to JSON */ bool SaveToDisk(void); @@ -341,13 +341,13 @@ public: typedef cWorld * cWorldPtr; /** Loads the player data from the disk file - Takes a (NULL) cWorld pointer which it will assign a value to based on either the loaded world or default world by calling LoadFromFile() + Sets a_World to the world where the player will spawn, based on the stored world name or the default world by calling LoadFromFile() Returns true on success, false on failure */ bool LoadFromDisk(cWorldPtr & a_World); /** Loads the player data from the specified file - Takes a (NULL) cWorld pointer which it will assign a value to based on either the loaded world or default world + Sets a_World to the world where the player will spawn, based on the stored world name or the default world Returns true on success, false on failure */ bool LoadFromFile(const AString & a_FileName, cWorldPtr & a_World); diff --git a/src/World.cpp b/src/World.cpp index 9cbaf48fb..bcb2fa88d 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -66,9 +66,6 @@ const int TIME_NIGHT_END = 22812; const int TIME_SUNRISE = 23999; const int TIME_SPAWN_DIVISOR = 148; -#define DEFAULT_NETHER_NAME GetName() + "_nether" -#define DEFAULT_END_NAME GetName() + "_end" - @@ -255,7 +252,7 @@ cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AStrin m_Scoreboard(this), m_MapManager(this), m_GeneratorCallbacks(*this), - m_TickThread(*this) + m_TickThread(*this) { LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str()); @@ -580,8 +577,8 @@ void cWorld::Start(void) if (GetDimension() == dimOverworld) { - m_NetherWorldName = IniFile.GetValueSet("LinkedWorlds", "NetherWorldName", DEFAULT_NETHER_NAME); - m_EndWorldName = IniFile.GetValueSet("LinkedWorlds", "EndWorldName", DEFAULT_END_NAME); + m_NetherWorldName = IniFile.GetValueSet("LinkedWorlds", "NetherWorldName", GetName() + "_nether"); + m_EndWorldName = IniFile.GetValueSet("LinkedWorlds", "EndWorldName", GetName() + "_end"); } else { -- cgit v1.2.3 From 9678341a11caa08a40c3ddb562d893fc0cd2ba73 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 24 Jul 2014 12:15:48 +0200 Subject: Made the cWorld::SpawnMobFinalize function more readable. --- src/World.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/World.cpp b/src/World.cpp index 4ddd11f59..104805209 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2975,21 +2975,31 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eTyp int cWorld::SpawnMobFinalize(cMonster * a_Monster) { + // Invalid cMonster object. Bail out. if (!a_Monster) + { return -1; + } + + // Give the mob full health. a_Monster->SetHealth(a_Monster->GetMaxHealth()); + + // A plugin doesn't agree with the spawn. bail out. if (cPluginManager::Get()->CallHookSpawningMonster(*this, *a_Monster)) { delete a_Monster; a_Monster = NULL; return -1; } + + // Initialize the monster into the current world. if (!a_Monster->Initialize(*this)) { delete a_Monster; a_Monster = NULL; return -1; } + BroadcastSpawnEntity(*a_Monster); cPluginManager::Get()->CallHookSpawnedMonster(*this, *a_Monster); -- cgit v1.2.3 From c0b62ef139a65ca648135fb6999e6623438fdd71 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Jul 2014 18:32:05 +0200 Subject: Added a queue for setting chunk data. Fixes #1196. --- src/CMakeLists.txt | 2 + src/Chunk.cpp | 40 ++++++-------- src/Chunk.h | 14 ++--- src/ChunkMap.cpp | 25 +++------ src/ChunkMap.h | 20 ++----- src/SetChunkData.cpp | 115 ++++++++++++++++++++++++++++++++++++++ src/SetChunkData.h | 120 ++++++++++++++++++++++++++++++++++++++++ src/World.cpp | 85 +++++++++++++++++----------- src/World.h | 36 ++++++------ src/WorldStorage/WSSAnvil.cpp | 5 +- src/WorldStorage/WSSCompact.cpp | 5 +- 11 files changed, 349 insertions(+), 118 deletions(-) create mode 100644 src/SetChunkData.cpp create mode 100644 src/SetChunkData.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b8780e8a6..29337cb2e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,6 +56,7 @@ SET (SRCS Root.cpp Scoreboard.cpp Server.cpp + SetChunkData.cpp Statistics.cpp StringCompression.cpp StringUtils.cpp @@ -124,6 +125,7 @@ SET (HDRS Root.h Scoreboard.h Server.h + SetChunkData.h StackWalker.h Statistics.h StringCompression.h diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 60987b070..10bc2ff23 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -34,6 +34,7 @@ #include "MobCensus.h" #include "MobSpawner.h" #include "BlockInServerPluginInterface.h" +#include "SetChunkData.h" #include "json/json.h" @@ -265,41 +266,34 @@ void cChunk::GetAllData(cChunkDataCallback & a_Callback) -void cChunk::SetAllData( - const BLOCKTYPE * a_BlockTypes, - const NIBBLETYPE * a_BlockMeta, - const NIBBLETYPE * a_BlockLight, - const NIBBLETYPE * a_BlockSkyLight, - const HeightMap * a_HeightMap, - const BiomeMap & a_BiomeMap, - cBlockEntityList & a_BlockEntities -) +void cChunk::SetAllData(cSetChunkData & a_SetChunkData) { - memcpy(m_BiomeMap, a_BiomeMap, sizeof(m_BiomeMap)); + ASSERT(a_SetChunkData.IsHeightMapValid()); + ASSERT(a_SetChunkData.AreBiomesValid()); + + memcpy(m_BiomeMap, a_SetChunkData.GetBiomes(), sizeof(m_BiomeMap)); + memcpy(m_HeightMap, a_SetChunkData.GetHeightMap(), sizeof(m_HeightMap)); - if (a_HeightMap != NULL) + m_ChunkData.SetBlockTypes(a_SetChunkData.GetBlockTypes()); + m_ChunkData.SetMetas(a_SetChunkData.GetBlockMetas()); + if (a_SetChunkData.IsLightValid()) { - memcpy(m_HeightMap, a_HeightMap, sizeof(m_HeightMap)); + m_ChunkData.SetBlockLight(a_SetChunkData.GetBlockLight()); + m_ChunkData.SetSkyLight(a_SetChunkData.GetSkyLight()); + m_IsLightValid = true; } - - if (a_HeightMap == NULL) + else { - CalculateHeightmap(a_BlockTypes); + m_IsLightValid = false; } - m_ChunkData.SetBlockTypes(a_BlockTypes); - m_ChunkData.SetMetas(a_BlockMeta); - m_ChunkData.SetBlockLight(a_BlockLight); - m_ChunkData.SetSkyLight(a_BlockSkyLight); - - m_IsLightValid = (a_BlockLight != NULL) && (a_BlockSkyLight != NULL); - // Clear the block entities present - either the loader / saver has better, or we'll create empty ones: for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr) { delete *itr; } - std::swap(a_BlockEntities, m_BlockEntities); + m_BlockEntities.clear(); + std::swap(a_SetChunkData.GetBlockEntities(), m_BlockEntities); // Set all block entities' World variable: for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr) diff --git a/src/Chunk.h b/src/Chunk.h index 9ab39a0a2..5d50f9717 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -95,16 +95,10 @@ public: /** Gets all chunk data, calls the a_Callback's methods for each data type */ void GetAllData(cChunkDataCallback & a_Callback); - /** Sets all chunk data */ - void SetAllData( - const BLOCKTYPE * a_BlockTypes, - const NIBBLETYPE * a_BlockMeta, - const NIBBLETYPE * a_BlockLight, - const NIBBLETYPE * a_BlockSkyLight, - const cChunkDef::HeightMap * a_HeightMap, - const cChunkDef::BiomeMap & a_BiomeMap, - cBlockEntityList & a_BlockEntities - ); + /** Sets all chunk data as either loaded from the storage or generated. + BlockLight and BlockSkyLight are optional, if not present, chunk will be marked as unlighted. + Modifies the BlockEntity list in a_SetChunkData - moves the block entities into the chunk. */ + void SetAllData(cSetChunkData & a_SetChunkData); void SetLight( const cChunkDef::BlockNibbles & a_BlockLight, diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 3ef981e94..05d219918 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -16,6 +16,7 @@ #include "MobCensus.h" #include "MobSpawner.h" #include "BoundingBox.h" +#include "SetChunkData.h" #include "Entities/Pickup.h" @@ -912,28 +913,20 @@ void cChunkMap::MarkChunkSaved (int a_ChunkX, int a_ChunkZ) -void cChunkMap::SetChunkData( - int a_ChunkX, int a_ChunkZ, - const BLOCKTYPE * a_BlockTypes, - const NIBBLETYPE * a_BlockMeta, - const NIBBLETYPE * a_BlockLight, - const NIBBLETYPE * a_BlockSkyLight, - const cChunkDef::HeightMap * a_HeightMap, - const cChunkDef::BiomeMap & a_BiomeMap, - cBlockEntityList & a_BlockEntities, - bool a_MarkDirty -) +void cChunkMap::SetChunkData(cSetChunkData & a_SetChunkData) { + int ChunkX = a_SetChunkData.GetChunkX(); + int ChunkZ = a_SetChunkData.GetChunkZ(); { cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunkNoLoad(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ); + cChunkPtr Chunk = GetChunkNoLoad(ChunkX, ZERO_CHUNK_Y, ChunkZ); if (Chunk == NULL) { return; } - Chunk->SetAllData(a_BlockTypes, a_BlockMeta, a_BlockLight, a_BlockSkyLight, a_HeightMap, a_BiomeMap, a_BlockEntities); + Chunk->SetAllData(a_SetChunkData); - if (a_MarkDirty) + if (a_SetChunkData.ShouldMarkDirty()) { Chunk->MarkDirty(); } @@ -942,7 +935,7 @@ void cChunkMap::SetChunkData( cChunkStays ToBeDisabled; for (cChunkStays::iterator itr = m_ChunkStays.begin(), end = m_ChunkStays.end(); itr != end; ++itr) { - if ((*itr)->ChunkAvailable(a_ChunkX, a_ChunkZ)) + if ((*itr)->ChunkAvailable(ChunkX, ChunkZ)) { // The chunkstay wants to be disabled, add it to a list of to-be-disabled chunkstays for later processing: ToBeDisabled.push_back(*itr); @@ -957,7 +950,7 @@ void cChunkMap::SetChunkData( } // Notify plugins of the chunk becoming available - cPluginManager::Get()->CallHookChunkAvailable(m_World, a_ChunkX, a_ChunkZ); + cPluginManager::Get()->CallHookChunkAvailable(m_World, ChunkX, ChunkZ); } diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 4be1a4752..e33d9f894 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -34,6 +34,7 @@ class cChunkDataSerializer; class cBlockArea; class cMobCensus; class cMobSpawner; +class cSetChunkData; typedef std::list cClientHandleList; typedef cChunk * cChunkPtr; @@ -112,22 +113,11 @@ public: void MarkChunkSaved (int a_ChunkX, int a_ChunkZ); /** Sets the chunk data as either loaded from the storage or generated. - a_BlockLight and a_BlockSkyLight are optional, if not present, chunk will be marked as unlighted. - a_BiomeMap is optional, if not present, biomes will be calculated by the generator - a_HeightMap is optional, if not present, will be calculated. - If a_MarkDirty is set, the chunk is set as dirty (used after generating) + BlockLight and BlockSkyLight are optional, if not present, chunk will be marked as unlighted. + If MarkDirty is set, the chunk is set as dirty (used after generating) + Modifies the BlockEntity list in a_SetChunkData - moves the block entities into the chunk. */ - void SetChunkData( - int a_ChunkX, int a_ChunkZ, - const BLOCKTYPE * a_BlockTypes, - const NIBBLETYPE * a_BlockMeta, - const NIBBLETYPE * a_BlockLight, - const NIBBLETYPE * a_BlockSkyLight, - const cChunkDef::HeightMap * a_HeightMap, - const cChunkDef::BiomeMap & a_BiomeMap, - cBlockEntityList & a_BlockEntities, - bool a_MarkDirty - ); + void SetChunkData(cSetChunkData & a_SetChunkData); void ChunkLighted( int a_ChunkX, int a_ChunkZ, diff --git a/src/SetChunkData.cpp b/src/SetChunkData.cpp new file mode 100644 index 000000000..6e0c2733e --- /dev/null +++ b/src/SetChunkData.cpp @@ -0,0 +1,115 @@ + +// SetChunkData.cpp + +// Implements the cSetChunkData class used for sending loaded / generated chunk + +#include "Globals.h" +#include "SetChunkData.h" + + + + + +cSetChunkData::cSetChunkData(int a_ChunkX, int a_ChunkZ, bool a_ShouldMarkDirty) : + m_ChunkX(a_ChunkX), + m_ChunkZ(a_ChunkZ), + m_ShouldMarkDirty(a_ShouldMarkDirty) +{ +} + + + + + +cSetChunkData::cSetChunkData( + int a_ChunkX, int a_ChunkZ, + const BLOCKTYPE * a_BlockTypes, + const NIBBLETYPE * a_BlockMetas, + const NIBBLETYPE * a_BlockLight, + const NIBBLETYPE * a_SkyLight, + const cChunkDef::HeightMap * a_HeightMap, + const cChunkDef::BiomeMap * a_Biomes, + cEntityList & a_Entities, + cBlockEntityList & a_BlockEntities, + bool a_ShouldMarkDirty +) : + m_ChunkX(a_ChunkX), + m_ChunkZ(a_ChunkZ), + m_ShouldMarkDirty(a_ShouldMarkDirty) +{ + // Check the params' validity: + ASSERT(a_BlockTypes != NULL); + ASSERT(a_BlockMetas != NULL); + ASSERT(a_Biomes != NULL); + + // Copy block types and metas: + memcpy(m_BlockTypes, a_BlockTypes, sizeof(cChunkDef::BlockTypes)); + memcpy(m_BlockMetas, a_BlockMetas, sizeof(cChunkDef::BlockNibbles)); + + // Copy lights, if both given: + if ((a_BlockLight != NULL) && (a_SkyLight != NULL)) + { + memcpy(m_BlockLight, a_BlockLight, sizeof(m_BlockLight)); + memcpy(m_SkyLight, a_SkyLight, sizeof(m_SkyLight)); + m_IsLightValid = true; + } + else + { + m_IsLightValid = false; + } + + // Copy the heightmap, if available: + if (a_HeightMap != NULL) + { + memcpy(m_HeightMap, a_HeightMap, sizeof(m_HeightMap)); + m_IsHeightMapValid = true; + } + else + { + m_IsHeightMapValid = false; + } + + // Copy biomes, if available: + if (a_Biomes != NULL) + { + memcpy(m_Biomes, a_Biomes, sizeof(m_Biomes)); + m_AreBiomesValid = true; + } + else + { + m_AreBiomesValid = false; + } + + // Move entities and blockentities: + std::swap(m_Entities, a_Entities); + std::swap(m_BlockEntities, a_BlockEntities); +} + + + + + +void cSetChunkData::CalculateHeightMap(void) +{ + for (int x = 0; x < cChunkDef::Width; x++) + { + for (int z = 0; z < cChunkDef::Width; z++) + { + for (int y = cChunkDef::Height - 1; y > -1; y--) + { + int index = cChunkDef::MakeIndexNoCheck(x, y, z); + if (m_BlockTypes[index] != E_BLOCK_AIR) + { + m_HeightMap[x + z * cChunkDef::Width] = (HEIGHTTYPE)y; + break; + } + } // for y + } // for z + } // for x + m_IsHeightMapValid = true; +} + + + + + diff --git a/src/SetChunkData.h b/src/SetChunkData.h new file mode 100644 index 000000000..a2f776f6b --- /dev/null +++ b/src/SetChunkData.h @@ -0,0 +1,120 @@ + +// SetChunkData.h + +// Declares the cSetChunkData class used for sending loaded / generated chunk data into cWorld + + + + + +#pragma once + + + + + +class cSetChunkData +{ +public: + /** Constructs a new instance with empty data. + Allocates new buffers for the block data. + Prefer to use this constructor, then fill the object with data and then send it to cWorld, as this will + reduce the copying required to queue the set operation. */ + cSetChunkData(int a_ChunkX, int a_ChunkZ, bool a_ShouldMarkDirty); + + /** Constructs a new instance based on data existing elsewhere, will copy all the memory. Prefer to use the + other constructor as much as possible. + Will move the entity and blockentity lists into the internal storage, and empty the a_Entities and + a_BlockEntities lists. + a_BlockTypes and a_BlockMetas must always be valid. + If either of the light arrays are NULL, the chunk data will be marked as not having any light at all and + will be scheduled for re-lighting once it is set into the chunkmap. + If a_Biomes is not valid, the internal flag is set and the world will calculate the biomes using the chunk + generator when setting the chunk data. + If a_HeightMap is not assigned, the world will calculate the heightmap based on the blocktypes when setting + the chunk data. */ + cSetChunkData( + int a_ChunkX, int a_ChunkZ, + const BLOCKTYPE * a_BlockTypes, + const NIBBLETYPE * a_BlockMetas, + const NIBBLETYPE * a_BlockLight, + const NIBBLETYPE * a_SkyLight, + const cChunkDef::HeightMap * a_HeightMap, + const cChunkDef::BiomeMap * a_Biomes, + cEntityList & a_Entities, + cBlockEntityList & a_BlockEntities, + bool a_ShouldMarkDirty + ); + + int GetChunkX(void) const { return m_ChunkX; } + int GetChunkZ(void) const { return m_ChunkZ; } + + /** Returns the internal storage of the block types, read-only. */ + const cChunkDef::BlockTypes & GetBlockTypes(void) const { return m_BlockTypes; } + + /** Returns the internal storage of the block types, read-only. */ + const cChunkDef::BlockNibbles & GetBlockMetas(void) const { return m_BlockMetas; } + + /** Returns the internal storage of the block light, read-only. */ + const cChunkDef::BlockNibbles & GetBlockLight(void) const { return m_BlockLight; } + + /** Returns the internal storage of the block types, read-only. */ + const cChunkDef::BlockNibbles & GetSkyLight(void) const { return m_SkyLight; } + + /** Returns the internal storage for heightmap, read-only. */ + const cChunkDef::HeightMap & GetHeightMap(void) const { return m_HeightMap; } + + /** Returns the internal storage for biomes, read-write. */ + cChunkDef::BiomeMap & GetBiomes(void) { return m_Biomes; } + + /** Returns the internal storage for entities, read-write. */ + cEntityList & GetEntities(void) { return m_Entities; } + + /** Returns the internal storage for block entities, read-write. */ + cBlockEntityList & GetBlockEntities(void) { return m_BlockEntities; } + + /** Returns whether both light arrays stored in this object are valid. */ + bool IsLightValid(void) const { return m_IsLightValid; } + + /** Returns whether the heightmap stored in this object is valid. */ + bool IsHeightMapValid(void) const { return m_IsHeightMapValid; } + + /** Returns whether the biomes stored in this object are valid. */ + bool AreBiomesValid(void) const { return m_AreBiomesValid; } + + /** Returns whether the chunk should be marked as dirty after its data is set. + Used by the generator to save chunks after generating. */ + bool ShouldMarkDirty(void) const { return m_ShouldMarkDirty; } + + /** Marks the biomes stored in this object as valid. */ + void MarkBiomesValid(void) { m_AreBiomesValid = true; } + + /** Calculates the heightmap based on the contained blocktypes and marks it valid. */ + void CalculateHeightMap(void); + +protected: + int m_ChunkX; + int m_ChunkZ; + + cChunkDef::BlockTypes m_BlockTypes; + cChunkDef::BlockNibbles m_BlockMetas; + cChunkDef::BlockNibbles m_BlockLight; + cChunkDef::BlockNibbles m_SkyLight; + cChunkDef::HeightMap m_HeightMap; + cChunkDef::BiomeMap m_Biomes; + cEntityList m_Entities; + cBlockEntityList m_BlockEntities; + + bool m_IsLightValid; + bool m_IsHeightMapValid; + bool m_AreBiomesValid; + bool m_ShouldMarkDirty; +}; + +typedef SharedPtr cSetChunkDataPtr; // TODO: Change to unique_ptr once we go C++11 +typedef std::vector cSetChunkDataPtrs; + + + + + diff --git a/src/World.cpp b/src/World.cpp index 104805209..7ad350e24 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -11,6 +11,7 @@ #include "ChunkMap.h" #include "Generating/ChunkDesc.h" #include "OSSupport/Timer.h" +#include "SetChunkData.h" // Serializers #include "WorldStorage/ScoreboardSerializer.h" @@ -719,6 +720,17 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec) // Call the plugins cPluginManager::Get()->CallHookWorldTick(*this, a_Dt, a_LastTickDurationMSec); + // Set any chunk data that has been queued for setting: + cSetChunkDataPtrs SetChunkDataQueue; + { + cCSLock Lock(m_CSSetChunkDataQueue); + std::swap(SetChunkDataQueue, m_SetChunkDataQueue); + } + for (cSetChunkDataPtrs::iterator itr = SetChunkDataQueue.begin(), end = SetChunkDataQueue.end(); itr != end; ++itr) + { + SetChunkData(**itr); + } // for itr - SetChunkDataQueue[] + // We need sub-tick precision here, that's why we store the time in seconds and calculate ticks off of it m_WorldAgeSecs += (double)a_Dt / 1000.0; m_TimeOfDaySecs += (double)a_Dt / 1000.0; @@ -2217,47 +2229,59 @@ void cWorld::MarkChunkSaved (int a_ChunkX, int a_ChunkZ) -void cWorld::SetChunkData( - int a_ChunkX, int a_ChunkZ, - const BLOCKTYPE * a_BlockTypes, - const NIBBLETYPE * a_BlockMeta, - const NIBBLETYPE * a_BlockLight, - const NIBBLETYPE * a_BlockSkyLight, - const cChunkDef::HeightMap * a_HeightMap, - const cChunkDef::BiomeMap * a_BiomeMap, - cEntityList & a_Entities, - cBlockEntityList & a_BlockEntities, - bool a_MarkDirty -) +void cWorld::QueueSetChunkData(const cSetChunkDataPtr & a_SetChunkData) { // Validate biomes, if needed: - cChunkDef::BiomeMap BiomeMap; - const cChunkDef::BiomeMap * Biomes = a_BiomeMap; - if (a_BiomeMap == NULL) + if (!a_SetChunkData->AreBiomesValid()) { // The biomes are not assigned, get them from the generator: - Biomes = &BiomeMap; - m_Generator.GenerateBiomes(a_ChunkX, a_ChunkZ, BiomeMap); + m_Generator.GenerateBiomes(a_SetChunkData->GetChunkX(), a_SetChunkData->GetChunkZ(), a_SetChunkData->GetBiomes()); + a_SetChunkData->MarkBiomesValid(); } - m_ChunkMap->SetChunkData( - a_ChunkX, a_ChunkZ, - a_BlockTypes, a_BlockMeta, a_BlockLight, a_BlockSkyLight, - a_HeightMap, *Biomes, - a_BlockEntities, - a_MarkDirty - ); + // Validate heightmap, if needed: + if (!a_SetChunkData->IsHeightMapValid()) + { + a_SetChunkData->CalculateHeightMap(); + } + + // Store a copy of the data in the queue: + // TODO: If the queue is too large, wait for it to get processed. Not likely, though. + cCSLock Lock(m_CSSetChunkDataQueue); + m_SetChunkDataQueue.push_back(a_SetChunkData); +} + + + + + +void cWorld::SetChunkData(cSetChunkData & a_SetChunkData) +{ + ASSERT(a_SetChunkData.AreBiomesValid()); + ASSERT(a_SetChunkData.IsHeightMapValid()); + + m_ChunkMap->SetChunkData(a_SetChunkData); // Initialize the entities (outside the m_ChunkMap's CS, to fix FS #347): - for (cEntityList::iterator itr = a_Entities.begin(), end = a_Entities.end(); itr != end; ++itr) + cEntityList Entities; + std::swap(a_SetChunkData.GetEntities(), Entities); + for (cEntityList::iterator itr = Entities.begin(), end = Entities.end(); itr != end; ++itr) { (*itr)->Initialize(*this); } // If a client is requesting this chunk, send it to them: - if (m_ChunkMap->HasChunkAnyClients(a_ChunkX, a_ChunkZ)) + int ChunkX = a_SetChunkData.GetChunkX(); + int ChunkZ = a_SetChunkData.GetChunkZ(); + if (m_ChunkMap->HasChunkAnyClients(ChunkX, ChunkZ)) + { + m_ChunkSender.ChunkReady(ChunkX, ChunkZ); + } + + // Save the chunk right after generating, so that we don't have to generate it again on next run + if (a_SetChunkData.ShouldMarkDirty()) { - m_ChunkSender.ChunkReady(a_ChunkX, a_ChunkZ); + m_Storage.QueueSaveChunk(ChunkX, 0, ChunkZ); } } @@ -3295,17 +3319,14 @@ void cWorld::cChunkGeneratorCallbacks::OnChunkGenerated(cChunkDesc & a_ChunkDesc cChunkDef::BlockNibbles BlockMetas; a_ChunkDesc.CompressBlockMetas(BlockMetas); - m_World->SetChunkData( + m_World->QueueSetChunkData(cSetChunkDataPtr(new cSetChunkData( a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ(), a_ChunkDesc.GetBlockTypes(), BlockMetas, NULL, NULL, // We don't have lighting, chunk will be lighted when needed &a_ChunkDesc.GetHeightMap(), &a_ChunkDesc.GetBiomeMap(), a_ChunkDesc.GetEntities(), a_ChunkDesc.GetBlockEntities(), true - ); - - // Save the chunk right after generating, so that we don't have to generate it again on next run - m_World->GetStorage().QueueSaveChunk(a_ChunkDesc.GetChunkX(), 0, a_ChunkDesc.GetChunkZ()); + ))); } diff --git a/src/World.h b/src/World.h index 2346ac523..6613b495a 100644 --- a/src/World.h +++ b/src/World.h @@ -49,9 +49,14 @@ class cNoteEntity; class cMobHeadEntity; class cCompositeChat; class cCuboid; +class cSetChunkData; + typedef std::list< cPlayer * > cPlayerList; +typedef SharedPtr cSetChunkDataPtr; // TODO: Change to unique_ptr once we go C++11 +typedef std::vector cSetChunkDataPtrs; + typedef cItemCallback cPlayerListCallback; typedef cItemCallback cEntityCallback; typedef cItemCallback cChestCallback; @@ -246,24 +251,9 @@ public: void MarkChunkSaving(int a_ChunkX, int a_ChunkZ); void MarkChunkSaved (int a_ChunkX, int a_ChunkZ); - /** Sets the chunk data as either loaded from the storage or generated. - a_BlockLight and a_BlockSkyLight are optional, if not present, chunk will be marked as unlighted. - a_BiomeMap is optional, if not present, biomes will be calculated by the generator - a_HeightMap is optional, if not present, will be calculated. - If a_MarkDirty is set, the chunk is set as dirty (used after generating) - */ - void SetChunkData( - int a_ChunkX, int a_ChunkZ, - const BLOCKTYPE * a_BlockTypes, - const NIBBLETYPE * a_BlockMeta, - const NIBBLETYPE * a_BlockLight, - const NIBBLETYPE * a_BlockSkyLight, - const cChunkDef::HeightMap * a_HeightMap, - const cChunkDef::BiomeMap * a_BiomeMap, - cEntityList & a_Entities, - cBlockEntityList & a_BlockEntities, - bool a_MarkDirty - ); + /** Puts the chunk data into a queue to be set into the chunkmap in the tick thread. + If the chunk data doesn't contain valid biomes, the biomes are calculated before adding the data into the queue. */ + void QueueSetChunkData(const cSetChunkDataPtr & a_SetChunkData); void ChunkLighted( int a_ChunkX, int a_ChunkZ, @@ -969,6 +959,12 @@ private: /** List of players that are scheduled for adding, waiting for the Tick thread to add them. */ cPlayerList m_PlayersToAdd; + + /** CS protecting m_SetChunkDataQueue. */ + cCriticalSection m_CSSetChunkDataQueue; + + /** Queue for the chunk data to be set into m_ChunkMap by the tick thread. Protected by m_CSSetChunkDataQueue */ + cSetChunkDataPtrs m_SetChunkDataQueue; cWorld(const AString & a_WorldName); @@ -1011,6 +1007,10 @@ private: /** Adds the players queued in the m_PlayersToAdd queue into the m_Players list. Assumes it is called from the Tick thread. */ void AddQueuedPlayers(void); + + /** Sets the specified chunk data into the chunkmap. Called in the tick thread. + Modifies the a_SetChunkData - moves the entities contained in it into the chunk. */ + void SetChunkData(cSetChunkData & a_SetChunkData); }; // tolua_export diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 663d489bc..2851647fe 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -14,6 +14,7 @@ #include "../Item.h" #include "../ItemGrid.h" #include "../StringCompression.h" +#include "../SetChunkData.h" #include "../BlockEntities/ChestEntity.h" #include "../BlockEntities/CommandBlockEntity.h" @@ -391,7 +392,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT } // for y //*/ - m_World->SetChunkData( + m_World->QueueSetChunkData(cSetChunkDataPtr(new cSetChunkData( a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, BlockTypes, MetaData, IsLightValid ? BlockLight : NULL, @@ -399,7 +400,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT NULL, Biomes, Entities, BlockEntities, false - ); + ))); return true; } diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index 5382a3e01..ee47047a0 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -18,6 +18,7 @@ #include "../BlockEntities/MobHeadEntity.h" #include "../BlockEntities/NoteEntity.h" #include "../BlockEntities/SignEntity.h" +#include "../SetChunkData.h" @@ -911,7 +912,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre NIBBLETYPE * BlockLight = (NIBBLETYPE *)(BlockData + LightOffset); NIBBLETYPE * SkyLight = (NIBBLETYPE *)(BlockData + SkyLightOffset); - a_World->SetChunkData( + a_World->QueueSetChunkData(cSetChunkDataPtr(new cSetChunkData( a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, BlockData, MetaData, IsLightValid ? BlockLight : NULL, @@ -919,7 +920,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre NULL, NULL, Entities, BlockEntities, false - ); + ))); return true; } -- cgit v1.2.3 From 4191be7ddba820af4ed0c505a8d62416c2b7a8b4 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 22 Jul 2014 15:36:13 -0700 Subject: Removed redundant semicolons and re-added warning --- src/Bindings/Plugin.h | 4 ++-- src/BlockEntities/BlockEntity.h | 4 ++-- src/BlockEntities/JukeboxEntity.h | 2 +- src/BlockEntities/NoteEntity.h | 2 +- src/Blocks/BlockHandler.h | 8 ++++---- src/Chunk.h | 6 +++--- src/ChunkDataCallback.h | 14 +++++++------- src/CommandOutput.h | 6 +++--- src/Entities/ArrowEntity.h | 2 +- src/Entities/Boat.h | 2 +- src/Entities/EnderCrystal.h | 2 +- src/Entities/Entity.h | 2 +- src/Entities/EntityEffect.h | 2 +- src/Entities/ExpBottleEntity.h | 2 +- src/Entities/ExpOrb.h | 2 +- src/Entities/FallingBlock.h | 2 +- src/Entities/FireChargeEntity.h | 2 +- src/Entities/FireworkEntity.h | 2 +- src/Entities/Floater.h | 2 +- src/Entities/GhastFireballEntity.h | 2 +- src/Entities/HangingEntity.h | 4 ++-- src/Entities/ItemFrame.h | 4 ++-- src/Entities/Minecart.h | 12 ++++++------ src/Entities/Painting.h | 2 +- src/Entities/Pawn.h | 2 +- src/Entities/Pickup.h | 2 +- src/Entities/Player.h | 2 +- src/Entities/ProjectileEntity.h | 2 +- src/Entities/SplashPotionEntity.h | 2 +- src/Entities/TNTEntity.h | 2 +- src/Entities/ThrownEggEntity.h | 2 +- src/Entities/ThrownEnderPearlEntity.h | 2 +- src/Entities/ThrownSnowballEntity.h | 2 +- src/Entities/WitherSkullEntity.h | 2 +- src/Generating/ChunkGenerator.h | 2 +- src/HTTPServer/HTTPMessage.h | 2 +- src/Mobs/Bat.h | 2 +- src/Mobs/Blaze.h | 2 +- src/Mobs/CaveSpider.h | 2 +- src/Mobs/Chicken.h | 2 +- src/Mobs/Cow.h | 2 +- src/Mobs/Creeper.h | 2 +- src/Mobs/EnderDragon.h | 2 +- src/Mobs/Enderman.h | 2 +- src/Mobs/Ghast.h | 2 +- src/Mobs/Giant.h | 2 +- src/Mobs/Horse.h | 2 +- src/Mobs/IronGolem.h | 2 +- src/Mobs/MagmaCube.h | 2 +- src/Mobs/Monster.h | 2 +- src/Mobs/Mooshroom.h | 2 +- src/Mobs/Ocelot.h | 2 +- src/Mobs/Pig.h | 2 +- src/Mobs/Sheep.h | 2 +- src/Mobs/Silverfish.h | 2 +- src/Mobs/Skeleton.h | 4 ++-- src/Mobs/Slime.h | 2 +- src/Mobs/SnowGolem.h | 2 +- src/Mobs/Spider.h | 2 +- src/Mobs/Squid.h | 2 +- src/Mobs/Villager.h | 2 +- src/Mobs/Witch.h | 2 +- src/Mobs/Wither.h | 2 +- src/Mobs/Wolf.h | 2 +- src/Mobs/Zombie.h | 2 +- src/Mobs/ZombiePigman.h | 2 +- src/OSSupport/Queue.h | 4 ++-- src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.h | 2 +- src/Simulator/Simulator.h | 2 +- src/World.h | 12 ++++++------ src/WorldStorage/FastNBT.h | 2 +- src/WorldStorage/WorldStorage.h | 4 ++-- 73 files changed, 103 insertions(+), 103 deletions(-) (limited to 'src') diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 3882b7474..39d53674b 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -115,10 +115,10 @@ public: virtual bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output) = 0; /// All bound commands are to be removed, do any language-dependent cleanup here - virtual void ClearCommands(void) {} ; + virtual void ClearCommands(void) {} /// All bound console commands are to be removed, do any language-dependent cleanup here - virtual void ClearConsoleCommands(void) {} ; + virtual void ClearConsoleCommands(void) {} // tolua_begin const AString & GetName(void) const { return m_Name; } diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h index 24c25e729..5710f8543 100644 --- a/src/BlockEntities/BlockEntity.h +++ b/src/BlockEntities/BlockEntity.h @@ -38,9 +38,9 @@ protected: public: // tolua_end - virtual ~cBlockEntity() {}; // force a virtual destructor in all descendants + virtual ~cBlockEntity() {} // force a virtual destructor in all descendants - virtual void Destroy(void) {}; + virtual void Destroy(void) {} void SetWorld(cWorld * a_World) { diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h index 8bb3009eb..d677d340f 100644 --- a/src/BlockEntities/JukeboxEntity.h +++ b/src/BlockEntities/JukeboxEntity.h @@ -58,7 +58,7 @@ public: static const char * GetClassStatic(void) { return "cJukeboxEntity"; } virtual void UsedBy(cPlayer * a_Player) override; - virtual void SendTo(cClientHandle &) override { }; + virtual void SendTo(cClientHandle &) override {} private: int m_Record; diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h index 07b8fd259..e8497da3e 100644 --- a/src/BlockEntities/NoteEntity.h +++ b/src/BlockEntities/NoteEntity.h @@ -52,7 +52,7 @@ public: // tolua_end virtual void UsedBy(cPlayer * a_Player) override; - virtual void SendTo(cClientHandle &) override { }; + virtual void SendTo(cClientHandle &) override {} static const char * GetClassStatic(void) { return "cNoteEntity"; } diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 01c64b457..94ab8d8c6 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -60,19 +60,19 @@ public: virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ); /// Called when a direct neighbor of this block has been changed (The position is the own position, not the neighbor position) - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {}; + virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {} /// Notifies all neighbors of the given block about a change static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ); /// Called while the player diggs the block. - virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {}; + virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {} /// Called if the user right clicks the block and the block is useable - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) {}; + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) {} /** Called when a right click to this block is cancelled */ - virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}; + virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {} /// Called when the item is mined to convert it into pickups. Pickups may specify multiple items. Appends items to a_Pickups, preserves its original contents virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta); diff --git a/src/Chunk.h b/src/Chunk.h index 5d50f9717..7eee3999c 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -380,9 +380,9 @@ public: cRedstoneSimulatorChunkData * GetRedstoneSimulatorData(void) { return &m_RedstoneSimulatorData; } cRedstoneSimulatorChunkData * GetRedstoneSimulatorQueuedData(void) { return &m_RedstoneSimulatorQueuedData; } cIncrementalRedstoneSimulator::PoweredBlocksList * GetRedstoneSimulatorPoweredBlocksList(void) { return &m_RedstoneSimulatorPoweredBlocksList; } - cIncrementalRedstoneSimulator::LinkedBlocksList * GetRedstoneSimulatorLinkedBlocksList(void) { return &m_RedstoneSimulatorLinkedBlocksList; }; - cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList * GetRedstoneSimulatorSimulatedPlayerToggleableList(void) { return &m_RedstoneSimulatorSimulatedPlayerToggleableList; }; - cIncrementalRedstoneSimulator::RepeatersDelayList * GetRedstoneSimulatorRepeatersDelayList(void) { return &m_RedstoneSimulatorRepeatersDelayList; }; + cIncrementalRedstoneSimulator::LinkedBlocksList * GetRedstoneSimulatorLinkedBlocksList(void) { return &m_RedstoneSimulatorLinkedBlocksList; } + cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList * GetRedstoneSimulatorSimulatedPlayerToggleableList(void) { return &m_RedstoneSimulatorSimulatedPlayerToggleableList; } + cIncrementalRedstoneSimulator::RepeatersDelayList * GetRedstoneSimulatorRepeatersDelayList(void) { return &m_RedstoneSimulatorRepeatersDelayList; } bool IsRedstoneDirty(void) const { return m_IsRedstoneDirty; } void SetIsRedstoneDirty(bool a_Flag) { m_IsRedstoneDirty = a_Flag; } diff --git a/src/ChunkDataCallback.h b/src/ChunkDataCallback.h index 53d44d038..804299816 100644 --- a/src/ChunkDataCallback.h +++ b/src/ChunkDataCallback.h @@ -29,25 +29,25 @@ public: (only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()). If false is returned, the chunk is skipped. */ - virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; }; + virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; } /// Called once to provide heightmap data - virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) {UNUSED(a_HeightMap); }; + virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) { UNUSED(a_HeightMap); } /// Called once to provide biome data - virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) {UNUSED(a_BiomeMap); }; + virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) { UNUSED(a_BiomeMap); } /// Called once to let know if the chunk lighting is valid. Return value is ignored - virtual void LightIsValid(bool a_IsLightValid) {UNUSED(a_IsLightValid); }; + virtual void LightIsValid(bool a_IsLightValid) { UNUSED(a_IsLightValid); } /// Called once to export block info - virtual void ChunkData(const cChunkData & a_Buffer) {UNUSED(a_Buffer); }; + virtual void ChunkData(const cChunkData & a_Buffer) { UNUSED(a_Buffer); } /// Called for each entity in the chunk - virtual void Entity(cEntity * a_Entity) {UNUSED(a_Entity); }; + virtual void Entity(cEntity * a_Entity) { UNUSED(a_Entity); } /// Called for each blockentity in the chunk - virtual void BlockEntity(cBlockEntity * a_Entity) {UNUSED(a_Entity); }; + virtual void BlockEntity(cBlockEntity * a_Entity) { UNUSED(a_Entity); } } ; diff --git a/src/CommandOutput.h b/src/CommandOutput.h index 5682b4fd8..daa9430c0 100644 --- a/src/CommandOutput.h +++ b/src/CommandOutput.h @@ -14,16 +14,16 @@ Descendants override that function to provide specific processing of the output. class cCommandOutputCallback { public: - virtual ~cCommandOutputCallback() {}; // Force a virtual destructor in subclasses + virtual ~cCommandOutputCallback() {} // Force a virtual destructor in subclasses - /// Syntax sugar function, calls Out() with Printf()-ed parameters; appends a "\n" + /// Syntax sugar function, calls Out() with Printf()-ed parameters; appends a newline" void Out(const char * a_Fmt, ...) FORMATSTRING(2, 3); /// Called when the command wants to output anything; may be called multiple times virtual void Out(const AString & a_Text) = 0; /// Called when the command processing has been finished - virtual void Finished(void) {}; + virtual void Finished(void) {} } ; diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h index ad93dba6c..4bfcb1f6d 100644 --- a/src/Entities/ArrowEntity.h +++ b/src/Entities/ArrowEntity.h @@ -28,7 +28,7 @@ public: // tolua_end - CLASS_PROTODEF(cArrowEntity); + CLASS_PROTODEF(cArrowEntity) /// Creates a new arrow with psNoPickup state and default damage modifier coeff cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/Boat.h b/src/Entities/Boat.h index 0fcfbd602..8de88d165 100644 --- a/src/Entities/Boat.h +++ b/src/Entities/Boat.h @@ -21,7 +21,7 @@ class cBoat : typedef cEntity super; public: - CLASS_PROTODEF(cBoat); + CLASS_PROTODEF(cBoat) // cEntity overrides: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; diff --git a/src/Entities/EnderCrystal.h b/src/Entities/EnderCrystal.h index 30211de13..c98c3b681 100644 --- a/src/Entities/EnderCrystal.h +++ b/src/Entities/EnderCrystal.h @@ -15,7 +15,7 @@ class cEnderCrystal : typedef cEntity super; public: - CLASS_PROTODEF(cEnderCrystal); + CLASS_PROTODEF(cEnderCrystal) cEnderCrystal(double a_X, double a_Y, double a_Z); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 83fe76e7e..efca60a6c 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -428,7 +428,7 @@ public: // tolua_end /// Called when the specified player right-clicks this entity - virtual void OnRightClicked(cPlayer &) {}; + virtual void OnRightClicked(cPlayer &) {} /// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy(). virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index ebd611ff0..396a9bbe0 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -55,7 +55,7 @@ public: @param a_OtherEffect The other effect to copy */ cEntityEffect & operator=(cEntityEffect a_OtherEffect); - virtual ~cEntityEffect(void) {}; + virtual ~cEntityEffect(void) {} /** Creates a pointer to the proper entity effect from the effect type @warning This function creates raw pointers that must be manually managed. diff --git a/src/Entities/ExpBottleEntity.h b/src/Entities/ExpBottleEntity.h index e9536452c..d62a84469 100644 --- a/src/Entities/ExpBottleEntity.h +++ b/src/Entities/ExpBottleEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cExpBottleEntity); + CLASS_PROTODEF(cExpBottleEntity) cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/ExpOrb.h b/src/Entities/ExpOrb.h index 2cd4ef31f..bdb9a5b19 100644 --- a/src/Entities/ExpOrb.h +++ b/src/Entities/ExpOrb.h @@ -16,7 +16,7 @@ class cExpOrb : public: // tolua_end - CLASS_PROTODEF(cExpOrb); + CLASS_PROTODEF(cExpOrb) cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward); cExpOrb(const Vector3d & a_Pos, int a_Reward); diff --git a/src/Entities/FallingBlock.h b/src/Entities/FallingBlock.h index 5ba9909bb..c20fe8eb9 100644 --- a/src/Entities/FallingBlock.h +++ b/src/Entities/FallingBlock.h @@ -20,7 +20,7 @@ class cFallingBlock : typedef cEntity super; public: - CLASS_PROTODEF(cFallingBlock); + CLASS_PROTODEF(cFallingBlock) /// Creates a new falling block. a_BlockPosition is expected in world coords cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h index 42ecc7d74..5df55bec4 100644 --- a/src/Entities/FireChargeEntity.h +++ b/src/Entities/FireChargeEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cFireChargeEntity); + CLASS_PROTODEF(cFireChargeEntity) cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/FireworkEntity.h b/src/Entities/FireworkEntity.h index 7dbdc49e1..20f18b6dc 100644 --- a/src/Entities/FireworkEntity.h +++ b/src/Entities/FireworkEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cFireworkEntity); + CLASS_PROTODEF(cFireworkEntity) cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item); const cItem & GetItem(void) const { return m_FireworkItem; } diff --git a/src/Entities/Floater.h b/src/Entities/Floater.h index 5d2720b6a..96d77ac82 100644 --- a/src/Entities/Floater.h +++ b/src/Entities/Floater.h @@ -16,7 +16,7 @@ class cFloater : public: // tolua_end - CLASS_PROTODEF(cFloater); + CLASS_PROTODEF(cFloater) cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime); diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h index fa59fa642..3ed72d9ef 100644 --- a/src/Entities/GhastFireballEntity.h +++ b/src/Entities/GhastFireballEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cGhastFireballEntity); + CLASS_PROTODEF(cGhastFireballEntity) cGhastFireballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/HangingEntity.h b/src/Entities/HangingEntity.h index 6498e4b5b..3593f9ede 100644 --- a/src/Entities/HangingEntity.h +++ b/src/Entities/HangingEntity.h @@ -16,7 +16,7 @@ class cHangingEntity : public: - CLASS_PROTODEF(cHangingEntity); + CLASS_PROTODEF(cHangingEntity) cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z); @@ -38,7 +38,7 @@ public: private: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override {}; + virtual void Tick(float a_Dt, cChunk & a_Chunk) override {} eBlockFace m_BlockFace; diff --git a/src/Entities/ItemFrame.h b/src/Entities/ItemFrame.h index 9261e52cc..a63b78b70 100644 --- a/src/Entities/ItemFrame.h +++ b/src/Entities/ItemFrame.h @@ -16,7 +16,7 @@ class cItemFrame : public: - CLASS_PROTODEF(cItemFrame); + CLASS_PROTODEF(cItemFrame) cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z); @@ -24,7 +24,7 @@ public: const cItem & GetItem(void) { return m_Item; } // tolua_export /** Set the item in the frame */ - void SetItem(cItem & a_Item) { m_Item = a_Item; }; // tolua_export + void SetItem(cItem & a_Item) { m_Item = a_Item; } // tolua_export /** Returns the rotation from the item in the frame */ Byte GetRotation(void) const { return m_Rotation; } // tolua_export diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h index c585cfab0..410d3c77d 100644 --- a/src/Entities/Minecart.h +++ b/src/Entities/Minecart.h @@ -21,7 +21,7 @@ class cMinecart : typedef cEntity super; public: - CLASS_PROTODEF(cMinecart); + CLASS_PROTODEF(cMinecart) /** Minecart payload, values correspond to packet subtype */ enum ePayload @@ -89,7 +89,7 @@ class cRideableMinecart : typedef cMinecart super; public: - CLASS_PROTODEF(cRideableMinecart); + CLASS_PROTODEF(cRideableMinecart) cRideableMinecart(double a_X, double a_Y, double a_Z, const cItem & a_Content, int a_Height); @@ -113,7 +113,7 @@ class cMinecartWithChest : typedef cMinecart super; public: - CLASS_PROTODEF(cMinecartWithChest); + CLASS_PROTODEF(cMinecartWithChest) /// Number of item slots in the chest static const int NumSlots = 9 * 3; @@ -144,7 +144,7 @@ class cMinecartWithFurnace : typedef cMinecart super; public: - CLASS_PROTODEF(cMinecartWithFurnace); + CLASS_PROTODEF(cMinecartWithFurnace) cMinecartWithFurnace(double a_X, double a_Y, double a_Z); @@ -176,7 +176,7 @@ class cMinecartWithTNT : typedef cMinecart super; public: - CLASS_PROTODEF(cMinecartWithTNT); + CLASS_PROTODEF(cMinecartWithTNT) cMinecartWithTNT(double a_X, double a_Y, double a_Z); } ; @@ -191,7 +191,7 @@ class cMinecartWithHopper : typedef cMinecart super; public: - CLASS_PROTODEF(cMinecartWithHopper); + CLASS_PROTODEF(cMinecartWithHopper) cMinecartWithHopper(double a_X, double a_Y, double a_Z); } ; diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h index ce7c6f3de..9877c95c5 100644 --- a/src/Entities/Painting.h +++ b/src/Entities/Painting.h @@ -15,7 +15,7 @@ class cPainting : typedef cEntity super; public: - CLASS_PROTODEF(cPainting); + CLASS_PROTODEF(cPainting) cPainting(const AString & a_Name, int a_Direction, double a_X, double a_Y, double a_Z); const AString & GetName(void) const { return m_Name; } // tolua_export diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index 63c7cfbb6..d50bcd8af 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -16,7 +16,7 @@ class cPawn : typedef cEntity super; public: - CLASS_PROTODEF(cPawn); + CLASS_PROTODEF(cPawn) cPawn(eEntityType a_EntityType, double a_Width, double a_Height); diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h index d7c5d2b26..4d5250819 100644 --- a/src/Entities/Pickup.h +++ b/src/Entities/Pickup.h @@ -23,7 +23,7 @@ class cPickup : public: // tolua_end - CLASS_PROTODEF(cPickup); + CLASS_PROTODEF(cPickup) cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 26db2050b..488884602 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -48,7 +48,7 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); }; + virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); } /** Returns the curently equipped weapon; empty item if none */ virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); } diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index e6b05714e..0ebc32f36 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -41,7 +41,7 @@ public: // tolua_end - CLASS_PROTODEF(cProjectileEntity); + CLASS_PROTODEF(cProjectileEntity) cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height); cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height); diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 290dd81d4..dd14ea82f 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -23,7 +23,7 @@ public: // tolua_end - CLASS_PROTODEF(cSplashPotionEntity); + CLASS_PROTODEF(cSplashPotionEntity) cSplashPotionEntity( cEntity * a_Creator, diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h index df61b14f5..48503cf76 100644 --- a/src/Entities/TNTEntity.h +++ b/src/Entities/TNTEntity.h @@ -14,7 +14,7 @@ class cTNTEntity : public: // tolua_end - CLASS_PROTODEF(cTNTEntity); + CLASS_PROTODEF(cTNTEntity) cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks = 80); cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks = 80); diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h index f93731256..a0b7d5340 100644 --- a/src/Entities/ThrownEggEntity.h +++ b/src/Entities/ThrownEggEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cThrownEggEntity); + CLASS_PROTODEF(cThrownEggEntity) cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h index 549d8a3eb..436450013 100644 --- a/src/Entities/ThrownEnderPearlEntity.h +++ b/src/Entities/ThrownEnderPearlEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cThrownEnderPearlEntity); + CLASS_PROTODEF(cThrownEnderPearlEntity) cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h index 6f3efdd7e..8d195ced1 100644 --- a/src/Entities/ThrownSnowballEntity.h +++ b/src/Entities/ThrownSnowballEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cThrownSnowballEntity); + CLASS_PROTODEF(cThrownSnowballEntity) cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h index ebc1550e3..c59acd807 100644 --- a/src/Entities/WitherSkullEntity.h +++ b/src/Entities/WitherSkullEntity.h @@ -22,7 +22,7 @@ public: // tolua_end - CLASS_PROTODEF(cWitherSkullEntity); + CLASS_PROTODEF(cWitherSkullEntity) cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Generating/ChunkGenerator.h b/src/Generating/ChunkGenerator.h index 9b2d9eb3c..88d71f3f9 100644 --- a/src/Generating/ChunkGenerator.h +++ b/src/Generating/ChunkGenerator.h @@ -44,7 +44,7 @@ public: { public: cGenerator(cChunkGenerator & a_ChunkGenerator); - virtual ~cGenerator() {} ; // Force a virtual destructor + virtual ~cGenerator() {} // Force a virtual destructor /// Called to initialize the generator on server startup. virtual void Initialize(cIniFile & a_IniFile); diff --git a/src/HTTPServer/HTTPMessage.h b/src/HTTPServer/HTTPMessage.h index dab942136..e402c8ad6 100644 --- a/src/HTTPServer/HTTPMessage.h +++ b/src/HTTPServer/HTTPMessage.h @@ -33,7 +33,7 @@ public: cHTTPMessage(eKind a_Kind); // Force a virtual destructor in all descendants - virtual ~cHTTPMessage() {}; + virtual ~cHTTPMessage() {} /** Adds a header into the internal map of headers. Recognizes special headers: Content-Type and Content-Length */ void AddHeader(const AString & a_Key, const AString & a_Value); diff --git a/src/Mobs/Bat.h b/src/Mobs/Bat.h index e878d0ee8..6b06aeb4f 100644 --- a/src/Mobs/Bat.h +++ b/src/Mobs/Bat.h @@ -15,7 +15,7 @@ class cBat : public: cBat(void); - CLASS_PROTODEF(cBat); + CLASS_PROTODEF(cBat) bool IsHanging(void) const {return false; } } ; diff --git a/src/Mobs/Blaze.h b/src/Mobs/Blaze.h index 5970451c7..f283b1070 100644 --- a/src/Mobs/Blaze.h +++ b/src/Mobs/Blaze.h @@ -15,7 +15,7 @@ class cBlaze : public: cBlaze(void); - CLASS_PROTODEF(cBlaze); + CLASS_PROTODEF(cBlaze) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void Attack(float a_Dt) override; diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h index 3f8b2cece..f9ed10e1b 100644 --- a/src/Mobs/CaveSpider.h +++ b/src/Mobs/CaveSpider.h @@ -14,7 +14,7 @@ class cCaveSpider : public: cCaveSpider(void); - CLASS_PROTODEF(cCaveSpider); + CLASS_PROTODEF(cCaveSpider) virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void Attack(float a_Dt) override; diff --git a/src/Mobs/Chicken.h b/src/Mobs/Chicken.h index a4c1d6b9e..b1a50b61c 100644 --- a/src/Mobs/Chicken.h +++ b/src/Mobs/Chicken.h @@ -14,7 +14,7 @@ class cChicken : public: cChicken(void); - CLASS_PROTODEF(cChicken); + CLASS_PROTODEF(cChicken) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; diff --git a/src/Mobs/Cow.h b/src/Mobs/Cow.h index 973171ab5..8814b7e09 100644 --- a/src/Mobs/Cow.h +++ b/src/Mobs/Cow.h @@ -15,7 +15,7 @@ class cCow : public: cCow(); - CLASS_PROTODEF(cCow); + CLASS_PROTODEF(cCow) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h index fc7db6716..747daca09 100644 --- a/src/Mobs/Creeper.h +++ b/src/Mobs/Creeper.h @@ -15,7 +15,7 @@ class cCreeper : public: cCreeper(void); - CLASS_PROTODEF(cCreeper); + CLASS_PROTODEF(cCreeper) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; diff --git a/src/Mobs/EnderDragon.h b/src/Mobs/EnderDragon.h index 77177edfe..1d4cd657c 100644 --- a/src/Mobs/EnderDragon.h +++ b/src/Mobs/EnderDragon.h @@ -15,7 +15,7 @@ class cEnderDragon : public: cEnderDragon(void); - CLASS_PROTODEF(cEnderDragon); + CLASS_PROTODEF(cEnderDragon) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; } ; diff --git a/src/Mobs/Enderman.h b/src/Mobs/Enderman.h index 32e40e70b..aa2eff682 100644 --- a/src/Mobs/Enderman.h +++ b/src/Mobs/Enderman.h @@ -15,7 +15,7 @@ class cEnderman : public: cEnderman(void); - CLASS_PROTODEF(cEnderman); + CLASS_PROTODEF(cEnderman) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; diff --git a/src/Mobs/Ghast.h b/src/Mobs/Ghast.h index 43e8bedb6..1d4e6b94a 100644 --- a/src/Mobs/Ghast.h +++ b/src/Mobs/Ghast.h @@ -15,7 +15,7 @@ class cGhast : public: cGhast(void); - CLASS_PROTODEF(cGhast); + CLASS_PROTODEF(cGhast) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void Attack(float a_Dt) override; diff --git a/src/Mobs/Giant.h b/src/Mobs/Giant.h index 356dd4352..7c04c9b4f 100644 --- a/src/Mobs/Giant.h +++ b/src/Mobs/Giant.h @@ -15,7 +15,7 @@ class cGiant : public: cGiant(void); - CLASS_PROTODEF(cGiant); + CLASS_PROTODEF(cGiant) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; } ; diff --git a/src/Mobs/Horse.h b/src/Mobs/Horse.h index be0c23f9b..47189b3b0 100644 --- a/src/Mobs/Horse.h +++ b/src/Mobs/Horse.h @@ -15,7 +15,7 @@ class cHorse : public: cHorse(int Type, int Color, int Style, int TameTimes); - CLASS_PROTODEF(cHorse); + CLASS_PROTODEF(cHorse) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; diff --git a/src/Mobs/IronGolem.h b/src/Mobs/IronGolem.h index 30f9bedff..c5341ed76 100644 --- a/src/Mobs/IronGolem.h +++ b/src/Mobs/IronGolem.h @@ -15,7 +15,7 @@ class cIronGolem : public: cIronGolem(void); - CLASS_PROTODEF(cIronGolem); + CLASS_PROTODEF(cIronGolem) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; diff --git a/src/Mobs/MagmaCube.h b/src/Mobs/MagmaCube.h index 43065cae5..bfe63fa2e 100644 --- a/src/Mobs/MagmaCube.h +++ b/src/Mobs/MagmaCube.h @@ -15,7 +15,7 @@ public: /// Creates a MagmaCube of the specified size; size is 1 .. 3, with 1 being the smallest cMagmaCube(int a_Size); - CLASS_PROTODEF(cMagmaCube); + CLASS_PROTODEF(cMagmaCube) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; int GetSize(void) const { return m_Size; } diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index ffd078505..cdbd26c09 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -82,7 +82,7 @@ public: */ cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); - CLASS_PROTODEF(cMonster); + CLASS_PROTODEF(cMonster) virtual void SpawnOn(cClientHandle & a_ClientHandle) override; diff --git a/src/Mobs/Mooshroom.h b/src/Mobs/Mooshroom.h index 16f6c8248..fb002c2bf 100644 --- a/src/Mobs/Mooshroom.h +++ b/src/Mobs/Mooshroom.h @@ -15,7 +15,7 @@ class cMooshroom : public: cMooshroom(void); - CLASS_PROTODEF(cMooshroom); + CLASS_PROTODEF(cMooshroom) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; diff --git a/src/Mobs/Ocelot.h b/src/Mobs/Ocelot.h index adb7a1f75..f2727d354 100644 --- a/src/Mobs/Ocelot.h +++ b/src/Mobs/Ocelot.h @@ -18,7 +18,7 @@ public: { } - CLASS_PROTODEF(cOcelot); + CLASS_PROTODEF(cOcelot) } ; diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h index 313af2f44..534a0ca6f 100644 --- a/src/Mobs/Pig.h +++ b/src/Mobs/Pig.h @@ -15,7 +15,7 @@ class cPig : public: cPig(void); - CLASS_PROTODEF(cPig); + CLASS_PROTODEF(cPig) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h index 5ffd3e4fe..28e1c7254 100644 --- a/src/Mobs/Sheep.h +++ b/src/Mobs/Sheep.h @@ -20,7 +20,7 @@ public: with the GenerateNaturalRandomColor() function. */ cSheep(int a_Color = -1); - CLASS_PROTODEF(cSheep); + CLASS_PROTODEF(cSheep) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; diff --git a/src/Mobs/Silverfish.h b/src/Mobs/Silverfish.h index a6e11c49d..2df333dbc 100644 --- a/src/Mobs/Silverfish.h +++ b/src/Mobs/Silverfish.h @@ -18,7 +18,7 @@ public: { } - CLASS_PROTODEF(cSilverfish); + CLASS_PROTODEF(cSilverfish) } ; diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h index 9a121ef48..577588b32 100644 --- a/src/Mobs/Skeleton.h +++ b/src/Mobs/Skeleton.h @@ -15,7 +15,7 @@ class cSkeleton : public: cSkeleton(bool IsWither); - CLASS_PROTODEF(cSkeleton); + CLASS_PROTODEF(cSkeleton) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void MoveToPosition(const Vector3d & a_Position) override; @@ -24,7 +24,7 @@ public: virtual bool IsUndead(void) override { return true; } - bool IsWither(void) const { return m_bIsWither; }; + bool IsWither(void) const { return m_bIsWither; } private: diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h index 15ae113dc..f0b800f94 100644 --- a/src/Mobs/Slime.h +++ b/src/Mobs/Slime.h @@ -16,7 +16,7 @@ public: /** Creates a slime of the specified size; size can be 1, 2 or 4, with 1 is the smallest and 4 is the tallest. */ cSlime(int a_Size); - CLASS_PROTODEF(cSlime); + CLASS_PROTODEF(cSlime) // cAggressiveMonster overrides: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; diff --git a/src/Mobs/SnowGolem.h b/src/Mobs/SnowGolem.h index ff5e90da8..aba89e52d 100644 --- a/src/Mobs/SnowGolem.h +++ b/src/Mobs/SnowGolem.h @@ -15,7 +15,7 @@ class cSnowGolem : public: cSnowGolem(void); - CLASS_PROTODEF(cSnowGolem); + CLASS_PROTODEF(cSnowGolem) virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; diff --git a/src/Mobs/Spider.h b/src/Mobs/Spider.h index 51e65d028..813d2e266 100644 --- a/src/Mobs/Spider.h +++ b/src/Mobs/Spider.h @@ -15,7 +15,7 @@ class cSpider : public: cSpider(void); - CLASS_PROTODEF(cSpider); + CLASS_PROTODEF(cSpider) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; } ; diff --git a/src/Mobs/Squid.h b/src/Mobs/Squid.h index a9dba8b70..b57340427 100644 --- a/src/Mobs/Squid.h +++ b/src/Mobs/Squid.h @@ -17,7 +17,7 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - CLASS_PROTODEF(cSquid); + CLASS_PROTODEF(cSquid) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; diff --git a/src/Mobs/Villager.h b/src/Mobs/Villager.h index 068dfd835..aa81f0790 100644 --- a/src/Mobs/Villager.h +++ b/src/Mobs/Villager.h @@ -27,7 +27,7 @@ public: cVillager(eVillagerType VillagerType); - CLASS_PROTODEF(cVillager); + CLASS_PROTODEF(cVillager) // cEntity overrides virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; diff --git a/src/Mobs/Witch.h b/src/Mobs/Witch.h index 51c63322a..bd059f61d 100644 --- a/src/Mobs/Witch.h +++ b/src/Mobs/Witch.h @@ -16,7 +16,7 @@ class cWitch : public: cWitch(); - CLASS_PROTODEF(cWitch); + CLASS_PROTODEF(cWitch) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index cc8d1459b..2403823ed 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -15,7 +15,7 @@ class cWither : public: cWither(void); - CLASS_PROTODEF(cWither); + CLASS_PROTODEF(cWither) unsigned int GetWitherInvulnerableTicks(void) const { return m_WitherInvulnerableTicks; } diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h index fb8a7c995..2e83db701 100644 --- a/src/Mobs/Wolf.h +++ b/src/Mobs/Wolf.h @@ -16,7 +16,7 @@ class cWolf : public: cWolf(void); - CLASS_PROTODEF(cWolf); + CLASS_PROTODEF(cWolf) virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void OnRightClicked(cPlayer & a_Player) override; diff --git a/src/Mobs/Zombie.h b/src/Mobs/Zombie.h index 082573d8b..118b6e6e7 100644 --- a/src/Mobs/Zombie.h +++ b/src/Mobs/Zombie.h @@ -14,7 +14,7 @@ class cZombie : public: cZombie(bool a_IsVillagerZombie); - CLASS_PROTODEF(cZombie); + CLASS_PROTODEF(cZombie) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void MoveToPosition(const Vector3d & a_Position) override; diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h index a4bad7efb..bae0115eb 100644 --- a/src/Mobs/ZombiePigman.h +++ b/src/Mobs/ZombiePigman.h @@ -14,7 +14,7 @@ class cZombiePigman : public: cZombiePigman(void); - CLASS_PROTODEF(cZombiePigman); + CLASS_PROTODEF(cZombiePigman) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void KilledBy(TakeDamageInfo & a_TDI) override; diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index 269f9db41..bf4d7f004 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -26,14 +26,14 @@ struct cQueueFuncs public: /// Called when an Item is deleted from the queue without being returned - static void Delete(T) {}; + static void Delete(T) {} /// Called when an Item is inserted with EnqueueItemIfNotPresent and there is another equal value already inserted static void Combine(T & a_existing, const T & a_new) { UNUSED(a_existing); UNUSED(a_new); - }; + } }; diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index c5ba7a679..166e9ab1b 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -138,7 +138,7 @@ protected: virtual void SendData(const char * a_Data, size_t a_Size) = 0; /// Called after writing each packet, enables descendants to flush their buffers - virtual void Flush(void) {}; + virtual void Flush(void) {} // Helpers for writing partial packet data, write using SendData() void WriteByte(Byte a_Value) diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index d7ebf535b..bf08b6c50 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -90,7 +90,7 @@ public: virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay) override; virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override; - virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override {}; + virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override {} virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override; virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void SendWeather (eWeather a_Weather) override; diff --git a/src/Simulator/Simulator.h b/src/Simulator/Simulator.h index 171eba91c..4d9a18867 100644 --- a/src/Simulator/Simulator.h +++ b/src/Simulator/Simulator.h @@ -32,7 +32,7 @@ public: UNUSED(a_ChunkX); UNUSED(a_ChunkZ); UNUSED(a_Chunk); - }; + } /// Called when a block changes virtual void WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk); diff --git a/src/World.h b/src/World.h index 6613b495a..9658178ae 100644 --- a/src/World.h +++ b/src/World.h @@ -96,7 +96,7 @@ public: class cTask { public: - virtual ~cTask(){}; + virtual ~cTask() {} virtual void Run(cWorld & a_World) = 0; } ; @@ -645,7 +645,7 @@ public: void GetChunkStats(int & a_NumValid, int & a_NumDirty, int & a_NumInLightingQueue); // Various queues length queries (cannot be const, they lock their CS): - inline int GetGeneratorQueueLength (void) { return m_Generator.GetQueueLength(); } // tolua_export + inline int GetGeneratorQueueLength (void) { return m_Generator.GetQueueLength(); } // tolua_export inline size_t GetLightingQueueLength (void) { return m_Lighting.GetQueueLength(); } // tolua_export inline size_t GetStorageLoadQueueLength(void) { return m_Storage.GetLoadQueueLength(); } // tolua_export inline size_t GetStorageSaveQueueLength(void) { return m_Storage.GetSaveQueueLength(); } // tolua_export @@ -677,13 +677,13 @@ public: void CastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ); /** Sets the specified weather; resets weather interval; asks and notifies plugins of the change */ - void SetWeather (eWeather a_NewWeather); + void SetWeather(eWeather a_NewWeather); /** Forces a weather change in the next game tick */ - void ChangeWeather (void); + void ChangeWeather(void); /** Returns the current weather. Instead of comparing values directly to the weather constants, use IsWeatherXXX() functions, if possible */ - eWeather GetWeather (void) const { return m_Weather; }; + eWeather GetWeather(void) const { return m_Weather; } /** Returns true if the current weather is sun */ bool IsWeatherSunny(void) const { return (m_Weather == wSunny); } @@ -698,7 +698,7 @@ public: bool IsWeatherRain(void) const { return (m_Weather == wRain); } /** Returns true if it is raining at the specified location. This takes into account biomes. */ - bool IsWeatherRainAt (int a_BlockX, int a_BlockZ) + bool IsWeatherRainAt(int a_BlockX, int a_BlockZ) { return (IsWeatherRain() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h index 7aa83fc24..4ef72e379 100644 --- a/src/WorldStorage/FastNBT.h +++ b/src/WorldStorage/FastNBT.h @@ -160,7 +160,7 @@ public: /** Returns the direct child tag of the specified name, or -1 if no such tag. */ int FindChildByName(int a_Tag, const char * a_Name, size_t a_NameLength = 0) const; - /** Returns the child tag of the specified path (Name1\Name2\Name3...), or -1 if no such tag. */ + /** Returns the child tag of the specified path (Name1/Name2/Name3...), or -1 if no such tag. */ int FindTagByPath(int a_Tag, const AString & a_Path) const; eTagType GetType(int a_Tag) const { return m_Tags[(size_t)a_Tag].m_Type; } diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index 2d5d9c830..978a5b5d1 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -103,11 +103,11 @@ protected: struct FuncTable { - static void Delete(sChunkLoad) {}; + static void Delete(sChunkLoad) {} static void Combine(sChunkLoad & a_orig, const sChunkLoad a_new) { a_orig.m_Generate |= a_new.m_Generate; - }; + } }; typedef cQueue sChunkLoadQueue; -- cgit v1.2.3 From 3a6002de5b13c1cd56d904892e5af6123978225d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 24 Jul 2014 21:38:25 +0100 Subject: Fixed block drops * Fixes #1242 (the issue addressed within) --- src/Blocks/BlockBigFlower.h | 6 +++--- src/Blocks/BlockHandler.cpp | 19 ++++++++++-------- src/Blocks/BlockHandler.h | 3 ++- src/Items/ItemHandler.cpp | 47 +++++++++++++++++++++++++++++++++++++++++---- src/Items/ItemSword.h | 1 - 5 files changed, 59 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h index bc7098aa0..0b6ac9d8a 100644 --- a/src/Blocks/BlockBigFlower.h +++ b/src/Blocks/BlockBigFlower.h @@ -19,16 +19,16 @@ public: } - virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim) override + virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop, bool a_DropVerbatim) override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); if (Meta & 0x8) { - super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ, a_DropVerbatim); + super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ, a_CanDrop, a_DropVerbatim); } else { - super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_DropVerbatim); + super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_CanDrop, a_DropVerbatim); } } diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 3e16f970a..ddb0186c9 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -418,19 +418,22 @@ void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) -void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim) +void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop, bool a_DropVerbatim) { cItems Pickups; NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - if (!a_DropVerbatim) + if (a_CanDrop) { - ConvertToPickups(Pickups, Meta); - } - else - { - // TODO: Add a proper overridable function for this - Pickups.Add(m_BlockType, 1, Meta); + if (!a_DropVerbatim) + { + ConvertToPickups(Pickups, Meta); + } + else + { + // TODO: Add a proper overridable function for this + Pickups.Add(m_BlockType, 1, Meta); + } } // Allow plugins to modify the pickups: diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 01c64b457..a5d15d930 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -79,9 +79,10 @@ public: /** Handles the dropping, but not destruction, of a block based on what ConvertTo(Verbatim)Pickups() returns, including the spawning of pickups and alertion of plugins @param a_Digger The entity causing the drop; it may be NULL + @param a_CanDrop Informs the handler whether the block should be dropped at all. One example when this is false is when stone is destroyed by hand @param a_DropVerbatim Calls ConvertToVerbatimPickups() instead of its counterpart, meaning the block itself is dropped by default (due to a speical tool or enchantment) */ - virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim = false); + virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop = true, bool a_DropVerbatim = false); /// Returns step sound name of block virtual const char * GetStepSound(void); diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 1671a8145..23dbb4348 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -330,7 +330,7 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const { cChunkInterface ChunkInterface(a_World->GetChunkMap()); cBlockInServerPluginInterface PluginInterface(*a_World); - Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block)); + Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block), a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0); } a_Player->UseEquippedItem(); @@ -511,9 +511,48 @@ bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType) bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) { - UNUSED(a_BlockType); - - return false; + switch (a_BlockType) + { + case E_BLOCK_ANVIL: + case E_BLOCK_ENCHANTMENT_TABLE: + case E_BLOCK_FURNACE: + case E_BLOCK_LIT_FURNACE: + case E_BLOCK_COAL_ORE: + case E_BLOCK_STONE: + case E_BLOCK_COBBLESTONE: + case E_BLOCK_END_STONE: + case E_BLOCK_MOSSY_COBBLESTONE: + case E_BLOCK_SANDSTONE_STAIRS: + case E_BLOCK_SANDSTONE: + case E_BLOCK_STONE_BRICKS: + case E_BLOCK_NETHER_BRICK: + case E_BLOCK_NETHERRACK: + case E_BLOCK_STONE_SLAB: + case E_BLOCK_DOUBLE_STONE_SLAB: + case E_BLOCK_STONE_PRESSURE_PLATE: + case E_BLOCK_BRICK: + case E_BLOCK_COBBLESTONE_STAIRS: + case E_BLOCK_COBBLESTONE_WALL: + case E_BLOCK_STONE_BRICK_STAIRS: + case E_BLOCK_NETHER_BRICK_STAIRS: + case E_BLOCK_CAULDRON: + case E_BLOCK_OBSIDIAN: + case E_BLOCK_DIAMOND_BLOCK: + case E_BLOCK_DIAMOND_ORE: + case E_BLOCK_GOLD_BLOCK: + case E_BLOCK_GOLD_ORE: + case E_BLOCK_REDSTONE_ORE: + case E_BLOCK_REDSTONE_ORE_GLOWING: + case E_BLOCK_EMERALD_ORE: + case E_BLOCK_IRON_BLOCK: + case E_BLOCK_IRON_ORE: + case E_BLOCK_LAPIS_ORE: + case E_BLOCK_LAPIS_BLOCK: + { + return false; + } + default: return true; + } } diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h index 44feb2d83..368b8724e 100644 --- a/src/Items/ItemSword.h +++ b/src/Items/ItemSword.h @@ -16,7 +16,6 @@ public: cItemSwordHandler(int a_ItemType) : cItemHandler(a_ItemType) { - } virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override -- cgit v1.2.3 From 0f298c8b84756cf5bc055ff82d43ffa9ea8d577b Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 25 Jul 2014 14:23:36 +0200 Subject: Speed up the NetherClumpFoliage finisher. Using IntNoiseXX instead of CubicNoiseXX. --- src/Generating/FinishGen.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index c67cc574e..b2585bfee 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -48,8 +48,8 @@ void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc) double ChunkX = a_ChunkDesc.GetChunkX() + 0.1; // We can't devide through 0 so lets add 0.1 to all the chunk coordinates. double ChunkZ = a_ChunkDesc.GetChunkZ() + 0.1; - NOISE_DATATYPE Val1 = m_Noise.CubicNoise2D((float) (ChunkX * ChunkZ * 0.01f), (float) (ChunkZ / ChunkX * 0.01f)); - NOISE_DATATYPE Val2 = m_Noise.CubicNoise2D((float) (ChunkX / ChunkZ / 0.01f), (float) (ChunkZ * ChunkX / 0.01f)); + NOISE_DATATYPE Val1 = m_Noise.IntNoise2D((int) (ChunkX * ChunkZ * 0.01f), (int) (ChunkZ / ChunkX * 0.01f)); + NOISE_DATATYPE Val2 = m_Noise.IntNoise2D((int) (ChunkX / ChunkZ / 0.01f), (int) (ChunkZ * ChunkX / 0.01f)); if (Val1 < 0) { @@ -88,12 +88,14 @@ void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc) { continue; } + if (!cBlockInfo::IsSolid(a_ChunkDesc.GetBlockType(PosX, y - 1, PosZ))) // Only place on solid blocks { continue; } - NOISE_DATATYPE BlockType = m_Noise.CubicNoise1D((float) (ChunkX * ChunkZ) / (y * 0.1f)); + // Choose what block to use. + NOISE_DATATYPE BlockType = m_Noise.IntNoise3D((int) ChunkX, y, (int) ChunkZ); if (BlockType < -0.7) { TryPlaceClump(a_ChunkDesc, PosX, y, PosZ, E_BLOCK_BROWN_MUSHROOM); @@ -119,10 +121,10 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a for (int x = a_RelX - 4; x < a_RelX + 4; x++) { - float xx = (float) a_ChunkDesc.GetChunkX() * cChunkDef::Width + x; + int xx = a_ChunkDesc.GetChunkX() * cChunkDef::Width + x; for (int z = a_RelZ - 4; z < a_RelZ + 4; z++) { - float zz = (float) a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; + int zz = a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; for (int y = a_RelY - 2; y < a_RelY + 2; y++) { if ((y < 1) || (y > cChunkDef::Height)) @@ -149,9 +151,8 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a } } - - NOISE_DATATYPE Val = m_Noise.CubicNoise2D(xx, zz); - if (Val < -0.70) + NOISE_DATATYPE Val = m_Noise.IntNoise2D(xx, zz); + if (Val < -0.5) { a_ChunkDesc.SetBlockType(x, y, z, a_Block); } -- cgit v1.2.3 From a39e19e94a1086cc2c5974cecc5d383cd26b3d12 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 25 Jul 2014 21:01:40 +0200 Subject: Tweaks to NetherClumpFoliage Simplefied the way NetherClupFoliage creates the X and Z coordinate. --- src/Generating/FinishGen.cpp | 40 ++++++---------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index b2585bfee..4c40270e8 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -45,42 +45,14 @@ static inline bool IsWater(BLOCKTYPE a_BlockType) void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc) { - double ChunkX = a_ChunkDesc.GetChunkX() + 0.1; // We can't devide through 0 so lets add 0.1 to all the chunk coordinates. - double ChunkZ = a_ChunkDesc.GetChunkZ() + 0.1; - - NOISE_DATATYPE Val1 = m_Noise.IntNoise2D((int) (ChunkX * ChunkZ * 0.01f), (int) (ChunkZ / ChunkX * 0.01f)); - NOISE_DATATYPE Val2 = m_Noise.IntNoise2D((int) (ChunkX / ChunkZ / 0.01f), (int) (ChunkZ * ChunkX / 0.01f)); + int ChunkX = a_ChunkDesc.GetChunkX(); + int ChunkZ = a_ChunkDesc.GetChunkZ(); - if (Val1 < 0) - { - Val1 = -Val1; - } - - if (Val2 < 0) - { - Val2 = -Val2; - } + int Val1 = m_Noise.IntNoise2DInt(ChunkX ^ ChunkZ, ChunkZ + ChunkX); + int Val2 = m_Noise.IntNoise2DInt(ChunkZ ^ ChunkX, ChunkZ - ChunkX); - int PosX, PosZ; - // Calculate PosX - if (Val1 <= 1) - { - PosX = (int) floor(Val1 * 16); - } - else - { - PosX = (int) floor(16 / Val1); - } - - // Calculate PosZ - if (Val2 <= 1) - { - PosZ = (int) floor(Val2 * 16); - } - else - { - PosZ = (int) floor(16 / Val2); - } + int PosX = Val1 % 16; + int PosZ = Val2 % 16; for (int y = 1; y < cChunkDef::Height; y++) { -- cgit v1.2.3 From 1595ef73dcd6f6a525744185bd24343c3f8050c8 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Jul 2014 03:42:42 -0700 Subject: Endianness.h: undefined ntohll before redefining --- src/Endianness.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Endianness.h b/src/Endianness.h index 5997086e0..9aeb44986 100644 --- a/src/Endianness.h +++ b/src/Endianness.h @@ -1,6 +1,7 @@ #pragma once +#undef ntohll #define ntohll(x) ((((UInt64)ntohl((u_long)x)) << 32) + ntohl(x >> 32)) -- cgit v1.2.3 From 0298d34406b1582e882795bf4d9d3fea18fd0135 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 02:56:59 -0700 Subject: Moved potion static functions to EntityEffect to create splash potions through world --- src/Entities/EntityEffect.cpp | 124 ++++++++++++++++++++++++++++++++ src/Entities/EntityEffect.h | 19 +++++ src/Entities/ProjectileEntity.cpp | 2 + src/Entities/SplashPotionEntity.cpp | 16 +++-- src/Entities/SplashPotionEntity.h | 4 +- src/Items/ItemPotion.h | 136 ++---------------------------------- src/WorldStorage/WSSAnvil.cpp | 2 +- 7 files changed, 164 insertions(+), 139 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp index 6c4b13a58..f58738aef 100644 --- a/src/Entities/EntityEffect.cpp +++ b/src/Entities/EntityEffect.cpp @@ -7,6 +7,130 @@ + +int cEntityEffect::GetPotionColor(short a_ItemDamage) +{ + // Lowest six bits + return (a_ItemDamage & 0x3f); +} + + + + + +cEntityEffect::eType cEntityEffect::GetPotionEffectType(short a_ItemDamage) +{ + // Lowest four bits + // Potion effect bits are different from entity effect values + // For reference: http://minecraft.gamepedia.com/Data_values#.22Potion_effect.22_bits + switch (a_ItemDamage & 0x0f) + { + case 0x01: return cEntityEffect::effRegeneration; + case 0x02: return cEntityEffect::effSpeed; + case 0x03: return cEntityEffect::effFireResistance; + case 0x04: return cEntityEffect::effPoison; + case 0x05: return cEntityEffect::effInstantHealth; + case 0x06: return cEntityEffect::effNightVision; + case 0x08: return cEntityEffect::effWeakness; + case 0x09: return cEntityEffect::effStrength; + case 0x0a: return cEntityEffect::effSlowness; + case 0x0c: return cEntityEffect::effInstantDamage; + case 0x0d: return cEntityEffect::effWaterBreathing; + case 0x0e: return cEntityEffect::effInvisibility; + + // No effect potions + case 0x00: + case 0x07: + case 0x0b: // Will be potion of leaping in 1.8 + case 0x0f: + { + break; + } + } + return cEntityEffect::effNoEffect; +} + + + + + +short cEntityEffect::GetPotionEffectIntensity(short a_ItemDamage) +{ + // Level II potion if the fifth lowest bit is set + return ((a_ItemDamage & 0x20) != 0) ? 1 : 0; +} + + + + + +int cEntityEffect::GetPotionEffectDuration(short a_ItemDamage) +{ + // Base duration in ticks + int base = 0; + double TierCoeff = 1, ExtCoeff = 1, SplashCoeff = 1; + + switch (GetPotionEffectType(a_ItemDamage)) + { + case cEntityEffect::effRegeneration: + case cEntityEffect::effPoison: + { + base = 900; + break; + } + + case cEntityEffect::effSpeed: + case cEntityEffect::effFireResistance: + case cEntityEffect::effNightVision: + case cEntityEffect::effStrength: + case cEntityEffect::effWaterBreathing: + case cEntityEffect::effInvisibility: + { + base = 3600; + break; + } + + case cEntityEffect::effWeakness: + case cEntityEffect::effSlowness: + { + base = 1800; + break; + } + } + + // If potion is level II, half the duration. If not, stays the same + TierCoeff = (GetPotionEffectIntensity(a_ItemDamage) > 0) ? 0.5 : 1; + + // If potion is extended, multiply duration by 8/3. If not, stays the same + // Extended potion if sixth lowest bit is set + ExtCoeff = (a_ItemDamage & 0x40) ? (8.0 / 3.0) : 1; + + // If potion is splash potion, multiply duration by 3/4. If not, stays the same + SplashCoeff = IsPotionDrinkable(a_ItemDamage) ? 1 : 0.75; + + // Ref.: + // http://minecraft.gamepedia.com/Data_values#.22Tier.22_bit + // http://minecraft.gamepedia.com/Data_values#.22Extended_duration.22_bit + // http://minecraft.gamepedia.com/Data_values#.22Splash_potion.22_bit + + return (int)(base * TierCoeff * ExtCoeff * SplashCoeff); +} + + + + + +bool cEntityEffect::IsPotionDrinkable(short a_ItemDamage) +{ + // Drinkable potion if 13th lowest bit is set + // Ref.: http://minecraft.gamepedia.com/Potions#Data_value_table + return ((a_ItemDamage & 0x2000) != 0); +} + + + + + cEntityEffect::cEntityEffect(): m_Ticks(0), m_Duration(0), diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index 396a9bbe0..04e25e303 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -36,6 +36,25 @@ public: effSaturation = 23, } ; + /** Returns the potion color (used by the client for visuals), based on the potion's damage value */ + static int GetPotionColor(short a_ItemDamage); + + + /** Translates the potion's damage value into the entity effect that the potion gives */ + static cEntityEffect::eType GetPotionEffectType(short a_ItemDamage); + + + /** Retrieves the intensity level from the potion's damage value. + Returns 0 for level I potions, 1 for level II potions. */ + static short GetPotionEffectIntensity(short a_ItemDamage); + + + /** Returns the effect duration, in ticks, based on the potion's damage value */ + static int GetPotionEffectDuration(short a_ItemDamage); + + /** Returns true if the potion with the given damage is drinkable */ + static bool IsPotionDrinkable(short a_ItemDamage); + // tolua_end /** Creates an empty entity effect */ diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index b5e81bc0c..43023ec28 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -22,6 +22,7 @@ #include "FireworkEntity.h" #include "GhastFireballEntity.h" #include "WitherSkullEntity.h" +#include "SplashPotionEntity.h" #include "Player.h" @@ -263,6 +264,7 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator, case pkGhastFireball: return new cGhastFireballEntity (a_Creator, a_X, a_Y, a_Z, Speed); case pkFireCharge: return new cFireChargeEntity (a_Creator, a_X, a_Y, a_Z, Speed); case pkExpBottle: return new cExpBottleEntity (a_Creator, a_X, a_Y, a_Z, Speed); + case pkSplashPotion: return new cSplashPotionEntity (a_Creator, a_X, a_Y, a_Z, Speed, *a_Item); case pkWitherSkull: return new cWitherSkullEntity (a_Creator, a_X, a_Y, a_Z, Speed); case pkFirework: { diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 6d874e957..d874a86e1 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -72,17 +72,21 @@ cSplashPotionEntity::cSplashPotionEntity( cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, - cEntityEffect::eType a_EntityEffectType, - cEntityEffect a_EntityEffect, - int a_PotionColor + cItem a_Item ) : super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), - m_EntityEffectType(a_EntityEffectType), - m_EntityEffect(a_EntityEffect), - m_PotionColor(a_PotionColor), + m_EntityEffectType(cEntityEffect::effNoEffect), + m_EntityEffect(cEntityEffect()), + m_PotionColor(0), m_DestroyTimer(-1) { SetSpeed(a_Speed); + m_EntityEffectType = cEntityEffect::GetPotionEffectType(a_Item.m_ItemDamage); + m_EntityEffect = cEntityEffect( + cEntityEffect::GetPotionEffectDuration(a_Item.m_ItemDamage), + cEntityEffect::GetPotionEffectIntensity(a_Item.m_ItemDamage) + ); + m_PotionColor = cEntityEffect::GetPotionColor(a_Item.m_ItemDamage); } diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index dd14ea82f..db1672f9b 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -29,9 +29,7 @@ public: cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, - cEntityEffect::eType a_EntityEffectType, - cEntityEffect a_EntityEffect, - int a_PotionColor + cItem a_Item ); cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; } diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index f16d89b39..cc974c8b9 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -17,126 +17,12 @@ public: } - /** Returns the potion color (used by the client for visuals), based on the potion's damage value */ - static int GetPotionColor(short a_ItemDamage) - { - // Lowest six bits - return (a_ItemDamage & 0x3f); - } - - - /** Translates the potion's damage value into the entity effect that the potion gives */ - static cEntityEffect::eType GetEntityEffectType(short a_ItemDamage) - { - // Lowest four bits - // Potion effect bits are different from entity effect values - // For reference: http://minecraft.gamepedia.com/Data_values#.22Potion_effect.22_bits - switch (a_ItemDamage & 0x0f) - { - case 0x01: return cEntityEffect::effRegeneration; - case 0x02: return cEntityEffect::effSpeed; - case 0x03: return cEntityEffect::effFireResistance; - case 0x04: return cEntityEffect::effPoison; - case 0x05: return cEntityEffect::effInstantHealth; - case 0x06: return cEntityEffect::effNightVision; - case 0x08: return cEntityEffect::effWeakness; - case 0x09: return cEntityEffect::effStrength; - case 0x0a: return cEntityEffect::effSlowness; - case 0x0c: return cEntityEffect::effInstantDamage; - case 0x0d: return cEntityEffect::effWaterBreathing; - case 0x0e: return cEntityEffect::effInvisibility; - - // No effect potions - case 0x00: - case 0x07: - case 0x0b: // Will be potion of leaping in 1.8 - case 0x0f: - { - break; - } - } - return cEntityEffect::effNoEffect; - } - - - /** Retrieves the intensity level from the potion's damage value. - Returns 0 for level I potions, 1 for level II potions. */ - static short GetEntityEffectIntensity(short a_ItemDamage) - { - // Level II potion if the fifth lowest bit is set - return ((a_ItemDamage & 0x20) != 0) ? 1 : 0; - } - - - /** Returns the effect duration, in ticks, based on the potion's damage value */ - static int GetEntityEffectDuration(short a_ItemDamage) - { - // Base duration in ticks - int base = 0; - double TierCoeff = 1, ExtCoeff = 1, SplashCoeff = 1; - - switch (GetEntityEffectType(a_ItemDamage)) - { - case cEntityEffect::effRegeneration: - case cEntityEffect::effPoison: - { - base = 900; - break; - } - - case cEntityEffect::effSpeed: - case cEntityEffect::effFireResistance: - case cEntityEffect::effNightVision: - case cEntityEffect::effStrength: - case cEntityEffect::effWaterBreathing: - case cEntityEffect::effInvisibility: - { - base = 3600; - break; - } - - case cEntityEffect::effWeakness: - case cEntityEffect::effSlowness: - { - base = 1800; - break; - } - } - - // If potion is level II, half the duration. If not, stays the same - TierCoeff = (GetEntityEffectIntensity(a_ItemDamage) > 0) ? 0.5 : 1; - - // If potion is extended, multiply duration by 8/3. If not, stays the same - // Extended potion if sixth lowest bit is set - ExtCoeff = (a_ItemDamage & 0x40) ? (8.0 / 3.0) : 1; - - // If potion is splash potion, multiply duration by 3/4. If not, stays the same - SplashCoeff = IsPotionDrinkable(a_ItemDamage) ? 1 : 0.75; - - // Ref.: - // http://minecraft.gamepedia.com/Data_values#.22Tier.22_bit - // http://minecraft.gamepedia.com/Data_values#.22Extended_duration.22_bit - // http://minecraft.gamepedia.com/Data_values#.22Splash_potion.22_bit - - return (int)(base * TierCoeff * ExtCoeff * SplashCoeff); - } - - - /** Returns true if the potion with the given damage is drinkable */ - static bool IsPotionDrinkable(short a_ItemDamage) - { - // Drinkable potion if 13th lowest bit is set - // Ref.: http://minecraft.gamepedia.com/Potions#Data_value_table - return ((a_ItemDamage & 0x2000) != 0); - } - - // cItemHandler overrides: virtual bool IsDrinkable(short a_ItemDamage) override { // Drinkable potion if 13th lowest bit is set // Ref.: http://minecraft.gamepedia.com/Potions#Data_value_table - return IsPotionDrinkable(a_ItemDamage); + return cEntityEffect::IsPotionDrinkable(a_ItemDamage); } @@ -145,7 +31,7 @@ public: short PotionDamage = a_Item.m_ItemDamage; // Do not throw non-splash potions: - if (IsPotionDrinkable(PotionDamage)) + if (cEntityEffect::IsPotionDrinkable(PotionDamage)) { return false; } @@ -153,18 +39,8 @@ public: Vector3d Pos = a_Player->GetThrowStartPos(); Vector3d Speed = a_Player->GetLookVector() * 7; - cSplashPotionEntity * Projectile = new cSplashPotionEntity( - a_Player, Pos.x, Pos.y, Pos.z, Speed, - GetEntityEffectType(PotionDamage), cEntityEffect(GetEntityEffectDuration(PotionDamage), - GetEntityEffectIntensity(PotionDamage)), GetPotionColor(PotionDamage) - ); - if (Projectile == NULL) - { - return false; - } - if (!Projectile->Initialize(*a_World)) + if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, cProjectileEntity::pkSplashPotion, a_Player, &a_Player->GetEquippedItem(), &Speed) < 0) { - delete Projectile; return false; } @@ -182,12 +58,14 @@ public: short PotionDamage = a_Item->m_ItemDamage; // Do not drink undrinkable potions: - if (!IsDrinkable(a_Item->m_ItemDamage)) + if (!cEntityEffect::IsPotionDrinkable(a_Item->m_ItemDamage)) { return false; } - a_Player->AddEntityEffect(GetEntityEffectType(PotionDamage), GetEntityEffectDuration(PotionDamage), GetEntityEffectIntensity(PotionDamage)); + a_Player->AddEntityEffect(cEntityEffect::GetPotionEffectType(PotionDamage), + cEntityEffect::GetPotionEffectDuration(PotionDamage), + cEntityEffect::GetPotionEffectIntensity(PotionDamage)); a_Player->GetInventory().RemoveOneEquippedItem(); a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE); return true; diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 2851647fe..023813769 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1670,7 +1670,7 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { - std::auto_ptr SplashPotion(new cSplashPotionEntity(NULL, 0, 0, 0, Vector3d(0, 0, 0), cEntityEffect::effNoEffect, cEntityEffect(), 0)); + std::auto_ptr SplashPotion(new cSplashPotionEntity(NULL, 0, 0, 0, Vector3d(0, 0, 0), cItem())); if (!LoadProjectileBaseFromNBT(*SplashPotion.get(), a_NBT, a_TagIdx)) { return; -- cgit v1.2.3 From 60d4a165140b3b1c5202c21fd197b61cae18077c Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 13:11:06 -0700 Subject: Fixed indentations, removed redundant init code in SplashPotionEntity.cpp --- src/Entities/EntityEffect.cpp | 2 +- src/Entities/EntityEffect.h | 3 +-- src/Entities/SplashPotionEntity.cpp | 3 --- src/Items/ItemPotion.h | 8 +++++--- 4 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp index f58738aef..fdcbe822e 100644 --- a/src/Entities/EntityEffect.cpp +++ b/src/Entities/EntityEffect.cpp @@ -38,7 +38,7 @@ cEntityEffect::eType cEntityEffect::GetPotionEffectType(short a_ItemDamage) case 0x0d: return cEntityEffect::effWaterBreathing; case 0x0e: return cEntityEffect::effInvisibility; - // No effect potions + // No effect potions case 0x00: case 0x07: case 0x0b: // Will be potion of leaping in 1.8 diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index 04e25e303..f9c1e4eb2 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -44,8 +44,7 @@ public: static cEntityEffect::eType GetPotionEffectType(short a_ItemDamage); - /** Retrieves the intensity level from the potion's damage value. - Returns 0 for level I potions, 1 for level II potions. */ + /** Retrieves the intensity level from the potion's damage value. Returns 0 for level I potions, 1 for level II potions. */ static short GetPotionEffectIntensity(short a_ItemDamage); diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index d874a86e1..ed16f060d 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -75,9 +75,6 @@ cSplashPotionEntity::cSplashPotionEntity( cItem a_Item ) : super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), - m_EntityEffectType(cEntityEffect::effNoEffect), - m_EntityEffect(cEntityEffect()), - m_PotionColor(0), m_DestroyTimer(-1) { SetSpeed(a_Speed); diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index cc974c8b9..24614cd8a 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -63,9 +63,11 @@ public: return false; } - a_Player->AddEntityEffect(cEntityEffect::GetPotionEffectType(PotionDamage), - cEntityEffect::GetPotionEffectDuration(PotionDamage), - cEntityEffect::GetPotionEffectIntensity(PotionDamage)); + a_Player->AddEntityEffect( + cEntityEffect::GetPotionEffectType(PotionDamage), + cEntityEffect::GetPotionEffectDuration(PotionDamage), + cEntityEffect::GetPotionEffectIntensity(PotionDamage) + ); a_Player->GetInventory().RemoveOneEquippedItem(); a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE); return true; -- cgit v1.2.3 From 16e0beb5b6f6c4c103acfccc1940585513b5c258 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Jul 2014 03:55:40 -0700 Subject: SplashPotionEntity: Use `const cItem &` instead of a cItem --- src/Entities/SplashPotionEntity.cpp | 2 +- src/Entities/SplashPotionEntity.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index ed16f060d..fd1a0179b 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -72,7 +72,7 @@ cSplashPotionEntity::cSplashPotionEntity( cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, - cItem a_Item + const cItem & a_Item ) : super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), m_DestroyTimer(-1) diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index db1672f9b..4afc5f204 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -29,7 +29,7 @@ public: cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, - cItem a_Item + const cItem & a_Item ); cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; } -- cgit v1.2.3 From 4de8f5ca2926068eb855ba19c35de2a63ddebf28 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 26 Jul 2014 13:26:14 +0200 Subject: Rename function. --- src/Items/ItemHandler.cpp | 6 +++--- src/Items/ItemHandler.h | 2 +- src/Items/ItemShears.h | 2 +- src/Items/ItemSword.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index e256fa232..ec86648b3 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -335,7 +335,7 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const if (!cBlockInfo::IsOneHitDig(Block)) { - a_Player->UseEquippedItem(GetDurabilityLostWithThatAction(dlaBreakBlock)); + a_Player->UseEquippedItem(GetDurabilityLossByAction(dlaBreakBlock)); } } @@ -346,7 +346,7 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const void cItemHandler::OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity) { UNUSED(a_AttackedEntity); - a_Attacker->UseEquippedItem(GetDurabilityLostWithThatAction(dlaAttackEntity)); + a_Attacker->UseEquippedItem(GetDurabilityLossByAction(dlaAttackEntity)); } @@ -364,7 +364,7 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I -short cItemHandler::GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action) +short cItemHandler::GetDurabilityLossByAction(eDurabilityLostAction a_Action) { switch (a_Action) { diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index 28b1dd13b..1d5f59f3e 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -64,7 +64,7 @@ public: virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item); /** Get the durability lost which the item will get, when a specified action was performed. */ - virtual short GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action); + virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action); /** Returns the maximum stack size for a given item */ virtual char GetMaxStackSize(void); diff --git a/src/Items/ItemShears.h b/src/Items/ItemShears.h index 8f5d5f385..fa2794df2 100644 --- a/src/Items/ItemShears.h +++ b/src/Items/ItemShears.h @@ -63,7 +63,7 @@ public: } - virtual short GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action) override + virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override { return 0; } diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h index 1a17023ef..b90965535 100644 --- a/src/Items/ItemSword.h +++ b/src/Items/ItemSword.h @@ -44,7 +44,7 @@ public: } - virtual short GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action) override + virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override { switch (a_Action) { -- cgit v1.2.3 From 6e2025d12544e33c379f0d03ab875faad08c7330 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 26 Jul 2014 13:29:25 +0200 Subject: Change comment. --- src/UI/SlotArea.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index e9b1ef8e0..b5f84c24c 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1866,7 +1866,7 @@ void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C { ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots())); - // Creative inventory must treat a_ClickedItem as a DraggedItem instead, replacing the inventory slot with it + // When the player is in creative mode, the client sends the new item as a_ClickedItem, not the current item in the slot. if (a_Player.IsGameModeCreative() && (m_ParentWindow.GetWindowType() == cWindow::wtInventory)) { if ((a_ClickAction == caDropKey) || (a_ClickAction == caCtrlDropKey)) -- cgit v1.2.3 From c2a2aea9f8808b9742fedbfc8c8864cb9082afd5 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 26 Jul 2014 17:09:59 +0200 Subject: Derp. --- src/Items/ItemHoe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Items/ItemHoe.h b/src/Items/ItemHoe.h index 6523b36d9..8d0b71478 100644 --- a/src/Items/ItemHoe.h +++ b/src/Items/ItemHoe.h @@ -33,7 +33,7 @@ public: } - virtual short GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action) override + virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override { return 0; } -- cgit v1.2.3 From 77f4297c6ee4daca51220f60b626658a22a22ea2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Jul 2014 00:03:26 +0200 Subject: RoughRavines: Initial generator implementation. This provides the basic shape of the ravines, with the basic settings based on GridStructGen, and good default values. --- src/Generating/CMakeLists.txt | 2 + src/Generating/ComposableGenerator.cpp | 14 ++- src/Generating/RoughRavines.cpp | 214 +++++++++++++++++++++++++++++++++ src/Generating/RoughRavines.h | 37 ++++++ 4 files changed, 264 insertions(+), 3 deletions(-) create mode 100644 src/Generating/RoughRavines.cpp create mode 100644 src/Generating/RoughRavines.h (limited to 'src') diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt index 9063abd97..58df9d421 100644 --- a/src/Generating/CMakeLists.txt +++ b/src/Generating/CMakeLists.txt @@ -25,6 +25,7 @@ SET (SRCS PrefabPiecePool.cpp RainbowRoadsGen.cpp Ravines.cpp + RoughRavines.cpp StructGen.cpp TestRailsGen.cpp Trees.cpp @@ -52,6 +53,7 @@ SET (HDRS PrefabPiecePool.h RainbowRoadsGen.h Ravines.h + RoughRavines.h StructGen.h TestRailsGen.h Trees.h diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index ab6accee7..757f6ddb7 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -26,6 +26,7 @@ #include "POCPieceGenerator.h" #include "RainbowRoadsGen.h" #include "Ravines.h" +#include "RoughRavines.h" #include "TestRailsGen.h" #include "UnderwaterBaseGen.h" #include "VillageGen.h" @@ -397,16 +398,23 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "RainbowRoads") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsGridSize", 512); + int GridSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsGridSize", 512); int MaxOffset = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxOffset", 128); - int MaxDepth = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxDepth", 30); - int MaxSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxSize", 260); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxDepth", 30); + int MaxSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxSize", 260); m_FinishGens.push_back(new cRainbowRoadsGen(Seed, GridSize, MaxOffset, MaxDepth, MaxSize)); } else if (NoCaseCompare(*itr, "Ravines") == 0) { m_FinishGens.push_back(new cStructGenRavines(Seed, 128)); } + else if (NoCaseCompare(*itr, "RoughRavines") == 0) + { + int GridSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesGridSize", 256); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxOffset", 128); + int MaxSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxSize", 64); + m_FinishGens.push_back(new cRoughRavines(Seed, MaxSize, GridSize, MaxOffset)); + } else if (NoCaseCompare(*itr, "Snow") == 0) { m_FinishGens.push_back(new cFinishGenSnow); diff --git a/src/Generating/RoughRavines.cpp b/src/Generating/RoughRavines.cpp new file mode 100644 index 000000000..1b1351a19 --- /dev/null +++ b/src/Generating/RoughRavines.cpp @@ -0,0 +1,214 @@ + +// RoughRavines.cpp + +// Implements the cRoughRavines class representing the rough ravine generator + +#include "Globals.h" + +#include "RoughRavines.h" + + + + + +//////////////////////////////////////////////////////////////////////////////// +// cRoughRavine: + +class cRoughRavine : + public cGridStructGen::cStructure +{ + typedef cGridStructGen::cStructure super; + +public: + cRoughRavine(int a_Seed, int a_MaxSize, int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) : + super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), + m_Noise(a_Seed + 100), + m_MaxSize(a_MaxSize) + { + // Create the basic structure - 2 lines meeting at the centerpoint: + m_DefPoints.resize(a_MaxSize + 1); + int Half = a_MaxSize / 2; // m_DefPoints[Half] will be the centerpoint + int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 7; + float Len = (float)(3 * a_MaxSize / 4 + rnd % (a_MaxSize / 4)); // Random number between 3 / 4 * a_MaxSize and a_MaxSize + rnd = rnd / a_MaxSize; + float Angle = (float)rnd; // Angle is in radians, will be wrapped in the "sin" and "cos" operations + float OfsX = sin(Angle) * Len; + float OfsZ = cos(Angle) * Len; + m_DefPoints[0].Set (a_OriginX - OfsX, a_OriginZ - OfsZ, 1, 42, 34); + m_DefPoints[Half].Set ((float)a_OriginX, (float)a_OriginZ, Len / 10, 62, 16); + m_DefPoints[a_MaxSize].Set(a_OriginX + OfsX, a_OriginZ + OfsZ, 1, 44, 32); + + // Calculate the points in between, recursively: + SubdivideLine(0, Half); + SubdivideLine(Half, a_MaxSize); + } + +protected: + struct sRavineDefPoint + { + float m_X; + float m_Z; + float m_Radius; + float m_Top; + float m_Bottom; + + void Set(float a_X, float a_Z, float a_Radius, float a_Top, float a_Bottom) + { + m_X = a_X; + m_Z = a_Z; + m_Radius = a_Radius; + m_Top = a_Top; + m_Bottom = a_Bottom; + } + }; + typedef std::vector sRavineDefPoints; + + cNoise m_Noise; + + int m_MaxSize; + + sRavineDefPoints m_DefPoints; + + + /** Recursively subdivides the line between the points of the specified index. + Sets the midpoint to the center of the line plus or minus a random offset, then calls itself for each half + of the new line. */ + void SubdivideLine(int a_Idx1, int a_Idx2) + { + // Calculate the midpoint: + const sRavineDefPoint & p1 = m_DefPoints[a_Idx1]; + const sRavineDefPoint & p2 = m_DefPoints[a_Idx2]; + float MidX = (p1.m_X + p2.m_X) / 2; + float MidZ = (p1.m_Z + p2.m_Z) / 2; + float MidR = (p1.m_Radius + p2.m_Radius) / 2 + 0.1f; + float MidT = (p1.m_Top + p2.m_Top) / 2; + float MidB = (p1.m_Bottom + p2.m_Bottom) / 2; + + // Adjust the midpoint by a small amount of perpendicular vector in a random one of its two directions: + float dx = p2.m_X - p1.m_X; + float dz = p2.m_Z - p1.m_Z; + if ((m_Noise.IntNoise2DInt((int)MidX, (int)MidZ) / 11) % 2 == 0) + { + MidX += dz / 10; + MidZ -= dx / 10; + } + else + { + MidX -= dz / 10; + MidZ += dx / 10; + } + int MidIdx = (a_Idx1 + a_Idx2) / 2; + m_DefPoints[MidIdx].Set(MidX, MidZ, MidR, MidT, MidB); + + // Recurse the two halves, if they are worth recursing: + if (MidIdx - a_Idx1 > 1) + { + SubdivideLine(a_Idx1, MidIdx); + } + if (a_Idx2 - MidIdx > 1) + { + SubdivideLine(MidIdx, a_Idx2); + } + } + + + virtual void DrawIntoChunk(cChunkDesc & a_ChunkDesc) override + { + int BlockStartX = a_ChunkDesc.GetChunkX() * cChunkDef::Width; + int BlockStartZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width; + int BlockEndX = BlockStartX + cChunkDef::Width; + int BlockEndZ = BlockStartZ + cChunkDef::Width; + for (sRavineDefPoints::const_iterator itr = m_DefPoints.begin(), end = m_DefPoints.end(); itr != end; ++itr) + { + if ( + (ceilf (itr->m_X + itr->m_Radius) < BlockStartX) || + (floorf(itr->m_X - itr->m_Radius) > BlockEndX) || + (ceilf (itr->m_Z + itr->m_Radius) < BlockStartZ) || + (floorf(itr->m_Z - itr->m_Radius) > BlockEndZ) + ) + { + // Cannot intersect, bail out early + continue; + } + + // Carve out a cylinder around the xz point, m_Radius in diameter, from Bottom to Top: + float RadiusSq = itr->m_Radius * itr->m_Radius; // instead of doing sqrt for each distance, we do sqr of the radius + float DifX = BlockStartX - itr->m_X; // substitution for faster calc + float DifZ = BlockStartZ - itr->m_Z; // substitution for faster calc + for (int x = 0; x < cChunkDef::Width; x++) for (int z = 0; z < cChunkDef::Width; z++) + { + #ifdef _DEBUG + // DEBUG: Make the roughravine shapepoints visible on a single layer (so that we can see with Minutor what's going on) + if ((DifX + x == 0) && (DifZ + z == 0)) + { + a_ChunkDesc.SetBlockType(x, 4, z, E_BLOCK_LAPIS_ORE); + } + #endif // _DEBUG + + float DistSq = (DifX + x) * (DifX + x) + (DifZ + z) * (DifZ + z); + if (DistSq <= RadiusSq) + { + int Top = std::min((int)ceilf(itr->m_Top), +cChunkDef::Height); + for (int y = std::max((int)floorf(itr->m_Bottom), 1); y <= Top; y++) + { + switch (a_ChunkDesc.GetBlockType(x, y, z)) + { + // Only carve out these specific block types + case E_BLOCK_DIRT: + case E_BLOCK_GRASS: + case E_BLOCK_STONE: + case E_BLOCK_COBBLESTONE: + case E_BLOCK_GRAVEL: + case E_BLOCK_SAND: + case E_BLOCK_SANDSTONE: + case E_BLOCK_NETHERRACK: + case E_BLOCK_COAL_ORE: + case E_BLOCK_IRON_ORE: + case E_BLOCK_GOLD_ORE: + case E_BLOCK_DIAMOND_ORE: + case E_BLOCK_REDSTONE_ORE: + case E_BLOCK_REDSTONE_ORE_GLOWING: + { + a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR); + break; + } + default: break; + } + } + } + } // for x, z - a_BlockTypes + } // for itr - m_Points[] + } +}; + + + + + +//////////////////////////////////////////////////////////////////////////////// +// cRoughRavines: + +cRoughRavines::cRoughRavines(int a_Seed, int a_MaxSize, int a_GridSize, int a_MaxOffset) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 64), + m_Seed(a_Seed), + m_MaxSize(a_MaxSize) +{ + if (m_MaxSize < 1) + { + m_MaxSize = 16; + LOGWARNING("RoughRavines: MaxSize too small, adjusting request from %d to %d", a_MaxSize, m_MaxSize); + } +} + + + + + +cGridStructGen::cStructurePtr cRoughRavines::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) +{ + return cStructurePtr(new cRoughRavine(m_Seed, m_MaxSize, a_GridX, a_GridZ, a_OriginX, a_OriginZ)); +} + + + + diff --git a/src/Generating/RoughRavines.h b/src/Generating/RoughRavines.h new file mode 100644 index 000000000..68c628d84 --- /dev/null +++ b/src/Generating/RoughRavines.h @@ -0,0 +1,37 @@ + +// RoughRavines.h + +// Declares the cRoughRavines class representing the rough ravine generator + + + + +#pragma once + +#include "GridStructGen.h" + + + + + +class cRoughRavines : + public cGridStructGen +{ + typedef cGridStructGen super; + +public: + cRoughRavines(int a_Seed, int a_MaxSize, int a_GridSize, int a_MaxOffset); + +protected: + int m_Seed; + + /** Maximum size of the ravine, in each of the X / Z axis */ + int m_MaxSize; + + // cGridStructGen overrides: + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; +}; + + + + -- cgit v1.2.3 From ce54936f01a832e8bcbd6320d95b4208bad3487f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Jul 2014 00:08:25 +0200 Subject: Updated NetherFort prefabs to latest Gallery content. --- src/Generating/Prefabs/NetherFortPrefabs.cpp | 789 +++++++++++++++++++++++++-- 1 file changed, 752 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/NetherFortPrefabs.cpp b/src/Generating/Prefabs/NetherFortPrefabs.cpp index ee3a8899b..fb0e93daa 100644 --- a/src/Generating/Prefabs/NetherFortPrefabs.cpp +++ b/src/Generating/Prefabs/NetherFortPrefabs.cpp @@ -1410,6 +1410,383 @@ const cPrefab::sDef g_NetherFortPrefabs[] = + //////////////////////////////////////////////////////////////////////////////// + // BridgeDoubleStairs: + // The data has been exported from the gallery Nether, area index 115, ID 810, created by STR_Warrior + { + // Size: + 15, 16, 16, // SizeX = 15, SizeY = 16, SizeZ = 16 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 14, 15, 15, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:112: 0\n" /* netherbrick */ + "b:114: 7\n" /* netherbrickstairs */ + "c:114: 6\n" /* netherbrickstairs */ + "d:114: 4\n" /* netherbrickstairs */ + "e:114: 5\n" /* netherbrickstairs */ + "f:114: 2\n" /* netherbrickstairs */ + "g:114: 3\n" /* netherbrickstairs */ + "h:114: 1\n" /* netherbrickstairs */ + "i: 44:14\n" /* step */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmaaam" + /* 1 */ "aammmmmmmmmaaaa" + /* 2 */ "aammmmmmmmmmmma" + /* 3 */ "aammmmmmmmmmmma" + /* 4 */ "mmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmm" + /* 12 */ "aammmmmmmmmmmma" + /* 13 */ "aammmmmmmmmmmma" + /* 14 */ "aammmmmmmmmaaaa" + /* 15 */ "mmmmmmmmmmmaaam" + + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmaaam" + /* 1 */ "aammmmmmmmmaaaa" + /* 2 */ "aammmmmmmmmmmma" + /* 3 */ "aammmmmmmmmmmma" + /* 4 */ "mmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmm" + /* 12 */ "aammmmmmmmmmmma" + /* 13 */ "aammmmmmmmmmmma" + /* 14 */ "aammmmmmmmmaaaa" + /* 15 */ "mmmmmmmmmmmaaam" + + // Level 2 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmaaam" + /* 1 */ "aammmmmmmmmaaaa" + /* 2 */ "aammmmmmmmmmmma" + /* 3 */ "aammmmmmmmmmmma" + /* 4 */ "mmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmm" + /* 12 */ "aammmmmmmmmmmma" + /* 13 */ "aammmmmmmmmmmma" + /* 14 */ "aammmmmmmmmaaaa" + /* 15 */ "mmmmmmmmmmmaaam" + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmaaam" + /* 1 */ "aammmmmmmmmaaaa" + /* 2 */ "aammmmmmmmmbbba" + /* 3 */ "aammmmmmmmmmmma" + /* 4 */ "mmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmm" + /* 12 */ "aammmmmmmmmmmma" + /* 13 */ "aammmmmmmmmccca" + /* 14 */ "aammmmmmmmmaaaa" + /* 15 */ "mmmmmmmmmmmaaam" + + // Level 4 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmaaam" + /* 1 */ "aammmmmmmmmaaaa" + /* 2 */ "aammmmmmmmmaaaa" + /* 3 */ "aammmmmmmmmbbba" + /* 4 */ "mmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmm" + /* 12 */ "aammmmmmmmmccca" + /* 13 */ "aammmmmmmmmaaaa" + /* 14 */ "aammmmmmmmmaaaa" + /* 15 */ "mmmmmmmmmmmaaam" + + // Level 5 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmdaaae" + /* 1 */ "aammmmmmmmdaaaa" + /* 2 */ "aammmmmmmmdaaaa" + /* 3 */ "aammmmmmmmdaaaa" + /* 4 */ "mmmmmmmmmmdaaae" + /* 5 */ "mmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmdaaae" + /* 12 */ "aammmmmmmmdaaaa" + /* 13 */ "aammmmmmmmdaaaa" + /* 14 */ "aammmmmmmmdaaaa" + /* 15 */ "mmmmmmmmmmdaaae" + + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmaaaaa" + /* 1 */ "aammmmmmmmaaaaa" + /* 2 */ "aammmmmmmmaaaaa" + /* 3 */ "aammmmmmmmaaaaa" + /* 4 */ "mmmmmmmmmmaaaaa" + /* 5 */ "mmmmmmmmmmdaaae" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmdaaae" + /* 11 */ "mmmmmmmmmmaaaaa" + /* 12 */ "aammmmmmmmaaaaa" + /* 13 */ "aammmmmmmmaaaaa" + /* 14 */ "aammmmmmmmaaaaa" + /* 15 */ "mmmmmmmmmmaaaaa" + + // Level 7 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmma...a" + /* 1 */ "aammmmmmmma...a" + /* 2 */ "aammmmmmmma...a" + /* 3 */ "aammmmmmmma...a" + /* 4 */ "mmmmmmmmmmafffa" + /* 5 */ "mmmmmmmmmaaaaaa" + /* 6 */ "mmmmmmmmmaaaaae" + /* 7 */ "mmmmmmmmmaaaaae" + /* 8 */ "mmmmmmmmmaaaaae" + /* 9 */ "mmmmmmmmmaaaaae" + /* 10 */ "mmmmmmmmmaaaaaa" + /* 11 */ "mmmmmmmmmmaggga" + /* 12 */ "aammmmmmmma...a" + /* 13 */ "aammmmmmmma...a" + /* 14 */ "aammmmmmmma...a" + /* 15 */ "mmmmmmmmmma...a" + + // Level 8 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmm...m" + /* 1 */ "aammmmmmmma...a" + /* 2 */ "aammmmmmmma...a" + /* 3 */ "aammmmmmmma...a" + /* 4 */ "mmmmmmmmmma...a" + /* 5 */ "mmmmmmmmmaafffa" + /* 6 */ "mmmmmmmmaaaaaaa" + /* 7 */ "mmmmmmmmaaaaaaa" + /* 8 */ "mmmmmmmmaaaaaaa" + /* 9 */ "mmmmmmmmaaaaaaa" + /* 10 */ "mmmmmmmmmaaggga" + /* 11 */ "mmmmmmmmmma...a" + /* 12 */ "aammmmmmmma...a" + /* 13 */ "aammmmmmmma...a" + /* 14 */ "aammmmmmmma...a" + /* 15 */ "mmmmmmmmmmm...m" + + // Level 9 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmm...m" + /* 1 */ "aaemmmmmmma...a" + /* 2 */ "aaemmmmmmma...a" + /* 3 */ "aaemmmmmmma...a" + /* 4 */ "mmmmmmmmmma...a" + /* 5 */ "mmmmmmmmmaa...a" + /* 6 */ "mmmmaaaaah....a" + /* 7 */ "mmmmaaaaah....a" + /* 8 */ "mmmmaaaaah....a" + /* 9 */ "mmmmaaaaah....a" + /* 10 */ "mmmmmmmmmaa...a" + /* 11 */ "mmmmmmmmmma...a" + /* 12 */ "aaemmmmmmma...a" + /* 13 */ "aaemmmmmmma...a" + /* 14 */ "aaemmmmmmma...a" + /* 15 */ "mmmmmmmmmmm...m" + + // Level 10 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "aaaeimmmmmammma" + /* 2 */ "aaaeimmmmmammma" + /* 3 */ "aaaeimmmmma...a" + /* 4 */ "mmmmmmmmmmm...m" + /* 5 */ "mmmmaaaaaam...m" + /* 6 */ "mmmmaaaah.....m" + /* 7 */ "mmmmaaaah.....m" + /* 8 */ "mmmmaaaah.....m" + /* 9 */ "mmmmaaaah.....m" + /* 10 */ "mmmmaaaaaam...m" + /* 11 */ "mmmmmmmmmmm...m" + /* 12 */ "aaaeimmmmma...a" + /* 13 */ "aaaeimmmmmammma" + /* 14 */ "aaaeimmmmmammma" + /* 15 */ "mmmmmmmmmmmmmmm" + + // Level 11 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "ccccccccccccccc" + /* 1 */ "aaaaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaaaa" + /* 4 */ "bbbbaaaaabbbbbb" + /* 5 */ "mmmmagggamm...m" + /* 6 */ "mmmma.........m" + /* 7 */ "mmmma.........m" + /* 8 */ "mmmma.........m" + /* 9 */ "mmmma.........m" + /* 10 */ "mmmmafffamm...m" + /* 11 */ "ccccaaaahcccccc" + /* 12 */ "aaaaaaaaaaaaaaa" + /* 13 */ "aaaaaaaaaaaaaaa" + /* 14 */ "aaaaaaaaaaaaaaa" + /* 15 */ "bbbbbbbbbbbbbbb" + + // Level 12 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "aaaaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaaaa" + /* 4 */ "aaaaagggaaaaaaa" + /* 5 */ "mmmma...ammmmmm" + /* 6 */ "mmmma.........m" + /* 7 */ "mmmmm.........m" + /* 8 */ "mmmmm.........m" + /* 9 */ "mmmma.........m" + /* 10 */ "mmmma...ammmmmm" + /* 11 */ "aaaaafffaaaaaaa" + /* 12 */ "aaaaaaaaaaaaaaa" + /* 13 */ "aaaaaaaaaaaaaaa" + /* 14 */ "aaaaaaaaaaaaaaa" + /* 15 */ "aaaaaaaaaaaaaaa" + + // Level 13 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "aaaaaaaaaaaaaaa" + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "aaaaa...aaaaaaa" + /* 5 */ "mmmma...ammmmmm" + /* 6 */ "mmmmm.....mmmmm" + /* 7 */ "mmmmm.....mmmmm" + /* 8 */ "mmmmm.....mmmmm" + /* 9 */ "mmmmm.....mmmmm" + /* 10 */ "mmmma...ammmmmm" + /* 11 */ "aaaaa...aaaaaaa" + /* 12 */ "..............." + /* 13 */ "..............." + /* 14 */ "..............." + /* 15 */ "aaaaaaaaaaaaaaa" + + // Level 14 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "mmmmm...mmmmmmm" + /* 5 */ "mmmmm...mmmmmmm" + /* 6 */ "mmmmm...mmmmmmm" + /* 7 */ "mmmmm...mmmmmmm" + /* 8 */ "mmmmm...mmmmmmm" + /* 9 */ "mmmmm...mmmmmmm" + /* 10 */ "mmmmm...mmmmmmm" + /* 11 */ "mmmmm...mmmmmmm" + /* 12 */ "..............." + /* 13 */ "..............." + /* 14 */ "..............." + /* 15 */ "mmmmmmmmmmmmmmm" + + // Level 15 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "mmmmm...mmmmmmm" + /* 5 */ "mmmmm...mmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmm" + /* 10 */ "mmmmm...mmmmmmm" + /* 11 */ "mmmmm...mmmmmmm" + /* 12 */ "..............." + /* 13 */ "..............." + /* 14 */ "..............." + /* 15 */ "mmmmmmmmmmmmmmm", + + // Connectors: + "0: 0, 13, 13: 4\n" /* Type 0, direction X- */ + "0: 14, 13, 13: 5\n" /* Type 0, direction X+ */ + "0: 0, 13, 2: 4\n" /* Type 0, direction X- */ + "0: 14, 13, 2: 5\n" /* Type 0, direction X+ */ + "0: 12, 7, 15: 3\n" /* Type 0, direction Z+ */ + "0: 12, 7, 0: 2\n" /* Type 0, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // BridgeDoubleStairs + + + //////////////////////////////////////////////////////////////////////////////// // BridgeFunnelDown: // The data has been exported from the gallery Nether, area index 0, ID 2, created by Aloe_vera @@ -2606,12 +2983,12 @@ const cPrefab::sDef g_NetherFortPrefabs[] = /* 2 */ "aaaaaaaaaaa" /* 3 */ "aaaaaaaaaaa" /* 4 */ "aaaaaaaaaaa" - /* 5 */ "aaaaa......" - /* 6 */ "aaaaa......" - /* 7 */ "aaaaa......" - /* 8 */ "aaaaa......" - /* 9 */ "aaaaa......" - /* 10 */ "aaaaa......" + /* 5 */ "aaaaammmmmm" + /* 6 */ "aaaaammmmmm" + /* 7 */ "aaaaammmmmm" + /* 8 */ "aaaaammmmmm" + /* 9 */ "aaaaammmmmm" + /* 10 */ "aaaaammmmmm" // Level 1 /* z\x* 1 */ @@ -2621,12 +2998,12 @@ const cPrefab::sDef g_NetherFortPrefabs[] = /* 2 */ "a.........." /* 3 */ "a.........." /* 4 */ "a...aaaaaaa" - /* 5 */ "a...a......" - /* 6 */ "a...a......" - /* 7 */ "a...a......" - /* 8 */ "a...a......" - /* 9 */ "a...a......" - /* 10 */ "a...a......" + /* 5 */ "a...ammmmmm" + /* 6 */ "a...ammmmmm" + /* 7 */ "a...ammmmmm" + /* 8 */ "a...ammmmmm" + /* 9 */ "a...ammmmmm" + /* 10 */ "a...ammmmmm" // Level 2 /* z\x* 1 */ @@ -2636,12 +3013,12 @@ const cPrefab::sDef g_NetherFortPrefabs[] = /* 2 */ "a.........." /* 3 */ "b.........." /* 4 */ "a...abababa" - /* 5 */ "b...b......" - /* 6 */ "a...a......" - /* 7 */ "b...b......" - /* 8 */ "a...a......" - /* 9 */ "b...b......" - /* 10 */ "a...a......" + /* 5 */ "b...bmmmmmm" + /* 6 */ "a...ammmmmm" + /* 7 */ "b...bmmmmmm" + /* 8 */ "a...ammmmmm" + /* 9 */ "b...bmmmmmm" + /* 10 */ "a...ammmmmm" // Level 3 /* z\x* 1 */ @@ -2651,12 +3028,12 @@ const cPrefab::sDef g_NetherFortPrefabs[] = /* 2 */ "a.........." /* 3 */ "b.........." /* 4 */ "a...abababa" - /* 5 */ "b...b......" - /* 6 */ "a...a......" - /* 7 */ "b...b......" - /* 8 */ "a...a......" - /* 9 */ "b...b......" - /* 10 */ "a...a......" + /* 5 */ "b...bmmmmmm" + /* 6 */ "a...ammmmmm" + /* 7 */ "b...bmmmmmm" + /* 8 */ "a...ammmmmm" + /* 9 */ "b...bmmmmmm" + /* 10 */ "a...ammmmmm" // Level 4 /* z\x* 1 */ @@ -2666,12 +3043,12 @@ const cPrefab::sDef g_NetherFortPrefabs[] = /* 2 */ "a.........." /* 3 */ "b.........." /* 4 */ "a...abababa" - /* 5 */ "b...b......" - /* 6 */ "a...a......" - /* 7 */ "b...b......" - /* 8 */ "a...a......" - /* 9 */ "b...b......" - /* 10 */ "a...a......" + /* 5 */ "b...bmmmmmm" + /* 6 */ "a...ammmmmm" + /* 7 */ "b...bmmmmmm" + /* 8 */ "a...ammmmmm" + /* 9 */ "b...bmmmmmm" + /* 10 */ "a...ammmmmm" // Level 5 /* z\x* 1 */ @@ -2681,12 +3058,12 @@ const cPrefab::sDef g_NetherFortPrefabs[] = /* 2 */ "daaaaaaaaaa" /* 3 */ "daaaaaaaaaa" /* 4 */ "daaaeeeeeee" - /* 5 */ "daaaf......" - /* 6 */ "daaaf......" - /* 7 */ "daaaf......" - /* 8 */ "daaaf......" - /* 9 */ "daaaf......" - /* 10 */ "daaaf......", + /* 5 */ "daaafmmmmmm" + /* 6 */ "daaafmmmmmm" + /* 7 */ "daaafmmmmmm" + /* 8 */ "daaafmmmmmm" + /* 9 */ "daaafmmmmmm" + /* 10 */ "daaafmmmmmm", // Connectors: "1: 2, 1, 10: 3\n" /* Type 1, direction Z+ */ @@ -4097,7 +4474,12 @@ const cPrefab::sDef g_NetherFortPrefabs[] = /* 14 */ "abbaabbaabbaabba", // Connectors: - "", + "1: 0, 6, 7: 4\n" /* Type 1, direction X- */ + "-1: 0, 6, 7: 4\n" /* Type -1, direction X- */ + "1: 9, 1, 0: 2\n" /* Type 1, direction Z- */ + "-1: 9, 1, 0: 2\n" /* Type -1, direction Z- */ + "1: 9, 1, 14: 3\n" /* Type 1, direction Z+ */ + "-1: 9, 1, 14: 3\n" /* Type -1, direction Z+ */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotation allowed */ @@ -4314,6 +4696,339 @@ const cPrefab::sDef g_NetherFortPrefabs[] = + //////////////////////////////////////////////////////////////////////////////// + // SlabbedBridgeStairs: + // The data has been exported from the gallery Nether, area index 116, ID 811, created by Aloe_vera + { + // Size: + 16, 14, 16, // SizeX = 16, SizeY = 14, SizeZ = 16 + + // Hitbox (relative to bounding box): + 0, 0, 0, // MinX, MinY, MinZ + 15, 13, 15, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:112: 0\n" /* netherbrick */ + "b:114: 5\n" /* netherbrickstairs */ + "c:114: 4\n" /* netherbrickstairs */ + "d: 44:14\n" /* step */ + "e:114: 6\n" /* netherbrickstairs */ + "f:114: 7\n" /* netherbrickstairs */ + "g: 44: 6\n" /* step */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "aammmmmmmmmmmmaa" + /* 2 */ "aammmmmmmmmmmmaa" + /* 3 */ "aammmmmmmmmmmmaa" + /* 4 */ "mmmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmmm" + /* 12 */ "maaammmmmmmmmmmm" + /* 13 */ "maaammmmmmmmmmmm" + /* 14 */ "maaammmmmmmmaaam" + /* 15 */ "mmmmmmmmmmmmaaam" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "aabmmmmmmmmmmcaa" + /* 2 */ "aabmmmmmmmmmmcaa" + /* 3 */ "aabmmmmmmmmmmcaa" + /* 4 */ "mmmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmmm" + /* 12 */ "maaammmmmmmmmmmm" + /* 13 */ "maaammmmmmmmmmmm" + /* 14 */ "maaammmmmmmmaaam" + /* 15 */ "mmmmmmmmmmmmaaam" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmmmmm" + /* 1 */ "aaabdmmmmmmdcaaa" + /* 2 */ "aaabdmmmmmmdcaaa" + /* 3 */ "aaabdmmmmmmdcaaa" + /* 4 */ "mmmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmmm" + /* 12 */ "maaammmmmmmmmmmm" + /* 13 */ "maaammmmmmmmmmmm" + /* 14 */ "maaammmmmmmmaaam" + /* 15 */ "mmmmmmmmmmmmaaam" + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "eeeeeeeeeeeeeeee" + /* 1 */ "aaaaaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaaaaa" + /* 4 */ "ffffffffffffffff" + /* 5 */ "mmmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmmm" + /* 12 */ "maaammmmmmmmmmmm" + /* 13 */ "maaammmmmmmmmmmm" + /* 14 */ "maaammmmmmmmaaam" + /* 15 */ "mmmmmmmmmmmmaaam" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aaaaaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaaaaa" + /* 4 */ "aaaaaaaaaaaaaaaa" + /* 5 */ "faaabmmmmmmmmmmm" + /* 6 */ "caaabmmmmmmmmmmm" + /* 7 */ "caaabmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmmm" + /* 12 */ "maaammmmmmmmmmmm" + /* 13 */ "maaammmmmmmmmmmm" + /* 14 */ "maaammmmmmmmaaam" + /* 15 */ "mmmmmmmmmmmmaaam" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aaaaaaaaaaaaaaaa" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "................" + /* 4 */ "a...aaaaaaaaaaaa" + /* 5 */ "agggammmmmmmmmmm" + /* 6 */ "aaaaammmmmmmmmmm" + /* 7 */ "aaaaammmmmmmmmmm" + /* 8 */ "caaabmmmmmmmmmmm" + /* 9 */ "caaabmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmmm" + /* 12 */ "maaammmmmmmmmmmm" + /* 13 */ "maaammmmmmmmmmmm" + /* 14 */ "maaammmmmmmmaaam" + /* 15 */ "mmmmmmmmmmmmaaam" + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmaaam" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "................" + /* 4 */ "m...mmmmmmmmaaam" + /* 5 */ "a...ammmmmmmmmmm" + /* 6 */ "a...ammmmmmmmmmm" + /* 7 */ "agggammmmmmmmmmm" + /* 8 */ "aaaaammmmmmmmmmm" + /* 9 */ "aaaaammmmmmmmmmm" + /* 10 */ "caaabmmmmmmmmmmm" + /* 11 */ "caaabmmmmmmmmmmm" + /* 12 */ "maaabmmmmmmmmmmm" + /* 13 */ "maaabmmmmmmmmmmm" + /* 14 */ "maaafmmmmmmmaaam" + /* 15 */ "mmmmmmmmmmmmaaam" + + // Level 7 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmaaam" + /* 1 */ "................" + /* 2 */ "................" + /* 3 */ "................" + /* 4 */ "m...mmmmmmmmaaam" + /* 5 */ "m...mmmmmmmmmmmm" + /* 6 */ "m...mmmmmmmmmmmm" + /* 7 */ "a...ammmmmmmmmmm" + /* 8 */ "a...ammmmmmmmmmm" + /* 9 */ "agggammmmmmmmmmm" + /* 10 */ "aaaaammmmmmmmmmm" + /* 11 */ "aaaaaeemmmmmmmmm" + /* 12 */ "caaaaaammmmmmmmm" + /* 13 */ "caaaaaammmmmmmmm" + /* 14 */ "caaaaaammmmmaaam" + /* 15 */ "fffffffmmmmmaaam" + + // Level 8 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmmaaam" + /* 1 */ "mmmmmmmmmmmmmmmm" + /* 2 */ "mmmmmmmmmmmmmmmm" + /* 3 */ "mmmmmmmmmmmmmmmm" + /* 4 */ "m...mmmmmmmmaaam" + /* 5 */ "m...mmmmmmmmmmmm" + /* 6 */ "m...mmmmmmmmmmmm" + /* 7 */ "m...mmmmmmmmmmmm" + /* 8 */ "m...mmmmmmmmmmmm" + /* 9 */ "a...ammmmmmmmmmm" + /* 10 */ "a...ammmmmmmmmmm" + /* 11 */ "a...aaaeemmmmmmm" + /* 12 */ "a....gaaammmmmmm" + /* 13 */ "a....gaaammmmmmm" + /* 14 */ "a....gaaammmaaam" + /* 15 */ "aaaaaaaffmmmaaam" + + // Level 9 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmcaaab" + /* 1 */ "mmmmmmmmmmmcaaab" + /* 2 */ "mmmmmmmmmmmcaaab" + /* 3 */ "mmmmmmmmmmmcaaab" + /* 4 */ "mmmmmmmmmmmcaaab" + /* 5 */ "mmmmmmmmmmmcaaab" + /* 6 */ "m...mmmmmmmcaaab" + /* 7 */ "m...mmmmmmmcaaab" + /* 8 */ "m...mmmmmmmcaaab" + /* 9 */ "m...mmmmmmmcaaab" + /* 10 */ "m...mmmmmmmcaaab" + /* 11 */ "m...maaaaeecaaab" + /* 12 */ "m......gaaaaaaab" + /* 13 */ "m......gaaaaaaab" + /* 14 */ "m......gaaaaaaab" + /* 15 */ "mmmmmaaaafffaaab" + + // Level 10 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmaaaaa" + /* 1 */ "mmmmmmmmmmmaaaaa" + /* 2 */ "mmmmmmmmmmmaaaaa" + /* 3 */ "mmmmmmmmmmmaaaaa" + /* 4 */ "mmmmmmmmmmmaaaaa" + /* 5 */ "mmmmmmmmmmmaaaaa" + /* 6 */ "mmmmmmmmmmmaaaaa" + /* 7 */ "mmmmmmmmmmmaaaaa" + /* 8 */ "m...mmmmmmmaaaaa" + /* 9 */ "m...mmmmmmmaaaaa" + /* 10 */ "m...mmmmmmmaaaaa" + /* 11 */ "m...mmmaaaaaaaaa" + /* 12 */ "m........gaaaaaa" + /* 13 */ "m........gaaaaaa" + /* 14 */ "m........gaaaaaa" + /* 15 */ "mmmmmmmaaaaaaaaa" + + // Level 11 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmma...a" + /* 1 */ "mmmmmmmmmmma...a" + /* 2 */ "mmmmmmmmmmma...a" + /* 3 */ "mmmmmmmmmmma...a" + /* 4 */ "mmmmmmmmmmma...a" + /* 5 */ "mmmmmmmmmmma...a" + /* 6 */ "mmmmmmmmmmma...a" + /* 7 */ "mmmmmmmmmmma...a" + /* 8 */ "mmmmmmmmmmma...a" + /* 9 */ "mmmmmmmmmmma...a" + /* 10 */ "mmmmmmmmmmma...a" + /* 11 */ "mmmmmmmmmaaa...a" + /* 12 */ "mmmm...........a" + /* 13 */ "mmmm...........a" + /* 14 */ "mmmm...........a" + /* 15 */ "mmmmmmmmmaaa...a" + + // Level 12 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmm...m" + /* 1 */ "mmmmmmmmmmmm...m" + /* 2 */ "mmmmmmmmmmmm...m" + /* 3 */ "mmmmmmmmmmmm...m" + /* 4 */ "mmmmmmmmmmmm...m" + /* 5 */ "mmmmmmmmmmmm...m" + /* 6 */ "mmmmmmmmmmmm...m" + /* 7 */ "mmmmmmmmmmmm...m" + /* 8 */ "mmmmmmmmmmmm...m" + /* 9 */ "mmmmmmmmmmmm...m" + /* 10 */ "mmmmmmmmmmmm...m" + /* 11 */ "mmmmmmmmmmmm...m" + /* 12 */ "mmmmmm.........m" + /* 13 */ "mmmmmm.........m" + /* 14 */ "mmmmmm.........m" + /* 15 */ "mmmmmmmmmmmm...m" + + // Level 13 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "mmmmmmmmmmmm...m" + /* 1 */ "mmmmmmmmmmmm...m" + /* 2 */ "mmmmmmmmmmmm...m" + /* 3 */ "mmmmmmmmmmmm...m" + /* 4 */ "mmmmmmmmmmmm...m" + /* 5 */ "mmmmmmmmmmmm...m" + /* 6 */ "mmmmmmmmmmmm...m" + /* 7 */ "mmmmmmmmmmmm...m" + /* 8 */ "mmmmmmmmmmmm...m" + /* 9 */ "mmmmmmmmmmmm...m" + /* 10 */ "mmmmmmmmmmmm...m" + /* 11 */ "mmmmmmmmmmmm...m" + /* 12 */ "mmmmmmmm.......m" + /* 13 */ "mmmmmmmm.......m" + /* 14 */ "mmmmmmmm.......m" + /* 15 */ "mmmmmmmmmmmm...m", + + // Connectors: + "0: 13, 11, 0: 2\n" /* Type 0, direction Z- */ + "0: 13, 11, 15: 3\n" /* Type 0, direction Z+ */ + "0: 0, 5, 2: 4\n" /* Type 0, direction X- */ + "0: 15, 5, 2: 5\n" /* Type 0, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + true, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // SlabbedBridgeStairs + + + //////////////////////////////////////////////////////////////////////////////// // StairsToOpen1: // The data has been exported from the gallery Nether, area index 27, ID 277, created by Aloe_vera -- cgit v1.2.3 From 50fc1a54699b437aa7f5fccc22f594707d31238d Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 27 Jul 2014 11:59:54 +0200 Subject: NetherClumpFoliage: Fixed assert --- src/Generating/FinishGen.cpp | 47 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 4c40270e8..03137f616 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -91,19 +91,50 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a { bool IsFireBlock = a_Block == E_BLOCK_FIRE; - for (int x = a_RelX - 4; x < a_RelX + 4; x++) + int MinX = a_RelX - 4; + if (MinX < 0) // Check if the coordinate is outside the chunk. If it it then adjust it. + { + MinX = 0; + } + + int MaxX = a_RelX + 4; + if (MaxX > cChunkDef::Width) // Check if the coordinate is outside the chunk. If it it then adjust it. + { + MaxX = cChunkDef::Width; + } + + int MinZ = a_RelZ - 4; + if (MinZ < 0) // Check if the coordinate is outside the chunk. If it it then adjust it. + { + MinZ = 0; + } + + int MaxZ = a_RelZ + 4; + if (MaxZ > cChunkDef::Width) // Check if the coordinate is outside the chunk. If it it then adjust it. + { + MaxZ = cChunkDef::Width; + } + + int MinY = a_RelY - 2; + if (MinY < 0) // Check if the coordinate is outside the chunk. If it it then adjust it. + { + MinY = 0; + } + + int MaxY = a_RelY + 2; + if (MaxY > cChunkDef::Height) // Check if the coordinate is outside the chunk. If it it then adjust it. + { + MaxY = cChunkDef::Height; + } + + for (int x = MinX; x < MaxX; x++) { int xx = a_ChunkDesc.GetChunkX() * cChunkDef::Width + x; - for (int z = a_RelZ - 4; z < a_RelZ + 4; z++) + for (int z = MinZ; z < MaxZ; z++) { int zz = a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; - for (int y = a_RelY - 2; y < a_RelY + 2; y++) + for (int y = MinY; y < MaxY; y++) { - if ((y < 1) || (y > cChunkDef::Height)) - { - continue; - } - if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks. { continue; -- cgit v1.2.3 From fe7018bd005adb8dadf849bd988696d638919f23 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 27 Jul 2014 13:12:45 +0200 Subject: Added a ceiling to disguise the bedrock above it. --- src/Generating/CompoGen.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index faf2ac243..655d629b7 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -628,7 +628,15 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++) { a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK); - a_ChunkDesc.SetBlockType(x, a_ChunkDesc.GetHeight(x, z), z, E_BLOCK_BEDROCK); + + int Height = a_ChunkDesc.GetHeight(x, z); + a_ChunkDesc.SetBlockType(x, Height, z, E_BLOCK_BEDROCK); + int CeilingDisguiseHeight = Height - 2 - (m_Noise1.IntNoise2DInt(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x, a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) % 3); + + for (int y = Height - 1; y > CeilingDisguiseHeight; y--) + { + a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_NETHERRACK); + } } } -- cgit v1.2.3 From 472f70a6762369eb3375eb1ed874a95faaf2de71 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Jul 2014 13:54:27 +0200 Subject: RoughRavines: More settings - size, width, roughness --- src/Generating/ComposableGenerator.cpp | 18 +++++++--- src/Generating/RoughRavines.cpp | 66 ++++++++++++++++++++++++---------- src/Generating/RoughRavines.h | 23 +++++++++++- 3 files changed, 84 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 757f6ddb7..3326dda36 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -410,10 +410,20 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "RoughRavines") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesGridSize", 256); - int MaxOffset = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxOffset", 128); - int MaxSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxSize", 64); - m_FinishGens.push_back(new cRoughRavines(Seed, MaxSize, GridSize, MaxOffset)); + int GridSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesGridSize", 256); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxOffset", 128); + int MaxSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxSize", 128); + int MinSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMinSize", 64); + double MaxCenterWidth = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxCenterWidth", 8); + double MinCenterWidth = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinCenterWidth", 2); + double MaxRoughness = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxRoughness", 0.2); + double MinRoughness = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinRoughness", 0.05); + m_FinishGens.push_back(new cRoughRavines( + Seed, MaxSize, MinSize, + (float)MaxCenterWidth, (float)MinCenterWidth, + (float)MaxRoughness, (float)MinRoughness, + GridSize, MaxOffset + )); } else if (NoCaseCompare(*itr, "Snow") == 0) { diff --git a/src/Generating/RoughRavines.cpp b/src/Generating/RoughRavines.cpp index 1b1351a19..ddc1a0351 100644 --- a/src/Generating/RoughRavines.cpp +++ b/src/Generating/RoughRavines.cpp @@ -20,27 +20,27 @@ class cRoughRavine : typedef cGridStructGen::cStructure super; public: - cRoughRavine(int a_Seed, int a_MaxSize, int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) : + cRoughRavine(int a_Seed, int a_Size, float a_CenterWidth, float a_Roughness, int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) : super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_Noise(a_Seed + 100), - m_MaxSize(a_MaxSize) + m_Roughness(a_Roughness) { // Create the basic structure - 2 lines meeting at the centerpoint: - m_DefPoints.resize(a_MaxSize + 1); - int Half = a_MaxSize / 2; // m_DefPoints[Half] will be the centerpoint + int Max = 2 * a_Size; + int Half = a_Size; // m_DefPoints[Half] will be the centerpoint + m_DefPoints.resize(Max + 1); int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 7; - float Len = (float)(3 * a_MaxSize / 4 + rnd % (a_MaxSize / 4)); // Random number between 3 / 4 * a_MaxSize and a_MaxSize - rnd = rnd / a_MaxSize; + float Len = (float)a_Size; float Angle = (float)rnd; // Angle is in radians, will be wrapped in the "sin" and "cos" operations float OfsX = sin(Angle) * Len; float OfsZ = cos(Angle) * Len; - m_DefPoints[0].Set (a_OriginX - OfsX, a_OriginZ - OfsZ, 1, 42, 34); - m_DefPoints[Half].Set ((float)a_OriginX, (float)a_OriginZ, Len / 10, 62, 16); - m_DefPoints[a_MaxSize].Set(a_OriginX + OfsX, a_OriginZ + OfsZ, 1, 44, 32); + m_DefPoints[0].Set (a_OriginX - OfsX, a_OriginZ - OfsZ, 1, 42, 34); + m_DefPoints[Half].Set((float)a_OriginX, (float)a_OriginZ, a_CenterWidth, 62, 16); + m_DefPoints[Max].Set (a_OriginX + OfsX, a_OriginZ + OfsZ, 1, 44, 32); // Calculate the points in between, recursively: SubdivideLine(0, Half); - SubdivideLine(Half, a_MaxSize); + SubdivideLine(Half, Max); } protected: @@ -69,6 +69,8 @@ protected: sRavineDefPoints m_DefPoints; + float m_Roughness; + /** Recursively subdivides the line between the points of the specified index. Sets the midpoint to the center of the line plus or minus a random offset, then calls itself for each half @@ -89,13 +91,13 @@ protected: float dz = p2.m_Z - p1.m_Z; if ((m_Noise.IntNoise2DInt((int)MidX, (int)MidZ) / 11) % 2 == 0) { - MidX += dz / 10; - MidZ -= dx / 10; + MidX += dz * m_Roughness; + MidZ -= dx * m_Roughness; } else { - MidX -= dz / 10; - MidZ += dx / 10; + MidX -= dz * m_Roughness; + MidZ += dx * m_Roughness; } int MidIdx = (a_Idx1 + a_Idx2) / 2; m_DefPoints[MidIdx].Set(MidX, MidZ, MidR, MidT, MidB); @@ -188,16 +190,41 @@ protected: //////////////////////////////////////////////////////////////////////////////// // cRoughRavines: -cRoughRavines::cRoughRavines(int a_Seed, int a_MaxSize, int a_GridSize, int a_MaxOffset) : +cRoughRavines::cRoughRavines( + int a_Seed, + int a_MaxSize, int a_MinSize, + float a_MaxCenterWidth, float a_MinCenterWidth, + float a_MaxRoughness, float a_MinRoughness, + int a_GridSize, int a_MaxOffset +) : super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 64), m_Seed(a_Seed), - m_MaxSize(a_MaxSize) + m_MaxSize(a_MaxSize), + m_MinSize(a_MinSize), + m_MaxCenterWidth(a_MaxCenterWidth), + m_MinCenterWidth(a_MinCenterWidth), + m_MaxRoughness(a_MaxRoughness), + m_MinRoughness(a_MinRoughness) { - if (m_MaxSize < 1) + if (m_MinSize > m_MaxSize) + { + std::swap(m_MinSize, m_MaxSize); + std::swap(a_MinSize, a_MaxSize); + } + if (m_MaxSize < 16) { m_MaxSize = 16; LOGWARNING("RoughRavines: MaxSize too small, adjusting request from %d to %d", a_MaxSize, m_MaxSize); } + if (m_MinSize < 16) + { + m_MinSize = 16; + LOGWARNING("RoughRavines: MinSize too small, adjusting request from %d to %d", a_MinSize, m_MinSize); + } + if (m_MinSize == m_MaxSize) + { + m_MaxSize = m_MinSize + 1; + } } @@ -206,7 +233,10 @@ cRoughRavines::cRoughRavines(int a_Seed, int a_MaxSize, int a_GridSize, int a_Ma cGridStructGen::cStructurePtr cRoughRavines::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { - return cStructurePtr(new cRoughRavine(m_Seed, m_MaxSize, a_GridX, a_GridZ, a_OriginX, a_OriginZ)); + int Size = m_MinSize + (m_Noise.IntNoise2DInt(a_GridX, a_GridZ) / 7) % (m_MaxSize - m_MinSize); // Random int from m_MinSize to m_MaxSize + float CenterWidth = m_MinCenterWidth + abs(m_Noise.IntNoise2D(a_GridX, a_GridZ + 10)) * (m_MaxCenterWidth - m_MinCenterWidth); // Random float from m_MinCenterWidth to m_MaxCenterWidth + float Roughness = m_MinRoughness + abs(m_Noise.IntNoise2D(a_GridX + 10, a_GridZ)) * (m_MaxRoughness - m_MinRoughness); // Random float from m_MinRoughness to m_MaxRoughness + return cStructurePtr(new cRoughRavine(m_Seed, Size, CenterWidth, Roughness, a_GridX, a_GridZ, a_OriginX, a_OriginZ)); } diff --git a/src/Generating/RoughRavines.h b/src/Generating/RoughRavines.h index 68c628d84..dce2f9ba7 100644 --- a/src/Generating/RoughRavines.h +++ b/src/Generating/RoughRavines.h @@ -20,13 +20,34 @@ class cRoughRavines : typedef cGridStructGen super; public: - cRoughRavines(int a_Seed, int a_MaxSize, int a_GridSize, int a_MaxOffset); + cRoughRavines( + int a_Seed, + int a_MaxSize, int a_MinSize, + float a_MaxCenterWidth, float a_MinCenterWidth, + float a_MaxRoughness, float a_MinRoughness, + int a_GridSize, int a_MaxOffset + ); protected: int m_Seed; /** Maximum size of the ravine, in each of the X / Z axis */ int m_MaxSize; + + /** Minimum size of the ravine */ + int m_MinSize; + + /** Maximum width of the ravine's center, in blocks */ + float m_MaxCenterWidth; + + /** Minimum width of the ravine's center, in blocks */ + float m_MinCenterWidth; + + /** Maximum roughness of the ravine */ + float m_MaxRoughness; + + /** Minimum roughness of the ravine */ + float m_MinRoughness; // cGridStructGen overrides: virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; -- cgit v1.2.3 From bfad1be567ac4fd2393398f52c615496422a67f8 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 27 Jul 2014 14:03:23 +0200 Subject: Made nether ceiling smooth. --- src/Generating/CompoGen.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 655d629b7..87557afa0 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -631,7 +631,14 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) int Height = a_ChunkDesc.GetHeight(x, z); a_ChunkDesc.SetBlockType(x, Height, z, E_BLOCK_BEDROCK); - int CeilingDisguiseHeight = Height - 2 - (m_Noise1.IntNoise2DInt(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x, a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) % 3); + // int CeilingDisguiseHeight = Height - 2 - (m_Noise1.IntNoise2DInt(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x, a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) % 3); + NOISE_DATATYPE CeilingDisguise = (m_Noise1.CubicNoise2D((float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x) / 10, (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) / 10)); + if (CeilingDisguise < 0) + { + CeilingDisguise = -CeilingDisguise; + } + + int CeilingDisguiseHeight = Height - 2 - CeilingDisguise * 3; for (int y = Height - 1; y > CeilingDisguiseHeight; y--) { -- cgit v1.2.3 From 3addd4890c8e09a561b93e84b542a2ab08ee0496 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 27 Jul 2014 14:04:34 +0200 Subject: Removed forgotten comment --- src/Generating/CompoGen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 87557afa0..912d74248 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -631,7 +631,7 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) int Height = a_ChunkDesc.GetHeight(x, z); a_ChunkDesc.SetBlockType(x, Height, z, E_BLOCK_BEDROCK); - // int CeilingDisguiseHeight = Height - 2 - (m_Noise1.IntNoise2DInt(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x, a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) % 3); + NOISE_DATATYPE CeilingDisguise = (m_Noise1.CubicNoise2D((float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x) / 10, (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) / 10)); if (CeilingDisguise < 0) { -- cgit v1.2.3 From 960ab982b96d23485b6c42df1ed2b08a251a0c22 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Jul 2014 16:05:45 +0200 Subject: RoughRavines: Added per-height radius modifier. Ledges! --- src/Generating/RoughRavines.cpp | 105 ++++++++++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/Generating/RoughRavines.cpp b/src/Generating/RoughRavines.cpp index ddc1a0351..8dec791c9 100644 --- a/src/Generating/RoughRavines.cpp +++ b/src/Generating/RoughRavines.cpp @@ -22,6 +22,7 @@ class cRoughRavine : public: cRoughRavine(int a_Seed, int a_Size, float a_CenterWidth, float a_Roughness, int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) : super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), + m_Seed(a_Seed + 100), m_Noise(a_Seed + 100), m_Roughness(a_Roughness) { @@ -41,6 +42,9 @@ public: // Calculate the points in between, recursively: SubdivideLine(0, Half); SubdivideLine(Half, Max); + + // Initialize the per-height radius modifiers: + InitPerHeightRadius(a_GridX, a_GridZ); } protected: @@ -63,6 +67,8 @@ protected: }; typedef std::vector sRavineDefPoints; + int m_Seed; + cNoise m_Noise; int m_MaxSize; @@ -71,6 +77,9 @@ protected: float m_Roughness; + /** Number to add to the radius based on the height. This creates the "ledges" in the ravine walls. */ + float m_PerHeightRadius[cChunkDef::Height]; + /** Recursively subdivides the line between the points of the specified index. Sets the midpoint to the center of the line plus or minus a random offset, then calls itself for each half @@ -114,6 +123,29 @@ protected: } + void InitPerHeightRadius(int a_GridX, int a_GridZ) + { + int h = 0; + while (h < cChunkDef::Height) + { + m_Noise.SetSeed(m_Seed + h); + int rnd = m_Noise.IntNoise2DInt(a_GridX, a_GridZ) / 13; + int NumBlocks = (rnd % 3) + 2; + rnd = rnd / 4; + float Val = (float)(rnd % 256) / 128 - 1; // Random float in range [-1, +1] + if (h + NumBlocks > cChunkDef::Height) + { + NumBlocks = cChunkDef::Height - h; + } + for (int i = 0; i < NumBlocks; i++) + { + m_PerHeightRadius[h + i] = Val; + } + h += NumBlocks; + } + } + + virtual void DrawIntoChunk(cChunkDesc & a_ChunkDesc) override { int BlockStartX = a_ChunkDesc.GetChunkX() * cChunkDef::Width; @@ -123,18 +155,20 @@ protected: for (sRavineDefPoints::const_iterator itr = m_DefPoints.begin(), end = m_DefPoints.end(); itr != end; ++itr) { if ( - (ceilf (itr->m_X + itr->m_Radius) < BlockStartX) || - (floorf(itr->m_X - itr->m_Radius) > BlockEndX) || - (ceilf (itr->m_Z + itr->m_Radius) < BlockStartZ) || - (floorf(itr->m_Z - itr->m_Radius) > BlockEndZ) + (ceilf (itr->m_X + itr->m_Radius + 2) < BlockStartX) || + (floorf(itr->m_X - itr->m_Radius - 2) > BlockEndX) || + (ceilf (itr->m_Z + itr->m_Radius + 2) < BlockStartZ) || + (floorf(itr->m_Z - itr->m_Radius - 2) > BlockEndZ) ) { // Cannot intersect, bail out early continue; } - // Carve out a cylinder around the xz point, m_Radius in diameter, from Bottom to Top: - float RadiusSq = itr->m_Radius * itr->m_Radius; // instead of doing sqrt for each distance, we do sqr of the radius + // Carve out a cylinder around the xz point, up to (m_Radius + 2) in diameter, from Bottom to Top: + // On each height level, use m_PerHeightRadius[] to modify the actual radius used + // EnlargedRadiusSq is the square of the radius enlarged by the maximum m_PerHeightRadius offset - anything outside it will never be touched. + float RadiusSq = (itr->m_Radius + 2) * (itr->m_Radius + 2); float DifX = BlockStartX - itr->m_X; // substitution for faster calc float DifZ = BlockStartZ - itr->m_Z; // substitution for faster calc for (int x = 0; x < cChunkDef::Width; x++) for (int z = 0; z < cChunkDef::Width; z++) @@ -147,37 +181,44 @@ protected: } #endif // _DEBUG + // If the column is outside the enlarged radius, bail out completely float DistSq = (DifX + x) * (DifX + x) + (DifZ + z) * (DifZ + z); - if (DistSq <= RadiusSq) + if (DistSq > RadiusSq) + { + continue; + } + + int Top = std::min((int)ceilf(itr->m_Top), +cChunkDef::Height); + for (int y = std::max((int)floorf(itr->m_Bottom), 1); y <= Top; y++) { - int Top = std::min((int)ceilf(itr->m_Top), +cChunkDef::Height); - for (int y = std::max((int)floorf(itr->m_Bottom), 1); y <= Top; y++) + if ((itr->m_Radius + m_PerHeightRadius[y]) * (itr->m_Radius + m_PerHeightRadius[y]) < DistSq) + { + continue; + } + switch (a_ChunkDesc.GetBlockType(x, y, z)) { - switch (a_ChunkDesc.GetBlockType(x, y, z)) + // Only carve out these specific block types + case E_BLOCK_DIRT: + case E_BLOCK_GRASS: + case E_BLOCK_STONE: + case E_BLOCK_COBBLESTONE: + case E_BLOCK_GRAVEL: + case E_BLOCK_SAND: + case E_BLOCK_SANDSTONE: + case E_BLOCK_NETHERRACK: + case E_BLOCK_COAL_ORE: + case E_BLOCK_IRON_ORE: + case E_BLOCK_GOLD_ORE: + case E_BLOCK_DIAMOND_ORE: + case E_BLOCK_REDSTONE_ORE: + case E_BLOCK_REDSTONE_ORE_GLOWING: { - // Only carve out these specific block types - case E_BLOCK_DIRT: - case E_BLOCK_GRASS: - case E_BLOCK_STONE: - case E_BLOCK_COBBLESTONE: - case E_BLOCK_GRAVEL: - case E_BLOCK_SAND: - case E_BLOCK_SANDSTONE: - case E_BLOCK_NETHERRACK: - case E_BLOCK_COAL_ORE: - case E_BLOCK_IRON_ORE: - case E_BLOCK_GOLD_ORE: - case E_BLOCK_DIAMOND_ORE: - case E_BLOCK_REDSTONE_ORE: - case E_BLOCK_REDSTONE_ORE_GLOWING: - { - a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR); - break; - } - default: break; + a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR); + break; } - } - } + default: break; + } // switch (BlockType) + } // for y } // for x, z - a_BlockTypes } // for itr - m_Points[] } -- cgit v1.2.3 From 30893e7ee2f4dbaa3e4348b07cdc77aada168e1f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Jul 2014 19:57:47 +0200 Subject: RoughRavines: Made floor and ceiling settings-adjustable. The world.ini has settings for the minimum and maximum height for each at the ravines' center and edges. --- src/Generating/ComposableGenerator.cpp | 32 ++++++++++++++------- src/Generating/RoughRavines.cpp | 51 ++++++++++++++++++++++++++++------ src/Generating/RoughRavines.h | 30 +++++++++++++++++++- src/Noise.h | 6 ++++ 4 files changed, 99 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 3326dda36..0d9bedf45 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -410,18 +410,30 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "RoughRavines") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesGridSize", 256); - int MaxOffset = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxOffset", 128); - int MaxSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxSize", 128); - int MinSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMinSize", 64); - double MaxCenterWidth = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxCenterWidth", 8); - double MinCenterWidth = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinCenterWidth", 2); - double MaxRoughness = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxRoughness", 0.2); - double MinRoughness = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinRoughness", 0.05); + int GridSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesGridSize", 256); + int MaxOffset = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxOffset", 128); + int MaxSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxSize", 128); + int MinSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMinSize", 64); + double MaxCenterWidth = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxCenterWidth", 8); + double MinCenterWidth = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinCenterWidth", 2); + double MaxRoughness = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxRoughness", 0.2); + double MinRoughness = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinRoughness", 0.05); + double MaxFloorHeightEdge = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxFloorHeightEdge", 8); + double MinFloorHeightEdge = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinFloorHeightEdge", 30); + double MaxFloorHeightCenter = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxFloorHeightCenter", 20); + double MinFloorHeightCenter = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinFloorHeightCenter", 6); + double MaxCeilingHeightEdge = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxCeilingHeightEdge", 56); + double MinCeilingHeightEdge = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinCeilingHeightEdge", 38); + double MaxCeilingHeightCenter = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxCeilingHeightCenter", 58); + double MinCeilingHeightCenter = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinCeilingHeightCenter", 36); m_FinishGens.push_back(new cRoughRavines( Seed, MaxSize, MinSize, - (float)MaxCenterWidth, (float)MinCenterWidth, - (float)MaxRoughness, (float)MinRoughness, + (float)MaxCenterWidth, (float)MinCenterWidth, + (float)MaxRoughness, (float)MinRoughness, + (float)MaxFloorHeightEdge, (float)MinFloorHeightEdge, + (float)MaxFloorHeightCenter, (float)MinFloorHeightCenter, + (float)MaxCeilingHeightEdge, (float)MinCeilingHeightEdge, + (float)MaxCeilingHeightCenter, (float)MinCeilingHeightCenter, GridSize, MaxOffset )); } diff --git a/src/Generating/RoughRavines.cpp b/src/Generating/RoughRavines.cpp index 8dec791c9..badc7768e 100644 --- a/src/Generating/RoughRavines.cpp +++ b/src/Generating/RoughRavines.cpp @@ -20,7 +20,13 @@ class cRoughRavine : typedef cGridStructGen::cStructure super; public: - cRoughRavine(int a_Seed, int a_Size, float a_CenterWidth, float a_Roughness, int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) : + cRoughRavine( + int a_Seed, int a_Size, + float a_CenterWidth, float a_Roughness, + float a_FloorHeightEdge1, float a_FloorHeightEdge2, float a_FloorHeightCenter, + float a_CeilingHeightEdge1, float a_CeilingHeightEdge2, float a_CeilingHeightCenter, + int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ + ) : super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_Seed(a_Seed + 100), m_Noise(a_Seed + 100), @@ -35,9 +41,9 @@ public: float Angle = (float)rnd; // Angle is in radians, will be wrapped in the "sin" and "cos" operations float OfsX = sin(Angle) * Len; float OfsZ = cos(Angle) * Len; - m_DefPoints[0].Set (a_OriginX - OfsX, a_OriginZ - OfsZ, 1, 42, 34); - m_DefPoints[Half].Set((float)a_OriginX, (float)a_OriginZ, a_CenterWidth, 62, 16); - m_DefPoints[Max].Set (a_OriginX + OfsX, a_OriginZ + OfsZ, 1, 44, 32); + m_DefPoints[0].Set (a_OriginX - OfsX, a_OriginZ - OfsZ, 1, a_CeilingHeightEdge1, a_FloorHeightEdge1); + m_DefPoints[Half].Set((float)a_OriginX, (float)a_OriginZ, a_CenterWidth, a_CeilingHeightCenter, a_FloorHeightCenter); + m_DefPoints[Max].Set (a_OriginX + OfsX, a_OriginZ + OfsZ, 1, a_CeilingHeightEdge2, a_FloorHeightEdge2); // Calculate the points in between, recursively: SubdivideLine(0, Half); @@ -235,7 +241,11 @@ cRoughRavines::cRoughRavines( int a_Seed, int a_MaxSize, int a_MinSize, float a_MaxCenterWidth, float a_MinCenterWidth, - float a_MaxRoughness, float a_MinRoughness, + float a_MaxRoughness, float a_MinRoughness, + float a_MaxFloorHeightEdge, float a_MinFloorHeightEdge, + float a_MaxFloorHeightCenter, float a_MinFloorHeightCenter, + float a_MaxCeilingHeightEdge, float a_MinCeilingHeightEdge, + float a_MaxCeilingHeightCenter, float a_MinCeilingHeightCenter, int a_GridSize, int a_MaxOffset ) : super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 64), @@ -245,7 +255,15 @@ cRoughRavines::cRoughRavines( m_MaxCenterWidth(a_MaxCenterWidth), m_MinCenterWidth(a_MinCenterWidth), m_MaxRoughness(a_MaxRoughness), - m_MinRoughness(a_MinRoughness) + m_MinRoughness(a_MinRoughness), + m_MaxFloorHeightEdge(a_MaxFloorHeightEdge), + m_MinFloorHeightEdge(a_MinFloorHeightEdge), + m_MaxFloorHeightCenter(a_MaxFloorHeightCenter), + m_MinFloorHeightCenter(a_MinFloorHeightCenter), + m_MaxCeilingHeightEdge(a_MaxCeilingHeightEdge), + m_MinCeilingHeightEdge(a_MinCeilingHeightEdge), + m_MaxCeilingHeightCenter(a_MaxCeilingHeightCenter), + m_MinCeilingHeightCenter(a_MinCeilingHeightCenter) { if (m_MinSize > m_MaxSize) { @@ -274,10 +292,25 @@ cRoughRavines::cRoughRavines( cGridStructGen::cStructurePtr cRoughRavines::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { + // Pick a random value for each of the ravine's parameters: int Size = m_MinSize + (m_Noise.IntNoise2DInt(a_GridX, a_GridZ) / 7) % (m_MaxSize - m_MinSize); // Random int from m_MinSize to m_MaxSize - float CenterWidth = m_MinCenterWidth + abs(m_Noise.IntNoise2D(a_GridX, a_GridZ + 10)) * (m_MaxCenterWidth - m_MinCenterWidth); // Random float from m_MinCenterWidth to m_MaxCenterWidth - float Roughness = m_MinRoughness + abs(m_Noise.IntNoise2D(a_GridX + 10, a_GridZ)) * (m_MaxRoughness - m_MinRoughness); // Random float from m_MinRoughness to m_MaxRoughness - return cStructurePtr(new cRoughRavine(m_Seed, Size, CenterWidth, Roughness, a_GridX, a_GridZ, a_OriginX, a_OriginZ)); + float CenterWidth = m_Noise.IntNoise2DInRange(a_GridX + 10, a_GridZ, m_MinCenterWidth, m_MaxCenterWidth); + float Roughness = m_Noise.IntNoise2DInRange(a_GridX + 20, a_GridZ, m_MinRoughness, m_MaxRoughness); + float FloorHeightEdge1 = m_Noise.IntNoise2DInRange(a_GridX + 30, a_GridZ, m_MinFloorHeightEdge, m_MaxFloorHeightEdge); + float FloorHeightEdge2 = m_Noise.IntNoise2DInRange(a_GridX + 40, a_GridZ, m_MinFloorHeightEdge, m_MaxFloorHeightEdge); + float FloorHeightCenter = m_Noise.IntNoise2DInRange(a_GridX + 50, a_GridZ, m_MinFloorHeightCenter, m_MaxFloorHeightCenter); + float CeilingHeightEdge1 = m_Noise.IntNoise2DInRange(a_GridX + 60, a_GridZ, m_MinCeilingHeightEdge, m_MaxCeilingHeightEdge); + float CeilingHeightEdge2 = m_Noise.IntNoise2DInRange(a_GridX + 70, a_GridZ, m_MinCeilingHeightEdge, m_MaxCeilingHeightEdge); + float CeilingHeightCenter = m_Noise.IntNoise2DInRange(a_GridX + 80, a_GridZ, m_MinCeilingHeightCenter, m_MaxCeilingHeightCenter); + + // Create a ravine: + return cStructurePtr(new cRoughRavine( + m_Seed, + Size, CenterWidth, Roughness, + FloorHeightEdge1, FloorHeightEdge2, FloorHeightCenter, + CeilingHeightEdge1, CeilingHeightEdge2, CeilingHeightCenter, + a_GridX, a_GridZ, a_OriginX, a_OriginZ + )); } diff --git a/src/Generating/RoughRavines.h b/src/Generating/RoughRavines.h index dce2f9ba7..4c905b641 100644 --- a/src/Generating/RoughRavines.h +++ b/src/Generating/RoughRavines.h @@ -24,7 +24,11 @@ public: int a_Seed, int a_MaxSize, int a_MinSize, float a_MaxCenterWidth, float a_MinCenterWidth, - float a_MaxRoughness, float a_MinRoughness, + float a_MaxRoughness, float a_MinRoughness, + float a_MaxFloorHeightEdge, float a_MinFloorHeightEdge, + float a_MaxFloorHeightCenter, float a_MinFloorHeightCenter, + float a_MaxCeilingHeightEdge, float a_MinCeilingHeightEdge, + float a_MaxCeilingHeightCenter, float a_MinCeilingHeightCenter, int a_GridSize, int a_MaxOffset ); @@ -49,6 +53,30 @@ protected: /** Minimum roughness of the ravine */ float m_MinRoughness; + /** Maximum floor height at the ravine's edge */ + float m_MaxFloorHeightEdge; + + /** Minimum floor height at the ravine's edge */ + float m_MinFloorHeightEdge; + + /** Maximum floor height at the ravine's center */ + float m_MaxFloorHeightCenter; + + /** Minimum floor height at the ravine's center */ + float m_MinFloorHeightCenter; + + /** Maximum ceiling height at the ravine's edge */ + float m_MaxCeilingHeightEdge; + + /** Minimum ceiling height at the ravine's edge */ + float m_MinCeilingHeightEdge; + + /** Maximum ceiling height at the ravine's center */ + float m_MaxCeilingHeightCenter; + + /** Minimum ceiling height at the ravine's center */ + float m_MinCeilingHeightCenter; + // cGridStructGen overrides: virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; }; diff --git a/src/Noise.h b/src/Noise.h index 48a1c73f7..e69e5cdad 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -33,6 +33,12 @@ public: INLINE NOISE_DATATYPE IntNoise2D(int a_X, int a_Y) const; INLINE NOISE_DATATYPE IntNoise3D(int a_X, int a_Y, int a_Z) const; + // Return a float number in the specified range: + INLINE NOISE_DATATYPE IntNoise2DInRange(int a_X, int a_Y, float a_Min, float a_Max) const + { + return a_Min + std::abs(IntNoise2D(a_X, a_Y)) * (a_Max - a_Min); + } + // Note: These functions have a mod8-irregular chance - each of the mod8 remainders has different chance of occurrence. Divide by 8 to rectify. INLINE int IntNoise1DInt(int a_X) const; INLINE int IntNoise2DInt(int a_X, int a_Y) const; -- cgit v1.2.3 From 003f0e69a9fb8a6d617f498b238543c903cff313 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Jul 2014 20:04:09 +0200 Subject: Updated NetherForts' weights. --- src/Generating/Prefabs/NetherFortPrefabs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Generating/Prefabs/NetherFortPrefabs.cpp b/src/Generating/Prefabs/NetherFortPrefabs.cpp index fb0e93daa..a3e3da158 100644 --- a/src/Generating/Prefabs/NetherFortPrefabs.cpp +++ b/src/Generating/Prefabs/NetherFortPrefabs.cpp @@ -1773,7 +1773,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = true, // DefaultWeight: - 100, + 20, // DepthWeight: "", @@ -5015,7 +5015,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = true, // DefaultWeight: - 100, + 20, // DepthWeight: "", -- cgit v1.2.3 From 579b80fd3a3b633e59034c0924459a860d611b27 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Jul 2014 20:08:33 +0200 Subject: Added a missing include for abs(float). --- src/Noise.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/Noise.h b/src/Noise.h index e69e5cdad..4cf8d4ad8 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -5,6 +5,12 @@ #pragma once +#include + + + + + // Some settings #define NOISE_DATATYPE float -- cgit v1.2.3 From d61f1d0f4a1565d4de7e8100d9bf766d6fd458d1 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 27 Jul 2014 20:48:39 +0200 Subject: NetherClumpGenerator: Fixed generating stuff on halfslabs and fences --- src/Generating/FinishGen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 03137f616..9f0c8f3fa 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -141,7 +141,7 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a } BLOCKTYPE BlockBelow = a_ChunkDesc.GetBlockType(x, y - 1, z); - if (!cBlockInfo::IsSolid(BlockBelow)) // Only place on solid blocks + if (!cBlockInfo::FullyOccupiesVoxel(BlockBelow)) // Only place on solid blocks { continue; } -- cgit v1.2.3 From fd4ee20b2a927649b4671be95dccc8644c96e5ab Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Jul 2014 23:15:51 +0200 Subject: Hotfixed compilation problems. --- src/Items/ItemHandler.cpp | 2 +- src/Items/ItemSword.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index ec86648b3..d36b5d663 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -366,7 +366,7 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I short cItemHandler::GetDurabilityLossByAction(eDurabilityLostAction a_Action) { - switch (a_Action) + switch ((int)a_Action) { case dlaAttackEntity: return 2; case dlaBreakBlock: return 1; diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h index b90965535..2b2dbfc0d 100644 --- a/src/Items/ItemSword.h +++ b/src/Items/ItemSword.h @@ -46,7 +46,7 @@ public: virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override { - switch (a_Action) + switch ((int)a_Action) { case dlaAttackEntity: return 1; case dlaBreakBlock: return 2; -- cgit v1.2.3 From 5b69b2ce4faf5a14e6ab5d5974b790d2bd751a95 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 28 Jul 2014 12:30:16 +0200 Subject: DistortedHeightmap: Now generates gravel in deep ocean. --- src/Generating/DistortedHeightmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp index 1337896ab..c18c402da 100644 --- a/src/Generating/DistortedHeightmap.cpp +++ b/src/Generating/DistortedHeightmap.cpp @@ -809,7 +809,7 @@ void cDistortedHeightmap::FillColumnPattern(cChunkDesc & a_ChunkDesc, int a_RelX } // Select the ocean-floor pattern to use: - a_Pattern = ChooseOceanFloorPattern(a_RelX, a_RelZ); + a_Pattern = a_ChunkDesc.GetBiome(a_RelX, a_RelZ) == biDeepOcean ? patGravel.Get() : ChooseOceanFloorPattern(a_RelX, a_RelZ); HasHadWater = true; } // for y a_ChunkDesc.SetBlockType(a_RelX, 0, a_RelZ, E_BLOCK_BEDROCK); -- cgit v1.2.3 From bf1aa7993202c2f57de88b068d999d262f1874f6 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 28 Jul 2014 14:23:29 +0200 Subject: Renamed cFinishGenSingleBiomeSingleTopBlock to cFinishGenSingleTopBlock Now accepts a vector of biomes and a vector of allowed blocks. --- src/Generating/ComposableGenerator.cpp | 31 +++++++++++++++++++-- src/Generating/FinishGen.cpp | 21 ++++++++------ src/Generating/FinishGen.h | 50 +++++++++++++++++++++++++++------- 3 files changed, 82 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index ab6accee7..ed1e7f6c1 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -323,7 +323,24 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "DeadBushes") == 0) { - m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_DEAD_BUSH, biDesert, 2, E_BLOCK_SAND, E_BLOCK_SAND)); + // A list with all the allowed biomes. + cFinishGenSingleTopBlock::BiomeList AllowedBiomes; + AllowedBiomes.push_back(biDesert); + AllowedBiomes.push_back(biDesertHills); + AllowedBiomes.push_back(biDesertM); + AllowedBiomes.push_back(biMesa); + AllowedBiomes.push_back(biMesaBryce); + AllowedBiomes.push_back(biMesaPlateauF); + AllowedBiomes.push_back(biMesaPlateauFM); + AllowedBiomes.push_back(biMesaPlateauM); + + // A list with all the allowed blocks that can be below the lilypad. + cFinishGenSingleTopBlock::BlockList AllowedBlocks; + AllowedBlocks.push_back(E_BLOCK_SAND); + AllowedBlocks.push_back(E_BLOCK_HARDENED_CLAY); + AllowedBlocks.push_back(E_BLOCK_STAINED_CLAY); + + m_FinishGens.push_back(new cFinishGenSingleTopBlock(Seed, E_BLOCK_DEAD_BUSH, AllowedBiomes, 2, AllowedBlocks)); } else if (NoCaseCompare(*itr, "DirectOverhangs") == 0) { @@ -370,7 +387,17 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "Lilypads") == 0) { - m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_LILY_PAD, biSwampland, 4, E_BLOCK_WATER, E_BLOCK_STATIONARY_WATER)); + // A list with all the allowed biomes. + cFinishGenSingleTopBlock::BiomeList AllowedBiomes; + AllowedBiomes.push_back(biSwampland); + AllowedBiomes.push_back(biSwamplandM); + + // A list with all the allowed blocks that can be below the lilypad. + cFinishGenSingleTopBlock::BlockList AllowedBlocks; + AllowedBlocks.push_back(E_BLOCK_WATER); + AllowedBlocks.push_back(E_BLOCK_STATIONARY_WATER); + + m_FinishGens.push_back(new cFinishGenSingleTopBlock(Seed, E_BLOCK_LILY_PAD, AllowedBiomes, 4, AllowedBlocks)); } else if (NoCaseCompare(*itr, "NetherClumpFoliage") == 0) { diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 9f0c8f3fa..4c99c7f86 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -456,12 +456,12 @@ void cFinishGenIce::GenFinish(cChunkDesc & a_ChunkDesc) //////////////////////////////////////////////////////////////////////////////// // cFinishGenLilypads: -int cFinishGenSingleBiomeSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap) +int cFinishGenSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap) { int res = 0; for (size_t i = 0; i < ARRAYCOUNT(a_BiomeMap); i++) { - if (a_BiomeMap[i] == m_Biome) + if (IsAllowedBiome(a_BiomeMap[i])) { res++; } @@ -473,7 +473,7 @@ int cFinishGenSingleBiomeSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap & -void cFinishGenSingleBiomeSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc) +void cFinishGenSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc) { // Add Lilypads on top of water surface in Swampland @@ -486,11 +486,13 @@ void cFinishGenSingleBiomeSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc) int z = (m_Noise.IntNoise3DInt(ChunkX - ChunkZ, i, ChunkZ) / 11) % cChunkDef::Width; // Place the block at {x, z} if possible: - if (a_ChunkDesc.GetBiome(x, z) != m_Biome) + EMCSBiome Biome = a_ChunkDesc.GetBiome(x, z); + if (!IsAllowedBiome(Biome)) { // Incorrect biome continue; } + int Height = a_ChunkDesc.GetHeight(x, z); if (Height >= cChunkDef::Height) { @@ -502,13 +504,16 @@ void cFinishGenSingleBiomeSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc) // Not an empty block continue; } + BLOCKTYPE BlockBelow = a_ChunkDesc.GetBlockType(x, Height, z); - if ((BlockBelow == m_AllowedBelow1) || (BlockBelow == m_AllowedBelow2)) + if (!IsAllowedBlockBelow(BlockBelow)) { - a_ChunkDesc.SetBlockType(x, Height + 1, z, m_BlockType); - a_ChunkDesc.SetHeight(x, z, Height + 1); + continue; } - } // for i + + a_ChunkDesc.SetBlockType(x, Height + 1, z, m_BlockType); + a_ChunkDesc.SetHeight(x, z, Height + 1); + } } diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 810bb4a91..1b885df88 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -143,32 +143,62 @@ Used for: - Lilypads finisher - DeadBushes finisher */ -class cFinishGenSingleBiomeSingleTopBlock : +class cFinishGenSingleTopBlock : public cFinishGen { public: - cFinishGenSingleBiomeSingleTopBlock( - int a_Seed, BLOCKTYPE a_BlockType, EMCSBiome a_Biome, int a_Amount, - BLOCKTYPE a_AllowedBelow1, BLOCKTYPE a_AllowedBelow2 + + typedef std::vector BlockList; + typedef std::vector BiomeList; + + cFinishGenSingleTopBlock( + int a_Seed, BLOCKTYPE a_BlockType, BiomeList a_Biomes, int a_Amount, + BlockList a_AllowedBelow ) : m_Noise(a_Seed), m_BlockType(a_BlockType), - m_Biome(a_Biome), + m_Biomes(a_Biomes), m_Amount(a_Amount), - m_AllowedBelow1(a_AllowedBelow1), - m_AllowedBelow2(a_AllowedBelow2) + m_AllowedBelow(a_AllowedBelow) { } protected: cNoise m_Noise; BLOCKTYPE m_BlockType; - EMCSBiome m_Biome; int m_Amount; ///< Relative amount of blocks to try adding. 1 = one block per 256 biome columns. - BLOCKTYPE m_AllowedBelow1; ///< First of the two blocktypes that are allowed below m_BlockType - BLOCKTYPE m_AllowedBelow2; ///< Second of the two blocktypes that are allowed below m_BlockType + + BlockList m_AllowedBelow; + BiomeList m_Biomes; int GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap); + + // Returns true if the given biome is a biome that is allowed. + bool IsAllowedBiome(EMCSBiome a_Biome) + { + for (BiomeList::iterator itr = m_Biomes.begin(); itr != m_Biomes.end(); ++itr) + { + if (a_Biome == *itr) + { + return true; + } + } + return false; + } + + // Returns true if the given blocktype may be below m_BlockType + bool IsAllowedBlockBelow(BLOCKTYPE a_BlockBelow) + { + for (BlockList::iterator itr = m_AllowedBelow.begin(); itr != m_AllowedBelow.end(); ++itr) + { + if (*itr == a_BlockBelow) + { + return true; + } + } + return false; + } + // cFinishGen override: virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; -- cgit v1.2.3 From 579f850506a1cc72f8f205f9e8c686f434e63023 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 28 Jul 2014 14:28:16 +0200 Subject: Forgot Mesa Plateau biome. --- src/Generating/ComposableGenerator.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index ed1e7f6c1..a8c1a842f 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -330,6 +330,7 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) AllowedBiomes.push_back(biDesertM); AllowedBiomes.push_back(biMesa); AllowedBiomes.push_back(biMesaBryce); + AllowedBiomes.push_back(biMesaPlateau); AllowedBiomes.push_back(biMesaPlateauF); AllowedBiomes.push_back(biMesaPlateauFM); AllowedBiomes.push_back(biMesaPlateauM); -- cgit v1.2.3 From e74984675cf74f3a74d2694dda10802b158f734c Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 28 Jul 2014 16:53:01 +0200 Subject: Using suggestions --- src/Generating/FinishGen.h | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 1b885df88..a856b2cda 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -147,9 +147,12 @@ class cFinishGenSingleTopBlock : public cFinishGen { public: - typedef std::vector BlockList; + bool m_IsAllowedBelow[256]; + typedef std::vector BiomeList; + bool m_IsBiomeAllowed[256]; + cFinishGenSingleTopBlock( int a_Seed, BLOCKTYPE a_BlockType, BiomeList a_Biomes, int a_Amount, @@ -157,46 +160,38 @@ public: ) : m_Noise(a_Seed), m_BlockType(a_BlockType), - m_Biomes(a_Biomes), - m_Amount(a_Amount), - m_AllowedBelow(a_AllowedBelow) + m_Amount(a_Amount) { + // Load the allowed blocks into m_IsAllowedBelow + for (BlockList::iterator itr = a_AllowedBelow.begin(); itr != a_AllowedBelow.end(); ++itr) + { + m_IsAllowedBelow[*itr] = true; + } + + // Load the allowed biomes into m_IsBiomeAllowed + for (BiomeList::iterator itr = a_Biomes.begin(); itr != a_Biomes.end(); ++itr) + { + m_IsBiomeAllowed[*itr] = true; + } } protected: cNoise m_Noise; BLOCKTYPE m_BlockType; int m_Amount; ///< Relative amount of blocks to try adding. 1 = one block per 256 biome columns. - - BlockList m_AllowedBelow; - BiomeList m_Biomes; int GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap); // Returns true if the given biome is a biome that is allowed. - bool IsAllowedBiome(EMCSBiome a_Biome) + inline bool IsAllowedBiome(EMCSBiome a_Biome) { - for (BiomeList::iterator itr = m_Biomes.begin(); itr != m_Biomes.end(); ++itr) - { - if (a_Biome == *itr) - { - return true; - } - } - return false; + return m_IsBiomeAllowed[a_Biome]; } // Returns true if the given blocktype may be below m_BlockType - bool IsAllowedBlockBelow(BLOCKTYPE a_BlockBelow) + inline bool IsAllowedBlockBelow(BLOCKTYPE a_BlockBelow) { - for (BlockList::iterator itr = m_AllowedBelow.begin(); itr != m_AllowedBelow.end(); ++itr) - { - if (*itr == a_BlockBelow) - { - return true; - } - } - return false; + return m_IsAllowedBelow[a_BlockBelow]; } -- cgit v1.2.3 From 57bb03148af3ad2adf2e613cf11ec8bc1852e00e Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 29 Jul 2014 13:13:23 +0200 Subject: SingleTopBlock: All blocktypes and biometypes get initialized properly --- src/Generating/FinishGen.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index a856b2cda..2500ab344 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -161,13 +161,25 @@ public: m_Noise(a_Seed), m_BlockType(a_BlockType), m_Amount(a_Amount) - { + { + // Initialize all the block types. + for (int idx = 0; idx < ARRAYCOUNT(m_IsAllowedBelow); ++idx) + { + m_IsAllowedBelow[idx] = false; + } + // Load the allowed blocks into m_IsAllowedBelow for (BlockList::iterator itr = a_AllowedBelow.begin(); itr != a_AllowedBelow.end(); ++itr) { m_IsAllowedBelow[*itr] = true; } - + + // Initialize all the biome types. + for (int idx = 0; idx < ARRAYCOUNT(m_IsBiomeAllowed); ++idx) + { + m_IsBiomeAllowed[idx] = false; + } + // Load the allowed biomes into m_IsBiomeAllowed for (BiomeList::iterator itr = a_Biomes.begin(); itr != a_Biomes.end(); ++itr) { -- cgit v1.2.3 From c8c01b055d49496f1e0ed340b816dfc57f9edd68 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 29 Jul 2014 15:24:11 +0200 Subject: Fixed comment above cFinishGenSingleTopBlock --- src/Generating/FinishGen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 4c99c7f86..842c9ccc5 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -454,7 +454,7 @@ void cFinishGenIce::GenFinish(cChunkDesc & a_ChunkDesc) //////////////////////////////////////////////////////////////////////////////// -// cFinishGenLilypads: +// cFinishGenSingleTopBlock: int cFinishGenSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap) { -- cgit v1.2.3 From 4ccf14f3b3f7deb19a32afd4253c506d5a224c54 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 29 Jul 2014 17:01:15 +0200 Subject: Some finishing touches Removed whitespace fixed dead bush comment --- src/Generating/ComposableGenerator.cpp | 2 +- src/Generating/FinishGen.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index a8c1a842f..5231b499f 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -335,7 +335,7 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) AllowedBiomes.push_back(biMesaPlateauFM); AllowedBiomes.push_back(biMesaPlateauM); - // A list with all the allowed blocks that can be below the lilypad. + // A list with all the allowed blocks that can be below the dead bush. cFinishGenSingleTopBlock::BlockList AllowedBlocks; AllowedBlocks.push_back(E_BLOCK_SAND); AllowedBlocks.push_back(E_BLOCK_HARDENED_CLAY); diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 2500ab344..ed32768b3 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -161,7 +161,7 @@ public: m_Noise(a_Seed), m_BlockType(a_BlockType), m_Amount(a_Amount) - { + { // Initialize all the block types. for (int idx = 0; idx < ARRAYCOUNT(m_IsAllowedBelow); ++idx) { -- cgit v1.2.3 From cb77b39dc6ff19698c504525259aa2c3170aadae Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 29 Jul 2014 16:36:24 +0100 Subject: Detrailed whitespace --- src/Entities/Entity.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 261afd89d..da578013d 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -617,7 +617,7 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk) // Handle drowning HandleAir(); - } + } if (!DetectPortal()) // Our chunk is invalid if we have moved to another world { @@ -1129,7 +1129,7 @@ bool cEntity::DetectPortal() cPlayer * Player = (cPlayer *)this; Player->TeleportToCoords(Player->GetLastBedPos().x, Player->GetLastBedPos().y, Player->GetLastBedPos().z); Player->GetClientHandle()->SendRespawn(dimOverworld); - } + } return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false); } @@ -1146,7 +1146,7 @@ bool cEntity::DetectPortal() { ((cPlayer *)this)->AwardAchievement(achEnterTheEnd); ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimEnd); - } + } return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetEndWorldName(), dimEnd, GetWorld()->GetName()), false); } -- cgit v1.2.3 From 4f5d73b7704e351365a987b421c35f1384afa240 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 29 Jul 2014 20:50:30 +0100 Subject: Slight cleanup after portals --- src/Bindings/PluginManager.cpp | 8 +++----- src/ClientHandle.cpp | 3 +-- src/Entities/Player.cpp | 2 +- src/Generating/CompoGen.cpp | 2 +- src/World.cpp | 6 ++++-- src/World.h | 5 +++-- src/WorldStorage/NBTChunkSerializer.cpp | 1 - src/WorldStorage/WSSAnvil.cpp | 7 +------ 8 files changed, 14 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 088b92a6d..3560b8660 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -476,11 +476,9 @@ bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_ENTITY_ADD_EFFECT); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_ENTITY_ADD_EFFECT); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnEntityAddEffect(a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier)) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index aaed483e2..b390bf2d6 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -120,8 +120,7 @@ cClientHandle::~cClientHandle() } if (World != NULL) { - m_Player->SetWorldTravellingFrom(NULL); // Make sure that the player entity is actually removed - World->RemovePlayer(m_Player); // Must be called before cPlayer::Destroy() as otherwise cChunk tries to delete the player, and then we do it again + World->RemovePlayer(m_Player, true); // Must be called before cPlayer::Destroy() as otherwise cChunk tries to delete the player, and then we do it again m_Player->Destroy(); } delete m_Player; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index ffdcca2ec..cf3322968 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1627,7 +1627,7 @@ bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) // Remove player from the old world SetWorldTravellingFrom(GetWorld()); // cChunk handles entity removal - GetWorld()->RemovePlayer(this); + GetWorld()->RemovePlayer(this, false); // Queue adding player to the new world, including all the necessary adjustments to the object a_World->AddPlayer(this); diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 912d74248..178673e32 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -638,7 +638,7 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) CeilingDisguise = -CeilingDisguise; } - int CeilingDisguiseHeight = Height - 2 - CeilingDisguise * 3; + int CeilingDisguiseHeight = Height - 2 - (int)CeilingDisguise * 3; for (int y = Height - 1; y > CeilingDisguiseHeight; y--) { diff --git a/src/World.cpp b/src/World.cpp index 0b0f7870b..84c0f2b93 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2465,10 +2465,12 @@ void cWorld::AddPlayer(cPlayer * a_Player) -void cWorld::RemovePlayer(cPlayer * a_Player) +void cWorld::RemovePlayer(cPlayer * a_Player, bool a_RemoveFromChunk) { - if (!a_Player->IsWorldTravellingFrom(this)) + if (a_RemoveFromChunk) { + // To prevent iterator invalidations when an entity goes through a portal and calls this function whilst being ticked by cChunk + // we should not change cChunk's entity list if asked not to m_ChunkMap->RemoveEntity(a_Player); } { diff --git a/src/World.h b/src/World.h index 4bf5a9d64..6649c4163 100644 --- a/src/World.h +++ b/src/World.h @@ -281,8 +281,9 @@ public: /** Removes the player from the world. Removes the player from the addition queue, too, if appropriate. - If the player has a ClientHandle, the ClientHandle is removed from all chunks in the world and will not be ticked by this world anymore. */ - void RemovePlayer(cPlayer * a_Player); + If the player has a ClientHandle, the ClientHandle is removed from all chunks in the world and will not be ticked by this world anymore. + @param a_RemoveFromChunk determines if the entity should be removed from its chunk as well. Should be false when ticking from cChunk. */ + void RemovePlayer(cPlayer * a_Player, bool a_RemoveFromChunk); /** Calls the callback for each player in the list; returns true if all players processed, false if the callback aborted by returning true */ virtual bool ForEachPlayer(cPlayerListCallback & a_Callback) override; // >> EXPORTED IN MANUALBINDINGS << diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index b7a3d40ce..4857da1b6 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -486,7 +486,6 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster) m_Writer.AddFloat("", a_Monster->GetDropChanceBoots()); m_Writer.EndList(); m_Writer.AddByte("CanPickUpLoot", (char)a_Monster->CanPickUpLoot()); - m_Writer.AddShort("Health", (short)a_Monster->GetHealth()); switch (a_Monster->GetMobType()) { case cMonster::mtBat: diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 6134e2c0a..71ff3ef99 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -2475,10 +2475,7 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N // Load health: int Health = a_NBT.FindChildByName(a_TagIdx, "Health"); - if (Health > 0) - { - a_Entity.SetHealth(a_NBT.GetShort(Health)); - } + a_Entity.SetHealth(Health > 0 ? a_NBT.GetShort(Health) : a_Entity.GetMaxHealth()); return true; } @@ -2507,8 +2504,6 @@ bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT & a_Monster.SetCanPickUpLoot(CanPickUpLoot); } - int HealthTag = a_NBT.FindChildByName(a_TagIdx, "Health"); - a_Monster.SetHealth(HealthTag > 0 ? a_NBT.GetShort(HealthTag) : a_Monster.GetMaxHealth()); return true; } -- cgit v1.2.3