mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r1833) byte -> char transition: the rest
This commit is contained in:
parent
27dc506a03
commit
eed181245d
|
@ -554,8 +554,8 @@ DEF_CONSOLE_CMD(ConNetworkClients)
|
|||
DEF_CONSOLE_CMD(ConNetworkConnect)
|
||||
{
|
||||
char* ip;
|
||||
const byte *port = NULL;
|
||||
const byte *player = NULL;
|
||||
const char *port = NULL;
|
||||
const char *player = NULL;
|
||||
uint16 rport;
|
||||
|
||||
if (argc<2) return NULL;
|
||||
|
|
2
engine.c
2
engine.c
|
@ -625,7 +625,7 @@ void TriggerVehicle(Vehicle *veh, enum VehicleTrigger trigger)
|
|||
|
||||
static char *_engine_custom_names[256];
|
||||
|
||||
void SetCustomEngineName(int engine, char *name)
|
||||
void SetCustomEngineName(int engine, const char *name)
|
||||
{
|
||||
_engine_custom_names[engine] = strdup(name);
|
||||
}
|
||||
|
|
2
engine.h
2
engine.h
|
@ -114,7 +114,7 @@ enum VehicleTrigger {
|
|||
};
|
||||
void TriggerVehicle(Vehicle *veh, enum VehicleTrigger trigger);
|
||||
|
||||
void SetCustomEngineName(int engine, char *name);
|
||||
void SetCustomEngineName(int engine, const char *name);
|
||||
StringID GetCustomEngineName(int engine);
|
||||
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ void NetworkShutDown(void);
|
|||
void NetworkGameLoop(void);
|
||||
void NetworkUDPGameLoop(void);
|
||||
bool NetworkServerStart(void);
|
||||
bool NetworkClientConnectGame(const byte* host, unsigned short port);
|
||||
bool NetworkClientConnectGame(const char* host, unsigned short port);
|
||||
void NetworkReboot(void);
|
||||
void NetworkDisconnect(void);
|
||||
void NetworkSend_Command(uint32 tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
|
||||
|
|
|
@ -2102,10 +2102,11 @@ extern GetNewsStringCallbackProc * const _get_news_string_callback[];
|
|||
static bool DrawScrollingStatusText(NewsItem *ni, int pos)
|
||||
{
|
||||
StringID str;
|
||||
byte *s, *d;
|
||||
const char *s;
|
||||
char *d;
|
||||
DrawPixelInfo tmp_dpi, *old_dpi;
|
||||
int x;
|
||||
byte buffer[256];
|
||||
char buffer[256];
|
||||
|
||||
if (ni->display_mode == 3) {
|
||||
str = _get_news_string_callback[ni->callback](ni);
|
||||
|
@ -2127,7 +2128,7 @@ static bool DrawScrollingStatusText(NewsItem *ni, int pos)
|
|||
} else if (*s == 0x0D) {
|
||||
d[0] = d[1] = d[2] = d[3] = ' ';
|
||||
d+=4;
|
||||
} else if (*s >= ' ' && (*s < 0x88 || *s >= 0x99)) {
|
||||
} else if ((byte)*s >= ' ' && ((byte)*s < 0x88 || (byte)*s >= 0x99)) {
|
||||
*d++ = *s;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -678,7 +678,7 @@ void GuiShowTooltips(StringID string_id)
|
|||
static void DrawStationCoverageText(const uint *accepts, int str_x, int str_y, uint mask)
|
||||
{
|
||||
int i;
|
||||
byte *b;
|
||||
char *b;
|
||||
|
||||
b = _userstring;
|
||||
b[0] = 0x81;
|
||||
|
@ -698,7 +698,7 @@ static void DrawStationCoverageText(const uint *accepts, int str_x, int str_y, u
|
|||
}
|
||||
}
|
||||
|
||||
if (b == (byte*)&_userstring[3]) {
|
||||
if (b == &_userstring[3]) {
|
||||
b[0] = 0x81;
|
||||
b[1] = STR_00D0_NOTHING;
|
||||
b[2] = STR_00D0_NOTHING >> 8;
|
||||
|
@ -779,7 +779,7 @@ void SetHScrollCount(Window *w, int num)
|
|||
* [IN]buf: string to be checked
|
||||
* [OUT]count: gets set to the count of characters
|
||||
* [OUT]width: gets set to the pixels width */
|
||||
static void GetCurrentStringSize(const byte *buf, int *count, int *width)
|
||||
static void GetCurrentStringSize(const char *buf, int *count, int *width)
|
||||
{
|
||||
*count = 0;
|
||||
*width = -1;
|
||||
|
@ -788,7 +788,7 @@ static void GetCurrentStringSize(const byte *buf, int *count, int *width)
|
|||
if (*++buf == 0)
|
||||
break;
|
||||
(*count)++;
|
||||
(*width) += _stringwidth_table[*buf - 32];
|
||||
(*width) += _stringwidth_table[(byte)*buf - 32];
|
||||
} while (1);
|
||||
}
|
||||
|
||||
|
|
16
network.c
16
network.c
|
@ -425,9 +425,9 @@ unsigned long NetworkResolveHost(const char *hostname)
|
|||
// connection_string will be re-terminated to seperate out the hostname, and player and port will
|
||||
// be set to the player and port strings given by the user, inside the memory area originally
|
||||
// occupied by connection_string.
|
||||
void ParseConnectionString(const byte **player, const byte **port, byte *connection_string)
|
||||
void ParseConnectionString(const char **player, const char **port, char *connection_string)
|
||||
{
|
||||
byte *p;
|
||||
char *p;
|
||||
for (p = connection_string; *p != '\0'; p++) {
|
||||
if (*p == '#') {
|
||||
*player = p + 1;
|
||||
|
@ -819,7 +819,7 @@ static void NetworkInitialize(void)
|
|||
// Query a server to fetch his game-info
|
||||
// If game_info is true, only the gameinfo is fetched,
|
||||
// else only the client_info is fetched
|
||||
NetworkGameList *NetworkQueryServer(const byte* host, unsigned short port, bool game_info)
|
||||
NetworkGameList *NetworkQueryServer(const char* host, unsigned short port, bool game_info)
|
||||
{
|
||||
if (!_network_available) return NULL;
|
||||
|
||||
|
@ -853,13 +853,13 @@ NetworkGameList *NetworkQueryServer(const byte* host, unsigned short port, bool
|
|||
/* Validates an address entered as a string and adds the server to
|
||||
* the list. If you use this functions, the games will be marked
|
||||
* as manually added. */
|
||||
void NetworkAddServer(const byte *b)
|
||||
void NetworkAddServer(const char *b)
|
||||
{
|
||||
if (*b != '\0') {
|
||||
NetworkGameList *item;
|
||||
const byte *port = NULL;
|
||||
const byte *player = NULL;
|
||||
byte host[NETWORK_HOSTNAME_LENGTH];
|
||||
const char *port = NULL;
|
||||
const char *player = NULL;
|
||||
char host[NETWORK_HOSTNAME_LENGTH];
|
||||
uint16 rport;
|
||||
|
||||
ttd_strlcpy(host, b, lengthof(host));
|
||||
|
@ -896,7 +896,7 @@ void NetworkRebuildHostList(void)
|
|||
}
|
||||
|
||||
// Used by clients, to connect to a server
|
||||
bool NetworkClientConnectGame(const byte* host, unsigned short port)
|
||||
bool NetworkClientConnectGame(const char* host, unsigned short port)
|
||||
{
|
||||
if (!_network_available) return false;
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ VARDEF uint8 _network_autoclean_protected; // Unprotect a company after X mont
|
|||
|
||||
VARDEF uint16 _network_restart_game_date; // If this year is reached, the server automaticly restarts
|
||||
|
||||
NetworkGameList *NetworkQueryServer(const byte* host, unsigned short port, bool game_info);
|
||||
NetworkGameList *NetworkQueryServer(const char* host, unsigned short port, bool game_info);
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
|
@ -211,9 +211,9 @@ VARDEF bool _network_server; // network-server is active
|
|||
VARDEF bool _network_dedicated; // are we a dedicated server?
|
||||
VARDEF byte _network_playas; // an id to play as..
|
||||
|
||||
void ParseConnectionString(const byte **player, const byte **port, byte *connection_string);
|
||||
void ParseConnectionString(const char **player, const char **port, char *connection_string);
|
||||
void NetworkUpdateClientInfo(uint16 client_index);
|
||||
void NetworkAddServer(const byte *b);
|
||||
void NetworkAddServer(const char *b);
|
||||
void NetworkRebuildHostList(void);
|
||||
void NetworkChangeCompanyPassword(const char *str);
|
||||
|
||||
|
|
|
@ -516,7 +516,7 @@ void NetworkUDPSearchGame(void)
|
|||
_network_udp_broadcast = 300; // Stay searching for 300 ticks
|
||||
}
|
||||
|
||||
NetworkGameList *NetworkUDPQueryServer(const byte* host, unsigned short port)
|
||||
NetworkGameList *NetworkUDPQueryServer(const char* host, unsigned short port)
|
||||
{
|
||||
struct sockaddr_in out_addr;
|
||||
Packet *p;
|
||||
|
|
|
@ -8,7 +8,7 @@ bool NetworkUDPListen(SOCKET *udp, uint32 host, uint16 port, bool broadcast);
|
|||
void NetworkUDPReceive(SOCKET udp);
|
||||
void NetworkUDPSearchGame(void);
|
||||
void NetworkUDPQueryMasterServer(void);
|
||||
NetworkGameList *NetworkUDPQueryServer(const byte* host, unsigned short port);
|
||||
NetworkGameList *NetworkUDPQueryServer(const char* host, unsigned short port);
|
||||
void NetworkUDPAdvertise(void);
|
||||
void NetworkUDPRemoveAdvertise(void);
|
||||
|
||||
|
|
19
newgrf.c
19
newgrf.c
|
@ -1509,6 +1509,7 @@ static void VehicleNewName(byte *buf, int len)
|
|||
uint8 lang;
|
||||
uint8 id;
|
||||
uint8 endid;
|
||||
const char* name;
|
||||
|
||||
check_length(len, 6, "VehicleNewName");
|
||||
feature = buf[1];
|
||||
|
@ -1530,17 +1531,19 @@ static void VehicleNewName(byte *buf, int len)
|
|||
return;
|
||||
}
|
||||
|
||||
buf += 5, len -= 5;
|
||||
name = (const char*)(buf + 5);
|
||||
len -= 5;
|
||||
for (; id < endid && len > 0; id++) {
|
||||
int ofs = strlen(buf) + 1;
|
||||
int ofs = strlen(name) + 1;
|
||||
|
||||
if (ofs < 128) {
|
||||
DEBUG(grf, 8) ("VehicleNewName: %d <- %s", id, buf);
|
||||
SetCustomEngineName(id, buf);
|
||||
DEBUG(grf, 8) ("VehicleNewName: %d <- %s", id, name);
|
||||
SetCustomEngineName(id, name);
|
||||
} else {
|
||||
DEBUG(grf, 7) ("VehicleNewName: Too long a name (%d)", ofs);
|
||||
}
|
||||
buf += ofs, len -= ofs;
|
||||
name += ofs;
|
||||
len -= ofs;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1712,14 +1715,14 @@ static void GRFInfo(byte *buf, int len)
|
|||
/* TODO: Check version. (We should have own versioning done somehow.) */
|
||||
uint8 version;
|
||||
uint32 grfid;
|
||||
char *name;
|
||||
char *info;
|
||||
const char *name;
|
||||
const char *info;
|
||||
|
||||
check_length(len, 9, "GRFInfo");
|
||||
version = buf[1];
|
||||
/* this is de facto big endian - grf_load_dword() unsuitable */
|
||||
grfid = buf[2] << 24 | buf[3] << 16 | buf[4] << 8 | buf[5];
|
||||
name = buf + 6;
|
||||
name = (const char*)(buf + 6);
|
||||
info = name + strlen(name) + 1;
|
||||
|
||||
_cur_grffile->grfid = grfid;
|
||||
|
|
12
news_gui.c
12
news_gui.c
|
@ -503,10 +503,11 @@ static byte getNews(byte i)
|
|||
}
|
||||
|
||||
// cut string after len pixels
|
||||
static void GetNewsString(NewsItem *ni, byte *buffer, uint max)
|
||||
static void GetNewsString(NewsItem *ni, char *buffer, uint max)
|
||||
{
|
||||
StringID str;
|
||||
byte *s, *d;
|
||||
const char *s;
|
||||
char *d;
|
||||
uint len = 0;
|
||||
|
||||
if (ni->display_mode == 3) {
|
||||
|
@ -537,8 +538,8 @@ static void GetNewsString(NewsItem *ni, byte *buffer, uint max)
|
|||
} else if (*s == '\r') {
|
||||
d[0] = d[1] = d[2] = d[3] = ' ';
|
||||
d += 4;
|
||||
} else if (*s >= ' ' && (*s < 0x88 || *s >= 0x99)) {
|
||||
len += _stringwidth_table[*s - 32];
|
||||
} else if ((byte)*s >= ' ' && ((byte)*s < 0x88 || (byte)*s >= 0x99)) {
|
||||
len += _stringwidth_table[(byte)*s - 32];
|
||||
*d++ = *s;
|
||||
}
|
||||
}
|
||||
|
@ -549,7 +550,6 @@ static void MessageHistoryWndProc(Window *w, WindowEvent *e)
|
|||
{
|
||||
switch (e->event) {
|
||||
case WE_PAINT: {
|
||||
byte buffer[256];
|
||||
int y = 19;
|
||||
byte p, show;
|
||||
NewsItem *ni;
|
||||
|
@ -560,6 +560,8 @@ static void MessageHistoryWndProc(Window *w, WindowEvent *e)
|
|||
show = min(_total_news, w->vscroll.cap);
|
||||
|
||||
for (p = w->vscroll.pos; p < w->vscroll.pos + show; p++) {
|
||||
char buffer[256];
|
||||
|
||||
// get news in correct order
|
||||
ni = &_news_items[getNews(p)];
|
||||
|
||||
|
|
|
@ -775,7 +775,7 @@ int8 SaveHighScoreValue(const Player *p)
|
|||
for (i = 0; i < lengthof(_highscore_table[0]); i++) {
|
||||
/* You are in the TOP5. Move all values one down and save us there */
|
||||
if (hs[i].score <= score) {
|
||||
byte buf[sizeof(hs[i].company)];
|
||||
char buf[sizeof(hs[i].company)];
|
||||
|
||||
// move all elements one down starting from the replaced one
|
||||
memmove(&hs[i + 1], &hs[i], sizeof(HighScore) * (lengthof(_highscore_table[0]) - i - 1));
|
||||
|
@ -820,7 +820,6 @@ int8 SaveHighScoreValueNetwork(void)
|
|||
|
||||
{
|
||||
HighScore *hs;
|
||||
byte buf[sizeof(_highscore_table[0]->company)];
|
||||
Player* const *p_cur = &player_sort[0];
|
||||
uint8 i;
|
||||
|
||||
|
@ -828,6 +827,8 @@ int8 SaveHighScoreValueNetwork(void)
|
|||
|
||||
/* Copy over Top5 companies */
|
||||
for (i = 0; i < lengthof(_highscore_table[LAST_HS_ITEM]) && i < (uint8)count; i++) {
|
||||
char buf[sizeof(_highscore_table[0]->company)];
|
||||
|
||||
hs = &_highscore_table[LAST_HS_ITEM][i];
|
||||
SetDParam(0, (*p_cur)->president_name_1);
|
||||
SetDParam(1, (*p_cur)->president_name_2);
|
||||
|
|
|
@ -158,7 +158,7 @@ static IniFile *ini_load(const char *filename)
|
|||
IniGroup *group = NULL;
|
||||
IniItem *item;
|
||||
|
||||
byte *comment = NULL;
|
||||
char *comment = NULL;
|
||||
uint comment_size = 0;
|
||||
uint comment_alloc = 0;
|
||||
|
||||
|
|
|
@ -786,7 +786,7 @@ static bool FileMD5(const MD5File file, bool warn)
|
|||
|
||||
#if !defined(WIN32)
|
||||
if (f == NULL) {
|
||||
byte *s;
|
||||
char *s;
|
||||
// make lower case and check again
|
||||
for (s = buf + strlen(_path.data_dir) - 1; *s != 0; s++)
|
||||
*s = tolower(*s);
|
||||
|
|
|
@ -317,8 +317,6 @@ static void DrawStationViewWindow(Window *w)
|
|||
int pos;
|
||||
StringID str;
|
||||
uint16 station_id;
|
||||
byte *b;
|
||||
|
||||
|
||||
station_id = (uint16)w->window_number;
|
||||
|
||||
|
@ -401,6 +399,8 @@ static void DrawStationViewWindow(Window *w)
|
|||
} while (pos > -5 && ++i != 12);
|
||||
|
||||
if (IsWindowOfPrototype(w, _station_view_widgets)) {
|
||||
char *b;
|
||||
|
||||
b = _userstring;
|
||||
b[0] = 0x81;
|
||||
b[1] = STR_000C_ACCEPTS;
|
||||
|
@ -408,7 +408,7 @@ static void DrawStationViewWindow(Window *w)
|
|||
b += 3;
|
||||
|
||||
for(i=0; i!=NUM_CARGO; i++) {
|
||||
if ((b - (byte *) &_userstring) + 5 > USERSTRING_LEN - 1)
|
||||
if ((b - _userstring) + 5 > USERSTRING_LEN - 1)
|
||||
break;
|
||||
if (st->goods[i].waiting_acceptance & 0x8000) {
|
||||
b[0] = 0x81;
|
||||
|
@ -418,7 +418,7 @@ static void DrawStationViewWindow(Window *w)
|
|||
}
|
||||
}
|
||||
|
||||
if (b == (byte*)&_userstring[3]) {
|
||||
if (b == &_userstring[3]) {
|
||||
b[0] = 0x81;
|
||||
b[1] = STR_00D0_NOTHING;
|
||||
b[2] = STR_00D0_NOTHING >> 8;
|
||||
|
|
4
ttd.c
4
ttd.c
|
@ -647,8 +647,8 @@ int ttd_main(int argc, char* argv[])
|
|||
#ifdef ENABLE_NETWORK
|
||||
if ((network) && (_network_available)) {
|
||||
if (network_conn != NULL) {
|
||||
const byte *port = NULL;
|
||||
const byte *player = NULL;
|
||||
const char *port = NULL;
|
||||
const char *player = NULL;
|
||||
uint16 rport;
|
||||
|
||||
rport = NETWORK_DEFAULT_PORT;
|
||||
|
|
|
@ -303,7 +303,7 @@ VARDEF uint _returned_refit_amount;
|
|||
// Deals with the type of the savegame, independent of extension
|
||||
typedef struct {
|
||||
int mode; // savegame/scenario type (old, new)
|
||||
byte name[MAX_PATH]; // name
|
||||
char name[MAX_PATH]; // name
|
||||
} SmallFiosItem;
|
||||
|
||||
// Used when switching from the intro menu.
|
||||
|
|
Loading…
Reference in New Issue