Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix game report OS version on Windows & Android #30841

Merged
merged 2 commits into from
May 26, 2019
Merged

Fix game report OS version on Windows & Android #30841

merged 2 commits into from
May 26, 2019

Conversation

neitsa
Copy link
Contributor

@neitsa neitsa commented May 25, 2019

Summary

SUMMARY: Bugfixes "Fix game report OS version on Windows & Android"

Purpose of change

Follow up for PR #30729 (added precise system versions in the game report).

  • Move the "bitness" report next to the game version, as it seems to have confused some players.

    • the "bitness" (32 or 64-bit) is the one from the game, not the one of the OS. This introduce some confusion for people running the 32-bit version of the game on a 64-bit OS.
  • Fix a null byte problem on Windows (and possibly Android).


Given this BYTE (unsigned char) buffer:

        constexpr DWORD c_buffer_size = 512;
        std::vector<BYTE> byte_buffer( c_buffer_size );

And its conversion to string:

                output.append( std::string( byte_buffer.begin(), byte_buffer.end() ) );

It is possible that, if the byte buffer contains non-null characters after null characters, the null characters are still embedded in the string.

e.g. given a byte buffer with foo\0\0\0ABC\0 you still get the null characters in the output string. I didn't see this behavior during my previous tests but it happened today while I was trying to unstack another bug.

Describe the solution

Use:

  • std::string( reinterpret_cast<char *>( byte_buffer.data() )

Rather than:

  • std::string( byte_buffer.begin(), byte_buffer.end() )

Describe alternatives you've considered

N/A.

Additional context

Test results:

- OS: Windows
    - OS Version: 10.0 1809
- Game Version: 0.D-3479-g323318274f-dirty [64-bit]
- Graphics Version: Tiles
- Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Filthy Clothing [filthy_morale],
    Icecoon's Arsenal [ew_pack],
    Medieval and Historic Content [Medieval_Stuff],
    More Survival Tools [More_Survival_Tools],
    Folding Parts pack [deoxymod],
    Vehicle Additions Pack [blazemod],
    Tanks and Other Vehicles [Tanks],
    Classes and Scenarios Mod [more_classes_scenarios],
    Simplified Nutrition [novitamins],
    StatsThroughSkills [StatsThroughSkills]
]

@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` labels May 26, 2019
@ZhilkinSerg ZhilkinSerg merged commit 42b10b8 into CleverRaven:master May 26, 2019
@neitsa neitsa deleted the fix/game_report branch May 26, 2019 13:30
@jbytheway
Copy link
Contributor

You could avoid a reinterpret_cast by using e.g. std::find to locate the first zero byte in the vector. Should be fairly neat code. Not a big issue, though.

@neitsa
Copy link
Contributor Author

neitsa commented May 27, 2019

Oh, right! I didn't think about that, the first thing that came to my mind was using .data() rather than searching for the first null byte. I'll see to make this patch soon. Thanks a lot for your suggestion jbytheway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants