… | |
… | |
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 | */ |
335 | void |
335 | void |
336 | esrv_draw_look (object *pl) |
336 | esrv_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. |