version 1.22 | | version 1.23 |
---|
| | |
| | |
/* | | /* |
* static char *rcsid_item_c = | | * static char *rcsid_item_c = |
* "$Id: item.c,v 1.22 2002/04/19 05:28:13 mwedel Exp $"; | | * "$Id: item.c,v 1.23 2002/05/31 04:18:39 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
void esrv_draw_look(object *pl) | | void esrv_draw_look(object *pl) |
{ | | { |
object *tmp, *last; | | object *tmp, *last; |
int flags, got_one=0,anim_speed, start_look=0, end_look=0; | | int flags, got_one=0,anim_speed, start_look=0, end_look=0, len; |
SockList sl; | | SockList sl; |
char buf[MAX_BUF]; | | char buf[MAX_BUF], *item_p,item_n[MAX_BUF]; |
| | |
if (!pl->contr->socket.update_look) { | | if (!pl->contr->socket.update_look) { |
LOG(llevDebug,"esrv_draw_look called when update_look was not set\n"); | | LOG(llevDebug,"esrv_draw_look called when update_look was not set\n"); |
| | |
sl.buf=malloc(MAXSOCKBUF); | | sl.buf=malloc(MAXSOCKBUF); |
| | |
Write_String_To_Socket(&pl->contr->socket, "delinv 0", strlen("delinv 0")); | | Write_String_To_Socket(&pl->contr->socket, "delinv 0", strlen("delinv 0")); |
strcpy((char*)sl.buf,"item1 "); | | sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd); |
sl.len=strlen((char*)sl.buf); | | sl.len=strlen((char*)sl.buf); |
| | |
SockList_AddInt(&sl, 0); | | SockList_AddInt(&sl, 0); |
| | |
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(tmp, FLAG_NO_PICK) ? -1 : WEIGHT(tmp)); |
SockList_AddInt(&sl, tmp->face->number); | | SockList_AddInt(&sl, tmp->face->number); |
if (pl->contr->socket.sc_version>=1024) { | | |
int len; | | |
char *item_p,item_n[MAX_BUF]; | | |
| | |
strncpy(item_n,query_base_name(tmp, 0),127); | | strncpy(item_n,query_base_name(tmp, 0),127); |
item_n[127]=0; | | item_n[127]=0; |
| | |
SockList_AddChar(&sl, (char ) len); | | SockList_AddChar(&sl, (char ) len); |
memcpy(sl.buf+sl.len, item_n, len); | | memcpy(sl.buf+sl.len, item_n, len); |
sl.len += len; | | sl.len += len; |
} else | | |
add_stringlen_to_sockbuf(query_base_name(tmp,0), &sl); | | |
| | |
SockList_AddShort(&sl,tmp->animation_id); | | SockList_AddShort(&sl,tmp->animation_id); |
anim_speed=0; | | anim_speed=0; |
| | |
} | | } |
SockList_AddChar(&sl, (char) anim_speed); | | SockList_AddChar(&sl, (char) anim_speed); |
SockList_AddInt(&sl, tmp->nrof); | | SockList_AddInt(&sl, tmp->nrof); |
| | |
| | if (pl->contr->socket.itemcmd == 2) |
| | SockList_AddShort(&sl, tmp->client_type); |
| | |
SET_FLAG(tmp, FLAG_CLIENT_SENT); | | SET_FLAG(tmp, FLAG_CLIENT_SENT); |
got_one++; | | got_one++; |
| | |
if (sl.len > (MAXSOCKBUF-MAXITEMLEN)) { | | if (sl.len > (MAXSOCKBUF-MAXITEMLEN)) { |
Send_With_Handling(&pl->contr->socket, &sl); | | Send_With_Handling(&pl->contr->socket, &sl); |
strcpy((char*)sl.buf,"item1 "); | | sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd); |
sl.len=strlen((char*)sl.buf); | | sl.len=strlen((char*)sl.buf); |
SockList_AddInt(&sl, 0); | | SockList_AddInt(&sl, 0); |
got_one=0; | | got_one=0; |
| | |
void esrv_send_inventory(object *pl, object *op) | | void esrv_send_inventory(object *pl, object *op) |
{ | | { |
object *tmp; | | object *tmp; |
int flags, got_one=0, anim_speed; | | int flags, got_one=0, anim_speed, len; |
SockList sl; | | SockList sl; |
char item_n[MAX_BUF]; | | char item_n[MAX_BUF], *item_p; |
| | |
sl.buf=malloc(MAXSOCKBUF); | | sl.buf=malloc(MAXSOCKBUF); |
| | |
| | |
sl.len=strlen((char*)sl.buf); | | sl.len=strlen((char*)sl.buf); |
Send_With_Handling(&pl->contr->socket, &sl); | | Send_With_Handling(&pl->contr->socket, &sl); |
| | |
strcpy((char*)sl.buf,"item1 "); | | sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd); |
sl.len=strlen((char*)sl.buf); | | sl.len=strlen((char*)sl.buf); |
| | |
SockList_AddInt(&sl, op->count); | | SockList_AddInt(&sl, op->count); |
| | |
SockList_AddInt(&sl, QUERY_FLAG(tmp, FLAG_NO_PICK) ? -1 : WEIGHT(tmp)); | | SockList_AddInt(&sl, QUERY_FLAG(tmp, FLAG_NO_PICK) ? -1 : WEIGHT(tmp)); |
SockList_AddInt(&sl, tmp->face->number); | | SockList_AddInt(&sl, tmp->face->number); |
| | |
if (pl->contr->socket.sc_version>=1024) { | | |
int len; | | |
char *item_p; | | |
| | |
strncpy(item_n,query_base_name(tmp, 0),127); | | strncpy(item_n,query_base_name(tmp, 0),127); |
item_n[127]=0; | | item_n[127]=0; |
len=strlen(item_n); | | len=strlen(item_n); |
| | |
SockList_AddChar(&sl, (char) len); | | SockList_AddChar(&sl, (char) len); |
memcpy(sl.buf+sl.len, item_n, len); | | memcpy(sl.buf+sl.len, item_n, len); |
sl.len += len; | | sl.len += len; |
} else | | |
add_stringlen_to_sockbuf(query_base_name(tmp,0), &sl); | | |
| | |
SockList_AddShort(&sl,tmp->animation_id); | | SockList_AddShort(&sl,tmp->animation_id); |
anim_speed=0; | | anim_speed=0; |
| | |
} | | } |
SockList_AddChar(&sl, (char)anim_speed); | | SockList_AddChar(&sl, (char)anim_speed); |
SockList_AddInt(&sl, tmp->nrof); | | SockList_AddInt(&sl, tmp->nrof); |
| | if (pl->contr->socket.itemcmd == 2) |
| | SockList_AddShort(&sl, tmp->client_type); |
SET_FLAG(tmp, FLAG_CLIENT_SENT); | | SET_FLAG(tmp, 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 |
* items (especially with some of the bags out there) to | | * items (especially with some of the bags out there) to |
* overflow the buffer. IF so, send multiple item1 commands. | | * overflow the buffer. IF so, send multiple item commands. |
*/ | | */ |
if (sl.len > (MAXSOCKBUF-MAXITEMLEN)) { | | if (sl.len > (MAXSOCKBUF-MAXITEMLEN)) { |
Send_With_Handling(&pl->contr->socket, &sl); | | Send_With_Handling(&pl->contr->socket, &sl); |
strcpy((char*)sl.buf,"item1 "); | | sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd); |
sl.len=strlen((char*)sl.buf); | | sl.len=strlen((char*)sl.buf); |
SockList_AddInt(&sl, op->count); | | SockList_AddInt(&sl, op->count); |
got_one=0; | | got_one=0; |
| | |
SockList_AddInt(&sl, op->face->number); | | SockList_AddInt(&sl, op->face->number); |
} | | } |
if (flags & UPD_NAME) { | | if (flags & UPD_NAME) { |
if (pl->contr->socket.sc_version>=1024) { | | |
int len; | | int len; |
char *item_p, item_n[MAX_BUF]; | | char *item_p, item_n[MAX_BUF]; |
| | |
| | |
SockList_AddChar(&sl, (char)len); | | SockList_AddChar(&sl, (char)len); |
memcpy(sl.buf+sl.len, item_n, len); | | memcpy(sl.buf+sl.len, item_n, len); |
sl.len += len; | | sl.len += len; |
} else | | |
add_stringlen_to_sockbuf(query_base_name(op,0), &sl); | | |
} | | } |
if (flags & UPD_ANIM) | | if (flags & UPD_ANIM) |
SockList_AddShort(&sl,op->animation_id); | | SockList_AddShort(&sl,op->animation_id); |
| | |
| | |
void esrv_send_item(object *pl, object*op) | | void esrv_send_item(object *pl, object*op) |
{ | | { |
int anim_speed; | | int anim_speed, len; |
SockList sl; | | SockList sl; |
char item_n[MAX_BUF]; | | char item_n[MAX_BUF], *item_p; |
| | |
/* If this is not the player object, do some more checks */ | | /* If this is not the player object, do some more checks */ |
if (op!=pl) { | | if (op!=pl) { |
| | |
| | |
sl.buf=malloc(MAXSOCKBUF); | | sl.buf=malloc(MAXSOCKBUF); |
| | |
strcpy((char*)sl.buf,"item1 "); | | sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd); |
sl.len=strlen((char*)sl.buf); | | sl.len=strlen((char*)sl.buf); |
| | |
SockList_AddInt(&sl, op->env? op->env->count:0); | | SockList_AddInt(&sl, op->env? op->env->count:0); |
| | |
SockList_AddInt(&sl, WEIGHT(op)); | | SockList_AddInt(&sl, WEIGHT(op)); |
SockList_AddInt(&sl, op->face->number); | | SockList_AddInt(&sl, op->face->number); |
| | |
if (pl->contr->socket.sc_version>=1024) { | | |
int len; | | |
char *item_p; | | |
| | |
strncpy(item_n,query_base_name(op, 0),127); | | strncpy(item_n,query_base_name(op, 0),127); |
item_n[127]=0; | | item_n[127]=0; |
len=strlen(item_n); | | len=strlen(item_n); |
| | |
SockList_AddChar(&sl, (char)len); | | SockList_AddChar(&sl, (char)len); |
memcpy(sl.buf+sl.len, item_n, len); | | memcpy(sl.buf+sl.len, item_n, len); |
sl.len += len; | | sl.len += len; |
} else | | |
add_stringlen_to_sockbuf(query_base_name(op,0), &sl); | | |
| | |
SockList_AddShort(&sl,op->animation_id); | | SockList_AddShort(&sl,op->animation_id); |
anim_speed=0; | | anim_speed=0; |
| | |
} | | } |
SockList_AddChar(&sl, (char)anim_speed); | | SockList_AddChar(&sl, (char)anim_speed); |
SockList_AddInt(&sl, op->nrof); | | SockList_AddInt(&sl, op->nrof); |
| | if (pl->contr->socket.itemcmd == 2) |
| | SockList_AddShort(&sl, op->client_type); |
| | |
Send_With_Handling(&pl->contr->socket, &sl); | | Send_With_Handling(&pl->contr->socket, &sl); |
SET_FLAG(op, FLAG_CLIENT_SENT); | | SET_FLAG(op, FLAG_CLIENT_SENT); |
free(sl.buf); | | free(sl.buf); |