Skip to content

Commit

Permalink
Revert "GENDER: Enable the user to select the gender (#199)"
Browse files Browse the repository at this point in the history
This reverses the gender PR and issues that came with it, since we lack the time to fix them. But we keep some fixes that came with the PR. This also fixes then #222.
  • Loading branch information
kai-li-wop committed Jun 30, 2024
1 parent ca3d3d1 commit 61218a8
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 147 deletions.
30 changes: 12 additions & 18 deletions code/cgame/cg_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,34 +156,28 @@ static void CG_Obituary(entityState_t *ent) {
gender = ci->gender;
switch (mod) {
case MOD_BALLOONY_SPLASH:
if (gender == GENDER_MALE)
message = "tripped on his own water bomb";
else if (gender == GENDER_FEMALE)
if (gender == GENDER_FEMALE)
message = "tripped on her own water bomb";
else if (gender == GENDER_NEUTER)
message = "tripped on its own water bomb";
else
message = "tripped on their own water bomb";
message = "tripped on his own water bomb";
break;
case MOD_BETTY_SPLASH:
if (gender == GENDER_MALE)
message = "blew himself up";
else if (gender == GENDER_FEMALE)
if (gender == GENDER_FEMALE)
message = "blew herself up";
else if (gender == GENDER_NEUTER)
message = "blew itself up";
else
message = "blew themselves up";
message = "blew himself up";
break;
case MOD_BUBBLEG_SPLASH:
if (gender == GENDER_MALE)
message = "melted himself";
else if (gender == GENDER_FEMALE)
if (gender == GENDER_FEMALE)
message = "melted herself";
else if (gender == GENDER_NEUTER)
message = "melted itself";
else
message = "melted themselves";
message = "melted himself";
break;
case MOD_IMPERIUS_SPLASH:
message = "should have used a smaller gun";
Expand All @@ -205,19 +199,19 @@ static void CG_Obituary(entityState_t *ent) {

if (cgs.gametype < GT_TEAM) {
if (cgs.gametype == GT_LPS) {
const char *gender_strings[] = {"they have", "he has", "she has", "it has", NULL};
const char *gender_strings[] = {"he", "she", "it", NULL};
CASSERT(ARRAY_LEN(gender_strings) == GENDER_MAX + 1);

gender = ci->gender;
if (gender >= GENDER_MAX || gender < GENDER_NONE)
gender = GENDER_NONE;
if (gender >= GENDER_MAX || gender < GENDER_MALE)
gender = GENDER_NEUTER;

if (ent->generic1 == 0)
s = va("You fragged %s,\n%s no lives left.", targetName, gender_strings[gender]);
s = va("You fragged %s\n%s has no lives left.", targetName, gender_strings[gender]);
else if (ent->generic1 == 1)
s = va("You fragged %s,\n%s 1 life left.", targetName, gender_strings[gender]);
s = va("You fragged %s\n%s has 1 life left.", targetName, gender_strings[gender]);
else
s = va("You fragged %s,\n%s %i lives left.", targetName, gender_strings[gender], ent->generic1);
s = va("You fragged %s\n%s has %i lives left.", targetName, gender_strings[gender], ent->generic1);
} else
s = va("You fragged %s\n%s place with %i", targetName,
CG_PlaceString(cg.snap->ps.persistant[PERS_RANK] + 1), cg.snap->ps.persistant[PERS_SCORE]);
Expand Down
3 changes: 1 addition & 2 deletions code/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ typedef struct {
float headScale;

footstep_t footsteps;
gender_t gender; // user settings (can also be from model)
gender_t genderModel; // cached value from model (animation.cfg)
gender_t gender; // from model

qhandle_t legsModel;
qhandle_t legsSkin;
Expand Down
48 changes: 18 additions & 30 deletions code/cgame/cg_players.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ static qboolean CG_ParseAnimationFile(const char *filename, clientInfo_t *ci) {
ci->footsteps = FOOTSTEP_NORMAL;
VectorClear(ci->headOffset);
ci->headScale = 1.0f;
ci->gender = GENDER_MALE;
ci->fixedlegs = qfalse;
ci->fixedtorso = qfalse;

Expand Down Expand Up @@ -166,15 +167,14 @@ static qboolean CG_ParseAnimationFile(const char *filename, clientInfo_t *ci) {
} else if (!Q_stricmp(token, "sex")) {
token = COM_Parse(&text_p);
if (!token[0]) {
ci->genderModel = GENDER_NONE;
break;
}
if (token[0] == 'm' || token[0] == 'M') {
ci->genderModel = GENDER_MALE;
} else if (token[0] == 'f' || token[0] == 'F') {
ci->genderModel = GENDER_FEMALE;
if (token[0] == 'f' || token[0] == 'F') {
ci->gender = GENDER_FEMALE;
} else if (token[0] == 'n' || token[0] == 'N') {
ci->genderModel = GENDER_NEUTER;
ci->gender = GENDER_NEUTER;
} else {
ci->gender = GENDER_MALE;
}
continue;
} else if (!Q_stricmp(token, "fixedlegs")) {
Expand All @@ -195,6 +195,7 @@ static qboolean CG_ParseAnimationFile(const char *filename, clientInfo_t *ci) {

// read information for each frame
for (i = 0; i < MAX_ANIMATIONS; i++) {

token = COM_Parse(&text_p);
if (!token[0]) {
if (i >= TORSO_GETFLAG && i <= TORSO_NEGATIVE) {
Expand Down Expand Up @@ -667,21 +668,18 @@ static void CG_LoadClientInfo(int clientNum, clientInfo_t *ci) {
CG_ResetPlayerEntity(&cg_entities[i]);
}
}

if (ci->gender == GENDER_MAX) {
ci->gender = ci->genderModel;
}
}

/**
* @brief Copies the attributes of a model from its @c animation.cfg properties to the new @c clientInfo_t
* @sa CG_ParseAnimationFile()
*/
/*
======================
CG_CopyClientInfoModel
======================
*/
static void CG_CopyClientInfoModel(const clientInfo_t *from, clientInfo_t *to) {
VectorCopy(from->headOffset, to->headOffset);
to->headScale = from->headScale;
to->footsteps = from->footsteps;
to->genderModel = from->genderModel;
to->gender = from->gender;

to->legsModel = from->legsModel;
to->legsSkin = from->legsSkin;
Expand Down Expand Up @@ -801,9 +799,11 @@ static void CG_SetDeferredClientInfo(int clientNum, clientInfo_t *ci) {
CG_LoadClientInfo(clientNum, ci);
}

/**
* @sa ClientUserinfoChanged()
*/
/*
======================
CG_NewClientInfo
======================
*/
void CG_NewClientInfo(int clientNum) {
clientInfo_t *ci;
clientInfo_t newInfo;
Expand Down Expand Up @@ -883,17 +883,6 @@ void CG_NewClientInfo(int clientNum) {
// team leader
v = Info_ValueForKey(configstring, "tl");
newInfo.teamLeader = atoi(v);

// sex
// if a sex option is set in the userinfo string we take this,
// otherwise we check for GENDER_MAX in CG_ParseAnimationFile() to use the
// setting from animation.cfg
newInfo.gender = GENDER_MAX;
v = Info_ValueForKey(configstring, "s");
if (v[0] != '\0') {
newInfo.gender = atoi(v);
}

oldTeam = ci->team;

// this may be run before the first snapshot arrives
Expand Down Expand Up @@ -1002,7 +991,6 @@ void CG_NewClientInfo(int clientNum) {

// replace whatever was there with the new one
newInfo.infoValid = qtrue;

*ci = newInfo;

// if the local client changed teams in a team gametype, adjust team- and enemymodels
Expand Down
2 changes: 1 addition & 1 deletion code/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3400,7 +3400,7 @@ void CL_Init(void) {
Cvar_Get("spraycolor", "2", CVAR_USERINFO | CVAR_ARCHIVE);
Cvar_Get("randomcolor", "0", CVAR_USERINFO | CVAR_ARCHIVE);
Cvar_Get("handicap", "100", CVAR_USERINFO | CVAR_ARCHIVE);
Cvar_Get("sex", "model", CVAR_USERINFO | CVAR_ARCHIVE);
Cvar_Get("sex", "male", CVAR_USERINFO | CVAR_ARCHIVE);

Cvar_Get("password", "", CVAR_USERINFO);
Cvar_Get("cg_predictItems", "1", CVAR_USERINFO | CVAR_ARCHIVE);
Expand Down
2 changes: 1 addition & 1 deletion code/game/bg_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ typedef enum {

int convertGTStringToGTNumber(const char *argStr);

typedef enum { GENDER_NONE, GENDER_MALE, GENDER_FEMALE, GENDER_NEUTER, GENDER_MAX } gender_t;
typedef enum { GENDER_MALE, GENDER_FEMALE, GENDER_NEUTER, GENDER_MAX } gender_t;

/*
===================================================================================
Expand Down
46 changes: 15 additions & 31 deletions code/game/g_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,15 +741,17 @@ static void ClientCleanName(const char *in, char *out, int outSize) {
Q_strncpyz(out, "UnnamedPlayer", outSize);
}

/**
* Called from ClientConnect when the player first connects and
* directly by the server system when the player updates a userinfo variable.
*
* The game can override any of the settings and call trap_SetUserinfo
* if desired.
*
* @see CG_NewClientInfo()
*/
/*
===========
ClientUserInfoChanged
Called from ClientConnect when the player first connects and
directly by the server system when the player updates a userinfo variable.
The game can override any of the settings and call trap_SetUserinfo
if desired.
============
*/
void ClientUserinfoChanged(int clientNum) {
gentity_t *ent;
int teamLeader, team, health, randomColor;
Expand All @@ -760,7 +762,6 @@ void ClientUserinfoChanged(int clientNum) {
gclient_t *client;
char sprayColor[MAX_INFO_STRING];
char userinfo[MAX_INFO_STRING];
gender_t gender;

ent = g_entities + clientNum;
client = ent->client;
Expand Down Expand Up @@ -813,20 +814,6 @@ void ClientUserinfoChanged(int clientNum) {
}
client->ps.stats[STAT_MAX_HEALTH] = client->pers.maxHealth;

// set gender
s = Info_ValueForKey(userinfo, "sex");
if (!Q_stricmp(s, "neuter")) {
gender = GENDER_NEUTER;
} else if (!Q_stricmp(s, "female")) {
gender = GENDER_FEMALE;
} else if (!Q_stricmp(s, "male")) {
gender = GENDER_MALE;
} else if (!Q_stricmp(s, "none")) {
gender = GENDER_NONE;
} else {
gender = GENDER_MAX;
}

// set model
if (g_gametype.integer >= GT_TEAM) {
Q_strncpyz(model, Info_ValueForKey(userinfo, "team_model"), sizeof(model));
Expand Down Expand Up @@ -858,19 +845,16 @@ void ClientUserinfoChanged(int clientNum) {
// send over a subset of the userinfo keys so other clients can
// print scoreboards, display models, and play custom sounds
if (ent->r.svFlags & SVF_BOT) {
// cyr{
const char *rndSprayColor;
int rnd = randomindex(NUM_COLORS);
rndSprayColor = va("%d", rnd);
s = va("n\\%s\\t\\%i\\model\\%s\\hmodel\\%s\\sc\\%s\\hc\\%i\\w\\%i\\l\\%i\\skill\\%s\\tl\\%d"
"\\sl\\%s",
s = va("n\\%s\\t\\%i\\model\\%s\\hmodel\\%s\\sc\\%s\\hc\\%i\\w\\%i\\l\\%i\\skill\\%s\\tl\\%d\\sl\\%s",
client->pers.netname, team, model, headModel, rndSprayColor, client->pers.maxHealth, client->sess.wins,
client->sess.losses, Info_ValueForKey(userinfo, "skill"), teamLeader, client->sess.selectedlogo);
// cyr}
} else {
s = va("n\\%s\\t\\%i\\model\\%s\\hmodel\\%s\\sc\\%s\\rc\\%i\\hc\\%i\\w\\%i\\l\\%i\\tl\\%d\\sl\\%s\\s\\%i",
client->pers.netname, client->sess.sessionTeam, model, headModel, sprayColor, randomColor, client->pers.maxHealth,
client->sess.wins, client->sess.losses, teamLeader, client->sess.selectedlogo, (int)gender);
s = va("n\\%s\\t\\%i\\model\\%s\\hmodel\\%s\\sc\\%s\\rc\\%i\\hc\\%i\\w\\%i\\l\\%i\\tl\\%d\\sl\\%s",
client->pers.netname, client->sess.sessionTeam, model, headModel, sprayColor, randomColor,
client->pers.maxHealth, client->sess.wins, client->sess.losses, teamLeader, client->sess.selectedlogo);
}

trap_SetConfigstring(CS_PLAYERS + clientNum, s);
Expand Down
Loading

0 comments on commit 61218a8

Please sign in to comment.