-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[APctl] Fix stuck issue when scanning AP to Recruit on MGS:PW #14345
Conversation
9fd40c7
to
dac94ee
Compare
Core/HLE/sceNet.cpp
Outdated
char dummyMAC[ETHER_ADDR_LEN]; | ||
memset(&dummyMAC, entryId, sizeof(dummyMAC)); |
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.
Nitpick, but char dummyMAC[ETHER_ADDR_LEN] {};
will yield the same result without an explicit memset.
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.
Ah i forgot we can memset it using {x} to initialize it >.<
Edit: hmm.. using { entryId }
without type casting it will get this warning warning C4838: conversion from 'int' to 'char' requires a narrowing conversion
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.
I think CookiePLMonster thought you were zero-initializing it, in which case it would have worked.
You can remove the & sign though, leaving memset(dummyMAC, entryId, sizeof(dummyMAC));
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.
ah right, if i wanted to use &
i need to explicitly pointing it to the first char like &dummy[0]
Core/HLE/sceNet.cpp
Outdated
Memory::WriteStruct(resultAddr, &netApctlInfo.strength); | ||
else { | ||
// Randomize signal strength between 1%~99% since games like MGS:PW are using signal strength to determine the strength of the recruit | ||
Memory::Write_U8(rand()*99 + 1, resultAddr); |
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.
rand()*99+1 will not do what you think. rand() returns very large integer numbers, so the only thing limiting here is that you just write a byte.
Probably not worth messing with a better random generator here, so the "right" way to do this with rand() should be something like:
(int)(((float)rand()/(float)RAND_MAX)) * 99.0 + 1.0)
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.
Ah you're right, i was taking the code example from here https://www.cplusplus.com/reference/cstdlib/rand/
And it should be rand() % 99
instead of rand()*99
>.< i must have been sleepy, but this doesn't seems to be evenly spread across the range and tends to have small numbers.
Btw, is that supposed to be (int)(((float)rand() / (float)RAND_MAX) * 99.0 + 1.0)
? it seems to have too many )
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.
yeah, that'd also be acceptable for this use case.
Core/HLE/sceNet.cpp
Outdated
Memory::WriteStruct(resultAddr, &netApctlInfo.bssid); | ||
else { | ||
// Generate a BSSID/MAC address | ||
char dummyMAC[ETHER_ADDR_LEN]{ static_cast<char>(entryId) }; |
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.
be aware that this will only set the first char of dummyMAC to entryId, the rest will be 0. that might be fine though. if you want all the bytes to be set to entryId, switch back to memset.
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.
eh.. it's not the same with memset? ugh okay, i'll change it back
cede00b
to
eee32f8
Compare
e360a9a
to
f459999
Compare
…using signal strength to determine the strength of the recruit
…HLE to prevent generating confusing logs
This should fix recruiting on MGS:PW using faked AP #8094