diff options
author | admin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-11-02 21:40:39 +0100 |
---|---|---|
committer | admin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-11-02 21:40:39 +0100 |
commit | a5af50c293d87a21632c2811577c7b1838f6974f (patch) | |
tree | fe95ecc0694f4d4318ff011c50a18e89ad570be7 | |
parent | Fixed some "Entity was not found in any chunk!" warnings (diff) | |
download | cuberite-a5af50c293d87a21632c2811577c7b1838f6974f.tar cuberite-a5af50c293d87a21632c2811577c7b1838f6974f.tar.gz cuberite-a5af50c293d87a21632c2811577c7b1838f6974f.tar.bz2 cuberite-a5af50c293d87a21632c2811577c7b1838f6974f.tar.lz cuberite-a5af50c293d87a21632c2811577c7b1838f6974f.tar.xz cuberite-a5af50c293d87a21632c2811577c7b1838f6974f.tar.zst cuberite-a5af50c293d87a21632c2811577c7b1838f6974f.zip |
Diffstat (limited to '')
-rw-r--r-- | VC2010/MCServer.vcxproj | 6 | ||||
-rw-r--r-- | VC2010/MCServer.vcxproj.filters | 20 | ||||
-rw-r--r-- | makefile | 12 | ||||
-rw-r--r-- | source/PacketID.h | 2 | ||||
-rw-r--r-- | source/cClientHandle.cpp | 33 | ||||
-rw-r--r-- | source/packets/cPacket_NewInvalidState.cpp | 30 | ||||
-rw-r--r-- | source/packets/cPacket_NewInvalidState.h | 24 | ||||
-rw-r--r-- | source/packets/cPacket_Thunderbolt.cpp | 19 | ||||
-rw-r--r-- | source/packets/cPacket_Thunderbolt.h | 27 |
9 files changed, 164 insertions, 9 deletions
diff --git a/VC2010/MCServer.vcxproj b/VC2010/MCServer.vcxproj index 66ed07b48..64a9e3726 100644 --- a/VC2010/MCServer.vcxproj +++ b/VC2010/MCServer.vcxproj @@ -311,6 +311,8 @@ <ClCompile Include="..\source\packets\cPacket_Disconnect.cpp" />
<ClCompile Include="..\source\packets\cPacket_EntityEquipment.cpp" />
<ClCompile Include="..\source\packets\cPacket_CreateInventoryAction.cpp" />
+ <ClCompile Include="..\source\packets\cPacket_NewInvalidState.cpp" />
+ <ClCompile Include="..\source\packets\cPacket_Thunderbolt.cpp" />
<ClCompile Include="..\source\packets\cPacket_EntityLook.cpp" />
<ClCompile Include="..\source\packets\cPacket_EntityStatus.cpp" />
<ClCompile Include="..\source\packets\cPacket_Flying.cpp" />
@@ -450,6 +452,8 @@ <ClInclude Include="..\source\packets\cPacket_Disconnect.h" />
<ClInclude Include="..\source\packets\cPacket_EntityEquipment.h" />
<ClInclude Include="..\source\packets\cPacket_CreateInventoryAction.h" />
+ <ClInclude Include="..\source\packets\cPacket_NewInvalidState.h" />
+ <ClInclude Include="..\source\packets\cPacket_Thunderbolt.h" />
<ClInclude Include="..\source\packets\cPacket_EntityLook.h" />
<ClInclude Include="..\source\packets\cPacket_EntityStatus.h" />
<ClInclude Include="..\source\packets\cPacket_Flying.h" />
@@ -518,4 +522,4 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
\ No newline at end of file +</Project>
diff --git a/VC2010/MCServer.vcxproj.filters b/VC2010/MCServer.vcxproj.filters index 2e0ec8324..cccd8071f 100644 --- a/VC2010/MCServer.vcxproj.filters +++ b/VC2010/MCServer.vcxproj.filters @@ -286,6 +286,12 @@ <Filter Include="Packets\cPacket_CreateInventoryAction">
<UniqueIdentifier>{0c47e5f8-ea4d-40dc-ac8e-740c5512c768}</UniqueIdentifier>
</Filter>
+ <Filter Include="Packets\cPacket_NewInvalidState">
+ <UniqueIdentifier>{0c12e5f5-ea4d-10dc-ac7e-540c5562c767}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Packets\cPacket_Thunderbolt">
+ <UniqueIdentifier>{0c32e5f8-ea4d-30dc-ac8e-140c4512c668}</UniqueIdentifier>
+ </Filter>
<Filter Include="Packets\cPacket_UseEntity">
<UniqueIdentifier>{bff5658b-0806-430c-9929-062f4bd4760b}</UniqueIdentifier>
</Filter>
@@ -655,6 +661,12 @@ <ClCompile Include="..\source\packets\cPacket_CreateInventoryAction.cpp">
<Filter>Packets\cPacket_CreateInventoryAction</Filter>
</ClCompile>
+ <ClCompile Include="..\source\packets\cPacket_NewInvalidState.cpp">
+ <Filter>Packets\cPacket_NewInvalidState</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\packets\cPacket_Thunderbolt.cpp">
+ <Filter>Packets\cPacket_Thunderbolt</Filter>
+ </ClCompile>
<ClCompile Include="..\source\packets\cPacket_UseEntity.cpp">
<Filter>Packets\cPacket_UseEntity</Filter>
</ClCompile>
@@ -1059,6 +1071,12 @@ <ClInclude Include="..\source\packets\cPacket_CreateInventoryAction.h">
<Filter>Packets\cPacket_CreateInventoryAction</Filter>
</ClInclude>
+ <ClInclude Include="..\source\packets\cPacket_NewInvalidState.h">
+ <Filter>Packets\cPacket_NewInvalidState</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\packets\cPacket_Thunderbolt.h">
+ <Filter>Packets\cPacket_Thunderbolt</Filter>
+ </ClInclude>
<ClInclude Include="..\source\packets\cPacket_UseEntity.h">
<Filter>Packets\cPacket_UseEntity</Filter>
</ClInclude>
@@ -1159,4 +1177,4 @@ <ItemGroup>
<ResourceCompile Include="MCServer.rc" />
</ItemGroup>
-</Project>
\ No newline at end of file +</Project>
@@ -128,6 +128,8 @@ MCServer : \ build/cPacket_Disconnect.o\ build/cPacket_EntityEquipment.o\ build/cPacket_CreateInventoryAction.o\ + build/cPacket_NewInvalidState.o\ + build/cPacket_Thunderbolt.o\ build/cPacket_EntityLook.o\ build/cPacket_EntityStatus.o\ build/cPacket_Flying.o\ @@ -311,6 +313,8 @@ MCServer : \ build/cPacket_Disconnect.o\ build/cPacket_EntityEquipment.o\ build/cPacket_CreateInventoryAction.o\ + build/cPacket_NewInvalidState.o\ + build/cPacket_Thunderbolt.o\ build/cPacket_EntityLook.o\ build/cPacket_EntityStatus.o\ build/cPacket_Flying.o\ @@ -497,6 +501,8 @@ clean : build/cPacket_Disconnect.o\ build/cPacket_EntityEquipment.o\ build/cPacket_CreateInventoryAction.o\ + build/cPacket_NewInvalidState.o\ + build/cPacket_Thunderbolt.o\ build/cPacket_EntityLook.o\ build/cPacket_EntityStatus.o\ build/cPacket_Flying.o\ @@ -879,6 +885,12 @@ build/cPacket_EntityEquipment.o : source/packets/cPacket_EntityEquipment.cpp build/cPacket_CreateInventoryAction.o : source/packets/cPacket_CreateInventoryAction.cpp $(CC) $(CC_OPTIONS) source/packets/cPacket_CreateInventoryAction.cpp -c $(INCLUDE) -o build/cPacket_CreateInventoryAction.o +build/cPacket_NewInvalidState.o : source/packets/cPacket_NewInvalidState.cpp + $(CC) $(CC_OPTIONS) source/packets/cPacket_NewInvalidState.cpp -c $(INCLUDE) -o build/cPacket_NewInvalidState.o + +build/cPacket_Thunderbolt.o : source/packets/cPacket_Thunderbolt.cpp + $(CC) $(CC_OPTIONS) source/packets/cPacket_Thunderbolt.cpp -c $(INCLUDE) -o build/cPacket_Thunderbolt.o + build/cPacket_EntityLook.o : source/packets/cPacket_EntityLook.cpp $(CC) $(CC_OPTIONS) source/packets/cPacket_EntityLook.cpp -c $(INCLUDE) -o build/cPacket_EntityLook.o diff --git a/source/PacketID.h b/source/PacketID.h index 75482bbb0..98d6fc415 100644 --- a/source/PacketID.h +++ b/source/PacketID.h @@ -39,6 +39,8 @@ enum ENUM_PACKET_ID E_MAP_CHUNK = 0x33,
E_MULTI_BLOCK = 0x34,
E_BLOCK_CHANGE = 0x35,
+ E_NEW_INVALID_STATE = 0x46,
+ E_THUNDERBOLT = 0x47,
E_WINDOW_OPEN = 0x64,
E_WINDOW_CLOSE = 0x65,
E_WINDOW_CLICK = 0x66,
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index 621e8a19e..4c09c4309 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -56,6 +56,7 @@ #include "packets/cPacket_ItemSwitch.h"
#include "packets/cPacket_EntityEquipment.h"
#include "packets/cPacket_CreateInventoryAction.h"
+#include "packets/cPacket_NewInvalidState.h"
#include "packets/cPacket_UseEntity.h"
#include "packets/cPacket_WindowClose.h"
#include "packets/cPacket_13.h"
@@ -127,16 +128,17 @@ cClientHandle::cClientHandle(const cSocket & a_Socket) m_pState->PacketMap[E_LOGIN] = new cPacket_Login;
m_pState->PacketMap[E_PLAYERPOS] = new cPacket_PlayerPosition;
m_pState->PacketMap[E_PLAYERLOOK] = new cPacket_PlayerLook;
- m_pState->PacketMap[E_PLAYERMOVELOOK] = new cPacket_PlayerMoveLook;
- m_pState->PacketMap[E_CHAT] = new cPacket_Chat;
+ m_pState->PacketMap[E_PLAYERMOVELOOK] = new cPacket_PlayerMoveLook;
+ m_pState->PacketMap[E_CHAT] = new cPacket_Chat;
m_pState->PacketMap[E_ANIMATION] = new cPacket_ArmAnim;
m_pState->PacketMap[E_FLYING] = new cPacket_Flying;
m_pState->PacketMap[E_BLOCK_DIG] = new cPacket_BlockDig;
m_pState->PacketMap[E_BLOCK_PLACE] = new cPacket_BlockPlace;
m_pState->PacketMap[E_DISCONNECT] = new cPacket_Disconnect;
m_pState->PacketMap[E_ITEM_SWITCH] = new cPacket_ItemSwitch;
- m_pState->PacketMap[E_ENTITY_EQUIPMENT] = new cPacket_EntityEquipment;
- m_pState->PacketMap[E_CREATE_INVENTORY_ACTION] = new cPacket_CreateInventoryAction;
+ m_pState->PacketMap[E_ENTITY_EQUIPMENT] = new cPacket_EntityEquipment;
+ m_pState->PacketMap[E_CREATE_INVENTORY_ACTION] = new cPacket_CreateInventoryAction;
+ m_pState->PacketMap[E_NEW_INVALID_STATE] = new cPacket_NewInvalidState;
m_pState->PacketMap[E_PICKUP_SPAWN] = new cPacket_PickupSpawn;
m_pState->PacketMap[E_USE_ENTITY] = new cPacket_UseEntity;
m_pState->PacketMap[E_WINDOW_CLOSE] = new cPacket_WindowClose;
@@ -144,7 +146,7 @@ cClientHandle::cClientHandle(const cSocket & a_Socket) m_pState->PacketMap[E_PACKET_13] = new cPacket_13;
m_pState->PacketMap[E_UPDATE_SIGN] = new cPacket_UpdateSign;
m_pState->PacketMap[E_RESPAWN] = new cPacket_Respawn;
- m_pState->PacketMap[E_PING] = new cPacket_Ping;
+ m_pState->PacketMap[E_PING] = new cPacket_Ping;
memset( m_LoadedChunks, 0x00, sizeof(cChunk*)*VIEWDISTANCE*VIEWDISTANCE );
@@ -372,12 +374,22 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) {
switch( a_Packet->m_PacketID )
{
+ case E_NEW_INVALID_STATE: // New/Invalid State packet received. I'm guessing the client only sends it when there's a problem with the bed?
+ {
+ LOGINFO("Got New Invalid State packet");
+ }
+ break;
+ case E_CREATE_INVENTORY_ACTION: // I don't think we need to do anything with this packet, but justin case...
+ {
+ LOGINFO("Got Create Inventory Action packet");
+ }
+ break;
case E_PING: // Somebody tries to retreive information about the server
{
LOGINFO("Got ping");
char NumPlayers[8];
sprintf_s(NumPlayers, 8, "%i", cRoot::Get()->GetWorld()->GetNumPlayers() );
- std::string response = std::string("Should be able to connect now!" + cChatColor::Delimiter + NumPlayers + cChatColor::Delimiter + "9001" );
+ std::string response = std::string("MCServer! - It's OVER 9000!" + cChatColor::Delimiter + NumPlayers + cChatColor::Delimiter + "9001" );
Kick( response.c_str() );
}
break;
@@ -630,6 +642,10 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) {
case E_BLOCK_WORKBENCH:
{
+ LOG("WorkBench");
+ cPacket_NewInvalidState RainPacket;
+ RainPacket.m_Reason = 1; //begin rain
+ Send( RainPacket );
bPlaceBlock = false;
cWindow* Window = new cCraftingWindow( 0, true );
m_Player->OpenWindow( Window );
@@ -638,6 +654,10 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) case E_BLOCK_FURNACE:
case E_BLOCK_CHEST:
{
+ LOG("Chest");
+ cPacket_NewInvalidState RainPacket;
+ RainPacket.m_Reason = 2; //end rain
+ Send( RainPacket );
bPlaceBlock = false;
cBlockEntity* BlockEntity = m_Player->GetWorld()->GetBlockEntity( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
if( BlockEntity )
@@ -971,7 +991,6 @@ void cClientHandle::Tick(float a_Dt) Send( cPacket_UpdateHealth( (short)m_Player->GetHealth() ) );
//quick bugfix to prevent players from spawning in ground
-// m_Player->TeleportTo( cRoot::Get()->GetWorld()->GetPosX(), cRoot::Get()->GetWorld()->GetPosY()+1, cRoot::Get()->GetWorld()->GetPosZ() );
m_Player->TeleportTo( m_Player->GetPosX(), m_Player->GetPosY()+1, m_Player->GetPosZ() );
World->UnlockEntities();
diff --git a/source/packets/cPacket_NewInvalidState.cpp b/source/packets/cPacket_NewInvalidState.cpp new file mode 100644 index 000000000..6755ec207 --- /dev/null +++ b/source/packets/cPacket_NewInvalidState.cpp @@ -0,0 +1,30 @@ +#include "cPacket_NewInvalidState.h" + +cPacket_NewInvalidState::cPacket_NewInvalidState( const cPacket_NewInvalidState & a_Copy ) +{ + m_PacketID = E_NEW_INVALID_STATE; + m_Reason = a_Copy.m_Reason; + m_GameMode = a_Copy.m_GameMode; +} + +bool cPacket_NewInvalidState::Parse(cSocket & a_Socket) { + m_Socket = a_Socket; + if( !ReadByte ( m_Reason ) ) return false; + if( !ReadByte ( m_GameMode ) ) return false; + return true; +} + +bool cPacket_NewInvalidState::Send(cSocket & a_Socket) +{ + unsigned int TotalSize = c_Size; + char* Message = new char[TotalSize]; + + unsigned int i = 0; + AppendByte ( (char)m_PacketID, Message, i ); + AppendByte ( m_Reason, Message, i ); + AppendByte ( m_GameMode, Message, i ); + + bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) ); + delete [] Message; + return RetVal; +} diff --git a/source/packets/cPacket_NewInvalidState.h b/source/packets/cPacket_NewInvalidState.h new file mode 100644 index 000000000..a83cb8080 --- /dev/null +++ b/source/packets/cPacket_NewInvalidState.h @@ -0,0 +1,24 @@ +#pragma once + +#include "cPacket.h" +#include "PacketID.h" + + +class cPacket_NewInvalidState : public cPacket +{ +public: + cPacket_NewInvalidState() + : m_Reason( 0 ) + , m_GameMode( 0 ) + { m_PacketID = E_NEW_INVALID_STATE;} + cPacket_NewInvalidState( const cPacket_NewInvalidState & a_Copy ); + virtual cPacket* Clone() const { return new cPacket_NewInvalidState(*this); } + + bool Parse(cSocket & a_Socket); + bool Send(cSocket & a_Socket); + + char m_Reason; // 0 = Invalid Bed, 1 = Begin Raining, 2 End Raining, 3 = Change Gamemode + char m_GameMode; // Used only when reason = 3. 0 is survival, 1 is creative. + + static const unsigned int c_Size = 1 + 1 + 1; +}; diff --git a/source/packets/cPacket_Thunderbolt.cpp b/source/packets/cPacket_Thunderbolt.cpp new file mode 100644 index 000000000..c6fdefb60 --- /dev/null +++ b/source/packets/cPacket_Thunderbolt.cpp @@ -0,0 +1,19 @@ +#include "cPacket_Thunderbolt.h" + +bool cPacket_Thunderbolt::Send(cSocket & a_Socket) +{ + unsigned int TotalSize = c_Size; + char* Message = new char[TotalSize]; + + unsigned int i = 0; + AppendByte ( (char)m_PacketID, Message, i ); + AppendInteger ( m_UniqueID, Message, i ); + AppendBool ( m_Unknown, Message, i ); + AppendInteger ( m_xLBPos, Message, i ); + AppendInteger ( m_yLBPos, Message, i ); + AppendInteger ( m_zLBPos, Message, i ); + + bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) ); + delete [] Message; + return RetVal; +} diff --git a/source/packets/cPacket_Thunderbolt.h b/source/packets/cPacket_Thunderbolt.h new file mode 100644 index 000000000..51dad5814 --- /dev/null +++ b/source/packets/cPacket_Thunderbolt.h @@ -0,0 +1,27 @@ +#pragma once + +#include "cPacket.h" +#include "PacketID.h" + +class cPacket_Thunderbolt : public cPacket +{ +public: + cPacket_Thunderbolt() + : m_UniqueID( 0 ) + , m_Unknown( 0 ) + , m_xLBPos( 0 ) + , m_yLBPos( 0 ) + , m_zLBPos( 0 ) + { m_PacketID = E_THUNDERBOLT;} + virtual cPacket* Clone() const { return new cPacket_Thunderbolt(*this); } + + bool Send(cSocket & a_Socket); + + int m_UniqueID; // The entity ID of the thunderbolt + bool m_Unknown; // Always true. Might have a meaning in the future... + int m_xLBPos; // Thunderbolt X as Absolute Integer + int m_yLBPos; // Thunderbolt Y as Absolute Integer + int m_zLBPos; // Thunderbolt Z as Absolute Integer + + static const unsigned int c_Size = 1 + 4 + 1 + 4 + 4 + 4; +}; |