59212 Commits

Author SHA1 Message Date
gfgtdf
009403ae3e simplify wesnothd::game::change_controller 2014-11-18 04:38:09 +01:00
Chris Beck
fa54d659ef server: catch invalid utf8 exceptions
issue reported by coverity
2014-11-17 19:43:50 -05:00
Chris Beck
c150a47e93 catch boost::bad_function_call exceptions in server command handler
Don't know if this can actually happen in practice but it is
reported by coverity.
2014-11-17 19:11:37 -05:00
Chris Beck
f6bdc94ccd replace many lexical_cast with lexical_cast_default
This is to avoid bad_lexical_cast exception. I'm not sure if in
any cases this could actually have thrown but it's better to be
safe.
2014-11-17 18:55:17 -05:00
Chris Beck
1a0d9a0985 fix an uncaught bad lexical cast exception
coverity reports that it would crash the server
2014-11-17 18:50:04 -05:00
Chris Beck
67eb086736 fixup caeaa6ba67ed0e05220e189c12df768479320e01
variable reorder warning
2014-11-17 18:44:14 -05:00
Chris Beck
caeaa6ba67 refactor lua show_dialog
The lua show dialog used to get the video object from resources,
which is not ideal. In this version, lua kernel base internalizes
a pointer to the video object, and show_dialog is bound to a
method of the lua kernel base.

From now on, lua kernels which want to show dialogs need to be
constructed with a pointer to a CVideo, if it is null the lua will
fail with a runtime error.

The application lua kernel is constructed with the video for
game_launcher, and the game lua kernel is modified so that it is
owned by the play controller and not the game events manager, and
held in a boost scoped pointer rather than manually deleted. This
is because the game events manager doesn't have a video object,
also it conceptually seems independent of the lua kernel anyways.

The map generator lua kernels are constructed with NULL, but if a
user configuration dialog is provided (new feature) then when they
try to run it they will update with the mp_create's video pointer.
2014-11-17 17:03:00 -05:00
Chris Beck
968d8a900d add an assert to detect possible division by zero
issue found by coverity
2014-11-17 14:35:20 -05:00
Chris Beck
9f69a5196e add gui2 unit tests for advanced_graphics_options, mp_alerts dialogs 2014-11-17 14:08:39 -05:00
Chris Beck
f621233cc2 tlua_interpreter: add some asserts for null pointers 2014-11-17 13:55:11 -05:00
gfgtdf
80ca2ec06a fixup a comment 2014-11-17 18:52:39 +01:00
gfgtdf
b3d74c482f check "from_side" in wesnothd::game::is_legal_command
previously this was done outside of is_legal_command becasue
is_legal_command wasn't applied to the currently active side.
2014-11-17 18:13:30 +01:00
gfgtdf
2ea7c1e09d refactor wesnothd::game::is_legal_command 2014-11-17 18:13:29 +01:00
gfgtdf
db31880012 only allow "dependent" commands for players
previously this was also allowed for teh host regardless whether he is a
player or not.
2014-11-17 18:13:27 +01:00
gfgtdf
2944051f83 remove old server compability code
the code that was previously outcommented was outcommented for 1.11.13
compability.

we shouldn't always allow "global_variable", "global_vaiable" falls into
the "dependent" category and should only be allowed if we have a
"from_side" attribute.
2014-11-17 18:13:26 +01:00
gfgtdf
7651676c3c add comment 2014-11-17 18:13:25 +01:00
gfgtdf
2435976575 don't create blank attributes in replay.cpp 2014-11-17 18:13:23 +01:00
Chris Beck
9eb72f5cb5 clean up gui2 dialog "lua interpreter"
- There were some bad comments and includes
- Moved all implementation details out of header
- Split up functionality into model / view / controller style
- Fix copyright statement
- Add many code comments to cpp file
2014-11-17 04:40:15 -05:00
gfgtdf
59860ca9b2 remove unused wesnothd code
[wait_global] was part of the pre 1.11.13 mp sync code.
2014-11-17 03:22:54 +01:00
Ignacio R. Morelle
a36bc41e36 Rename falcon race icon so the editor can actually find it 2014-11-16 21:22:27 -03:00
Ignacio R. Morelle
53833dd0c3 Remove pointless debug output, part of the team color implementation
The output is formatted even when the engine logdomain severity is less
than 'debug', which is bad. It also doesn't really reflect the objects
in question accurately since it uses values from a synthetic palette
that isn't actually used.
2014-11-16 21:20:44 -03:00
gfgtdf
262fc819ea fixup a65752a67
obviously we also wanted to sync network if there wasn't any
exception....

fixes up
a65752a676
2014-11-16 22:22:55 +01:00
gfgtdf
b487985255 Update changelog 2014-11-16 21:16:03 +01:00
gfgtdf
a65752a676 remove class with throwing destructor 2014-11-16 19:53:33 +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
50d2b133ec Merge pull request #333 from gfgtdf/wesnothd_sides
don't limit server max sides
2014-11-16 16:24:24 +01:00
gfgtdf
a53594b2b1 remove outcommented code 2014-11-16 04:53:54 +01:00
gfgtdf
10b2c0d9be fix mp connect colors
i actualy didnt test whether this casues bugs. But we use color to set
the value of combo_color_ combobox which has only MAX_PLAYER number of
options.
2014-11-16 04:53:53 +01:00
gfgtdf
f6065d3da9 don't limit server max sides
there are 2 reasons why the maximum side number is limited in some
contexts:
1) The map format can only store 9 starting positions
2) only the first 9 sides have default colors.

However, 'color' and 'starting position' are both sideproperties that
can explicitly given by wml if needed. And the server doesn't use any of
them, so i see no reason why the server should reject those games.
2014-11-16 04:53:23 +01:00
mattsc
7c71f81ed0 Update Xcode project file 2014-11-15 14:55:35 -08:00
gfgtdf
b1160fe451 add static to a local function. 2014-11-15 23:49:56 +01:00
gfgtdf
7fdc1eed56 fix mp reloading
the previous code tried to read "playing_team" from [multiplayer]. This
reulted in bug when reloading when it's not side1's turn.
2014-11-15 18:58:42 +01:00
gfgtdf
97bf7a08e2 use .size() instead of counting manually 2014-11-15 18:38:00 +01:00
gfgtdf
076c6ef75f remove unneeded check
comparing nsides_ here isn't needed becasue nsides_ cannot change inside
that loop.
2014-11-15 15:56:10 +01:00
gfgtdf
113c8d8504 don't print blank attribute values
blank values have no string representation, the are more temporary
values created becasue someone wanted to put something in them but then
thought different.

writing and reading them caused then to be converted to empty string
values which is something diffrerent.
2014-11-15 15:50:18 +01:00
gfgtdf
8c9a738b54 don't limit gold and income in mpconnect if not neeeded
partly fixes http://gna.org/bugs/?22485.
2014-11-15 15:49:14 +01:00
gfgtdf
e5c5839109 limit variable scopes
knowing that those varaiables aren't used later down makdes the code
easier to understand.
2014-11-15 15:48:59 +01:00
gfgtdf
ec1e0f22f2 use sides_.size() instead of MAX_PLAYES
we usualy want to use that number to index the sides_ vector so
comparing against sides_.size() makes more sense.
We now also use side_index for the index of the side in sides_ and
side_num for the value of side_cfg["side"]
I also put some additional checks.
2014-11-15 15:47:52 +01:00
gfgtdf
622d4c1313 fix config::get_diff 2014-11-15 15:47:51 +01:00
Nils Kneuper
fd9bfbc42d updated Russian translation 2014-11-15 10:39:08 +01:00
gfgtdf
64edd3d100 remove part of anicent wesnothserver implementation
in ~wesnoth1.4 wesnoth game had a simple server implementation which was
removed becasue it was buggy and wesnothd was better.

The code i removed here was a relict of that implementation.
2014-11-15 03:05:55 +01:00
gfgtdf
bb9b00b770 fix value of "current_player" in mp_connect 2014-11-14 23:10:52 +01:00
gfgtdf
8a6a3cc476 fixup user_description generation 2014-11-14 20:46:06 +01:00
gfgtdf
48fa14d49c "Anonymous local player" -> "Anonymous player"
this string is displayed by non hosts too, so "local" is not true since
it's not local from the other clients point of view.
Also the previous string was too large for a unit name in the sidebar.
Note that this does not effect the "Local player" string in the hosts mp
connect controller options.
2014-11-14 19:34:26 +01:00
gfgtdf
af89a91de7 fix [side]controller= in mp_connect
this was broken in the commit "make "player_id" the controlling client's
id for ai sides"
2014-11-14 19:21:09 +01:00
gfgtdf
7da44d91dc fix segfault in [replace_map]
a default constructed vconfig was previously unable to be derefereced,
Now it can be dereferenced.
The previous behaviour led to segfaults on wrong parameters to
[replace_map].
2014-11-14 19:21:08 +01:00
gfgtdf
027dc80c4d remove unneeded check
"save_id" isn't used to detemine which clients controlls which side. So
this check doesnt make sense.
2014-11-14 19:21:06 +01:00
gfgtdf
1d6d7a9c1d fix leader names in mp
"name" is here the name of the leader, previously the flg manager set it
to the name of the faction.
2014-11-14 19:21:05 +01:00
gfgtdf
69829d6b66 simplify serversided controller tweaks
we also simplify the code by using [side]player_id= which is always the controlling client id so we don't have to distinguish between "ai", "human" and "network"

the client never sends controller="network_ai" becasue the mp connect engine converts all "network_ai" into "ai". But the serversided controller tweaks convert "ai" into "network_ai".
2014-11-14 19:21:04 +01:00
gfgtdf
9833fa4657 make "player_id" the controlling client's id for ai sides.
the main intention is to simplify the serversided contoller tweaks.
2014-11-14 19:21:03 +01:00