Skip to content

Commit

Permalink
Corrects implementation of cwevent "fate" fields.
Browse files Browse the repository at this point in the history
The implementation of the cwevent runner/batter "fate" fields was simply not correct.  This fixes the problem.

This closes #45.
  • Loading branch information
tturocy committed Dec 30, 2023
1 parent a411c70 commit c4fa2fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
compatibility.
- In `cwgame`, "unknown" in now an accepted value for `info,temp` and `info,windspeed`.
"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)


# [0.10.0] - 2023-01-02
Expand Down
17 changes: 9 additions & 8 deletions src/cwlib/gameiter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,19 +1037,20 @@ int cw_gameiter_runner_fate(CWGameIterator *orig_gameiter, int base)
orig_gameiter->event_data->advance[base] >= 4) {
return orig_gameiter->event_data->advance[base];
}

base = orig_gameiter->event_data->advance[base];
gameiter = cw_gameiter_copy(orig_gameiter);
while (gameiter->event != NULL &&
gameiter->state->inning == orig_gameiter->state->inning &&
gameiter->state->batting_team == orig_gameiter->state->batting_team &&
base >= 1 && base <= 3) {
cw_gameiter_next(gameiter);
if (gameiter->event && strcmp(gameiter->event->event_text, "NP") != 0) {
cw_gameiter_next(gameiter);
while (gameiter->event != NULL &&
gameiter->state->inning == orig_gameiter->state->inning &&
gameiter->state->batting_team == orig_gameiter->state->batting_team) {
if (strcmp(gameiter->event->event_text, "NP") != 0) {
base = gameiter->event_data->advance[base];
if (base < 1 || base > 3) {
break;
}
}
cw_gameiter_next(gameiter);
}

cw_gameiter_cleanup(gameiter);
free(gameiter);
return base;
Expand Down

0 comments on commit c4fa2fe

Please sign in to comment.