- printf("OP_STOP_PLAYING: %d\n", buf[0]);
- sprintf(msgbuf, "client %d stops game", buf[0]);
- sysmsg(msgbuf);
+ int client_nr = getNetworkBuffer8BitInteger(read_buffer);
+ int cause_for_stopping = getNetworkBuffer8BitInteger(read_buffer);
+
+ printf("OP_STOP_PLAYING: %d [%d]\n", client_nr, cause_for_stopping);
+ Error(ERR_NETWORK_CLIENT, "client %d stops game [%d]",
+ client_nr, cause_for_stopping);
+
+ if (game_status == GAME_MODE_PLAYING)
+ {
+ int index_nr = client_nr - 1;
+ struct PlayerInfo *client_player = &stored_player[index_nr];
+ boolean stopped_by_remote_player = (!client_player->connected_locally);
+ char message[100];
+
+ if (cause_for_stopping == NETWORK_STOP_BY_PLAYER)
+ sprintf(message, "Network game stopped by player %d!", client_nr);
+ else
+ sprintf(message, (cause_for_stopping == NETWORK_STOP_BY_ERROR ?
+ "Network game stopped due to internal error!" :
+ "Network game stopped!"));
+
+ if (cause_for_stopping != NETWORK_STOP_BY_PLAYER ||
+ stopped_by_remote_player)
+ Request(message, REQ_CONFIRM | REQ_STAY_CLOSED);
+
+ SetGameStatus(GAME_MODE_MAIN);