Merged in a patch for sounds by l0udPL
http://forum.mc-server.org/showthread.php?tid=434&pid=4564#pid4564 git-svn-id: http://mc-server.googlecode.com/svn/trunk@858 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
2132599cbb
commit
9eed83c33a
@ -1815,6 +1815,10 @@
|
||||
RelativePath="..\source\blocks\BlockGlowstone.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\blocks\BlockGravel.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\blocks\BlockIce.h"
|
||||
>
|
||||
@ -1875,6 +1879,10 @@
|
||||
RelativePath="..\source\blocks\BlockRedstoneTorch.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\blocks\BlockSand.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\blocks\BlockSapling.h"
|
||||
>
|
||||
|
@ -70,6 +70,7 @@ public:
|
||||
virtual void SendPlayerPosition (void) = 0;
|
||||
virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
|
||||
virtual void SendRespawn (void) = 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 SendSpawnMob (const cMonster & a_Mob) = 0;
|
||||
virtual void SendTeleportEntity (const cEntity & a_Entity) = 0;
|
||||
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
|
||||
@ -81,7 +82,7 @@ public:
|
||||
virtual void SendWholeInventory (const cWindow & a_Window) = 0;
|
||||
virtual void SendWindowClose (char a_WindowID) = 0;
|
||||
virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) = 0;
|
||||
|
||||
|
||||
/// Returns the ServerID used for authentication through session.minecraft.net
|
||||
virtual AString GetAuthServerID(void) = 0;
|
||||
|
||||
|
@ -577,6 +577,16 @@ void cProtocol125::SendRespawn(void)
|
||||
|
||||
|
||||
|
||||
void cProtocol125::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
//TODO: Not needed in this protocol?
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cProtocol125::SendSpawnMob(const cMonster & a_Mob)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
virtual void SendPlayerPosition (void) override;
|
||||
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
|
||||
virtual void SendRespawn (void) 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 SendSpawnMob (const cMonster & a_Mob) override;
|
||||
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
|
||||
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
|
@ -59,6 +59,7 @@ enum
|
||||
PACKET_CHUNK_DATA = 0x33,
|
||||
PACKET_BLOCK_CHANGE = 0x35,
|
||||
PACKET_BLOCK_ACTION = 0x36,
|
||||
PACKET_SOUND_EFFECT = 0x3e
|
||||
} ;
|
||||
|
||||
|
||||
@ -310,6 +311,23 @@ 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)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
WriteByte (PACKET_SOUND_EFFECT);
|
||||
WriteString (a_SoundName);
|
||||
WriteInt (a_SrcX);
|
||||
WriteInt (a_SrcY);
|
||||
WriteInt (a_SrcZ);
|
||||
WriteFloat (a_Volume);
|
||||
WriteByte ((char)(a_Pitch * 63.0f));
|
||||
Flush();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cProtocol132::SendSpawnMob(const cMonster & a_Mob)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
|
@ -38,9 +38,10 @@ public:
|
||||
virtual void SendDestroyEntity(const cEntity & a_Entity) 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 SendSpawnMob (const cMonster & a_Mob) override;
|
||||
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
|
||||
|
||||
|
||||
virtual AString GetAuthServerID(void) override;
|
||||
|
||||
// DEBUG:
|
||||
|
@ -347,6 +347,14 @@ void cProtocolRecognizer::SendRespawn(void)
|
||||
|
||||
|
||||
|
||||
void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cProtocolRecognizer::SendSpawnMob(const cMonster & a_Mob)
|
||||
{
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
virtual void SendPlayerPosition (void) override;
|
||||
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
|
||||
virtual void SendRespawn (void) 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 SendSpawnMob (const cMonster & a_Mob) override;
|
||||
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
|
||||
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include "Block.h"
|
||||
#include "../cItem.h"
|
||||
#include "../cWorld.h"
|
||||
#include "BlockSand.h"
|
||||
#include "BlockGravel.h"
|
||||
#include "BlockDoor.h"
|
||||
#include "BlockFire.h"
|
||||
#include "BlockRedstone.h"
|
||||
@ -75,6 +77,10 @@ cBlockHandler *cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockID)
|
||||
{
|
||||
switch(a_BlockID)
|
||||
{
|
||||
case E_BLOCK_SAND:
|
||||
return new cBlockSandHandler(a_BlockID);
|
||||
case E_BLOCK_GRAVEL:
|
||||
return new cBlockGravelHandler(a_BlockID);
|
||||
case E_BLOCK_WOODEN_DOOR:
|
||||
case E_BLOCK_IRON_DOOR:
|
||||
return new cBlockDoorHandler(a_BlockID);
|
||||
@ -349,6 +355,14 @@ void cBlockHandler::DropBlock(cWorld *a_World, int a_X, int a_Y, int a_Z)
|
||||
|
||||
|
||||
|
||||
AString cBlockHandler::GetStepSound() {
|
||||
return "step.stone";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cBlockHandler::CanBePlacedAt(cWorld *a_World, int a_X, int a_Y, int a_Z, char a_Dir)
|
||||
{
|
||||
return CanBeAt(a_World, a_X, a_Y, a_Z);
|
||||
|
@ -41,7 +41,8 @@ public:
|
||||
virtual NIBBLETYPE GetDropMeta(NIBBLETYPE a_BlockMeta);
|
||||
// This function handles the dropping of a block based on the Drop id, drop count and drop meta. This will not destroy the block
|
||||
virtual void DropBlock(cWorld *a_World, int a_X, int a_Y, int a_Z);
|
||||
|
||||
/// Returns step sound name of block
|
||||
virtual AString GetStepSound();
|
||||
|
||||
// Indicates whether this block needs random ticks DEFAULT: False
|
||||
virtual bool NeedsRandomTicks();
|
||||
|
@ -50,6 +50,13 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.cloth";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -18,5 +18,9 @@ public:
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.wood";
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -14,5 +14,10 @@ public:
|
||||
{
|
||||
return a_BlockMeta;
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.cloth";
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -55,5 +55,10 @@ public:
|
||||
{
|
||||
return a_World->GetBlock(a_X, a_Y - 1, a_Z) == E_BLOCK_FARMLAND;
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.grass";
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -63,5 +63,10 @@ public:
|
||||
}
|
||||
} // for i - repeat twice
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.gravel";
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -62,4 +62,13 @@ void cBlockDoorHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYP
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, a_BlockMeta);
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AString cBlockDoorHandler::GetStepSound(void)
|
||||
{
|
||||
if (m_BlockID == E_BLOCK_WOODEN_DOOR)
|
||||
return "step.wood";
|
||||
|
||||
else
|
||||
return "step.stone";
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ public:
|
||||
virtual void OnDestroyed(cWorld *a_World, int a_X, int a_Y, int a_Z) override;
|
||||
virtual void OnDigging(cWorld *a_World, cPlayer *a_Player, int a_X, int a_Y, int a_Z) override;
|
||||
virtual void OnUse(cWorld *a_World, cPlayer *a_Player, int a_X, int a_Y, int a_Z) override;
|
||||
virtual AString GetStepSound(void) override;
|
||||
virtual char GetDropCount() override;
|
||||
virtual bool IsUseable() override
|
||||
{
|
||||
|
@ -25,5 +25,9 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.wood";
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -29,4 +29,10 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.grass";
|
||||
}
|
||||
|
||||
};
|
||||
|
18
source/blocks/BlockGravel.h
Normal file
18
source/blocks/BlockGravel.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include "Block.h"
|
||||
|
||||
|
||||
class cBlockGravelHandler : public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockGravelHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
{
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.gravel";
|
||||
}
|
||||
|
||||
};
|
@ -30,5 +30,11 @@ public:
|
||||
char Dir = cLadder::MetaDataToDirection(a_World->GetBlockMeta( a_X, a_Y, a_Z));
|
||||
return CanBePlacedAt(a_World, a_X, a_Y, a_Z, Dir);
|
||||
}
|
||||
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.wood";
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -108,6 +108,11 @@ public:
|
||||
a_World->DigBlock(a_X, a_Y, a_Z);
|
||||
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.grass";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -21,4 +21,9 @@ public:
|
||||
MTRand r1;
|
||||
return (char)(3 + r1.randInt(4));
|
||||
}
|
||||
};
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.wood";
|
||||
}
|
||||
};
|
||||
|
@ -39,4 +39,9 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.grass";
|
||||
}
|
||||
};
|
||||
|
@ -44,4 +44,9 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.wood";
|
||||
}
|
||||
};
|
||||
|
@ -20,4 +20,9 @@ public:
|
||||
{
|
||||
return E_ITEM_REDSTONE_TORCH_ON;
|
||||
}
|
||||
};
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.wood";
|
||||
}
|
||||
};
|
||||
|
18
source/blocks/BlockSand.h
Normal file
18
source/blocks/BlockSand.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include "Block.h"
|
||||
|
||||
|
||||
class cBlockSandHandler : public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockSandHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
{
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.sand";
|
||||
}
|
||||
|
||||
};
|
@ -48,4 +48,9 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.grass";
|
||||
}
|
||||
};
|
||||
|
@ -39,4 +39,9 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.wood";
|
||||
}
|
||||
};
|
||||
|
@ -39,4 +39,13 @@ public:
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
if (m_BlockID == E_BLOCK_WOODEN_SLAB || m_BlockID ==E_BLOCK_DOUBLE_WOODEN_SLAB)
|
||||
return "step.wood";
|
||||
|
||||
else
|
||||
return "step.stone";
|
||||
}
|
||||
};
|
||||
|
@ -35,5 +35,10 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.cloth";
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -18,5 +18,5 @@ public:
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
//TODO: step sound
|
||||
};
|
||||
|
@ -37,5 +37,10 @@ public:
|
||||
{
|
||||
return a_World->GetBlock(a_X, a_Y - 1, a_Z) == E_BLOCK_FARMLAND;
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.wood";
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -59,6 +59,11 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.grass";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -32,4 +32,10 @@ public:
|
||||
{
|
||||
return a_World->GetBlock(a_X, a_Y - 1, a_Z) != E_BLOCK_AIR;
|
||||
}
|
||||
};
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.grass";
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -154,6 +154,11 @@ public:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.wood";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -26,5 +26,10 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.grass";
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -13,5 +13,10 @@ public:
|
||||
{
|
||||
return a_BlockMeta;
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.wood";
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -21,6 +21,11 @@ public:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual AString GetStepSound(void) override
|
||||
{
|
||||
return "step.wood";
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -1834,6 +1834,22 @@ void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, cons
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
|
||||
{
|
||||
if (*itr == a_Exclude)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
(*itr)->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
|
||||
} // for itr - LoadedByClient[]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude)
|
||||
{
|
||||
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
|
||||
|
@ -187,6 +187,7 @@ public:
|
||||
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, 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 BroadcastChunkData (cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
|
||||
|
||||
void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
|
||||
|
@ -447,6 +447,25 @@ void cChunkMap::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, c
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
int ChunkX, ChunkZ;
|
||||
|
||||
cChunkDef::BlockToChunk(a_SrcX / 8, a_SrcY / 8, a_SrcZ / 8, 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChunkMap::BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude)
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
|
@ -75,6 +75,8 @@ public:
|
||||
|
||||
void BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, 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 BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
|
||||
|
||||
/// Broadcasts the block entity, if it is at the coords specified, to all clients except a_Exclude
|
||||
|
@ -677,6 +677,8 @@ void cClientHandle::HandleBlockPlace(int a_BlockX, int a_BlockY, int a_BlockZ, c
|
||||
if (NewBlock->CanBePlacedAt(World, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace))
|
||||
{
|
||||
ItemHandler->PlaceBlock(World, m_Player, &m_Player->GetInventory().GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
|
||||
// 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1404,6 +1406,15 @@ void cClientHandle::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
|
||||
|
||||
|
||||
void cClientHandle::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
|
||||
{
|
||||
m_Protocol->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
|
||||
{
|
||||
// Check chunks being sent, erase them from m_ChunksToSend:
|
||||
|
@ -111,6 +111,7 @@ public:
|
||||
void SendWeather(eWeather a_Weather);
|
||||
void SendTimeUpdate(Int64 a_WorldTime);
|
||||
void SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
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 SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer);
|
||||
|
||||
const AString & GetUsername(void) const; //tolua_export
|
||||
|
@ -37,6 +37,8 @@ void cNoteEntity::UsedBy( cPlayer * a_Player )
|
||||
void cNoteEntity::MakeSound( void )
|
||||
{
|
||||
char instrument;
|
||||
AString sampleName;
|
||||
|
||||
switch (m_World->GetBlock(m_PosX, m_PosY - 1, m_PosZ))
|
||||
{
|
||||
case E_BLOCK_PLANKS:
|
||||
@ -45,6 +47,7 @@ void cNoteEntity::MakeSound( void )
|
||||
{
|
||||
// TODO: add other wood-based blocks if needed
|
||||
instrument = E_INST_DOUBLE_BASS;
|
||||
sampleName = "note.db";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -53,6 +56,7 @@ void cNoteEntity::MakeSound( void )
|
||||
case E_BLOCK_SOULSAND:
|
||||
{
|
||||
instrument = E_INST_SNARE_DRUM;
|
||||
sampleName = "note.snare";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -61,6 +65,7 @@ void cNoteEntity::MakeSound( void )
|
||||
case E_BLOCK_GLOWSTONE:
|
||||
{
|
||||
instrument = E_INST_CLICKS;
|
||||
sampleName = "note.hat";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -74,17 +79,23 @@ void cNoteEntity::MakeSound( void )
|
||||
{
|
||||
// TODO: add other stone-based blocks if needed
|
||||
instrument = E_INST_BASS_DRUM;
|
||||
sampleName = "note.bassattack";
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
instrument = E_INST_HARP_PIANO;
|
||||
sampleName = "note.harp";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_World->BroadcastBlockAction(m_PosX, m_PosY, m_PosZ, instrument, m_Pitch, E_BLOCK_NOTE_BLOCK);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1421,6 +1421,15 @@ void cWorld::BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline,
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
m_ChunkMap->BroadcastSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch, a_Exclude);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cWorld::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
|
||||
{
|
||||
m_ChunkMap->BroadcastBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_Exclude);
|
||||
|
@ -92,6 +92,7 @@ public:
|
||||
void BroadcastTimeUpdate (const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, 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
|
||||
|
||||
/// If there is a block entity at the specified coods, sends it to all clients except a_Exclude
|
||||
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user