Beispiel #1
0
	LIST_Foreach(updateCharacters, updateCharacter_t, c) {
		Employee* employee = E_GetEmployeeFromChrUCN(c->ucn);

		if (!employee) {
			Com_Printf("Warning: Could not get character with ucn: %i.\n", c->ucn);
			continue;
		}

		character_t* chr = &employee->chr;
		const bool fullHP = c->HP >= chr->maxHP;
		chr->STUN = c->STUN;
		chr->morale = c->morale;

		memcpy(chr->wounds.treatmentLevel, c->wounds.treatmentLevel, sizeof(chr->wounds.treatmentLevel));
		memcpy(chr->score.kills, c->chrscore.kills, sizeof(chr->score.kills));
		memcpy(chr->score.stuns, c->chrscore.stuns, sizeof(chr->score.stuns));
		chr->score.assignedMissions = c->chrscore.assignedMissions;

		for (int i = ABILITY_POWER; i <= SKILL_NUM_TYPES; ++i) {
			const int maxXP = CHAR_GetMaxExperiencePerMission(static_cast<abilityskills_t>(i));
			const int gainedXP = std::min(maxXP, c->chrscore.experience[i] - chr->score.experience[i]);
			chr->score.experience[i] += gainedXP;
			cgi->Com_DPrintf(DEBUG_CLIENT, "CP_UpdateCharacterData: Soldier %s earned %d experience points in skill #%d (total experience: %d)\n",
						chr->name, gainedXP, i, chr->score.experience[SKILL_NUM_TYPES]);
		}

		CHAR_UpdateSkills(chr);
		/* If character returned unscratched and maxHP just went up due to experience
		 * don't send him/her to the hospital */
		chr->HP = (fullHP ? chr->maxHP : std::min(c->HP, chr->maxHP));
	}
Beispiel #2
0
/**
 * @brief Parses the character data which was send by G_MatchSendResults using G_SendCharacterData
 * @param[in] msg The network buffer message. If this is NULL the character is updated, if this
 * is not NULL the data is stored in a temp buffer because the player can choose to retry
 * the mission and we have to catch this situation to not update the character data in this case.
 * @sa G_SendCharacterData
 * @sa GAME_SendCurrentTeamSpawningInfo
 * @sa E_Save
 */
void CP_ParseCharacterData (struct dbuffer *msg)
{
	static linkedList_t *updateCharacters = NULL;

	if (!msg) {
		updateCharacter_t *c;
		LIST_Foreach(updateCharacters, updateCharacter_t, c) {
			employee_t *employee = E_GetEmployeeFromChrUCN(c->ucn);
			character_t* chr;

			if (!employee) {
				Com_Printf("Warning: Could not get character with ucn: %i.\n", c->ucn);
				continue;
			}

			chr = &employee->chr;
			chr->HP = min(c->HP, chr->maxHP);
			chr->STUN = c->STUN;
			chr->morale = c->morale;

			memcpy(chr->score.experience, c->chrscore.experience, sizeof(chr->score.experience));
			memcpy(chr->score.skills, c->chrscore.skills, sizeof(chr->score.skills));
			memcpy(chr->score.kills, c->chrscore.kills, sizeof(chr->score.kills));
			memcpy(chr->score.stuns, c->chrscore.stuns, sizeof(chr->score.stuns));
			chr->score.assignedMissions = c->chrscore.assignedMissions;
		}
/**
 * @brief Change the name of the selected actor.
 * @note called via "employee_changename"
 */
static void E_ChangeName_f (void)
{
	Employee* employee = E_GetEmployeeFromChrUCN(cgi->Cvar_GetInteger("mn_ucn"));
	if (!employee)
		return;

	/* employee name should not contain " */
	if (!Com_IsValidName(cgi->Cvar_GetString("mn_name"))) {
		cgi->Cvar_ForceSet("mn_name", employee->chr.name);
		return;
	}

	Q_strncpyz(employee->chr.name, cgi->Cvar_GetString("mn_name"), sizeof(employee->chr.name));
}