ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra/Deliantra.pm
(Generate patch)

Comparing deliantra/Deliantra/Deliantra.pm (file contents):
Revision 1.119 by root, Wed Dec 26 18:05:00 2007 UTC vs.
Revision 1.131 by root, Tue Sep 1 21:37:25 2009 UTC

4 4
5=cut 5=cut
6 6
7package Deliantra; 7package Deliantra;
8 8
9our $VERSION = '1.13'; 9our $VERSION = '1.24';
10 10
11use strict; 11use common::sense;
12 12
13use base 'Exporter'; 13use base 'Exporter';
14 14
15use Carp (); 15use Carp ();
16use File::Spec; 16use File::Spec;
24 editor_archs arch_extents 24 editor_archs arch_extents
25); 25);
26 26
27use JSON::XS qw(decode_json encode_json); 27use JSON::XS qw(decode_json encode_json);
28 28
29our $LIB = $ENV{CROSSFIRE_LIBDIR}; 29our $LIB = $ENV{DELIANTRA_LIBDIR};
30 30
31our $VARDIR = $ENV{HOME} ? "$ENV{HOME}/.crossfire" 31our $VARDIR = $ENV{HOME} ? "$ENV{HOME}/.deliantra"
32 : $ENV{AppData} ? "$ENV{APPDATA}/crossfire" 32 : $ENV{AppData} ? "$ENV{APPDATA}/deliantra"
33 : File::Spec->tmpdir . "/crossfire"; 33 : File::Spec->tmpdir . "/deliantra";
34 34
35mkdir $VARDIR, 0777; 35mkdir $VARDIR, 0777;
36 36
37sub TILESIZE (){ 32 } 37sub TILESIZE (){ 32 }
38sub CACHESTRIDE (){ 64 } 38sub CACHESTRIDE (){ 64 }
69 69
70 elevation 70 elevation
71 71
72 name name_pl custom_name attach title race 72 name name_pl custom_name attach title race
73 slaying skill msg lore other_arch 73 slaying skill msg lore other_arch
74 face animation is_animated 74 sound sound_destroy face animation is_animated
75 magicmap smoothlevel smoothface 75 magicmap smoothlevel smoothface
76 str dex con wis pow cha int 76 str dex con wis pow cha int
77 hp maxhp sp maxsp grace maxgrace 77 hp maxhp sp maxsp grace maxgrace
78 exp perm_exp expmul 78 exp perm_exp expmul
79 food dam luck wc ac x y speed speed_left move_state attack_movement 79 food dam luck wc ac x y speed speed_left move_state attack_movement
151 boat => MOVE_BOAT, 151 boat => MOVE_BOAT,
152 ship => MOVE_SHIP, 152 ship => MOVE_SHIP,
153 all => MOVE_ALL, 153 all => MOVE_ALL,
154); 154);
155 155
156our @MOVE_TYPE = keys %MOVE_TYPE; 156our @MOVE_TYPE = qw(all ship boat swim flying fly_high fly_low walk);
157 157
158{ 158{
159 package Deliantra::MoveType; 159 package Deliantra::MoveType;
160 160
161 use overload 161 use overload
182 $_[0] 182 $_[0]
183 }, 183 },
184 'eq' => sub { "$_[0]" eq "$_[1]" }, 184 'eq' => sub { "$_[0]" eq "$_[1]" },
185 'ne' => sub { "$_[0]" ne "$_[1]" }, 185 'ne' => sub { "$_[0]" ne "$_[1]" },
186 ; 186 ;
187
188 sub TO_JSON {
189 $_[0][0]
190 }
187} 191}
188 192
189sub Deliantra::MoveType::new { 193sub Deliantra::MoveType::new {
190 my ($class, $string) = @_; 194 my ($class, $string) = @_;
191 195
431sub normalize_arch($) { 435sub normalize_arch($) {
432 my ($ob) = @_; 436 my ($ob) = @_;
433 437
434 normalize_object $ob; 438 normalize_object $ob;
435 439
440 return if $ob->{_atype} eq "object";
441
436 my $arch = $ARCH{$ob->{_name}} 442 my $arch = $ARCH{$ob->{_name}}
437 or (warn "$ob->{_name}: no such archetype", return $ob); 443 or (warn "$ob->{_name}: no such archetype", return $ob);
438 444
439 if ($arch->{type} == 22) { # map 445 if ($arch->{type} == 22) { # map
440 my %normalize = ( 446 my %normalize = (
484} 490}
485 491
486sub attr_freeze($) { 492sub attr_freeze($) {
487 my ($ob) = @_; 493 my ($ob) = @_;
488 494
489 $ob->{attach} = Deliantra::encode_json $ob->{attach} 495 $ob->{attach} = JSON::XS->new->utf8->canonical->encode ($ob->{attach})
490 if exists $ob->{attach}; 496 if exists $ob->{attach};
491 497
492 $ob 498 $ob
493} 499}
494 500
514 520
515 my %arc; 521 my %arc;
516 my ($more, $prev); 522 my ($more, $prev);
517 my $comment; 523 my $comment;
518 524
519 open my $fh, "<:raw:perlio:utf8", $path 525 open my $fh, "<:utf8", $path
520 or Carp::croak "$path: $!"; 526 or Carp::croak "$path: $!";
521 527
522# binmode $fh; 528# binmode $fh;
523 529
524 my $parse_block; $parse_block = sub { 530 my $parse_block; $parse_block = sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines