mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Modernize various files (src/k*, src/l*)
* range-based for loops * code style * C++ headers instead of C headers * Default operators
This commit is contained in:
parent
1d086aee7c
commit
951f1201c4
6 changed files with 25 additions and 32 deletions
|
@ -246,9 +246,9 @@ static const struct table_key table[] = {
|
|||
|
||||
struct table_key lookup_keyname(const char *name)
|
||||
{
|
||||
for (u16 i = 0; i < ARRLEN(table); i++) {
|
||||
if (strcmp(table[i].Name, name) == 0)
|
||||
return table[i];
|
||||
for (const auto &table_key : table) {
|
||||
if (strcmp(table_key.Name, name) == 0)
|
||||
return table_key;
|
||||
}
|
||||
|
||||
throw UnknownKeycode(name);
|
||||
|
@ -256,9 +256,9 @@ struct table_key lookup_keyname(const char *name)
|
|||
|
||||
struct table_key lookup_keykey(irr::EKEY_CODE key)
|
||||
{
|
||||
for (u16 i = 0; i < ARRLEN(table); i++) {
|
||||
if (table[i].Key == key)
|
||||
return table[i];
|
||||
for (const auto &table_key : table) {
|
||||
if (table_key.Key == key)
|
||||
return table_key;
|
||||
}
|
||||
|
||||
std::ostringstream os;
|
||||
|
@ -268,9 +268,9 @@ struct table_key lookup_keykey(irr::EKEY_CODE key)
|
|||
|
||||
struct table_key lookup_keychar(wchar_t Char)
|
||||
{
|
||||
for (u16 i = 0; i < ARRLEN(table); i++) {
|
||||
if (table[i].Char == Char)
|
||||
return table[i];
|
||||
for (const auto &table_key : table) {
|
||||
if (table_key.Char == Char)
|
||||
return table_key;
|
||||
}
|
||||
|
||||
std::ostringstream os;
|
||||
|
@ -285,7 +285,9 @@ KeyPress::KeyPress(const char *name)
|
|||
Char = L'\0';
|
||||
m_name = "";
|
||||
return;
|
||||
} else if (strlen(name) <= 4) {
|
||||
}
|
||||
|
||||
if (strlen(name) <= 4) {
|
||||
// Lookup by resulting character
|
||||
int chars_read = mbtowc(&Char, name, 1);
|
||||
FATAL_ERROR_IF(chars_read != 1, "Unexpected multibyte character");
|
||||
|
@ -339,7 +341,7 @@ const char *KeyPress::sym() const
|
|||
|
||||
const char *KeyPress::name() const
|
||||
{
|
||||
if (m_name == "")
|
||||
if (m_name.empty())
|
||||
return "";
|
||||
const char *ret;
|
||||
if (valid_kcode(Key))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue