From 3d68466ab03c3f7f2879451a57acba65ed5b197f Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 8 Aug 2014 18:55:05 +0200 Subject: Send the old slab to the client when the interact cancelled. --- src/Blocks/BlockSlab.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 214445eda..28fdbe7af 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -110,6 +110,17 @@ public: { return ((a_BlockType == E_BLOCK_WOODEN_SLAB) || (a_BlockType == E_BLOCK_STONE_SLAB)); } + + + 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 + { + if ((a_BlockFace == BLOCK_FACE_NONE) || (a_Player->GetEquippedItem().m_ItemType != (short)m_BlockType)) + { + return; + } + + a_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); + } /// Converts the single-slab blocktype to its equivalent double-slab blocktype -- cgit v1.2.3 From ebfc0fdc676eb4e0e99fc59ab6da6919fa2ef471 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 8 Aug 2014 22:04:53 +0200 Subject: Added comment. --- src/Blocks/BlockSlab.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 28fdbe7af..49f00c88c 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -119,6 +119,9 @@ public: return; } + /* Sends the slab back to the client. + The normal back sending adds the block face to the locations, but this don't work because the Y-Coordinate with the block face + is one higher than the real slab position. */ a_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); } -- cgit v1.2.3 From 5eb5411f1e9f3683e8ecb6448877ba6cf34b2dbf Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 10 Aug 2014 11:06:04 +0200 Subject: Removed an old and outdated comment. --- src/Generating/FinishGen.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index e8324095e..eb57a5faa 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -484,8 +484,6 @@ int cFinishGenSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap void cFinishGenSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc) { - // Add Lilypads on top of water surface in Swampland - int NumToGen = GetNumToGen(a_ChunkDesc.GetBiomeMap()); int ChunkX = a_ChunkDesc.GetChunkX(); int ChunkZ = a_ChunkDesc.GetChunkZ(); -- cgit v1.2.3 From ecfae286064b4a8fcf6e4df38c09e8055e83de33 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 10 Aug 2014 11:40:33 +0200 Subject: Changed cStructGenOreNests to take a list of ores + the block to replace. --- src/Generating/ComposableGenerator.cpp | 52 +++++++++++++++++++++++++++++- src/Generating/StructGen.cpp | 58 ++++++---------------------------- src/Generating/StructGen.h | 26 ++++++++++++--- 3 files changed, 83 insertions(+), 53 deletions(-) diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index cedb9aeb7..79a92171f 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -400,7 +400,57 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "OreNests") == 0) { - m_FinishGens.push_back(new cStructGenOreNests(Seed)); + cStructGenOreNests::OreList Ores; + + // Coal vein + cStructGenOreNests::OreInfo CoalVein; + CoalVein.BlockType = E_BLOCK_COAL_ORE; + CoalVein.MaxHeight = 127; + CoalVein.NumNests = 50; + CoalVein.NestSize = 10; + Ores.push_back(CoalVein); + + // Iron vein + cStructGenOreNests::OreInfo IronVein; + IronVein.BlockType = E_BLOCK_IRON_ORE; + IronVein.MaxHeight = 64; + IronVein.NumNests = 14; + IronVein.NestSize = 6; + Ores.push_back(IronVein); + + // Gold vein + cStructGenOreNests::OreInfo GoldVein; + GoldVein.BlockType = E_BLOCK_GOLD_ORE; + GoldVein.MaxHeight = 32; + GoldVein.NumNests = 2; + GoldVein.NestSize = 6; + Ores.push_back(GoldVein); + + // Redstone vein + cStructGenOreNests::OreInfo RedstoneVein; + RedstoneVein.BlockType = E_BLOCK_REDSTONE_ORE; + RedstoneVein.MaxHeight = 16; + RedstoneVein.NumNests = 4; + RedstoneVein.NestSize = 6; + Ores.push_back(RedstoneVein); + + // Lapis vein + cStructGenOreNests::OreInfo LapisVein; + LapisVein.BlockType = E_BLOCK_LAPIS_ORE; + LapisVein.MaxHeight = 30; + LapisVein.NumNests = 2; + LapisVein.NestSize = 5; + Ores.push_back(LapisVein); + + // Diamond vein + cStructGenOreNests::OreInfo DiamondVein; + DiamondVein.BlockType = E_BLOCK_DIAMOND_ORE; + DiamondVein.MaxHeight = 15; + DiamondVein.NumNests = 1; + DiamondVein.NestSize = 4; + Ores.push_back(DiamondVein); + + m_FinishGens.push_back(new cStructGenOreNests(Seed, Ores, E_BLOCK_STONE)); } else if (NoCaseCompare(*itr, "POCPieces") == 0) { diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp index f7e609353..1a43f2b2e 100644 --- a/src/Generating/StructGen.cpp +++ b/src/Generating/StructGen.cpp @@ -12,45 +12,6 @@ -//////////////////////////////////////////////////////////////////////////////// -// cStructGenOreNests configuration: - -const int MAX_HEIGHT_COAL = 127; -const int NUM_NESTS_COAL = 50; -const int NEST_SIZE_COAL = 10; - -const int MAX_HEIGHT_IRON = 64; -const int NUM_NESTS_IRON = 14; -const int NEST_SIZE_IRON = 6; - -const int MAX_HEIGHT_REDSTONE = 16; -const int NUM_NESTS_REDSTONE = 4; -const int NEST_SIZE_REDSTONE = 6; - -const int MAX_HEIGHT_GOLD = 32; -const int NUM_NESTS_GOLD = 2; -const int NEST_SIZE_GOLD = 6; - -const int MAX_HEIGHT_DIAMOND = 15; -const int NUM_NESTS_DIAMOND = 1; -const int NEST_SIZE_DIAMOND = 4; - -const int MAX_HEIGHT_LAPIS = 30; -const int NUM_NESTS_LAPIS = 2; -const int NEST_SIZE_LAPIS = 5; - -const int MAX_HEIGHT_DIRT = 127; -const int NUM_NESTS_DIRT = 20; -const int NEST_SIZE_DIRT = 32; - -const int MAX_HEIGHT_GRAVEL = 70; -const int NUM_NESTS_GRAVEL = 15; -const int NEST_SIZE_GRAVEL = 32; - - - - - //////////////////////////////////////////////////////////////////////////////// // cStructGenTrees: @@ -311,14 +272,15 @@ void cStructGenOreNests::GenFinish(cChunkDesc & a_ChunkDesc) int ChunkX = a_ChunkDesc.GetChunkX(); int ChunkZ = a_ChunkDesc.GetChunkZ(); cChunkDef::BlockTypes & BlockTypes = a_ChunkDesc.GetBlockTypes(); - GenerateOre(ChunkX, ChunkZ, E_BLOCK_COAL_ORE, MAX_HEIGHT_COAL, NUM_NESTS_COAL, NEST_SIZE_COAL, BlockTypes, 1); - GenerateOre(ChunkX, ChunkZ, E_BLOCK_IRON_ORE, MAX_HEIGHT_IRON, NUM_NESTS_IRON, NEST_SIZE_IRON, BlockTypes, 2); - GenerateOre(ChunkX, ChunkZ, E_BLOCK_REDSTONE_ORE, MAX_HEIGHT_REDSTONE, NUM_NESTS_REDSTONE, NEST_SIZE_REDSTONE, BlockTypes, 3); - GenerateOre(ChunkX, ChunkZ, E_BLOCK_GOLD_ORE, MAX_HEIGHT_GOLD, NUM_NESTS_GOLD, NEST_SIZE_GOLD, BlockTypes, 4); - GenerateOre(ChunkX, ChunkZ, E_BLOCK_DIAMOND_ORE, MAX_HEIGHT_DIAMOND, NUM_NESTS_DIAMOND, NEST_SIZE_DIAMOND, BlockTypes, 5); - GenerateOre(ChunkX, ChunkZ, E_BLOCK_LAPIS_ORE, MAX_HEIGHT_LAPIS, NUM_NESTS_LAPIS, NEST_SIZE_LAPIS, BlockTypes, 6); - GenerateOre(ChunkX, ChunkZ, E_BLOCK_DIRT, MAX_HEIGHT_DIRT, NUM_NESTS_DIRT, NEST_SIZE_DIRT, BlockTypes, 10); - GenerateOre(ChunkX, ChunkZ, E_BLOCK_GRAVEL, MAX_HEIGHT_GRAVEL, NUM_NESTS_GRAVEL, NEST_SIZE_GRAVEL, BlockTypes, 11); + + int seq = 1; + + // Generate the ores from the ore list. + for (OreList::iterator itr = m_OreList.begin(); itr != m_OreList.end(); ++itr) + { + GenerateOre(ChunkX, ChunkZ, itr->BlockType, itr->MaxHeight, itr->NumNests, itr->NestSize, BlockTypes, seq); + seq++; + } } @@ -376,7 +338,7 @@ void cStructGenOreNests::GenerateOre(int a_ChunkX, int a_ChunkZ, BLOCKTYPE a_Ore } int Index = cChunkDef::MakeIndexNoCheck(BlockX, BlockY, BlockZ); - if (a_BlockTypes[Index] == E_BLOCK_STONE) + if (a_BlockTypes[Index] == m_ToReplace) { a_BlockTypes[Index] = a_OreType; } diff --git a/src/Generating/StructGen.h b/src/Generating/StructGen.h index 9176bc192..e2fe8bc1a 100644 --- a/src/Generating/StructGen.h +++ b/src/Generating/StructGen.h @@ -76,11 +76,29 @@ class cStructGenOreNests : public cFinishGen { public: - cStructGenOreNests(int a_Seed) : m_Noise(a_Seed), m_Seed(a_Seed) {} - + struct OreInfo + { + BLOCKTYPE BlockType; // The type of the nest. + int MaxHeight; // The highest possible a nest can occur + int NumNests; // How many nests per chunk + int NestSize; // The amount of blocks a nest can have. + }; + + typedef std::vector OreList; + + cStructGenOreNests(int a_Seed, OreList a_OreList, BLOCKTYPE a_ToReplace) : + m_Noise(a_Seed), + m_Seed(a_Seed), + m_OreList(a_OreList), + m_ToReplace(a_ToReplace) + {} + protected: - cNoise m_Noise; - int m_Seed; + cNoise m_Noise; + int m_Seed; + + OreList m_OreList; // A list of possible ores. + BLOCKTYPE m_ToReplace; // cFinishGen override: virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; -- cgit v1.2.3 From 0ac3c67a21ae6fbd060322d65fcdad4f98148567 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 10 Aug 2014 11:48:05 +0200 Subject: Added NetherOreNests. It generates Nether Quarts. --- src/Generating/ComposableGenerator.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 79a92171f..1ae86a29f 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -398,6 +398,21 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) int MaxDepth = a_IniFile.GetValueSetI("Generator", "NetherFortsMaxDepth", 12); m_FinishGens.push_back(new cNetherFortGen(Seed, GridSize, MaxOffset, MaxDepth)); } + else if (NoCaseCompare(*itr, "NetherOreNests") == 0) + { + cStructGenOreNests::OreList Ores; + + // Quarts vein + cStructGenOreNests::OreInfo QuartsVein; + QuartsVein.BlockType = E_BLOCK_NETHER_QUARTZ_ORE; + QuartsVein.MaxHeight = 255; + QuartsVein.NumNests = 80; + QuartsVein.NestSize = 8; + Ores.push_back(QuartsVein); + + m_FinishGens.push_back(new cStructGenOreNests(Seed, Ores, E_BLOCK_NETHERRACK)); + + } else if (NoCaseCompare(*itr, "OreNests") == 0) { cStructGenOreNests::OreList Ores; -- cgit v1.2.3 From e529401dbb6d9c6de3b5e81b3308a478fe1a36db Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 10 Aug 2014 11:57:05 +0200 Subject: Added NaturalPatches generator It generates gravel and dirt. --- src/Generating/ComposableGenerator.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 1ae86a29f..58ad8fc2e 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -387,6 +387,28 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) m_FinishGens.push_back(new cFinishGenSingleTopBlock(Seed, E_BLOCK_LILY_PAD, AllowedBiomes, 4, AllowedBlocks)); } + else if (NoCaseCompare(*itr, "NaturalPatches") == 0) + { + cStructGenOreNests::OreList Ores; + + // Dirt vein + cStructGenOreNests::OreInfo DirtVein; + DirtVein.BlockType = E_BLOCK_DIRT; + DirtVein.MaxHeight = 127; + DirtVein.NumNests = 20; + DirtVein.NestSize = 32; + Ores.push_back(DirtVein); + + // Gravel vein + cStructGenOreNests::OreInfo GravelVein; + GravelVein.BlockType = E_BLOCK_DIRT; + GravelVein.MaxHeight = 127; + GravelVein.NumNests = 20; + GravelVein.NestSize = 32; + Ores.push_back(GravelVein); + + m_FinishGens.push_back(new cStructGenOreNests(Seed, Ores, E_BLOCK_STONE)); + } else if (NoCaseCompare(*itr, "NetherClumpFoliage") == 0) { m_FinishGens.push_back(new cFinishGenNetherClumpFoliage(Seed)); -- cgit v1.2.3 From ae611563919d123a93d6aab0eaf20c7423acce23 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 10 Aug 2014 17:08:22 +0200 Subject: Fixed swing arm animation when you ate. --- src/Entities/Player.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index d1d7349a6..8fa060a5d 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -601,7 +601,6 @@ void cPlayer::FinishEating(void) // Send the packets: m_ClientHandle->SendEntityStatus(*this, esPlayerEatingAccepted); - m_World->BroadcastEntityAnimation(*this, 0); m_World->BroadcastEntityMetadata(*this); // consume the item: @@ -619,8 +618,8 @@ void cPlayer::FinishEating(void) // 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); + cItem EmptyBowl(E_ITEM_BOWL); + GetInventory().AddItem(EmptyBowl, true, true); } } @@ -631,7 +630,6 @@ void cPlayer::FinishEating(void) void cPlayer::AbortEating(void) { m_EatingFinishTick = -1; - m_World->BroadcastEntityAnimation(*this, 0); m_World->BroadcastEntityMetadata(*this); } -- cgit v1.2.3 From 938bf1df69ae88ecdd85029d20bfd09d4fbf7618 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 10 Aug 2014 17:12:08 +0200 Subject: Changed comment. --- src/Blocks/BlockSlab.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 49f00c88c..e67f0e8b3 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -119,9 +119,7 @@ public: return; } - /* Sends the slab back to the client. - The normal back sending adds the block face to the locations, but this don't work because the Y-Coordinate with the block face - is one higher than the real slab position. */ + // Sends the slab back to the client. It's to refuse a doubleslab placement. a_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); } -- cgit v1.2.3 From 63a07b7ffc0d34beba6752c3c1f4f5771eb2c36b Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 10 Aug 2014 20:47:16 +0100 Subject: Fixed potential crash in Player.cpp Fixes CID 71780 If ShouldBroadcastDeathMessages is false the pointer would fall through to a check agaist it being a player --- src/Entities/Player.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 8fa060a5d..8667344c7 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -906,6 +906,10 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) } GetWorld()->BroadcastChatDeath(Printf("%s %s", GetName().c_str(), DamageText.c_str())); } + else if (a_TDI.Attacker == NULL) // && !m_World->ShouldBroadcastDeathMessages() by fallthrough + { + // no-op + } else if (a_TDI.Attacker->IsPlayer()) { cPlayer * Killer = (cPlayer *)a_TDI.Attacker; -- cgit v1.2.3 From 07103ed9d7af1c37623d6c8c96ec5084938c244b Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 10 Aug 2014 21:26:28 +0100 Subject: Spaces --- src/Entities/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 8667344c7..608316e9a 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -906,7 +906,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) } GetWorld()->BroadcastChatDeath(Printf("%s %s", GetName().c_str(), DamageText.c_str())); } - else if (a_TDI.Attacker == NULL) // && !m_World->ShouldBroadcastDeathMessages() by fallthrough + else if (a_TDI.Attacker == NULL) // && !m_World->ShouldBroadcastDeathMessages() by fallthrough { // no-op } -- cgit v1.2.3 From d95768d01a93a14df38f6e0e33ca180b779c5df0 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 10 Aug 2014 22:36:02 +0200 Subject: Bunch of tweaks: Renamed Quarts to Quartz Using const_iterator instead of iterator Used CheckBasicStyle script to find style errors --- src/Generating/ComposableGenerator.cpp | 14 +++++++------- src/Generating/StructGen.cpp | 2 +- src/Generating/StructGen.h | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 58ad8fc2e..2f575fe27 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -424,13 +424,13 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) { cStructGenOreNests::OreList Ores; - // Quarts vein - cStructGenOreNests::OreInfo QuartsVein; - QuartsVein.BlockType = E_BLOCK_NETHER_QUARTZ_ORE; - QuartsVein.MaxHeight = 255; - QuartsVein.NumNests = 80; - QuartsVein.NestSize = 8; - Ores.push_back(QuartsVein); + // Quartz vein + cStructGenOreNests::OreInfo QuartzVein; + QuartzVein.BlockType = E_BLOCK_NETHER_QUARTZ_ORE; + QuartzVein.MaxHeight = 255; + QuartzVein.NumNests = 80; + QuartzVein.NestSize = 8; + Ores.push_back(QuartzVein); m_FinishGens.push_back(new cStructGenOreNests(Seed, Ores, E_BLOCK_NETHERRACK)); diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp index 1a43f2b2e..731324b0d 100644 --- a/src/Generating/StructGen.cpp +++ b/src/Generating/StructGen.cpp @@ -276,7 +276,7 @@ void cStructGenOreNests::GenFinish(cChunkDesc & a_ChunkDesc) int seq = 1; // Generate the ores from the ore list. - for (OreList::iterator itr = m_OreList.begin(); itr != m_OreList.end(); ++itr) + for (OreList::const_iterator itr = m_OreList.begin(); itr != m_OreList.end(); ++itr) { GenerateOre(ChunkX, ChunkZ, itr->BlockType, itr->MaxHeight, itr->NumNests, itr->NestSize, BlockTypes, seq); seq++; diff --git a/src/Generating/StructGen.h b/src/Generating/StructGen.h index e2fe8bc1a..55d5bc1c7 100644 --- a/src/Generating/StructGen.h +++ b/src/Generating/StructGen.h @@ -78,16 +78,16 @@ class cStructGenOreNests : public: struct OreInfo { - BLOCKTYPE BlockType; // The type of the nest. - int MaxHeight; // The highest possible a nest can occur - int NumNests; // How many nests per chunk - int NestSize; // The amount of blocks a nest can have. + BLOCKTYPE BlockType; // The type of the nest. + int MaxHeight; // The highest possible a nest can occur + int NumNests; // How many nests per chunk + int NestSize; // The amount of blocks a nest can have. }; typedef std::vector OreList; - cStructGenOreNests(int a_Seed, OreList a_OreList, BLOCKTYPE a_ToReplace) : - m_Noise(a_Seed), + cStructGenOreNests(int a_Seed, OreList a_OreList, BLOCKTYPE a_ToReplace) : + m_Noise(a_Seed), m_Seed(a_Seed), m_OreList(a_OreList), m_ToReplace(a_ToReplace) @@ -97,7 +97,7 @@ protected: cNoise m_Noise; int m_Seed; - OreList m_OreList; // A list of possible ores. + OreList m_OreList; // A list of possible ores. BLOCKTYPE m_ToReplace; // cFinishGen override: -- cgit v1.2.3 From 5623a045f598a068a7bae77cc3acad62f6160452 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 10 Aug 2014 22:06:56 +0100 Subject: Fixed potential null dereference Fixes CID 70466 --- src/BlockEntities/HopperEntity.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index 48d3b8dcc..88e7b8e1b 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -549,13 +549,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: - cChestEntity * Chest = (cChestEntity *)a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ); - if (Chest == NULL) + cChestEntity * ConnectedChest = (cChestEntity *)a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ); + if (ConnectedChest == 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)) + if (MoveItemsToGrid(*ConnectedChest)) { // Chest block directly connected was not full return true; @@ -586,13 +586,13 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block } BLOCKTYPE Block = Neighbor->GetBlock(x, a_BlockY, z); - if (Block != Chest->GetBlockType()) + if (Block != ConnectedChest->GetBlockType()) { // Not the same kind of chest continue; } - Chest = (cChestEntity *)Neighbor->GetBlockEntity(a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z); + cChestEntity * 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); -- cgit v1.2.3 From df96f437a3802ffeb36c1fefca3d2674bbb94079 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 10 Aug 2014 22:15:52 +0100 Subject: Fixed circular dependecy luaState_Call.inc --- src/Bindings/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index a2b381a26..54152668a 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -45,7 +45,6 @@ set(BINDING_DEPENDENCIES ../Bindings/AllToLua.pkg ../Bindings/gen_LuaState_Call.lua ../Bindings/LuaFunctions.h - ../Bindings/LuaState_Call.inc ../Bindings/LuaWindow.h ../Bindings/Plugin.h ../Bindings/PluginLua.h @@ -128,6 +127,7 @@ if (NOT MSVC) endif () set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES GENERATED TRUE) set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE) +set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/LuaState_Call.inc PROPERTIES GENERATED TRUE) if(NOT MSVC) add_library(Bindings ${SRCS} ${HDRS}) -- cgit v1.2.3 From dba672361164dc5dc5f94d24bde3176c7de89d4c Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 2 Aug 2014 22:42:53 -0700 Subject: Player.cpp: change unnamed enum to constant integers --- src/Entities/Player.cpp | 2 +- src/Entities/Player.h | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 608316e9a..91bcddca3 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -509,7 +509,7 @@ void cPlayer::Heal(int a_Health) void cPlayer::SetFoodLevel(int a_FoodLevel) { - int FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL)); + int FoodLevel = Clamp(a_FoodLevel, 0, MAX_FOOD_LEVEL); if (cRoot::Get()->GetPluginManager()->CallHookPlayerFoodLevelChange(*this, FoodLevel)) { diff --git a/src/Entities/Player.h b/src/Entities/Player.h index e26808bfc..f345a0207 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -29,12 +29,13 @@ class cPlayer : typedef cPawn super; public: - enum - { - MAX_HEALTH = 20, - MAX_FOOD_LEVEL = 20, - EATING_TICKS = 30, ///< Number of ticks it takes to eat an item - } ; + static const int MAX_HEALTH = 20; + + static const int MAX_FOOD_LEVEL = 20; + + /** Number of ticks it takes to eat an item */ + static const int EATING_TICKS = 30; + // tolua_end CLASS_PROTODEF(cPlayer) -- cgit v1.2.3 From 92f67789fc24572092a70d582aef22d7ef1dd272 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 2 Aug 2014 22:56:08 -0700 Subject: Gave names to unnamed enums --- src/Enchantments.h | 2 +- src/HTTPServer/HTTPMessage.h | 2 +- src/Inventory.h | 4 ++-- src/Protocol/Protocol125.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Enchantments.h b/src/Enchantments.h index 98d7c0d36..824f6aa55 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -43,7 +43,7 @@ public: /** Individual enchantment IDs, corresponding to their NBT IDs: http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs */ - enum + enum eEnchantment { enchProtection = 0, enchFireProtection = 1, diff --git a/src/HTTPServer/HTTPMessage.h b/src/HTTPServer/HTTPMessage.h index e402c8ad6..c0667030f 100644 --- a/src/HTTPServer/HTTPMessage.h +++ b/src/HTTPServer/HTTPMessage.h @@ -18,7 +18,7 @@ class cHTTPMessage { public: - enum + enum eStatus { HTTP_OK = 200, HTTP_BAD_REQUEST = 400, diff --git a/src/Inventory.h b/src/Inventory.h index ed134aee4..5628fb0da 100644 --- a/src/Inventory.h +++ b/src/Inventory.h @@ -39,8 +39,8 @@ public: enum { invArmorCount = 4, - invInventoryCount = 9 * 3, - invHotbarCount = 9, + invInventoryCount = 9 * 3, + invHotbarCount = 9, invArmorOffset = 0, invInventoryOffset = invArmorOffset + invArmorCount, diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 18efeb079..3adac3055 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -103,7 +103,7 @@ public: protected: /// Results of packet-parsing: - enum + enum eParseResult { PARSE_OK = 1, PARSE_ERROR = -1, -- cgit v1.2.3 From a7eb4032ee32f8299857ccdfc4ad9f45227abb05 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 10 Aug 2014 17:13:14 -0700 Subject: Fixed tolua error with static initialization --- src/Entities/Player.cpp | 9 +++++++++ src/Entities/Player.h | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 91bcddca3..4398a5bf3 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -33,6 +33,15 @@ +const int cPlayer::MAX_HEALTH = 20; + +const int cPlayer::MAX_FOOD_LEVEL = 20; + +/** Number of ticks it takes to eat an item */ +const int cPlayer::EATING_TICKS = 30; + + + cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) : diff --git a/src/Entities/Player.h b/src/Entities/Player.h index f345a0207..d3ed1ef9d 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -29,12 +29,12 @@ class cPlayer : typedef cPawn super; public: - static const int MAX_HEALTH = 20; + static const int MAX_HEALTH; - static const int MAX_FOOD_LEVEL = 20; + static const int MAX_FOOD_LEVEL; /** Number of ticks it takes to eat an item */ - static const int EATING_TICKS = 30; + static const int EATING_TICKS; // tolua_end -- cgit v1.2.3 From 0a52ed6eb97ca5cc08fe255bfd04f78b4ea19a7e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 11 Aug 2014 15:33:20 +0200 Subject: cProtocol172: Check return values. Fixes CID 43489, CID 43490, CID 43491, CID 43493, CID 66410, CID 66411, CID 66416, CID 66417, CID 66418, CID 66419, CID 66420, CID 66421, CID 66422, CID 66423, CID 66424, CID 66425, CID 66429, CID 66430, CID 66431 --- src/Protocol/Protocol17x.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 318342f09..1f8ca00bb 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -48,7 +48,10 @@ Implements the 1.7.x protocol classes: #define HANDLE_READ(ByteBuf, Proc, Type, Var) \ Type Var; \ - ByteBuf.Proc(Var); + if (!ByteBuf.Proc(Var))\ + {\ + return;\ + } @@ -1700,8 +1703,7 @@ bool cProtocol172::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) void cProtocol172::HandlePacketStatusPing(cByteBuffer & a_ByteBuffer) { - Int64 Timestamp; - a_ByteBuffer.ReadBEInt64(Timestamp); + HANDLE_READ(a_ByteBuffer, ReadBEInt64, Int64, Timestamp); cPacketizer Pkt(*this, 0x01); // Ping packet Pkt.WriteInt64(Timestamp); @@ -2054,7 +2056,10 @@ void cProtocol172::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer) HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Channel); HANDLE_READ(a_ByteBuffer, ReadBEShort, short, Length); AString Data; - a_ByteBuffer.ReadString(Data, Length); + if (!a_ByteBuffer.ReadString(Data, Length)) + { + return; + } m_Client->HandlePluginMessage(Channel, Data); } -- cgit v1.2.3 From f7726317c9c1c27fa3d0b9b7c2df35ffff6f1f1a Mon Sep 17 00:00:00 2001 From: Christophe Piveteau Date: Mon, 11 Aug 2014 18:57:41 +0200 Subject: Add entry for bat in monsters.ini --- MCServer/monsters.ini | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MCServer/monsters.ini b/MCServer/monsters.ini index d29b01d8f..c4bc8c810 100644 --- a/MCServer/monsters.ini +++ b/MCServer/monsters.ini @@ -185,4 +185,10 @@ AttackDamage=6.0 SightDistance=25.0 MaxHealth=100 +[Bat] +AttackRange=2.0 +AttackRate=1 +AttackDamage=0.0 +SightDistance=25.0 +MaxHealth=6 -- cgit v1.2.3