mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r21701) -Codechange: ConsoleColour = TextColour, so make it that way and remove some unneeded casts
This commit is contained in:
parent
1c2d56d314
commit
b25cf57542
|
@ -84,7 +84,7 @@ void IConsoleFree()
|
||||||
* @param colour_code the colour of the command. Red in case of errors, etc.
|
* @param colour_code the colour of the command. Red in case of errors, etc.
|
||||||
* @param string the message entered or output on the console (notice, error, etc.)
|
* @param string the message entered or output on the console (notice, error, etc.)
|
||||||
*/
|
*/
|
||||||
void IConsolePrint(ConsoleColour colour_code, const char *string)
|
void IConsolePrint(TextColour colour_code, const char *string)
|
||||||
{
|
{
|
||||||
assert(IsValidConsoleColour(colour_code));
|
assert(IsValidConsoleColour(colour_code));
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ void IConsolePrint(ConsoleColour colour_code, const char *string)
|
||||||
* by any other means. Uses printf() style format, for more information look
|
* by any other means. Uses printf() style format, for more information look
|
||||||
* at IConsolePrint()
|
* at IConsolePrint()
|
||||||
*/
|
*/
|
||||||
void CDECL IConsolePrintF(ConsoleColour colour_code, const char *format, ...)
|
void CDECL IConsolePrintF(TextColour colour_code, const char *format, ...)
|
||||||
{
|
{
|
||||||
assert(IsValidConsoleColour(colour_code));
|
assert(IsValidConsoleColour(colour_code));
|
||||||
|
|
||||||
|
|
|
@ -958,7 +958,7 @@ DEF_CONSOLE_CMD(ConEchoC)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 3) return false;
|
if (argc < 3) return false;
|
||||||
IConsolePrint((ConsoleColour)atoi(argv[1]), argv[2]);
|
IConsolePrint((TextColour)atoi(argv[1]), argv[2]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1626,7 +1626,7 @@ DEF_CONSOLE_CMD(ConContent)
|
||||||
static const char * const types[] = { "Base graphics", "NewGRF", "AI", "AI library", "Scenario", "Heightmap", "Base sound", "Base music" };
|
static const char * const types[] = { "Base graphics", "NewGRF", "AI", "AI library", "Scenario", "Heightmap", "Base sound", "Base music" };
|
||||||
assert_compile(lengthof(types) == CONTENT_TYPE_END - CONTENT_TYPE_BEGIN);
|
assert_compile(lengthof(types) == CONTENT_TYPE_END - CONTENT_TYPE_BEGIN);
|
||||||
static const char * const states[] = { "Not selected", "Selected", "Dep Selected", "Installed", "Unknown" };
|
static const char * const states[] = { "Not selected", "Selected", "Dep Selected", "Installed", "Unknown" };
|
||||||
static const ConsoleColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR };
|
static const TextColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR };
|
||||||
|
|
||||||
const ContentInfo *ci = *iter;
|
const ContentInfo *ci = *iter;
|
||||||
IConsolePrintF(state_to_colour[ci->state], "%d, %s, %s, %s", ci->id, types[ci->type - 1], states[ci->state], ci->name);
|
IConsolePrintF(state_to_colour[ci->state], "%d, %s, %s, %s", ci->id, types[ci->type - 1], states[ci->state], ci->name);
|
||||||
|
|
|
@ -23,8 +23,8 @@ void IConsoleFree();
|
||||||
void IConsoleClose();
|
void IConsoleClose();
|
||||||
|
|
||||||
/* console output */
|
/* console output */
|
||||||
void IConsolePrint(ConsoleColour colour_code, const char *string);
|
void IConsolePrint(TextColour colour_code, const char *string);
|
||||||
void CDECL IConsolePrintF(ConsoleColour colour_code, const char *format, ...) WARN_FORMAT(2, 3);
|
void CDECL IConsolePrintF(TextColour colour_code, const char *format, ...) WARN_FORMAT(2, 3);
|
||||||
void IConsoleDebug(const char *dbg, const char *string);
|
void IConsoleDebug(const char *dbg, const char *string);
|
||||||
void IConsoleWarning(const char *string);
|
void IConsoleWarning(const char *string);
|
||||||
void IConsoleError(const char *string);
|
void IConsoleError(const char *string);
|
||||||
|
|
|
@ -489,8 +489,8 @@ static void IConsoleHistoryNavigate(int direction)
|
||||||
* @param colour_code the colour of the command. Red in case of errors, etc.
|
* @param colour_code the colour of the command. Red in case of errors, etc.
|
||||||
* @param str the message entered or output on the console (notice, error, etc.)
|
* @param str the message entered or output on the console (notice, error, etc.)
|
||||||
*/
|
*/
|
||||||
void IConsoleGUIPrint(ConsoleColour colour_code, char *str)
|
void IConsoleGUIPrint(TextColour colour_code, char *str)
|
||||||
{
|
{
|
||||||
new IConsoleLine(str, (TextColour)colour_code);
|
new IConsoleLine(str, colour_code);
|
||||||
SetWindowDirty(WC_CONSOLE, 0);
|
SetWindowDirty(WC_CONSOLE, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ bool GetArgumentInteger(uint32 *value, const char *arg);
|
||||||
|
|
||||||
void IConsoleGUIInit();
|
void IConsoleGUIInit();
|
||||||
void IConsoleGUIFree();
|
void IConsoleGUIFree();
|
||||||
void IConsoleGUIPrint(ConsoleColour colour_code, char *string);
|
void IConsoleGUIPrint(TextColour colour_code, char *string);
|
||||||
char *RemoveUnderscores(char *name);
|
char *RemoveUnderscores(char *name);
|
||||||
|
|
||||||
#endif /* CONSOLE_INTERNAL_H */
|
#endif /* CONSOLE_INTERNAL_H */
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#ifndef CONSOLE_TYPE_H
|
#ifndef CONSOLE_TYPE_H
|
||||||
#define CONSOLE_TYPE_H
|
#define CONSOLE_TYPE_H
|
||||||
|
|
||||||
|
#include "gfx_type.h"
|
||||||
|
|
||||||
/** Modes of the in-game console. */
|
/** Modes of the in-game console. */
|
||||||
enum IConsoleModes {
|
enum IConsoleModes {
|
||||||
ICONSOLE_FULL, ///< In-game console is closed.
|
ICONSOLE_FULL, ///< In-game console is closed.
|
||||||
|
@ -19,16 +21,14 @@ enum IConsoleModes {
|
||||||
ICONSOLE_CLOSED ///< In-game console is opened, whole screen.
|
ICONSOLE_CLOSED ///< In-game console is opened, whole screen.
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Colours of the console messages. */
|
/* Colours of the console messages. */
|
||||||
enum ConsoleColour {
|
static const TextColour CC_DEFAULT = TC_SILVER; ///< Default colour of the console.
|
||||||
CC_DEFAULT = 1,
|
static const TextColour CC_ERROR = TC_RED; ///< Colour for error lines.
|
||||||
CC_ERROR = 3,
|
static const TextColour CC_WARNING = TC_LIGHT_BLUE; ///< Colour for warning lines.
|
||||||
CC_WARNING = 13,
|
static const TextColour CC_INFO = TC_YELLOW; ///< Colour for information lines.
|
||||||
CC_INFO = 8,
|
static const TextColour CC_DEBUG = TC_LIGHT_BROWN; ///< Colour for debug output.
|
||||||
CC_DEBUG = 5,
|
static const TextColour CC_COMMAND = TC_GOLD; ///< Colour for the console's commands.
|
||||||
CC_COMMAND = 2,
|
static const TextColour CC_WHITE = TC_WHITE; ///< White console lines for various things such as the welcome.
|
||||||
CC_WHITE = 12,
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline bool IsValidConsoleColour(uint c)
|
static inline bool IsValidConsoleColour(uint c)
|
||||||
{
|
{
|
||||||
|
|
|
@ -163,7 +163,7 @@ bool NetworkCompanyIsPassworded(CompanyID company_id)
|
||||||
/* This puts a text-message to the console, or in the future, the chat-box,
|
/* This puts a text-message to the console, or in the future, the chat-box,
|
||||||
* (to keep it all a bit more general)
|
* (to keep it all a bit more general)
|
||||||
* If 'self_send' is true, this is the client who is sending the message */
|
* If 'self_send' is true, this is the client who is sending the message */
|
||||||
void NetworkTextMessage(NetworkAction action, ConsoleColour colour, bool self_send, const char *name, const char *str, int64 data)
|
void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const char *name, const char *str, int64 data)
|
||||||
{
|
{
|
||||||
StringID strid;
|
StringID strid;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
|
|
@ -783,7 +783,7 @@ void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_i
|
||||||
* @param colour_code The colour of the string.
|
* @param colour_code The colour of the string.
|
||||||
* @param string The string to show.
|
* @param string The string to show.
|
||||||
*/
|
*/
|
||||||
void NetworkServerSendAdminRcon(AdminIndex admin_index, ConsoleColour colour_code, const char *string)
|
void NetworkServerSendAdminRcon(AdminIndex admin_index, TextColour colour_code, const char *string)
|
||||||
{
|
{
|
||||||
ServerNetworkAdminSocketHandler::Get(admin_index)->SendRcon(colour_code, string);
|
ServerNetworkAdminSocketHandler::Get(admin_index)->SendRcon(colour_code, string);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bc
|
||||||
|
|
||||||
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const char *msg, int64 data = 0, bool from_admin = false);
|
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const char *msg, int64 data = 0, bool from_admin = false);
|
||||||
void NetworkAdminUpdate(AdminUpdateFrequency freq);
|
void NetworkAdminUpdate(AdminUpdateFrequency freq);
|
||||||
void NetworkServerSendAdminRcon(AdminIndex admin_index, ConsoleColour colour_code, const char *string);
|
void NetworkServerSendAdminRcon(AdminIndex admin_index, TextColour colour_code, const char *string);
|
||||||
void NetworkAdminConsole(const char *origin, const char *string);
|
void NetworkAdminConsole(const char *origin, const char *string);
|
||||||
void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket *cp);
|
void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket *cp);
|
||||||
|
|
||||||
|
|
|
@ -981,7 +981,7 @@ DEF_GAME_RECEIVE_COMMAND(Client, PACKET_SERVER_CHAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ci != NULL) {
|
if (ci != NULL) {
|
||||||
NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColour(ci->client_playas), self_send, name, msg, data);
|
NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), self_send, name, msg, data);
|
||||||
}
|
}
|
||||||
return NETWORK_RECV_STATUS_OKAY;
|
return NETWORK_RECV_STATUS_OKAY;
|
||||||
}
|
}
|
||||||
|
@ -1069,13 +1069,13 @@ DEF_GAME_RECEIVE_COMMAND(Client, PACKET_SERVER_RCON)
|
||||||
{
|
{
|
||||||
if (this->status < STATUS_AUTHORIZED) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
|
if (this->status < STATUS_AUTHORIZED) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
|
||||||
|
|
||||||
uint colour_code = p->Recv_uint16();
|
TextColour colour_code = (TextColour)p->Recv_uint16();
|
||||||
if (!IsValidConsoleColour(colour_code)) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
|
if (!IsValidConsoleColour(colour_code)) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
|
||||||
|
|
||||||
char rcon_out[NETWORK_RCONCOMMAND_LENGTH];
|
char rcon_out[NETWORK_RCONCOMMAND_LENGTH];
|
||||||
p->Recv_string(rcon_out, sizeof(rcon_out));
|
p->Recv_string(rcon_out, sizeof(rcon_out));
|
||||||
|
|
||||||
IConsolePrint((ConsoleColour)colour_code, rcon_out);
|
IConsolePrint(colour_code, rcon_out);
|
||||||
|
|
||||||
return NETWORK_RECV_STATUS_OKAY;
|
return NETWORK_RECV_STATUS_OKAY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ NetworkClientInfo *NetworkFindClientInfoFromClientID(ClientID client_id);
|
||||||
const char *GetClientIP(NetworkClientInfo *ci);
|
const char *GetClientIP(NetworkClientInfo *ci);
|
||||||
|
|
||||||
void NetworkServerDoMove(ClientID client_id, CompanyID company_id);
|
void NetworkServerDoMove(ClientID client_id, CompanyID company_id);
|
||||||
void NetworkServerSendRcon(ClientID client_id, ConsoleColour colour_code, const char *string);
|
void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const char *string);
|
||||||
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0, bool from_admin = false);
|
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0, bool from_admin = false);
|
||||||
|
|
||||||
void NetworkServerKickClient(ClientID client_id);
|
void NetworkServerKickClient(ClientID client_id);
|
||||||
|
|
|
@ -163,7 +163,7 @@ void NetworkSyncCommandQueue(NetworkClientSocket *cs);
|
||||||
|
|
||||||
/* from network.c */
|
/* from network.c */
|
||||||
void NetworkError(StringID error_string);
|
void NetworkError(StringID error_string);
|
||||||
void NetworkTextMessage(NetworkAction action, ConsoleColour colour, bool self_send, const char *name, const char *str = "", int64 data = 0);
|
void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const char *name, const char *str = "", int64 data = 0);
|
||||||
uint NetworkCalculateLag(const NetworkClientSocket *cs);
|
uint NetworkCalculateLag(const NetworkClientSocket *cs);
|
||||||
NetworkClientSocket *NetworkFindClientStateFromClientID(ClientID client_id);
|
NetworkClientSocket *NetworkFindClientStateFromClientID(ClientID client_id);
|
||||||
StringID GetNetworkErrorMsg(NetworkErrorCode err);
|
StringID GetNetworkErrorMsg(NetworkErrorCode err);
|
||||||
|
|
|
@ -1142,7 +1142,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
||||||
ci = NetworkFindClientInfoFromClientID(from_id);
|
ci = NetworkFindClientInfoFromClientID(from_id);
|
||||||
/* Display the text locally, and that is it */
|
/* Display the text locally, and that is it */
|
||||||
if (ci != NULL) {
|
if (ci != NULL) {
|
||||||
NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColour(ci->client_playas), false, ci->client_name, msg, data);
|
NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), false, ci->client_name, msg, data);
|
||||||
|
|
||||||
if (_settings_client.network.server_admin_chat) {
|
if (_settings_client.network.server_admin_chat) {
|
||||||
NetworkAdminChat(action, desttype, from_id, msg, data, from_admin);
|
NetworkAdminChat(action, desttype, from_id, msg, data, from_admin);
|
||||||
|
@ -1164,7 +1164,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
||||||
ci = NetworkFindClientInfoFromClientID(from_id);
|
ci = NetworkFindClientInfoFromClientID(from_id);
|
||||||
ci_to = NetworkFindClientInfoFromClientID((ClientID)dest);
|
ci_to = NetworkFindClientInfoFromClientID((ClientID)dest);
|
||||||
if (ci != NULL && ci_to != NULL) {
|
if (ci != NULL && ci_to != NULL) {
|
||||||
NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColour(ci->client_playas), true, ci_to->client_name, msg, data);
|
NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), true, ci_to->client_name, msg, data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FOR_ALL_CLIENT_SOCKETS(cs) {
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
||||||
|
@ -1198,7 +1198,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
||||||
ci = NetworkFindClientInfoFromClientID(from_id);
|
ci = NetworkFindClientInfoFromClientID(from_id);
|
||||||
ci_own = NetworkFindClientInfoFromClientID(CLIENT_ID_SERVER);
|
ci_own = NetworkFindClientInfoFromClientID(CLIENT_ID_SERVER);
|
||||||
if (ci != NULL && ci_own != NULL && ci_own->client_playas == dest) {
|
if (ci != NULL && ci_own != NULL && ci_own->client_playas == dest) {
|
||||||
NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColour(ci->client_playas), false, ci->client_name, msg, data);
|
NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), false, ci->client_name, msg, data);
|
||||||
if (from_id == CLIENT_ID_SERVER) show_local = false;
|
if (from_id == CLIENT_ID_SERVER) show_local = false;
|
||||||
ci_to = ci_own;
|
ci_to = ci_own;
|
||||||
}
|
}
|
||||||
|
@ -1213,7 +1213,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
||||||
StringID str = Company::IsValidID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
|
StringID str = Company::IsValidID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
|
||||||
SetDParam(0, ci_to->client_playas);
|
SetDParam(0, ci_to->client_playas);
|
||||||
GetString(name, str, lastof(name));
|
GetString(name, str, lastof(name));
|
||||||
NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColour(ci_own->client_playas), true, name, msg, data);
|
NetworkTextMessage(action, GetDrawStringCompanyColour(ci_own->client_playas), true, name, msg, data);
|
||||||
} else {
|
} else {
|
||||||
FOR_ALL_CLIENT_SOCKETS(cs) {
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
||||||
if (cs->client_id == from_id) {
|
if (cs->client_id == from_id) {
|
||||||
|
@ -1236,7 +1236,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
||||||
|
|
||||||
ci = NetworkFindClientInfoFromClientID(from_id);
|
ci = NetworkFindClientInfoFromClientID(from_id);
|
||||||
if (ci != NULL) {
|
if (ci != NULL) {
|
||||||
NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColour(ci->client_playas), false, ci->client_name, msg, data);
|
NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), false, ci->client_name, msg, data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1846,7 +1846,7 @@ void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
|
||||||
NetworkServerSendChat(action, DESTTYPE_BROADCAST, 0, "", client_id, company_id + 1);
|
NetworkServerSendChat(action, DESTTYPE_BROADCAST, 0, "", client_id, company_id + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkServerSendRcon(ClientID client_id, ConsoleColour colour_code, const char *string)
|
void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const char *string)
|
||||||
{
|
{
|
||||||
NetworkFindClientStateFromClientID(client_id)->SendRConResult(colour_code, string);
|
NetworkFindClientStateFromClientID(client_id)->SendRConResult(colour_code, string);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue