70791 Commits

Author SHA1 Message Date
pentarctagon
ce628e028b Remove checking for a different SDL2 minimum version.
I removed this from scons a while ago, though it looks like I forgot or didn't notice that cmake does the same.
2018-01-28 12:53:26 -06:00
Gregory A Lundberg
73be496708
Revert "cppcheck is confused by an initializer list"
This reverts commit 2e1dbfc235334117c61c7a4bbb4ff1d1f76e2a2d.
2018-01-28 09:27:03 -06:00
Charles Dang
1d93797d34 Added override specifiers for display_context overrides
Also did some formatting cleanup in game_board. Didn't really care to touch the others.

Removed virtual specifier from non-const game_board::teams. It didn't override anything
in the base class (display_context, which has the const version) and nothing inherits
from game_board to override it (the non-const version) later.
2018-01-29 02:10:59 +11:00
Gregory A Lundberg
c0689b7924
prefer prefix ++
cppcheck (via Codacy) points out it's better to use prefix ++ on iterators in a for statement.
2018-01-28 09:07:28 -06:00
Gregory A Lundberg
8f22144e8e
clarify ^ vs ?:
cppcheck (via Codacy) points out the operator precidence is unclearn. Added parentheses to fix that.
2018-01-28 09:07:27 -06:00
Gregory A Lundberg
45eae14999
fix poor rethrows
cppcheck (via Codacy) points out that it is better to rethrow the current event than to throw a new copy of it.
2018-01-28 09:07:27 -06:00
Gregory A Lundberg
b74df558e0
clearly check itor at end
cppcheck (via Codacy) notes that it's not clear that the iterator (j) cannot exceed end() because most don't expect pointer math.

Rewrote to make it more clear what is going on.
2018-01-28 09:07:27 -06:00
Gregory A Lundberg
59554ca0cd
cppcheck has a problem
cppcheck (via Codacy) had a problem with the form `T & T` so used `auto & T`

This is probably a bug in cppcheck but reported to Codacy in case it's their fault since the message form was for && and this was just &.
2018-01-28 09:07:27 -06:00
Gregory A Lundberg
45d101e8ca
variable not assigned in operator=
cppcheck (via Codacy) points out that one member vairable was not assigned.
2018-01-28 09:07:26 -06:00
Gregory A Lundberg
84194f76ef
perform initialization in the initializer
cppcheck (via Codacy) pointed out it's sorta silly to default initialize then immediately assign a non-default value.
2018-01-28 09:07:26 -06:00
Gregory A Lundberg
2e1dbfc235
cppcheck is confused by an initializer list 2018-01-28 09:07:26 -06:00
Gregory A Lundberg
e12a2a19ca
fix reassign before first use
cppcheck (via Codacy) pointed out that a variable was initialized, then reassigned, before the initialed value was used.

Moved the variable declaration to the point the actually-used value was assigned.
2018-01-28 09:07:26 -06:00
Gregory A Lundberg
5e0c3056dc
clarify resize and stretch logic
cppcheck (via Codacy) rightly noted that the construct ((!!w ^ !!h)) was confusing.

Rearrange the code a bit, note some things must be true without testing them, and we can eliminate two variables, make the code faster than the "cute optimization" and make it FAR easier to read.
2018-01-28 09:07:25 -06:00
Gregory A Lundberg
36e92900c3
pass const struct by ref instead of by value
cppcheck (via Codacy) reports the lowest-quality C++ is src/sever/game.hpp with 41 warnings.

There is no need to copy the const socket_ptr struct all over place to pass-by-value. It's const, so we can pass-by-reference and save time and memory.
2018-01-28 09:06:26 -06:00
Charles Dang
99051100a4 Revert 229b9be7eb59 and re-add with comment 2018-01-29 01:43:50 +11:00
Charles Dang
69cd6640d0 Editor: cleaned up a bunch of accessors
Map Context:
* Removed get_team() in favor of non-const local team() overload.
* Removeded get_map() (both overloads) in favor of map() and a local non-const overload of the same.
* Made both overloads of map() return editor_map instead of gamemap (former inherits from the latter).

Context Manager:
* Removed team, unit, and label accessors that only fetched the same info from the current map_context.
  Having more functions of this name only made things a lot more confusing.

Editor Controller:
* Change all instances of the three intermediate accessors mentioned above to data queries directly
  from the current map context via editor_controller::get_current_map_context. The result is the same,
  we just no longer have three levels of indirection.
2018-01-29 01:41:43 +11:00
Charles Dang
b0bb9d94f0 MP Join Game: proceed to game anyway if faction select dialog was dismissed
This makes more sense. The previous behavior seemed unintuitive. If a player then wants
to leave, they can subsequently.
2018-01-28 22:19:34 +11:00
Charles Dang
e52bd6eba7 Faction Select: allow dialog to be closed with ESC (fixes #2404)
I had probably added this before since I wanted a player joining a game to always choose
a leader, but that's rather mitigated by the fact that there's a cancel button.
2018-01-28 22:15:09 +11:00
Charles Dang
626d413798 Editor/Context Manager: cleaned up context refresh code
This used to need to be a class of its own in order to store some info prior to switching
the context, but that's not the case anymore. Moved map_context_refresher::refresh into
context_manager. Also moved the set_window_title call into the function as well, since it
was called in all three places the context refresher was used.
2018-01-28 22:07:51 +11:00
Charles Dang
e19b19bf42 Made more use of get_team() and its bounds checking 2018-01-28 16:48:38 +11:00
Charles Dang
229b9be7eb Play Controller: removed useless optimization 2018-01-28 16:34:29 +11:00
Charles Dang
b779c91df7 Display Context: enable bounds checking for get_team()
Also enabled it for the non-const version in game_board.
2018-01-28 00:20:31 +11:00
Charles Dang
24e40cc0b1 Editor/Map Context: made non-const units accessor local to this class
Since having a non-const pure virtual member of display_context was causing crashes, and
it was only needed here, I've made it a local class member.
2018-01-27 02:27:21 +11:00
Charles Dang
ab4580c6ea Revert "Display Context: added write-access units() overload (pure virtual)"
This reverts commit 0f8e25f970ee9b8fba010c5ffa528aa6238d8900. For some damn reason
this was causing invalid access crashes for me on VS 2017 release builds, but no one
else could repro. Since I can implement a non-const accessor in the map_context class
anyway, I'm reverting.
2018-01-27 00:43:34 +11:00
Charles Dang
88b31f2609 Attempt to fix tests (fixup b98cbe31cc86)
Includes sorting of include list.
2018-01-26 16:27:39 +11:00
Wedge009
0925aa7e0c Align default quit hot-key with conventions (fixes #2397)
Switch quit to title-screen from Ctrl+Q to Ctrl+W (OSX already uses Cmd+W) and quit-to-desktop from Ctrl+Shift+Q to Ctrl+Q.
2018-01-26 14:12:03 +11:00
Charles Dang
b98cbe31cc Moved dummy display context class to tests, since it's only used there now. 2018-01-26 14:11:42 +11:00
Charles Dang
de21ae13c5 Display: allow actually passing a nullptr for the display_context arg
Avoids having to initially use a dummy context when initializing an editor_display.
The editor calls display::change_display_context later.
2018-01-26 14:04:05 +11:00
Charles Dang
806e176744 Fixup c616d8274fcc (unused variable) 2018-01-26 14:00:33 +11:00
Charles Dang
6a21fdc675 Removed resources::units once again
I had re-added it in a limited context in eaea9be1177398b2fe1 since I needed it to fix
(IIRC) a crash in the editor when adding units, since the editor didn't have a game_board.
However, looking at the code again, I realized that the display class (base of editor_display)
holds a pointer to a display_context object. map_context inherits from display_context, and
the editor sets the editor_display's display_context to the current map_context. Therefor, I
could just access the units needed via display::get_units, instead of needing a global pointer.
2018-01-26 13:56:08 +11:00
Charles Dang
489dcebd01 Editor/Map Context: removed get_units() functions in favor of display_context overrides 2018-01-26 13:44:30 +11:00
Charles Dang
0f8e25f970 Display Context: added write-access units() overload (pure virtual) 2018-01-26 13:40:54 +11:00
Charles Dang
f9238c015b Remove accidentally-committed debug output from 207e763401a11e
[ci skip]
2018-01-26 12:43:08 +11:00
Charles Dang
c616d8274f Avoid unnecessary double dynamic_cast
Could have been using the display singleton all this time, but it became a double cast
with the change from resources::screen to the game_display singleton.
2018-01-26 12:41:23 +11:00
Charles Dang
786233d5c9 Replace resources::screen with game_display singleton
This is consistent with the use of display::get_singleton() (in fact, it's the same
pointer). It also makes the code more readable, and means we get to further clean up
the resources set.
2018-01-26 12:36:45 +11:00
Charles Dang
d11b62590f Fixup 3dc8617ec9396 (fixes #2398)
See doc comment.
2018-01-26 09:57:29 +11:00
Charles Dang
182b4bb1e5 Editor: don't serialize [side] user_team_name= and [unit] name= if empty (fixes #2317) 2018-01-25 20:16:11 +11:00
Charles Dang
cd937c745c Editor: fixed starting position labels not vanishing immediately when deleted (fixes #1970) 2018-01-25 20:11:27 +11:00
Charles Dang
438e021a27 Editor: exclude some rarely-used keys from [time] and [item] if empty
Note that I added the exclude-if-not-empty code directly to time_of_day::write, since
that's what the editor uses, instead of manually writing keys as it does with items and
side units. Hopefully that won't have an adverse effect somewhere else.
2018-01-25 18:15:16 +11:00
Charles Dang
d98093ebba Config Attribute Value: added write_if_not_empty helper
Takes a string and assigns a value only if that string is not empty.
2018-01-25 18:13:27 +11:00
Gregory A Lundberg
4a6042a3c9
fix crash on #wesnoth.unit_types
`#wesnoth.unit_types` should simply return the number of unit types.

This fixes the crash and reports the correct value: the number of unit types defined.

This does not fix the rest of the crap like pairs() crawls, you can't interate variations or get the variation count.

My knee-jerk reaction is to delete all scripting support for unit_types so that it's filed where it belongs: in the Trash. But, what the hell, nobody has complained about what utter shit this code is, so I'll just fix this so we don't crash and carry on working on getting the code to actually do what it's supposed to instead of the lame-ass shit it currently does.

Can you tell what I think of this file?

closes #2381
2018-01-24 11:05:35 -06:00
Alexander van Gessel
09fe1f4106 Merge branch 'master' of github.com:wesnoth/wesnoth 2018-01-24 16:18:16 +01:00
Alexander van Gessel
45a61de238 Initialize all members
Found by coverity.
2018-01-24 16:16:52 +01:00
Gregory A Lundberg
b5f6e43efd
Fix Coverity 1385374 uninitialized member 2018-01-24 09:13:44 -06:00
Charles Dang
207e763401 Improved handling of race icons (fixes #2030)
* The editor_icon= key will now be respected in the Unit Preview Pane
* If no appropriate icon is found, a generic icon will be used instead, in both the editor
  and unit preview pane.
2018-01-25 00:10:02 +11:00
Charles Dang
8903ea9446 ToD Manager: don't write stub ToD to scenario file (fixes #2302) 2018-01-24 16:24:50 +11:00
Charles Dang
3dc8617ec9 Fixup c8b0833 (crash when creating scenario in Editor)
There's no AI manager in the editor (a game state is required), nor a need for one, so I simply
disabled the AI initialization if we're not in the editor.
2018-01-24 16:12:57 +11:00
Gregory A Lundberg
e9e22f30b7 fix wreorder variable initialized before other 2018-01-24 14:29:01 +11:00
Jyrki Vesterinen
c8b0833b1a Make AI manager a singleton
Fixes #2372.

It turned out that the AI kept dangling references to the old Lua state,
and crashed while destroying AI contexts for destroyed sides.

The best way to avoid it is to ensure that game_state, which already owns
the Lua state, also owns the AI. That way, the AI will be destroyed before
the Lua state and a dangling reference can't stay.
2018-01-24 14:29:01 +11:00
Charles Dang
671cebe035 TSG: tweak description slightly
[ci skip]
2018-01-24 12:00:14 +11:00