--- deliantra/server/common/living.C 2010/04/06 21:11:48 1.117 +++ deliantra/server/common/living.C 2012/01/27 22:00:39 1.127 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2002 Mark Wedel & Crossfire Development Team * Copyright (©) 1992 Frank Tore Johansen * @@ -141,7 +141,7 @@ Both come in handy at least in function add_exp() */ -#define MAX_EXPERIENCE levels[settings.max_level] +#define MAX_EXPERIENCE levels [settings.max_level] /* because exp_obj sum to make the total score, * we cannot allow that sum to exceed the maximum @@ -158,9 +158,7 @@ * -b.t. */ -#define MAX_EXP_IN_OBJ levels[settings.max_level]/(MAX_EXP_CAT - 1) - -extern sint64 *levels; +#define MAX_EXP_IN_OBJ MAX_EXP_IN_OBJ / (MAX_EXP_CAT - 1) #define MAX_SAVE_LEVEL 110 @@ -463,7 +461,7 @@ else { new_draw_info (NDI_UNIQUE, 0, op, "You are blinded."); - SET_FLAG (op, FLAG_BLIND); + op->set_flag (FLAG_BLIND); if (op->type == PLAYER) op->contr->do_los = 1; } @@ -475,7 +473,7 @@ else { new_draw_info (NDI_UNIQUE, 0, op, "Your vision returns."); - CLEAR_FLAG (op, FLAG_BLIND); + op->clr_flag (FLAG_BLIND); if (op->type == PLAYER) op->contr->do_los = 1; } @@ -612,7 +610,7 @@ { tmp = at->instance (); tmp = insert_ob_in_ob (tmp, this); - SET_FLAG (tmp, FLAG_APPLIED); + tmp->set_flag (FLAG_APPLIED); } } @@ -642,7 +640,7 @@ tmp = at->instance (); tmp = insert_ob_in_ob (tmp, this); - SET_FLAG (tmp, FLAG_APPLIED); + tmp->set_flag (FLAG_APPLIED); } if (value) @@ -733,7 +731,7 @@ void object::update_stats () { - float f, max_speed = 9, added_speed = 0, bonus_speed = 0, speed_reduce_from_disease = 1; + float max_speed = 9, added_speed = 0, bonus_speed = 0, speed_reduce_from_disease = 1; int weapon_weight = 0, weapon_speed = 0; int best_wc = 0, best_ac = 0, wc = 0, ac = 0; int prot[NROFATTACKS], vuln[NROFATTACKS], potion_resist[NROFATTACKS]; @@ -769,20 +767,20 @@ slaying = 0; - if (!QUERY_FLAG (this, FLAG_WIZ)) + if (!this->flag [FLAG_WIZ]) { - CLEAR_FLAG (this, FLAG_XRAYS); - CLEAR_FLAG (this, FLAG_MAKE_INVIS); + this->clr_flag (FLAG_XRAYS); + this->clr_flag (FLAG_MAKE_INVIS); } - CLEAR_FLAG (this, FLAG_LIFESAVE); - CLEAR_FLAG (this, FLAG_STEALTH); - CLEAR_FLAG (this, FLAG_BLIND); + this->clr_flag (FLAG_LIFESAVE); + this->clr_flag (FLAG_STEALTH); + this->clr_flag (FLAG_BLIND); - if (!QUERY_FLAG (arch, FLAG_REFL_SPELL )) CLEAR_FLAG (this, FLAG_REFL_SPELL); - if (!QUERY_FLAG (arch, FLAG_REFL_MISSILE)) CLEAR_FLAG (this, FLAG_REFL_MISSILE); - if (!QUERY_FLAG (arch, FLAG_UNDEAD )) CLEAR_FLAG (this, FLAG_UNDEAD); - if (!QUERY_FLAG (arch, FLAG_SEE_IN_DARK )) CLEAR_FLAG (this, FLAG_SEE_IN_DARK); + if (!arch->flag [FLAG_REFL_SPELL ]) this->clr_flag (FLAG_REFL_SPELL); + if (!arch->flag [FLAG_REFL_MISSILE]) this->clr_flag (FLAG_REFL_MISSILE); + if (!arch->flag [FLAG_UNDEAD ]) this->clr_flag (FLAG_UNDEAD); + if (!arch->flag [FLAG_SEE_IN_DARK ]) this->clr_flag (FLAG_SEE_IN_DARK); path_attuned = arch->path_attuned; path_repelled = arch->path_repelled; @@ -815,7 +813,7 @@ * basically, if a server updates its max level, these playes may find * that their protection from physical goes down */ - if (!QUERY_FLAG (this, FLAG_USE_ARMOUR) && type == PLAYER) + if (!this->flag [FLAG_USE_ARMOUR] && type == PLAYER) { ac = max (-10, arch->stats.ac - level / 3); prot[ATNR_PHYSICAL] += ((100 - prot[AT_PHYSICAL]) * (80 * level / settings.max_level)) / 100; @@ -837,7 +835,7 @@ * applied so we can tell the player what changed. But change_abil * then calls this function. */ - if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->type == POTION) + if (tmp->flag [FLAG_APPLIED] && tmp->type == POTION) continue; glow_radius += tmp->glow_radius; @@ -874,7 +872,8 @@ */ if ((tmp->flag [FLAG_APPLIED] && tmp->type != CONTAINER - && tmp->type != CLOSE_CON) + && tmp->type != CLOSE_CON + && tmp->type != SPELL) || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) { if (type == PLAYER) @@ -919,9 +918,9 @@ else if (tmp->type != POTION) for (int i = 0; i < NROFATTACKS; i++) if (tmp->resist[i] > 0) - prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; + prot[i] += (100 - prot[i]) * tmp->resist[i] / 100; else if (tmp->resist[i] < 0) - vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; + vuln[i] += (100 - vuln[i]) * -tmp->resist[i] / 100; /* There may be other things that should not adjust the attacktype */ if (tmp->type != SYMPTOM) @@ -936,13 +935,13 @@ flag |= tmp->flag & copy_flags; - if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (arch, FLAG_UNDEAD)) - SET_FLAG (this, FLAG_UNDEAD); + if (tmp->flag [FLAG_UNDEAD] && !arch->flag [FLAG_UNDEAD]) + this->set_flag (FLAG_UNDEAD); //TODO: copy_flags? - if (QUERY_FLAG (tmp, FLAG_MAKE_INVIS)) + if (tmp->flag [FLAG_MAKE_INVIS]) { - SET_FLAG (this, FLAG_MAKE_INVIS); + set_flag (FLAG_MAKE_INVIS); invisible = 1; } @@ -979,7 +978,7 @@ if (tmp->stats.dam > 0) { /* skill is a 'weapon' */ - if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) + if (!this->flag [FLAG_READY_WEAPON]) weapon_speed = max (0, WEAPON_SPEED (tmp)); weapon_weight = tmp->weight; @@ -1026,11 +1025,7 @@ break; - case WAND: - case ROD: - case HORN: - break; - + case RANGED: case BOW: case WEAPON: wc -= tmp->stats.wc + tmp->magic; @@ -1093,7 +1088,7 @@ ac -= tmp->stats.ac + tmp->magic; if (ARMOUR_SPEED (tmp)) - max_speed = min (max_speed, ARMOUR_SPEED (tmp) / 10.f); + min_it (max_speed, ARMOUR_SPEED (tmp) / 10.f); break; } /* switch tmp->type */ @@ -1527,7 +1522,7 @@ /* clear the flag - exp goes into this bucket, but player * still doesn't know it. */ - CLEAR_FLAG (skill_obj, FLAG_CAN_USE_SKILL); + skill_obj->clr_flag (FLAG_CAN_USE_SKILL); skill_obj->stats.exp = 0; skill_obj->level = 1; op->insert (skill_obj); @@ -1614,10 +1609,7 @@ sint64 level_exp (int level, double expmul) { - if (level > settings.max_level) - return (sint64) (expmul * levels[settings.max_level]); - - return (sint64) (expmul * levels[level]); + return expmul * level_to_min_exp (level); } /* @@ -1655,11 +1647,10 @@ * flag is what to do if the player doesn't have the skill: */ static void -add_player_exp (object *op, sint64 exp, const char *skill_name, int flag) +add_player_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag) { object *skill_obj; sint64 limit, exp_to_add; - int i; /* prevents some forms of abuse. */ if (op->contr->braced) @@ -1695,7 +1686,7 @@ * than half what you need to gain for next level. */ exp_to_add = exp; - limit = (levels[op->level + 1] - levels[op->level]) / 2; + limit = (levels [op->level + 1] - levels [op->level]) / 2; if (exp_to_add > limit) exp_to_add = limit; @@ -1712,7 +1703,7 @@ if (skill_obj) { exp_to_add = exp; - limit = (levels[skill_obj->level + 1] - levels[skill_obj->level]) / 2; + limit = (levels [skill_obj->level + 1] - levels [skill_obj->level]) / 2; if (exp_to_add > limit) exp_to_add = limit; @@ -1779,7 +1770,7 @@ * a postive number. */ static void -subtract_player_exp (object *op, sint64 exp, const char *skill, int flag) +subtract_player_exp (object *op, sint64 exp, shstr_tmp skill, int flag) { float fraction = (float) exp / (float) op->stats.exp; object *tmp; @@ -1788,7 +1779,7 @@ for (tmp = op->inv; tmp; tmp = tmp->below) if (tmp->type == SKILL && tmp->stats.exp) { - if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (&tmp->skill, skill)) + if (flag == SK_SUBTRACT_SKILL_EXP && skill && tmp->skill == skill) { del_exp = check_exp_loss (tmp, exp); tmp->stats.exp -= del_exp; @@ -1799,7 +1790,7 @@ /* only want to process other skills if we are not trying * to match a specific skill. */ - del_exp = check_exp_loss (tmp, (sint64) (tmp->stats.exp * fraction)); + del_exp = check_exp_loss (tmp, tmp->stats.exp * fraction); tmp->stats.exp -= del_exp; player_lvl_adj (op, tmp); } @@ -1823,7 +1814,7 @@ * these last two values are only used for players. */ void -change_exp (object *op, sint64 exp, const char *skill_name, int flag) +change_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag) { #ifdef EXP_DEBUG LOG (llevDebug, "change_exp() called for %s, exp = %" PRId64 "\n", query_name (op), exp); @@ -1850,7 +1841,7 @@ if (op->type != PLAYER) { /* Sanity check */ - if (!QUERY_FLAG (op, FLAG_ALIVE)) + if (!op->flag [FLAG_ALIVE]) return; /* reset exp to max allowed value. We subtract from @@ -1911,7 +1902,7 @@ } percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100; - level_loss = op->stats.exp - levels[max (0, op->level - settings.death_penalty_level)]; + level_loss = op->stats.exp - levels [max (0, op->level - settings.death_penalty_level)]; if (level_loss < 0) level_loss = 0;