fix turn 1 event and [option]s in side turn events
This commit is contained in:
parent
4229a95809
commit
bbfdfcf9ed
4 changed files with 85 additions and 49 deletions
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
Copyright (C) 2006 by Joerg Hinrichs <joerg.hinrichs@alice-dsl.de>
|
||||
wesnoth playlevel Copyright (C) 2003 by David White <davidnwhite@verizon.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2006 by Joerg Hinrichs <joerg.hinrichs@alice-dsl.de>
|
||||
wesnoth playlevel Copyright (C) 2003 by David White <davidnwhite@verizon.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "play_controller.hpp"
|
||||
|
||||
#include "config_adapter.hpp"
|
||||
|
@ -269,6 +269,9 @@ void play_controller::fire_start(bool execute){
|
|||
if(execute) {
|
||||
game_events::fire("start");
|
||||
gamestate_.set_variable("turn_number", "1");
|
||||
first_turn_ = true;
|
||||
} else {
|
||||
first_turn_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,10 +295,30 @@ void play_controller::init_side(const unsigned int team_index){
|
|||
std::stringstream player_number_str;
|
||||
player_number_str << player_number_;
|
||||
gamestate_.set_variable("side_number",player_number_str.str());
|
||||
|
||||
|
||||
if(first_turn_) {
|
||||
if(gui_->viewing_team() == team_index && !team_manager_.is_observer()) {
|
||||
recorder.add_event("turn 1");
|
||||
recorder.add_event("new turn");
|
||||
recorder.add_event("side turn");
|
||||
game_events::fire("turn 1");
|
||||
game_events::fire("new turn");
|
||||
game_events::fire("side turn");
|
||||
} else if(current_team.is_ai()) {
|
||||
game_events::fire("turn 1");
|
||||
game_events::fire("new turn");
|
||||
game_events::fire("side turn");
|
||||
}
|
||||
first_turn_ = false;
|
||||
} else
|
||||
//fire side turn event only if real side change occurs not counting changes from void to a side
|
||||
if (team_index != (first_player_ - 1) || status_.turn() > start_turn_) {
|
||||
game_events::fire("side turn");
|
||||
if(gui_->viewing_team() == team_index && !team_manager_.is_observer()) {
|
||||
recorder.add_event("side turn");
|
||||
game_events::fire("side turn");
|
||||
} else if(current_team.is_ai()) {
|
||||
game_events::fire("side turn");
|
||||
}
|
||||
}
|
||||
|
||||
//we want to work out if units for this player should get healed, and the
|
||||
|
@ -425,9 +448,9 @@ bool play_controller::can_execute_command(hotkey::HOTKEY_COMMAND command) const
|
|||
case hotkey::HOTKEY_HELP:
|
||||
case hotkey::HOTKEY_USER_CMD:
|
||||
return true;
|
||||
|
||||
case hotkey::HOTKEY_SAVE_GAME:
|
||||
return !events::commands_disabled;
|
||||
|
||||
case hotkey::HOTKEY_SAVE_GAME:
|
||||
return !events::commands_disabled;
|
||||
|
||||
case hotkey::HOTKEY_SHOW_ENEMY_MOVES:
|
||||
case hotkey::HOTKEY_BEST_ENEMY_MOVES:
|
||||
|
@ -674,12 +697,12 @@ bool play_controller::in_context_menu(hotkey::HOTKEY_COMMAND command) const
|
|||
}
|
||||
}
|
||||
|
||||
hotkey::ACTION_STATE play_controller::get_action_state(hotkey::HOTKEY_COMMAND command) const
|
||||
{
|
||||
switch(command) {
|
||||
case hotkey::HOTKEY_DELAY_SHROUD:
|
||||
return current_team().auto_shroud_updates() ? hotkey::ACTION_OFF : hotkey::ACTION_ON;
|
||||
default:
|
||||
return hotkey::ACTION_STATELESS;
|
||||
}
|
||||
}
|
||||
hotkey::ACTION_STATE play_controller::get_action_state(hotkey::HOTKEY_COMMAND command) const
|
||||
{
|
||||
switch(command) {
|
||||
case hotkey::HOTKEY_DELAY_SHROUD:
|
||||
return current_team().auto_shroud_updates() ? hotkey::ACTION_OFF : hotkey::ACTION_ON;
|
||||
default:
|
||||
return hotkey::ACTION_STATELESS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
/*
|
||||
Copyright (C) 2006 by Joerg Hinrichs <joerg.hinrichs@alice-dsl.de>
|
||||
wesnoth playlevel Copyright (C) 2003 by David White <davidnwhite@verizon.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
/*
|
||||
Copyright (C) 2006 by Joerg Hinrichs <joerg.hinrichs@alice-dsl.de>
|
||||
wesnoth playlevel Copyright (C) 2003 by David White <davidnwhite@verizon.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef PLAY_CONTROLLER_H_INCLUDED
|
||||
#define PLAY_CONTROLLER_H_INCLUDED
|
||||
|
@ -19,7 +19,7 @@
|
|||
#include "display.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "game_events.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
#include "generic_event.hpp"
|
||||
#include "halo.hpp"
|
||||
#include "help.hpp"
|
||||
|
@ -44,10 +44,10 @@ public:
|
|||
~play_controller();
|
||||
|
||||
virtual void play_slice();
|
||||
|
||||
//event handler, overriden from observer
|
||||
//there is nothing to handle in this class actually but that might change in the future
|
||||
virtual void handle_generic_event(const std::string& /*name*/) {}
|
||||
|
||||
//event handler, overriden from observer
|
||||
//there is nothing to handle in this class actually but that might change in the future
|
||||
virtual void handle_generic_event(const std::string& /*name*/) {}
|
||||
|
||||
//event handlers, overriden from command_executor
|
||||
virtual void objectives();
|
||||
|
@ -74,8 +74,8 @@ public:
|
|||
const int get_ticks();
|
||||
|
||||
protected:
|
||||
void handle_event(const SDL_Event& event);
|
||||
virtual hotkey::ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND command) const;
|
||||
void handle_event(const SDL_Event& event);
|
||||
virtual hotkey::ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND command) const;
|
||||
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command) const;
|
||||
void show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu);
|
||||
bool in_context_menu(hotkey::HOTKEY_COMMAND command) const;
|
||||
|
@ -111,7 +111,7 @@ protected:
|
|||
|
||||
//other objects
|
||||
display* gui_;
|
||||
const set_random_generator generator_setter;
|
||||
const set_random_generator generator_setter;
|
||||
const statistics::scenario_context statistics_context_;
|
||||
const game_data& gameinfo_;
|
||||
const config& level_;
|
||||
|
@ -125,7 +125,7 @@ protected:
|
|||
undo_list redo_stack_;
|
||||
|
||||
const int ticks_;
|
||||
const unit_type::experience_accelerator xp_mod_;
|
||||
const unit_type::experience_accelerator xp_mod_;
|
||||
//if a team is specified whose turn it is, it means we're loading a game
|
||||
//instead of starting a fresh one
|
||||
const bool loading_game_;
|
||||
|
@ -137,6 +137,7 @@ protected:
|
|||
unsigned int start_turn_;
|
||||
bool skip_replay_;
|
||||
bool browse_;
|
||||
bool first_turn_;
|
||||
|
||||
private:
|
||||
// Expand AUTOSAVES in the menu items, returning real names.
|
||||
|
|
|
@ -359,7 +359,13 @@ void replay::end_turn()
|
|||
config* const cmd = add_command();
|
||||
cmd->add_child("end_turn");
|
||||
}
|
||||
|
||||
void replay::add_event(const std::string& name)
|
||||
{
|
||||
config* const cmd = add_command();
|
||||
config& ev = cmd->add_child("fire_event");
|
||||
ev["raise"] = name;
|
||||
(*cmd)["undo"] = "no";
|
||||
}
|
||||
void replay::speak(const config& cfg)
|
||||
{
|
||||
config* const cmd = add_command(false);
|
||||
|
@ -926,6 +932,11 @@ bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
|
|||
check_victory(units,teams);
|
||||
}
|
||||
fix_shroud = !replayer.is_skipping();
|
||||
} else if((child = cfg->child("fire_event")) != NULL) {
|
||||
for(config::child_list::const_iterator v = child->get_children("set_variable").begin(); v != child->get_children("set_variable").end(); ++v) {
|
||||
state_of_game.set_variable((**v)["name"],(**v)["value"]);
|
||||
}
|
||||
game_events::fire((*child)["raise"]);
|
||||
} else {
|
||||
ERR_NW << "unrecognized action\n";
|
||||
if (!game_config::ignore_replay_errors) throw replay::error();
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
void clear_labels();
|
||||
void add_rename(const std::string& name, const gamemap::location& loc);
|
||||
void end_turn();
|
||||
void add_event(const std::string& name);
|
||||
|
||||
void speak(const config& cfg);
|
||||
std::string build_chat_log(const std::string& team) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue