ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/item-worldmap.ext
(Generate patch)

Comparing deliantra/server/ext/item-worldmap.ext (file contents):
Revision 1.16 by root, Wed Sep 19 21:56:30 2007 UTC vs.
Revision 1.20 by root, Tue Sep 23 04:29:11 2008 UTC

97 97
98 if ($ns->{can_widget}) { 98 if ($ns->{can_widget}) {
99 my $ws = $ns->{ws_worldmap} ||= create_widgets $ns; 99 my $ws = $ns->{ws_worldmap} ||= create_widgets $ns;
100 $ws->{toplevel}->toggle_visibility; 100 $ws->{toplevel}->toggle_visibility;
101 } else { 101 } else {
102 $ns->send_msg ("log", "Your client doesn't support the (required) widget extension. Try CFPlus at http://crossfire.schmorp.de/.", cf::NDI_RED); 102 $ns->send_msg ("log", "Your client doesn't support the (required) widget extension. Try the deliantra client at http://www.deliantra.net/.", cf::NDI_RED);
103 } 103 }
104 104
105 cf::override 1; 105 cf::override 1;
106 }, 106 },
107; 107;
108 108
109cf::post_init {
109cf::async_ext { 110 cf::async_ext {
110 $Coro::current->{desc} = "worldmap updater"; 111 $Coro::current->{desc} = "worldmap updater";
111 my $schedule_interval = Coro::Event->timer (after => 1);
112 112
113 while () { 113 while () {
114 $schedule_interval->interval ($WORLDMAP_UPDATE_INTERVAL); 114 Coro::EV::timer_once $WORLDMAP_UPDATE_INTERVAL;
115 $schedule_interval->next;
116 115
117 cf::get_slot 0.01, -50, "worldmap update"; 116 cf::get_slot 0.01, -50, "worldmap update";
118 117
119 ++$GENCOUNT; 118 ++$GENCOUNT;
120 119
121 # recalculate player info 120 # recalculate player info
122 my %new; 121 my %new;
123 for (values %cf::PLAYER) { 122 for (values %cf::PLAYER) {
124 my $map = $_->ob->map 123 my $map = $_->ob->map
125 or next; 124 or next;
126 $map =~ /^\/world\/world_(\d\d\d)_(\d\d\d)/ 125 $map =~ /^\/world\/world_(\d\d\d)_(\d\d\d)/
127 or next; 126 or next;
128 127
129 my $ob = $_->ob; 128 my $ob = $_->ob;
130 my $x = ($1 - 100) * 50 + $ob->x; 129 my $x = ($1 - 100) * 50 + $ob->x;
131 my $y = ($2 - 100) * 50 + $ob->y; 130 my $y = ($2 - 100) * 50 + $ob->y;
132 131
133 0 <= $x && 0 <= $y && $x < 1500 && $y < 1500 132 0 <= $x && 0 <= $y && $x < 1500 && $y < 1500
134 or next; 133 or next;
135 134
136 $x = int $x * $MAPW / 1500; 135 $x = int $x * $MAPW / 1500;
137 $y = int $y * $MAPH / 1500; 136 $y = int $y * $MAPH / 1500;
138 137
139 my $name = $ob->name; 138 my $name = $ob->name;
140 139
141 if (my $pi = delete $PLAYERINFO{$name}) { 140 if (my $pi = delete $PLAYERINFO{$name}) {
142 if ($pi->[0] == $x && $pi->[1] == $y) { 141 if ($pi->[0] == $x && $pi->[1] == $y) {
143 $new{$name} = $pi; 142 $new{$name} = $pi;
144 next; 143 next;
144 }
145 } 145 }
146
147 $new{$name} = [$x, $y];
146 } 148 }
149
150 *PLAYERINFO = \%new;
151
152 cf::get_slot 0.03, -50, "worldmap socket update";
153 for (values %cf::PLAYER) {
154 my $ns = $_->ns
147 155 or next;
148 $new{$name} = [$x, $y]; 156
157 update_worldmap $ns->{ws_worldmap}
158 if $ns->{ws_worldmap} && $ns->{ws_worldmap}{toplevel}{visibility};
159 }
149 } 160 }
150
151 *PLAYERINFO = \%new;
152
153 cf::get_slot 0.03, -50, "worldmap socket update";
154 for (values %cf::PLAYER) {
155 my $ns = $_->ns
156 or next;
157
158 update_worldmap $ns->{ws_worldmap}
159 if $ns->{ws_worldmap} && $ns->{ws_worldmap}{toplevel}{visibility};
160 }
161 } 161 };
162}; 162};
163 163

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines