59250 Commits

Author SHA1 Message Date
mattsc
b5f62d0d4c Update Xcode project file 2014-11-20 16:48:56 -08:00
Chris Beck
371dd9038a Merge branch 'master' of https://github.com/wesnoth/wesnoth 2014-11-20 16:58:37 -05:00
Chris Beck
e89383d1aa move lua Rng wrapper to the lua kernel base 2014-11-20 16:58:12 -05:00
Chris Beck
e18cfd7049 move lua rng bindings to their own file 2014-11-20 16:13:49 -05:00
Chris Beck
d7770f5a92 move lua map_location operations to their own file 2014-11-20 15:53:26 -05:00
mattsc
94c68a7228 Update Xcode project file 2014-11-20 12:47:21 -08:00
Chris Beck
fccddbb226 move lua fileops to their own file 2014-11-20 15:37:22 -05:00
Chris Beck
29aaa7e05c fix a bug in lua console implementation
I think that without this, if tab completion is pressed many times
it might cause the lua stack to overflow in some cases.
2014-11-20 15:12:06 -05:00
Chris Beck
e7e0bb57dc keep the old lua print function (to cout) around, as "std_print"
name should change maybe
2014-11-20 15:07:35 -05:00
Chris Beck
c282bdfafd Merge branch 'master' of https://github.com/wesnoth/wesnoth 2014-11-20 13:25:23 -05:00
Chris Beck
31966fcfb8 suppress uninitialized variables warnings in xBRZ for gcc <= 4.7 2014-11-20 13:24:56 -05:00
Alexander van Gessel
ae7efb8597 Turn a null-dereference into an assertion failure
Found by coverity
2014-11-20 18:29:12 +01:00
Alexander van Gessel
12b2e1d1a0 Fix pointer-to-local-leaves-scope issue
Found by coverity
2014-11-20 18:21:57 +01:00
Alexander van Gessel
b31dabb47a gui2::show_error_message takes only 1 string argument
Found by coverity
2014-11-20 17:45:08 +01:00
gfgtdf
bb42e2fbef fix mapgen random seed 2014-11-20 05:16:30 +01:00
gfgtdf
83975887ea eliminate a rand() call
that was hidden inside std::random_shuffle
2014-11-20 05:16:29 +01:00
Chris Beck
75ea364d59 Merge branch 'master' of https://github.com/wesnoth/wesnoth 2014-11-19 23:10:24 -05:00
Chris Beck
dffbd96068 add bindings for map_location functions to the lua kernel base
I mainly want to use this for random map generators, it would be
silly to rewrite this stuff in lua after we already have it in C++
(and unit tested there).
2014-11-19 23:09:37 -05:00
Ignacio R. Morelle
8e3428e6a3 fs: Don't complain about failing to read /proc/self/exe with Boost.filesystem
This is intended to silently fail on Unix-like platforms where no procfs
is available, and indeed that's how it works in the non-BFS
implementation of get_exe_dir(). The caller (currently a single function
in game.cpp/wesnoth.cpp) must be able to deal with this situation
in a graceful fashion.
2014-11-20 00:35:03 -03:00
gfgtdf
3c431d8406 Update CMakeLists.txt 2014-11-20 03:40:25 +01:00
gfgtdf
0d52790f8e fixup build 2014-11-20 03:39:31 +01:00
gfgtdf
ce7189d628 make editor search for scenario_generation too 2014-11-20 02:34:33 +01:00
gfgtdf
8b426ebee5 add seed textbox in map editor random generation 2014-11-20 02:34:32 +01:00
gfgtdf
c094f68d91 use mt19937 instead of simple_rng in cavegen. 2014-11-20 02:34:30 +01:00
gfgtdf
a7534ec83e add seed to map_generator 2014-11-20 02:34:28 +01:00
gfgtdf
d12a46a820 add seed to default_generate_map 2014-11-20 02:34:26 +01:00
gfgtdf
4a12e4ff82 move a rand() call 2014-11-20 02:34:25 +01:00
gfgtdf
3ceca1e554 move default_generate_map to its own file 2014-11-20 02:34:16 +01:00
Chris Beck
3101d826ed travis: disable all tests on the translations build 2014-11-19 15:51:30 -05:00
Chris Beck
e02787e3b6 travis: add a dedicated build for translations 2014-11-19 14:40:35 -05:00
Chris Beck
548c5d74ae fix a bug that caused std::hex to get written into std::cerr
reported by gfgtdf
2014-11-19 13:40:23 -05:00
Chris Beck
f5e2204326 add assertions after many unchecked dynamic casts
These were all reported by coverity, and indeed seem to have been
assumed to work without failing at runtime.
2014-11-19 00:21:41 -05:00
Chris Beck
d27aab7439 gamestate_inspector: add a ctor initialization for lua_button ptr
This was a minor oversight by me, issue raised by Coverity.
2014-11-18 23:51:29 -05:00
Ignacio R. Morelle
151aa77d2c Add an assertion check to detect a null pointer case
Also preemptively block subsequent dereferences.

Hopefully somebody will eventually hit an assertion failure here and
report back to help me understand how such a situation could possibly
arise, so I can decide whether to remove the assert and leave the new
loop conditional intact or change it to match the intended behavior
(e.g. it's possible `!active || active->empty()` would be preferable in
some scenario).

Spotted by Coverity.
2014-11-19 00:08:51 -03:00
Ignacio R. Morelle
196b5183b1 addon/mg: Drop superfluous NULL pointer check
update_all_button's value is obtained from operator new, which will
throw if the allocation fails, so it can never be NULL in subsequent
statements.

Found by coverity.
2014-11-18 23:37:34 -03:00
Chris Beck
a6ef798feb savepng: fix a null pointer dereference
spotted by coverity, also I reproduced it once with command like
`wesnoth --render-image foo.png`
2014-11-18 21:31:08 -05:00
Ignacio R. Morelle
c43f9883d6 preproc: Inherit parent textdomain on slowpath macro substitution (bug #22962)
Fixes bug #22962, reported on the forums as affecting the Swamplings
add-on from 1.10: <http://r.wesnoth.org/r41129>

This is most likely a regression from 1.8.x, as it doesn't affect 1.8.6
and the reporter on the forums claims it affected 1.10.x.

Direct substitutions do not require the instantiation of a new
preprocessor_streambuf, instead inheriting the current context's
streambuf, along with its textdomain. preprocessor_data() is then
constructed with an overruled textdomain which leads to a no-op as it is
identical to the streambuf's current textdomain.

Nested substitutions _do_ require a new streambuf created by means of
its copy constructor, which leaves the new streambuf's textdomain set to
the default of PACKAGE (defined as "wesnoth"). Then a new
preprocessor_data context is instantiated and instructed to overrule the
initial textdomain with the macro's textdomain. However,
preprocessor_data's base class constructor (`preprocessor`) has already
copied the streambuf's initial textdomain id to its previous textdomain
record, causing it to restore that textdomain on destruction instead of
the correct one.

Thus, when performing slowpath substitutions we need to make sure the
preprocessor_data and preprocessor constructors see the parent context's
streambuf textdomain instead of the wesnoth default. Later, the nested
preprocessor_data will restore the correct textdomain and emit a
trailing <FE>line directive for the parent if necessary.

The alternative of having the preprocessor_streambuf copy constructor
copy the original streambuf's textdomain would also fix this bug, but it
would break the intended behavior for slowpath file inclusions, which
always default to wesnoth. Although most WML containing translatable
strings have a #textdomain directive at the start nowadays (and this is
in fact enforced by wmllint), it's probably a bad idea to change the
current behavior in this case for UMC, at least for the 1.12.x stable
series.

I do not expect regressions from this commit and it certainly won't
cause compatibility issues or behavior changes outside i18n -- at least
for add-ons that are doing things right and not relying on translatable
strings having the wrong value.

DM, DW, DiD, EI, HttT, LoW, Liberty, SoF, THoT, TRoW, TSG, data/core,
and data/multiplayer all present preprocessor output differences before
and after this fix, but they amount to no changes to the parser's
output; unlike SotBE and UtBS, which benefit from the fix:

 * data/campaigns/Son_Of_The_Black_Eye/scenarios/07_The_Desert_of_Death.cfg:439
   had the {TURNS_RUN_OUT} core macro substitution bound to the
   campaign's own textdomain instead of wesnoth for some reason.

 * data/campaigns/Under_the_Burning_Suns/scenarios/05_A_Subterranean_Struggle.cfg:1749
   onwards (the ENEMY_ATTACK and ALLY_REINFORCEMENTS macros) bound
   several strings to the wesnoth textdomain instead of the campaign's
   textdomain.

I also tested this commit with my own add-on, After_the_Storm, which
presented similar results as DM et al above. Finally, Swamplings is
properly fixed by this change.
2014-11-18 05:19:39 -03:00
gfgtdf
115c2a7985 use generic_string()
this fixes a bug which caused that _final.cfg wasn't included last
becasue we compared a string with "/_final.cfg". By using
generic_string() we make sure that the seperators are '/'.

http://gna.org/bugs/?22967
2014-11-18 04:38:10 +01:00
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