Merge branch 'master' of https://github.com/tigerw/MCServer into tigerw-master

Conflicts:
	source/Piston.cpp

Merged pull request and fixed merge conflicts
master
Tiger Wang 2013-08-18 15:58:27 +01:00
commit fb32c28f80
10 changed files with 176 additions and 19 deletions

@ -1 +0,0 @@
Subproject commit 52e1de4332a026e58fda843aae98c1f51e57199e

View File

@ -48,6 +48,7 @@
363:1 @ 200 = 364:1 # 1 Raw Beef -> 1 Cooked Beef (steak) 363:1 @ 200 = 364:1 # 1 Raw Beef -> 1 Cooked Beef (steak)
365:1 @ 200 = 366:1 # 1 Raw Chicken -> 1 Cooked Chicken 365:1 @ 200 = 366:1 # 1 Raw Chicken -> 1 Cooked Chicken
337:1 @ 200 = 336:1 # 1 Clay -> 1 Clay Brick 337:1 @ 200 = 336:1 # 1 Clay -> 1 Clay Brick
82:1 @ 200 = 172:1 # 1 Clay Block -> 1 Hardened Clay
87:1 @ 200 = 405:1 # 1 NetherRack -> 1 NetherBrick 87:1 @ 200 = 405:1 # 1 NetherRack -> 1 NetherBrick
349:1 @ 200 = 350:1 # 1 Raw Fish -> 1 Cooked Fish 349:1 @ 200 = 350:1 # 1 Raw Fish -> 1 Cooked Fish
17:1 @ 200 = 263:1:1 # 1 Log -> 1 Charcoal 17:1 @ 200 = 263:1:1 # 1 Log -> 1 Charcoal
@ -60,7 +61,8 @@
#-------------------------- #--------------------------
# Fuels # Fuels
! 263:1 = 1600 # 1 Charcoal -> 80 sec ! 263:1 = 1600 # 1 Coal -> 80 sec
! 263:1:1 = 1600 # 1 Charcoal -> 80 sec
! 42:126:1 = 150 # 1 Halfslab -> 7.5 seconds ! 42:126:1 = 150 # 1 Halfslab -> 7.5 seconds
! 5:1 = 300 # 1 Planks -> 15 sec ! 5:1 = 300 # 1 Planks -> 15 sec
! 280:1 = 100 # 1 Stick -> 5 sec ! 280:1 = 100 # 1 Stick -> 5 sec
@ -73,3 +75,4 @@
! 327:1 = 200000 # 1 Lava Bucket -> 1000 sec ! 327:1 = 200000 # 1 Lava Bucket -> 1000 sec
! 17:1 = 300 # 1 Wood -> 15 sec ! 17:1 = 300 # 1 Wood -> 15 sec
! 6:1 = 100 # 1 Sapling -> 5 sec ! 6:1 = 100 # 1 Sapling -> 5 sec
! 173:1 = 7400 # 1 Coal Block -> 370 sec, based on https://github.com/minetest/common/commit/e0f5a6fd6936052756e27a05a2bfdd6aa86b38e1 which is a clone of MC

View File

@ -169,8 +169,11 @@ enum ENUM_BLOCK_ID
E_BLOCK_ACTIVATOR_RAIL = 157, E_BLOCK_ACTIVATOR_RAIL = 157,
E_BLOCK_DROPPER = 158, E_BLOCK_DROPPER = 158,
E_BLOCK_STAINED_CLAY = 159,
E_BLOCK_HAY_BALE = 170,
E_BLOCK_CARPET = 171, E_BLOCK_CARPET = 171,
E_BLOCK_HARDENED_CLAY = 172,
E_BLOCK_BLOCK_OF_COAL = 173,
// Keep these two as the last values, without a number - they will get their correct number assigned automagically by C++ // Keep these two as the last values, without a number - they will get their correct number assigned automagically by C++
// IsValidBlock() depends on this // IsValidBlock() depends on this
@ -507,6 +510,41 @@ enum
E_META_WOOL_RED = 14, E_META_WOOL_RED = 14,
E_META_WOOL_BLACK = 15, E_META_WOOL_BLACK = 15,
// E_BLOCK_CARPET metas:
E_META_CARPET_WHITE = 0,
E_META_CARPET_ORANGE = 1,
E_META_CARPET_MAGENTA = 2,
E_META_CARPET_LIGHTBLUE = 3,
E_META_CARPET_YELLOW = 4,
E_META_CARPET_LIGHTGREEN = 5,
E_META_CARPET_PINK = 6,
E_META_CARPET_GRAY = 7,
E_META_CARPET_LIGHTGRAY = 8,
E_META_CARPET_CYAN = 9,
E_META_CARPET_PURPLE = 10,
E_META_CARPET_BLUE = 11,
E_META_CARPET_BROWN = 12,
E_META_CARPET_GREEN = 13,
E_META_CARPET_RED = 14,
E_META_CARPET_BLACK = 15,
// E_BLOCK_STAINED_CLAY metas
E_META_STAINED_CLAY_WHITE = 0,
E_META_STAINED_CLAY_ORANGE = 1,
E_META_STAINED_CLAY_MAGENTA = 2,
E_META_STAINED_CLAY_LIGHTBLUE = 3,
E_META_STAINED_CLAY_YELLOW = 4,
E_META_STAINED_CLAY_LIGHTGREEN = 5,
E_META_STAINED_CLAY_PINK = 6,
E_META_STAINED_CLAY_GRAY = 7,
E_META_STAINED_CLAY_LIGHTGRAY = 8,
E_META_STAINED_CLAY_CYAN = 9,
E_META_STAINED_CLAY_PURPLE = 10,
E_META_STAINED_CLAY_BLUE = 11,
E_META_STAINED_CLAY_BROWN = 12,
E_META_STAINED_CLAY_GREEN = 13,
E_META_STAINED_CLAY_RED = 14,
E_META_STAINED_CLAY_BLACK = 15,
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Item metas: // Item metas:

View File

@ -1607,6 +1607,61 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
void cChunk::SetServerBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
{
ASSERT(!((a_RelX < 0) || (a_RelX >= Width) || (a_RelY < 0) || (a_RelY >= Height) || (a_RelZ < 0) || (a_RelZ >= Width)));
ASSERT(IsValid());
const int index = MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);
const BLOCKTYPE OldBlockType = cChunkDef::GetBlock(m_BlockTypes, index);
const BLOCKTYPE OldBlockMeta = GetNibble(m_BlockMeta, index);
if ((OldBlockType == a_BlockType) && (OldBlockMeta == a_BlockMeta))
{
return;
}
MarkDirty();
m_BlockTypes[index] = a_BlockType;
SetNibble(m_BlockMeta, index, a_BlockMeta);
// ONLY recalculate lighting if it's necessary!
if(
(g_BlockLightValue[OldBlockType ] != g_BlockLightValue[a_BlockType]) ||
(g_BlockSpreadLightFalloff[OldBlockType] != g_BlockSpreadLightFalloff[a_BlockType]) ||
(g_BlockTransparent[OldBlockType] != g_BlockTransparent[a_BlockType])
)
{
m_IsLightValid = false;
}
// Update heightmap, if needed:
if (a_RelY >= m_HeightMap[a_RelX + a_RelZ * Width])
{
if (a_BlockType != E_BLOCK_AIR)
{
m_HeightMap[a_RelX + a_RelZ * Width] = (unsigned char)a_RelY;
}
else
{
for (int y = a_RelY - 1; y > 0; --y)
{
if (m_BlockTypes[MakeIndexNoCheck(a_RelX, y, a_RelZ)] != E_BLOCK_AIR)
{
m_HeightMap[a_RelX + a_RelZ * Width] = (unsigned char)y;
break;
}
} // for y - column in m_BlockData
}
}
}
void cChunk::SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client) void cChunk::SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client)
{ {
// The coords must be valid, because the upper level already does chunk lookup. No need to check them again. // The coords must be valid, because the upper level already does chunk lookup. No need to check them again.

View File

@ -148,6 +148,8 @@ public:
void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta); void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
void GetBlockInfo (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight); void GetBlockInfo (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight);
void SetServerBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta );
/** Returns the chunk into which the specified block belongs, by walking the neighbors. /** Returns the chunk into which the specified block belongs, by walking the neighbors.
Will return self if appropriate. Returns NULL if not reachable through neighbors. Will return self if appropriate. Returns NULL if not reachable through neighbors.
*/ */

View File

@ -1171,6 +1171,24 @@ void cChunkMap::SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_B
void cChunkMap::SetServerBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
{
int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ;
cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ );
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
if ((Chunk != NULL) && Chunk->IsValid())
{
Chunk->SetServerBlock(X, Y, Z, a_BlockType, a_BlockMeta );
m_World->GetSimulatorManager()->WakeUp(a_BlockX, a_BlockY, a_BlockZ, Chunk);
}
}
bool cChunkMap::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) bool cChunkMap::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{ {
int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ; int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ;

View File

@ -135,6 +135,7 @@ public:
NIBBLETYPE GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ); NIBBLETYPE GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ);
void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockMeta); void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockMeta);
void SetBlock (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta); void SetBlock (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta);
void SetServerBlock (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta);
bool GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta); bool GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
bool GetBlockInfo (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight); bool GetBlockInfo (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight);

View File

@ -99,7 +99,7 @@ void cPiston::ExtendPiston(int pistx, int pisty, int pistz)
{ {
AddDir(pistx, pisty, pistz, pistonMeta, -1); AddDir(pistx, pisty, pistz, pistonMeta, -1);
m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currBlockMeta); m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currBlockMeta);
m_World->SetBlock( oldx, oldy, oldz, currBlock, currBlockMeta); m_World->SetServerBlock( oldx, oldy, oldz, currBlock, currBlockMeta);
oldx = pistx; oldx = pistx;
oldy = pisty; oldy = pisty;
oldz = pistz; oldz = pistz;
@ -111,10 +111,19 @@ void cPiston::ExtendPiston(int pistx, int pisty, int pistz)
AddDir(pistx, pisty, pistz, pistonMeta, -1); AddDir(pistx, pisty, pistz, pistonMeta, -1);
// "pist" now at piston body, "ext" at future extension // "pist" now at piston body, "ext" at future extension
m_World->BroadcastBlockAction(pistx, pisty, pistz, 0, pistonMeta, pistonBlock); if (pistonBlock == E_BLOCK_STICKY_PISTON)
{
m_World->BroadcastBlockAction(pistx, pisty, pistz, 0, pistonMeta, E_BLOCK_STICKY_PISTON);
}
else
{
m_World->BroadcastBlockAction(pistx, pisty, pistz, 0, pistonMeta, E_BLOCK_PISTON);
}
m_World->BroadcastSoundEffect("tile.piston.out", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f); m_World->BroadcastSoundEffect("tile.piston.out", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f);
m_World->FastSetBlock( pistx, pisty, pistz, pistonBlock, pistonMeta | 0x8 ); m_World->FastSetBlock( pistx, pisty, pistz, pistonBlock, pistonMeta | 0x8 );
m_World->SetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0)); m_World->SetServerBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, isSticky + pistonMeta);
} }
@ -132,9 +141,18 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz )
return; return;
} }
if (pistonBlock == E_BLOCK_STICKY_PISTON)
{
m_World->BroadcastBlockAction(pistx, pisty, pistz, 1, pistonMeta & ~(8), E_BLOCK_STICKY_PISTON);
}
else
{
m_World->BroadcastBlockAction(pistx, pisty, pistz, 1, pistonMeta & ~(8), E_BLOCK_PISTON); m_World->BroadcastBlockAction(pistx, pisty, pistz, 1, pistonMeta & ~(8), E_BLOCK_PISTON);
}
m_World->BroadcastSoundEffect("tile.piston.in", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f); m_World->BroadcastSoundEffect("tile.piston.in", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f);
m_World->FastSetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8)); //Set the base m_World->SetServerBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8));
// Check the extension: // Check the extension:
AddDir(pistx, pisty, pistz, pistonMeta, 1); AddDir(pistx, pisty, pistz, pistonMeta, 1);
@ -154,17 +172,17 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz )
m_World->GetBlockTypeMeta(tempx, tempy, tempz, tempBlock, tempMeta); m_World->GetBlockTypeMeta(tempx, tempy, tempz, tempBlock, tempMeta);
if (CanPull(tempBlock, tempMeta)) if (CanPull(tempBlock, tempMeta))
{ {
m_World->SetBlock(pistx, pisty, pistz, tempBlock, tempMeta); m_World->SetServerBlock(pistx, pisty, pistz, tempBlock, tempMeta);
m_World->SetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0); m_World->SetServerBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0);
} }
else else
{ {
m_World->SetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0); m_World->SetServerBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0);
} }
} }
else else
{ {
m_World->SetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0); m_World->SetServerBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0);
} }
} }
@ -215,6 +233,7 @@ bool cPiston::CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
case E_BLOCK_END_PORTAL: case E_BLOCK_END_PORTAL:
case E_BLOCK_END_PORTAL_FRAME: case E_BLOCK_END_PORTAL_FRAME:
case E_BLOCK_FURNACE: case E_BLOCK_FURNACE:
case E_BLOCK_LIT_FURNACE:
case E_BLOCK_HOPPER: case E_BLOCK_HOPPER:
case E_BLOCK_JUKEBOX: case E_BLOCK_JUKEBOX:
case E_BLOCK_MOB_SPAWNER: case E_BLOCK_MOB_SPAWNER:

View File

@ -1385,6 +1385,21 @@ void cWorld::FastSetBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBB
void cWorld::SetServerBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
if (a_BlockType == E_BLOCK_AIR)
{
BlockHandler(GetBlock(a_X, a_Y, a_Z))->OnDestroyed(this, a_X, a_Y, a_Z);
}
m_ChunkMap->SetServerBlock(a_X, a_Y, a_Z, a_BlockType, a_BlockMeta);
BlockHandler(a_BlockType)->OnPlaced(this, a_X, a_Y, a_Z, a_BlockType, a_BlockMeta);
}
BLOCKTYPE cWorld::GetBlock(int a_X, int a_Y, int a_Z) BLOCKTYPE cWorld::GetBlock(int a_X, int a_Y, int a_Z)
{ {
// First check if it isn't queued in the m_FastSetBlockQueue: // First check if it isn't queued in the m_FastSetBlockQueue:
@ -2635,12 +2650,18 @@ void cWorld::TabCompleteUserName(const AString & a_Text, AStringVector & a_Resul
cCSLock Lock(m_CSPlayers); cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(), end = m_Players.end(); itr != end; ++itr) for (cPlayerList::iterator itr = m_Players.begin(), end = m_Players.end(); itr != end; ++itr)
{ {
if (NoCaseCompare((*itr)->GetName().substr(0, a_Text.length()), a_Text) != 0) size_t LastSpace = a_Text.find_last_of(" "); //Find the position of the last space
std::string LastWord = a_Text.substr(LastSpace + 1, a_Text.length()); //Find the last word
std::string PlayerName ((*itr)->GetName());
std::size_t Found = PlayerName.find(LastWord); //Try to find last word in playername
if (Found!=0)
{ {
// Player name doesn't match continue; //No match
continue;
} }
a_Results.push_back((*itr)->GetName());
a_Results.push_back((*itr)->GetName()); //Match!
} }
} }

View File

@ -313,6 +313,7 @@ public:
// tolua_begin // tolua_begin
void SetBlock (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void SetBlock (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
void FastSetBlock (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void FastSetBlock (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
void SetServerBlock (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
BLOCKTYPE GetBlock (int a_BlockX, int a_BlockY, int a_BlockZ); BLOCKTYPE GetBlock (int a_BlockX, int a_BlockY, int a_BlockZ);
NIBBLETYPE GetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ); NIBBLETYPE GetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ);
void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData); void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData);