Skip to content

Commit

Permalink
Treat null or blank values for batting and throwing side in rosters a…
Browse files Browse the repository at this point in the history
…s question marks.
  • Loading branch information
tturocy committed Dec 31, 2023
1 parent c4fa2fe commit ebdda2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"unknown" values are output as 0 for `BEVENT` compatibility.
- In `cwevent`, the implementation of the batter/runner "fate" extended fields was
entirely incorrect. This has been corrected. (#45)
- In handling rosters, treat blank or null values for batting or throwing side
as if they were explicit question marks.


# [0.10.0] - 2023-01-02
Expand Down
4 changes: 2 additions & 2 deletions src/cwlib/roster.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ cw_roster_batting_hand(CWRoster *roster, char *player_id)

for (player = roster->first_player; player; player = player->next) {
if (!strcmp(player->player_id, player_id)) {
return player->bats;
return (player->bats != '\0' && player->bats != ' ') ? player->bats : '?';
}
}

Expand All @@ -311,7 +311,7 @@ cw_roster_throwing_hand(CWRoster *roster, char *player_id)

for (player = roster->first_player; player; player = player->next) {
if (!strcmp(player->player_id, player_id)) {
return player->throws;
return (player->throws != '\0' && player->throws != ' ') ? player->throws : '?';
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/cwtools/cwevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ DECLARE_FIELDFUNC(cwevent_batter_hand)
{
char batterHand, pitcherHand;
if (gameiter->event->batter_hand == ' ') {
batterHand = cw_roster_batting_hand((gameiter->event->batting_team == 0) ?
visitors : home,
gameiter->event->batter);
batterHand = cw_roster_batting_hand((gameiter->event->batting_team == 0) ?
visitors : home,
gameiter->event->batter);
}
else {
batterHand = gameiter->event->batter_hand;
Expand All @@ -230,11 +230,11 @@ DECLARE_FIELDFUNC(cwevent_batter_hand)
if (gameiter->state->pitcher_hand != ' ') {
pitcherHand = gameiter->state->pitcher_hand;
}
else{
else {
pitcherHand =
cw_roster_throwing_hand((gameiter->event->batting_team == 0) ?
home : visitors,
gameiter->state->fielders[1][1-gameiter->state->batting_team]);
cw_roster_throwing_hand((gameiter->event->batting_team == 0) ?
home : visitors,
gameiter->state->fielders[1][1 - gameiter->state->batting_team]);
}
if (pitcherHand == 'L') {
batterHand = 'R';
Expand Down

0 comments on commit ebdda2e

Please sign in to comment.