--- deliantra/server/socket/item.C 2006/12/14 01:21:58 1.16 +++ deliantra/server/socket/item.C 2006/12/14 04:30:33 1.19 @@ -116,7 +116,7 @@ * animation of face to the client. */ static void -add_object_to_socklist (NewSocket &ns, packet &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 @@ -220,18 +220,18 @@ 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); + Send_With_Handling (pl->contr->socket, &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,7 +307,7 @@ } if (got_one) - Send_With_Handling (&pl->contr->socket, &sl); + Send_With_Handling (pl->contr->socket, &sl); } @@ -323,10 +323,10 @@ packet sl; sl.printf ("delinv %d", op->count); - Send_With_Handling (&pl->contr->socket, &sl); + Send_With_Handling (pl->contr->socket, &sl); sl.reset (); - sl.printf ("item%d ", pl->contr->socket.itemcmd); + sl.printf ("item%d ", pl->contr->socket->itemcmd); sl << uint32 (op->count); @@ -341,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++; @@ -349,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); + Send_With_Handling (pl->contr->socket, &sl); + + sl.reset (); + sl.printf ("item%d ", pl->contr->socket->itemcmd); sl << uint32 (op->count); got_one = 0; } @@ -361,7 +362,7 @@ } if (got_one) - Send_With_Handling (&pl->contr->socket, &sl); + Send_With_Handling (pl->contr->socket, &sl); } @@ -424,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); } @@ -489,7 +490,7 @@ if (flags & UPD_NROF) sl << uint32 (op->nrof); - Send_With_Handling (&pl->contr->socket, &sl); + Send_With_Handling (pl->contr->socket, &sl); } /** @@ -509,23 +510,23 @@ */ if (!op->env) { - pl->contr->socket.update_look = 1; + pl->contr->socket->update_look = 1; return; } } 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); + Send_With_Handling (pl->contr->socket, &sl); SET_FLAG (op, FLAG_CLIENT_SENT); } @@ -543,7 +544,7 @@ sl << "delitem " << uint32 (tag); - Send_With_Handling (&pl->socket, &sl); + Send_With_Handling (pl->socket, &sl); } @@ -624,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; } @@ -760,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);