From c652b6bd009fecda1210f5d5de5f80e3b7aa66ef Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 5 Jul 2022 21:20:21 +0200 Subject: [PATCH] made flags in hyper.h consistent with langen.cpp --- hyper.h | 7 ++++--- language.cpp | 21 ++++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/hyper.h b/hyper.h index fd59e64b..d03cc36a 100644 --- a/hyper.h +++ b/hyper.h @@ -110,10 +110,11 @@ struct hr_shortest_path_exception { }; #define GEN_F 1 #define GEN_N 2 #define GEN_O 3 +#define GEN_BASE_MASK 7 -#define GENF_ELISION (4 << 0) -#define GENF_PLURALONLY (4 << 1) -#define GENF_PROPER (4 << 2) +#define GENF_ELISION (1 << 3) +#define GENF_PLURALONLY (1 << 4) +#define GENF_PROPER (1 << 5) // Add a message to the GUI. // If multiple messages appear with the same spamtype != 0, the older ones disappear quickly diff --git a/language.cpp b/language.cpp index c83d9ad2..5257a7f9 100644 --- a/language.cpp +++ b/language.cpp @@ -96,23 +96,26 @@ template const T* findInHashTableS(string s, const T *table, int size) #endif string choose2(int g, string a, string b) { - if((g & 0b11) == GEN_M || (g & 0b11) == GEN_O) return a; - if((g & 0b11) == GEN_F || (g & 0b11) == GEN_N) return b; + g &= GEN_BASE_MASK; + if(g == GEN_M || g == GEN_O) return a; + if(g == GEN_F || g == GEN_N) return b; return "?" + a; } string choose3(int g, string a, string b, string c) { - if((g & 0b11) == GEN_M || (g & 0b11) == GEN_O) return a; - if((g & 0b11) == GEN_F) return b; - if((g & 0b11) == GEN_N) return c; + g &= GEN_BASE_MASK; + if(g == GEN_M || g == GEN_O) return a; + if(g == GEN_F) return b; + if(g == GEN_N) return c; return "?" + a; } string choose4(int g, string a, string b, string c, string d) { - if((g & 0b11) == GEN_M) return a; - if((g & 0b11) == GEN_F) return b; - if((g & 0b11) == GEN_N) return c; - if((g & 0b11) == GEN_O) return d; + g &= GEN_BASE_MASK; + if(g == GEN_M) return a; + if(g == GEN_F) return b; + if(g == GEN_N) return c; + if(g == GEN_O) return d; return "?" + a; }