mirror of https://github.com/OpenTTD/OpenTTD
Codechange: [Network] Use std::string to send the client name and rcon commands
parent
fd95736bac
commit
806f78aa04
|
@ -491,7 +491,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendSetPassword(const std::str
|
||||||
* Tell the server that we like to change the name of the client.
|
* Tell the server that we like to change the name of the client.
|
||||||
* @param name The new name.
|
* @param name The new name.
|
||||||
*/
|
*/
|
||||||
NetworkRecvStatus ClientNetworkGameSocketHandler::SendSetName(const char *name)
|
NetworkRecvStatus ClientNetworkGameSocketHandler::SendSetName(const std::string &name)
|
||||||
{
|
{
|
||||||
Packet *p = new Packet(PACKET_CLIENT_SET_NAME);
|
Packet *p = new Packet(PACKET_CLIENT_SET_NAME);
|
||||||
|
|
||||||
|
@ -516,7 +516,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendQuit()
|
||||||
* @param pass The password for the remote command.
|
* @param pass The password for the remote command.
|
||||||
* @param command The actual command.
|
* @param command The actual command.
|
||||||
*/
|
*/
|
||||||
NetworkRecvStatus ClientNetworkGameSocketHandler::SendRCon(const std::string &pass, const char *command)
|
NetworkRecvStatus ClientNetworkGameSocketHandler::SendRCon(const std::string &pass, const std::string &command)
|
||||||
{
|
{
|
||||||
Packet *p = new Packet(PACKET_CLIENT_RCON);
|
Packet *p = new Packet(PACKET_CLIENT_RCON);
|
||||||
p->Send_string(pass);
|
p->Send_string(pass);
|
||||||
|
@ -1258,7 +1258,7 @@ void NetworkClient_Connected()
|
||||||
* @param password The password.
|
* @param password The password.
|
||||||
* @param command The command to execute.
|
* @param command The command to execute.
|
||||||
*/
|
*/
|
||||||
void NetworkClientSendRcon(const std::string &password, const char *command)
|
void NetworkClientSendRcon(const std::string &password, const std::string &command)
|
||||||
{
|
{
|
||||||
MyClient::SendRCon(password, command);
|
MyClient::SendRCon(password, command);
|
||||||
}
|
}
|
||||||
|
@ -1355,7 +1355,7 @@ void NetworkUpdateClientName(const std::string &client_name)
|
||||||
/* Don't change the name if it is the same as the old name */
|
/* Don't change the name if it is the same as the old name */
|
||||||
if (client_name.compare(ci->client_name) != 0) {
|
if (client_name.compare(ci->client_name) != 0) {
|
||||||
if (!_network_server) {
|
if (!_network_server) {
|
||||||
MyClient::SendSetName(client_name.c_str());
|
MyClient::SendSetName(client_name);
|
||||||
} else {
|
} else {
|
||||||
/* Copy to a temporary buffer so no #n gets added after our name in the settings when there are duplicate names. */
|
/* Copy to a temporary buffer so no #n gets added after our name in the settings when there are duplicate names. */
|
||||||
char temporary_name[NETWORK_CLIENT_NAME_LENGTH];
|
char temporary_name[NETWORK_CLIENT_NAME_LENGTH];
|
||||||
|
|
|
@ -95,8 +95,8 @@ public:
|
||||||
|
|
||||||
static NetworkRecvStatus SendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data);
|
static NetworkRecvStatus SendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data);
|
||||||
static NetworkRecvStatus SendSetPassword(const std::string &password);
|
static NetworkRecvStatus SendSetPassword(const std::string &password);
|
||||||
static NetworkRecvStatus SendSetName(const char *name);
|
static NetworkRecvStatus SendSetName(const std::string &name);
|
||||||
static NetworkRecvStatus SendRCon(const std::string &password, const char *command);
|
static NetworkRecvStatus SendRCon(const std::string &password, const std::string &command);
|
||||||
static NetworkRecvStatus SendMove(CompanyID company, const std::string &password);
|
static NetworkRecvStatus SendMove(CompanyID company, const std::string &password);
|
||||||
|
|
||||||
static bool IsConnected();
|
static bool IsConnected();
|
||||||
|
|
|
@ -55,7 +55,7 @@ void NetworkClientsToSpectators(CompanyID cid);
|
||||||
bool NetworkClientConnectGame(const std::string &connection_string, CompanyID default_company, const std::string &join_server_password = "", const std::string &join_company_password = "");
|
bool NetworkClientConnectGame(const std::string &connection_string, CompanyID default_company, const std::string &join_server_password = "", const std::string &join_company_password = "");
|
||||||
void NetworkClientJoinGame();
|
void NetworkClientJoinGame();
|
||||||
void NetworkClientRequestMove(CompanyID company, const std::string &pass = "");
|
void NetworkClientRequestMove(CompanyID company, const std::string &pass = "");
|
||||||
void NetworkClientSendRcon(const std::string &password, const char *command);
|
void NetworkClientSendRcon(const std::string &password, const std::string &command);
|
||||||
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data = 0);
|
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data = 0);
|
||||||
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
|
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
|
||||||
bool NetworkCompanyIsPassworded(CompanyID company_id);
|
bool NetworkCompanyIsPassworded(CompanyID company_id);
|
||||||
|
|
Loading…
Reference in New Issue