-
Notifications
You must be signed in to change notification settings - Fork 48
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
[GEN][ZH] Fix incorrect AsciiString hash implementation for non-stlport #450
Conversation
Example error messages:
|
size_t operator()(const AsciiString& ast) const | ||
{ | ||
#ifdef USING_STLPORT | ||
std::hash<const char *> tmp; | ||
return tmp((const char *) ast.str()); | ||
#else | ||
// TheSuperHackers @bugfix xezon 16/03/2024 std::hash implementation for STLPort does not work here. | ||
// Use string view to capture c string and pass that to the hash function. No allocation. | ||
std::hash<std::string_view> hasher; | ||
return hasher(std::string_view(ast.str(), ast.getLength())); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change corrects the ASCII string parsing and fixes the behaviour.
std::string_view
creates a C string out of the ascii string that the std::hash
hasher can make use of.
I have applied this change and the game launches without the ini parsing issues any longer as explained in #491. It crashes during the game but I am unsure whether that is related to this. |
You also have to apply the Asm fix in #479 as the original Asm causes runtime problems at random. But this fix corrects the ini failures. |
b23474e
to
82200aa
Compare
Fix for Generals replicated. Comment simplified. To be merged after VS2022 CI. |
Shouldn't the Generals version also pass a cost reference? Matches the ZH version for completeness then. |
Oh right. I did not copy that over properly. |
6ab582a
to
54fa62d
Compare
Fixed. |
54fa62d
to
a7670ae
Compare
This error causes the game to crash early with non-stlport builds. The reason is that the hash impl for stlport does not work with the standard/new std::hash.