… | |
… | |
58 | qw(move_type move_block move_allow move_on move_off move_slow); |
58 | qw(move_type move_block move_allow move_on move_off move_slow); |
59 | |
59 | |
60 | # same as in server save routine, to (hopefully) be compatible |
60 | # same as in server save routine, to (hopefully) be compatible |
61 | # to the other editors. |
61 | # to the other editors. |
62 | our @FIELD_ORDER_MAP = (qw( |
62 | our @FIELD_ORDER_MAP = (qw( |
|
|
63 | file_format_version |
63 | name attach swap_time reset_timeout fixed_resettime difficulty region |
64 | name attach swap_time reset_timeout fixed_resettime difficulty region |
64 | shopitems shopgreed shopmin shopmax shoprace |
65 | shopitems shopgreed shopmin shopmax shoprace |
65 | darkness width height enter_x enter_y msg maplore |
66 | darkness width height enter_x enter_y msg maplore |
66 | unique template |
67 | unique template |
67 | outdoor temp pressure humid windspeed winddir sky nosmooth |
68 | outdoor temp pressure humid windspeed winddir sky nosmooth |
… | |
… | |
213 | adamant => 256, |
214 | adamant => 256, |
214 | liquid => 512, |
215 | liquid => 512, |
215 | tin => 1024, |
216 | tin => 1024, |
216 | bone => 2048, |
217 | bone => 2048, |
217 | ice => 4096, |
218 | ice => 4096, |
|
|
219 | |
|
|
220 | # guesses |
|
|
221 | runestone => 12, |
|
|
222 | bronze => 18, |
|
|
223 | "ancient wood" => 20, |
|
|
224 | glass => 36, |
|
|
225 | marble => 66, |
|
|
226 | ice => 68, |
|
|
227 | stone => 70, |
|
|
228 | stone => 80, |
|
|
229 | cloth => 136, |
|
|
230 | ironwood => 144, |
|
|
231 | adamantium => 258, |
|
|
232 | glacium => 260, |
|
|
233 | blood => 544, |
218 | ; |
234 | ; |
219 | |
235 | |
220 | # object as in "Object xxx", i.e. archetypes |
236 | # object as in "Object xxx", i.e. archetypes |
221 | sub normalize_object($) { |
237 | sub normalize_object($) { |
222 | my ($ob) = @_; |
238 | my ($ob) = @_; |
… | |
… | |
230 | delete $ob->{material}; |
246 | delete $ob->{material}; |
231 | } else { |
247 | } else { |
232 | warn "object $ob->{_name} has both materialname ($ob->{materialname}) and material ($ob->{material}) set.\n"; |
248 | warn "object $ob->{_name} has both materialname ($ob->{materialname}) and material ($ob->{material}) set.\n"; |
233 | delete $ob->{material}; # assume materilname is more specific and nuke material |
249 | delete $ob->{material}; # assume materilname is more specific and nuke material |
234 | } |
250 | } |
|
|
251 | } elsif (my $name = $MATERIAL{$ob->{material}}) { |
|
|
252 | delete $ob->{material}; |
|
|
253 | $ob->{materialname} = $name; |
235 | } else { |
254 | } else { |
236 | if (my $name = $MATERIAL{$ob->{material}}) { |
255 | warn "object $ob->{_name} has unknown material ($ob->{material}) set.\n"; |
237 | delete $ob->{material}; |
|
|
238 | $ob->{materialname} = $name; |
|
|
239 | } |
|
|
240 | } |
256 | } |
241 | } |
257 | } |
242 | |
258 | |
243 | # nuke outdated or never supported fields |
259 | # nuke outdated or never supported fields |
244 | delete @$ob{qw( |
260 | delete @$ob{qw( |
… | |
… | |
289 | if (defined (my $v = delete $ob->{slow_move})) { |
305 | if (defined (my $v = delete $ob->{slow_move})) { |
290 | $ob->{move_slow} |= MOVE_WALK; |
306 | $ob->{move_slow} |= MOVE_WALK; |
291 | $ob->{move_slow_penalty} = $v; |
307 | $ob->{move_slow_penalty} = $v; |
292 | } |
308 | } |
293 | if (defined (my $v = delete $ob->{walk_on})) { |
309 | if (defined (my $v = delete $ob->{walk_on})) { |
294 | $ob->{move_on} = MOVE_ALL unless exists $ob->{move_on}; |
310 | $ob->{move_on} = MOVE_NONE unless exists $ob->{move_on}; |
295 | $ob->{move_on} = $v ? $ob->{move_on} | MOVE_WALK |
311 | $ob->{move_on} = $v ? $ob->{move_on} | MOVE_WALK |
296 | : $ob->{move_on} & ~MOVE_WALK; |
312 | : $ob->{move_on} & ~MOVE_WALK; |
297 | } |
313 | } |
298 | if (defined (my $v = delete $ob->{walk_off})) { |
314 | if (defined (my $v = delete $ob->{walk_off})) { |
299 | $ob->{move_off} = MOVE_ALL unless exists $ob->{move_off}; |
315 | $ob->{move_off} = MOVE_NONE unless exists $ob->{move_off}; |
300 | $ob->{move_off} = $v ? $ob->{move_off} | MOVE_WALK |
316 | $ob->{move_off} = $v ? $ob->{move_off} | MOVE_WALK |
301 | : $ob->{move_off} & ~MOVE_WALK; |
317 | : $ob->{move_off} & ~MOVE_WALK; |
302 | } |
318 | } |
303 | if (defined (my $v = delete $ob->{fly_on})) { |
319 | if (defined (my $v = delete $ob->{fly_on})) { |
304 | $ob->{move_on} = MOVE_ALL unless exists $ob->{move_on}; |
320 | $ob->{move_on} = MOVE_NONE unless exists $ob->{move_on}; |
305 | $ob->{move_on} = $v ? $ob->{move_on} | MOVE_FLY_LOW |
321 | $ob->{move_on} = $v ? $ob->{move_on} | MOVE_FLY_LOW |
306 | : $ob->{move_on} & ~MOVE_FLY_LOW; |
322 | : $ob->{move_on} & ~MOVE_FLY_LOW; |
307 | } |
323 | } |
308 | if (defined (my $v = delete $ob->{fly_off})) { |
324 | if (defined (my $v = delete $ob->{fly_off})) { |
309 | $ob->{move_off} = MOVE_ALL unless exists $ob->{move_off}; |
325 | $ob->{move_off} = MOVE_NONE unless exists $ob->{move_off}; |
310 | $ob->{move_off} = $v ? $ob->{move_off} | MOVE_FLY_LOW |
326 | $ob->{move_off} = $v ? $ob->{move_off} | MOVE_FLY_LOW |
311 | : $ob->{move_off} & ~MOVE_FLY_LOW; |
327 | : $ob->{move_off} & ~MOVE_FLY_LOW; |
312 | } |
328 | } |
313 | if (defined (my $v = delete $ob->{flying})) { |
329 | if (defined (my $v = delete $ob->{flying})) { |
314 | $ob->{move_type} = MOVE_ALL unless exists $ob->{move_type}; |
330 | $ob->{move_type} = MOVE_NONE unless exists $ob->{move_type}; |
315 | $ob->{move_type} = $v ? $ob->{move_type} | MOVE_FLY_LOW |
331 | $ob->{move_type} = $v ? $ob->{move_type} | MOVE_FLY_LOW |
316 | : $ob->{move_type} & ~MOVE_FLY_LOW; |
332 | : $ob->{move_type} & ~MOVE_FLY_LOW; |
317 | } |
333 | } |
318 | |
334 | |
319 | # convert idiotic event_xxx things into objects |
335 | # convert idiotic event_xxx things into objects |
… | |
… | |
552 | |
568 | |
553 | my $inv = delete $a{inventory}; |
569 | my $inv = delete $a{inventory}; |
554 | my $more = delete $a{more}; # arches do not support 'more', but old maps can contain some |
570 | my $more = delete $a{more}; # arches do not support 'more', but old maps can contain some |
555 | my $anim = delete $a{anim}; |
571 | my $anim = delete $a{anim}; |
556 | |
572 | |
|
|
573 | if ($a{_atype} eq 'object') { |
|
|
574 | $str .= join "\n", "anim", @$anim, "mina\n" |
|
|
575 | if $anim; |
|
|
576 | } |
|
|
577 | |
557 | my @kv; |
578 | my @kv; |
558 | |
579 | |
559 | for ($a{_name} eq "map" |
580 | for ($a{_name} eq "map" |
560 | ? @Crossfire::FIELD_ORDER_MAP |
581 | ? @Crossfire::FIELD_ORDER_MAP |
561 | : @Crossfire::FIELD_ORDER) { |
582 | : @Crossfire::FIELD_ORDER) { |
… | |
… | |
605 | } |
626 | } |
606 | } |
627 | } |
607 | |
628 | |
608 | if ($inv) { |
629 | if ($inv) { |
609 | $append->($_) for @$inv; |
630 | $append->($_) for @$inv; |
610 | } |
|
|
611 | |
|
|
612 | if ($a{_atype} eq 'object') { |
|
|
613 | $str .= join "\n", "anim", @$anim, "mina\n" |
|
|
614 | if $anim; |
|
|
615 | } |
631 | } |
616 | |
632 | |
617 | $str .= "end\n"; |
633 | $str .= "end\n"; |
618 | |
634 | |
619 | if ($a{_atype} eq 'object') { |
635 | if ($a{_atype} eq 'object') { |
… | |
… | |
780 | ]; |
796 | ]; |
781 | |
797 | |
782 | $attr |
798 | $attr |
783 | } |
799 | } |
784 | |
800 | |
785 | sub arch_edit_sections { |
|
|
786 | # if (edit_type == IGUIConstants.TILE_EDIT_NONE) |
|
|
787 | # edit_type = 0; |
|
|
788 | # else if (edit_type != 0) { |
|
|
789 | # // all flags from 'check_type' must be unset in this arch because they get recalculated now |
|
|
790 | # edit_type &= ~check_type; |
|
|
791 | # } |
|
|
792 | # |
|
|
793 | # } |
|
|
794 | # if ((check_type & IGUIConstants.TILE_EDIT_MONSTER) != 0 && |
|
|
795 | # getAttributeValue("alive", defarch) == 1 && |
|
|
796 | # (getAttributeValue("monster", defarch) == 1 || |
|
|
797 | # getAttributeValue("generator", defarch) == 1)) { |
|
|
798 | # // Monster: monsters/npcs/generators |
|
|
799 | # edit_type |= IGUIConstants.TILE_EDIT_MONSTER; |
|
|
800 | # } |
|
|
801 | # if ((check_type & IGUIConstants.TILE_EDIT_WALL) != 0 && |
|
|
802 | # arch_type == 0 && getAttributeValue("no_pass", defarch) == 1) { |
|
|
803 | # // Walls |
|
|
804 | # edit_type |= IGUIConstants.TILE_EDIT_WALL; |
|
|
805 | # } |
|
|
806 | # if ((check_type & IGUIConstants.TILE_EDIT_CONNECTED) != 0 && |
|
|
807 | # getAttributeValue("connected", defarch) != 0) { |
|
|
808 | # // Connected Objects |
|
|
809 | # edit_type |= IGUIConstants.TILE_EDIT_CONNECTED; |
|
|
810 | # } |
|
|
811 | # if ((check_type & IGUIConstants.TILE_EDIT_EXIT) != 0 && |
|
|
812 | # arch_type == 66 || arch_type == 41 || arch_type == 95) { |
|
|
813 | # // Exit: teleporter/exit/trapdoors |
|
|
814 | # edit_type |= IGUIConstants.TILE_EDIT_EXIT; |
|
|
815 | # } |
|
|
816 | # if ((check_type & IGUIConstants.TILE_EDIT_TREASURE) != 0 && |
|
|
817 | # getAttributeValue("no_pick", defarch) == 0 && (arch_type == 4 || |
|
|
818 | # arch_type == 5 || arch_type == 36 || arch_type == 60 || |
|
|
819 | # arch_type == 85 || arch_type == 111 || arch_type == 123 || |
|
|
820 | # arch_type == 124 || arch_type == 130)) { |
|
|
821 | # // Treasure: randomtreasure/money/gems/potions/spellbooks/scrolls |
|
|
822 | # edit_type |= IGUIConstants.TILE_EDIT_TREASURE; |
|
|
823 | # } |
|
|
824 | # if ((check_type & IGUIConstants.TILE_EDIT_DOOR) != 0 && |
|
|
825 | # arch_type == 20 || arch_type == 23 || arch_type == 26 || |
|
|
826 | # arch_type == 91 || arch_type == 21 || arch_type == 24) { |
|
|
827 | # // Door: door/special door/gates + keys |
|
|
828 | # edit_type |= IGUIConstants.TILE_EDIT_DOOR; |
|
|
829 | # } |
|
|
830 | # if ((check_type & IGUIConstants.TILE_EDIT_EQUIP) != 0 && |
|
|
831 | # getAttributeValue("no_pick", defarch) == 0 && ((arch_type >= 13 && |
|
|
832 | # arch_type <= 16) || arch_type == 33 || arch_type == 34 || |
|
|
833 | # arch_type == 35 || arch_type == 39 || arch_type == 70 || |
|
|
834 | # arch_type == 87 || arch_type == 99 || arch_type == 100 || |
|
|
835 | # arch_type == 104 || arch_type == 109 || arch_type == 113 || |
|
|
836 | # arch_type == 122 || arch_type == 3)) { |
|
|
837 | # // Equipment: weapons/armour/wands/rods |
|
|
838 | # edit_type |= IGUIConstants.TILE_EDIT_EQUIP; |
|
|
839 | # } |
|
|
840 | # |
|
|
841 | # return(edit_type); |
|
|
842 | # |
|
|
843 | # |
|
|
844 | } |
|
|
845 | |
|
|
846 | sub cache_file($$&&) { |
801 | sub cache_file($$&&) { |
847 | my ($src, $cache, $load, $create) = @_; |
802 | my ($src, $cache, $load, $create) = @_; |
848 | |
803 | |
849 | my ($size, $mtime) = (stat $src)[7,9] |
804 | my ($size, $mtime) = (stat $src)[7,9] |
850 | or Carp::croak "$src: $!"; |
805 | or Carp::croak "$src: $!"; |