478 Commits

Author SHA1 Message Date
Charles Dang
545253ec2b Don't warn that user_team_name is unrecognized (yet) 2015-10-26 12:47:22 +11:00
Charles Dang
1215f65eb8 Fixed team_id/team_name not being set correctly in new format 2015-10-26 12:40:43 +11:00
Charles Dang
3781e7839f Rename team_name/user_team_name to team_id/team_name (old syntax still valid) 2015-10-26 00:44:28 +11:00
gfgtdf
5438ec8a48 side specific variables.
http://gna.org/bugs/?23490

This makes it possible to store variables inside the side with the lua
functions get/set_side_variable. These variables are carried over along
other side specific data(units, gold)
2015-10-08 22:29:17 +02:00
gfgtdf
49219ad0fd add team share_vision=all/shroud/none
previously there were 2 flags share_view=yes/no and share_maps=yes/no,
but only 3 possible settings (share both, share none, only share shroud)
(so share_maps= was ignored if share_viewv=yes). This made the wml code and
the c++ code needlessly complicated.

Now these 2 flags are replaced by share_vision=all/shroud/none
2015-07-23 14:00:08 +02:00
gfgtdf
2d80c97b13 use synced choices for controller changes by wml
Using synced_context::ask_server_choice has some advantages over the
previous implementation:

Instead of calculating which client controls a side separately on each
client, we now calculate that on the server and send the result to the
clients. This makes it more robust against calculation mismatches on the
clients (OOS).

The mechanism which notifies the server about controller changes is more
robust because previously only the currently active side sent that message
to the server, but now all clients send that information to the server (and
the server ignores non-first notifications). Specially this fixes the rare
case that none of the clients control the currently active client during
that event (which can for example happen if the currently active side
disconnected from the game after the action was invoked but before the side
was modified on that client.).

We automatically get non-undoability (just like for random seed requests)
2015-07-08 03:02:26 +02:00
gfgtdf
6aa3b3bc9a don't check team names on serverside
http://gna.org/bugs/?23028

previously clients could add a "team_name" to specific packages which
should only be redirect to sides in this team. But the serversided code
which calculated in which team a side was had some bugs:
1) It did not correctly handle sides that were in multiple teams
([side] team_name="team1,team2"...)
2) The serversided data about teams was not updated when wml changed the
teams, also the calculation which side was controlled by a human used
posssibly oudated information.

This commit moves this calculation to the sending client so that the
clients now must specify a list of sides to which the package should be
sended.
2015-06-10 14:26:07 +02:00
gfgtdf
a2b5c18d05 add attribute_value::to_enum and attribute_value::operator=(enum)
which convert attribute_values to classes generated by MAKE_ENUM makro.
2015-06-04 02:09:49 +02:00
gfgtdf
da1c8bf60e rewrite MAKE_ENUM macro
Instead of creating an enum, the MAKE_ENUM macro now creates a struct
which holds an enum and provides functions for enum <-> string
conversion.

This has multiple advantages:
1) We don't need MAKE_ENUM_STREAM_OPS anymore.
2) The generated struct is much easier to use in templates
3) We don't allow implicit to int conversions anymore.
4) The enum values are now declared inside the structs scope.
2015-06-04 02:08:02 +02:00
Charles Dang
759ab3d4cb Removed unused (as of 430eab79fc15) copy_ally_shroud function 2015-06-04 03:55:35 +11:00
Chris Beck
729126e033 add "disallow_shuffle" attribute to [side]
which causes them to be ignored by the "shuffle_sides" phase,
regardless of the heuristic used by the connect engine
2015-04-08 22:24:20 -04:00
aquileia
ba2def989c Fixup e5814560be for C++98 2015-04-09 02:01:22 +02:00
aquileia
e5814560be Fix boost list_of -> flat_set conversion on MSVC 2015-04-08 22:57:13 +02:00
gfgtdf
68eaaad4fb use flat_set for team::attributes
boost::container::flat_set aka sorted vector is much faster than
set::set for iteration, faster for lookup and much slower for
insertion,.

Since we only use team::attributes by iterating over its elements and
never insert elements into it  after we create it, it makes sense to use
flat_set here.
2015-03-26 22:31:33 +01:00
gfgtdf
c1a052714b add carryover_add and carryover_percentage to team::attributes list 2015-03-26 22:20:47 +01:00
gfgtdf
280dd8e7ed fix some indention 2015-03-22 01:39:55 +01:00
gfgtdf
fe9b02059b fix 'persistent' member of team class
prviously it depended on whether a team was local or not.
2015-03-03 21:55:49 +01:00
Chris Beck
e89f52ca5c bug #23188: check the game events for NULL when capturing villages
This is a minor change in that village capture events won't be
fired during team building, whereas in 1.12 it appears that they
would be.
2015-02-28 22:15:50 -05:00
gfgtdf
7471b4eeec add side specific results in [endlevel]
adds [result] tags in [endlevel] as suggested in
http://gna.org/bugs/?4960
the following [endlevel] attributes can now be given side spcific:
'result', 'bonus', 'carryover_precentage', 'carryover_add'

In the normnal case we show a victory message on a client if any of the
local humans is victorious, but we have to watch out for border cases
like when there are no human sides and behave just like we did
previously in this case.

This also fixes a bug that the calculated carryover could be different
from what is shown in the message (see comment in playcampaign.cpp that
was removed by this commit)

This also removes some unused functions in carryover.cpp that were
incompatible with this commit.
2015-02-11 22:40:32 +01:00
gfgtdf
92bf33174b remove unused member variable 2015-02-11 22:40:31 +01:00
Ignacio R. Morelle
57ae45387a New Year copyright update 2015-01-01 19:07:35 -03:00
gfgtdf
9f28fc8f37 don't do variable subsitution when parsing [team][village]
Becasue are no posibilities to change the variables or the positions of
the villages before this code happens, i cannot see any common usecase
for this feature, Also it's not documented in the wiki.

Note that it is of course still possible to change village owners
depending on variables in a prestart event.
2014-12-31 15:02:56 +01:00
gfgtdf
9b7b0f3861 use utils::join 2014-12-31 15:02:55 +01:00
Chris Beck
3c69e774f9 fix strict compilation (fixes up HEAD^) 2014-12-22 00:34:53 -05:00
Chris Beck
5732ed504d add proxy_controller type to teams
Proxy controller is a field of team, parallel to controller, but
intended only as an interface option and should not be visible to
wml / lua, nor synced with other players or the server, nor saved
in savefiles. The proxy controller indicates "who is making the
moves" rather than "who is getting credit for it". The controller
type, by contrast, affects the victory / defeat results of a
scenario and needs to be synced so that all players can save the
game and get sane controller types when they reload.

Currently the proxy controller only affects human controlled sides,
although in principle it could be changed to affect AI sides also.
(temporarily make an AI side human controlled?)

This commit changes the implementation of "idle" sides to use
proxy controller instead of controller, which is much cleaner and
reduces complications. It changes the ":droid" and ":idle" commands
to use it also.

After this commit, there is no way to actually change controller
types between AI and HUMAN as far as I know. We could consider to
add commands :make_ai / :make_human for this purpose.
2014-12-21 23:13:48 -05:00
Chris Beck
f5481ce961 make game_events::pump not a singleton
Instances of this are now owned by the manager.

It would be nice to refactor this to provide all of the front-
facing methods in the manager instead of in the pump, since the
pump itself is somewhat an implementation detail. But this is
nearly the "smallest" diff change that would remove the singleton
restriction.
2014-12-14 20:50:40 -05:00
gfgtdf
a1d27250c8 simplify use of config_of 2 2014-12-10 00:31:04 +01:00
gfgtdf
6dee1366a5 notify server of wml controller changes
Previously this scenario would have resulted in OOS, becasue of the content of the "side turn" event:

[scenario]
	id= "03_MANYSIDES_TEST"
	name= _ "MP Sides Test"
	description= _ "This secnario is for testing side numbers"
	map_data= "border_size=1
usage=map

Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg
Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg
Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg
Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg, Ch, Ch, Gg, Ch, Ch, Gg, Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg
Rr^Vhc, Rr^Vhc, Rr^Vhc, 1 Kh, Ch, Gg, Gg, Gg, Ch, 2 Kh, Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg
Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg, Gg, Ch, Gg, Ch, Gg, Gg, Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg
Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg
Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg
Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Rr^Vhc, Rr^Vhc, Rr^Vhc, Gg"

	experience_modifier=20%
	turns=-1
	{DEFAULT_SCHEDULE}
	allow_new_game = yes
	[side]
		side={NUMBER}
		id= "leader{NUMBER}"
		save_id= "leader{NUMBER}"
		controller={CONTROLLER}
		team_name={TEAMNAME}
		type = "Elvish Archer"
		canrecruit="yes"
		village_gold=5
		income=10
		share_maps=yes
		share_view=yes
        shroud=yes
		gold=200
		experience=40
		recruit=Elvish Archer,Elvish Fighter,Elvish Scout,Elvish Shaman
		x,y = {X} ,{Y}
	[/side]
	{NORMALSIDE  1 "human" "good" 3  2 }
	{NORMALSIDE  2 "ai" "evil" 4  2 }
	{NORMALSIDE  3 "human" "good" 5  2 }
	{NORMALSIDE  4 "ai" "evil" 6  2 }
	{NORMALSIDE  5 "human" "good" 7  2 }
	{NORMALSIDE  6 "ai" "evil" 8  2 }
	{NORMALSIDE  7 "human" "good" 9  3 }
	{NORMALSIDE  8 "ai" "evil" 9  3 }
	{NORMALSIDE  9 "human" "good" 3  6 }
	{NORMALSIDE 10 "ai" "evil" 4  6 }
	{NORMALSIDE 11 "human" "good" 5  6 }
	{NORMALSIDE 12 "ai" "evil" 6  6 }
	{NORMALSIDE 13 "human" "good" 7  6 }
	{NORMALSIDE 14 "ai" "evil" 3  6 }
	{NORMALSIDE 15 "human" "good" 9  6 }
	{NORMALSIDE 16 "ai" "evil" 10 6 }
	[event]
		name = "side turn"
		first_time_only = no
		[lua]
		code = <<
			local helper = wesnoth.require("lua/helper.lua")
			local controller = helper.rand("human,ai,null")
			local side_num = wesnoth.current.side + 1
			if side_num > #wesnoth.get_sides({}) then side_num = 1 end
			wesnoth.sides[side_num].controller = controller
		>>
		[/lua]
	[/event]
[/scenario]
2014-11-16 19:31:17 +01:00
gfgtdf
78ae2f2768 read lost= from [team] when loading a savefile
from 73f1a0c0875fa511c68c18b197d76b1bdf9e1e80 in 1.12
2014-10-15 00:37:28 +02:00
Chris Beck
7e2e63bd5e fix bug: description is a known attribute of team
This fixes a problem where faction description would overwrite the
leader's unit type description.
2014-07-22 20:43:40 -04:00
Chris Beck
4286b13a79 team::build takes a pointer to the game_data obj we want to use
This eliminates another use of resources:: in class team
2014-07-06 18:45:30 -04:00
Chris Beck
6f4763ce04 get_village takes a pointer to variable set when fire_event desired 2014-07-06 18:16:40 -04:00
Chris Beck
d64c296edc remove pointless "team::nteams()" static getter 2014-07-06 16:59:56 -04:00
Chris Beck
e3d34a34be remove pointless static singleton getter for teams 2014-07-06 16:19:49 -04:00
Chris Beck
e62553139c move is_observer to gameboard, with accessor in playcontroller 2014-06-26 00:40:53 -04:00
Chris Beck
f5a9de40d5 move village_owner function to display_context
I would have liked to put it in game_board, but it is needed for
reports so it can't go there
2014-06-25 22:22:07 -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
06f02b52c5 add fake_unit_manager, split off from game_display object
This commit adds two classes -- fake_unit, and fake_unit_manager,
both split off from code contained in game_display. The display
object is reconfigured to hold a pointer to the manager and
display the units it contains. The rest of the code is configured
to add fake units to the manager, not the display.

This improves encapsulation and helps to reduce the game_display
class.
2014-06-16 17:31:38 -04: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
Chris Beck
8b6339af9b move code managing preference encounters out of play controller 2014-06-01 08:41:32 -04:00
Chris Beck
30c179b92d refactor enum casts: prefer lexical cast default and cfg["x"].str() 2014-05-27 03:44:23 -04:00
Chris Beck
9ac310e191 team::controller enum to use MAKE_ENUM macro 2014-05-25 16:22:55 -04:00
Chris Beck
986a872287 failed conversion of enums results in error dialog, in debug mode
The make_enum macro header now includes wml_exception.hpp, and
game_config. We use the FAIL macro to launch a transient
twml_exception dialog when an enum is casted from an illegal
string value. This means that when enums in our C++ classes are
initialized using lexical_cast<enum_type> (cfg["attribute"]),
we will automatically give error reports for bad values.
2014-05-25 03:11:46 -04:00
Chris Beck
ea428a506c refactor team to use MAKE_ENUM macro for team::DEFEAT_CONDITION 2014-05-24 14:59:21 -04:00
Chris Beck
f09d405629 cleanup previous two find and replace results
Just wanted to remove the empty strings that got created:

find . -type f -exec sed -i 's/<< "" <</<</g' '{}' \;

find . -type f -exec sed -i 's/<<"" <</<</g' '{}' \;

I also unstaged tools/schema/tags.cpp, since I don't think I changed
that.
2014-05-20 15:54:16 -04:00
Chris Beck
03a956d05c Make sure all warning logs are flushed, so travis gets the results.
This is the result of running command, in src/,

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

and inspecting the results.

Also ran this subsequently:

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

which only affected render.cpp
2014-05-20 15:48:36 -04:00
gfgtdf
8dbeefef9a rename values of [side]defeat_condition=
most likely defeat_condition= will re renamed too defeat= too.
2014-05-20 04:01:48 +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
Chris Beck
c81d4b0916 STL-ize an odd, null terminated static const char * [] 2014-05-13 23:09:53 -04:00