36 #define MAXITEMLEN 300 50 unsigned int flags = 0;
87 if (op->type == CONTAINER
118 int flags, len, anim_speed;
129 if (head->animation == NULL) {
130 LOG(
llevError,
"Item %s in %s (%d,%d) has FLAG_ANIMATE but animation_id 0\n", head->name, (head->env ? head->env->name : (head->map ? head->map->path :
"???")), head->x, head->y);
132 }
else if (!ns->
anims_sent[head->animation->num])
141 if (!head->custom_name) {
144 len = strlen(item_n);
149 len = strlen(item_n);
150 safe_strncpy(item_p, head->custom_name,
sizeof(item_p));
152 strncpy(item_n+len+1, item_p, 127);
154 item_n[len+1+127] = 0;
155 len += strlen(item_n+1+len)+1;
161 if (head->anim_speed)
162 anim_speed = head->anim_speed;
164 if (
FABS(head->speed) < 0.001)
166 else if (
FABS(head->speed) >= 1.0)
169 anim_speed = (int)(1.0/
FABS(head->speed));
171 if (anim_speed > 255)
189 int got_one = 0, start_look = 0, end_look = 0, objects_sent = 0;
193 if (!pl->contr->socket.update_look) {
194 LOG(
llevDebug,
"esrv_draw_look called when update_look was not set\n");
197 pl->contr->socket.update_look = 0;
206 if (pl->contr->transport)
207 for (tmp = pl->contr->transport->inv; tmp && tmp->above; tmp = tmp->above)
210 for (tmp =
GET_MAP_OB(pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above)
224 if (pl->contr->socket.look_position) {
225 int overhead = 1+(pl->contr->transport != NULL);
226 int prev_len = pl->contr->socket.num_look_objects-overhead-(pl->contr->socket.look_position > pl->contr->socket.num_look_objects-overhead);
231 snprintf(buf,
sizeof(buf),
"Click here to see previous group of items");
241 if (pl->contr->transport) {
261 if (start_look++ < pl->contr->socket.look_position)
265 if (objects_sent >= pl->contr->socket.num_look_objects) {
270 SockList_AddInt(&sl, 0x80000000|(pl->contr->socket.look_position+end_look-1));
274 snprintf(buf,
sizeof(buf),
"Click here to see next group of items");
308 int got_one = 0, start_look = 0, end_look = 0, objects_sent = 0;
311 int prev_len = pl->contr->socket.num_look_objects - 2 - (((pl->contr->socket.container_position > pl->contr->socket.num_look_objects - 1)) ? 1 : 0);
322 if (pl != op && pl->contr->socket.container_position) {
323 SockList_AddInt(&sl, 0x80000000|
MAX(0, pl->contr->socket.container_position-prev_len));
327 snprintf(buf,
sizeof(buf),
"Click here to see previous group of items");
341 if (LOOK_OBJ(head)) {
342 if (start_look++ < pl->contr->socket.container_position && pl != op)
346 if (pl != op && objects_sent >= pl->contr->socket.num_look_objects) {
351 SockList_AddInt(&sl, 0x80000000|(pl->contr->socket.container_position + end_look - 1));
355 snprintf(buf,
sizeof(buf),
"Click here to see next group of items");
383 if (pl != op && pl->contr->socket.container_position) {
388 pl->contr->socket.container_position =
MAX(0, pl->contr->socket.container_position - prev_len);
453 op->contr->last_weight = weight;
467 if (!op->custom_name) {
471 strlcpy(item_n, op->custom_name,
sizeof(item_n)-1);
472 strlcpy(item_p, op->custom_name,
sizeof(item_p));
475 len = strlen(item_n)+1;
476 snprintf(item_n+len,
sizeof(item_n)-len,
"%s", item_p);
477 len += strlen(item_n+len);
488 anim_speed = op->anim_speed;
490 if (
FABS(op->speed) < 0.001)
492 else if (
FABS(op->speed) >= 1.0)
495 anim_speed = (int)(1.0/
FABS(op->speed));
497 if (anim_speed > 255)
524 pl->contr->socket.update_look = 1;
543 if (pl->contr != NULL && pl->container != NULL && op->env == pl->container)
544 pl->contr->socket.update_inventory = 1;
562 if (pl->
ob->container != NULL && ob->env == pl->
ob->container)
579 if (pl->count == count)
583 if (op->count == count)
585 else if (op->type == CONTAINER && pl->container == op) {
587 if (tmp->count == count)
594 if (HEAD(op)->count == count)
596 else if (op->type == CONTAINER && pl->container == op) {
598 if (tmp->count == count)
604 if (pl->contr->transport) {
606 if (tmp->count == count)
618 if (len <= 0 || !buf) {
619 LOG(
llevDebug,
"Player '%s' sent bogus examine_cmd information\n", pl->
ob->name);
626 LOG(
llevDebug,
"Player '%s' tried to examine the unknown object (%ld)\n", pl->
ob->name, tag);
637 if (!buf || len <= 0) {
638 LOG(
llevDebug,
"Player '%s' sent bogus apply_cmd information\n", pl->
ob->name);
653 if (tag&0x80000000) {
654 if (pl->
ob->container != NULL) {
666 LOG(
llevDebug,
"Player '%s' tried to apply the unknown object (%d)\n", pl->
ob->name, tag);
680 LOG(
llevDebug,
"Player '%s' sent bogus lock_item_cmd information\n", pl->
ob->name);
689 "Could not find object to lock/unlock");
695 "Can't lock/unlock an item on the ground");
698 if (op->env != pl->
ob) {
700 "Can't lock/unlock an item not directly in your inventory");
708 "Unlocked %s.", name);
738 LOG(
llevDebug,
"Player '%s' sent bogus mark_item_cmd information\n", pl->
ob->name);
746 "Could not find object to mark");
780 for (tmp =
GET_MAP_OB(m, x, y); tmp != NULL && tmp->above != NULL; tmp = tmp->above)
808 if ((HEAD(tmp)->inv != NULL && (tmp->type != CONTAINER && tmp->type != FLESH))
820 "You see nothing there.");
832 if (len <= 0 || !buf) {
833 LOG(
llevDebug,
"Player '%s' sent bogus look_at_cmd information\n", pl->
ob->name);
838 if (!(cp = strchr(buf,
' '))) {
857 LOG(
llevDebug,
"Player '%s' tried to move an unknown object (%lu)\n", pl->name, (
unsigned long)tag);
864 if (!to && !pl->contr->transport) {
867 if (op->map && !op->env) {
883 }
else if (to == pl->count) {
888 pl->contr->count = nrof;
893 if (pl->contr->transport) {
901 LOG(
llevDebug,
"Player '%s' tried to move object to the unknown location (%d)\n", pl->name, to);
909 if (env->type == CONTAINER
918 object *scroll, *spell, *marked, *inscription, *currentspell;
919 tag_t tscroll, tspell, tmarked;
923 LOG(
llevDebug,
"Player %s sent an invalid inscribe command.\n", pl->
ob->name);
937 LOG(
llevDebug,
"Player %s sent an invalid inscribe command.\n", pl->
ob->name);
945 LOG(
llevDebug,
"Player %s sent an invalid scroll for inscribe command.\n", pl->
ob->name);
951 LOG(
llevDebug,
"Player %s sent an invalid spell for inscribe command.\n", pl->
ob->name);
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
#define FLAG_KNOWN_BLESSED
void inscribe_scroll_cmd(char *buf, int len, player *pl)
void SockList_AddPrintf(SockList *sl, const char *format,...)
void look_at(object *op, int dx, int dy)
void SockList_Reset(SockList *sl)
void lock_item_cmd(uint8_t *data, int len, player *pl)
void esrv_del_item(player *pl, object *ob)
void SockList_Init(SockList *sl)
void esrv_draw_look(object *pl)
int GetInt_String(const unsigned char *data)
#define MSG_TYPE_COMMAND_FAILURE
void esrv_send_item(object *pl, object *op)
static unsigned int query_flags(const object *op)
void apply_cmd(char *buf, int len, player *pl)
#define MSG_TYPE_COMMAND_EXAMINE
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
void pick_up(object *op, object *alt)
void query_base_name(const object *op, int plural, char *buf, size_t size)
void SockList_AddShort(SockList *sl, uint16_t data)
void esrv_move_object(object *pl, tag_t to, tag_t tag, long nrof)
object * ranges[range_size]
uint16_t container_position
void SockList_AddInt(SockList *sl, uint32_t data)
void look_at_cmd(char *buf, int len, player *pl)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
#define FOR_OB_AND_BELOW_FINISH()
#define FLAG_KNOWN_MAGICAL
int apply_by_living(object *pl, object *op, int aflag, int quiet)
int is_identified(const object *op)
int object_can_pick(const object *who, const object *item)
#define MSG_TYPE_COMMAND_SUCCESS
#define MSG_TYPE_COMMAND_ERROR
void SockList_Term(SockList *sl)
int sack_can_hold(const object *pl, const object *sack, const object *op, uint32_t nrof)
void mark_item_cmd(uint8_t *data, int len, player *pl)
void SockList_AddString(SockList *sl, const char *data)
void examine(object *op, object *tmp)
#define MSG_TYPE_SKILL_FAILURE
static void add_object_to_socklist(socket_struct *ns, SockList *sl, object *head)
size_t SockList_Avail(const SockList *sl)
uint32_t update_inventory
int8_t blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]
#define QUERY_FLAG(xyz, p)
#define CLEAR_FLAG(xyz, p)
void put_object_in_sack(object *op, object *sack, object *tmp, uint32_t nrof)
void examine_cmd(char *buf, int len, player *pl)
static const flag_definition flags[]
void inventory(object *op, object *inv)
void SockList_AddChar(SockList *sl, unsigned char c)
#define FLAG_KNOWN_CURSED
void esrv_update_item(int flags, object *pl, object *op)
void esrv_send_animation(socket_struct *ns, const Animations *anim)
void esrv_send_face(socket_struct *ns, const Face *face, int nocache)
uint8_t anims_sent[MAXANIMNUM]
void SockList_AddLen8Data(SockList *sl, const void *data, size_t len)
static object * esrv_get_ob_from_count(object *pl, tag_t count)
int transport_can_hold(const object *transport, const object *op, int nrof)
object * object_merge(object *op, object *top)
void query_short_name(const object *op, char *buf, size_t size)
int out_of_map(mapstruct *m, int x, int y)
#define FOR_OB_AND_BELOW_PREPARE(op_)
#define GET_MAP_OB(M, X, Y)
void LOG(LogLevel logLevel, const char *format,...)
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
void query_name(const object *op, char *buf, size_t size)
int write_on_item(object *pl, const char *params, object *skill)
object * drop_object(object *op, object *tmp, uint32_t nrof)
object * find_skill_by_name(object *who, const char *name)
void esrv_send_inventory(object *pl, object *op)
size_t strlcpy(char *dst, const char *src, size_t size)
#define FOR_INV_PREPARE(op_, it_)
void Send_With_Handling(socket_struct *ns, SockList *sl)