version 1.33 | | version 1.34 |
---|
| | |
| | |
/* | | /* |
* static char *rcsid_item_c = | | * static char *rcsid_item_c = |
* "$Id: item.c,v 1.33 2005/08/12 13:47:00 ryo_saeba Exp $"; | | * "$Id: item.c,v 1.34 2005/08/17 06:58:11 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
} | | } |
| | |
for (last=NULL; tmp!=last; tmp=tmp->below) { | | for (last=NULL; tmp!=last; tmp=tmp->below) { |
| | object *head; |
| | |
if (QUERY_FLAG(tmp, FLAG_IS_FLOOR) && !last) { | | if (QUERY_FLAG(tmp, FLAG_IS_FLOOR) && !last) { |
last = tmp->below; /* assumes double floor mode */ | | last = tmp->below; /* assumes double floor mode */ |
if (last && QUERY_FLAG(last, FLAG_IS_FLOOR)) | | if (last && QUERY_FLAG(last, FLAG_IS_FLOOR)) |
| | |
SockList_AddShort(&sl, 0); | | SockList_AddShort(&sl, 0); |
break; | | break; |
} | | } |
| | if (tmp->head) head = tmp->head; |
| | else head = tmp; |
| | |
flags = query_flags (tmp); | | flags = query_flags (head); |
if (QUERY_FLAG(tmp, FLAG_NO_PICK)) | | if (QUERY_FLAG(head, FLAG_NO_PICK)) |
flags |= F_NOPICK; | | flags |= F_NOPICK; |
if (!(pl->contr->socket.faces_sent[tmp->face->number] & NS_FACESENT_FACE)) | | if (!(pl->contr->socket.faces_sent[head->face->number] & NS_FACESENT_FACE)) |
esrv_send_face(&pl->contr->socket, tmp->face->number,0); | | esrv_send_face(&pl->contr->socket, head->face->number,0); |
| | |
if (QUERY_FLAG(tmp,FLAG_ANIMATE) && | | if (QUERY_FLAG(head,FLAG_ANIMATE) && |
!pl->contr->socket.anims_sent[tmp->animation_id]) | | !pl->contr->socket.anims_sent[head->animation_id]) |
esrv_send_animation(&pl->contr->socket, tmp->animation_id); | | esrv_send_animation(&pl->contr->socket, head->animation_id); |
| | |
SockList_AddInt(&sl, tmp->count); | | SockList_AddInt(&sl, head->count); |
SockList_AddInt(&sl, flags); | | SockList_AddInt(&sl, flags); |
SockList_AddInt(&sl, QUERY_FLAG(tmp, FLAG_NO_PICK) ? -1 : WEIGHT(tmp)); | | SockList_AddInt(&sl, QUERY_FLAG(head, FLAG_NO_PICK) ? -1 : WEIGHT(head)); |
SockList_AddInt(&sl, tmp->face->number); | | SockList_AddInt(&sl, head->face->number); |
| | |
if (!tmp->custom_name) { | | if (!head->custom_name) { |
strncpy(item_n,query_base_name(tmp, 0),127); | | strncpy(item_n,query_base_name(head, 0),127); |
item_n[127]=0; | | item_n[127]=0; |
len=strlen(item_n); | | len=strlen(item_n); |
item_p=query_base_name(tmp, 1); | | item_p=query_base_name(head, 1); |
} | | } else { |
else { | | strncpy(item_n,head->custom_name,127); |
strncpy(item_n,tmp->custom_name,127); | | |
item_n[127]=0; | | item_n[127]=0; |
len=strlen(item_n); | | len=strlen(item_n); |
item_p=tmp->custom_name; | | item_p=head->custom_name; |
} | | } |
strncpy(item_n+len+1, item_p, 127); | | strncpy(item_n+len+1, item_p, 127); |
item_n[254]=0; | | item_n[254]=0; |
| | |
memcpy(sl.buf+sl.len, item_n, len); | | memcpy(sl.buf+sl.len, item_n, len); |
sl.len += len; | | sl.len += len; |
| | |
SockList_AddShort(&sl,tmp->animation_id); | | SockList_AddShort(&sl,head->animation_id); |
anim_speed=0; | | anim_speed=0; |
if (QUERY_FLAG(tmp,FLAG_ANIMATE)) { | | if (QUERY_FLAG(head,FLAG_ANIMATE)) { |
if (tmp->anim_speed) anim_speed=tmp->anim_speed; | | if (head->anim_speed) anim_speed=head->anim_speed; |
else { | | else { |
if (FABS(tmp->speed)<0.001) anim_speed=255; | | if (FABS(head->speed)<0.001) anim_speed=255; |
else if (FABS(tmp->speed)>=1.0) anim_speed=1; | | else if (FABS(head->speed)>=1.0) anim_speed=1; |
else anim_speed = (int) (1.0/FABS(tmp->speed)); | | else anim_speed = (int) (1.0/FABS(head->speed)); |
} | | } |
if (anim_speed>255) anim_speed=255; | | if (anim_speed>255) anim_speed=255; |
} | | } |
SockList_AddChar(&sl, (char) anim_speed); | | SockList_AddChar(&sl, (char) anim_speed); |
SockList_AddInt(&sl, tmp->nrof); | | SockList_AddInt(&sl, head->nrof); |
| | |
if (pl->contr->socket.itemcmd == 2) | | if (pl->contr->socket.itemcmd == 2) |
SockList_AddShort(&sl, tmp->client_type); | | SockList_AddShort(&sl, head->client_type); |
| | |
SET_FLAG(tmp, FLAG_CLIENT_SENT); | | SET_FLAG(head, FLAG_CLIENT_SENT); |
got_one++; | | got_one++; |
| | |
if (sl.len > (MAXSOCKBUF-MAXITEMLEN)) { | | if (sl.len > (MAXSOCKBUF-MAXITEMLEN)) { |
| | |
SockList_AddInt(&sl, 0); | | SockList_AddInt(&sl, 0); |
got_one=0; | | got_one=0; |
} | | } |
} | | } /* If LOOK_OBJ() */ |
} | | } |
if (got_one) | | if (got_one) |
Send_With_Handling(&pl->contr->socket, &sl); | | Send_With_Handling(&pl->contr->socket, &sl); |
| | |
SockList_AddInt(&sl, op->count); | | SockList_AddInt(&sl, op->count); |
| | |
for (tmp=op->inv; tmp; tmp=tmp->below) { | | for (tmp=op->inv; tmp; tmp=tmp->below) { |
if (LOOK_OBJ(tmp)) { | | object *head; |
flags = query_flags (tmp); | | |
if (QUERY_FLAG(tmp, FLAG_NO_PICK)) | | if (tmp->head) head = tmp->head; |
| | else head = tmp; |
| | |
| | if (LOOK_OBJ(head)) { |
| | flags = query_flags (head); |
| | if (QUERY_FLAG(head, FLAG_NO_PICK)) |
flags |= F_NOPICK; | | flags |= F_NOPICK; |
if (!(pl->contr->socket.faces_sent[tmp->face->number] & NS_FACESENT_FACE)) | | if (!(pl->contr->socket.faces_sent[head->face->number] & NS_FACESENT_FACE)) |
esrv_send_face(&pl->contr->socket, tmp->face->number,0); | | esrv_send_face(&pl->contr->socket, head->face->number,0); |
if (QUERY_FLAG(tmp,FLAG_ANIMATE) && | | if (QUERY_FLAG(head,FLAG_ANIMATE) && |
!pl->contr->socket.anims_sent[tmp->animation_id]) | | !pl->contr->socket.anims_sent[head->animation_id]) |
esrv_send_animation(&pl->contr->socket, tmp->animation_id); | | esrv_send_animation(&pl->contr->socket, head->animation_id); |
SockList_AddInt(&sl, tmp->count); | | SockList_AddInt(&sl, head->count); |
SockList_AddInt(&sl, flags); | | SockList_AddInt(&sl, flags); |
SockList_AddInt(&sl, QUERY_FLAG(tmp, FLAG_NO_PICK) ? -1 : WEIGHT(tmp)); | | SockList_AddInt(&sl, QUERY_FLAG(head, FLAG_NO_PICK) ? -1 : WEIGHT(head)); |
SockList_AddInt(&sl, tmp->face->number); | | SockList_AddInt(&sl, head->face->number); |
| | |
if (!tmp->custom_name) { | | if (!head->custom_name) { |
strncpy(item_n,query_base_name(tmp, 0),127); | | strncpy(item_n,query_base_name(head, 0),127); |
item_n[127]=0; | | item_n[127]=0; |
len=strlen(item_n); | | len=strlen(item_n); |
item_p=query_base_name(tmp, 1); | | item_p=query_base_name(head, 1); |
} | | } else { |
else { | | strncpy(item_n,head->custom_name,127); |
strncpy(item_n,tmp->custom_name,127); | | |
item_n[127]=0; | | item_n[127]=0; |
len=strlen(item_n); | | len=strlen(item_n); |
item_p=tmp->custom_name; | | item_p=head->custom_name; |
} | | } |
strncpy(item_n+len+1, item_p, 127); | | strncpy(item_n+len+1, item_p, 127); |
item_n[254]=0; | | item_n[254]=0; |
| | |
memcpy(sl.buf+sl.len, item_n, len); | | memcpy(sl.buf+sl.len, item_n, len); |
sl.len += len; | | sl.len += len; |
| | |
SockList_AddShort(&sl,tmp->animation_id); | | SockList_AddShort(&sl,head->animation_id); |
anim_speed=0; | | anim_speed=0; |
if (QUERY_FLAG(tmp,FLAG_ANIMATE)) { | | if (QUERY_FLAG(head,FLAG_ANIMATE)) { |
if (tmp->anim_speed) anim_speed=tmp->anim_speed; | | if (head->anim_speed) anim_speed=head->anim_speed; |
else { | | else { |
if (FABS(tmp->speed)<0.001) anim_speed=255; | | if (FABS(head->speed)<0.001) anim_speed=255; |
else if (FABS(tmp->speed)>=1.0) anim_speed=1; | | else if (FABS(head->speed)>=1.0) anim_speed=1; |
else anim_speed = (int) (1.0/FABS(tmp->speed)); | | else anim_speed = (int) (1.0/FABS(head->speed)); |
} | | } |
if (anim_speed>255) anim_speed=255; | | if (anim_speed>255) anim_speed=255; |
} | | } |
SockList_AddChar(&sl, (char)anim_speed); | | SockList_AddChar(&sl, (char)anim_speed); |
SockList_AddInt(&sl, tmp->nrof); | | SockList_AddInt(&sl, head->nrof); |
if (pl->contr->socket.itemcmd == 2) | | if (pl->contr->socket.itemcmd == 2) |
SockList_AddShort(&sl, tmp->client_type); | | SockList_AddShort(&sl, head->client_type); |
SET_FLAG(tmp, FLAG_CLIENT_SENT); | | SET_FLAG(head, FLAG_CLIENT_SENT); |
got_one++; | | got_one++; |
| | |
/* IT is possible for players to accumulate a huge amount of | | /* IT is possible for players to accumulate a huge amount of |
| | |
SockList_AddInt(&sl, op->count); | | SockList_AddInt(&sl, op->count); |
got_one=0; | | got_one=0; |
} | | } |
} | | } /* If LOOK_OBJ() */ |
} | | } |
if (got_one) | | if (got_one) |
Send_With_Handling(&pl->contr->socket, &sl); | | Send_With_Handling(&pl->contr->socket, &sl); |
| | |
sl.len=strlen((char*)sl.buf); | | sl.len=strlen((char*)sl.buf); |
| | |
SockList_AddChar(&sl, (char) flags); | | SockList_AddChar(&sl, (char) flags); |
| | |
| | if (op->head) op=op->head; |
| | |
SockList_AddInt(&sl, op->count); | | SockList_AddInt(&sl, op->count); |
| | |
if (flags & UPD_LOCATION) | | if (flags & UPD_LOCATION) |
| | |
sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd); | | sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd); |
sl.len=strlen((char*)sl.buf); | | sl.len=strlen((char*)sl.buf); |
| | |
| | if (op->head) op=op->head; |
| | |
SockList_AddInt(&sl, op->env? op->env->count:0); | | SockList_AddInt(&sl, op->env? op->env->count:0); |
| | |
if (!(pl->contr->socket.faces_sent[op->face->number] & NS_FACESENT_FACE)) | | if (!(pl->contr->socket.faces_sent[op->face->number] & NS_FACESENT_FACE)) |