1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_object_c = |
|
|
4 | * "$Id: object.C,v 1.26 2006/09/11 11:46:52 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
11 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
29 | |
23 | |
30 | /* Eneq(@csd.uu.se): Added weight-modifiers in environment of objects. |
24 | /* Eneq(@csd.uu.se): Added weight-modifiers in environment of objects. |
31 | sub/add_weight will transcend the environment updating the carrying |
25 | sub/add_weight will transcend the environment updating the carrying |
32 | variable. */ |
26 | variable. */ |
33 | #include <global.h> |
27 | #include <global.h> |
34 | #ifndef WIN32 /* ---win32 exclude headers */ |
|
|
35 | # include <stdio.h> |
28 | #include <stdio.h> |
36 | # include <sys/types.h> |
29 | #include <sys/types.h> |
37 | # include <sys/uio.h> |
30 | #include <sys/uio.h> |
38 | #endif /* win32 */ |
|
|
39 | #include <object.h> |
31 | #include <object.h> |
40 | #include <funcpoint.h> |
32 | #include <funcpoint.h> |
41 | #include <skills.h> |
33 | #include <skills.h> |
42 | #include <loader.h> |
34 | #include <loader.h> |
|
|
35 | |
43 | int nrofallocobjects = 0; |
36 | int nrofallocobjects = 0; |
44 | |
37 | |
45 | object *objects; /* Pointer to the list of used objects */ |
38 | object *objects; /* Pointer to the list of used objects */ |
46 | object *active_objects; /* List of active objects that need to be processed */ |
39 | object *active_objects; /* List of active objects that need to be processed */ |
47 | |
40 | |
… | |
… | |
249 | /* |
242 | /* |
250 | * sum_weight() is a recursive function which calculates the weight |
243 | * sum_weight() is a recursive function which calculates the weight |
251 | * an object is carrying. It goes through in figures out how much |
244 | * an object is carrying. It goes through in figures out how much |
252 | * containers are carrying, and sums it up. |
245 | * containers are carrying, and sums it up. |
253 | */ |
246 | */ |
254 | signed long |
247 | long |
255 | sum_weight (object *op) |
248 | sum_weight (object *op) |
256 | { |
249 | { |
257 | signed long sum; |
250 | long sum; |
258 | object *inv; |
251 | object *inv; |
259 | |
252 | |
260 | for (sum = 0, inv = op->inv; inv != NULL; inv = inv->below) |
253 | for (sum = 0, inv = op->inv; inv != NULL; inv = inv->below) |
261 | { |
254 | { |
262 | if (inv->inv) |
255 | if (inv->inv) |
… | |
… | |
891 | /* if the object is being removed, we can't make intelligent |
884 | /* if the object is being removed, we can't make intelligent |
892 | * decisions, because remove_ob can't really pass the object |
885 | * decisions, because remove_ob can't really pass the object |
893 | * that is being removed. |
886 | * that is being removed. |
894 | */ |
887 | */ |
895 | else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) |
888 | else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) |
896 | { |
|
|
897 | update_now = 1; |
889 | update_now = 1; |
898 | } |
|
|
899 | else if (action == UP_OBJ_FACE) |
890 | else if (action == UP_OBJ_FACE) |
900 | { |
|
|
901 | /* Nothing to do for that case */ |
891 | /* Nothing to do for that case */; |
902 | } |
|
|
903 | else |
892 | else |
904 | { |
|
|
905 | LOG (llevError, "update_object called with invalid action: %d\n", action); |
893 | LOG (llevError, "update_object called with invalid action: %d\n", action); |
906 | } |
|
|
907 | |
894 | |
908 | if (update_now) |
895 | if (update_now) |
909 | { |
896 | { |
910 | SET_MAP_FLAGS (op->map, op->x, op->y, flags | P_NO_ERROR | P_NEED_UPDATE); |
897 | SET_MAP_FLAGS (op->map, op->x, op->y, flags | P_NO_ERROR | P_NEED_UPDATE); |
911 | update_position (op->map, op->x, op->y); |
898 | update_position (op->map, op->x, op->y); |