Skip to content

Conversation

@anr2me
Copy link
Collaborator

@anr2me anr2me commented Apr 4, 2021

This should fix recruiting on MGS:PW using faked AP #8094

@anr2me anr2me force-pushed the apctl branch 3 times, most recently from 9fd40c7 to dac94ee Compare April 4, 2021 03:19
@anr2me anr2me marked this pull request as draft April 4, 2021 06:53
@anr2me anr2me marked this pull request as ready for review April 4, 2021 07:05
@anr2me anr2me marked this pull request as draft April 4, 2021 07:39
@anr2me anr2me marked this pull request as ready for review April 4, 2021 07:49
Comment on lines 1239 to 1240
char dummyMAC[ETHER_ADDR_LEN];
memset(&dummyMAC, entryId, sizeof(dummyMAC));
Copy link
Contributor

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.

Copy link
Collaborator Author

@anr2me anr2me Apr 4, 2021

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

Copy link
Owner

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));

Copy link
Collaborator Author

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]

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);
Copy link
Owner

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)

Copy link
Collaborator Author

@anr2me anr2me Apr 4, 2021

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 )

Copy link
Owner

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.

Memory::WriteStruct(resultAddr, &netApctlInfo.bssid);
else {
// Generate a BSSID/MAC address
char dummyMAC[ETHER_ADDR_LEN]{ static_cast<char>(entryId) };
Copy link
Owner

@hrydgard hrydgard Apr 4, 2021

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.

Copy link
Collaborator Author

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

@anr2me anr2me force-pushed the apctl branch 2 times, most recently from cede00b to eee32f8 Compare April 4, 2021 12:54
@anr2me anr2me marked this pull request as draft April 4, 2021 21:12
@anr2me anr2me force-pushed the apctl branch 2 times, most recently from e360a9a to f459999 Compare April 4, 2021 21:41
@anr2me anr2me marked this pull request as ready for review April 4, 2021 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants