626 Commits

Author SHA1 Message Date
Mark de Wever
e35f4bb501 Strip trailing whitespace. 2014-06-09 15:26:19 +02:00
Chris Beck
f814a35c5f remove unnecessary argument to play_controller::fire_prestart
The argument "execute" was always true.
2014-06-08 22:47:43 -04:00
Chris Beck
3c54dd63c8 Merge branch 'master' of git://github.com/wesnoth/wesnoth 2014-06-08 21:36:58 -04:00
Chris Beck
84ab0c2fb0 play_controllers uses const accessors to game_board
Favor these over using friend access to privates anyways.
Eventually will be able to factor that out.
2014-06-08 21:34:59 -04:00
gfgtdf
0beb8a1e79 remove game_state from menu_handler 2014-06-09 03:02:58 +02:00
Chris Beck
97f99407c1 move some code out of play_controller to game_board 2014-06-08 20:29:20 -04:00
Chris Beck
358531e06c menu handler uses game_board in it's constructor 2014-06-08 19:00:54 -04:00
Chris Beck
57cc44be64 game_display uses game_board in it's constructor 2014-06-08 14:59:20 -04:00
Chris Beck
8534aa2851 remove unnecessary argument to game_display::scroll_to_leader
The function was requiring a reference to unit map, although
the game_display owns a referece to this, and it was always
called with that instance.
2014-06-08 12:44:03 -04:00
Chris Beck
de026e6215 play_controller::init_side signals rather than throws 2014-06-07 21:11:13 -04:00
gfgtdf
b401f76f50 remove game_state::write_snapshot 2014-06-06 02:51:56 +02:00
gfgtdf
afbf5c6e58 remove resources::state_of_game
we don't want to expose the fileds "snapshot", "carryover_sides".
instead we only add classification, and mp_game_setting to resources
which are members of game_state.

in order to do that, we have to add a do_autosave method to
play_controller.

this commit also moves some code from game_state::write_snapshot to
play_controller::to_config which was intended to be in a different
commit.
2014-06-01 23:59:15 +02:00
gfgtdf
a08efab4c0 remove unused variable 2014-06-01 23:56:09 +02:00
Chris Beck
096cb97cc1 Merge pull request #180 from cbeck88/add_game_board_struct_alternate
This is a refactor to introduce an object encapsulating the unit map, the game map, and the list of teams. Introducing this object permits us to move a substantial amount of code out of the play_controller object, and also to give a home to some helper functions in unit.?pp that previously sat in the global namespace. It also allows us to simplify the construction of some of the clients of play_controller.

This refactor is ongoing WIP. The goals are

(1) better organize the architecture of the engine, to make saving and reloading easier.
(2) Facilitate the introduction of an improved pathfinding mechanism, which will need to sit between most of the other engine modules and the unit map / game map.
(3) Refactoring clarifies what the existing code is doing, therefore it may help us to find bugs in the current system, which may be fixed independently of the refactor in 1.12.
2014-06-01 13:42:10 -04:00
Chris Beck
2d2385b952 integrate game_board into mouse_handler 2014-06-01 12:53:34 -04:00
gfgtdf
ebbf813e03 Merge pull request #177 from gfgtdf/remove_diffic
remove "difficulty_" and "random_mode_" from game_data and carryover
(we already have them in the classification)
2014-06-01 18:36:16 +02:00
Chris Beck
df74d891d2 give global fcn's (find/get)_visible_unit a home in game_board
Unit tested and playtested after moving the functions decalarations,
and definitions, adding links to play_controller::game_board from
resources.?pp, and executing find and replace commands:

git grep -lz 'find_visible_unit(' | xargs -0 perl -i'' -pE "s/find_visible_unit\(/resources::gameboard->find_visible_unit\(/g"
git grep -lz 'get_visible_unit(' | xargs -0 perl -i'' -pE "s/get_visible_unit\(/resources::gameboard->get_visible_unit\(/g"
2014-06-01 11:31:47 -04:00
Chris Beck
8b6339af9b move code managing preference encounters out of play controller 2014-06-01 08:41:32 -04:00
Chris Beck
2afe4f4f5a move game_board to its own file, update project files 2014-06-01 08:13:34 -04:00
Chris Beck
6fff2e8be2 move some of the savegame code from play_controller to game_board 2014-06-01 02:27:50 -04:00
Chris Beck
0e7769a12c move some functionality out of play controller to game_board
This moves some simple code which manipulates the end turn status
of the units on the map.
2014-06-01 01:54:41 -04:00
gfgtdf
064dcc3d4e fixup carryover_on_defeat
we need to save the preceed_to_next_scenario value for linger saves. We
don't really need it for the next scenario in the carryover though.
2014-06-01 03:55:20 +02:00
gfgtdf
b138912ce3 remove "random_mode_" from game_data
we already have this information in the classification.
2014-05-31 23:11:28 +02:00
Chris Beck
5fa083680e cleanup for loops made ugly in previous commit
This is a strict refactor.
2014-05-31 14:08:29 -04:00
Chris Beck
5718992f9a add game_board struct to hold map, units, teams
For now this will just help us to put code in logical places and make
the save and load process simpler. This change is invisible outside
of play_controller.

Please don't backport this to 1.12.
2014-05-31 13:08:20 -04:00
gfgtdf
dd8ac6754a Merge pull request #172 from gfgtdf/random_tod
sync random_start time the normal way
2014-05-31 18:44:00 +02:00
gfgtdf
7aef411514 Merge pull request #176 from gfgtdf/carryover_on_defeeat
go to next scenario if there is at least one human
2014-05-31 18:38:27 +02:00
gfgtdf
14437136a9 go to next scenario if there is at least one human
defeated sides in mp now also advance to the next scenario if there is
at least one networked human side that got a victory.
2014-05-31 14:58:11 +02:00
Chris Beck
eb18ffc8a8 clean up find_human_team_before function
This is a strict refactor.
2014-05-30 22:21:59 -04:00
Chris Beck
d86ff4d650 eliminate unnecessary argument in play_controller
This is a strict refactor within the parameters of the program.
2014-05-30 22:18:48 -04:00
Chris Beck
1a7d358e39 Merge pull request #174 from cbeck88/fixup_end_of_scenario_saves
fixup end of scenario saves

iceiceice writes: does anyone know why we have this line?
https://github.com/wesnoth/wesnoth/blob/master/src/play_controller.cpp#L752
it causes end of scenario saves to be stripped of all units
my theory is that it was for some point in time before carryover was implemented properly
i propose to remove it in 1.12 and master

AI0867 writes: See commit aa2cf7d.
Looks like the carryover refactoring might have made it do the opposite of what it used to.
2014-05-30 19:32:57 -04:00
Chris Beck
1e4858fa4a remove unnecessary arguments
maybe_do_init_side and do_init_side both required a team_index
argument, which was always player_number_ - 1, (checked this with
assertions and playtesting), and which was available in the class
which defined them
2014-05-29 21:34:09 -04:00
Chris Beck
bf0fca4d83 assert that do_init_side functions are never called with bad arg 2014-05-29 20:43:44 -04:00
gfgtdf
e50a7785fd fix reloading
this is intended to fix
1) an error messages in stderr when reloading a game related to
synced_context: (the original game called random ... times ...)
2) reloading a save with init_side_done = no
2014-05-30 00:59:45 +02:00
Chris Beck
38211c1036 fixup end of scenario saves 2014-05-29 12:38:56 -04:00
Chris Beck
c663cdcaba remove code made dead by commit d808b7c7874465e314c433029d709236bea4fab9 2014-05-29 12:31:10 -04:00
gfgtdf
73de2e684a move is_host_ to playturn.hpp 2014-05-29 04:07:36 +02:00
gfgtdf
d808b7c787 Update check_victory
Now the game ends on all client at the same time even with victory_when_enemies_defeated_= no.

previously in mp the attribute victory_when_enemies_defeated only prevents victory for human sides but doesn't prevent defeats. This means in a simple 1vs1 Mp game with victory_when_enemies_defeated=no when side 1 gets defeated, Player 1 will get the "You have been defeated" message and for client 2 the game continues. I tested with adding victory_when_enemies_defeated =no in 2p_Arcanclave_Citadel.cfg.
When side 1 looses (leader killed) (during side 2' turn) the following happens:
[list=1]
[*]side 1 gets a "you get defeated", side 2 continues
[*]when side 1 checks "end scenario" side 2 gets a "side 1 has left the game... reassign controll to ai/human/idle/..."
[*]I clicked "controll by human" on client 2
[*]I ended side 2's turn and continued playing side 1 on client 2 and didnt get defeated
[/list]
I am sure that this is not the intended behaviour.

this commits also effects when "enemies defeated" is fired accodignly so it is fired on all clients at the same time like any synced event.
2014-05-28 23:58:39 +02:00
gfgtdf
59880e984b sync random_start time the normal way
we now use the deterministic rng which we also use for start unit unit
traits.
2014-05-28 21:04:07 +02:00
gfgtdf
84556b11fc remove num_turns parameter
this was always equal to level["turns"].to_int(-1) so i replaced it with that.
2014-05-28 04:31:20 +02:00
gfgtdf
4eb40973dd fix indention & remove commented out code 2014-05-28 00:48:40 +02:00
gfgtdf
387017d6d2 add a check_victory after init side 2014-05-26 01:23:35 +02:00
Chris Beck
239cb5fdc6 save play_controller.init_side_done as a toplevel member of snapshot
This is in an effort to address https://gna.org/bugs/?21397
2014-05-25 10:49:22 -04:00
Chris Beck
3c9844889b Make sure all error logs flush with std::endl, so we get on travis.
This is the result of running this command in directory src/

find . -type f -exec sed -i 's/\(ERR.*\)\\n\"\;/\1\" << std::endl\;/g' '{}' \;

and carefully inspecting the results.
2014-05-20 15:37:52 -04:00
Chris Beck
c5838b9513 inline the definition map_location::null_location
If we decided it was worth it to inline map_location ==, then
surely this is also worth it to inline null_location, as the
compiler may be able to reduce tests for == null location to
"x == ... && y == ...", without having to move to a different
compilation unit.
2014-05-20 10:42:13 -04:00
Chris Beck
4b64eea0a6 always flush streams when logging in play_controller
Especially in check_victory, because it could throw an exception
and perhaps not get flushed. But its also good more generally in
a place like this.
2014-05-20 01:32:20 -04:00
Chris Beck
1bd43bb6a9 refactor is_observer out of check_victory
This is a minor change to victory_when_enemies_defeated condition.

Old logic: If there are no not defeated sides which are enemies
of eachother (i.e. there is still a battle going on),
BUT victory_when_enemies_defeated = false, and either we found
a not defeated local human player, or we are a multiplayer observer
(there are no locally controlled sides), then don't end the level.

New logic: If there are no not defeated sides which are enemies,
BUT victory when enemies defeated = false, and EITHER we found a
not defeated local human player, OR there is a not defeated remote
human player AND no local human side assigned at all,
then don't end the level.

I think this more precisely the behavior we want. is_observer
doesn't belong in this function, and with the introduction of
defeat_condition, UMC will pretty much always be able to get the
behavior they want, so I'm much more comfortable to introduce this
change now than I would be otherwise.
2014-05-20 01:10:31 -04:00
gfgtdf
d948a04d9d rename remove_from_carryover_on_leaders_loss_
to remove_from_carryover_on_defeat_
2014-05-19 04:34:03 +02:00
gfgtdf
12d190ff9f add "always" defeat_condition 2014-05-19 04:21:52 +02:00
gfgtdf
26d60c0a8f replace fight_on_without_leader with defeat_condition
[side] now has an attribute defeat_condition which can be "no_leader"(default), "no_units" or "never"
"no_leader" behaves liek it behaved before.
"no_units" behaves like fight_on_without_leader=yes behaved before
"never" is new and causes the side to never get defeated, this usually means the scenariodesigner has to end the scenario with [endlevel]
2014-05-19 00:30:21 +02:00