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.18 by root, Thu Dec 14 02:37:37 2006 UTC vs.
Revision 1.19 by root, Thu Dec 14 04:30:33 2006 UTC

199{ 199{
200 object *tmp, *last; 200 object *tmp, *last;
201 int got_one = 0, start_look = 0, end_look = 0; 201 int got_one = 0, start_look = 0, end_look = 0;
202 char buf[MAX_BUF]; 202 char buf[MAX_BUF];
203 203
204 if (!pl->contr->socket.update_look) 204 if (!pl->contr->socket->update_look)
205 { 205 {
206 LOG (llevDebug, "esrv_draw_look called when update_look was not set\n"); 206 LOG (llevDebug, "esrv_draw_look called when update_look was not set\n");
207 return; 207 return;
208 } 208 }
209 else 209 else
210 pl->contr->socket.update_look = 0; 210 pl->contr->socket->update_look = 0;
211 211
212 if (QUERY_FLAG (pl, FLAG_REMOVED) 212 if (QUERY_FLAG (pl, FLAG_REMOVED)
213 || !pl->map 213 || !pl->map
214 || pl->map->in_memory != MAP_IN_MEMORY 214 || pl->map->in_memory != MAP_IN_MEMORY
215 || out_of_map (pl->map, pl->x, pl->y)) 215 || out_of_map (pl->map, pl->x, pl->y))
218 for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above) 218 for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above)
219 ; 219 ;
220 220
221 packet sl; 221 packet sl;
222 222
223 pl->contr->socket.send_packet ("delinv 0"); 223 pl->contr->socket->send_packet ("delinv 0");
224 224
225 sl.printf ("item%d ", pl->contr->socket.itemcmd); 225 sl.printf ("item%d ", pl->contr->socket->itemcmd);
226 226
227 sl << uint32 (0); 227 sl << uint32 (0);
228 228
229 if (!(pl->contr->socket.faces_sent[empty_face->number] & NS_FACESENT_FACE)) 229 if (!(pl->contr->socket->faces_sent[empty_face->number] & NS_FACESENT_FACE))
230 esrv_send_face (&pl->contr->socket, empty_face->number, 0); 230 esrv_send_face (pl->contr->socket, empty_face->number, 0);
231 231
232 if (pl->contr->socket.look_position) 232 if (pl->contr->socket->look_position)
233 { 233 {
234 sl << uint32 (0x80000000 | (pl->contr->socket.look_position - NUM_LOOK_OBJECTS)) 234 sl << uint32 (0x80000000 | (pl->contr->socket->look_position - NUM_LOOK_OBJECTS))
235 << uint32 (0) 235 << uint32 (0)
236 << sint32 (-1) 236 << sint32 (-1)
237 << uint32 (empty_face->number); 237 << uint32 (empty_face->number);
238 238
239 sl.printf ("Click here to see %d previous items", NUM_LOOK_OBJECTS); 239 sl.printf ("Click here to see %d previous items", NUM_LOOK_OBJECTS);
240 240
241 sl << uint16 (0) 241 sl << uint16 (0)
242 << uint8 (0) 242 << uint8 (0)
243 << uint32 (0); 243 << uint32 (0);
244 244
245 if (pl->contr->socket.itemcmd == 2) 245 if (pl->contr->socket->itemcmd == 2)
246 sl << uint16 (0); 246 sl << uint16 (0);
247 } 247 }
248 248
249 for (last = NULL; tmp != last; tmp = tmp->below) 249 for (last = NULL; tmp != last; tmp = tmp->below)
250 { 250 {
257 last = last->below; 257 last = last->below;
258 } 258 }
259 259
260 if (LOOK_OBJ (tmp)) 260 if (LOOK_OBJ (tmp))
261 { 261 {
262 if (++start_look < pl->contr->socket.look_position) 262 if (++start_look < pl->contr->socket->look_position)
263 continue; 263 continue;
264 264
265 end_look++; 265 end_look++;
266 266
267 if (end_look > NUM_LOOK_OBJECTS) 267 if (end_look > NUM_LOOK_OBJECTS)
268 { 268 {
269 /* What we basically do is make a 'fake' object - when the user applies it, 269 /* What we basically do is make a 'fake' object - when the user applies it,
270 * we notice the special tag the object has, and act accordingly. 270 * we notice the special tag the object has, and act accordingly.
271 */ 271 */
272 sl << uint32 (0x80000000 | (pl->contr->socket.look_position + NUM_LOOK_OBJECTS)) 272 sl << uint32 (0x80000000 | (pl->contr->socket->look_position + NUM_LOOK_OBJECTS))
273 << uint32 (0) 273 << uint32 (0)
274 << uint32 ((uint32) - 1) 274 << uint32 ((uint32) - 1)
275 << uint32 (empty_face->number); 275 << uint32 (empty_face->number);
276 276
277 sl.printf ("Click here to see next group of items"); 277 sl.printf ("Click here to see next group of items");
278 278
279 sl << uint16 (0) 279 sl << uint16 (0)
280 << uint8 (0) 280 << uint8 (0)
281 << uint32 (0); 281 << uint32 (0);
282 282
283 if (pl->contr->socket.itemcmd == 2) 283 if (pl->contr->socket->itemcmd == 2)
284 sl << uint16 (0); 284 sl << uint16 (0);
285 285
286 break; 286 break;
287 } 287 }
288 288
289 if (tmp->head) 289 if (tmp->head)
290 head = tmp->head; 290 head = tmp->head;
291 else 291 else
292 head = tmp; 292 head = tmp;
293 293
294 add_object_to_socklist (pl->contr->socket, sl, head); 294 add_object_to_socklist (*pl->contr->socket, sl, head);
295 got_one++; 295 got_one++;
296 296
297 if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) 297 if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN))
298 { 298 {
299 Send_With_Handling (&pl->contr->socket, &sl); 299 Send_With_Handling (pl->contr->socket, &sl);
300 300
301 sl.reset (); 301 sl.reset ();
302 sl.printf ("item%d ", pl->contr->socket.itemcmd); 302 sl.printf ("item%d ", pl->contr->socket->itemcmd);
303 sl << uint32 (0); 303 sl << uint32 (0);
304 got_one = 0; 304 got_one = 0;
305 } 305 }
306 } /* If LOOK_OBJ() */ 306 } /* If LOOK_OBJ() */
307 } 307 }
308 308
309 if (got_one) 309 if (got_one)
310 Send_With_Handling (&pl->contr->socket, &sl); 310 Send_With_Handling (pl->contr->socket, &sl);
311 311
312} 312}
313 313
314/** 314/**
315 * Sends whole inventory. 315 * Sends whole inventory.
321 int got_one = 0; 321 int got_one = 0;
322 322
323 packet sl; 323 packet sl;
324 324
325 sl.printf ("delinv %d", op->count); 325 sl.printf ("delinv %d", op->count);
326 Send_With_Handling (&pl->contr->socket, &sl); 326 Send_With_Handling (pl->contr->socket, &sl);
327 327
328 sl.reset (); 328 sl.reset ();
329 sl.printf ("item%d ", pl->contr->socket.itemcmd); 329 sl.printf ("item%d ", pl->contr->socket->itemcmd);
330 330
331 sl << uint32 (op->count); 331 sl << uint32 (op->count);
332 332
333 for (tmp = op->inv; tmp; tmp = tmp->below) 333 for (tmp = op->inv; tmp; tmp = tmp->below)
334 { 334 {
339 else 339 else
340 head = tmp; 340 head = tmp;
341 341
342 if (LOOK_OBJ (head)) 342 if (LOOK_OBJ (head))
343 { 343 {
344 add_object_to_socklist (pl->contr->socket, sl, head); 344 add_object_to_socklist (*pl->contr->socket, sl, head);
345 345
346 got_one++; 346 got_one++;
347 347
348 /* IT is possible for players to accumulate a huge amount of 348 /* IT is possible for players to accumulate a huge amount of
349 * items (especially with some of the bags out there) to 349 * items (especially with some of the bags out there) to
350 * overflow the buffer. IF so, send multiple item commands. 350 * overflow the buffer. IF so, send multiple item commands.
351 */ 351 */
352 if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) 352 if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN))
353 { 353 {
354 Send_With_Handling (&pl->contr->socket, &sl); 354 Send_With_Handling (pl->contr->socket, &sl);
355 355
356 sl.reset (); 356 sl.reset ();
357 sl.printf ("item%d ", pl->contr->socket.itemcmd); 357 sl.printf ("item%d ", pl->contr->socket->itemcmd);
358 sl << uint32 (op->count); 358 sl << uint32 (op->count);
359 got_one = 0; 359 got_one = 0;
360 } 360 }
361 } /* If LOOK_OBJ() */ 361 } /* If LOOK_OBJ() */
362 } 362 }
363 363
364 if (got_one) 364 if (got_one)
365 Send_With_Handling (&pl->contr->socket, &sl); 365 Send_With_Handling (pl->contr->socket, &sl);
366 366
367} 367}
368 368
369/** 369/**
370 * Updates object *op for player *pl. 370 * Updates object *op for player *pl.
423 op->contr->last_weight = weight; 423 op->contr->last_weight = weight;
424 } 424 }
425 425
426 if (flags & UPD_FACE) 426 if (flags & UPD_FACE)
427 { 427 {
428 if (!(pl->contr->socket.faces_sent[op->face->number] & NS_FACESENT_FACE)) 428 if (!(pl->contr->socket->faces_sent[op->face->number] & NS_FACESENT_FACE))
429 esrv_send_face (&pl->contr->socket, op->face->number, 0); 429 esrv_send_face (pl->contr->socket, op->face->number, 0);
430 430
431 sl << uint32 (op->face->number); 431 sl << uint32 (op->face->number);
432 } 432 }
433 433
434 if (flags & UPD_NAME) 434 if (flags & UPD_NAME)
488 } 488 }
489 489
490 if (flags & UPD_NROF) 490 if (flags & UPD_NROF)
491 sl << uint32 (op->nrof); 491 sl << uint32 (op->nrof);
492 492
493 Send_With_Handling (&pl->contr->socket, &sl); 493 Send_With_Handling (pl->contr->socket, &sl);
494} 494}
495 495
496/** 496/**
497 * Sends item's info to player. 497 * Sends item's info to player.
498 */ 498 */
508 /* if the item is on the ground, mark that the look needs to 508 /* if the item is on the ground, mark that the look needs to
509 * be updated. 509 * be updated.
510 */ 510 */
511 if (!op->env) 511 if (!op->env)
512 { 512 {
513 pl->contr->socket.update_look = 1; 513 pl->contr->socket->update_look = 1;
514 return; 514 return;
515 } 515 }
516 } 516 }
517 517
518 packet sl; 518 packet sl;
519 519
520 sl.printf ("item%d ", pl->contr->socket.itemcmd); 520 sl.printf ("item%d ", pl->contr->socket->itemcmd);
521 521
522 if (op->head) 522 if (op->head)
523 op = op->head; 523 op = op->head;
524 524
525 sl << uint32 (op->env ? op->env->count : 0); 525 sl << uint32 (op->env ? op->env->count : 0);
526 526
527 add_object_to_socklist (pl->contr->socket, sl, op); 527 add_object_to_socklist (*pl->contr->socket, sl, op);
528 528
529 Send_With_Handling (&pl->contr->socket, &sl); 529 Send_With_Handling (pl->contr->socket, &sl);
530 SET_FLAG (op, FLAG_CLIENT_SENT); 530 SET_FLAG (op, FLAG_CLIENT_SENT);
531 531
532} 532}
533 533
534/** 534/**
542 packet sl; 542 packet sl;
543 543
544 sl << "delitem " 544 sl << "delitem "
545 << uint32 (tag); 545 << uint32 (tag);
546 546
547 Send_With_Handling (&pl->socket, &sl); 547 Send_With_Handling (pl->socket, &sl);
548} 548}
549 549
550 550
551/******************************************************************************* 551/*******************************************************************************
552 * 552 *
623 return; 623 return;
624 624
625 /* If the high bit is set, player applied a pseudo object. */ 625 /* If the high bit is set, player applied a pseudo object. */
626 if (tag & 0x80000000) 626 if (tag & 0x80000000)
627 { 627 {
628 pl->socket.look_position = tag & 0x7fffffff; 628 pl->socket->look_position = tag & 0x7fffffff;
629 pl->socket.update_look = 1; 629 pl->socket->update_look = 1;
630 return; 630 return;
631 } 631 }
632 632
633 object *op = esrv_get_ob_from_count (pl->ob, tag); 633 object *op = esrv_get_ob_from_count (pl->ob, tag);
634 634
759 { 759 {
760 return; 760 return;
761 } 761 }
762 dy = atoi (cp); 762 dy = atoi (cp);
763 763
764 if (FABS (dx) > pl->socket.mapx / 2 || FABS (dy) > pl->socket.mapy / 2) 764 if (FABS (dx) > pl->socket->mapx / 2 || FABS (dy) > pl->socket->mapy / 2)
765 return; 765 return;
766 766
767 if (pl->blocked_los[dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]) 767 if (pl->blocked_los[dx + pl->socket->mapx / 2][dy + pl->socket->mapy / 2])
768 return; 768 return;
769 769
770 look_at (pl->ob, dx, dy); 770 look_at (pl->ob, dx, dy);
771} 771}
772 772

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines