resolve conflicts

This commit is contained in:
Marlian 2026-03-09 17:16:12 +01:00 committed by GitHub
parent 87d6f109f0
commit 2fbf232f28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -56,7 +56,7 @@
#ifndef _DURANGO #ifndef _DURANGO
#include "..\Minecraft.World\CommonStats.h" #include "..\Minecraft.World\CommonStats.h"
#endif #endif
extern ConsoleUIController ui;
LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dimension) : Player(level, user->name) LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dimension) : Player(level, user->name)
@ -79,11 +79,11 @@ LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dim
this->minecraft = minecraft; this->minecraft = minecraft;
this->dimension = dimension; this->dimension = dimension;
if (user != NULL && user->name.length() > 0) if (user != nullptr && user->name.length() > 0)
{ {
customTextureUrl = L"http://s3.amazonaws.com/MinecraftSkins/" + user->name + L".png"; customTextureUrl = L"http://s3.amazonaws.com/MinecraftSkins/" + user->name + L".png";
} }
if( user != NULL ) if( user != nullptr )
{ {
this->name = user->name; this->name = user->name;
//wprintf(L"Created LocalPlayer with name %ls\n", name.c_str() ); //wprintf(L"Created LocalPlayer with name %ls\n", name.c_str() );
@ -95,7 +95,7 @@ LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dim
} }
} }
input = NULL; input = nullptr;
m_iPad = -1; m_iPad = -1;
m_iScreenSection=C4JRender::VIEWPORT_TYPE_FULLSCREEN; // assume singleplayer default m_iScreenSection=C4JRender::VIEWPORT_TYPE_FULLSCREEN; // assume singleplayer default
m_bPlayerRespawned=false; m_bPlayerRespawned=false;
@ -124,7 +124,7 @@ LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dim
LocalPlayer::~LocalPlayer() LocalPlayer::~LocalPlayer()
{ {
if( this->input != NULL ) if( this->input != nullptr )
delete input; delete input;
} }
@ -188,9 +188,9 @@ void LocalPlayer::aiStep()
{ {
if (!level->isClientSide) if (!level->isClientSide)
{ {
if (riding != NULL) this->ride(nullptr); if (riding != nullptr) this->ride(nullptr);
} }
if (minecraft->screen != NULL) minecraft->setScreen(NULL); if (minecraft->screen != nullptr) minecraft->setScreen(nullptr);
if (portalTime == 0) if (portalTime == 0)
{ {
@ -334,6 +334,7 @@ void LocalPlayer::aiStep()
if (abilities.flying) if (abilities.flying)
{ {
// yd = 0;
if (javaFlight) if (javaFlight)
{ {
if (ullButtonsPressed & (1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE) ) yd -= 0.15f; if (ullButtonsPressed & (1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE) ) yd -= 0.15f;
@ -397,11 +398,11 @@ void LocalPlayer::aiStep()
jumpRidingTicks++; jumpRidingTicks++;
if (jumpRidingTicks < 10) if (jumpRidingTicks < 10)
{ {
jumpRidingScale = (float) jumpRidingTicks * .1f; jumpRidingScale = static_cast<float>(jumpRidingTicks) * .1f;
} }
else else
{ {
jumpRidingScale = .8f + (2.f / ((float) (jumpRidingTicks - 9))) * .1f; jumpRidingScale = .8f + (2.f / static_cast<float>(jumpRidingTicks - 9)) * .1f;
} }
} }
} }
@ -435,9 +436,9 @@ void LocalPlayer::aiStep()
#ifdef _DEBUG_MENUS_ENABLED #ifdef _DEBUG_MENUS_ENABLED
if(abilities.debugflying) if(abilities.debugflying)
{ {
flyX = (float)viewVector->x * input->ya; flyX = static_cast<float>(viewVector->x) * input->ya;
flyY = (float)viewVector->y * input->ya; flyY = static_cast<float>(viewVector->y) * input->ya;
flyZ = (float)viewVector->z * input->ya; flyZ = static_cast<float>(viewVector->z) * input->ya;
} }
else else
#endif #endif
@ -458,11 +459,11 @@ void LocalPlayer::aiStep()
if( isSprinting() ) if( isSprinting() )
{ {
// 4J: Accelrate up to full speed if we are sprinting, moving in the direction of the view vector // 4J: Accelrate up to full speed if we are sprinting, moving in the direction of the view vector
flyX = (float)viewVector->x * input->ya; flyX = static_cast<float>(viewVector->x) * input->ya;
flyY = (float)viewVector->y * input->ya; flyY = static_cast<float>(viewVector->y) * input->ya;
flyZ = (float)viewVector->z * input->ya; flyZ = static_cast<float>(viewVector->z) * input->ya;
float scale = ((float)(SPRINT_DURATION - sprintTime))/10.0f; float scale = static_cast<float>(SPRINT_DURATION - sprintTime)/10.0f;
scale = scale * scale; scale = scale * scale;
if ( scale > 1.0f ) scale = 1.0f; if ( scale > 1.0f ) scale = 1.0f;
flyX *= scale; flyX *= scale;
@ -562,7 +563,7 @@ float LocalPlayer::getFieldOfViewModifier()
if (isUsingItem() && getUseItem()->id == Item::bow->id) if (isUsingItem() && getUseItem()->id == Item::bow->id)
{ {
int ticksHeld = getTicksUsingItem(); int ticksHeld = getTicksUsingItem();
float scale = (float) ticksHeld / BowItem::MAX_DRAW_DURATION; float scale = static_cast<float>(ticksHeld) / BowItem::MAX_DRAW_DURATION;
if (scale > 1) if (scale > 1)
{ {
scale = 1; scale = 1;
@ -592,7 +593,7 @@ void LocalPlayer::readAdditionalSaveData(CompoundTag *entityTag)
void LocalPlayer::closeContainer() void LocalPlayer::closeContainer()
{ {
Player::closeContainer(); Player::closeContainer();
minecraft->setScreen(NULL); minecraft->setScreen(nullptr);
// 4J - Close any xui here // 4J - Close any xui here
// Fix for #9164 - CRASH: MP: Title crashes upon opening a chest and having another user destroy it. // Fix for #9164 - CRASH: MP: Title crashes upon opening a chest and having another user destroy it.
@ -723,21 +724,21 @@ bool LocalPlayer::openTrading(shared_ptr<Merchant> traderTarget, const wstring &
void LocalPlayer::crit(shared_ptr<Entity> e) void LocalPlayer::crit(shared_ptr<Entity> e)
{ {
shared_ptr<CritParticle> critParticle = shared_ptr<CritParticle>( new CritParticle((Level *)minecraft->level, e) ); shared_ptr<CritParticle> critParticle = std::make_shared<CritParticle>(reinterpret_cast<Level*>(minecraft->level), e);
critParticle->CritParticlePostConstructor(); critParticle->CritParticlePostConstructor();
minecraft->particleEngine->add(critParticle); minecraft->particleEngine->add(critParticle);
} }
void LocalPlayer::magicCrit(shared_ptr<Entity> e) void LocalPlayer::magicCrit(shared_ptr<Entity> e)
{ {
shared_ptr<CritParticle> critParticle = shared_ptr<CritParticle>( new CritParticle((Level *)minecraft->level, e, eParticleType_magicCrit) ); shared_ptr<CritParticle> critParticle = std::make_shared<CritParticle>(reinterpret_cast<Level*>(minecraft->level), e, eParticleType_magicCrit);
critParticle->CritParticlePostConstructor(); critParticle->CritParticlePostConstructor();
minecraft->particleEngine->add(critParticle); minecraft->particleEngine->add(critParticle);
} }
void LocalPlayer::take(shared_ptr<Entity> e, int orgCount) void LocalPlayer::take(shared_ptr<Entity> e, int orgCount)
{ {
minecraft->particleEngine->add( shared_ptr<TakeAnimationParticle>( new TakeAnimationParticle((Level *)minecraft->level, e, shared_from_this(), -0.5f) ) ); minecraft->particleEngine->add(std::make_shared<TakeAnimationParticle>(reinterpret_cast<Level*>(minecraft->level), e, shared_from_this(), -0.5f));
} }
void LocalPlayer::chat(const wstring& message) void LocalPlayer::chat(const wstring& message)
@ -772,8 +773,8 @@ void LocalPlayer::hurtTo(float newHealth, ETelemetryChallenges damageSource)
if( this->getHealth() <= 0) if( this->getHealth() <= 0)
{ {
int deathTime = (int)(level->getGameTime() % Level::TICKS_PER_DAY)/1000; int deathTime = static_cast<int>(level->getGameTime() % Level::TICKS_PER_DAY)/1000;
int carriedId = inventory->getSelected() == NULL ? 0 : inventory->getSelected()->id; int carriedId = inventory->getSelected() == nullptr ? 0 : inventory->getSelected()->id;
TelemetryManager->RecordPlayerDiedOrFailed(GetXboxPad(), 0, y, 0, 0, carriedId, 0, damageSource); TelemetryManager->RecordPlayerDiedOrFailed(GetXboxPad(), 0, y, 0, 0, carriedId, 0, damageSource);
// if there are any xuiscenes up for this player, close them // if there are any xuiscenes up for this player, close them
@ -818,11 +819,11 @@ void LocalPlayer::awardStat(Stat *stat, byteArray param)
delete [] param.data; delete [] param.data;
if (!app.CanRecordStatsAndAchievements()) return; if (!app.CanRecordStatsAndAchievements()) return;
if (stat == NULL) return; if (stat == nullptr) return;
if (stat->isAchievement()) if (stat->isAchievement())
{ {
Achievement *ach = (Achievement *) stat; Achievement *ach = static_cast<Achievement *>(stat);
// 4J-PB - changed to attempt to award everytime - the award may need a storage device, so needs a primary player, and the player may not have been a primary player when they first 'got' the award // 4J-PB - changed to attempt to award everytime - the award may need a storage device, so needs a primary player, and the player may not have been a primary player when they first 'got' the award
// so let the award manager figure it out // so let the award manager figure it out
//if (!minecraft->stats[m_iPad]->hasTaken(ach)) //if (!minecraft->stats[m_iPad]->hasTaken(ach))
@ -848,7 +849,7 @@ void LocalPlayer::awardStat(Stat *stat, byteArray param)
} }
// 4J-JEV: To stop spamming trophies. // 4J-JEV: To stop spamming trophies.
unsigned long long achBit = ((unsigned long long)1) << ach->getAchievementID(); unsigned long long achBit = static_cast<unsigned long long>(1) << ach->getAchievementID();
if ( !(achBit & m_awardedThisSession) ) if ( !(achBit & m_awardedThisSession) )
{ {
ProfileManager.Award(m_iPad, ach->getAchievementID()); ProfileManager.Award(m_iPad, ach->getAchievementID());
@ -1214,7 +1215,7 @@ void LocalPlayer::playSound(int soundId, float volume, float pitch)
bool LocalPlayer::isRidingJumpable() bool LocalPlayer::isRidingJumpable()
{ {
return riding != NULL && riding->GetType() == eTYPE_HORSE; return riding != nullptr && riding->GetType() == eTYPE_HORSE;
} }
float LocalPlayer::getJumpRidingScale() float LocalPlayer::getJumpRidingScale()
@ -1233,9 +1234,9 @@ bool LocalPlayer::hasPermission(EGameCommand command)
void LocalPlayer::onCrafted(shared_ptr<ItemInstance> item) void LocalPlayer::onCrafted(shared_ptr<ItemInstance> item)
{ {
if( minecraft->localgameModes[m_iPad] != NULL ) if( minecraft->localgameModes[m_iPad] != nullptr )
{ {
TutorialMode *gameMode = (TutorialMode *)minecraft->localgameModes[m_iPad]; TutorialMode *gameMode = static_cast<TutorialMode *>(minecraft->localgameModes[m_iPad]);
gameMode->getTutorial()->onCrafted(item); gameMode->getTutorial()->onCrafted(item);
} }
} }
@ -1257,8 +1258,8 @@ void LocalPlayer::mapPlayerChunk(const unsigned int flagTileType)
int cx = this->xChunk; int cx = this->xChunk;
int cz = this->zChunk; int cz = this->zChunk;
int pZ = ((int) floor(this->z)) %16; int pZ = static_cast<int>(floor(this->z)) %16;
int pX = ((int) floor(this->x)) %16; int pX = static_cast<int>(floor(this->x)) %16;
cout<<"player in chunk ("<<cx<<","<<cz<<") at (" cout<<"player in chunk ("<<cx<<","<<cz<<") at ("
<<this->x<<","<<this->y<<","<<this->z<<")\n"; <<this->x<<","<<this->y<<","<<this->z<<")\n";
@ -1290,14 +1291,14 @@ void LocalPlayer::mapPlayerChunk(const unsigned int flagTileType)
void LocalPlayer::handleMouseDown(int button, bool down) void LocalPlayer::handleMouseDown(int button, bool down)
{ {
// 4J Stu - We should not accept any input while asleep, except the above to wake up // 4J Stu - We should not accept any input while asleep, except the above to wake up
if(isSleeping() && level != NULL && level->isClientSide) if(isSleeping() && level != nullptr && level->isClientSide)
{ {
return; return;
} }
if (!down) missTime = 0; if (!down) missTime = 0;
if (button == 0 && missTime > 0) return; if (button == 0 && missTime > 0) return;
if (down && minecraft->hitResult != NULL && minecraft->hitResult->type == HitResult::TILE && button == 0) if (down && minecraft->hitResult != nullptr && minecraft->hitResult->type == HitResult::TILE && button == 0)
{ {
int x = minecraft->hitResult->x; int x = minecraft->hitResult->x;
int y = minecraft->hitResult->y; int y = minecraft->hitResult->y;
@ -1346,9 +1347,9 @@ bool LocalPlayer::creativeModeHandleMouseClick(int button, bool buttonPressed)
} }
// Get distance from last click point in each axis // Get distance from last click point in each axis
float dX = (float)x - lastClickX; float dX = static_cast<float>(x) - lastClickX;
float dY = (float)y - lastClickY; float dY = static_cast<float>(y) - lastClickY;
float dZ = (float)z - lastClickZ; float dZ = static_cast<float>(z) - lastClickZ;
bool newClick = false; bool newClick = false;
float ddx = dX - lastClickdX; float ddx = dX - lastClickdX;
@ -1454,9 +1455,9 @@ bool LocalPlayer::creativeModeHandleMouseClick(int button, bool buttonPressed)
else else
{ {
// First click - just record position & handle // First click - just record position & handle
lastClickX = (float)x; lastClickX = static_cast<float>(x);
lastClickY = (float)y; lastClickY = static_cast<float>(y);
lastClickZ = (float)z; lastClickZ = static_cast<float>(z);
// If we actually placed an item, then move into the init state as we are going to be doing the special creative mode auto repeat // If we actually placed an item, then move into the init state as we are going to be doing the special creative mode auto repeat
bool itemPlaced = handleMouseClick(button); bool itemPlaced = handleMouseClick(button);
// If we're sprinting or riding, don't auto-repeat at all. With auto repeat on, we can quickly place fires causing photosensitivity issues due to rapid flashing // If we're sprinting or riding, don't auto-repeat at all. With auto repeat on, we can quickly place fires causing photosensitivity issues due to rapid flashing
@ -1504,7 +1505,7 @@ bool LocalPlayer::handleMouseClick(int button)
// 4J-PB - Adding a special case in here for sleeping in a bed in a multiplayer game - we need to wake up, and we don't have the inbedchatscreen with a button // 4J-PB - Adding a special case in here for sleeping in a bed in a multiplayer game - we need to wake up, and we don't have the inbedchatscreen with a button
if(button==1 && (isSleeping() && level != NULL && level->isClientSide)) if(button==1 && (isSleeping() && level != nullptr && level->isClientSide))
{ {
if(lastClickState == lastClick_oldRepeat) return false; if(lastClickState == lastClick_oldRepeat) return false;
@ -1515,14 +1516,14 @@ bool LocalPlayer::handleMouseClick(int button)
} }
// 4J Stu - We should not accept any input while asleep, except the above to wake up // 4J Stu - We should not accept any input while asleep, except the above to wake up
if(isSleeping() && level != NULL && level->isClientSide) if(isSleeping() && level != nullptr && level->isClientSide)
{ {
return false; return false;
} }
shared_ptr<ItemInstance> oldItem = inventory->getSelected(); shared_ptr<ItemInstance> oldItem = inventory->getSelected();
if (minecraft->hitResult == NULL) if (minecraft->hitResult == nullptr)
{ {
if (button == 0 && minecraft->localgameModes[GetXboxPad()]->hasMissTime()) missTime = 10; if (button == 0 && minecraft->localgameModes[GetXboxPad()]->hasMissTime()) missTime = 10;
} }
@ -1573,7 +1574,7 @@ bool LocalPlayer::handleMouseClick(int button)
else else
{ {
shared_ptr<ItemInstance> item = oldItem; shared_ptr<ItemInstance> item = oldItem;
int oldCount = item != NULL ? item->count : 0; int oldCount = item != nullptr ? item->count : 0;
bool usedItem = false; bool usedItem = false;
if (minecraft->gameMode->useItemOn(minecraft->localplayers[GetXboxPad()], level, item, x, y, z, face, minecraft->hitResult->pos, false, &usedItem)) if (minecraft->gameMode->useItemOn(minecraft->localplayers[GetXboxPad()], level, item, x, y, z, face, minecraft->hitResult->pos, false, &usedItem))
{ {
@ -1586,7 +1587,7 @@ bool LocalPlayer::handleMouseClick(int button)
//app.DebugPrintf("Player %d is swinging\n",GetXboxPad()); //app.DebugPrintf("Player %d is swinging\n",GetXboxPad());
swing(); swing();
} }
if (item == NULL) if (item == nullptr)
{ {
return false; return false;
} }
@ -1605,7 +1606,7 @@ bool LocalPlayer::handleMouseClick(int button)
if (mayUse && button == 1) if (mayUse && button == 1)
{ {
shared_ptr<ItemInstance> item = inventory->getSelected(); shared_ptr<ItemInstance> item = inventory->getSelected();
if (item != NULL) if (item != nullptr)
{ {
if (minecraft->gameMode->useItem(minecraft->localplayers[GetXboxPad()], level, item)) if (minecraft->gameMode->useItem(minecraft->localplayers[GetXboxPad()], level, item))
{ {
@ -1621,23 +1622,23 @@ void LocalPlayer::updateRichPresence()
if((m_iPad!=-1)/* && !ui.GetMenuDisplayed(m_iPad)*/ ) if((m_iPad!=-1)/* && !ui.GetMenuDisplayed(m_iPad)*/ )
{ {
shared_ptr<ItemInstance> selectedItem = inventory->getSelected(); shared_ptr<ItemInstance> selectedItem = inventory->getSelected();
if(selectedItem != NULL && selectedItem->id == Item::fishingRod_Id) if(selectedItem != nullptr && selectedItem->id == Item::fishingRod_Id)
{ {
app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_FISHING); app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_FISHING);
} }
else if(selectedItem != NULL && selectedItem->id == Item::map_Id) else if(selectedItem != nullptr && selectedItem->id == Item::map_Id)
{ {
app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_MAP); app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_MAP);
} }
else if ( (riding != NULL) && riding->instanceof(eTYPE_MINECART) ) else if ( (riding != nullptr) && riding->instanceof(eTYPE_MINECART) )
{ {
app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_RIDING_MINECART); app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_RIDING_MINECART);
} }
else if ( (riding != NULL) && riding->instanceof(eTYPE_BOAT) ) else if ( (riding != nullptr) && riding->instanceof(eTYPE_BOAT) )
{ {
app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_BOATING); app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_BOATING);
} }
else if ( (riding != NULL) && riding->instanceof(eTYPE_PIG) ) else if ( (riding != nullptr) && riding->instanceof(eTYPE_PIG) )
{ {
app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_RIDING_PIG); app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_RIDING_PIG);
} }
@ -1678,13 +1679,13 @@ float LocalPlayer::getAndResetChangeDimensionTimer()
void LocalPlayer::handleCollectItem(shared_ptr<ItemInstance> item) void LocalPlayer::handleCollectItem(shared_ptr<ItemInstance> item)
{ {
if(item != NULL) if(item != nullptr)
{ {
unsigned int itemCountAnyAux = 0; unsigned int itemCountAnyAux = 0;
unsigned int itemCountThisAux = 0; unsigned int itemCountThisAux = 0;
for (unsigned int k = 0; k < inventory->items.length; ++k) for (unsigned int k = 0; k < inventory->items.length; ++k)
{ {
if (inventory->items[k] != NULL) if (inventory->items[k] != nullptr)
{ {
// do they have the item // do they have the item
if(inventory->items[k]->id == item->id) if(inventory->items[k]->id == item->id)
@ -1700,7 +1701,7 @@ void LocalPlayer::handleCollectItem(shared_ptr<ItemInstance> item)
} }
} }
} }
TutorialMode *gameMode = (TutorialMode *)minecraft->localgameModes[m_iPad]; TutorialMode *gameMode = static_cast<TutorialMode *>(minecraft->localgameModes[m_iPad]);
gameMode->getTutorial()->onTake(item, itemCountAnyAux, itemCountThisAux); gameMode->getTutorial()->onTake(item, itemCountAnyAux, itemCountThisAux);
} }