From cbf9ebbba3e3e76b8956519bbb1e195217eb64e1 Mon Sep 17 00:00:00 2001 From: Dino <8dino2@gmail.com> Date: Sun, 3 Sep 2023 09:13:13 -0400 Subject: [PATCH] Added gender stuff --- actionlite/g_local.h | 11 +++++++++++ actionlite/p_client.cpp | 42 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/actionlite/g_local.h b/actionlite/g_local.h index f14f24a..083fef4 100644 --- a/actionlite/g_local.h +++ b/actionlite/g_local.h @@ -1944,6 +1944,15 @@ constexpr item_id_t weap_ids[] = { IT_WEAPON_SNIPER }; +typedef enum { + GENDER_MALE, + GENDER_FEMALE, + GENDER_NEUTRAL +} gender_t; + +#define GENDER_STR( ent, he, she, it ) (((ent)->client->pers.gender == GENDER_MALE) ? he : (((ent)->client->pers.gender == GENDER_FEMALE) ? she : it)) + + //====================================================================== // Action Add End //====================================================================== @@ -2595,6 +2604,7 @@ void RemoveAttackingPainDaemons(edict_t *self); bool G_ShouldPlayersCollide(bool weaponry); bool P_UseCoopInstancedItems(); // ACTION +void CL_FixUpGender(edict_t *ent, const char *userinfo); void ClientFixLegs(edict_t *ent); // ACTION @@ -2808,6 +2818,7 @@ struct client_respawn_t // Action Add // Number of team kills this game + gender_t gender; int32_t team_kills; int32_t team_wounds; diff --git a/actionlite/p_client.cpp b/actionlite/p_client.cpp index 347c7ac..2ce947a 100644 --- a/actionlite/p_client.cpp +++ b/actionlite/p_client.cpp @@ -427,6 +427,44 @@ bool P_UseCoopInstancedItems() return g_coop_instanced_items->integer || g_coop_squad_respawn->integer; } +//======================================================================= +// Action Add +//======================================================================= +// Gender-based messaging in a genderless world +// Credit to skuller for the `CL_FixUpGender` function +//======================================================================= + +// This only applies to Action skins, all others become neutral +void CL_FixUpGender(edict_t *ent, const char *userinfo) +{ + char *p; + char sk[MAX_QPATH]; + char val[MAX_INFO_VALUE] = { 0 }; + + if (!ent->client) + return false; + + Q_strlcpy(sk, info_skin->string, sizeof(sk)); + if ((p = strchr(sk, '/')) != NULL) + *p = 0; + if (Q_stricmp(sk, "male") == 0 || + Q_stricmp(sk, "actionmale") == 0 || + Q_stricmp(sk, "aqmarine") == 0 || + Q_stricmp(sk, "messiah") == 0 || + Q_stricmp(sk, "sas") == 0 || + Q_stricmp(sk, "terror") == 0 + ) + Q_strlcpy(val, "male", sizeof(val)); + else if (Q_stricmp(sk, "female") == 0 || + Q_stricmp(sk, "crackhor") == 0 || + Q_stricmp(sk, "actionrally") == 0 || + Q_stricmp(sk, "sydney") == 0 + ) + Q_strlcpy(val, "female", sizeof(val)); + else + Q_strlcpy(val, "none", sizeof(val)); +} + //======================================================================= void ClientObituary(edict_t *self, edict_t *inflictor, edict_t *attacker, mod_t mod) @@ -3432,6 +3470,10 @@ void ClientUserinfoChanged(edict_t *ent, const char *userinfo) if (!gi.Info_ValueForKey(userinfo, "skin", val, sizeof(val))) Q_strlcpy(val, "male/grunt", sizeof(val)); + // set gender based on skin (Action add) + //if (!gi.Info_ValueForKey(userinfo, "gender", val, sizeof(val))) + CL_FixUpGender(ent, userinfo); + int playernum = ent - g_edicts - 1; // combine name and skin into a configstring