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.64 by root, Mon May 5 22:03:22 2008 UTC vs.
Revision 1.67 by root, Tue May 6 19:47:56 2008 UTC

253 * animation of face to the client. 253 * animation of face to the client.
254 */ 254 */
255static void 255static void
256add_object_to_socklist (client &ns, packet &sl, object *head) 256add_object_to_socklist (client &ns, packet &sl, object *head)
257{ 257{
258 int flags, len, anim_speed;
259 char item_n[MAX_BUF]; 258 char item_n[MAX_BUF];
260 const char *item_p; 259 const char *item_p;
261 260
262 flags = query_flags (head); 261 int flags = query_flags (head);
263 if (QUERY_FLAG (head, FLAG_NO_PICK)) 262 if (QUERY_FLAG (head, FLAG_NO_PICK))
264 flags |= F_NOPICK; 263 flags |= F_NOPICK;
265 264
266 ns.send_face (head->face, -50); 265 ns.send_face (head->face, -50);
267 ns.flush_fx (); 266 ns.flush_fx ();
272 sl << uint32 (head->count) 271 sl << uint32 (head->count)
273 << uint32 (flags) 272 << uint32 (flags)
274 << uint32 (QUERY_FLAG (head, FLAG_NO_PICK) ? -1 : head->client_weight ()) 273 << uint32 (QUERY_FLAG (head, FLAG_NO_PICK) ? -1 : head->client_weight ())
275 << uint32 (head->face); 274 << uint32 (head->face);
276 275
276 int len;
277
277 if (!head->custom_name) 278 if (!head->custom_name)
278 { 279 {
279 strncpy (item_n, query_base_name (head, 0), 127); 280 strncpy (item_n, query_base_name (head, 0), 127);
280 item_n[127] = 0; 281 item_n[127] = 0;
281 len = strlen (item_n); 282 len = strlen (item_n);
294 len += strlen (item_n + 1 + len) + 1; 295 len += strlen (item_n + 1 + len) + 1;
295 296
296 sl << data8 (item_n, len) 297 sl << data8 (item_n, len)
297 << uint16 (head->animation_id); 298 << uint16 (head->animation_id);
298 299
299 anim_speed = 0; 300 int anim_speed = !head->flag [FLAG_ANIMATE] ? 0
300 if (QUERY_FLAG (head, FLAG_ANIMATE)) 301 : head->anim_speed ? clamp (head->anim_speed, 1, 255)
301 { 302 : 1. / clamp (fabs (head->speed), 1./255., 1./1.);
302 if (head->anim_speed)
303 anim_speed = head->anim_speed;
304 else
305 {
306 if (fabs (head->speed) < 0.001)
307 anim_speed = 255;
308 else if (fabs (head->speed) >= 1.0)
309 anim_speed = 1;
310 else
311 anim_speed = (int) (1.0 / fabs (head->speed));
312 }
313
314 if (anim_speed > 255)
315 anim_speed = 255;
316 }
317 303
318 sl << uint8 (anim_speed) 304 sl << uint8 (anim_speed)
319 << uint32 (head->nrof); 305 << uint32 (head->nrof);
320 306
321 if (ns.itemcmd == 2) 307 if (ns.itemcmd == 2)
909 895
910/** Move an object to a new location */ 896/** Move an object to a new location */
911void 897void
912esrv_move_object (object *pl, tag_t to, tag_t tag, long nrof) 898esrv_move_object (object *pl, tag_t to, tag_t tag, long nrof)
913{ 899{
914 object *op, *env;
915
916 op = esrv_get_ob_from_count (pl, tag); 900 object *op = esrv_get_ob_from_count (pl, tag);
917 if (!op) 901 if (!op)
918 { 902 {
919 LOG (llevDebug, "Player '%s' tried to move an unknown object (%ld)\n", &pl->name, tag); 903 LOG (llevDebug, "Player '%s' tried to move an unknown object (%ld)\n", &pl->name, tag);
920 return; 904 return;
921 } 905 }
930 */ 914 */
931 if (op->inv && QUERY_FLAG (op, FLAG_APPLIED)) 915 if (op->inv && QUERY_FLAG (op, FLAG_APPLIED))
932 { 916 {
933 int cnt = MAX_ITEM_PER_DROP; 917 int cnt = MAX_ITEM_PER_DROP;
934 918
935 for (object *current = op->inv; current; ) 919 for (object *current = op->inv; current && cnt--; )
936 { 920 {
937 object *next = current->below; 921 object *next = current->below;
938
939 drop_object (pl, current, 0); 922 drop_object (pl, current, 0);
940
941 if (--cnt <= 0) break;
942
943 current = next; 923 current = next;
944 } 924 }
945 925
946 if (cnt <= 0) 926 if (cnt <= 0)
947 op->failmsg ("Only dropped some items, can't drop that many items at once."); 927 op->failmsg ("Only dropped some items, can't drop that many items at once.");
960 pl->contr->count = nrof; 940 pl->contr->count = nrof;
961 pick_up (pl, op); 941 pick_up (pl, op);
962 return; 942 return;
963 } 943 }
964 944
965 env = esrv_get_ob_from_count (pl, to); 945 object *env = esrv_get_ob_from_count (pl, to);
966 if (!env) 946 if (!env)
967 { 947 {
968 LOG (llevDebug, "Player '%s' tried to move object to the unknown location (%d)\n", &pl->name, to); 948 LOG (llevDebug, "Player '%s' tried to move object to the unknown location (%d)\n", &pl->name, to);
969 return; 949 return;
970 } 950 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines