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

mystery_gift.c #271

Merged
merged 10 commits into from
Dec 19, 2023
Merged

mystery_gift.c #271

merged 10 commits into from
Dec 19, 2023

Conversation

PikalaxALT
Copy link
Collaborator

No description provided.

@PikalaxALT PikalaxALT marked this pull request as ready for review December 7, 2023 01:37
Copy link
Collaborator

@adrienntindall adrienntindall left a 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

include/mystery_gift.h Outdated Show resolved Hide resolved

BOOL SaveMysteryGift_ReceiveGiftAndClearCardByIndex(MYSTERY_GIFT_SAVE* mg, int index) {
GF_ASSERT(index < NUM_SAVED_WONDER_CARDS);
mg->cards[index].tag = MG_TAG_invalid;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MG_TAG_INVALID?

Copy link
Collaborator Author

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.

src/mystery_gift.c Outdated Show resolved Hide resolved
src/mystery_gift.c Outdated Show resolved Hide resolved
src/mystery_gift.c Outdated Show resolved Hide resolved
src/mystery_gift.c Outdated Show resolved Hide resolved
u8 raw[256];
} MysteryGiftData;

typedef struct {
Copy link
Member

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MysteryGift_TagIsValid

Copy link
Collaborator Author

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.

Copy link
Member

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

Copy link
Collaborator Author

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.

Copy link
Member

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

Copy link
Collaborator

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Index instead of Idx

Copy link
Collaborator Author

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".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style agreed idx bad

Copy link
Collaborator Author

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?

Copy link
Collaborator

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

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

Copy link
Collaborator Author

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

Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Member

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

Copy link
Collaborator

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pointer alignment

src/mystery_gift.c Show resolved Hide resolved
src/mystery_gift.c Show resolved Hide resolved
src/mystery_gift.c Outdated Show resolved Hide resolved
@red031000
Copy link
Member

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)

u32 item;
u16 ruleset[24];
int base_decoration;
MG_MON_DECO_TAG mon_decoration;
Copy link
Collaborator

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

Copy link
Collaborator

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

Copy link
Collaborator Author

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHOTO -> Photo

Copy link
Collaborator Author

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

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

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

}
}

int GetFirstQueuedMysteryGiftIdx(void) {
Copy link
Collaborator

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.

Copy link
Collaborator Author

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?


static MysteryGiftSave* sMysteryGiftSaveData;

void GetStaticPointerToSaveMysteryGift(SaveData* saveData) {
Copy link
Collaborator

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

Copy link
Member

@red031000 red031000 left a 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

@adrienntindall adrienntindall merged commit 439efca into pret:master Dec 19, 2023
1 check passed
github-actions bot pushed a commit that referenced this pull request Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants