diff options
author | June McEnroe <june@causal.agency> | 2019-03-15 15:58:29 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-03-15 15:58:29 -0400 |
commit | 031cbc6eb23bf5b58f0b3c3cba5ed26cc52cf58e (patch) | |
tree | 339f9aa8d1d5e46e29a3a342cc1f1e76a0a156c8 | |
parent | Turn on -Wpedantic (diff) | |
download | cards-031cbc6eb23bf5b58f0b3c3cba5ed26cc52cf58e.tar.gz cards-031cbc6eb23bf5b58f0b3c3cba5ed26cc52cf58e.zip |
Simplify Cards constants
-rw-r--r-- | cards.c | 4 | ||||
-rw-r--r-- | cards.h | 8 | ||||
-rw-r--r-- | dump.c | 2 |
3 files changed, 6 insertions, 8 deletions
diff --git a/cards.c b/cards.c index 2e8ab20..35660ad 100644 --- a/cards.c +++ b/cards.c @@ -131,7 +131,7 @@ struct Cards *Cards_Load(struct SDL_RWops *rw) { SDL_ReadLE32(rw); // reserved id &= 0x7FFF; - if (id >= Cards_CardLen) continue; + if (id >= Cards_Count) continue; Sint64 next = SDL_RWtell(rw); if (next < 0) goto fail; @@ -173,7 +173,7 @@ fail: } void Cards_Free(struct Cards *cards) { - for (int i = 0; i < Cards_CardLen; ++i) { + for (int i = 0; i < Cards_Count; ++i) { if (!cards->surfaces[i]) continue; SDL_FreeSurface(cards->surfaces[i]); } diff --git a/cards.h b/cards.h index 0308cdf..2ce85a9 100644 --- a/cards.h +++ b/cards.h @@ -23,10 +23,8 @@ enum { Cards_Width = 71, Cards_Height = 96, -}; -enum Cards_Card { - Cards_Club, + Cards_Club = 0, Cards_Diamond = 13, Cards_Heart = 26, Cards_Spade = 39, @@ -43,11 +41,11 @@ enum Cards_Card { Cards_X = 67, Cards_O, - Cards_CardLen, + Cards_Count, }; struct Cards { - struct SDL_Surface *surfaces[Cards_CardLen]; + struct SDL_Surface *surfaces[Cards_Count]; }; struct Cards *Cards_Load(struct SDL_RWops *rw); diff --git a/dump.c b/dump.c index 86b0df4..f52a24c 100644 --- a/dump.c +++ b/dump.c @@ -39,7 +39,7 @@ int main(int argc, char *argv[]) { if (!cards) return fail("Cards_Load"); SDL_RWclose(rw); - for (int i = 0; i < Cards_CardLen; ++i) { + for (int i = 0; i < Cards_Count; ++i) { if (!cards->surfaces[i]) continue; char name[sizeof("00.bmp")]; snprintf(name, sizeof(name), "%02d.bmp", i); |