made it so multiplayer games update movement on mutation
This commit is contained in:
parent
184814107c
commit
a65b337308
3 changed files with 45 additions and 29 deletions
|
@ -23,7 +23,7 @@ RESULT enter(display& disp, config& game_data)
|
|||
|
||||
std::vector<std::string> messages;
|
||||
|
||||
gui::textbox message_entry(disp,300);
|
||||
gui::textbox message_entry(disp,500);
|
||||
|
||||
for(;;) {
|
||||
std::cerr << "game data: " << game_data.write() << "\n";
|
||||
|
|
|
@ -172,35 +172,13 @@ LEVEL_RESULT play_level(game_data& gameinfo, config& terrain_config,
|
|||
dialogs::show_objectives(gui,*level);
|
||||
}
|
||||
|
||||
const int start_command = recorder.ncommands();
|
||||
|
||||
try {
|
||||
play_turn(gameinfo,state_of_game,status,terrain_config,
|
||||
level, video, key, gui, events_manager, map,
|
||||
teams, player_number, units);
|
||||
} catch(end_level_exception& e) {
|
||||
if(network::nconnections() > 0) {
|
||||
config cfg;
|
||||
cfg.children["turn"].push_back(
|
||||
new config(recorder.get_data_range(start_command,
|
||||
recorder.ncommands())));
|
||||
network::send_data(cfg);
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
play_turn(gameinfo,state_of_game,status,terrain_config,
|
||||
level, video, key, gui, events_manager, map,
|
||||
teams, player_number, units);
|
||||
|
||||
if(game_config::debug)
|
||||
display::clear_debug_highlights();
|
||||
|
||||
if(network::nconnections() > 0) {
|
||||
config cfg;
|
||||
cfg.children["turn"].push_back(
|
||||
new config(recorder.get_data_range(start_command,
|
||||
recorder.ncommands())));
|
||||
network::send_data(cfg);
|
||||
}
|
||||
|
||||
} else if(!replaying && team_it->is_ai()) {
|
||||
const int start_command = recorder.ncommands();
|
||||
|
||||
|
@ -250,6 +228,9 @@ LEVEL_RESULT play_level(game_data& gameinfo, config& terrain_config,
|
|||
player_number,status,state_of_game,&replay_obj);
|
||||
|
||||
recorder.add_config(*cfg.children["turn"].front());
|
||||
|
||||
gui.invalidate_all();
|
||||
gui.draw();
|
||||
}
|
||||
|
||||
std::cerr << "finished networked...\n";
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "language.hpp"
|
||||
#include "log.hpp"
|
||||
#include "mouse.hpp"
|
||||
#include "network.hpp"
|
||||
#include "playlevel.hpp"
|
||||
#include "playturn.hpp"
|
||||
#include "preferences.hpp"
|
||||
|
@ -104,10 +105,44 @@ void play_turn(game_data& gameinfo, game_state& state_of_game,
|
|||
|
||||
std::cerr << "done gotos\n";
|
||||
|
||||
int start_command = recorder.ncommands();
|
||||
|
||||
for(;;) {
|
||||
const bool res = turn_slice(gameinfo,state_of_game,status,
|
||||
terrain_config,level,video,key,gui,map,
|
||||
teams,team_num,units,turn_data,false);
|
||||
bool res = false;
|
||||
|
||||
try {
|
||||
res = turn_slice(gameinfo,state_of_game,status,
|
||||
terrain_config,level,video,key,gui,map,
|
||||
teams,team_num,units,turn_data,false);
|
||||
} catch(end_level_exception& e) {
|
||||
|
||||
//if the game is over, and it's a networked game, then
|
||||
//tell the foreign hosts of the final moves
|
||||
if(network::nconnections() > 0 &&
|
||||
start_command < recorder.ncommands()) {
|
||||
config cfg;
|
||||
cfg.children["turn"].push_back(
|
||||
new config(recorder.get_data_range(start_command,
|
||||
recorder.ncommands())));
|
||||
network::send_data(cfg);
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
//send network data if any moves have been made
|
||||
if(network::nconnections() > 0 &&
|
||||
(turn_data.undo_stack.empty() || res) &&
|
||||
start_command < recorder.ncommands()) {
|
||||
config cfg;
|
||||
cfg.children["turn"].push_back(
|
||||
new config(recorder.get_data_range(start_command,
|
||||
recorder.ncommands())));
|
||||
network::send_data(cfg);
|
||||
|
||||
start_command = recorder.ncommands();
|
||||
}
|
||||
|
||||
if(res) {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue