Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Testing AStyle

  • Loading branch information...
commit 5d47fd57d3311861d3049e88f297611dfa283e09 1 parent 6f4bc2c
HAR authored
Showing with 6,661 additions and 5,537 deletions.
  1. +85 −84 src/blocks/basic.cpp
  2. +12 −12 src/blocks/basic.h
  3. +32 −28 src/blocks/blockfurnace.cpp
  4. +2 −2 src/blocks/blockfurnace.h
  5. +27 −21 src/blocks/cake.cpp
  6. +46 −42 src/blocks/chest.cpp
  7. +1 −1  src/blocks/chest.h
  8. +22 −18 src/blocks/default.cpp
  9. +9 −9 src/blocks/default.h
  10. +110 −98 src/blocks/door.cpp
  11. +9 −9 src/blocks/door.h
  12. +21 −18 src/blocks/dyed.cpp
  13. +47 −46 src/blocks/falling.cpp
  14. +10 −10 src/blocks/fire.cpp
  15. +8 −8 src/blocks/fire.h
  16. +29 −21 src/blocks/ladder.cpp
  17. +97 −97 src/blocks/ladder.h
  18. +28 −22 src/blocks/liquid.cpp
  19. +9 −9 src/blocks/liquid.h
  20. +48 −45 src/blocks/note.cpp
  21. +2 −2 src/blocks/note.h
  22. +226 −183 src/blocks/plant.cpp
  23. +19 −18 src/blocks/plant.h
  24. +45 −45 src/blocks/sign.cpp
  25. +8 −8 src/blocks/sign.h
  26. +31 −29 src/blocks/snow.cpp
  27. +8 −8 src/blocks/snow.h
  28. +6 −6 src/blocks/stair.cpp
  29. +8 −8 src/blocks/stair.h
  30. +44 −42 src/blocks/torch.cpp
  31. +9 −9 src/blocks/torch.h
  32. +166 −163 src/blocks/tracks.cpp
  33. +15 −15 src/blocks/workbench.cpp
  34. +1 −1  src/blocks/workbench.h
  35. +48 −43 src/chat.cpp
  36. +41 −38 src/chunkmap.h
  37. +15 −15 src/cliScreen.cpp
  38. +1 −1  src/cliScreen.h
  39. +8 −8 src/config.cpp
  40. +1 −1  src/config.h
  41. +41 −41 src/config/lexer.cpp
  42. +70 −69 src/config/node.cpp
  43. +7 −4 src/config/node.h
  44. +19 −19 src/config/parser.cpp
  45. +4 −4 src/config/scanner.cpp
  46. +2 −2 src/constants.cpp
  47. +6 −6 src/constants.h
  48. +73 −38 src/furnace.cpp
  49. +42 −15 src/furnace.h
  50. +9 −9 src/furnaceManager.cpp
  51. +3 −3 src/furnaceManager.h
  52. +699 −663 src/hook.h
  53. +486 −424 src/inventory.cpp
  54. +35 −26 src/inventory.h
  55. +9 −5 src/items/food.cpp
  56. +1 −1  src/items/itembasic.cpp
  57. +1 −1  src/items/itembasic.h
  58. +8 −7 src/items/projectile.cpp
  59. +5 −4 src/kit.h
  60. +138 −98 src/lighting.cpp
  61. +20 −15 src/lighting.h
  62. +1 −1  src/logger.cpp
  63. +12 −12 src/logtype.h
  64. +448 −407 src/map.cpp
  65. +11 −11 src/map.h
  66. +134 −112 src/mineserver.cpp
  67. +79 −25 src/mineserver.h
  68. +141 −67 src/mob.cpp
  69. +11 −5 src/mob.h
  70. +162 −91 src/nbt.cpp
  71. +20 −20 src/nbt.h
  72. +387 −349 src/packets.cpp
  73. +60 −58 src/packets.h
  74. +84 −40 src/physics.cpp
  75. +1 −1  src/physics.h
  76. +71 −71 src/plugin.cpp
  77. +39 −33 src/plugin.h
  78. +257 −129 src/plugin_api.cpp
  79. +49 −49 src/plugin_api.h
  80. +165 −144 src/plugins/PyScript/PyScript.cpp
  81. +12 −12 src/plugins/PyScript/PyScript.h
  82. +48 −29 src/plugins/PyScript/python_plugin_api.cpp
  83. +7 −7 src/plugins/PyScript/python_plugin_api.h
  84. +4 −3 src/screenBase.cpp
  85. +1 −1  src/screenBase.h
  86. +25 −25 src/sockets.cpp
  87. +1 −1  src/sockets.h
  88. +29 −23 src/tools.cpp
  89. +23 −18 src/tools.h
  90. +42 −42 src/tree.cpp
  91. +39 −16 src/tree.h
  92. +426 −358 src/user.cpp
  93. +7 −7 src/user.h
  94. +14 −14 src/vec.h
  95. +279 −208 src/worldgen/biomegen.cpp
  96. +7 −7 src/worldgen/biomegen.h
  97. +8 −8 src/worldgen/cavegen.cpp
  98. +1 −1  src/worldgen/cavegen.h
  99. +128 −112 src/worldgen/heavengen.cpp
  100. +12 −11 src/worldgen/heavengen.h
  101. +207 −166 src/worldgen/mapgen.cpp
  102. +11 −11 src/worldgen/mapgen.h
  103. +154 −124 src/worldgen/nethergen.cpp
  104. +12 −11 src/worldgen/nethergen.h
View
169 src/blocks/basic.cpp
@@ -34,7 +34,8 @@
#include "basic.h"
-bool BlockBasic::affectedBlock(int block){
+bool BlockBasic::affectedBlock(int block)
+{
return false;
}
@@ -44,26 +45,26 @@ bool BlockBasic::isBlockStackable(const uint8_t block)
/* Check block below allows blocks placed on top */
switch(block)
{
- case BLOCK_WORKBENCH:
- case BLOCK_CHEST:
- case BLOCK_JUKEBOX:
- case BLOCK_TORCH:
- case BLOCK_REDSTONE_TORCH_OFF:
- case BLOCK_REDSTONE_TORCH_ON:
- case BLOCK_WATER:
- case BLOCK_STATIONARY_WATER:
- case BLOCK_LAVA:
- case BLOCK_STATIONARY_LAVA:
- case BLOCK_AIR:
- case BLOCK_MINECART_TRACKS:
- case BLOCK_WOODEN_DOOR:
- case BLOCK_IRON_DOOR:
- case BLOCK_ICE:
- case BLOCK_CAKE:
- return false;
- break;
- default:
- break;
+ case BLOCK_WORKBENCH:
+ case BLOCK_CHEST:
+ case BLOCK_JUKEBOX:
+ case BLOCK_TORCH:
+ case BLOCK_REDSTONE_TORCH_OFF:
+ case BLOCK_REDSTONE_TORCH_ON:
+ case BLOCK_WATER:
+ case BLOCK_STATIONARY_WATER:
+ case BLOCK_LAVA:
+ case BLOCK_STATIONARY_LAVA:
+ case BLOCK_AIR:
+ case BLOCK_MINECART_TRACKS:
+ case BLOCK_WOODEN_DOOR:
+ case BLOCK_IRON_DOOR:
+ case BLOCK_ICE:
+ case BLOCK_CAKE:
+ return false;
+ break;
+ default:
+ break;
}
return true;
@@ -75,11 +76,11 @@ bool BlockBasic::isUserOnBlock(const int32_t x, const int8_t y, const int32_t z,
for(unsigned int i = 0; i < User::all().size(); i++)
{
/* don't allow block placement on top of player */
- if (User::all()[i]->checkOnBlock(x,y,z))
+ if(User::all()[i]->checkOnBlock(x, y, z))
@winex
winex added a note

hmm, why not if ( as stated in CodingStyle?

most other stuff is perfect, maybe except for #include indentation in #ifdef-#endifs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
{
return true;
}
- if (User::all()[i]->checkOnBlock(x,y-1,z))
+ if(User::all()[i]->checkOnBlock(x, y - 1, z))
{
return true;
}
@@ -88,35 +89,35 @@ bool BlockBasic::isUserOnBlock(const int32_t x, const int8_t y, const int32_t z,
return false;
}
-bool BlockBasic::translateDirection(int32_t *x, int8_t *y, int32_t *z, int map,const int8_t direction)
+bool BlockBasic::translateDirection(int32_t* x, int8_t* y, int32_t* z, int map, const int8_t direction)
{
uint8_t block, meta;
- Mineserver::get()->map(map)->getBlock(*x,*y,*z,&block,&meta);
- if (block != BLOCK_SNOW)
+ Mineserver::get()->map(map)->getBlock(*x, *y, *z, &block, &meta);
+ if(block != BLOCK_SNOW)
{
switch(direction)
{
- case BLOCK_SOUTH:
- *x-=1;
- break;
- case BLOCK_NORTH:
- *x+=1;
- break;
- case BLOCK_EAST:
- *z+=1;
- break;
- case BLOCK_WEST:
- *z-=1;
- break;
- case BLOCK_TOP:
- *y+=1;
- break;
- case BLOCK_BOTTOM:
- *y-=1;
- break;
- default:
- return false;
- break;
+ case BLOCK_SOUTH:
+ *x -= 1;
+ break;
+ case BLOCK_NORTH:
+ *x += 1;
+ break;
+ case BLOCK_EAST:
+ *z += 1;
+ break;
+ case BLOCK_WEST:
+ *z -= 1;
+ break;
+ case BLOCK_TOP:
+ *y += 1;
+ break;
+ case BLOCK_BOTTOM:
+ *y -= 1;
+ break;
+ default:
+ return false;
+ break;
}
}
return true;
@@ -137,15 +138,15 @@ bool BlockBasic::spawnBlockItem(const int32_t x, const int8_t y, const int32_t z
{
Drop* drop = NULL;
- if (BLOCKDROPS.count(block))
+ if(BLOCKDROPS.count(block))
{
drop = BLOCKDROPS[block];
- while (drop)
+ while(drop)
{
- if ((int)drop->probability >= rand() % 10000)
+ if((int)drop->probability >= rand() % 10000)
{
- if (drop->count)
+ if(drop->count)
{
Mineserver::get()->map(map)->createPickupSpawn(x, y, z, drop->item_id, drop->count, meta, NULL);
}
@@ -161,50 +162,50 @@ bool BlockBasic::spawnBlockItem(const int32_t x, const int8_t y, const int32_t z
return false;
}
-void BlockBasic::notifyNeighbours(const int32_t x, const int8_t y, const int32_t z, const int map, const std::string callback, User* user,const uint8_t oldblock, const int8_t ignore_direction)
+void BlockBasic::notifyNeighbours(const int32_t x, const int8_t y, const int32_t z, const int map, const std::string callback, User* user, const uint8_t oldblock, const int8_t ignore_direction)
{
uint8_t block;
uint8_t meta;
-//why is this commented out?
+ //why is this commented out?
-/* Function::invoker_type inv(user, oldblock, x, y, z, 0);
+ /* Function::invoker_type inv(user, oldblock, x, y, z, 0);
- if (ignore_direction != BLOCK_SOUTH && Mineserver::get()->map(map)->getBlock(x+1, y, z, &block, &meta) && block != BLOCK_AIR)
- {
- inv = Function::invoker_type(user, oldblock, x+1, y, z, BLOCK_SOUTH);
- Mineserver::get()->plugin()->runBlockCallback(block, callback, inv);
- }
+ if (ignore_direction != BLOCK_SOUTH && Mineserver::get()->map(map)->getBlock(x+1, y, z, &block, &meta) && block != BLOCK_AIR)
+ {
+ inv = Function::invoker_type(user, oldblock, x+1, y, z, BLOCK_SOUTH);
+ Mineserver::get()->plugin()->runBlockCallback(block, callback, inv);
+ }
- if (ignore_direction != BLOCK_NORTH && Mineserver::get()->map(map)->getBlock(x-1, y, z, &block, &meta) && block != BLOCK_AIR)
- {
- inv = Function::invoker_type(user, oldblock, x-1, y, z, BLOCK_NORTH);
- Mineserver::get()->plugin()->runBlockCallback(block, callback, inv);
- }
+ if (ignore_direction != BLOCK_NORTH && Mineserver::get()->map(map)->getBlock(x-1, y, z, &block, &meta) && block != BLOCK_AIR)
+ {
+ inv = Function::invoker_type(user, oldblock, x-1, y, z, BLOCK_NORTH);
+ Mineserver::get()->plugin()->runBlockCallback(block, callback, inv);
+ }
- if (y < 127 && ignore_direction != BLOCK_TOP && Mineserver::get()->map(map)->getBlock(x, y+1, z, &block, &meta) && block != BLOCK_AIR)
- {
- inv = Function::invoker_type(user, oldblock, x, y+1, z, BLOCK_TOP);
- Mineserver::get()->plugin()->runBlockCallback(block, callback, inv);
- }
+ if (y < 127 && ignore_direction != BLOCK_TOP && Mineserver::get()->map(map)->getBlock(x, y+1, z, &block, &meta) && block != BLOCK_AIR)
+ {
+ inv = Function::invoker_type(user, oldblock, x, y+1, z, BLOCK_TOP);
+ Mineserver::get()->plugin()->runBlockCallback(block, callback, inv);
+ }
- if (y > 0 && ignore_direction != BLOCK_BOTTOM && Mineserver::get()->map(map)->getBlock(x, y-1, z, &block, &meta) && block != BLOCK_AIR)
- {
- inv = Function::invoker_type(user, oldblock, x, y-1, z, BLOCK_BOTTOM);
- Mineserver::get()->plugin()->runBlockCallback(block, callback, inv);
- }
+ if (y > 0 && ignore_direction != BLOCK_BOTTOM && Mineserver::get()->map(map)->getBlock(x, y-1, z, &block, &meta) && block != BLOCK_AIR)
+ {
+ inv = Function::invoker_type(user, oldblock, x, y-1, z, BLOCK_BOTTOM);
+ Mineserver::get()->plugin()->runBlockCallback(block, callback, inv);
+ }
- if (ignore_direction != BLOCK_WEST && Mineserver::get()->map(map)->getBlock(x, y, z+1, &block, &meta) && block != BLOCK_AIR)
- {
- inv = Function::invoker_type(user, oldblock, x, y, z+1, BLOCK_WEST);
- Mineserver::get()->plugin()->runBlockCallback(block, callback, inv);
- }
+ if (ignore_direction != BLOCK_WEST && Mineserver::get()->map(map)->getBlock(x, y, z+1, &block, &meta) && block != BLOCK_AIR)
+ {
+ inv = Function::invoker_type(user, oldblock, x, y, z+1, BLOCK_WEST);
+ Mineserver::get()->plugin()->runBlockCallback(block, callback, inv);
+ }
- if (ignore_direction != BLOCK_EAST && Mineserver::get()->map(map)->getBlock(x, y, z-1, &block, &meta) && block != BLOCK_AIR)
- {
- inv = Function::invoker_type(user, oldblock, x, y, z-1, BLOCK_EAST);
- Mineserver::get()->plugin()->runBlockCallback(block, callback, inv);
- }*/
+ if (ignore_direction != BLOCK_EAST && Mineserver::get()->map(map)->getBlock(x, y, z-1, &block, &meta) && block != BLOCK_AIR)
+ {
+ inv = Function::invoker_type(user, oldblock, x, y, z-1, BLOCK_EAST);
+ Mineserver::get()->plugin()->runBlockCallback(block, callback, inv);
+ }*/
}
void BlockBasic::onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
View
24 src/blocks/basic.h
@@ -45,26 +45,26 @@ class BlockBasic
virtual bool affectedBlock(int block);
virtual void notifyNeighbours(const int32_t x, const int8_t y, const int32_t z, const int map, const std::string callback, User* user, const uint8_t oldblock, const int8_t ignore_direction);
- virtual void timer200(){ }
+ virtual void timer200() { }
virtual void onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- virtual void onDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z,int map, int8_t direction);
- virtual void onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z,int map, int8_t direction);
- virtual bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z,int map, int8_t direction);
- virtual void onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z,int map, int8_t direction);
- virtual bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z,int map, int8_t direction);
- virtual void onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z,int map, int8_t direction);
- virtual void onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z,int map, int8_t direction);
+ virtual void onDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ virtual void onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ virtual bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ virtual void onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ virtual bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ virtual void onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ virtual void onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
virtual void onNeighbourMove(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int8_t direction);
virtual bool onInteract(User* user, int32_t x, int8_t y, int32_t z, int map);
void revertBlock(User* user, int32_t x, int8_t y, int32_t z, int map);
-
+
protected:
bool isBlockStackable(const uint8_t block);
- bool isUserOnBlock(const int32_t x, const int8_t y, const int32_t z,const int map);
- virtual bool translateDirection(int32_t *x, int8_t *y, int32_t *z, const int map, const int8_t direction);
+ bool isUserOnBlock(const int32_t x, const int8_t y, const int32_t z, const int map);
+ virtual bool translateDirection(int32_t* x, int8_t* y, int32_t* z, const int map, const int8_t direction);
bool isBlockEmpty(const int32_t x, const int8_t y, const int32_t z, const int map);
- bool spawnBlockItem(const int32_t x, const int8_t y, const int32_t z, const int map, const uint8_t block, uint8_t meta=0);
+ bool spawnBlockItem(const int32_t x, const int8_t y, const int32_t z, const int map, const uint8_t block, uint8_t meta = 0);
};
#endif
View
60 src/blocks/blockfurnace.cpp
@@ -47,35 +47,35 @@ bool BlockFurnace::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, in
uint8_t oldblock;
uint8_t oldmeta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* Check block below allows blocks placed on top */
- if (!this->isBlockStackable(oldblock))
+ if(!this->isBlockStackable(oldblock))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* move the x,y,z coords dependent upon placement direction */
- if (!this->translateDirection(&x,&y,&z,map,direction))
+ if(!this->translateDirection(&x, &y, &z, map, direction))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (this->isUserOnBlock(x,y,z,map))
+ if(this->isUserOnBlock(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (!this->isBlockEmpty(x,y,z,map))
+ if(!this->isBlockEmpty(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
@@ -87,19 +87,21 @@ bool BlockFurnace::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, in
int chunk_x = blockToChunk(x);
int chunk_z = blockToChunk(z);
- sChunk *chunk = Mineserver::get()->map(map)->loadMap(chunk_x, chunk_z);
-
+ sChunk* chunk = Mineserver::get()->map(map)->loadMap(chunk_x, chunk_z);
+
if(chunk == NULL)
- revertBlock(user,x,y,z,map);
- return true;
+ {
+ revertBlock(user, x, y, z, map);
+ }
+ return true;
for(uint32_t i = 0; i < chunk->furnaces.size(); i++)
{
if(chunk->furnaces[i]->x == x &&
- chunk->furnaces[i]->y == y &&
- chunk->furnaces[i]->z == z)
+ chunk->furnaces[i]->y == y &&
+ chunk->furnaces[i]->z == z)
{
- chunk->furnaces.erase(chunk->furnaces.begin()+i);
+ chunk->furnaces.erase(chunk->furnaces.begin() + i);
break;
}
}
@@ -109,45 +111,47 @@ bool BlockFurnace::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, in
bool BlockFurnace::onInteract(User* user, int32_t x, int8_t y, int32_t z, int map)
{
- Mineserver::get()->inventory()->windowOpen(user,WINDOW_FURNACE,x, y, z);
+ Mineserver::get()->inventory()->windowOpen(user, WINDOW_FURNACE, x, y, z);
return true;
}
-bool BlockFurnace::onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z,int map, int8_t direction)
+bool BlockFurnace::onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
uint8_t block;
uint8_t meta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &block, &meta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &block, &meta))
{
return true;
}
bool destroy = false;
-
+
int chunk_x = blockToChunk(x);
int chunk_z = blockToChunk(z);
- sChunk *chunk = Mineserver::get()->map(map)->loadMap(chunk_x, chunk_z);
-
+ sChunk* chunk = Mineserver::get()->map(map)->loadMap(chunk_x, chunk_z);
+
if(chunk == NULL)
+ {
return true;
-
+ }
+
for(uint32_t i = 0; i < chunk->furnaces.size(); i++)
{
if(chunk->furnaces[i]->x == x &&
- chunk->furnaces[i]->y == y &&
- chunk->furnaces[i]->z == z)
+ chunk->furnaces[i]->y == y &&
+ chunk->furnaces[i]->z == z)
{
- chunk->furnaces.erase(chunk->furnaces.begin()+i);
+ chunk->furnaces.erase(chunk->furnaces.begin() + i);
break;
}
}
Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
- this->spawnBlockItem(x,y,z,map,block);
+ this->spawnBlockItem(x, y, z, map, block);
return false;
}
View
4 src/blocks/blockfurnace.h
@@ -40,7 +40,7 @@ class BlockFurnace : public BlockBasic
{
public:
bool affectedBlock(int block);
- bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z,int map, int8_t direction);
+ bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
bool onInteract(User* user, int32_t x, int8_t y, int32_t z, int map);
- bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z,int map, int8_t direction);
+ bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
};
View
48 src/blocks/cake.cpp
@@ -35,9 +35,9 @@ bool BlockCake::affectedBlock(int block)
{
switch(block)
{
- case BLOCK_CAKE:
- case ITEM_CAKE:
- return true;
+ case BLOCK_CAKE:
+ case ITEM_CAKE:
+ return true;
}
return false;
}
@@ -47,36 +47,36 @@ bool BlockCake::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32
uint8_t oldblock;
uint8_t oldmeta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* Check block below allows blocks placed on top */
- if (!this->isBlockStackable(oldblock))
+ if(!this->isBlockStackable(oldblock))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* move the x,y,z coords dependent upon placement direction */
- if (!this->translateDirection(&x,&y,&z,map,direction))
+ if(!this->translateDirection(&x, &y, &z, map, direction))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (this->isUserOnBlock(x,y,z,map))
+ if(this->isUserOnBlock(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (!this->isBlockEmpty(x,y,z,map))
+ if(!this->isBlockEmpty(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
- return true;
+ revertBlock(user, x, y, z, map);
+ return true;
}
Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_CAKE, 0);
@@ -91,25 +91,29 @@ bool BlockCake::onInteract(User* user, int32_t x, int8_t y, int32_t z, int map)
Mineserver::get()->map(map)->getBlock(x, y, z, &block, &metadata);
metadata = metadata + 1;
int healammount = 3;
- int newhealth = user->health+healammount;
+ int newhealth = user->health + healammount;
if(metadata < 6)
{
- if(newhealth > 20)
- newhealth=20;
+ if(newhealth > 20)
+ {
+ newhealth = 20;
+ }
user->sethealth(newhealth);
Mineserver::get()->map(map)->setBlock(x, y, z, block, metadata);
Mineserver::get()->map(map)->sendBlockChange(x, y, z, (char)block, metadata);
}
else
{
- if(newhealth > 20)
- newhealth=20;
+ if(newhealth > 20)
+ {
+ newhealth = 20;
+ }
user->sethealth(newhealth);
Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
}
- return false;
+ return false;
}
void BlockCake::onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
@@ -124,8 +128,10 @@ bool BlockCake::onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t
uint8_t block;
uint8_t meta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z,&block, &meta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &block, &meta))
+ {
return true;
+ }
Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
View
88 src/blocks/chest.cpp
@@ -49,19 +49,19 @@ bool BlockChest::affectedBlock(int block)
void BlockChest::onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
// Locksystem
- if(user->inv[36+user->currentItemSlot()].getType() == ITEM_WOODEN_AXE)
- {
+ if(user->inv[36 + user->currentItemSlot()].getType() == ITEM_WOODEN_AXE)
+ {
int chunk_x = blockToChunk(x);
int chunk_z = blockToChunk(z);
- sChunk *chunk = Mineserver::get()->map(map)->loadMap(chunk_x, chunk_z);
+ sChunk* chunk = Mineserver::get()->map(map)->loadMap(chunk_x, chunk_z);
if(chunk == NULL)
{
return;
}
- NBT_Value *entityList = (*(*(chunk->nbt))["Level"])["TileEntities"];
+ NBT_Value* entityList = (*(*(chunk->nbt))["Level"])["TileEntities"];
if(!entityList)
{
@@ -81,12 +81,12 @@ void BlockChest::onStartedDigging(User* user, int8_t status, int32_t x, int8_t y
//bool done = false; // Unused variable
- for( ; iter != end; iter++ )
+ for(; iter != end; iter++)
{
if((**iter)["x"] == NULL || (**iter)["y"] == NULL || (**iter)["z"] == NULL ||
- (**iter)["x"]->GetType() != NBT_Value::TAG_INT ||
- (**iter)["y"]->GetType() != NBT_Value::TAG_INT ||
- (**iter)["z"]->GetType() != NBT_Value::TAG_INT)
+ (**iter)["x"]->GetType() != NBT_Value::TAG_INT ||
+ (**iter)["y"]->GetType() != NBT_Value::TAG_INT ||
+ (**iter)["z"]->GetType() != NBT_Value::TAG_INT)
{
continue;
}
@@ -94,7 +94,7 @@ void BlockChest::onStartedDigging(User* user, int8_t status, int32_t x, int8_t y
if((int32_t)(*(**iter)["x"]) == x && (int32_t)(*(**iter)["y"]) == y && (int32_t)(*(**iter)["z"]) == z)
{
int8_t locked;
- NBT_Value *nbtLockdata = (**iter)["Lockdata"];
+ NBT_Value* nbtLockdata = (**iter)["Lockdata"];
if(nbtLockdata != NULL)
{
std::string player = *(*nbtLockdata)["player"]->GetString();
@@ -102,9 +102,9 @@ void BlockChest::onStartedDigging(User* user, int8_t status, int32_t x, int8_t y
if(player == user->nick)
{
locked = *(*nbtLockdata)["locked"];
- locked = (locked==1)?0:1;
+ locked = (locked == 1) ? 0 : 1;
*(*nbtLockdata)["locked"] = locked;
-
+
if(locked == 1)
{
Mineserver::get()->chat()->sendMsg(user, MC_COLOR_RED + "Chest locked", Chat::USER);
@@ -113,13 +113,13 @@ void BlockChest::onStartedDigging(User* user, int8_t status, int32_t x, int8_t y
{
Mineserver::get()->chat()->sendMsg(user, MC_COLOR_RED + "Chest opened", Chat::USER);
}
-
+
}
- }
- else
+ }
+ else
{
// If lockdata is missing (old chest)
- NBT_Value *nbtLock = new NBT_Value(NBT_Value::TAG_COMPOUND);
+ NBT_Value* nbtLock = new NBT_Value(NBT_Value::TAG_COMPOUND);
nbtLock->Insert("player", new NBT_Value(user->nick));
nbtLock->Insert("locked", new NBT_Value((int8_t)1));
(*iter)->Insert("Lockdata", nbtLock);
@@ -146,47 +146,51 @@ bool BlockChest::onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_
uint8_t block;
uint8_t meta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &block, &meta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &block, &meta))
+ {
return true;
+ }
bool destroy = false;
-
+
int chunk_x = blockToChunk(x);
int chunk_z = blockToChunk(z);
- sChunk *chunk = Mineserver::get()->map(map)->loadMap(chunk_x, chunk_z);
-
+ sChunk* chunk = Mineserver::get()->map(map)->loadMap(chunk_x, chunk_z);
+
if(chunk == NULL)
+ {
return true;
-
+ }
+
for(uint32_t i = 0; i < chunk->chests.size(); i++)
{
if(chunk->chests[i]->x == x &&
- chunk->chests[i]->y == y &&
- chunk->chests[i]->z == z)
+ chunk->chests[i]->y == y &&
+ chunk->chests[i]->z == z)
{
for(uint32_t item_i = 0; item_i < 27; item_i++)
{
if(chunk->chests[i]->items[item_i].getType() != -1)
{
- Mineserver::get()->map(map)->createPickupSpawn( chunk->chests[i]->x,
- chunk->chests[i]->y,
- chunk->chests[i]->z,
- chunk->chests[i]->items[item_i].getType(),
- chunk->chests[i]->items[item_i].getCount(),
- chunk->chests[i]->items[item_i].getHealth(),
- NULL);
+ Mineserver::get()->map(map)->createPickupSpawn(chunk->chests[i]->x,
+ chunk->chests[i]->y,
+ chunk->chests[i]->z,
+ chunk->chests[i]->items[item_i].getType(),
+ chunk->chests[i]->items[item_i].getCount(),
+ chunk->chests[i]->items[item_i].getHealth(),
+ NULL);
}
}
- chunk->chests.erase(chunk->chests.begin()+i);
+ chunk->chests.erase(chunk->chests.begin() + i);
break;
}
}
Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
- this->spawnBlockItem(x,y,z,map,block);
+ this->spawnBlockItem(x, y, z, map, block);
return false;
}
@@ -200,35 +204,35 @@ bool BlockChest::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int3
uint8_t oldblock;
uint8_t oldmeta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* Check block below allows blocks placed on top */
- if (!this->isBlockStackable(oldblock))
+ if(!this->isBlockStackable(oldblock))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* move the x,y,z coords dependent upon placement direction */
- if (!this->translateDirection(&x,&y,&z,map,direction))
+ if(!this->translateDirection(&x, &y, &z, map, direction))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (this->isUserOnBlock(x,y,z,map))
+ if(this->isUserOnBlock(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (!this->isBlockEmpty(x,y,z,map))
+ if(!this->isBlockEmpty(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
@@ -255,6 +259,6 @@ void BlockChest::onNeighbourMove(User* user, int16_t oldblock, int32_t x, int8_t
bool BlockChest::onInteract(User* user, int32_t x, int8_t y, int32_t z, int map)
{
//ToDo: check for large chest!
- Mineserver::get()->inventory()->windowOpen(user,WINDOW_CHEST,x, y, z);
+ Mineserver::get()->inventory()->windowOpen(user, WINDOW_CHEST, x, y, z);
return true;
}
View
2  src/blocks/chest.h
@@ -45,7 +45,7 @@ class BlockChest : public BlockBasic
void onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y, int map, int32_t z, int8_t direction);
bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
void onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z,int map, int8_t direction);
+ bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
void onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
void onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
void onNeighbourMove(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
View
40 src/blocks/default.cpp
@@ -53,19 +53,20 @@ bool BlockDefault::onBroken(User* user, int8_t status, int32_t x, int8_t y, int3
uint8_t block;
uint8_t meta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z,&block, &meta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &block, &meta))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if(block != BLOCK_GRAY_CLOTH && block != BLOCK_WOOD){
+ if(block != BLOCK_GRAY_CLOTH && block != BLOCK_WOOD)
+ {
// Only Cloth and Wood have colour metadata
meta = 0;
}
Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
- this->spawnBlockItem(x,y,z,map,block,meta);
+ this->spawnBlockItem(x, y, z, map, block, meta);
return false;
}
@@ -78,42 +79,45 @@ bool BlockDefault::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, in
uint8_t oldblock;
uint8_t oldmeta;
- if(newblock > 255){ return true; }
+ if(newblock > 255)
+ {
+ return true;
+ }
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* Check block below allows blocks placed on top */
- if (!this->isBlockStackable(oldblock))
+ if(!this->isBlockStackable(oldblock))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (!this->translateDirection(&x,&y,&z,map,direction))
+ if(!this->translateDirection(&x, &y, &z, map, direction))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (this->isUserOnBlock(x,y,z,map))
+ if(this->isUserOnBlock(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (!this->isBlockEmpty(x,y,z,map))
+ if(!this->isBlockEmpty(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
- return true;
+ revertBlock(user, x, y, z, map);
+ return true;
}
//direction = user->relativeToBlock(x, y, z);
- if(newblock<256)
+ if(newblock < 256)
{
Mineserver::get()->map(map)->setBlock(x, y, z, (char)newblock, 0);
Mineserver::get()->map(map)->sendBlockChange(x, y, z, (char)newblock, 0);
@@ -133,7 +137,7 @@ void BlockDefault::onReplace(User* user, int16_t newblock, int32_t x, int8_t y,
uint8_t oldblock;
uint8_t oldmeta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
{
return;
}
View
18 src/blocks/default.h
@@ -39,14 +39,14 @@ class BlockDefault: public BlockBasic
public:
bool affectedBlock(int block);
- void onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onNeighbourMove(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onNeighbourMove(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
};
View
208 src/blocks/door.cpp
@@ -47,7 +47,7 @@ bool BlockDoor::affectedBlock(int block)
void BlockDoor::onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
- uint8_t block,metadata;
+ uint8_t block, metadata;
Mineserver::get()->map(map)->getBlock(x, y, z, &block, &metadata);
// Toggle door state
@@ -55,18 +55,22 @@ void BlockDoor::onStartedDigging(User* user, int8_t status, int32_t x, int8_t y,
uint8_t metadata2, block2;
- int modifier = ((metadata & 0x8)==0x8) ? -1 : 1;
+ int modifier = ((metadata & 0x8) == 0x8) ? -1 : 1;
Mineserver::get()->map(map)->setBlock(x, y, z, block, metadata);
- Mineserver::get()->map(map)->sendBlockChange(x, y, z, (char)block, metadata);
+ Mineserver::get()->map(map)->sendBlockChange(x, y, z, (char)block, metadata);
Mineserver::get()->map(map)->getBlock(x, y + modifier, z, &block2, &metadata2);
- if (block2 == block)
+ if(block2 == block)
{
if((metadata2 & 0x4) && !(metadata & 0x4))
+ {
metadata2 ^= 0x4;
+ }
else if(!(metadata2 & 0x4) && (metadata & 0x4))
+ {
metadata2 ^= 0x4;
+ }
Mineserver::get()->map(map)->setBlock(x, y + modifier, z, block2, metadata2);
Mineserver::get()->map(map)->sendBlockChange(x, y + modifier, z, (char)block, metadata2);
@@ -86,14 +90,14 @@ void BlockDoor::onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y,
bool BlockDoor::onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
// get block info
- uint8_t block,metadata;
+ uint8_t block, metadata;
uint8_t metadata2, block2;
Mineserver::get()->map(map)->getBlock(x, y, z, &block, &metadata);
// check if block is the upper part of the door
- int modifier = ((metadata & 0x8)==0x8) ? -1 : 1;
+ int modifier = ((metadata & 0x8) == 0x8) ? -1 : 1;
Mineserver::get()->map(map)->getBlock(x, y + modifier, z, &block2, &metadata2);
// if upper part, remove it
- if (block2 == block)
+ if(block2 == block)
{
Mineserver::get()->map(map)->setBlock(x, y + modifier, z, BLOCK_AIR, 0);
Mineserver::get()->map(map)->sendBlockChange(x, y + modifier, z, BLOCK_AIR, 0);
@@ -101,50 +105,54 @@ bool BlockDoor::onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t
// remove lower part
Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
- this->spawnBlockItem(x, y, z,map, block, 0);
+ this->spawnBlockItem(x, y, z, map, block, 0);
return false;
}
void BlockDoor::onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
-// get block info
- uint8_t block,metadata;
+ // get block info
+ uint8_t block, metadata;
uint8_t metadata2, block2;
Mineserver::get()->map(map)->getBlock(x, y, z, &block, &metadata);
// check if block is the upper part of the door
- int modifier = ((metadata & 0x8)==0x8) ? -1 : 1;
+ int modifier = ((metadata & 0x8) == 0x8) ? -1 : 1;
- Mineserver::get()->map(map)->getBlock(x, y + modifier, z, &block2, &metadata2);
- if (metadata & 0x4)
- {
- metadata &= (0x8 | 0x3);
- }
- else
- {
- metadata |= 0x4;
- }
- // do nothing if the block is not below door
- if(direction == BLOCK_BOTTOM && (block == BLOCK_WOODEN_DOOR || block == BLOCK_IRON_DOOR))
- {
- return;
- }
- // break the door if the block is below it
+ Mineserver::get()->map(map)->getBlock(x, y + modifier, z, &block2, &metadata2);
+ if(metadata & 0x4)
+ {
+ metadata &= (0x8 | 0x3);
+ }
+ else
+ {
+ metadata |= 0x4;
+ }
+ // do nothing if the block is not below door
+ if(direction == BLOCK_BOTTOM && (block == BLOCK_WOODEN_DOOR || block == BLOCK_IRON_DOOR))
+ {
+ return;
+ }
+ // break the door if the block is below it
if(direction == BLOCK_TOP && (block == BLOCK_WOODEN_DOOR || block == BLOCK_IRON_DOOR))
{
- Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
- Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
- this->spawnBlockItem(x, y, z,map, block, 0);
+ Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
+ Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
+ this->spawnBlockItem(x, y, z, map, block, 0);
+
+ Mineserver::get()->map(map)->getBlock(x, y + modifier, z, &block2, &metadata2);
- Mineserver::get()->map(map)->getBlock(x, y + modifier, z, &block2, &metadata2);
+ if(block2 == block)
+ {
+ metadata2 = metadata;
- if (block2 == block)
- {
- metadata2 = metadata;
-
- if(metadata & 0x8)
- metadata2 &= 0x7;
- else
- metadata2 |= 0x8;
+ if(metadata & 0x8)
+ {
+ metadata2 &= 0x7;
+ }
+ else
+ {
+ metadata2 |= 0x8;
+ }
Mineserver::get()->map(map)->setBlock(x, y + modifier, z, BLOCK_AIR, 0);
Mineserver::get()->map(map)->sendBlockChange(x, y + modifier, z, BLOCK_AIR, 0);
@@ -154,67 +162,67 @@ void BlockDoor::onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_
bool BlockDoor::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
- uint8_t oldblock;
- uint8_t oldmeta;
+ uint8_t oldblock;
+ uint8_t oldmeta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* Check block below allows blocks placed on top */
- if (!this->isBlockStackable(oldblock))
+ if(!this->isBlockStackable(oldblock))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* move the x,y,z coords dependent upon placement direction */
- if (!this->translateDirection(&x,&y,&z,map,direction))
+ if(!this->translateDirection(&x, &y, &z, map, direction))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (this->isUserOnBlock(x,y,z,map))
+ if(this->isUserOnBlock(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (!this->isBlockEmpty(x,y,z,map))
+ if(!this->isBlockEmpty(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
// checking for an item rather then a block
- if (newblock == ITEM_WOODEN_DOOR)
+ if(newblock == ITEM_WOODEN_DOOR)
{
- newblock = BLOCK_WOODEN_DOOR;
+ newblock = BLOCK_WOODEN_DOOR;
}
- else if (newblock == ITEM_IRON_DOOR)
+ else if(newblock == ITEM_IRON_DOOR)
{
- newblock = BLOCK_IRON_DOOR;
+ newblock = BLOCK_IRON_DOOR;
}
direction = user->relativeToBlock(x, y, z);
switch(direction)
{
- case BLOCK_EAST:
- direction = BLOCK_WEST;
- break;
- case BLOCK_WEST:
- direction = BLOCK_EAST;
- break;
- case BLOCK_NORTH:
- direction = BLOCK_SOUTH;
- break;
- case BLOCK_SOUTH:
- direction = BLOCK_NORTH;
- break;
+ case BLOCK_EAST:
+ direction = BLOCK_WEST;
+ break;
+ case BLOCK_WEST:
+ direction = BLOCK_EAST;
+ break;
+ case BLOCK_NORTH:
+ direction = BLOCK_SOUTH;
+ break;
+ case BLOCK_SOUTH:
+ direction = BLOCK_NORTH;
+ break;
}
Mineserver::get()->map(map)->setBlock(x, y, z, (char)newblock, direction);
@@ -223,8 +231,8 @@ bool BlockDoor::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32
/* Get correct direction for top of the door */
direction ^= 8;
- Mineserver::get()->map(map)->setBlock(x, y+1, z, (char)newblock, direction);
- Mineserver::get()->map(map)->sendBlockChange(x, y+1, z, (char)newblock, direction);
+ Mineserver::get()->map(map)->setBlock(x, y + 1, z, (char)newblock, direction);
+ Mineserver::get()->map(map)->sendBlockChange(x, y + 1, z, (char)newblock, direction);
return false;
}
@@ -238,37 +246,41 @@ void BlockDoor::onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int
bool BlockDoor::onInteract(User* user, int32_t x, int8_t y, int32_t z, int map)
{
- uint8_t block,metadata;
+ uint8_t block, metadata;
uint8_t metadata2, block2;
Mineserver::get()->map(map)->getBlock(x, y, z, &block, &metadata);
- int modifier = ((metadata & 0x8)==0x8) ? -1 : 1;
+ int modifier = ((metadata & 0x8) == 0x8) ? -1 : 1;
- Mineserver::get()->map(map)->getBlock(x, y + modifier, z, &block2, &metadata2);
- if (metadata & 0x4)
- {
- metadata &= (0x8 | 0x3);
- }
- else
- {
- metadata |= 0x4;
- }
-
- Mineserver::get()->map(map)->setBlock(x, y, z, block, metadata);
- Mineserver::get()->map(map)->sendBlockChange(x, y, z, (char)block, metadata);
-
- Mineserver::get()->map(map)->getBlock(x, y + modifier, z, &block2, &metadata2);
-
- if (block2 == block)
- {
- metadata2 = metadata;
-
- if(metadata & 0x8)
- metadata2 &= 0x7;
- else
- metadata2 |= 0x8;
-
- Mineserver::get()->map(map)->setBlock(x, y + modifier, z, block2, metadata2);
- Mineserver::get()->map(map)->sendBlockChange(x, y + modifier, z, (char)block, metadata2);
- }
- return false;
+ Mineserver::get()->map(map)->getBlock(x, y + modifier, z, &block2, &metadata2);
+ if(metadata & 0x4)
+ {
+ metadata &= (0x8 | 0x3);
+ }
+ else
+ {
+ metadata |= 0x4;
+ }
+
+ Mineserver::get()->map(map)->setBlock(x, y, z, block, metadata);
+ Mineserver::get()->map(map)->sendBlockChange(x, y, z, (char)block, metadata);
+
+ Mineserver::get()->map(map)->getBlock(x, y + modifier, z, &block2, &metadata2);
+
+ if(block2 == block)
+ {
+ metadata2 = metadata;
+
+ if(metadata & 0x8)
+ {
+ metadata2 &= 0x7;
+ }
+ else
+ {
+ metadata2 |= 0x8;
+ }
+
+ Mineserver::get()->map(map)->setBlock(x, y + modifier, z, block2, metadata2);
+ Mineserver::get()->map(map)->sendBlockChange(x, y + modifier, z, (char)block, metadata2);
+ }
+ return false;
}
View
18 src/blocks/door.h
@@ -40,14 +40,14 @@ class BlockDoor : public BlockBasic
public:
bool affectedBlock(int block);
- void onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int map, int32_t z, int8_t direction);
- void onDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- bool onInteract(User* user, int32_t x, int8_t y, int32_t z, int map);
+ void onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int map, int32_t z, int8_t direction);
+ void onDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ bool onInteract(User* user, int32_t x, int8_t y, int32_t z, int map);
};
View
39 src/blocks/dyed.cpp
@@ -32,7 +32,8 @@
bool BlockDyed::affectedBlock(int block)
{
- switch(block){
+ switch(block)
+ {
case BLOCK_GRAY_CLOTH:
case BLOCK_WOOD:
case BLOCK_STEP:
@@ -46,55 +47,57 @@ bool BlockDyed::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32
uint8_t oldblock;
uint8_t oldmeta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
//Combine two steps
if(newblock == BLOCK_STEP && oldblock == BLOCK_STEP && direction == BLOCK_TOP)
{
- Item item = user->inv[user->curItem+36];
+ Item item = user->inv[user->curItem + 36];
- if (item.getHealth() == oldmeta)
+ if(item.getHealth() == oldmeta)
{
Mineserver::get()->map(map)->setBlock(x, y, z, (char)BLOCK_DOUBLE_STEP, oldmeta);
Mineserver::get()->map(map)->sendBlockChange(x, y, z, (char)BLOCK_DOUBLE_STEP, oldmeta);
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
- } else {
- revertBlock(user,x,y,z,map);
+ }
+ else
+ {
+ revertBlock(user, x, y, z, map);
return true;
}
}
/* Check block below allows blocks placed on top */
- if (!this->isBlockStackable(oldblock))
+ if(!this->isBlockStackable(oldblock))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (!this->translateDirection(&x,&y,&z,map,direction))
+ if(!this->translateDirection(&x, &y, &z, map, direction))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (this->isUserOnBlock(x,y,z,map))
+ if(this->isUserOnBlock(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (!this->isBlockEmpty(x,y,z,map))
+ if(!this->isBlockEmpty(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
- return true;
+ revertBlock(user, x, y, z, map);
+ return true;
}
- Item item = user->inv[user->curItem+36];
+ Item item = user->inv[user->curItem + 36];
Mineserver::get()->map(map)->setBlock(x, y, z, (char)newblock, item.getHealth());
Mineserver::get()->map(map)->sendBlockChange(x, y, z, (char)newblock, item.getHealth());
View
93 src/blocks/falling.cpp
@@ -32,7 +32,8 @@
bool BlockFalling::affectedBlock(int block)
{
- switch(block){
+ switch(block)
+ {
case BLOCK_SAND:
case BLOCK_SLOW_SAND:
case BLOCK_GRAVEL:
@@ -44,50 +45,50 @@ bool BlockFalling::affectedBlock(int block)
void BlockFalling::onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
- this->onNeighbourMove(user, oldblock, x, y, z, map, direction);
+ this->onNeighbourMove(user, oldblock, x, y, z, map, direction);
}
bool BlockFalling::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
- uint8_t oldblock;
- uint8_t oldmeta;
+ uint8_t oldblock;
+ uint8_t oldmeta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* Check block below allows blocks placed on top */
- if (!this->isBlockStackable(oldblock))
+ if(!this->isBlockStackable(oldblock))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* move the x,y,z coords dependent upon placement direction */
- if (!this->translateDirection(&x,&y,&z,map, direction))
+ if(!this->translateDirection(&x, &y, &z, map, direction))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (this->isUserOnBlock(x,y,z,map))
+ if(this->isUserOnBlock(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (!this->isBlockEmpty(x,y,z,map))
+ if(!this->isBlockEmpty(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- Mineserver::get()->map(map)->setBlock(x, y, z,(char)newblock, 0);
- Mineserver::get()->map(map)->sendBlockChange(x, y, z,(char)newblock, 0);
+ Mineserver::get()->map(map)->setBlock(x, y, z, (char)newblock, 0);
+ Mineserver::get()->map(map)->sendBlockChange(x, y, z, (char)newblock, 0);
- applyPhysics(user,x,y,z,map);
+ applyPhysics(user, x, y, z, map);
return false;
}
@@ -96,50 +97,50 @@ void BlockFalling::onNeighbourMove(User* user, int16_t oldblock, int32_t x, int8
uint8_t block;
uint8_t meta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &block, &meta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &block, &meta))
{
return;
}
- applyPhysics(user,x,y,z,map);
+ applyPhysics(user, x, y, z, map);
}
void BlockFalling::applyPhysics(User* user, int32_t x, int8_t y, int32_t z, int map)
{
uint8_t fallblock, block;
uint8_t fallmeta, meta;
-
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &fallblock, &fallmeta))
+
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &fallblock, &fallmeta))
{
return;
}
-
- while(Mineserver::get()->map(map)->getBlock(x, y-1, z, &block, &meta))
+
+ while(Mineserver::get()->map(map)->getBlock(x, y - 1, z, &block, &meta))
{
switch(block)
{
- case BLOCK_AIR:
- case BLOCK_WATER:
- case BLOCK_STATIONARY_WATER:
- case BLOCK_LAVA:
- case BLOCK_STATIONARY_LAVA:
- break;
- default:
- // stop falling
- return;
- break;
- }
-
- // Destroy original block
- Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
- Mineserver::get()->map(map)->setBlock(x, y, z,BLOCK_AIR, 0);
-
- y--;
-
- Mineserver::get()->map(map)->setBlock(x, y, z, fallblock, fallmeta);
- Mineserver::get()->map(map)->sendBlockChange(x, y, z, fallblock, fallmeta);
-
- this->notifyNeighbours(x, y+1, z,map, "onNeighbourMove", user, block, BLOCK_BOTTOM);
- }
+ case BLOCK_AIR:
+ case BLOCK_WATER:
+ case BLOCK_STATIONARY_WATER:
+ case BLOCK_LAVA:
+ case BLOCK_STATIONARY_LAVA:
+ break;
+ default:
+ // stop falling
+ return;
+ break;
+ }
+
+ // Destroy original block
+ Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
+ Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
+
+ y--;
+
+ Mineserver::get()->map(map)->setBlock(x, y, z, fallblock, fallmeta);
+ Mineserver::get()->map(map)->sendBlockChange(x, y, z, fallblock, fallmeta);
+
+ this->notifyNeighbours(x, y + 1, z, map, "onNeighbourMove", user, block, BLOCK_BOTTOM);
+ }
}
View
20 src/blocks/fire.cpp
@@ -73,16 +73,16 @@ bool BlockFire::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32
uint8_t oldblock;
uint8_t oldmeta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* Check block below allows blocks placed on top */
- if (!this->isBlockStackable(oldblock))
+ if(!this->isBlockStackable(oldblock))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
@@ -90,16 +90,16 @@ bool BlockFire::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32
y++;
/* FIXME: Need this or should be just let em burn? */
- if (this->isUserOnBlock(x,y,z,map))
+ if(this->isUserOnBlock(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* if the block isn't empty then you can't burn it */
- if (!this->isBlockEmpty(x,y,z,map))
+ if(!this->isBlockEmpty(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
@@ -116,7 +116,7 @@ void BlockFire::onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t
void BlockFire::onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
- Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
- Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
+ Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
+ Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
}
View
16 src/blocks/fire.h
@@ -39,13 +39,13 @@ class BlockFire : public BlockBasic
public:
bool affectedBlock(int block);
- void onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
};
View
50 src/blocks/ladder.cpp
@@ -58,21 +58,21 @@ bool BlockLadder::onBroken(User* user, int8_t status, int32_t x, int8_t y, int32
uint8_t block;
uint8_t meta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &block, &meta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &block, &meta))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
- this->spawnBlockItem(x,y,z,map,block);
+ this->spawnBlockItem(x, y, z, map, block);
return false;
}
void BlockLadder::onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
- uint8_t block,meta;
+ uint8_t block, meta;
Mineserver::get()->map(map)->getBlock(x, y, z, &block, &meta);
//Ladder is not attached to top or bottom block
@@ -81,7 +81,7 @@ void BlockLadder::onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int
return;
}
- if( (meta == 2 && direction == BLOCK_EAST) ||
+ if((meta == 2 && direction == BLOCK_EAST) ||
(meta == 3 && direction == BLOCK_WEST) ||
(meta == 4 && direction == BLOCK_NORTH) ||
(meta == 5 && direction == BLOCK_SOUTH))
@@ -101,49 +101,57 @@ bool BlockLadder::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int
//Cant place ladders on top or bottom of the block
if(direction == BLOCK_TOP || direction == BLOCK_BOTTOM)
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* Check block below allows blocks placed on top */
- if (!this->isBlockStackable(oldblock))
+ if(!this->isBlockStackable(oldblock))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* move the x,y,z coords dependent upon placement direction */
- if (!this->translateDirection(&x,&y,&z,map,direction))
+ if(!this->translateDirection(&x, &y, &z, map, direction))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (this->isUserOnBlock(x,y,z,map))
+ if(this->isUserOnBlock(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (!this->isBlockEmpty(x,y,z,map))
+ if(!this->isBlockEmpty(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
int8_t ladderDirection = 0;
switch(direction)
{
- case BLOCK_WEST: ladderDirection = 2; break;
- case BLOCK_EAST: ladderDirection = 3; break;
- case BLOCK_SOUTH: ladderDirection = 4; break;
- case BLOCK_NORTH: ladderDirection = 5; break;
+ case BLOCK_WEST:
+ ladderDirection = 2;
+ break;
+ case BLOCK_EAST:
+ ladderDirection = 3;
+ break;
+ case BLOCK_SOUTH:
+ ladderDirection = 4;
+ break;
+ case BLOCK_NORTH:
+ ladderDirection = 5;
+ break;
}
Mineserver::get()->map(map)->setBlock(x, y, z, (char)newblock, ladderDirection);
@@ -160,7 +168,7 @@ void BlockLadder::onReplace(User* user, int16_t newblock, int32_t x, int8_t y, i
uint8_t oldblock;
uint8_t oldmeta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
{
return;
}
View
194 src/blocks/ladder.h
@@ -36,102 +36,102 @@ class BlockLadder: public BlockBasic
public:
bool affectedBlock(int block);
- /** Fired when the player's begins swinging to hit a block
- @param user The user who is digging
- @param status
- @param x The x position of the current block being hit
- @param y The y position of the current block being hit
- @param z The z position of the current block being hit
- @param direction The direction that the user is facing
- */
- void onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
-
- /** Fired when the player is digging
- @param user The user who is digging
- @param status
- @param x The x position of the current block being hit
- @param y The y position of the current block being hit
- @param z The z position of the current block being hit
- @param direction The direction that the user is facing
- */
- void onDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
-
- /** Fired when the player stops digging but hasn't broken the block
- @param user The user who has stopped digging
- @param status
- @param x The x position of the current block not being hit anymore
- @param y The y position of the current block not being hit anymore
- @param z The z position of the current block not being hit anymore
- @param direction The direction that the user is facing
- */
- void onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
-
- /** Fired when the player has broken the block
- @param user The user who has broken the block
- @param status
- @param x The x position of the block that has been broken
- @param y The y position of the block that has been broken
- @param z The z position of the block that has been broken
- @param direction The direction that the user is facing
- */
- bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
-
- /** Fired when a neighbour block is broken.
- @param user The user who broke the block
- @param oldblock The type of block that was just broken
- @param x The x position of the current neighbour block being called
- @param y The y position of the current neighbour block being called
- @param z The z position of the current neighbour block being called
- @param direction The direction of the neighbour block that was broken
- */
- void onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
-
- /** Fired when a block is placed
- @param user The user who placed the block
- @param newblock The block that is attempting to be placed
- @param x The x position of where the block was placed
- @param y The y position of where the block was placed
- @param z The z position of where the block was placed
- @param direction The direction that the user is facing
- */
- bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
-
- /** Fired when a neighbour block is placed
- @param user The user who placed the block
- @param newblock The block that is attempting to be placed
- @param x The x position of the current neighbour block being called
- @param y The y position of the current neighbour block being called
- @param z The z position of the current neighbour block being called
- @param direction The direction that the user is facing
-
- @note You should only check if the block is of type BLOCK_AIR before placing. This
- allows another block's onReplace method to either allow of deny the replacement
- of a block with the block you're replacing it with.
- */
- void onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
-
- /** Fired when a block is to be placed
- @param user The user who placed the block
- @param newblock The block that is attempting to replaced this block
- @param x The x position of where the block is to be replaced
- @param y The y position of where the block is to be replaced
- @param z The z position of where the block is to be replaced
- @param direction The direction of the neighbour block that was broken
-
- @note To deny the replace simply to not change the block. To replace
- the block change the block to be BLOCK_AIR and check for BLOCK_AIR
- in the onPlace callback.
- */
- void onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
-
- /** Fired when a neighbour block is moving position.
- @param user The user who broke the block
- @param oldblock The type of block that has moved
- @param x The x position of the current neighbour block being called
- @param y The y position of the current neighbour block being called
- @param z The z position of the current neighbour block being called
- @param direction The direction that the block was in
- */
- void onNeighbourMove(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ /** Fired when the player's begins swinging to hit a block
+ @param user The user who is digging
+ @param status
+ @param x The x position of the current block being hit
+ @param y The y position of the current block being hit
+ @param z The z position of the current block being hit
+ @param direction The direction that the user is facing
+ */
+ void onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+
+ /** Fired when the player is digging
+ @param user The user who is digging
+ @param status
+ @param x The x position of the current block being hit
+ @param y The y position of the current block being hit
+ @param z The z position of the current block being hit
+ @param direction The direction that the user is facing
+ */
+ void onDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+
+ /** Fired when the player stops digging but hasn't broken the block
+ @param user The user who has stopped digging
+ @param status
+ @param x The x position of the current block not being hit anymore
+ @param y The y position of the current block not being hit anymore
+ @param z The z position of the current block not being hit anymore
+ @param direction The direction that the user is facing
+ */
+ void onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+
+ /** Fired when the player has broken the block
+ @param user The user who has broken the block
+ @param status
+ @param x The x position of the block that has been broken
+ @param y The y position of the block that has been broken
+ @param z The z position of the block that has been broken
+ @param direction The direction that the user is facing
+ */
+ bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+
+ /** Fired when a neighbour block is broken.
+ @param user The user who broke the block
+ @param oldblock The type of block that was just broken
+ @param x The x position of the current neighbour block being called
+ @param y The y position of the current neighbour block being called
+ @param z The z position of the current neighbour block being called
+ @param direction The direction of the neighbour block that was broken
+ */
+ void onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+
+ /** Fired when a block is placed
+ @param user The user who placed the block
+ @param newblock The block that is attempting to be placed
+ @param x The x position of where the block was placed
+ @param y The y position of where the block was placed
+ @param z The z position of where the block was placed
+ @param direction The direction that the user is facing
+ */
+ bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+
+ /** Fired when a neighbour block is placed
+ @param user The user who placed the block
+ @param newblock The block that is attempting to be placed
+ @param x The x position of the current neighbour block being called
+ @param y The y position of the current neighbour block being called
+ @param z The z position of the current neighbour block being called
+ @param direction The direction that the user is facing
+
+ @note You should only check if the block is of type BLOCK_AIR before placing. This
+ allows another block's onReplace method to either allow of deny the replacement
+ of a block with the block you're replacing it with.
+ */
+ void onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+
+ /** Fired when a block is to be placed
+ @param user The user who placed the block
+ @param newblock The block that is attempting to replaced this block
+ @param x The x position of where the block is to be replaced
+ @param y The y position of where the block is to be replaced
+ @param z The z position of where the block is to be replaced
+ @param direction The direction of the neighbour block that was broken
+
+ @note To deny the replace simply to not change the block. To replace
+ the block change the block to be BLOCK_AIR and check for BLOCK_AIR
+ in the onPlace callback.
+ */
+ void onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+
+ /** Fired when a neighbour block is moving position.
+ @param user The user who broke the block
+ @param oldblock The type of block that has moved
+ @param x The x position of the current neighbour block being called
+ @param y The y position of the current neighbour block being called
+ @param z The z position of the current neighbour block being called
+ @param direction The direction that the block was in
+ */
+ void onNeighbourMove(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
};
View
50 src/blocks/liquid.cpp
@@ -62,7 +62,7 @@ bool BlockLiquid::onBroken(User* user, int8_t status, int32_t x, int8_t y, int32
void BlockLiquid::onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
- physics(x,y,z,map);
+ physics(x, y, z, map);
}
bool BlockLiquid::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
@@ -70,22 +70,22 @@ bool BlockLiquid::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int
uint8_t oldblock;
uint8_t oldmeta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
/* move the x,y,z coords dependent upon placement direction */
- if (!this->translateDirection(&x,&y,&z,map,direction))
+ if(!this->translateDirection(&x, &y, &z, map, direction))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
- if (!this->isBlockEmpty(x,y,z,map))
+ if(!this->isBlockEmpty(x, y, z, map))
{
- revertBlock(user,x,y,z,map);
+ revertBlock(user, x, y, z, map);
return true;
}
@@ -93,39 +93,45 @@ bool BlockLiquid::onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int
int block = newblock;
- if (block == ITEM_WATER_BUCKET)
- newblock = BLOCK_STATIONARY_WATER;
+ if(block == ITEM_WATER_BUCKET)
+ {
+ newblock = BLOCK_STATIONARY_WATER;
+ }
- if (block == ITEM_LAVA_BUCKET)
- newblock = BLOCK_STATIONARY_LAVA;
+ if(block == ITEM_LAVA_BUCKET)
+ {
+ newblock = BLOCK_STATIONARY_LAVA;
+ }
Mineserver::get()->map(map)->setBlock(x, y, z, (char)newblock, 0);
Mineserver::get()->map(map)->sendBlockChange(x, y, z, (char)newblock, 0);
- physics(x,y,z,map);
+ physics(x, y, z, map);
return false;
}
void BlockLiquid::onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
- physics(x,y,z,map);
+ physics(x, y, z, map);
}
void BlockLiquid::onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction)
{
- uint8_t oldblock;
- uint8_t oldmeta;
- if (!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
- return;
+ uint8_t oldblock;
+ uint8_t oldmeta;
+ if(!Mineserver::get()->map(map)->getBlock(x, y, z, &oldblock, &oldmeta))
+ {
+ return;
+ }
- Mineserver::get()->physics(map)->removeSimulation(vec(x,y,z));
+ Mineserver::get()->physics(map)->removeSimulation(vec(x, y, z));
- Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
- Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
+ Mineserver::get()->map(map)->sendBlockChange(x, y, z, BLOCK_AIR, 0);
+ Mineserver::get()->map(map)->setBlock(x, y, z, BLOCK_AIR, 0);
}
void BlockLiquid::physics(int32_t x, int8_t y, int32_t z, int map)
{
- Mineserver::get()->physics(map)->addSimulation(vec(x, y, z));
- //Mineserver::get()->physics()->checkSurrounding(vec(x, y, z));
+ Mineserver::get()->physics(map)->addSimulation(vec(x, y, z));
+ //Mineserver::get()->physics()->checkSurrounding(vec(x, y, z));
}
View
18 src/blocks/liquid.h
@@ -40,15 +40,15 @@ class BlockLiquid: public BlockBasic
public:
bool affectedBlock(int block);
- void onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
- void onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onStartedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onStoppedDigging(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ bool onBroken(User* user, int8_t status, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onNeighbourBroken(User* user, int16_t oldblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ bool onPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onNeighbourPlace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
+ void onReplace(User* user, int16_t newblock, int32_t x, int8_t y, int32_t z, int map, int8_t direction);
private:
- void physics(int32_t x, int8_t y, int32_t z,int map);
+ void physics(int32_t x, int8_t y, int32_t z, int map);