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:
@@ -29,12 +29,12 @@ ServerPlayerGameMode::ServerPlayerGameMode(Level *level)
|
||||
this->level = level;
|
||||
|
||||
// 4J Added
|
||||
m_gameRules = nullptr;
|
||||
m_gameRules = NULL;
|
||||
}
|
||||
|
||||
ServerPlayerGameMode::~ServerPlayerGameMode()
|
||||
{
|
||||
if(m_gameRules!=nullptr) delete m_gameRules;
|
||||
if(m_gameRules!=NULL) delete m_gameRules;
|
||||
}
|
||||
|
||||
void ServerPlayerGameMode::setGameModeForPlayer(GameType *gameModeForPlayer)
|
||||
@@ -86,7 +86,7 @@ void ServerPlayerGameMode::tick()
|
||||
{
|
||||
Tile *tile = Tile::tiles[t];
|
||||
float destroyProgress = tile->getDestroyProgress(player, player->level, delayedDestroyX, delayedDestroyY, delayedDestroyZ) * (ticksSpentDestroying + 1);
|
||||
int state = static_cast<int>(destroyProgress * 10);
|
||||
int state = (int) (destroyProgress * 10);
|
||||
|
||||
if (state != lastSentState)
|
||||
{
|
||||
@@ -105,7 +105,7 @@ void ServerPlayerGameMode::tick()
|
||||
int t = level->getTile(xDestroyBlock, yDestroyBlock, zDestroyBlock);
|
||||
Tile *tile = Tile::tiles[t];
|
||||
|
||||
if (tile == nullptr)
|
||||
if (tile == NULL)
|
||||
{
|
||||
level->destroyTileProgress(player->entityId, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1);
|
||||
lastSentState = -1;
|
||||
@@ -115,7 +115,7 @@ void ServerPlayerGameMode::tick()
|
||||
{
|
||||
int ticksSpentDestroying = gameTicks - destroyProgressStart;
|
||||
float destroyProgress = tile->getDestroyProgress(player, player->level, xDestroyBlock, yDestroyBlock, zDestroyBlock) * (ticksSpentDestroying + 1);
|
||||
int state = static_cast<int>(destroyProgress * 10);
|
||||
int state = (int) (destroyProgress * 10);
|
||||
|
||||
if (state != lastSentState)
|
||||
{
|
||||
@@ -166,7 +166,7 @@ void ServerPlayerGameMode::startDestroyBlock(int x, int y, int z, int face)
|
||||
xDestroyBlock = x;
|
||||
yDestroyBlock = y;
|
||||
zDestroyBlock = z;
|
||||
int state = static_cast<int>(progress * 10);
|
||||
int state = (int) (progress * 10);
|
||||
level->destroyTileProgress(player->entityId, x, y, z, state);
|
||||
lastSentState = state;
|
||||
}
|
||||
@@ -216,13 +216,13 @@ bool ServerPlayerGameMode::superDestroyBlock(int x, int y, int z)
|
||||
Tile *oldTile = Tile::tiles[level->getTile(x, y, z)];
|
||||
int data = level->getData(x, y, z);
|
||||
|
||||
if (oldTile != nullptr)
|
||||
if (oldTile != NULL)
|
||||
{
|
||||
oldTile->playerWillDestroy(level, x, y, z, data, player);
|
||||
}
|
||||
|
||||
bool changed = level->removeTile(x, y, z);
|
||||
if (oldTile != nullptr && changed)
|
||||
if (oldTile != NULL && changed)
|
||||
{
|
||||
oldTile->destroy(level, x, y, z, data);
|
||||
}
|
||||
@@ -241,7 +241,7 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z)
|
||||
|
||||
if (gameModeForPlayer->isCreative())
|
||||
{
|
||||
if (player->getCarriedItem() != nullptr && dynamic_cast<WeaponItem *>(player->getCarriedItem()->getItem()) != nullptr)
|
||||
if (player->getCarriedItem() != NULL && dynamic_cast<WeaponItem *>(player->getCarriedItem()->getItem()) != NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z)
|
||||
|
||||
if (isCreative())
|
||||
{
|
||||
shared_ptr<TileUpdatePacket> tup = std::make_shared<TileUpdatePacket>(x, y, z, level);
|
||||
shared_ptr<TileUpdatePacket> tup = shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) );
|
||||
// 4J - a bit of a hack here, but if we want to tell the client that it needs to inform the renderer of a block being destroyed, then send a block 255 instead of a 0. This is handled in ClientConnection::handleTileUpdate
|
||||
if( tup->block == 0 )
|
||||
{
|
||||
@@ -298,7 +298,7 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z)
|
||||
{
|
||||
shared_ptr<ItemInstance> item = player->getSelectedItem();
|
||||
bool canDestroy = player->canDestroy(Tile::tiles[t]);
|
||||
if (item != nullptr)
|
||||
if (item != NULL)
|
||||
{
|
||||
item->mineBlock(level, t, x, y, z, player);
|
||||
if (item->count == 0)
|
||||
@@ -322,7 +322,7 @@ bool ServerPlayerGameMode::useItem(shared_ptr<Player> player, Level *level, shar
|
||||
int oldCount = item->count;
|
||||
int oldAux = item->getAuxValue();
|
||||
shared_ptr<ItemInstance> itemInstance = item->use(level, player);
|
||||
if (itemInstance != item || (itemInstance != nullptr && (itemInstance->count != oldCount || itemInstance->getUseDuration() > 0 || itemInstance->getAuxValue() != oldAux)))
|
||||
if (itemInstance != item || (itemInstance != NULL && (itemInstance->count != oldCount || itemInstance->getUseDuration() > 0 || itemInstance->getAuxValue() != oldAux)))
|
||||
{
|
||||
player->inventory->items[player->inventory->selected] = itemInstance;
|
||||
if (isCreative())
|
||||
@@ -348,7 +348,7 @@ bool ServerPlayerGameMode::useItemOn(shared_ptr<Player> player, Level *level, sh
|
||||
{
|
||||
// 4J-PB - Adding a test only version to allow tooltips to be displayed
|
||||
int t = level->getTile(x, y, z);
|
||||
if (!player->isSneaking() || player->getCarriedItem() == nullptr)
|
||||
if (!player->isSneaking() || player->getCarriedItem() == NULL)
|
||||
{
|
||||
if (t > 0 && player->isAllowedToUse(Tile::tiles[t]))
|
||||
{
|
||||
@@ -360,14 +360,14 @@ bool ServerPlayerGameMode::useItemOn(shared_ptr<Player> player, Level *level, sh
|
||||
{
|
||||
if (Tile::tiles[t]->use(level, x, y, z, player, face, clickX, clickY, clickZ))
|
||||
{
|
||||
if(m_gameRules != nullptr) m_gameRules->onUseTile(t,x,y,z);
|
||||
if(m_gameRules != NULL) m_gameRules->onUseTile(t,x,y,z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item == nullptr || !player->isAllowedToUse(item)) return false;
|
||||
if (item == NULL || !player->isAllowedToUse(item)) return false;
|
||||
if (isCreative())
|
||||
{
|
||||
int aux = item->getAuxValue();
|
||||
@@ -391,6 +391,6 @@ void ServerPlayerGameMode::setLevel(ServerLevel *newLevel)
|
||||
// 4J Added
|
||||
void ServerPlayerGameMode::setGameRules(GameRulesInstance *rules)
|
||||
{
|
||||
if(m_gameRules != nullptr) delete m_gameRules;
|
||||
if(m_gameRules != NULL) delete m_gameRules;
|
||||
m_gameRules = rules;
|
||||
}
|
||||
Reference in New Issue
Block a user