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:
Loki Rautio
2026-03-07 21:12:22 -06:00
parent a9be52c41a
commit 087b7e7abf
1373 changed files with 19449 additions and 19903 deletions

View File

@@ -65,8 +65,8 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
{
sendPosTick = 4;
unsigned int playerDecorationsSize = static_cast<int>(parent->decorations.size());
unsigned int nonPlayerDecorationsSize = static_cast<int>(parent->nonPlayerDecorations.size());
unsigned int playerDecorationsSize = (int)parent->decorations.size();
unsigned int nonPlayerDecorationsSize = (int)parent->nonPlayerDecorations.size();
charArray data = charArray( (playerDecorationsSize + nonPlayerDecorationsSize ) * DEC_PACKET_BYTES + 1);
data[0] = 1;
for (unsigned int i = 0; i < parent->decorations.size(); i++)
@@ -74,7 +74,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
MapDecoration *md = parent->decorations.at(i);
#ifdef _LARGE_WORLDS
data[i * DEC_PACKET_BYTES + 1] = (char) (md->img);
data[i * DEC_PACKET_BYTES + 8] = static_cast<char>(md->rot & 0xF);
data[i * DEC_PACKET_BYTES + 8] = (char) (md->rot & 0xF);
#else
data[i * DEC_PACKET_BYTES + 1] = (char) ((md->img << 4) | (md->rot & 0xF));
#endif
@@ -92,7 +92,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
MapDecoration *md = it.second;
#ifdef _LARGE_WORLDS
data[dataIndex * DEC_PACKET_BYTES + 1] = (char) (md->img);
data[dataIndex * DEC_PACKET_BYTES + 8] = static_cast<char>(md->rot & 0xF);
data[dataIndex * DEC_PACKET_BYTES + 8] = (char) (md->rot & 0xF);
#else
data[dataIndex * DEC_PACKET_BYTES + 1] = (char) ((md->img << 4) | (md->rot & 0xF));
#endif
@@ -107,7 +107,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
++dataIndex;
}
bool thesame = !itemInstance->isFramed();
if (lastSentDecorations.data == nullptr || lastSentDecorations.length != data.length)
if (lastSentDecorations.data == NULL || lastSentDecorations.length != data.length)
{
thesame = false;
}
@@ -125,7 +125,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
if (!thesame)
{
if( lastSentDecorations.data != nullptr )
if( lastSentDecorations.data != NULL )
{
delete[] lastSentDecorations.data;
}
@@ -148,8 +148,8 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
charArray data = charArray(len + 3);
data[0] = HEADER_COLOURS;
data[1] = static_cast<char>(column);
data[2] = static_cast<char>(min);
data[1] = (char) column;
data[2] = (char) min;
for (unsigned int y = 0; y < data.length - 3; y++)
{
data[y + 3] = parent->colors[(y + min) * MapItem::IMAGE_WIDTH + column];
@@ -199,7 +199,7 @@ void MapItemSavedData::load(CompoundTag *tag)
{
byteArray newColors = tag->getByteArray(L"colors");
//4J
if(colors.data != nullptr)
if(colors.data != NULL)
{
delete[] colors.data;
}
@@ -236,7 +236,7 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
{
if (carriedByPlayers.find(player) == carriedByPlayers.end())
{
shared_ptr<HoldingPlayer> hp = std::make_shared<HoldingPlayer>(player, this);
shared_ptr<HoldingPlayer> hp = shared_ptr<HoldingPlayer>( new HoldingPlayer(player, this ) );
carriedByPlayers.insert( playerHoldingPlayerMapType::value_type(player, hp) );
carriedBy.push_back(hp);
}
@@ -303,17 +303,17 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
float xd = (float) ( origX - x ) / (1 << scale);
float yd = (float) ( origZ - z ) / (1 << scale);
char x = static_cast<char>(xd * 2 + 0.5);
char y = static_cast<char>(yd * 2 + 0.5);
char x = (char) (xd * 2 + 0.5);
char y = (char) (yd * 2 + 0.5);
int size = MAP_SIZE - 1;
#ifdef _LARGE_WORLDS
if (xd < -size || yd < -size || xd > size || yd > size)
{
if (xd <= -size) x = static_cast<byte>(size * 2 + 2.5);
if (yd <= -size) y = static_cast<byte>(size * 2 + 2.5);
if (xd >= size) x = static_cast<byte>(size * 2 + 1);
if (yd >= size) y = static_cast<byte>(size * 2 + 1);
if (xd <= -size) x = (byte) (size * 2 + 2.5);
if (yd <= -size) y = (byte) (size * 2 + 2.5);
if (xd >= size) x = (byte) (size * 2 + 1);
if (yd >= size) y = (byte) (size * 2 + 1);
}
#endif
//decorations.push_back(new MapDecoration(4, x, y, 0));
@@ -332,25 +332,25 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
if( nonPlayerDecorations.find( item->getFrame()->entityId ) == nonPlayerDecorations.end() )
{
float xd = static_cast<float>(item->getFrame()->xTile - x) / (1 << scale);
float yd = static_cast<float>(item->getFrame()->zTile - z) / (1 << scale);
char x = static_cast<char>(xd * 2 + 0.5);
char y = static_cast<char>(yd * 2 + 0.5);
float xd = (float) ( item->getFrame()->xTile - x ) / (1 << scale);
float yd = (float) ( item->getFrame()->zTile - z ) / (1 << scale);
char x = (char) (xd * 2 + 0.5);
char y = (char) (yd * 2 + 0.5);
int size = MAP_SIZE - 1;
char rot = static_cast<char>((item->getFrame()->dir * 90) * 16 / 360);
char rot = (char) ( (item->getFrame()->dir * 90) * 16 / 360);
if (dimension < 0)
{
int s = static_cast<int>(playerLevel->getLevelData()->getDayTime() / 10);
rot = static_cast<char>((s * s * 34187121 + s * 121) >> 15 & 15);
int s = (int) (playerLevel->getLevelData()->getDayTime() / 10);
rot = (char) ((s * s * 34187121 + s * 121) >> 15 & 15);
}
#ifdef _LARGE_WORLDS
if (xd < -size || yd < -size || xd > size || yd > size)
{
if (xd <= -size) x = static_cast<byte>(size * 2 + 2.5);
if (yd <= -size) y = static_cast<byte>(size * 2 + 2.5);
if (xd >= size) x = static_cast<byte>(size * 2 + 1);
if (yd >= size) y = static_cast<byte>(size * 2 + 1);
if (xd <= -size) x = (byte) (size * 2 + 2.5);
if (yd <= -size) y = (byte) (size * 2 + 2.5);
if (xd >= size) x = (byte) (size * 2 + 1);
if (yd >= size) y = (byte) (size * 2 + 1);
}
#endif
//decorations.push_back(new MapDecoration(7, x, y, 0));
@@ -399,12 +399,12 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
PlayerList *players = MinecraftServer::getInstance()->getPlayerList();
for(auto& decorationPlayer : players->players)
{
if(decorationPlayer!=nullptr && decorationPlayer->dimension == this->dimension)
if(decorationPlayer!=NULL && decorationPlayer->dimension == this->dimension)
{
float xd = static_cast<float>(decorationPlayer->x - x) / (1 << scale);
float yd = static_cast<float>(decorationPlayer->z - z) / (1 << scale);
char x = static_cast<char>(xd * 2);
char y = static_cast<char>(yd * 2);
float xd = (float) (decorationPlayer->x - x) / (1 << scale);
float yd = (float) (decorationPlayer->z - z) / (1 << scale);
char x = (char) (xd * 2);
char y = (char) (yd * 2);
int size = MAP_SIZE; // - 1;
char rot;
char imgIndex;
@@ -414,16 +414,16 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
#endif
{
rot = static_cast<char>(decorationPlayer->yRot * 16 / 360 + 0.5);
rot = (char) (decorationPlayer->yRot * 16 / 360 + 0.5);
if (dimension < 0)
{
int s = static_cast<int>(playerLevel->getLevelData()->getDayTime() / 10);
rot = static_cast<char>((s * s * 34187121 + s * 121) >> 15 & 15);
int s = (int) (playerLevel->getLevelData()->getDayTime() / 10);
rot = (char) ((s * s * 34187121 + s * 121) >> 15 & 15);
}
// 4J Stu - As we have added new icons for players on a new row below
// other icons used in Java we need to move our index to the next row
imgIndex = static_cast<int>(decorationPlayer->getPlayerIndex());
imgIndex = (int)decorationPlayer->getPlayerIndex();
if(imgIndex>3) imgIndex += 4;
}
#ifdef _LARGE_WORLDS
@@ -431,16 +431,16 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
{
// 4J Stu - As we have added new icons for players on a new row below
// other icons used in Java we need to move our index to the next row
imgIndex = static_cast<int>(decorationPlayer->getPlayerIndex());
imgIndex = (int)decorationPlayer->getPlayerIndex();
if(imgIndex>3) imgIndex += 4;
imgIndex += 16; // Add 16 to indicate that it's on the next texture
rot = 0;
size--; // Added to match the old adjusted size
if (xd <= -size) x = static_cast<byte>(size * 2 + 2.5);
if (yd <= -size) y = static_cast<byte>(size * 2 + 2.5);
if (xd >= size) x = static_cast<byte>(size * 2 + 1);
if (yd >= size) y = static_cast<byte>(size * 2 + 1);
if (xd <= -size) x = (byte) (size * 2 + 2.5);
if (yd <= -size) y = (byte) (size * 2 + 2.5);
if (xd >= size) x = (byte) (size * 2 + 1);
if (yd >= size) y = (byte) (size * 2 + 1);
}
#endif
@@ -527,7 +527,7 @@ void MapItemSavedData::handleComplexItemData(charArray &data)
#endif
char x = data[i * DEC_PACKET_BYTES + 2];
char y = data[i * DEC_PACKET_BYTES + 3];
int entityId = (static_cast<int>(data[i * DEC_PACKET_BYTES + 4])&0xFF) | ( (static_cast<int>(data[i * DEC_PACKET_BYTES + 5])&0xFF)<<8) | ((static_cast<int>(data[i * DEC_PACKET_BYTES + 6])&0xFF)<<16) | ((static_cast<int>(data[i * DEC_PACKET_BYTES + 7])&0x7F)<<24);
int entityId = (((int)data[i * DEC_PACKET_BYTES + 4])&0xFF) | ( (((int)data[i * DEC_PACKET_BYTES + 5])&0xFF)<<8) | ((((int)data[i * DEC_PACKET_BYTES + 6])&0xFF)<<16) | ((((int)data[i * DEC_PACKET_BYTES + 7])&0x7F)<<24);
bool visible = (data[i * DEC_PACKET_BYTES + 7] & 0x80) != 0;
decorations.push_back(new MapDecoration(img, x, y, rot, entityId, visible));
}
@@ -545,7 +545,7 @@ shared_ptr<MapItemSavedData::HoldingPlayer> MapItemSavedData::getHoldingPlayer(s
if (it == carriedByPlayers.end())
{
hp = std::make_shared<HoldingPlayer>(player, this);
hp = shared_ptr<HoldingPlayer>( new HoldingPlayer(player, this) );
carriedByPlayers[player] = hp;
carriedBy.push_back(hp);
}