1252 Commits

Author SHA1 Message Date
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
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
a53594b2b1 remove outcommented code 2014-11-16 04:53:54 +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
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
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
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
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
Chris Beck
da4074e882 use boost mersenne twister rng, add boost::random dependency
This is a squash of work done in april, see closed github pull
request. #160
2014-11-03 11:24:24 -05:00
gfgtdf
081cb8f6cc add a comment. 2014-11-01 22:37:16 +01:00
gfgtdf
c2d61b3595 fix some copyright notices 2014-10-31 22:35:45 +01:00
Alexander van Gessel (AI0867)
e5cb79b8e9 Move everything in src/filesystem.hpp into its own namespace
This is a chearry pick by me (gfgtdf) of 66176b1738. It differes a lot from the original becasue since there were so much merging conflics i decided to do it mostly from scratch.

Conflicts:
	src/addon/manager.cpp
	src/addon/manager_ui.cpp
	src/campaign_server/campaign_server.cpp
	src/config_cache.cpp
	src/create_engine.cpp
	src/editor/map/context_manager.cpp
	src/editor/map/map_context.cpp
	src/font.cpp
	src/game_config_manager.cpp
	src/gamestatus.cpp
	src/gui/dialogs/editor/custom_tod.cpp
	src/gui/dialogs/lobby/lobby_data.cpp
	src/gui/dialogs/mp_create_game.cpp
	src/gui/widgets/settings.cpp
	src/hotkeys.cpp
	src/image.cpp
	src/multiplayer_lobby.cpp
	src/network.cpp
	src/playcampaign.cpp
	src/preferences.cpp
	src/savegame.cpp
	src/serialization/preprocessor.cpp
	src/tests/main.cpp
	src/wesnoth.cpp
	src/widgets/button.cpp
2014-10-13 18:31:18 +02:00
gfgtdf
6c19b3e865 remove server compability code for 1.11.12
this causes stderr warnings.
2014-07-16 22:38:57 +02: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
Mark de Wever
c119584895 Strip trailing whitespace. 2014-07-13 12:41:43 +02:00
Alexander van Gessel
d8aea90eaa Merge pull request #224 from AI0867/wesnothd_memory_leak
Fix a memory leak in forum_user_handler
2014-07-01 03:51:08 +02:00
Alexander van Gessel
34da068c61 Merge pull request #225 from AI0867/wesnothd_memory_leak2
Fix memory leak in wesnothd
2014-07-01 03:49:47 +02:00
Chris Beck
cc04fc4310 fixup potential null dereference in server code
If a client submitted a bad message it would cause the server to
crash.

Issue found by coverity.
2014-06-29 15:00:49 -04:00
gfgtdf
9ba544c23c fix a comment that contained an invalid char. 2014-06-29 20:25:13 +02:00
Chris Beck
32dc07478f revert and fixup boost/function.hpp external include guards 2014-06-29 11:40:53 -04:00
Chris Beck
ae39fe4e8a Revert "put include guards on boost/function"
This reverts commit 8f0fe88635c0a06969b7f49b13e4fb74b066b317.
2014-06-29 11:07:25 -04:00
Alexander van Gessel
907d34820b Add a comment explaining the use of boost::shared_ptr 2014-06-28 17:20:37 +02:00
Ignacio R. Morelle
90e9ec3b2f wesnothd/fuh: Fix instances of std::string initialized from time_t(0)
Fixes the build with the fuh enabled on clang 3.3:

> src/server/forum_user_handler.cpp:206:10: error: expression which evaluates to zero treated as a null pointer constant of type 'const char *' [-Werror,-Wnon-literal-null-conversion]
>   return time_t(0);
>          ^~~~~~~~~
> src/server/forum_user_handler.cpp:215:10: error: expression which evaluates to zero treated as a null pointer constant of type 'const char *' [-Werror,-Wnon-literal-null-conversion]
>   return time_t(0);
>          ^~~~~~~~~

A time_t(0) is cast equivalently to a null pointer, and an empty C
string is equivalent to a null pointer for std::string instantiation.
2014-06-26 19:58:44 -04:00
Alexander van Gessel
564c7190ec Fix memory leak in wesnothd 2014-06-26 19:36:27 +02:00
Alexander van Gessel
fe52ab3989 Fix a memory leak in forum_user_handler 2014-06-26 18:14:51 +02:00
Ignacio R. Morelle
6629fdf64e wesnothd: Only reset the commands FIFO stream when reloading if needed
May or may not fix the issue noted in commit
62eb55a5a712b3e2157cf7fc0bb12873c4f0a574 regarding the SIGHUP handler,
which is in charge of scheduling load_config() to run. Rather
unfortunately, I'm unable to reproduce the issue on my own machine, so
I'll have to take this to production and test it live.
2014-06-24 20:47:58 -04:00
gfgtdf
bc26958d06 readd mp_game_title key
to servergenerated replaysaves.

idk where its used but i was told that readding it is a good idea.
2014-06-24 01:24:02 +02:00
Mark de Wever
ef104ed833 Fix Clang documentation warnings.
The string //<< is seen as documentation comment instead of normal
comment.
2014-06-21 12:21:12 +02:00
gfgtdf
0e3b185f62 fix servergenerated replays
if this is a reloaded game then we dont need to add [start]
2014-06-19 22:00:44 +02:00
Chris Beck
8f0fe88635 put include guards on boost/function
According to clang boost/function.hpp does not have include guards,
and from inspecting clang diagnostics we include it many times
in several compilation units. This commit adds an external include
guard to all of our includes of this header, it was made using

find . -type f -exec sed -i 's/^#include <boost\/function\.hpp>$/\n#ifndef I

and inspecting the results.
2014-06-19 13:58:58 -04:00
gfgtdf
ac9628e3cf fix servergenerated replays
I also removed 'mp_game_title' because if i leave it, it casues an 'attributes not in order' error since level_ contains attributes. Idk what it does so i removed it. if we want it we should write in into level_
2014-06-15 17:29:52 +02:00
gfgtdf
7172e43cf8 make wesnothd use savefile format for new games
the serverside part
2014-06-15 17:29:28 +02:00
Mark de Wever
e35f4bb501 Strip trailing whitespace. 2014-06-09 15:26:19 +02:00
Chris Beck
db09f880c2 catch exceptions thrown from server/game dtor 2014-06-08 00:00:18 -04:00
Chris Beck
9dd32c490e catch exceptions thrown in server man_manager dtor 2014-06-07 23:44:59 -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
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
Alexander van Gessel
45a4334a2f Magic number reduction 2014-05-03 02:40:46 +02:00
Chris Beck
43ee443016 fixup scenario transitions
when the host transitions to the next scenario, in some cases he will
send "[start]" before the other clients even have the new scenario cfg
this means that the controller tweaks he send will hit them while they
are in linger mode or something, and the next scenario won't work.

we fixup the download_next_level function on the server side so that
it updates the level config when sending it out to the transitioning
client.

this fixes up commit fb726e0610af42fa815cf340fa68c570b8bef0d3
and bug #21931
2014-04-19 12:26:14 -04: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
Chris Beck
4aa14aa24a fixup "make level reflect start of scenario"
we change set_attr to set_attr_dup as gfgtdf pointed out
2014-04-19 12:25:35 -04:00
Chris Beck
f25511d2ee add [start] tag to server replays as needed by gfgtdf
this should have been part of 121, but wasn't
digest from irc logs:
post PR 121, all [replay]'s are expected to begin with an item
[command]
    [start]
    [/start]
[/command]
which may also contain some [checkup] children which help to
ensure that we didnt go OOS in prestart.
these commands are not generated by the server and distributed,
because we want the clients to begin loading the game without
waiting for the server to finish.
all clients, including observers, will add them automatically.
the server therefore should not add them to the history, and
rather just prepend them to [replay] when generating the
savefile.
2014-04-16 16:18:30 -04:00
Chris Beck
84722f567d fixup server controller tweaks
server was not properly handling empty sides in the initial level
thanks to gfgtdf for tracking this down and spotting the coding
mistake.
2014-04-12 01:21:36 -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