fixed initial r,c

このコミットが含まれているのは:
woosh 2023-11-15 08:16:45 +00:00 committed by ninya9k
コミット fbabee3e02
1個のファイルの変更8行の追加6行の削除

14
uttt.c
ファイルの表示

@ -338,7 +338,11 @@ int ut_cursgetpos(const struct ut_state *state, int *r, int *c)
(state->boards[r / 3][c / 3] == '\0' || d % 3 == 1))
MEVENT event;
ut_cursprintf("Select move with arrow keys or mouse.\n");
if(state->playBoard == -1)
if(*r < 0 || *r >= 9 || *c < 0 || *c >= 9)
{
*r = 4; *c = 4;
}
else if(state->playBoard == -1)
{
*r = 3 * (*r / 3) + 1;
*c = 3 * (*c / 3) + 1;
@ -503,7 +507,7 @@ int ut_local_game(struct ut_state *state) {
int x, y;
for(;;)
{
int r, c, err;
int r = 4, c = 4;
ut_curserase();
ut_cursdraw(state);
char w = ut_winner((char *)state->boards, 0, 3);
@ -519,10 +523,8 @@ int ut_local_game(struct ut_state *state) {
}
break;
}
err = ut_cursgetpos(state, &r, &c);
if (err) {continue;}
err = ut_move(state, state, r, c);
if (err) {continue;}
if(ut_cursgetpos(state, &r, &c)) {continue;}
if(ut_move(state, state, r, c)) {continue;}
}
return 0;
}