Skip to content

Commit

Permalink
Merge pull request #959 from wxwisiasdf/signox
Browse files Browse the repository at this point in the history
fix a single "!=" instead of a "==" causing mp issues
  • Loading branch information
schombert authored Jan 14, 2024
2 parents f413598 + d038eaf commit 8589db3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/gamestate/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4289,8 +4289,9 @@ void notify_player_picks_nation(sys::state& state, dcon::nation_id source, dcon:
add_to_command_queue(state, p);
}
bool can_notify_player_picks_nation(sys::state& state, dcon::nation_id source, dcon::nation_id target) {
// Invalid OR rebel nation
if(!bool(target) || target == state.national_definitions.rebel_id)
if(source == target) //redundant
return false;
if(!bool(target) || target == state.national_definitions.rebel_id) //Invalid OR rebel nation
return false;
// TODO: Support Co-op (one day)
return state.world.nation_get_is_player_controlled(target) == false;
Expand Down
26 changes: 13 additions & 13 deletions src/network/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,18 @@ static void send_post_handshake_commands(sys::state& state, network::client_data
std::vector<char> tmp = client.send_buffer;
client.send_buffer.clear();
if(state.mode == sys::game_mode_type::pick_nation) {
/* Send the savefile to the newly connected client (if not a new game) */
if(!state.network_state.is_new_game) {
command::payload c;
memset(&c, 0, sizeof(command::payload));
c.type = command::command_type::notify_save_loaded;
c.source = state.local_player_nation;
c.data.notify_save_loaded.target = client.playing_as;
network::broadcast_save_to_clients(state, c, state.network_state.current_save_buffer.get(), state.network_state.current_save_length, state.network_state.current_save_checksum);
#ifndef NDEBUG
state.console_log("host:send:cmd: (new(2)->save_loaded)");
#endif
}
{ /* Tell this client about every other client */
command::payload c;
memset(&c, 0, sizeof(c));
Expand All @@ -444,18 +456,6 @@ static void send_post_handshake_commands(sys::state& state, network::client_data
}
}
}
/* Send the savefile to the newly connected client (if not a new game) */
if(!state.network_state.is_new_game) {
command::payload c;
memset(&c, 0, sizeof(command::payload));
c.type = command::command_type::notify_save_loaded;
c.source = state.local_player_nation;
c.data.notify_save_loaded.target = client.playing_as;
network::broadcast_save_to_clients(state, c, state.network_state.current_save_buffer.get(), state.network_state.current_save_length, state.network_state.current_save_checksum);
#ifndef NDEBUG
state.console_log("host:send:cmd: (new(2)->save_loaded)");
#endif
}
} else if(state.mode == sys::game_mode_type::in_game || state.mode == sys::game_mode_type::select_states) {
{ /* Tell this client about every other client */
command::payload c;
Expand Down Expand Up @@ -960,7 +960,7 @@ void kick_player(sys::state& state, client_data& client) {

void switch_player(sys::state& state, dcon::nation_id new_n, dcon::nation_id old_n) {
state.network_state.map_of_player_names.insert_or_assign(new_n.index(), state.network_state.map_of_player_names[old_n.index()]);
if(state.network_mode != sys::network_mode_type::host) {
if(state.network_mode == sys::network_mode_type::host) {
for(auto& client : state.network_state.clients) {
if(!client.is_active())
continue;
Expand Down

0 comments on commit 8589db3

Please sign in to comment.