merged patch #714 by silene
- removal of dead stuff and static linkage marking for internal functions
This commit is contained in:
parent
48d08c07b8
commit
f231fb12e0
70 changed files with 326 additions and 867 deletions
|
@ -23,9 +23,9 @@
|
|||
namespace about
|
||||
{
|
||||
|
||||
config about_list = config();
|
||||
std::map<std::string , std::string> images;
|
||||
std::string images_default;
|
||||
static config about_list = config();
|
||||
static std::map<std::string , std::string> images;
|
||||
static std::string images_default;
|
||||
|
||||
std::vector<std::string> get_text(std::string campaign) {
|
||||
std::vector< std::string > res;
|
||||
|
|
|
@ -24,8 +24,6 @@ class display;
|
|||
namespace about
|
||||
{
|
||||
|
||||
extern config about_list;
|
||||
|
||||
void show_about(display &disp, std::string campaign="");
|
||||
void set_about(const config& cfg);
|
||||
std::vector<std::string> get_text(std::string campaign="");
|
||||
|
|
|
@ -60,14 +60,14 @@ private:
|
|||
// since it is called from a variety of places.
|
||||
namespace victory_conditions
|
||||
{
|
||||
bool when_enemies_defeated = true;
|
||||
static bool when_enemies_defeated = true;
|
||||
|
||||
void set_victory_when_enemies_defeated(bool on)
|
||||
{
|
||||
when_enemies_defeated = on;
|
||||
}
|
||||
|
||||
bool victory_when_enemies_defeated()
|
||||
static bool victory_when_enemies_defeated()
|
||||
{
|
||||
return when_enemies_defeated;
|
||||
}
|
||||
|
|
|
@ -322,7 +322,6 @@ bool unit_can_move(const gamemap::location& loc, const unit_map& units,
|
|||
|
||||
namespace victory_conditions {
|
||||
void set_victory_when_enemies_defeated(bool on);
|
||||
bool victory_when_enemies_defeated();
|
||||
}
|
||||
|
||||
//Function to check if an attack will satisfy the requirements for backstab
|
||||
|
|
|
@ -253,32 +253,6 @@ void ai::do_attack_analysis(
|
|||
}
|
||||
|
||||
|
||||
struct battle_type {
|
||||
battle_type(const gamemap::location& a, const gamemap::location& d,
|
||||
t_translation::t_letter t)
|
||||
: attacker(a),defender(d),terrain(t),weapon(-1)
|
||||
{}
|
||||
|
||||
const gamemap::location attacker;
|
||||
const gamemap::location defender;
|
||||
const t_translation::t_letter terrain;
|
||||
int weapon;
|
||||
};
|
||||
|
||||
bool operator<(const battle_type& a, const battle_type& b)
|
||||
{
|
||||
return a.attacker < b.attacker ||
|
||||
a.attacker == b.attacker && a.defender < b.defender ||
|
||||
a.attacker == b.attacker && a.defender == b.defender &&
|
||||
a.terrain < b.terrain;
|
||||
}
|
||||
|
||||
bool operator==(const battle_type& a, const battle_type& b)
|
||||
{
|
||||
return a.attacker == b.attacker && a.defender == b.defender &&
|
||||
a.terrain == b.terrain;
|
||||
}
|
||||
|
||||
void ai::attack_analysis::analyze(const gamemap& map, unit_map& units,
|
||||
const std::vector<team>& teams,
|
||||
const gamestatus& status, const game_data& gamedata,
|
||||
|
|
|
@ -26,9 +26,21 @@
|
|||
#define ERR_NG LOG_STREAM(err, engine)
|
||||
#define DEBUG_NG LOG_STREAM(info, engine)
|
||||
|
||||
const int terrain_builder::rule_image::TILEWIDTH = 72;
|
||||
const int terrain_builder::rule_image::UNITPOS = 36 + 18;
|
||||
const int terrain_builder::tile::BASE_Y_INTERVAL = 100000;
|
||||
/** The tile width used when using basex and basey. This is not,
|
||||
* necessarily, the tile width in pixels, this is totally
|
||||
* arbitrary. However, it will be set to 72 for convenience.
|
||||
*/
|
||||
static const int TILEWIDTH = 72;
|
||||
/** The position of unit graphics in a tile. Graphics whose y
|
||||
* position is below this value are considered background for
|
||||
* this tile; graphics whose y position is above this value are
|
||||
* considered foreground.
|
||||
*/
|
||||
static const int UNITPOS = 36 + 18;
|
||||
/** The allowed interval for the base-y position. The possible values are from
|
||||
* -BASE_Y_INTERVAL to BASE_Y_INTERVAL-1
|
||||
*/
|
||||
static const int BASE_Y_INTERVAL = 100000;
|
||||
|
||||
terrain_builder::rule_image::rule_image(int layer, int x, int y, bool global_image) :
|
||||
layer(layer), basex(x), basey(y), global_image(global_image)
|
||||
|
@ -57,7 +69,7 @@ void terrain_builder::tile::add_image_to_cache(const std::string &tod, ordered_r
|
|||
else
|
||||
basey -= BASE_Y_INTERVAL/2;
|
||||
|
||||
if(layer < 0 || (layer == 0 && basey < rule_image::UNITPOS)) {
|
||||
if(layer < 0 || (layer == 0 && basey < UNITPOS)) {
|
||||
images_background.push_back(tod_variant->second.image);
|
||||
} else {
|
||||
images_foreground.push_back(tod_variant->second.image);
|
||||
|
@ -348,14 +360,14 @@ terrain_builder::terrain_constraint terrain_builder::rotate(const terrain_builde
|
|||
|
||||
double vx, vy, rx, ry;
|
||||
|
||||
vx = double(itor->basex) - double(rule_image::TILEWIDTH)/2;
|
||||
vy = double(itor->basey) - double(rule_image::TILEWIDTH)/2;
|
||||
vx = double(itor->basex) - double(TILEWIDTH)/2;
|
||||
vy = double(itor->basey) - double(TILEWIDTH)/2;
|
||||
|
||||
rx = xyrotations[angle].xx * vx + xyrotations[angle].xy * vy;
|
||||
ry = xyrotations[angle].yx * vx + xyrotations[angle].yy * vy;
|
||||
|
||||
itor->basex = int(rx + rule_image::TILEWIDTH/2);
|
||||
itor->basey = int(ry + rule_image::TILEWIDTH/2);
|
||||
itor->basex = int(rx + TILEWIDTH/2);
|
||||
itor->basey = int(ry + TILEWIDTH/2);
|
||||
|
||||
//std::cerr << "Rotation: from " << vx << ", " << vy << " to " << itor->basex <<
|
||||
// ", " << itor->basey << "\n";
|
||||
|
@ -481,8 +493,8 @@ void terrain_builder::add_images_from_config(rule_imagelist& images, const confi
|
|||
|
||||
int basex = 0, basey = 0;
|
||||
if((**img)["base"].empty()) {
|
||||
basex = rule_image::TILEWIDTH / 2 + dx;
|
||||
basey = rule_image::TILEWIDTH / 2 + dy;
|
||||
basex = TILEWIDTH / 2 + dx;
|
||||
basey = TILEWIDTH / 2 + dy;
|
||||
} else {
|
||||
std::vector<std::string> base = utils::split((**img)["base"]);
|
||||
|
||||
|
@ -526,9 +538,8 @@ void terrain_builder::add_constraints(
|
|||
constraints[loc].terrain_types_match = type;
|
||||
}
|
||||
|
||||
int x = loc.x * rule_image::TILEWIDTH * 3 / 4;
|
||||
int y = loc.y * rule_image::TILEWIDTH + (loc.x % 2) *
|
||||
rule_image::TILEWIDTH / 2;
|
||||
int x = loc.x * TILEWIDTH * 3 / 4;
|
||||
int y = loc.y * TILEWIDTH + (loc.x % 2) * TILEWIDTH / 2;
|
||||
add_images_from_config(constraints[loc].images, global_images, true, x, y);
|
||||
}
|
||||
|
||||
|
@ -827,7 +838,7 @@ void terrain_builder::apply_rule(const terrain_builder::building_rule &rule, con
|
|||
// Thus, allowed values for basey are from -50000 to 49999
|
||||
for(img = constraint->second.images.begin(); img != constraint->second.images.end(); ++img) {
|
||||
btile.images.insert(std::pair<int, const rule_image*>(
|
||||
img->layer*tile::BASE_Y_INTERVAL + tile::BASE_Y_INTERVAL/2 + img->basey, &*img));
|
||||
img->layer*BASE_Y_INTERVAL + BASE_Y_INTERVAL/2 + img->basey, &*img));
|
||||
}
|
||||
|
||||
// Sets flags
|
||||
|
|
|
@ -163,17 +163,6 @@ public:
|
|||
*/
|
||||
int basex, basey;
|
||||
|
||||
/** The tile width used when using basex and basey. This is not,
|
||||
* necessarily, the tile width in pixels, this is totally
|
||||
* arbitrary. However, it will be set to 72 for convenience.
|
||||
*/
|
||||
static const int TILEWIDTH;
|
||||
/** The position of unit graphics in a tile. Graphics whose y
|
||||
* position is below this value are considered background for
|
||||
* this tile; graphics whose y position is above this value are
|
||||
* considered foreground. */
|
||||
static const int UNITPOS;
|
||||
|
||||
/** Set to true if the image was defined as a child of the
|
||||
* [terrain_graphics] tag, set to false if it was defined as a
|
||||
* child of a [tile] tag */
|
||||
|
@ -251,11 +240,6 @@ public:
|
|||
*/
|
||||
ordered_ri_list images;
|
||||
|
||||
/** The allowed interval for the base-y position. The possible values are from
|
||||
* -BASE_Y_INTERVAL to BASE_Y_INTERVAL-1
|
||||
*/
|
||||
static const int BASE_Y_INTERVAL;
|
||||
|
||||
/** The list of images which are in front of the unit sprites,
|
||||
* attached to this tile. This member is considered a cache: it
|
||||
* is built once, and on-demand.
|
||||
|
|
|
@ -239,16 +239,6 @@ void handle_system_event(const SDL_Event& event)
|
|||
}
|
||||
}
|
||||
|
||||
void copy_ucs2_to_clipboard(const ucs2_string& text)
|
||||
{
|
||||
if(text.empty())
|
||||
return;
|
||||
clipboard_string = utils::ucs2_string_to_utf8_string(text);
|
||||
UseX x11;
|
||||
XSetSelectionOwner(x11->dpy(), XA_PRIMARY, x11->window(), CurrentTime);
|
||||
XSetSelectionOwner(x11->dpy(), x11->XA_CLIPBOARD(), x11->window(), CurrentTime);
|
||||
}
|
||||
|
||||
void copy_to_clipboard(const std::string& text)
|
||||
{
|
||||
if (text.empty()) {
|
||||
|
@ -324,24 +314,6 @@ static bool try_grab_target(Atom target, std::string& ret)
|
|||
return false;
|
||||
}
|
||||
|
||||
ucs2_string copy_ucs2_from_clipboard()
|
||||
{
|
||||
if(!clipboard_string.empty())
|
||||
return utils::utf8_string_to_ucs2_string(clipboard_string);
|
||||
utf8_string text;
|
||||
|
||||
UseX x11;
|
||||
if(try_grab_target(x11->UTF8_STRING(), text))
|
||||
return utils::utf8_string_to_ucs2_string(text);
|
||||
if(try_grab_target(x11->XA_COMPOUND_TEXT(), text))
|
||||
return utils::utf8_string_to_ucs2_string(text);
|
||||
if(try_grab_target(x11->XA_TEXT(), text))
|
||||
return utils::utf8_string_to_ucs2_string(text);
|
||||
if(try_grab_target(XA_STRING, text))
|
||||
return utils::utf8_string_to_ucs2_string(text);
|
||||
return ucs2_string();
|
||||
}
|
||||
|
||||
std::string copy_from_clipboard()
|
||||
{
|
||||
if (!clipboard_string.empty())
|
||||
|
@ -376,43 +348,6 @@ std::string copy_from_clipboard()
|
|||
void handle_system_event(const SDL_Event& )
|
||||
{}
|
||||
|
||||
void copy_ucs2_to_clipboard(const ucs2_string& text)
|
||||
{
|
||||
if(text.empty())
|
||||
return;
|
||||
if(!OpenClipboard(NULL))
|
||||
return;
|
||||
EmptyClipboard();
|
||||
|
||||
//convert newlines
|
||||
ucs2_string str;
|
||||
str.reserve(text.size() + 1);
|
||||
ucs2_string::const_iterator first = text.begin();
|
||||
ucs2_string::const_iterator last = text.begin();
|
||||
do {
|
||||
if(*last != '\n') {
|
||||
++last;
|
||||
continue;
|
||||
}
|
||||
str.insert(str.end(), first, last);
|
||||
str.push_back('\r');
|
||||
str.push_back('\n');
|
||||
first = ++last;
|
||||
} while(last != text.end());
|
||||
str.push_back('\0');
|
||||
|
||||
HGLOBAL hglb = GlobalAlloc(GMEM_MOVEABLE, str.size() * sizeof(Uint16));
|
||||
if(hglb == NULL) {
|
||||
CloseClipboard();
|
||||
return;
|
||||
}
|
||||
Uint16* const buffer = reinterpret_cast<Uint16* const>(GlobalLock(hglb));
|
||||
memcpy(buffer, (Uint16 const *)&str.front(), str.size() * sizeof(Uint16));
|
||||
GlobalUnlock(hglb);
|
||||
SetClipboardData(CF_UNICODETEXT, hglb);
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
void copy_to_clipboard(const std::string& text)
|
||||
{
|
||||
if(text.empty())
|
||||
|
@ -448,36 +383,6 @@ void copy_to_clipboard(const std::string& text)
|
|||
CloseClipboard();
|
||||
}
|
||||
|
||||
ucs2_string copy_ucs2_from_clipboard()
|
||||
{
|
||||
if(!IsClipboardFormatAvailable(CF_UNICODETEXT))
|
||||
return ucs2_string();
|
||||
if(!OpenClipboard(NULL))
|
||||
return ucs2_string();
|
||||
|
||||
HGLOBAL hglb = GetClipboardData(CF_UNICODETEXT);
|
||||
if(hglb == NULL) {
|
||||
CloseClipboard();
|
||||
return ucs2_string();
|
||||
}
|
||||
Uint16 const * buffer = reinterpret_cast<Uint16 const *>(GlobalLock(hglb));
|
||||
if(buffer == NULL) {
|
||||
CloseClipboard();
|
||||
return ucs2_string();
|
||||
}
|
||||
|
||||
//convert newlines
|
||||
ucs2_string str;
|
||||
while(*buffer != '\0') {
|
||||
if(*buffer != '\r')
|
||||
str.push_back(*buffer);
|
||||
++buffer;
|
||||
}
|
||||
GlobalUnlock(hglb);
|
||||
CloseClipboard();
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string copy_from_clipboard()
|
||||
{
|
||||
if(!IsClipboardFormatAvailable(CF_TEXT))
|
||||
|
@ -548,51 +453,6 @@ std::string copy_from_clipboard()
|
|||
#define CLIPBOARD_FUNCS_DEFINED
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
void copy_ucs2_to_clipboard(const ucs2_string& text) {
|
||||
ucs2_string str;
|
||||
str.reserve(text.size() + 1);
|
||||
for(int i = 0; i < text.size(); ++i) {
|
||||
if(text[i] == '\n')
|
||||
str.push_back('\r');
|
||||
else
|
||||
str.push_back(text[i]);
|
||||
}
|
||||
str.push_back(0);
|
||||
OSStatus err = noErr;
|
||||
ScrapRef scrap = kScrapRefNone;
|
||||
err = ClearCurrentScrap();
|
||||
if(err != noErr)
|
||||
return;
|
||||
err = GetCurrentScrap(&scrap);
|
||||
if(err != noErr)
|
||||
return;
|
||||
PutScrapFlavor(scrap, kScrapFlavorTypeUnicode, kScrapFlavorMaskNone, str.size(), &str.front());
|
||||
}
|
||||
|
||||
ucs2_string copy_ucs2_from_clipboard() {
|
||||
ucs2_string str;
|
||||
OSStatus err = noErr;
|
||||
ScrapRef scrap = kScrapRefNone;
|
||||
err = GetCurrentScrap(&scrap);
|
||||
if(err != noErr)
|
||||
return str;
|
||||
Size scrapsize;
|
||||
err = GetScrapFlavorSize(scrap, kScrapFlavorTypeUnicode, &scrapsize);
|
||||
if(err != noErr)
|
||||
return str;
|
||||
str.reserve(scrapsize);
|
||||
str.resize(scrapsize);
|
||||
err = GetScrapFlavorData(scrap, kScrapFlavorTypeUnicode, &scrapsize, const_cast<Uint16*>(&str.front()));
|
||||
if(err != noErr) {
|
||||
str.clear();
|
||||
return str;
|
||||
}
|
||||
for(int i = 0; i < str.size(); ++i) {
|
||||
if(str[i] == '\r')
|
||||
str[i] = '\n';
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
void copy_to_clipboard(const std::string& text)
|
||||
{
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
#include <string>
|
||||
#include "SDL.h"
|
||||
#include "serialization/string_utils.hpp"
|
||||
void copy_ucs2_to_clipboard(const ucs2_string& text);
|
||||
ucs2_string copy_ucs2_from_clipboard();
|
||||
void copy_to_clipboard(const std::string& text);
|
||||
std::string copy_from_clipboard();
|
||||
|
||||
|
|
|
@ -26,15 +26,12 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool use_colour_cursors()
|
||||
static bool use_colour_cursors()
|
||||
{
|
||||
return game_config::editor == false && preferences::use_colour_cursors();
|
||||
}
|
||||
|
||||
SDL_Cursor* create_cursor(surface surf)
|
||||
static SDL_Cursor* create_cursor(surface surf)
|
||||
{
|
||||
const surface nsurf(make_neutral_surface(surf));
|
||||
if(nsurf == NULL) {
|
||||
|
@ -85,6 +82,8 @@ SDL_Cursor* create_cursor(surface surf)
|
|||
return SDL_CreateCursor(&data[0],&mask[0],cursor_width,nsurf->h,0,0);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
SDL_Cursor* cache[cursor::NUM_CURSORS] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
|
||||
|
||||
//this array must have members corresponding to cursor::CURSOR_TYPE enum members
|
||||
|
@ -107,7 +106,9 @@ bool have_focus = true;
|
|||
bool hide_bw = false;
|
||||
bool colour_ready = false;
|
||||
|
||||
SDL_Cursor* get_cursor(cursor::CURSOR_TYPE type)
|
||||
}
|
||||
|
||||
static SDL_Cursor* get_cursor(cursor::CURSOR_TYPE type)
|
||||
{
|
||||
if(cache[type] == NULL) {
|
||||
static const std::string prefix = "cursors-bw/";
|
||||
|
@ -118,7 +119,7 @@ SDL_Cursor* get_cursor(cursor::CURSOR_TYPE type)
|
|||
return cache[type];
|
||||
}
|
||||
|
||||
void clear_cache()
|
||||
static void clear_cache()
|
||||
{
|
||||
for(size_t n = 0; n != cursor::NUM_CURSORS; ++n) {
|
||||
if(cache[n] != NULL) {
|
||||
|
@ -132,8 +133,6 @@ void clear_cache()
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace cursor
|
||||
{
|
||||
|
||||
|
|
|
@ -60,8 +60,9 @@ namespace {
|
|||
#endif
|
||||
|
||||
const int MaxZoom = 200;
|
||||
}
|
||||
|
||||
int MinZoom(const gamemap& map, const SDL_Rect& viewport)
|
||||
static int MinZoom(const gamemap& map, const SDL_Rect& viewport)
|
||||
{
|
||||
if(map.x()<4 || !map.y() ) return DefaultZoom;
|
||||
// These ugly formulas try to give the optimal and mathematically exact minimal zoom
|
||||
|
@ -75,6 +76,7 @@ namespace {
|
|||
return minimum<int>(zoom,DefaultZoom);
|
||||
}
|
||||
|
||||
namespace {
|
||||
const size_t SideBarGameStatus_x = 16;
|
||||
const size_t SideBarGameStatus_y = 220;
|
||||
}
|
||||
|
@ -724,9 +726,7 @@ void display::flip()
|
|||
font::undraw_floating_labels(frameBuffer);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void draw_panel(CVideo& video, const theme::panel& panel, std::vector<gui::button>& buttons)
|
||||
static void draw_panel(CVideo& video, const theme::panel& panel, std::vector<gui::button>& buttons)
|
||||
{
|
||||
//log_scope("draw panel");
|
||||
surface surf(image::get_image(panel.image(),image::UNSCALED));
|
||||
|
@ -759,7 +759,7 @@ void draw_panel(CVideo& video, const theme::panel& panel, std::vector<gui::butto
|
|||
}
|
||||
}
|
||||
|
||||
void draw_label(CVideo& video, surface target, const theme::label& label)
|
||||
static void draw_label(CVideo& video, surface target, const theme::label& label)
|
||||
{
|
||||
//log_scope("draw label");
|
||||
|
||||
|
@ -804,8 +804,6 @@ void draw_label(CVideo& video, surface target, const theme::label& label)
|
|||
update_rect(loc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void display::draw(bool update,bool force)
|
||||
{
|
||||
bool changed = false;
|
||||
|
@ -1708,15 +1706,12 @@ void display::draw_movement_info(const gamemap::location& loc, int xloc, int ylo
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
const std::string& get_direction(size_t n)
|
||||
static const std::string& get_direction(size_t n)
|
||||
{
|
||||
static std::string const dirs[6] = { "-n", "-ne", "-se", "-s", "-sw", "-nw" };
|
||||
return dirs[n >= sizeof(dirs)/sizeof(*dirs) ? 0 : n];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::vector<std::string> display::get_fog_shroud_graphics(const gamemap::location& loc)
|
||||
{
|
||||
std::vector<std::string> res;
|
||||
|
@ -2325,7 +2320,7 @@ void display::delay(unsigned int milliseconds) const
|
|||
|
||||
// timestring() returns the current date as a string.
|
||||
// Uses preferences::clock_format() for formatting.
|
||||
std::string timestring ( void )
|
||||
static std::string timestring ()
|
||||
{
|
||||
#define TIME_SIZE 10
|
||||
time_t now = time ( NULL );
|
||||
|
|
|
@ -37,6 +37,8 @@ unsigned input_blocker::instance_count = 0; //static initialization
|
|||
namespace events
|
||||
{
|
||||
|
||||
void raise_help_string_event(int mousex, int mousey);
|
||||
|
||||
namespace {
|
||||
int disallow_resize = 0;
|
||||
}
|
||||
|
@ -219,13 +221,6 @@ void focus_handler(const handler* ptr)
|
|||
}
|
||||
}
|
||||
|
||||
void cycle_focus()
|
||||
{
|
||||
if(event_contexts.empty() == false) {
|
||||
event_contexts.back().cycle_focus();
|
||||
}
|
||||
}
|
||||
|
||||
bool has_focus(const handler* ptr, const SDL_Event* event)
|
||||
{
|
||||
if(event_contexts.empty()) {
|
||||
|
|
|
@ -510,18 +510,13 @@ std::string get_user_data_dir()
|
|||
#endif
|
||||
}
|
||||
|
||||
std::string read_stream(std::istream& s)
|
||||
static std::string read_stream(std::istream& s)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << s.rdbuf();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string read_stdin()
|
||||
{
|
||||
return read_stream(std::cin);
|
||||
}
|
||||
|
||||
std::istream *istream_file(std::string const &fname)
|
||||
{
|
||||
LOG_FS << "streaming " << fname << " for reading.\n";
|
||||
|
@ -599,9 +594,7 @@ std::string read_map(const std::string& name)
|
|||
return res;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool is_directory_internal(const std::string& fname)
|
||||
static bool is_directory_internal(const std::string& fname)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
_finddata_t info;
|
||||
|
@ -623,8 +616,6 @@ bool is_directory_internal(const std::string& fname)
|
|||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool is_directory(const std::string& fname)
|
||||
{
|
||||
#ifdef USE_ZIPIOS
|
||||
|
@ -726,9 +717,7 @@ bool operator!=(const file_tree_checksum& lhs, const file_tree_checksum& rhs)
|
|||
return !operator==(lhs,rhs);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void get_file_tree_checksum_internal(const std::string& path, file_tree_checksum& res)
|
||||
static void get_file_tree_checksum_internal(const std::string& path, file_tree_checksum& res)
|
||||
{
|
||||
std::vector<std::string> files, dirs;
|
||||
get_files_in_dir(path,&files,&dirs,ENTIRE_FILE_PATH);
|
||||
|
@ -751,15 +740,6 @@ void get_file_tree_checksum_internal(const std::string& path, file_tree_checksum
|
|||
}
|
||||
}
|
||||
|
||||
} //end anonymous namespace
|
||||
|
||||
file_tree_checksum get_file_tree_checksum(const std::string& path)
|
||||
{
|
||||
file_tree_checksum res;
|
||||
get_file_tree_checksum_internal(path,res);
|
||||
return res;
|
||||
}
|
||||
|
||||
const file_tree_checksum& data_tree_checksum()
|
||||
{
|
||||
static file_tree_checksum checksum;
|
||||
|
@ -824,15 +804,15 @@ std::set<std::string> binary_paths;
|
|||
typedef std::map<std::string,std::vector<std::string> > paths_map;
|
||||
paths_map binary_paths_cache;
|
||||
|
||||
void init_binary_paths()
|
||||
}
|
||||
|
||||
static void init_binary_paths()
|
||||
{
|
||||
if(binary_paths.empty()) {
|
||||
binary_paths.insert("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
binary_paths_manager::binary_paths_manager()
|
||||
{}
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ std::istream *istream_file(std::string const &fname);
|
|||
std::ostream *ostream_file(std::string const &fname);
|
||||
//throws io_exception if an error occurs
|
||||
void write_file(const std::string& fname, const std::string& data);
|
||||
std::string read_stdin();
|
||||
|
||||
std::string read_map(const std::string& name);
|
||||
|
||||
|
@ -96,10 +95,6 @@ bool operator==(const file_tree_checksum& lhs, const file_tree_checksum& rhs);
|
|||
bool operator!=(const file_tree_checksum& lhs, const file_tree_checksum& rhs);
|
||||
|
||||
|
||||
//function to get the time at which the most recently modified file
|
||||
//in a directory tree was modified at
|
||||
file_tree_checksum get_file_tree_checksum(const std::string& path);
|
||||
|
||||
//function to get the time at which the data/ tree was last modified at
|
||||
const file_tree_checksum& data_tree_checksum();
|
||||
|
||||
|
|
128
src/font.cpp
128
src/font.cpp
|
@ -107,8 +107,10 @@ typedef std::map<std::string,SDL_Rect> line_size_cache_map;
|
|||
//map of styles -> sizes -> cache
|
||||
std::map<int,std::map<int,line_size_cache_map> > line_size_cache;
|
||||
|
||||
}
|
||||
|
||||
//Splits the UTF-8 text into text_chunks using the same font.
|
||||
std::vector<text_chunk> split_text(std::string const & utf8_text) {
|
||||
static std::vector<text_chunk> split_text(std::string const & utf8_text) {
|
||||
text_chunk current_chunk(0);
|
||||
std::vector<text_chunk> chunks;
|
||||
|
||||
|
@ -144,7 +146,7 @@ std::vector<text_chunk> split_text(std::string const & utf8_text) {
|
|||
return chunks;
|
||||
}
|
||||
|
||||
TTF_Font* open_font(const std::string& fname, int size)
|
||||
static TTF_Font* open_font(const std::string& fname, int size)
|
||||
{
|
||||
std::string name;
|
||||
if(!game_config::path.empty()) {
|
||||
|
@ -180,7 +182,7 @@ TTF_Font* open_font(const std::string& fname, int size)
|
|||
return font;
|
||||
}
|
||||
|
||||
TTF_Font* get_font(font_id id)
|
||||
static TTF_Font* get_font(font_id id)
|
||||
{
|
||||
const std::map<font_id, TTF_Font*>::iterator it = font_table.find(id);
|
||||
if(it != font_table.end())
|
||||
|
@ -201,7 +203,7 @@ TTF_Font* get_font(font_id id)
|
|||
return font;
|
||||
}
|
||||
|
||||
void clear_fonts()
|
||||
static void clear_fonts()
|
||||
{
|
||||
for(std::map<font_id,TTF_Font*>::iterator i = font_table.begin(); i != font_table.end(); ++i) {
|
||||
TTF_CloseFont(i->second);
|
||||
|
@ -213,6 +215,8 @@ void clear_fonts()
|
|||
line_size_cache.clear();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
struct font_style_setter
|
||||
{
|
||||
font_style_setter(TTF_Font* font, int style) : font_(font), old_style_(0)
|
||||
|
@ -276,7 +280,16 @@ manager::~manager()
|
|||
TTF_Quit();
|
||||
}
|
||||
|
||||
void set_font_list(const std::vector<subset_descriptor>& fontlist)
|
||||
//structure used to describe a font, and the subset of the Unicode character
|
||||
//set it covers.
|
||||
struct subset_descriptor
|
||||
{
|
||||
std::string name;
|
||||
std::vector<std::pair<size_t, size_t> > present_codepoints;
|
||||
};
|
||||
|
||||
//sets the font list to be used.
|
||||
static void set_font_list(const std::vector<subset_descriptor>& fontlist)
|
||||
{
|
||||
clear_fonts();
|
||||
font_map.reserve(0x10000);
|
||||
|
@ -553,7 +566,7 @@ text_surface &text_cache::find(text_surface const &t)
|
|||
|
||||
}
|
||||
|
||||
surface render_text(const std::string& text, int fontsize, const SDL_Color& colour, int style)
|
||||
static surface render_text(const std::string& text, int fontsize, const SDL_Color& colour, int style)
|
||||
{
|
||||
const std::vector<std::string> lines = utils::split(text, '\n', utils::REMOVE_EMPTY);
|
||||
std::vector<std::vector<surface> > surfaces;
|
||||
|
@ -614,85 +627,6 @@ surface get_rendered_text(const std::string& str, int size, const SDL_Color& col
|
|||
return render_text(str, size, colour, style);
|
||||
}
|
||||
|
||||
//Measure a single line of ucs2 text with a specific font_size and
|
||||
//style without newline chars.
|
||||
//
|
||||
//This is INSECURE with lines which are WIDER than UINT16_MAX pixels.
|
||||
//
|
||||
//It is intended for the command_line widget only which has a line
|
||||
//length restriction and small font size.
|
||||
SDL_Rect measure_ucs2_text_line(ucs2_string::const_iterator first, ucs2_string::const_iterator last, int font_size, int style) {
|
||||
wassert(last - first >= 0);
|
||||
|
||||
SDL_Rect rect;
|
||||
rect.w = 0;
|
||||
rect.h = 0;
|
||||
|
||||
ucs2_string chunk((last - first ) + 2);
|
||||
ucs2_string::iterator chunk_itor = chunk.begin();
|
||||
*chunk_itor = 0;
|
||||
|
||||
int current_font = 0;
|
||||
|
||||
//set the font for the first char
|
||||
if(*first < font_map.size() && font_map[*first] >= 0) {
|
||||
current_font = font_map[*first];
|
||||
}
|
||||
|
||||
for(;first != last; ++first) {
|
||||
if(*first < font_map.size() && font_map[*first] >= 0 && font_map[*first] != current_font) {
|
||||
TTF_Font* ttfont = get_font(font_id(current_font, font_size));
|
||||
if(ttfont == NULL) {
|
||||
chunk_itor = chunk.begin();
|
||||
*(chunk_itor++) = *first;
|
||||
current_font = font_map[*first];
|
||||
continue;
|
||||
}
|
||||
*(chunk_itor++) = 0;
|
||||
|
||||
font_style_setter const style_setter(ttfont, style);
|
||||
|
||||
int x, y;
|
||||
TTF_SizeUNICODE(ttfont, (Uint16 const *)&chunk.front(), &x, &y);
|
||||
rect.x = x;
|
||||
rect.y = y;
|
||||
|
||||
rect.w += rect.x;
|
||||
rect.h = maximum<Sint16>(rect.h, rect.y);
|
||||
|
||||
chunk_itor = chunk.begin();
|
||||
|
||||
current_font = font_map[*first];
|
||||
}
|
||||
*(chunk_itor++) = *first;
|
||||
}
|
||||
if (chunk_itor != chunk.begin()) {
|
||||
TTF_Font* ttfont = get_font(font_id(current_font, font_size));
|
||||
if(ttfont == NULL) {
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
return rect;
|
||||
}
|
||||
*(chunk_itor++) = 0;
|
||||
|
||||
font_style_setter const style_setter(ttfont, style);
|
||||
|
||||
int x, y;
|
||||
TTF_SizeUNICODE(ttfont, (Uint16 const *)&chunk.front(), &x, &y);
|
||||
rect.x = x;
|
||||
rect.y = y;
|
||||
|
||||
rect.w += rect.x;
|
||||
rect.h = maximum<Sint16>(rect.h, rect.y);
|
||||
}
|
||||
//reset rect.x and rec.y because we abused it to store the area
|
||||
//of the last chunk
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
||||
SDL_Rect draw_text_line(surface gui_surface, const SDL_Rect& area, int size,
|
||||
const SDL_Color& colour, const std::string& text,
|
||||
int x, int y, bool use_tooltips, int style)
|
||||
|
@ -781,15 +715,6 @@ int get_max_height(int size)
|
|||
return TTF_FontHeight(font);
|
||||
}
|
||||
|
||||
std::string remove_first_space(const std::string& text)
|
||||
{
|
||||
if (text.length() > 0 && text[0] == ' ') {
|
||||
return text.substr(1);
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
int line_width(const std::string& line, int font_size, int style)
|
||||
{
|
||||
return line_size(line,font_size,style).w;
|
||||
|
@ -1089,17 +1014,6 @@ void show_floating_label(int handle, bool value)
|
|||
}
|
||||
}
|
||||
|
||||
const std::string& get_floating_label_text(int handle)
|
||||
{
|
||||
const label_map::iterator i = labels.find(handle);
|
||||
if(i != labels.end()) {
|
||||
return i->second.text();
|
||||
} else {
|
||||
static const std::string empty_str;
|
||||
return empty_str;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Rect get_floating_label_rect(int handle)
|
||||
{
|
||||
const label_map::iterator i = labels.find(handle);
|
||||
|
@ -1185,8 +1099,7 @@ void undraw_floating_labels(surface screen)
|
|||
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool add_font_to_fontlist(config* fonts_config, std::vector<font::subset_descriptor>& fontlist, const std::string& name)
|
||||
static bool add_font_to_fontlist(config* fonts_config, std::vector<font::subset_descriptor>& fontlist, const std::string& name)
|
||||
{
|
||||
config* font = fonts_config->find_child("font", "name", name);
|
||||
if(font == NULL)
|
||||
|
@ -1213,7 +1126,6 @@ namespace {
|
|||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace font {
|
||||
|
||||
|
|
16
src/font.hpp
16
src/font.hpp
|
@ -32,17 +32,6 @@ struct manager {
|
|||
struct error {};
|
||||
};
|
||||
|
||||
//structure used to describe a font, and the subset of the Unicode character
|
||||
//set it covers.
|
||||
struct subset_descriptor
|
||||
{
|
||||
std::string name;
|
||||
std::vector<std::pair<size_t, size_t> > present_codepoints;
|
||||
};
|
||||
|
||||
//sets the font list to be used.
|
||||
void set_font_list(const std::vector<subset_descriptor>& fontlist);
|
||||
|
||||
//various standard colours
|
||||
extern const SDL_Color NORMAL_COLOUR, GRAY_COLOUR, LOBBY_COLOUR, GOOD_COLOUR, BAD_COLOUR,
|
||||
BLACK_COLOUR, DARK_COLOUR, YELLOW_COLOUR, BUTTON_COLOUR,
|
||||
|
@ -93,9 +82,6 @@ SDL_Rect draw_text_line(CVideo* gui, const SDL_Rect& area, int size,
|
|||
const SDL_Color& colour, const std::string& text,
|
||||
int x, int y, bool use_tooltips, int style);
|
||||
|
||||
//measures the width and height of a single ucs2 text line
|
||||
SDL_Rect measure_ucs2_text_line(ucs2_string::const_iterator first, ucs2_string::const_iterator last, int font_size = SIZE_NORMAL, int style = TTF_STYLE_NORMAL);
|
||||
|
||||
// Returns the maximum height of a font, in pixels
|
||||
int get_max_height(int size);
|
||||
|
||||
|
@ -157,8 +143,6 @@ void remove_floating_label(int handle);
|
|||
/// hides or shows a floating label
|
||||
void show_floating_label(int handle, bool show);
|
||||
|
||||
const std::string& get_floating_label_text(int handle);
|
||||
|
||||
SDL_Rect get_floating_label_rect(int handle);
|
||||
|
||||
void draw_floating_labels(surface screen);
|
||||
|
|
16
src/game.cpp
16
src/game.cpp
|
@ -68,14 +68,14 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
bool less_campaigns_rank(const config* a, const config* b) {
|
||||
static bool less_campaigns_rank(const config* a, const config* b) {
|
||||
return lexical_cast_default<int>((*a)["rank"],1000) <
|
||||
lexical_cast_default<int>((*b)["rank"],1000);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class game_controller
|
||||
{
|
||||
public:
|
||||
|
@ -847,10 +847,9 @@ bool game_controller::new_campaign()
|
|||
return true;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
}
|
||||
|
||||
std::string format_file_size(const std::string& size_str)
|
||||
static std::string format_file_size(const std::string& size_str)
|
||||
{
|
||||
double size = lexical_cast_default<double>(size_str,0.0);
|
||||
|
||||
|
@ -883,7 +882,8 @@ std::string format_file_size(const std::string& size_str)
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
namespace
|
||||
{
|
||||
|
||||
void game_controller::download_campaigns()
|
||||
{
|
||||
|
@ -1622,7 +1622,7 @@ game_controller::~game_controller()
|
|||
sound::close_sound();
|
||||
}
|
||||
|
||||
int play_game(int argc, char** argv)
|
||||
static int play_game(int argc, char** argv)
|
||||
{
|
||||
const int start_ticks = SDL_GetTicks();
|
||||
|
||||
|
|
|
@ -32,24 +32,16 @@ namespace game_config
|
|||
int rest_heal_amount= 2;
|
||||
int recall_cost = 20;
|
||||
int kill_experience = 8;
|
||||
int leadership_bonus = 25;
|
||||
int lobby_refresh = 2000;
|
||||
const std::string version = VERSION;
|
||||
bool debug = false, editor = false, ignore_replay_errors = false, mp_debug = false, exit_at_end = false, no_delay = false, disable_autosave = false;
|
||||
|
||||
std::string game_icon = "wesnoth-icon.png", game_title, game_logo, title_music, anonymous_music,
|
||||
victory_music, defeat_music;
|
||||
std::string game_icon = "wesnoth-icon.png", game_title, game_logo, title_music;
|
||||
int title_logo_x = 0, title_logo_y = 0, title_buttons_x = 0, title_buttons_y = 0, title_buttons_padding = 0,
|
||||
title_tip_x = 0, title_tip_y = 0, title_tip_width = 0, title_tip_padding = 0;
|
||||
|
||||
std::string missile_n_image, missile_ne_image;
|
||||
title_tip_x = 0, title_tip_width = 0, title_tip_padding = 0;
|
||||
|
||||
std::string terrain_mask_image = "terrain/alphamask.png";
|
||||
|
||||
std::string map_image = "maps/wesnoth.png";
|
||||
std::string rightside_image = "misc/rightside.png";
|
||||
std::string rightside_image_bot = "misc/rightside-bottom.png";
|
||||
|
||||
std::string energy_image = "misc/bar-energy.png";
|
||||
std::string moved_ball_image = "misc/ball-moved.png";
|
||||
std::string unmoved_ball_image = "misc/ball-unmoved.png";
|
||||
|
@ -59,7 +51,6 @@ namespace game_config
|
|||
std::string flag_image = "terrain/flag-1.png:150,terrain/flag-2.png:150";
|
||||
std::string flag_rgb;
|
||||
|
||||
std::string dot_image = "misc/dot.png";
|
||||
std::string cross_image = "misc/cross.png";
|
||||
|
||||
std::vector<std::string> foot_left_nw, foot_left_n, foot_right_nw, foot_right_n;
|
||||
|
@ -70,8 +61,6 @@ namespace game_config
|
|||
std::string checked_menu_image = "buttons/checkbox-pressed.png";
|
||||
std::string wml_menu_image = "buttons/WML-custom.png";
|
||||
|
||||
std::string download_campaign_image;
|
||||
|
||||
std::string level_image;
|
||||
std::string ellipsis_image;
|
||||
|
||||
|
@ -125,16 +114,12 @@ namespace game_config
|
|||
game_title = v["title"];
|
||||
game_logo = v["logo"];
|
||||
title_music = v["title_music"];
|
||||
anonymous_music = v["anonymous_music"];
|
||||
victory_music = v["victory_music"];
|
||||
defeat_music = v["defeat_music"];
|
||||
|
||||
title_logo_x = atoi(v["logo_x"].c_str());
|
||||
title_logo_y = atoi(v["logo_y"].c_str());
|
||||
title_buttons_x = atoi(v["buttons_x"].c_str());
|
||||
title_buttons_y = atoi(v["buttons_y"].c_str());
|
||||
title_tip_x = atoi(v["tip_x"].c_str());
|
||||
title_tip_y = atoi(v["tip_y"].c_str());
|
||||
title_tip_width = atoi(v["tip_width"].c_str());
|
||||
|
||||
#ifdef USE_TINY_GUI
|
||||
|
@ -145,10 +130,6 @@ namespace game_config
|
|||
title_buttons_padding = atoi(v["buttons_padding"].c_str());
|
||||
#endif
|
||||
|
||||
map_image = v["map_image"];
|
||||
rightside_image = v["sidebar_image"];
|
||||
rightside_image_bot = v["sidebar_image_bottom"];
|
||||
|
||||
energy_image = v["energy_image"];
|
||||
moved_ball_image = v["moved_ball_image"];
|
||||
unmoved_ball_image = v["unmoved_ball_image"];
|
||||
|
@ -157,21 +138,16 @@ namespace game_config
|
|||
ally_ball_image = v["ally_ball_image"];
|
||||
flag_image = v["flag_image"];
|
||||
cross_image = v["cross_image"];
|
||||
dot_image = v["dot_image"];
|
||||
|
||||
foot_left_nw = utils::split(v["footprint_left_nw"]);
|
||||
foot_left_n = utils::split(v["footprint_left_n"]);
|
||||
foot_right_nw = utils::split(v["footprint_right_nw"]);
|
||||
foot_right_n = utils::split(v["footprint_right_n"]);
|
||||
|
||||
missile_n_image = v["missile_n_image"];
|
||||
missile_ne_image = v["missile_ne_image"];
|
||||
|
||||
terrain_mask_image = v["terrain_mask_image"];
|
||||
|
||||
observer_image = v["observer_image"];
|
||||
|
||||
download_campaign_image = v["download_campaign_image"];
|
||||
level_image = v["level_image"];
|
||||
ellipsis_image = v["ellipsis_image"];
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ namespace game_config
|
|||
extern int rest_heal_amount;
|
||||
extern int recall_cost;
|
||||
extern int kill_experience;
|
||||
extern int leadership_bonus;
|
||||
extern int lobby_refresh;
|
||||
extern const std::string version;
|
||||
|
||||
|
@ -38,20 +37,18 @@ namespace game_config
|
|||
|
||||
extern std::string path;
|
||||
|
||||
extern std::string game_icon, game_title, game_logo, title_music, map_image, rightside_image, rightside_image_bot,
|
||||
anonymous_music, victory_music, defeat_music,
|
||||
extern std::string game_icon, game_title, game_logo, title_music,
|
||||
moved_ball_image, unmoved_ball_image, partmoved_ball_image,
|
||||
enemy_ball_image, ally_ball_image, energy_image,
|
||||
flag_image, dot_image, cross_image,
|
||||
missile_n_image, missile_ne_image,
|
||||
terrain_mask_image, observer_image, download_campaign_image,
|
||||
flag_image, cross_image,
|
||||
terrain_mask_image, observer_image,
|
||||
checked_menu_image, unchecked_menu_image, wml_menu_image, level_image, ellipsis_image;
|
||||
|
||||
extern std::string flag_rgb;
|
||||
|
||||
extern std::vector<std::string> foot_left_nw,foot_left_n,foot_right_nw,foot_right_n;
|
||||
|
||||
extern int title_logo_x, title_logo_y, title_buttons_x, title_buttons_y, title_buttons_padding, title_tip_x, title_tip_y, title_tip_width, title_tip_padding;
|
||||
extern int title_logo_x, title_logo_y, title_buttons_x, title_buttons_y, title_buttons_padding, title_tip_x, title_tip_width, title_tip_padding;
|
||||
|
||||
extern std::map<std::string, color_range> team_rgb_range;
|
||||
extern std::map<std::string, std::string> team_rgb_name;
|
||||
|
|
|
@ -101,6 +101,8 @@ void message_dialog::action(gui::dialog_process_info &dp_info)
|
|||
message_dialog::~message_dialog()
|
||||
{
|
||||
}
|
||||
|
||||
} //end anonymous namespace
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// std::getline might be broken in Visual Studio so show a warning
|
||||
|
@ -119,7 +121,7 @@ message_dialog::~message_dialog()
|
|||
* does not need to be the order in which these messages are encountered.
|
||||
* Messages are always written to std::cerr
|
||||
*/
|
||||
void show_wml_errors()
|
||||
static void show_wml_errors()
|
||||
{
|
||||
// Get all unique messages in messages with the number of encounters for
|
||||
// these messages
|
||||
|
@ -169,11 +171,12 @@ void show_wml_errors()
|
|||
std::cerr << caption << ": " << msg.str() << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
} //end anonymous namespace
|
||||
|
||||
namespace game_events {
|
||||
|
||||
static bool unit_matches_filter(const unit& u, const vconfig filter,const gamemap::location& loc);
|
||||
static bool matches_special_filter(const config* cfg, const vconfig filter);
|
||||
|
||||
game_state* get_state_of_game()
|
||||
{
|
||||
return state_of_game;
|
||||
|
@ -330,7 +333,11 @@ at the moment.
|
|||
*/
|
||||
const size_t MaxLoop = 65536;
|
||||
|
||||
bool events_init() { return screen != NULL; }
|
||||
}
|
||||
|
||||
static bool events_init() { return screen != NULL; }
|
||||
|
||||
namespace {
|
||||
|
||||
struct queued_event {
|
||||
queued_event(const std::string& name, const gamemap::location& loc1,
|
||||
|
@ -416,8 +423,9 @@ private:
|
|||
vconfig cfg_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
gamemap::location cfg_to_loc(const vconfig cfg,int defaultx = 0, int defaulty = 0)
|
||||
static gamemap::location cfg_to_loc(const vconfig cfg,int defaultx = 0, int defaulty = 0)
|
||||
{
|
||||
int x = lexical_cast_default(cfg["x"], defaultx) - 1;
|
||||
int y = lexical_cast_default(cfg["y"], defaulty) - 1;
|
||||
|
@ -425,11 +433,13 @@ gamemap::location cfg_to_loc(const vconfig cfg,int defaultx = 0, int defaulty =
|
|||
return gamemap::location(x, y);
|
||||
}
|
||||
|
||||
std::vector<gamemap::location> multiple_locs(const vconfig cfg)
|
||||
static std::vector<gamemap::location> multiple_locs(const vconfig cfg)
|
||||
{
|
||||
return parse_location_range(cfg["x"],cfg["y"]);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
std::multimap<std::string,event_handler> events_map;
|
||||
|
||||
//this function handles all the different types of actions that can be triggered
|
||||
|
@ -2193,13 +2203,15 @@ bool event_handler::handle_event(const queued_event& event_info, const vconfig c
|
|||
return mutated;
|
||||
}
|
||||
|
||||
bool filter_loc_impl(const gamemap::location& loc, const std::string& xloc,
|
||||
}
|
||||
|
||||
static bool filter_loc_impl(const gamemap::location& loc, const std::string& xloc,
|
||||
const std::string& yloc)
|
||||
{
|
||||
return loc.matches_range(xloc, yloc);
|
||||
}
|
||||
|
||||
bool filter_loc(const gamemap::location& loc, const vconfig cfg)
|
||||
static bool filter_loc(const gamemap::location& loc, const vconfig cfg)
|
||||
{
|
||||
const std::string xloc = cfg["x"];
|
||||
const std::string yloc = cfg["y"];
|
||||
|
@ -2207,7 +2219,7 @@ bool filter_loc(const gamemap::location& loc, const vconfig cfg)
|
|||
return filter_loc_impl(loc,xloc,yloc);
|
||||
}
|
||||
|
||||
bool process_event(event_handler& handler, const queued_event& ev)
|
||||
static bool process_event(event_handler& handler, const queued_event& ev)
|
||||
{
|
||||
if(handler.disabled())
|
||||
return false;
|
||||
|
@ -2280,8 +2292,6 @@ bool process_event(event_handler& handler, const queued_event& ev)
|
|||
return res;
|
||||
}
|
||||
|
||||
} //end anonymous namespace
|
||||
|
||||
namespace game_events {
|
||||
|
||||
bool matches_special_filter(const config* cfg, const vconfig filter)
|
||||
|
@ -2334,8 +2344,8 @@ bool unit_matches_filter(unit_map::const_iterator itor, const vconfig filter)
|
|||
return res;
|
||||
}
|
||||
|
||||
config::child_list unit_wml_configs;
|
||||
std::set<std::string> unit_wml_ids;
|
||||
static config::child_list unit_wml_configs;
|
||||
static std::set<std::string> unit_wml_ids;
|
||||
|
||||
manager::manager(const config& cfg, display& gui_, gamemap& map_,
|
||||
soundsource::manager& sndsources_,
|
||||
|
|
|
@ -61,8 +61,6 @@ game_state* get_state_of_game();
|
|||
void write_events(config& cfg);
|
||||
void add_events(const config::child_list& cfgs,const std::string& id);
|
||||
|
||||
bool matches_special_filter(const config* cfg, const vconfig filter);
|
||||
bool unit_matches_filter(const unit& u, const vconfig filter,const gamemap::location& loc);
|
||||
bool unit_matches_filter(unit_map::const_iterator itor, const vconfig filter);
|
||||
|
||||
//function to fire an event. Events may have up to two arguments, both of
|
||||
|
|
|
@ -85,7 +85,7 @@ void conv_ansi_utf8(std::string &name, bool a2u) {
|
|||
return;
|
||||
}
|
||||
|
||||
void replace_underbar2space(std::string &name) {
|
||||
static void replace_underbar2space(std::string &name) {
|
||||
LOG_NG << "conv(A2U)-from:[" << name << "]" << std::endl;
|
||||
conv_ansi_utf8(name, true);
|
||||
LOG_NG << "conv(A2U)-to:[" << name << "]" << std::endl;
|
||||
|
@ -94,7 +94,7 @@ void replace_underbar2space(std::string &name) {
|
|||
LOG_NG << "replace_underbar2space-to:[" << name << "]" << std::endl;
|
||||
}
|
||||
|
||||
void replace_space2underbar(std::string &name) {
|
||||
static void replace_space2underbar(std::string &name) {
|
||||
LOG_NG << "conv(U2A)-from:[" << name << "]" << std::endl;
|
||||
conv_ansi_utf8(name, false);
|
||||
LOG_NG << "conv(U2A)-to:[" << name << "]" << std::endl;
|
||||
|
@ -103,14 +103,17 @@ void replace_space2underbar(std::string &name) {
|
|||
LOG_NG << "replace_underbar2space-to:[" << name << "]" << std::endl;
|
||||
}
|
||||
#else /* ! _WIN32 */
|
||||
void replace_underbar2space(std::string &name) {
|
||||
static void replace_underbar2space(std::string &name) {
|
||||
std::replace(name.begin(),name.end(),'_',' ');
|
||||
}
|
||||
void replace_space2underbar(std::string &name) {
|
||||
static void replace_space2underbar(std::string &name) {
|
||||
std::replace(name.begin(),name.end(),' ','_');
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
static void extract_summary_from_config(config& cfg_save, config& cfg_summary);
|
||||
static void extract_summary_data_from_save(const game_state& gamestate, config& out);
|
||||
|
||||
player_info* game_state::get_player(const std::string& id) {
|
||||
std::map< std::string, player_info >::iterator found = players.find(id);
|
||||
if (found == players.end()) {
|
||||
|
@ -153,9 +156,7 @@ void time_of_day::write(config& cfg) const
|
|||
cfg["mask"] = image_mask;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void parse_times(const config& cfg, std::vector<time_of_day>& normal_times)
|
||||
static void parse_times(const config& cfg, std::vector<time_of_day>& normal_times)
|
||||
{
|
||||
const config::child_list& times = cfg.get_children("time");
|
||||
config::child_list::const_iterator t;
|
||||
|
@ -171,7 +172,6 @@ void parse_times(const config& cfg, std::vector<time_of_day>& normal_times)
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
/// Reads turns and time information from parameters
|
||||
/// It sets random starting ToD and current_tod to config
|
||||
///
|
||||
|
@ -396,7 +396,7 @@ bool gamestatus::next_turn()
|
|||
return numTurns_ == -1 || turn_ <= size_t(numTurns_);
|
||||
}
|
||||
|
||||
player_info read_player(const game_data& data, const config* cfg)
|
||||
static player_info read_player(const game_data& data, const config* cfg)
|
||||
{
|
||||
player_info res;
|
||||
|
||||
|
@ -552,7 +552,7 @@ game_state::game_state(const game_data& data, const config& cfg)
|
|||
}
|
||||
}
|
||||
|
||||
void write_player(const player_info& player, config& cfg)
|
||||
static void write_player(const player_info& player, config& cfg)
|
||||
{
|
||||
cfg["name"] = player.name;
|
||||
|
||||
|
@ -580,7 +580,7 @@ void write_player(const player_info& player, config& cfg)
|
|||
cfg["can_recruit"] = can_recruit_str;
|
||||
}
|
||||
|
||||
void write_player(config_writer &out, const player_info& player)
|
||||
static void write_player(config_writer &out, const player_info& player)
|
||||
{
|
||||
out.write_key_val("name", player.name);
|
||||
|
||||
|
@ -850,7 +850,7 @@ bool save_index_loaded = false;
|
|||
config save_index_cfg;
|
||||
}
|
||||
|
||||
config& save_index()
|
||||
static config& save_index()
|
||||
{
|
||||
if(save_index_loaded == false) {
|
||||
try {
|
||||
|
@ -881,17 +881,6 @@ config& save_summary(const std::string& save)
|
|||
return *res;
|
||||
}
|
||||
|
||||
void delete_save_summary(const std::string& save)
|
||||
{
|
||||
config& cfg = save_index();
|
||||
const config* const res = cfg.find_child("save","save",save);
|
||||
if(res != NULL) {
|
||||
const config::child_list& children = cfg.get_children("save");
|
||||
const size_t index = std::find(children.begin(),children.end(),res) - children.begin();
|
||||
cfg.remove_child("save",index);
|
||||
}
|
||||
}
|
||||
|
||||
void write_save_index()
|
||||
{
|
||||
log_scope("write_save_index()");
|
||||
|
@ -1333,15 +1322,13 @@ void game_state::clear_variable(const std::string& varname)
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
void clear_wmi(std::map<std::string, wml_menu_item*>& gs_wmi) {
|
||||
static void clear_wmi(std::map<std::string, wml_menu_item*>& gs_wmi) {
|
||||
std::map<std::string, wml_menu_item*>::iterator itor = gs_wmi.begin();
|
||||
for(itor = gs_wmi.begin(); itor != gs_wmi.end(); ++itor) {
|
||||
delete itor->second;
|
||||
}
|
||||
gs_wmi.clear();
|
||||
}
|
||||
} //end anon namespace
|
||||
|
||||
game_state::game_state(const game_state& state)
|
||||
{
|
||||
|
|
|
@ -232,13 +232,8 @@ void save_game(const game_state& gamestate);
|
|||
//function to delete a save
|
||||
void delete_game(const std::string& name);
|
||||
|
||||
config& save_index();
|
||||
config& save_summary(const std::string& save);
|
||||
void delete_save_summary(const std::string& save);
|
||||
|
||||
void write_save_index();
|
||||
|
||||
void extract_summary_data_from_save(const game_state& gamestate, config& out);
|
||||
void extract_summary_from_config(config& cfg_save, config& cfg_summary);
|
||||
|
||||
#endif
|
||||
|
|
67
src/help.cpp
67
src/help.cpp
|
@ -52,7 +52,7 @@ namespace help {
|
|||
|
||||
/// Generate the help contents from the configurations given to the
|
||||
/// manager.
|
||||
void generate_contents();
|
||||
static void generate_contents();
|
||||
|
||||
struct section;
|
||||
|
||||
|
@ -419,74 +419,74 @@ private:
|
|||
// see.
|
||||
|
||||
/// Dispatch generators to their appropriate functions.
|
||||
std::vector<topic> generate_topics(const bool sort_topics,const std::string &generator);
|
||||
std::string generate_topic_text(const std::string &generator);
|
||||
std::string generate_about_text();
|
||||
std::vector<topic> generate_unit_topics(const bool);
|
||||
static std::vector<topic> generate_topics(const bool sort_topics,const std::string &generator);
|
||||
static std::string generate_topic_text(const std::string &generator);
|
||||
static std::string generate_about_text();
|
||||
static std::vector<topic> generate_unit_topics(const bool);
|
||||
enum UNIT_DESCRIPTION_TYPE {FULL_DESCRIPTION, NO_DESCRIPTION, NON_REVEALING_DESCRIPTION};
|
||||
/// Return the type of description that should be shown for a unit of
|
||||
/// the given kind. This method is intended to filter out information
|
||||
/// about units that should not be shown, for example due to not being
|
||||
/// encountered.
|
||||
UNIT_DESCRIPTION_TYPE description_type(const unit_type &type);
|
||||
std::vector<topic> generate_ability_topics(const bool);
|
||||
std::vector<topic> generate_weapon_special_topics(const bool);
|
||||
static UNIT_DESCRIPTION_TYPE description_type(const unit_type &type);
|
||||
static std::vector<topic> generate_ability_topics(const bool);
|
||||
static std::vector<topic> generate_weapon_special_topics(const bool);
|
||||
|
||||
/// Parse a help config, return the top level section. Return an empty
|
||||
/// section if cfg is NULL.
|
||||
section parse_config(const config *cfg);
|
||||
static section parse_config(const config *cfg);
|
||||
/// Recursive function used by parse_config.
|
||||
void parse_config_internal(const config *help_cfg, const config *section_cfg,
|
||||
static void parse_config_internal(const config *help_cfg, const config *section_cfg,
|
||||
section &sec, int level=0);
|
||||
|
||||
/// Return true if the section with id section_id is referenced from
|
||||
/// another section in the config, or the toplevel.
|
||||
bool section_is_referenced(const std::string §ion_id, const config &cfg);
|
||||
static bool section_is_referenced(const std::string §ion_id, const config &cfg);
|
||||
/// Return true if the topic with id topic_id is referenced from
|
||||
/// another section in the config, or the toplevel.
|
||||
bool topic_is_referenced(const std::string &topic_id, const config &cfg);
|
||||
static bool topic_is_referenced(const std::string &topic_id, const config &cfg);
|
||||
|
||||
/// Search for the topic with the specified identifier in the section
|
||||
/// and its subsections. Return the found topic, or NULL if none could
|
||||
/// be found.
|
||||
const topic *find_topic(const section &sec, const std::string &id);
|
||||
static const topic *find_topic(const section &sec, const std::string &id);
|
||||
|
||||
/// Search for the section with the specified identifier in the section
|
||||
/// and its subsections. Return the found section or NULL if none could
|
||||
/// be found.
|
||||
const section *find_section(const section &sec, const std::string &id);
|
||||
static const section *find_section(const section &sec, const std::string &id);
|
||||
|
||||
/// Parse a text string. Return a vector with the different parts of the
|
||||
/// text. Each markup item is a separate part while the text between
|
||||
/// markups are separate parts.
|
||||
std::vector<std::string> parse_text(const std::string &text);
|
||||
static std::vector<std::string> parse_text(const std::string &text);
|
||||
|
||||
/// Convert the contents to wml attributes, surrounded within
|
||||
/// [element_name]...[/element_name]. Return the resulting WML.
|
||||
std::string convert_to_wml(const std::string &element_name, const std::string &contents);
|
||||
static std::string convert_to_wml(const std::string &element_name, const std::string &contents);
|
||||
|
||||
/// Return true if s is a representation of a truth value
|
||||
/// (yes/true/...), otherwise false.
|
||||
bool get_bool(const std::string &s);
|
||||
static bool get_bool(const std::string &s);
|
||||
|
||||
/// Return the color the string represents. Return font::NORMAL_COLOUR if
|
||||
/// the string is empty or can't be matched against any other color.
|
||||
SDL_Color string_to_color(const std::string &s);
|
||||
static SDL_Color string_to_color(const std::string &s);
|
||||
|
||||
/// Make a best effort to word wrap s. All parts are less than width.
|
||||
std::vector<std::string> split_in_width(const std::string &s, const int font_size, const unsigned width);
|
||||
static std::vector<std::string> split_in_width(const std::string &s, const int font_size, const unsigned width);
|
||||
|
||||
std::string remove_first_space(const std::string& text);
|
||||
static std::string remove_first_space(const std::string& text);
|
||||
|
||||
/// Return a lowercase copy of s.
|
||||
std::string to_lower(const std::string &s);
|
||||
static std::string to_lower(const std::string &s);
|
||||
|
||||
/// Prepend all chars with meaning inside attributes with a backslash.
|
||||
std::string escape(const std::string &s);
|
||||
static std::string escape(const std::string &s);
|
||||
|
||||
/// Return the first word in s, not removing any spaces in the start of
|
||||
/// it.
|
||||
std::string get_first_word(const std::string &s);
|
||||
static std::string get_first_word(const std::string &s);
|
||||
|
||||
} // namespace help
|
||||
|
||||
|
@ -517,10 +517,12 @@ namespace {
|
|||
// The topic to open by default when opening the help dialog.
|
||||
const std::string default_show_topic = "introduction_topic";
|
||||
|
||||
}
|
||||
|
||||
/// Return true if the id is valid for user defined topics and
|
||||
/// sections. Some IDs are special, such as toplevel and may not be
|
||||
/// be defined in the config.
|
||||
bool is_valid_id(const std::string &id) {
|
||||
static bool is_valid_id(const std::string &id) {
|
||||
if (id == "toplevel") {
|
||||
return false;
|
||||
}
|
||||
|
@ -539,6 +541,8 @@ namespace {
|
|||
return true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
/// Class to be used as a function object when generating the about
|
||||
/// text. Translate the about dialog formatting to format suitable
|
||||
/// for the help dialog.
|
||||
|
@ -555,22 +559,24 @@ namespace {
|
|||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Helpers for making generation of topics easier.
|
||||
std::string jump_to(const unsigned pos)
|
||||
static std::string jump_to(const unsigned pos)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "<jump>to=" << pos << "</jump>";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string jump(const unsigned amount)
|
||||
static std::string jump(const unsigned amount)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "<jump>amount=" << amount << "</jump>";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string bold(const std::string &s)
|
||||
static std::string bold(const std::string &s)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "<bold>text='" << help::escape(s) << "'</bold>";
|
||||
|
@ -582,7 +588,7 @@ namespace {
|
|||
// that create a table. The table spec contains a vector with
|
||||
// vectors with pairs. The pairs are the markup string that should
|
||||
// be in a cell, and the width of that cell.
|
||||
std::string generate_table(const table_spec &tab, const unsigned int spacing=font::relative_size(20))
|
||||
static std::string generate_table(const table_spec &tab, const unsigned int spacing=font::relative_size(20))
|
||||
{
|
||||
table_spec::const_iterator row_it;
|
||||
std::vector<std::pair<std::string, unsigned> >::const_iterator col_it;
|
||||
|
@ -625,7 +631,7 @@ namespace {
|
|||
}
|
||||
|
||||
// Return the width for the image with filename.
|
||||
unsigned image_width(const std::string &filename)
|
||||
static unsigned image_width(const std::string &filename)
|
||||
{
|
||||
image::locator loc(filename);
|
||||
surface surf(image::get_image(loc, image::UNSCALED));
|
||||
|
@ -635,11 +641,10 @@ namespace {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void push_tab_pair(std::vector<std::pair<std::string, unsigned int> > &v, const std::string &s)
|
||||
static void push_tab_pair(std::vector<std::pair<std::string, unsigned int> > &v, const std::string &s)
|
||||
{
|
||||
v.push_back(std::make_pair(s, font::line_width(s, normal_font_size)));
|
||||
}
|
||||
}
|
||||
|
||||
namespace help {
|
||||
|
||||
|
|
|
@ -134,6 +134,9 @@ hotkey::hotkey_item null_hotkey_;
|
|||
|
||||
namespace hotkey {
|
||||
|
||||
static void key_event_execute(display& disp, const SDL_KeyboardEvent& event, command_executor* executor);
|
||||
|
||||
|
||||
hotkey_item::hotkey_item(HOTKEY_COMMAND id, const std::string& command, const std::string& description, bool hidden)
|
||||
: id_(id), command_(command), description_(description), type_(UNBOUND),
|
||||
ctrl_(false), alt_(false), cmd_(false), shift_(false), hidden_(hidden)
|
||||
|
|
|
@ -238,8 +238,6 @@ public:
|
|||
//is still meaningful to call with executor=NULL
|
||||
void key_event(display& disp, const SDL_KeyboardEvent& event, command_executor* executor);
|
||||
|
||||
void key_event_execute(display& disp, const SDL_KeyboardEvent& event, command_executor* executor);
|
||||
|
||||
void execute_command(display& disp, HOTKEY_COMMAND command, command_executor* executor, int index=-1);
|
||||
|
||||
//object which will ensure that basic keyboard events like escape
|
||||
|
|
|
@ -488,7 +488,7 @@ void set_zoom(int amount)
|
|||
}
|
||||
}
|
||||
|
||||
surface get_unmasked(const locator i_locator)
|
||||
static surface get_unmasked(const locator i_locator)
|
||||
{
|
||||
surface image(get_image(i_locator, UNSCALED));
|
||||
|
||||
|
@ -506,7 +506,7 @@ surface get_unmasked(const locator i_locator)
|
|||
return res;
|
||||
}
|
||||
|
||||
surface get_scaled_to_hex(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
||||
static surface get_scaled_to_hex(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
||||
{
|
||||
surface res(get_image(i_locator, UNMASKED, adj));
|
||||
|
||||
|
@ -528,7 +528,7 @@ surface get_scaled_to_hex(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
|||
return res;
|
||||
}
|
||||
|
||||
surface get_scaled_to_zoom(const locator i_locator)
|
||||
static surface get_scaled_to_zoom(const locator i_locator)
|
||||
{
|
||||
wassert(zoom != tile_size);
|
||||
wassert(tile_size != 0);
|
||||
|
@ -542,13 +542,13 @@ surface get_scaled_to_zoom(const locator i_locator)
|
|||
}
|
||||
}
|
||||
|
||||
surface get_brightened(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
||||
static surface get_brightened(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
||||
{
|
||||
surface image(get_image(i_locator, SCALED_TO_HEX, adj));
|
||||
return surface(brighten_image(image, ftofxp(1.5)));
|
||||
}
|
||||
|
||||
surface get_semi_brightened(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
||||
static surface get_semi_brightened(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
||||
{
|
||||
surface image(get_image(i_locator, SCALED_TO_HEX, adj));
|
||||
return surface(brighten_image(image, ftofxp(1.25)));
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#define LOG_NG LOG_STREAM(info, engine)
|
||||
|
||||
bool show_intro_part(display &disp, const config& part,
|
||||
static bool show_intro_part(display &disp, const config& part,
|
||||
const std::string& scenario);
|
||||
|
||||
void show_intro(display &disp, const config& data, const config& level)
|
||||
|
|
|
@ -38,28 +38,18 @@ namespace {
|
|||
string_map strings_;
|
||||
}
|
||||
|
||||
std::vector<language_def> known_languages;
|
||||
static std::vector<language_def> known_languages;
|
||||
|
||||
std::string languagedef_name (const language_def& def)
|
||||
{
|
||||
return def.language;
|
||||
}
|
||||
|
||||
bool languagedef_rtl (const language_def& def)
|
||||
{
|
||||
return def.rtl;
|
||||
}
|
||||
|
||||
bool current_language_rtl()
|
||||
{
|
||||
return get_language().rtl;
|
||||
}
|
||||
|
||||
bool languagedef_lessthan_p (const language_def& def1, const language_def& def2)
|
||||
{
|
||||
return (def1.language < def2.language);
|
||||
}
|
||||
|
||||
bool language_def::operator== (const language_def& a) const
|
||||
{
|
||||
return ((language == a.language) /* && (localename == a.localename) */ );
|
||||
|
|
|
@ -38,8 +38,6 @@ struct language_def
|
|||
};
|
||||
|
||||
std::string languagedef_name (const language_def& def);
|
||||
bool languagedef_rtl (const language_def& def);
|
||||
bool languagedef_lessthan_p (const language_def& def1, const language_def& def2);
|
||||
|
||||
struct symbol_table
|
||||
{
|
||||
|
|
|
@ -25,18 +25,17 @@
|
|||
|
||||
namespace {
|
||||
const size_t max_label_size = 64;
|
||||
}
|
||||
|
||||
//our definition of map labels being obscured is if the tile is obscured,
|
||||
//or the tile below is obscured. This is because in the case where the tile
|
||||
//itself is visible, but the tile below is obscured, the bottom half of the
|
||||
//tile will still be shrouded, and the label being drawn looks weird
|
||||
bool is_shrouded(const display& disp, const gamemap::location& loc)
|
||||
static bool is_shrouded(const display& disp, const gamemap::location& loc)
|
||||
{
|
||||
return disp.shrouded(loc.x,loc.y) || disp.shrouded(loc.x,loc.y+1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
map_labels::map_labels(const display& disp,
|
||||
const gamemap& map,
|
||||
const team* team) :
|
||||
|
|
|
@ -44,8 +44,6 @@ config map_generator::create_scenario(const std::vector<std::string>& args)
|
|||
return res;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
typedef std::vector<std::vector<int> > height_map;
|
||||
typedef t_translation::t_map terrain_map;
|
||||
|
||||
|
@ -60,7 +58,7 @@ typedef gamemap::location location;
|
|||
//so, how large the island should be. Hills with centers that are more than 'island_size'
|
||||
//away from the center of the map will be inverted (i.e. be valleys).
|
||||
//'island_size' as 0 indicates no island
|
||||
height_map generate_height_map(size_t width, size_t height,
|
||||
static height_map generate_height_map(size_t width, size_t height,
|
||||
size_t iterations, size_t hill_size,
|
||||
size_t island_size, size_t island_off_center)
|
||||
{
|
||||
|
@ -180,7 +178,7 @@ height_map generate_height_map(size_t width, size_t height,
|
|||
//'lake_fall_off' % chance to make another water tile in each of the directions n,s,e,w.
|
||||
//In each of the directions it does make another water tile, it will have 'lake_fall_off'/2 %
|
||||
//chance to make another water tile in each of the directions. This will continue recursively.
|
||||
bool generate_lake(terrain_map& terrain, int x, int y, int lake_fall_off, std::set<location>& locs_touched)
|
||||
static bool generate_lake(terrain_map& terrain, int x, int y, int lake_fall_off, std::set<location>& locs_touched)
|
||||
{
|
||||
if(x < 0 || y < 0 || size_t(x) >= terrain.size() || size_t(y) >= terrain.front().size()) {
|
||||
return false;
|
||||
|
@ -220,7 +218,7 @@ typedef gamemap::location location;
|
|||
//path that can be found that makes the river flow into another body of water or off the map
|
||||
//will be used. If no path can be found, then the river's generation will be aborted, and
|
||||
//false will be returned. true is returned if the river is generated successfully.
|
||||
bool generate_river_internal(const height_map& heights, terrain_map& terrain, int x, int y, std::vector<location>& river, std::set<location>& seen_locations, int river_uphill)
|
||||
static bool generate_river_internal(const height_map& heights, terrain_map& terrain, int x, int y, std::vector<location>& river, std::set<location>& seen_locations, int river_uphill)
|
||||
{
|
||||
const bool on_map = x >= 0 && y >= 0 && x < (long)heights.size() && y < (long)heights.back().size();
|
||||
|
||||
|
@ -270,7 +268,7 @@ bool generate_river_internal(const height_map& heights, terrain_map& terrain, in
|
|||
return false;
|
||||
}
|
||||
|
||||
std::vector<location> generate_river(const height_map& heights, terrain_map& terrain, int x, int y, int river_uphill)
|
||||
static std::vector<location> generate_river(const height_map& heights, terrain_map& terrain, int x, int y, int river_uphill)
|
||||
{
|
||||
std::vector<location> river;
|
||||
std::set<location> seen_locations;
|
||||
|
@ -284,7 +282,7 @@ std::vector<location> generate_river(const height_map& heights, terrain_map& ter
|
|||
|
||||
//function to return a random tile at one of the borders of a map that is
|
||||
//of the given dimensions.
|
||||
location random_point_at_side(size_t width, size_t height)
|
||||
static location random_point_at_side(size_t width, size_t height)
|
||||
{
|
||||
const int side = rand()%4;
|
||||
if(side < 2) {
|
||||
|
@ -299,7 +297,7 @@ location random_point_at_side(size_t width, size_t height)
|
|||
}
|
||||
|
||||
//function which, given the map will output it in a valid format.
|
||||
std::string output_map(const terrain_map& terrain,
|
||||
static std::string output_map(const terrain_map& terrain,
|
||||
std::map<int, t_translation::coordinate> starting_positions)
|
||||
{
|
||||
//remember that we only want the middle 1/9th of the map. All other
|
||||
|
@ -332,6 +330,8 @@ std::string output_map(const terrain_map& terrain,
|
|||
return t_translation::write_game_map(map, starting_positions);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
//an object that will calculate the cost of building a road over terrain
|
||||
//for use in the a_star_search algorithm.
|
||||
struct road_path_calculator : cost_calculator
|
||||
|
@ -413,7 +413,9 @@ bool is_valid_terrain::operator()(int x, int y) const
|
|||
return std::find(terrain_.begin(),terrain_.end(),map_[x][y]) != terrain_.end();
|
||||
}
|
||||
|
||||
int rank_castle_location(int x, int y, const is_valid_terrain& valid_terrain, int min_x, int max_x, int min_y, int max_y,
|
||||
}
|
||||
|
||||
static int rank_castle_location(int x, int y, const is_valid_terrain& valid_terrain, int min_x, int max_x, int min_y, int max_y,
|
||||
size_t min_distance, const std::vector<gamemap::location>& other_castles, int highest_ranking)
|
||||
{
|
||||
const gamemap::location loc(x,y);
|
||||
|
@ -478,7 +480,7 @@ int rank_castle_location(int x, int y, const is_valid_terrain& valid_terrain, in
|
|||
return surrounding_ranking + current_ranking;
|
||||
}
|
||||
|
||||
gamemap::location place_village(const t_translation::t_map& map,
|
||||
static gamemap::location place_village(const t_translation::t_map& map,
|
||||
const size_t x, const size_t y, const size_t radius, const config& cfg)
|
||||
{
|
||||
const gamemap::location loc(x,y);
|
||||
|
@ -520,7 +522,7 @@ gamemap::location place_village(const t_translation::t_map& map,
|
|||
return best_loc;
|
||||
}
|
||||
|
||||
std::string generate_name(const unit_race& name_generator, const std::string& id,
|
||||
static std::string generate_name(const unit_race& name_generator, const std::string& id,
|
||||
std::string* base_name=NULL,
|
||||
utils::string_map* additional_symbols=NULL)
|
||||
{
|
||||
|
@ -550,6 +552,8 @@ std::string generate_name(const unit_race& name_generator, const std::string& id
|
|||
return "";
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
//the configuration file should contain a number of [height] tags:
|
||||
//[height]
|
||||
//height=n
|
||||
|
|
|
@ -24,11 +24,8 @@ const char LARGE_TEXT='*', SMALL_TEXT='`', GOOD_TEXT='@', BAD_TEXT='#',
|
|||
NORMAL_TEXT='{', BLACK_TEXT='}', BOLD_TEXT='~', IMAGE='&',
|
||||
COLOR_TEXT='<', NULL_MARKUP='^', GRAY_TEXT='|';
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
//function which will parse the markup tags at the front of a string
|
||||
std::string::const_iterator parse_markup(std::string::const_iterator i1, std::string::const_iterator i2,
|
||||
static std::string::const_iterator parse_markup(std::string::const_iterator i1, std::string::const_iterator i2,
|
||||
int* font_size, SDL_Color* colour, int* style)
|
||||
{
|
||||
if(font_size == NULL || colour == NULL) {
|
||||
|
@ -139,8 +136,6 @@ std::string::const_iterator parse_markup(std::string::const_iterator i1, std::st
|
|||
return i1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Copy string but without tags at the begining
|
||||
std::string del_tags(std::string name){
|
||||
|
@ -253,9 +248,7 @@ bool is_format_char(char c)
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void cut_word(std::string& line, std::string& word, int size, int max_width)
|
||||
static void cut_word(std::string& line, std::string& word, int size, int max_width)
|
||||
{
|
||||
std::string tmp = line;
|
||||
utils::utf8_iterator tc(word);
|
||||
|
@ -279,6 +272,7 @@ void cut_word(std::string& line, std::string& word, int size, int max_width)
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
/*
|
||||
* According to Kinsoku-Shori, Japanese rules about line-breaking:
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace events{
|
|||
}
|
||||
}
|
||||
|
||||
bool is_illegal_file_char(char c)
|
||||
static bool is_illegal_file_char(char c)
|
||||
{
|
||||
return c == '/' || c == '\\' || c == ':';
|
||||
}
|
||||
|
@ -353,10 +353,6 @@ namespace events{
|
|||
}
|
||||
}
|
||||
|
||||
bool is_player_char(char c){
|
||||
return (isalpha(c) != 0);
|
||||
}
|
||||
|
||||
void menu_handler::status_table()
|
||||
{
|
||||
std::stringstream heading;
|
||||
|
|
|
@ -41,7 +41,7 @@ command_disabler::~command_disabler()
|
|||
--commands_disabled;
|
||||
}
|
||||
|
||||
bool command_active()
|
||||
static bool command_active()
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
return (SDL_GetModState()&KMOD_META) != 0;
|
||||
|
|
|
@ -56,8 +56,9 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void run_lobby_loop(display& disp, mp::ui& ui)
|
||||
static void run_lobby_loop(display& disp, mp::ui& ui)
|
||||
{
|
||||
disp.video().modeChanged();
|
||||
bool first = true;
|
||||
|
@ -81,13 +82,17 @@ void run_lobby_loop(display& disp, mp::ui& ui)
|
|||
font::cache_mode(font::CACHE_GAME);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
enum server_type {
|
||||
ABORT_SERVER,
|
||||
WESNOTHD_SERVER,
|
||||
SIMPLE_SERVER
|
||||
};
|
||||
|
||||
server_type open_connection(display& disp, const std::string& original_host)
|
||||
}
|
||||
|
||||
static server_type open_connection(display& disp, const std::string& original_host)
|
||||
{
|
||||
std::string h = original_host;
|
||||
|
||||
|
@ -240,7 +245,7 @@ server_type open_connection(display& disp, const std::string& original_host)
|
|||
// creating the dialogs, then, according to the dialog result, of calling other
|
||||
// of those screen functions.
|
||||
|
||||
void enter_wait_mode(display& disp, const config& game_config, game_data& data, mp::chat& chat, config& gamelist, bool observe)
|
||||
static void enter_wait_mode(display& disp, const config& game_config, game_data& data, mp::chat& chat, config& gamelist, bool observe)
|
||||
{
|
||||
mp::ui::result res;
|
||||
game_state state;
|
||||
|
@ -284,7 +289,7 @@ void enter_wait_mode(display& disp, const config& game_config, game_data& data,
|
|||
}
|
||||
}
|
||||
|
||||
void enter_connect_mode(display& disp, const config& game_config, game_data& data,
|
||||
static void enter_connect_mode(display& disp, const config& game_config, game_data& data,
|
||||
mp::chat& chat, config& gamelist, const mp::create::parameters& params,
|
||||
mp::controller default_controller, bool is_server)
|
||||
{
|
||||
|
@ -328,7 +333,7 @@ void enter_connect_mode(display& disp, const config& game_config, game_data& dat
|
|||
}
|
||||
}
|
||||
|
||||
void enter_create_mode(display& disp, const config& game_config, game_data& data, mp::chat& chat, config& gamelist, mp::controller default_controller, bool is_server)
|
||||
static void enter_create_mode(display& disp, const config& game_config, game_data& data, mp::chat& chat, config& gamelist, mp::controller default_controller, bool is_server)
|
||||
{
|
||||
mp::ui::result res;
|
||||
mp::create::parameters params;
|
||||
|
@ -354,7 +359,7 @@ void enter_create_mode(display& disp, const config& game_config, game_data& data
|
|||
}
|
||||
}
|
||||
|
||||
void enter_lobby_mode(display& disp, const config& game_config, game_data& data, mp::chat& chat, config& gamelist)
|
||||
static void enter_lobby_mode(display& disp, const config& game_config, game_data& data, mp::chat& chat, config& gamelist)
|
||||
{
|
||||
mp::ui::result res;
|
||||
|
||||
|
@ -424,8 +429,6 @@ void enter_lobby_mode(display& disp, const config& game_config, game_data& data,
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace mp {
|
||||
|
||||
void start_server(display& disp, const config& game_config, game_data& data,
|
||||
|
|
|
@ -27,15 +27,6 @@
|
|||
|
||||
namespace {
|
||||
std::vector<std::string> empty_string_vector;
|
||||
|
||||
std::string games_menu_heading()
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << HEADING_PREFIX << _("Map") << COLUMN_SEPARATOR << _("Name")
|
||||
<< COLUMN_SEPARATOR << _("Status") << COLUMN_SEPARATOR << _("Settings");
|
||||
return str.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace mp {
|
||||
|
|
|
@ -81,13 +81,15 @@ connection_map connections;
|
|||
|
||||
network::connection connection_id = 1;
|
||||
|
||||
int create_connection(TCPsocket sock, const std::string& host, int port)
|
||||
}
|
||||
|
||||
static int create_connection(TCPsocket sock, const std::string& host, int port)
|
||||
{
|
||||
connections.insert(std::pair<network::connection,connection_details>(connection_id,connection_details(sock,host,port)));
|
||||
return connection_id++;
|
||||
}
|
||||
|
||||
connection_details& get_connection_details(network::connection handle)
|
||||
static connection_details& get_connection_details(network::connection handle)
|
||||
{
|
||||
const connection_map::iterator i = connections.find(handle);
|
||||
if(i == connections.end()) {
|
||||
|
@ -97,28 +99,28 @@ connection_details& get_connection_details(network::connection handle)
|
|||
return i->second;
|
||||
}
|
||||
|
||||
TCPsocket get_socket(network::connection handle)
|
||||
static TCPsocket get_socket(network::connection handle)
|
||||
{
|
||||
return get_connection_details(handle).sock;
|
||||
}
|
||||
|
||||
void remove_connection(network::connection handle)
|
||||
static void remove_connection(network::connection handle)
|
||||
{
|
||||
connections.erase(handle);
|
||||
}
|
||||
|
||||
bool is_pending_remote_handle(network::connection handle)
|
||||
static bool is_pending_remote_handle(network::connection handle)
|
||||
{
|
||||
const connection_details& details = get_connection_details(handle);
|
||||
return details.host != "" && details.remote_handle == 0;
|
||||
}
|
||||
|
||||
void set_remote_handle(network::connection handle, int remote_handle)
|
||||
static void set_remote_handle(network::connection handle, int remote_handle)
|
||||
{
|
||||
get_connection_details(handle).remote_handle = remote_handle;
|
||||
}
|
||||
|
||||
void check_error()
|
||||
static void check_error()
|
||||
{
|
||||
const TCPsocket sock = network_worker_pool::detect_error();
|
||||
if(sock) {
|
||||
|
@ -130,6 +132,8 @@ void check_error()
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
SDLNet_SocketSet socket_set = 0;
|
||||
std::set<network::connection> waiting_sockets;
|
||||
typedef std::vector<network::connection> sockets_list;
|
||||
|
|
|
@ -125,7 +125,7 @@ threading::condition* cond = NULL;
|
|||
std::map<Uint32,threading::thread*> threads;
|
||||
std::vector<Uint32> to_clear;
|
||||
|
||||
SOCKET_STATE send_buf(TCPsocket sock, config& config_in) {
|
||||
static SOCKET_STATE send_buf(TCPsocket sock, config& config_in) {
|
||||
#ifdef __BEOS__
|
||||
int timeout = 15000;
|
||||
#endif
|
||||
|
@ -213,7 +213,7 @@ SOCKET_STATE send_buf(TCPsocket sock, config& config_in) {
|
|||
}
|
||||
}
|
||||
|
||||
SOCKET_STATE receive_buf(TCPsocket sock, std::vector<char>& buf)
|
||||
static SOCKET_STATE receive_buf(TCPsocket sock, std::vector<char>& buf)
|
||||
{
|
||||
char num_buf[4];
|
||||
int len = SDLNet_TCP_Recv(sock,num_buf,4);
|
||||
|
@ -295,7 +295,7 @@ SOCKET_STATE receive_buf(TCPsocket sock, std::vector<char>& buf)
|
|||
return SOCKET_READY;
|
||||
}
|
||||
|
||||
int process_queue(void*)
|
||||
static int process_queue(void*)
|
||||
{
|
||||
LOG_NW << "thread started...\n";
|
||||
for(;;) {
|
||||
|
@ -525,7 +525,7 @@ void queue_data(TCPsocket sock,const config& buf)
|
|||
namespace
|
||||
{
|
||||
|
||||
void remove_buffers(TCPsocket sock)
|
||||
static void remove_buffers(TCPsocket sock)
|
||||
{
|
||||
buffer_set new_bufs;
|
||||
new_bufs.reserve(bufs.size());
|
||||
|
|
|
@ -216,8 +216,7 @@ label_AStarSearch_end:
|
|||
return locRoute;
|
||||
}
|
||||
|
||||
namespace {
|
||||
gamemap::location find_vacant(const gamemap& map,
|
||||
static gamemap::location find_vacant(const gamemap& map,
|
||||
const unit_map& units,
|
||||
const gamemap::location& loc, int depth,
|
||||
VACANT_TILE_TYPE vacancy,
|
||||
|
@ -251,8 +250,6 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gamemap::location find_vacant_tile(const gamemap& map,
|
||||
const unit_map& units,
|
||||
const gamemap::location& loc,
|
||||
|
@ -268,9 +265,7 @@ gamemap::location find_vacant_tile(const gamemap& map,
|
|||
return gamemap::location();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void get_tiles_radius_internal(const gamemap::location& a, size_t radius, std::set<gamemap::location>& res, std::map<gamemap::location,int>& visited)
|
||||
static void get_tiles_radius_internal(const gamemap::location& a, size_t radius, std::set<gamemap::location>& res, std::map<gamemap::location,int>& visited)
|
||||
{
|
||||
visited[a] = radius;
|
||||
res.insert(a);
|
||||
|
@ -288,8 +283,6 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void get_tiles_radius(const gamemap::location& a, size_t radius, std::set<gamemap::location>& res)
|
||||
{
|
||||
std::map<gamemap::location,int> visited;
|
||||
|
@ -346,9 +339,7 @@ bool enemy_zoc(gamemap const &map,
|
|||
return false;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void find_routes(const gamemap& map, const gamestatus& status,
|
||||
static void find_routes(const gamemap& map, const gamestatus& status,
|
||||
const game_data& gamedata,
|
||||
const unit_map& units,
|
||||
const unit& u,
|
||||
|
@ -446,8 +437,6 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
} //end anon namespace
|
||||
|
||||
paths::paths(gamemap const &map, gamestatus const &status,
|
||||
game_data const &gamedata,
|
||||
unit_map const &units,
|
||||
|
|
|
@ -53,19 +53,6 @@ void get_adjacent_tiles(const gamemap::location& a, gamemap::location* res)
|
|||
res->y = a.y - (is_even(a.x) ? 1:0);
|
||||
}
|
||||
|
||||
gamemap::location::DIRECTION get_adjacent_direction(const gamemap::location& from, const gamemap::location& to)
|
||||
{
|
||||
gamemap::location adj[6];
|
||||
get_adjacent_tiles(from,adj);
|
||||
for(size_t n = 0; n != 6; ++n) {
|
||||
if(adj[n] == to) {
|
||||
return static_cast<gamemap::location::DIRECTION>(n);
|
||||
}
|
||||
}
|
||||
|
||||
return gamemap::location::NDIRECTIONS;
|
||||
}
|
||||
|
||||
bool tiles_adjacent(const gamemap::location& a, const gamemap::location& b)
|
||||
{
|
||||
//two tiles are adjacent if y is different by 1, and x by 0, or if
|
||||
|
|
|
@ -23,10 +23,6 @@ bool tiles_adjacent(const gamemap::location& a, const gamemap::location& b);
|
|||
//res. res must point to an array of 6 location objects.
|
||||
void get_adjacent_tiles(const gamemap::location& a, gamemap::location* res);
|
||||
|
||||
//function which returns the direction from 'from' to 'to'. If 'from' and 'to' are not adjacent, then
|
||||
//the function will return 'NDIRECTIONS'.
|
||||
gamemap::location::DIRECTION get_adjacent_direction(const gamemap::location& from, const gamemap::location& to);
|
||||
|
||||
//function which gives the number of hexes between two tiles (i.e. the minimum
|
||||
//number of hexes that have to be traversed to get from one hex to the other)
|
||||
size_t distance_between(const gamemap::location& a, const gamemap::location& b);
|
||||
|
|
|
@ -130,7 +130,7 @@ void play_controller::init_managers(){
|
|||
LOG_NG << "done initializing managers... " << (SDL_GetTicks() - ticks_) << "\n";
|
||||
}
|
||||
|
||||
int placing_score(const config& side, const gamemap& map, const gamemap::location& pos)
|
||||
static int placing_score(const config& side, const gamemap& map, const gamemap::location& pos)
|
||||
{
|
||||
int positions = 0, liked = 0;
|
||||
#ifdef TERRAIN_TRANSLATION_COMPATIBLE
|
||||
|
@ -165,8 +165,7 @@ struct placing_info {
|
|||
gamemap::location pos;
|
||||
};
|
||||
|
||||
bool operator<(const placing_info& a, const placing_info& b) { return a.score > b.score; }
|
||||
bool operator==(const placing_info& a, const placing_info& b) { return a.score == b.score; }
|
||||
static bool operator<(const placing_info& a, const placing_info& b) { return a.score > b.score; }
|
||||
|
||||
void play_controller::place_sides_in_preferred_locations(gamemap& map, const config::child_list& sides)
|
||||
{
|
||||
|
@ -724,8 +723,7 @@ void play_controller::play_slice()
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
void trim_items(std::vector<std::string>& newitems) {
|
||||
static void trim_items(std::vector<std::string>& newitems) {
|
||||
if (newitems.size() > 5) {
|
||||
std::vector<std::string> subitems;
|
||||
subitems.push_back(newitems[0]);
|
||||
|
@ -736,7 +734,6 @@ void trim_items(std::vector<std::string>& newitems) {
|
|||
newitems = subitems;
|
||||
}
|
||||
}
|
||||
} //end anon namespace
|
||||
|
||||
void play_controller::expand_autosaves(std::vector<std::string>& items)
|
||||
{
|
||||
|
|
|
@ -95,7 +95,7 @@ void play_replay(display& disp, game_state& gamestate, const config& game_config
|
|||
}
|
||||
}
|
||||
|
||||
void clean_autosaves(const std::string &label)
|
||||
static void clean_autosaves(const std::string &label)
|
||||
{
|
||||
std::vector<save_info> games = get_saves_list();
|
||||
std::string prefix = label + "-" + _("Auto-Save");
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
|
||||
namespace preferences {
|
||||
|
||||
static void set_gamma(int gamma);
|
||||
static void set_turbo_speed(double speed);
|
||||
|
||||
|
||||
display* disp = NULL;
|
||||
|
||||
display_manager::display_manager(display* d)
|
||||
|
@ -125,7 +129,7 @@ void set_turbo(bool ison)
|
|||
}
|
||||
}
|
||||
|
||||
void set_turbo_speed(const double speed)
|
||||
static void set_turbo_speed(double speed)
|
||||
{
|
||||
save_turbo_speed(speed);
|
||||
|
||||
|
@ -134,7 +138,7 @@ void set_turbo_speed(const double speed)
|
|||
}
|
||||
}
|
||||
|
||||
void set_adjust_gamma(bool val)
|
||||
static void set_adjust_gamma(bool val)
|
||||
{
|
||||
//if we are turning gamma adjustment off, then set it to '1.0'
|
||||
if(val == false && adjust_gamma()) {
|
||||
|
@ -145,7 +149,7 @@ void set_adjust_gamma(bool val)
|
|||
_set_adjust_gamma(val);
|
||||
}
|
||||
|
||||
void set_gamma(int gamma)
|
||||
static void set_gamma(int gamma)
|
||||
{
|
||||
_set_gamma(gamma);
|
||||
|
||||
|
@ -164,17 +168,17 @@ void set_grid(bool ison)
|
|||
}
|
||||
}
|
||||
|
||||
void set_lobby_joins(int ison)
|
||||
static void set_lobby_joins(int ison)
|
||||
{
|
||||
_set_lobby_joins(ison);
|
||||
}
|
||||
|
||||
void set_sort_list(bool ison)
|
||||
static void set_sort_list(bool ison)
|
||||
{
|
||||
_set_sort_list(ison);
|
||||
}
|
||||
|
||||
void set_iconize_list(bool ison)
|
||||
static void set_iconize_list(bool ison)
|
||||
{
|
||||
_set_iconize_list(ison);
|
||||
}
|
||||
|
|
|
@ -26,9 +26,6 @@ namespace preferences {
|
|||
void set_fullscreen(bool ison);
|
||||
void set_resolution(const std::pair<int,int>& res);
|
||||
void set_turbo(bool ison);
|
||||
void set_turbo_speed(const double speed);
|
||||
void set_adjust_gamma(bool val);
|
||||
void set_gamma(int gamma);
|
||||
void set_grid(bool ison);
|
||||
void set_colour_cursors(bool value);
|
||||
|
||||
|
|
|
@ -21,9 +21,7 @@
|
|||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
namespace {
|
||||
|
||||
const std::string& campaign_dir()
|
||||
static const std::string& campaign_dir()
|
||||
{
|
||||
#ifdef __amigaos4__
|
||||
static const std::string res = "data/campaigns";
|
||||
|
@ -33,14 +31,12 @@ const std::string& campaign_dir()
|
|||
return res;
|
||||
}
|
||||
|
||||
void setup_dirs()
|
||||
static void setup_dirs()
|
||||
{
|
||||
make_directory(get_user_data_dir() + "/data");
|
||||
make_directory(campaign_dir());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void get_campaign_info(const std::string& campaign_name, config& cfg)
|
||||
{
|
||||
scoped_istream stream = istream_file(campaign_dir() + "/" + campaign_name + ".pbl");
|
||||
|
@ -119,9 +115,12 @@ std::vector<config *> find_scripts(const config &cfg, std::string extension)
|
|||
namespace {
|
||||
|
||||
const char escape_char = 1;
|
||||
bool needs_escaping(char c) { return c == 0 || c == escape_char; }
|
||||
|
||||
std::string encode_binary(const std::string& str)
|
||||
}
|
||||
|
||||
static bool needs_escaping(char c) { return c == 0 || c == escape_char; }
|
||||
|
||||
static std::string encode_binary(const std::string& str)
|
||||
{
|
||||
std::string res;
|
||||
res.resize(str.size());
|
||||
|
@ -139,7 +138,7 @@ std::string encode_binary(const std::string& str)
|
|||
return res;
|
||||
}
|
||||
|
||||
std::string unencode_binary(const std::string& str)
|
||||
static std::string unencode_binary(const std::string& str)
|
||||
{
|
||||
std::string res;
|
||||
res.resize(str.size());
|
||||
|
@ -158,13 +157,13 @@ std::string unencode_binary(const std::string& str)
|
|||
return res;
|
||||
}
|
||||
|
||||
void archive_file(const std::string& path, const std::string& fname, config& cfg)
|
||||
static void archive_file(const std::string& path, const std::string& fname, config& cfg)
|
||||
{
|
||||
cfg["name"] = fname;
|
||||
cfg["contents"] = encode_binary(read_file(path + '/' + fname));
|
||||
}
|
||||
|
||||
void archive_dir(const std::string& path, const std::string& dirname, config& cfg)
|
||||
static void archive_dir(const std::string& path, const std::string& dirname, config& cfg)
|
||||
{
|
||||
cfg["name"] = dirname;
|
||||
const std::string dir = path + '/' + dirname;
|
||||
|
@ -180,22 +179,18 @@ void archive_dir(const std::string& path, const std::string& dirname, config& cf
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void archive_campaign(const std::string& campaign_name, config& cfg)
|
||||
{
|
||||
archive_file(campaign_dir(),campaign_name + ".cfg",cfg.add_child("file"));
|
||||
archive_dir(campaign_dir(),campaign_name,cfg.add_child("dir"));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void unarchive_file(const std::string& path, const config& cfg)
|
||||
static void unarchive_file(const std::string& path, const config& cfg)
|
||||
{
|
||||
write_file(path + '/' + cfg["name"].str(), unencode_binary(cfg["contents"]));
|
||||
}
|
||||
|
||||
void unarchive_dir(const std::string& path, const config& cfg)
|
||||
static void unarchive_dir(const std::string& path, const config& cfg)
|
||||
{
|
||||
std::string dir;
|
||||
if (cfg["name"].empty())
|
||||
|
@ -216,17 +211,13 @@ void unarchive_dir(const std::string& path, const config& cfg)
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void unarchive_campaign(const config& cfg)
|
||||
{
|
||||
setup_dirs();
|
||||
unarchive_dir(campaign_dir(),cfg);
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool two_dots(char a, char b) { return a == '.' && b == '.'; }
|
||||
}
|
||||
static bool two_dots(char a, char b) { return a == '.' && b == '.'; }
|
||||
|
||||
bool campaign_name_legal(const std::string& name)
|
||||
{
|
||||
|
|
10
src/race.cpp
10
src/race.cpp
|
@ -23,7 +23,9 @@ namespace {
|
|||
|
||||
config::child_list empty_traits;
|
||||
|
||||
void add_prefixes(const wide_string& str, size_t length, markov_prefix_map& res)
|
||||
}
|
||||
|
||||
static void add_prefixes(const wide_string& str, size_t length, markov_prefix_map& res)
|
||||
{
|
||||
for(size_t i = 0; i <= str.size(); ++i) {
|
||||
const size_t start = i > length ? i - length : 0;
|
||||
|
@ -33,7 +35,7 @@ void add_prefixes(const wide_string& str, size_t length, markov_prefix_map& res)
|
|||
}
|
||||
}
|
||||
|
||||
markov_prefix_map markov_prefixes(const std::vector<std::string>& items, size_t length)
|
||||
static markov_prefix_map markov_prefixes(const std::vector<std::string>& items, size_t length)
|
||||
{
|
||||
markov_prefix_map res;
|
||||
|
||||
|
@ -44,7 +46,7 @@ markov_prefix_map markov_prefixes(const std::vector<std::string>& items, size_t
|
|||
return res;
|
||||
}
|
||||
|
||||
wide_string markov_generate_name(const markov_prefix_map& prefixes, size_t chain_size, size_t max_len)
|
||||
static wide_string markov_generate_name(const markov_prefix_map& prefixes, size_t chain_size, size_t max_len)
|
||||
{
|
||||
if(chain_size == 0)
|
||||
return wide_string();
|
||||
|
@ -106,8 +108,6 @@ wide_string markov_generate_name(const markov_prefix_map& prefixes, size_t chain
|
|||
return originalRes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
unit_race::unit_race() : ntraits_(0), chain_size_(0), not_living_(false), traits_(&empty_traits), global_traits_(true)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -46,9 +46,8 @@
|
|||
std::string replay::last_replay_error;
|
||||
|
||||
//functions to verify that the unit structure on both machines is identical
|
||||
namespace {
|
||||
|
||||
void verify(const unit_map& units, const config& cfg)
|
||||
static void verify(const unit_map& units, const config& cfg)
|
||||
{
|
||||
std::stringstream errbuf;
|
||||
LOG_NW << "verifying unit structure...\n";
|
||||
|
@ -116,45 +115,17 @@ namespace {
|
|||
LOG_NW << "verification passed\n";
|
||||
}
|
||||
|
||||
config create_verification(const unit_map& units)
|
||||
{
|
||||
config res;
|
||||
std::stringstream buf;
|
||||
buf << units.size();
|
||||
res["num_units"] = buf.str();
|
||||
|
||||
for(unit_map::const_iterator i = units.begin(); i != units.end(); ++i) {
|
||||
config u;
|
||||
i->first.write(u);
|
||||
|
||||
static const std::string fields[] = {"type","hitpoints","experience","side",""};
|
||||
config tmp;
|
||||
i->second.write(tmp);
|
||||
for(const std::string* f = fields; f->empty() == false; ++f) {
|
||||
u[*f] = tmp[*f];
|
||||
}
|
||||
|
||||
res.add_child("unit",u);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
namespace {
|
||||
const unit_map* unit_map_ref = NULL;
|
||||
}
|
||||
|
||||
void verify_units(const config& cfg)
|
||||
static void verify_units(const config& cfg)
|
||||
{
|
||||
if(unit_map_ref != NULL) {
|
||||
verify(*unit_map_ref,cfg);
|
||||
}
|
||||
}
|
||||
|
||||
config make_verify_units()
|
||||
{
|
||||
return create_verification(*unit_map_ref);
|
||||
}
|
||||
}
|
||||
|
||||
verification_manager::verification_manager(const unit_map& units)
|
||||
{
|
||||
unit_map_ref = &units;
|
||||
|
@ -622,8 +593,7 @@ replay& get_replay_source()
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
void check_checksums(display& disp,const unit_map& units,const config& cfg)
|
||||
static void check_checksums(display& disp,const unit_map& units,const config& cfg)
|
||||
{
|
||||
if(! game_config::mp_debug) {
|
||||
return;
|
||||
|
@ -646,7 +616,6 @@ void check_checksums(display& disp,const unit_map& units,const config& cfg)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
|
||||
unit_map& units,
|
||||
|
|
|
@ -82,8 +82,7 @@ bool operator<(const surface& a, const surface& b)
|
|||
return a.get() < b.get();
|
||||
}
|
||||
|
||||
namespace {
|
||||
SDL_PixelFormat& get_neutral_pixel_format()
|
||||
static SDL_PixelFormat& get_neutral_pixel_format()
|
||||
{
|
||||
static bool first_time = true;
|
||||
static SDL_PixelFormat format;
|
||||
|
@ -98,8 +97,6 @@ namespace {
|
|||
return format;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
surface make_neutral_surface(surface const &surf)
|
||||
{
|
||||
if(surf == NULL) {
|
||||
|
|
|
@ -31,11 +31,9 @@ variable_set::~variable_set()
|
|||
{
|
||||
}
|
||||
|
||||
namespace {
|
||||
static bool two_dots(char a, char b) { return a == '.' && b == '.'; }
|
||||
|
||||
bool two_dots(char a, char b) { return a == '.' && b == '.'; }
|
||||
|
||||
std::string do_interpolation(const std::string &str, const variable_set& set)
|
||||
static std::string do_interpolation(const std::string &str, const variable_set& set)
|
||||
{
|
||||
std::string res = str;
|
||||
//this needs to be able to store negative numbers to check for the while's condition
|
||||
|
@ -125,8 +123,6 @@ std::string do_interpolation(const std::string &str, const variable_set& set)
|
|||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace utils {
|
||||
|
||||
bool isnewline(char c)
|
||||
|
@ -657,48 +653,6 @@ wide_string string_to_wstring(const std::string &src)
|
|||
return res;
|
||||
}
|
||||
|
||||
ucs2_string utf8_string_to_ucs2_string(const utf8_string& src)
|
||||
{
|
||||
ucs2_string res;
|
||||
try {
|
||||
utf8_iterator i1(src);
|
||||
const utf8_iterator i2(utf8_iterator::end(src));
|
||||
while(i1 != i2) {
|
||||
push_back(res, *i1);
|
||||
++i1;
|
||||
}
|
||||
}
|
||||
catch(invalid_utf8_exception e) {
|
||||
ERR_GENERAL << "Invalid UTF-8 string: \"" << src << "\"\n";
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
utf8_string ucs2_string_to_utf8_string(const ucs2_string& src)
|
||||
{
|
||||
utf8_string dst;
|
||||
dst.reserve(src.size());
|
||||
ucs2_string::const_iterator itor = src.begin();
|
||||
for(;itor != src.end(); ++itor) {
|
||||
if(*itor < 0x0080) {
|
||||
push_back(dst,*itor);
|
||||
continue;
|
||||
}
|
||||
if(0x0080 <= *itor && *itor < 0x0800) {
|
||||
push_back(dst,(*itor >> 6) | 0xC0);
|
||||
push_back(dst,(*itor & 0x003F) | 0x80);
|
||||
continue;
|
||||
}
|
||||
if((0x0800 <= *itor && *itor < 0xD800) || (0xDFFF < *itor && *itor < 0xFFFE)) {
|
||||
push_back(dst,(*itor >> 12) | 0xE0);
|
||||
push_back(dst,((*itor >> 6) & 0x003F) | 0x80);
|
||||
push_back(dst,(*itor & 0x003F) | 0x80);
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
utf8_string capitalize(const utf8_string& s)
|
||||
{
|
||||
if(s.size() > 0) {
|
||||
|
|
|
@ -110,8 +110,6 @@ private:
|
|||
std::string wstring_to_string(const wide_string &);
|
||||
wide_string string_to_wstring(const std::string &);
|
||||
std::string wchar_to_string(const wchar_t);
|
||||
ucs2_string utf8_string_to_ucs2_string(const utf8_string& src);
|
||||
utf8_string ucs2_string_to_utf8_string(const ucs2_string& src);
|
||||
|
||||
/** Returns a version of the string with the first letter capitalized */
|
||||
utf8_string capitalize(const utf8_string&);
|
||||
|
|
|
@ -40,7 +40,7 @@ std::vector<Mix_Chunk*> channel_chunks;
|
|||
// is playing on a channel for fading/panning)
|
||||
std::vector<int> channel_ids;
|
||||
|
||||
bool play_sound_internal(const std::string& files, channel_group group, bool sound_on,
|
||||
static bool play_sound_internal(const std::string& files, channel_group group, bool sound_on,
|
||||
unsigned int distance=0, int id=-1);
|
||||
}
|
||||
|
||||
|
@ -66,11 +66,14 @@ unsigned max_cached_chunks = 256;
|
|||
#endif
|
||||
|
||||
std::map< Mix_Chunk*, int > chunk_usage;
|
||||
void increment_chunk_usage(Mix_Chunk* mcp) {
|
||||
|
||||
}
|
||||
|
||||
static void increment_chunk_usage(Mix_Chunk* mcp) {
|
||||
++(chunk_usage[mcp]);
|
||||
}
|
||||
|
||||
void decrement_chunk_usage(Mix_Chunk* mcp) {
|
||||
static void decrement_chunk_usage(Mix_Chunk* mcp) {
|
||||
if(mcp == NULL) return;
|
||||
std::map< Mix_Chunk*, int >::iterator this_usage = chunk_usage.find(mcp);
|
||||
wassert(this_usage != chunk_usage.end());
|
||||
|
@ -80,6 +83,8 @@ void decrement_chunk_usage(Mix_Chunk* mcp) {
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class sound_cache_chunk {
|
||||
public:
|
||||
sound_cache_chunk(const std::string& f) : group(sound::NULL_CHANNEL), file(f), data_(NULL) {}
|
||||
|
@ -177,7 +182,9 @@ void music_track::write(config &snapshot, bool append)
|
|||
std::vector<music_track> current_track_list;
|
||||
struct music_track current_track("");
|
||||
|
||||
bool track_ok(const std::string &name)
|
||||
}
|
||||
|
||||
static bool track_ok(const std::string &name)
|
||||
{
|
||||
LOG_AUDIO << "Considering " << name << "\n";
|
||||
|
||||
|
@ -235,7 +242,7 @@ bool track_ok(const std::string &name)
|
|||
}
|
||||
|
||||
|
||||
const struct music_track &choose_track()
|
||||
static const music_track &choose_track()
|
||||
{
|
||||
wassert(!current_track_list.empty());
|
||||
|
||||
|
@ -253,7 +260,7 @@ const struct music_track &choose_track()
|
|||
return current_track_list[track];
|
||||
}
|
||||
|
||||
std::string pick_one(const std::string &files)
|
||||
static std::string pick_one(const std::string &files)
|
||||
{
|
||||
std::vector<std::string> names = utils::split(files);
|
||||
|
||||
|
@ -284,6 +291,8 @@ std::string pick_one(const std::string &files)
|
|||
return names[choice];
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
struct audio_lock
|
||||
{
|
||||
audio_lock()
|
||||
|
@ -303,7 +312,7 @@ struct audio_lock
|
|||
namespace sound {
|
||||
|
||||
// Removes channel-chunk and channel-id mapping
|
||||
void channel_finished_hook(int channel)
|
||||
static void channel_finished_hook(int channel)
|
||||
{
|
||||
channel_chunks[channel] = NULL;
|
||||
channel_ids[channel] = -1;
|
||||
|
|
|
@ -20,9 +20,7 @@
|
|||
#include "soundsource.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
int calculate_volume(int x, int y, const display &disp)
|
||||
static int calculate_volume(int x, int y, const display &disp)
|
||||
{
|
||||
SDL_Rect area = disp.map_area();
|
||||
|
||||
|
@ -34,8 +32,6 @@ int calculate_volume(int x, int y, const display &disp)
|
|||
return maximum<int>(0, 128 * static_cast<int>(sqrt(dx + dy) / (sqrt(area.w*area.w + area.h * area.h))));
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
|
||||
namespace soundsource {
|
||||
|
||||
unsigned int manager::positional_source::last_id = 0;
|
||||
|
|
|
@ -77,7 +77,9 @@ void scenario_stats::write(config_writer &out) const
|
|||
|
||||
std::vector<scenario_stats> master_stats;
|
||||
|
||||
stats& get_stats(int team)
|
||||
}
|
||||
|
||||
static stats& get_stats(int team)
|
||||
{
|
||||
if(master_stats.empty()) {
|
||||
master_stats.push_back(scenario_stats(""));
|
||||
|
@ -92,7 +94,7 @@ stats& get_stats(int team)
|
|||
return team_stats[index];
|
||||
}
|
||||
|
||||
config write_str_int_map(const stats::str_int_map& m)
|
||||
static config write_str_int_map(const stats::str_int_map& m)
|
||||
{
|
||||
config res;
|
||||
for(stats::str_int_map::const_iterator i = m.begin(); i != m.end(); ++i) {
|
||||
|
@ -104,7 +106,7 @@ config write_str_int_map(const stats::str_int_map& m)
|
|||
return res;
|
||||
}
|
||||
|
||||
void write_str_int_map(config_writer &out, const stats::str_int_map& m)
|
||||
static void write_str_int_map(config_writer &out, const stats::str_int_map& m)
|
||||
{
|
||||
for(stats::str_int_map::const_iterator i = m.begin(); i != m.end(); ++i) {
|
||||
char buf[50];
|
||||
|
@ -113,7 +115,7 @@ void write_str_int_map(config_writer &out, const stats::str_int_map& m)
|
|||
}
|
||||
}
|
||||
|
||||
stats::str_int_map read_str_int_map(const config& cfg)
|
||||
static stats::str_int_map read_str_int_map(const config& cfg)
|
||||
{
|
||||
stats::str_int_map m;
|
||||
for(string_map::const_iterator i = cfg.values.begin(); i != cfg.values.end(); ++i) {
|
||||
|
@ -123,7 +125,7 @@ stats::str_int_map read_str_int_map(const config& cfg)
|
|||
return m;
|
||||
}
|
||||
|
||||
config write_battle_result_map(const stats::battle_result_map& m)
|
||||
static config write_battle_result_map(const stats::battle_result_map& m)
|
||||
{
|
||||
config res;
|
||||
for(stats::battle_result_map::const_iterator i = m.begin(); i != m.end(); ++i) {
|
||||
|
@ -138,7 +140,7 @@ config write_battle_result_map(const stats::battle_result_map& m)
|
|||
return res;
|
||||
}
|
||||
|
||||
void write_battle_result_map(config_writer &out, const stats::battle_result_map& m)
|
||||
static void write_battle_result_map(config_writer &out, const stats::battle_result_map& m)
|
||||
{
|
||||
for(stats::battle_result_map::const_iterator i = m.begin(); i != m.end(); ++i) {
|
||||
out.open_child("sequence");
|
||||
|
@ -151,7 +153,7 @@ void write_battle_result_map(config_writer &out, const stats::battle_result_map&
|
|||
}
|
||||
}
|
||||
|
||||
stats::battle_result_map read_battle_result_map(const config& cfg)
|
||||
static stats::battle_result_map read_battle_result_map(const config& cfg)
|
||||
{
|
||||
stats::battle_result_map m;
|
||||
const config::child_list c = cfg.get_children("sequence");
|
||||
|
@ -165,21 +167,21 @@ stats::battle_result_map read_battle_result_map(const config& cfg)
|
|||
return m;
|
||||
}
|
||||
|
||||
void merge_str_int_map(stats::str_int_map& a, const stats::str_int_map& b)
|
||||
static void merge_str_int_map(stats::str_int_map& a, const stats::str_int_map& b)
|
||||
{
|
||||
for(stats::str_int_map::const_iterator i = b.begin(); i != b.end(); ++i) {
|
||||
a[i->first] += i->second;
|
||||
}
|
||||
}
|
||||
|
||||
void merge_battle_result_maps(stats::battle_result_map& a, const stats::battle_result_map& b)
|
||||
static void merge_battle_result_maps(stats::battle_result_map& a, const stats::battle_result_map& b)
|
||||
{
|
||||
for(stats::battle_result_map::const_iterator i = b.begin(); i != b.end(); ++i) {
|
||||
merge_str_int_map(a[i->first],i->second);
|
||||
}
|
||||
}
|
||||
|
||||
void merge_stats(stats& a, const stats& b)
|
||||
static void merge_stats(stats& a, const stats& b)
|
||||
{
|
||||
merge_str_int_map(a.recruits,b.recruits);
|
||||
merge_str_int_map(a.recalls,b.recalls);
|
||||
|
@ -198,8 +200,6 @@ void merge_stats(stats& a, const stats& b)
|
|||
a.expected_damage_taken += b.expected_damage_taken;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace statistics
|
||||
{
|
||||
|
||||
|
@ -466,17 +466,6 @@ void advance_unit(const unit& u)
|
|||
s.advanced_to[u.id()]++;
|
||||
}
|
||||
|
||||
std::vector<std::string> get_categories()
|
||||
{
|
||||
std::vector<std::string> res;
|
||||
res.push_back("all_statistics");
|
||||
for(std::vector<scenario_stats>::const_iterator i = master_stats.begin(); i != master_stats.end(); ++i) {
|
||||
res.push_back(i->scenario_name);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
stats calculate_stats(int category, int side)
|
||||
{
|
||||
if(category == 0) {
|
||||
|
|
|
@ -105,7 +105,6 @@ namespace statistics
|
|||
void fresh_stats();
|
||||
void clear_current_scenario();
|
||||
|
||||
std::vector<std::string> get_categories();
|
||||
stats calculate_stats(int category, int side);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,9 @@ namespace {
|
|||
const Uint32 DefaultFontRGB = 0x00C8C8C8;
|
||||
|
||||
_rect ref_rect = { 0, 0, 0, 0 };
|
||||
}
|
||||
|
||||
size_t compute(std::string expr, size_t ref1, size_t ref2=0 ) {
|
||||
static size_t compute(std::string expr, size_t ref1, size_t ref2=0 ) {
|
||||
size_t ref = 0;
|
||||
if (expr[0] == '=') {
|
||||
ref = ref1;
|
||||
|
@ -50,7 +51,7 @@ namespace {
|
|||
}
|
||||
|
||||
// if x2 or y2 are not specified, use x1 and y1 values
|
||||
_rect read_rect(const config& cfg) {
|
||||
static _rect read_rect(const config& cfg) {
|
||||
_rect rect = { 0, 0, 0, 0 };
|
||||
const std::vector<std::string> items = utils::split(cfg["rect"].c_str());
|
||||
if(items.size() >= 1)
|
||||
|
@ -72,7 +73,7 @@ namespace {
|
|||
return rect;
|
||||
}
|
||||
|
||||
SDL_Rect read_sdl_rect(const config& cfg) {
|
||||
static SDL_Rect read_sdl_rect(const config& cfg) {
|
||||
SDL_Rect sdlrect;
|
||||
const _rect rect = read_rect(cfg);
|
||||
sdlrect.x = rect.x1;
|
||||
|
@ -83,7 +84,7 @@ namespace {
|
|||
return sdlrect;
|
||||
}
|
||||
|
||||
std::string resolve_rect(const std::string& rect_str) {
|
||||
static std::string resolve_rect(const std::string& rect_str) {
|
||||
_rect rect = { 0, 0, 0, 0 };
|
||||
std::stringstream resolved;
|
||||
const std::vector<std::string> items = utils::split(rect_str.c_str());
|
||||
|
@ -110,9 +111,11 @@ namespace {
|
|||
return resolved.str();
|
||||
}
|
||||
|
||||
namespace {
|
||||
config empty_config = config();
|
||||
}
|
||||
|
||||
config& find_ref(const std::string& id, config& cfg, bool remove = false) {
|
||||
static config& find_ref(const std::string& id, config& cfg, bool remove = false) {
|
||||
for(config::child_map::const_iterator i = cfg.all_children().begin();
|
||||
i != cfg.all_children().end(); i++) {
|
||||
for (config::child_list::const_iterator j = i->second.begin();
|
||||
|
@ -148,7 +151,7 @@ namespace {
|
|||
}
|
||||
#endif
|
||||
|
||||
void expand_partialresolution(config& dst_cfg, const config& top_cfg)
|
||||
static void expand_partialresolution(config& dst_cfg, const config& top_cfg)
|
||||
{
|
||||
std::vector<config> res_cfgs_;
|
||||
// resolve all the partialresolutions
|
||||
|
@ -218,7 +221,7 @@ namespace {
|
|||
return;
|
||||
}
|
||||
|
||||
void do_resolve_rects(const config& cfg, config& resolved_config, config* resol_cfg = NULL) {
|
||||
static void do_resolve_rects(const config& cfg, config& resolved_config, config* resol_cfg = NULL) {
|
||||
|
||||
// recursively resolve children
|
||||
for(config::all_children_iterator i = cfg.ordered_begin(); i != cfg.ordered_end(); ++i) {
|
||||
|
@ -255,7 +258,6 @@ namespace {
|
|||
resolved_config.values["rect"] = resolve_rect(cfg["rect"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
theme::object::object() : location_modified_(false), loc_(empty_rect), relative_loc_(empty_rect),
|
||||
last_screen_(empty_rect), xanchor_(object::FIXED), yanchor_(object::FIXED)
|
||||
|
|
|
@ -20,9 +20,8 @@
|
|||
#include <vector>
|
||||
|
||||
#define ERR_G LOG_STREAM(err, general)
|
||||
namespace {
|
||||
|
||||
int run_async_operation(void* data)
|
||||
static int run_async_operation(void* data)
|
||||
{
|
||||
threading::async_operation* const op = reinterpret_cast<threading::async_operation*>(data);
|
||||
op->run();
|
||||
|
@ -44,6 +43,8 @@ int run_async_operation(void* data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
std::vector<SDL_Thread*> detached_threads;
|
||||
|
||||
}
|
||||
|
|
|
@ -38,9 +38,7 @@
|
|||
#define LOG_DP LOG_STREAM(info, display)
|
||||
#define ERR_DP LOG_STREAM(err, display)
|
||||
|
||||
namespace {
|
||||
|
||||
bool fade_logo(display& screen, int xpos, int ypos)
|
||||
static bool fade_logo(display& screen, int xpos, int ypos)
|
||||
{
|
||||
const surface logo(image::get_image(game_config::game_logo,image::UNSCALED));
|
||||
if(logo == NULL) {
|
||||
|
@ -100,7 +98,7 @@ bool fade_logo(display& screen, int xpos, int ypos)
|
|||
return true;
|
||||
}
|
||||
|
||||
const std::string& get_tip_of_day(const config& tips,int* ntip)
|
||||
static const std::string& get_tip_of_day(const config& tips,int* ntip)
|
||||
{
|
||||
static const std::string empty_string;
|
||||
string_map::const_iterator it;
|
||||
|
@ -134,7 +132,7 @@ const std::string& get_tip_of_day(const config& tips,int* ntip)
|
|||
return it->second;
|
||||
}
|
||||
|
||||
const config get_tips_of_day()
|
||||
static const config get_tips_of_day()
|
||||
{
|
||||
config cfg;
|
||||
|
||||
|
@ -151,7 +149,7 @@ const config get_tips_of_day()
|
|||
|
||||
|
||||
|
||||
void draw_tip_of_day(display& screen, config& tips_of_day, int* ntip, const std::string& style, gui::button* const next_tip_button, gui::button* const help_tip_button, const SDL_Rect* const main_dialog_area, surface_restorer& tip_of_day_restorer)
|
||||
static void draw_tip_of_day(display& screen, config& tips_of_day, int* ntip, const std::string& style, gui::button* const next_tip_button, gui::button* const help_tip_button, const SDL_Rect* const main_dialog_area, surface_restorer& tip_of_day_restorer)
|
||||
{
|
||||
|
||||
// Restore the previous tip of day area to its old state (section of the title image).
|
||||
|
@ -203,8 +201,6 @@ void draw_tip_of_day(display& screen, config& tips_of_day, int* ntip, const std:
|
|||
LOG_DP << "drew tip of day\n";
|
||||
}
|
||||
|
||||
} //end anonymous namespace
|
||||
|
||||
namespace gui {
|
||||
|
||||
TITLE_RESULT show_title(display& screen, config& tips_of_day, int* ntip)
|
||||
|
|
|
@ -21,9 +21,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
|
||||
bool rectangles_overlap(const SDL_Rect& a, const SDL_Rect& b)
|
||||
static bool rectangles_overlap(const SDL_Rect& a, const SDL_Rect& b)
|
||||
{
|
||||
const bool xoverlap = a.x >= b.x && a.x < b.x + b.w ||
|
||||
b.x >= a.x && b.x < a.x + a.w;
|
||||
|
@ -34,6 +32,8 @@ bool rectangles_overlap(const SDL_Rect& a, const SDL_Rect& b)
|
|||
return xoverlap && yoverlap;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
CVideo* video_ = NULL;
|
||||
|
||||
struct tooltip
|
||||
|
@ -56,13 +56,9 @@ int tooltip_handle = 0;
|
|||
SDL_Rect current_rect;
|
||||
surface current_background = NULL;
|
||||
|
||||
SDL_Rect get_text_size(const std::string& msg)
|
||||
{
|
||||
SDL_Rect area = {0,0,10000,10000};
|
||||
return font::draw_text(NULL,area,font_size,font::BLACK_COLOUR,msg,0,0);
|
||||
}
|
||||
|
||||
void clear_tooltip()
|
||||
static void clear_tooltip()
|
||||
{
|
||||
if(tooltip_handle != 0) {
|
||||
font::remove_floating_label(tooltip_handle);
|
||||
|
@ -70,7 +66,7 @@ void clear_tooltip()
|
|||
}
|
||||
}
|
||||
|
||||
void show_tooltip(const tooltip& tip)
|
||||
static void show_tooltip(const tooltip& tip)
|
||||
{
|
||||
if(video_ == NULL) {
|
||||
return;
|
||||
|
@ -109,8 +105,6 @@ void show_tooltip(const tooltip& tip)
|
|||
font::move_floating_label(tooltip_handle,rect.x,rect.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace tooltips {
|
||||
|
||||
manager::manager(CVideo& video)
|
||||
|
@ -176,11 +170,4 @@ void process(int mousex, int mousey)
|
|||
current_tooltip = tips.end();
|
||||
}
|
||||
|
||||
SDL_Rect draw_text(CVideo* gui, const SDL_Rect& area, int size,
|
||||
const SDL_Color& colour, const std::string& text,
|
||||
int x, int y)
|
||||
{
|
||||
return font::draw_text(gui, area, size, colour, text, x, y, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,13 +33,6 @@ void clear_tooltips(const SDL_Rect& rect);
|
|||
void add_tooltip(const SDL_Rect& rect, const std::string& message);
|
||||
void process(int mousex, int mousey);
|
||||
|
||||
|
||||
//a function exactly the same as font::draw_text, but will also register
|
||||
//a tooltip
|
||||
SDL_Rect draw_text(CVideo* gui, const SDL_Rect& area, int size,
|
||||
const SDL_Color& colour, const std::string& text,
|
||||
int x, int y);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
13
src/unit.cpp
13
src/unit.cpp
|
@ -2376,9 +2376,8 @@ size_t unit::modification_count(const std::string& type, const std::string& id)
|
|||
return res;
|
||||
}
|
||||
|
||||
namespace {
|
||||
/* Helper function for add_modifications */
|
||||
void mod_mdr_merge(config& dst, const config& mod, bool delta)
|
||||
static void mod_mdr_merge(config& dst, const config& mod, bool delta)
|
||||
{
|
||||
string_map::const_iterator iter = mod.values.begin();
|
||||
string_map::const_iterator end = mod.values.end();
|
||||
|
@ -2390,7 +2389,6 @@ void mod_mdr_merge(config& dst, const config& mod, bool delta)
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void unit::add_modification(const std::string& type, const config& mod,
|
||||
bool no_add)
|
||||
|
@ -3094,15 +3092,6 @@ unit_map::const_iterator team_leader(unsigned int side, const unit_map& units)
|
|||
return units.end();
|
||||
}
|
||||
|
||||
std::string team_name(int side, const unit_map& units)
|
||||
{
|
||||
const unit_map::const_iterator i = team_leader(side,units);
|
||||
if(i != units.end())
|
||||
return i->second.description();
|
||||
else
|
||||
return "-";
|
||||
}
|
||||
|
||||
unit_map::iterator find_visible_unit(unit_map& units,
|
||||
const gamemap::location loc,
|
||||
const gamemap& map,
|
||||
|
|
|
@ -446,7 +446,6 @@ void sort_units(std::vector< unit > &);
|
|||
int team_units(const unit_map& units, unsigned int team_num);
|
||||
int team_upkeep(const unit_map& units, unsigned int team_num);
|
||||
unit_map::const_iterator team_leader(unsigned int side, const unit_map& units);
|
||||
std::string team_name(int side, const unit_map& units);
|
||||
unit_map::iterator find_visible_unit(unit_map& units,
|
||||
const gamemap::location loc,
|
||||
const gamemap& map,
|
||||
|
|
|
@ -30,10 +30,7 @@
|
|||
|
||||
#define LOG_DP LOG_STREAM(info, display)
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
void teleport_unit_between(display& disp, const gamemap::location& a, const gamemap::location& b, unit& temp_unit)
|
||||
static void teleport_unit_between(display& disp, const gamemap::location& a, const gamemap::location& b, unit& temp_unit)
|
||||
{
|
||||
if(disp.update_locked() || disp.fogged(a.x,a.y) && disp.fogged(b.x,b.y)) {
|
||||
return;
|
||||
|
@ -66,7 +63,7 @@ void teleport_unit_between(display& disp, const gamemap::location& a, const game
|
|||
events::pump();
|
||||
}
|
||||
|
||||
void move_unit_between(display& disp, const gamemap& map, const gamemap::location& a, const gamemap::location& b, unit& temp_unit)
|
||||
static void move_unit_between(display& disp, const gamemap& map, const gamemap::location& a, const gamemap::location& b, unit& temp_unit)
|
||||
{
|
||||
if(disp.update_locked() || disp.fogged(a.x,a.y) && disp.fogged(b.x,b.y)) {
|
||||
return;
|
||||
|
@ -103,8 +100,6 @@ void move_unit_between(display& disp, const gamemap& map, const gamemap::locatio
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace unit_display
|
||||
{
|
||||
|
||||
|
@ -212,9 +207,7 @@ const attack_type* attack,const attack_type* secondary_attack, unit* winner)
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void unit_attack_ranged(display& disp, unit_map& units,
|
||||
static void unit_attack_ranged(display& disp, unit_map& units,
|
||||
const gamemap::location& a, const gamemap::location& b,
|
||||
int damage, const attack_type& attack, const attack_type* secondary_attack,bool update_display, int swing)
|
||||
|
||||
|
@ -384,8 +377,6 @@ void unit_attack_ranged(display& disp, unit_map& units,
|
|||
|
||||
}
|
||||
|
||||
} //end anon namespace
|
||||
|
||||
void unit_attack(display& disp, unit_map& units,
|
||||
const gamemap::location& a, const gamemap::location& b, int damage,
|
||||
const attack_type& attack, const attack_type* secondary_attack,
|
||||
|
|
|
@ -69,8 +69,9 @@ int main( int argc, char** argv )
|
|||
|
||||
namespace {
|
||||
bool fullScreen = false;
|
||||
}
|
||||
|
||||
unsigned int get_flags(unsigned int flags)
|
||||
static unsigned int get_flags(unsigned int flags)
|
||||
{
|
||||
//SDL under Windows doesn't seem to like hardware surfaces for
|
||||
//some reason.
|
||||
|
@ -83,19 +84,23 @@ unsigned int get_flags(unsigned int flags)
|
|||
return flags;
|
||||
}
|
||||
|
||||
namespace {
|
||||
std::vector<SDL_Rect> update_rects;
|
||||
bool update_all = false;
|
||||
}
|
||||
|
||||
bool rect_contains(const SDL_Rect& a, const SDL_Rect& b) {
|
||||
static bool rect_contains(const SDL_Rect& a, const SDL_Rect& b) {
|
||||
return a.x <= b.x && a.y <= b.y && a.x+a.w >= b.x+b.w && a.y+a.h >= b.y+b.h;
|
||||
}
|
||||
|
||||
void clear_updates()
|
||||
static void clear_updates()
|
||||
{
|
||||
update_all = false;
|
||||
update_rects.clear();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
surface frameBuffer = NULL;
|
||||
|
||||
}
|
||||
|
|
|
@ -230,9 +230,7 @@ bool button::hit(int x, int y) const
|
|||
return point_in_rect(x,y,location());
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool not_image(const std::string& str) { return !str.empty() && str[0] != IMAGE_PREFIX; }
|
||||
}
|
||||
static bool not_image(const std::string& str) { return !str.empty() && str[0] != IMAGE_PREFIX; }
|
||||
|
||||
void button::set_label(const std::string& val)
|
||||
{
|
||||
|
|
|
@ -33,8 +33,8 @@ namespace {
|
|||
|
||||
namespace gui {
|
||||
|
||||
const std::string file_menu::dir_picture("misc/folder-icon.png");
|
||||
const std::string file_menu::path_up("..");
|
||||
static const std::string dir_picture("misc/folder-icon.png");
|
||||
static const std::string path_up("..");
|
||||
const char file_menu::path_delim('/');
|
||||
|
||||
file_menu::file_menu(CVideo &disp, std::string start_file)
|
||||
|
|
|
@ -24,8 +24,6 @@ class file_menu : public menu {
|
|||
public:
|
||||
//Static members
|
||||
static const char path_delim;
|
||||
static const std::string dir_picture;
|
||||
static const std::string path_up;
|
||||
|
||||
/// Initialize the file menu. start_file is the file that will be
|
||||
/// selected initially. The current directory will be
|
||||
|
|
|
@ -107,7 +107,6 @@ public:
|
|||
friend class imgsel_style;
|
||||
static style &default_style;
|
||||
static style simple_style;
|
||||
static imgsel_style slateborder_style;
|
||||
static imgsel_style bluebg_style;
|
||||
|
||||
struct item
|
||||
|
|
|
@ -35,9 +35,6 @@
|
|||
namespace gui {
|
||||
|
||||
//static initializations
|
||||
menu::imgsel_style menu::slateborder_style("misc/selection", false,
|
||||
0x000000, 0x4a4440, 0x999999,
|
||||
0.0, 0.2, 0.2);
|
||||
menu::imgsel_style menu::bluebg_style("misc/selection2", true,
|
||||
0x000000, 0x000000, 0x333333,
|
||||
0.35, 0.0, 0.3);
|
||||
|
|
Loading…
Add table
Reference in a new issue