summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/Defines.h6
-rw-r--r--source/cBlockToPickup.cpp2
-rw-r--r--source/cInventory.cpp6
-rw-r--r--source/cMonster.cpp2
-rw-r--r--source/cPickup.cpp15
-rw-r--r--source/cPlayer.cpp2
-rw-r--r--source/cTracer.cpp7
-rw-r--r--source/packets/cPacket_AddToInventory.cpp4
-rw-r--r--source/packets/cPacket_ItemData.cpp2
-rw-r--r--source/packets/cPacket_WholeInventory.cpp2
10 files changed, 30 insertions, 18 deletions
diff --git a/source/Defines.h b/source/Defines.h
index ba62a241e..6d86da825 100644
--- a/source/Defines.h
+++ b/source/Defines.h
@@ -1,6 +1,7 @@
#pragma once
#include "MemoryLeak.h"
+#include "BlockID.h"
//tolua_begin
// emissive blocks
@@ -45,6 +46,11 @@ inline bool IsValidItem( int a_ItemID ) //tolua_export
return IsValidBlock( a_ItemID );
} //tolua_export
+inline bool IsBlockWater (char a_BlockID)
+{
+ return (a_BlockID == E_BLOCK_WATER || a_BlockID == E_BLOCK_STATIONARY_WATER);
+}
+
inline void AddDirection( int & a_X, char & a_Y, int & a_Z, char a_Direction, bool a_bInverse = false ) //tolua_export
{//tolua_export
if( !a_bInverse )
diff --git a/source/cBlockToPickup.cpp b/source/cBlockToPickup.cpp
index 7a80e4a97..c653f5409 100644
--- a/source/cBlockToPickup.cpp
+++ b/source/cBlockToPickup.cpp
@@ -54,6 +54,4 @@ ENUM_ITEM_ID cBlockToPickup::ToPickup( unsigned char a_BlockID, ENUM_ITEM_ID a_U
default:
return (ENUM_ITEM_ID)a_BlockID;
}
- //TODO: Whats that? :D
- return E_ITEM_EMPTY;
}
diff --git a/source/cInventory.cpp b/source/cInventory.cpp
index 68b8b431e..18862b78b 100644
--- a/source/cInventory.cpp
+++ b/source/cInventory.cpp
@@ -320,9 +320,9 @@ void cInventory::SendSlot( int a_SlotNum )
{
cPacket_InventorySlot InventorySlot;
InventorySlot.m_ItemCount = Item->m_ItemCount;
- InventorySlot.m_ItemID = Item->m_ItemID;
- InventorySlot.m_ItemUses = (char)Item->m_ItemHealth;
- InventorySlot.m_SlotNum = (short)a_SlotNum;
+ InventorySlot.m_ItemID = (short) Item->m_ItemID;
+ InventorySlot.m_ItemUses = (char) Item->m_ItemHealth;
+ InventorySlot.m_SlotNum = (short) a_SlotNum;
InventorySlot.m_WindowID = 0; // Inventory window ID
m_Owner->GetClientHandle()->Send( InventorySlot );
}
diff --git a/source/cMonster.cpp b/source/cMonster.cpp
index 0d99a2e7b..7fec8fa5c 100644
--- a/source/cMonster.cpp
+++ b/source/cMonster.cpp
@@ -615,7 +615,7 @@ void cMonster::DropItem(ENUM_ITEM_ID a_Item, unsigned int a_Count)
{
if(a_Count > 0)
{
- cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( a_Item, a_Count ) );
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( a_Item, (char) a_Count ) );
Pickup->Initialize( GetWorld() );
}
}
diff --git a/source/cPickup.cpp b/source/cPickup.cpp
index 4788c2e1f..7c4a546ec 100644
--- a/source/cPickup.cpp
+++ b/source/cPickup.cpp
@@ -80,7 +80,8 @@ cPickup::cPickup(cPacket_PickupSpawn* a_PickupSpawnPacket)
m_Speed->z = (float)(a_PickupSpawnPacket->m_Roll) / 8;
// Spawn it on clients
- cRoot::Get()->GetServer()->Broadcast( *a_PickupSpawnPacket );
+ if(a_PickupSpawnPacket->m_Item != E_ITEM_EMPTY)
+ cRoot::Get()->GetServer()->Broadcast( *a_PickupSpawnPacket );
m_EntityType = E_PICKUP;
}
@@ -98,12 +99,13 @@ void cPickup::SpawnOn( cClientHandle* a_Target )
PickupSpawn.m_Rotation = (char)(m_Speed->x * 8);
PickupSpawn.m_Pitch = (char)(m_Speed->y * 8);
PickupSpawn.m_Roll = (char)(m_Speed->z * 8);
- a_Target->Send( PickupSpawn );
+ if(PickupSpawn.m_Item != E_ITEM_EMPTY)
+ a_Target->Send( PickupSpawn );
}
void cPickup::Tick(float a_Dt)
{
- m_Timer+=a_Dt;
+ m_Timer += a_Dt;
a_Dt = a_Dt / 1000.f;
if(m_bCollected)
{
@@ -152,7 +154,9 @@ void cPickup::HandlePhysics(float a_Dt)
cWorld* World = GetWorld();
int BlockX = (m_Pos->x)<0 ? (int)m_Pos->x-1 : (int)m_Pos->x;
int BlockZ = (m_Pos->z)<0 ? (int)m_Pos->z-1 : (int)m_Pos->z;
- if( World->GetBlock( BlockX, (int)m_Pos->y -1, BlockZ ) == E_BLOCK_AIR )
+ char BlockBelow = World->GetBlock( BlockX, (int)m_Pos->y -1, BlockZ );
+ //Not only air, falls through water ;)
+ if( BlockBelow == E_BLOCK_AIR || IsBlockWater(BlockBelow))
{
m_bOnGround = false;
}
@@ -162,7 +166,8 @@ void cPickup::HandlePhysics(float a_Dt)
m_Timer = 0;
return;
}
- if( World->GetBlock( BlockX, (int)m_Pos->y, BlockZ ) != E_BLOCK_AIR ) // If in ground itself, push it out
+ char BlockIn = World->GetBlock( BlockX, (int)m_Pos->y, BlockZ );
+ if( BlockIn != E_BLOCK_AIR && !IsBlockWater(BlockIn) ) // If in ground itself, push it out
{
m_bOnGround = true;
m_Pos->y += 0.2;
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index 65b6187a6..2087f7927 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -325,7 +325,7 @@ void cPlayer::Heal( int a_Health )
{
if( m_Health < 20 )
{
- m_Health = MIN(a_Health + m_Health, 20);
+ m_Health = (short) MIN(a_Health + m_Health, 20);
cPacket_UpdateHealth Health;
Health.m_Health = m_Health;
diff --git a/source/cTracer.cpp b/source/cTracer.cpp
index 28e5c49b5..2dce341b4 100644
--- a/source/cTracer.cpp
+++ b/source/cTracer.cpp
@@ -9,6 +9,8 @@
#include "cMCLogger.h"
#include "cEntity.h"
+#include "Defines.h"
+
#ifndef _WIN32
#include <stdlib.h> // abs()
#endif
@@ -209,7 +211,8 @@ int cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
}
char BlockID = m_World->GetBlock( pos->x, pos->y, pos->z );
- if ( BlockID != E_BLOCK_AIR )
+ //No collision with water ;)
+ if ( BlockID != E_BLOCK_AIR || IsBlockWater(BlockID))
{
*BlockHitPosition = pos;
int Normal = GetHitNormal(a_Start, End, *pos );
@@ -280,7 +283,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 )
+ if( BlockID == E_BLOCK_AIR || IsBlockWater(BlockID))
return 0;
Vector3f BlockPos;
diff --git a/source/packets/cPacket_AddToInventory.cpp b/source/packets/cPacket_AddToInventory.cpp
index 0a9dad8c0..72f099e2f 100644
--- a/source/packets/cPacket_AddToInventory.cpp
+++ b/source/packets/cPacket_AddToInventory.cpp
@@ -9,14 +9,14 @@ bool cPacket_AddToInventory::Send( cSocket & a_Socket )
cPacket_ItemData Item;
- TotalSize += Item.GetSize(m_ItemType);
+ TotalSize += Item.GetSize((short) m_ItemType);
char* Message = new char[TotalSize];
unsigned int i = 0;
AppendByte ( (char) m_PacketID, Message, i );
- Item.AppendItem(Message, i, m_ItemType, m_Count, this->m_Life);
+ Item.AppendItem(Message, i, (short) m_ItemType, m_Count, this->m_Life);
bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
delete [] Message;
diff --git a/source/packets/cPacket_ItemData.cpp b/source/packets/cPacket_ItemData.cpp
index 60772d690..1c1d13c60 100644
--- a/source/packets/cPacket_ItemData.cpp
+++ b/source/packets/cPacket_ItemData.cpp
@@ -42,7 +42,7 @@ int cPacket_ItemData::GetSize(short a_ItemID)
void cPacket_ItemData::AppendItem(char* a_Message, unsigned int &a_Iterator, cItem *a_Item)
{
- return AppendItem(a_Message, a_Iterator, a_Item->m_ItemID, a_Item->m_ItemCount, a_Item->m_ItemHealth);
+ return AppendItem(a_Message, a_Iterator, (short) a_Item->m_ItemID, a_Item->m_ItemCount, a_Item->m_ItemHealth);
}
void cPacket_ItemData::AppendItem(char* a_Message, unsigned int &a_Iterator, short a_ItemID, char a_Quantity, short a_Damage)
diff --git a/source/packets/cPacket_WholeInventory.cpp b/source/packets/cPacket_WholeInventory.cpp
index 4bc68ed0b..f9b7be2c4 100644
--- a/source/packets/cPacket_WholeInventory.cpp
+++ b/source/packets/cPacket_WholeInventory.cpp
@@ -44,7 +44,7 @@ bool cPacket_WholeInventory::Send(cSocket & a_Socket)
for(int i = 0; i < m_Count; i++)
{
- TotalSize += Item.GetSize(m_Items[i].m_ItemID);
+ TotalSize += Item.GetSize((short) m_Items[i].m_ItemID);
}
char* Message = new char[TotalSize];