(svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
--- a/src/blitter/factory.hpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/blitter/factory.hpp Mon Jan 07 14:23:25 2008 +0000
@@ -4,8 +4,8 @@
#define BLITTER_FACTORY_HPP
#include "base.hpp"
-#include "../string.h"
#include "../debug.h"
+#include "../string_func.h"
#include <string>
#include <map>
--- a/src/console.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/console.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -10,7 +10,6 @@
#include "window_gui.h"
#include "player.h"
#include "variables.h"
-#include "string.h"
#include <stdarg.h>
#include <string.h>
#include "console.h"
@@ -19,6 +18,7 @@
#include "network/network_server.h"
#include "core/alloc_func.hpp"
#include "window_func.h"
+#include "string_func.h"
#define ICON_BUFFER 79
#define ICON_HISTORY_SIZE 20
--- a/src/console_cmds.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/console_cmds.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -9,7 +9,6 @@
#include "engine.h"
#include "landscape.h"
#include "saveload.h"
-#include "string.h"
#include "variables.h"
#include "network/network_data.h"
#include "network/network_client.h"
@@ -30,6 +29,7 @@
#include "map_func.h"
#include "date_func.h"
#include "vehicle_func.h"
+#include "string_func.h"
// ** scriptfile handling ** //
static FILE *_script_file;
--- a/src/debug.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/debug.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -8,7 +8,7 @@
#include "openttd.h"
#include "console.h"
#include "debug.h"
-#include "string.h"
+#include "string_func.h"
#include "network/core/core.h"
#if defined(ENABLE_NETWORK)
--- a/src/driver.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/driver.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -6,7 +6,6 @@
#include "openttd.h"
#include "debug.h"
#include "driver.h"
-#include "string.h"
#include "sound/sound_driver.hpp"
#include "music/music_driver.hpp"
--- a/src/driver.h Mon Jan 07 14:02:26 2008 +0000
+++ b/src/driver.h Mon Jan 07 14:23:25 2008 +0000
@@ -7,7 +7,7 @@
#include "debug.h"
#include "core/enum_type.hpp"
-#include "string.h"
+#include "string_func.h"
#include <string>
#include <map>
--- a/src/engine.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/engine.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -17,7 +17,6 @@
#include "newgrf_cargo.h"
#include "table/engines.h"
#include "group.h"
-#include "string.h"
#include "misc/autoptr.hpp"
#include "strings_func.h"
#include "viewport.h"
@@ -26,6 +25,7 @@
#include "date_func.h"
#include "autoreplace_base.h"
#include "autoreplace_gui.h"
+#include "string_func.h"
EngineInfo _engine_info[TOTAL_NUM_ENGINES];
RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES];
--- a/src/fileio.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/fileio.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -5,12 +5,12 @@
#include "stdafx.h"
#include "openttd.h"
#include "fileio.h"
-#include "string.h"
#include "variables.h"
#include "debug.h"
#include "fios.h"
#include "core/alloc_func.hpp"
#include "core/math_func.hpp"
+#include "string_func.h"
#ifdef WIN32
#include <windows.h>
#else
--- a/src/fios.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/fios.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -6,7 +6,6 @@
#include "stdafx.h"
#include "openttd.h"
-#include "string.h"
#include "variables.h"
#include "heightmap.h"
#include "table/strings.h"
@@ -14,6 +13,7 @@
#include "fileio.h"
#include "core/alloc_func.hpp"
#include "functions.h"
+#include "string_func.h"
#include <sys/types.h>
#include <sys/stat.h>
--- a/src/fontcache.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/fontcache.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -8,7 +8,6 @@
#include "table/sprites.h"
#include "table/control_codes.h"
#include "spritecache.h"
-#include "string.h"
#include "fontcache.h"
#include "spriteloader/spriteloader.hpp"
#include "blitter/factory.hpp"
--- a/src/genworld_gui.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/genworld_gui.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -14,7 +14,6 @@
#include "player.h"
#include "command_func.h"
#include "variables.h"
-#include "string.h"
#include "settings_func.h"
#include "debug.h"
#include "genworld.h"
@@ -26,6 +25,7 @@
#include "date_func.h"
#include "sound_func.h"
#include "fios.h"
+#include "string_func.h"
/**
* In what 'mode' the GenerateLandscapeWindowProc is.
--- a/src/gfx.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/gfx.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -6,7 +6,6 @@
#include "openttd.h"
#include "gfx_func.h"
#include "spritecache.h"
-#include "string.h"
#include "table/palettes.h"
#include "table/sprites.h"
#include "variables.h"
--- a/src/gfxinit.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/gfxinit.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -10,7 +10,6 @@
#include "table/sprites.h"
#include "fileio.h"
#include "fios.h"
-#include "string.h"
#include "newgrf.h"
#include "md5.h"
#include "variables.h"
--- a/src/group_cmd.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/group_cmd.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -13,7 +13,6 @@
#include "group.h"
#include "train.h"
#include "aircraft.h"
-#include "string.h"
#include "vehicle_gui.h"
#include "misc/autoptr.hpp"
#include "strings_func.h"
@@ -22,6 +21,7 @@
#include "vehicle_func.h"
#include "autoreplace_base.h"
#include "autoreplace_func.h"
+#include "string_func.h"
/**
* Update the num engines of a groupID. Decrease the old one and increase the new one
--- a/src/group_gui.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/group_gui.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -22,6 +22,7 @@
#include "window_func.h"
#include "vehicle_func.h"
#include "autoreplace_gui.h"
+#include "string_func.h"
struct Sorting {
--- a/src/main_gui.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/main_gui.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -26,7 +26,6 @@
#include "train.h"
#include "roadveh.h"
#include "bridge_map.h"
-#include "string.h"
#include "screenshot.h"
#include "genworld.h"
#include "vehicle_gui.h"
@@ -49,6 +48,7 @@
#include "transparency.h"
#include "strings_func.h"
#include "zoom_func.h"
+#include "string_func.h"
static int _rename_id = 1;
static int _rename_what = -1;
--- a/src/misc.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/misc.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -8,7 +8,6 @@
#include "landscape.h"
#include "news.h"
#include "player.h"
-#include "string.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "saveload.h"
@@ -27,6 +26,7 @@
#include "date_func.h"
#include "vehicle_func.h"
#include "texteff.hpp"
+#include "string_func.h"
char _name_array[512][32];
--- a/src/misc_cmd.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/misc_cmd.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -4,7 +4,6 @@
#include "stdafx.h"
#include "openttd.h"
-#include "string.h"
#include "table/strings.h"
#include "command_func.h"
#include "economy_func.h"
@@ -20,6 +19,7 @@
#include "gfx_func.h"
#include "functions.h"
#include "vehicle_func.h"
+#include "string_func.h"
/** Change the player's face.
* @param tile unused
--- a/src/misc_gui.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/misc_gui.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -24,7 +24,6 @@
#include "player.h"
#include "town.h"
#include "network/network.h"
-#include "string.h"
#include "variables.h"
#include "train.h"
#include "tgp.h"
@@ -39,6 +38,7 @@
#include "window_func.h"
#include "date_func.h"
#include "sound_func.h"
+#include "string_func.h"
/* Variables to display file lists */
FiosItem *_fios_list;
--- a/src/music/extmidi.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/music/extmidi.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -4,7 +4,6 @@
#include "../stdafx.h"
#include "../openttd.h"
#include "../sound_func.h"
-#include "../string.h"
#include "../variables.h"
#include "../debug.h"
#include "extmidi.h"
--- a/src/music/libtimidity.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/music/libtimidity.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -3,7 +3,6 @@
#include "../stdafx.h"
#include "../openttd.h"
#include "../sound.h"
-#include "../string.h"
#include "../variables.h"
#include "../debug.h"
#include "libtimidity.h"
--- a/src/namegen.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/namegen.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -7,7 +7,7 @@
#include "debug.h"
#include "namegen.h"
#include "table/namegen.h"
-#include "string.h"
+#include "string_func.h"
static inline uint32 SeedChance(int shift_by, int max, uint32 seed)
{
--- a/src/network/core/packet.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/network/core/packet.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -7,7 +7,7 @@
#ifdef ENABLE_NETWORK
#include "../../stdafx.h"
-#include "../../string.h"
+#include "../../string_func.h"
#include "packet.h"
--- a/src/network/network.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/network/network.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -9,7 +9,6 @@
#include "../openttd.h"
#include "../debug.h"
-#include "../string.h"
#include "../strings_func.h"
#include "../map_func.h"
#include "../command_func.h"
@@ -32,6 +31,7 @@
#include "../texteff.hpp"
#include "../core/random_func.hpp"
#include "../window_func.h"
+#include "../string_func.h"
#ifdef DEBUG_DUMP_COMMANDS
#include "../core/alloc_func.hpp"
#endif
--- a/src/network/network_client.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/network/network_client.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -4,7 +4,6 @@
#include "../stdafx.h"
#include "../debug.h"
-#include "../string.h"
#include "../openttd.h"
#include "network_data.h"
#include "core/tcp.h"
@@ -22,6 +21,7 @@
#include "../md5.h"
#include "../strings_func.h"
#include "../window_func.h"
+#include "../string_func.h"
// This file handles all the client-commands
--- a/src/network/network_data.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/network/network_data.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -5,11 +5,11 @@
#include "../stdafx.h"
#include "../debug.h"
#include "network_data.h"
-#include "../string.h"
#include "network_client.h"
#include "../command_func.h"
#include "../callback_table.h"
#include "../core/alloc_func.hpp"
+#include "../string_func.h"
// Add a command to the local command queue
void NetworkAddCommandQueue(NetworkTCPSocketHandler *cs, CommandPacket *cp)
--- a/src/network/network_gui.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/network/network_gui.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -3,7 +3,6 @@
#ifdef ENABLE_NETWORK
#include "../stdafx.h"
#include "../openttd.h"
-#include "../string.h"
#include "../strings_func.h"
#include "../table/sprites.h"
#include "network.h"
@@ -21,12 +20,12 @@
#include "../variables.h"
#include "network_server.h"
#include "network_udp.h"
-#include "../string.h"
#include "../town.h"
#include "../newgrf.h"
#include "../functions.h"
#include "../window_func.h"
#include "../core/alloc_func.hpp"
+#include "../string_func.h"
#define BGC 5
#define BTC 15
--- a/src/network/network_server.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/network/network_server.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -5,7 +5,6 @@
#include "../stdafx.h"
#include "../openttd.h" // XXX StringID
#include "../debug.h"
-#include "../string.h"
#include "../strings_func.h"
#include "network_data.h"
#include "core/tcp.h"
@@ -23,6 +22,7 @@
#include "../genworld.h"
#include "../core/alloc_func.hpp"
#include "../fileio.h"
+#include "../string_func.h"
// This file handles all the server-commands
--- a/src/network/network_udp.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/network/network_udp.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -11,7 +11,6 @@
#include "../stdafx.h"
#include "../debug.h"
-#include "../string.h"
#include "network_data.h"
#include "../date_func.h"
#include "../map_func.h"
@@ -20,6 +19,7 @@
#include "../variables.h"
#include "../newgrf_config.h"
#include "../core/endian_func.hpp"
+#include "../string_func.h"
#include "core/udp.h"
--- a/src/newgrf.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/newgrf.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -15,7 +15,6 @@
#include "sprite.h"
#include "newgrf.h"
#include "variables.h"
-#include "string.h"
#include "table/strings.h"
#include "bridge.h"
#include "town.h"
@@ -46,6 +45,7 @@
#include "date_func.h"
#include "vehicle_func.h"
#include "sound_func.h"
+#include "string_func.h"
/* TTDPatch extended GRF format codec
* (c) Petr Baudis 2004 (GPL'd)
--- a/src/newgrf_config.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/newgrf_config.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -6,13 +6,13 @@
#include "openttd.h"
#include "debug.h"
#include "variables.h"
-#include "string.h"
#include "saveload.h"
#include "md5.h"
#include "network/network_data.h"
#include "newgrf.h"
#include "newgrf_config.h"
#include "core/alloc_func.hpp"
+#include "string_func.h"
#include "fileio.h"
#include "fios.h"
--- a/src/newgrf_gui.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/newgrf_gui.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -15,6 +15,7 @@
#include "strings_func.h"
#include "window_func.h"
#include "core/alloc_func.hpp"
+#include "string_func.h"
/** Parse an integerlist string and set each found value
* @param p the string to be parsed. Each element in the list is seperated by a
--- a/src/newgrf_text.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/newgrf_text.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -12,7 +12,6 @@
#include "stdafx.h"
#include "debug.h"
#include "openttd.h"
-#include "string.h"
#include "variables.h"
#include "table/strings.h"
#include "newgrf.h"
@@ -21,6 +20,7 @@
#include "strings_func.h"
#include "core/alloc_func.hpp"
#include "newgrf_storage.h"
+#include "string_func.h"
#define GRFTAB 28
#define TABSIZE 11
--- a/src/newgrf_townname.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/newgrf_townname.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -10,8 +10,8 @@
#include "openttd.h"
#include "table/strings.h"
#include "newgrf_townname.h"
-#include "string.h"
#include "core/alloc_func.hpp"
+#include "string_func.h"
static GRFTownName *_grf_townnames = NULL;
--- a/src/news_gui.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/news_gui.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -10,13 +10,13 @@
#include "viewport.h"
#include "news.h"
#include "variables.h"
-#include "string.h"
#include "transparency.h"
#include "strings_func.h"
#include "window_func.h"
#include "date_func.h"
#include "vehicle_base.h"
#include "sound_func.h"
+#include "string_func.h"
/** @file news_gui.cpp
*
--- a/src/openttd.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/openttd.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -4,7 +4,6 @@
#include "stdafx.h"
#define VARDEF
-#include "string.h"
#include "debug.h"
#include "driver.h"
#include "saveload.h"
--- a/src/order_cmd.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/order_cmd.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -22,6 +22,7 @@
#include "functions.h"
#include "window_func.h"
#include "settings_type.h"
+#include "string_func.h"
DEFINE_OLD_POOL_GENERIC(Order, Order)
--- a/src/os2.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/os2.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -5,7 +5,6 @@
#include "stdafx.h"
#include "openttd.h"
#include "variables.h"
-#include "string.h"
#include "table/strings.h"
#include "gui.h"
#include "fileio.h"
--- a/src/player_gui.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/player_gui.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -26,6 +26,7 @@
#include "functions.h"
#include "window_func.h"
#include "date_func.h"
+#include "string_func.h"
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied);
static void DoSelectPlayerFace(PlayerID player, bool show_big);
--- a/src/players.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/players.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -5,7 +5,6 @@
#include "stdafx.h"
#include "openttd.h"
#include "engine.h"
-#include "string.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "player.h"
@@ -30,6 +29,7 @@
#include "sound_func.h"
#include "autoreplace_func.h"
#include "autoreplace_gui.h"
+#include "string_func.h"
/**
* Sets the local player and updates the patch settings that are set on a
--- a/src/roadveh_gui.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/roadveh_gui.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -17,6 +17,7 @@
#include "newgrf_engine.h"
#include "strings_func.h"
#include "vehicle_func.h"
+#include "string_func.h"
void DrawRoadVehDetails(const Vehicle *v, int x, int y)
--- a/src/screenshot.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/screenshot.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -9,7 +9,6 @@
#include "player.h"
#include "screenshot.h"
#include "variables.h"
-#include "string.h"
#include "blitter/factory.hpp"
#include "fileio.h"
#include "strings_func.h"
--- a/src/settings.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/settings.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -23,7 +23,6 @@
#include "openttd.h"
#include "currency.h"
#include "screenshot.h"
-#include "string.h"
#include "variables.h"
#include "network/network.h"
#include "settings_internal.h"
@@ -48,6 +47,7 @@
#endif
#include "spritecache.h"
#include "transparency.h"
+#include "string_func.h"
GameOptions _opt;
GameOptions _opt_newgame;
--- a/src/settings_gui.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/settings_gui.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -5,7 +5,6 @@
#include "stdafx.h"
#include "openttd.h"
#include "currency.h"
-#include "string.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "gui.h"
@@ -25,6 +24,7 @@
#include "window_func.h"
#include "vehicle_base.h"
#include "core/alloc_func.hpp"
+#include "string_func.h"
static uint32 _difficulty_click_a;
static uint32 _difficulty_click_b;
--- a/src/signs.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/signs.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -11,7 +11,6 @@
#include "saveload.h"
#include "command_func.h"
#include "variables.h"
-#include "string.h"
#include "misc/autoptr.hpp"
#include "strings_func.h"
#include "viewport.h"
@@ -19,6 +18,7 @@
#include "functions.h"
#include "window_func.h"
#include "map_func.h"
+#include "string_func.h"
SignID _new_sign_id;
uint _total_signs;
--- a/src/spritecache.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/spritecache.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -5,7 +5,6 @@
#include "stdafx.h"
#include "openttd.h"
#include "variables.h"
-#include "string.h"
#include "debug.h"
#include "spritecache.h"
#include "table/sprites.h"
--- a/src/station_cmd.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/station_cmd.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -4,7 +4,6 @@
#include "stdafx.h"
#include "openttd.h"
-#include "string.h"
#include "aircraft.h"
#include "bridge_map.h"
#include "cmd_helper.h"
@@ -45,6 +44,7 @@
#include "window_func.h"
#include "date_func.h"
#include "vehicle_func.h"
+#include "string_func.h"
DEFINE_OLD_POOL_GENERIC(Station, Station)
DEFINE_OLD_POOL_GENERIC(RoadStop, RoadStop)
--- a/src/strgen/strgen.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/strgen/strgen.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -1,10 +1,10 @@
/* $Id$ */
#include "../stdafx.h"
-#include "../string.h"
#include "../table/control_codes.h"
#include "../core/alloc_func.hpp"
#include "../core/endian_func.hpp"
+#include "../string_func.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
--- a/src/string.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/string.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -4,10 +4,10 @@
#include "stdafx.h"
#include "openttd.h"
-#include "string.h"
#include "table/control_codes.h"
#include "debug.h"
#include "core/alloc_func.hpp"
+#include "string_func.h"
#include <stdarg.h>
#include <ctype.h> // required for tolower()
--- a/src/string.h Mon Jan 07 14:02:26 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,170 +0,0 @@
-/* $Id$ */
-
-/** @file string.h */
-
-#ifndef STRING_H
-#define STRING_H
-
-#include "core/bitmath_func.hpp"
-
-/**
- * usage ttd_strlcpy(dst, src, lengthof(dst));
- * @param dst destination buffer
- * @param src string to copy/concatenate
- * @param size size of the destination buffer
- */
-void ttd_strlcat(char *dst, const char *src, size_t size);
-void ttd_strlcpy(char *dst, const char *src, size_t size);
-
-/**
- * usage: strecpy(dst, src, lastof(dst));
- * @param dst destination buffer
- * @param src string to copy
- * @param last pointer to the last element in the dst array
- * if NULL no boundary check is performed
- * @return a pointer to the terminating \0 in the destination buffer
- */
-char *strecat(char *dst, const char *src, const char *last);
-char *strecpy(char *dst, const char *src, const char *last);
-
-char *CDECL str_fmt(const char *str, ...);
-
-/** Scans the string for valid characters and if it finds invalid ones,
- * replaces them with a question mark '?' */
-void str_validate(char *str);
-
-/** Scans the string for colour codes and strips them */
-void str_strip_colours(char *str);
-
-/**
- * Valid filter types for IsValidChar.
- */
-enum CharSetFilter {
- CS_ALPHANUMERAL, ///< Both numeric and alphabetic and spaces and stuff
- CS_NUMERAL, ///< Only numeric ones
- CS_ALPHA, ///< Only alphabetic values
-};
-
-/** Convert the given string to lowercase, only works with ASCII! */
-void strtolower(char *str);
-
-
-static inline bool StrEmpty(const char *s) { return s == NULL || s[0] == '\0'; }
-
-
-/** Get the length of a string, within a limited buffer */
-static inline int ttd_strnlen(const char *str, int maxlen)
-{
- const char *t;
- for (t = str; *t != '\0' && t - str < maxlen; t++);
- return t - str;
-}
-
-/** Convert the md5sum number to a 'hexadecimal' string, return next pos in buffer */
-char *md5sumToString(char *buf, const char *last, const uint8 md5sum[16]);
-
-typedef uint32 WChar;
-
-/**
- * Only allow certain keys. You can define the filter to be used. This makes
- * sure no invalid keys can get into an editbox, like BELL.
- * @param key character to be checked
- * @param afilter the filter to use
- * @return true or false depending if the character is printable/valid or not
- */
-bool IsValidChar(WChar key, CharSetFilter afilter);
-
-size_t Utf8Decode(WChar *c, const char *s);
-size_t Utf8Encode(char *buf, WChar c);
-size_t Utf8TrimString(char *s, size_t maxlen);
-
-
-static inline WChar Utf8Consume(const char **s)
-{
- WChar c;
- *s += Utf8Decode(&c, *s);
- return c;
-}
-
-
-/** Return the length of a UTF-8 encoded character.
- * @param c Unicode character.
- * @return Length of UTF-8 encoding for character.
- */
-static inline size_t Utf8CharLen(WChar c)
-{
- if (c < 0x80) return 1;
- if (c < 0x800) return 2;
- if (c < 0x10000) return 3;
- if (c < 0x110000) return 4;
-
- /* Invalid valid, we encode as a '?' */
- return 1;
-}
-
-
-/**
- * Return the length of an UTF-8 encoded value based on a single char. This
- * char should be the first byte of the UTF-8 encoding. If not, or encoding
- * is invalid, return value is 0
- * @param c char to query length of
- * @return requested size
- */
-static inline size_t Utf8EncodedCharLen(char c)
-{
- if (GB(c, 3, 5) == 0x1E) return 4;
- if (GB(c, 4, 4) == 0x0E) return 3;
- if (GB(c, 5, 3) == 0x06) return 2;
- if (GB(c, 7, 1) == 0x00) return 1;
-
- /* Invalid UTF8 start encoding */
- return 0;
-}
-
-
-/* Check if the given character is part of a UTF8 sequence */
-static inline bool IsUtf8Part(char c)
-{
- return GB(c, 6, 2) == 2;
-}
-
-/**
- * Retrieve the previous UNICODE character in an UTF-8 encoded string.
- * @param s char pointer pointing to (the first char of) the next character
- * @return a pointer in 's' to the previous UNICODE character's first byte
- * @note The function should not be used to determine the length of the previous
- * encoded char because it might be an invalid/corrupt start-sequence
- */
-static inline char *Utf8PrevChar(const char *s)
-{
- const char *ret = s;
- while (IsUtf8Part(*--ret));
- return (char*)ret;
-}
-
-
-static inline bool IsPrintable(WChar c)
-{
- if (c < 0x20) return false;
- if (c < 0xE000) return true;
- if (c < 0xE200) return false;
- return true;
-}
-
-/**
- * Check whether UNICODE character is whitespace or not
- * @param c UNICODE character to check
- * @return a boolean value whether 'c' is a whitespace character or not
- * @see http://www.fileformat.info/info/unicode/category/Zs/list.htm
- */
-static inline bool IsWhitespace(WChar c)
-{
- return
- c == 0x0020 /* SPACE */ ||
- c == 0x00A0 /* NO-BREAK SPACE */ ||
- c == 0x3000 /* IDEOGRAPHIC SPACE */
- ;
-}
-
-
-#endif /* STRING_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/string_func.h Mon Jan 07 14:23:25 2008 +0000
@@ -0,0 +1,159 @@
+/* $Id$ */
+
+/** @file string.h Functions related to low-level strings. */
+
+#ifndef STRING_FUNC_H
+#define STRING_FUNC_H
+
+#include "core/bitmath_func.hpp"
+#include "string_type.h"
+
+/**
+ * usage ttd_strlcpy(dst, src, lengthof(dst));
+ * @param dst destination buffer
+ * @param src string to copy/concatenate
+ * @param size size of the destination buffer
+ */
+void ttd_strlcat(char *dst, const char *src, size_t size);
+void ttd_strlcpy(char *dst, const char *src, size_t size);
+
+/**
+ * usage: strecpy(dst, src, lastof(dst));
+ * @param dst destination buffer
+ * @param src string to copy
+ * @param last pointer to the last element in the dst array
+ * if NULL no boundary check is performed
+ * @return a pointer to the terminating \0 in the destination buffer
+ */
+char *strecat(char *dst, const char *src, const char *last);
+char *strecpy(char *dst, const char *src, const char *last);
+
+char *CDECL str_fmt(const char *str, ...);
+
+/** Scans the string for valid characters and if it finds invalid ones,
+ * replaces them with a question mark '?' */
+void str_validate(char *str);
+
+/** Scans the string for colour codes and strips them */
+void str_strip_colours(char *str);
+
+/** Convert the given string to lowercase, only works with ASCII! */
+void strtolower(char *str);
+
+
+static inline bool StrEmpty(const char *s) { return s == NULL || s[0] == '\0'; }
+
+
+/** Get the length of a string, within a limited buffer */
+static inline int ttd_strnlen(const char *str, int maxlen)
+{
+ const char *t;
+ for (t = str; *t != '\0' && t - str < maxlen; t++);
+ return t - str;
+}
+
+/** Convert the md5sum number to a 'hexadecimal' string, return next pos in buffer */
+char *md5sumToString(char *buf, const char *last, const uint8 md5sum[16]);
+
+/**
+ * Only allow certain keys. You can define the filter to be used. This makes
+ * sure no invalid keys can get into an editbox, like BELL.
+ * @param key character to be checked
+ * @param afilter the filter to use
+ * @return true or false depending if the character is printable/valid or not
+ */
+bool IsValidChar(WChar key, CharSetFilter afilter);
+
+size_t Utf8Decode(WChar *c, const char *s);
+size_t Utf8Encode(char *buf, WChar c);
+size_t Utf8TrimString(char *s, size_t maxlen);
+
+
+static inline WChar Utf8Consume(const char **s)
+{
+ WChar c;
+ *s += Utf8Decode(&c, *s);
+ return c;
+}
+
+
+/** Return the length of a UTF-8 encoded character.
+ * @param c Unicode character.
+ * @return Length of UTF-8 encoding for character.
+ */
+static inline size_t Utf8CharLen(WChar c)
+{
+ if (c < 0x80) return 1;
+ if (c < 0x800) return 2;
+ if (c < 0x10000) return 3;
+ if (c < 0x110000) return 4;
+
+ /* Invalid valid, we encode as a '?' */
+ return 1;
+}
+
+
+/**
+ * Return the length of an UTF-8 encoded value based on a single char. This
+ * char should be the first byte of the UTF-8 encoding. If not, or encoding
+ * is invalid, return value is 0
+ * @param c char to query length of
+ * @return requested size
+ */
+static inline size_t Utf8EncodedCharLen(char c)
+{
+ if (GB(c, 3, 5) == 0x1E) return 4;
+ if (GB(c, 4, 4) == 0x0E) return 3;
+ if (GB(c, 5, 3) == 0x06) return 2;
+ if (GB(c, 7, 1) == 0x00) return 1;
+
+ /* Invalid UTF8 start encoding */
+ return 0;
+}
+
+
+/* Check if the given character is part of a UTF8 sequence */
+static inline bool IsUtf8Part(char c)
+{
+ return GB(c, 6, 2) == 2;
+}
+
+/**
+ * Retrieve the previous UNICODE character in an UTF-8 encoded string.
+ * @param s char pointer pointing to (the first char of) the next character
+ * @return a pointer in 's' to the previous UNICODE character's first byte
+ * @note The function should not be used to determine the length of the previous
+ * encoded char because it might be an invalid/corrupt start-sequence
+ */
+static inline char *Utf8PrevChar(const char *s)
+{
+ const char *ret = s;
+ while (IsUtf8Part(*--ret));
+ return (char*)ret;
+}
+
+
+static inline bool IsPrintable(WChar c)
+{
+ if (c < 0x20) return false;
+ if (c < 0xE000) return true;
+ if (c < 0xE200) return false;
+ return true;
+}
+
+/**
+ * Check whether UNICODE character is whitespace or not
+ * @param c UNICODE character to check
+ * @return a boolean value whether 'c' is a whitespace character or not
+ * @see http://www.fileformat.info/info/unicode/category/Zs/list.htm
+ */
+static inline bool IsWhitespace(WChar c)
+{
+ return
+ c == 0x0020 /* SPACE */ ||
+ c == 0x00A0 /* NO-BREAK SPACE */ ||
+ c == 0x3000 /* IDEOGRAPHIC SPACE */
+ ;
+}
+
+#endif /* STRING_FUNC_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/string_type.h Mon Jan 07 14:23:25 2008 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+/** @file string_type.h Types for strings. */
+
+#ifndef STRING_TYPE_H
+#define STRING_TYPE_H
+
+/**
+ * Valid filter types for IsValidChar.
+ */
+enum CharSetFilter {
+ CS_ALPHANUMERAL, ///< Both numeric and alphabetic and spaces and stuff
+ CS_NUMERAL, ///< Only numeric ones
+ CS_ALPHA, ///< Only alphabetic values
+};
+
+typedef uint32 WChar;
+
+#endif /* STRING_TYPE_H */
--- a/src/strings.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/strings.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -5,7 +5,6 @@
#include "stdafx.h"
#include "openttd.h"
#include "currency.h"
-#include "string.h"
#include "table/strings.h"
#include "namegen.h"
#include "station.h"
@@ -34,6 +33,7 @@
#include "core/endian_func.hpp"
#include "date_func.h"
#include "vehicle_base.h"
+#include "string_func.h"
/* for opendir/readdir/closedir */
# include "fios.h"
--- a/src/textbuf_gui.h Mon Jan 07 14:02:26 2008 +0000
+++ b/src/textbuf_gui.h Mon Jan 07 14:23:25 2008 +0000
@@ -5,8 +5,8 @@
#ifndef TEXTBUF_GUI_H
#define TEXTBUF_GUI_H
-#include "string.h"
#include "window_type.h"
+#include "string_type.h"
struct Textbuf {
char *buf; ///< buffer in which text is saved
--- a/src/texteff.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/texteff.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -9,7 +9,6 @@
#include "viewport.h"
#include "saveload.h"
#include "console.h"
-#include "string.h"
#include "variables.h"
#include "table/sprites.h"
#include "blitter/factory.hpp"
--- a/src/timetable_gui.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/timetable_gui.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -11,11 +11,11 @@
#include "gui.h"
#include "window_gui.h"
#include "textbuf_gui.h"
-#include "string.h"
#include "cargotype.h"
#include "depot.h"
#include "strings_func.h"
#include "vehicle_base.h"
+#include "string_func.h"
static int GetOrderFromTimetableWndPt(Window *w, int y, const Vehicle *v)
{
--- a/src/town_cmd.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/town_cmd.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -40,8 +40,8 @@
#include "transparency.h"
#include "tunnelbridge_map.h"
#include "strings_func.h"
-#include "string.h"
#include "window_func.h"
+#include "string_func.h"
/* Initialize the town-pool */
--- a/src/unix.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/unix.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -4,7 +4,6 @@
#include "stdafx.h"
#include "openttd.h"
-#include "string.h"
#include "table/strings.h"
#include "variables.h"
#include "textbuf_gui.h"
--- a/src/vehicle.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/vehicle.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -46,6 +46,7 @@
#include "variables.h"
#include "autoreplace_func.h"
#include "autoreplace_gui.h"
+#include "string_func.h"
#define INVALID_COORD (0x7fffffff)
#define GEN_HASH(x, y) ((GB((y), 6, 6) << 6) + GB((x), 7, 6))
--- a/src/vehicle_gui.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/vehicle_gui.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -34,6 +34,7 @@
#include "vehicle_func.h"
#include "autoreplace_gui.h"
#include "core/alloc_func.hpp"
+#include "string_func.h"
struct Sorting {
Listing aircraft;
--- a/src/waypoint.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/waypoint.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -19,7 +19,6 @@
#include "table/strings.h"
#include "yapf/yapf.h"
#include "newgrf.h"
-#include "string.h"
#include "misc/autoptr.hpp"
#include "strings_func.h"
#include "viewport.h"
@@ -29,6 +28,7 @@
#include "date_func.h"
#include "vehicle_func.h"
#include "vehicle_base.h"
+#include "string_func.h"
enum {
MAX_WAYPOINTS_PER_TOWN = 64,
--- a/src/win32.cpp Mon Jan 07 14:02:26 2008 +0000
+++ b/src/win32.cpp Mon Jan 07 14:23:25 2008 +0000
@@ -6,7 +6,6 @@
#include "openttd.h"
#include "debug.h"
#include "saveload.h"
-#include "string.h"
#include "gfx_func.h"
#include "textbuf_gui.h"
#include "fileio.h"
--- a/src/window_gui.h Mon Jan 07 14:02:26 2008 +0000
+++ b/src/window_gui.h Mon Jan 07 14:23:25 2008 +0000
@@ -5,7 +5,6 @@
#ifndef WINDOW_GUI_H
#define WINDOW_GUI_H
-#include "string.h"
#include "order.h"
#include "rail_type.h"
#include "road_type.h"