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.45 by root, Mon May 28 21:22:26 2007 UTC vs.
Revision 1.48 by root, Fri Jun 8 09:18:31 2007 UTC

331 * Send the look window. Don't need to do animations here 331 * Send the look window. Don't need to do animations here
332 * This sends all the faces to the client, not just updates. This is 332 * This sends all the faces to the client, not just updates. This is
333 * because object ordering would otherwise be inconsistent. 333 * because object ordering would otherwise be inconsistent.
334 */ 334 */
335void 335void
336esrv_draw_look (object *pl) 336esrv_draw_look (player *pl)
337{ 337{
338 int got_one = 0, start_look = 0, end_look = 0; 338 int got_one = 0, start_look = 0, end_look = 0;
339 339
340 object *ob = pl->ob;
341
340 if (!pl->contr->ns->update_look) 342 if (!pl->ns->update_look)
341 { 343 {
342 LOG (llevDebug, "esrv_draw_look called when update_look was not set (player %s)\n", &pl->name); 344 LOG (llevDebug, "esrv_draw_look called when update_look was not set (player %s)\n", &ob->name);
343 return; 345 return;
344 } 346 }
345 else 347 else
346 pl->contr->ns->update_look = 0; 348 pl->ns->update_look = 0;
347 349
348 if (QUERY_FLAG (pl, FLAG_REMOVED) 350 if (QUERY_FLAG (ob, FLAG_REMOVED)
349 || !pl->map 351 || !ob->map
350 || pl->map->in_memory != MAP_IN_MEMORY 352 || ob->map->in_memory != MAP_IN_MEMORY
351 || out_of_map (pl->map, pl->x, pl->y)) 353 || out_of_map (ob->map, ob->x, ob->y))
352 return; 354 return;
353 355
354 pl->contr->ns->send_packet ("delinv 0"); 356 pl->ns->send_packet ("delinv 0");
355 357
356 packet sl; 358 packet sl;
357 sl.printf ("item%d ", pl->contr->ns->itemcmd); 359 sl.printf ("item%d ", pl->ns->itemcmd);
358 360
359 sl << uint32 (0); 361 sl << uint32 (0);
360 362
361 pl->contr->ns->send_face (empty_face); 363 pl->ns->send_face (empty_face);
362 pl->contr->ns->flush_fx (); 364 pl->ns->flush_fx ();
363 365
364 if (pl->contr->ns->look_position) 366 if (pl->ns->look_position)
365 { 367 {
366 char buf[80]; 368 char buf[80];
367 snprintf (buf, 80, "Apply this to see %d previous items", FLOORBOX_PAGESIZE); 369 snprintf (buf, 80, "Apply this to see %d previous items", FLOORBOX_PAGESIZE);
368 370
369 sl << uint32 (0x80000000 | (pl->contr->ns->look_position - FLOORBOX_PAGESIZE)) 371 sl << uint32 (0x80000000 | (pl->ns->look_position - FLOORBOX_PAGESIZE))
370 << uint32 (0) 372 << uint32 (0)
371 << sint32 (-1) 373 << sint32 (-1)
372 << uint32 (empty_face) 374 << uint32 (empty_face)
373 << data8 (buf) 375 << data8 (buf)
374 << uint16 (0) 376 << uint16 (0)
375 << uint8 (0) 377 << uint8 (0)
376 << uint32 (0); 378 << uint32 (0);
377 379
378 if (pl->contr->ns->itemcmd == 2) 380 if (pl->ns->itemcmd == 2)
379 sl << uint16 (0); 381 sl << uint16 (0);
380 } 382 }
381 383
382 object *tmp = pl->ms ().top; 384 object *tmp = ob->ms ().top;
383 for (object *last = 0; tmp != last; tmp = tmp->below) 385 for (object *last = 0; tmp != last; tmp = tmp->below)
384 { 386 {
385 object *head; 387 object *head;
386 388
387 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !last) 389 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !last)
391 last = last->below; 393 last = last->below;
392 } 394 }
393 395
394 if (tmp->client_visible ()) 396 if (tmp->client_visible ())
395 { 397 {
396 if (++start_look < pl->contr->ns->look_position) 398 if (++start_look < pl->ns->look_position)
397 continue; 399 continue;
398 400
399 end_look++; 401 end_look++;
400 402
401 if (end_look > FLOORBOX_PAGESIZE) 403 if (end_look > FLOORBOX_PAGESIZE)
402 { 404 {
403 /* What we basically do is make a 'fake' object - when the user applies it, 405 /* What we basically do is make a 'fake' object - when the user applies it,
404 * we notice the special tag the object has, and act accordingly. 406 * we notice the special tag the object has, and act accordingly.
405 */ 407 */
406 sl << uint32 (0x80000000 | (pl->contr->ns->look_position + FLOORBOX_PAGESIZE)) 408 sl << uint32 (0x80000000 | (pl->ns->look_position + FLOORBOX_PAGESIZE))
407 << uint32 (0) 409 << uint32 (0)
408 << uint32 ((uint32) - 1) 410 << uint32 ((uint32) - 1)
409 << uint32 (empty_face) 411 << uint32 (empty_face)
410 << data8 ("Apply this to see next group of items") 412 << data8 ("Apply this to see next group of items")
411 << uint16 (0) 413 << uint16 (0)
412 << uint8 (0) 414 << uint8 (0)
413 << uint32 (0); 415 << uint32 (0);
414 416
415 if (pl->contr->ns->itemcmd == 2) 417 if (pl->ns->itemcmd == 2)
416 sl << uint16 (0); 418 sl << uint16 (0);
417 419
418 break; 420 break;
419 } 421 }
420 422
421 if (tmp->head) 423 if (tmp->head)
422 head = tmp->head; 424 head = tmp->head;
423 else 425 else
424 head = tmp; 426 head = tmp;
425 427
426 add_object_to_socklist (*pl->contr->ns, sl, head); 428 add_object_to_socklist (*pl->ns, sl, head);
427 got_one++; 429 got_one++;
428 430
429 if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) 431 if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN))
430 { 432 {
431 pl->contr->ns->send_packet (sl); 433 pl->ns->send_packet (sl);
432 434
433 sl.reset (); 435 sl.reset ();
434 sl.printf ("item%d ", pl->contr->ns->itemcmd); 436 sl.printf ("item%d ", pl->ns->itemcmd);
435 sl << uint32 (0); 437 sl << uint32 (0);
436 got_one = 0; 438 got_one = 0;
437 } 439 }
438 } 440 }
439 } 441 }
440 442
441 if (got_one) 443 if (got_one)
442 pl->contr->ns->send_packet (sl); 444 pl->ns->send_packet (sl);
443 445
444} 446}
445 447
446/** 448/**
447 * Sends whole inventory. 449 * Sends whole inventory.
834 * look_at prints items on the specified square. 836 * look_at prints items on the specified square.
835 * 837 *
836 * [ removed EARTHWALL check and added check for containers inventory. 838 * [ removed EARTHWALL check and added check for containers inventory.
837 * Tero.Haatanen@lut.fi ] 839 * Tero.Haatanen@lut.fi ]
838 */ 840 */
839void 841static void
840look_at (object *op, int dx, int dy) 842look_at (player *pl, int dx, int dy)
841{ 843{
842 object *tmp; 844 object *ob = pl->ob;
845
846 maptile *m = pl->observe->map;
847 sint16 x = pl->observe->x + dx;
848 sint16 y = pl->observe->y + dy;
849
850 if (!xy_normalise (m, x, y))
851 {
852 new_draw_info (NDI_UNIQUE, 0, ob, "You see nothing there.");
853 return;
854 }
855
843 int flag = 0; 856 int flag = 0;
844 sint16 x, y;
845 maptile *m;
846 857
847 x = op->x + dx; 858 for (object *tmp = m->at (x, y).top; tmp; tmp = tmp->below)
848 y = op->y + dy;
849
850 if (out_of_map (op->map, x, y))
851 return;
852
853 m = get_map_from_coord (op->map, &x, &y);
854 if (!m)
855 return;
856
857 for (tmp = GET_MAP_OB (m, x, y); tmp && tmp->above; tmp = tmp->above)
858 ; 859 {
859
860 for (; tmp; tmp = tmp->below)
861 {
862 if (tmp->invisible && !QUERY_FLAG (op, FLAG_WIZ)) 860 if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ))
863 continue; 861 continue;
864 862
865 if (!flag) 863 if (!flag)
866 { 864 {
867 if (dx || dy) 865 if (dx || dy)
868 new_draw_info (NDI_UNIQUE, 0, op, "There you see:"); 866 new_draw_info (NDI_UNIQUE, 0, ob, "There you see:");
869 else 867 else
870 {
871 clear_win_info (op);
872 new_draw_info (NDI_UNIQUE, 0, op, "You see:"); 868 new_draw_info (NDI_UNIQUE, 0, ob, "You see:");
873 } 869
874 flag = 1; 870 flag = 1;
875 } 871 }
876 872
877 if (QUERY_FLAG (op, FLAG_WIZ)) 873 if (QUERY_FLAG (ob, FLAG_WIZ))
878 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s (%d).", query_name (tmp), tmp->count); 874 new_draw_info_format (NDI_UNIQUE, 0, ob, "- %s (%d).", query_name (tmp), tmp->count);
879 else 875 else
880 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s.", query_name (tmp)); 876 new_draw_info_format (NDI_UNIQUE, 0, ob, "- %s.", query_name (tmp));
881 877
882 if (((tmp->inv != NULL || (tmp->head && tmp->head->inv)) && 878 if (((tmp->inv != NULL || (tmp->head && tmp->head->inv)) &&
883 (tmp->type != CONTAINER && tmp->type != FLESH)) || QUERY_FLAG (op, FLAG_WIZ)) 879 (tmp->type != CONTAINER && tmp->type != FLESH)) || QUERY_FLAG (ob, FLAG_WIZ))
884 inventory (op, tmp->head == NULL ? tmp : tmp->head); 880 inventory (ob, tmp->head == NULL ? tmp : tmp->head);
885 881
886 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !QUERY_FLAG (op, FLAG_WIZ)) /* don't continue under the floor */ 882 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !QUERY_FLAG (ob, FLAG_WIZ)) /* don't continue under the floor */
887 break; 883 break;
888 } 884 }
889 885
890 if (!flag) 886 if (!flag)
891 { 887 {
892 if (dx || dy) 888 if (dx || dy)
893 new_draw_info (NDI_UNIQUE, 0, op, "You see nothing there."); 889 new_draw_info (NDI_UNIQUE, 0, ob, "You see nothing there.");
894 else 890 else
895 new_draw_info (NDI_UNIQUE, 0, op, "You see nothing."); 891 new_draw_info (NDI_UNIQUE, 0, ob, "You see nothing.");
896 } 892 }
897} 893}
898 894
899/** Client wants to look at some object. Lets do so. */ 895/** Client wants to look at some object. Lets do so. */
900void 896void
901LookAt (char *buf, int len, player *pl) 897LookAt (char *buf, int len, player *pl)
902{ 898{
903 int dx, dy;
904 char *cp; 899 char *cp;
905 900
906 dx = atoi (buf); 901 int dx = atoi (buf);
907 if (!(cp = strchr (buf, ' '))) 902 if (!(cp = strchr (buf, ' ')))
908 return; 903 return;
909 904
910 dy = atoi (cp); 905 int dy = atoi (cp);
906
907 if (player *opl = pl->observe->contr)
908 if (client *ns = opl->ns)
909 {
911 if (fabs (dx) > pl->ns->mapx / 2 || fabs (dy) > pl->ns->mapy / 2) 910 if (fabs (dx) > ns->mapx / 2 || fabs (dy) > ns->mapy / 2)
912 return; 911 return;
913 912
914 if (pl->blocked_los[dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]) 913 if (opl->blocked_los[dx + ns->mapx / 2][dy + ns->mapy / 2])
915 return; 914 return;
915 }
916 916
917 look_at (pl->ob, dx, dy); 917 look_at (pl, dx, dy);
918} 918}
919 919
920/** Move an object to a new location */ 920/** Move an object to a new location */
921void 921void
922esrv_move_object (object *pl, tag_t to, tag_t tag, long nrof) 922esrv_move_object (object *pl, tag_t to, tag_t tag, long nrof)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines