Skip to content

[Fix] Add trader/buyer cleanup actions#4843

Merged
Akkadius merged 2 commits intoEQEmu:masterfrom
neckkola:Fix_AddTraderBuyerConstraints
May 15, 2025
Merged

[Fix] Add trader/buyer cleanup actions#4843
Akkadius merged 2 commits intoEQEmu:masterfrom
neckkola:Fix_AddTraderBuyerConstraints

Conversation

@neckkola
Copy link
Copy Markdown
Contributor

@neckkola neckkola commented Apr 5, 2025

Cleanup several compiler warnings

Description

There have been some reports of trader/buyer tables with erroneous entries when a bazaar instance crashes, or an active trader
is ported. In reviewing, several updates have been added to protect from various scenarios.

Add trader/buyer db cleanup for

  • on zone idle
  • on client first login
  • when world drops a zone connection
  • in Client::ProcessMovePC

Also made a few compiler warning updates.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Testing

Tested with various combos of db entires and zone idle, crash, client crash, etc

Clients tested:
RoF2

Checklist

  • I have tested my changes
  • I have performed a self-review of my code. Ensuring variables, functions and methods are named in a human-readable way, comments are added only where naming of variables, functions and methods can't give enough context.
  • I own the changes of my code and take responsibility for the potential issues that occur

Add trader/buyer db cleanup for
- on zone idle
- on client first login
- when world drops a zone connection
- in Client::ProcessMovePC

Cleanup several compiler warnings
Comment on lines +88 to +100
auto port = (*iter)->GetCPort();
auto zone_id = (*iter)->GetZoneID();
auto instance_id = (*iter)->GetInstanceID();
if (zone_id == Zones::BAZAAR) {
TraderRepository::DeleteWhere(
database,
fmt::format("`char_zone_id` = '{}' AND `char_zone_instance_id` = '{}'", zone_id, instance_id)
);
BuyerRepository::DeleteBuyers(database, zone_id, instance_id);

LogTradingDetail("Removed trader abd buyer entries for Zone ID {} and Instance ID {}", zone_id, instance_id);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make a function that takes in the ZS as input and performs this action if Bazaar?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

zone/trading.cpp Outdated
Comment on lines +1561 to +1564
auto outapp = std::make_unique<EQApplicationPacket>(
OP_BazaarSearch,
static_cast<uint32>(sizeof(BazaarWelcome_Struct))
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

zone/zoning.cpp Outdated

// Added to ensure that if a player is moved (ported, gmmove, etc) and they are an active trader or buyer, they will
// be removed from future transactions.
if(IsTrader()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(IsTrader()) { vs if (IsTrader()) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

zone/zoning.cpp Outdated
TraderEndTrader();
}

if(IsBuyer()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(IsBuyer()) { vs if (IsBuyer()) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@neckkola
Copy link
Copy Markdown
Contributor Author

Thanks for the comments Akk. My formatting was clearly lost. Updated and fixed up my auto formatting.

@Akkadius Akkadius merged commit 1221e88 into EQEmu:master May 15, 2025
1 check passed
@Akkadius Akkadius mentioned this pull request May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants