Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.
This reverts commit a9be52c41a.
This commit is contained in:
@@ -65,7 +65,7 @@ void PlayerChunkMap::PlayerChunk::add(shared_ptr<ServerPlayer> player, bool send
|
||||
player->seenChunks.insert(pos);
|
||||
|
||||
// 4J Added the sendPacket check. See PlayerChunkMap::add for the usage
|
||||
if( sendPacket ) player->connection->send(std::make_shared<ChunkVisibilityPacket>(pos.x, pos.z, true));
|
||||
if( sendPacket ) player->connection->send( shared_ptr<ChunkVisibilityPacket>( new ChunkVisibilityPacket(pos.x, pos.z, true) ) );
|
||||
|
||||
if (players.empty())
|
||||
{
|
||||
@@ -83,7 +83,7 @@ void PlayerChunkMap::PlayerChunk::add(shared_ptr<ServerPlayer> player, bool send
|
||||
|
||||
void PlayerChunkMap::PlayerChunk::remove(shared_ptr<ServerPlayer> player)
|
||||
{
|
||||
PlayerChunkMap::PlayerChunk *toDelete = nullptr;
|
||||
PlayerChunkMap::PlayerChunk *toDelete = NULL;
|
||||
|
||||
//app.DebugPrintf("--- PlayerChunkMap::PlayerChunk::remove x=%d\tz=%d\n",x,z);
|
||||
auto it = find(players.begin(), players.end(), player);
|
||||
@@ -122,7 +122,7 @@ void PlayerChunkMap::PlayerChunk::remove(shared_ptr<ServerPlayer> player)
|
||||
// 4J - I don't think there's any point sending these anymore, as we don't need to unload chunks with fixed sized maps
|
||||
// 4J - We do need to send these to unload entities in chunks when players are dead. If we do not and the entity is removed
|
||||
// while they are dead, that entity will remain in the clients world
|
||||
if (player->connection != nullptr && player->seenChunks.find(pos) != player->seenChunks.end())
|
||||
if (player->connection != NULL && player->seenChunks.find(pos) != player->seenChunks.end())
|
||||
{
|
||||
INetworkPlayer *thisNetPlayer = player->connection->getNetworkPlayer();
|
||||
bool noOtherPlayersFound = true;
|
||||
@@ -134,7 +134,7 @@ void PlayerChunkMap::PlayerChunk::remove(shared_ptr<ServerPlayer> player)
|
||||
if ( currPlayer )
|
||||
{
|
||||
INetworkPlayer *currNetPlayer = currPlayer->connection->getNetworkPlayer();
|
||||
if( currNetPlayer != nullptr && currNetPlayer->IsSameSystem( thisNetPlayer ) && currPlayer->seenChunks.find(pos) != currPlayer->seenChunks.end() )
|
||||
if( currNetPlayer != NULL && currNetPlayer->IsSameSystem( thisNetPlayer ) && currPlayer->seenChunks.find(pos) != currPlayer->seenChunks.end() )
|
||||
{
|
||||
noOtherPlayersFound = false;
|
||||
break;
|
||||
@@ -144,12 +144,12 @@ void PlayerChunkMap::PlayerChunk::remove(shared_ptr<ServerPlayer> player)
|
||||
if(noOtherPlayersFound)
|
||||
{
|
||||
//wprintf(L"Sending ChunkVisiblity packet false for chunk (%d,%d) to player %ls\n", x, z, player->name.c_str() );
|
||||
player->connection->send(std::make_shared<ChunkVisibilityPacket>(pos.x, pos.z, false));
|
||||
player->connection->send( shared_ptr<ChunkVisibilityPacket>( new ChunkVisibilityPacket(pos.x, pos.z, false) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//app.DebugPrintf("PlayerChunkMap::PlayerChunk::remove - QNetPlayer is nullptr\n");
|
||||
//app.DebugPrintf("PlayerChunkMap::PlayerChunk::remove - QNetPlayer is NULL\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ void PlayerChunkMap::PlayerChunk::tileChanged(int x, int y, int z)
|
||||
|
||||
if (changes < MAX_CHANGES_BEFORE_RESEND)
|
||||
{
|
||||
short id = static_cast<short>((x << 12) | (z << 8) | (y));
|
||||
short id = (short) ((x << 12) | (z << 8) | (y));
|
||||
|
||||
for (int i = 0; i < changes; i++)
|
||||
{
|
||||
@@ -208,7 +208,7 @@ void PlayerChunkMap::PlayerChunk::prioritiseTileChanges()
|
||||
// One system id per machine so we send at most once per system. Local = 256, remote = GetSmallId().
|
||||
static int getSystemIdForSentTo(INetworkPlayer* np)
|
||||
{
|
||||
if (np == nullptr) return -1;
|
||||
if (np == NULL) return -1;
|
||||
return np->IsLocal() ? 256 : (int)np->GetSmallId();
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<Packet> packet)
|
||||
{
|
||||
shared_ptr<ServerPlayer> player = players[i];
|
||||
INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer();
|
||||
if (thisPlayer == nullptr) continue;
|
||||
if (thisPlayer == NULL) continue;
|
||||
int sysId = getSystemIdForSentTo(thisPlayer);
|
||||
if (sysId >= 0 && sentToSystemIds.find(sysId) != sentToSystemIds.end())
|
||||
continue;
|
||||
@@ -239,15 +239,15 @@ void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<Packet> packet)
|
||||
for (size_t i = 0; i < allPlayers.size(); i++)
|
||||
{
|
||||
shared_ptr<ServerPlayer> player = allPlayers[i];
|
||||
if (player->connection == nullptr || player->connection->isLocal()) continue;
|
||||
if (player->connection == NULL || player->connection->isLocal()) continue;
|
||||
|
||||
INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer();
|
||||
if (thisPlayer == nullptr) continue;
|
||||
if (thisPlayer == NULL) continue;
|
||||
int sysId = getSystemIdForSentTo(thisPlayer);
|
||||
if (sysId >= 0 && sentToSystemIds.find(sysId) != sentToSystemIds.end())
|
||||
continue;
|
||||
|
||||
const int flagIndex = ServerPlayer::getFlagIndexForChunk(pos, parent->dimension);
|
||||
int flagIndex = ServerPlayer::getFlagIndexForChunk(pos, parent->dimension);
|
||||
if (!g_NetworkManager.SystemFlagGet(thisPlayer, flagIndex)) continue;
|
||||
|
||||
player->connection->send(packet);
|
||||
@@ -270,7 +270,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
|
||||
int x = pos.x * 16 + xChangeMin;
|
||||
int y = yChangeMin;
|
||||
int z = pos.z * 16 + zChangeMin;
|
||||
broadcast(std::make_shared<TileUpdatePacket>(x, y, z, level));
|
||||
broadcast( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
||||
if (level->isEntityTile(x, y, z))
|
||||
{
|
||||
broadcast(level->getTileEntity(x, y, z));
|
||||
@@ -300,7 +300,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
|
||||
// Block region update packets can only encode ys in a range of 1 - 256
|
||||
if( ys > 256 ) ys = 256;
|
||||
|
||||
broadcast(std::make_shared<BlockRegionUpdatePacket>(xp, yp, zp, xs, ys, zs, level));
|
||||
broadcast( shared_ptr<BlockRegionUpdatePacket>( new BlockRegionUpdatePacket(xp, yp, zp, xs, ys, zs, level) ) );
|
||||
vector<shared_ptr<TileEntity> > *tes = level->getTileEntitiesInRegion(xp, yp, zp, xp + xs, yp + ys, zp + zs);
|
||||
for (unsigned int i = 0; i < tes->size(); i++)
|
||||
{
|
||||
@@ -313,7 +313,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
|
||||
else
|
||||
{
|
||||
// 4J As we only get here if changes is less than MAX_CHANGES_BEFORE_RESEND (10) we only need to send a byte value in the packet
|
||||
broadcast(std::make_shared<ChunkTilesUpdatePacket>(pos.x, pos.z, changedTiles, static_cast<byte>(changes), level));
|
||||
broadcast( shared_ptr<ChunkTilesUpdatePacket>( new ChunkTilesUpdatePacket(pos.x, pos.z, changedTiles, (byte)changes, level) ) );
|
||||
for (int i = 0; i < changes; i++)
|
||||
{
|
||||
int x = pos.x * 16 + ((changedTiles[i] >> 12) & 15);
|
||||
@@ -334,10 +334,10 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
|
||||
|
||||
void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<TileEntity> te)
|
||||
{
|
||||
if (te != nullptr)
|
||||
if (te != NULL)
|
||||
{
|
||||
shared_ptr<Packet> p = te->getUpdatePacket();
|
||||
if (p != nullptr)
|
||||
if (p != NULL)
|
||||
{
|
||||
broadcast(p);
|
||||
}
|
||||
@@ -375,7 +375,7 @@ void PlayerChunkMap::tick()
|
||||
{
|
||||
lastInhabitedUpdate = time;
|
||||
|
||||
for (size_t i = 0; i < knownChunks.size(); i++)
|
||||
for (int i = 0; i < knownChunks.size(); i++)
|
||||
{
|
||||
PlayerChunk *chunk = knownChunks.at(i);
|
||||
|
||||
@@ -492,8 +492,8 @@ void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player)
|
||||
if( addRequests.size() )
|
||||
{
|
||||
// Find the nearest chunk request to the player
|
||||
int px = static_cast<int>(player->x);
|
||||
int pz = static_cast<int>(player->z);
|
||||
int px = (int)player->x;
|
||||
int pz = (int)player->z;
|
||||
int minDistSq = -1;
|
||||
|
||||
auto itNearest = addRequests.end();
|
||||
@@ -527,7 +527,7 @@ void PlayerChunkMap::broadcastTileUpdate(shared_ptr<Packet> packet, int x, int y
|
||||
int xc = x >> 4;
|
||||
int zc = z >> 4;
|
||||
PlayerChunk *chunk = getChunk(xc, zc, false);
|
||||
if (chunk != nullptr)
|
||||
if (chunk != NULL)
|
||||
{
|
||||
chunk->broadcast(packet);
|
||||
}
|
||||
@@ -538,7 +538,7 @@ void PlayerChunkMap::tileChanged(int x, int y, int z)
|
||||
int xc = x >> 4;
|
||||
int zc = z >> 4;
|
||||
PlayerChunk *chunk = getChunk(xc, zc, false);
|
||||
if (chunk != nullptr)
|
||||
if (chunk != NULL)
|
||||
{
|
||||
chunk->tileChanged(x & 15, y, z & 15);
|
||||
}
|
||||
@@ -559,7 +559,7 @@ void PlayerChunkMap::prioritiseTileChanges(int x, int y, int z)
|
||||
int xc = x >> 4;
|
||||
int zc = z >> 4;
|
||||
PlayerChunk *chunk = getChunk(xc, zc, false);
|
||||
if (chunk != nullptr)
|
||||
if (chunk != NULL)
|
||||
{
|
||||
chunk->prioritiseTileChanges();
|
||||
}
|
||||
@@ -569,8 +569,8 @@ void PlayerChunkMap::add(shared_ptr<ServerPlayer> player)
|
||||
{
|
||||
static int direction[4][2] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, {0, -1} };
|
||||
|
||||
int xc = static_cast<int>(player->x) >> 4;
|
||||
int zc = static_cast<int>(player->z) >> 4;
|
||||
int xc = (int) player->x >> 4;
|
||||
int zc = (int) player->z >> 4;
|
||||
|
||||
player->lastMoveX = player->x;
|
||||
player->lastMoveZ = player->z;
|
||||
@@ -660,7 +660,7 @@ void PlayerChunkMap::add(shared_ptr<ServerPlayer> player)
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
player->connection->send(std::make_shared<ChunkVisibilityAreaPacket>(minX, maxX, minZ, maxZ));
|
||||
player->connection->send( shared_ptr<ChunkVisibilityAreaPacket>( new ChunkVisibilityAreaPacket(minX, maxX, minZ, maxZ) ) );
|
||||
|
||||
#ifdef _LARGE_WORLDS
|
||||
getLevel()->cache->dontDrop(xc,zc);
|
||||
@@ -672,14 +672,14 @@ void PlayerChunkMap::add(shared_ptr<ServerPlayer> player)
|
||||
|
||||
void PlayerChunkMap::remove(shared_ptr<ServerPlayer> player)
|
||||
{
|
||||
int xc = static_cast<int>(player->lastMoveX) >> 4;
|
||||
int zc = static_cast<int>(player->lastMoveZ) >> 4;
|
||||
int xc = ((int) player->lastMoveX) >> 4;
|
||||
int zc = ((int) player->lastMoveZ) >> 4;
|
||||
|
||||
for (int x = xc - radius; x <= xc + radius; x++)
|
||||
for (int z = zc - radius; z <= zc + radius; z++)
|
||||
{
|
||||
PlayerChunk *playerChunk = getChunk(x, z, false);
|
||||
if (playerChunk != nullptr) playerChunk->remove(player);
|
||||
if (playerChunk != NULL) playerChunk->remove(player);
|
||||
}
|
||||
|
||||
auto it = find(players.begin(), players.end(), player);
|
||||
@@ -715,16 +715,16 @@ bool PlayerChunkMap::chunkInRange(int x, int z, int xc, int zc)
|
||||
// need to be created, so that we aren't creating potentially 20 chunks per player per tick
|
||||
void PlayerChunkMap::move(shared_ptr<ServerPlayer> player)
|
||||
{
|
||||
int xc = static_cast<int>(player->x) >> 4;
|
||||
int zc = static_cast<int>(player->z) >> 4;
|
||||
int xc = ((int) player->x) >> 4;
|
||||
int zc = ((int) player->z) >> 4;
|
||||
|
||||
double _xd = player->lastMoveX - player->x;
|
||||
double _zd = player->lastMoveZ - player->z;
|
||||
double dist = _xd * _xd + _zd * _zd;
|
||||
if (dist < 8 * 8) return;
|
||||
|
||||
int last_xc = static_cast<int>(player->lastMoveX) >> 4;
|
||||
int last_zc = static_cast<int>(player->lastMoveZ) >> 4;
|
||||
int last_xc = ((int) player->lastMoveX) >> 4;
|
||||
int last_zc = ((int) player->lastMoveZ) >> 4;
|
||||
|
||||
int xd = xc - last_xc;
|
||||
int zd = zc - last_zc;
|
||||
@@ -759,7 +759,7 @@ bool PlayerChunkMap::isPlayerIn(shared_ptr<ServerPlayer> player, int xChunk, int
|
||||
{
|
||||
PlayerChunk *chunk = getChunk(xChunk, zChunk, false);
|
||||
|
||||
if(chunk == nullptr)
|
||||
if(chunk == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -770,7 +770,7 @@ bool PlayerChunkMap::isPlayerIn(shared_ptr<ServerPlayer> player, int xChunk, int
|
||||
return it1 != chunk->players.end() && it2 == player->chunksToSend.end();
|
||||
}
|
||||
|
||||
//return chunk == nullptr ? false : chunk->players->contains(player) && !player->chunksToSend->contains(chunk->pos);
|
||||
//return chunk == NULL ? false : chunk->players->contains(player) && !player->chunksToSend->contains(chunk->pos);
|
||||
}
|
||||
|
||||
int PlayerChunkMap::convertChunkRangeToBlock(int radius)
|
||||
@@ -784,13 +784,13 @@ void PlayerChunkMap::setRadius(int newRadius)
|
||||
if( radius != newRadius )
|
||||
{
|
||||
PlayerList* players = level->getServer()->getPlayerList();
|
||||
for( size_t i = 0;i < players->players.size();i += 1 )
|
||||
for( int i = 0;i < players->players.size();i += 1 )
|
||||
{
|
||||
shared_ptr<ServerPlayer> player = players->players[i];
|
||||
if( player->level == level )
|
||||
{
|
||||
int xc = static_cast<int>(player->x) >> 4;
|
||||
int zc = static_cast<int>(player->z) >> 4;
|
||||
int xc = ((int) player->x) >> 4;
|
||||
int zc = ((int) player->z) >> 4;
|
||||
|
||||
for (int x = xc - newRadius; x <= xc + newRadius; x++)
|
||||
for (int z = zc - newRadius; z <= zc + newRadius; z++)
|
||||
|
||||
Reference in New Issue
Block a user