ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/item.C
(Generate patch)

Comparing deliantra/server/socket/item.C (file contents):
Revision 1.1 by elmex, Sun Aug 13 17:16:06 2006 UTC vs.
Revision 1.2 by root, Tue Aug 29 07:34:01 2006 UTC

1 1
2/* 2/*
3 * static char *rcsid_item_c = 3 * static char *rcsid_item_c =
4 * "$Id: item.C,v 1.1 2006/08/13 17:16:06 elmex Exp $"; 4 * "$Id: item.C,v 1.2 2006/08/29 07:34:01 root Exp $";
5 */ 5 */
6 6
7/* 7/*
8 CrossFire, A Multiplayer game for X-windows 8 CrossFire, A Multiplayer game for X-windows
9 9
219 219
220 if(QUERY_FLAG(pl, FLAG_REMOVED) || pl->map == NULL || 220 if(QUERY_FLAG(pl, FLAG_REMOVED) || pl->map == NULL ||
221 pl->map->in_memory != MAP_IN_MEMORY || out_of_map(pl->map,pl->x,pl->y)) 221 pl->map->in_memory != MAP_IN_MEMORY || out_of_map(pl->map,pl->x,pl->y))
222 return; 222 return;
223 223
224 if (pl->contr->transport)
225 for (tmp=pl->contr->transport->inv; tmp && tmp->above;tmp=tmp->above) ;
226 else
227 for (tmp=get_map_ob(pl->map,pl->x,pl->y); tmp && tmp->above;tmp=tmp->above) ; 224 for (tmp=get_map_ob(pl->map,pl->x,pl->y); tmp && tmp->above;tmp=tmp->above) ;
228 225
229 sl.buf= (unsigned char *) malloc(MAXSOCKBUF); 226 sl.buf= (unsigned char *) malloc(MAXSOCKBUF);
230 227
231 Write_String_To_Socket(&pl->contr->socket, "delinv 0", strlen("delinv 0")); 228 Write_String_To_Socket(&pl->contr->socket, "delinv 0", strlen("delinv 0"));
232 sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd); 229 sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd);
247 SockList_AddShort(&sl,0); 244 SockList_AddShort(&sl,0);
248 SockList_AddChar(&sl, 0); 245 SockList_AddChar(&sl, 0);
249 SockList_AddInt(&sl, 0); 246 SockList_AddInt(&sl, 0);
250 if (pl->contr->socket.itemcmd == 2) 247 if (pl->contr->socket.itemcmd == 2)
251 SockList_AddShort(&sl, 0); 248 SockList_AddShort(&sl, 0);
252 }
253
254 if (pl->contr->transport) {
255 add_object_to_socklist(&pl->contr->socket, &sl, pl->contr->transport);
256 got_one++;
257 } 249 }
258 250
259 for (last=NULL; tmp!=last; tmp=tmp->below) { 251 for (last=NULL; tmp!=last; tmp=tmp->below) {
260 object *head; 252 object *head;
261 253
400 SockList_AddInt(&sl, query_flags(op)); 392 SockList_AddInt(&sl, query_flags(op));
401 393
402 if (flags & UPD_WEIGHT) { 394 if (flags & UPD_WEIGHT) {
403 sint32 weight = WEIGHT(op); 395 sint32 weight = WEIGHT(op);
404 396
405 /* TRANSPORTS are odd - they sort of look like containers, yet can't be
406 * picked up. So we don't to send the weight, as it is odd that you see
407 * weight sometimes and not other (the draw_look won't send it
408 * for example.
409 */
410 SockList_AddInt(&sl, QUERY_FLAG(op, FLAG_NO_PICK) ? -1 : weight); 397 SockList_AddInt(&sl, QUERY_FLAG(op, FLAG_NO_PICK) ? -1 : weight);
411 if (pl == op) { 398 if (pl == op) {
412 op->contr->last_weight = weight; 399 op->contr->last_weight = weight;
413 } 400 }
414 } 401 }
557 else if (op->type == CONTAINER && pl->container == op) 544 else if (op->type == CONTAINER && pl->container == op)
558 for(tmp = op->inv; tmp; tmp = tmp->below) 545 for(tmp = op->inv; tmp; tmp = tmp->below)
559 if (tmp->count == count) 546 if (tmp->count == count)
560 return tmp; 547 return tmp;
561 548
562 if (pl->contr->transport) {
563 for(tmp = pl->contr->transport->inv; tmp; tmp = tmp->below)
564 if (tmp->count == count)
565 return tmp;
566 }
567 return NULL; 549 return NULL;
568} 550}
569 551
570 552
571/** Client wants to examine some object. So lets do so. */ 553/** Client wants to examine some object. So lets do so. */
737 LOG(llevDebug, "Player '%s' tried to move an unknown object (%ld)\n", 719 LOG(llevDebug, "Player '%s' tried to move an unknown object (%ld)\n",
738 pl->name, tag); 720 pl->name, tag);
739 return; 721 return;
740 } 722 }
741 723
742 /* If on a transport, you don't drop to the ground - you drop to the
743 * transport.
744 */
745 if (!to && !pl->contr->transport) { /* drop it to the ground */ 724 if (!to) { /* drop it to the ground */
746/* LOG(llevDebug, "Drop it on the ground.\n");*/ 725/* LOG(llevDebug, "Drop it on the ground.\n");*/
747 726
748 if (op->map && !op->env) { 727 if (op->map && !op->env) {
749/* LOG(llevDebug,"Dropping object to ground that is already on ground\n");*/ 728/* LOG(llevDebug,"Dropping object to ground that is already on ground\n");*/
750 return; 729 return;
770 749
771 pl->contr->count = nrof; 750 pl->contr->count = nrof;
772 pick_up(pl, op); 751 pick_up(pl, op);
773 return ; 752 return ;
774 } 753 }
775 /* If not dropped or picked up, we are putting it into a sack */
776 if (pl->contr->transport) {
777 if (can_pick(pl, op) && transport_can_hold(pl->contr->transport, op, nrof)) {
778 put_object_in_sack (pl, pl->contr->transport, op, nrof);
779 }
780 } else {
781 env = esrv_get_ob_from_count(pl, to); 754 env = esrv_get_ob_from_count(pl, to);
782 if (!env) { 755 if (!env) {
783 LOG(llevDebug, 756 LOG(llevDebug,
784 "Player '%s' tried to move object to the unknown location (%d)\n", 757 "Player '%s' tried to move object to the unknown location (%d)\n",
785 pl->name, to); 758 pl->name, to);
786 return; 759 return;
787 } 760 }
788 /* put_object_in_sack presumes that necessary sanity checking 761 /* put_object_in_sack presumes that necessary sanity checking
789 * has already been done (eg, it can be picked up and fits in 762 * has already been done (eg, it can be picked up and fits in
790 * in a sack, so check for those things. We should also check 763 * in a sack, so check for those things. We should also check
791 * an make sure env is in fact a container for that matter. 764 * an make sure env is in fact a container for that matter.
792 */ 765 */
793 if (env->type == CONTAINER 766 if (env->type == CONTAINER
794 && can_pick(pl, op) && sack_can_hold(pl, env, op, nrof)) { 767 && can_pick(pl, op) && sack_can_hold(pl, env, op, nrof)) {
795 put_object_in_sack (pl, env, op, nrof); 768 put_object_in_sack (pl, env, op, nrof);
796 }
797 } 769 }
798} 770}
799 771
800 772

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines