Skip to content

Conversation

@DealsBeam
Copy link

The player's wielded item was previously hardcoded to always come from the "main" inventory list. This limited the flexibility for mods or future game features that might require a different inventory setup for wieldable items.

This change introduces a new member variable, m_wield_list_name, to the Player class, allowing the wield inventory list to be specified dynamically.

  • The m_wield_list_name is initialized to "main" to ensure backward compatibility with existing behavior.
  • The getWieldedItem, setWieldIndex, and getMaxHotbarItemcount functions were updated to use this new variable instead of the hardcoded "main" string.
  • Added setWieldListName and getWieldListName methods to manage the new variable.
  • A new unit test has been added to verify that items can be wielded from a custom-named inventory list.

google-labs-jules bot and others added 6 commits October 14, 2025 02:46
**Findings:**
- A persistent build failure, caused by a segmentation fault during the compilation of `jsoncpp`, prevented the execution of static analysis and unit tests.
- Manual code review of critical files (`main.cpp`, `server.cpp`, network stack, Lua API) revealed that the code is generally well-structured and follows good security practices.
- Identified areas for improvement in input validation within the Lua API, command-line argument parsing, and network command handling.

**Recommendations:**
- Prioritize resolving the `jsoncpp` build failure to enable automated testing and static analysis.
- Enhance input validation in the Lua API, particularly for functions that accept player names and positions.
- Improve the robustness of command-line argument parsing and network command handling.
Proactive Code Audit and Build Issue Analysis
The player's wielded item was previously hardcoded to always come from the "main" inventory list. This limited the flexibility for mods or future game features that might require a different inventory setup for wieldable items.

This change introduces a new member variable, `m_wield_list_name`, to the `Player` class, allowing the wield inventory list to be specified dynamically.

- The `m_wield_list_name` is initialized to "main" to ensure backward compatibility with existing behavior.
- The `getWieldedItem`, `setWieldIndex`, and `getMaxHotbarItemcount` functions were updated to use this new variable instead of the hardcoded "main" string.
- Added `setWieldListName` and `getWieldListName` methods to manage the new variable.
- A new unit test has been added to verify that items can be wielded from a custom-named inventory list.
The player's wielded item was previously hardcoded to always come from the "main" inventory list. This limited the flexibility for mods or future game features that might require a different inventory setup for wieldable items.

This change introduces a new member variable, `m_wield_list_name`, to the `Player` class, allowing the wield inventory list to be specified dynamically.

- The `m_wield_list_name` is initialized to "main" to ensure backward compatibility with existing behavior.
- The `getWieldedItem`, `setWieldIndex`, and `getMaxHotbarItemcount` functions were updated to use this new variable instead of the hardcoded "main" string.
- Added `setWieldListName` and `getWieldListName` methods to manage the new variable.
- A new unit test has been added to verify that items can be wielded from a custom-named inventory list.
The player's wielded item was previously hardcoded to always come from the "main" inventory list. This limited the flexibility for mods or future game features that might require a different inventory setup for wieldable items.

This change introduces a new member variable, `m_wield_list_name`, to the `Player` class, allowing the wield inventory list to be specified dynamically.

- The `m_wield_list_name` is initialized to "main" to ensure backward compatibility with existing behavior.
- The `getWieldedItem`, `setWieldIndex`, and `getMaxHotbarItemcount` functions were updated to use this new variable instead of the hardcoded "main" string.
- Added `setWieldListName` and `getWieldListName` methods to manage the new variable.
- A new unit test has been added to verify that items can be wielded from a custom-named inventory list.
@SmallJoker
Copy link
Member

Closely related: #15905. That PR also de-hardcodes the main inventory list, and allows combining multiple inventory lists into the same hotbar.

@cx384
Copy link
Contributor

cx384 commented Oct 30, 2025

I would rather de-hardcode it all at once, "main" list, index offset, and combining multiple inventories, like #15905 does.
Also, we don't really need a new member variable with setters and getters if it stays constant anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants