--- deliantra/server/socket/request.C 2008/12/28 06:59:27 1.148 +++ deliantra/server/socket/request.C 2012/11/21 13:22:34 1.192 @@ -1,26 +1,29 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. - * - * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team - * Copyright (©) 2001,2007 Mark Wedel - * Copyright (©) 1992,2007 Frank Tore Johansen - * - * Deliantra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * + * + * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2001 Mark Wedel + * Copyright (©) 1992 Frank Tore Johansen + * + * Deliantra is free software: you can redistribute it and/or modify it under + * the terms of the Affero GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * + * + * You should have received a copy of the Affero GNU General Public License + * and the GNU General Public License along with this program. If not, see + * . + * * The authors can be reached via e-mail to */ +//+GPL + /** * \file * Client handling. @@ -43,7 +46,6 @@ #include #include -#include /* This block is basically taken from socket.c - I assume if it works there, * it should work here. @@ -65,16 +67,30 @@ * client. If a value is -1, then we don't send that to the * client. */ -short atnr_cs_stat[NROFATTACKS] = { CS_STAT_RES_PHYS, - CS_STAT_RES_MAG, CS_STAT_RES_FIRE, CS_STAT_RES_ELEC, - CS_STAT_RES_COLD, CS_STAT_RES_CONF, CS_STAT_RES_ACID, - CS_STAT_RES_DRAIN, -1 /* weaponmagic */ , - CS_STAT_RES_GHOSTHIT, CS_STAT_RES_POISON, - CS_STAT_RES_SLOW, CS_STAT_RES_PARA, CS_STAT_TURN_UNDEAD, - CS_STAT_RES_FEAR, -1 /* Cancellation */ , - CS_STAT_RES_DEPLETE, CS_STAT_RES_DEATH, - -1 /* Chaos */ , -1 /* Counterspell */ , - -1 /* Godpower */ , CS_STAT_RES_HOLYWORD, +static short atnr_cs_stat[NROFATTACKS] = +{ + CS_STAT_RES_PHYS, + CS_STAT_RES_MAG, + CS_STAT_RES_FIRE, + CS_STAT_RES_ELEC, + CS_STAT_RES_COLD, + CS_STAT_RES_CONF, + CS_STAT_RES_ACID, + CS_STAT_RES_DRAIN, + -1 /* weaponmagic */, + CS_STAT_RES_GHOSTHIT, + CS_STAT_RES_POISON, + CS_STAT_RES_SLOW, + CS_STAT_RES_PARA, + CS_STAT_TURN_UNDEAD, + CS_STAT_RES_FEAR, + -1 /* Cancellation */, + CS_STAT_RES_DEPLETE, + CS_STAT_RES_DEATH, + -1 /* Chaos */, + -1 /* Counterspell */, + -1 /* Godpower */, + CS_STAT_RES_HOLYWORD, CS_STAT_RES_BLIND, -1, /* Internal */ -1, /* life stealing */ @@ -132,10 +148,7 @@ memset (&pl->ns->lastmap, 0, sizeof (pl->ns->lastmap)); pl->ns->force_newmap = false; - - if (pl->ns->newmapcmd == 1) - pl->ns->send_packet ("newmap"); - + pl->ns->send_packet ("newmap"); pl->ns->floorbox_reset (); } @@ -143,18 +156,22 @@ send_map_info (player *pl) { client &socket = *pl->ns; - object *ob = pl->observe; + object *ob = pl->viewpoint; if (socket.mapinfocmd) { - if (ob->map && ob->map->path[0]) + if (ob->map && ob->map->path) { int flags = 0; - if (ob->map->tile_path[0]) flags |= 1; - if (ob->map->tile_path[1]) flags |= 2; - if (ob->map->tile_path[2]) flags |= 4; - if (ob->map->tile_path[3]) flags |= 8; + // due to historical glitches, the bit ordering and map index ordering differs + if (ob->map->tile_path [TILE_NORTH]) flags |= 0x01; + if (ob->map->tile_path [TILE_EAST ]) flags |= 0x02; + if (ob->map->tile_path [TILE_SOUTH]) flags |= 0x04; + if (ob->map->tile_path [TILE_WEST ]) flags |= 0x08; + // these two are debatable + if (ob->map->tile_path [TILE_UP ]) flags |= 0x10; + if (ob->map->tile_path [TILE_DOWN ]) flags |= 0x20; socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s", flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, @@ -170,7 +187,7 @@ check_map_change (player *pl) { client &socket = *pl->ns; - object *ob = pl->observe; + object *ob = pl->viewpoint; region *reg = ob->region (); if (socket.current_region != reg) @@ -179,7 +196,7 @@ socket.current_region = reg; } - // first try to aovid a full newmap on tiled map scrolls + // first try to avoid a full newmap on tiled map scrolls if (socket.current_map != ob->map && !socket.force_newmap) { rv_vector rv; @@ -219,9 +236,50 @@ } /** + * This sends the skill number to name mapping. We ignore + * the params - we always send the same info no matter what. + */ +static void +send_skill_info (client *ns, char *params) +{ + packet sl; + sl << "replyinfo skill_info\n"; + + for (int i = 0; i < skillvec.size (); ++i) + sl.printf ("%d:%s\n", CS_STAT_SKILLINFO + i, &skillvec [i]->name); + + if (sl.length () > MAXSOCKBUF) + cleanup ("buffer overflow in send_skill_info!"); + + ns->send_packet (sl); +} + +/** + * This sends the spell path to name mapping. We ignore + * the params - we always send the same info no matter what. + */ +static void +send_spell_paths (client * ns, char *params) +{ + packet sl; + + sl << "replyinfo spell_paths\n"; + + for (int i = 0; i < NRSPELLPATHS; i++) + sl.printf ("%d:%s\n", 1 << i, spellpathnames[i]); + + if (sl.length () > MAXSOCKBUF) + cleanup ("buffer overflow in send_spell_paths!"); + + ns->send_packet (sl); +} + +/** * RequestInfo is sort of a meta command. There is some specific * request of information, but we call other functions to provide * that information. + * requestinfo is completely deprecated, use resource exti request + * and the fxix or http protocols. */ void RequestInfo (char *buf, int len, client *ns) @@ -238,11 +296,7 @@ break; } - if (!strcmp (buf, "image_info")) - send_image_info (ns, params); - else if (!strcmp (buf, "image_sums")) - send_image_sums (ns, params); - else if (!strcmp (buf, "skill_info")) + if (!strcmp (buf, "skill_info")) send_skill_info (ns, params); else if (!strcmp (buf, "spell_paths")) send_spell_paths (ns, params); @@ -268,6 +322,8 @@ INVOKE_CLIENT (EXTICMD, ns, ARG_DATA (buf, len)); } +//-GPL + void client::mapinfo_queue_clear () { @@ -284,17 +340,23 @@ buf += strlen (buf) + 9; // initial map and its origin - maptile *map = pl->observe->map; - int mapx = pl->ns->mapx / 2 - pl->observe->x; - int mapy = pl->ns->mapy / 2 - pl->observe->y; + maptile *map = pl->viewpoint->map; + int mapx = pl->ns->mapx / 2 - pl->viewpoint->x; + int mapy = pl->ns->mapy / 2 - pl->viewpoint->y; int max_distance = 8; // limit maximum path length to something generous while (*buf && map && max_distance) { int dir = *buf++ - '1'; - if (dir >= 0 && dir <= 3) + // due to historical glitches, the mapinfo index and tile index differs + static unsigned char dirmap [] = { TILE_NORTH, TILE_EAST, TILE_SOUTH, TILE_WEST, TILE_UP, TILE_DOWN }; + + // maybe we should only allow the four flat directions + if (IN_RANGE_EXC (dir, 0, array_length (dirmap))) { + dir = dirmap [dir]; + if (!map->tile_path [dir]) map = 0; else if (map->tile_available (dir, false)) @@ -327,10 +389,14 @@ { int flags = 0; - if (map->tile_path[0]) flags |= 1; - if (map->tile_path[1]) flags |= 2; - if (map->tile_path[2]) flags |= 4; - if (map->tile_path[3]) flags |= 8; + // due to historical glitches, the bit ordering and map index ordering differs + if (map->tile_path [TILE_NORTH]) flags |= 0x01; + if (map->tile_path [TILE_EAST ]) flags |= 0x02; + if (map->tile_path [TILE_SOUTH]) flags |= 0x04; + if (map->tile_path [TILE_WEST ]) flags |= 0x08; + // these two are debatable + if (map->tile_path [TILE_UP ]) flags |= 0x10; + if (map->tile_path [TILE_DOWN ]) flags |= 0x20; send_packet_printf ("mapinfo %s spatial %d %d %d %d %d %s", token, flags, mapx, mapy, map->width, map->height, &map->path); } @@ -401,68 +467,7 @@ INVOKE_CLIENT (ADDME, ns, ARG_DATA (buf, len)); } -/* -#define MSG_TYPE_BOOK 1 -#define MSG_TYPE_CARD 2 -#define MSG_TYPE_PAPER 3 -#define MSG_TYPE_SIGN 4 -#define MSG_TYPE_MONUMENT 5 -#define MSG_TYPE_SCRIPTED_DIALOG 6*/ - -/** Reply to ExtendedInfos command */ -void -ToggleExtendedText (char *buf, int len, client * ns) -{ - char cmdback[MAX_BUF]; - char temp[10]; - char command[50]; - int info, nextinfo, i, flag; - - cmdback[0] = '\0'; - - nextinfo = 0; - while (1) - { - /* 1. Extract an info */ - info = nextinfo; - - while ((info < len) && (buf[info] == ' ')) - info++; - - if (info >= len) - break; - - nextinfo = info + 1; - - while ((nextinfo < len) && (buf[nextinfo] != ' ')) - nextinfo++; - - if (nextinfo - info >= 49) /*Erroneous info asked */ - continue; - - strncpy (command, &(buf[info]), nextinfo - info); - command[nextinfo - info] = '\0'; - /* 2. Interpret info */ - i = sscanf (command, "%d", &flag); - - if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST)) - ns->supported_readables |= (1 << flag); - /*3. Next info */ - } - - /* Send resulting state */ - strcpy (cmdback, "ExtendedTextSet"); - - for (i = 0; i <= MSG_TYPE_LAST; i++) - if (ns->supported_readables & (1 << i)) - { - strcat (cmdback, " "); - snprintf (temp, sizeof (temp), "%d", i); - strcat (cmdback, temp); - } - - ns->send_packet (cmdback); -} +//+GPL /** * This handles the general commands from the client (ie, north, fire, cast, @@ -485,41 +490,7 @@ buf++; } - execute_newserver_command (pl->ob, (char *) buf); - - /* Perhaps something better should be done with a left over count. - * Cleaning up the input should probably be done first - all actions - * for the command that issued the count should be done before any other - * commands. - */ - pl->count = 0; -} - -/** - * This handles the general commands from the client (ie, north, fire, cast, - * etc.). It is a lot like PlayerCmd above, but is called with the - * 'ncom' method which gives more information back to the client so it - * can throttle. - */ -void -NewPlayerCmd (char *buf, int len, player *pl) -{ - if (len <= 6) - { - LOG (llevDebug, "%s: corrupt ncom command <%s>: not long enough (%d) - discarding\n", pl->ns->host, buf, len); - return; - } - - uint16 cmdid = net_uint16 ((uint8 *)buf); - sint32 repeat = net_sint32 ((uint8 *)buf + 2); - - /* -1 is special - no repeat, but don't update */ - if (repeat != -1) - pl->count = repeat; - - buf += 6; //len -= 6; - - execute_newserver_command (pl->ob, buf); + execute_newserver_command (pl->ob, (char *)buf); /* Perhaps something better should be done with a left over count. * Cleaning up the input should probably be done first - all actions @@ -527,16 +498,6 @@ * commands. */ pl->count = 0; - - //TODO: schmorp thinks whatever this calculates, it makes no sense at all - int time = fabs (pl->ob->speed) < 0.001 - ? time = MAX_TIME * 100 - : time = (int) (MAX_TIME / fabs (pl->ob->speed)); - - /* Send confirmation of command execution now */ - packet sl ("comc"); - sl << uint16 (cmdid) << uint32 (time); - pl->ns->send_packet (sl); } /** This is a reply to a previous query. */ @@ -583,50 +544,12 @@ } /** - * Client tells its version. If there is a mismatch, we close the - * socket. In real life, all we should care about is the client having - * something older than the server. If we assume the client will be - * backwards compatible, having it be a later version should not be a - * problem. + * Client tells its version info. */ void -VersionCmd (char *buf, int len, client * ns) +VersionCmd (char *buf, int len, client *ns) { - if (!buf) - { - LOG (llevError, "CS: received corrupted version command\n"); - return; - } - - ns->cs_version = atoi (buf); - ns->sc_version = ns->cs_version; - - LOG (llevDebug, "connection from client <%s>\n", buf); - - //TODO: should log here just for statistics - - //if (VERSION_CS != ns->cs_version) - // unchecked; - - char *cp = strchr (buf + 1, ' '); - if (!cp) - return; - - ns->sc_version = atoi (cp); - - //if (VERSION_SC != ns->sc_version) - // unchecked; - - cp = strchr (cp + 1, ' '); - - if (cp) - { - ns->version = cp + 1; - - if (ns->sc_version < 1026) - ns->send_packet_printf ("drawinfo %d %s", NDI_RED, - "**** VERSION WARNING ****\n**** CLIENT IS TOO OLD!! UPDATE THE CLIENT!! ****"); - } + INVOKE_CLIENT (VERSION, ns, ARG_DATA (buf, len)); } /** sound related functions. */ @@ -687,7 +610,17 @@ static void rangetostring (player *pl, char *obuf) { - dynbuf_text buf; + dynbuf_text &buf = msg_dynbuf; buf.clear (); + +#if 0 + // print ranged/chosen_skill etc. objects every call + printf ("%s %s => %s (%s)\n", + pl->ranged_ob ? &pl->ranged_ob->name : "-", + pl->combat_ob ? &pl->combat_ob->name : "-", + pl->ob->current_weapon ? &pl->ob->current_weapon->name : "-", + pl->ob->chosen_skill ? &pl->ob->chosen_skill->name : "-" + ); +#endif if (pl->ranged_ob) buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name; @@ -743,9 +676,6 @@ void esrv_update_stats (player *pl) { - char buf[MAX_BUF]; - uint16 flags; - client *ns = pl->ns; if (!ns) return; @@ -772,7 +702,7 @@ 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++) + for (int s = 0; s < CS_NUM_SKILLS; s++) if (object *skill = opl->last_skill_ob [s]) if (skill->stats.exp != ns->last_skill_exp [s]) { @@ -781,7 +711,7 @@ /* Always send along the level if exp changes. This is only * 1 extra byte, but keeps processing simpler. */ - sl << uint8 (s + CS_STAT_SKILLINFO) + sl << uint8 (CS_STAT_SKILLINFO + s) << uint8 (skill->level) << uint64 (skill->stats.exp); } @@ -791,32 +721,20 @@ 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, 1.f/TICK); + AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f / TICK); AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); - AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP, 1.f/TICK); + AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP, 1.f / TICK); AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM); - flags = 0; - - if (opl->fire_on) - flags |= SF_FIREON; - - if (opl->run_on) - flags |= SF_RUNON; + int flags = (opl->fire_on ? SF_FIREON : 0) + | (opl->run_on ? SF_RUNON : 0); AddIfShort (ns->last_flags, flags, CS_STAT_FLAGS); - 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++) - { - /* Skip ones we won't send */ - if (atnr_cs_stat[i] == -1) - continue; - - AddIfShort (ns->last_resist[i], ob->resist[i], atnr_cs_stat[i]); - } + for (int i = 0; i < NROFATTACKS; i++) + /* Skip ones we won't send */ + if (atnr_cs_stat[i] >= 0) + AddIfShort (ns->last_resist[i], ob->resist[i], atnr_cs_stat[i]); if (pl->ns->monitor_spells) { @@ -825,6 +743,7 @@ AddIfInt (ns->last_path_denied, ob->path_denied, CS_STAT_SPELL_DENY); } + char buf[MAX_BUF]; rangetostring (opl, buf); /* we want use the new fire & run system in new client */ AddIfString (ns->stats.range, buf, CS_STAT_RANGE); set_title (ob, buf); @@ -928,53 +847,31 @@ return 0; } -// prefetch (and touch) all maps within a specific distancd -static void -prefetch_surrounding_maps (maptile *map, int distance) -{ - map->touch (); - - if (--distance) - for (int dir = 4; --dir; ) - if (const shstr &path = map->tile_path [dir]) - if (maptile *&neigh = map->tile_map [dir]) - prefetch_surrounding_maps (neigh, distance); - else - neigh = maptile::find_async (path, map); -} - -// prefetch a generous area around the player -static void -prefetch_surrounding_maps (object *op) -{ - prefetch_surrounding_maps (op->map, 3); -} - /** * Draws client map. */ void draw_client_map (player *pl) { - object *ob = pl->observe; - if (!ob->active) + object *ob = pl->viewpoint; + if (!pl->observe->active) return; /* If player is just joining the game, he isn't here yet, so the map * can get swapped out. If so, don't try to send them a map. All will * be OK once they really log in. */ - if (!ob->map || ob->map->in_memory != MAP_ACTIVE) + if (!ob->map || ob->map->state != MAP_ACTIVE) return; int startlen, oldlen; check_map_change (pl); - prefetch_surrounding_maps (pl->ob); + pl->ob->prefetch_surrounding_maps (); /* do LOS after calls to update_position */ /* unfortunately, we need to udpate los when observing, currently */ - if (pl->do_los || pl->observe != pl->ob) + if (pl->do_los || pl->viewpoint != pl->ob) { pl->do_los = 0; pl->update_los (); @@ -1005,7 +902,7 @@ client &socket = *pl->ns; - packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a"); + packet sl ("map1a"); startlen = sl.length (); @@ -1036,7 +933,7 @@ continue; } - + int d = pl->blocked_los_uc (dx, dy); if (d > 3) @@ -1107,9 +1004,9 @@ && op->stats.maxhp > 0 && (op->type == PLAYER || op->type == DOOR // does not work, have maxhp 0 - || QUERY_FLAG (op, FLAG_MONSTER) - || QUERY_FLAG (op, FLAG_ALIVE) - || QUERY_FLAG (op, FLAG_GENERATOR))) + || op->flag [FLAG_MONSTER] + || op->flag [FLAG_ALIVE] + || op->flag [FLAG_GENERATOR])) { stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge @@ -1215,62 +1112,6 @@ } } -/*****************************************************************************/ -/* GROS: The following one is used to allow a plugin to send a generic cmd to*/ -/* a player. Of course, the client need to know the command to be able to */ -/* manage it ! */ -/*****************************************************************************/ -void -send_plugin_custom_message (object *pl, char *buf) -{ - pl->contr->ns->send_packet (buf); -} - -/** - * This sends the skill number to name mapping. We ignore - * the params - we always send the same info no matter what. - */ -void -send_skill_info (client *ns, char *params) -{ - packet sl; - sl << "replyinfo skill_info\n"; - - for (int i = 1; i < NUM_SKILLS; i++) - sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names [i]); - - if (sl.length () > MAXSOCKBUF) - { - LOG (llevError, "Buffer overflow in send_skill_info!\n"); - fatal (0); - } - - ns->send_packet (sl); -} - -/** - * This sends the spell path to name mapping. We ignore - * the params - we always send the same info no matter what. - */ -void -send_spell_paths (client * ns, char *params) -{ - packet sl; - - sl << "replyinfo spell_paths\n"; - - for (int i = 0; i < NRSPELLPATHS; i++) - sl.printf ("%d:%s\n", 1 << i, spellpathnames[i]); - - if (sl.length () > MAXSOCKBUF) - { - LOG (llevError, "Buffer overflow in send_spell_paths!\n"); - fatal (0); - } - - ns->send_packet (sl); -} - /** * This looks for any spells the player may have that have changed their stats. * it then sends an updspell packet for each spell that has changed in this way @@ -1281,50 +1122,54 @@ if (!pl->ns) return; + pl->ns->update_spells = false; + if (!pl->ns->monitor_spells) return; for (object *spell = pl->ob->inv; spell; spell = spell->below) - { - if (spell->type == SPELL) - { - int flags = 0; + if (spell->type == SPELL) + { + int flags = 0; + int val; - /* check if we need to update it */ - if (spell->cached_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA)) - { - spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); - flags |= UPD_SP_MANA; - } + /* check if we need to update it */ + val = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); + if (spell->cached_sp != val) + { + spell->cached_sp = val; + flags |= UPD_SP_MANA; + } - if (spell->cached_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE)) - { - spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); - flags |= UPD_SP_GRACE; - } + val = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); + if (spell->cached_grace != val) + { + spell->cached_grace = val; + flags |= UPD_SP_GRACE; + } - if (spell->cached_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell)) - { - spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); - flags |= UPD_SP_DAMAGE; - } + val = casting_level (pl->ob, spell); + if (spell->cached_eat != val) + { + spell->cached_eat = val; + flags |= UPD_SP_LEVEL; + } - if (flags) - { - packet sl; + if (flags) + { + packet sl; - sl << "updspell " - << uint8 (flags) - << uint32 (spell->count); - - if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp); - if (flags & UPD_SP_GRACE ) sl << uint16 (spell->cached_grace); - if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->cached_eat); + sl << "updspell " + << uint8 (flags) + << uint32 (spell->count); - pl->ns->send_packet (sl); - } - } - } + if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp); + if (flags & UPD_SP_GRACE) sl << uint16 (spell->cached_grace); + if (flags & UPD_SP_LEVEL) sl << uint16 (spell->cached_eat); + + pl->ns->send_packet (sl); + } + } } void @@ -1350,7 +1195,7 @@ static void append_spell (player *pl, packet &sl, object *spell) { - int i, skill = 0; + int skill = 0; if (!(spell->name)) { @@ -1361,12 +1206,12 @@ /* store costs and damage in the object struct, to compare to later */ spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); - spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); + spell->cached_eat = casting_level (pl->ob, spell); /* figure out which skill it uses, if it uses one */ if (spell->skill) if (object *tmp = pl->find_skill (spell->skill)) - skill = tmp->subtype + CS_STAT_SKILLINFO; + skill = CS_STAT_SKILLINFO + SKILL_INDEX (tmp); // spells better have a face if (!spell->face) @@ -1387,8 +1232,10 @@ << uint8 (skill) << uint32 (spell->path_attuned) << uint32 (spell->face) - << data8 (spell->name) - << data16 (spell->msg); + << data8 (spell->name); + + if (pl->ns->monitor_spells < 2) + sl << data16 (spell->msg); } /** @@ -1450,13 +1297,12 @@ append_spell (pl, sl, spell); if (sl.length () > MAXSOCKBUF) - { - LOG (llevError, "Buffer overflow in esrv_add_spells!\n"); - fatal (0); - } + cleanup ("buffer overflow in esrv_add_spells!"); /* finally, we can send the packet */ pl->ns->flush_fx (); pl->ns->send_packet (sl); } +//-GPL +