56265 Commits

Author SHA1 Message Date
Elvish_Hunter
0aa53a06cc Merge branch 'elseif_branch' of github.com:wesnoth/wesnoth-old into elseif_branch
Merging the branch with the one I created locally.
2014-04-04 10:55:45 +02:00
gfgtdf
9d3594620e added forgotten translatable mark 2014-04-04 01:26:09 +02:00
Chris Beck
9f334718af update changelog 2014-04-03 18:23:01 -04:00
Chris Beck
1c4ba02a30 Merge pull request #123 from cbeck88/server_controller_tweaks
Server controller tweaks
2014-04-03 17:19:40 -04:00
Chris Beck
fb726e0610 move controller tweaks to server
(fixup of 736ceaa6c7e81882c9c5b2e932307b1f1ecb3bfd)

Following discussion with Soliton, we move all "controller tweaks"
i.e. assignments of networked side to human on the matching client
at start of game, to be server decisions, performed concurrent with
start of game.

In fact the controller tweaks are performed using
game::change_controller, which is modified so that it doesn't try to
make server messages before the game has started.

When the server receives [start_game] from the host, the server will
call game::change_controller for every side, sending corresponding
messages to all players and observers, updating them as appropriate.
The server will also rewrite level_ so that human sides are "network"
and ai sides are "network_ai", making the level_ correct for any
observer who subsequently joins.

We remove the obsoleted client-side code in playcampaign.cpp,
multiplayer.cpp.

We also add to multiplayer_wait.cpp the necessary support code to
interpret [change_controller] messages recieved before game start.
2014-04-03 16:51:49 -04: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
c0ea446999 fix skip_replay part2
This was broken in da4cdef146bf5a1b8026f12d6b1caa6c1cd20602.
2014-04-03 21:11:29 +02:00
gfgtdf
c181214cb6 fix skip_replay part1
In da4cdef146bf5a1b8026f12d6b1caa6c1cd20602 this was broken.
The same needs to be done in playmp_controller.cpp
2014-04-03 21:07:56 +02:00
Boldizsár Lipka
9a889057cf Use surface instead of SDL_Surface* for storing pixel data.
Safer when someone else uses the surface, too.
2014-04-03 15:01:29 +02:00
Boldizsár Lipka
81f477f422 Remove a local variable shadowing a data member.
Not sure how that thing got there.
2014-04-03 14:18:10 +02:00
Elvish_Hunter
2caf68aa4b Changelog entries for my series of commits 2014-04-03 12:40:11 +02:00
Elvish_Hunter
8d73d0ced0 [switch]: implemented checks for missing [case], variable= and value=, C++ part 2014-04-03 12:36:21 +02:00
Elvish_Hunter
df3063ed70 [switch]: implemented checks for missing [case], variable= and value=, Lua part 2014-04-03 12:33:20 +02:00
Elvish_Hunter
7e4beb8630 Get rid of obsolete if_while_handler function 2014-04-03 12:30:22 +02:00
Elvish_Hunter
cf55cf84e6 [while]: added sanity checks for missing [do] tags 2014-04-03 12:28:17 +02:00
Elvish_Hunter
c81530509f Added [elseif] support, C++ part. This includes the missing [then] checks 2014-04-03 12:25:04 +02:00
Elvish_Hunter
2cff4662e2 Added [elseif] support, Lua part. Also included sanity checks for missing [then] tags inside [if] 2014-04-03 12:19:05 +02:00
Chris Beck
c9321455b2 update changelogs 2014-04-03 03:30:25 -04:00
Chris Beck
e6a852f4a4 use a single combo for quick replays / blindfold in mp lobby
this fixes up commit cb9d69aff4a37c8325b2c126e243812f2d91cfeb where we
introduced the second checkbox. it turns out that there isn't space for
this in 800w resolutions (reported as bug #21888)
2014-04-03 00:02:03 -04:00
gfgtdf
3acb4f22be temporarily disable check for backwards compatibility
this commit brings backwards compatibility between 1.13.0 and 1.13.0-dev
it should be reverted when 1.13.0 comes out.
2014-04-03 01:51:55 +02:00
gfgtdf
8617a02a88 Merge pull request #121 from gfgtdf/sync_2
sync, attack events, start/prestart and more

sync attack events, sync start/prestart, fix  gna.org/bugs/?20871, partly implement gna.org/bugs/?21697 fixing OOS related to [get_global_variable], unify the rng for attacks and other things, implement a third argument for wesnoth.synchronize_choice, implement the deterministic mode for sp. See https://github.com/wesnoth/wesnoth/pull/121 for full descrition.
2014-04-03 00:38:45 +02:00
gfgtdf
b4847d95e7 implement the deterministic mode for sp. part2
the player can now choose whether he want to play a new SP game in the
deterministic mode where he'll get the same results when he reloads a
game.

i think it would also be nice to enable the deterministic mode for MP for players with verybad network connection, because that would result in less network traffic but more options to cheat.
but i currently don't know enough about the mp connect code to that.
2014-04-02 23:43:28 +02:00
gfgtdf
8495ebceae implement the deterministic mode for sp. part1
I don't really know much about the gamestatus cpp/hpp file, so i just
copied from the difficulty code (to create the random_mode attribute).

I add the deterministic mode to the ui in another commit.
2014-04-02 23:43:16 +02: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
32a0583c1a add comment in replay.hpp 2014-04-02 23:38:56 +02:00
gfgtdf
0b60e2ca45 add skip_ally_sighted to replay
because this can affect the result of a move, we need this data in the
replay.
2014-04-02 23:38:43 +02:00
gfgtdf
838446c1ef rearrange comments and debuglogs 2014-04-02 23:38:31 +02:00
gfgtdf
8a539e0b5d correct the value of pos_ in replays. 2014-04-02 23:38:19 +02:00
gfgtdf
e7aae5a00f added a check for unit's destination in moves 2014-04-02 23:38:06 +02:00
gfgtdf
bd837f4d34 removed unused code 2014-04-02 23:37:53 +02:00
gfgtdf
d511933ded bring back unit_advancements_aspect
by moving code from synced_commands.cpp to actions/attack.cpp so that it
can be directly called from ai/actions.cpp
2014-04-02 23:37:41 +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
19cf6f5cd3 adding wesnoth.is_synced() #21697 2014-04-02 23:36:49 +02:00
gfgtdf
116afcda09 add from_side check for require_random
"from_side" is an attribute whose only purpose is to enable a check by
the server that a package is really sended by the side given in
"from_side", if thats not the case, the server sets an attribute
"side_invalid". The main purpose of this contruct is to disallow
cheating in mp.
2014-04-02 23:36:11 +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
gfgtdf
821dbd1cb8 use synced_context
these commit uses the synced_context in replays in and in attacks.
we also don't need to use expected_advanaments anymore, because advancements now run through get_user_choice.
Which was not posible before, because get_user_choice didn't work during attacks.

the main intention of these commits is to fix gna.org/bugs/?20871, gna.org/bugs/?21697, some OOS erros related to use of multiple
[get_global_variable] with different sides in one event.
To remove the deterministic random for traits and similar as discusssed
here http://forums.wesnoth.org/viewtopic.php?f=6&t=39611. And to sync
start end prestart events.

the file synced_commands.cpp is mosty code moved from replay.cpp with the main intention to make do_replay.cpp smaller. But also to be able to call run_in_synced_context from non replay if posible,
so that we can just use the same function syned_context::run_in_scned_context that we call during replays, but in most cases this won't be possible.

the file synced_checkup.cpp was written to replace get/set_random_results from rnadom.cpp which was used to check wether unit checksums and attacks results match the ones in the replay. And wasn't realy related to random.

We also use the new random generator which is automaticly synced during
the execution of scned_context::run_in_scned_context, and otherwise not.
So we cannot cause oos anymore by using rand= from an unsnced command
like "select"
Alternativeley we can also set the new random synced by using the new
RAII object set_sconext_sycned, this happens for example during prestart
events.
Unlike the old random generator, the new random generator is not
determinstic by default because it asks the server (or itself in a SP
game) for a new seed, at every side command (attack, move, recruit ...)
that requires random ,similar to how the previous rand for attacks
worked (it doesnt ask at the beginning, just the first time it is needed
unlinke how attacks worked before). That way we can also unify the rng
for attacks and for other random choices.

this commit breaks ai's advancement aspects, i'll bring it back in a later commit.

this commit is part of pr 121.
2014-04-02 23:34:55 +02:00
gfgtdf
7d3a42c7fa use synced context: sync the turn ... events and prestart events.
by using set_scontext_synced and recording brefore doing that.

we split fire_prestart and fire_preload becasue prestart runs in a synced context and fire preload not.

we also dont need recorder.pre_replay anymore becasue of the changes to the rng.

the line synced_context::run_in_synced_context("auto_shroud", replay_helper::get_auto_shroud(true));
was accidently placed in this commit and should rather be in the commit called "use synced_context in undo and rest"
this commit is part of pr 121.
2014-04-02 23:34:42 +02:00
gfgtdf
1f794e03d8 use synced_context: change get_user_input
previously and afterwards there can be 2 ways an action(attack, rectuit, move...) can be executed, the first way is that the action runs on the local client, and the action is sended over the network as soon as it is completed, this happends in recruits, moves, recall, and some more. The second way is that the action is sended over the network first and is then executed on all cielents simultaniously, this happends in attack events, and similar happends in prestart/start events. This is also why mp_sync didn work in this actions before: side 2 noticed that it needs data from side 1 but side 1 did send the execeution of the action before it generated the user_input data. That's why side 2 doesnt have the user input data at this point. Previously there was one special and very bugged case when the code waited for remote input before calling get_user_choice: [get_global_variable].

This commit moves (and fixes) the "waiting" from persist_var.cpp into get_user_choice so that the caller of get_user_choice don't have to worry about it. With this we can also use get_user_choice if we already sended data over the network. And we can enable the mp_sync in attack related events and prestart events. The intention of this commit is to fix fix http://gna.org/bugs/?20871.

the plan is to sync start and prestart events, so we don't need to check for that anymore,
we also don't need to pass the rng because we can use call random_new::generator->..

this commit is part of pr 121
2014-04-02 23:34:17 +02:00
gfgtdf
da4cdef146 use synced_context: fix mp observers
with the new synced_context system, the old code would bring code in the wrong order onto the replay if we received data during get_user_choice
which now could be called during turn_info::handle_turn.

also previous code would fail to process
[turn]
[command]
[move]
x = 3,4,5
y = 4,3,3
[/move]
[/command]
[/turn]
[turn]
[command]
dependent = yes
[input]
[/input]
[/command]
[/turn]
because [input] would be processed after [move] was processed, but
[move] need [input] on the replay to work properly.
(if luas sync_choice was called from a moveto event)

this commit is part or pr 121.
2014-04-02 23:34:04 +02:00
gfgtdf
75d81ee49c use new synced_context: use new rng
the plan is, that random_new::generator will be a object that does synced random calls during a synced context and otherwise not,
so that we cannot create OOS anymore by using random in unsynced actions like select event

the intention is also to unfy random calls for attacks and random calls and for other actions like traits and [set_variable] rand= .

the synced random generator will be set with the set_scontext_synced object.

the new rng will be similar to the old rng used for attacks becasue it will ask the server for a new seed for every new user action (=recruit, attack...) that requires random numbers.

Previously there were 2 different random generators, one for attacks, and one for other things, pr 121 is supposed to fix the problems with the "sending data over teh network first" an we try to throw the old rng for non attack things out. So that attacks and other tings use the same rng.

We use a new random generator which is automaticly synced during the execution of scned_context::run_in_scned_context, and otherwise not. So we cannot cause oos anymore by using rand= from an unsnced command like "select"
Alternativeley we can also set the new random synced by using the new RAII object set_sconext_sycned, this happens for example during prestart events.
Unlike the old random generator, the new random generator is not determinstic by default because it asks the server (or itself in a SP game) for a new seed, at every side command (attack, move, recruit ...) that requires random, similar to how the previous rand for attacks worked (it doesn't ask at the beginning, just the first time it is needed unlinke how attacks worked before). That way i can also use the same rng for attacks and for other random choices.

I also plan to move the code from set/get_random_results to syncec_checkup.cpp later.

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