From 7aabc1f5d8d0e97748413c646a019f11b4eba383 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 3 Sep 2013 14:54:50 +0200 Subject: [PATCH 1/6] Fixed the Win nightbuild script naming ini files badly (thx Tigerw). --- Nightbuild2008.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nightbuild2008.cmd b/Nightbuild2008.cmd index 0d93380e9..6de8d9f67 100644 --- a/Nightbuild2008.cmd +++ b/Nightbuild2008.cmd @@ -102,7 +102,7 @@ if errorlevel 1 goto haderror :: Copy all the example ini files into the Install folder for zipping: -copy MCServer\*.example.ini Install\*.example.ini +copy MCServer\*.example.ini Install\ :: Use 7-zip to compress the resulting files into a single file: set FILESUFFIX=%MYYEAR%_%MYMONTH%_%MYDAY%_%MYTIME%_%COMMITID% From a80be25c920a657b7be596ee9f42d2d2f8f0c5dc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 5 Sep 2013 15:22:16 +0200 Subject: [PATCH 2/6] Removed TimedWait from cEvent. Unsupported on MacOS. --- source/OSSupport/Event.cpp | 47 -------------------------------------- source/OSSupport/Event.h | 10 -------- 2 files changed, 57 deletions(-) diff --git a/source/OSSupport/Event.cpp b/source/OSSupport/Event.cpp index 32f780946..cbacbba17 100644 --- a/source/OSSupport/Event.cpp +++ b/source/OSSupport/Event.cpp @@ -116,50 +116,3 @@ void cEvent::Set(void) - -cEvent::eWaitResult cEvent::Wait(int a_TimeoutMilliSec) -{ - #ifdef _WIN32 - DWORD res = WaitForSingleObject(m_Event, (DWORD)a_TimeoutMilliSec); - switch (res) - { - case WAIT_OBJECT_0: - { - // The semaphore was signalled - return wrSignalled; - } - case WAIT_TIMEOUT: - { - // The timeout was hit - return wrTimeout; - } - default: - { - LOGWARNING("cEvent: timed-waiting for the event failed: %d, GLE = %d. Continuing, but server may be unstable.", res, GetLastError()); - return wrError; - } - } - #else - timespec timeout; - timeout.tv_sec = time(NULL) + a_TimeoutMilliSec / 1000; - timeout.tv_nsec = (a_TimeoutMilliSec % 1000) * 1000000; - int res = sem_timedwait(m_Event, &timeout); - if (res == 0) - { - // The semaphore was signalled - return wrSignalled; - } - int err = errno; - if (err == ETIMEDOUT) - { - // The timeout was hit - return wrTimeout; - } - LOGWARNING("cEvent: timed-waiting for the event failed: %i, errno = %i. Continuing, but server may be unstable.", res, err); - return wrError; - #endif -} - - - - diff --git a/source/OSSupport/Event.h b/source/OSSupport/Event.h index 803d73b7e..71f418c0c 100644 --- a/source/OSSupport/Event.h +++ b/source/OSSupport/Event.h @@ -19,22 +19,12 @@ class cEvent { public: - enum eWaitResult - { - wrSignalled, - wrTimeout, - wrError, - } ; - cEvent(void); ~cEvent(); void Wait(void); void Set (void); - /// Waits for the semaphore with a timeout - eWaitResult Wait(int a_TimeoutMilliSec); - private: #ifdef _WIN32 From e8d1ed36c5dcf92639ca5969213a58a6c6ed0dc0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 5 Sep 2013 22:40:08 +0200 Subject: [PATCH 3/6] Moved daylight burning directly into cMonster. --- source/Mobs/Monster.cpp | 36 ++++++++++++++++++++++++++++++++++++ source/Mobs/Monster.h | 7 +++++++ source/Mobs/Skeleton.cpp | 19 +------------------ source/Mobs/Skeleton.h | 1 - source/Mobs/Zombie.cpp | 20 +------------------- source/Mobs/Zombie.h | 3 +-- 6 files changed, 46 insertions(+), 40 deletions(-) diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 9ae91f1e0..11b530968 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -15,6 +15,7 @@ #include "../Vector3i.h" #include "../Vector3d.h" #include "../Tracer.h" +#include "../Chunk.h" // #include "../../iniFile/iniFile.h" @@ -100,6 +101,9 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) return; } + // Burning in daylight + HandleDaylightBurning(a_Chunk); + HandlePhysics(a_Dt,a_Chunk); BroadcastMovementUpdate(); @@ -473,3 +477,35 @@ void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned + +void cMonster::HandleDaylightBurning(cChunk & a_Chunk) +{ + if (!m_BurnsInDaylight) + { + return; + } + + int RelY = (int)floor(GetPosY()); + if ((RelY < 0) || (RelY >= cChunkDef::Height)) + { + // Outside the world + return; + } + + int RelX = (int)floor(GetPosX()) - a_Chunk.GetPosX() * cChunkDef::Width; + int RelZ = (int)floor(GetPosZ()) - a_Chunk.GetPosZ() * cChunkDef::Width; + if ( + (a_Chunk.GetSkyLight(RelX, RelY, RelZ) == 15) && // In the daylight + (a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand + (GetWorld()->GetTimeOfDay() < (12000 + 1000)) && // It is nighttime + !IsOnFire() // Not already burning + ) + { + // Burn for 100 ticks, then decide again + StartBurning(100); + } +} + + + + diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 755678d39..5f33d4450 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -107,6 +107,9 @@ public: void SetAttackDamage(float ad); void SetSightDistance(float sd); + /// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick + void SetBurnsInDaylight(bool a_BurnsInDaylight) { a_BurnsInDaylight = a_BurnsInDaylight; } + enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState; enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality; @@ -134,8 +137,12 @@ protected: float m_AttackDamage; float m_AttackRange; float m_AttackInterval; + + bool m_BurnsInDaylight; void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0); + + void HandleDaylightBurning(cChunk & a_Chunk); } ; // tolua_export diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp index ad4037db9..10dad4065 100644 --- a/source/Mobs/Skeleton.cpp +++ b/source/Mobs/Skeleton.cpp @@ -11,24 +11,7 @@ cSkeleton::cSkeleton(void) : super("Skeleton", 51, "mob.skeleton.hurt", "mob.skeleton.death", 0.6, 1.8) { -} - - - - - -void cSkeleton::Tick(float a_Dt, cChunk & a_Chunk) -{ - cMonster::Tick(a_Dt, a_Chunk); - - if ((GetWorld()->GetBlockSkyLight(GetPosX(), GetPosY(), GetPosZ()) == 15) && (GetWorld()->GetBlock(GetPosX(), GetPosY(), GetPosZ()) != E_BLOCK_SOULSAND)) - { - if ((GetWorld()->GetTimeOfDay() < (12000 + 1000)) && !IsOnFire()) - { - // Burn for 100 ticks, then decide again - StartBurning(100); - } - } + SetBurnsInDaylight(true); } diff --git a/source/Mobs/Skeleton.h b/source/Mobs/Skeleton.h index bc541bac2..d0a2da490 100644 --- a/source/Mobs/Skeleton.h +++ b/source/Mobs/Skeleton.h @@ -17,7 +17,6 @@ public: CLASS_PROTODEF(cSkeleton); - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Zombie.cpp b/source/Mobs/Zombie.cpp index f3adf1283..9b238baef 100644 --- a/source/Mobs/Zombie.cpp +++ b/source/Mobs/Zombie.cpp @@ -8,28 +8,10 @@ -// They're eating your brains! - cZombie::cZombie(void) : super("Zombie", 54, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8) { -} - - - - - -void cZombie::Tick(float a_Dt, cChunk & a_Chunk) -{ - super::Tick(a_Dt, a_Chunk); - if ((GetWorld()->GetBlockSkyLight(GetPosX(), GetPosY(), GetPosZ()) == 15) && (GetWorld()->GetBlock(GetPosX(), GetPosY(), GetPosZ()) != E_BLOCK_SOULSAND)) - { - if ((GetWorld()->GetTimeOfDay() < (12000 + 1000)) && !IsOnFire()) - { - // Burn for 100 ticks, then decide again - StartBurning(100); - } - } + SetBurnsInDaylight(true); } diff --git a/source/Mobs/Zombie.h b/source/Mobs/Zombie.h index 61f8e3bb8..4835a53c4 100644 --- a/source/Mobs/Zombie.h +++ b/source/Mobs/Zombie.h @@ -12,11 +12,10 @@ class cZombie : typedef cAggressiveMonster super; public: - cZombie(); + cZombie(void); CLASS_PROTODEF(cZombie); - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; } ; From f300ed54e5f53ed9e417d88eb63fd38e1979bacf Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 6 Sep 2013 00:04:49 +0200 Subject: [PATCH 4/6] Implemented SteerVehicle packet. --- source/ClientHandle.cpp | 9 +++++++++ source/ClientHandle.h | 1 + source/Entities/Entity.cpp | 33 +++++++++++++++++++++++++++------ source/Entities/Entity.h | 2 ++ source/Protocol/Protocol16x.cpp | 4 ++++ 5 files changed, 43 insertions(+), 6 deletions(-) diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index 357c07105..3d819ee18 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -1090,6 +1090,15 @@ void cClientHandle::HandleSlotSelected(short a_SlotNum) +void cClientHandle::HandleSteerVehicle(float a_Forward, float a_Sideways) +{ + m_Player->SteerVehicle(a_Forward, a_Sideways); +} + + + + + void cClientHandle::HandleWindowClose(char a_WindowID) { m_Player->CloseWindowIfID(a_WindowID); diff --git a/source/ClientHandle.h b/source/ClientHandle.h index 761cf25fe..9a2092361 100644 --- a/source/ClientHandle.h +++ b/source/ClientHandle.h @@ -177,6 +177,7 @@ public: void HandleRespawn (void); void HandleRightClick (int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, const cItem & a_HeldItem); void HandleSlotSelected (short a_SlotNum); + void HandleSteerVehicle (float Forward, float Sideways); void HandleTabCompletion (const AString & a_Text); void HandleUpdateSign ( int a_BlockX, int a_BlockY, int a_BlockZ, diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp index 56fd36a05..4066e81ab 100644 --- a/source/Entities/Entity.cpp +++ b/source/Entities/Entity.cpp @@ -546,22 +546,24 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) } else { + // TODO: This condition belongs to minecarts, without it, they derails too much. + // But it shouldn't be here for other entities. We need a complete minecart physics overhaul. if ( - (BlockBelow != E_BLOCK_RAIL) && - (BlockBelow != E_BLOCK_DETECTOR_RAIL) && - (BlockBelow != E_BLOCK_POWERED_RAIL) && + (BlockBelow != E_BLOCK_RAIL) && + (BlockBelow != E_BLOCK_DETECTOR_RAIL) && + (BlockBelow != E_BLOCK_POWERED_RAIL) && (BlockBelow != E_BLOCK_ACTIVATOR_RAIL) - ) + ) { // Friction if (NextSpeed.SqrLength() > 0.0004f) { - NextSpeed.x *= 0.7f / (1 + a_Dt); + NextSpeed.x *= 0.6666; if (fabs(NextSpeed.x) < 0.05) { NextSpeed.x = 0; } - NextSpeed.z *= 0.7f / (1 + a_Dt); + NextSpeed.z *= 0.6666; if (fabs(NextSpeed.z) < 0.05) { NextSpeed.z = 0; @@ -1225,6 +1227,25 @@ void cEntity::AddSpeedZ(double a_AddSpeedZ) +void cEntity::SteerVehicle(float a_Forward, float a_Sideways) +{ + if (m_AttachedTo == NULL) + { + return; + } + if ((a_Forward != 0) || (a_Sideways != 0)) + { + Vector3d LookVector = GetLookVector(); + double AddSpeedX = LookVector.x * a_Forward + LookVector.z * a_Sideways; + double AddSpeedZ = LookVector.z * a_Forward - LookVector.x * a_Sideways; + m_AttachedTo->AddSpeed(AddSpeedX, 0, AddSpeedZ); + } +} + + + + + ////////////////////////////////////////////////////////////////////////// // Get look vector (this is NOT a rotation!) Vector3d cEntity::GetLookVector(void) const diff --git a/source/Entities/Entity.h b/source/Entities/Entity.h index 2d058abae..b4777d249 100644 --- a/source/Entities/Entity.h +++ b/source/Entities/Entity.h @@ -185,6 +185,8 @@ public: void AddSpeedX (double a_AddSpeedX); void AddSpeedY (double a_AddSpeedY); void AddSpeedZ (double a_AddSpeedZ); + + void SteerVehicle(float a_Forward, float a_Sideways); inline int GetUniqueID(void) const { return m_UniqueID; } inline bool IsDestroyed(void) const { return !m_IsInitialized; } diff --git a/source/Protocol/Protocol16x.cpp b/source/Protocol/Protocol16x.cpp index 3a640da21..be5b45f19 100644 --- a/source/Protocol/Protocol16x.cpp +++ b/source/Protocol/Protocol16x.cpp @@ -213,6 +213,10 @@ int cProtocol161::ParseSteerVehicle(void) { m_Client->HandleUnmount(); } + else + { + m_Client->HandleSteerVehicle(Forward, Sideways); + } return PARSE_OK; } From c789a8ddf5840cf7861c73536279da8bbd9281c3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 8 Sep 2013 00:14:57 +0100 Subject: [PATCH 5/6] Initial boat support + Boats are saved + Boats have physics + Boats spawn --- source/Entities/Boat.cpp | 84 ++++++++++++++++++++++ source/Entities/Boat.h | 34 +++++++++ source/Items/ItemBoat.h | 54 ++++++++++++++ source/Items/ItemHandler.cpp | 6 ++ source/WorldStorage/NBTChunkSerializer.cpp | 16 +++++ source/WorldStorage/NBTChunkSerializer.h | 2 + source/WorldStorage/WSSAnvil.cpp | 21 +++++- source/WorldStorage/WSSAnvil.h | 1 + 8 files changed, 217 insertions(+), 1 deletion(-) create mode 100644 source/Entities/Boat.cpp create mode 100644 source/Entities/Boat.h create mode 100644 source/Items/ItemBoat.h diff --git a/source/Entities/Boat.cpp b/source/Entities/Boat.cpp new file mode 100644 index 000000000..f29766fc1 --- /dev/null +++ b/source/Entities/Boat.cpp @@ -0,0 +1,84 @@ + +// Minecart.cpp + +// Implements the cMinecart class representing a minecart in the world +// Indiana Jones! + +#include "Globals.h" +#include "Boat.h" +#include "../World.h" +#include "../ClientHandle.h" +#include "Player.h" + + + + + +cBoat::cBoat(double a_X, double a_Y, double a_Z) : + super(etBoat, a_X, a_Y, a_Z, 0.98, 0.7) +{ + SetMass(20.f); + SetMaxHealth(6); + SetHealth(6); +} + + + + +void cBoat::SpawnOn(cClientHandle & a_ClientHandle) +{ + a_ClientHandle.SendSpawnVehicle(*this, 1, 0); +} + + + + + +void cBoat::DoTakeDamage(TakeDamageInfo & TDI) +{ + super::DoTakeDamage(TDI); + + if (GetHealth() == 0) + { + Destroy(true); + } +} + + + + + +void cBoat::OnRightClicked(cPlayer & a_Player) +{ + if (m_Attachee != NULL) + { + if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID()) + { + // This player is already sitting in, they want out. + a_Player.Detach(); + return; + } + + if (m_Attachee->IsPlayer()) + { + // Another player is already sitting in here, cannot attach + return; + } + + // Detach whatever is sitting in this minecart now: + m_Attachee->Detach(); + } + + // Attach the player to this minecart + a_Player.AttachTo(this); +} + + + + + +void cBoat::HandlePhysics(float a_Dt, cChunk & a_Chunk) +{ + super::HandlePhysics(a_Dt, a_Chunk); + BroadcastMovementUpdate(); +} diff --git a/source/Entities/Boat.h b/source/Entities/Boat.h new file mode 100644 index 000000000..439b73a09 --- /dev/null +++ b/source/Entities/Boat.h @@ -0,0 +1,34 @@ + +// Boat.h + +// Declares the cBoat class representing a minecart in the world + + + + + +#pragma once + +#include "Entity.h" +#include "../Item.h" + + + + + +class cBoat : + public cEntity +{ + typedef cEntity super; + +public: + CLASS_PROTODEF(cBoat); + + // cEntity overrides: + virtual void SpawnOn(cClientHandle & a_ClientHandle) override; + virtual void OnRightClicked(cPlayer & a_Player) override; + virtual void DoTakeDamage(TakeDamageInfo & TDI) override; + virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override; + + cBoat(double a_X, double a_Y, double a_Z); +} ; \ No newline at end of file diff --git a/source/Items/ItemBoat.h b/source/Items/ItemBoat.h new file mode 100644 index 000000000..6e3395f1d --- /dev/null +++ b/source/Items/ItemBoat.h @@ -0,0 +1,54 @@ + +// ItemBoat.h + +// Declares the various boat ItemHandlers + + + + + +#pragma once + +#include "../Entities/Boat.h" + + + + + +class cItemBoatHandler : + public cItemHandler +{ + typedef cItemHandler super; + +public: + cItemBoatHandler(int a_ItemType) : + super(a_ItemType) + { + } + + + + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + { + if (a_Dir < 0) + { + return false; + } + + double x = (double)a_BlockX + 0.5; + double y = (double)a_BlockY + 0.5; + double z = (double)a_BlockZ + 0.5; + + cBoat * Boat = NULL; + + Boat = new cBoat (x, y, z); + Boat->Initialize(a_World); + + return true; + } + +} ; + + + + diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp index 2ae193d52..374d0ebf5 100644 --- a/source/Items/ItemHandler.cpp +++ b/source/Items/ItemHandler.cpp @@ -8,6 +8,7 @@ // Handlers: #include "ItemBed.h" +#include "ItemBoat.h" #include "ItemBow.h" #include "ItemBrewingStand.h" #include "ItemBucket.h" @@ -180,6 +181,11 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) return new cItemMinecartHandler(a_ItemType); } + case E_ITEM_BOAT: + { + return new cItemBoatHandler(a_ItemType); + } + // Food: case E_ITEM_BREAD: case E_ITEM_COOKIE: diff --git a/source/WorldStorage/NBTChunkSerializer.cpp b/source/WorldStorage/NBTChunkSerializer.cpp index baae0dc01..8b2d969f8 100644 --- a/source/WorldStorage/NBTChunkSerializer.cpp +++ b/source/WorldStorage/NBTChunkSerializer.cpp @@ -19,6 +19,7 @@ #include "../OSSupport/MakeDir.h" #include "FastNBT.h" #include "../Entities/FallingBlock.h" +#include "../Entities/Boat.h" #include "../Entities/Minecart.h" #include "../Mobs/Monster.h" #include "../Entities/Pickup.h" @@ -252,6 +253,20 @@ void cNBTChunkSerializer::AddBasicEntity(cEntity * a_Entity, const AString & a_C +void cNBTChunkSerializer::AddBoatEntity(cBoat * a_Boat) +{ + const char * EntityClass = NULL; + EntityClass = "Boat"; + + m_Writer.BeginCompound(""); + AddBasicEntity(a_Boat, EntityClass); + m_Writer.EndCompound(); +} + + + + + void cNBTChunkSerializer::AddFallingBlockEntity(cFallingBlock * a_FallingBlock) { m_Writer.BeginCompound(""); @@ -461,6 +476,7 @@ void cNBTChunkSerializer::Entity(cEntity * a_Entity) switch (a_Entity->GetEntityType()) { + case cEntity::etBoat: AddBoatEntity ((cBoat *) a_Entity); break; case cEntity::etFallingBlock: AddFallingBlockEntity((cFallingBlock *) a_Entity); break; case cEntity::etMinecart: AddMinecartEntity ((cMinecart *) a_Entity); break; case cEntity::etMonster: AddMonsterEntity ((cMonster *) a_Entity); break; diff --git a/source/WorldStorage/NBTChunkSerializer.h b/source/WorldStorage/NBTChunkSerializer.h index 481c578f3..9d4ac208c 100644 --- a/source/WorldStorage/NBTChunkSerializer.h +++ b/source/WorldStorage/NBTChunkSerializer.h @@ -19,6 +19,7 @@ class cFastNBTWriter; class cEntity; class cBlockEntity; +class cBoat; class cChestEntity; class cDispenserEntity; class cDropperEntity; @@ -94,6 +95,7 @@ protected: // Entities: void AddBasicEntity (cEntity * a_Entity, const AString & a_ClassName); + void AddBoatEntity (cBoat * a_Boat); void AddFallingBlockEntity(cFallingBlock * a_FallingBlock); void AddMinecartEntity (cMinecart * a_Minecart); void AddMonsterEntity (cMonster * a_Monster); diff --git a/source/WorldStorage/WSSAnvil.cpp b/source/WorldStorage/WSSAnvil.cpp index 3ab64148e..3d69fe5ef 100644 --- a/source/WorldStorage/WSSAnvil.cpp +++ b/source/WorldStorage/WSSAnvil.cpp @@ -23,6 +23,7 @@ #include "../OSSupport/MakeDir.h" #include "FastNBT.h" #include "../Mobs/Monster.h" +#include "../Entities/Boat.h" #include "../Entities/FallingBlock.h" #include "../Entities/Minecart.h" #include "../Entities/Pickup.h" @@ -911,7 +912,11 @@ void cWSSAnvil::LoadSignFromNBT(cBlockEntityList & a_BlockEntities, const cParse void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, int a_IDTagLength) { - if (strncmp(a_IDTag, "FallingBlock", a_IDTagLength) == 0) + if (strncmp(a_IDTag, "Boat", a_IDTagLength) == 0) + { + LoadBoatFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + } + else if (strncmp(a_IDTag, "FallingBlock", a_IDTagLength) == 0) { LoadFallingBlockFromNBT(a_Entities, a_NBT, a_EntityTagIdx); } @@ -967,6 +972,20 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a +void cWSSAnvil::LoadBoatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) +{ + std::auto_ptr Boat(new cBoat(0, 0, 0)); + if (!LoadEntityBaseFromNBT(*Boat.get(), a_NBT, a_TagIdx)) + { + return; + } + a_Entities.push_back(Boat.release()); +} + + + + + void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { // TODO diff --git a/source/WorldStorage/WSSAnvil.h b/source/WorldStorage/WSSAnvil.h index b2556ab50..b364e18fa 100644 --- a/source/WorldStorage/WSSAnvil.h +++ b/source/WorldStorage/WSSAnvil.h @@ -138,6 +138,7 @@ protected: void LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, int a_IDTagLength); + void LoadBoatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIndx); void LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadMinecartRFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadMinecartCFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); From 50e24fb75fec614bb195e5a322e2ceff9cdd2b1a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 8 Sep 2013 16:56:16 +0100 Subject: [PATCH 6/6] Fixed a bunch of stuff * Fixed compilation * Made it less obvious I COPIED ALL THE CODE from Minecarts * Fixed alignment spaces to make xoft happy --- source/Entities/Boat.cpp | 6 +++--- source/Entities/Boat.h | 2 +- source/Entities/Entity.h | 2 ++ source/WorldStorage/WSSAnvil.h | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/source/Entities/Boat.cpp b/source/Entities/Boat.cpp index f29766fc1..eebd3a373 100644 --- a/source/Entities/Boat.cpp +++ b/source/Entities/Boat.cpp @@ -1,8 +1,8 @@ -// Minecart.cpp +// Boat.cpp -// Implements the cMinecart class representing a minecart in the world -// Indiana Jones! +// Implements the cBoat class representing a boat in the world +// Pirates of the Carribean! #include "Globals.h" #include "Boat.h" diff --git a/source/Entities/Boat.h b/source/Entities/Boat.h index 439b73a09..e7a67958d 100644 --- a/source/Entities/Boat.h +++ b/source/Entities/Boat.h @@ -1,7 +1,7 @@ // Boat.h -// Declares the cBoat class representing a minecart in the world +// Declares the cBoat class representing a boat in the world diff --git a/source/Entities/Entity.h b/source/Entities/Entity.h index b4777d249..156f737a3 100644 --- a/source/Entities/Entity.h +++ b/source/Entities/Entity.h @@ -92,6 +92,7 @@ public: etMonster, etFallingBlock, etMinecart, + etBoat, etTNT, etProjectile, @@ -119,6 +120,7 @@ public: bool IsPickup (void) const { return (m_EntityType == etPickup); } bool IsMob (void) const { return (m_EntityType == etMob); } bool IsMinecart(void) const { return (m_EntityType == etMinecart); } + bool IsBoat (void) const { return (m_EntityType == etBoat); } bool IsTNT (void) const { return (m_EntityType == etTNT); } /// Returns true if the entity is of the specified class or a subclass (cPawn's IsA("cEntity") returns true) diff --git a/source/WorldStorage/WSSAnvil.h b/source/WorldStorage/WSSAnvil.h index b364e18fa..9236b3582 100644 --- a/source/WorldStorage/WSSAnvil.h +++ b/source/WorldStorage/WSSAnvil.h @@ -138,7 +138,7 @@ protected: void LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, int a_IDTagLength); - void LoadBoatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIndx); + void LoadBoatFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIndx); void LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadMinecartRFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadMinecartCFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);