|
@@ -34,6 +34,7 @@ static FILE *p2_conn = nullptr;
|
|
|
static ServerState server_state = SS_LOBBY;
|
|
static ServerState server_state = SS_LOBBY;
|
|
|
static GameState game_state;
|
|
static GameState game_state;
|
|
|
static SCDArray_NetMsgType out_msgs;
|
|
static SCDArray_NetMsgType out_msgs;
|
|
|
|
|
+static bool l_win = false;
|
|
|
|
|
|
|
|
SCDARRAY_IMPL(NetMsgType, NetMsgType)
|
|
SCDARRAY_IMPL(NetMsgType, NetMsgType)
|
|
|
|
|
|
|
@@ -104,6 +105,20 @@ static bool send_out_msgs() {
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
+ case NET_MSG_WIN:
|
|
|
|
|
+ {
|
|
|
|
|
+ WinMsg msg = {
|
|
|
|
|
+ .win = (uint8_t) l_win
|
|
|
|
|
+ };
|
|
|
|
|
+ if (!send_msg(p1_conn, NET_MSG_WIN, (uint8_t *) &msg)) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ msg.win = (uint8_t) !l_win;
|
|
|
|
|
+ if (!send_msg(p2_conn, NET_MSG_WIN, (uint8_t *) &msg)) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -194,6 +209,7 @@ static bool handle_player_input(const bool p1) {
|
|
|
case NET_MSG_IS_PLAYER_1:
|
|
case NET_MSG_IS_PLAYER_1:
|
|
|
case NET_MSG_BALL_UPDATE:
|
|
case NET_MSG_BALL_UPDATE:
|
|
|
case NET_MSG_SCORE_UPDATE:
|
|
case NET_MSG_SCORE_UPDATE:
|
|
|
|
|
+ case NET_MSG_WIN:
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
@@ -286,6 +302,22 @@ static void server_game() {
|
|
|
assert_scufcont_success(SCDArray_NetMsgType_push_back(&out_msgs, &type));
|
|
assert_scufcont_success(SCDArray_NetMsgType_push_back(&out_msgs, &type));
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
+ case GSEVENT_L_WIN:
|
|
|
|
|
+ {
|
|
|
|
|
+ SE_LOG("Win");
|
|
|
|
|
+ l_win = true;
|
|
|
|
|
+ const NetMsgType type = NET_MSG_WIN;
|
|
|
|
|
+ assert_scufcont_success(SCDArray_NetMsgType_push_back(&out_msgs, &type));
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ case GSEVENT_R_WIN:
|
|
|
|
|
+ {
|
|
|
|
|
+ SE_LOG("Win");
|
|
|
|
|
+ l_win = false;
|
|
|
|
|
+ const NetMsgType type = NET_MSG_WIN;
|
|
|
|
|
+ assert_scufcont_success(SCDArray_NetMsgType_push_back(&out_msgs, &type));
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Player output
|
|
// Player output
|