mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 01:23:24 -08:00
* [Protocol] Add shuffle players option and player order command/event Adds a 'Shuffle players at start' option to game creation plus a local player id on the game state so clients can reconcile seat changes, and a SET_PLAYER_ORDER command (1206) with a PLAYER_ORDER_CHANGED event (2023) so the game host can set or randomize the seating order. Took 6 minutes * [Server] Shuffle and reorder player seats before a game starts Auto-shuffles the seats at game start when enabled (now for games with two or more players instead of three or more) and handles the new SET_PLAYER_ORDER command so the game host or a moderator can reorder or randomize the seats before the game starts. Re-seating re-keys the player ids while keeping the per-user game/seat routing and persistent player records in sync, then broadcasts the new order to everyone. * [Client] Add shuffle players option and turn order dialog Adds the 'Shuffle players at start' checkbox to game creation and a host-only 'Set turn order...' action that opens a dialog to reorder or randomize the seats before the game starts. Seating changes are shown in the game's message log. * [Client] Move the turn order dialog strings into retranslateUi Follows the DlgInviteToGame convention so the dialog can be retranslated instead of freezing its strings at construction time. * [Server] Keep player ids stable across seat shuffles * [Client] Lay out table and turn order dialog in seat order * [Server] Send game-joined player list in seat order * [Client] Reword the shuffle option to match its behaviour * [Client] Address the seat-order review comments - Give the game setup checkboxes a row of their own so they no longer collide in the create-game dialog - Rename DlgTurnOrder::randomize() to isRandomizeRequested() - Document what the ids in GameState::seatOrder mean - Keep "Set turn order..." in sync with the game: hidden for non-hosts and once the game has started, re-shown when the game ends or hosting moves to the local player (new GameState::hostChanged signal) * [Client] Do not preview a randomized turn order Randomizing is a request to the server, not a local shuffle. Shuffling the list locally meant the dialog showed an order the server then discarded, and let the host re-open it until a favourable order appeared. The dialog now switches to a mode that says the server will randomize and toggles back to the manual list on request. * [Client] Let moderators set the turn order The server accepts SET_PLAYER_ORDER from the host or a moderator, but the client hid the action from everyone except the host, making the moderator branch unreachable. Visibility and the handler now share canSetTurnOrder(). * [Server] Rely on the player order event instead of a full state resend cmdSetPlayerOrder re-sent the whole game state after reseating, so every client reloaded its deck view mid-lobby for no reason. The new seating reaches clients through the Event_PlayerOrderChanged that reseatPlayers broadcasts. * [Client] Show random turn order in the game selector The restrictions column listed "open decklists" but not the new seating option, so a joining player had no way to see that seats will be randomized each game. Game info already shows the disabled checkbox. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
256 lines
8.3 KiB
CMake
256 lines
8.3 KiB
CMake
# CMakeLists for common directory
|
|
#
|
|
# provides the protobuf interfaces
|
|
|
|
set(PROTO_FILES
|
|
admin_commands.proto
|
|
card_attributes.proto
|
|
color.proto
|
|
command_attach_card.proto
|
|
command_change_zone_properties.proto
|
|
command_concede.proto
|
|
command_create_arrow.proto
|
|
command_create_counter.proto
|
|
command_create_token.proto
|
|
command_deck_del.proto
|
|
command_deck_del_dir.proto
|
|
command_deck_download.proto
|
|
command_deck_download_public.proto
|
|
command_deck_list.proto
|
|
command_deck_list_other_user.proto
|
|
command_deck_new_dir.proto
|
|
command_deck_select.proto
|
|
command_deck_set_visibility.proto
|
|
command_deck_share_create.proto
|
|
command_deck_share_download.proto
|
|
command_deck_share_list.proto
|
|
command_deck_share_list_mine.proto
|
|
command_deck_share_remove.proto
|
|
command_deck_upload.proto
|
|
command_del_counter.proto
|
|
command_delete_arrow.proto
|
|
command_draw_cards.proto
|
|
command_dump_zone.proto
|
|
command_flip_card.proto
|
|
command_game_say.proto
|
|
command_get_server_stats.proto
|
|
command_inc_card_counter.proto
|
|
command_inc_counter.proto
|
|
command_kick_from_game.proto
|
|
command_leave_game.proto
|
|
command_move_card.proto
|
|
command_mulligan.proto
|
|
command_next_turn.proto
|
|
command_ready_start.proto
|
|
command_replay_delete_match.proto
|
|
command_replay_download.proto
|
|
command_replay_download_by_game_id.proto
|
|
command_replay_get_code.proto
|
|
command_replay_list.proto
|
|
command_replay_modify_match.proto
|
|
command_replay_submit_code.proto
|
|
command_report.proto
|
|
command_report_add_comment.proto
|
|
command_report_assign.proto
|
|
command_report_details.proto
|
|
command_report_list.proto
|
|
command_report_my_list.proto
|
|
command_report_reopen.proto
|
|
command_report_resolve.proto
|
|
command_report_stats.proto
|
|
command_report_user_info.proto
|
|
command_reveal_cards.proto
|
|
command_reverse_turn.proto
|
|
command_roll_die.proto
|
|
command_set_active_phase.proto
|
|
command_set_card_attr.proto
|
|
command_set_card_counter.proto
|
|
command_set_counter.proto
|
|
command_set_player_order.proto
|
|
command_set_playmat.proto
|
|
command_set_sideboard_lock.proto
|
|
command_set_sideboard_plan.proto
|
|
command_shuffle.proto
|
|
command_undo_draw.proto
|
|
commands.proto
|
|
context_concede.proto
|
|
context_connection_state_changed.proto
|
|
context_deck_select.proto
|
|
context_move_card.proto
|
|
context_mulligan.proto
|
|
context_ping_changed.proto
|
|
context_ready_start.proto
|
|
context_set_sideboard_lock.proto
|
|
context_undo_draw.proto
|
|
developer_commands.proto
|
|
event_add_to_list.proto
|
|
event_attach_card.proto
|
|
event_change_zone_properties.proto
|
|
event_connection_closed.proto
|
|
event_create_arrow.proto
|
|
event_create_counter.proto
|
|
event_create_token.proto
|
|
event_del_counter.proto
|
|
event_delete_arrow.proto
|
|
event_destroy_card.proto
|
|
event_draw_cards.proto
|
|
event_dump_zone.proto
|
|
event_flip_card.proto
|
|
event_game_closed.proto
|
|
event_game_host_changed.proto
|
|
event_game_joined.proto
|
|
event_game_log_notice.proto
|
|
event_game_say.proto
|
|
event_game_state_changed.proto
|
|
event_join.proto
|
|
event_join_room.proto
|
|
event_kicked.proto
|
|
event_leave.proto
|
|
event_leave_room.proto
|
|
event_list_games.proto
|
|
event_list_rooms.proto
|
|
event_move_card.proto
|
|
event_notify_user.proto
|
|
event_player_order_changed.proto
|
|
event_player_properties_changed.proto
|
|
event_remove_from_list.proto
|
|
event_remove_messages.proto
|
|
event_replay_added.proto
|
|
event_reveal_cards.proto
|
|
event_reverse_turn.proto
|
|
event_roll_die.proto
|
|
event_room_channel_say.proto
|
|
event_room_say.proto
|
|
event_server_complete_list.proto
|
|
event_server_identification.proto
|
|
event_server_message.proto
|
|
event_server_shutdown.proto
|
|
event_set_active_phase.proto
|
|
event_set_active_player.proto
|
|
event_set_card_attr.proto
|
|
event_set_card_counter.proto
|
|
event_set_counter.proto
|
|
event_shuffle.proto
|
|
event_user_joined.proto
|
|
event_user_left.proto
|
|
event_user_message.proto
|
|
game_commands.proto
|
|
game_event.proto
|
|
game_event_container.proto
|
|
game_event_context.proto
|
|
game_replay.proto
|
|
isl_message.proto
|
|
moderator_commands.proto
|
|
move_card_to_zone.proto
|
|
response.proto
|
|
response_activate.proto
|
|
response_adjust_mod.proto
|
|
response_ban_history.proto
|
|
response_card_art_rule_entry.proto
|
|
response_deck_download.proto
|
|
response_deck_list.proto
|
|
response_deck_share_create.proto
|
|
response_deck_share_download.proto
|
|
response_deck_share_list.proto
|
|
response_deck_share_list_mine.proto
|
|
response_deck_upload.proto
|
|
response_dump_zone.proto
|
|
response_forgotpasswordrequest.proto
|
|
response_get_admin_notes.proto
|
|
response_get_games_of_user.proto
|
|
response_get_server_stats.proto
|
|
response_get_user_info.proto
|
|
response_join_room.proto
|
|
response_list_users.proto
|
|
response_login.proto
|
|
response_password_salt.proto
|
|
response_register.proto
|
|
response_replay_download.proto
|
|
response_replay_download_by_game_id.proto
|
|
response_replay_get_code.proto
|
|
response_replay_list.proto
|
|
response_report_details.proto
|
|
response_report_list.proto
|
|
response_report_my_list.proto
|
|
response_report_stats.proto
|
|
response_report_user_info.proto
|
|
response_moderator_last_logins.proto
|
|
response_remove_user_avatar.proto
|
|
response_remove_user_banner.proto
|
|
response_clear_blacklisted_banners.proto
|
|
response_reset_user_password.proto
|
|
response_user_alts.proto
|
|
response_user_sessions.proto
|
|
response_viewlog_history.proto
|
|
response_warn_history.proto
|
|
response_warn_list.proto
|
|
room_commands.proto
|
|
room_event.proto
|
|
server_message.proto
|
|
serverinfo_arrow.proto
|
|
serverinfo_ban.proto
|
|
serverinfo_card.proto
|
|
serverinfo_cardcounter.proto
|
|
serverinfo_chat_message.proto
|
|
serverinfo_counter.proto
|
|
serverinfo_deck_share_item.proto
|
|
serverinfo_deck_share_summary.proto
|
|
serverinfo_deckstorage.proto
|
|
serverinfo_game.proto
|
|
serverinfo_gametype.proto
|
|
serverinfo_moderator_login.proto
|
|
serverinfo_player.proto
|
|
serverinfo_playerping.proto
|
|
serverinfo_playerproperties.proto
|
|
serverinfo_replay.proto
|
|
serverinfo_replay_match.proto
|
|
serverinfo_report.proto
|
|
serverinfo_room.proto
|
|
serverinfo_room_channel.proto
|
|
serverinfo_user.proto
|
|
serverinfo_user_alt.proto
|
|
serverinfo_user_session.proto
|
|
serverinfo_warning.proto
|
|
serverinfo_zone.proto
|
|
session_commands.proto
|
|
session_event.proto
|
|
)
|
|
|
|
if(MSVC)
|
|
set(unused_warning /wd4100)
|
|
else()
|
|
set(unused_warning -Wno-unused-parameter)
|
|
endif()
|
|
|
|
if(${Protobuf_VERSION} VERSION_LESS "3.21.0.0")
|
|
message(STATUS "Using Protobuf Legacy Mode")
|
|
include_directories(${PROTOBUF_INCLUDE_DIRS})
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
|
|
|
|
add_library(libcockatrice_protocol_pb ${PROTO_SRCS} ${PROTO_HDRS})
|
|
target_compile_options(libcockatrice_protocol_pb PRIVATE ${unused_warning})
|
|
set(libcockatrice_protocol_pb_LIBS ${PROTOBUF_LIBRARIES})
|
|
if(UNIX)
|
|
set(libcockatrice_protocol_pb_LIBS ${libcockatrice_protocol_pb_LIBS} -lpthread)
|
|
endif(UNIX)
|
|
target_link_libraries(libcockatrice_protocol_pb ${libcockatrice_protocol_pb_LIBS})
|
|
|
|
# ubuntu uses an outdated package for protobuf, 3.1.0 is required
|
|
if(${Protobuf_VERSION} VERSION_LESS "3.1.0")
|
|
# remove unused parameter and misleading indentation warnings when compiling to avoid errors
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-unused-parameter -Wno-misleading-indentation")
|
|
message(WARNING "Older protobuf version found (${Protobuf_VERSION} < 3.1.0), "
|
|
"disabled the warnings 'unused-parameter' and 'misleading-indentation' for protobuf generated code "
|
|
"to avoid compilation errors."
|
|
)
|
|
endif()
|
|
else()
|
|
add_library(libcockatrice_protocol_pb ${PROTO_FILES})
|
|
target_compile_options(libcockatrice_protocol_pb PRIVATE ${unused_warning})
|
|
target_link_libraries(libcockatrice_protocol_pb PUBLIC protobuf::libprotobuf)
|
|
set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
|
target_include_directories(libcockatrice_protocol_pb PUBLIC "${PROTOBUF_INCLUDE_DIRS}")
|
|
|
|
protobuf_generate(TARGET libcockatrice_protocol_pb IMPORT_DIRS "." PROTOC_OUT_DIR "${PROTO_BINARY_DIR}")
|
|
endif()
|