Merge pull request #909 from jfhumann/fixes
Bug fixes and optimizations. We need to visit the API functions and check that they return only those values expected. `cWorld::CreateProjectile()` seems affected, too, by the same issue of ToLua returning extra values. In the cleanest form, these functions will need moving to ManualBindings.cpp
This commit is contained in:
commit
6492aa000b
@ -128,10 +128,11 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
|
||||
if (DispChunk->GetBlock(DispX, DispY, DispZ) == E_BLOCK_AIR)
|
||||
{
|
||||
DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_FIRE, 0);
|
||||
m_Contents.SetSlot(a_SlotNum, m_Contents.GetSlot(a_SlotNum).m_ItemType, m_Contents.GetSlot(a_SlotNum).m_ItemCount, m_Contents.GetSlot(a_SlotNum).m_ItemDamage + 1);
|
||||
// If the durability has run out destroy the item.
|
||||
if (m_Contents.GetSlot(a_SlotNum).m_ItemDamage > 64)
|
||||
{
|
||||
|
||||
bool ItemBroke = m_Contents.DamageItem(a_SlotNum, 1);
|
||||
|
||||
if (ItemBroke)
|
||||
{
|
||||
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
||||
}
|
||||
}
|
||||
|
@ -413,19 +413,20 @@ bool cFurnaceEntity::CanCookInputToOutput(void) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_Contents.GetSlot(fsOutput).IsEmpty())
|
||||
const cItem & Slot = m_Contents.GetSlot(fsOutput);
|
||||
if (Slot.IsEmpty())
|
||||
{
|
||||
// The output is empty, can cook
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!m_Contents.GetSlot(fsOutput).IsEqual(*m_CurrentRecipe->Out))
|
||||
if (!Slot.IsEqual(*m_CurrentRecipe->Out))
|
||||
{
|
||||
// The output slot is blocked with something that cannot be stacked with the recipe's output
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_Contents.GetSlot(fsOutput).IsFullStack())
|
||||
if (Slot.IsFullStack())
|
||||
{
|
||||
// Cannot add any more items to the output slot
|
||||
return false;
|
||||
|
@ -234,24 +234,27 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
|
||||
|
||||
bool TrySuckPickupIn(cPickup * a_Pickup)
|
||||
{
|
||||
cItem & Item = a_Pickup->GetItem();
|
||||
|
||||
for (int i = 0; i < ContentsWidth * ContentsHeight; i++)
|
||||
{
|
||||
if (m_Contents.IsSlotEmpty(i))
|
||||
{
|
||||
m_bFoundPickupsAbove = true;
|
||||
m_Contents.SetSlot(i, a_Pickup->GetItem());
|
||||
m_Contents.SetSlot(i, Item);
|
||||
a_Pickup->Destroy(); // Kill pickup
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (m_Contents.GetSlot(i).IsEqual(a_Pickup->GetItem()) && !m_Contents.GetSlot(i).IsFullStack())
|
||||
else if (m_Contents.GetSlot(i).IsEqual(Item) && !m_Contents.GetSlot(i).IsFullStack())
|
||||
{
|
||||
m_bFoundPickupsAbove = true;
|
||||
|
||||
int PreviousCount = m_Contents.GetSlot(i).m_ItemCount;
|
||||
a_Pickup->GetItem().m_ItemCount -= m_Contents.ChangeSlotCount(i, a_Pickup->GetItem().m_ItemCount) - PreviousCount; // Set count to however many items were added
|
||||
|
||||
if (a_Pickup->GetItem().IsEmpty())
|
||||
Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added
|
||||
|
||||
if (Item.IsEmpty())
|
||||
{
|
||||
a_Pickup->Destroy(); // Kill pickup if all items were added
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
(Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
|
||||
)
|
||||
{
|
||||
// FIXME: This is unreachable, as the condition is the same as the above one
|
||||
a_BlockMeta = (yaw < 0) ? 4 : 5;
|
||||
return true;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ public:
|
||||
NIBBLETYPE Meta = 0;
|
||||
char RailsCnt = 0;
|
||||
bool Neighbors[8]; // 0 - EAST, 1 - WEST, 2 - NORTH, 3 - SOUTH, 4 - EAST UP, 5 - WEST UP, 6 - NORTH UP, 7 - SOUTH UP
|
||||
memset(Neighbors, false, sizeof(Neighbors));
|
||||
memset(Neighbors, 0, sizeof(Neighbors));
|
||||
Neighbors[0] = (IsUnstable(a_ChunkInterface, a_BlockX + 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN));
|
||||
Neighbors[1] = (IsUnstable(a_ChunkInterface, a_BlockX - 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN));
|
||||
Neighbors[2] = (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ - 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN));
|
||||
|
@ -288,7 +288,7 @@ bool cBoundingBox::CalcLineIntersection(const Vector3d & a_Min, const Vector3d &
|
||||
Coeff = c;
|
||||
}
|
||||
c = a_Line1.LineCoeffToXZPlane(a_Line2, a_Max.y);
|
||||
if ((c >= 0) && (c >= 0) && (c < Coeff) && IsInside(a_Min, a_Max, a_Line1 + (a_Line2 - a_Line1) * c))
|
||||
if ((c >= 0) && (c < Coeff) && IsInside(a_Min, a_Max, a_Line1 + (a_Line2 - a_Line1) * c))
|
||||
{
|
||||
Face = (a_Line1.y > a_Line2.y) ? BLOCK_FACE_YP : BLOCK_FACE_YM;
|
||||
Coeff = c;
|
||||
|
@ -452,7 +452,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill)
|
||||
{
|
||||
cMonster& Monster = (cMonster&)(**itr);
|
||||
currentPosition = Monster.GetPosition();
|
||||
for (std::list<const Vector3d*>::const_iterator itr2 = playerPositions.begin(); itr2 != playerPositions.end(); itr2 ++)
|
||||
for (std::list<const Vector3d*>::const_iterator itr2 = playerPositions.begin(); itr2 != playerPositions.end(); ++itr2)
|
||||
{
|
||||
toFill.CollectMob(Monster,*this,(currentPosition-**itr2).SqrLength());
|
||||
}
|
||||
@ -600,7 +600,7 @@ void cChunk::Tick(float a_Dt)
|
||||
delete ToDelete;
|
||||
continue;
|
||||
}
|
||||
itr++;
|
||||
++itr;
|
||||
} // for itr - m_Entitites[]
|
||||
|
||||
// If any entity moved out of the chunk, move it to the neighbor:
|
||||
|
@ -382,14 +382,14 @@ private:
|
||||
|
||||
struct sSetBlockQueueItem
|
||||
{
|
||||
Int64 m_Tick;
|
||||
int m_RelX, m_RelY, m_RelZ;
|
||||
BLOCKTYPE m_BlockType;
|
||||
NIBBLETYPE m_BlockMeta;
|
||||
Int64 m_Tick;
|
||||
BLOCKTYPE m_PreviousType;
|
||||
|
||||
sSetBlockQueueItem(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType) :
|
||||
m_RelX(a_RelX), m_RelY(a_RelY), m_RelZ(a_RelZ), m_BlockType(a_BlockType), m_BlockMeta(a_BlockMeta), m_Tick(a_Tick), m_PreviousType(a_PreviousBlockType)
|
||||
m_Tick(a_Tick), m_RelX(a_RelX), m_RelY(a_RelY), m_RelZ(a_RelZ), m_BlockType(a_BlockType), m_BlockMeta(a_BlockMeta), m_PreviousType(a_PreviousBlockType)
|
||||
{
|
||||
}
|
||||
} ;
|
||||
|
@ -1656,7 +1656,7 @@ void cChunkMap::AddEntity(cEntity * a_Entity)
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ());
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
LOGWARNING("Entity at %p (%s, ID %d) spawning in a non-existent chunk, the entity is lost.",
|
||||
a_Entity, a_Entity->GetClass(), a_Entity->GetUniqueID()
|
||||
@ -1691,7 +1691,7 @@ void cChunkMap::RemoveEntity(cEntity * a_Entity)
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ());
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1723,7 +1723,7 @@ bool cChunkMap::ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -1973,7 +1973,7 @@ bool cChunkMap::ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEnti
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -1988,7 +1988,7 @@ bool cChunkMap::ForEachChestInChunk(int a_ChunkX, int a_ChunkZ, cChestCallback &
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2003,7 +2003,7 @@ bool cChunkMap::ForEachDispenserInChunk(int a_ChunkX, int a_ChunkZ, cDispenserCa
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2018,7 +2018,7 @@ bool cChunkMap::ForEachDropperInChunk(int a_ChunkX, int a_ChunkZ, cDropperCallba
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2033,7 +2033,7 @@ bool cChunkMap::ForEachDropSpenserInChunk(int a_ChunkX, int a_ChunkZ, cDropSpens
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2048,7 +2048,7 @@ bool cChunkMap::ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, cFurnaceCallba
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2066,7 +2066,7 @@ bool cChunkMap::DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cB
|
||||
cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2084,7 +2084,7 @@ bool cChunkMap::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCa
|
||||
cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2102,7 +2102,7 @@ bool cChunkMap::DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDis
|
||||
cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2120,7 +2120,7 @@ bool cChunkMap::DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropp
|
||||
cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2138,7 +2138,7 @@ bool cChunkMap::DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cD
|
||||
cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2156,7 +2156,7 @@ bool cChunkMap::DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurna
|
||||
cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2173,7 +2173,7 @@ bool cChunkMap::DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNot
|
||||
cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2190,7 +2190,7 @@ bool cChunkMap::DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, c
|
||||
cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2208,7 +2208,7 @@ bool cChunkMap::DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHe
|
||||
cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2226,7 +2226,7 @@ bool cChunkMap::DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlo
|
||||
cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2244,7 +2244,7 @@ bool cChunkMap::GetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, AString &
|
||||
cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
|
||||
if ((Chunk == NULL) && !Chunk->IsValid())
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -453,14 +453,16 @@ void cClientHandle::HandlePing(void)
|
||||
{
|
||||
// Somebody tries to retrieve information about the server
|
||||
AString Reply;
|
||||
const cServer & Server = *cRoot::Get()->GetServer();
|
||||
|
||||
Printf(Reply, "%s%s%i%s%i",
|
||||
cRoot::Get()->GetServer()->GetDescription().c_str(),
|
||||
Server.GetDescription().c_str(),
|
||||
cChatColor::Delimiter.c_str(),
|
||||
cRoot::Get()->GetServer()->GetNumPlayers(),
|
||||
Server.GetNumPlayers(),
|
||||
cChatColor::Delimiter.c_str(),
|
||||
cRoot::Get()->GetServer()->GetMaxPlayers()
|
||||
Server.GetMaxPlayers()
|
||||
);
|
||||
Kick(Reply.c_str());
|
||||
Kick(Reply);
|
||||
}
|
||||
|
||||
|
||||
@ -1216,8 +1218,8 @@ void cClientHandle::HandleChat(const AString & a_Message)
|
||||
Color = AString("@") + Color[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
Color.empty();
|
||||
{
|
||||
Color.clear();
|
||||
}
|
||||
Msg.AddTextPart(AString("<") + m_Player->GetName() + "> ", Color);
|
||||
Msg.ParseText(a_Message);
|
||||
|
@ -661,14 +661,16 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
|
||||
ASSERT(itrS->x + a_OffsetX < a_GridWidth);
|
||||
ASSERT(itrS->y + a_OffsetY < a_GridHeight);
|
||||
int GridID = (itrS->x + a_OffsetX) + a_GridStride * (itrS->y + a_OffsetY);
|
||||
|
||||
const cItem & Item = itrS->m_Item;
|
||||
if (
|
||||
(itrS->x >= a_GridWidth) ||
|
||||
(itrS->y >= a_GridHeight) ||
|
||||
(itrS->m_Item.m_ItemType != a_CraftingGrid[GridID].m_ItemType) || // same item type?
|
||||
(itrS->m_Item.m_ItemCount > a_CraftingGrid[GridID].m_ItemCount) || // not enough items
|
||||
(Item.m_ItemType != a_CraftingGrid[GridID].m_ItemType) || // same item type?
|
||||
(Item.m_ItemCount > a_CraftingGrid[GridID].m_ItemCount) || // not enough items
|
||||
(
|
||||
(itrS->m_Item.m_ItemDamage > 0) && // should compare damage values?
|
||||
(itrS->m_Item.m_ItemDamage != a_CraftingGrid[GridID].m_ItemDamage)
|
||||
(Item.m_ItemDamage > 0) && // should compare damage values?
|
||||
(Item.m_ItemDamage != a_CraftingGrid[GridID].m_ItemDamage)
|
||||
)
|
||||
)
|
||||
{
|
||||
|
@ -206,7 +206,7 @@ int cRSAPrivateKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte
|
||||
ASSERT(!"Invalid a_DecryptedMaxLength!");
|
||||
return -1;
|
||||
}
|
||||
if (a_EncryptedMaxLength < m_Rsa.len)
|
||||
if (a_PlainLength < m_Rsa.len)
|
||||
{
|
||||
LOGD("%s: Invalid a_PlainLength: got %u, exp at least %u",
|
||||
__FUNCTION__, (unsigned)a_PlainLength, (unsigned)(m_Rsa.len)
|
||||
|
@ -112,18 +112,21 @@ void cDeadlockDetect::CheckWorldAge(const AString & a_WorldName, Int64 a_Age)
|
||||
ASSERT(!"Unknown world in cDeadlockDetect");
|
||||
return;
|
||||
}
|
||||
if (itr->second.m_Age == a_Age)
|
||||
|
||||
cDeadlockDetect::sWorldAge & WorldAge = itr->second;
|
||||
|
||||
if (WorldAge.m_Age == a_Age)
|
||||
{
|
||||
itr->second.m_NumCyclesSame += 1;
|
||||
if (itr->second.m_NumCyclesSame > (1000 * m_IntervalSec) / CYCLE_MILLISECONDS)
|
||||
WorldAge.m_NumCyclesSame += 1;
|
||||
if (WorldAge.m_NumCyclesSame > (1000 * m_IntervalSec) / CYCLE_MILLISECONDS)
|
||||
{
|
||||
DeadlockDetected();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itr->second.m_Age = a_Age;
|
||||
itr->second.m_NumCyclesSame = 0;
|
||||
WorldAge.m_Age = a_Age;
|
||||
WorldAge.m_NumCyclesSame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -795,7 +795,7 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta)
|
||||
{
|
||||
BLOCKTYPE BlockXM = m_World->GetBlock(POSX_TOINT - 1, POSY_TOINT, POSZ_TOINT);
|
||||
BLOCKTYPE BlockXP = m_World->GetBlock(POSX_TOINT + 1, POSY_TOINT, POSZ_TOINT);
|
||||
BLOCKTYPE BlockZM = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT + 1);
|
||||
BLOCKTYPE BlockZM = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT - 1);
|
||||
BLOCKTYPE BlockZP = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT + 1);
|
||||
if (
|
||||
(!IsBlockRail(BlockXM) && cBlockInfo::IsSolid(BlockXM)) ||
|
||||
|
@ -85,9 +85,10 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
|
||||
if (!LoadFromDisk())
|
||||
{
|
||||
m_Inventory.Clear();
|
||||
SetPosX(cRoot::Get()->GetDefaultWorld()->GetSpawnX());
|
||||
SetPosY(cRoot::Get()->GetDefaultWorld()->GetSpawnY());
|
||||
SetPosZ(cRoot::Get()->GetDefaultWorld()->GetSpawnZ());
|
||||
cWorld * DefaultWorld = cRoot::Get()->GetDefaultWorld();
|
||||
SetPosX(DefaultWorld->GetSpawnX());
|
||||
SetPosY(DefaultWorld->GetSpawnY());
|
||||
SetPosZ(DefaultWorld->GetSpawnZ());
|
||||
|
||||
LOGD("Player \"%s\" is connecting for the first time, spawning at default world spawn {%.2f, %.2f, %.2f}",
|
||||
a_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ()
|
||||
@ -1165,9 +1166,9 @@ Vector3d cPlayer::GetThrowSpeed(double a_SpeedCoeff) const
|
||||
|
||||
|
||||
|
||||
void cPlayer::ForceSetSpeed(Vector3d a_Direction)
|
||||
void cPlayer::ForceSetSpeed(const Vector3d & a_Speed)
|
||||
{
|
||||
SetSpeed(a_Direction);
|
||||
SetSpeed(a_Speed);
|
||||
m_ClientHandle->SendEntityVelocity(*this);
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ public:
|
||||
void LoginSetGameMode(eGameMode a_GameMode);
|
||||
|
||||
/** Forces the player to move in the given direction. */
|
||||
void ForceSetSpeed(Vector3d a_Direction); // tolua_export
|
||||
void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export
|
||||
|
||||
/** Tries to move to a new position, with attachment-related checks (y == -999) */
|
||||
void MoveTo(const Vector3d & a_NewPos); // tolua_export
|
||||
|
@ -56,7 +56,6 @@ void cFurnaceRecipe::ReloadRecipes(void)
|
||||
std::ifstream f;
|
||||
char a_File[] = "furnace.txt";
|
||||
f.open(a_File, std::ios::in);
|
||||
std::string input;
|
||||
|
||||
if (!f.good())
|
||||
{
|
||||
|
@ -200,13 +200,14 @@ void cCaveTunnel::Randomize(cNoise & a_Noise)
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
// For each already present point, insert a point in between it and its predecessor, shifted randomly.
|
||||
int PrevX = m_Points.front().m_BlockX;
|
||||
int PrevY = m_Points.front().m_BlockY;
|
||||
int PrevZ = m_Points.front().m_BlockZ;
|
||||
int PrevR = m_Points.front().m_Radius;
|
||||
cCaveDefPoint & Point = m_Points.front();
|
||||
int PrevX = Point.m_BlockX;
|
||||
int PrevY = Point.m_BlockY;
|
||||
int PrevZ = Point.m_BlockZ;
|
||||
int PrevR = Point.m_Radius;
|
||||
cCaveDefPoints Pts;
|
||||
Pts.reserve(m_Points.size() * 2 + 1);
|
||||
Pts.push_back(m_Points.front());
|
||||
Pts.push_back(Point);
|
||||
for (cCaveDefPoints::const_iterator itr = m_Points.begin() + 1, end = m_Points.end(); itr != end; ++itr)
|
||||
{
|
||||
int Random = a_Noise.IntNoise3DInt(PrevX, PrevY, PrevZ + i) / 11;
|
||||
@ -244,11 +245,12 @@ bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints &
|
||||
a_Dst.clear();
|
||||
a_Dst.reserve(Num * 2 + 2);
|
||||
cCaveDefPoints::const_iterator itr = a_Src.begin() + 1;
|
||||
a_Dst.push_back(a_Src.front());
|
||||
int PrevX = a_Src.front().m_BlockX;
|
||||
int PrevY = a_Src.front().m_BlockY;
|
||||
int PrevZ = a_Src.front().m_BlockZ;
|
||||
int PrevR = a_Src.front().m_Radius;
|
||||
const cCaveDefPoint & Source = a_Src.front();
|
||||
a_Dst.push_back(Source);
|
||||
int PrevX = Source.m_BlockX;
|
||||
int PrevY = Source.m_BlockY;
|
||||
int PrevZ = Source.m_BlockZ;
|
||||
int PrevR = Source.m_Radius;
|
||||
for (int i = 0; i <= Num; ++i, ++itr)
|
||||
{
|
||||
int dx = itr->m_BlockX - PrevX;
|
||||
@ -310,9 +312,10 @@ void cCaveTunnel::FinishLinear(void)
|
||||
std::swap(Pts, m_Points);
|
||||
|
||||
m_Points.reserve(Pts.size() * 3);
|
||||
int PrevX = Pts.front().m_BlockX;
|
||||
int PrevY = Pts.front().m_BlockY;
|
||||
int PrevZ = Pts.front().m_BlockZ;
|
||||
cCaveDefPoint & PrevPoint = Pts.front();
|
||||
int PrevX = PrevPoint.m_BlockX;
|
||||
int PrevY = PrevPoint.m_BlockY;
|
||||
int PrevZ = PrevPoint.m_BlockZ;
|
||||
for (cCaveDefPoints::const_iterator itr = Pts.begin() + 1, end = Pts.end(); itr != end; ++itr)
|
||||
{
|
||||
int x1 = itr->m_BlockX;
|
||||
@ -433,9 +436,10 @@ void cCaveTunnel::FinishLinear(void)
|
||||
|
||||
void cCaveTunnel::CalcBoundingBox(void)
|
||||
{
|
||||
m_MinBlockX = m_MaxBlockX = m_Points.front().m_BlockX;
|
||||
m_MinBlockY = m_MaxBlockY = m_Points.front().m_BlockY;
|
||||
m_MinBlockZ = m_MaxBlockZ = m_Points.front().m_BlockZ;
|
||||
cCaveDefPoint & Point = m_Points.front();
|
||||
m_MinBlockX = m_MaxBlockX = Point.m_BlockX;
|
||||
m_MinBlockY = m_MaxBlockY = Point.m_BlockY;
|
||||
m_MinBlockZ = m_MaxBlockZ = Point.m_BlockZ;
|
||||
for (cCaveDefPoints::const_iterator itr = m_Points.begin() + 1, end = m_Points.end(); itr != end; ++itr)
|
||||
{
|
||||
m_MinBlockX = std::min(m_MinBlockX, itr->m_BlockX - itr->m_Radius);
|
||||
|
@ -269,7 +269,7 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block
|
||||
int CenterZ = a_BlockZ + OffsetZ;
|
||||
|
||||
// Get the base angle in which the ravine "axis" goes:
|
||||
float Angle = (float)(((float)((a_Noise.IntNoise3DInt(20 * a_BlockX, 70 * a_BlockZ, 6000) / 9) % 16384)) / 16384.0 * 3.141592653);
|
||||
float Angle = (float)(((float)((a_Noise.IntNoise3DInt(20 * a_BlockX, 70 * a_BlockZ, 6000) / 9) % 16384)) / 16384.0 * M_PI);
|
||||
float xc = sin(Angle);
|
||||
float zc = cos(Angle);
|
||||
|
||||
@ -311,12 +311,13 @@ void cStructGenRavines::cRavine::RefineDefPoints(const cRavDefPoints & a_Src, cR
|
||||
a_Dst.clear();
|
||||
a_Dst.reserve(Num * 2 + 2);
|
||||
cRavDefPoints::const_iterator itr = a_Src.begin() + 1;
|
||||
a_Dst.push_back(a_Src.front());
|
||||
int PrevX = a_Src.front().m_BlockX;
|
||||
int PrevZ = a_Src.front().m_BlockZ;
|
||||
int PrevR = a_Src.front().m_Radius;
|
||||
int PrevT = a_Src.front().m_Top;
|
||||
int PrevB = a_Src.front().m_Bottom;
|
||||
const cRavDefPoint & Source = a_Src.front();
|
||||
a_Dst.push_back(Source);
|
||||
int PrevX = Source.m_BlockX;
|
||||
int PrevZ = Source.m_BlockZ;
|
||||
int PrevR = Source.m_Radius;
|
||||
int PrevT = Source.m_Top;
|
||||
int PrevB = Source.m_Bottom;
|
||||
for (int i = 0; i <= Num; ++i, ++itr)
|
||||
{
|
||||
int dx = itr->m_BlockX - PrevX;
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
|
||||
void cGroup::AddCommand( AString a_Command )
|
||||
void cGroup::AddCommand( const AString & a_Command )
|
||||
{
|
||||
m_Commands[ a_Command ] = true;
|
||||
}
|
||||
@ -16,7 +16,7 @@ void cGroup::AddCommand( AString a_Command )
|
||||
|
||||
|
||||
|
||||
void cGroup::AddPermission( AString a_Permission )
|
||||
void cGroup::AddPermission( const AString & a_Permission )
|
||||
{
|
||||
m_Permissions[ a_Permission ] = true;
|
||||
}
|
||||
|
@ -11,11 +11,11 @@ public: // tolua_export
|
||||
cGroup() {}
|
||||
~cGroup() {}
|
||||
|
||||
void SetName( AString a_Name ) { m_Name = a_Name; } // tolua_export
|
||||
void SetName( const AString & a_Name ) { m_Name = a_Name; } // tolua_export
|
||||
const AString & GetName() const { return m_Name; } // tolua_export
|
||||
void SetColor( AString a_Color ) { m_Color = a_Color; } // tolua_export
|
||||
void AddCommand( AString a_Command ); // tolua_export
|
||||
void AddPermission( AString a_Permission ); // tolua_export
|
||||
void SetColor( const AString & a_Color ) { m_Color = a_Color; } // tolua_export
|
||||
void AddCommand( const AString & a_Command ); // tolua_export
|
||||
void AddPermission( const AString & a_Permission ); // tolua_export
|
||||
void InheritFrom( cGroup* a_Group ); // tolua_export
|
||||
|
||||
typedef std::map< AString, bool > PermissionMap;
|
||||
|
@ -198,9 +198,6 @@ bool cItem::IsEnchantable(short item)
|
||||
return true;
|
||||
if ((item >= 298) && (item <= 317))
|
||||
return true;
|
||||
if ((item >= 290) && (item <= 294))
|
||||
return true;
|
||||
|
||||
if ((item == 346) || (item == 359) || (item == 261))
|
||||
return true;
|
||||
|
||||
|
@ -431,7 +431,6 @@ bool cItemHandler::IsTool()
|
||||
|| (m_ItemType >= 267 && m_ItemType <= 279)
|
||||
|| (m_ItemType >= 283 && m_ItemType <= 286)
|
||||
|| (m_ItemType >= 290 && m_ItemType <= 294)
|
||||
|| (m_ItemType >= 256 && m_ItemType <= 259)
|
||||
|| (m_ItemType == 325)
|
||||
|| (m_ItemType == 346);
|
||||
}
|
||||
|
@ -58,13 +58,13 @@ public:
|
||||
|
||||
struct FoodInfo
|
||||
{
|
||||
int FoodLevel;
|
||||
double Saturation;
|
||||
int FoodLevel;
|
||||
int PoisonChance; // 0 - 100, in percent. 0 = no chance of poisoning, 100 = sure poisoning
|
||||
|
||||
FoodInfo(int a_FoodLevel, double a_Saturation, int a_PoisonChance = 0) :
|
||||
FoodLevel(a_FoodLevel),
|
||||
Saturation(a_Saturation),
|
||||
FoodLevel(a_FoodLevel),
|
||||
PoisonChance(a_PoisonChance)
|
||||
{
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ void cMobProximityCounter::CollectMob(cEntity& a_Monster, cChunk& a_Chunk, doubl
|
||||
|
||||
void cMobProximityCounter::convertMaps()
|
||||
{
|
||||
for(tMonsterToDistance::const_iterator itr = m_MonsterToDistance.begin(); itr != m_MonsterToDistance.end(); itr++)
|
||||
for(tMonsterToDistance::const_iterator itr = m_MonsterToDistance.begin(); itr != m_MonsterToDistance.end(); ++itr)
|
||||
{
|
||||
m_DistanceToMonster.insert(tDistanceToMonster::value_type(itr->second.m_Distance,sMonsterAndChunk(*itr->first,itr->second.m_Chunk)));
|
||||
}
|
||||
@ -55,7 +55,7 @@ cMobProximityCounter::sIterablePair cMobProximityCounter::getMobWithinThosesDist
|
||||
convertMaps();
|
||||
}
|
||||
|
||||
for(tDistanceToMonster::const_iterator itr = m_DistanceToMonster.begin(); itr != m_DistanceToMonster.end(); itr++)
|
||||
for(tDistanceToMonster::const_iterator itr = m_DistanceToMonster.begin(); itr != m_DistanceToMonster.end(); ++itr)
|
||||
{
|
||||
if (toReturn.m_Begin == m_DistanceToMonster.end())
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily,const std::set<cMonst
|
||||
m_NewPack(true),
|
||||
m_MobType(cMonster::mtInvalidType)
|
||||
{
|
||||
for (std::set<cMonster::eType>::const_iterator itr = a_AllowedTypes.begin(); itr != a_AllowedTypes.end(); itr++)
|
||||
for (std::set<cMonster::eType>::const_iterator itr = a_AllowedTypes.begin(); itr != a_AllowedTypes.end(); ++itr)
|
||||
{
|
||||
if (cMonster::FamilyFromType(*itr) == a_MonsterFamily)
|
||||
{
|
||||
@ -112,7 +112,7 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
||||
|
||||
for(int i = 0; i < iRandom; i++)
|
||||
{
|
||||
itr++;
|
||||
++itr;
|
||||
}
|
||||
|
||||
return *itr;
|
||||
|
@ -36,7 +36,8 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
|
||||
void cSheep::OnRightClicked(cPlayer & a_Player)
|
||||
{
|
||||
if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared))
|
||||
const cItem & EquippedItem = a_Player.GetEquippedItem();
|
||||
if ((EquippedItem.m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared))
|
||||
{
|
||||
m_IsSheared = true;
|
||||
m_World->BroadcastEntityMetadata(*this);
|
||||
@ -51,9 +52,9 @@ void cSheep::OnRightClicked(cPlayer & a_Player)
|
||||
Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor));
|
||||
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
|
||||
}
|
||||
if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - a_Player.GetEquippedItem().m_ItemDamage))
|
||||
else if ((EquippedItem.m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - EquippedItem.m_ItemDamage))
|
||||
{
|
||||
m_WoolColor = 15 - a_Player.GetEquippedItem().m_ItemDamage;
|
||||
m_WoolColor = 15 - EquippedItem.m_ItemDamage;
|
||||
if (!a_Player.IsGameModeCreative())
|
||||
{
|
||||
a_Player.GetInventory().RemoveOneEquippedItem();
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
void SetIsTame (bool a_IsTame) { m_IsTame = a_IsTame; }
|
||||
void SetIsBegging (bool a_IsBegging) { m_IsBegging = a_IsBegging; }
|
||||
void SetIsAngry (bool a_IsAngry) { m_IsAngry = a_IsAngry; }
|
||||
void SetOwner (AString a_NewOwner) { m_OwnerName = a_NewOwner; }
|
||||
void SetOwner (const AString & a_NewOwner) { m_OwnerName = a_NewOwner; }
|
||||
void SetCollarColor(int a_CollarColor) { m_CollarColor = a_CollarColor; }
|
||||
|
||||
protected:
|
||||
|
@ -840,12 +840,14 @@ void cPerlinNoise::Generate2D(
|
||||
}
|
||||
|
||||
// Generate the first octave directly into array:
|
||||
m_Octaves.front().m_Noise.Generate2D(
|
||||
const cOctave & FirstOctave = m_Octaves.front();
|
||||
|
||||
FirstOctave.m_Noise.Generate2D(
|
||||
a_Workspace, a_SizeX, a_SizeY,
|
||||
a_StartX * m_Octaves.front().m_Frequency, a_EndX * m_Octaves.front().m_Frequency,
|
||||
a_StartY * m_Octaves.front().m_Frequency, a_EndY * m_Octaves.front().m_Frequency
|
||||
a_StartX * FirstOctave.m_Frequency, a_EndX * FirstOctave.m_Frequency,
|
||||
a_StartY * FirstOctave.m_Frequency, a_EndY * FirstOctave.m_Frequency
|
||||
);
|
||||
NOISE_DATATYPE Amplitude = m_Octaves.front().m_Amplitude;
|
||||
NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude;
|
||||
for (int i = 0; i < ArrayCount; i++)
|
||||
{
|
||||
a_Array[i] *= Amplitude;
|
||||
@ -902,13 +904,15 @@ void cPerlinNoise::Generate3D(
|
||||
}
|
||||
|
||||
// Generate the first octave directly into array:
|
||||
m_Octaves.front().m_Noise.Generate3D(
|
||||
const cOctave & FirstOctave = m_Octaves.front();
|
||||
|
||||
FirstOctave.m_Noise.Generate3D(
|
||||
a_Workspace, a_SizeX, a_SizeY, a_SizeZ,
|
||||
a_StartX * m_Octaves.front().m_Frequency, a_EndX * m_Octaves.front().m_Frequency,
|
||||
a_StartY * m_Octaves.front().m_Frequency, a_EndY * m_Octaves.front().m_Frequency,
|
||||
a_StartZ * m_Octaves.front().m_Frequency, a_EndZ * m_Octaves.front().m_Frequency
|
||||
a_StartX * FirstOctave.m_Frequency, a_EndX * FirstOctave.m_Frequency,
|
||||
a_StartY * FirstOctave.m_Frequency, a_EndY * FirstOctave.m_Frequency,
|
||||
a_StartZ * FirstOctave.m_Frequency, a_EndZ * FirstOctave.m_Frequency
|
||||
);
|
||||
NOISE_DATATYPE Amplitude = m_Octaves.front().m_Amplitude;
|
||||
NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude;
|
||||
for (int i = 0; i < ArrayCount; i++)
|
||||
{
|
||||
a_Array[i] = a_Workspace[i] * Amplitude;
|
||||
|
@ -119,9 +119,10 @@ void cAuthenticator::Execute(void)
|
||||
}
|
||||
ASSERT(!m_Queue.empty());
|
||||
|
||||
int ClientID = m_Queue.front().m_ClientID;
|
||||
AString UserName = m_Queue.front().m_Name;
|
||||
AString ServerID = m_Queue.front().m_ServerID;
|
||||
cAuthenticator::cUser & User = m_Queue.front();
|
||||
int ClientID = User.m_ClientID;
|
||||
AString UserName = User.m_Name;
|
||||
AString ServerID = User.m_ServerID;
|
||||
m_Queue.pop_front();
|
||||
Lock.Unlock();
|
||||
|
||||
|
@ -538,9 +538,10 @@ void cProtocol125::SendHealth(void)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
WriteByte (PACKET_UPDATE_HEALTH);
|
||||
WriteShort((short)m_Client->GetPlayer()->GetHealth());
|
||||
WriteShort((short)m_Client->GetPlayer()->GetFoodLevel());
|
||||
WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel());
|
||||
cPlayer * Player = m_Client->GetPlayer();
|
||||
WriteShort((short)Player->GetHealth());
|
||||
WriteShort((short)Player->GetFoodLevel());
|
||||
WriteFloat((float)Player->GetFoodSaturationLevel());
|
||||
Flush();
|
||||
}
|
||||
|
||||
@ -668,13 +669,14 @@ void cProtocol125::SendPickupSpawn(const cPickup & a_Pickup)
|
||||
cCSLock Lock(m_CSPacket);
|
||||
WriteByte (PACKET_PICKUP_SPAWN);
|
||||
WriteInt (a_Pickup.GetUniqueID());
|
||||
WriteShort (a_Pickup.GetItem().m_ItemType);
|
||||
WriteChar (a_Pickup.GetItem().m_ItemCount);
|
||||
WriteShort (a_Pickup.GetItem().m_ItemDamage);
|
||||
const cItem & Item = a_Pickup.GetItem();
|
||||
WriteShort (Item.m_ItemType);
|
||||
WriteChar (Item.m_ItemCount);
|
||||
WriteShort (Item.m_ItemDamage);
|
||||
WriteVectorI((Vector3i)(a_Pickup.GetPosition() * 32));
|
||||
WriteByte ((char)(a_Pickup.GetSpeed().x * 8));
|
||||
WriteByte ((char)(a_Pickup.GetSpeed().y * 8));
|
||||
WriteByte ((char)(a_Pickup.GetSpeed().z * 8));
|
||||
WriteByte ((char)(a_Pickup.GetSpeedX() * 8));
|
||||
WriteByte ((char)(a_Pickup.GetSpeedY() * 8));
|
||||
WriteByte ((char)(a_Pickup.GetSpeedZ() * 8));
|
||||
Flush();
|
||||
}
|
||||
|
||||
@ -831,10 +833,11 @@ void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect
|
||||
void cProtocol125::SendRespawn(void)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
cPlayer * Player = m_Client->GetPlayer();
|
||||
WriteByte (PACKET_RESPAWN);
|
||||
WriteInt ((int)(m_Client->GetPlayer()->GetWorld()->GetDimension()));
|
||||
WriteInt ((int)(Player->GetWorld()->GetDimension()));
|
||||
WriteByte (2); // TODO: Difficulty; 2 = Normal
|
||||
WriteChar ((char)m_Client->GetPlayer()->GetGameMode());
|
||||
WriteChar ((char)Player->GetGameMode());
|
||||
WriteShort (256); // Current world height
|
||||
WriteString("default");
|
||||
}
|
||||
@ -846,10 +849,11 @@ void cProtocol125::SendRespawn(void)
|
||||
void cProtocol125::SendExperience(void)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
cPlayer * Player = m_Client->GetPlayer();
|
||||
WriteByte (PACKET_EXPERIENCE);
|
||||
WriteFloat (m_Client->GetPlayer()->GetXpPercentage());
|
||||
WriteShort (m_Client->GetPlayer()->GetXpLevel());
|
||||
WriteShort (m_Client->GetPlayer()->GetCurrentXp());
|
||||
WriteFloat (Player->GetXpPercentage());
|
||||
WriteShort (Player->GetXpLevel());
|
||||
WriteShort (Player->GetCurrentXp());
|
||||
Flush();
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,8 @@ void cProtocol132::SendWholeInventory(const cWindow & a_Window)
|
||||
super::SendWholeInventory(a_Window);
|
||||
|
||||
// Send the player inventory and hotbar:
|
||||
const cInventory & Inventory = m_Client->GetPlayer()->GetInventory();
|
||||
cPlayer * Player = m_Client->GetPlayer();
|
||||
const cInventory & Inventory = Player->GetInventory();
|
||||
int BaseOffset = a_Window.GetNumSlots() - (cInventory::invNumSlots - cInventory::invInventoryOffset); // Number of non-inventory slots
|
||||
char WindowID = a_Window.GetWindowID();
|
||||
for (short i = 0; i < cInventory::invInventoryCount; i++)
|
||||
@ -422,7 +423,7 @@ void cProtocol132::SendWholeInventory(const cWindow & a_Window)
|
||||
} // for i - Hotbar[]
|
||||
|
||||
// Send even the item being dragged:
|
||||
SendInventorySlot(-1, -1, m_Client->GetPlayer()->GetDraggingItem());
|
||||
SendInventorySlot(-1, -1, Player->GetDraggingItem());
|
||||
}
|
||||
|
||||
|
||||
@ -800,10 +801,12 @@ void cProtocol132::SendCompass(const cWorld & a_World)
|
||||
void cProtocol132::SendEncryptionKeyRequest(void)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
cServer * Server = cRoot::Get()->GetServer();
|
||||
WriteByte(0xfd);
|
||||
WriteString(cRoot::Get()->GetServer()->GetServerID());
|
||||
WriteShort((short)(cRoot::Get()->GetServer()->GetPublicKeyDER().size()));
|
||||
SendData(cRoot::Get()->GetServer()->GetPublicKeyDER().data(), cRoot::Get()->GetServer()->GetPublicKeyDER().size());
|
||||
WriteString(Server->GetServerID());
|
||||
const AString & PublicKeyDER = Server->GetPublicKeyDER();
|
||||
WriteShort((short)(PublicKeyDER.size()));
|
||||
SendData(PublicKeyDER.data(), PublicKeyDER.size());
|
||||
WriteShort(4);
|
||||
WriteInt((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
|
||||
Flush();
|
||||
@ -874,10 +877,11 @@ void cProtocol132::StartEncryption(const Byte * a_Key)
|
||||
|
||||
// Prepare the m_AuthServerID:
|
||||
cSHA1Checksum Checksum;
|
||||
AString ServerID = cRoot::Get()->GetServer()->GetServerID();
|
||||
cServer * Server = cRoot::Get()->GetServer();
|
||||
AString ServerID = Server->GetServerID();
|
||||
Checksum.Update((const Byte *)ServerID.c_str(), ServerID.length());
|
||||
Checksum.Update(a_Key, 16);
|
||||
Checksum.Update((const Byte *)cRoot::Get()->GetServer()->GetPublicKeyDER().data(), cRoot::Get()->GetServer()->GetPublicKeyDER().size());
|
||||
Checksum.Update((const Byte *)Server->GetPublicKeyDER().data(), Server->GetPublicKeyDER().size());
|
||||
Byte Digest[20];
|
||||
Checksum.Finalize(Digest);
|
||||
cSHA1Checksum::DigestToJava(Digest, m_AuthServerID);
|
||||
|
@ -103,9 +103,9 @@ void cProtocol142::SendPickupSpawn(const cPickup & a_Pickup)
|
||||
WriteInt (a_Pickup.GetUniqueID());
|
||||
WriteItem (a_Pickup.GetItem());
|
||||
WriteVectorI((Vector3i)(a_Pickup.GetPosition() * 32));
|
||||
WriteChar ((char)(a_Pickup.GetSpeed().x * 8));
|
||||
WriteChar ((char)(a_Pickup.GetSpeed().y * 8));
|
||||
WriteChar ((char)(a_Pickup.GetSpeed().z * 8));
|
||||
WriteChar((char)(a_Pickup.GetSpeedX() * 8));
|
||||
WriteChar((char)(a_Pickup.GetSpeedY() * 8));
|
||||
WriteChar((char)(a_Pickup.GetSpeedZ() * 8));
|
||||
Flush();
|
||||
}
|
||||
|
||||
@ -170,9 +170,9 @@ void cProtocol146::SendPickupSpawn(const cPickup & a_Pickup)
|
||||
WriteInt ((int)(a_Pickup.GetPosY() * 32));
|
||||
WriteInt ((int)(a_Pickup.GetPosZ() * 32));
|
||||
WriteInt (1);
|
||||
WriteShort((short)(a_Pickup.GetSpeed().x * 32));
|
||||
WriteShort((short)(a_Pickup.GetSpeed().y * 32));
|
||||
WriteShort((short)(a_Pickup.GetSpeed().z * 32));
|
||||
WriteShort((short)(a_Pickup.GetSpeedX() * 32));
|
||||
WriteShort((short)(a_Pickup.GetSpeedY() * 32));
|
||||
WriteShort((short)(a_Pickup.GetSpeedZ() * 32));
|
||||
WriteByte(0);
|
||||
WriteByte(0);
|
||||
|
||||
|
@ -131,9 +131,10 @@ void cProtocol161::SendHealth(void)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
WriteByte (PACKET_UPDATE_HEALTH);
|
||||
WriteFloat((float)m_Client->GetPlayer()->GetHealth());
|
||||
WriteShort((short)m_Client->GetPlayer()->GetFoodLevel());
|
||||
WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel());
|
||||
cPlayer * Player = m_Client->GetPlayer();
|
||||
WriteFloat((float)Player->GetHealth());
|
||||
WriteShort((short)Player->GetFoodLevel());
|
||||
WriteFloat((float)Player->GetFoodSaturationLevel());
|
||||
Flush();
|
||||
}
|
||||
|
||||
@ -144,11 +145,12 @@ void cProtocol161::SendHealth(void)
|
||||
void cProtocol161::SendPlayerMaxSpeed(void)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
cPlayer * Player = m_Client->GetPlayer();
|
||||
WriteByte(PACKET_ENTITY_PROPERTIES);
|
||||
WriteInt(m_Client->GetPlayer()->GetUniqueID());
|
||||
WriteInt(Player->GetUniqueID());
|
||||
WriteInt(1);
|
||||
WriteString("generic.movementSpeed");
|
||||
WriteDouble(0.1 * m_Client->GetPlayer()->GetMaxSpeed());
|
||||
WriteDouble(0.1 * Player->GetMaxSpeed());
|
||||
Flush();
|
||||
}
|
||||
|
||||
@ -295,11 +297,12 @@ cProtocol162::cProtocol162(cClientHandle * a_Client) :
|
||||
void cProtocol162::SendPlayerMaxSpeed(void)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
cPlayer * Player = m_Client->GetPlayer();
|
||||
WriteByte(PACKET_ENTITY_PROPERTIES);
|
||||
WriteInt(m_Client->GetPlayer()->GetUniqueID());
|
||||
WriteInt(Player->GetUniqueID());
|
||||
WriteInt(1);
|
||||
WriteString("generic.movementSpeed");
|
||||
WriteDouble(0.1 * m_Client->GetPlayer()->GetMaxSpeed());
|
||||
WriteDouble(0.1 * Player->GetMaxSpeed());
|
||||
WriteShort(0);
|
||||
Flush();
|
||||
}
|
||||
|
@ -563,9 +563,10 @@ void cProtocol172::SendHealth(void)
|
||||
ASSERT(m_State == 3); // In game mode?
|
||||
|
||||
cPacketizer Pkt(*this, 0x06); // Update Health packet
|
||||
Pkt.WriteFloat((float)m_Client->GetPlayer()->GetHealth());
|
||||
Pkt.WriteShort(m_Client->GetPlayer()->GetFoodLevel());
|
||||
Pkt.WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel());
|
||||
cPlayer * Player = m_Client->GetPlayer();
|
||||
Pkt.WriteFloat((float)Player->GetHealth());
|
||||
Pkt.WriteShort(Player->GetFoodLevel());
|
||||
Pkt.WriteFloat((float)Player->GetFoodSaturationLevel());
|
||||
}
|
||||
|
||||
|
||||
@ -607,12 +608,13 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
|
||||
{
|
||||
// Send the Join Game packet:
|
||||
{
|
||||
cServer * Server = cRoot::Get()->GetServer();
|
||||
cPacketizer Pkt(*this, 0x01); // Join Game packet
|
||||
Pkt.WriteInt(a_Player.GetUniqueID());
|
||||
Pkt.WriteByte((Byte)a_Player.GetEffectiveGameMode() | (cRoot::Get()->GetServer()->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
|
||||
Pkt.WriteByte((Byte)a_Player.GetEffectiveGameMode() | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
|
||||
Pkt.WriteChar((char)a_World.GetDimension());
|
||||
Pkt.WriteByte(2); // TODO: Difficulty (set to Normal)
|
||||
Pkt.WriteByte(std::min(cRoot::Get()->GetServer()->GetMaxPlayers(), 60));
|
||||
Pkt.WriteByte(std::min(Server->GetMaxPlayers(), 60));
|
||||
Pkt.WriteString("default"); // Level type - wtf?
|
||||
}
|
||||
|
||||
@ -758,22 +760,23 @@ void cProtocol172::SendPlayerAbilities(void)
|
||||
|
||||
cPacketizer Pkt(*this, 0x39); // Player Abilities packet
|
||||
Byte Flags = 0;
|
||||
if (m_Client->GetPlayer()->IsGameModeCreative())
|
||||
cPlayer * Player = m_Client->GetPlayer();
|
||||
if (Player->IsGameModeCreative())
|
||||
{
|
||||
Flags |= 0x01;
|
||||
Flags |= 0x08; // Godmode, used for creative
|
||||
}
|
||||
if (m_Client->GetPlayer()->IsFlying())
|
||||
if (Player->IsFlying())
|
||||
{
|
||||
Flags |= 0x02;
|
||||
}
|
||||
if (m_Client->GetPlayer()->CanFly())
|
||||
if (Player->CanFly())
|
||||
{
|
||||
Flags |= 0x04;
|
||||
}
|
||||
Pkt.WriteByte(Flags);
|
||||
Pkt.WriteFloat((float)(0.05 * m_Client->GetPlayer()->GetFlyingMaxSpeed()));
|
||||
Pkt.WriteFloat((float)(0.1 * m_Client->GetPlayer()->GetMaxSpeed()));
|
||||
Pkt.WriteFloat((float)(0.05 * Player->GetFlyingMaxSpeed()));
|
||||
Pkt.WriteFloat((float)(0.1 * Player->GetMaxSpeed()));
|
||||
}
|
||||
|
||||
|
||||
@ -832,17 +835,18 @@ void cProtocol172::SendPlayerMaxSpeed(void)
|
||||
ASSERT(m_State == 3); // In game mode?
|
||||
|
||||
cPacketizer Pkt(*this, 0x20); // Entity Properties
|
||||
Pkt.WriteInt(m_Client->GetPlayer()->GetUniqueID());
|
||||
cPlayer * Player = m_Client->GetPlayer();
|
||||
Pkt.WriteInt(Player->GetUniqueID());
|
||||
Pkt.WriteInt(1); // Count
|
||||
Pkt.WriteString("generic.movementSpeed");
|
||||
// The default game speed is 0.1, multiply that value by the relative speed:
|
||||