#!/usr/bin/perl -w use strict; ###################################################################### # This is best used like... # ./parser.pl --nodmx --hook checkpoint.pm captures/artemis-blah | perl # It will collect all the object fields, # and output them all on every heartbeat ###################################################################### BEGIN { require "parser.pl"; } # we are based on parser.pl EXCEPT... our %ObjTypes; # will come from parser.pl my %obj; # will store all the details of all the objects "in-game" # because we are about to legitimately redefine some functions... no warnings qw(redefine); # Override this so we do NOT attempt to output DEADBEEF binary from # any of the "normal" parser.pl perl-to-binary functions we've NOT # overridden: sub SendPacket {} # Override this so we keep strings printable, NOT convert to Artemis UTF16: sub UTF16 { return Data::Dumper::qquote(shift); } # Override this so we can store the params passed to ObjNPC or whatever: sub ObjGeneric { my ($type, $id, %kv) = @_; return $type unless defined $id; return ($type, $id) unless %kv; # if this is the first time we have seen it... my $this = $obj{$id} //= { _type => $type, _name => $ObjTypes{$type}[0], _id => $id, }; # store all the other values: for my $key (keys %kv) { $this->{$key} = $kv{$key}; } } sub objectDelete { my $id = shift; delete $obj{$id}; } # Override this so we can OUTPUT all the objects we collected so far: sub heartbeat { print "#"x70, "\n"; for (sort keys %obj) { my $this = $obj{$_}; print $this->{_name} || 'NONAME', ' ' , $this->{_id}; for my $key (sort keys %$this) { next if $key =~ /^_/; # skip metadata, print "real" keys: print " $key=", $this->{$key}; } print "\n"; } } 1; # valid perl modules need to return true