Codechange: Use null pointer literal instead of the NULL macro

This commit is contained in:
Henry Wilson
2019-04-10 22:07:06 +01:00
committed by Michael Lutz
parent 3b4f224c0b
commit 7c8e7c6b6e
463 changed files with 5674 additions and 5674 deletions

View File

@@ -57,7 +57,7 @@ bool _network_available; ///< is network mode available?
bool _network_dedicated; ///< are we a dedicated server?
bool _is_network_server; ///< Does this client wants to be a network-server?
NetworkServerGameInfo _network_game_info; ///< Information about our game.
NetworkCompanyState *_network_company_states = NULL; ///< Statistics about some companies.
NetworkCompanyState *_network_company_states = nullptr; ///< Statistics about some companies.
ClientID _network_own_client_id; ///< Our client identifier.
ClientID _redirect_console_to_client; ///< If not invalid, redirect the console output to a client.
bool _network_need_advertise; ///< Whether we need to advertise.
@@ -119,7 +119,7 @@ NetworkClientInfo::~NetworkClientInfo()
/**
* Return the CI given it's client-identifier
* @param client_id the ClientID to search for
* @return return a pointer to the corresponding NetworkClientInfo struct or NULL when not found
* @return return a pointer to the corresponding NetworkClientInfo struct or nullptr when not found
*/
/* static */ NetworkClientInfo *NetworkClientInfo::GetByClientID(ClientID client_id)
{
@@ -129,13 +129,13 @@ NetworkClientInfo::~NetworkClientInfo()
if (ci->client_id == client_id) return ci;
}
return NULL;
return nullptr;
}
/**
* Return the client state given it's client-identifier
* @param client_id the ClientID to search for
* @return return a pointer to the corresponding NetworkClientSocket struct or NULL when not found
* @return return a pointer to the corresponding NetworkClientSocket struct or nullptr when not found
*/
/* static */ ServerNetworkGameSocketHandler *ServerNetworkGameSocketHandler::GetByClientID(ClientID client_id)
{
@@ -145,7 +145,7 @@ NetworkClientInfo::~NetworkClientInfo()
if (cs->client_id == client_id) return cs;
}
return NULL;
return nullptr;
}
byte NetworkSpectatorCount()
@@ -378,7 +378,7 @@ void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode)
char buffer[DRAW_STRING_BUFFER];
GetString(buffer, str, lastof(buffer));
NetworkTextMessage(NETWORK_ACTION_SERVER_MESSAGE, CC_DEFAULT, false, NULL, buffer);
NetworkTextMessage(NETWORK_ACTION_SERVER_MESSAGE, CC_DEFAULT, false, nullptr, buffer);
break;
}
@@ -541,7 +541,7 @@ void NetworkClose(bool close_admins)
}
ServerNetworkGameSocketHandler::CloseListeners();
ServerNetworkAdminSocketHandler::CloseListeners();
} else if (MyClient::my_client != NULL) {
} else if (MyClient::my_client != nullptr) {
MyClient::SendQuit();
MyClient::my_client->CloseConnection(NETWORK_RECV_STATUS_CONN_LOST);
}
@@ -554,7 +554,7 @@ void NetworkClose(bool close_admins)
NetworkFreeLocalCommandQueue();
free(_network_company_states);
_network_company_states = NULL;
_network_company_states = nullptr;
InitializeNetworkPools(close_admins);
}
@@ -608,8 +608,8 @@ void NetworkTCPQueryServer(NetworkAddress address)
void NetworkAddServer(const char *b)
{
if (*b != '\0') {
const char *port = NULL;
const char *company = NULL;
const char *port = nullptr;
const char *company = nullptr;
char host[NETWORK_HOSTNAME_LENGTH];
uint16 rport;
@@ -619,7 +619,7 @@ void NetworkAddServer(const char *b)
rport = NETWORK_DEFAULT_PORT;
ParseConnectionString(&company, &port, host);
if (port != NULL) rport = atoi(port);
if (port != nullptr) rport = atoi(port);
NetworkUDPQueryServer(NetworkAddress(host, rport), true);
}
@@ -649,7 +649,7 @@ void NetworkRebuildHostList()
{
_network_host_list.clear();
for (NetworkGameList *item = _network_game_list; item != NULL; item = item->next) {
for (NetworkGameList *item = _network_game_list; item != nullptr; item = item->next) {
if (item->manually) _network_host_list.emplace_back(item->address.GetAddressAsString(false));
}
}
@@ -884,21 +884,21 @@ void NetworkGameLoop()
static FILE *f = FioFOpenFile("commands.log", "rb", SAVE_DIR);
static Date next_date = 0;
static uint32 next_date_fract;
static CommandPacket *cp = NULL;
static CommandPacket *cp = nullptr;
static bool check_sync_state = false;
static uint32 sync_state[2];
if (f == NULL && next_date == 0) {
if (f == nullptr && next_date == 0) {
DEBUG(net, 0, "Cannot open commands.log");
next_date = 1;
}
while (f != NULL && !feof(f)) {
while (f != nullptr && !feof(f)) {
if (_date == next_date && _date_fract == next_date_fract) {
if (cp != NULL) {
NetworkSendCommand(cp->tile, cp->p1, cp->p2, cp->cmd & ~CMD_FLAGS_MASK, NULL, cp->text, cp->company);
if (cp != nullptr) {
NetworkSendCommand(cp->tile, cp->p1, cp->p2, cp->cmd & ~CMD_FLAGS_MASK, nullptr, cp->text, cp->company);
DEBUG(net, 0, "injecting: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text, GetCommandName(cp->cmd));
free(cp);
cp = NULL;
cp = nullptr;
}
if (check_sync_state) {
if (sync_state[0] == _random.state[0] && sync_state[1] == _random.state[1]) {
@@ -912,16 +912,16 @@ void NetworkGameLoop()
}
}
if (cp != NULL || check_sync_state) break;
if (cp != nullptr || check_sync_state) break;
char buff[4096];
if (fgets(buff, lengthof(buff), f) == NULL) break;
if (fgets(buff, lengthof(buff), f) == nullptr) break;
char *p = buff;
/* Ignore the "[date time] " part of the message */
if (*p == '[') {
p = strchr(p, ']');
if (p == NULL) break;
if (p == nullptr) break;
p += 2;
}
@@ -968,10 +968,10 @@ void NetworkGameLoop()
NOT_REACHED();
}
}
if (f != NULL && feof(f)) {
if (f != nullptr && feof(f)) {
DEBUG(net, 0, "End of commands.log");
fclose(f);
f = NULL;
f = nullptr;
}
#endif /* DEBUG_DUMP_COMMANDS */
if (_frame_counter >= _frame_counter_max) {