parent
6036971c77
commit
e0a361de2a
@ -1707,19 +1707,6 @@ bool cChunk::AddClient(cClientHandle * a_Client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_LoadedByClient.push_back(a_Client);
|
m_LoadedByClient.push_back(a_Client);
|
||||||
|
|
||||||
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
// DEBUG:
|
|
||||||
LOGD("cChunk: Entity #%d (%s) at [%i, %i, %i] spawning for player \"%s\"",
|
|
||||||
(*itr)->GetUniqueID(), (*itr)->GetClass(),
|
|
||||||
m_PosX, m_PosY, m_PosZ,
|
|
||||||
a_Client->GetUsername().c_str()
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
(*itr)->SpawnOn(*a_Client);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,22 +247,38 @@ void cChunkSender::SendChunk(int a_ChunkX, int a_ChunkZ, std::unordered_set<cCli
|
|||||||
}
|
}
|
||||||
cChunkDataSerializer Data(m_Data, m_BiomeMap, m_World.GetDimension());
|
cChunkDataSerializer Data(m_Data, m_BiomeMap, m_World.GetDimension());
|
||||||
|
|
||||||
for (const auto client : a_Clients)
|
for (const auto Client : a_Clients)
|
||||||
{
|
{
|
||||||
// Send:
|
// Send:
|
||||||
client->SendChunkData(a_ChunkX, a_ChunkZ, Data);
|
Client->SendChunkData(a_ChunkX, a_ChunkZ, Data);
|
||||||
|
|
||||||
// Send block-entity packets:
|
// Send block-entity packets:
|
||||||
for (const auto & Pos : m_BlockEntities)
|
for (const auto & Pos : m_BlockEntities)
|
||||||
{
|
{
|
||||||
m_World.SendBlockEntity(Pos.x, Pos.y, Pos.z, *client);
|
m_World.SendBlockEntity(Pos.x, Pos.y, Pos.z, *Client);
|
||||||
} // for itr - m_Packets[]
|
} // for itr - m_Packets[]
|
||||||
|
|
||||||
|
// Send entity packets:
|
||||||
|
for (const auto EntityID : m_EntityIDs)
|
||||||
|
{
|
||||||
|
m_World.DoWithEntityByID(EntityID, [Client](cEntity & a_Entity)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
// DEBUG:
|
||||||
|
LOGD("cChunkSender: Entity #%d (%s) at [%f, %f, %f] spawning for player \"%s\"",
|
||||||
|
a_Entity.GetUniqueID(), a_Entity.GetClass(),
|
||||||
|
a_Entity.GetPosition().x, a_Entity.GetPosition().y, a_Entity.GetPosition().z,
|
||||||
|
Client->GetUsername().c_str()
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
a_Entity.SpawnOn(*Client);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_Data.Clear();
|
m_Data.Clear();
|
||||||
m_BlockEntities.clear();
|
m_BlockEntities.clear();
|
||||||
|
m_EntityIDs.clear();
|
||||||
// TODO: Send entity spawn packets
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -278,9 +294,9 @@ void cChunkSender::BlockEntity(cBlockEntity * a_Entity)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunkSender::Entity(cEntity *)
|
void cChunkSender::Entity(cEntity * a_Entity)
|
||||||
{
|
{
|
||||||
// Nothing needed yet, perhaps in the future when we save entities into chunks we'd like to send them upon load, too ;)
|
m_EntityIDs.push_back(a_Entity->GetUniqueID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ protected:
|
|||||||
// NOTE that m_BlockData[] is inherited from the cChunkDataCollector
|
// NOTE that m_BlockData[] is inherited from the cChunkDataCollector
|
||||||
unsigned char m_BiomeMap[cChunkDef::Width * cChunkDef::Width];
|
unsigned char m_BiomeMap[cChunkDef::Width * cChunkDef::Width];
|
||||||
std::vector<Vector3i> m_BlockEntities; // Coords of the block entities to send
|
std::vector<Vector3i> m_BlockEntities; // Coords of the block entities to send
|
||||||
// TODO: sEntityIDs m_Entities; // Entity-IDs of the entities to send
|
std::vector<UInt32> m_EntityIDs; // Entity-IDs of the entities to send
|
||||||
|
|
||||||
// cIsThread override:
|
// cIsThread override:
|
||||||
virtual void Execute(void) override;
|
virtual void Execute(void) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user