Skip to content

Conversation

@Skyaero42
Copy link

@Skyaero42 Skyaero42 commented Sep 4, 2025

@Skyaero42 Skyaero42 force-pushed the refractor/strncpy branch 4 times, most recently from 1b26f0d to 863e100 Compare September 4, 2025 07:48
@xezon
Copy link

xezon commented Sep 4, 2025

"Partially resolves" means merging this change will close the issue.

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

This needs another pass. strncpy was not correctly substituted at many places.

@helmutbuhler
Copy link

The Replay Checker crashes with this:
GetStringFromRegistry - looking in SOFTWARE\Electronic Arts\EA Games\General for key InstallPat
Looks like the last character is deleted.

@Skyaero42 Skyaero42 marked this pull request as draft September 6, 2025 18:03
@Skyaero42 Skyaero42 self-assigned this Sep 6, 2025
@Skyaero42 Skyaero42 added the Refactor Edits the code with insignificant behavior changes, is never user facing label Sep 6, 2025
@Skyaero42 Skyaero42 marked this pull request as ready for review September 6, 2025 18:20
@Skyaero42 Skyaero42 requested a review from xezon September 7, 2025 18:39
@xezon xezon changed the title refactor: Replacing strncpy with strlcpy fix: Replace strncpy with strlcpy for robustness Sep 8, 2025
@xezon xezon added this to the Stability fixes milestone Sep 8, 2025
@xezon xezon added Fix Is fixing something, but is not user facing Minor Severity: Minor < Major < Critical < Blocker labels Sep 8, 2025
Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

I think the lengths need another review pass.

@Skyaero42 Skyaero42 force-pushed the refractor/strncpy branch 3 times, most recently from 18edc27 to bad3f0f Compare September 15, 2025 19:35
nameLen=strlen(shadowInfo->m_ShadowName);
if (nameLen <= 1) //no texture name given, use same as object
{ strcpy(texture_name,defaultDecalName);
if (strlen(shadowInfo->m_ShadowName) <= 1) //no texture name given, use same as object
Copy link

Choose a reason for hiding this comment

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

I expect we can simplify this to if (shadowInfo->m_ShadowName[0] == '\0') without any change in functionality.

Copy link
Author

Choose a reason for hiding this comment

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

If I understand C-strings correctly:

m_ShadowName[0] = 'a';
m_ShadowName[1] = '\0';

This represents a string of length 1. In that case, strlen(m_ShadowName) returns 1, so the original condition strlen(...) <= 1 would evaluate to true.

The null terminator is at index [1], not [0]. So checking only m_ShadowName[0] == '\0' is not equivalent — it would only detect the empty string (""), not a one-character string.

So at the moment the game does not allow texture names of 1 character. I don't know if that is intentional, or that this comparison is bugged.

Copy link

Choose a reason for hiding this comment

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

Yes it is odd comparison. One would expect strlen(shadowInfo->m_ShadowName) == 0 or strlen(shadowInfo->m_ShadowName) < 1. I suspect that was the intention.

You can run the game with a break point for if (strlen(shadowInfo->m_ShadowName) == 1) and see if that ever hits. If it never hits, I do not think we need to care for it.

@Skyaero42
Copy link
Author

Skyaero42 commented Sep 30, 2025

Something is off and it is caused by this PR.

Spy satelite / spy drone have a similar issue

image

@xezon
Copy link

xezon commented Sep 30, 2025

Looks shadow decal related

@Skyaero42
Copy link
Author

Made another pass

  • rebased onto latest main
  • debug/breakpoint on all statement to verify the correct copy. Unfortunately I couldn't trigger all statements - some functions may not be in use anymore
  • Applied a few fixes (in particular the shadow decal)

Game looks and runs well. I think this is (finally) it.

@xezon xezon added Stability Concerns stability of the runtime and removed Fix Is fixing something, but is not user facing labels Oct 12, 2025
@xezon
Copy link

xezon commented Oct 15, 2025

Is this fully replicated in Generals?

@Skyaero42
Copy link
Author

Is this fully replicated in Generals?

Yes it is

@xezon xezon merged commit 630f6df into TheSuperHackers:main Oct 15, 2025
17 checks passed
fbraz3 pushed a commit to fbraz3/GeneralsX that referenced this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing Stability Concerns stability of the runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants