509 Commits

Author SHA1 Message Date
Ignacio R. Morelle
9b21df3ce9 Add missing line break to log message (bug #23073) 2014-12-21 18:57:25 -03:00
gfgtdf
90c94876b1 simplyfy mpsync
That huge block in pull_remote_choice existed becasue we don't want to
return becasue we dont wan't to make choices for sides that we only
controll  temporary.
With the 'new' idle controller type this can be simplyfied by just not
making choices for idle sides.
2014-11-25 19:34:44 +01:00
gfgtdf
2435976575 don't create blank attributes in replay.cpp 2014-11-17 18:13:23 +01:00
gfgtdf
d9aad84702 Update replay.cpp 2014-09-07 22:08:15 +02:00
Zappaman
783eecc23f added flag to do_replay_function that allows executing just one move 2014-08-27 22:58:45 +03:00
Chris Beck
2d1e234fcc Silence many clang warnings [-Wmissing-variable-declarations]
warning: no previous extern declaration for non-static variable ...
2014-07-15 11:05:51 -04:00
Chris Beck
cb5a9a0d28 add display chat manager, notifications support outside game_display
The functionality of tracking observers and displaying chat messages
is moved to a manager class, which the gui owns.

The functionality of displaying notifications is similarly moved out
of the game_display and to a private namespace. (Static singleton
pattern seems okay here since there really won't need to be more
than one of these for a single application, it seems.)
2014-06-27 15:57:57 -04:00
Chris Beck
b51d6a15d1 rename gamestatus.?pp -> game_data.?pp, b/c of content changes 2014-06-24 13:44:25 -04:00
Chris Beck
1cc51deb87 remove unit.hpp include from game_display.hpp 2014-06-17 13:17:14 -04:00
gfgtdf
ac262a15d4 fix unused variable warning 2014-06-16 02:25:15 +02:00
gfgtdf
8edaafec6f remove unneeded includes in replay.cpp 2014-06-16 01:16:14 +02:00
gfgtdf
11169c60eb removed unneeded replaystack.clear call
we already clear the undostack after an action if data was sended over teh netwrok (we call synced_context::can_undo to check) so there is no need for the call here.
2014-06-16 01:10:10 +02:00
gfgtdf
20267cec05 fix get_user_choice_multiple_sides
the comment in replay.cpp says we want "send data to others" so
calling "pull_remote_user_input" is not really correct. I added a
function synced_context::send_user_choice for this case.

this fixes a bug where players can get an oos error in
wesnoth.synconize_choice
I backported a simpler version to 1.12:
0e79ef919f5718cd8024bbbac31ed1e7b67e4fc7 because i don't know whether
this bug can happen in 1.12 too.
2014-06-15 23:46:43 +02:00
Chris Beck
656870ca64 move parse_location_range to map:: object
This function required the use of resources::game_map, so properly
should be a method of game_map. This will help us to make sure that
such functions work when using either the editor or the play
controller, or the replay controller, and generally improve
encapsulation.
2014-06-11 14:50:07 -04:00
Mark de Wever
e35f4bb501 Strip trailing whitespace. 2014-06-09 15:26:19 +02:00
Chris Beck
a784abd045 catch exceptions thrown from replay_network_sender dtor 2014-06-07 23:56:00 -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
gfgtdf
562e1edd00 remove do_replay s side parameter
and use controller->current_side() instead.
2014-05-27 01:10:30 +02: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
gfgtdf
be333c535b fix replay of delayed shroud updates (21986)
we have to enable the undo stack during replays to make these work. This
was accidently disabled during pr 121.
2014-05-11 22:52:35 +02:00
Chris Beck
ca5c64b6d1 Fix a bunch of typos: syced -> synced
This commit is the result of running this command in src/ directory:
git grep -lz 'syced' | xargs -0 perl -i'' -pE "s/syced/synced/g"

Thank you stackoverflow :)
http://stackoverflow.com/questions/1583219/awk-sed-how-to-do-a-recursive-find-replace-of-a-string

(I used the "git safe" version)
2014-05-11 12:21:57 -04:00
gfgtdf
5bf4125bf9 tidyup replay.cpp 2014-04-27 20:01:52 +02:00
gfgtdf
357d1a4ce3 more robust replay.cpp functions
we now add nonundoable commands at the current position instead of
assuming
at_end(), this way nonundoable replay entrys like speak can now also be
added
while we are not at end.
Usually playturn_network_adapter ensures that we are always are at_end()
and i didn't get any error with the previous solution but the new
solution
is just more robust in case something goes wrong.
Note that we cannot add nonundoable commands at end if we aren’t at end
because
in that case the user would see the message again when he replays it.
Note that we cannot just do this for normal command because it might
bring the
replay in disorder.
2014-04-27 20:01:51 +02:00
gfgtdf
a343d3a1f4 more robust replaying 2014-04-23 22:50:32 +02:00
gfgtdf
b5fa39ab9d more robust replaying
instead of giving an assertion error after the OOS message we now

1) ignore dependent comments when we find them but didn't expect them
2) save commands for later when we find them while expecting another
dependent command. In this case we try to get a correct dependent
command by querying the user.

after we showed the OOS message ofc.
2014-04-23 22:48:18 +02:00
gfgtdf
5b669472fe fix 21926
we now add a [start] in replays if there is none.
2014-04-23 22:09:29 +02:00
gfgtdf
55aaf19c99 add replay::add_start_if_not_there_yet
the intention is to fix 21927 in a later patch
2014-04-23 22:09:23 +02:00
Chris Beck
90c7dab0c2 purge "record_change_controller"
we can use "change_controller" now instead because of the new
network adapter from gfgtdf
2014-04-19 12:26:02 -04:00
gfgtdf
6845d5d9fe removed invalid comment.
when i wrote that code, i forgot that the user can press continue in the assertion error dialog.
2014-04-16 03:49:56 +02:00
gfgtdf
627c5a9c5c use const config& for value check
the intention is to remove the annoying 
async=""
dependent=""
undo=""
in replays.
2014-04-12 00:33:42 +02:00
gfgtdf
4765b33f58 add side parameter in sync_choice
when we call sync_choice with a third argument there was no way to
determine for which side we actualy made the decision.
2014-04-11 23:05:32 +02:00
gfgtdf
c9552c9a33 allow user_choice in prestart for invisible choices 2014-04-11 23:05:20 +02:00
gfgtdf
e1a5bb89dc disable get_user_choice during prestart events
get_user_choice usually shows a dialog to the user. Because we shouldn't
use the screen during prestart events i disabled it there.

this commit might contain spelling corrections.
2014-04-11 23:05:09 +02:00
gfgtdf
d1cd2e0b17 give do_replays return a better name
I forgot what my real intention with this change was, but i still think this is a good change, becasue now people don't have to look up the comments to see what do_replay returns.
So i committed it.
2014-04-09 19:51:08 +02:00
gfgtdf
6ce4e441a2 removed unused 'do_until' argument
we don't need this parameter anymore because we have the "dependent" key
in commands.
2014-04-09 19:51:02 +02:00
Chris Beck
8e5572a239 make server level_ reflect true start of game position
Previousy, the [side]'s in level_ were updated with controller changes,
so that observers who join would be up to date, since controller changes
were not stored in history. We now change this, so that controller changes
are stored in history.

These are stored as "[record_change_controller]" tags rather than
"[change_controller]" because during a replay we should not
restart the turn and reinit in the event of such a change.

This is in preparation to move all controller tweaks to server-side.
2014-04-03 16:51:49 -04:00
gfgtdf
01f38ca46e removed dialogs::advance_unit
i already wrote  another version of that code in actions/attacks.cpp
thats uses get_user_choice for advancement choices.
the only function left thats used dialogs::advance_unit was the code for
the :unit advance=n debug command, now that code uses
attack.cpp::advance_unit_at too.
2014-04-02 23:43:05 +02:00
gfgtdf
de77f6b924 removed outcommented code in replay.cpp + add comments 2014-04-02 23:42:53 +02:00
gfgtdf
56a4630db1 don't send data if it's not needed
thsi code used the variable is_simulaneously, is_simultaneously_ is true
when we have aready sended data over the network, this variable is used
in get_user_choice so that when we make a local choice we only send it
immediately over the network if did already send data over the network.
2014-04-02 23:39:45 +02:00
gfgtdf
1fc539ecbf removed unused replay_source_manager 2014-04-02 23:39:32 +02:00
gfgtdf
3b86c95561 a third argument for lua wesnoth.synchronize_choice
luas sync_choice now takes a third parameter which is a array of number
that determines on which sides the function will be evaluated, if you
use this parameter you'll also get a table back, the passed function
will then be executed on all passed sides simulaniously (you don't have
to wait for the other side before you can make your input) example:
[code]
[event]
name = "start"
[lua]
code = <<

local result = wesnoth.synchronize_choice(
function()
local option1 = T.option { message = "No", T.command { T.set_variable {
name = "input1", value = "No"}}}
local option2 = T.option { message = "Yes", T.command { T.set_variable {
name = "input1", value = "Yes"}}}

wesnoth.fire(T.message{ message =  "Are you sure you want to play this
game?", option1, option2})
return { value = wesnoth.get_variable("input1") }
end,
function()
return { value = math.random(30) }
end, {1,2})

wesnoth.message("Player 1 wants to play: " .. result[1].value)
wesnoth.message("Player 2 wants to play: " .. result[2].value)

>>
[/lua]
[/event]
[/code]
note, that wesnoth is still a turn based strategy game and it's most
likeley a bad idea to require user input from sides when it's not their
turn because they might be afk.
so it might be better to use it during [start] events

we replace lua_settop by lua_pushvalue because we want to be able to
call the function multiple times in case one controller controlls more
than one of the passed sides.
2014-04-02 23:39:21 +02:00
gfgtdf
33d61fadff removed unused code 2014-04-02 23:39:08 +02:00
gfgtdf
8a539e0b5d correct the value of pos_ in replays. 2014-04-02 23:38:19 +02:00
gfgtdf
db9c46ce70 stop replay when we have reached the end.
the old code used to execute one last [end_turn] after the end of the
replay was reached, This doesn't work because the wml might require
[message][option] or similar during "turn end" events and we don't have
the data for that.
2014-04-02 23:37:15 +02:00
gfgtdf
632ef2d681 removed unused rng code.
i also replaced set_random_results/get_random_results with
synced_checkup in recruit_checksums in create.cpp.

i don't see a reason why we shouldn't use the checkup when calling
place_recruit from wml, since the wml is called on all clients. Just
like a normal recruit. (if we are in an unsynced context then checkup
doesnt have any effect anyway.)
2014-04-02 23:37:02 +02:00
gfgtdf
59a78cadf5 use synced_context in undo and rest
in undos we have to do it differently in different actions becasue in moves we just show the move (ro save performance i guess) but in other actions (recall/recruit) we also fire the events again.

"Rest" means: lua_ai, disband, fire_event (right click menus), update_shroud manualy.

this commit is part of pr 121.
2014-04-02 23:35:58 +02:00
gfgtdf
2b56c85dfb remove unused replay.cpp::type_by_index 2014-04-02 23:35:46 +02:00
gfgtdf
bce9467f30 add third argument to recorder.user_input
the third argument is from_side which is part of a contruct to prevent cheating in mp.
2014-04-02 23:35:34 +02:00
gfgtdf
1465f0c664 use synced_context in recruits/recalls
we use ignore_error_function to get the same behavior as before. that means we allow to pass an invalid recall and just nothing happens in this case. We also don't put anything on the recorder, because run_in_sycned_context removes it from the recorder if we weren't successful, as intended.
2014-04-02 23:35:21 +02:00
gfgtdf
d0ded837af use synced_context in moves
In order to get the same move results that we got during the game in replay, we now save continue_move/skip_sighed in the replay.
We also call move_unit now with replay_dest = NULL, is_replay = false during replay.
So during replays we now execute the same code, that we execute during the normal game. That also means that, the variable replay_ in move.cpp is now always false. which means there is some unused code now in move.cpp
i still hesitate to remove this code because it somehow seems to be too easy to do it like this, but i have found no bugs.
i suppose, that is_replay_ if a leftover from a time when visibility wasn't calculated normally during replays.
in a later commit i also put skip_ally_sighted in the replay data.

I don't use run_in_synced_context for moves because some methods use the returnvalue of move_unit. Instead i splitted move_unit into move_unit_and_recod and move_unit_from_replay, because using 'if' isn't possible for set_scontext_synced. And i don't want to record a move if nothing happend. Also i think a very small code duplicate for one 'if' less is a very fair trade.

this commit is part of pr 121.
2014-04-02 23:35:08 +02:00