--- deliantra/server/socket/item.C 2006/12/14 01:12:35 1.15 +++ deliantra/server/socket/item.C 2006/12/14 20:39:54 1.20 @@ -111,12 +111,12 @@ return flags; } -/* Used in the send_look to put object head into SockList +/* Used in the send_look to put object head into packet * sl for socket ns. Need socket to know if we need to send * animation of face to the client. */ static void -add_object_to_socklist (NewSocket &ns, SockList &sl, object *head) +add_object_to_socklist (client_socket &ns, packet &sl, object *head) { int flags, len, anim_speed; char item_n[MAX_BUF]; @@ -201,13 +201,13 @@ int got_one = 0, start_look = 0, end_look = 0; char buf[MAX_BUF]; - if (!pl->contr->socket.update_look) + if (!pl->contr->socket->update_look) { LOG (llevDebug, "esrv_draw_look called when update_look was not set\n"); return; } else - pl->contr->socket.update_look = 0; + pl->contr->socket->update_look = 0; if (QUERY_FLAG (pl, FLAG_REMOVED) || !pl->map @@ -218,20 +218,20 @@ for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above) ; - SockList sl (MAXSOCKBUF); + packet sl; - pl->contr->socket.send_packet ("delinv 0"); + pl->contr->socket->send_packet ("delinv 0"); - sl.printf ("item%d ", pl->contr->socket.itemcmd); + sl.printf ("item%d ", pl->contr->socket->itemcmd); sl << uint32 (0); - if (!(pl->contr->socket.faces_sent[empty_face->number] & NS_FACESENT_FACE)) - esrv_send_face (&pl->contr->socket, empty_face->number, 0); + if (!(pl->contr->socket->faces_sent[empty_face->number] & NS_FACESENT_FACE)) + esrv_send_face (pl->contr->socket, empty_face->number, 0); - if (pl->contr->socket.look_position) + if (pl->contr->socket->look_position) { - sl << uint32 (0x80000000 | (pl->contr->socket.look_position - NUM_LOOK_OBJECTS)) + sl << uint32 (0x80000000 | (pl->contr->socket->look_position - NUM_LOOK_OBJECTS)) << uint32 (0) << sint32 (-1) << uint32 (empty_face->number); @@ -242,7 +242,7 @@ << uint8 (0) << uint32 (0); - if (pl->contr->socket.itemcmd == 2) + if (pl->contr->socket->itemcmd == 2) sl << uint16 (0); } @@ -259,7 +259,7 @@ if (LOOK_OBJ (tmp)) { - if (++start_look < pl->contr->socket.look_position) + if (++start_look < pl->contr->socket->look_position) continue; end_look++; @@ -269,7 +269,7 @@ /* What we basically do is make a 'fake' object - when the user applies it, * we notice the special tag the object has, and act accordingly. */ - sl << uint32 (0x80000000 | (pl->contr->socket.look_position + NUM_LOOK_OBJECTS)) + sl << uint32 (0x80000000 | (pl->contr->socket->look_position + NUM_LOOK_OBJECTS)) << uint32 (0) << uint32 ((uint32) - 1) << uint32 (empty_face->number); @@ -280,7 +280,7 @@ << uint8 (0) << uint32 (0); - if (pl->contr->socket.itemcmd == 2) + if (pl->contr->socket->itemcmd == 2) sl << uint16 (0); break; @@ -291,15 +291,15 @@ else head = tmp; - add_object_to_socklist (pl->contr->socket, sl, head); + add_object_to_socklist (*pl->contr->socket, sl, head); got_one++; - if (sl.len >= (MAXSOCKBUF - MAXITEMLEN)) + if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) { - Send_With_Handling (&pl->contr->socket, &sl); + pl->contr->socket->send_packet (sl); sl.reset (); - sl.printf ("item%d ", pl->contr->socket.itemcmd); + sl.printf ("item%d ", pl->contr->socket->itemcmd); sl << uint32 (0); got_one = 0; } @@ -307,9 +307,8 @@ } if (got_one) - Send_With_Handling (&pl->contr->socket, &sl); + pl->contr->socket->send_packet (sl); - sl.free (); } /** @@ -321,13 +320,13 @@ object *tmp; int got_one = 0; - SockList sl (MAXSOCKBUF); + packet sl; sl.printf ("delinv %d", op->count); - Send_With_Handling (&pl->contr->socket, &sl); + pl->contr->socket->send_packet (sl); sl.reset (); - sl.printf ("item%d ", pl->contr->socket.itemcmd); + sl.printf ("item%d ", pl->contr->socket->itemcmd); sl << uint32 (op->count); @@ -342,7 +341,7 @@ if (LOOK_OBJ (head)) { - add_object_to_socklist (pl->contr->socket, sl, head); + add_object_to_socklist (*pl->contr->socket, sl, head); got_one++; @@ -350,11 +349,12 @@ * items (especially with some of the bags out there) to * overflow the buffer. IF so, send multiple item commands. */ - if (sl.len >= (MAXSOCKBUF - MAXITEMLEN)) + if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) { - Send_With_Handling (&pl->contr->socket, &sl); - sprintf ((char *) sl.buf, "item%d ", pl->contr->socket.itemcmd); - sl.len = strlen ((char *) sl.buf); + pl->contr->socket->send_packet (sl); + + sl.reset (); + sl.printf ("item%d ", pl->contr->socket->itemcmd); sl << uint32 (op->count); got_one = 0; } @@ -362,9 +362,8 @@ } if (got_one) - Send_With_Handling (&pl->contr->socket, &sl); + pl->contr->socket->send_packet (sl); - sl.free (); } /** @@ -398,7 +397,7 @@ LOG (llevDebug, "We have not sent item %s (%d)\n", &op->name, op->count); } - SockList sl (MAXSOCKBUF); + packet sl; sl << "upditem " << uint8 (flags); @@ -426,8 +425,8 @@ if (flags & UPD_FACE) { - if (!(pl->contr->socket.faces_sent[op->face->number] & NS_FACESENT_FACE)) - esrv_send_face (&pl->contr->socket, op->face->number, 0); + if (!(pl->contr->socket->faces_sent[op->face->number] & NS_FACESENT_FACE)) + esrv_send_face (pl->contr->socket, op->face->number, 0); sl << uint32 (op->face->number); } @@ -491,8 +490,7 @@ if (flags & UPD_NROF) sl << uint32 (op->nrof); - Send_With_Handling (&pl->contr->socket, &sl); - sl.free (); + pl->contr->socket->send_packet (sl); } /** @@ -512,26 +510,25 @@ */ if (!op->env) { - pl->contr->socket.update_look = 1; + pl->contr->socket->update_look = 1; return; } } - SockList sl (MAXSOCKBUF); + packet sl; - sl.printf ("item%d ", pl->contr->socket.itemcmd); + sl.printf ("item%d ", pl->contr->socket->itemcmd); if (op->head) op = op->head; sl << uint32 (op->env ? op->env->count : 0); - add_object_to_socklist (pl->contr->socket, sl, op); + add_object_to_socklist (*pl->contr->socket, sl, op); - Send_With_Handling (&pl->contr->socket, &sl); + pl->contr->socket->send_packet (sl); SET_FLAG (op, FLAG_CLIENT_SENT); - sl.free (); } /** @@ -542,13 +539,12 @@ void esrv_del_item (player *pl, int tag) { - SockList sl (MAXSOCKBUF); + packet sl; sl << "delitem " << uint32 (tag); - Send_With_Handling (&pl->socket, &sl); - sl.free (); + pl->socket->send_packet (sl); } @@ -629,8 +625,8 @@ /* If the high bit is set, player applied a pseudo object. */ if (tag & 0x80000000) { - pl->socket.look_position = tag & 0x7fffffff; - pl->socket.update_look = 1; + pl->socket->look_position = tag & 0x7fffffff; + pl->socket->update_look = 1; return; } @@ -765,10 +761,10 @@ } dy = atoi (cp); - if (FABS (dx) > pl->socket.mapx / 2 || FABS (dy) > pl->socket.mapy / 2) + if (FABS (dx) > pl->socket->mapx / 2 || FABS (dy) > pl->socket->mapy / 2) return; - if (pl->blocked_los[dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]) + if (pl->blocked_los[dx + pl->socket->mapx / 2][dy + pl->socket->mapy / 2]) return; look_at (pl->ob, dx, dy);