Fixes:
- Pickups fall through water now (Server-side they stayed in the water surface) - Suppressed some warnings (int to short etc.) - Water is now passable for cTracer git-svn-id: http://mc-server.googlecode.com/svn/trunk@96 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
0498a43d21
commit
e54373160b
@ -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 )
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 );
|
||||
}
|
||||
|
@ -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() );
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ cPickup::cPickup(cPacket_PickupSpawn* a_PickupSpawnPacket)
|
||||
m_Speed->z = (float)(a_PickupSpawnPacket->m_Roll) / 8;
|
||||
|
||||
// Spawn it on clients
|
||||
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);
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user