fixed compile error. Fixed crash when loading a multiplayer save
This commit is contained in:
parent
9c89de0392
commit
1b63e2db62
6 changed files with 24 additions and 14 deletions
|
@ -10,7 +10,7 @@ experience=500
|
||||||
level=3
|
level=3
|
||||||
alignment=chaotic
|
alignment=chaotic
|
||||||
advanceto=null
|
advanceto=null
|
||||||
cost=26
|
cost=36
|
||||||
usage=fighter
|
usage=fighter
|
||||||
unit_description="Hardened by battle, the Troll Warrior can deliver deadly blows with its mace, besides being able to regenerate its wounds during combat."
|
unit_description="Hardened by battle, the Troll Warrior can deliver deadly blows with its mace, besides being able to regenerate its wounds during combat."
|
||||||
get_hit_sound=groan.wav
|
get_hit_sound=groan.wav
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "gamestatus.hpp"
|
#include "gamestatus.hpp"
|
||||||
#include "key.hpp"
|
#include "key.hpp"
|
||||||
#include "language.hpp"
|
#include "language.hpp"
|
||||||
|
#include "log.hpp"
|
||||||
#include "mapgen.hpp"
|
#include "mapgen.hpp"
|
||||||
#include "multiplayer.hpp"
|
#include "multiplayer.hpp"
|
||||||
#include "multiplayer_client.hpp"
|
#include "multiplayer_client.hpp"
|
||||||
|
@ -169,6 +170,7 @@ int play_game(int argc, char** argv)
|
||||||
|
|
||||||
CVideo video;
|
CVideo video;
|
||||||
const font::manager font_manager;
|
const font::manager font_manager;
|
||||||
|
|
||||||
const sound::manager sound_manager;
|
const sound::manager sound_manager;
|
||||||
const preferences::manager prefs_manager;
|
const preferences::manager prefs_manager;
|
||||||
const image::manager image_manager;
|
const image::manager image_manager;
|
||||||
|
|
|
@ -46,7 +46,7 @@ mp_connect::mp_connect(display& disp, std::string game_name,
|
||||||
combos_team_(), combos_color_(), sliders_gold_(),
|
combos_team_(), combos_color_(), sliders_gold_(),
|
||||||
launch_(gui::button(disp, string_table["im_ready"])),
|
launch_(gui::button(disp, string_table["im_ready"])),
|
||||||
cancel_(gui::button(disp, string_table["cancel"])),
|
cancel_(gui::button(disp, string_table["cancel"])),
|
||||||
gold_bg_(NULL), width_(630), height_(290)
|
width_(630), height_(290)
|
||||||
{
|
{
|
||||||
// Send Initial information
|
// Send Initial information
|
||||||
config response;
|
config response;
|
||||||
|
@ -58,8 +58,8 @@ mp_connect::mp_connect(display& disp, std::string game_name,
|
||||||
int mp_connect::load_map(int map, int num_turns, int village_gold,
|
int mp_connect::load_map(int map, int num_turns, int village_gold,
|
||||||
bool fog_game, bool shroud_game)
|
bool fog_game, bool shroud_game)
|
||||||
{
|
{
|
||||||
|
log_scope("load_map");
|
||||||
// Setup the game
|
// Setup the game
|
||||||
config loaded_level;
|
|
||||||
config* level_ptr;
|
config* level_ptr;
|
||||||
|
|
||||||
const config::child_list& levels = cfg_->get_children("multiplayer");
|
const config::child_list& levels = cfg_->get_children("multiplayer");
|
||||||
|
@ -76,6 +76,10 @@ int mp_connect::load_map(int map, int num_turns, int village_gold,
|
||||||
return status_;
|
return status_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_scope("loading save");
|
||||||
|
|
||||||
|
std::cerr << "a\n";
|
||||||
|
|
||||||
load_game(*data_, game, *state_);
|
load_game(*data_, game, *state_);
|
||||||
|
|
||||||
if(state_->campaign_type != "multiplayer") {
|
if(state_->campaign_type != "multiplayer") {
|
||||||
|
@ -96,8 +100,8 @@ int mp_connect::load_map(int map, int num_turns, int village_gold,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loaded_level = state_->starting_pos;
|
loaded_level_ = state_->starting_pos;
|
||||||
level_ptr= &loaded_level;
|
level_ptr= &loaded_level_;
|
||||||
|
|
||||||
//make all sides untaken
|
//make all sides untaken
|
||||||
for(config::child_itors i = level_ptr->child_range("side");
|
for(config::child_itors i = level_ptr->child_range("side");
|
||||||
|
@ -111,14 +115,16 @@ int mp_connect::load_map(int map, int num_turns, int village_gold,
|
||||||
recorder = replay(state_->replay_data);
|
recorder = replay(state_->replay_data);
|
||||||
|
|
||||||
//if this is a snapshot save, we don't want to use the replay data
|
//if this is a snapshot save, we don't want to use the replay data
|
||||||
if(loaded_level["snapshot"] == "yes")
|
if(loaded_level_["snapshot"] == "yes")
|
||||||
recorder.set_to_end();
|
recorder.set_to_end();
|
||||||
|
|
||||||
//add the replay data under the level data so clients can
|
//add the replay data under the level data so clients can
|
||||||
//receive it
|
//receive it
|
||||||
level_ptr->clear_children("replay");
|
level_ptr->clear_children("replay");
|
||||||
level_ptr->add_child("replay") = state_->replay_data;
|
level_ptr->add_child("replay") = state_->replay_data;
|
||||||
}else{
|
|
||||||
|
std::cerr << "b\n";
|
||||||
|
} else {
|
||||||
//Load a new map
|
//Load a new map
|
||||||
level_ptr = levels[map];
|
level_ptr = levels[map];
|
||||||
|
|
||||||
|
@ -319,7 +325,7 @@ void mp_connect::gui_init()
|
||||||
sliders_gold_.push_back(gui::slider(*disp_, rect, 0.0+((80.0)/979.0)));
|
sliders_gold_.push_back(gui::slider(*disp_, rect, 0.0+((80.0)/979.0)));
|
||||||
rect.w = 30;
|
rect.w = 30;
|
||||||
rect.x = (disp_->x()-width_)/2+603;
|
rect.x = (disp_->x()-width_)/2+603;
|
||||||
gold_bg_ = get_surface_portion(disp_->video().getSurface(), rect);
|
gold_bg_ = surface_restorer(&disp_->video(),rect);
|
||||||
font::draw_text(disp_, disp_->screen_area(), 12, font::GOOD_COLOUR,
|
font::draw_text(disp_, disp_->screen_area(), 12, font::GOOD_COLOUR,
|
||||||
"100", rect.x, rect.y);
|
"100", rect.x, rect.y);
|
||||||
}
|
}
|
||||||
|
@ -372,8 +378,8 @@ int mp_connect::gui_do()
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
const config::child_list& possible_sides = cfg_->get_children("multiplayer_side");
|
const config::child_list& possible_sides = cfg_->get_children("multiplayer_side");
|
||||||
const config::child_itors sides = level_->child_range("side");
|
const config::child_itors sides = level_->child_range("side");
|
||||||
int new_playergold;
|
int new_playergold = -1;
|
||||||
int cur_playergold;
|
int cur_playergold = -1;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
int mousex, mousey;
|
int mousex, mousey;
|
||||||
|
@ -479,8 +485,7 @@ int mp_connect::gui_do()
|
||||||
rect.y = (disp_->y() - height_) / 2 + 55 + (30 * n);
|
rect.y = (disp_->y() - height_) / 2 + 55 + (30 * n);
|
||||||
rect.w = 30;
|
rect.w = 30;
|
||||||
rect.h = launch_.height();
|
rect.h = launch_.height();
|
||||||
SDL_BlitSurface(gold_bg_, NULL,
|
gold_bg_.restore();
|
||||||
disp_->video().getSurface(), &rect);
|
|
||||||
font::draw_text(disp_, disp_->screen_area(), 12,
|
font::draw_text(disp_, disp_->screen_area(), 12,
|
||||||
font::GOOD_COLOUR,
|
font::GOOD_COLOUR,
|
||||||
(*sides.first[n])["gold"],
|
(*sides.first[n])["gold"],
|
||||||
|
|
|
@ -48,6 +48,8 @@ private:
|
||||||
game_state *state_;
|
game_state *state_;
|
||||||
config *level_;
|
config *level_;
|
||||||
|
|
||||||
|
config loaded_level_;
|
||||||
|
|
||||||
bool show_replay_;
|
bool show_replay_;
|
||||||
bool save_;
|
bool save_;
|
||||||
int status_;
|
int status_;
|
||||||
|
@ -70,7 +72,7 @@ private:
|
||||||
gui::button launch_;
|
gui::button launch_;
|
||||||
gui::button cancel_;
|
gui::button cancel_;
|
||||||
|
|
||||||
SDL_Surface *gold_bg_;
|
surface_restorer gold_bg_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "game_config.hpp"
|
#include "game_config.hpp"
|
||||||
|
#include "log.hpp"
|
||||||
#include "sound.hpp"
|
#include "sound.hpp"
|
||||||
|
|
||||||
#include "SDL_mixer.h"
|
#include "SDL_mixer.h"
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
theme::object::object() : loc_(empty_rect), relative_loc_(empty_rect),
|
theme::object::object() : loc_(empty_rect), relative_loc_(empty_rect),
|
||||||
last_screen_(empty_rect), xanchor_(), yanchor_()
|
last_screen_(empty_rect), xanchor_(object::FIXED), yanchor_(object::FIXED)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
theme::object::object(const config& cfg)
|
theme::object::object(const config& cfg)
|
||||||
|
|
Loading…
Add table
Reference in a new issue