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.13 by root, Thu Dec 14 00:13:26 2006 UTC vs.
Revision 1.23 by root, Fri Dec 15 19:59:20 2006 UTC

33 */ 33 */
34 34
35 35
36#include <global.h> 36#include <global.h>
37#include <object.h> /* LOOK_OBJ */ 37#include <object.h> /* LOOK_OBJ */
38#include <newclient.h>
39#include <newserver.h>
40#include <sproto.h> 38#include <sproto.h>
41 39
42/** This is the maximum number of bytes we expect any one item to take up */ 40/** This is the maximum number of bytes we expect any one item to take up */
43#define MAXITEMLEN 300 41#define MAXITEMLEN 300
44 42
45/******************************************************************************* 43/*******************************************************************************
46 * 44 *
47 * Functions related to sending object data to the client. 45 * Functions related to sending object data to the client.
48 * 46 *
49 ******************************************************************************/ 47 ******************************************************************************/
50
51/**
52 * Adds string to socklist.
53 *
54 * This is a simple function that we use a lot here. It basically
55 * adds the specified buffer into the socklist, but prepends a
56 * single byte in length. If the data is longer than that byte, it is
57 * truncated approprately.
58 */
59inline void
60add_stringlen_to_sockbuf (const char *buf, SockList * sl)
61{
62 int len;
63
64 len = strlen (buf);
65 if (len > 255)
66 len = 255;
67 SockList_AddChar (sl, (char) len);
68 strncpy ((char *) sl->buf + sl->len, buf, len);
69 sl->len += len;
70}
71 48
72/** 49/**
73 * This is a similar to query_name, but returns flags 50 * This is a similar to query_name, but returns flags
74 * to be sended to client. 51 * to be sended to client.
75 */ 52 */
130 flags |= F_LOCKED; 107 flags |= F_LOCKED;
131 108
132 return flags; 109 return flags;
133} 110}
134 111
135/* Used in the send_look to put object head into SockList 112/* Used in the send_look to put object head into packet
136 * sl for socket ns. Need socket to know if we need to send 113 * sl for socket ns. Need socket to know if we need to send
137 * animation of face to the client. 114 * animation of face to the client.
138 */ 115 */
139static void 116static void
140add_object_to_socklist (NewSocket &ns, SockList &sl, object *head) 117add_object_to_socklist (client &ns, packet &sl, object *head)
141{ 118{
142 int flags, len, anim_speed; 119 int flags, len, anim_speed;
143 char item_n[MAX_BUF]; 120 char item_n[MAX_BUF];
144 const char *item_p; 121 const char *item_p;
145 122
220{ 197{
221 object *tmp, *last; 198 object *tmp, *last;
222 int got_one = 0, start_look = 0, end_look = 0; 199 int got_one = 0, start_look = 0, end_look = 0;
223 char buf[MAX_BUF]; 200 char buf[MAX_BUF];
224 201
225 if (!pl->contr->socket.update_look) 202 if (!pl->contr->socket->update_look)
226 { 203 {
227 LOG (llevDebug, "esrv_draw_look called when update_look was not set\n"); 204 LOG (llevDebug, "esrv_draw_look called when update_look was not set\n");
228 return; 205 return;
229 } 206 }
230 else 207 else
231 pl->contr->socket.update_look = 0; 208 pl->contr->socket->update_look = 0;
232 209
233 if (QUERY_FLAG (pl, FLAG_REMOVED) 210 if (QUERY_FLAG (pl, FLAG_REMOVED)
234 || !pl->map 211 || !pl->map
235 || pl->map->in_memory != MAP_IN_MEMORY 212 || pl->map->in_memory != MAP_IN_MEMORY
236 || out_of_map (pl->map, pl->x, pl->y)) 213 || out_of_map (pl->map, pl->x, pl->y))
237 return; 214 return;
238 215
239 for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above); 216 for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above)
217 ;
240 218
241 SockList sl (MAXSOCKBUF); 219 packet sl;
242 220
243 Write_String_To_Socket (&pl->contr->socket, "delinv 0", sizeof ("delinv 0") - 1); 221 pl->contr->socket->send_packet ("delinv 0");
244 222
245 sl.printf ("item%d ", pl->contr->socket.itemcmd); 223 sl.printf ("item%d ", pl->contr->socket->itemcmd);
246 224
247 sl << uint32 (0); 225 sl << uint32 (0);
248 226
249 if (!(pl->contr->socket.faces_sent[empty_face->number] & NS_FACESENT_FACE)) 227 if (!(pl->contr->socket->faces_sent[empty_face->number] & NS_FACESENT_FACE))
250 esrv_send_face (&pl->contr->socket, empty_face->number, 0); 228 esrv_send_face (pl->contr->socket, empty_face->number, 0);
251 229
252 if (pl->contr->socket.look_position) 230 if (pl->contr->socket->look_position)
253 { 231 {
232 char buf[80];
233 snprintf (buf, 80, "Apply this to see %d previous items", NUM_LOOK_OBJECTS);
234
254 sl << uint32 (0x80000000 | (pl->contr->socket.look_position - NUM_LOOK_OBJECTS)) 235 sl << uint32 (0x80000000 | (pl->contr->socket->look_position - NUM_LOOK_OBJECTS))
255 << uint32 (0) 236 << uint32 (0)
256 << sint32 (-1) 237 << sint32 (-1)
257 << uint32 (empty_face->number); 238 << uint32 (empty_face->number)
258 239 << data8 (buf)
259 sl.printf ("Click here to see %d previous items", NUM_LOOK_OBJECTS);
260
261 sl << uint16 (0) 240 << uint16 (0)
262 << uint8 (0) 241 << uint8 (0)
263 << uint32 (0); 242 << uint32 (0);
264 243
265 if (pl->contr->socket.itemcmd == 2) 244 if (pl->contr->socket->itemcmd == 2)
266 sl << uint16 (0); 245 sl << uint16 (0);
267 } 246 }
268 247
269 for (last = NULL; tmp != last; tmp = tmp->below) 248 for (last = NULL; tmp != last; tmp = tmp->below)
270 { 249 {
277 last = last->below; 256 last = last->below;
278 } 257 }
279 258
280 if (LOOK_OBJ (tmp)) 259 if (LOOK_OBJ (tmp))
281 { 260 {
282 if (++start_look < pl->contr->socket.look_position) 261 if (++start_look < pl->contr->socket->look_position)
283 continue; 262 continue;
284 263
285 end_look++; 264 end_look++;
286 265
287 if (end_look > NUM_LOOK_OBJECTS) 266 if (end_look > NUM_LOOK_OBJECTS)
288 { 267 {
289 /* What we basically do is make a 'fake' object - when the user applies it, 268 /* What we basically do is make a 'fake' object - when the user applies it,
290 * we notice the special tag the object has, and act accordingly. 269 * we notice the special tag the object has, and act accordingly.
291 */ 270 */
292 SockList_AddInt (&sl, 0x80000000 | (pl->contr->socket.look_position + NUM_LOOK_OBJECTS)); 271 sl << uint32 (0x80000000 | (pl->contr->socket->look_position + NUM_LOOK_OBJECTS))
293 SockList_AddInt (&sl, 0); 272 << uint32 (0)
294 SockList_AddInt (&sl, (uint32) - 1); 273 << uint32 ((uint32) - 1)
295 SockList_AddInt (&sl, empty_face->number); 274 << uint32 (empty_face->number)
296 sprintf (buf, "Click here to see next group of items"); 275 << data8 ("Apply this to see next group of items")
297 add_stringlen_to_sockbuf (buf, &sl); 276 << uint16 (0)
298 SockList_AddShort (&sl, 0); 277 << uint8 (0)
299 SockList_AddChar (&sl, 0); 278 << uint32 (0);
300 SockList_AddInt (&sl, 0); 279
301 if (pl->contr->socket.itemcmd == 2) 280 if (pl->contr->socket->itemcmd == 2)
302 SockList_AddShort (&sl, 0); 281 sl << uint16 (0);
282
303 break; 283 break;
304 } 284 }
285
305 if (tmp->head) 286 if (tmp->head)
306 head = tmp->head; 287 head = tmp->head;
307 else 288 else
308 head = tmp; 289 head = tmp;
309 290
310 add_object_to_socklist (pl->contr->socket, sl, head); 291 add_object_to_socklist (*pl->contr->socket, sl, head);
311 got_one++; 292 got_one++;
312 293
313 if (sl.len >= (MAXSOCKBUF - MAXITEMLEN)) 294 if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN))
314 { 295 {
315 Send_With_Handling (&pl->contr->socket, &sl); 296 pl->contr->socket->send_packet (sl);
297
298 sl.reset ();
316 sprintf ((char *) sl.buf, "item%d ", pl->contr->socket.itemcmd); 299 sl.printf ("item%d ", pl->contr->socket->itemcmd);
317 sl.len = strlen ((char *) sl.buf); 300 sl << uint32 (0);
318 SockList_AddInt (&sl, 0);
319 got_one = 0; 301 got_one = 0;
320 } 302 }
321 } /* If LOOK_OBJ() */ 303 } /* If LOOK_OBJ() */
322 } 304 }
323 305
324 if (got_one) 306 if (got_one)
325 Send_With_Handling (&pl->contr->socket, &sl); 307 pl->contr->socket->send_packet (sl);
326 308
327 sl.free ();
328} 309}
329 310
330/** 311/**
331 * Sends whole inventory. 312 * Sends whole inventory.
332 */ 313 */
333void 314void
334esrv_send_inventory (object *pl, object *op) 315esrv_send_inventory (object *pl, object *op)
335{ 316{
336 object *tmp; 317 object *tmp;
337 int got_one = 0; 318 int got_one = 0;
338 SockList sl;
339 319
340 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 320 packet sl;
341 321
342 sprintf ((char *) sl.buf, "delinv %d", op->count); 322 sl.printf ("delinv %d", op->count);
343 sl.len = strlen ((char *) sl.buf); 323 pl->contr->socket->send_packet (sl);
344 Send_With_Handling (&pl->contr->socket, &sl);
345 324
325 sl.reset ();
346 sprintf ((char *) sl.buf, "item%d ", pl->contr->socket.itemcmd); 326 sl.printf ("item%d ", pl->contr->socket->itemcmd);
347 sl.len = strlen ((char *) sl.buf);
348 327
349 SockList_AddInt (&sl, op->count); 328 sl << uint32 (op->count);
350 329
351 for (tmp = op->inv; tmp; tmp = tmp->below) 330 for (tmp = op->inv; tmp; tmp = tmp->below)
352 { 331 {
353 object *head; 332 object *head;
354 333
357 else 336 else
358 head = tmp; 337 head = tmp;
359 338
360 if (LOOK_OBJ (head)) 339 if (LOOK_OBJ (head))
361 { 340 {
362 add_object_to_socklist (pl->contr->socket, sl, head); 341 add_object_to_socklist (*pl->contr->socket, sl, head);
363 342
364 got_one++; 343 got_one++;
365 344
366 /* IT is possible for players to accumulate a huge amount of 345 /* IT is possible for players to accumulate a huge amount of
367 * items (especially with some of the bags out there) to 346 * items (especially with some of the bags out there) to
368 * overflow the buffer. IF so, send multiple item commands. 347 * overflow the buffer. IF so, send multiple item commands.
369 */ 348 */
370 if (sl.len >= (MAXSOCKBUF - MAXITEMLEN)) 349 if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN))
371 { 350 {
372 Send_With_Handling (&pl->contr->socket, &sl); 351 pl->contr->socket->send_packet (sl);
352
353 sl.reset ();
373 sprintf ((char *) sl.buf, "item%d ", pl->contr->socket.itemcmd); 354 sl.printf ("item%d ", pl->contr->socket->itemcmd);
374 sl.len = strlen ((char *) sl.buf); 355 sl << uint32 (op->count);
375 SockList_AddInt (&sl, op->count);
376 got_one = 0; 356 got_one = 0;
377 } 357 }
378 } /* If LOOK_OBJ() */ 358 } /* If LOOK_OBJ() */
379 } 359 }
360
380 if (got_one) 361 if (got_one)
381 Send_With_Handling (&pl->contr->socket, &sl); 362 pl->contr->socket->send_packet (sl);
382 sl.free (); 363
383} 364}
384 365
385/** 366/**
386 * Updates object *op for player *pl. 367 * Updates object *op for player *pl.
387 * 368 *
391 */ 372 */
392 373
393void 374void
394esrv_update_item (int flags, object *pl, object *op) 375esrv_update_item (int flags, object *pl, object *op)
395{ 376{
396 SockList sl;
397
398 /* If we have a request to send the player item, skip a few checks. */ 377 /* If we have a request to send the player item, skip a few checks. */
399 if (op != pl) 378 if (op != pl)
400 { 379 {
401 if (!LOOK_OBJ (op)) 380 if (!LOOK_OBJ (op))
402 return; 381 return;
413 * and track back the call. 392 * and track back the call.
414 */ 393 */
415 LOG (llevDebug, "We have not sent item %s (%d)\n", &op->name, op->count); 394 LOG (llevDebug, "We have not sent item %s (%d)\n", &op->name, op->count);
416 } 395 }
417 396
418 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 397 packet sl;
419 398
420 strcpy ((char *) sl.buf, "upditem "); 399 sl << "upditem "
421 sl.len = strlen ((char *) sl.buf); 400 << uint8 (flags);
422
423 SockList_AddChar (&sl, (char) flags);
424 401
425 if (op->head) 402 if (op->head)
426 op = op->head; 403 op = op->head;
427 404
428 SockList_AddInt (&sl, op->count); 405 sl << uint32 (op->count);
429 406
430 if (flags & UPD_LOCATION) 407 if (flags & UPD_LOCATION)
431 SockList_AddInt (&sl, op->env ? op->env->count : 0); 408 sl << uint32 (op->env ? op->env->count : 0);
432 409
433 if (flags & UPD_FLAGS) 410 if (flags & UPD_FLAGS)
434 SockList_AddInt (&sl, query_flags (op)); 411 sl << uint32 (query_flags (op));
435 412
436 if (flags & UPD_WEIGHT) 413 if (flags & UPD_WEIGHT)
437 { 414 {
438 sint32 weight = WEIGHT (op); 415 sint32 weight = WEIGHT (op);
439 416
440 SockList_AddInt (&sl, QUERY_FLAG (op, FLAG_NO_PICK) ? -1 : weight); 417 sl << uint32 (QUERY_FLAG (op, FLAG_NO_PICK) ? -1 : weight);
418
441 if (pl == op) 419 if (pl == op)
442 {
443 op->contr->last_weight = weight; 420 op->contr->last_weight = weight;
444 }
445 } 421 }
446 422
447 if (flags & UPD_FACE) 423 if (flags & UPD_FACE)
448 { 424 {
449 if (!(pl->contr->socket.faces_sent[op->face->number] & NS_FACESENT_FACE)) 425 if (!(pl->contr->socket->faces_sent[op->face->number] & NS_FACESENT_FACE))
450 esrv_send_face (&pl->contr->socket, op->face->number, 0); 426 esrv_send_face (pl->contr->socket, op->face->number, 0);
451 SockList_AddInt (&sl, op->face->number); 427
428 sl << uint32 (op->face->number);
452 } 429 }
453 430
454 if (flags & UPD_NAME) 431 if (flags & UPD_NAME)
455 { 432 {
456 int len; 433 int len;
473 } 450 }
474 451
475 strncpy (item_n + len + 1, item_p, 127); 452 strncpy (item_n + len + 1, item_p, 127);
476 item_n[254] = 0; 453 item_n[254] = 0;
477 len += strlen (item_n + 1 + len) + 1; 454 len += strlen (item_n + 1 + len) + 1;
478 SockList_AddChar (&sl, (char) len); 455
479 memcpy (sl.buf + sl.len, item_n, len); 456 sl << data8 (item_n, len);
480 sl.len += len;
481 } 457 }
482 458
483 if (flags & UPD_ANIM) 459 if (flags & UPD_ANIM)
484 SockList_AddShort (&sl, op->animation_id); 460 sl << uint16 (op->animation_id);
485 461
486 if (flags & UPD_ANIMSPEED) 462 if (flags & UPD_ANIMSPEED)
487 { 463 {
488 int anim_speed = 0; 464 int anim_speed = 0;
489 465
498 else if (FABS (op->speed) >= 1.0) 474 else if (FABS (op->speed) >= 1.0)
499 anim_speed = 1; 475 anim_speed = 1;
500 else 476 else
501 anim_speed = (int) (1.0 / FABS (op->speed)); 477 anim_speed = (int) (1.0 / FABS (op->speed));
502 } 478 }
479
503 if (anim_speed > 255) 480 if (anim_speed > 255)
504 anim_speed = 255; 481 anim_speed = 255;
505 } 482 }
506 SockList_AddChar (&sl, (char) anim_speed); 483
484 sl << uint8 (anim_speed);
507 } 485 }
486
508 if (flags & UPD_NROF) 487 if (flags & UPD_NROF)
509 SockList_AddInt (&sl, op->nrof); 488 sl << uint32 (op->nrof);
510 489
511 Send_With_Handling (&pl->contr->socket, &sl); 490 pl->contr->socket->send_packet (sl);
512 sl.free ();
513} 491}
514 492
515/** 493/**
516 * Sends item's info to player. 494 * Sends item's info to player.
517 */ 495 */
518void 496void
519esrv_send_item (object *pl, object *op) 497esrv_send_item (object *pl, object *op)
520{ 498{
521 SockList sl;
522
523 /* If this is not the player object, do some more checks */ 499 /* If this is not the player object, do some more checks */
524 if (op != pl) 500 if (op != pl)
525 { 501 {
526 /* We only send 'visibile' objects to the client */ 502 /* We only send 'visibile' objects to the client */
527 if (!LOOK_OBJ (op)) 503 if (!LOOK_OBJ (op))
529 /* if the item is on the ground, mark that the look needs to 505 /* if the item is on the ground, mark that the look needs to
530 * be updated. 506 * be updated.
531 */ 507 */
532 if (!op->env) 508 if (!op->env)
533 { 509 {
534 pl->contr->socket.update_look = 1; 510 pl->contr->socket->update_look = 1;
535 return; 511 return;
536 } 512 }
537 } 513 }
538 514
539 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 515 packet sl;
540 516
541 sprintf ((char *) sl.buf, "item%d ", pl->contr->socket.itemcmd); 517 sl.printf ("item%d ", pl->contr->socket->itemcmd);
542 sl.len = strlen ((char *) sl.buf);
543 518
544 if (op->head) 519 if (op->head)
545 op = op->head; 520 op = op->head;
546 521
547 SockList_AddInt (&sl, op->env ? op->env->count : 0); 522 sl << uint32 (op->env ? op->env->count : 0);
548 523
549 add_object_to_socklist (pl->contr->socket, sl, op); 524 add_object_to_socklist (*pl->contr->socket, sl, op);
550 525
551 Send_With_Handling (&pl->contr->socket, &sl); 526 pl->contr->socket->send_packet (sl);
552 SET_FLAG (op, FLAG_CLIENT_SENT); 527 SET_FLAG (op, FLAG_CLIENT_SENT);
553 528
554 sl.free ();
555} 529}
556 530
557/** 531/**
558 * Tells the client to delete an item. Uses the item 532 * Tells the client to delete an item. Uses the item
559 * command with a -1 location. 533 * command with a -1 location.
560 */ 534 */
561 535
562void 536void
563esrv_del_item (player *pl, int tag) 537esrv_del_item (player *pl, int tag)
564{ 538{
565 SockList sl; 539 packet sl;
566 540
567 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 541 sl << "delitem "
542 << uint32 (tag);
568 543
569 strcpy ((char *) sl.buf, "delitem "); 544 pl->socket->send_packet (sl);
570 sl.len = strlen ((char *) sl.buf);
571 SockList_AddInt (&sl, tag);
572
573 Send_With_Handling (&pl->socket, &sl);
574 sl.free ();
575} 545}
576 546
577 547
578/******************************************************************************* 548/*******************************************************************************
579 * 549 *
650 return; 620 return;
651 621
652 /* If the high bit is set, player applied a pseudo object. */ 622 /* If the high bit is set, player applied a pseudo object. */
653 if (tag & 0x80000000) 623 if (tag & 0x80000000)
654 { 624 {
655 pl->socket.look_position = tag & 0x7fffffff; 625 pl->socket->look_position = tag & 0x7fffffff;
656 pl->socket.update_look = 1; 626 pl->socket->update_look = 1;
657 return; 627 return;
658 } 628 }
659 629
660 object *op = esrv_get_ob_from_count (pl->ob, tag); 630 object *op = esrv_get_ob_from_count (pl->ob, tag);
661 631
668 player_apply (pl->ob, op, 0, 0); 638 player_apply (pl->ob, op, 0, 0);
669} 639}
670 640
671/** Client wants to apply some object. Lets do so. */ 641/** Client wants to apply some object. Lets do so. */
672void 642void
673LockItem (uint8 *data, int len, player *pl) 643LockItem (char *data, int len, player *pl)
674{ 644{
675 int flag = data[0]; 645 int flag = data[0];
676 tag_t tag = net_uint32 (data + 1); 646 tag_t tag = net_uint32 ((uint8 *)data + 1);
677 object *op = esrv_get_ob_from_count (pl->ob, tag); 647 object *op = esrv_get_ob_from_count (pl->ob, tag);
678 648
679 if (!op) 649 if (!op)
680 { 650 {
681 new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to lock/unlock"); 651 new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to lock/unlock");
690 esrv_update_item (UPD_FLAGS, pl->ob, op); 660 esrv_update_item (UPD_FLAGS, pl->ob, op);
691} 661}
692 662
693/** Client wants to apply some object. Lets do so. */ 663/** Client wants to apply some object. Lets do so. */
694void 664void
695MarkItem (uint8 * data, int len, player *pl) 665MarkItem (char *data, int len, player *pl)
696{ 666{
697 tag_t tag = net_uint32 (data); 667 tag_t tag = net_uint32 ((uint8 *)data);
698 object *op = esrv_get_ob_from_count (pl->ob, tag); 668 object *op = esrv_get_ob_from_count (pl->ob, tag);
699 669
700 if (!op) 670 if (!op)
701 { 671 {
702 new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to mark"); 672 new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to mark");
786 { 756 {
787 return; 757 return;
788 } 758 }
789 dy = atoi (cp); 759 dy = atoi (cp);
790 760
791 if (FABS (dx) > pl->socket.mapx / 2 || FABS (dy) > pl->socket.mapy / 2) 761 if (FABS (dx) > pl->socket->mapx / 2 || FABS (dy) > pl->socket->mapy / 2)
792 return; 762 return;
793 763
794 if (pl->blocked_los[dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]) 764 if (pl->blocked_los[dx + pl->socket->mapx / 2][dy + pl->socket->mapy / 2])
795 return; 765 return;
796 766
797 look_at (pl->ob, dx, dy); 767 look_at (pl->ob, dx, dy);
798} 768}
799 769
810 return; 780 return;
811 } 781 }
812 782
813 if (!to) 783 if (!to)
814 { /* drop it to the ground */ 784 { /* drop it to the ground */
815
816/* LOG(llevDebug, "Drop it on the ground.\n");*/
817
818 if (op->map && !op->env) 785 if (op->map && !op->env)
819 {
820
821/* LOG(llevDebug,"Dropping object to ground that is already on ground\n");*/
822 return; 786 return;
823 } 787
824 /* If it is an active container, then we should drop all objects 788 /* If it is an active container, then we should drop all objects
825 * in the container and not the container itself. 789 * in the container and not the container itself.
826 */ 790 */
827 if (op->inv && QUERY_FLAG (op, FLAG_APPLIED)) 791 if (op->inv && QUERY_FLAG (op, FLAG_APPLIED))
828 { 792 {
831 for (current = op->inv; current != NULL; current = next) 795 for (current = op->inv; current != NULL; current = next)
832 { 796 {
833 next = current->below; 797 next = current->below;
834 drop_object (pl, current, 0); 798 drop_object (pl, current, 0);
835 } 799 }
800
836 esrv_update_item (UPD_WEIGHT, pl, op); 801 esrv_update_item (UPD_WEIGHT, pl, op);
837 } 802 }
838 else 803 else
839 { 804 {
840 drop_object (pl, op, nrof); 805 drop_object (pl, op, nrof);
849 814
850 pl->contr->count = nrof; 815 pl->contr->count = nrof;
851 pick_up (pl, op); 816 pick_up (pl, op);
852 return; 817 return;
853 } 818 }
819
854 env = esrv_get_ob_from_count (pl, to); 820 env = esrv_get_ob_from_count (pl, to);
855 if (!env) 821 if (!env)
856 { 822 {
857 LOG (llevDebug, "Player '%s' tried to move object to the unknown location (%d)\n", &pl->name, to); 823 LOG (llevDebug, "Player '%s' tried to move object to the unknown location (%d)\n", &pl->name, to);
858 return; 824 return;
859 } 825 }
826
860 /* put_object_in_sack presumes that necessary sanity checking 827 /* put_object_in_sack presumes that necessary sanity checking
861 * has already been done (eg, it can be picked up and fits in 828 * has already been done (eg, it can be picked up and fits in
862 * in a sack, so check for those things. We should also check 829 * in a sack, so check for those things. We should also check
863 * an make sure env is in fact a container for that matter. 830 * an make sure env is in fact a container for that matter.
864 */ 831 */
865 if (env->type == CONTAINER && can_pick (pl, op) && sack_can_hold (pl, env, op, nrof)) 832 if (env->type == CONTAINER && can_pick (pl, op) && sack_can_hold (pl, env, op, nrof))
866 { 833 {
867 put_object_in_sack (pl, env, op, nrof); 834 put_object_in_sack (pl, env, op, nrof);
868 } 835 }
869} 836}
837

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines