Skip to content

Commit

Permalink
fixed small forgotten reference bug and added query functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Redeker committed Jun 6, 2011
1 parent 3dd4fe9 commit 99137f4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
6 changes: 6 additions & 0 deletions KNOWN_BUGS
@@ -0,0 +1,6 @@
- Opening a new UI dialog while a key is pressed leads to
keyrepeats in the non-visible window. Currently the server needs
to be very clean w.r.t. opening/closing windows.

- Pending timer events might have a reference to a partly destructed player
object. Think of a better way to handle logouts and player destruction.
10 changes: 3 additions & 7 deletions lib/Games/Construder/Server/Objects.pm
Expand Up @@ -17,25 +17,21 @@ Games::Construder::Server::Objects - desc
=cut =cut


our $PL;
our $POS;

our %TYPES = ( our %TYPES = (
36 => \&ia_construction_pad, 36 => \&ia_construction_pad,
); );


sub interact { sub interact {
my ($player, $type, $pos) = @_; my ($player, $type, $pos) = @_;
$PL = $player;
$POS = $pos;

my $cb = $TYPES{$type} my $cb = $TYPES{$type}
or return; or return;


$cb->(); $cb->($player, $pos);
} }


sub ia_construction_pad { sub ia_construction_pad {
my ($PL, $POS) = @_;

my $a = Games::Construder::World::get_pattern (@$POS, 0); my $a = Games::Construder::World::get_pattern (@$POS, 0);
if ($a) { if ($a) {
my $obj = $Games::Construder::Server::RES->get_object_by_pattern ($a); my $obj = $Games::Construder::Server::RES->get_object_by_pattern ($a);
Expand Down
16 changes: 15 additions & 1 deletion lib/Games/Construder/Server/Player.pm
Expand Up @@ -362,7 +362,7 @@ sub logout {
delete $self->{upd_score_hl_tmout}; delete $self->{upd_score_hl_tmout};
delete $self->{death_timer}; delete $self->{death_timer};
warn "player $self->{name} logged out\n"; warn "player $self->{name} logged out\n";
#d# print Devel::FindRef::track $self; print Devel::FindRef::track $self;
} }


my $world_c = 0; my $world_c = 0;
Expand Down Expand Up @@ -490,6 +490,20 @@ sub update_score {


# TODO: Continue here with UI rewrite: # TODO: Continue here with UI rewrite:


sub query {
my ($self, $pos) = @_;
return unless @$pos;

world_mutate_at ($pos, sub {
my ($data) = @_;
if ($data->[0]) {
$self->{uis}->{material_view}->show ($data->[0]);
}
return 0;
});

}

sub interact { sub interact {
my ($self, $pos) = @_; my ($self, $pos) = @_;
warn "INTERACT: @$pos\n"; warn "INTERACT: @$pos\n";
Expand Down
3 changes: 3 additions & 0 deletions lib/Games/Construder/Server/UI.pm
Expand Up @@ -281,6 +281,7 @@ sub commands {
c => "cheat", c => "cheat",
t => "location_book", t => "location_book",
e => "interact", e => "interact",
q => "query",
) )
} }


Expand All @@ -303,6 +304,8 @@ sub handle_command {
$pl->teleport ([0, 0, 0]); $pl->teleport ([0, 0, 0]);
} elsif ($cmd eq 'interact') { } elsif ($cmd eq 'interact') {
$pl->interact ($pos->[0]) if @{$pos->[0] || []}; $pl->interact ($pos->[0]) if @{$pos->[0] || []};
} elsif ($cmd eq 'query') {
$pl->query ($pos->[0]);
} elsif ($cmd eq 'exit_server') { } elsif ($cmd eq 'exit_server') {
exit; exit;
} }
Expand Down

0 comments on commit 99137f4

Please sign in to comment.