53 Commits

Author SHA1 Message Date
Steve Cotton
99f27b7191 Make saved_game::expand_scenario() look correct, and add a const
This doesn't change the behavior - the changed line is in a conditional block
which tells us exactly which of scenario_id()'s code paths will happen, and it
will still end up using carryover_["next_scenario"]. The change is just making
it consistent with the way that other lines in expand_scenario() find out which
scenario id to use; it's preparing to load the next scenario, so it should use
that scenario's id to load any metadata, not the current scenario's id.

Also, scenario_id() should be const. This helps with refactoring out the
existence of a de-facto singleton instance of saved_game.
2020-11-16 04:52:24 +01:00
Pentarctagon
5a77a86330 Have mainline content send [multiplayer][addon] info as well.
This commit:
* sends the era and scenario as part of a [multiplayer][addon] in order to make it consistent with how add-ons' information is sent to wesnothd. this means all of the game's content information is now available in the [multiplayer][addon] data.
* correctly covers the case of there potentially being modifications added to mainline at some point. the current code looks at the [multiplayer]mp_scenario= and [multiplayer]mp_era attributes to cover the case of a mainline era/scenario being used, but looks for modifications only in the [multiplayer][addon] data, which wouldn't have any entry for a mainline modification right now if one were added.
2020-08-14 09:03:18 -05:00
gfgtdf
528dbccd94
support scenario files in map_file (#4804)
* support scenario files in map_file

Now a scenario generated by the scenario editor can be loaded
just like a simple map file.

fixes #4803
2020-03-15 13:24:26 +01:00
gfgtdf
7599746b25 put [resource] before other content (again); fixes #3345
Now content that is loaded via [load_resource] is placed to the position
where the [load_resource] was. This fixes a problem where previously one could
not use lua variables/functions created by the [resource][lua] because the
engine would put the [lua] tags from the [resource] after the [resource] from the
scenario.

This time it uses size_t indicies instad of vector iterators to prevent
possible bugs arisong from invalidating iterators when the size of the
vector changes.

This reverts commit b3e1680f886ec27c29150912bb27949d7cdd7f6e.

In the long run i think it might actually be better to allow [event] and
[lua] to have a order/priority attribute similar to lua on_event events.
Then this commit would probably not be needed anymore.
2018-10-18 19:25:49 +02:00
Jyrki Vesterinen
b3e1680f88 Revert "put [resource] before other content; fixes #3345"
This reverts commit 706740220957a9313909f5cc358ba5aba3bf4118.

The commit used the `pos` iterator after invalidating
it (passing an iterator to `config::add_child_at()`
invalidates it), resulting in undefined behavior.
2018-10-17 19:53:09 +03:00
josteph
d443df9be1 Commandline: Add --campaign-skip-story option
Fixes #3472

(cherry-picked from commit f7be872da24474a47894becd7c6d5f013c495a2f)
2018-10-07 03:25:19 +00:00
gfgtdf
7067402209 put [resource] before other content; fixes #3345
Now content that is loaded via [load_resource] is placed to the position
where the [load_resource] was. This fixes a problem where previously one could
not use lua variables/functions created by the [resource][lua] because the
engine would put the [lua] tags from the [resource] after the [resource] from the
scenario.

(cherry-picked from commit 1ac635ec63e775dcd1aa90d04b9adf3f061ef476)
2018-10-07 03:24:42 +00:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0678f40a209797d72dfaba3e5e88545
(cherry-picked from commit bc4d22dc72e79c3d6a3364ac896e473afd298246)
2018-10-07 03:23:36 +00:00
gfgtdf
5224eefa77 fix require_scenario=yes not working with map_generation
this fixes require_scenario=yes for scenarios that use map_generation or
scenario_generation, the problem was that create_engine does not call
saved_game::expand_scenario for random maps, (which is the function that
checks require_scenario=yes)

fixes #3105

(cherry-picked from commit a10287c5c2a49ff248f218c11f4061e472090089)
2018-10-07 03:21:26 +00:00
Charles Dang
8a4d1ad145 Saved Game: reame "starting pos" to "starting point" to avoid confusion
The old name was too easy to confuse with a side's map staring position, something
I've done several times.

(cherry-picked from commit 8f93d0a7c67f77e3917c5a24c55a9d450579a423)
2018-10-07 03:21:07 +00:00
Charles Dang
950a156712 Addressed most of the remaining whitespace issues from #2613
[ci skip]
2018-03-11 14:59:37 +11:00
Matthias Krüger
a2168d2e24 codespell fixes to /src 2018-02-08 21:54:09 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Charles Dang
b5934273ad Added non-member swap() functions for classes with member swap() functions
This is to enable them to work with std::swap.
2017-09-03 01:07:06 +11:00
Jyrki Vesterinen
670bcf71a3 Address a bunch of Coverity Scan warnings 2017-09-01 23:24:04 +03:00
Charles Dang
2101353d36 Convert include guards to the shorter #pragma once
Turns out I mistook @celticminstrel's opinion that we should use include guards over pragma (737916e).
Since all major compilers support `#pragma once`, there's no reason not to use it.

For future mergability reasons, this excludes src/spirit_po and src/xBRZ. It also excludes src/boost-patched.
2017-05-09 19:41:37 +11:00
Rikard Falkeborn
94e73a7ccc Add const to some more functions 2017-04-17 16:51:30 +11:00
Celtic Minstrel
b4dc11ce36 Belated 2017 copyright update 2017-03-19 10:05:38 -04:00
gfgtdf
4810e2c0ff add warning if current_player attribute is specified by wml
specifying this attribute in [side] can result in assertion failure.
2016-03-09 16:12:08 +01:00
Charles Dang
3baba9235e Add missing copyright notices 2016-02-29 22:43:06 +11:00
Elvish_Hunter
9b7b1751fd Removed trailing tabs and whitespaces from C++ source
I used this command line: find <source directory> -name \*.\[ch\]pp -print0 | xargs -0 sed -i 's/[[:blank:]]*$//'
2015-12-21 20:39:46 +01:00
gfgtdf
0769824821 fix [load_resource] tag
previously it didnt wokr corrently in modifications and eras.
2015-12-08 19:11:18 +01:00
gfgtdf
d3652e1b6d add [resource] tag simlar to mp modifications.
[scenario],[multiplayer],[era],[modification] and [campaign] can now
contain [load_resource] tags that will load [resource]s that are
toplevel tags similar to [modification] whose child tags will be copied
into the scenario.
2015-04-12 18:31:27 +02:00
gfgtdf
236227e967 refactor saved_game::set_default_save_id and rename 2015-03-26 19:12:15 +01:00
gfgtdf
a15867e634 less coping of configs when loading saved.
First we make saved_game assignment operator copy and swap.
This might increase performance in case where the copy elison can be aplied.

Second we add a set_data(config& ) method that moves the savefile cfg
into this object. And use that function in the loadgame class.
2015-03-07 01:32:35 +01:00
gfgtdf
bb0ecd14c0 recorder writes directly into saved_game object
Previously recorder had config memaber and saved_game had a config
memeber.
And when saving a game the config was copied from recorder to saved_game
and the other way when loading a game.

Now the recorder object directly writes into the saved_game object. This
saves some copying when saving and loading data.

I also moved the pos_ variable from the recorder object to the
saved_game replay_recorder_base object, This fixes a bug where saving a
game during a replay also caused to not yet played turns to be written
into the savefile.
2015-03-06 05:19:31 +01:00
gfgtdf
0da5b24a76 copy snapshot less often when saving
First we remove the snapshot_ memaber form savegame class which was
previously copied with saved_game.set_snapshot

Second we use copy and swap in saved_game::set_snapshot
saved_game::set_scenario, this makes it possible to apply copy elison
and saves another copy of the snapshot if the compiler is smart enough.
2015-02-13 21:01:29 +01:00
gfgtdf
26cce3d1cd add comment 2015-02-13 21:01:22 +01:00
gfgtdf
10af811493 fix assertion failure on random scenario generation
the connect_engine.cpp code assumed that save_id was already set, which
wasnt the case if we used scenario_generation becasue the setting of
save_id in expand_scenario might be overwritten in
expand_random_scenario.
2015-01-31 22:57:48 +01:00
gfgtdf
14616607f5 fix some spelling in comments. 2014-12-29 22:48:16 +01:00
gfgtdf
05afcd4dff remove saved_game operator =
this assignment operator is not better than the defult operator.
2014-10-30 02:32:57 +01:00
gfgtdf
cc526e9737 remove unused function 2014-10-30 01:46:06 +01:00
gfgtdf
618cc110b3 move some savegame manipulation to saved_game.cpp 2014-10-26 02:38:43 +02:00
gfgtdf
f092b2a1ce update comments in saved_game.hpp 2014-09-10 15:07:20 +02:00
gfgtdf
ab0dc2466d using a bool to remember whether we expanded carryover
instead of having 2 objects from which exactly one is empty and then
check by using empty().
2014-08-01 01:41:58 +02:00
gfgtdf
35e1391652 make saved_game::carryoves_sides(_start) private 2014-08-01 01:38:50 +02:00
Mark de Wever
c119584895 Strip trailing whitespace. 2014-07-13 12:41:43 +02:00
gfgtdf
139d6252dd add update_label function to saved_game 2014-06-27 05:17:39 +02:00
gfgtdf
78e1916e68 fixup build after 'remove unused functions + fix comments' 2014-06-25 21:00:55 +02:00
gfgtdf
467ea33855 remove unused functions + fix comments 2014-06-25 18:02:04 +02:00
gfgtdf
d1ec28507e more log on corrupt saves 2014-06-17 19:53:10 +02:00
gfgtdf
63c07fea3e move game_classification to its own file 2014-06-17 00:12:42 +02:00
gfgtdf
976d990804 fix random map generation
this was previously broken because we passed a temporary pointer to
generate_map. While fixing this i moved it to saved_game.cpp

i also added a call to expand_random_scenario in mp_game_utils so that
in a mp campaign players advance to the next scenario which is randomly
generated. they have all the same scenario.
2014-06-15 17:31:15 +02:00
gfgtdf
d9c6d18a63 fix [option]s/[events]s in [modification]s and [era]
this was broken by a commite earlier by me.

We now add them to teh scenario in saved_game.cpp and not in the mp
code. The reason is that we stil want them to work if a mp campaign game
was reloaded in sp.
2014-06-15 17:30:54 +02:00
gfgtdf
7e3b5c199a add not_corrupt() function in saved_game class
and add comments about other functions.
2014-06-15 17:30:02 +02:00
gfgtdf
728b29dc61 make wesnothd use savefile format for new games
This patch changes the mp wesnothd protocol.

multiplayer connect now works as following:
multiplayer_create/configure creates saved_game object which is then
loaded by mp_connect and sended to the server in the usual savefile
format, this especially implies that [side] are no longer at toplevel
but instead nested into [scenario] or [snapshot].

mp options are saved into state (the saved_game object)
(state_.mp_settings()) previously we had a separate mp_settings object
for that now we only have one mp_setting object.

This commit still not fixes mp modification/era events/options. The
reason is, that i want to move the expansion of those to saved_game.cpp
for better compatibility to Sp (Especially make era events work in mp games
reloaded in sp), but if that won't work i'll just enable them how they
were before.

There  are still some things to do. Especially the server generated
replay-saves will be completely broken. (will fix in another commit)

we don't use the [replay_start] as starting pos in mp anymore so i removed
2 lines in playcampaign that assumed that.

I also removed soem code in mo_game_utils that seemed redundant, bugged or useless

since we now send the [carryover_sides_start] over the network too there
is no reason to apply [carryover_sides_start] before getting into
mp_connect engine (when advanging the the next scenario), even more,
since the new code expects only ONE of [carryover_sides_start] or
[carryover_sides] to be present, we cannot expand carryover_sides_start
in playcampaign before going to mp_connect because we might wan to modify
[carryover_sides_start] in mp_connect

still TODO:
* rename mp::configure::get_parameters
* reimplement mp modification/era s events/options
* remove fields from the mp_game_settings object
* remove disabled/outcommented code
2014-06-15 17:29:17 +02:00
gfgtdf
dd7dca975d fixup scenario advancing
the "gamestate().remove_snapshot();" is unneded and would undo the
"gamestate().set_snapshot();" in playcampaign
2014-06-15 17:00:54 +02:00
gfgtdf
9e40b26219 load replay from [scenario] if [replay_start] is not present
the intention is to change the serverside generated replays to contain
[scenario] & [carryover_sides_start] & [replay]. [replay_start] would
be wrong because carryover isn't expanded in these servergenerated
saves.

Servergenerated saves from reloaded (non start of scenario) games will
then contain  [replay_start] & [carryover_sides] & [replay]
2014-06-15 17:00:50 +02:00
gfgtdf
5bfce15789 move carryover handling out of playcampaign.cpp
this also makes a small change in the savefile format: [endlevel] ->
[end_level_data] in snapshots.

we still have the "store_carryover" function in playcampaign.cpp which does the visual message.
Note that the real carryover happens after linger mode while that message happens before linger mode this simplifies linger mode saves.
2014-06-15 17:00:43 +02:00
gfgtdf
29f84b0d74 move more code playcampaign -> saved_game
also removes some out commented code.
2014-06-15 17:00:41 +02:00