Project modernization (#630)

* Fixed boats falling and a TP glitch #266

* Replaced every C-style cast with C++ ones

* Replaced every C-style cast with C++ ones

* Fixed boats falling and a TP glitch #266

* Updated NULL to nullptr and fixing some type issues

* Modernized and fixed a few bugs

- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.

* Fixing more conflicts

* Replace int loops with size_t and start work on overrides
This commit is contained in:
ModMaker101
2026-03-07 21:56:03 -05:00
committed by GitHub
parent 1be5faaea7
commit a9be52c41a
1373 changed files with 19903 additions and 19449 deletions

View File

@@ -28,7 +28,7 @@ bool BucketItem::TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, sh
{
bool pickLiquid = content == 0;
HitResult *hr = getPlayerPOVHitResult(level, player, pickLiquid);
if (hr == NULL) return false;
if (hr == nullptr) return false;
if (hr->type == HitResult::TILE)
{
@@ -105,7 +105,7 @@ shared_ptr<ItemInstance> BucketItem::use(shared_ptr<ItemInstance> itemInstance,
bool pickLiquid = content == 0;
HitResult *hr = getPlayerPOVHitResult(level, player, pickLiquid);
if (hr == NULL) return itemInstance;
if (hr == nullptr) return itemInstance;
if (hr->type == HitResult::TILE)
{
@@ -117,10 +117,10 @@ shared_ptr<ItemInstance> BucketItem::use(shared_ptr<ItemInstance> itemInstance,
{
app.DebugPrintf("!!!!!!!!!!! Can't place that here\n");
shared_ptr<ServerPlayer> servPlayer = dynamic_pointer_cast<ServerPlayer>(player);
if( servPlayer != NULL )
if( servPlayer != nullptr )
{
app.DebugPrintf("Sending ChatPacket::e_ChatCannotPlaceLava to player\n");
servPlayer->connection->send( shared_ptr<ChatPacket>( new ChatPacket(L"", ChatPacket::e_ChatCannotPlaceLava ) ) );
servPlayer->connection->send(std::make_shared<ChatPacket>(L"", ChatPacket::e_ChatCannotPlaceLava));
}
delete hr;
@@ -141,13 +141,13 @@ shared_ptr<ItemInstance> BucketItem::use(shared_ptr<ItemInstance> itemInstance,
if (--itemInstance->count <= 0)
{
return shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_water) );
return std::make_shared<ItemInstance>(Item::bucket_water);
}
else
{
if (!player->inventory->add(shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_water))))
if (!player->inventory->add(std::make_shared<ItemInstance>(Item::bucket_water)))
{
player->drop(shared_ptr<ItemInstance>(new ItemInstance(Item::bucket_water_Id, 1, 0)));
player->drop(std::make_shared<ItemInstance>(Item::bucket_water_Id, 1, 0));
}
return itemInstance;
}
@@ -168,13 +168,13 @@ shared_ptr<ItemInstance> BucketItem::use(shared_ptr<ItemInstance> itemInstance,
}
if (--itemInstance->count <= 0)
{
return shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_lava) );
return std::make_shared<ItemInstance>(Item::bucket_lava);
}
else
{
if (!player->inventory->add(shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_lava))))
if (!player->inventory->add(std::make_shared<ItemInstance>(Item::bucket_lava)))
{
player->drop(shared_ptr<ItemInstance>(new ItemInstance(Item::bucket_lava_Id, 1, 0)));
player->drop(std::make_shared<ItemInstance>(Item::bucket_lava_Id, 1, 0));
}
return itemInstance;
}
@@ -183,7 +183,7 @@ shared_ptr<ItemInstance> BucketItem::use(shared_ptr<ItemInstance> itemInstance,
else if (content < 0)
{
delete hr;
return shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_empty) );
return std::make_shared<ItemInstance>(Item::bucket_empty);
}
else
{
@@ -199,7 +199,7 @@ shared_ptr<ItemInstance> BucketItem::use(shared_ptr<ItemInstance> itemInstance,
if (emptyBucket(level, xt, yt, zt) && !player->abilities.instabuild)
{
return shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_empty) );
return std::make_shared<ItemInstance>(Item::bucket_empty);
}
}