summaryrefslogtreecommitdiff
path: root/src/hotkeys.cpp
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2019-04-10 22:07:06 +0100
committerMichael Lutz <michi@icosahedron.de>2019-04-10 23:22:20 +0200
commit7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch)
tree99f134b7e66367cf11e10bc5061896eab4a3264f /src/hotkeys.cpp
parent3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff)
downloadopenttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/hotkeys.cpp')
-rw-r--r--src/hotkeys.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp
index 3093a8229..38ac4325d 100644
--- a/src/hotkeys.cpp
+++ b/src/hotkeys.cpp
@@ -24,7 +24,7 @@ char *_hotkeys_file;
* List of all HotkeyLists.
* This is a pointer to ensure initialisation order with the various static HotkeyList instances.
*/
-static std::vector<HotkeyList*> *_hotkey_lists = NULL;
+static std::vector<HotkeyList*> *_hotkey_lists = nullptr;
/** String representation of a keycode */
struct KeycodeNames {
@@ -254,7 +254,7 @@ void Hotkey::AddKeycode(uint16 keycode)
HotkeyList::HotkeyList(const char *ini_group, Hotkey *items, GlobalHotkeyHandlerFunc global_hotkey_handler) :
global_hotkey_handler(global_hotkey_handler), ini_group(ini_group), items(items)
{
- if (_hotkey_lists == NULL) _hotkey_lists = new std::vector<HotkeyList*>();
+ if (_hotkey_lists == nullptr) _hotkey_lists = new std::vector<HotkeyList*>();
_hotkey_lists->push_back(this);
}
@@ -270,11 +270,11 @@ HotkeyList::~HotkeyList()
void HotkeyList::Load(IniFile *ini)
{
IniGroup *group = ini->GetGroup(this->ini_group);
- for (Hotkey *hotkey = this->items; hotkey->name != NULL; ++hotkey) {
+ for (Hotkey *hotkey = this->items; hotkey->name != nullptr; ++hotkey) {
IniItem *item = group->GetItem(hotkey->name, false);
- if (item != NULL) {
+ if (item != nullptr) {
hotkey->keycodes.clear();
- if (item->value != NULL) ParseHotkeys(hotkey, item->value);
+ if (item->value != nullptr) ParseHotkeys(hotkey, item->value);
}
}
}
@@ -286,7 +286,7 @@ void HotkeyList::Load(IniFile *ini)
void HotkeyList::Save(IniFile *ini) const
{
IniGroup *group = ini->GetGroup(this->ini_group);
- for (const Hotkey *hotkey = this->items; hotkey->name != NULL; ++hotkey) {
+ for (const Hotkey *hotkey = this->items; hotkey->name != nullptr; ++hotkey) {
IniItem *item = group->GetItem(hotkey->name, true);
item->SetValue(SaveKeycodes(hotkey));
}
@@ -300,7 +300,7 @@ void HotkeyList::Save(IniFile *ini) const
*/
int HotkeyList::CheckMatch(uint16 keycode, bool global_only) const
{
- for (const Hotkey *list = this->items; list->name != NULL; ++list) {
+ for (const Hotkey *list = this->items; list->name != nullptr; ++list) {
auto begin = list->keycodes.begin();
auto end = list->keycodes.end();
if (std::find(begin, end, keycode | WKC_GLOBAL_HOTKEY) != end || (!global_only && std::find(begin, end, keycode) != end)) {
@@ -344,7 +344,7 @@ void SaveHotkeysToConfig()
void HandleGlobalHotkeys(WChar key, uint16 keycode)
{
for (HotkeyList *list : *_hotkey_lists) {
- if (list->global_hotkey_handler == NULL) continue;
+ if (list->global_hotkey_handler == nullptr) continue;
int hotkey = list->CheckMatch(keycode, true);
if (hotkey >= 0 && (list->global_hotkey_handler(hotkey) == ES_HANDLED)) return;