--- deliantra/server/socket/request.C 2008/07/13 11:57:25 1.133 +++ deliantra/server/socket/request.C 2008/12/20 02:32:31 1.142 @@ -835,7 +835,7 @@ AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA); for (int s = 0; s < NUM_SKILLS; s++) - if (object *skill = opl->last_skill_ob[s]) + if (object *skill = opl->last_skill_ob [s]) if (skill->stats.exp != ns->last_skill_exp [s]) { ns->last_skill_exp [s] = skill->stats.exp; @@ -914,7 +914,6 @@ pl->ns->last_weight = weight; pl->ns->send_packet (sl); - SET_FLAG (pl->ob, FLAG_CLIENT_SENT); } /****************************************************************************** @@ -1042,16 +1041,14 @@ if (!ob->active) return; - maptile *plmap = ob->map; - /* 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 (!plmap || plmap->in_memory != MAP_ACTIVE) + if (!ob->map || ob->map->in_memory != MAP_ACTIVE) return; - int x, y, ax, ay, startlen, max_x, max_y, oldlen; + int startlen, oldlen; int estartlen, eoldlen; uint8 eentrysize; uint16 ewhatstart, ewhatflag; @@ -1062,7 +1059,7 @@ /* do LOS after calls to update_position */ if (ob != pl->ob) - clear_los (pl); + pl->clear_los (0); else if (pl->do_los) { update_los (ob); @@ -1118,33 +1115,27 @@ estartlen = esl.length (); } - /* x,y are the real map locations. ax, ay are viewport relative - * locations. - */ - ay = 0; - /* We could do this logic as conditionals in the if statement, * but that started to get a bit messy to look at. */ - max_x = ob->x + (socket.mapx + 1) / 2; - max_y = ob->y + (socket.mapy + 1) / 2; + int hx = socket.mapx / 2; + int hy = socket.mapy / 2; - for (y = ob->y - socket.mapy / 2; y < max_y; y++, ay++) + for (int dx = -hx; dx <= hx; dx++) { sint16 nx, ny; maptile *m = 0; - ax = 0; - for (x = ob->x - socket.mapx / 2; x < max_x; x++, ax++) + for (int dy = -hy; dy <= hy; dy++) { - // check to see if we can simply go one right quickly - ++nx; - if (m && nx >= m->width) + // check to see if we can simply go one down quickly + if (m && ++ny >= m->height) m = 0; + // no, so do it the slow way if (!m) { - nx = x; ny = y; m = plmap; + nx = ob->x + dx; ny = ob->y + dy; m = ob->map; if (xy_normalise (m, nx, ny)) m->touch (); @@ -1152,6 +1143,9 @@ m = 0; } + int ax = dx + hx; + int ay = dy + hy; + int emask, mask; emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; @@ -1162,9 +1156,9 @@ */ if (!m) { - /* space is out of map. Update space and clear values - * if this hasn't already been done. If the space is out - * of the map, it shouldn't have a head + /* space is out of map. Update space and clear values + * if this hasn't already been done. If the space is out + * of the map, it shouldn't have a head. */ if (lastcell.count != -1) { @@ -1175,7 +1169,7 @@ continue; } - int d = pl->blocked_los[ax][ay]; + int d = pl->blocked_los_uc (dx, dy); if (d > 3) { @@ -1264,17 +1258,21 @@ && 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))) + || QUERY_FLAG (op, FLAG_MONSTER) + || QUERY_FLAG (op, FLAG_ALIVE) + || QUERY_FLAG (op, 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 } - if (op->msg && op->msg[0] == '@') + if (op->has_dialogue ()) flags |= 1; if (op->type == PLAYER) - player = op->count; + player = op == ob ? pl->ob->count + : op == pl->ob ? ob->count + : op->count; } if (lastcell.stat_hp != stat_hp) @@ -1327,8 +1325,9 @@ if (update_space (sl, socket, ms, lastcell, 1)) mask |= 0x2; - if (ms.player () == ob - && (ob->invisible & (ob->invisible < 50 ? 1 : 7))) + if (ob->invisible + && ob->invisible & (ob->invisible < 50 ? 1 : 7) + && ms.player () == ob) { // force player to be visible to himself if invisible if (lastcell.faces[0] != ob->face) @@ -1434,7 +1433,7 @@ 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]); + sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names [i]); if (sl.length () > MAXSOCKBUF) { @@ -1562,14 +1561,8 @@ /* figure out which skill it uses, if it uses one */ if (spell->skill) - { - for (i = 1; i < NUM_SKILLS; i++) - if (!strcmp (spell->skill, skill_names[i])) - { - skill = i + CS_STAT_SKILLINFO; - break; - } - } + if (object *tmp = pl->find_skill (spell->skill)) + skill = tmp->subtype + CS_STAT_SKILLINFO; // spells better have a face if (!spell->face)