--- deliantra/server/socket/item.C 2006/12/14 01:21:58 1.16 +++ deliantra/server/socket/item.C 2006/12/15 19:59:20 1.23 @@ -35,8 +35,6 @@ #include #include /* LOOK_OBJ */ -#include -#include #include /** This is the maximum number of bytes we expect any one item to take up */ @@ -116,7 +114,7 @@ * animation of face to the client. */ static void -add_object_to_socklist (NewSocket &ns, packet &sl, object *head) +add_object_to_socklist (client &ns, packet &sl, object *head) { int flags, len, anim_speed; char item_n[MAX_BUF]; @@ -201,13 +199,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,29 +218,30 @@ 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)) + char buf[80]; + snprintf (buf, 80, "Apply this to see %d previous items", NUM_LOOK_OBJECTS); + + sl << uint32 (0x80000000 | (pl->contr->socket->look_position - NUM_LOOK_OBJECTS)) << uint32 (0) << sint32 (-1) - << uint32 (empty_face->number); - - sl.printf ("Click here to see %d previous items", NUM_LOOK_OBJECTS); - - sl << uint16 (0) + << uint32 (empty_face->number) + << data8 (buf) + << uint16 (0) << uint8 (0) << uint32 (0); - if (pl->contr->socket.itemcmd == 2) + if (pl->contr->socket->itemcmd == 2) sl << uint16 (0); } @@ -259,7 +258,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,18 +268,16 @@ /* 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); - - sl.printf ("Click here to see next group of items"); - - sl << uint16 (0) + << uint32 (empty_face->number) + << data8 ("Apply this to see next group of items") + << uint16 (0) << uint8 (0) << uint32 (0); - if (pl->contr->socket.itemcmd == 2) + if (pl->contr->socket->itemcmd == 2) sl << uint16 (0); break; @@ -291,15 +288,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,7 +304,7 @@ } if (got_one) - Send_With_Handling (&pl->contr->socket, &sl); + pl->contr->socket->send_packet (sl); } @@ -323,10 +320,10 @@ 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); @@ -341,7 +338,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 +346,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; } @@ -361,7 +359,7 @@ } if (got_one) - Send_With_Handling (&pl->contr->socket, &sl); + pl->contr->socket->send_packet (sl); } @@ -424,8 +422,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 +487,7 @@ if (flags & UPD_NROF) sl << uint32 (op->nrof); - Send_With_Handling (&pl->contr->socket, &sl); + pl->contr->socket->send_packet (sl); } /** @@ -509,23 +507,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); + pl->contr->socket->send_packet (sl); SET_FLAG (op, FLAG_CLIENT_SENT); } @@ -543,7 +541,7 @@ sl << "delitem " << uint32 (tag); - Send_With_Handling (&pl->socket, &sl); + pl->socket->send_packet (sl); } @@ -624,8 +622,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; } @@ -642,10 +640,10 @@ /** Client wants to apply some object. Lets do so. */ void -LockItem (uint8 *data, int len, player *pl) +LockItem (char *data, int len, player *pl) { int flag = data[0]; - tag_t tag = net_uint32 (data + 1); + tag_t tag = net_uint32 ((uint8 *)data + 1); object *op = esrv_get_ob_from_count (pl->ob, tag); if (!op) @@ -664,9 +662,9 @@ /** Client wants to apply some object. Lets do so. */ void -MarkItem (uint8 * data, int len, player *pl) +MarkItem (char *data, int len, player *pl) { - tag_t tag = net_uint32 (data); + tag_t tag = net_uint32 ((uint8 *)data); object *op = esrv_get_ob_from_count (pl->ob, tag); if (!op) @@ -760,10 +758,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);