Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixed small forgotten reference bug and added query functionality.

  • Loading branch information...
commit 99137f4460c6c5099bdc5caadc5449b8f9b6cd97 1 parent 3dd4fe9
elmex elmex authored
6 KNOWN_BUGS
... ... @@ -0,0 +1,6 @@
  1 +- Opening a new UI dialog while a key is pressed leads to
  2 + keyrepeats in the non-visible window. Currently the server needs
  3 + to be very clean w.r.t. opening/closing windows.
  4 +
  5 +- Pending timer events might have a reference to a partly destructed player
  6 + object. Think of a better way to handle logouts and player destruction.
10 lib/Games/Construder/Server/Objects.pm
@@ -17,25 +17,21 @@ Games::Construder::Server::Objects - desc
17 17
18 18 =cut
19 19
20   -our $PL;
21   -our $POS;
22   -
23 20 our %TYPES = (
24 21 36 => \&ia_construction_pad,
25 22 );
26 23
27 24 sub interact {
28 25 my ($player, $type, $pos) = @_;
29   - $PL = $player;
30   - $POS = $pos;
31   -
32 26 my $cb = $TYPES{$type}
33 27 or return;
34 28
35   - $cb->();
  29 + $cb->($player, $pos);
36 30 }
37 31
38 32 sub ia_construction_pad {
  33 + my ($PL, $POS) = @_;
  34 +
39 35 my $a = Games::Construder::World::get_pattern (@$POS, 0);
40 36 if ($a) {
41 37 my $obj = $Games::Construder::Server::RES->get_object_by_pattern ($a);
16 lib/Games/Construder/Server/Player.pm
@@ -362,7 +362,7 @@ sub logout {
362 362 delete $self->{upd_score_hl_tmout};
363 363 delete $self->{death_timer};
364 364 warn "player $self->{name} logged out\n";
365   - #d# print Devel::FindRef::track $self;
  365 + print Devel::FindRef::track $self;
366 366 }
367 367
368 368 my $world_c = 0;
@@ -490,6 +490,20 @@ sub update_score {
490 490
491 491 # TODO: Continue here with UI rewrite:
492 492
  493 +sub query {
  494 + my ($self, $pos) = @_;
  495 + return unless @$pos;
  496 +
  497 + world_mutate_at ($pos, sub {
  498 + my ($data) = @_;
  499 + if ($data->[0]) {
  500 + $self->{uis}->{material_view}->show ($data->[0]);
  501 + }
  502 + return 0;
  503 + });
  504 +
  505 +}
  506 +
493 507 sub interact {
494 508 my ($self, $pos) = @_;
495 509 warn "INTERACT: @$pos\n";
3  lib/Games/Construder/Server/UI.pm
@@ -281,6 +281,7 @@ sub commands {
281 281 c => "cheat",
282 282 t => "location_book",
283 283 e => "interact",
  284 + q => "query",
284 285 )
285 286 }
286 287
@@ -303,6 +304,8 @@ sub handle_command {
303 304 $pl->teleport ([0, 0, 0]);
304 305 } elsif ($cmd eq 'interact') {
305 306 $pl->interact ($pos->[0]) if @{$pos->[0] || []};
  307 + } elsif ($cmd eq 'query') {
  308 + $pl->query ($pos->[0]);
306 309 } elsif ($cmd eq 'exit_server') {
307 310 exit;
308 311 }

0 comments on commit 99137f4

Please sign in to comment.
Something went wrong with that request. Please try again.