Merge lp:~mxsscott/widelands/clang into lp:widelands

Proposed by Mark Scott
Status: Merged
Merged at revision: 6491
Proposed branch: lp:~mxsscott/widelands/clang
Merge into: lp:widelands
Diff against target: 1018 lines (+148/-139)
30 files modified
src/compile_diagnostics.h (+18/-2)
src/editor/editorinteractive.h (+1/-1)
src/editor/tools/editor_set_port_space_tool.cc (+1/-2)
src/editor/tools/editor_set_port_space_tool.h (+4/-5)
src/editor/tools/editor_tool.h (+2/-1)
src/editor/tools/editor_tool_action.h (+1/-1)
src/editor/ui_menus/editor_player_menu.h (+2/-4)
src/gamecontroller.h (+2/-2)
src/graphic/text/rt_render.cc (+1/-4)
src/io/filesystem/filesystem.cc (+15/-25)
src/io/filesystem/filesystem.h (+9/-3)
src/logic/building.h (+1/-1)
src/logic/game.h (+4/-4)
src/logic/player.cc (+2/-2)
src/logic/playercommand.cc (+6/-9)
src/logic/playercommand.h (+7/-9)
src/logic/replay.cc (+14/-13)
src/logic/replay.h (+9/-8)
src/logic/ship.h (+1/-1)
src/map_io/widelands_map_players_view_data_packet.cc (+3/-3)
src/md5.h (+5/-4)
src/network/netclient.cc (+2/-2)
src/network/nethost.cc (+1/-1)
src/network/network.cc (+3/-3)
src/network/network.h (+5/-5)
src/scripting/pluto.cc (+1/-1)
src/ui_basic/table.cc (+0/-1)
src/ui_basic/table.h (+18/-12)
src/ui_basic/window.h (+4/-3)
src/wui/warehousewindow.cc (+6/-7)
To merge this branch: bzr merge lp:~mxsscott/widelands/clang
Reviewer Review Type Date Requested Status
Mark Scott Needs Resubmitting
SirVer Needs Fixing
Review via email: mp+144001@code.launchpad.net

Description of the change

Fix cause of warnings reported by clang/llvm.

To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

Ensure these macros so nothing for other compilers. -> typo: so should be do.
const char * & extension -> can you have a look if only the pointer or even better a const string& can be passed in here. reference to pointer looks fragile to me.
if (/* const Coords starting_pos = */map.get_starting_pos(m_plnum)) { -> you can just remove the variable here I think.

otherwise LGTM. Can you close the bug if this is appropriate now?

review: Needs Fixing
Revision history for this message
Mark Scott (mxsscott) wrote :

Macro comment type:
  Came directly from the source page https://svn.boost.org/trac/boost/wiki/Guidelines/WarningsGuidelines. I'll fix it.

FileSystem::FS_Filename(...) and the const char * & extension parameter:
  I agree, this doesn't look nice. I'll look into their usage and work out what their return values currently are to see if I can make better method signatures, and change to std::string.

const Coords starting_pos:
  Will remove comment.

Revision history for this message
Mark Scott (mxsscott) wrote :

Updates made following SirVer's comments.

If someone gives a quick nod on the filesystem changes I'll merge this into trunk and close the bug.

review: Needs Resubmitting
Revision history for this message
SirVer (sirver) wrote :

Interestingly, the diff does not seem to update on resubmit. I had a look at the new commits, and: <nod> :) Certainly an improvement - thanks for making the changes and caring for the CLANG warnings.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/compile_diagnostics.h'
--- src/compile_diagnostics.h 2013-01-06 12:55:31 +0000
+++ src/compile_diagnostics.h 2013-01-20 19:32:24 +0000
@@ -25,8 +25,6 @@
25 * use in the middle of functions.25 * use in the middle of functions.
26 */26 */
27#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 40627#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
28# define GCC_DIAG_STR(s) #s
29# define GCC_DIAG_JOINSTR(x, y) GCC_DIAG_STR(x ## y)
30# define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x)28# define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x)
31# define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)29# define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
32# define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(push) \30# define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(push) \
@@ -37,5 +35,23 @@
37# define GCC_DIAG_ON(x)35# define GCC_DIAG_ON(x)
38#endif36#endif
3937
38/* Macros for disabling Clang warnings and errors
39 * From https://svn.boost.org/trac/boost/wiki/Guidelines/WarningsGuidelines and
40 * slightly modified.
41 */
42#ifdef __clang__
43# define CLANG_DIAG_DO_PRAGMA(x) _Pragma (#x)
44// _Pragma is unary operator #pragma ("")
45# define CLANG_DIAG_PRAGMA(x) CLANG_DIAG_DO_PRAGMA(clang diagnostic x)
46# define CLANG_DIAG_OFF(x) CLANG_DIAG_PRAGMA(push) \
47 CLANG_DIAG_PRAGMA(ignored x)
48// For example: #pragma clang diagnostic ignored "-Wno-unused-variable"
49# define CLANG_DIAG_ON(x) CLANG_DIAG_PRAGMA(pop)
50// For example: #pragma clang diagnostic warning "-Wno-unused-variable"
51#else // Ensure these macros do nothing for other compilers.
52# define CLANG_DIAG_OFF(x)
53# define CLANG_DIAG_ON(x)
54# define CLANG_DIAG_PRAGMA(x)
55#endif
4056
41#endif57#endif
4258
=== modified file 'src/editor/editorinteractive.h'
--- src/editor/editorinteractive.h 2012-06-06 14:51:03 +0000
+++ src/editor/editorinteractive.h 2013-01-20 19:32:24 +0000
@@ -39,7 +39,7 @@
3939
4040
41class Editor;41class Editor;
42struct Editor_Tool;42class Editor_Tool;
4343
44/**44/**
45 * This is the EditorInteractive. It is like the InteractivePlayer class,45 * This is the EditorInteractive. It is like the InteractivePlayer class,
4646
=== modified file 'src/editor/tools/editor_set_port_space_tool.cc'
--- src/editor/tools/editor_set_port_space_tool.cc 2012-02-21 13:52:14 +0000
+++ src/editor/tools/editor_set_port_space_tool.cc 2013-01-20 19:32:24 +0000
@@ -51,8 +51,7 @@
51Editor_Set_Port_Space_Tool::Editor_Set_Port_Space_Tool51Editor_Set_Port_Space_Tool::Editor_Set_Port_Space_Tool
52(Editor_Unset_Port_Space_Tool & the_unset_tool)52(Editor_Unset_Port_Space_Tool & the_unset_tool)
53 :53 :
54 Editor_Tool(the_unset_tool, *this),54 Editor_Tool(the_unset_tool, *this)
55 m_unset_tool(the_unset_tool)
56{}55{}
5756
5857
5958
=== modified file 'src/editor/tools/editor_set_port_space_tool.h'
--- src/editor/tools/editor_set_port_space_tool.h 2012-02-21 13:52:14 +0000
+++ src/editor/tools/editor_set_port_space_tool.h 2013-01-20 19:32:24 +0000
@@ -28,7 +28,8 @@
28#define FSEL_EUPS_FILENAME "pics/fsel_editor_unset_port_space.png"28#define FSEL_EUPS_FILENAME "pics/fsel_editor_unset_port_space.png"
2929
30/// Unsets a buildspace for ports.30/// Unsets a buildspace for ports.
31struct Editor_Unset_Port_Space_Tool : public Editor_Tool {31class Editor_Unset_Port_Space_Tool : public Editor_Tool {
32public:
32 Editor_Unset_Port_Space_Tool();33 Editor_Unset_Port_Space_Tool();
3334
34 int32_t handle_click_impl35 int32_t handle_click_impl
@@ -44,7 +45,8 @@
4445
4546
46/// Sets a buildspace for ports.47/// Sets a buildspace for ports.
47struct Editor_Set_Port_Space_Tool : public Editor_Tool {48class Editor_Set_Port_Space_Tool : public Editor_Tool {
49public:
48 Editor_Set_Port_Space_Tool(Editor_Unset_Port_Space_Tool &);50 Editor_Set_Port_Space_Tool(Editor_Unset_Port_Space_Tool &);
4951
50 int32_t handle_click_impl52 int32_t handle_click_impl
@@ -56,9 +58,6 @@
56 Editor_Interactive & parent, Editor_Action_Args & args);58 Editor_Interactive & parent, Editor_Action_Args & args);
5759
58 char const * get_sel_impl() const {return FSEL_ESPS_FILENAME;}60 char const * get_sel_impl() const {return FSEL_ESPS_FILENAME;}
59
60private:
61 Editor_Unset_Port_Space_Tool & m_unset_tool;
62};61};
6362
64int32_t Editor_Tool_Set_Port_Space_Callback63int32_t Editor_Tool_Set_Port_Space_Callback
6564
=== modified file 'src/editor/tools/editor_tool.h'
--- src/editor/tools/editor_tool.h 2012-02-21 13:52:14 +0000
+++ src/editor/tools/editor_tool.h 2013-01-20 19:32:24 +0000
@@ -36,7 +36,8 @@
36 * one function (like delete_building, place building, modify building are 336 * one function (like delete_building, place building, modify building are 3
37 * tools).37 * tools).
38 */38 */
39struct Editor_Tool : boost::noncopyable {39class Editor_Tool : boost::noncopyable {
40public:
40 Editor_Tool(Editor_Tool & second, Editor_Tool & third, bool uda = true) :41 Editor_Tool(Editor_Tool & second, Editor_Tool & third, bool uda = true) :
41 m_second(second), m_third(third), undoable(uda)42 m_second(second), m_third(third), undoable(uda)
42 {}43 {}
4344
=== modified file 'src/editor/tools/editor_tool_action.h'
--- src/editor/tools/editor_tool_action.h 2012-02-21 13:52:14 +0000
+++ src/editor/tools/editor_tool_action.h 2013-01-20 19:32:24 +0000
@@ -23,7 +23,7 @@
23#include "logic/widelands_geometry.h"23#include "logic/widelands_geometry.h"
24#include "editor_action_args.h"24#include "editor_action_args.h"
2525
26struct Editor_Tool;26class Editor_Tool;
27namespace Widelands {class map;}27namespace Widelands {class map;}
28struct Editor_Interactive;28struct Editor_Interactive;
2929
3030
=== modified file 'src/editor/ui_menus/editor_player_menu.h'
--- src/editor/ui_menus/editor_player_menu.h 2012-02-15 21:25:34 +0000
+++ src/editor/ui_menus/editor_player_menu.h 2013-01-20 19:32:24 +0000
@@ -38,7 +38,8 @@
38struct Button;38struct Button;
39}39}
4040
41struct Editor_Player_Menu : public UI::UniqueWindow {41class Editor_Player_Menu : public UI::UniqueWindow {
42public:
42 Editor_Player_Menu43 Editor_Player_Menu
43 (Editor_Interactive &, UI::UniqueWindow::Registry &);44 (Editor_Interactive &, UI::UniqueWindow::Registry &);
44 virtual ~Editor_Player_Menu() {}45 virtual ~Editor_Player_Menu() {}
@@ -55,9 +56,6 @@
55 * m_plr_set_tribes_buts [MAX_PLAYERS];56 * m_plr_set_tribes_buts [MAX_PLAYERS];
56 std::vector<std::string> m_tribes;57 std::vector<std::string> m_tribes;
5758
58 int32_t m_spt_index;
59 int32_t m_mis_index;
60
61 int32_t m_posy;59 int32_t m_posy;
6260
63 void name_changed(int32_t);61 void name_changed(int32_t);
6462
=== modified file 'src/gamecontroller.h'
--- src/gamecontroller.h 2012-04-28 10:57:54 +0000
+++ src/gamecontroller.h 2013-01-20 19:32:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2008-2011 by the Widelands Development Team2 * Copyright (C) 2008-2011, 2013 by the Widelands Development Team
3 *3 *
4 * This program is free software; you can redistribute it and/or4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License5 * modify it under the terms of the GNU General Public License
@@ -26,7 +26,7 @@
2626
27namespace Widelands {27namespace Widelands {
28struct Game;28struct Game;
29struct PlayerCommand;29class PlayerCommand;
30}30}
3131
3232
3333
=== modified file 'src/graphic/text/rt_render.cc'
--- src/graphic/text/rt_render.cc 2013-01-06 15:23:45 +0000
+++ src/graphic/text/rt_render.cc 2013-01-20 19:32:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2006-2012 by the Widelands Development Team2 * Copyright (C) 2006-2013 by the Widelands Development Team
3 *3 *
4 * This program is free software; you can redistribute it and/or4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License5 * modify it under the terms of the GNU General Public License
@@ -402,9 +402,6 @@
402 assert(false); // This should never be called402 assert(false); // This should never be called
403 }403 }
404 virtual bool is_non_mandatory_space() {return true;}404 virtual bool is_non_mandatory_space() {return true;}
405
406private:
407 uint32_t m_w;
408};405};
409406
410/*407/*
411408
=== modified file 'src/io/filesystem/filesystem.cc'
--- src/io/filesystem/filesystem.cc 2012-09-21 21:36:07 +0000
+++ src/io/filesystem/filesystem.cc 2013-01-20 19:32:24 +0000
@@ -46,7 +46,7 @@
46#include "log.h"46#include "log.h"
47#include <windows.h>47#include <windows.h>
48#include <io.h>48#include <io.h>
49#include <direct.h>49#include <direct.h>
50#else50#else
51#include <glob.h>51#include <glob.h>
52#include <sys/types.h>52#include <sys/types.h>
@@ -321,8 +321,8 @@
321 * Returns the filename of this path, everything after the last321 * Returns the filename of this path, everything after the last
322 * / or \ (or the whole string)322 * / or \ (or the whole string)
323 */323 */
324char const * FileSystem::FS_Filename(char const * p) {324const char * FileSystem::FS_Filename(const char * p) {
325 char const * result = p;325 const char * result = p;
326326
327 while (*p != '\0') {327 while (*p != '\0') {
328 if (*p == '/' || *p == '\\')328 if (*p == '/' || *p == '\\')
@@ -333,32 +333,22 @@
333 return result;333 return result;
334}334}
335335
336char const * FileSystem::FS_Filename(char const * p, char const * & extension)336std::string FileSystem::FS_FilenameExt(const std::string & f)
337{337{
338 extension = 0;338 // Find last '.' - denotes start of extension
339 char const * result = p;339 size_t ext_start = f.rfind('.');
340340
341 while (*p != '\0') {341 if (std::string::npos == ext_start)
342 if (*p == '/' || *p == '\\') {342 return "";
343 extension = 0;343 else
344 result = p + 1;344 return f.substr(ext_start);
345 } else if (*p == '.')
346 extension = p;
347 ++p;
348 }
349
350
351 if (not extension)
352 extension = p;
353 return result;
354}345}
355346
356std::string FileSystem::FS_FilenameWoExt(char const * const p)347std::string FileSystem::FS_FilenameWoExt(const char * const p)
357{348{
358 char const * extension;349 std::string fname(p ? FileSystem::FS_Filename(p) : "");
359 std::string fname(p ? FileSystem::FS_Filename(p, extension) : "");350 std::string ext(FileSystem::FS_FilenameExt(fname));
360 return351 return fname.substr(0, fname.length() - ext.length());
361 extension ? fname.substr(0, fname.length() - strlen(extension)) : fname;
362}352}
363353
364/// Create a filesystem from a zipfile or a real directory354/// Create a filesystem from a zipfile or a real directory
365355
=== modified file 'src/io/filesystem/filesystem.h'
--- src/io/filesystem/filesystem.h 2013-01-08 17:05:51 +0000
+++ src/io/filesystem/filesystem.h 2013-01-20 19:32:24 +0000
@@ -114,9 +114,15 @@
114 std::string getWorkingDirectory() const;114 std::string getWorkingDirectory() const;
115 std::string FS_CanonicalizeName(std::string path) const;115 std::string FS_CanonicalizeName(std::string path) const;
116 bool pathIsAbsolute(std::string const & path) const;116 bool pathIsAbsolute(std::string const & path) const;
117 static char const * FS_Filename(char const *);117
118 static char const * FS_Filename(char const *, char const * & extension);118 ///Given a filename, return the name with any path stripped off.
119 static std::string FS_FilenameWoExt(char const *);119 static const char * FS_Filename(const char * n);
120
121 ///Given a filename (without any path), return the extension, if any.
122 static std::string FS_FilenameExt(const std::string & f);
123
124 ///Given a filename, return the name with any path or extension stripped off.
125 static std::string FS_FilenameWoExt(const char * n);
120 static std::string GetHomedir();126 static std::string GetHomedir();
121127
122 virtual unsigned long long DiskSpace() = 0;128 virtual unsigned long long DiskSpace() = 0;
123129
=== modified file 'src/logic/building.h'
--- src/logic/building.h 2012-11-24 16:22:10 +0000
+++ src/logic/building.h 2013-01-20 19:32:24 +0000
@@ -35,7 +35,7 @@
35#include <cstring>35#include <cstring>
36#include <vector>36#include <vector>
3737
38namespace UI {struct Window;}38namespace UI {class Window;}
39struct BuildingHints;39struct BuildingHints;
40struct Interactive_GameBase;40struct Interactive_GameBase;
41struct Profile;41struct Profile;
4242
=== modified file 'src/logic/game.h'
--- src/logic/game.h 2012-02-15 21:25:34 +0000
+++ src/logic/game.h 2013-01-20 19:32:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2002-2004, 2006-2011 by the Widelands Development Team2 * Copyright (C) 2002-2004, 2006-2011, 2013 by the Widelands Development Team
3 *3 *
4 * This program is free software; you can redistribute it and/or4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License5 * modify it under the terms of the GNU General Public License
@@ -58,9 +58,9 @@
5858
59struct Player;59struct Player;
60struct Map_Loader;60struct Map_Loader;
61struct PlayerCommand;61class PlayerCommand;
62struct ReplayReader;62class ReplayReader;
63struct ReplayWriter;63class ReplayWriter;
6464
65struct Game : Editor_Game_Base {65struct Game : Editor_Game_Base {
66 struct General_Stats {66 struct General_Stats {
6767
=== modified file 'src/logic/player.cc'
--- src/logic/player.cc 2012-09-21 21:36:07 +0000
+++ src/logic/player.cc 2013-01-20 19:32:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2002-2003, 2006-2012 by the Widelands Development Team2 * Copyright (C) 2002-2003, 2006-2013 by the Widelands Development Team
3 *3 *
4 * This program is free software; you can redistribute it and/or4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License5 * modify it under the terms of the GNU General Public License
@@ -109,7 +109,7 @@
109109
110void Player::create_default_infrastructure() {110void Player::create_default_infrastructure() {
111 const Map & map = egbase().map();111 const Map & map = egbase().map();
112 if (Coords const starting_pos = map.get_starting_pos(m_plnum)) {112 if (map.get_starting_pos(m_plnum)) {
113 try {113 try {
114 Tribe_Descr::Initialization const & initialization =114 Tribe_Descr::Initialization const & initialization =
115 tribe().initialization(m_initialization_index);115 tribe().initialization(m_initialization_index);
116116
=== modified file 'src/logic/playercommand.cc'
--- src/logic/playercommand.cc 2012-09-21 21:36:07 +0000
+++ src/logic/playercommand.cc 2013-01-20 19:32:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2004, 2007-2011 by the Widelands Development Team2 * Copyright (C) 2004, 2007-2011, 2013 by the Widelands Development Team
3 *3 *
4 * This program is free software; you can redistribute it and/or4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License5 * modify it under the terms of the GNU General Public License
@@ -903,8 +903,7 @@
903 uint32_t const _economy,903 uint32_t const _economy,
904 Ware_Index const _ware_type)904 Ware_Index const _ware_type)
905 :905 :
906 Cmd_ChangeTargetQuantity(_duetime, _sender, _economy, _ware_type),906 Cmd_ChangeTargetQuantity(_duetime, _sender, _economy, _ware_type)
907 m_economy(0)
908{}907{}
909908
910void Cmd_ResetWareTargetQuantity::execute(Game & game)909void Cmd_ResetWareTargetQuantity::execute(Game & game)
@@ -947,7 +946,7 @@
947}946}
948947
949Cmd_ResetWareTargetQuantity::Cmd_ResetWareTargetQuantity(StreamRead & des)948Cmd_ResetWareTargetQuantity::Cmd_ResetWareTargetQuantity(StreamRead & des)
950 : Cmd_ChangeTargetQuantity(des), m_economy(0)949 : Cmd_ChangeTargetQuantity(des)
951{}950{}
952951
953void Cmd_ResetWareTargetQuantity::serialize(StreamWrite & ser)952void Cmd_ResetWareTargetQuantity::serialize(StreamWrite & ser)
@@ -1026,8 +1025,7 @@
1026 uint32_t const _economy,1025 uint32_t const _economy,
1027 Ware_Index const _ware_type)1026 Ware_Index const _ware_type)
1028 :1027 :
1029 Cmd_ChangeTargetQuantity(_duetime, _sender, _economy, _ware_type),1028 Cmd_ChangeTargetQuantity(_duetime, _sender, _economy, _ware_type)
1030 m_economy(0)
1031{}1029{}
10321030
1033void Cmd_ResetWorkerTargetQuantity::execute(Game & game)1031void Cmd_ResetWorkerTargetQuantity::execute(Game & game)
@@ -1070,7 +1068,7 @@
1070}1068}
10711069
1072Cmd_ResetWorkerTargetQuantity::Cmd_ResetWorkerTargetQuantity(StreamRead & des)1070Cmd_ResetWorkerTargetQuantity::Cmd_ResetWorkerTargetQuantity(StreamRead & des)
1073 : Cmd_ChangeTargetQuantity(des), m_economy(0)1071 : Cmd_ChangeTargetQuantity(des)
1074{}1072{}
10751073
1076void Cmd_ResetWorkerTargetQuantity::serialize(StreamWrite & ser)1074void Cmd_ResetWorkerTargetQuantity::serialize(StreamWrite & ser)
@@ -1395,8 +1393,7 @@
13951393
1396Cmd_ChangeMilitaryConfig::Cmd_ChangeMilitaryConfig(StreamRead & des)1394Cmd_ChangeMilitaryConfig::Cmd_ChangeMilitaryConfig(StreamRead & des)
1397:1395:
1398PlayerCommand (0, des.Unsigned8()),1396PlayerCommand (0, des.Unsigned8())
1399serial(0)
1400{1397{
1401 retreat = des.Unsigned8();1398 retreat = des.Unsigned8();
1402 /// Read reserved data1399 /// Read reserved data
14031400
=== modified file 'src/logic/playercommand.h'
--- src/logic/playercommand.h 2012-09-21 21:36:07 +0000
+++ src/logic/playercommand.h 2013-01-20 19:32:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2004, 2006-2011 by the Widelands Development Team2 * Copyright (C) 2004, 2006-2011, 2013 by the Widelands Development Team
3 *3 *
4 * This program is free software; you can redistribute it and/or4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License5 * modify it under the terms of the GNU General Public License
@@ -38,7 +38,8 @@
38 * reasonably unique (to be precise, they must be unique per duetime) and38 * reasonably unique (to be precise, they must be unique per duetime) and
39 * the same across all hosts, to ensure parallel simulation.39 * the same across all hosts, to ensure parallel simulation.
40 */40 */
41struct PlayerCommand : public GameLogicCommand {41class PlayerCommand : public GameLogicCommand {
42public:
42 PlayerCommand (int32_t time, Player_Number);43 PlayerCommand (int32_t time, Player_Number);
4344
44 /// For savegame loading45 /// For savegame loading
@@ -344,7 +345,7 @@
344};345};
345346
346struct Cmd_ResetWareTargetQuantity : public Cmd_ChangeTargetQuantity {347struct Cmd_ResetWareTargetQuantity : public Cmd_ChangeTargetQuantity {
347 Cmd_ResetWareTargetQuantity() : Cmd_ChangeTargetQuantity(), m_economy(0), m_ware_type() {}348 Cmd_ResetWareTargetQuantity() : Cmd_ChangeTargetQuantity(), m_ware_type() {}
348 Cmd_ResetWareTargetQuantity349 Cmd_ResetWareTargetQuantity
349 (int32_t duetime, Player_Number sender,350 (int32_t duetime, Player_Number sender,
350 uint32_t economy, Ware_Index index);351 uint32_t economy, Ware_Index index);
@@ -361,7 +362,6 @@
361 virtual void serialize (StreamWrite &);362 virtual void serialize (StreamWrite &);
362363
363private:364private:
364 uint32_t m_economy;
365 Ware_Index m_ware_type;365 Ware_Index m_ware_type;
366};366};
367367
@@ -388,7 +388,7 @@
388};388};
389389
390struct Cmd_ResetWorkerTargetQuantity : public Cmd_ChangeTargetQuantity {390struct Cmd_ResetWorkerTargetQuantity : public Cmd_ChangeTargetQuantity {
391 Cmd_ResetWorkerTargetQuantity() : Cmd_ChangeTargetQuantity(), m_economy(0), m_ware_type() {}391 Cmd_ResetWorkerTargetQuantity() : Cmd_ChangeTargetQuantity(), m_ware_type() {}
392 Cmd_ResetWorkerTargetQuantity392 Cmd_ResetWorkerTargetQuantity
393 (int32_t duetime, Player_Number sender,393 (int32_t duetime, Player_Number sender,
394 uint32_t economy, Ware_Index index);394 uint32_t economy, Ware_Index index);
@@ -405,7 +405,6 @@
405 virtual void serialize (StreamWrite &);405 virtual void serialize (StreamWrite &);
406406
407private:407private:
408 uint32_t m_economy;
409 Ware_Index m_ware_type;408 Ware_Index m_ware_type;
410};409};
411410
@@ -517,12 +516,12 @@
517516
518// This is at very early stage, more vars should be added517// This is at very early stage, more vars should be added
519struct Cmd_ChangeMilitaryConfig : public PlayerCommand {518struct Cmd_ChangeMilitaryConfig : public PlayerCommand {
520 Cmd_ChangeMilitaryConfig() : PlayerCommand(), serial(0), retreat(0) {} // For savegame loading519 Cmd_ChangeMilitaryConfig() : PlayerCommand(), retreat(0) {} // For savegame loading
521 Cmd_ChangeMilitaryConfig520 Cmd_ChangeMilitaryConfig
522 (int32_t const t,521 (int32_t const t,
523 int32_t const p,522 int32_t const p,
524 uint32_t const ret)523 uint32_t const ret)
525 : PlayerCommand(t, p), serial(0), retreat(ret)524 : PlayerCommand(t, p), retreat(ret)
526 {}525 {}
527526
528 // Write these commands to a file (for savegames)527 // Write these commands to a file (for savegames)
@@ -537,7 +536,6 @@
537 virtual void serialize (StreamWrite &);536 virtual void serialize (StreamWrite &);
538537
539private:538private:
540 Serial serial;
541 // By now only retreat info is stored539 // By now only retreat info is stored
542 uint8_t retreat;540 uint8_t retreat;
543};541};
544542
=== modified file 'src/logic/replay.cc'
--- src/logic/replay.cc 2012-09-21 21:36:07 +0000
+++ src/logic/replay.cc 2013-01-20 19:32:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2007-2009 by the Widelands Development Team2 * Copyright (C) 2007-2009,2013 by the Widelands Development Team
3 *3 *
4 * This program is free software; you can redistribute it and/or4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License5 * modify it under the terms of the GNU General Public License
@@ -48,8 +48,9 @@
48#define SYNC_INTERVAL 20048#define SYNC_INTERVAL 200
4949
5050
51struct Cmd_ReplaySyncRead : public Command {51class Cmd_ReplaySyncRead : public Command {
52 Cmd_ReplaySyncRead(uint32_t const _duetime, md5_checksum const & hash)52public:
53 Cmd_ReplaySyncRead(const uint32_t _duetime, const md5_checksum & hash)
53 : Command(_duetime), m_hash(hash)54 : Command(_duetime), m_hash(hash)
54 {}55 {}
5556
@@ -57,7 +58,7 @@
5758
58 void execute(Game & game)59 void execute(Game & game)
59 {60 {
60 md5_checksum const myhash = game.get_sync_hash();61 const md5_checksum myhash = game.get_sync_hash();
6162
62 if (m_hash != myhash) {63 if (m_hash != myhash) {
63 log64 log
@@ -84,8 +85,7 @@
84/**85/**
85 * Load the savegame part of the given replay and open the command log.86 * Load the savegame part of the given replay and open the command log.
86 */87 */
87ReplayReader::ReplayReader(Game & game, std::string const & filename)88ReplayReader::ReplayReader(Game & game, const std::string & filename)
88 : m_game(game)
89{89{
90 m_replaytime = 0;90 m_replaytime = 0;
9191
@@ -98,7 +98,7 @@
98 static_cast<Widelands::StreamRead *>(g_fs->OpenStreamRead(filename));98 static_cast<Widelands::StreamRead *>(g_fs->OpenStreamRead(filename));
9999
100 try {100 try {
101 uint32_t const magic = m_cmdlog->Unsigned32();101 const uint32_t magic = m_cmdlog->Unsigned32();
102 if (magic == 0x2E21A100)102 if (magic == 0x2E21A100)
103 // Note: This was never released as part of a build103 // Note: This was never released as part of a build
104 throw wexception104 throw wexception
@@ -109,7 +109,7 @@
109 throw wexception109 throw wexception
110 ("%s apparently not a valid replay file", filename.c_str());110 ("%s apparently not a valid replay file", filename.c_str());
111111
112 uint8_t const version = m_cmdlog->Unsigned8();112 const uint8_t version = m_cmdlog->Unsigned8();
113 if (version < REPLAY_VERSION)113 if (version < REPLAY_VERSION)
114 throw wexception114 throw wexception
115 ("Replay of version %u is known to have desync problems", version);115 ("Replay of version %u is known to have desync problems", version);
@@ -141,7 +141,7 @@
141 * \return a \ref Command that should be enqueued in the command queue141 * \return a \ref Command that should be enqueued in the command queue
142 * or 0 if there are no remaining commands before the given time.142 * or 0 if there are no remaining commands before the given time.
143 */143 */
144Command * ReplayReader::GetNextCommand(uint32_t const time)144Command * ReplayReader::GetNextCommand(const uint32_t time)
145{145{
146 if (!m_cmdlog)146 if (!m_cmdlog)
147 return 0;147 return 0;
@@ -208,8 +208,9 @@
208 * Command / timer that regularly inserts synchronization hashes into208 * Command / timer that regularly inserts synchronization hashes into
209 * the replay.209 * the replay.
210 */210 */
211struct Cmd_ReplaySyncWrite : public Command {211class Cmd_ReplaySyncWrite : public Command {
212 Cmd_ReplaySyncWrite(uint32_t const _duetime) : Command(_duetime) {}212public:
213 Cmd_ReplaySyncWrite(const uint32_t _duetime) : Command(_duetime) {}
213214
214 virtual uint8_t id() const {return QUEUE_CMD_REPLAYSYNCWRITE;}215 virtual uint8_t id() const {return QUEUE_CMD_REPLAYSYNCWRITE;}
215216
@@ -230,7 +231,7 @@
230 * This is expected to be called just after game load has completed231 * This is expected to be called just after game load has completed
231 * and the game has changed into running state.232 * and the game has changed into running state.
232 */233 */
233ReplayWriter::ReplayWriter(Game & game, std::string const & filename)234ReplayWriter::ReplayWriter(Game & game, const std::string & filename)
234 : m_game(game), m_filename(filename)235 : m_game(game), m_filename(filename)
235{236{
236 g_fs->EnsureDirectoryExists(REPLAY_DIR);237 g_fs->EnsureDirectoryExists(REPLAY_DIR);
@@ -295,7 +296,7 @@
295/**296/**
296 * Store a synchronization hash for the current game time in the replay.297 * Store a synchronization hash for the current game time in the replay.
297 */298 */
298void ReplayWriter::SendSync(md5_checksum const & hash)299void ReplayWriter::SendSync(const md5_checksum & hash)
299{300{
300 m_cmdlog->Unsigned8(pkt_syncreport);301 m_cmdlog->Unsigned8(pkt_syncreport);
301 m_cmdlog->Unsigned32(m_game.get_gametime());302 m_cmdlog->Unsigned32(m_game.get_gametime());
302303
=== modified file 'src/logic/replay.h'
--- src/logic/replay.h 2012-02-15 21:25:34 +0000
+++ src/logic/replay.h 2013-01-20 19:32:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2007-2009 by the Widelands Development Team2 * Copyright (C) 2007-2009,2013 by the Widelands Development Team
3 *3 *
4 * This program is free software; you can redistribute it and/or4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License5 * modify it under the terms of the GNU General Public License
@@ -40,22 +40,22 @@
40namespace Widelands {40namespace Widelands {
41struct Command;41struct Command;
42struct Game;42struct Game;
43struct PlayerCommand;43class PlayerCommand;
44struct StreamRead;44struct StreamRead;
45struct StreamWrite;45struct StreamWrite;
4646
47/**47/**
48 * Read game replays from disk.48 * Read game replays from disk.
49 */49 */
50struct ReplayReader {50class ReplayReader {
51 ReplayReader(Game &, std::string const & filename);51public:
52 ReplayReader(Game & game, const std::string & filename);
52 ~ReplayReader();53 ~ReplayReader();
5354
54 Command * GetNextCommand(uint32_t time);55 Command * GetNextCommand(uint32_t time);
55 bool EndOfReplay();56 bool EndOfReplay();
5657
57private:58private:
58 Game & m_game;
59 StreamRead * m_cmdlog;59 StreamRead * m_cmdlog;
6060
61 uint32_t m_replaytime;61 uint32_t m_replaytime;
@@ -64,12 +64,13 @@
64/**64/**
65 * Write game replays to disk.65 * Write game replays to disk.
66 */66 */
67struct ReplayWriter {67class ReplayWriter {
68 ReplayWriter(Game &, std::string const & filename);68public:
69 ReplayWriter(Game &, const std::string & filename);
69 ~ReplayWriter();70 ~ReplayWriter();
7071
71 void SendPlayerCommand(PlayerCommand *);72 void SendPlayerCommand(PlayerCommand *);
72 void SendSync(md5_checksum const &);73 void SendSync(const md5_checksum &);
7374
74private:75private:
75 Game & m_game;76 Game & m_game;
7677
=== modified file 'src/logic/ship.h'
--- src/logic/ship.h 2012-02-15 21:25:34 +0000
+++ src/logic/ship.h 2013-01-20 19:32:24 +0000
@@ -24,7 +24,7 @@
24#include "economy/shippingitem.h"24#include "economy/shippingitem.h"
25#include "graphic/diranimations.h"25#include "graphic/diranimations.h"
2626
27namespace UI {struct Window;}27namespace UI {class Window;}
28struct Interactive_GameBase;28struct Interactive_GameBase;
2929
30namespace Widelands {30namespace Widelands {
3131
=== modified file 'src/map_io/widelands_map_players_view_data_packet.cc'
--- src/map_io/widelands_map_players_view_data_packet.cc 2012-09-21 21:36:07 +0000
+++ src/map_io/widelands_map_players_view_data_packet.cc 2013-01-20 19:32:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2007-2008, 2010-2012 by the Widelands Development Team2 * Copyright (C) 2007-2008, 2010-2013 by the Widelands Development Team
3 *3 *
4 * This program is free software; you can redistribute it and/or4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License5 * modify it under the terms of the GNU General Public License
@@ -439,12 +439,12 @@
439 // Store the player's view of roads and ownership in these439 // Store the player's view of roads and ownership in these
440 // temporary variables and save it in the player when set.440 // temporary variables and save it in the player when set.
441 uint8_t roads = 0;441 uint8_t roads = 0;
442 Player_Number owner;442 Player_Number owner = 0;
443443
444 switch (f_vision) { // owner and map_object_descr444 switch (f_vision) { // owner and map_object_descr
445 case 0:445 case 0:
446 // The player has never seen this node, so he has no446 // The player has never seen this node, so he has no
447 // information about it. Neither should he be be informed about447 // information about it. Neither should he be informed about
448 // it now.448 // it now.
449 break;449 break;
450 case 1: {450 case 1: {
451451
=== modified file 'src/md5.h'
--- src/md5.h 2012-12-15 14:40:29 +0000
+++ src/md5.h 2013-01-20 19:32:24 +0000
@@ -69,9 +69,10 @@
69 *69 *
70 * Instances of this class can be copied.70 * Instances of this class can be copied.
71 */71 */
72template <typename Base> struct MD5Checksum : public Base {72template <typename Base> class MD5Checksum : public Base {
73public:
73 MD5Checksum() {Reset();}74 MD5Checksum() {Reset();}
74 explicit MD5Checksum(MD5Checksum const & other)75 explicit MD5Checksum(const MD5Checksum & other)
75 :76 :
76 Base(),77 Base(),
77 can_handle_data(other.can_handle_data), sum(other.sum), ctx(other.ctx)78 can_handle_data(other.can_handle_data), sum(other.sum), ctx(other.ctx)
@@ -91,7 +92,7 @@
91 ///92 ///
92 /// \param data data to compute chksum for93 /// \param data data to compute chksum for
93 /// \param size size of data94 /// \param size size of data
94 void Data(void const * const newdata, size_t const size) {95 void Data(const void * const newdata, const size_t size) {
95 assert(can_handle_data);96 assert(can_handle_data);
96 md5_process_bytes(newdata, size, &ctx);97 md5_process_bytes(newdata, size, &ctx);
97 }98 }
@@ -108,7 +109,7 @@
108 /// before this function.109 /// before this function.
109 ///110 ///
110 /// \return a pointer to an array of 16 bytes containing the checksum.111 /// \return a pointer to an array of 16 bytes containing the checksum.
111 md5_checksum const & GetChecksum() const {112 const md5_checksum & GetChecksum() const {
112 assert(!can_handle_data);113 assert(!can_handle_data);
113 return sum;114 return sum;
114 }115 }
115116
=== modified file 'src/network/netclient.cc'
--- src/network/netclient.cc 2013-01-01 15:25:07 +0000
+++ src/network/netclient.cc 2013-01-20 19:32:24 +0000
@@ -753,7 +753,7 @@
753 char * complete = complete_buf.get();753 char * complete = complete_buf.get();
754#endif754#endif
755 fr.DataComplete(complete, bytes);755 fr.DataComplete(complete, bytes);
756 MD5Checksum<FileRead> md5sum;756 SimpleMD5Checksum md5sum;
757 md5sum.Data(complete, bytes);757 md5sum.Data(complete, bytes);
758 md5sum.FinishChecksum();758 md5sum.FinishChecksum();
759 std::string localmd5 = md5sum.GetChecksum().str();759 std::string localmd5 = md5sum.GetChecksum().str();
@@ -844,7 +844,7 @@
844 char * complete = complete_buf.get();844 char * complete = complete_buf.get();
845#endif845#endif
846 fr.DataComplete(complete, file->bytes);846 fr.DataComplete(complete, file->bytes);
847 MD5Checksum<FileRead> md5sum;847 SimpleMD5Checksum md5sum;
848 md5sum.Data(complete, file->bytes);848 md5sum.Data(complete, file->bytes);
849 md5sum.FinishChecksum();849 md5sum.FinishChecksum();
850 std::string localmd5 = md5sum.GetChecksum().str();850 std::string localmd5 = md5sum.GetChecksum().str();
851851
=== modified file 'src/network/nethost.cc'
--- src/network/nethost.cc 2013-01-06 11:10:00 +0000
+++ src/network/nethost.cc 2013-01-20 19:32:24 +0000
@@ -1533,7 +1533,7 @@
1533 std::vector<char> complete(file->bytes);1533 std::vector<char> complete(file->bytes);
1534 fr.SetFilePos(0);1534 fr.SetFilePos(0);
1535 fr.DataComplete(&complete[0], file->bytes);1535 fr.DataComplete(&complete[0], file->bytes);
1536 MD5Checksum<FileRead> md5sum;1536 SimpleMD5Checksum md5sum;
1537 md5sum.Data(&complete[0], file->bytes);1537 md5sum.Data(&complete[0], file->bytes);
1538 md5sum.FinishChecksum();1538 md5sum.FinishChecksum();
1539 file->md5sum = md5sum.GetChecksum().str();1539 file->md5sum = md5sum.GetChecksum().str();
15401540
=== modified file 'src/network/network.cc'
--- src/network/network.cc 2012-02-15 21:25:34 +0000
+++ src/network/network.cc 2013-01-20 19:32:24 +0000
@@ -186,10 +186,10 @@
186 return m_index < buffer.size();186 return m_index < buffer.size();
187}187}
188188
189bool Deserializer::read (TCPsocket sock)189bool Deserializer::read(TCPsocket sock)
190{190{
191 uint8_t buffer[512];191 uint8_t buffer[512];
192 int32_t const bytes = SDLNet_TCP_Recv(sock, buffer, sizeof(buffer));192 const int32_t bytes = SDLNet_TCP_Recv(sock, buffer, sizeof(buffer));
193 if (bytes <= 0)193 if (bytes <= 0)
194 return false;194 return false;
195195
@@ -206,7 +206,7 @@
206 if (queue.size() < 2)206 if (queue.size() < 2)
207 return false;207 return false;
208208
209 uint16_t const size = queue[0] << 8 | queue[1];209 const uint16_t size = queue[0] << 8 | queue[1];
210 if (size < 2)210 if (size < 2)
211 return false;211 return false;
212212
213213
=== modified file 'src/network/network.h'
--- src/network/network.h 2012-02-15 21:25:34 +0000
+++ src/network/network.h 2013-01-20 19:32:24 +0000
@@ -31,7 +31,7 @@
31#include <string>31#include <string>
32#include <vector>32#include <vector>
3333
34struct Deserializer;34class Deserializer;
3535
36struct SyncCallback {36struct SyncCallback {
37 virtual ~SyncCallback() {}37 virtual ~SyncCallback() {}
@@ -130,7 +130,8 @@
130 std::vector<FilePart> parts;130 std::vector<FilePart> parts;
131};131};
132132
133struct Deserializer {133class Deserializer {
134public:
134 /**135 /**
135 * Read data from the given socket.136 * Read data from the given socket.
136 * \return \c false if the socket was disconnected or another error137 * \return \c false if the socket was disconnected or another error
@@ -138,17 +139,16 @@
138 * \c true if some data could be read (this does not imply that \ref avail139 * \c true if some data could be read (this does not imply that \ref avail
139 * will return \c true !)140 * will return \c true !)
140 */141 */
141 bool read (TCPsocket);142 bool read(TCPsocket sock);
142143
143 /**144 /**
144 * \return \c true if an entire packet has been received.145 * \return \c true if an entire packet has been received.
145 */146 */
146 bool avail () const;147 bool avail() const;
147148
148private:149private:
149 friend struct RecvPacket;150 friend struct RecvPacket;
150 std::vector<uint8_t> queue;151 std::vector<uint8_t> queue;
151 size_t index;
152};152};
153153
154154
155155
=== modified file 'src/scripting/pluto.cc'
--- src/scripting/pluto.cc 2013-01-06 11:05:01 +0000
+++ src/scripting/pluto.cc 2013-01-20 19:32:24 +0000
@@ -31,7 +31,7 @@
31//are only used in conditional asserts31//are only used in conditional asserts
32#include "compile_diagnostics.h"32#include "compile_diagnostics.h"
33GCC_DIAG_OFF("-Wunused-variable")33GCC_DIAG_OFF("-Wunused-variable")
3434CLANG_DIAG_OFF("-Wunused-variable")
3535
36// Forward declarated from lua_impl.h. So we do not need to include it36// Forward declarated from lua_impl.h. So we do not need to include it
37int luna_restore_object(lua_State * L);37int luna_restore_object(lua_State * L);
3838
=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc 2012-12-14 20:09:35 +0000
+++ src/ui_basic/table.cc 2013-01-20 19:32:24 +0000
@@ -48,7 +48,6 @@
48:48:
49 Panel (parent, x, y, w, h),49 Panel (parent, x, y, w, h),
50 m_total_width (0),50 m_total_width (0),
51 m_max_pic_width (0),
52 m_fontname (UI_FONT_NAME),51 m_fontname (UI_FONT_NAME),
53 m_fontsize (UI_FONT_SIZE_SMALL),52 m_fontsize (UI_FONT_SIZE_SMALL),
54 m_headerheight (15),53 m_headerheight (15),
5554
=== modified file 'src/ui_basic/table.h'
--- src/ui_basic/table.h 2012-12-14 20:09:35 +0000
+++ src/ui_basic/table.h 2013-01-20 19:32:24 +0000
@@ -42,8 +42,8 @@
42/// 1. a reference type,42/// 1. a reference type,
43/// 2. a pointer type or43/// 2. a pointer type or
44/// 3. uintptr_t.44/// 3. uintptr_t.
45template<typename Entry> struct Table {45template<typename Entry> class Table {
4646public:
47 struct Entry_Record {47 struct Entry_Record {
48 };48 };
4949
@@ -108,8 +108,8 @@
108 virtual bool handle_key(bool down, SDL_keysym code);108 virtual bool handle_key(bool down, SDL_keysym code);
109};109};
110110
111template <> struct Table<void *> : public Panel {111template <> class Table<void *> : public Panel {
112112public:
113 struct Entry_Record {113 struct Entry_Record {
114 Entry_Record(void * entry);114 Entry_Record(void * entry);
115115
@@ -132,7 +132,7 @@
132 bool is_checked(uint8_t col) const;132 bool is_checked(uint8_t col) const;
133133
134 private:134 private:
135 friend struct Table<void *>;135 friend class Table<void *>;
136 void * m_entry;136 void * m_entry;
137 bool use_clr;137 bool use_clr;
138 RGBColor clr;138 RGBColor clr;
@@ -261,7 +261,6 @@
261261
262 Columns m_columns;262 Columns m_columns;
263 uint32_t m_total_width;263 uint32_t m_total_width;
264 uint32_t m_max_pic_width;
265 std::string m_fontname;264 std::string m_fontname;
266 uint32_t m_fontsize;265 uint32_t m_fontsize;
267 uint32_t m_headerheight;266 uint32_t m_headerheight;
@@ -281,8 +280,10 @@
281};280};
282281
283template <typename Entry>282template <typename Entry>
284 struct Table<const Entry * const> : public Table<void *>283 class Table<const Entry * const> : public Table<void *>
285{284{
285public:
286
286 typedef Table<void *> Base;287 typedef Table<void *> Base;
287 Table288 Table
288 (Panel * parent,289 (Panel * parent,
@@ -310,7 +311,8 @@
310 }311 }
311};312};
312313
313template <typename Entry> struct Table<Entry * const> : public Table<void *> {314template <typename Entry> class Table<Entry * const> : public Table<void *> {
315public:
314 typedef Table<void *> Base;316 typedef Table<void *> Base;
315 Table317 Table
316 (Panel * parent,318 (Panel * parent,
@@ -337,7 +339,8 @@
337 }339 }
338};340};
339341
340template <typename Entry> struct Table<const Entry &> : public Table<void *> {342template <typename Entry> class Table<const Entry &> : public Table<void *> {
343public:
341 typedef Table<void *> Base;344 typedef Table<void *> Base;
342 Table345 Table
343 (Panel * parent,346 (Panel * parent,
@@ -367,7 +370,8 @@
367 }370 }
368};371};
369372
370template <typename Entry> struct Table<Entry &> : public Table<void *> {373template <typename Entry> class Table<Entry &> : public Table<void *> {
374public:
371 typedef Table<void *> Base;375 typedef Table<void *> Base;
372 Table376 Table
373 (Panel * parent,377 (Panel * parent,
@@ -396,7 +400,8 @@
396};400};
397401
398compile_assert(sizeof(void *) == sizeof(uintptr_t));402compile_assert(sizeof(void *) == sizeof(uintptr_t));
399template <> struct Table<uintptr_t> : public Table<void *> {403template <> class Table<uintptr_t> : public Table<void *> {
404public:
400 typedef Table<void *> Base;405 typedef Table<void *> Base;
401 Table406 Table
402 (Panel * parent,407 (Panel * parent,
@@ -424,7 +429,8 @@
424 return reinterpret_cast<uintptr_t>(Base::get_selected());429 return reinterpret_cast<uintptr_t>(Base::get_selected());
425 }430 }
426};431};
427template <> struct Table<uintptr_t const> : public Table<uintptr_t> {432template <> class Table<uintptr_t const> : public Table<uintptr_t> {
433public:
428 typedef Table<uintptr_t> Base;434 typedef Table<uintptr_t> Base;
429 Table435 Table
430 (Panel * parent,436 (Panel * parent,
431437
=== modified file 'src/ui_basic/window.h'
--- src/ui_basic/window.h 2012-12-17 20:01:04 +0000
+++ src/ui_basic/window.h 2013-01-20 19:32:24 +0000
@@ -50,7 +50,8 @@
50 * Minimize means, that the window is only the caption bar, nothing inside.50 * Minimize means, that the window is only the caption bar, nothing inside.
51 * Another click on this bar resizes the window again51 * Another click on this bar resizes the window again
52 */52 */
53struct Window : public NamedPanel {53class Window : public NamedPanel {
54public:
54 Window55 Window
55 (Panel * parent,56 (Panel * parent,
56 const std::string& name,57 const std::string& name,
@@ -61,7 +62,7 @@
61 const std::string& title);62 const std::string& title);
6263
63 void set_title(const std::string &);64 void set_title(const std::string &);
64 std::string const & get_title() const {return m_title;}65 const std::string & get_title() const {return m_title;}
6566
66 void set_center_panel(Panel * panel);67 void set_center_panel(Panel * panel);
67 void move_out_of_the_way();68 void move_out_of_the_way();
@@ -93,7 +94,7 @@
9394
94private:95private:
95 bool _is_minimal;96 bool _is_minimal;
96 uint32_t _oldw, _oldh; // if it is, these are the old formats97 uint32_t _oldh; // if it is, this is the old height
97 bool _dragging, _docked_left, _docked_right, _docked_bottom;98 bool _dragging, _docked_left, _docked_right, _docked_bottom;
98 int32_t _drag_start_win_x, _drag_start_win_y;99 int32_t _drag_start_win_x, _drag_start_win_y;
99 int32_t _drag_start_mouse_x, _drag_start_mouse_y;100 int32_t _drag_start_mouse_x, _drag_start_mouse_y;
100101
=== modified file 'src/wui/warehousewindow.cc'
--- src/wui/warehousewindow.cc 2012-12-14 20:09:35 +0000
+++ src/wui/warehousewindow.cc 2013-01-20 19:32:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2002-2004, 2006-2011 by the Widelands Development Team2 * Copyright (C) 2002-2004, 2006-2011, 2013 by the Widelands Development Team
3 *3 *
4 * This program is free software; you can redistribute it and/or4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License5 * modify it under the terms of the GNU General Public License
@@ -40,25 +40,24 @@
40/**40/**
41 * Extends the wares display to show and modify stock policy of items.41 * Extends the wares display to show and modify stock policy of items.
42 */42 */
43struct WarehouseWaresDisplay : WaresDisplay {43class WarehouseWaresDisplay : public WaresDisplay {
44public:
44 WarehouseWaresDisplay45 WarehouseWaresDisplay
45 (UI::Panel * parent, uint32_t width,46 (UI::Panel * parent, uint32_t width,
46 Interactive_GameBase &, Warehouse &, Widelands::WareWorker type, bool selectable);47 Warehouse & wh, Widelands::WareWorker type, bool selectable);
4748
48protected:49protected:
49 virtual void draw_ware(RenderTarget & dst, Widelands::Ware_Index ware);50 virtual void draw_ware(RenderTarget & dst, Widelands::Ware_Index ware);
5051
51private:52private:
52 Interactive_GameBase & m_igbase;
53 Warehouse & m_warehouse;53 Warehouse & m_warehouse;
54};54};
5555
56WarehouseWaresDisplay::WarehouseWaresDisplay56WarehouseWaresDisplay::WarehouseWaresDisplay
57 (UI::Panel * parent, uint32_t width, Interactive_GameBase & igbase,57 (UI::Panel * parent, uint32_t width,
58 Warehouse & wh, Widelands::WareWorker type, bool selectable)58 Warehouse & wh, Widelands::WareWorker type, bool selectable)
59:59:
60WaresDisplay(parent, 0, 0, wh.owner().tribe(), type, selectable),60WaresDisplay(parent, 0, 0, wh.owner().tribe(), type, selectable),
61m_igbase(igbase),
62m_warehouse(wh)61m_warehouse(wh)
63{62{
64 set_inner_size(width, 0);63 set_inner_size(width, 0);
@@ -110,7 +109,7 @@
110 m_wh(wh),109 m_wh(wh),
111 m_can_act(m_gb.can_act(m_wh.owner().player_number())),110 m_can_act(m_gb.can_act(m_wh.owner().player_number())),
112 m_type(type),111 m_type(type),
113 m_display(this, width, m_gb, m_wh, m_type, m_can_act)112 m_display(this, width, m_wh, m_type, m_can_act)
114{113{
115 add(&m_display, UI::Box::AlignLeft, true);114 add(&m_display, UI::Box::AlignLeft, true);
116115

Subscribers

People subscribed via source and target branches

to status/vote changes: