widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #06529
[Merge] lp:~widelands-dev/widelands/codecheck-comments into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/codecheck-comments into lp:widelands.
Commit message:
Added a new codecheck rule that requires comments to start with a blank space + a bit of code cleanup.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/codecheck-comments/+merge/288667
I have to fix comments that have no blank space after // a lot during code review, so I've added a codecheck rule.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/codecheck-comments into lp:widelands.
=== added file 'cmake/codecheck/rules/missing_space_starting_comment'
--- cmake/codecheck/rules/missing_space_starting_comment 1970-01-01 00:00:00 +0000
+++ cmake/codecheck/rules/missing_space_starting_comment 2016-03-10 16:23:18 +0000
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+
+
+"""
+Comments should all start with a blank space
+"""
+
+error_msg = "Comments need to start with a space."
+
+strip_comments_and_strings = False
+regexp = r"""((^|\s)//[^\s/<!])|((^|\s)//<[^\s])|((^|\s)//!<[^\s])"""
+
+
+forbidden = [
+ '//spaceless comment',
+ '///spaceless comment',
+ '//<spaceless comment',
+ '///<spaceless comment',
+]
+
+allowed = [
+ '// nifty comment',
+ '/// nifty comment',
+ '//< we have a lot of those',
+ '///< we have a lot of those',
+ '//!< and some of those',
+ '///!< and some of those',
+]
=== modified file 'src/ai/ai_help_structs.h'
--- src/ai/ai_help_structs.h 2016-02-25 19:20:21 +0000
+++ src/ai/ai_help_structs.h 2016-03-10 16:23:18 +0000
@@ -368,7 +368,7 @@
int32_t cnt_target; // number of buildings as target
int32_t cnt_limit_by_aimode; // limit imposed by weak or normal AI mode
- int32_t cnt_upgrade_pending; //number of buildings that are to be upgraded
+ int32_t cnt_upgrade_pending; // number of buildings that are to be upgraded
// used to track amount of wares produced by building
uint32_t stocklevel;
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2016-03-02 17:13:06 +0000
+++ src/ai/defaultai.cc 2016-03-10 16:23:18 +0000
@@ -376,7 +376,7 @@
if (check_economies()) { // economies must be consistent
return;
}
- if (gametime < 15000) { //more frequent on the beginning of game
+ if (gametime < 15000) { // More frequent at the beginning of game
set_taskpool_task_time(gametime + 2000, SchedulerTaskId::kConstructBuilding);
} else {
set_taskpool_task_time(gametime + 6000, SchedulerTaskId::kConstructBuilding);
@@ -1523,7 +1523,7 @@
const int32_t kBottomLimit = 40; // to prevent too dense militarysites
// modifying least_military_score, down if more military sites are needed and vice versa
if (too_many_ms_constructionsites || too_many_vacant_mil || needs_boost_economy) {
- if (persistent_data->least_military_score < kUpperLimit) { //no sense to let it grow too high
+ if (persistent_data->least_military_score < kUpperLimit) { // No sense in letting it grow too high
persistent_data->least_military_score += 20;
}
} else {
@@ -2099,7 +2099,7 @@
prio += 5;
}
- //+1 if any consumers_ are nearby
+ // +1 if any consumers_ are nearby
consumers_nearby_count = 0;
for (size_t k = 0; k < bo.outputs.size(); ++k)
@@ -2771,7 +2771,7 @@
if (flag.get_economy()->warehouses().empty() && flag.get_building()) {
// occupied military buildings get special treatment
- //(extended grace time + longer radius)
+ // (extended grace time + longer radius)
bool occupied_military_ = false;
Building* b = flag.get_building();
if (upcast(MilitarySite, militb, b)) {
@@ -2882,7 +2882,7 @@
if (map.findpath(flag.get_position(), reachable_coords, 0, *path2, check) >= 0) {
// path is possible, but for now we presume connection
- //'walking on existing roads' is not possible
+ // 'walking on existing roads' is not possible
// so we assign 'virtual distance'
int32_t virtual_distance = 0;
// the same economy, but connection not spotted above via "walking on roads"
@@ -3977,7 +3977,7 @@
bo.primary_priority += 50;
}
- //if we are close to enemy (was seen in last 15 minutes)
+ // If we are close to enemy (was seen in last 15 minutes)
if (enemy_last_seen_ < gametime && enemy_last_seen_ + 15 * 60 * 1000 > gametime) {
bo.primary_priority += 10;
}
=== modified file 'src/ai/defaultai.h'
--- src/ai/defaultai.h 2016-02-25 19:20:21 +0000
+++ src/ai/defaultai.h 2016-03-10 16:23:18 +0000
@@ -227,7 +227,7 @@
void print_land_stats();
- //checks whether first value is in range, or lesser then...
+ // Checks whether first value is in range, or lesser then...
template<typename T> void check_range(const T, const T, const T, const char *);
template<typename T> void check_range(const T, const T, const char *);
@@ -303,9 +303,6 @@
int32_t resource_necessity_water_;
bool resource_necessity_water_needed_; // unless atlanteans
- // average count of trees around cutters
- //uint32_t trees_around_cutters_;
-
uint16_t military_last_dismantle_;
uint32_t military_last_build_; // sometimes expansions just stops, this is time of last military
// building build
@@ -329,7 +326,7 @@
// the purpose is to print out a warning that the game is pacing too fast
int32_t scheduler_delay_counter_;
- //this points to persistent data stored in Player object
+ // This points to persistent data stored in Player object
Widelands::Player::AiPersistentState* persistent_data;
// this is a bunch of patterns that have to identify weapons and armors for input queues of trainingsites
=== modified file 'src/base/i18n.cc'
--- src/base/i18n.cc 2015-02-27 09:38:51 +0000
+++ src/base/i18n.cc 2016-03-10 16:23:18 +0000
@@ -115,8 +115,8 @@
}
textdomains.pop_back();
- //don't try to get the previous TD when the very first one ('widelands')
- //just got dropped
+ // Don't try to get the previous TD when the very first one ('widelands')
+ // just got dropped
if (!textdomains.empty()) {
char const * const domain = textdomains.back().first.c_str();
@@ -281,7 +281,7 @@
leave_while = true;
break;
} else {
- //log("locale is not working: %s\n", try_locale.c_str());
+ // log("locale is not working: %s\n", try_locale.c_str());
}
}
if (leave_while) break;
=== modified file 'src/economy/economy.cc'
--- src/economy/economy.cc 2016-02-09 16:29:48 +0000
+++ src/economy/economy.cc 2016-03-10 16:23:18 +0000
@@ -361,8 +361,6 @@
*/
void Economy::add_wares(DescriptionIndex const id, uint32_t const count)
{
- //log("%p: add(%i, %i)\n", this, id, count);
-
wares_.add(id, count);
start_request_timer();
@@ -370,8 +368,6 @@
}
void Economy::add_workers(DescriptionIndex const id, uint32_t const count)
{
- //log("%p: add(%i, %i)\n", this, id, count);
-
workers_.add(id, count);
start_request_timer();
@@ -387,8 +383,6 @@
void Economy::remove_wares(DescriptionIndex const id, uint32_t const count)
{
assert(owner_.egbase().tribes().ware_exists(id));
- //log("%p: remove(%i, %i) from %i\n", this, id, count, wares_.stock(id));
-
wares_.remove(id, count);
// TODO(unknown): remove from global player inventory?
@@ -401,8 +395,6 @@
*/
void Economy::remove_workers(DescriptionIndex const id, uint32_t const count)
{
- //log("%p: remove(%i, %i) from %i\n", this, id, count, workers_.stock(id));
-
workers_.remove(id, count);
// TODO(unknown): remove from global player inventory?
=== modified file 'src/economy/flag.cc'
--- src/economy/flag.cc 2016-02-07 06:10:47 +0000
+++ src/economy/flag.cc 2016-03-10 16:23:18 +0000
@@ -712,8 +712,6 @@
*/
void Flag::cleanup(EditorGameBase & egbase)
{
- //molog("Flag::cleanup\n");
-
while (!flag_jobs_.empty()) {
delete flag_jobs_.begin()->request;
flag_jobs_.erase(flag_jobs_.begin());
@@ -726,8 +724,6 @@
ware.destroy (egbase);
}
- //molog(" wares destroyed\n");
-
if (building_) {
building_->remove(egbase); // immediate death
assert(!building_);
@@ -745,8 +741,6 @@
unset_position(egbase, position_);
- //molog(" done\n");
-
PlayerImmovable::cleanup(egbase);
}
=== modified file 'src/economy/fleet.cc'
--- src/economy/fleet.cc 2016-02-18 08:42:46 +0000
+++ src/economy/fleet.cc 2016-03-10 16:23:18 +0000
@@ -687,7 +687,7 @@
std::list<uint16_t> waiting_ports;
// this is just helper - first member of scores map
- std::pair<uint16_t, uint16_t> mapping; //ship number, port number
+ std::pair<uint16_t, uint16_t> mapping; // ship number, port number
// first we go over ships - idle ones (=without destination)
// then over wares on these ships and create first ship-port
@@ -714,7 +714,7 @@
continue;
}
- bool destination_found = false; //just a functional check
+ bool destination_found = false; // Just a functional check
for (uint16_t p = 0; p < ports_.size(); p += 1) {
if (ports_[p] == ships_[s]->items_[i].get_destination(game)) {
mapping.first = s;
@@ -765,7 +765,7 @@
mapping.first = s;
mapping.second = p;
- // folowing aproximately considers free capacity of a ship
+ // following aproximately considers free capacity of a ship
scores[mapping] += ((ships_[s]->get_nritems() > 15)?1:3)
+
std::min(
@@ -774,7 +774,7 @@
}
}
- //now adding score for distance
+ // Now adding score for distance
for (std::pair<std::pair<uint16_t, uint16_t>, uint16_t> ship_port_relation : scores) {
// here we get distance ship->port
=== modified file 'src/economy/portdock.cc'
--- src/economy/portdock.cc 2016-02-18 08:42:46 +0000
+++ src/economy/portdock.cc 2016-03-10 16:23:18 +0000
@@ -172,7 +172,7 @@
if (egbase.objects().object_still_available(warehouse_)) {
- //we need to remember this for possible recreation of portdock
+ // We need to remember this for possible recreation of portdock
wh = warehouse_;
// Transfer all our wares into the warehouse.
@@ -217,7 +217,7 @@
if (wh) {
if (!wh->cleanup_in_progress_) {
if (upcast(Game, game, &egbase)) {
- if (game->is_loaded()) { //do not attempt when shutting down
+ if (game->is_loaded()) { // Do not attempt when shutting down
wh->restore_portdock_or_destroy(egbase);
}
}
=== modified file 'src/economy/request.cc'
--- src/economy/request.cc 2016-02-15 22:31:59 +0000
+++ src/economy/request.cc 2016-03-10 16:23:18 +0000
@@ -263,7 +263,6 @@
get_base_required_time(economy_->owner().egbase(), transfers_.size());
}
-//#define MAX_IDLE_PRIORITY 100
#define PRIORITY_MAX_COST 50000
#define COST_WEIGHT_IN_PRIORITY 1
#define WAITTIME_WEIGHT_IN_PRIORITY 2
=== modified file 'src/editor/editorinteractive.h'
--- src/editor/editorinteractive.h 2016-01-24 11:11:54 +0000
+++ src/editor/editorinteractive.h 2016-03-10 16:23:18 +0000
@@ -64,7 +64,6 @@
{}
EditorTool & current() const {return *current_pointer;}
using ToolVector = std::vector<EditorTool *>;
- //ToolVector tools;
EditorTool * current_pointer;
EditorTool::ToolIndex use_tool;
EditorInfoTool info;
=== modified file 'src/editor/ui_menus/editor_main_menu.cc'
--- src/editor/ui_menus/editor_main_menu.cc 2016-01-29 08:37:22 +0000
+++ src/editor/ui_menus/editor_main_menu.cc 2016-03-10 16:23:18 +0000
@@ -28,7 +28,7 @@
#include "editor/ui_menus/editor_main_menu_save_map.h"
#include "ui_fsmenu/fileview.h"
-//TODO(unknown): these should be defined globally for the whole UI
+// TODO(unknown): these should be defined globally for the whole UI
#define width 200
#define margin 15
#define vspacing 15
=== modified file 'src/editor/ui_menus/editor_main_menu_save_map.cc'
--- src/editor/ui_menus/editor_main_menu_save_map.cc 2016-02-23 19:45:57 +0000
+++ src/editor/ui_menus/editor_main_menu_save_map.cc 2016-03-10 16:23:18 +0000
@@ -281,14 +281,14 @@
Widelands::MapSaver* wms = new Widelands::MapSaver(*fs, egbase);
wms->save();
delete wms;
- //reset filesystem to avoid file locks on saves
+ // Reset filesystem to avoid file locks on saves
fs.reset();
eia().set_need_save(false);
g_fs->fs_unlink(complete_filename);
g_fs->fs_rename(tmp_name, complete_filename);
- // also change fs, as we assign it to the map below
+ // Also change fs, as we assign it to the map below
fs.reset(g_fs->make_sub_file_system(complete_filename));
- // set the filesystem of the map to the current save file / directory
+ // Set the filesystem of the map to the current save file / directory
map.swap_filesystem(fs);
// DONT use fs as of here, its garbage now!
=== modified file 'src/graphic/align.cc'
--- src/graphic/align.cc 2016-02-03 22:42:34 +0000
+++ src/graphic/align.cc 2016-03-10 16:23:18 +0000
@@ -54,7 +54,7 @@
}
void correct_for_align(Align align, uint32_t w, uint32_t h, Point* pt) {
- //Vertical Align
+ // Vertical Align
if (static_cast<int>(align & (Align::kVCenter | Align::kBottom))) {
if (static_cast<int>(align & Align::kVCenter))
pt->y -= h / 2;
@@ -62,7 +62,7 @@
pt->y -= h;
}
- //Horizontal Align
+ // Horizontal Align
if ((align & Align::kHorizontal) != Align::kLeft) {
if (static_cast<int>(align & Align::kHCenter))
pt->x -= w / 2;
=== modified file 'src/graphic/text/sdl_ttf_font.cc'
--- src/graphic/text/sdl_ttf_font.cc 2016-02-14 14:16:26 +0000
+++ src/graphic/text/sdl_ttf_font.cc 2016-03-10 16:23:18 +0000
@@ -128,10 +128,6 @@
}
void SdlTtfFont::m_set_style(int style) {
- // Those must have been handled by loading the correct font.
- // NOCOM assert(!(style & BOLD));
- //assert(!(style & ITALIC));
-
int sdl_style = TTF_STYLE_NORMAL;
if (style & UNDERLINE) sdl_style |= TTF_STYLE_UNDERLINE;
=== modified file 'src/graphic/text_parser.cc'
--- src/graphic/text_parser.cc 2016-02-03 22:42:34 +0000
+++ src/graphic/text_parser.cc 2016-03-10 16:23:18 +0000
@@ -63,7 +63,7 @@
std::vector<RichtextBlock> & blocks)
{
bool more_richtext_blocks = true;
- //First while loop parses all richtext blocks (images)
+ // First while loop parses all richtext blocks (images)
while (more_richtext_blocks) {
RichtextBlock new_richtext_block;
std::string unparsed_text;
@@ -81,7 +81,7 @@
std::vector<TextBlock> text_blocks;
- //Second while loop parses all textblocks of current richtext block
+ // Second while loop parses all textblocks of current richtext block
bool more_text_blocks = true;
while (more_text_blocks) {
std::string block_format;
@@ -114,11 +114,11 @@
const bool extract_more = extract_format_block(block, block_text, block_format, "<p", ">", "</p>");
- //Split the the text because of " "
+ // Split the the text because of " "
std::vector<std::string> unwrapped_words;
split_words(block_text, &unwrapped_words);
- //Handle user defined line breaks, and save them
+ // Handle user defined line breaks, and save them
for (const std::string& temp_words : unwrapped_words) {
for (std::string line = temp_words;;) {
line = i18n::make_ligatures(line.c_str());
@@ -193,25 +193,25 @@
return false;
}
- //Append block_format
+ // Append block_format
block_format.erase();
block_format.append(block.substr(0, format_end_pos));
- //Delete whole format block
+ // Delete whole format block
block.erase(0, format_end_pos + format_end.size());
- //Find end of block
+ // Find end of block
const std::string::size_type block_end_pos = block.find(block_end);
if (block_end_pos == std::string::npos) {
return false;
}
- //Extract text of block
+ // Extract text of block
block_text.erase();
block_text.append(block.substr(0, block_end_pos));
- //Erase text including closing tag
+ // Erase text including closing tag
block.erase(0, block_end_pos + block_end.size());
- //Is something left
+ // Is something left
return block.find(block_start) != std::string::npos;
}
=== modified file 'src/io/filesystem/disk_filesystem.cc'
--- src/io/filesystem/disk_filesystem.cc 2016-02-21 11:22:21 +0000
+++ src/io/filesystem/disk_filesystem.cc 2016-03-10 16:23:18 +0000
@@ -550,7 +550,7 @@
GetDiskFreeSpaceEx
(canonicalize_name(directory_).c_str(), &freeavailable, 0, 0)
?
- //if more than 2G free space report that much
+ // If more than 2G free space report that much
freeavailable.HighPart ? std::numeric_limits<unsigned long>::max() :
freeavailable.LowPart : 0;
#else
=== modified file 'src/io/filesystem/filesystem.cc'
--- src/io/filesystem/filesystem.cc 2016-02-15 20:37:29 +0000
+++ src/io/filesystem/filesystem.cc 2016-03-10 16:23:18 +0000
@@ -84,7 +84,7 @@
return false;
#ifdef _WIN32
- if (path.size() >= 3 && path[1] == ':' && path[2] == '\\') //"C:\"
+ if (path.size() >= 3 && path[1] == ':' && path[2] == '\\') // "C:\"
{
return true;
}
@@ -160,7 +160,7 @@
{
std::string homedir;
#ifdef _WIN32
- // trying to get it compatible to ALL windows versions...
+ // Trying to get it compatible to ALL windows versions...
// Could anybody please hit the Megasoft devs for not keeping
// their own "standards"?
#define TRY_USE_AS_HOMEDIR(name) \
@@ -186,7 +186,7 @@
("\nWARNING: either we can not detect your home directory "
"or you do not have one! Please contact the developers.\n\n");
- //TODO(unknown): is it really a good idea to set homedir to "." then ??
+ // TODO(unknown): is it really a good idea to set homedir to "." then ??
log("Instead of your home directory, '.' will be used.\n\n");
homedir = ".";
@@ -209,15 +209,15 @@
std::string::size_type pos; // start of token
std::string::size_type pos2; // next filesep character
- //extract the first path component
- if (path.find(filesep) == 0) //is this an absolute path?
+ // Extract the first path component
+ if (path.find(filesep) == 0) // Is this an absolute path?
pos = 1;
- else //relative path
+ else // Relative path
pos = 0;
pos2 = path.find(filesep, pos);
- //'current' token is now between pos and pos2
+ // 'current' token is now between pos and pos2
- //split path into it's components
+ // Split path into it's components
while (pos2 != std::string::npos) {
if (pos != pos2)
{
@@ -228,7 +228,7 @@
pos2 = path.find(filesep, pos);
}
- //extract the last component (most probably a filename)
+ // Extract the last component (most probably a filename)
std::string node = path.substr(pos);
if (!node.empty())
*components++ = node;
@@ -252,7 +252,7 @@
fs_tokenize(path, file_separator(), std::inserter(components, components.begin()));
- //tilde expansion
+ // Tilde expansion
if (!components.empty() && *components.begin() == "~") {
components.erase(components.begin());
fs_tokenize
@@ -265,18 +265,18 @@
(root_.empty() ? get_working_directory() : root_, file_separator(),
std::inserter(components, components.begin()));
- //clean up the path
+ // Clean up the path
for (i = components.begin(); i != components.end();) {
char const * str = i->c_str();
if (*str == '.') {
++str;
- //remove single dot
+ // Remove single dot
if (*str == '\0') {
i = components.erase(i);
continue;
}
- //remove double dot and the preceding component (if any)
+ // Remove double dot and the preceding component (if any)
else if (*str == '.' && *(str + 1) == '\0') {
if (i != components.begin()) {
#ifdef _WIN32
@@ -309,7 +309,7 @@
canonpath += '\\';
}
- //remove trailing slash
+ // Remove trailing slash
if (canonpath.size() > 1) canonpath.erase(canonpath.end() - 1);
#endif
@@ -375,7 +375,7 @@
errno == ENOENT ||
errno == ENOTDIR ||
#ifdef ELOOP
- errno == ELOOP || //MinGW does not support ELOOP (yet)
+ errno == ELOOP || // MinGW does not support ELOOP (yet)
#endif
errno == ENAMETOOLONG)
{
@@ -388,7 +388,7 @@
if (S_ISDIR(statinfo.st_mode)) {
return *new RealFSImpl(root);
}
- if (S_ISREG(statinfo.st_mode)) { //TODO(unknown): ensure root is a zipfile
+ if (S_ISREG(statinfo.st_mode)) { // TODO(unknown): ensure root is a zipfile
return *new ZipFilesystem(root);
}
=== modified file 'src/io/filesystem/filesystem.h'
--- src/io/filesystem/filesystem.h 2016-02-15 12:53:42 +0000
+++ src/io/filesystem/filesystem.h 2016-03-10 16:23:18 +0000
@@ -65,7 +65,7 @@
(const std::string & fname, void const * data, int32_t length)
= 0;
virtual void ensure_directory_exists(const std::string & fs_dirname) = 0;
- //TODO(unknown): use this only from inside ensure_directory_exists()
+ // TODO(unknown): use this only from inside ensure_directory_exists()
virtual void make_directory(const std::string & fs_dirname) = 0;
/**
=== modified file 'src/io/filesystem/layered_filesystem.cc'
--- src/io/filesystem/layered_filesystem.cc 2016-02-09 07:51:23 +0000
+++ src/io/filesystem/layered_filesystem.cc 2016-03-10 16:23:18 +0000
@@ -79,7 +79,7 @@
std::set<std::string> LayeredFileSystem::list_directory(const std::string& path) {
std::set<std::string> results;
FilenameSet files;
- //check home system first
+ // Check home system first
if (m_home) {
files = m_home->list_directory(path);
for
=== modified file 'src/io/streamwrite.h'
--- src/io/streamwrite.h 2014-09-20 09:37:47 +0000
+++ src/io/streamwrite.h 2016-03-10 16:23:18 +0000
@@ -56,7 +56,7 @@
*/
virtual void flush();
- //TODO(unknown): implement an overloaded method that accepts fmt as std::string
+ // TODO(unknown): implement an overloaded method that accepts fmt as std::string
void print_f(char const *, ...) __attribute__((format(printf, 2, 3)));
void signed_8 (int8_t const x) {data(&x, 1);}
=== modified file 'src/logic/cookie_priority_queue.h'
--- src/logic/cookie_priority_queue.h 2016-02-09 16:29:48 +0000
+++ src/logic/cookie_priority_queue.h 2016-03-10 16:23:18 +0000
@@ -217,7 +217,7 @@
swap(elt_cookie, parent_cookie);
}
- //selftest();
+ // selftest();
}
template<typename _T, typename _Cw, typename _CA>
@@ -261,7 +261,7 @@
break;
}
- //selftest();
+ // selftest();
}
template<typename _T, typename _Cw, typename _CA>
=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc 2016-02-16 10:27:23 +0000
+++ src/logic/editor_game_base.cc 2016-03-10 16:23:18 +0000
@@ -88,7 +88,7 @@
void EditorGameBase::think()
{
- //TODO(unknown): Get rid of this; replace by a function that just advances gametime
+ // TODO(unknown): Get rid of this; replace by a function that just advances gametime
// by a given number of milliseconds
}
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2016-03-08 08:22:28 +0000
+++ src/logic/game.cc 2016-03-10 16:23:18 +0000
@@ -71,7 +71,7 @@
namespace Widelands {
/// Define this to get lots of debugging output concerned with syncs
-//#define SYNC_DEBUG
+// #define SYNC_DEBUG
Game::SyncWrapper::~SyncWrapper() {
if (dump_ != nullptr) {
=== modified file 'src/logic/map.h'
--- src/logic/map.h 2016-02-23 19:45:57 +0000
+++ src/logic/map.h 2016-03-10 16:23:18 +0000
@@ -1088,10 +1088,8 @@
case WALK_E: return r_n(f);
case WALK_SE: return br_n(f);
case WALK_SW: return bl_n(f);
- //case WALK_W: return l_n(f);
- default:
- assert(WALK_W == dir);
- return l_n(f);
+ case WALK_W: return l_n(f);
+ default: NEVER_HERE();
}
}
=== modified file 'src/logic/map_objects/tribes/constructionsite.cc'
--- src/logic/map_objects/tribes/constructionsite.cc 2016-02-13 12:15:29 +0000
+++ src/logic/map_objects/tribes/constructionsite.cc 2016-03-10 16:23:18 +0000
@@ -232,8 +232,8 @@
builder_idle_ = false;
return true;
} else {
- //TODO(fweber): cause "construction sounds" to be played -
- //perhaps dependent on kind of construction?
+ // TODO(fweber): cause "construction sounds" to be played -
+ // perhaps dependent on kind of construction?
++work_completed_;
if (work_completed_ >= work_steps_)
@@ -276,7 +276,7 @@
wq.set_filled(wq.get_filled() - 1);
wq.set_max_size(wq.get_max_size() - 1);
- //update consumption statistic
+ // Update consumption statistic
owner().ware_consumed(wq.get_ware(), 1);
working_ = true;
=== modified file 'src/logic/map_objects/tribes/dismantlesite.cc'
--- src/logic/map_objects/tribes/dismantlesite.cc 2016-02-13 12:15:29 +0000
+++ src/logic/map_objects/tribes/dismantlesite.cc 2016-03-10 16:23:18 +0000
@@ -190,7 +190,7 @@
wq.set_filled(wq.get_filled() - 1);
wq.set_max_size(wq.get_max_size() - 1);
- //update statistics
+ // Update statistics
owner().ware_produced(wq.get_ware());
const WareDescr & wd = *owner().tribe().get_ware_descr(wq.get_ware());
=== modified file 'src/logic/map_objects/tribes/militarysite.cc'
--- src/logic/map_objects/tribes/militarysite.cc 2016-03-08 14:52:04 +0000
+++ src/logic/map_objects/tribes/militarysite.cc 2016-03-10 16:23:18 +0000
@@ -513,7 +513,7 @@
}
if (! upgrade_soldier_request_)
{
- //phoo -- I can safely request new soldiers.
+ // phoo -- I can safely request new soldiers.
doing_upgrade_request_ = false;
update_normal_soldier_request();
}
@@ -584,7 +584,7 @@
// Therefore I must poll in some occasions. Let's do that rather infrequently,
// to keep the game lightweight.
- //TODO(unknown): I would need two new callbacks, to get rid ot this polling.
+ // TODO(unknown): I would need two new callbacks, to get rid ot this polling.
if (timeofgame > next_swap_soldiers_time_)
{
next_swap_soldiers_time_ = timeofgame + (soldier_upgrade_try_ ? 20000 : 100000);
=== modified file 'src/logic/map_objects/tribes/production_program.cc'
--- src/logic/map_objects/tribes/production_program.cc 2016-03-02 17:13:06 +0000
+++ src/logic/map_objects/tribes/production_program.cc 2016-03-10 16:23:18 +0000
@@ -886,7 +886,6 @@
std::vector<uint8_t> consumption_quantities(nr_warequeues, 0);
Groups l_groups = consumed_wares_; // make a copy for local modification
- //log("ActConsume::execute(%s):\n", ps.descname().c_str());
// Iterate over all input queues and see how much we should consume from
// each of them.
@@ -973,7 +972,7 @@
assert(q <= warequeues[i]->get_filled());
warequeues[i]->set_filled(warequeues[i]->get_filled() - q);
- //update consumption statistic
+ // Update consumption statistic
ps.owner().ware_consumed(warequeues[i]->get_ware(), q);
}
return ps.program_step(game);
@@ -1038,7 +1037,6 @@
void ProductionProgram::ActProduce::execute
(Game & game, ProductionSite & ps) const
{
- //ps.molog(" Produce\n");
assert(ps.produced_wares_.empty());
ps.produced_wares_ = produced_wares_;
ps.working_positions_[0].worker->update_task_buildingwork(game);
@@ -1628,14 +1626,13 @@
(map.find_reachable_fields
(area, &fields, cstep, fna))
{
- //testing received fields to get one with less immovables
- //nearby
- Coords best_coords = fields.back(); //just to initialize it
+ // Testing received fields to get one with less immovables nearby
+ Coords best_coords = fields.back(); // Just to initialize it
uint32_t best_score = std::numeric_limits<uint32_t>::max();
while (!fields.empty()) {
Coords coords = fields.back();
- //counting immovables nearby
+ // Counting immovables nearby
std::vector<ImmovableFound> found_immovables;
const uint32_t imm_count =
map.find_immovables(Area<FCoords>(map.get_fcoords(coords), 2), &found_immovables);
@@ -1644,7 +1641,7 @@
best_coords = coords;
}
- //no need to go on, it cannot be better
+ // No need to go on, it cannot be better
if (imm_count == 0) {
break;
}
=== modified file 'src/logic/map_objects/tribes/productionsite.cc'
--- src/logic/map_objects/tribes/productionsite.cc 2016-03-02 08:28:09 +0000
+++ src/logic/map_objects/tribes/productionsite.cc 2016-03-10 16:23:18 +0000
@@ -326,7 +326,7 @@
}
- //if we are here, all needs are satisfied
+ // If we are here, all needs are satisfied
return true;
} else {
@@ -938,13 +938,11 @@
switch (result) {
case Failed:
- //changed by TB below
statistics_.erase(statistics_.begin(), statistics_.begin() + 1);
statistics_.push_back(false);
calc_statistics();
crude_percent_ = crude_percent_ * 8 / 10;
break;
- //end of changed by TB
case Completed:
skipped_programs_.erase(program_name);
statistics_.erase(statistics_.begin(), statistics_.begin() + 1);
@@ -955,9 +953,7 @@
break;
case Skipped:
skipped_programs_[program_name] = game.get_gametime();
- //changed by TB below
crude_percent_ = crude_percent_ * 98 / 100;
- //end of changed by TB
break;
case None:
break;
=== modified file 'src/logic/map_objects/tribes/productionsite.h'
--- src/logic/map_objects/tribes/productionsite.h 2016-02-16 13:43:48 +0000
+++ src/logic/map_objects/tribes/productionsite.h 2016-03-10 16:23:18 +0000
@@ -283,7 +283,7 @@
InputQueues input_queues_; ///< input queues for all inputs
std::vector<bool> statistics_;
uint8_t last_stat_percent_;
- uint32_t crude_percent_; //integer0-10000000, to be shirink to range 0-10
+ uint32_t crude_percent_; // integer0-10000000, to be shirink to range 0-10
bool is_stopped_;
std::string default_anim_; // normally "idle", "empty", if empty mine.
=== modified file 'src/logic/map_objects/tribes/ship.cc'
--- src/logic/map_objects/tribes/ship.cc 2016-02-22 07:25:15 +0000
+++ src/logic/map_objects/tribes/ship.cc 2016-03-10 16:23:18 +0000
@@ -794,9 +794,9 @@
get_position().y,
pd.get_positions(game)[0].x,
pd.get_positions(game)[0].y);
- //this should not happen, but in theory there could be some inconstinency
- //I (tiborb) failed to invoke this situation when testing so
- //I am not sure if following line behaves allright
+ // This should not happen, but in theory there could be some inconstinency
+ // I (tiborb) failed to invoke this situation when testing so
+ // I am not sure if following line behaves allright
get_fleet()->update(game);
start_task_idle(game, descr().main_animation(), 5000);
}
=== modified file 'src/logic/map_objects/tribes/ship.h'
--- src/logic/map_objects/tribes/ship.h 2016-02-15 23:26:42 +0000
+++ src/logic/map_objects/tribes/ship.h 2016-03-10 16:23:18 +0000
@@ -205,13 +205,13 @@
void exp_construct_port (Game &, const Coords&);
void exp_explore_island (Game &, IslandExploreDirection);
- //Returns integer of direction, or WalkingDir::IDLE if query invalid
- //Intended for LUA scripting
+ // Returns integer of direction, or WalkingDir::IDLE if query invalid
+ // Intended for LUA scripting
WalkingDir get_scouting_direction();
- //Returns integer of direction, or IslandExploreDirection::kNotSet
- //if query invalid
- //Intended for LUA scripting
+ // Returns integer of direction, or IslandExploreDirection::kNotSet
+ // if query invalid
+ // Intended for LUA scripting
IslandExploreDirection get_island_explore_direction();
void exp_cancel (Game &);
=== modified file 'src/logic/map_objects/tribes/warehouse.cc'
--- src/logic/map_objects/tribes/warehouse.cc 2016-02-21 18:57:49 +0000
+++ src/logic/map_objects/tribes/warehouse.cc 2016-03-10 16:23:18 +0000
@@ -542,7 +542,6 @@
portdock_->set_economy(get_economy());
// this is just to indicate something wrong is going on
- //(tiborb)
PortDock* pd_tmp = portdock_;
if (!pd_tmp->get_fleet()) {
log (" portdock for port at %3dx%3d created but without a fleet!\n",
@@ -595,11 +594,11 @@
const WareList& workers = get_workers();
for (DescriptionIndex id = 0; id < workers.get_nrwareids(); ++id) {
const uint32_t stock = workers.stock(id);
- //separate behaviour for the case of loading the game
- //(which does save/destroy/reload) and simply destroying ingame
+ // Separate behaviour for the case of loading the game
+ // (which does save/destroy/reload) and simply destroying ingame
if (game->is_loaded())
{
- //this game is really running
+ // This game is really running
for (uint32_t i = 0; i < stock; ++i) {
launch_worker(*game, id, Requirements()).start_task_leavebuilding(*game, true);
}
@@ -607,7 +606,7 @@
}
else
{
- //we are in the load-game sequence...
+ // We are in the load-game sequence...
remove_workers(id, stock);
}
}
@@ -990,7 +989,7 @@
return true;
}
- //we did not launch the ware...
+ // We did not launch the ware...
return false;
}
@@ -1095,7 +1094,7 @@
DescriptionIndex const id_ware = owner().tribe().ware_index(input);
if (owner().tribe().has_ware(id_ware)) {
remove_wares(id_ware, buildcost.second);
- //update statistic accordingly
+ // Update statistics accordingly
owner().ware_consumed(id_ware, buildcost.second);
} else
remove_workers(owner().tribe().safe_worker_index(input), buildcost.second);
=== modified file 'src/logic/map_objects/tribes/warehouse.h'
--- src/logic/map_objects/tribes/warehouse.h 2016-02-15 22:31:59 +0000
+++ src/logic/map_objects/tribes/warehouse.h 2016-03-10 16:23:18 +0000
@@ -273,8 +273,8 @@
PortDock * portdock_;
- //this is information for portdock,to know whether it should
- //try to recreate itself
+ // This is information for portdock, to know whether it should
+ // try to recreate itself
bool cleanup_in_progress_;
};
=== modified file 'src/logic/map_objects/tribes/worker.cc'
--- src/logic/map_objects/tribes/worker.cc 2016-02-17 16:20:45 +0000
+++ src/logic/map_objects/tribes/worker.cc 2016-03-10 16:23:18 +0000
@@ -111,7 +111,7 @@
{
Map & map = game.map();
- //Make sure that the specified resource is available in this world
+ // Make sure that the specified resource is available in this world
DescriptionIndex const res =
game.world().get_resource(action.sparam1.c_str());
if (res == Widelands::INVALID_INDEX)
@@ -216,7 +216,7 @@
Map & map = game.map();
- //Make sure that the specified resource is available in this world
+ // Make sure that the specified resource is available in this world
DescriptionIndex const res =
game.world().get_resource(action.sparam1.c_str());
if (res == Widelands::INVALID_INDEX)
@@ -1006,7 +1006,7 @@
return true;
}
- //update consumption statistic
+ // Update consumption statistic
owner().ware_consumed(wareindex, 1);
ware = fetch_carried_ware(game);
@@ -1536,9 +1536,9 @@
("MO(%u): [transfer]: from road to bad nextstep %u",
serial(), nextstep->serial());
} else
- //Scan-build reports Called C++ object pointer is null here.
- //This is a false positive.
- //See https://bugs.launchpad.net/widelands/+bug/1198918
+ // Scan-build reports Called C++ object pointer is null here.
+ // This is a false positive.
+ // See https://bugs.launchpad.net/widelands/+bug/1198918
throw wexception
("MO(%u): location %u has bad type",
serial(), location->serial());
@@ -2841,7 +2841,7 @@
descr().get_right_walk_anims(does_carry_ware())))
molog("[scout]: failed to reach destination\n");
else
- return; //start_task_movepath was successfull.
+ return; // start_task_movepath was successfull.
}
// Else evaluate for best second target
@@ -2874,8 +2874,8 @@
descr().get_right_walk_anims(does_carry_ware())))
molog("[scout]: Failed to reach destination\n");
else
- return; //Start task movepath success.
- //if failed go home
+ return; // Start task movepath success.
+ // If failed go home
}
}
// No reachable fields found.
=== modified file 'src/logic/player.cc'
--- src/logic/player.cc 2016-03-08 08:22:28 +0000
+++ src/logic/player.cc 2016-03-10 16:23:18 +0000
@@ -199,7 +199,7 @@
}
});
- //Populating remaining_shipnames vector
+ // Populating remaining_shipnames vector
for (const auto& shipname : tribe_descr.get_ship_names()) {
remaining_shipnames_.insert(shipname);
}
@@ -1013,8 +1013,6 @@
// top right neighbour
FCoords tr = map.tr_n(f);
PlayerNumber tr_owner_number = tr.field->get_owned_by();
- //MapIndex tr_index = map.get_index(tr, mapwidth);
- //Vision tr_vision = vision(tr_index);
// bottom right neighbour
FCoords br = map.br_n(f);
PlayerNumber br_owner_number = br.field->get_owned_by();
@@ -1028,9 +1026,6 @@
// left neighbour
FCoords l = map.l_n(f);
PlayerNumber l_owner_number = l.field->get_owned_by();
- //MapIndex l_index = map.get_index(l, mapwidth);
- //Vision l_vision = vision(l_index);
-
field.border = f.field->is_border();
field.border_r =
@@ -1166,7 +1161,7 @@
assert (ware_consumptions_.size() == egbase().tribes().nrwares());
assert (ware_stocks_.size() == egbase().tribes().nrwares());
- //calculate stocks
+ // Calculate stocks
std::vector<uint32_t> stocks(egbase().tribes().nrwares());
const uint32_t nrecos = get_nr_economies();
@@ -1182,8 +1177,7 @@
}
}
-
- //update statistics
+ // Update statistics
for (uint32_t i = 0; i < ware_productions_.size(); ++i) {
ware_productions_[i].push_back(current_produced_statistics_[i]);
current_produced_statistics_[i] = 0;
@@ -1374,7 +1368,7 @@
ware_productions_[idx][j] = fr.unsigned_32();
}
- //read consumption statistics
+ // Read consumption statistics
nr_wares = fr.unsigned_16();
nr_entries = fr.unsigned_16();
@@ -1397,7 +1391,7 @@
ware_consumptions_[idx][j] = fr.unsigned_32();
}
- //read stock statistics
+ // Read stock statistics
nr_wares = fr.unsigned_16();
nr_entries = fr.unsigned_16();
@@ -1418,7 +1412,7 @@
ware_stocks_[idx][j] = fr.unsigned_32();
}
- //all statistics should have the same size
+ // All statistics should have the same size
assert(ware_productions_.size() == ware_consumptions_.size());
assert(ware_productions_[0].size() == ware_consumptions_[0].size());
@@ -1440,7 +1434,7 @@
* Write statistics data to the give file
*/
void Player::write_statistics(FileWrite & fw) const {
- //write produce statistics
+ // Write produce statistics
fw.unsigned_16(current_produced_statistics_.size());
fw.unsigned_16(ware_productions_[0].size());
@@ -1452,7 +1446,7 @@
fw.unsigned_32(ware_productions_[i][j]);
}
- //write consume statistics
+ // Write consume statistics
fw.unsigned_16(current_consumed_statistics_.size());
fw.unsigned_16(ware_consumptions_[0].size());
@@ -1464,7 +1458,7 @@
fw.unsigned_32(ware_consumptions_[i][j]);
}
- //write stock statistics
+ // Write stock statistics
fw.unsigned_16(ware_stocks_.size());
fw.unsigned_16(ware_stocks_[0].size());
=== modified file 'src/logic/player.h'
--- src/logic/player.h 2016-03-02 17:13:06 +0000
+++ src/logic/player.h 2016-03-10 16:23:18 +0000
@@ -140,12 +140,12 @@
struct AiPersistentState {
AiPersistentState() : initialized(0) {}
- //was initialized
+ // Was initialized
uint8_t initialized;
uint32_t colony_scan_area;
uint32_t trees_around_cutters;
uint32_t expedition_start_time;
- int16_t ships_utilization; //0-10000 to avoid floats, used for decision for building new ships
+ int16_t ships_utilization; // 0-10000 to avoid floats, used for decision for building new ships
uint8_t no_more_expeditions;
int16_t last_attacked_player;
int32_t least_military_score;
=== modified file 'src/logic/save_handler.cc'
--- src/logic/save_handler.cc 2016-03-02 10:04:54 +0000
+++ src/logic/save_handler.cc 2016-03-10 16:23:18 +0000
@@ -78,7 +78,7 @@
last_saved_realtime_ = last_saved_realtime_ + 30000;
return;
}
- //roll autosaves
+ // Roll autosaves
int32_t number_of_rolls = g_options.pull_section("global").get_int("rolling_autosave", 5) - 1;
std::string filename_previous =
create_file_name(get_base_dir(), (boost::format("%s_%02d") % filename % number_of_rolls).str());
=== modified file 'src/logic/single_player_game_settings_provider.cc'
--- src/logic/single_player_game_settings_provider.cc 2016-01-18 19:35:25 +0000
+++ src/logic/single_player_game_settings_provider.cc 2016-03-10 16:23:18 +0000
@@ -95,7 +95,7 @@
player.ai = impls.at(0)->name;
player.random_ai = false;
}
- //If AI player then set tribe to random
+ // If AI player then set tribe to random
if (!s.scenario)
set_player_tribe(oldplayers, "", true);
}
=== modified file 'src/main.cc'
--- src/main.cc 2016-02-10 20:48:27 +0000
+++ src/main.cc 2016-03-10 16:23:18 +0000
@@ -46,7 +46,7 @@
WLApplication * g_app = nullptr;
try {
g_app = WLApplication::get(argc, const_cast<char const * *>(argv));
- //TODO(unknown): handle exceptions from the constructor
+ // TODO(unknown): handle exceptions from the constructor
g_app->run();
delete g_app;
=== modified file 'src/map_io/map_buildingdata_packet.cc'
--- src/map_io/map_buildingdata_packet.cc 2016-03-02 17:13:06 +0000
+++ src/map_io/map_buildingdata_packet.cc 2016-03-10 16:23:18 +0000
@@ -490,7 +490,6 @@
(game.map().get_fcoords(warehouse.get_position()),
warehouse.descr().vision_range()));
warehouse.next_military_act_ = game.get_gametime();
- //log("Read warehouse stuff for %p\n", &warehouse);
} else {
throw UnhandledVersionError("MapBuildingdataPacket - Warehouse",
packet_version, kCurrentPacketVersionWarehouse);
=== modified file 'src/map_io/map_object_loader.h'
--- src/map_io/map_object_loader.h 2015-11-29 09:43:15 +0000
+++ src/map_io/map_object_loader.h 2016-03-10 16:23:18 +0000
@@ -62,7 +62,7 @@
ReverseMapObjectMap::const_iterator const existing =
m_objects.find(n);
if (existing != m_objects.end()) {
- //delete &object; can not do this
+ // delete &object; can not do this
throw GameDataError("already loaded (%s)", to_string(existing->second->descr().type()).c_str());
}
m_objects.insert(std::pair<Serial, MapObject *>(n, &object));
=== modified file 'src/network/netclient.h'
--- src/network/netclient.h 2016-02-25 08:47:48 +0000
+++ src/network/netclient.h 2016-03-10 16:23:18 +0000
@@ -27,7 +27,7 @@
struct NetClientImpl;
-//TODO(unknown): Use composition instead of inheritance
+// TODO(unknown): Use composition instead of inheritance
/**
* NetClient manages the lifetime of a network game in which this computer
* participates as a client.
=== modified file 'src/network/nethost.cc'
--- src/network/nethost.cc 2016-02-25 08:47:48 +0000
+++ src/network/nethost.cc 2016-03-10 16:23:18 +0000
@@ -885,7 +885,7 @@
s.string(msg.msg);
s.unsigned_8(1);
s.string(msg.recipient);
- } else { //find the recipient
+ } else { // Find the recipient
int32_t clientnum = check_client(msg.recipient);
if (clientnum >= 0) {
s.signed_16(msg.playern);
@@ -1613,9 +1613,9 @@
// needs the file.
s.unsigned_8(NETCMD_NEW_FILE_AVAILABLE);
s.string(mapfilename);
- //Scan-build reports that access to bytes here results in a dereference of null pointer.
- //This is a false positive.
- //See https://bugs.launchpad.net/widelands/+bug/1198919
+ // Scan-build reports that access to bytes here results in a dereference of null pointer.
+ // This is a false positive.
+ // See https://bugs.launchpad.net/widelands/+bug/1198919
s.unsigned_32(file_->bytes);
s.string(file_->md5sum);
return true;
=== modified file 'src/profile/profile.cc'
--- src/profile/profile.cc 2016-02-14 15:49:59 +0000
+++ src/profile/profile.cc 2016-03-10 16:23:18 +0000
@@ -849,8 +849,8 @@
}
}
catch (const FileNotFoundError &) {
- //It's no problem if the config file does not exist. (It'll get
- //written on exit anyway)
+ // It's no problem if the config file does not exist. (It'll get
+ // written on exit anyway)
log("There's no configuration file, using default values.\n");
}
catch (const std::exception & e) {
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2016-03-02 17:13:06 +0000
+++ src/scripting/lua_map.cc 2016-03-10 16:23:18 +0000
@@ -4309,7 +4309,7 @@
*/
/* RST
- .. attribute:: field //working here
+ .. attribute:: field // working here
(RO) The field the bob is located on
*/
=== modified file 'src/sound/songset.cc'
--- src/sound/songset.cc 2014-10-14 06:30:20 +0000
+++ src/sound/songset.cc 2016-03-10 16:23:18 +0000
@@ -76,7 +76,7 @@
filename = *(current_song_++);
}
- //first, close the previous song and remove it from memory
+ // First, close the previous song and remove it from memory
if (m_) {
Mix_FreeMusic(m_);
m_ = nullptr;
@@ -88,7 +88,7 @@
fr_.close();
}
- //then open the new song
+ // Then open the new song
if (fr_.try_open(*g_fs, filename)) {
if (!(rwops_ = SDL_RWFromMem(fr_.data(0), fr_.get_size()))) {
fr_.close(); // fr_ should be Open iff rwops_ != 0
=== modified file 'src/sound/sound_handler.cc'
--- src/sound/sound_handler.cc 2016-01-28 05:24:34 +0000
+++ src/sound/sound_handler.cc 2016-03-10 16:23:18 +0000
@@ -95,12 +95,12 @@
{
read_config();
rng_.seed(SDL_GetTicks());
- //this RNG will still be somewhat predictable, but it's just to avoid
- //identical playback patterns
+ // This RNG will still be somewhat predictable, but it's just to avoid
+ // identical playback patterns
- //Windows Music has crickling inside if the buffer has another size
- //than 4k, but other systems work fine with less, some crash
- //with big buffers.
+ // Windows Music has crickling inside if the buffer has another size
+ // than 4k, but other systems work fine with less, some crash
+ // with big buffers.
#ifdef _WIN32
const uint16_t bufsize = 4096;
#else
@@ -294,7 +294,7 @@
(Mix_Chunk * const m =
Mix_LoadWAV_RW(SDL_RWFromMem(fr.data(fr.get_size(), 0), fr.get_size()), 1))
{
- //make sure that requested FXset exists
+ // Make sure that requested FXset exists
assert(fxs_.count(fx_name) > 0);
@@ -316,10 +316,8 @@
*/
int32_t SoundHandler::stereo_position(Widelands::Coords const position)
{
- //screen x, y (without clipping applied, might well be invisible)
+ // Screen x, y (without clipping applied, might well be invisible)
int32_t sx, sy;
- //x, y resolutions of game window
- Widelands::FCoords fposition;
if (nosound_)
return -1;
@@ -337,7 +335,7 @@
sx -= vp.x;
sy -= vp.y;
- //make sure position is inside viewport
+ // Make sure position is inside viewport
if (sx >= 0 && sx <= xres && sy >= 0 && sy <= yres)
return sx * 254 / xres;
@@ -355,34 +353,34 @@
uint8_t const priority)
{
bool allow_multiple = false; // convenience for easier code reading
- float evaluation; //temporary to calculate single influences
- float probability; //weighted total of all influences
+ float evaluation; // Temporary to calculate single influences
+ float probability; // Weighted total of all influences
if (nosound_)
return false;
- //probability that this fx gets played; initially set according to priority
+ // Probability that this fx gets played; initially set according to priority
// float division! not integer
probability = (priority % PRIO_ALLOW_MULTIPLE) / 128.0;
- //TODO(unknown): what to do with fx that happen offscreen?
- //TODO(unknown): reduce volume? reduce priority? other?
+ // TODO(unknown): what to do with fx that happen offscreen?
+ // TODO(unknown): reduce volume? reduce priority? other?
if (stereo_pos == -1) {
return false;
}
- //TODO(unknown): check for a free channel
+ // TODO(unknown): check for a free channel
if (priority == PRIO_ALWAYS_PLAY) {
- //TODO(unknown): if there is no free channel, kill a running fx and complain
+ // TODO(unknown): if there is no free channel, kill a running fx and complain
return true;
}
if (priority >= PRIO_ALLOW_MULTIPLE)
allow_multiple = true;
- //find out if an fx called fx_name is already running
+ // Find out if an fx called fx_name is already running
bool already_running = false;
// Access to active_fx_ is protected because it can
@@ -404,9 +402,9 @@
if (!allow_multiple && already_running)
return false;
- //TODO(unknown): long time since any play increases weighted_priority
- //TODO(unknown): high general frequency reduces weighted priority
- //TODO(unknown): deal with "coupled" effects like throw_net and retrieve_net
+ // TODO(unknown): long time since any play increases weighted_priority
+ // TODO(unknown): high general frequency reduces weighted priority
+ // TODO(unknown): deal with "coupled" effects like throw_net and retrieve_net
uint32_t const ticks_since_last_play =
SDL_GetTicks() - fxs_[fx_name]->last_used_;
@@ -417,17 +415,14 @@
// "decrease improbability"
probability = 1 - ((1 - probability) * (1 - evaluation));
- } else { //penalize an fx for playing in short succession
+ } else { // Penalize an fx for playing in short succession
evaluation =
static_cast<float>(ticks_since_last_play) / SLIDING_WINDOW_SIZE;
probability *= evaluation; // decrease probability
}
- //printf("XXXXX %s ticks: %i ev: %f prob: %f\n",
- // fx_name.c_str(), ticks_since_last_play, evaluation, probability);
-
- //finally: the decision
- // float division! not integer
+ // finally: the decision
+ // float division! not integer
return (rng_.rand() % 255) / 255.0 <= probability;
}
@@ -477,7 +472,7 @@
return;
}
- //see if the FX should be played
+ // See if the FX should be played
if (!play_or_not(fx_name, stereo_pos, priority))
return;
@@ -700,17 +695,17 @@
*/
void SoundHandler::music_finished_callback()
{
- //DO NOT CALL SDL_mixer FUNCTIONS OR SDL_LockAudio FROM HERE !!!
+ // DO NOT CALL SDL_mixer FUNCTIONS OR SDL_LockAudio FROM HERE !!!
SDL_Event event;
if (g_sound_handler.current_songset_ == "intro") {
- //special case for splashscreen: there, only one song is ever played
+ // Special case for splashscreen: there, only one song is ever played
event.type = SDL_KEYDOWN;
event.key.state = SDL_PRESSED;
event.key.keysym.sym = SDLK_ESCAPE;
} else {
- //else just play the next song - see general description for
- //further explanation
+ // Else just play the next song - see general description for
+ // further explanation
event.type = SDL_USEREVENT;
event.user.code = CHANGE_MUSIC;
}
@@ -722,7 +717,7 @@
*/
void SoundHandler::fx_finished_callback(int32_t const channel)
{
- //DO NOT CALL SDL_mixer FUNCTIONS OR SDL_LockAudio FROM HERE !!!
+ // DO NOT CALL SDL_mixer FUNCTIONS OR SDL_LockAudio FROM HERE !!!
assert(0 <= channel);
g_sound_handler.handle_channel_finished(static_cast<uint32_t>(channel));
=== modified file 'src/ui_basic/box.h'
--- src/ui_basic/box.h 2016-02-04 19:46:40 +0000
+++ src/ui_basic/box.h 2016-03-10 16:23:18 +0000
@@ -74,7 +74,7 @@
void scrollbar_moved(int32_t);
void update_positions();
- //don't resize beyond this size
+ // Don't resize beyond this size
int max_x_, max_y_;
struct Item {
=== modified file 'src/ui_basic/editbox.cc'
--- src/ui_basic/editbox.cc 2016-02-17 08:48:02 +0000
+++ src/ui_basic/editbox.cc 2016-03-10 16:23:18 +0000
@@ -188,7 +188,7 @@
* Handle keypress/release events
*/
// TODO(unknown): Text input works only because code.unicode happens to map to ASCII for
-// ASCII characters (--> //HERE). Instead, all user editable strings should be
+// ASCII characters (--> // HERE). Instead, all user editable strings should be
// real unicode.
bool EditBox::handle_key(bool const down, SDL_Keysym const code)
{
@@ -199,7 +199,7 @@
return true;
case SDLK_TAB:
- //let the panel handle the tab key
+ // Let the panel handle the tab key
return false;
case SDLK_KP_ENTER:
=== modified file 'src/ui_basic/panel.cc'
--- src/ui_basic/panel.cc 2016-03-02 17:11:16 +0000
+++ src/ui_basic/panel.cc 2016-03-10 16:23:18 +0000
@@ -112,9 +112,9 @@
* Free all of the panel's children.
*/
void Panel::free_children() {
- //Scan-build claims this results in double free.
- //This is a false positive.
- //See https://bugs.launchpad.net/widelands/+bug/1198928
+ // Scan-build claims this results in double free.
+ // This is a false positive.
+ // See https://bugs.launchpad.net/widelands/+bug/1198928
while (first_child_) delete first_child_;
}
=== modified file 'src/ui_basic/panel.h'
--- src/ui_basic/panel.h 2016-02-14 14:09:29 +0000
+++ src/ui_basic/panel.h 2016-03-10 16:23:18 +0000
@@ -128,7 +128,7 @@
int32_t get_x() const {return x_;}
int32_t get_y() const {return y_;}
Point get_pos() const {return Point(x_, y_);}
- //int unstead of uint because of overflow situations
+ // int instead of uint because of overflow situations
int32_t get_w() const {return w_;}
int32_t get_h() const {return h_;}
=== modified file 'src/ui_basic/radiobutton.cc'
--- src/ui_basic/radiobutton.cc 2016-02-03 18:09:15 +0000
+++ src/ui_basic/radiobutton.cc 2016-03-10 16:23:18 +0000
@@ -87,9 +87,9 @@
* Free all associated buttons.
*/
Radiogroup::~Radiogroup() {
- //Scan-build claims this results in double free.
- //This is a false positive.
- //See https://bugs.launchpad.net/widelands/+bug/1198928
+ // Scan-build claims this results in double free.
+ // This is a false positive.
+ // See https://bugs.launchpad.net/widelands/+bug/1198928
while (buttons_) delete buttons_;
}
=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc 2016-03-09 07:15:44 +0000
+++ src/ui_basic/table.cc 2016-03-10 16:23:18 +0000
@@ -491,7 +491,7 @@
select(static_cast<uint32_t>(new_selection));
- //scroll to newly selected entry
+ // Scroll to newly selected entry
if (scrollbar_)
{
// Keep an unselected item above or below
=== modified file 'src/ui_basic/tabpanel.cc'
--- src/ui_basic/tabpanel.cc 2016-02-14 14:09:29 +0000
+++ src/ui_basic/tabpanel.cc 2016-03-10 16:23:18 +0000
@@ -150,7 +150,7 @@
panel->get_desired_size(&panelw, &panelh);
// TODO(unknown): the panel might be bigger -> add a scrollbar in that case
- //panel->set_size(panelw, panelh);
+ // panel->set_size(panelw, panelh);
if (panelw > w)
w = panelw;
=== modified file 'src/ui_fsmenu/campaign_select.cc'
--- src/ui_fsmenu/campaign_select.cc 2016-02-07 16:31:06 +0000
+++ src/ui_fsmenu/campaign_select.cc 2016-03-10 16:23:18 +0000
@@ -370,8 +370,7 @@
}
-//telling this class what campaign we have and since we know what campaign we
-//have, fill it.
+// Telling this class what campaign we have and since we know what campaign we have, fill it.
void FullscreenMenuCampaignMapSelect::set_campaign(uint32_t const i) {
campaign = i;
fill_table();
=== modified file 'src/ui_fsmenu/launch_mpg.cc'
--- src/ui_fsmenu/launch_mpg.cc 2016-02-07 16:31:06 +0000
+++ src/ui_fsmenu/launch_mpg.cc 2016-03-10 16:23:18 +0000
@@ -492,11 +492,11 @@
if (settings.scenario)
set_scenario_values();
}
- //Try to translate the map name.
- //This will work on every official map as expected
- //and 'fail silently' (not find a translation) for already translated campaign map names.
- //It will also translate 'false-positively' on any user-made map which shares a name with
- //the official maps, but this should not be a problem to worry about.
+ // Try to translate the map name.
+ // This will work on every official map as expected
+ // and 'fail silently' (not find a translation) for already translated campaign map names.
+ // It will also translate 'false-positively' on any user-made map which shares a name with
+ // the official maps, but this should not be a problem to worry about.
i18n::Textdomain td("maps");
mapname_.set_text(_(settings.mapname));
}
=== modified file 'src/ui_fsmenu/mapselect.cc'
--- src/ui_fsmenu/mapselect.cc 2016-02-14 14:09:29 +0000
+++ src/ui_fsmenu/mapselect.cc 2016-03-10 16:23:18 +0000
@@ -233,8 +233,8 @@
// Fill it with all files we find in all directories.
FilenameSet files = g_fs->list_directory(curdir_);
- //If we are not at the top of the map directory hierarchy (we're not talking
- //about the absolute filesystem top!) we manually add ".."
+ // If we are not at the top of the map directory hierarchy (we're not talking
+ // about the absolute filesystem top!) we manually add ".."
if (curdir_ != basedir_) {
maps_data_.push_back(MapData::create_parent_dir(curdir_));
}
=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc 2016-02-18 18:12:48 +0000
+++ src/wlapplication.cc 2016-03-10 16:23:18 +0000
@@ -224,9 +224,9 @@
} // namespace
void WLApplication::setup_homedir() {
- //If we don't have a home directory don't do anything
+ // If we don't have a home directory don't do anything
if (homedir_.size()) {
- //assume some dir exists
+ // Assume some dir exists
try {
log ("Set home directory: %s\n", homedir_.c_str());
@@ -237,7 +237,7 @@
log("Failed to add home directory: %s\n", e.what());
}
} else {
- //TODO(unknown): complain
+ // TODO(unknown): complain
}
}
@@ -295,7 +295,7 @@
{
g_fs = new LayeredFileSystem();
- parse_commandline(argc, argv); //throws ParameterError, handled by main.cc
+ parse_commandline(argc, argv); // throws ParameterError, handled by main.cc
if (commandline_.count("homedir")) {
log ("Adding home directory: %s\n", commandline_["homedir"].c_str());
@@ -326,7 +326,7 @@
Section & config = g_options.pull_section("global");
- //Start the SDL core
+ // Start the SDL core
if (SDL_Init(SDL_INIT_VIDEO) == -1)
throw wexception("Failed to initialize SDL, no valid video driver: %s", SDL_GetError());
@@ -357,7 +357,7 @@
// seed random number generator used for random tribe selection
std::srand(time(nullptr));
- //make sure we didn't forget to read any global option
+ // Make sure we didn't forget to read any global option
g_options.check_used();
}
@@ -367,7 +367,7 @@
// TODO(unknown): Handle errors that happen here!
WLApplication::~WLApplication()
{
- //Do use the opposite order of WLApplication::init()
+ // Do use the opposite order of WLApplication::init()
shutdown_hardware();
shutdown_settings();
@@ -680,7 +680,7 @@
if (sdl_window) {
SDL_SetWindowGrab(sdl_window, SDL_FALSE);
}
- warp_mouse(mouse_position_); //TODO(unknown): is this redundant?
+ warp_mouse(mouse_position_); // TODO(unknown): is this redundant?
}
}
@@ -702,11 +702,11 @@
*/
bool WLApplication::init_settings() {
- //read in the configuration file
+ // Read in the configuration file
g_options.read("config", "global");
Section & s = g_options.pull_section("global");
- //then parse the commandline - overwrites conffile settings
+ // Then parse the commandline - overwrites conffile settings
handle_commandline_parameters();
set_mouse_swap(s.get_bool("swapmouse", false));
@@ -823,22 +823,22 @@
continue;
}
- //are we looking at an option at all?
+ // Are we looking at an option at all?
if (opt.compare(0, 2, "--"))
throw ParameterError();
else
opt.erase(0, 2); // yes. remove the leading "--", just for cosmetics
- //look if this option has a value
+ // Look if this option has a value
std::string::size_type const pos = opt.find('=');
if (pos == std::string::npos) { // if no equals sign found
value = "";
} else {
- //extract option value
+ // Extract option value
value = opt.substr(pos + 1);
- //remove value from option name
+ // Remove value from option name
opt.erase(pos, opt.size() - pos);
}
@@ -859,8 +859,8 @@
logfile_ = commandline_["logfile"];
std::cerr << "Redirecting log target to: " << logfile_ << std::endl;
if (logfile_.size() != 0) {
- //TODO(unknown): (very small) memory leak of 1 ofstream;
- //swaw the buffers (internally) of the file and wout
+ // TODO(unknown): (very small) memory leak of 1 ofstream;
+ // swaw the buffers (internally) of the file and wout
std::ofstream * widelands_out = new std::ofstream(logfile_.c_str());
std::streambuf * logbuf = widelands_out->rdbuf();
wout.rdbuf(logbuf);
@@ -949,10 +949,10 @@
commandline_.erase("script");
}
- //If it hasn't been handled yet it's probably an attempt to
- //override a conffile setting
- //With typos, this will create invalid config settings. They
- //will be taken care of (==ignored) when saving the options
+ // If it hasn't been handled yet it's probably an attempt to
+ // override a conffile setting
+ // With typos, this will create invalid config settings. They
+ // will be taken care of (==ignored) when saving the options
const std::map<std::string, std::string>::const_iterator commandline_end =
commandline_.end();
@@ -971,7 +971,7 @@
if (commandline_.count("help") || commandline_.count("version")) {
init_language();
- throw ParameterError(); //no message on purpose
+ throw ParameterError(); // No message on purpose
}
}
=== modified file 'src/wlapplication.h'
--- src/wlapplication.h 2016-02-09 16:29:48 +0000
+++ src/wlapplication.h 2016-03-10 16:23:18 +0000
@@ -20,7 +20,7 @@
#ifndef WL_WLAPPLICATION_H
#define WL_WLAPPLICATION_H
-//Workaround for bug http://sourceforge.net/p/mingw/bugs/2152/
+// Workaround for bug http://sourceforge.net/p/mingw/bugs/2152/
#ifdef __MINGW32__
#ifndef _WIN64
#define _USE_32BIT_TIME_T 1
@@ -146,7 +146,7 @@
/// \warning This function doesn't check for dumbness
bool get_key_state(SDL_Scancode const key) const {return SDL_GetKeyboardState(nullptr)[key];}
- //@{
+ // @{
void warp_mouse(Point);
void set_input_grab(bool grab);
@@ -161,7 +161,7 @@
/// Lock the mouse cursor into place (e.g., for scrolling the map)
void set_mouse_lock(const bool locked) {mouse_locked_ = locked;}
- //@}
+ // @}
// Refresh the graphics settings with the latest options.
@@ -217,7 +217,7 @@
/// --scenario or --loadgame.
std::string script_to_run_;
- //Log all output to this file if set, otherwise use cout
+ // Log all output to this file if set, otherwise use cout
std::string logfile_;
GameType game_type_;
@@ -252,9 +252,9 @@
std::string datadir_;
std::string datadir_for_testing_;
- ///Holds this process' one and only instance of WLApplication, if it was
- ///created already. nullptr otherwise.
- ///\note This is private on purpose. Read the class documentation.
+ /// Holds this process' one and only instance of WLApplication, if it was
+ /// created already. nullptr otherwise.
+ /// \note This is private on purpose. Read the class documentation.
static WLApplication * the_singleton;
void handle_mousebutton(SDL_Event &, InputCallback const *);
=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc 2016-02-13 12:15:29 +0000
+++ src/wui/buildingwindow.cc 2016-03-10 16:23:18 +0000
@@ -427,7 +427,6 @@
igbase().game().send_player_start_or_cancel_expedition(building_);
// No need to die here - as soon as the request is handled, the UI will get updated by the portdock
- //die();
}
/**
=== modified file 'src/wui/fieldaction.cc'
--- src/wui/fieldaction.cc 2016-02-13 12:15:29 +0000
+++ src/wui/fieldaction.cc 2016-03-10 16:23:18 +0000
@@ -751,7 +751,7 @@
*/
void FieldActionWindow::act_buildroad()
{
- //if we area already building a road just ignore this
+ // If we area already building a road just ignore this
if (!ibase().is_building_road()) {
ibase().start_build_road(m_node, m_plr->player_number());
okdialog();
=== modified file 'src/wui/game_debug_ui.cc'
--- src/wui/game_debug_ui.cc 2016-02-01 17:17:45 +0000
+++ src/wui/game_debug_ui.cc 2016-03-10 16:23:18 +0000
@@ -417,7 +417,7 @@
// Remove from our list if its not in the bobs
// list, or if it doesn't seem to exist anymore
m_ui_bobs.remove(idx);
- idx--; //reiter the same index
+ idx--; // reiter the same index
}
// Add remaining
for (const Widelands::Bob * temp_bob : bobs) {
=== modified file 'src/wui/game_main_menu_save_game.cc'
--- src/wui/game_main_menu_save_game.cc 2016-02-14 14:17:17 +0000
+++ src/wui/game_main_menu_save_game.cc 2016-03-10 16:23:18 +0000
@@ -123,7 +123,7 @@
} else {
// Display current game infos
{
- //Try to translate the map name.
+ // Try to translate the map name.
i18n::Textdomain td("maps");
mapname_.set_text(_(parent.game().get_map()->get_name()));
}
@@ -158,7 +158,7 @@
}
button_ok_->set_enabled(true);
- //Try to translate the map name.
+ // Try to translate the map name.
{
i18n::Textdomain td("maps");
mapname_.set_text(_(gpdp.get_mapname()));
=== modified file 'src/wui/game_message_menu.cc'
--- src/wui/game_message_menu.cc 2016-02-01 17:17:45 +0000
+++ src/wui/game_message_menu.cc 2016-03-10 16:23:18 +0000
@@ -450,7 +450,7 @@
switch (mode) {
case Inbox:
- //archive highlighted message
+ // Archive highlighted message
if (!work_done) {
if (!list->has_selection()) return;
@@ -460,7 +460,7 @@
}
break;
case Archive:
- //restore highlighted message
+ // Restore highlighted message
if (!work_done) {
if (!list->has_selection()) return;
=== modified file 'src/wui/game_summary.cc'
--- src/wui/game_summary.cc 2016-02-07 16:31:06 +0000
+++ src/wui/game_summary.cc 2016-03-10 16:23:18 +0000
@@ -159,8 +159,8 @@
Widelands::Player* single_won = nullptr;
uint8_t teawon_ = 0;
InteractivePlayer* ipl = game_.get_ipl();
- //this defines a row to be selected, current player,
- //if not then the first line
+ // This defines a row to be selected, current player,
+ // if not then the first line
uint32_t current_player_position = 0;
for (uintptr_t i = 0; i < players_status.size(); i++) {
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc 2016-02-22 09:53:09 +0000
+++ src/wui/interactive_base.cc 2016-03-10 16:23:18 +0000
@@ -362,7 +362,7 @@
static boost::format node_format("(%i, %i)");
node_text = as_condensed
((node_format % sel_.pos.node.x % sel_.pos.node.y).str());
- } else { //this is an editor
+ } else { // This is an editor
static boost::format node_format("(%i, %i, %i)");
const int32_t height = map[sel_.pos.node].get_height();
node_text = as_condensed
@@ -735,8 +735,6 @@
{
assert(buildroad_);
- //log("Add overlay\n");
-
Map & map = egbase().map();
// preview of the road
@@ -834,8 +832,6 @@
{
assert(buildroad_);
- //log("Remove overlay\n");
-
// preview of the road
if (jobid_) {
edge_overlay_manager_->remove_overlay(jobid_);
=== modified file 'src/wui/plot_area.cc'
--- src/wui/plot_area.cc 2016-03-07 18:55:11 +0000
+++ src/wui/plot_area.cc 2016-03-10 16:23:18 +0000
@@ -408,8 +408,8 @@
float posx = get_inner_w() - space_at_right;
const int lx = get_inner_w() - space_at_right;
int ly = yoffset;
- // init start point of the plot line with the first data value.
- // this prevent that the plot start always at zero
+ // Init start point of the plot line with the first data value.
+ // This prevents that the plot starts always at zero
if (int value = (*dataset)[dataset->size() - 1]) {
ly -= static_cast<int32_t>(scale_value(yline_length, highest_scale, value));
}
@@ -421,7 +421,7 @@
int32_t const curx = static_cast<int32_t>(posx);
int32_t cury = yoffset;
- //scale the line to the available space
+ // Scale the line to the available space
if (int32_t value = (*dataset)[i]) {
const float length_y = scale_value(yline_length, highest_scale, value);
cury -= static_cast<int32_t>(length_y);
@@ -495,7 +495,7 @@
void DifferentialPlotArea::draw(RenderTarget & dst) {
float const xline_length = get_inner_w() - space_at_right - spacing;
float const yline_length = get_inner_h() - space_at_bottom - spacing;
- //yoffset of the zero line
+ // yoffset of the zero line
float const yoffset = spacing + ((get_inner_h() - space_at_bottom) - spacing) / 2;
const uint32_t time_ms = get_plot_time();
@@ -509,7 +509,7 @@
// How many do we take together when relative ploting
const int32_t how_many = calc_how_many(time_ms, sample_rate_);
- //find max and min value
+ // Find max and min value
int32_t max = 0;
int32_t min = 0;
@@ -544,7 +544,7 @@
}
}
- //use equal positive and negative range
+ // Use equal positive and negative range
min = abs(min);
uint32_t highest_scale = 0;
if (min > max) {
@@ -552,7 +552,7 @@
} else {
highest_scale = max;
}
- //print the min and max values
+ // Print the min and max values
draw_value
(std::to_string(highest_scale), RGBColor(60, 125, 0),
Point(get_inner_w() - space_at_right - 2, spacing + 2), dst);
@@ -592,8 +592,8 @@
sub = xline_length / static_cast<float>(nr_samples);
}
- //highest_scale represent the space between zero line and top.
- //-> half of the whole differential plot area
+ // Highest_scale represent the space between zero line and top.
+ // -> half of the whole differential plot area
draw_plot_line(dst, dataset, yline_length, highest_scale * 2, sub, color, yoffset);
}
}
=== modified file 'src/wui/ware_statistics_menu.cc'
--- src/wui/ware_statistics_menu.cc 2016-01-29 08:37:22 +0000
+++ src/wui/ware_statistics_menu.cc 2016-03-10 16:23:18 +0000
@@ -46,7 +46,7 @@
static const char pic_tab_stock[] = "images/wui/stats/menu_tab_wares_stock.png";
static const RGBColor colors[] = {
- RGBColor(115, 115, 115), //inactive
+ RGBColor(115, 115, 115), // inactive
RGBColor(255, 0, 0),
RGBColor (0, 144, 12),
RGBColor (0, 0, 255),
@@ -96,7 +96,7 @@
RGBColor (96, 143, 71),
RGBColor(163, 74, 128),
RGBColor(183, 142, 10),
- RGBColor(105, 155, 160),//shark infested water, run!
+ RGBColor(105, 155, 160), // shark infested water, run!
};
static const uint32_t colors_length = sizeof(colors) / sizeof(RGBColor);
@@ -142,7 +142,7 @@
{
uint8_t const nr_wares = parent.get_player()->egbase().tribes().nrwares();
- //init color sets
+ // Init color sets
color_map_.resize(nr_wares);
std::fill(color_map_.begin(), color_map_.end(), INACTIVE);
active_colors_.resize(colors_length);
@@ -153,8 +153,8 @@
box->set_border(5, 5, 5, 5);
set_center_panel(box);
- //setup plot widgets
- //create a tabbed environment for the different plots
+ // Setup plot widgets
+ // Create a tabbed environment for the different plots
uint8_t const tab_offset = 30;
uint8_t const spacing = 5;
uint8_t const plot_width = get_inner_w() - 2 * spacing;
@@ -210,10 +210,10 @@
tabs->activate(0);
- //add tabbed environment to box
+ // Add tabbed environment to box
box->add(tabs, UI::Align::kLeft, true);
- //register statistics data
+ // Register statistics data
for (Widelands::DescriptionIndex cur_ware = 0; cur_ware < nr_wares; ++cur_ware) {
plot_production_->register_plot_data
(cur_ware,
@@ -264,27 +264,27 @@
* simultaneously.
*/
void WareStatisticsMenu::cb_changed_to(Widelands::DescriptionIndex id, bool what) {
- if (what) { //activate ware
- //search lowest free color
+ if (what) { // Activate ware
+ // Search lowest free color
uint8_t color_index = INACTIVE;
for (uint32_t i = 0; i < active_colors_.size(); ++i) {
if (!active_colors_[i]) {
- //prevent index out of bounds
+ // Prevent index out of bounds
color_index = std::min(i + 1, colors_length - 1);
active_colors_[i] = 1;
break;
}
}
- //assign color
+ // Assign color
color_map_[static_cast<size_t>(id)] = color_index;
plot_production_->set_plotcolor(static_cast<size_t>(id), colors[color_index]);
plot_consumption_->set_plotcolor(static_cast<size_t>(id), colors[color_index]);
plot_economy_->set_plotcolor(static_cast<size_t>(id), colors[color_index]);
plot_stock_->set_plotcolor(static_cast<size_t>(id), colors[color_index]);
- } else { //deactivate ware
+ } else { // Deactivate ware
uint8_t old_color = color_map_[static_cast<size_t>(id)];
if (old_color != INACTIVE) {
active_colors_[old_color - 1] = 0;
=== modified file 'src/wui/ware_statistics_menu.h'
--- src/wui/ware_statistics_menu.h 2016-01-28 05:24:34 +0000
+++ src/wui/ware_statistics_menu.h 2016-03-10 16:23:18 +0000
@@ -42,7 +42,7 @@
WuiPlotArea * plot_consumption_;
WuiPlotArea * plot_stock_;
DifferentialPlotArea * plot_economy_;
- std::vector<uint8_t> color_map_; //maps ware index to colors
+ std::vector<uint8_t> color_map_; // Maps ware index to colors
std::vector<bool> active_colors_;
void clicked_help();
=== modified file 'src/wui/waresdisplay.h'
--- src/wui/waresdisplay.h 2016-01-30 22:26:21 +0000
+++ src/wui/waresdisplay.h 2016-03-10 16:23:18 +0000
@@ -104,7 +104,7 @@
UI::Textarea curware_;
WareListSelectionType selected_;
WareListSelectionType hidden_;
- WareListSelectionType in_selection_; //Wares in temporary anchored selection
+ WareListSelectionType in_selection_; // Wares in temporary anchored selection
bool selectable_;
bool horizontal_;
=== modified file 'src/wui/watchwindow.cc'
--- src/wui/watchwindow.cc 2016-02-09 16:29:48 +0000
+++ src/wui/watchwindow.cc 2016-03-10 16:23:18 +0000
@@ -41,7 +41,7 @@
#define NUM_VIEWS 5
#define REFRESH_TIME 5000
-//Holds information for a view
+// Holds information for a view
struct WatchWindowView {
Point view_point;
Widelands::ObjectPointer tracking; // if non-null, we're tracking a Bob
@@ -168,7 +168,7 @@
toggle_buttons();
}
-//Calc point on map from coords
+// Calc point on map from coords
Point WatchWindow::calc_coords(Widelands::Coords const coords) {
// Initial positioning
int32_t vx = (coords.x + (coords.y & 1) * 0.5) * TRIANGLE_WIDTH;
@@ -179,7 +179,7 @@
return Point(vx - mapview.get_w() / 2, vy - height - mapview.get_h() / 2);
}
-//Switch to next view
+// Switch to next view
void WatchWindow::next_view(bool const first) {
if (!first && views.size() == 1)
return;
@@ -193,13 +193,13 @@
}
-//Saves the coordinates of a view if it was already shown (and possibly moved)
+// Saves the coordinates of a view if it was already shown (and possibly moved)
void WatchWindow::save_coords() {
views[cur_index].view_point = mapview.get_viewpoint();
}
-//Enables/Disables buttons for views
+// Enables/Disables buttons for views
void WatchWindow::toggle_buttons() {
for (uint32_t i = 0; i < NUM_VIEWS; ++i) {
if (i < views.size()) {
@@ -212,7 +212,7 @@
}
}
-//Draws the current view
+// Draws the current view
void WatchWindow::show_view(bool) {
mapview.set_viewpoint(views[cur_index].view_point, true);
}
@@ -264,7 +264,7 @@
===============
*/
void WatchWindow::stop_tracking_by_drag(int32_t, int32_t) {
- //Disable switching while dragging
+ // Disable switching while dragging
if (mapview.is_dragging()) {
last_visit = game().get_gametime();
views[cur_index].tracking = nullptr;
Follow ups