--- deliantra/server/socket/request.C 2006/12/19 04:58:05 1.45 +++ deliantra/server/socket/request.C 2006/12/21 06:12:37 1.49 @@ -140,15 +140,12 @@ static void clear_map (player *pl) { - client &socket = *pl->socket; - - memset (&socket.lastmap, 0, sizeof (socket.lastmap)); + memset (&pl->socket->lastmap, 0, sizeof (pl->socket->lastmap)); - if (socket.newmapcmd == 1) - socket.send_packet ("newmap"); + if (pl->socket->newmapcmd == 1) + pl->socket->send_packet ("newmap"); - socket.update_look = 1; - socket.look_position = 0; + pl->socket->floorbox_reset (); } /** check for map change and send new map data */ @@ -199,8 +196,7 @@ else { socket_map_scroll (&socket, ob->x - socket.current_x, ob->y - socket.current_y); - socket.update_look = 1; - socket.look_position = 0; + socket.floorbox_reset (); } } @@ -575,7 +571,10 @@ void AddMeCmd (char *buf, int len, client * ns) { - if (ns->status != Ns_Add || add_player (ns)) + if (INVOKE_CLIENT (ADDME, ns)) + return; + + if (ns->pl || add_player (ns)) ns->send_packet ("addme_failed"); else ns->send_packet ("addme_success"); @@ -725,10 +724,9 @@ ns->faces_sent[face] |= NS_FACESENT_SMOOTH; - packet sl; + packet sl ("smooth"); - sl << "smooth " - << uint16 (face) + sl << uint16 (face) << uint16 (smoothface); ns->send_packet (sl); @@ -815,16 +813,21 @@ : time = (int) (MAX_TIME / FABS (pl->ob->speed)); /* Send confirmation of command execution now */ - packet sl; - sl << "comc " << uint16 (cmdid) << uint32 (time); + packet sl ("comc"); + sl << uint16 (cmdid) << uint32 (time); pl->socket->send_packet (sl); } - /** This is a reply to a previous query. */ void -ReplyCmd (char *buf, int len, player *pl) +ReplyCmd (char *buf, int len, client *ns) { + if (!ns->pl) + return; //TODO: depends on the exact reply we are after + //TODO: but right now, we always have a ns->pl + + player *pl = ns->pl; + /* This is to synthesize how the data would be stored if it * was normally entered. A bit of a hack, and should be cleaned up * once all the X11 code is removed from the server. @@ -855,7 +858,6 @@ break; case ST_CHANGE_CLASS: - key_change_class (pl->ob, buf[0]); break; @@ -1039,8 +1041,7 @@ char buf[MAX_BUF]; uint16 flags; - packet sl; - sl << "stats "; + packet sl ("stats"); if (pl->ob) { @@ -1133,8 +1134,7 @@ { pl->last_weight = weight; - packet sl; - sl << "player "; + packet sl ("player"); sl << uint32 (pl->ob->count) << uint32 (weight) @@ -1165,10 +1165,9 @@ return; } - packet sl; + packet sl ("anim"); - sl << "anim " - << uint16 (anim_num) + sl << uint16 (anim_num) << uint16 (0); /* flags - not used right now */ /* Build up the list of faces. Also, send any information (ie, the @@ -1624,10 +1623,9 @@ check_map_change (pl->contr); - packet sl; + packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a"); packet esl; - sl << (socket.mapmode == Map1Cmd ? "map1 " : "map1a "); startlen = sl.length (); /*Extendedmapinfo structure initialisation */ @@ -1681,7 +1679,6 @@ ax = 0; for (x = pl->x - socket.mapx / 2; x < max_x; x++, ax++) { - emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; /* If this space is out of the normal viewable area, we only check @@ -2022,28 +2019,24 @@ memset (&newmap, 0, sizeof (struct Map)); for (j = (pl->y - pl->contr->socket->mapy / 2); j < (pl->y + (pl->contr->socket->mapy + 1) / 2); j++) - { - for (i = (pl->x - pl->contr->socket->mapx / 2); i < (pl->x + (pl->contr->socket->mapx + 1) / 2); i++) - { - ax = i; - ay = j; - m = pm; - mflags = get_map_flags (m, &m, ax, ay, &ax, &ay); + for (i = (pl->x - pl->contr->socket->mapx / 2); i < (pl->x + (pl->contr->socket->mapx + 1) / 2); i++) + { + ax = i; + ay = j; + m = pm; + mflags = get_map_flags (m, &m, ax, ay, &ax, &ay); - if (mflags & P_OUT_OF_MAP) - continue; + if (mflags & P_OUT_OF_MAP) + continue; - if (mflags & P_NEED_UPDATE) - update_position (m, ax, ay); + /* If a map is visible to the player, we don't want to swap it out + * just to reload it. This should really call something like + * swap_map, but this is much more efficient and 'good enough' + */ + if (mflags & P_NEW_MAP) + m->timeout = 50; + } - /* If a map is visible to the player, we don't want to swap it out - * just to reload it. This should really call something like - * swap_map, but this is much more efficient and 'good enough' - */ - if (mflags & P_NEW_MAP) - m->timeout = 50; - } - } /* do LOS after calls to update_position */ if (pl->contr->do_los) { @@ -2181,10 +2174,9 @@ return; } - packet sl; + packet sl ("delspell"); - sl << "delspell " - << uint32 (spell->count); + sl << uint32 (spell->count); pl->socket->send_packet (sl); } @@ -2247,8 +2239,7 @@ if (!pl->socket->monitor_spells) return; - packet sl; - sl << "addspell "; + packet sl ("addspell"); if (!spell) {