… | |
… | |
30 | * This containes item logic for client/server. It doesn't contain |
30 | * This containes item logic for client/server. It doesn't contain |
31 | * the actual commands that send the data, but does contain |
31 | * the actual commands that send the data, but does contain |
32 | * the logic for what items should be sent. |
32 | * the logic for what items should be sent. |
33 | */ |
33 | */ |
34 | |
34 | |
35 | |
|
|
36 | #include <global.h> |
35 | #include <global.h> |
37 | #include <object.h> /* LOOK_OBJ */ |
36 | #include <object.h> /* LOOK_OBJ */ |
38 | #include <newclient.h> |
|
|
39 | #include <newserver.h> |
|
|
40 | #include <sproto.h> |
37 | #include <sproto.h> |
41 | |
38 | |
42 | /** This is the maximum number of bytes we expect any one item to take up */ |
39 | /** This is the maximum number of bytes we expect any one item to take up */ |
43 | #define MAXITEMLEN 300 |
40 | #define MAXITEMLEN 300 |
44 | |
41 | |
… | |
… | |
48 | * |
45 | * |
49 | ******************************************************************************/ |
46 | ******************************************************************************/ |
50 | |
47 | |
51 | /** |
48 | /** |
52 | * This is a similar to query_name, but returns flags |
49 | * This is a similar to query_name, but returns flags |
53 | * to be sended to client. |
50 | * to be sent to client. |
54 | */ |
51 | */ |
55 | unsigned int |
52 | unsigned int |
56 | query_flags (object *op) |
53 | query_flags (object *op) |
57 | { |
54 | { |
58 | unsigned int flags = 0; |
55 | unsigned int flags = 0; |
59 | |
56 | |
60 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
57 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
61 | { |
58 | { |
62 | switch (op->type) |
59 | switch (op->type) |
63 | { |
60 | { |
64 | case BOW: |
61 | case BOW: |
65 | case WAND: |
62 | case WAND: |
66 | case ROD: |
63 | case ROD: |
67 | case HORN: |
64 | case HORN: |
68 | flags = a_readied; |
65 | flags = a_readied; |
69 | break; |
66 | break; |
70 | case WEAPON: |
67 | case WEAPON: |
71 | flags = a_wielded; |
68 | flags = a_wielded; |
72 | break; |
69 | break; |
73 | case SKILL: |
70 | case SKILL: |
74 | case ARMOUR: |
71 | case ARMOUR: |
75 | case HELMET: |
72 | case HELMET: |
76 | case SHIELD: |
73 | case SHIELD: |
77 | case RING: |
74 | case RING: |
78 | case BOOTS: |
75 | case BOOTS: |
79 | case GLOVES: |
76 | case GLOVES: |
80 | case AMULET: |
77 | case AMULET: |
81 | case GIRDLE: |
78 | case GIRDLE: |
82 | case BRACERS: |
79 | case BRACERS: |
83 | case CLOAK: |
80 | case CLOAK: |
84 | flags = a_worn; |
81 | flags = a_worn; |
85 | break; |
82 | break; |
86 | case CONTAINER: |
83 | case CONTAINER: |
87 | flags = a_active; |
84 | flags = a_active; |
88 | break; |
85 | break; |
89 | default: |
86 | default: |
90 | flags = a_applied; |
87 | flags = a_applied; |
91 | break; |
88 | break; |
92 | } |
89 | } |
93 | } |
90 | } |
|
|
91 | |
94 | if (op->type == CONTAINER && ((op->env && op->env->container == op) || (!op->env && QUERY_FLAG (op, FLAG_APPLIED)))) |
92 | if (op->type == CONTAINER && ((op->env && op->env->container == op) || (!op->env && QUERY_FLAG (op, FLAG_APPLIED)))) |
95 | flags |= F_OPEN; |
93 | flags |= F_OPEN; |
96 | |
94 | |
97 | if (QUERY_FLAG (op, FLAG_KNOWN_CURSED)) |
95 | if (QUERY_FLAG (op, FLAG_KNOWN_CURSED)) |
98 | { |
96 | { |
99 | if (QUERY_FLAG (op, FLAG_DAMNED)) |
97 | if (QUERY_FLAG (op, FLAG_DAMNED)) |
100 | flags |= F_DAMNED; |
98 | flags |= F_DAMNED; |
101 | else if (QUERY_FLAG (op, FLAG_CURSED)) |
99 | else if (QUERY_FLAG (op, FLAG_CURSED)) |
102 | flags |= F_CURSED; |
100 | flags |= F_CURSED; |
103 | } |
101 | } |
|
|
102 | |
104 | if (QUERY_FLAG (op, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (op, FLAG_IDENTIFIED)) |
103 | if (QUERY_FLAG (op, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (op, FLAG_IDENTIFIED)) |
105 | flags |= F_MAGIC; |
104 | flags |= F_MAGIC; |
106 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
105 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
107 | flags |= F_UNPAID; |
106 | flags |= F_UNPAID; |
108 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
107 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
109 | flags |= F_LOCKED; |
108 | flags |= F_LOCKED; |
110 | |
109 | |
111 | return flags; |
110 | return flags; |
112 | } |
111 | } |
113 | |
112 | |
114 | /* Used in the send_look to put object head into SockList |
113 | /* Used in the send_look to put object head into packet |
115 | * sl for socket ns. Need socket to know if we need to send |
114 | * sl for socket ns. Need socket to know if we need to send |
116 | * animation of face to the client. |
115 | * animation of face to the client. |
117 | */ |
116 | */ |
118 | static void |
117 | static void |
119 | add_object_to_socklist (NewSocket &ns, SockList &sl, object *head) |
118 | add_object_to_socklist (client &ns, packet &sl, object *head) |
120 | { |
119 | { |
121 | int flags, len, anim_speed; |
120 | int flags, len, anim_speed; |
122 | char item_n[MAX_BUF]; |
121 | char item_n[MAX_BUF]; |
123 | const char *item_p; |
122 | const char *item_p; |
124 | |
123 | |
… | |
… | |
187 | SET_FLAG (head, FLAG_CLIENT_SENT); |
186 | SET_FLAG (head, FLAG_CLIENT_SENT); |
188 | } |
187 | } |
189 | |
188 | |
190 | |
189 | |
191 | /** |
190 | /** |
192 | * Send the look window. Don't need to do animations here |
191 | * Send the look window. Don't need to do animations here |
193 | * This sends all the faces to the client, not just updates. This is |
192 | * This sends all the faces to the client, not just updates. This is |
194 | * because object ordering would otherwise be inconsistent |
193 | * because object ordering would otherwise be inconsistent. |
195 | */ |
194 | */ |
196 | |
|
|
197 | void |
195 | void |
198 | esrv_draw_look (object *pl) |
196 | esrv_draw_look (object *pl) |
199 | { |
197 | { |
200 | object *tmp, *last; |
198 | object *tmp, *last; |
201 | int got_one = 0, start_look = 0, end_look = 0; |
199 | int got_one = 0, start_look = 0, end_look = 0; |
202 | char buf[MAX_BUF]; |
200 | char buf[MAX_BUF]; |
203 | |
201 | |
204 | if (!pl->contr->socket.update_look) |
202 | if (!pl->contr->socket->update_look) |
205 | { |
203 | { |
206 | LOG (llevDebug, "esrv_draw_look called when update_look was not set\n"); |
204 | LOG (llevDebug, "esrv_draw_look called when update_look was not set\n"); |
207 | return; |
205 | return; |
208 | } |
206 | } |
209 | else |
207 | else |
210 | pl->contr->socket.update_look = 0; |
208 | pl->contr->socket->update_look = 0; |
211 | |
209 | |
212 | if (QUERY_FLAG (pl, FLAG_REMOVED) |
210 | if (QUERY_FLAG (pl, FLAG_REMOVED) |
213 | || !pl->map |
211 | || !pl->map |
214 | || pl->map->in_memory != MAP_IN_MEMORY |
212 | || pl->map->in_memory != MAP_IN_MEMORY |
215 | || out_of_map (pl->map, pl->x, pl->y)) |
213 | || out_of_map (pl->map, pl->x, pl->y)) |
216 | return; |
214 | return; |
217 | |
215 | |
218 | for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above) |
216 | for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above) |
219 | ; |
217 | ; |
220 | |
218 | |
221 | SockList sl (MAXSOCKBUF); |
219 | pl->contr->socket->send_packet ("delinv 0"); |
222 | |
220 | |
223 | Write_String_To_Socket (&pl->contr->socket, "delinv 0", sizeof ("delinv 0") - 1); |
221 | packet sl; |
224 | |
|
|
225 | sl.printf ("item%d ", pl->contr->socket.itemcmd); |
222 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
226 | |
223 | |
227 | sl << uint32 (0); |
224 | sl << uint32 (0); |
228 | |
225 | |
229 | if (!(pl->contr->socket.faces_sent[empty_face->number] & NS_FACESENT_FACE)) |
226 | if (!(pl->contr->socket->faces_sent[empty_face->number] & NS_FACESENT_FACE)) |
230 | esrv_send_face (&pl->contr->socket, empty_face->number, 0); |
227 | esrv_send_face (pl->contr->socket, empty_face->number, 0); |
231 | |
228 | |
232 | if (pl->contr->socket.look_position) |
229 | if (pl->contr->socket->look_position) |
233 | { |
230 | { |
|
|
231 | char buf[80]; |
|
|
232 | snprintf (buf, 80, "Apply this to see %d previous items", FLOORBOX_PAGESIZE); |
|
|
233 | |
234 | sl << uint32 (0x80000000 | (pl->contr->socket.look_position - NUM_LOOK_OBJECTS)) |
234 | sl << uint32 (0x80000000 | (pl->contr->socket->look_position - FLOORBOX_PAGESIZE)) |
235 | << uint32 (0) |
235 | << uint32 (0) |
236 | << sint32 (-1) |
236 | << sint32 (-1) |
237 | << uint32 (empty_face->number); |
237 | << uint32 (empty_face->number) |
238 | |
238 | << data8 (buf) |
239 | sl.printf ("Click here to see %d previous items", NUM_LOOK_OBJECTS); |
|
|
240 | |
|
|
241 | sl << uint16 (0) |
239 | << uint16 (0) |
242 | << uint8 (0) |
240 | << uint8 (0) |
243 | << uint32 (0); |
241 | << uint32 (0); |
244 | |
242 | |
245 | if (pl->contr->socket.itemcmd == 2) |
243 | if (pl->contr->socket->itemcmd == 2) |
246 | sl << uint16 (0); |
244 | sl << uint16 (0); |
247 | } |
245 | } |
248 | |
246 | |
249 | for (last = NULL; tmp != last; tmp = tmp->below) |
247 | for (last = NULL; tmp != last; tmp = tmp->below) |
250 | { |
248 | { |
… | |
… | |
257 | last = last->below; |
255 | last = last->below; |
258 | } |
256 | } |
259 | |
257 | |
260 | if (LOOK_OBJ (tmp)) |
258 | if (LOOK_OBJ (tmp)) |
261 | { |
259 | { |
262 | if (++start_look < pl->contr->socket.look_position) |
260 | if (++start_look < pl->contr->socket->look_position) |
263 | continue; |
261 | continue; |
264 | |
262 | |
265 | end_look++; |
263 | end_look++; |
266 | |
264 | |
267 | if (end_look > NUM_LOOK_OBJECTS) |
265 | if (end_look > FLOORBOX_PAGESIZE) |
268 | { |
266 | { |
269 | /* What we basically do is make a 'fake' object - when the user applies it, |
267 | /* 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. |
268 | * we notice the special tag the object has, and act accordingly. |
271 | */ |
269 | */ |
272 | sl << uint32 (0x80000000 | (pl->contr->socket.look_position + NUM_LOOK_OBJECTS)) |
270 | sl << uint32 (0x80000000 | (pl->contr->socket->look_position + FLOORBOX_PAGESIZE)) |
273 | << uint32 (0) |
271 | << uint32 (0) |
274 | << uint32 ((uint32) - 1) |
272 | << uint32 ((uint32) - 1) |
275 | << uint32 (empty_face->number); |
273 | << uint32 (empty_face->number) |
276 | |
274 | << data8 ("Apply this to see next group of items") |
277 | sl.printf ("Click here to see next group of items"); |
|
|
278 | |
|
|
279 | sl << uint16 (0) |
275 | << uint16 (0) |
280 | << uint8 (0) |
276 | << uint8 (0) |
281 | << uint32 (0); |
277 | << uint32 (0); |
282 | |
278 | |
283 | if (pl->contr->socket.itemcmd == 2) |
279 | if (pl->contr->socket->itemcmd == 2) |
284 | sl << uint16 (0); |
280 | sl << uint16 (0); |
285 | |
281 | |
286 | break; |
282 | break; |
287 | } |
283 | } |
288 | |
284 | |
289 | if (tmp->head) |
285 | if (tmp->head) |
290 | head = tmp->head; |
286 | head = tmp->head; |
291 | else |
287 | else |
292 | head = tmp; |
288 | head = tmp; |
293 | |
289 | |
294 | add_object_to_socklist (pl->contr->socket, sl, head); |
290 | add_object_to_socklist (*pl->contr->socket, sl, head); |
295 | got_one++; |
291 | got_one++; |
296 | |
292 | |
297 | if (sl.len >= (MAXSOCKBUF - MAXITEMLEN)) |
293 | if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) |
298 | { |
294 | { |
299 | Send_With_Handling (&pl->contr->socket, &sl); |
295 | pl->contr->socket->send_packet (sl); |
300 | |
296 | |
301 | sl.reset (); |
297 | sl.reset (); |
302 | sl.printf ("item%d ", pl->contr->socket.itemcmd); |
298 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
303 | sl << uint32 (0); |
299 | sl << uint32 (0); |
304 | got_one = 0; |
300 | got_one = 0; |
305 | } |
301 | } |
306 | } /* If LOOK_OBJ() */ |
302 | } |
307 | } |
303 | } |
308 | |
304 | |
309 | if (got_one) |
305 | if (got_one) |
310 | Send_With_Handling (&pl->contr->socket, &sl); |
306 | pl->contr->socket->send_packet (sl); |
311 | |
307 | |
312 | sl.free (); |
|
|
313 | } |
308 | } |
314 | |
309 | |
315 | /** |
310 | /** |
316 | * Sends whole inventory. |
311 | * Sends whole inventory. |
317 | */ |
312 | */ |
… | |
… | |
319 | esrv_send_inventory (object *pl, object *op) |
314 | esrv_send_inventory (object *pl, object *op) |
320 | { |
315 | { |
321 | object *tmp; |
316 | object *tmp; |
322 | int got_one = 0; |
317 | int got_one = 0; |
323 | |
318 | |
324 | SockList sl (MAXSOCKBUF); |
|
|
325 | |
319 | |
326 | sl.printf ("delinv %d", op->count); |
320 | pl->contr->socket->send_packet_printf ("delinv %d", op->count); |
327 | Send_With_Handling (&pl->contr->socket, &sl); |
|
|
328 | |
321 | |
329 | sl.reset (); |
322 | packet sl; |
330 | sl.printf ("item%d ", pl->contr->socket.itemcmd); |
323 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
331 | |
324 | |
332 | sl << uint32 (op->count); |
325 | sl << uint32 (op->count); |
333 | |
326 | |
334 | for (tmp = op->inv; tmp; tmp = tmp->below) |
327 | for (tmp = op->inv; tmp; tmp = tmp->below) |
335 | { |
328 | { |
… | |
… | |
340 | else |
333 | else |
341 | head = tmp; |
334 | head = tmp; |
342 | |
335 | |
343 | if (LOOK_OBJ (head)) |
336 | if (LOOK_OBJ (head)) |
344 | { |
337 | { |
345 | add_object_to_socklist (pl->contr->socket, sl, head); |
338 | add_object_to_socklist (*pl->contr->socket, sl, head); |
346 | |
339 | |
347 | got_one++; |
340 | got_one++; |
348 | |
341 | |
349 | /* IT is possible for players to accumulate a huge amount of |
342 | /* IT is possible for players to accumulate a huge amount of |
350 | * items (especially with some of the bags out there) to |
343 | * items (especially with some of the bags out there) to |
351 | * overflow the buffer. IF so, send multiple item commands. |
344 | * overflow the buffer. IF so, send multiple item commands. |
352 | */ |
345 | */ |
353 | if (sl.len >= (MAXSOCKBUF - MAXITEMLEN)) |
346 | if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) |
354 | { |
347 | { |
355 | Send_With_Handling (&pl->contr->socket, &sl); |
348 | pl->contr->socket->send_packet (sl); |
|
|
349 | |
|
|
350 | sl.reset (); |
356 | sprintf ((char *) sl.buf, "item%d ", pl->contr->socket.itemcmd); |
351 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
357 | sl.len = strlen ((char *) sl.buf); |
|
|
358 | sl << uint32 (op->count); |
352 | sl << uint32 (op->count); |
359 | got_one = 0; |
353 | got_one = 0; |
360 | } |
354 | } |
361 | } /* If LOOK_OBJ() */ |
355 | } /* If LOOK_OBJ() */ |
362 | } |
356 | } |
363 | |
357 | |
364 | if (got_one) |
358 | if (got_one) |
365 | Send_With_Handling (&pl->contr->socket, &sl); |
359 | pl->contr->socket->send_packet (sl); |
366 | |
|
|
367 | sl.free (); |
|
|
368 | } |
360 | } |
369 | |
361 | |
370 | /** |
362 | /** |
371 | * Updates object *op for player *pl. |
363 | * Updates object *op for player *pl. |
372 | * |
364 | * |
… | |
… | |
396 | * and track back the call. |
388 | * and track back the call. |
397 | */ |
389 | */ |
398 | LOG (llevDebug, "We have not sent item %s (%d)\n", &op->name, op->count); |
390 | LOG (llevDebug, "We have not sent item %s (%d)\n", &op->name, op->count); |
399 | } |
391 | } |
400 | |
392 | |
401 | SockList sl (MAXSOCKBUF); |
393 | packet sl ("upditem"); |
402 | |
394 | |
403 | sl << "upditem " |
|
|
404 | << uint8 (flags); |
395 | sl << uint8 (flags); |
405 | |
396 | |
406 | if (op->head) |
397 | if (op->head) |
407 | op = op->head; |
398 | op = op->head; |
408 | |
399 | |
409 | sl << uint32 (op->count); |
400 | sl << uint32 (op->count); |
… | |
… | |
424 | op->contr->last_weight = weight; |
415 | op->contr->last_weight = weight; |
425 | } |
416 | } |
426 | |
417 | |
427 | if (flags & UPD_FACE) |
418 | if (flags & UPD_FACE) |
428 | { |
419 | { |
429 | if (!(pl->contr->socket.faces_sent[op->face->number] & NS_FACESENT_FACE)) |
420 | if (!(pl->contr->socket->faces_sent[op->face->number] & NS_FACESENT_FACE)) |
430 | esrv_send_face (&pl->contr->socket, op->face->number, 0); |
421 | esrv_send_face (pl->contr->socket, op->face->number, 0); |
431 | |
422 | |
432 | sl << uint32 (op->face->number); |
423 | sl << uint32 (op->face->number); |
433 | } |
424 | } |
434 | |
425 | |
435 | if (flags & UPD_NAME) |
426 | if (flags & UPD_NAME) |
… | |
… | |
489 | } |
480 | } |
490 | |
481 | |
491 | if (flags & UPD_NROF) |
482 | if (flags & UPD_NROF) |
492 | sl << uint32 (op->nrof); |
483 | sl << uint32 (op->nrof); |
493 | |
484 | |
494 | Send_With_Handling (&pl->contr->socket, &sl); |
485 | pl->contr->socket->send_packet (sl); |
495 | sl.free (); |
|
|
496 | } |
486 | } |
497 | |
487 | |
498 | /** |
488 | /** |
499 | * Sends item's info to player. |
489 | * Sends item's info to player. |
500 | */ |
490 | */ |
… | |
… | |
510 | /* if the item is on the ground, mark that the look needs to |
500 | /* if the item is on the ground, mark that the look needs to |
511 | * be updated. |
501 | * be updated. |
512 | */ |
502 | */ |
513 | if (!op->env) |
503 | if (!op->env) |
514 | { |
504 | { |
515 | pl->contr->socket.update_look = 1; |
505 | pl->contr->socket->floorbox_update (); |
516 | return; |
506 | return; |
517 | } |
507 | } |
518 | } |
508 | } |
519 | |
509 | |
520 | SockList sl (MAXSOCKBUF); |
510 | packet sl; |
521 | |
511 | |
522 | sl.printf ("item%d ", pl->contr->socket.itemcmd); |
512 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
523 | |
513 | |
524 | if (op->head) |
514 | if (op->head) |
525 | op = op->head; |
515 | op = op->head; |
526 | |
516 | |
527 | sl << uint32 (op->env ? op->env->count : 0); |
517 | sl << uint32 (op->env ? op->env->count : 0); |
528 | |
518 | |
529 | add_object_to_socklist (pl->contr->socket, sl, op); |
519 | add_object_to_socklist (*pl->contr->socket, sl, op); |
530 | |
520 | |
531 | Send_With_Handling (&pl->contr->socket, &sl); |
521 | pl->contr->socket->send_packet (sl); |
532 | SET_FLAG (op, FLAG_CLIENT_SENT); |
522 | SET_FLAG (op, FLAG_CLIENT_SENT); |
533 | |
|
|
534 | sl.free (); |
|
|
535 | } |
523 | } |
536 | |
524 | |
537 | /** |
525 | /** |
538 | * Tells the client to delete an item. Uses the item |
526 | * Tells the client to delete an item. Uses the item |
539 | * command with a -1 location. |
527 | * command with a -1 location. |
540 | */ |
528 | */ |
541 | |
529 | |
542 | void |
530 | void |
543 | esrv_del_item (player *pl, int tag) |
531 | esrv_del_item (player *pl, int tag) |
544 | { |
532 | { |
545 | SockList sl (MAXSOCKBUF); |
533 | packet sl ("delitem"); |
546 | |
534 | |
547 | sl << "delitem " |
|
|
548 | << uint32 (tag); |
535 | sl << uint32 (tag); |
549 | |
536 | |
550 | Send_With_Handling (&pl->socket, &sl); |
537 | pl->socket->send_packet (sl); |
551 | sl.free (); |
|
|
552 | } |
538 | } |
553 | |
539 | |
554 | |
540 | |
555 | /******************************************************************************* |
541 | /******************************************************************************* |
556 | * |
542 | * |
… | |
… | |
578 | for (tmp = op->inv; tmp; tmp = tmp->below) |
564 | for (tmp = op->inv; tmp; tmp = tmp->below) |
579 | if (tmp->count == count) |
565 | if (tmp->count == count) |
580 | return tmp; |
566 | return tmp; |
581 | |
567 | |
582 | for (op = get_map_ob (pl->map, pl->x, pl->y); op; op = op->above) |
568 | for (op = get_map_ob (pl->map, pl->x, pl->y); op; op = op->above) |
583 | if (op->head != NULL && op->head->count == count) |
569 | if (op->head && op->head->count == count) |
584 | return op; |
570 | return op; |
585 | else if (op->count == count) |
571 | else if (op->count == count) |
586 | return op; |
572 | return op; |
587 | else if (op->type == CONTAINER && pl->container == op) |
573 | else if (op->type == CONTAINER && pl->container == op) |
588 | for (tmp = op->inv; tmp; tmp = tmp->below) |
574 | for (tmp = op->inv; tmp; tmp = tmp->below) |
589 | if (tmp->count == count) |
575 | if (tmp->count == count) |
590 | return tmp; |
576 | return tmp; |
591 | |
577 | |
592 | return NULL; |
578 | return 0; |
593 | } |
579 | } |
594 | |
580 | |
595 | |
581 | |
596 | /** Client wants to examine some object. So lets do so. */ |
582 | /** Client wants to examine some object. So lets do so. */ |
597 | void |
583 | void |
… | |
… | |
612 | } |
598 | } |
613 | |
599 | |
614 | examine (pl->ob, op); |
600 | examine (pl->ob, op); |
615 | } |
601 | } |
616 | |
602 | |
617 | /** Client wants to apply some object. Lets do so. */ |
603 | /** Client wants to apply some object. Lets do so. */ |
618 | void |
604 | void |
619 | ApplyCmd (char *buf, int len, player *pl) |
605 | ApplyCmd (char *buf, int len, player *pl) |
620 | { |
606 | { |
621 | tag_t tag = atoi (buf); |
607 | tag_t tag = atoi (buf); |
622 | |
608 | |
… | |
… | |
627 | return; |
613 | return; |
628 | |
614 | |
629 | /* If the high bit is set, player applied a pseudo object. */ |
615 | /* If the high bit is set, player applied a pseudo object. */ |
630 | if (tag & 0x80000000) |
616 | if (tag & 0x80000000) |
631 | { |
617 | { |
632 | pl->socket.look_position = tag & 0x7fffffff; |
618 | pl->socket->look_position = tag & 0x7fffffff; |
633 | pl->socket.update_look = 1; |
619 | pl->socket->floorbox_update (); |
634 | return; |
620 | return; |
635 | } |
621 | } |
636 | |
622 | |
637 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
623 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
638 | |
624 | |
… | |
… | |
643 | } |
629 | } |
644 | |
630 | |
645 | player_apply (pl->ob, op, 0, 0); |
631 | player_apply (pl->ob, op, 0, 0); |
646 | } |
632 | } |
647 | |
633 | |
648 | /** Client wants to apply some object. Lets do so. */ |
634 | /** Client wants to lock some object. Lets do so. */ |
649 | void |
635 | void |
650 | LockItem (uint8 *data, int len, player *pl) |
636 | LockItem (char *data, int len, player *pl) |
651 | { |
637 | { |
652 | int flag = data[0]; |
638 | int flag = data[0]; |
653 | tag_t tag = net_uint32 (data + 1); |
639 | tag_t tag = net_uint32 ((uint8 *)data + 1); |
654 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
640 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
655 | |
641 | |
656 | if (!op) |
642 | if (!op) |
657 | { |
643 | { |
658 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to lock/unlock"); |
644 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to lock/unlock"); |
… | |
… | |
665 | SET_FLAG (op, FLAG_INV_LOCKED); |
651 | SET_FLAG (op, FLAG_INV_LOCKED); |
666 | |
652 | |
667 | esrv_update_item (UPD_FLAGS, pl->ob, op); |
653 | esrv_update_item (UPD_FLAGS, pl->ob, op); |
668 | } |
654 | } |
669 | |
655 | |
670 | /** Client wants to apply some object. Lets do so. */ |
656 | /** Client wants to mark some object. Lets do so. */ |
671 | void |
657 | void |
672 | MarkItem (uint8 * data, int len, player *pl) |
658 | MarkItem (char *data, int len, player *pl) |
673 | { |
659 | { |
674 | tag_t tag = net_uint32 (data); |
660 | tag_t tag = net_uint32 ((uint8 *)data); |
675 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
661 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
676 | |
662 | |
677 | if (!op) |
663 | if (!op) |
678 | { |
664 | { |
679 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to mark"); |
665 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to mark"); |
… | |
… | |
763 | { |
749 | { |
764 | return; |
750 | return; |
765 | } |
751 | } |
766 | dy = atoi (cp); |
752 | dy = atoi (cp); |
767 | |
753 | |
768 | if (FABS (dx) > pl->socket.mapx / 2 || FABS (dy) > pl->socket.mapy / 2) |
754 | if (FABS (dx) > pl->socket->mapx / 2 || FABS (dy) > pl->socket->mapy / 2) |
769 | return; |
755 | return; |
770 | |
756 | |
771 | if (pl->blocked_los[dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]) |
757 | if (pl->blocked_los[dx + pl->socket->mapx / 2][dy + pl->socket->mapy / 2]) |
772 | return; |
758 | return; |
773 | |
759 | |
774 | look_at (pl->ob, dx, dy); |
760 | look_at (pl->ob, dx, dy); |
775 | } |
761 | } |
776 | |
762 | |
… | |
… | |
806 | } |
792 | } |
807 | |
793 | |
808 | esrv_update_item (UPD_WEIGHT, pl, op); |
794 | esrv_update_item (UPD_WEIGHT, pl, op); |
809 | } |
795 | } |
810 | else |
796 | else |
811 | { |
|
|
812 | drop_object (pl, op, nrof); |
797 | drop_object (pl, op, nrof); |
813 | } |
798 | |
814 | return; |
799 | return; |
815 | } |
800 | } |
816 | else if (to == pl->count) |
801 | else if (to == pl->count) |
817 | { /* pick it up to the inventory */ |
802 | { /* pick it up to the inventory */ |
818 | /* return if player has already picked it up */ |
803 | /* return if player has already picked it up */ |
… | |
… | |
835 | * has already been done (eg, it can be picked up and fits in |
820 | * has already been done (eg, it can be picked up and fits in |
836 | * in a sack, so check for those things. We should also check |
821 | * in a sack, so check for those things. We should also check |
837 | * an make sure env is in fact a container for that matter. |
822 | * an make sure env is in fact a container for that matter. |
838 | */ |
823 | */ |
839 | if (env->type == CONTAINER && can_pick (pl, op) && sack_can_hold (pl, env, op, nrof)) |
824 | if (env->type == CONTAINER && can_pick (pl, op) && sack_can_hold (pl, env, op, nrof)) |
840 | { |
|
|
841 | put_object_in_sack (pl, env, op, nrof); |
825 | put_object_in_sack (pl, env, op, nrof); |
842 | } |
|
|
843 | } |
826 | } |
844 | |
827 | |