From 10d98c67c0147e9b659da2df6e8965e78698990d Mon Sep 17 00:00:00 2001 From: Alison Watson Date: Fri, 20 Sep 2019 19:56:41 -0400 Subject: [PATCH] add automatic pronoun detection for FTE_STRINGS engines --- source/client.qc | 75 +++++++++++++++++++++++++++++------------------- source/defs.qc | 12 ++++++++ source/world.qc | 5 ++-- 3 files changed, 59 insertions(+), 33 deletions(-) diff --git a/source/client.qc b/source/client.qc index e180077..4a31d1e 100644 --- a/source/client.qc +++ b/source/client.qc @@ -1,5 +1,35 @@ // client.qc: player-adjacent functions +string(float pro) pronoun_subject = { + switch(pro) { + case PRO_NONE: return "none"; + case PRO_FAE: return "fae"; + case PRO_HE: return "he"; + case PRO_IT: return "it"; + case PRO_SHE: return "she"; + case PRO_THEY: return "they"; + case PRO_XEY: return "xey"; + case PRO_ZE_H: return "ze"; + case PRO_ZE_Z: return "ze"; + default: return "unknown"; + } +}; + +string(float pro) pronoun_possessive = { + switch(pro) { + case PRO_NONE: return "none"; + case PRO_FAE: return "faer"; + case PRO_HE: return "his"; + case PRO_IT: return "its"; + case PRO_SHE: return "her"; + case PRO_THEY: return "their"; + case PRO_XEY: return "xyr"; + case PRO_ZE_H: return "hir"; + case PRO_ZE_Z: return "zir"; + default: return "unknown"; + } +}; + /* ============================================================================= @@ -53,6 +83,8 @@ void() SetNewParms = { }; void() DecodeLevelParms = { + float ofs, ofs2, pro; + if(serverflags) { if(world.model == "maps/start.bsp") { SetNewParms(); // take away all stuff on starting new episode @@ -69,6 +101,19 @@ void() DecodeLevelParms = { self.weapon = parm8; self.armortype = parm9 * 0.01; self.pronoun = parm10; + + if(ext_strings) { + ofs = strstrofs(self.netname, "(", 0); + if(ofs != -1) { + for(pro = PRO_NONE; pro < PRO_MAX; pro++) { + ofs2 = strstrofs(self.netname, pronoun_possessive(pro), ofs); + if(ofs2 == ofs + 1 && strstrofs(self.netname, ")", ofs) != -1) { + self.pronoun = pro; + break; + } + } + } + } }; /* @@ -1105,36 +1150,6 @@ void() cheat_quad = { self.items = self.items | IT_QUAD; }; -string(float pro) pronoun_subject = { - switch(pro) { - case PRO_NONE: return "none"; - case PRO_FAE: return "fae"; - case PRO_HE: return "he"; - case PRO_IT: return "it"; - case PRO_SHE: return "she"; - case PRO_THEY: return "they"; - case PRO_XEY: return "xey"; - case PRO_ZE_H: return "ze"; - case PRO_ZE_Z: return "ze"; - default: return "unknown"; - } -}; - -string(float pro) pronoun_possessive = { - switch(pro) { - case PRO_NONE: return "none"; - case PRO_FAE: return "faer"; - case PRO_HE: return "his"; - case PRO_IT: return "its"; - case PRO_SHE: return "her"; - case PRO_THEY: return "their"; - case PRO_XEY: return "xyr"; - case PRO_ZE_H: return "hir"; - case PRO_ZE_Z: return "zir"; - default: return "unknown"; - } -}; - void(float pro) change_pronoun = { pro = minmax(pro, PRO_NONE, PRO_MAX - 1); diff --git a/source/defs.qc b/source/defs.qc index 5d8070b..b9c4950 100644 --- a/source/defs.qc +++ b/source/defs.qc @@ -271,6 +271,17 @@ void(entity e) setspawnparms = #78; float(string s) checkextension = #99; +float(string str, string sub, float startpos) strstrofs = #221; +float(string str, float ofs) str2chr = #222; +string(float... c) chr2str = #223; +string(float ccase, float calpha, float cnum, string... s) strconv = #224; +string(float chars, string... s) strpad = #225; +string(string info, string key, string... value) infoadd = #226; +string(string info, string key) infoget = #227; +float(string s1, string s2, float len) strncmp = #228; +float(string s1, string s2) strcasecmp = #229; +float(string s1, string s2, float len) strncasecmp = #230; + // constants -----------------------------------------------------------------| const vector VEC_ORIGIN = '0 0 0'; @@ -644,6 +655,7 @@ float player_respawned; float all_players_are_dead; float ext_con_set; +float ext_strings; // fields --------------------------------------------------------------------| diff --git a/source/world.qc b/source/world.qc index ac9ae2d..d75d150 100644 --- a/source/world.qc +++ b/source/world.qc @@ -18,9 +18,8 @@ void() worldspawn = { InitBodyQue(); if(cvar("pr_checkextension")) { - if(checkextension("DP_CON_SET")) { - ext_con_set = TRUE; - } + ext_con_set = checkextension("DP_CON_SET"); + ext_strings = checkextension("FTE_STRINGS"); } // custom map attributes