From 2691e8daed826e944ca38f4787c77273edbf9404 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 18 Aug 2012 09:56:28 +0000 Subject: Packet refactoring, phase two, partial. Rewritten a few packet handling functions not to use cPacket-descendant objects. This breaks plugin API! Plugins need to modify their hook functions to match those used in the Core plugin git-svn-id: http://mc-server.googlecode.com/svn/trunk@750 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cPlugin.cpp | 121 +++++++++++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 55 deletions(-) (limited to 'source/cPlugin.cpp') diff --git a/source/cPlugin.cpp b/source/cPlugin.cpp index 9a963f3f2..146e222cc 100644 --- a/source/cPlugin.cpp +++ b/source/cPlugin.cpp @@ -37,10 +37,16 @@ void cPlugin::Tick(float a_Dt) -bool cPlugin::OnBlockPlace(cPacket_BlockPlace * a_PacketData, cPlayer * a_Player) +bool cPlugin::OnBlockDig(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta) { - UNUSED(a_PacketData); UNUSED(a_Player); + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + UNUSED(a_BlockFace); + UNUSED(a_Status); + UNUSED(a_OldBlock); + UNUSED(a_OldMeta); return false; } @@ -48,22 +54,14 @@ bool cPlugin::OnBlockPlace(cPacket_BlockPlace * a_PacketData, cPlayer * a_Player -bool cPlugin::OnBlockDig(cPacket_BlockDig * a_PacketData, cPlayer * a_Player, cItem * a_PickupItem) -{ - UNUSED(a_PacketData); - UNUSED(a_Player); - UNUSED(a_PickupItem); - return false; -} - - - - - -bool cPlugin::OnCollectItem(cPickup * a_Pickup, cPlayer * a_Player) +bool cPlugin::OnBlockPlace(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem) { - UNUSED(a_Pickup); UNUSED(a_Player); + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + UNUSED(a_BlockFace); + UNUSED(a_HeldItem); return false; } @@ -71,10 +69,13 @@ bool cPlugin::OnCollectItem(cPickup * a_Pickup, cPlayer * a_Player) -bool cPlugin::OnDisconnect(const AString & a_Reason, cPlayer * a_Player) +bool cPlugin::OnBlockToPickup(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups) { - UNUSED(a_Reason); + UNUSED(a_BlockType); + UNUSED(a_BlockMeta); UNUSED(a_Player); + UNUSED(a_EquippedItem); + UNUSED(a_Pickups); return false; } @@ -93,27 +94,33 @@ bool cPlugin::OnChat(const char * a_Chat, cPlayer * a_Player) -bool cPlugin::OnLogin(cPacket_Login * a_PacketData) +void cPlugin::OnChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ) { - UNUSED(a_PacketData); - return false; + UNUSED(a_World); + UNUSED(a_ChunkX); + UNUSED(a_ChunkZ); } -void cPlugin::OnPlayerSpawn(cPlayer * a_Player) +bool cPlugin::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk) { - UNUSED(a_Player); + UNUSED(a_World); + UNUSED(a_ChunkX); + UNUSED(a_ChunkZ); + UNUSED(a_pLuaChunk); + return false; } -bool cPlugin::OnPlayerJoin(cPlayer * a_Player) +bool cPlugin::OnCollectItem(cPickup * a_Pickup, cPlayer * a_Player) { + UNUSED(a_Pickup); UNUSED(a_Player); return false; } @@ -122,19 +129,23 @@ bool cPlugin::OnPlayerJoin(cPlayer * a_Player) -void cPlugin::OnPlayerMove(cPlayer * a_Player) +bool cPlugin::OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { UNUSED(a_Player); + UNUSED(a_Grid); + UNUSED(a_Recipe); + return false; } -void cPlugin::OnTakeDamage(cPawn * a_Pawn, TakeDamageInfo * a_TakeDamageInfo) +bool cPlugin::OnDisconnect(const AString & a_Reason, cPlayer * a_Player) { - UNUSED(a_Pawn); - UNUSED(a_TakeDamageInfo); + UNUSED(a_Reason); + UNUSED(a_Player); + return false; } @@ -152,23 +163,21 @@ bool cPlugin::OnKilled(cPawn * a_Killed, cEntity * a_Killer) -void cPlugin::OnChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ) +bool cPlugin::OnLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) { - UNUSED(a_World); - UNUSED(a_ChunkX); - UNUSED(a_ChunkZ); + UNUSED(a_Client); + UNUSED(a_ProtocolVersion); + UNUSED(a_Username); + return false; } -bool cPlugin::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk) +bool cPlugin::OnPlayerJoin(cPlayer * a_Player) { - UNUSED(a_World); - UNUSED(a_ChunkX); - UNUSED(a_ChunkZ); - UNUSED(a_pLuaChunk); + UNUSED(a_Player); return false; } @@ -176,24 +185,18 @@ bool cPlugin::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cL -bool cPlugin::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) +void cPlugin::OnPlayerMove(cPlayer * a_Player) { UNUSED(a_Player); - UNUSED(a_Grid); - UNUSED(a_Recipe); - return false; } -bool cPlugin::OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) +void cPlugin::OnPlayerSpawn(cPlayer * a_Player) { UNUSED(a_Player); - UNUSED(a_Grid); - UNUSED(a_Recipe); - return false; } @@ -212,13 +215,11 @@ bool cPlugin::OnPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_G -bool cPlugin::OnBlockToPickup(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups) +bool cPlugin::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { - UNUSED(a_BlockType); - UNUSED(a_BlockMeta); UNUSED(a_Player); - UNUSED(a_EquippedItem); - UNUSED(a_Pickups); + UNUSED(a_Grid); + UNUSED(a_Recipe); return false; } @@ -226,17 +227,17 @@ bool cPlugin::OnBlockToPickup(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, con -bool cPlugin::OnWeatherChanged(cWorld * a_World) +void cPlugin::OnTakeDamage(cPawn * a_Pawn, TakeDamageInfo * a_TakeDamageInfo) { - UNUSED(a_World); - return false; + UNUSED(a_Pawn); + UNUSED(a_TakeDamageInfo); } -bool cPlugin::OnUpdatingSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4) +bool cPlugin::OnUpdatedSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) { UNUSED(a_World); UNUSED(a_BlockX); @@ -253,7 +254,7 @@ bool cPlugin::OnUpdatingSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a -bool cPlugin::OnUpdatedSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) +bool cPlugin::OnUpdatingSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4) { UNUSED(a_World); UNUSED(a_BlockX); @@ -270,6 +271,16 @@ bool cPlugin::OnUpdatedSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_ +bool cPlugin::OnWeatherChanged(cWorld * a_World) +{ + UNUSED(a_World); + return false; +} + + + + + void cPlugin::AddCommand(const AString & a_Command, const AString & a_Description, const AString & a_Permission) { CommandStruct Command; -- cgit v1.2.3