Talk:Witcher 3 Enums

My perl code for dumping enums from the game is below: --— Mpstark (talk) 13:13, 30 April 2016 (UTC)

use strict; use warnings; use File::Find;

$/ = "\r\n";

my $filename = 'D:/enumDump.txt'; my $start_dir = "D:/Games/The Witcher 3 Wild Hunt/content/content0/scripts"; # top level dir to search

print "Dumping enums from $start_dir into $filename\n";

my @files; open(my $fh, '>', $filename) or die "Could not open file '$filename' $!"; find(sub { push @files, $File::Find::name unless -d; }, $start_dir);

for my $file (@files) {   open(my $cur_file, '<:encoding(UCS-2le)', $file) or die "Could not open file '$filename' $!"; print "Dumping enums from $file\n"; my $found_enum = 0; my $enum_num = 0; while(<$cur_file>) {		chomp; s/^\s+//; #remove leading whitespace s/\s+$//; #remove trailing whitespace if (/\benum\b/ && !/.*".*\benum\b.*".*/) {			$found_enum = 1; $enum_num = 0; /^.*enum\s+([\w\d]+)/; print $fh "$1\n"; }		else{ if ($found_enum) {				/^([\w\d]+)\s*(=)?\s*([\d\w]+)?.*/; if ($1) {					print $fh "  $1"; if ($2) {						print $fh " $3\n"; $enum_num = $3; }					else {						print $fh " $enum_num\n"; $enum_num += 1; }				}			}		}		if ($found_enum && /\}/) {			$found_enum = 0; print $fh "\n"; }	}	close $cur_file; }

close $fh;