… | |
… | |
34 | |
34 | |
35 | /* |
35 | /* |
36 | * Object id parsing functions |
36 | * Object id parsing functions |
37 | */ |
37 | */ |
38 | |
38 | |
39 | #define OBLINKMALLOC(p) if(!((p)=(objectlink *)malloc(sizeof(objectlink))))\ |
|
|
40 | fatal(OUT_OF_MEMORY); |
|
|
41 | |
|
|
42 | #define ADD_ITEM(NEW,COUNT)\ |
39 | #define ADD_ITEM(NEW,COUNT)\ |
43 | if(!first) {\ |
40 | if(!first) {\ |
44 | OBLINKMALLOC(first);\ |
41 | first = new objectlink;\ |
45 | last=first;\ |
42 | last=first;\ |
46 | } else {\ |
43 | } else {\ |
47 | OBLINKMALLOC(last->next);\ |
44 | last->next = new objectlink;\ |
48 | last=last->next;\ |
45 | last=last->next;\ |
49 | }\ |
46 | }\ |
50 | last->next=NULL;\ |
47 | last->next=0;\ |
51 | last->ob=(NEW);\ |
48 | last->ob=(NEW);\ |
52 | last->id=(COUNT); |
49 | last->id=(COUNT); |
53 | |
50 | |
54 | /** |
51 | /** |
55 | * Search the inventory of 'pl' for what matches best with params. |
52 | * Search the inventory of 'pl' for what matches best with params. |
… | |
… | |
439 | if (alt->type == CONTAINER && QUERY_FLAG (alt, FLAG_APPLIED) && sack_can_hold (NULL, alt, tmp, count)) |
436 | if (alt->type == CONTAINER && QUERY_FLAG (alt, FLAG_APPLIED) && sack_can_hold (NULL, alt, tmp, count)) |
440 | break; /* General container comes next */ |
437 | break; /* General container comes next */ |
441 | if (!alt) |
438 | if (!alt) |
442 | alt = op; /* No free containers */ |
439 | alt = op; /* No free containers */ |
443 | } |
440 | } |
|
|
441 | |
444 | if (tmp->env == alt) |
442 | if (tmp->env == alt) |
445 | { |
443 | { |
446 | /* here it could be possible to check rent, |
444 | /* here it could be possible to check rent, |
447 | * if someone wants to implement it |
445 | * if someone wants to implement it |
448 | */ |
446 | */ |
… | |
… | |
490 | else |
488 | else |
491 | { |
489 | { |
492 | tmp = op->above; |
490 | tmp = op->above; |
493 | if (tmp) |
491 | if (tmp) |
494 | while (tmp->above) |
492 | while (tmp->above) |
495 | { |
|
|
496 | tmp = tmp->above; |
493 | tmp = tmp->above; |
497 | } |
494 | |
498 | if (!tmp) |
495 | if (!tmp) |
499 | tmp = op->below; |
496 | tmp = op->below; |
500 | } |
497 | } |
501 | |
498 | |
502 | if (tmp == NULL) |
499 | if (tmp == NULL) |