-
Notifications
You must be signed in to change notification settings - Fork 114
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
mystery_gift.c #271
mystery_gift.c #271
Conversation
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.
First pass while on mobile on the bus
src/mystery_gift.c
Outdated
|
||
BOOL SaveMysteryGift_ReceiveGiftAndClearCardByIndex(MYSTERY_GIFT_SAVE* mg, int index) { | ||
GF_ASSERT(index < NUM_SAVED_WONDER_CARDS); | ||
mg->cards[index].tag = MG_TAG_invalid; |
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.
MG_TAG_INVALID?
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.
Would need to change all the other constants in this define list.
include/mystery_gift.h
Outdated
u8 raw[256]; | ||
} MysteryGiftData; | ||
|
||
typedef struct { |
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.
struct name here
// will return a non-nullable pointer to a | ||
// special Wonder Card slot that's exclusive | ||
// to HGSS. Otherwise, returns NULL. | ||
WonderCard* SaveMysteryGift_CardGetByIdx(MysteryGiftSave* mg, int index); |
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.
change all these to Save_MysteryGift
#include "save_arrays.h" | ||
#include "constants/save_arrays.h" | ||
|
||
BOOL MysteryGiftTagIsValid(u32 tag); |
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.
MysteryGift_TagIsValid
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 name implies the argument is a MysteryGift*, which it isn't.
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.
no? the name implies that the function is to do with mystery gifts, I thought that was how the naming is done, not based on arguments
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.
The nomenclature is based on the pseudo-OOP. MysteryGift_TagIsValid
would be read as if it was the C++ routine bool MysteryGift::TagIsValid() const
.
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 feel like further discussion is needed on what the prefixes are based on exactly, so it's down and agreed
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.
Pika is right about what we based this nomenclature on.
#include "constants/save_arrays.h" | ||
|
||
BOOL MysteryGiftTagIsValid(u32 tag); | ||
MysteryGift* SaveMysteryGift_GetByIdx(MysteryGiftSave* mg, int index); |
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.
Index instead of Idx
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.
What's the real advantage of spelling out "index" here? "Idx" is universally understood to mean "Index".
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.
style agreed idx bad
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.
reddo: "I consent to style"
donnel: "I consent to style"
pika: "I don't"
is there someone you forgot to ask?
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.
Idgaf as long as it's readable, Idx is still better than I
|
||
BOOL MysteryGiftTagIsValid(u32 tag); | ||
MysteryGift* SaveMysteryGift_GetByIdx(MysteryGiftSave* mg, int index); | ||
BOOL SaveMysteryGift_SetReceivedByIdx(MysteryGiftSave* mg, int index); |
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.
pointer alignment on all these
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.
Not sure what you mean here
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.
pointer should be MysteryGiftSave *mg
instead of current
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.
no, that is ugly af
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.
that's agreed by several people, and is the style in the whole repo
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.
it's ok red we can just fix it if pika wants to be dense here
|
||
// Returns TRUE if there is an open slot | ||
// to receive a gift. The capacity is 8. | ||
BOOL SaveMysteryGift_FindAvailable(const MysteryGiftSave* mg); |
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.
pointer alignment
still a bit of issue with style here, I would like it to be followed because it has been agreed upon (and it was quite difficult to find something that most, if not everyone agreed with) |
include/mystery_gift.h
Outdated
u32 item; | ||
u16 ruleset[24]; | ||
int base_decoration; | ||
MG_MON_DECO_TAG mon_decoration; |
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.
Don't use snake_case for struct variables
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.
Also MG_MON_DECO_TAG to non-capitalized enum/struct name
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.
tbf this used to be an anonymous union inside struct MysteryGift
. variant names are unchanged from that union.
int base_decoration; | ||
MG_MON_DECO_TAG mon_decoration; | ||
u8 pokewalkerCourse; | ||
PHOTO photo; |
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.
PHOTO -> Photo
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.
Out of scope
#include "save_arrays.h" | ||
#include "constants/save_arrays.h" | ||
|
||
BOOL MysteryGiftTagIsValid(u32 tag); |
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.
Pika is right about what we based this nomenclature on.
|
||
BOOL MysteryGiftTagIsValid(u32 tag); | ||
MysteryGift* SaveMysteryGift_GetByIdx(MysteryGiftSave* mg, int index); | ||
BOOL SaveMysteryGift_SetReceivedByIdx(MysteryGiftSave* mg, int index); |
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.
it's ok red we can just fix it if pika wants to be dense here
src/mystery_gift.c
Outdated
} | ||
} | ||
|
||
int GetFirstQueuedMysteryGiftIdx(void) { |
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.
Arguably using the SaveMysteryGift(Data) prefix here is fine since it's modifying the static instance of SaveMysteryGiftData, ie analogous to a static function of the class. Ditto for everything else.
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.
In my scrcmd_11 PR, I explore the possibility of this static pointer, at one point in development, holding a transaction. Upon further study of retsam, this was not the case, but wouldn't it be cool if it was?
src/mystery_gift.c
Outdated
|
||
static MysteryGiftSave* sMysteryGiftSaveData; | ||
|
||
void GetStaticPointerToSaveMysteryGift(SaveData* saveData) { |
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.
Related to the comment below - GetStaticPointerToSaveMysteryGift is a whole hell of a lot worse than MysteryGiftSave_SetInstance/_SetFromSave or something similar. I think
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.
honestly at this point I feel like I'll just go through and correct the style myself when I get to that file, I don't want to block this for much longer
No description provided.