Skip to content

Fix build warnings#370

Merged
Mosch0512 merged 4 commits intosven-n:mainfrom
Mosch0512:fix-build-warnings
May 8, 2026
Merged

Fix build warnings#370
Mosch0512 merged 4 commits intosven-n:mainfrom
Mosch0512:fix-build-warnings

Conversation

@Mosch0512
Copy link
Copy Markdown
Collaborator

Handling the build warnings from our action workflows :D

Mosch0512 added 2 commits May 8, 2026 23:18
Mechanical fixes across 62 files to clear C++20-deprecation, NULL-misuse, and
miscellaneous warnings flagged by the i686-w64-mingw32 GCC 13 build:

- _struct.h, WSclient.h: drop trailing tokens after #endif; switch memset
  fill values from NULL to 0 (these two headers alone accounted for ~1500
  warnings before).
- 158 NULL-as-int sites converted to 0 (or L'\0' for wchar_t) at compiler-
  flagged lines only.
- 218 deprecated enum+enum arithmetic sites wrapped with static_cast<int>(...)
  on the unnamed-enum operand (MODEL_TYPE_CHARM_MIXWING + EWS_*,
  MODEL_BODY_* + c->SkinIndex, MODEL_X - MODEL_ITEM, etc).
- 9 trailing #endif tokens in GameShop/MsgBoxIGS*.cpp.
- 3 narrowing conversions in POINT/SIZE/RECT brace-initializers.
- 3 enum-compare sites cast to int.
- 6 BYTE-typed switches with negative case literals (-1, -2) → 255, 254.
- 5 delete-of-void* sites cast to the concrete pointer type before delete
  (xstreambuf BYTE*, CSParts CSIPartsMDL*).
- 1 VLA-style `new (T[n])` → `new T[n]` (UIMng.cpp).
- Stray `]` after #include in ZzzEffect.cpp.
- Redundant `extern` on a definition in UIGuildInfo.cpp.
- `#pragma once` removed from main-file .cpp's (NewUIGroup, NewUITextBox).
- stdafx.h: NOMINMAX guarded with #ifndef so libstdc++ pre-define no longer
  produces a redefine warning.

Six warnings remain — all flag real bugs that need human review rather than
mechanical changes:
  TextureScript.cpp:58,63    case 'DC'/'DT' on a single-char switch (dead code)
  ZzzInterface.cpp:3883      'and' of mutually exclusive equal-tests is always 0
  UIWindows.cpp:4215         delete on pointer to a range-for copy member (UB)

Verified locally with the same toolchain CI uses (i686-w64-mingw32, Ninja,
Release, BUILD_TESTING=OFF). Build links cleanly; final warning count: 6.
Each was a real bug rather than a style nit; mechanical "silence the
warning" fixes weren't appropriate.

ZzzInterface.cpp:3311-3312 (-Wlogical-op-parentheses-equivalent: 'and' of
mutually exclusive equal-tests is always 0)
  The block at line 3308 filters by `CurrentAction` range while excluding
  specific values via `!=`.  The two final clauses used `==` against
  PLAYER_FENRIR_SKILL_ONE_RIGHT and PLAYER_RAGE_FENRIR_ONE_RIGHT, making the
  whole condition unsatisfiable (CurrentAction can't equal two values at
  once) and the guarded `break` permanently dead.  Surrounding pattern shows
  the intent was to *exclude* those Fenrir actions from the range check, so
  the operators are flipped to `!=`.

TextureScript.cpp:58-66 (-Wmultichar + -Wswitch-outside-range)
  `switch (strTokenFile[i])` is over a single `char`; cases `'DC'` and `'DT'`
  are multi-character constants that can never match a `char` value.  Pure
  dead code — removed the two `case` blocks; no behavior change.

UIWindows.cpp:4204-4218 (-Wfree-nonheap-object)
  CLetterList::ClearLetterTextCache iterated the m_LetterCache map by value
  copy and called `delete &cachedLetter.second` on a stack-local POD copy —
  undefined behavior.  RemoveLetterTextCache had the same UB pattern via an
  iterator into the map's internal storage; the compiler missed it because
  the iterator's lifetime is fuzzier, but it's equally invalid.

  FS_LETTER_TEXT is a POD with no owning members, and m_LetterCache stores
  values directly (std::map<DWORD, FS_LETTER_TEXT>), so destruction is
  handled correctly by std::map::erase / std::map::clear.  Both `delete`
  calls removed (the local `letter` variables become unused and are dropped).

Final warning count: 0.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on resolving various build warnings that have accumulated in the project. The changes involve type safety improvements, such as explicit casting for enum arithmetic, and code modernization, including the replacement of null pointer constants and the use of safer memory management practices. These adjustments improve code stability and ensure compliance with modern C++ standards.

Highlights

  • Build Warning Fixes: Addressed numerous compiler warnings across the codebase, primarily by adding explicit static_casts for type conversions and fixing incorrect macro usage.
  • Code Cleanup: Replaced deprecated or incorrect NULL usage with 0 or nullptr, and corrected preprocessor directive syntax.
  • Memory Management: Updated manual memory management patterns, including replacing C-style arrays with std::vector in UIMng.cpp and improving object deletion safety.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements widespread code cleanup and modernization, focusing on type safety with static_cast, correcting string comparison logic, and replacing NULL with 0 or nullptr. It also improves memory management by using std::vector and cleans up preprocessor directives. Feedback identifies a high-severity bug in WSclient.cpp where wchar_t buffers are incorrectly handled with byte-based memset and memcpy, potentially leading to undefined behavior. Additionally, a regression was noted regarding the removal of action-checking logic which disables attack debouncing; the reviewer recommends implementing the suggested include list of animations to properly maintain functionality.

Comment thread src/source/WSclient.cpp Outdated
Comment thread src/source/ZzzInterface.cpp
The loop walked GuildMark[] looking for the rival guild's index, but
built its comparison key by copy/casting raw wire bytes:

    wchar_t Temp[8 + 1];
    memset(Temp, 0, 8);                       // 8 bytes = 4 wchar_t (of 9)
    memcpy(Temp, (wchar_t*)Data->Name, 8);    // UTF-8 bytes punned as wide
    Temp[8] = 0;
    if (wcscmp(p->GuildName, Temp) == 0)

Two bugs stacked: Data->Name is char[8] of UTF-8 (every other call site
goes through CMultiLanguage::ConvertFromUtf8 - see line 7445), so the
wchar_t* cast pairs adjacent UTF-8 bytes into wide-char gibberish; and
the byte counts on memset/memcpy are wchar-count-times-2 short of the
buffer's 18 bytes, leaving slots 4-7 uninitialized.

ConvertFromUtf8 already populates GuildWarName from Data->Name 19 lines
above, and nothing mutates GuildWarName before the loop. Drop the broken
local Temp rebuild and compare against GuildWarName directly.

Effect: GuildWarIndex now actually gets set when the war target matches
a player's guild-mark slot. Previously this loop's matches were
non-deterministic at best; the renderer was relying on the working
FindGuildName(GuildWarName) path at line 426 to set GuildWarIndex.
Comment thread src/source/TextureScript.cpp
The wchar_t-string variant of the texture-script parser had zero callers
across the codebase (grep -rn '\bparsingTScript\b' returned only the
definition and the header declaration). Only parsingTScriptA(char*) is
ever invoked - by ZzzBMD.cpp:2834 (BMD load) and SMD2BMD.cpp:235 (model
converter), both of which pass char-string texture names from BMD blobs.

The deleted wchar_t function also had a latent fall-through bug that
would never have surfaced in production because it was never called:
its `case L'D':` branch handled L'C' / L'T' lookahead correctly, but the
loop's next iteration saw the consumed character (L'C' or L'T'), hit the
`default:` arm, set m_bBeScript = false, and returned. Anyone reviving
this would need to advance `i` inside the D case in addition to wiring
up callers.

Removes 73 lines of code that compiled but couldn't run, ran but
couldn't return success, and could-have-returned but no asset asks for
it.
@Mosch0512 Mosch0512 merged commit d518a50 into sven-n:main May 8, 2026
1 check passed
@Mosch0512 Mosch0512 deleted the fix-build-warnings branch May 10, 2026 04:19
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.

1 participant