--- deliantra/server/socket/request.C 2007/01/07 02:39:15 1.60 +++ deliantra/server/socket/request.C 2007/01/08 18:18:36 1.61 @@ -1009,50 +1009,54 @@ char buf[MAX_BUF]; uint16 flags; - if (!pl->ns) + client *ns = pl->ns; + if (!ns) + return; + + object *ob = pl->ob; + if (!ob) return; packet sl ("stats"); - if (pl->ob) - { - AddIfShort (pl->last_stats.hp, pl->ob->stats.hp, CS_STAT_HP); - AddIfShort (pl->last_stats.maxhp, pl->ob->stats.maxhp, CS_STAT_MAXHP); - AddIfShort (pl->last_stats.sp, pl->ob->stats.sp, CS_STAT_SP); - AddIfShort (pl->last_stats.maxsp, pl->ob->stats.maxsp, CS_STAT_MAXSP); - AddIfShort (pl->last_stats.grace, pl->ob->stats.grace, CS_STAT_GRACE); - AddIfShort (pl->last_stats.maxgrace, pl->ob->stats.maxgrace, CS_STAT_MAXGRACE); - AddIfShort (pl->last_stats.Str, pl->ob->stats.Str, CS_STAT_STR); - AddIfShort (pl->last_stats.Dex, pl->ob->stats.Dex, CS_STAT_DEX); - AddIfShort (pl->last_stats.Con, pl->ob->stats.Con, CS_STAT_CON); - AddIfShort (pl->last_stats.Int, pl->ob->stats.Int, CS_STAT_INT); - AddIfShort (pl->last_stats.Wis, pl->ob->stats.Wis, CS_STAT_WIS); - AddIfShort (pl->last_stats.Pow, pl->ob->stats.Pow, CS_STAT_POW); - AddIfShort (pl->last_stats.Cha, pl->ob->stats.Cha, CS_STAT_CHA); - } + AddIfShort (ns->last_stats.hp, ob->stats.hp, CS_STAT_HP); + AddIfShort (ns->last_stats.maxhp, ob->stats.maxhp, CS_STAT_MAXHP); + AddIfShort (ns->last_stats.sp, ob->stats.sp, CS_STAT_SP); + AddIfShort (ns->last_stats.maxsp, ob->stats.maxsp, CS_STAT_MAXSP); + AddIfShort (ns->last_stats.grace, ob->stats.grace, CS_STAT_GRACE); + AddIfShort (ns->last_stats.maxgrace, ob->stats.maxgrace, CS_STAT_MAXGRACE); + AddIfShort (ns->last_stats.Str, ob->stats.Str, CS_STAT_STR); + AddIfShort (ns->last_stats.Dex, ob->stats.Dex, CS_STAT_DEX); + AddIfShort (ns->last_stats.Con, ob->stats.Con, CS_STAT_CON); + AddIfShort (ns->last_stats.Int, ob->stats.Int, CS_STAT_INT); + AddIfShort (ns->last_stats.Wis, ob->stats.Wis, CS_STAT_WIS); + AddIfShort (ns->last_stats.Pow, ob->stats.Pow, CS_STAT_POW); + AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA); for (int s = 0; s < NUM_SKILLS; s++) - if (pl->last_skill_ob[s] && pl->last_skill_exp[s] != pl->last_skill_ob[s]->stats.exp) - { - /* Always send along the level if exp changes. This is only - * 1 extra byte, but keeps processing simpler. - */ - sl << uint8 (s + CS_STAT_SKILLINFO) - << uint8 (pl->last_skill_ob[s]->level) - << uint64 (pl->last_skill_ob[s]->stats.exp); - - pl->last_skill_exp[s] = pl->last_skill_ob[s]->stats.exp; - } + if (object *skill = pl->last_skill_ob[s]) + if (skill->stats.exp != ns->last_skill_exp [s]) + { + ns->last_skill_exp [s] = skill->stats.exp; + + /* Always send along the level if exp changes. This is only + * 1 extra byte, but keeps processing simpler. + */ + sl << uint8 (s + CS_STAT_SKILLINFO) + << uint8 (skill->level) + << uint64 (skill->stats.exp); + } + + AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64); + AddIfShort (ns->last_level, ob->level, CS_STAT_LEVEL); + AddIfShort (ns->last_stats.wc, ob->stats.wc, CS_STAT_WC); + AddIfShort (ns->last_stats.ac, ob->stats.ac, CS_STAT_AC); + AddIfShort (ns->last_stats.dam, ob->stats.dam, CS_STAT_DAM); + AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED); + AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); + AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP); + AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM); - AddIfInt64 (pl->last_stats.exp, pl->ob->stats.exp, CS_STAT_EXP64); - AddIfShort (pl->last_level, (char) pl->ob->level, CS_STAT_LEVEL); - AddIfShort (pl->last_stats.wc, pl->ob->stats.wc, CS_STAT_WC); - AddIfShort (pl->last_stats.ac, pl->ob->stats.ac, CS_STAT_AC); - AddIfShort (pl->last_stats.dam, pl->ob->stats.dam, CS_STAT_DAM); - AddIfFloat (pl->last_speed, pl->ob->speed, CS_STAT_SPEED); - AddIfShort (pl->last_stats.food, pl->ob->stats.food, CS_STAT_FOOD); - AddIfFloat (pl->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP); - AddIfInt (pl->last_weight_limit, (sint32) weight_limit[pl->ob->stats.Str], CS_STAT_WEIGHT_LIM); flags = 0; if (pl->fire_on) @@ -1061,10 +1065,10 @@ if (pl->run_on) flags |= SF_RUNON; - AddIfShort (pl->last_flags, flags, CS_STAT_FLAGS); + AddIfShort (ns->last_flags, flags, CS_STAT_FLAGS); - if (pl->ns->sc_version < 1025) - { AddIfShort (pl->last_resist[ATNR_PHYSICAL], pl->ob->resist[ATNR_PHYSICAL], CS_STAT_ARMOUR) } + if (ns->sc_version < 1025) + { AddIfShort (ns->last_resist[ATNR_PHYSICAL], ob->resist[ATNR_PHYSICAL], CS_STAT_ARMOUR) } else for (int i = 0; i < NROFATTACKS; i++) { @@ -1072,24 +1076,24 @@ if (atnr_cs_stat[i] == -1) continue; - AddIfShort (pl->last_resist[i], pl->ob->resist[i], (char) atnr_cs_stat[i]); + AddIfShort (ns->last_resist[i], ob->resist[i], atnr_cs_stat[i]); } if (pl->ns->monitor_spells) { - AddIfInt (pl->last_path_attuned, pl->ob->path_attuned, CS_STAT_SPELL_ATTUNE); - AddIfInt (pl->last_path_repelled, pl->ob->path_repelled, CS_STAT_SPELL_REPEL); - AddIfInt (pl->last_path_denied, pl->ob->path_denied, CS_STAT_SPELL_DENY); + AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE); + AddIfInt (ns->last_path_repelled, ob->path_repelled, CS_STAT_SPELL_REPEL); + AddIfInt (ns->last_path_denied, ob->path_denied, CS_STAT_SPELL_DENY); } - rangetostring (pl->ob, buf); /* we want use the new fire & run system in new client */ - AddIfString (pl->ns->stats.range, buf, CS_STAT_RANGE); - set_title (pl->ob, buf); - AddIfString (pl->ns->stats.title, buf, CS_STAT_TITLE); + rangetostring (ob, buf); /* we want use the new fire & run system in new client */ + AddIfString (ns->stats.range, buf, CS_STAT_RANGE); + set_title (ob, buf); + AddIfString (ns->stats.title, buf, CS_STAT_TITLE); /* Only send it away if we have some actual data */ if (sl.length () > 6) - pl->ns->send_packet (sl); + ns->send_packet (sl); } /** @@ -1098,8 +1102,6 @@ void esrv_new_player (player *pl, uint32 weight) { - pl->last_weight = weight; - packet sl ("player"); sl << uint32 (pl->ob->count) @@ -1107,6 +1109,7 @@ << uint32 (pl->ob->face->number) << data8 (pl->ob->name); + pl->ns->last_weight = weight; pl->ns->send_packet (sl); SET_FLAG (pl->ob, FLAG_CLIENT_SENT); }