diff options
| author | Loki Rautio <lokirautio@gmail.com> | 2026-03-07 21:12:22 -0600 |
|---|---|---|
| committer | Loki Rautio <lokirautio@gmail.com> | 2026-03-07 21:12:22 -0600 |
| commit | 087b7e7abfe81dd7f0fdcdea36ac9f245950df1a (patch) | |
| tree | 69454763e73ca764af4e682d3573080b13138a0e /Minecraft.Client/ClientConnection.cpp | |
| parent | a9be52c41a02d207233199e98898fe7483d7e817 (diff) | |
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 a9be52c41a02d207233199e98898fe7483d7e817.
Diffstat (limited to 'Minecraft.Client/ClientConnection.cpp')
| -rw-r--r-- | Minecraft.Client/ClientConnection.cpp | 367 |
1 files changed, 177 insertions, 190 deletions
diff --git a/Minecraft.Client/ClientConnection.cpp b/Minecraft.Client/ClientConnection.cpp index 63ee763a..9b955cae 100644 --- a/Minecraft.Client/ClientConnection.cpp +++ b/Minecraft.Client/ClientConnection.cpp @@ -95,7 +95,7 @@ ClientConnection::ClientConnection(Minecraft *minecraft, const wstring& ip, int } else { - connection = nullptr; + connection = NULL; delete socket; } #endif @@ -106,9 +106,9 @@ ClientConnection::ClientConnection(Minecraft *minecraft, Socket *socket, int iUs // 4J - added initiliasers random = new Random(); done = false; - level = nullptr; + level = NULL; started = false; - savedDataStorage = new SavedDataStorage(nullptr); + savedDataStorage = new SavedDataStorage(NULL); maxPlayers = 20; this->minecraft = minecraft; @@ -122,7 +122,7 @@ ClientConnection::ClientConnection(Minecraft *minecraft, Socket *socket, int iUs m_userIndex = iUserIndex; } - if( socket == nullptr ) + if( socket == NULL ) { socket = new Socket(); // 4J - Local connection } @@ -134,7 +134,7 @@ ClientConnection::ClientConnection(Minecraft *minecraft, Socket *socket, int iUs } else { - connection = nullptr; + connection = NULL; // TODO 4J Stu - This will cause issues since the session player owns the socket //delete socket; } @@ -157,8 +157,8 @@ void ClientConnection::tick() INetworkPlayer *ClientConnection::getNetworkPlayer() { - if( connection != nullptr && connection->getSocket() != nullptr) return connection->getSocket()->getPlayer(); - else return nullptr; + if( connection != NULL && connection->getSocket() != NULL) return connection->getSocket()->getPlayer(); + else return NULL; } void ClientConnection::handleLogin(shared_ptr<LoginPacket> packet) @@ -167,7 +167,7 @@ void ClientConnection::handleLogin(shared_ptr<LoginPacket> packet) PlayerUID OnlineXuid; ProfileManager.GetXUID(m_userIndex,&OnlineXuid,true); // online xuid - MOJANG_DATA *pMojangData = nullptr; + MOJANG_DATA *pMojangData = NULL; if(!g_NetworkManager.IsLocalGame()) { @@ -208,7 +208,7 @@ void ClientConnection::handleLogin(shared_ptr<LoginPacket> packet) if(iUserID!=-1) { - BYTE *pBuffer=nullptr; + BYTE *pBuffer=NULL; DWORD dwSize=0; bool bRes; @@ -285,17 +285,17 @@ void ClientConnection::handleLogin(shared_ptr<LoginPacket> packet) Level *dimensionLevel = minecraft->getLevel( packet->dimension ); - if( dimensionLevel == nullptr ) + if( dimensionLevel == NULL ) { level = new MultiPlayerLevel(this, new LevelSettings(packet->seed, GameType::byId(packet->gameType), false, false, packet->m_newSeaLevel, packet->m_pLevelType, packet->m_xzSize, packet->m_hellScale), packet->dimension, packet->difficulty); // 4J Stu - We want to share the SavedDataStorage between levels int otherDimensionId = packet->dimension == 0 ? -1 : 0; Level *activeLevel = minecraft->getLevel(otherDimensionId); - if( activeLevel != nullptr ) + if( activeLevel != NULL ) { // Don't need to delete it here as it belongs to a client connection while will delete it when it's done - //if( level->savedDataStorage != nullptr ) delete level->savedDataStorage; + //if( level->savedDataStorage != NULL ) delete level->savedDataStorage; level->savedDataStorage = activeLevel->savedDataStorage; } @@ -341,12 +341,12 @@ void ClientConnection::handleLogin(shared_ptr<LoginPacket> packet) level = (MultiPlayerLevel *)minecraft->getLevel( packet->dimension ); shared_ptr<Player> player; - if(level==nullptr) + if(level==NULL) { int otherDimensionId = packet->dimension == 0 ? -1 : 0; MultiPlayerLevel *activeLevel = minecraft->getLevel(otherDimensionId); - if(activeLevel == nullptr) + if(activeLevel == NULL) { otherDimensionId = packet->dimension == 0 ? 1 : (packet->dimension == -1 ? 1 : -1); activeLevel = minecraft->getLevel(otherDimensionId); @@ -433,7 +433,7 @@ void ClientConnection::handleAddEntity(shared_ptr<AddEntityPacket> packet) shared_ptr<Entity> owner = getEntity(packet->data); // 4J - check all local players to find match - if( owner == nullptr ) + if( owner == NULL ) { for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { @@ -449,10 +449,10 @@ void ClientConnection::handleAddEntity(shared_ptr<AddEntityPacket> packet) } } - if (owner != nullptr && owner->instanceof(eTYPE_PLAYER)) + if (owner != NULL && owner->instanceof(eTYPE_PLAYER)) { shared_ptr<Player> player = dynamic_pointer_cast<Player>(owner); - shared_ptr<FishingHook> hook = std::make_shared<FishingHook>(level, x, y, z, player); + shared_ptr<FishingHook> hook = shared_ptr<FishingHook>( new FishingHook(level, x, y, z, player) ); e = hook; // 4J Stu - Move the player->fishing out of the ctor as we cannot reference 'this' player->fishing = hook; @@ -461,10 +461,10 @@ void ClientConnection::handleAddEntity(shared_ptr<AddEntityPacket> packet) } break; case AddEntityPacket::ARROW: - e = std::make_shared<Arrow>(level, x, y, z); + e = shared_ptr<Entity>( new Arrow(level, x, y, z) ); break; case AddEntityPacket::SNOWBALL: - e = std::make_shared<Snowball>(level, x, y, z); + e = shared_ptr<Entity>( new Snowball(level, x, y, z) ); break; case AddEntityPacket::ITEM_FRAME: { @@ -473,64 +473,64 @@ void ClientConnection::handleAddEntity(shared_ptr<AddEntityPacket> packet) int iz = (int) z; app.DebugPrintf("ClientConnection ITEM_FRAME xyz %d,%d,%d\n",ix,iy,iz); } - e = std::make_shared<ItemFrame>(level, (int)x, (int)y, (int)z, packet->data); + e = shared_ptr<Entity>(new ItemFrame(level, (int) x, (int) y, (int) z, packet->data)); packet->data = 0; setRot = false; break; case AddEntityPacket::THROWN_ENDERPEARL: - e = std::make_shared<ThrownEnderpearl>(level, x, y, z); + e = shared_ptr<Entity>( new ThrownEnderpearl(level, x, y, z) ); break; case AddEntityPacket::EYEOFENDERSIGNAL: - e = std::make_shared<EyeOfEnderSignal>(level, x, y, z); + e = shared_ptr<Entity>( new EyeOfEnderSignal(level, x, y, z) ); break; case AddEntityPacket::FIREBALL: - e = std::make_shared<LargeFireball>(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); + e = shared_ptr<Entity>( new LargeFireball(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0) ); packet->data = 0; break; case AddEntityPacket::SMALL_FIREBALL: - e = std::make_shared<SmallFireball>(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); + e = shared_ptr<Entity>( new SmallFireball(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0) ); packet->data = 0; break; case AddEntityPacket::DRAGON_FIRE_BALL: - e = std::make_shared<DragonFireball>(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); + e = shared_ptr<Entity>( new DragonFireball(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0) ); packet->data = 0; break; case AddEntityPacket::EGG: - e = std::make_shared<ThrownEgg>(level, x, y, z); + e = shared_ptr<Entity>( new ThrownEgg(level, x, y, z) ); break; case AddEntityPacket::THROWN_POTION: - e = std::make_shared<ThrownPotion>(level, x, y, z, packet->data); + e = shared_ptr<Entity>( new ThrownPotion(level, x, y, z, packet->data) ); packet->data = 0; break; case AddEntityPacket::THROWN_EXPBOTTLE: - e = std::make_shared<ThrownExpBottle>(level, x, y, z); + e = shared_ptr<Entity>( new ThrownExpBottle(level, x, y, z) ); packet->data = 0; break; case AddEntityPacket::BOAT: - e = std::make_shared<Boat>(level, x, y, z); + e = shared_ptr<Entity>( new Boat(level, x, y, z) ); break; case AddEntityPacket::PRIMED_TNT: - e = std::make_shared<PrimedTnt>(level, x, y, z, std::shared_ptr<LivingEntity>()); + e = shared_ptr<Entity>( new PrimedTnt(level, x, y, z, nullptr) ); break; case AddEntityPacket::ENDER_CRYSTAL: - e = std::make_shared<EnderCrystal>(level, x, y, z); + e = shared_ptr<Entity>( new EnderCrystal(level, x, y, z) ); break; case AddEntityPacket::ITEM: - e = std::make_shared<ItemEntity>(level, x, y, z); + e = shared_ptr<Entity>( new ItemEntity(level, x, y, z) ); break; case AddEntityPacket::FALLING: - e = std::make_shared<FallingTile>(level, x, y, z, packet->data & 0xFFFF, packet->data >> 16); + e = shared_ptr<Entity>( new FallingTile(level, x, y, z, packet->data & 0xFFFF, packet->data >> 16) ); packet->data = 0; break; case AddEntityPacket::WITHER_SKULL: - e = std::make_shared<WitherSkull>(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); + e = shared_ptr<Entity>(new WitherSkull(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0)); packet->data = 0; break; case AddEntityPacket::FIREWORKS: - e = std::make_shared<FireworksRocketEntity>(level, x, y, z, std::shared_ptr<ItemInstance>()); + e = shared_ptr<Entity>(new FireworksRocketEntity(level, x, y, z, nullptr)); break; case AddEntityPacket::LEASH_KNOT: - e = std::make_shared<LeashFenceKnotEntity>(level, (int)x, (int)y, (int)z); + e = shared_ptr<Entity>(new LeashFenceKnotEntity(level, (int) x, (int) y, (int) z)); packet->data = 0; break; #ifndef _FINAL_BUILD @@ -549,7 +549,7 @@ void ClientConnection::handleAddEntity(shared_ptr<AddEntityPacket> packet) shared_ptr<Entity> owner = getEntity(packet->data); // 4J - check all local players to find match - if( owner == nullptr ) + if( owner == NULL ) { for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { @@ -565,7 +565,7 @@ void ClientConnection::handleAddEntity(shared_ptr<AddEntityPacket> packet) } } shared_ptr<Player> player = dynamic_pointer_cast<Player>(owner); - if (player != nullptr) + if (player != NULL) { shared_ptr<FishingHook> hook = shared_ptr<FishingHook>( new FishingHook(level, x, y, z, player) ); e = hook; @@ -609,7 +609,7 @@ void ClientConnection::handleAddEntity(shared_ptr<AddEntityPacket> packet) */ - if (e != nullptr) + if (e != NULL) { e->xp = packet->x; e->yp = packet->y; @@ -661,7 +661,7 @@ void ClientConnection::handleAddEntity(shared_ptr<AddEntityPacket> packet) shared_ptr<Entity> owner = getEntity(packet->data); // 4J - check all local players to find match - if( owner == nullptr ) + if( owner == NULL ) { for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { @@ -676,7 +676,7 @@ void ClientConnection::handleAddEntity(shared_ptr<AddEntityPacket> packet) } } - if ( owner != nullptr && owner->instanceof(eTYPE_LIVINGENTITY) ) + if ( owner != NULL && owner->instanceof(eTYPE_LIVINGENTITY) ) { dynamic_pointer_cast<Arrow>(e)->owner = dynamic_pointer_cast<LivingEntity>(owner); } @@ -692,7 +692,7 @@ void ClientConnection::handleAddEntity(shared_ptr<AddEntityPacket> packet) void ClientConnection::handleAddExperienceOrb(shared_ptr<AddExperienceOrbPacket> packet) { - shared_ptr<Entity> e = std::make_shared<ExperienceOrb>(level, packet->x / 32.0, packet->y / 32.0, packet->z / 32.0, packet->value); + shared_ptr<Entity> e = shared_ptr<ExperienceOrb>( new ExperienceOrb(level, packet->x / 32.0, packet->y / 32.0, packet->z / 32.0, packet->value) ); e->xp = packet->x; e->yp = packet->y; e->zp = packet->z; @@ -708,8 +708,8 @@ void ClientConnection::handleAddGlobalEntity(shared_ptr<AddGlobalEntityPacket> p double y = packet->y / 32.0; double z = packet->z / 32.0; shared_ptr<Entity> e;// = nullptr; - if (packet->type == AddGlobalEntityPacket::LIGHTNING) e = std::make_shared<LightningBolt>(level, x, y, z); - if (e != nullptr) + if (packet->type == AddGlobalEntityPacket::LIGHTNING) e = shared_ptr<LightningBolt>( new LightningBolt(level, x, y, z) ); + if (e != NULL) { e->xp = packet->x; e->yp = packet->y; @@ -723,21 +723,21 @@ void ClientConnection::handleAddGlobalEntity(shared_ptr<AddGlobalEntityPacket> p void ClientConnection::handleAddPainting(shared_ptr<AddPaintingPacket> packet) { - shared_ptr<Painting> painting = std::make_shared<Painting>(level, packet->x, packet->y, packet->z, packet->dir, packet->motive); + shared_ptr<Painting> painting = shared_ptr<Painting>( new Painting(level, packet->x, packet->y, packet->z, packet->dir, packet->motive) ); level->putEntity(packet->id, painting); } void ClientConnection::handleSetEntityMotion(shared_ptr<SetEntityMotionPacket> packet) { shared_ptr<Entity> e = getEntity(packet->id); - if (e == nullptr) return; + if (e == NULL) return; e->lerpMotion(packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); } void ClientConnection::handleSetEntityData(shared_ptr<SetEntityDataPacket> packet) { shared_ptr<Entity> e = getEntity(packet->id); - if (e != nullptr && packet->getUnpackedData() != nullptr) + if (e != NULL && packet->getUnpackedData() != NULL) { e->getEntityData()->assignValues(packet->getUnpackedData()); } @@ -764,7 +764,7 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet) // a duplicate remote player for a local slot by checking the username directly. for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if (minecraft->localplayers[idx] != nullptr && minecraft->localplayers[idx]->name == packet->name) + if (minecraft->localplayers[idx] != NULL && minecraft->localplayers[idx]->name == packet->name) { app.DebugPrintf("AddPlayerPacket received for local player name %ls\n", packet->name.c_str()); return; @@ -778,7 +778,7 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet) // their stored server index rather than using it directly as an array subscript. for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(minecraft->localplayers[idx] != nullptr && + if(minecraft->localplayers[idx] != NULL && minecraft->localplayers[idx]->getPlayerIndex() == packet->m_playerIndex) { app.DebugPrintf("AddPlayerPacket received for local player (controller %d, server index %d), skipping RemotePlayer creation\n", idx, packet->m_playerIndex); @@ -792,7 +792,7 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet) double z = packet->z / 32.0; float yRot = packet->yRot * 360 / 256.0f; float xRot = packet->xRot * 360 / 256.0f; - shared_ptr<RemotePlayer> player = std::make_shared<RemotePlayer>(minecraft->level, packet->name); + shared_ptr<RemotePlayer> player = shared_ptr<RemotePlayer>( new RemotePlayer(minecraft->level, packet->name) ); player->xo = player->xOld = player->xp = packet->x; player->yo = player->yOld = player->yp = packet->y; player->zo = player->zOld = player->zp = packet->z; @@ -804,7 +804,7 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet) #ifdef _DURANGO // On Durango request player display name from network manager INetworkPlayer *networkPlayer = g_NetworkManager.GetPlayerByXuid(player->getXuid()); - if (networkPlayer != nullptr) player->m_displayName = networkPlayer->GetDisplayName(); + if (networkPlayer != NULL) player->m_displayName = networkPlayer->GetDisplayName(); #else // On all other platforms display name is just gamertag so don't check with the network manager player->m_displayName = player->getName(); @@ -812,7 +812,7 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet) #ifdef _WINDOWS64 { - IQNetPlayer* matchedQNetPlayer = nullptr; + IQNetPlayer* matchedQNetPlayer = NULL; PlayerUID pktXuid = player->getXuid(); const PlayerUID WIN64_XUID_BASE = (PlayerUID)0xe000d45248242f2e; // Legacy compatibility path for peers still using embedded smallId XUIDs. @@ -820,7 +820,7 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet) { BYTE smallId = (BYTE)(pktXuid - WIN64_XUID_BASE); INetworkPlayer* np = g_NetworkManager.GetPlayerBySmallId(smallId); - if (np != nullptr) + if (np != NULL) { NetworkPlayerXbox* npx = (NetworkPlayerXbox*)np; matchedQNetPlayer = npx->GetQNetPlayer(); @@ -828,18 +828,18 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet) } // Current Win64 path: identify QNet player by name and attach packet XUID. - if (matchedQNetPlayer == nullptr) + if (matchedQNetPlayer == NULL) { for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) { BYTE smallId = static_cast<BYTE>(i); INetworkPlayer* np = g_NetworkManager.GetPlayerBySmallId(smallId); - if (np == nullptr) + if (np == NULL) continue; NetworkPlayerXbox* npx = (NetworkPlayerXbox*)np; IQNetPlayer* qp = npx->GetQNetPlayer(); - if (qp != nullptr && _wcsicmp(qp->m_gamertag, packet->name.c_str()) == 0) + if (qp != NULL && _wcsicmp(qp->m_gamertag, packet->name.c_str()) == 0) { matchedQNetPlayer = qp; break; @@ -847,7 +847,7 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet) } } - if (matchedQNetPlayer != nullptr) + if (matchedQNetPlayer != NULL) { // Store packet-authoritative XUID on this network slot so later lookups by XUID // (e.g. remove player, display mapping) work for both legacy and uid.dat clients. @@ -865,11 +865,11 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet) int item = packet->carriedItem; if (item == 0) { - player->inventory->items[player->inventory->selected] = shared_ptr<ItemInstance>(); // nullptr; + player->inventory->items[player->inventory->selected] = shared_ptr<ItemInstance>(); // NULL; } else { - player->inventory->items[player->inventory->selected] = std::make_shared<ItemInstance>(item, 1, 0); + player->inventory->items[player->inventory->selected] = shared_ptr<ItemInstance>( new ItemInstance(item, 1, 0) ); } player->absMoveTo(x, y, z, yRot, xRot); @@ -878,22 +878,19 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet) player->setCustomCape( packet->m_capeId ); player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_All, packet->m_uiGamePrivileges); - if (!player->customTextureUrl.empty() && player->customTextureUrl.substr(0, 3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(player->customTextureUrl)) - { - if (minecraft->addPendingClientTextureRequest(player->customTextureUrl)) - { - app.DebugPrintf("Client sending TextureAndGeometryPacket to get custom skin %ls for player %ls\n", player->customTextureUrl.c_str(), player->name.c_str()); - - send(std::make_shared<TextureAndGeometryPacket>( - player->customTextureUrl, - nullptr, - static_cast<DWORD>(0))); - } - } + if(!player->customTextureUrl.empty() && player->customTextureUrl.substr(0,3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(player->customTextureUrl)) + { + if( minecraft->addPendingClientTextureRequest(player->customTextureUrl) ) + { + app.DebugPrintf("Client sending TextureAndGeometryPacket to get custom skin %ls for player %ls\n",player->customTextureUrl.c_str(), player->name.c_str()); + + send(shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(player->customTextureUrl,NULL,0) ) ); + } + } else if(!player->customTextureUrl.empty() && app.IsFileInMemoryTextures(player->customTextureUrl)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(player->customTextureUrl,nullptr,0); + app.AddMemoryTextureFile(player->customTextureUrl,NULL,0); } app.DebugPrintf("Custom skin for player %ls is %ls\n",player->name.c_str(),player->customTextureUrl.c_str()); @@ -903,17 +900,13 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet) if( minecraft->addPendingClientTextureRequest(player->customTextureUrl2) ) { app.DebugPrintf("Client sending texture packet to get custom cape %ls for player %ls\n",player->customTextureUrl2.c_str(), player->name.c_str()); - send(std::make_shared<TexturePacket>( - player->customTextureUrl2, - nullptr, - static_cast<DWORD>(0) - )); + send(shared_ptr<TexturePacket>( new TexturePacket(player->customTextureUrl2,NULL,0) ) ); } } else if(!player->customTextureUrl2.empty() && app.IsFileInMemoryTextures(player->customTextureUrl2)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(player->customTextureUrl2,nullptr,0); + app.AddMemoryTextureFile(player->customTextureUrl2,NULL,0); } app.DebugPrintf("Custom cape for player %ls is %ls\n",player->name.c_str(),player->customTextureUrl2.c_str()); @@ -921,7 +914,7 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet) level->putEntity(packet->id, player); vector<shared_ptr<SynchedEntityData::DataItem> > *unpackedData = packet->getUnpackedData(); - if (unpackedData != nullptr) + if (unpackedData != NULL) { player->getEntityData()->assignValues(unpackedData); } @@ -931,7 +924,7 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet) void ClientConnection::handleTeleportEntity(shared_ptr<TeleportEntityPacket> packet) { shared_ptr<Entity> e = getEntity(packet->id); - if (e == nullptr) return; + if (e == NULL) return; e->xp = packet->x; e->yp = packet->y; e->zp = packet->z; @@ -960,7 +953,7 @@ void ClientConnection::handleSetCarriedItem(shared_ptr<SetCarriedItemPacket> pac void ClientConnection::handleMoveEntity(shared_ptr<MoveEntityPacket> packet) { shared_ptr<Entity> e = getEntity(packet->id); - if (e == nullptr) return; + if (e == NULL) return; e->xp += packet->xa; e->yp += packet->ya; e->zp += packet->za; @@ -981,7 +974,7 @@ void ClientConnection::handleMoveEntity(shared_ptr<MoveEntityPacket> packet) void ClientConnection::handleRotateMob(shared_ptr<RotateHeadPacket> packet) { shared_ptr<Entity> e = getEntity(packet->id); - if (e == nullptr) return; + if (e == NULL) return; float yHeadRot = packet->yHeadRot * 360 / 256.f; e->setYHeadRot(yHeadRot); } @@ -989,7 +982,7 @@ void ClientConnection::handleRotateMob(shared_ptr<RotateHeadPacket> packet) void ClientConnection::handleMoveEntitySmall(shared_ptr<MoveEntityPacketSmall> packet) { shared_ptr<Entity> e = getEntity(packet->id); - if (e == nullptr) return; + if (e == NULL) return; e->xp += packet->xa; e->yp += packet->ya; e->zp += packet->za; @@ -1015,18 +1008,18 @@ void ClientConnection::handleRemoveEntity(shared_ptr<RemoveEntitiesPacket> packe for (int i = 0; i < packet->ids.length; i++) { shared_ptr<Entity> entity = getEntity(packet->ids[i]); - if (entity != nullptr && entity->GetType() == eTYPE_PLAYER) + if (entity != NULL && entity->GetType() == eTYPE_PLAYER) { shared_ptr<Player> player = dynamic_pointer_cast<Player>(entity); - if (player != nullptr) + if (player != NULL) { PlayerUID xuid = player->getXuid(); INetworkPlayer* np = g_NetworkManager.GetPlayerByXuid(xuid); - if (np != nullptr) + if (np != NULL) { NetworkPlayerXbox* npx = (NetworkPlayerXbox*)np; IQNetPlayer* qp = npx->GetQNetPlayer(); - if (qp != nullptr) + if (qp != NULL) { extern CPlatformNetworkManagerStub* g_pPlatformNetworkManager; g_pPlatformNetworkManager->NotifyPlayerLeaving(qp); @@ -1096,7 +1089,7 @@ void ClientConnection::handleMovePlayer(shared_ptr<MovePlayerPacket> packet) player->zOld = player->z; started = true; - minecraft->setScreen(nullptr); + minecraft->setScreen(NULL); // Fix for #105852 - TU12: Content: Gameplay: Local splitscreen Players are spawned at incorrect places after re-joining previously saved and loaded "Mass Effect World". // Move this check from Minecraft::createExtraLocalPlayer @@ -1306,7 +1299,7 @@ void ClientConnection::handleDisconnect(shared_ptr<DisconnectPacket> packet) app.SetDisconnectReason( packet->reason ); app.SetAction(m_userIndex,eAppAction_ExitWorld,(void *)TRUE); - //minecraft->setLevel(nullptr); + //minecraft->setLevel(NULL); //minecraft->setScreen(new DisconnectedScreen(L"disconnect.disconnected", L"disconnect.genericReason", &packet->reason)); } @@ -1329,14 +1322,14 @@ void ClientConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, { UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestErrorMessage(IDS_EXITING_GAME, IDS_GENERIC_ERROR, uiIDA, 1, ProfileManager.GetPrimaryPad(),&ClientConnection::HostDisconnectReturned,nullptr); + ui.RequestErrorMessage(IDS_EXITING_GAME, IDS_GENERIC_ERROR, uiIDA, 1, ProfileManager.GetPrimaryPad(),&ClientConnection::HostDisconnectReturned,NULL); } else { app.SetAction(m_userIndex,eAppAction_ExitWorld,(void *)TRUE); } - //minecraft->setLevel(nullptr); + //minecraft->setLevel(NULL); //minecraft->setScreen(new DisconnectedScreen(L"disconnect.lost", reason, reasonObjects)); } @@ -1374,7 +1367,7 @@ void ClientConnection::handleTakeItemEntity(shared_ptr<TakeItemEntityPacket> pac } } - if (to == nullptr) + if (to == NULL) { // Don't know if this should ever really happen, but seems safest to try and remove the entity that has been collected even if we can't // create a particle as we don't know what really collected it @@ -1382,7 +1375,7 @@ void ClientConnection::handleTakeItemEntity(shared_ptr<TakeItemEntityPacket> pac return; } - if (from != nullptr) + if (from != NULL) { // If this is a local player, then we only want to do processing for it if this connection is associated with the player it is for. In // particular, we don't want to remove the item entity until we are processing it for the right connection, or else we won't have a valid @@ -1396,7 +1389,7 @@ void ClientConnection::handleTakeItemEntity(shared_ptr<TakeItemEntityPacket> pac // the tutorial for the player that actually picked up the item int playerPad = player->GetXboxPad(); - if( minecraft->localgameModes[playerPad] != nullptr ) + if( minecraft->localgameModes[playerPad] != NULL ) { // 4J-PB - add in the XP orb sound if(from->GetType() == eTYPE_EXPERIENCEORB) @@ -1410,7 +1403,7 @@ void ClientConnection::handleTakeItemEntity(shared_ptr<TakeItemEntityPacket> pac level->playSound(from, eSoundType_RANDOM_POP, 0.2f, ((random->nextFloat() - random->nextFloat()) * 0.7f + 1.0f) * 2.0f); } - minecraft->particleEngine->add(std::make_shared<TakeAnimationParticle>(minecraft->level, from, to, -0.5f)); + minecraft->particleEngine->add( shared_ptr<TakeAnimationParticle>( new TakeAnimationParticle(minecraft->level, from, to, -0.5f) ) ); level->removeEntity(packet->itemId); } else @@ -1423,7 +1416,7 @@ void ClientConnection::handleTakeItemEntity(shared_ptr<TakeItemEntityPacket> pac else { level->playSound(from, eSoundType_RANDOM_POP, 0.2f, ((random->nextFloat() - random->nextFloat()) * 0.7f + 1.0f) * 2.0f); - minecraft->particleEngine->add(std::make_shared<TakeAnimationParticle>(minecraft->level, from, to, -0.5f)); + minecraft->particleEngine->add( shared_ptr<TakeAnimationParticle>( new TakeAnimationParticle(minecraft->level, from, to, -0.5f) ) ); level->removeEntity(packet->itemId); } } @@ -1841,7 +1834,7 @@ void ClientConnection::handleChat(shared_ptr<ChatPacket> packet) void ClientConnection::handleAnimate(shared_ptr<AnimatePacket> packet) { shared_ptr<Entity> e = getEntity(packet->id); - if (e == nullptr) return; + if (e == NULL) return; if (packet->action == AnimatePacket::SWING) { if (e->instanceof(eTYPE_LIVINGENTITY)) dynamic_pointer_cast<LivingEntity>(e)->swing(); @@ -1859,13 +1852,13 @@ void ClientConnection::handleAnimate(shared_ptr<AnimatePacket> packet) } else if (packet->action == AnimatePacket::CRITICAL_HIT) { - shared_ptr<CritParticle> critParticle = std::make_shared<CritParticle>(minecraft->level, e); + shared_ptr<CritParticle> critParticle = shared_ptr<CritParticle>( new CritParticle(minecraft->level, e) ); critParticle->CritParticlePostConstructor(); minecraft->particleEngine->add( critParticle ); } else if (packet->action == AnimatePacket::MAGIC_CRITICAL_HIT) { - shared_ptr<CritParticle> critParticle = std::make_shared<CritParticle>(minecraft->level, e, eParticleType_magicCrit); + shared_ptr<CritParticle> critParticle = shared_ptr<CritParticle>( new CritParticle(minecraft->level, e, eParticleType_magicCrit) ); critParticle->CritParticlePostConstructor(); minecraft->particleEngine->add(critParticle); } @@ -1878,7 +1871,7 @@ void ClientConnection::handleAnimate(shared_ptr<AnimatePacket> packet) void ClientConnection::handleEntityActionAtPosition(shared_ptr<EntityActionAtPositionPacket> packet) { shared_ptr<Entity> e = getEntity(packet->id); - if (e == nullptr) return; + if (e == NULL) return; if (packet->action == EntityActionAtPositionPacket::START_SLEEP) { shared_ptr<Player> player = dynamic_pointer_cast<Player>(e); @@ -1938,7 +1931,7 @@ void ClientConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet) // Is this user friends with the host player? BOOL result; DWORD error; - error = XUserAreUsersFriends(idx,&packet->m_playerXuids[packet->m_hostIndex],1,&result,nullptr); + error = XUserAreUsersFriends(idx,&packet->m_playerXuids[packet->m_hostIndex],1,&result,NULL); if(error == ERROR_SUCCESS && result != TRUE) { canPlay = FALSE; @@ -1968,7 +1961,7 @@ void ClientConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet) // Is this user friends with the host player? BOOL result; DWORD error; - error = XUserAreUsersFriends(m_userIndex,&packet->m_playerXuids[packet->m_hostIndex],1,&result,nullptr); + error = XUserAreUsersFriends(m_userIndex,&packet->m_playerXuids[packet->m_hostIndex],1,&result,NULL); if(error == ERROR_SUCCESS && result != TRUE) { canPlay = FALSE; @@ -2020,7 +2013,7 @@ void ClientConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet) { if( ProfileManager.IsSignedIn(idx) && !ProfileManager.IsGuest(idx) ) { - error = XUserAreUsersFriends(idx,&packet->m_playerXuids[i],1,&result,nullptr); + error = XUserAreUsersFriends(idx,&packet->m_playerXuids[i],1,&result,NULL); if(error == ERROR_SUCCESS && result == TRUE) isAtLeastOneFriend = TRUE; } } @@ -2048,7 +2041,7 @@ void ClientConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet) { if( (!thisQuadrantOnly || m_userIndex == idx) && ProfileManager.IsSignedIn(idx) && !ProfileManager.IsGuest(idx) ) { - error = XUserAreUsersFriends(idx,&packet->m_playerXuids[i],1,&result,nullptr); + error = XUserAreUsersFriends(idx,&packet->m_playerXuids[i],1,&result,NULL); if(error == ERROR_SUCCESS) canPlay &= result; } if(!canPlay) break; @@ -2071,7 +2064,7 @@ void ClientConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet) { bool bChatRestricted=false; - ProfileManager.GetChatAndContentRestrictions(m_userIndex,true,&bChatRestricted,nullptr,nullptr); + ProfileManager.GetChatAndContentRestrictions(m_userIndex,true,&bChatRestricted,NULL,NULL); // Chat restricted orbis players can still play online #ifndef __ORBIS__ @@ -2160,11 +2153,11 @@ void ClientConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet) // which seems to be very unstable at the point of starting up the game if(m_userIndex == ProfileManager.GetPrimaryPad()) { - ProfileManager.GetChatAndContentRestrictions(m_userIndex,false,&bChatRestricted,&bContentRestricted,nullptr); + ProfileManager.GetChatAndContentRestrictions(m_userIndex,false,&bChatRestricted,&bContentRestricted,NULL); } else { - ProfileManager.GetChatAndContentRestrictions(m_userIndex,true,&bChatRestricted,&bContentRestricted,nullptr); + ProfileManager.GetChatAndContentRestrictions(m_userIndex,true,&bChatRestricted,&bContentRestricted,NULL); } // Chat restricted orbis players can still play online @@ -2337,8 +2330,8 @@ void ClientConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet) } BOOL allAllowed, friendsAllowed; ProfileManager.AllowedPlayerCreatedContent(m_userIndex,true,&allAllowed,&friendsAllowed); - send(std::make_shared<LoginPacket>(minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION, offlineXUID, onlineXUID, (allAllowed != TRUE && friendsAllowed == TRUE), - packet->m_ugcPlayersVersion, app.GetPlayerSkinId(m_userIndex), app.GetPlayerCapeId(m_userIndex), ProfileManager.IsGuest(m_userIndex))); + send( shared_ptr<LoginPacket>( new LoginPacket(minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION, offlineXUID, onlineXUID, (allAllowed!=TRUE && friendsAllowed==TRUE), + packet->m_ugcPlayersVersion, app.GetPlayerSkinId(m_userIndex), app.GetPlayerCapeId(m_userIndex), ProfileManager.IsGuest( m_userIndex )))); if(!g_NetworkManager.IsHost() ) { @@ -2415,7 +2408,7 @@ void ClientConnection::handleAddMob(shared_ptr<AddMobPacket> packet) level->putEntity(packet->id, mob); vector<shared_ptr<SynchedEntityData::DataItem> > *unpackedData = packet->getUnpackedData(); - if (unpackedData != nullptr) + if (unpackedData != NULL) { mob->getEntityData()->assignValues(unpackedData); } @@ -2450,10 +2443,10 @@ void ClientConnection::handleEntityLinkPacket(shared_ptr<SetEntityLinkPacket> pa // 4J: If the destination entity couldn't be found, defer handling of this packet // This was added to support leashing (the entity link packet is sent before the add entity packet) - if (destEntity == nullptr && packet->destId >= 0) + if (destEntity == NULL && packet->destId >= 0) { // We don't handle missing source entities because it shouldn't happen - assert(!(sourceEntity == nullptr && packet->sourceId >= 0)); + assert(!(sourceEntity == NULL && packet->sourceId >= 0)); deferredEntityLinkPackets.push_back(DeferredEntityLinkPacket(packet)); return; @@ -2466,16 +2459,16 @@ void ClientConnection::handleEntityLinkPacket(shared_ptr<SetEntityLinkPacket> pa { sourceEntity = Minecraft::GetInstance()->localplayers[m_userIndex]; - if (destEntity != nullptr && destEntity->instanceof(eTYPE_BOAT)) (dynamic_pointer_cast<Boat>(destEntity))->setDoLerp(false); + if (destEntity != NULL && destEntity->instanceof(eTYPE_BOAT)) (dynamic_pointer_cast<Boat>(destEntity))->setDoLerp(false); - displayMountMessage = (sourceEntity->riding == nullptr && destEntity != nullptr); + displayMountMessage = (sourceEntity->riding == NULL && destEntity != NULL); } - else if (destEntity != nullptr && destEntity->instanceof(eTYPE_BOAT)) + else if (destEntity != NULL && destEntity->instanceof(eTYPE_BOAT)) { (dynamic_pointer_cast<Boat>(destEntity))->setDoLerp(true); } - if (sourceEntity == nullptr) return; + if (sourceEntity == NULL) return; sourceEntity->ride(destEntity); @@ -2489,9 +2482,9 @@ void ClientConnection::handleEntityLinkPacket(shared_ptr<SetEntityLinkPacket> pa } else if (packet->type == SetEntityLinkPacket::LEASH) { - if ( (sourceEntity != nullptr) && sourceEntity->instanceof(eTYPE_MOB) ) + if ( (sourceEntity != NULL) && sourceEntity->instanceof(eTYPE_MOB) ) { - if (destEntity != nullptr) + if (destEntity != NULL) { (dynamic_pointer_cast<Mob>(sourceEntity))->setLeashedTo(destEntity, false); @@ -2507,7 +2500,7 @@ void ClientConnection::handleEntityLinkPacket(shared_ptr<SetEntityLinkPacket> pa void ClientConnection::handleEntityEvent(shared_ptr<EntityEventPacket> packet) { shared_ptr<Entity> e = getEntity(packet->entityId); - if (e != nullptr) e->handleEntityEvent(packet->eventId); + if (e != NULL) e->handleEntityEvent(packet->eventId); } shared_ptr<Entity> ClientConnection::getEntity(int entityId) @@ -2531,7 +2524,7 @@ void ClientConnection::handleSetHealth(shared_ptr<SetHealthPacket> packet) // We need food if(packet->food < FoodConstants::HEAL_LEVEL - 1) { - if(minecraft->localgameModes[m_userIndex] != nullptr && !minecraft->localgameModes[m_userIndex]->hasInfiniteItems() ) + if(minecraft->localgameModes[m_userIndex] != NULL && !minecraft->localgameModes[m_userIndex]->hasInfiniteItems() ) { minecraft->localgameModes[m_userIndex]->getTutorial()->changeTutorialState(e_Tutorial_State_Food_Bar); } @@ -2555,13 +2548,13 @@ void ClientConnection::handleTexture(shared_ptr<TexturePacket> packet) #ifndef _CONTENT_PACKAGE wprintf(L"Client received request for custom texture %ls\n",packet->textureName.c_str()); #endif - PBYTE pbData=nullptr; + PBYTE pbData=NULL; DWORD dwBytes=0; app.GetMemFileDetails(packet->textureName,&pbData,&dwBytes); if(dwBytes!=0) { - send(std::make_shared<TexturePacket>(packet->textureName, pbData, dwBytes)); + send( shared_ptr<TexturePacket>( new TexturePacket(packet->textureName,pbData,dwBytes) ) ); } } else @@ -2587,7 +2580,7 @@ void ClientConnection::handleTextureAndGeometry(shared_ptr<TextureAndGeometryPac #ifndef _CONTENT_PACKAGE wprintf(L"Client received request for custom texture and geometry %ls\n",packet->textureName.c_str()); #endif - PBYTE pbData=nullptr; + PBYTE pbData=NULL; DWORD dwBytes=0; app.GetMemFileDetails(packet->textureName,&pbData,&dwBytes); DLCSkinFile *pDLCSkinFile = app.m_dlcManager.getSkinFile(packet->textureName); @@ -2598,18 +2591,18 @@ void ClientConnection::handleTextureAndGeometry(shared_ptr<TextureAndGeometryPac { if(pDLCSkinFile->getAdditionalBoxesCount()!=0) { - send(std::make_shared<TextureAndGeometryPacket>(packet->textureName, pbData, dwBytes, pDLCSkinFile)); + send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwBytes,pDLCSkinFile) ) ); } else { - send(std::make_shared<TextureAndGeometryPacket>(packet->textureName, pbData, dwBytes)); + send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwBytes) ) ); } } else { unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(packet->dwSkinID); - send(std::make_shared<TextureAndGeometryPacket>(packet->textureName, pbData, dwBytes, app.GetAdditionalSkinBoxes(packet->dwSkinID), uiAnimOverrideBitmask)); + send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwBytes,app.GetAdditionalSkinBoxes(packet->dwSkinID),uiAnimOverrideBitmask) ) ); } } } @@ -2637,7 +2630,7 @@ void ClientConnection::handleTextureAndGeometry(shared_ptr<TextureAndGeometryPac void ClientConnection::handleTextureChange(shared_ptr<TextureChangePacket> packet) { shared_ptr<Entity> e = getEntity(packet->id); - if ( (e == nullptr) || !e->instanceof(eTYPE_PLAYER) ) return; + if ( (e == NULL) || !e->instanceof(eTYPE_PLAYER) ) return; shared_ptr<Player> player = dynamic_pointer_cast<Player>(e); bool isLocalPlayer = false; @@ -2678,25 +2671,22 @@ void ClientConnection::handleTextureChange(shared_ptr<TextureChangePacket> packe #ifndef _CONTENT_PACKAGE wprintf(L"handleTextureChange - Client sending texture packet to get custom skin %ls for player %ls\n",packet->path.c_str(), player->name.c_str()); #endif - send(std::make_shared<TexturePacket>( - player->customTextureUrl, - nullptr, - static_cast<DWORD>(0))); + send(shared_ptr<TexturePacket>( new TexturePacket(packet->path,NULL,0) ) ); } } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(packet->path,nullptr,0); + app.AddMemoryTextureFile(packet->path,NULL,0); } } void ClientConnection::handleTextureAndGeometryChange(shared_ptr<TextureAndGeometryChangePacket> packet) { shared_ptr<Entity> e = getEntity(packet->id); - if (e == nullptr) return; + if (e == NULL) return; shared_ptr<Player> player = dynamic_pointer_cast<Player>(e); - if( e == nullptr) return; + if( e == NULL) return; bool isLocalPlayer = false; for( int i = 0; i < XUSER_MAX_COUNT; i++ ) @@ -2726,16 +2716,13 @@ void ClientConnection::handleTextureAndGeometryChange(shared_ptr<TextureAndGeome #ifndef _CONTENT_PACKAGE wprintf(L"handleTextureAndGeometryChange - Client sending TextureAndGeometryPacket to get custom skin %ls for player %ls\n",packet->path.c_str(), player->name.c_str()); #endif - send(std::make_shared<TextureAndGeometryPacket>( - packet->path, - nullptr, - static_cast<DWORD>(0))); + send(shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->path,NULL,0) ) ); } } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(packet->path,nullptr,0); + app.AddMemoryTextureFile(packet->path,NULL,0); } } @@ -2756,12 +2743,12 @@ void ClientConnection::handleRespawn(shared_ptr<RespawnPacket> packet) level->removeClientConnection(this, false); MultiPlayerLevel *dimensionLevel = (MultiPlayerLevel *)minecraft->getLevel( packet->dimension ); - if( dimensionLevel == nullptr ) + if( dimensionLevel == NULL ) { dimensionLevel = new MultiPlayerLevel(this, new LevelSettings(packet->mapSeed, packet->playerGameType, false, minecraft->level->getLevelData()->isHardcore(), packet->m_newSeaLevel, packet->m_pLevelType, packet->m_xzSize, packet->m_hellScale), packet->dimension, packet->difficulty); // 4J Stu - We want to shared the savedDataStorage between both levels - //if( dimensionLevel->savedDataStorage != nullptr ) + //if( dimensionLevel->savedDataStorage != NULL ) //{ // Don't need to delete it here as it belongs to a client connection while will delete it when it's done // delete dimensionLevel->savedDataStorage;+ @@ -2801,7 +2788,7 @@ void ClientConnection::handleRespawn(shared_ptr<RespawnPacket> packet) TelemetryManager->RecordLevelStart(m_userIndex, eSen_FriendOrMatch_Playing_With_Invited_Friends, eSen_CompeteOrCoop_Coop_and_Competitive, Minecraft::GetInstance()->getLevel(packet->dimension)->difficulty, app.GetLocalPlayerCount(), g_NetworkManager.GetOnlinePlayerCount()); #endif - if( minecraft->localgameModes[m_userIndex] != nullptr ) + if( minecraft->localgameModes[m_userIndex] != NULL ) { TutorialMode *gameMode = (TutorialMode *)minecraft->localgameModes[m_userIndex]; gameMode->getTutorial()->showTutorialPopup(false); @@ -2912,7 +2899,7 @@ void ClientConnection::handleContainerOpen(shared_ptr<ContainerOpenPacket> packe default: assert(false); chestString = -1; break; } - if( player->openContainer(std::make_shared<SimpleContainer>(chestString, packet->title, packet->customName, packet->size))) + if( player->openContainer(shared_ptr<SimpleContainer>( new SimpleContainer(chestString, packet->title, packet->customName, packet->size) ))) { player->containerMenu->containerId = packet->containerId; } @@ -2924,7 +2911,7 @@ void ClientConnection::handleContainerOpen(shared_ptr<ContainerOpenPacket> packe break; case ContainerOpenPacket::HOPPER: { - shared_ptr<HopperTileEntity> hopper = std::make_shared<HopperTileEntity>(); + shared_ptr<HopperTileEntity> hopper = shared_ptr<HopperTileEntity>(new HopperTileEntity()); if (packet->customName) hopper->setCustomName(packet->title); if(player->openHopper(hopper)) { @@ -2938,7 +2925,7 @@ void ClientConnection::handleContainerOpen(shared_ptr<ContainerOpenPacket> packe break; case ContainerOpenPacket::FURNACE: { - shared_ptr<FurnaceTileEntity> furnace = std::make_shared<FurnaceTileEntity>(); + shared_ptr<FurnaceTileEntity> furnace = shared_ptr<FurnaceTileEntity>(new FurnaceTileEntity()); if (packet->customName) furnace->setCustomName(packet->title); if(player->openFurnace(furnace)) { @@ -2952,7 +2939,7 @@ void ClientConnection::handleContainerOpen(shared_ptr<ContainerOpenPacket> packe break; case ContainerOpenPacket::BREWING_STAND: { - shared_ptr<BrewingStandTileEntity> brewingStand = std::make_shared<BrewingStandTileEntity>(); + shared_ptr<BrewingStandTileEntity> brewingStand = shared_ptr<BrewingStandTileEntity>(new BrewingStandTileEntity()); if (packet->customName) brewingStand->setCustomName(packet->title); if( player->openBrewingStand(brewingStand)) @@ -2967,7 +2954,7 @@ void ClientConnection::handleContainerOpen(shared_ptr<ContainerOpenPacket> packe break; case ContainerOpenPacket::DROPPER: { - shared_ptr<DropperTileEntity> dropper = std::make_shared<DropperTileEntity>(); + shared_ptr<DropperTileEntity> dropper = shared_ptr<DropperTileEntity>(new DropperTileEntity()); if (packet->customName) dropper->setCustomName(packet->title); if( player->openTrap(dropper)) @@ -2982,7 +2969,7 @@ void ClientConnection::handleContainerOpen(shared_ptr<ContainerOpenPacket> packe break; case ContainerOpenPacket::TRAP: { - shared_ptr<DispenserTileEntity> dispenser = std::make_shared<DispenserTileEntity>(); + shared_ptr<DispenserTileEntity> dispenser = shared_ptr<DispenserTileEntity>(new DispenserTileEntity()); if (packet->customName) dispenser->setCustomName(packet->title); if( player->openTrap(dispenser)) @@ -3021,7 +3008,7 @@ void ClientConnection::handleContainerOpen(shared_ptr<ContainerOpenPacket> packe break; case ContainerOpenPacket::TRADER_NPC: { - shared_ptr<ClientSideMerchant> csm = std::make_shared<ClientSideMerchant>(player, packet->title); + shared_ptr<ClientSideMerchant> csm = shared_ptr<ClientSideMerchant>(new ClientSideMerchant(player, packet->title)); csm->createContainer(); if(player->openTrading(csm, packet->customName ? packet->title : L"")) { @@ -3035,7 +3022,7 @@ void ClientConnection::handleContainerOpen(shared_ptr<ContainerOpenPacket> packe break; case ContainerOpenPacket::BEACON: { - shared_ptr<BeaconTileEntity> beacon = std::make_shared<BeaconTileEntity>(); + shared_ptr<BeaconTileEntity> beacon = shared_ptr<BeaconTileEntity>(new BeaconTileEntity()); if (packet->customName) beacon->setCustomName(packet->title); if(player->openBeacon(beacon)) @@ -3073,7 +3060,7 @@ void ClientConnection::handleContainerOpen(shared_ptr<ContainerOpenPacket> packe iTitle = IDS_MULE; break; }; - if(player->openHorseInventory(dynamic_pointer_cast<EntityHorse>(entity), std::make_shared<AnimalChest>(iTitle, packet->title, packet->customName, packet->size))) + if(player->openHorseInventory(dynamic_pointer_cast<EntityHorse>(entity), shared_ptr<AnimalChest>(new AnimalChest(iTitle, packet->title, packet->customName, packet->size)))) { player->containerMenu->containerId = packet->containerId; } @@ -3108,7 +3095,7 @@ void ClientConnection::handleContainerOpen(shared_ptr<ContainerOpenPacket> packe } else { - send(std::make_shared<ContainerClosePacket>(packet->containerId)); + send(shared_ptr<ContainerClosePacket>(new ContainerClosePacket(packet->containerId))); } } } @@ -3128,9 +3115,9 @@ void ClientConnection::handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket> if(packet->slot >= 36 && packet->slot < 36 + 9) { shared_ptr<ItemInstance> lastItem = player->inventoryMenu->getSlot(packet->slot)->getItem(); - if (packet->item != nullptr) + if (packet->item != NULL) { - if (lastItem == nullptr || lastItem->count < packet->item->count) + if (lastItem == NULL || lastItem->count < packet->item->count) { packet->item->popTime = Inventory::POP_TIME_DURATION; } @@ -3148,7 +3135,7 @@ void ClientConnection::handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket> void ClientConnection::handleContainerAck(shared_ptr<ContainerAckPacket> packet) { shared_ptr<MultiplayerLocalPlayer> player = minecraft->localplayers[m_userIndex]; - AbstractContainerMenu *menu = nullptr; + AbstractContainerMenu *menu = NULL; if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_INVENTORY) { menu = player->inventoryMenu; @@ -3157,11 +3144,11 @@ void ClientConnection::handleContainerAck(shared_ptr<ContainerAckPacket> packet) { menu = player->containerMenu; } - if (menu != nullptr) + if (menu != NULL) { if (!packet->accepted) { - send(std::make_shared<ContainerAckPacket>(packet->containerId, packet->uid, true)); + send( shared_ptr<ContainerAckPacket>( new ContainerAckPacket(packet->containerId, packet->uid, true) )); } } } @@ -3182,13 +3169,13 @@ void ClientConnection::handleContainerContent(shared_ptr<ContainerSetContentPack void ClientConnection::handleTileEditorOpen(shared_ptr<TileEditorOpenPacket> packet) { shared_ptr<TileEntity> tileEntity = level->getTileEntity(packet->x, packet->y, packet->z); - if (tileEntity != nullptr) + if (tileEntity != NULL) { minecraft->localplayers[m_userIndex]->openTextEdit(tileEntity); } else if (packet->editorType == TileEditorOpenPacket::SIGN) { - shared_ptr<SignTileEntity> localSignDummy = std::make_shared<SignTileEntity>(); + shared_ptr<SignTileEntity> localSignDummy = shared_ptr<SignTileEntity>(new SignTileEntity()); localSignDummy->setLevel(level); localSignDummy->x = packet->x; localSignDummy->y = packet->y; @@ -3205,7 +3192,7 @@ void ClientConnection::handleSignUpdate(shared_ptr<SignUpdatePacket> packet) shared_ptr<TileEntity> te = minecraft->level->getTileEntity(packet->x, packet->y, packet->z); // 4J-PB - on a client connecting, the line below fails - if (dynamic_pointer_cast<SignTileEntity>(te) != nullptr) + if (dynamic_pointer_cast<SignTileEntity>(te) != NULL) { shared_ptr<SignTileEntity> ste = dynamic_pointer_cast<SignTileEntity>(te); for (int i = 0; i < MAX_SIGN_LINES; i++) @@ -3221,7 +3208,7 @@ void ClientConnection::handleSignUpdate(shared_ptr<SignUpdatePacket> packet) } else { - app.DebugPrintf("dynamic_pointer_cast<SignTileEntity>(te) == nullptr\n"); + app.DebugPrintf("dynamic_pointer_cast<SignTileEntity>(te) == NULL\n"); } } else @@ -3236,21 +3223,21 @@ void ClientConnection::handleTileEntityData(shared_ptr<TileEntityDataPacket> pac { shared_ptr<TileEntity> te = minecraft->level->getTileEntity(packet->x, packet->y, packet->z); - if (te != nullptr) + if (te != NULL) { - if (packet->type == TileEntityDataPacket::TYPE_MOB_SPAWNER && dynamic_pointer_cast<MobSpawnerTileEntity>(te) != nullptr) + if (packet->type == TileEntityDataPacket::TYPE_MOB_SPAWNER && dynamic_pointer_cast<MobSpawnerTileEntity>(te) != NULL) { dynamic_pointer_cast<MobSpawnerTileEntity>(te)->load(packet->tag); } - else if (packet->type == TileEntityDataPacket::TYPE_ADV_COMMAND && dynamic_pointer_cast<CommandBlockEntity>(te) != nullptr) + else if (packet->type == TileEntityDataPacket::TYPE_ADV_COMMAND && dynamic_pointer_cast<CommandBlockEntity>(te) != NULL) { dynamic_pointer_cast<CommandBlockEntity>(te)->load(packet->tag); } - else if (packet->type == TileEntityDataPacket::TYPE_BEACON && dynamic_pointer_cast<BeaconTileEntity>(te) != nullptr) + else if (packet->type == TileEntityDataPacket::TYPE_BEACON && dynamic_pointer_cast<BeaconTileEntity>(te) != NULL) { dynamic_pointer_cast<BeaconTileEntity>(te)->load(packet->tag); } - else if (packet->type == TileEntityDataPacket::TYPE_SKULL && dynamic_pointer_cast<SkullTileEntity>(te) != nullptr) + else if (packet->type == TileEntityDataPacket::TYPE_SKULL && dynamic_pointer_cast<SkullTileEntity>(te) != NULL) { dynamic_pointer_cast<SkullTileEntity>(te)->load(packet->tag); } @@ -3261,7 +3248,7 @@ void ClientConnection::handleTileEntityData(shared_ptr<TileEntityDataPacket> pac void ClientConnection::handleContainerSetData(shared_ptr<ContainerSetDataPacket> packet) { onUnhandledPacket(packet); - if (minecraft->localplayers[m_userIndex]->containerMenu != nullptr && minecraft->localplayers[m_userIndex]->containerMenu->containerId == packet->containerId) + if (minecraft->localplayers[m_userIndex]->containerMenu != NULL && minecraft->localplayers[m_userIndex]->containerMenu->containerId == packet->containerId) { minecraft->localplayers[m_userIndex]->containerMenu->setData(packet->id, packet->value); } @@ -3270,7 +3257,7 @@ void ClientConnection::handleContainerSetData(shared_ptr<ContainerSetDataPacket> void ClientConnection::handleSetEquippedItem(shared_ptr<SetEquippedItemPacket> packet) { shared_ptr<Entity> entity = getEntity(packet->entity); - if (entity != nullptr) + if (entity != NULL) { // 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game entity->setEquippedSlot(packet->slot, packet->getItem() ); @@ -3296,7 +3283,7 @@ void ClientConnection::handleTileDestruction(shared_ptr<TileDestructionPacket> p bool ClientConnection::canHandleAsyncPackets() { - return minecraft != nullptr && minecraft->level != nullptr && minecraft->localplayers[m_userIndex] != nullptr && level != nullptr; + return minecraft != NULL && minecraft->level != NULL && minecraft->localplayers[m_userIndex] != NULL && level != NULL; } void ClientConnection::handleGameEvent(shared_ptr<GameEventPacket> gameEventPacket) @@ -3305,7 +3292,7 @@ void ClientConnection::handleGameEvent(shared_ptr<GameEventPacket> gameEventPack int param = gameEventPacket->param; if (event >= 0 && event < GameEventPacket::EVENT_LANGUAGE_ID_LENGTH) { - if (GameEventPacket::EVENT_LANGUAGE_ID[event] > 0) // 4J - was nullptr check + if (GameEventPacket::EVENT_LANGUAGE_ID[event] > 0) // 4J - was NULL check { minecraft->localplayers[m_userIndex]->displayClientMessage(GameEventPacket::EVENT_LANGUAGE_ID[event]); } @@ -3337,7 +3324,7 @@ void ClientConnection::handleGameEvent(shared_ptr<GameEventPacket> gameEventPack ui.ShowOtherPlayersBaseScene(ProfileManager.GetPrimaryPad(), false); // This just allows it to be shown - if(minecraft->localgameModes[ProfileManager.GetPrimaryPad()] != nullptr) minecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); + if(minecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) minecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); // Temporarily make this scene fullscreen CXuiSceneBase::SetPlayerBaseScenePosition( ProfileManager.GetPrimaryPad(), CXuiSceneBase::e_BaseScene_Fullscreen ); @@ -3345,8 +3332,8 @@ void ClientConnection::handleGameEvent(shared_ptr<GameEventPacket> gameEventPack #else app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n", m_userIndex); // This just allows it to be shown - if(minecraft->localgameModes[ProfileManager.GetPrimaryPad()] != nullptr) minecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); - ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_EndPoem, nullptr, eUILayer_Scene, eUIGroup_Fullscreen); + if(minecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) minecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_EndPoem, NULL, eUILayer_Scene, eUIGroup_Fullscreen); #endif } else if( event == GameEventPacket::START_SAVING ) @@ -3390,7 +3377,7 @@ void ClientConnection::handleLevelEvent(shared_ptr<LevelEventPacket> packet) { for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { - if(minecraft->localplayers[i] != nullptr && minecraft->localplayers[i]->level != nullptr && minecraft->localplayers[i]->level->dimension->id == 1) + if(minecraft->localplayers[i] != NULL && minecraft->localplayers[i]->level != NULL && minecraft->localplayers[i]->level->dimension->id == 1) { minecraft->localplayers[i]->awardStat(GenericStats::completeTheEnd(),GenericStats::param_noArgs()); } @@ -3417,7 +3404,7 @@ void ClientConnection::handleAwardStat(shared_ptr<AwardStatPacket> packet) void ClientConnection::handleUpdateMobEffect(shared_ptr<UpdateMobEffectPacket> packet) { shared_ptr<Entity> e = getEntity(packet->entityId); - if ( (e == nullptr) || !e->instanceof(eTYPE_LIVINGENTITY) ) return; + if ( (e == NULL) || !e->instanceof(eTYPE_LIVINGENTITY) ) return; //( dynamic_pointer_cast<LivingEntity>(e) )->addEffect(new MobEffectInstance(packet->effectId, packet->effectDurationTicks, packet->effectAmplifier)); @@ -3429,7 +3416,7 @@ void ClientConnection::handleUpdateMobEffect(shared_ptr<UpdateMobEffectPacket> p void ClientConnection::handleRemoveMobEffect(shared_ptr<RemoveMobEffectPacket> packet) { shared_ptr<Entity> e = getEntity(packet->entityId); - if ( (e == nullptr) || !e->instanceof(eTYPE_LIVINGENTITY) ) return; + if ( (e == NULL) || !e->instanceof(eTYPE_LIVINGENTITY) ) return; ( dynamic_pointer_cast<LivingEntity>(e) )->removeEffectNoUpdate(packet->effectId); } @@ -3445,7 +3432,7 @@ void ClientConnection::handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet) INetworkPlayer *networkPlayer = g_NetworkManager.GetPlayerBySmallId(packet->m_networkSmallId); - if(networkPlayer != nullptr && networkPlayer->IsHost()) + if(networkPlayer != NULL && networkPlayer->IsHost()) { // Some settings should always be considered on for the host player Player::enableAllPlayerPrivileges(startingPrivileges,true); @@ -3456,17 +3443,17 @@ void ClientConnection::handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet) app.UpdatePlayerInfo(packet->m_networkSmallId, packet->m_playerColourIndex, packet->m_playerPrivileges); shared_ptr<Entity> entity = getEntity(packet->m_entityId); - if(entity != nullptr && entity->instanceof(eTYPE_PLAYER)) + if(entity != NULL && entity->instanceof(eTYPE_PLAYER)) { shared_ptr<Player> player = dynamic_pointer_cast<Player>(entity); player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_All, packet->m_playerPrivileges); } - if(networkPlayer != nullptr && networkPlayer->IsLocal()) + if(networkPlayer != NULL && networkPlayer->IsLocal()) { for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { shared_ptr<MultiplayerLocalPlayer> localPlayer = minecraft->localplayers[i]; - if(localPlayer != nullptr && localPlayer->connection != nullptr && localPlayer->connection->getNetworkPlayer() == networkPlayer ) + if(localPlayer != NULL && localPlayer->connection != NULL && localPlayer->connection->getNetworkPlayer() == networkPlayer ) { localPlayer->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_All,packet->m_playerPrivileges); displayPrivilegeChanges(localPlayer,startingPrivileges); @@ -3593,7 +3580,7 @@ void ClientConnection::displayPrivilegeChanges(shared_ptr<MultiplayerLocalPlayer void ClientConnection::handleKeepAlive(shared_ptr<KeepAlivePacket> packet) { - send(std::make_shared<KeepAlivePacket>(packet->id)); + send(shared_ptr<KeepAlivePacket>(new KeepAlivePacket(packet->id))); } void ClientConnection::handlePlayerAbilities(shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket) @@ -3664,7 +3651,7 @@ void ClientConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChan { for(unsigned int i = 0; i < minecraft->levels.length; ++i) { - if( minecraft->levels[i] != nullptr ) + if( minecraft->levels[i] != NULL ) { app.DebugPrintf("ClientConnection::handleServerSettingsChanged - Difficulty = %d",packet->data); minecraft->levels[i]->difficulty = packet->data; @@ -3698,11 +3685,11 @@ void ClientConnection::handleUpdateProgress(shared_ptr<UpdateProgressPacket> pac void ClientConnection::handleUpdateGameRuleProgressPacket(shared_ptr<UpdateGameRuleProgressPacket> packet) { LPCWSTR string = app.GetGameRulesString(packet->m_messageId); - if(string != nullptr) + if(string != NULL) { wstring message(string); message = GameRuleDefinition::generateDescriptionString(packet->m_definitionType,message,packet->m_data.data,packet->m_data.length); - if(minecraft->localgameModes[m_userIndex]!=nullptr) + if(minecraft->localgameModes[m_userIndex]!=NULL) { minecraft->localgameModes[m_userIndex]->getTutorial()->setMessage(message, packet->m_icon, packet->m_auxValue); } @@ -3748,7 +3735,7 @@ int ClientConnection::HostDisconnectReturned(void *pParam,int iPad,C4JStorage::E UINT uiIDA[2]; uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; - ui.RequestErrorMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&ClientConnection::ExitGameAndSaveReturned,nullptr); + ui.RequestErrorMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&ClientConnection::ExitGameAndSaveReturned,NULL); } else #else @@ -3763,7 +3750,7 @@ int ClientConnection::HostDisconnectReturned(void *pParam,int iPad,C4JStorage::E UINT uiIDA[2]; uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; - ui.RequestErrorMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&ClientConnection::ExitGameAndSaveReturned,nullptr); + ui.RequestErrorMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&ClientConnection::ExitGameAndSaveReturned,NULL); } else #endif @@ -3898,7 +3885,7 @@ void ClientConnection::handleSetPlayerTeamPacket(shared_ptr<SetPlayerTeamPacket> if (packet->method == SetPlayerTeamPacket::METHOD_ADD || packet->method == SetPlayerTeamPacket::METHOD_JOIN) { - for (size_t i = 0; i < packet->players.size(); i++) + for (int i = 0; i < packet->players.size(); i++) { scoreboard->addPlayerToTeam(packet->players[i], team); } @@ -3906,7 +3893,7 @@ void ClientConnection::handleSetPlayerTeamPacket(shared_ptr<SetPlayerTeamPacket> if (packet->method == SetPlayerTeamPacket::METHOD_LEAVE) { - for (size_t i = 0; i < packet->players.size(); i++) + for (int i = 0; i < packet->players.size(); i++) { scoreboard->removePlayerFromTeam(packet->players[i], team); } @@ -3941,7 +3928,7 @@ void ClientConnection::handleParticleEvent(shared_ptr<LevelParticlesPacket> pack void ClientConnection::handleUpdateAttributes(shared_ptr<UpdateAttributesPacket> packet) { shared_ptr<Entity> entity = getEntity(packet->getEntityId()); - if (entity == nullptr) return; + if (entity == NULL) return; if ( !entity->instanceof(eTYPE_LIVINGENTITY) ) { @@ -3980,7 +3967,7 @@ void ClientConnection::checkDeferredEntityLinkPackets(int newEntityId) { if (deferredEntityLinkPackets.empty()) return; - for (size_t i = 0; i < deferredEntityLinkPackets.size(); i++) + for (int i = 0; i < deferredEntityLinkPackets.size(); i++) { DeferredEntityLinkPacket *deferred = &deferredEntityLinkPackets[i]; |
