… | |
… | |
217 | } |
217 | } |
218 | |
218 | |
219 | return 0; |
219 | return 0; |
220 | } |
220 | } |
221 | |
221 | |
222 | /* When the map is loaded, load_object does not actually insert objects |
|
|
223 | * into inventory, but just links them. What this does is go through |
|
|
224 | * and insert them properly. |
|
|
225 | * The object 'container' is the object that contains the inventory. |
|
|
226 | * This is needed so that we can update the containers weight. |
|
|
227 | */ |
|
|
228 | static void |
|
|
229 | fix_container (object *container) |
|
|
230 | { |
|
|
231 | object *tmp = container->inv, *next; |
|
|
232 | |
|
|
233 | container->inv = 0; |
|
|
234 | while (tmp) |
|
|
235 | { |
|
|
236 | next = tmp->below; |
|
|
237 | if (tmp->inv) |
|
|
238 | fix_container (tmp); |
|
|
239 | |
|
|
240 | insert_ob_in_ob (tmp, container); |
|
|
241 | tmp = next; |
|
|
242 | } |
|
|
243 | |
|
|
244 | // go through and calculate what all the containers are carrying. |
|
|
245 | //TODO: remove |
|
|
246 | container->update_weight (); |
|
|
247 | } |
|
|
248 | |
|
|
249 | //-GPL |
222 | //-GPL |
250 | |
223 | |
251 | void |
224 | void |
252 | maptile::set_object_flag (int flag, int value) |
225 | maptile::set_object_flag (int flag, int value) |
253 | { |
226 | { |
… | |
… | |
268 | set_object_flag (FLAG_OBJ_ORIGINAL); |
241 | set_object_flag (FLAG_OBJ_ORIGINAL); |
269 | |
242 | |
270 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
243 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
271 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
244 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
272 | INVOKE_OBJECT (RESET, tmp); |
245 | INVOKE_OBJECT (RESET, tmp); |
|
|
246 | } |
|
|
247 | |
|
|
248 | void |
|
|
249 | maptile::post_load () |
|
|
250 | { |
|
|
251 | #if 0 |
|
|
252 | if (!spaces) |
|
|
253 | return; |
|
|
254 | |
|
|
255 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
|
|
256 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
|
|
257 | ; // nop |
|
|
258 | #endif |
273 | } |
259 | } |
274 | |
260 | |
275 | //+GPL |
261 | //+GPL |
276 | |
262 | |
277 | /* link_multipart_objects go through all the objects on the map looking |
263 | /* link_multipart_objects go through all the objects on the map looking |
… | |
… | |
448 | * map archetype. Mimic that behaviour. |
434 | * map archetype. Mimic that behaviour. |
449 | */ |
435 | */ |
450 | width = 16; |
436 | width = 16; |
451 | height = 16; |
437 | height = 16; |
452 | timeout = 300; |
438 | timeout = 300; |
453 | max_nrof = 1000; // 1000 items of anything |
|
|
454 | max_items = MAX_ITEM_PER_ACTION; |
439 | max_items = MAX_ITEM_PER_ACTION; |
455 | max_volume = 2000000; // 2m³ |
440 | max_volume = 2000000; // 2m³ |
456 | } |
441 | } |
457 | |
442 | |
458 | maptile::maptile (int w, int h) |
443 | maptile::maptile (int w, int h) |
… | |
… | |
1034 | sint8 light = 0; |
1019 | sint8 light = 0; |
1035 | MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; |
1020 | MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; |
1036 | uint64_t volume = 0; |
1021 | uint64_t volume = 0; |
1037 | uint32_t items = 0; |
1022 | uint32_t items = 0; |
1038 | object *anywhere = 0; |
1023 | object *anywhere = 0; |
|
|
1024 | uint8_t middle_visibility = 0; |
1039 | |
1025 | |
1040 | //object *middle = 0; |
1026 | //object *middle = 0; |
1041 | //object *top = 0; |
1027 | //object *top = 0; |
1042 | //object *floor = 0; |
1028 | //object *floor = 0; |
1043 | // this seems to generate better code than using locals, above |
1029 | // this seems to generate better code than using locals, above |
… | |
… | |
1060 | * |
1046 | * |
1061 | * Always put the player down for drawing. |
1047 | * Always put the player down for drawing. |
1062 | */ |
1048 | */ |
1063 | if (expect_true (!tmp->invisible)) |
1049 | if (expect_true (!tmp->invisible)) |
1064 | { |
1050 | { |
1065 | if (tmp->type == PLAYER || tmp->flag [FLAG_MONSTER]) |
1051 | if (expect_false (tmp->type == PLAYER || tmp->flag [FLAG_MONSTER])) |
1066 | top = tmp; |
1052 | top = tmp; |
|
|
1053 | else if (expect_false (tmp->flag [FLAG_IS_FLOOR])) |
|
|
1054 | { |
|
|
1055 | /* If we got a floor, that means middle and top were below it, |
|
|
1056 | * so should not be visible, so we clear them. |
|
|
1057 | */ |
|
|
1058 | middle = 0; |
|
|
1059 | top = 0; |
|
|
1060 | floor = tmp; |
|
|
1061 | volume = 0; |
|
|
1062 | items = 0; |
|
|
1063 | } |
1067 | else |
1064 | else |
1068 | { |
1065 | { |
1069 | if (expect_false (tmp->flag [FLAG_IS_FLOOR])) |
1066 | if (expect_true (!tmp->flag [FLAG_NO_PICK])) |
1070 | { |
1067 | { |
1071 | /* If we got a floor, that means middle and top were below it, |
|
|
1072 | * so should not be visible, so we clear them. |
|
|
1073 | */ |
|
|
1074 | middle = 0; |
|
|
1075 | top = 0; |
|
|
1076 | floor = tmp; |
|
|
1077 | volume = 0; |
|
|
1078 | items = 0; |
1068 | ++items; |
|
|
1069 | volume += tmp->volume (); |
1079 | } |
1070 | } |
|
|
1071 | |
|
|
1072 | /* Flag anywhere have high priority */ |
|
|
1073 | if (expect_false (tmp->flag [FLAG_SEE_ANYWHERE])) |
|
|
1074 | anywhere = tmp; |
|
|
1075 | |
|
|
1076 | /* Find the highest visible face around. If equal |
|
|
1077 | * visibilities, we still want the one nearer to the |
|
|
1078 | * top |
1080 | else |
1079 | */ |
|
|
1080 | if (expect_false (::faces [tmp->face].visibility >= middle_visibility)) |
1081 | { |
1081 | { |
1082 | if (expect_true (!tmp->flag [FLAG_NO_PICK])) |
1082 | middle_visibility = ::faces [tmp->face].visibility; |
1083 | { |
|
|
1084 | ++items; |
|
|
1085 | volume += tmp->volume (); |
|
|
1086 | } |
|
|
1087 | |
|
|
1088 | /* Flag anywhere have high priority */ |
|
|
1089 | if (expect_false (tmp->flag [FLAG_SEE_ANYWHERE])) |
|
|
1090 | anywhere = tmp; |
|
|
1091 | /* Find the highest visible face around. If equal |
|
|
1092 | * visibilities, we still want the one nearer to the |
|
|
1093 | * top |
|
|
1094 | */ |
|
|
1095 | else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility)) |
|
|
1096 | middle = tmp; |
1083 | middle = tmp; |
1097 | } |
1084 | } |
1098 | } |
1085 | } |
1099 | } |
1086 | } |
1100 | |
1087 | |
1101 | move_slow |= tmp->move_slow; |
1088 | move_slow |= tmp->move_slow; |