server icon indicating copy to clipboard operation
server copied to clipboard

[CPP] Fix error on zone when naked

Open ampitere opened this issue 9 months ago • 3 comments

I affirm:

  • [x] I understand that if I do not agree to the following points by completing the checkboxes my PR will be ignored.
  • [x] I understand I should leave resolving conversations to the LandSandBoat team so that reviewers won't miss what was said.
  • [x] I have read and understood the Contributing Guide and the Code of Conduct.
  • [x] I have tested my code and the things my code has changed since the last commit in the PR and will test after any later commits.

What does this pull request do?

Adds a check to prevent reporting an error if a character is naked and has no equipment to load. Resolves https://github.com/LandSandBoat/server/issues/5702

Steps to test these changes

  1. Unequip everything
  2. Zone
  3. Error shouldn't appear

ampitere avatar May 13 '24 02:05 ampitere

checking if you're naked here really is a no-op, this happens on CCharEntity construction when being put into the world, the intent of that error message appears to be checking for if the query failed, but apparently literally zero equipment will trip the false positive here

WinterSolstice8 avatar May 13 '24 03:05 WinterSolstice8

checking if you're naked here really is a no-op, this happens on CCharEntity construction when being put into the world, the intent of that error message appears to be checking for if the query failed, but apparently literally zero equipment will trip the false positive here

Do we need this error if db::preparedStmt is already reporting errors if it runs into them? It will show if the query failed and give the query so having both errors seems a bit redundant to me.

I'm not sure what else we can check for if db::preparedStmt fails gracefully and returns no results but also returns no results when a player is naked.

ampitere avatar May 13 '24 05:05 ampitere

Will wait for some input on Zach but I think if that is the case then we just don't need to log the error at all.

WinterSolstice8 avatar May 13 '24 05:05 WinterSolstice8

What did the code look like before my refactor?

zach2good avatar May 14 '24 22:05 zach2good

Gut feeling is that log message added with the nuking of XI_DEBUG_BREAK_IF (and oops to editing Zach's comment instead of adding this)

claywar avatar May 14 '24 22:05 claywar

What did the code look like before my refactor?

The if was previously if (ret != SQL_ERROR). The error was touched 3 years ago but was just cleanup.

ampitere avatar May 15 '24 00:05 ampitere

In which case none of this is really needed to match what was there before. This:

auto rset = db::preparedStmt(Query, PChar->id);
if (rset && rset->rowsCount())

Can/should become:

auto rset = db::preparedStmt(Query, PChar->id);
if (rset)

ie. "The query didn't fail" rather than "The query didn't fail AND there are rows of results" etc.

zach2good avatar May 15 '24 18:05 zach2good

In which case none of this is really needed to match what was there before. This:

auto rset = db::preparedStmt(Query, PChar->id);
if (rset && rset->rowsCount())

Can/should become:

auto rset = db::preparedStmt(Query, PChar->id);
if (rset)

ie. "The query didn't fail" rather than "The query didn't fail AND there are rows of results" etc.

Changed to if (rset).

ampitere avatar May 15 '24 19:05 ampitere

Presumably you've tested it and it works?

zach2good avatar May 15 '24 19:05 zach2good

Presumably you've tested it and it works?

Works perfectly, yes.

ampitere avatar May 15 '24 19:05 ampitere