diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..5d47aaef --- /dev/null +++ b/.gitattributes @@ -0,0 +1,8 @@ +# +# This file contains rules that control how Git handles binary and text files, including line endings +# + + +*.bat eol=crlf +*.sh eol=lf +*.pl eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..79d51cfc --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +data/ +obj/ +bak/ +Tools/MaxActorXImport/ActorXImporter.ini +Tools/UT2down/ +Unreal/Shaders.h diff --git a/Core/GL/make.pl b/Core/GL/make.pl index 1d4110b9..1b62bee4 100644 --- a/Core/GL/make.pl +++ b/Core/GL/make.pl @@ -1,644 +1,644 @@ -#!/usr/bin/perl -w - -#------------------------------------------------------------------------------ -# Defines -#------------------------------------------------------------------------------ - -sub TEST {0} # 0|1 - work | test -sub LOG_ERRS {0} # 0|1 - normal log | log errors only -sub TEST_ARGS {0} # 1 = show argument parsing as comments in CODE - -#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -if (not TEST) { - #......... work ......... - $infile = "funcs.in"; - $constfile = "consts.in"; - $outhdr = "../GLBind.h"; - $outcode = "../GLBindImpl.h"; -} else { - #......... test ......... - print "*** TEST RUN ***\n"; - $infile = "funcs.in.test"; - $constfile = "consts.in"; - $outhdr = "decl.h"; - $outcode = "impl.h"; -} - -$strucname = "GL"; -$constname = "NUM_GLFUNCS"; -$constname2 = "NUM_EXTFUNCS"; -$constname3 = "NUM_EXTENSIONS"; -$extArrName = "extInfo"; -$log = "printf("; - - -#------------------------------------------------------------------------------ -# Platform-dependent stuff -#------------------------------------------------------------------------------ - -sub PlatformArray { (0, 0, 0) } - -@platformNames = ("base", "win32", "linux"); - -sub PlatformIndex { - my $i; - my $name = $_[0]; - - $i = 0; - while ($i <= $#platformNames) - { - return $i if $platformNames[$i] eq $name; - $i++; - } - die "Unknown platform name: ", $name; -} - -sub PlatformDefine { - my $idx = $_[0]; - - if ($idx == 1) { - return "_WIN32"; - } elsif ($idx == 2) { - return "__linux__"; - } else { - die "Unknown platform index: ", $idx; - } -} - - -#------------------------------------------------------------------------------ -# Functions -#------------------------------------------------------------------------------ - - -sub getline { - while ($line = ) - { - # remove CR/LF - $line =~ s/\r//; - $line =~ s/\n//; - # remove "//..." comments - $line =~ s/\s*\/\/.*//; - # ignore empty lines - next if $line eq ""; - return 1; - } - return 0; -} - - -sub const { - my ($args) = @_; - my ($str); - - return if TEST; # do not generate this constants for test version - - @consts = split(' ', $args); - for $str (@consts) - { - print(CODE < 0; - printf(CODE "\n\t\"%s\"", $funcname); -} - -sub EmitLogInit { - print(CODE ",") if $num > 0; - printf(CODE "\n\tlog%s", $func); -} - -sub EmitLogDecl { - my ($s, $i); - my (@atype, @parm, @arr); - - if ($end eq "") - { - # no logging for this function, declare empty function - print(CODE "static $type APIENTRY log$func($args)\n{}\n\n"); - return; - } - - # add logging - - # separating arguments - @args = split(',', $args); - - # extracting type info for each argument - print(CODE "//\tParsing ($args):\n") if TEST_ARGS; - @atype = @parm = @arr = (); - $i = 0; - for $arg (@args) - { - my ($atype0, $parm0, $arr0); - ($atype0, $parm0, $arr0) = $arg =~ / \s* (\S+ .* [\*\s]) (\w+) (\[.*\])? /x; - if (!defined $parm0) { - # possibly declaration of this prototype has no argument name, has only a type - ($atype0) = $arg =~ / \s* (\S+ .* [\*\s]? $)/x; - $parm0 = "arg".($i+1); - $arr0 = ""; - } - ($atype0) = $atype0 =~ /\s*(\S.*\S)\s*/; # truncate leading and trailing spaces - $arr0 = "" if !defined $arr0; - print(CODE "//\t$i: type=[$atype0] parm=[$parm0] arr=[$arr0]\n") if TEST_ARGS; - $atype[$i] = $atype0; - $parm[$i] = $parm0; - $arr[$i] = $arr0; - $i++; - } - - # generate function header - # we need to parse params here because param names could be generated in a code above - print(CODE "static $type APIENTRY log$func("); - $i = 0; - for $s (@parm) - { - print(CODE ", ") if $i > 0; - print(CODE "${atype[$i]} $s${arr[$i]}"); - $i++; - } - print(CODE ")\n{\n"); - - if (LOG_ERRS) { - # special mode: log errors only - # generate call to a library function - my $void = $type =~ /\w*void$/; # may be GLvoid - if (!$void) { - print(CODE "\t$type ret = "); - } else { - print(CODE "\t"); - } - print(CODE "lib.$func("); - # make arguments for call - $i = 0; - for $s (@parm) - { - print(CODE ", ") if $i > 0; - print(CODE $s); - $i++; - } - print(CODE ");\n"); - print(CODE "\tGLenum err = lib.GetError();\n\tif (err) $log\"ERROR: %X in %s\\n\", err, \"$funcname\");\n"); -# print(CODE "\telse $log\"%s\\n\", \"", $funcname, "\");\n"); - print(CODE "\treturn ret;\n") if !$void; - print(CODE "}\n"); - return; - } - - # generate logging - if ($end =~ /ARGS/) - { - print(CODE "\t$log\"%s("); - $i = 0; - for $s (@atype) - { - my $fmt; - - #............... log with parsing params ........................ - die ("Array used for ", $s, " in func ", $func) if $arr[$i] ne ""; - if ($s =~ /.*\*/) { - $fmt = "\$%X"; # pointer - } elsif ($s =~ /\w*(int|sizei|byte|boolean)/) { - $fmt = "%d"; - } elsif ($s =~ /\w*(float|double|clampd|clampf)/) { - $fmt = "%g"; - } elsif ($s =~ /\w*(enum)/) { - $fmt = "GL_%s"; - } else { - die "Unknown argument type \"", $s, "\""; - } - print(CODE ", ") if $i > 0; - print(CODE $fmt); - $i++; - } - print(CODE ")\\n\", \"$funcname\""); - $i = 0; - for $s (@parm) - { - if ($atype[$i] =~ /\w*(enum)/) { - print(CODE ", EnumName($s)"); - } elsif ($atype[$i] =~ /.*\*/) { - # pointer: cast to unsigned to avoid warning in GCC - print(CODE ", (unsigned)$s"); - } else { - print(CODE ", $s"); - } - $i++; - } - print(CODE ");\n"); - } elsif ($end =~ /NOLOG/) { - # nothing - } elsif ($end =~ /;/) { - #................... log function name only .......................... - print(CODE "\t$log\"%s\\n\", \"", $funcname, "\");\n"); # make fprintf(..., "%s", "glFunction\n"); - } elsif ($end !~ /NAME/) { - die "Invalid token: \"", $end, "\""; - } - - # generate call to a library function - if ($type !~ /\w*void$/) { # may be GLvoid - print(CODE "\treturn "); - } else { - print(CODE "\t"); - } - print(CODE "lib.$func("); - # make arguments for call - $i = 0; - for $s (@parm) - { - print(CODE ", ") if $i > 0; - print(CODE $s); - $i++; - } - print(CODE ");\n}\n\n"); -} - -sub EmitExtensionHDR { - my $num; - - $num = $numExtensions[$platform] - 1; # position = count - 1 - $num += $numExtensions[0] if $platform; - my $name = $extName; - if ($name =~ /^[0-9]+.*/) { # OpenGL version instead of extension name - $name = "GL_".$name; - $name =~ s/\./_/g; - } - printf(HDR "#define Q%s\t(1 << %d)\n", uc($name), $num); -} - -sub EmitExtensionCODE { - my ($numFuncs, $alias); - - print(CODE ",\n") if $numExtensions[0] > 1 || $platform > 0; - # name - printf(CODE "\t{\"%s\\0\"", $extName); - foreach $alias (@aliases) { - printf(CODE " \"%s\\0\"", $alias); - } - print(CODE ", NULL, "); - # cvar - if ($extCvar ne "") { - printf(CODE "\"%s\", ", $extCvar); - } else { - print(CODE "NULL, "); - } - # funcs - $numFuncs = $numExt[$platform] - $firstExtFunc; - if ($numFuncs) { - $firstExtFunc += $numExt[0] if $platform; - printf(CODE "%s+%d, %d, ", $constname, $firstExtFunc, $numFuncs); - } else { - print(CODE "0, 0, "); - } - # require/deprecate - print(CODE $require, ", ", $prefer); - print(CODE "}"); -} - -sub CloseExtension { - &$subExtension () if defined $subExtension && $extName ne ""; - $extName = ""; -} - - -# Close opened platform-depended code -sub ClosePlatform { - my $lazy = $_[0]; - CloseExtension (); - $firstExtFunc = 0; - if ($platform != 0 && defined $subPlatform) - { - $oldPlatform = $platform; - if (!$lazy) { - $platform = 0; # base - &$subPlatform (); - } - } -} - -# Change work platform -sub OpenPlatform { - ClosePlatform (1); - $oldPlatform = $platform; - $platform = PlatformIndex($_[0]); - &$subPlatform () if defined $subPlatform; -} - -sub ExtNameRequired { - die "\"#", $_[0], "\" without \"#name\"" if $extName eq ""; -} - -sub ExtExpression { - my ($str, $i); - - $str = ""; - for $i (split (' ', $_[0])) - { - $i = "Q".uc($i); - $str = $str." | " if $str ne ""; - $str = $str.$i; - } - return $str; -} - -# Usage: Parse ( ) -sub Parse { - ($subBegin, $subPlatform, $subExtension) = @_; - - open(IN, $infile) || die "Input file ", $infile, " not found"; - @numBase = PlatformArray; - @numExt = PlatformArray; - @numExtensions = PlatformArray; - $num = 0; - $platform = 0; - $oldPlatform = 0; - $isExt = 0; - - while (getline()) - { - my ($cmd, undef, $cmda) = $line =~ /^\# \s* (\w+) (\s+ ([\w\.]+ (\s+ [\w\.]+)*)\s?)? $/x; - $cmd = "" if !defined $cmd; - - #.............. our "preprocessor" ............... - if ($cmd eq "platform") { - OpenPlatform($cmda); - } elsif ($cmd eq "extensions") { - ClosePlatform(0); - $isExt = 1; - $platform = 0; - } elsif ($cmd eq "name") { - die "\"#name\" without \"#extensions\"" if $isExt == 0; - CloseExtension(); - $numExtensions[$platform]++; - $extName = $cmda; - @aliases = (); - $extCvar = ""; # undefine cvar - $firstExtFunc = $numExt[$platform]; - $prefer = "0"; - $require = "0"; - } elsif ($cmd eq "alias") { - ExtNameRequired($cmd); - # alternative ways to add $cmda to array @aliases: -# @aliases = (@aliases, $cmda); #1 -# $aliases[++$#aliases] = $cmda; #2 - push @aliases, $cmda; #3 - } elsif ($cmd eq "cvar") { - ExtNameRequired($cmd); - $extCvar = $cmda; - } elsif ($cmd eq "prefer") { - ExtNameRequired($cmd); - $prefer = ExtExpression($cmda); - } elsif ($cmd eq "require") { - ExtNameRequired($cmd); - $require = ExtExpression($cmda); - } elsif ($cmd ne "") { - die "Unknown command: ", $cmd - } else { - #.......... function declaration ............. - ($type, $func, $args, $end) = $line =~ / \s* (\S+ .* [\*\s]) (\w+) \s* \( (.*) \) \s* (\S*.*) /x; - ($type) = $type =~ /\s*(\S.*\S)\s*/; # truncate leading and trailing spaces - if ($end =~ /NAME/) { - ($funcname) = $end =~ / .* NAME \s+ (\w+)/x; - } - else { - if ($platform == 0) { - $funcname = "gl".$func if $platform == 0; - } else { - $funcname = $func; - ($func) = $func =~ / [a-z]* ([A-Z]\w+) /x; - } - } - - &$subBegin () if defined $subBegin; - if ($isExt) { - $numExt[$platform]++; - } else { - $numBase[$platform]++; - } - $num++; - } - } - ClosePlatform(0); - - close(IN); -} - - -#------------------------------------------------------------------------------ -# Main program -#------------------------------------------------------------------------------ - -# open files -open(HDR, ">$outhdr") || die "Cannot create file ", $outhdr; -print(HDR "// Autogenerated file: do not modify\n\n"); -open(CODE, ">$outcode") || die "Cannot create file ", $outcode; -print(CODE "// Autogenerated file: do not modify\n\n"); - -Parse(); -$i = 0; -for $ct (@numBase) -{ - printf("Found %d + %d functions (%d extensions) for %s\n", $ct, $numExt[$i], $numExtensions[$i], $platformNames[$i]); - $i++; -} - - -#------------------------------------------------------------------------------ -# Creating header part -#------------------------------------------------------------------------------ - -print(HDR <) + { + # remove CR/LF + $line =~ s/\r//; + $line =~ s/\n//; + # remove "//..." comments + $line =~ s/\s*\/\/.*//; + # ignore empty lines + next if $line eq ""; + return 1; + } + return 0; +} + + +sub const { + my ($args) = @_; + my ($str); + + return if TEST; # do not generate this constants for test version + + @consts = split(' ', $args); + for $str (@consts) + { + print(CODE < 0; + printf(CODE "\n\t\"%s\"", $funcname); +} + +sub EmitLogInit { + print(CODE ",") if $num > 0; + printf(CODE "\n\tlog%s", $func); +} + +sub EmitLogDecl { + my ($s, $i); + my (@atype, @parm, @arr); + + if ($end eq "") + { + # no logging for this function, declare empty function + print(CODE "static $type APIENTRY log$func($args)\n{}\n\n"); + return; + } + + # add logging + + # separating arguments + @args = split(',', $args); + + # extracting type info for each argument + print(CODE "//\tParsing ($args):\n") if TEST_ARGS; + @atype = @parm = @arr = (); + $i = 0; + for $arg (@args) + { + my ($atype0, $parm0, $arr0); + ($atype0, $parm0, $arr0) = $arg =~ / \s* (\S+ .* [\*\s]) (\w+) (\[.*\])? /x; + if (!defined $parm0) { + # possibly declaration of this prototype has no argument name, has only a type + ($atype0) = $arg =~ / \s* (\S+ .* [\*\s]? $)/x; + $parm0 = "arg".($i+1); + $arr0 = ""; + } + ($atype0) = $atype0 =~ /\s*(\S.*\S)\s*/; # truncate leading and trailing spaces + $arr0 = "" if !defined $arr0; + print(CODE "//\t$i: type=[$atype0] parm=[$parm0] arr=[$arr0]\n") if TEST_ARGS; + $atype[$i] = $atype0; + $parm[$i] = $parm0; + $arr[$i] = $arr0; + $i++; + } + + # generate function header + # we need to parse params here because param names could be generated in a code above + print(CODE "static $type APIENTRY log$func("); + $i = 0; + for $s (@parm) + { + print(CODE ", ") if $i > 0; + print(CODE "${atype[$i]} $s${arr[$i]}"); + $i++; + } + print(CODE ")\n{\n"); + + if (LOG_ERRS) { + # special mode: log errors only + # generate call to a library function + my $void = $type =~ /\w*void$/; # may be GLvoid + if (!$void) { + print(CODE "\t$type ret = "); + } else { + print(CODE "\t"); + } + print(CODE "lib.$func("); + # make arguments for call + $i = 0; + for $s (@parm) + { + print(CODE ", ") if $i > 0; + print(CODE $s); + $i++; + } + print(CODE ");\n"); + print(CODE "\tGLenum err = lib.GetError();\n\tif (err) $log\"ERROR: %X in %s\\n\", err, \"$funcname\");\n"); +# print(CODE "\telse $log\"%s\\n\", \"", $funcname, "\");\n"); + print(CODE "\treturn ret;\n") if !$void; + print(CODE "}\n"); + return; + } + + # generate logging + if ($end =~ /ARGS/) + { + print(CODE "\t$log\"%s("); + $i = 0; + for $s (@atype) + { + my $fmt; + + #............... log with parsing params ........................ + die ("Array used for ", $s, " in func ", $func) if $arr[$i] ne ""; + if ($s =~ /.*\*/) { + $fmt = "\$%X"; # pointer + } elsif ($s =~ /\w*(int|sizei|byte|boolean)/) { + $fmt = "%d"; + } elsif ($s =~ /\w*(float|double|clampd|clampf)/) { + $fmt = "%g"; + } elsif ($s =~ /\w*(enum)/) { + $fmt = "GL_%s"; + } else { + die "Unknown argument type \"", $s, "\""; + } + print(CODE ", ") if $i > 0; + print(CODE $fmt); + $i++; + } + print(CODE ")\\n\", \"$funcname\""); + $i = 0; + for $s (@parm) + { + if ($atype[$i] =~ /\w*(enum)/) { + print(CODE ", EnumName($s)"); + } elsif ($atype[$i] =~ /.*\*/) { + # pointer: cast to unsigned to avoid warning in GCC + print(CODE ", (unsigned)$s"); + } else { + print(CODE ", $s"); + } + $i++; + } + print(CODE ");\n"); + } elsif ($end =~ /NOLOG/) { + # nothing + } elsif ($end =~ /;/) { + #................... log function name only .......................... + print(CODE "\t$log\"%s\\n\", \"", $funcname, "\");\n"); # make fprintf(..., "%s", "glFunction\n"); + } elsif ($end !~ /NAME/) { + die "Invalid token: \"", $end, "\""; + } + + # generate call to a library function + if ($type !~ /\w*void$/) { # may be GLvoid + print(CODE "\treturn "); + } else { + print(CODE "\t"); + } + print(CODE "lib.$func("); + # make arguments for call + $i = 0; + for $s (@parm) + { + print(CODE ", ") if $i > 0; + print(CODE $s); + $i++; + } + print(CODE ");\n}\n\n"); +} + +sub EmitExtensionHDR { + my $num; + + $num = $numExtensions[$platform] - 1; # position = count - 1 + $num += $numExtensions[0] if $platform; + my $name = $extName; + if ($name =~ /^[0-9]+.*/) { # OpenGL version instead of extension name + $name = "GL_".$name; + $name =~ s/\./_/g; + } + printf(HDR "#define Q%s\t(1 << %d)\n", uc($name), $num); +} + +sub EmitExtensionCODE { + my ($numFuncs, $alias); + + print(CODE ",\n") if $numExtensions[0] > 1 || $platform > 0; + # name + printf(CODE "\t{\"%s\\0\"", $extName); + foreach $alias (@aliases) { + printf(CODE " \"%s\\0\"", $alias); + } + print(CODE ", NULL, "); + # cvar + if ($extCvar ne "") { + printf(CODE "\"%s\", ", $extCvar); + } else { + print(CODE "NULL, "); + } + # funcs + $numFuncs = $numExt[$platform] - $firstExtFunc; + if ($numFuncs) { + $firstExtFunc += $numExt[0] if $platform; + printf(CODE "%s+%d, %d, ", $constname, $firstExtFunc, $numFuncs); + } else { + print(CODE "0, 0, "); + } + # require/deprecate + print(CODE $require, ", ", $prefer); + print(CODE "}"); +} + +sub CloseExtension { + &$subExtension () if defined $subExtension && $extName ne ""; + $extName = ""; +} + + +# Close opened platform-depended code +sub ClosePlatform { + my $lazy = $_[0]; + CloseExtension (); + $firstExtFunc = 0; + if ($platform != 0 && defined $subPlatform) + { + $oldPlatform = $platform; + if (!$lazy) { + $platform = 0; # base + &$subPlatform (); + } + } +} + +# Change work platform +sub OpenPlatform { + ClosePlatform (1); + $oldPlatform = $platform; + $platform = PlatformIndex($_[0]); + &$subPlatform () if defined $subPlatform; +} + +sub ExtNameRequired { + die "\"#", $_[0], "\" without \"#name\"" if $extName eq ""; +} + +sub ExtExpression { + my ($str, $i); + + $str = ""; + for $i (split (' ', $_[0])) + { + $i = "Q".uc($i); + $str = $str." | " if $str ne ""; + $str = $str.$i; + } + return $str; +} + +# Usage: Parse ( ) +sub Parse { + ($subBegin, $subPlatform, $subExtension) = @_; + + open(IN, $infile) || die "Input file ", $infile, " not found"; + @numBase = PlatformArray; + @numExt = PlatformArray; + @numExtensions = PlatformArray; + $num = 0; + $platform = 0; + $oldPlatform = 0; + $isExt = 0; + + while (getline()) + { + my ($cmd, undef, $cmda) = $line =~ /^\# \s* (\w+) (\s+ ([\w\.]+ (\s+ [\w\.]+)*)\s?)? $/x; + $cmd = "" if !defined $cmd; + + #.............. our "preprocessor" ............... + if ($cmd eq "platform") { + OpenPlatform($cmda); + } elsif ($cmd eq "extensions") { + ClosePlatform(0); + $isExt = 1; + $platform = 0; + } elsif ($cmd eq "name") { + die "\"#name\" without \"#extensions\"" if $isExt == 0; + CloseExtension(); + $numExtensions[$platform]++; + $extName = $cmda; + @aliases = (); + $extCvar = ""; # undefine cvar + $firstExtFunc = $numExt[$platform]; + $prefer = "0"; + $require = "0"; + } elsif ($cmd eq "alias") { + ExtNameRequired($cmd); + # alternative ways to add $cmda to array @aliases: +# @aliases = (@aliases, $cmda); #1 +# $aliases[++$#aliases] = $cmda; #2 + push @aliases, $cmda; #3 + } elsif ($cmd eq "cvar") { + ExtNameRequired($cmd); + $extCvar = $cmda; + } elsif ($cmd eq "prefer") { + ExtNameRequired($cmd); + $prefer = ExtExpression($cmda); + } elsif ($cmd eq "require") { + ExtNameRequired($cmd); + $require = ExtExpression($cmda); + } elsif ($cmd ne "") { + die "Unknown command: ", $cmd + } else { + #.......... function declaration ............. + ($type, $func, $args, $end) = $line =~ / \s* (\S+ .* [\*\s]) (\w+) \s* \( (.*) \) \s* (\S*.*) /x; + ($type) = $type =~ /\s*(\S.*\S)\s*/; # truncate leading and trailing spaces + if ($end =~ /NAME/) { + ($funcname) = $end =~ / .* NAME \s+ (\w+)/x; + } + else { + if ($platform == 0) { + $funcname = "gl".$func if $platform == 0; + } else { + $funcname = $func; + ($func) = $func =~ / [a-z]* ([A-Z]\w+) /x; + } + } + + &$subBegin () if defined $subBegin; + if ($isExt) { + $numExt[$platform]++; + } else { + $numBase[$platform]++; + } + $num++; + } + } + ClosePlatform(0); + + close(IN); +} + + +#------------------------------------------------------------------------------ +# Main program +#------------------------------------------------------------------------------ + +# open files +open(HDR, ">$outhdr") || die "Cannot create file ", $outhdr; +print(HDR "// Autogenerated file: do not modify\n\n"); +open(CODE, ">$outcode") || die "Cannot create file ", $outcode; +print(CODE "// Autogenerated file: do not modify\n\n"); + +Parse(); +$i = 0; +for $ct (@numBase) +{ + printf("Found %d + %d functions (%d extensions) for %s\n", $ct, $numExt[$i], $numExtensions[$i], $platformNames[$i]); + $i++; +} + + +#------------------------------------------------------------------------------ +# Creating header part +#------------------------------------------------------------------------------ + +print(HDR <) - { - # remove CR/LF - $line =~ s/\r//; - $line =~ s/\n//; - # remove comments - $line =~ s/\s*\/\/.*//; # // ... - $line =~ s/\s*\/\*.*\*\/\s*//; # /* ... */ - # remove leading and trailing spaces (again) - $line =~ s/^\s*//; - $line =~ s/\s*$//; - # replace all multiple spaces with a single one - $line =~ s/\s\s+/ /g; - # ignore empty lines - next if $line eq ""; - return 1; - } - return 0; -} - - -open(IN, $verfionsCpp) || Error ("can't open infile $verfionsCpp"); - -while (getline0()) -{ - if ($line =~ /^enum\s*\w+/) { - last; - } - print("SKIP: $line\n") if DBG; -} - -if ($line !~ ".*\{") { - getline0(); - die "Bad format" if $line !~ /\{/; -} - -$value = 0; -$findConst = $ARGV[0]; - -if (!defined($findConst)) { - print("Please supply constant name as argument\n"); - exit(1); -} - -while (getline0()) -{ - if ($line =~ /^\}/) { - last; - } - my ($name, undef, $val) = $line =~ /^ (\w+) (\s* \= \s* (\w+))? (\,)? $/x; - if (defined($val)) { - $value = $val; - } - - if (!defined($name)) { - print("Bad: $line\n") if DBG; - last; - } - print("ENUM: $name = $value ($line)\n") if DBG; - - if (uc($findConst) eq uc($name)) { - print("$findConst = $value\n"); - exit(0); - } - - $value = $value + 1; -} - -print("$findConst was not found!\n"); +#!/usr/bin/perl -w + +$verfionsCpp = "C:/Projects/Epic/UnrealEngine4-latest/Engine/Source/Runtime/Core/Public/UObject/ObjectVersion.h"; + +sub DBG() {0} + +sub getline0 { + while ($line = ) + { + # remove CR/LF + $line =~ s/\r//; + $line =~ s/\n//; + # remove comments + $line =~ s/\s*\/\/.*//; # // ... + $line =~ s/\s*\/\*.*\*\/\s*//; # /* ... */ + # remove leading and trailing spaces (again) + $line =~ s/^\s*//; + $line =~ s/\s*$//; + # replace all multiple spaces with a single one + $line =~ s/\s\s+/ /g; + # ignore empty lines + next if $line eq ""; + return 1; + } + return 0; +} + + +open(IN, $verfionsCpp) || Error ("can't open infile $verfionsCpp"); + +while (getline0()) +{ + if ($line =~ /^enum\s*\w+/) { + last; + } + print("SKIP: $line\n") if DBG; +} + +if ($line !~ ".*\{") { + getline0(); + die "Bad format" if $line !~ /\{/; +} + +$value = 0; +$findConst = $ARGV[0]; + +if (!defined($findConst)) { + print("Please supply constant name as argument\n"); + exit(1); +} + +while (getline0()) +{ + if ($line =~ /^\}/) { + last; + } + my ($name, undef, $val) = $line =~ /^ (\w+) (\s* \= \s* (\w+))? (\,)? $/x; + if (defined($val)) { + $value = $val; + } + + if (!defined($name)) { + print("Bad: $line\n") if DBG; + last; + } + print("ENUM: $name = $value ($line)\n") if DBG; + + if (uc($findConst) eq uc($name)) { + print("$findConst = $value\n"); + exit(0); + } + + $value = $value + 1; +} + +print("$findConst was not found!\n"); diff --git a/Tools/CompatTable/parse.pl b/Tools/CompatTable/parse.pl index b66e69c6..b03a6106 100644 --- a/Tools/CompatTable/parse.pl +++ b/Tools/CompatTable/parse.pl @@ -1,372 +1,372 @@ -#!/usr/bin/perl -w - -# TODO fixed table headers: jQuery version: http://codepen.io/jgx/pen/wiIGc - -$embed_css = 1; -$debug_js = 0; -$OUT = "table.html"; -$debug = 0; - -$JsLog = "opera.postError"; # Opera -#$JsLog = "console.log"; # IE - -#------------------------------------------------------------------------------ -# Line parser -#------------------------------------------------------------------------------ - -$unget_line = ""; -$inComment = 0; - -sub getline { - if ($unget_line ne "") { - local $ret = $unget_line; - $unget_line = ""; - return $ret; - } - - while ($line = ) - { - # remove CR/LF - $line =~ s/\r//; - $line =~ s/\n//; - # remove comments - if ($inComment) - { - if ($line =~ /.*\*\//) # close comment - { - $line =~ s/^.*\*\///; - $inComment = 0; # ... and continue parsing here - } - else - { - $line = "\\n"; # continue comment - return 1; - } - } - $line =~ s/\/\*.*\*\///g; # remove /* ... */ in a single line - if ($line =~ /\/\*/) - { - $inComment = 1; # open comment - $line =~ s/\/\*.*$//; # ... and continue parsing to remove extra spaces etc - } -# $line =~ s/\/\*.*$//; - $line =~ s/\s*\;.*//; # ; = comment - # remove traling and leading spaces - $line =~ s/^[\s\t]+//; - $line =~ s/[\s\t]+$//; - # remove cosmetic whitespaces -# $line =~ s/[\s\t]*([=*+\-,(){}#])[\s\t]*/$1/g; - $line =~ s/[\s\t]+/\ /g; - - next if $line eq ""; - return 1; - } - return 0; -} - - -sub ungetLine { - die "multiple ungetLine" if $unget_line ne ""; - $unget_line = $_[0]; -} - - -#------------------------------------------------------------------------------ -# Headers -#------------------------------------------------------------------------------ - -sub styleSheet { - my ($file) = $_[0]; - if (!$embed_css) { - print OUT "\n"; - } else { - print OUT < - - - -EOF -; - } -} - - -sub tableSearch { - print OUT < -EOF -; - my ($file) = $_[0]; - open(IN, $file) or die "Unable to read file $file\n"; - while (my $line = ) { - if ($debug_js) { - $line =~ s/DEBUG/$JsLog/g; - } else { - # remove debugging stuff - $line =~ s/DEBUG\(.*\);//g; - $line =~ s/(\s*\/\/.*)$//; -# $line =~ s/\s+/ /; - next if $line =~ /^\s*$/; - } - print OUT $line; - } - close(IN); - print OUT < - -
-
-
- FILTER -
-

-

-EOF -; -} - - -sub tableHeader { - print OUT < - - Year -
Title
- Mesh - Tex - Anim - Stat - Engine -
Developer
- -EOF -; -} - - -sub tableFooter { - my $supported = $partSupp + $fullSupp; - print OUT <  - - - - - - -
 
-

Year: By clicking on the year for an entry, it will take you to the thread on the form that talks about this game.

-

Title: By clicking on the title of a game, it will take you to the Wikipedia information for that game. If the Wikipedia page does not exist it will take you to their website or other press release.

-

Developer: By clicking on Developer for an entry it will take you to the Wikipedia information for that developer. If the Wikipedia page does not exist it will take you to their website or other related information.

-

Other columns: Mesh: skeletal mesh, Tex: texture, Anim: skeletal animation, Stat: static mesh.

-
- - - - Total games: ${supported} supported (${fullSupp} fully), ${notSupp} unsupported - - - -EOF -; -} - - -#------------------------------------------------------------------------------ -# Company urls -#------------------------------------------------------------------------------ - -%compUrls = (); - -sub readCompanies { - my ($file) = $_[0]; - open(IN, $file) or die "Unable to read file $file\n"; - - while (getline()) - { - my ($comp, $url) = $line =~ /(.+?) = (\S+)/x; - $compUrls{$comp} = $url; - } - - close(IN); -} - - -#------------------------------------------------------------------------------ -# Main code -#------------------------------------------------------------------------------ - -# parsing state -@lines = (); -$engine = ""; -$year = 0; - -# statistics -$fullSupp = 0; # number of fully supported games in total -$partSupp = 0; # number of partially supported games -$notSupp = 0; # number of unsupported games -$lastEngine = ""; -$yearGames = 0; # number of supported games in the current year - -sub yesno { - my ($v) = $_[0]; - return "YES" if ($v eq "Y"); - return "NO" if ($v eq "N"); - return $v; -} - - -sub flushYearStats { - if ($yearGames) { - printf(" %d %3d\n", $year, $yearGames); - $yearGames = 0; - } - if ($engine ne $lastEngine) { - $lastEngine = $engine; - printf("\n%s\n", $engine); - } -} - -sub flushGame { - my ($cmd, $val) = $lines[0] =~ /^ \[ (.+) \s* = \s* (.+) \] $/x; - if (defined($cmd) && defined($val)) { - # command - printf("COMMAND: [%s] = [%s]\n", $cmd, $val) if $debug; - if ($cmd =~ /engine/i) { - flushYearStats(); - $engine = $val; -print OUT <  - -
$val
- -EOF -; - } elsif ($cmd =~ /year/i) { - flushYearStats(); - $year = $val; -print OUT <  - -
$year
- -   -EOF -; - } else { - die "Unknown command: $cmd\n"; - } - } else { - # game - my ($game) = $lines[0] =~ /\[ \s* (.*) \s* \]/x; - my $caps = $lines[1]; - printf("GAME: [%s] [%s]\n", $game, $caps) if $debug; - my ($c1, $c2, $c3, $c4, $ver) = $caps =~ /^ (\S+) \s+ (\S+) \s+ (\S+) \s+ (\S+) \s+ (\S+) $/x; - my $color = ""; - my $note = ""; - if (defined($c1) && defined($ver)) { # everything is defined - # none - } else { - ($note, $ver) = $caps =~ /^ (\S+) \s+ (\S+) $/x; - if ($note =~ /unsupported/i) { - $c1 = $c2 = $c3 = $c4 = "N"; - #?? can add "all" etc - } else { - die "Unknown caps: \"$caps\" ($note)"; - } - } - if (($c1 =~ /[-Y]/i) && ($c2 =~ /[-Y]/i) && ($c3 =~ /[-Y]/i) && ($c4 =~ /[-Y]/i)) { - $color = "#BBFFBB"; - $fullSupp = $fullSupp + 1; - $yearGames++; - } elsif (($c1 =~ /[-N]/i) && ($c2 =~ /[-N]/i) && ($c3 =~ /[-N]/i) && ($c4 =~ /[-N]/i)) { - $color = "#FFBBBB"; - $notSupp = $notSupp + 1; - } else { - $partSupp = $partSupp + 1; - $yearGames++; - } - my $company = $lines[2]; - my $url1 = ""; - my $url2 = ""; - if (defined($lines[3])) { - $url1 = $lines[3]; - if (defined($lines[4])) { - $url2 = $lines[4]; - } - } - $url1 = "" if $url1 eq "-"; - $newWindow = " target=\"_blank\""; - if ($color ne "") { - print OUT " \n"; - } else { - print OUT " \n"; - } - if ($url2 ne "") { - print OUT " $year\n"; - } else { - print OUT " $year\n"; - } - - if ($url1 ne "") { - print OUT " \n"; - } else { - print OUT "
$game
\n"; - } - printf OUT " %s%s%s%s%s\n", yesno($c1), yesno($c2), yesno($c3), yesno($c4), $ver; - my $compUrl = $compUrls{$company}; - if (defined($compUrl)) { - print OUT " \n" - } else { - print OUT "
$company
\n" - } - print OUT " \n"; - - } - - @lines = (); -} - -sub process { - my ($file) =@_; - open(IN, $file) or die "Unable to read file $file\n"; - - while (getline()) - { - if ($line =~ /\[.*\]/) { - if (@lines) { - # new game or command - flushGame(@lines); - } - } - push @lines, $line - } - flushGame($lines); - - close(IN); -} - - -readCompanies("developers.ini"); - -open(OUT, ">$OUT") or die "Unable to create file $OUT\n"; -styleSheet("style.css"); -tableSearch("filter.js"); -tableHeader(); - -process("table.ini"); - -tableFooter(); -close(OUT); - -flushYearStats(); -printf("\nFound %d supported games (%d fully supported) + %d unsupported\n", $partSupp + $fullSupp, $fullSupp, $notSupp); +#!/usr/bin/perl -w + +# TODO fixed table headers: jQuery version: http://codepen.io/jgx/pen/wiIGc + +$embed_css = 1; +$debug_js = 0; +$OUT = "table.html"; +$debug = 0; + +$JsLog = "opera.postError"; # Opera +#$JsLog = "console.log"; # IE + +#------------------------------------------------------------------------------ +# Line parser +#------------------------------------------------------------------------------ + +$unget_line = ""; +$inComment = 0; + +sub getline { + if ($unget_line ne "") { + local $ret = $unget_line; + $unget_line = ""; + return $ret; + } + + while ($line = ) + { + # remove CR/LF + $line =~ s/\r//; + $line =~ s/\n//; + # remove comments + if ($inComment) + { + if ($line =~ /.*\*\//) # close comment + { + $line =~ s/^.*\*\///; + $inComment = 0; # ... and continue parsing here + } + else + { + $line = "\\n"; # continue comment + return 1; + } + } + $line =~ s/\/\*.*\*\///g; # remove /* ... */ in a single line + if ($line =~ /\/\*/) + { + $inComment = 1; # open comment + $line =~ s/\/\*.*$//; # ... and continue parsing to remove extra spaces etc + } +# $line =~ s/\/\*.*$//; + $line =~ s/\s*\;.*//; # ; = comment + # remove traling and leading spaces + $line =~ s/^[\s\t]+//; + $line =~ s/[\s\t]+$//; + # remove cosmetic whitespaces +# $line =~ s/[\s\t]*([=*+\-,(){}#])[\s\t]*/$1/g; + $line =~ s/[\s\t]+/\ /g; + + next if $line eq ""; + return 1; + } + return 0; +} + + +sub ungetLine { + die "multiple ungetLine" if $unget_line ne ""; + $unget_line = $_[0]; +} + + +#------------------------------------------------------------------------------ +# Headers +#------------------------------------------------------------------------------ + +sub styleSheet { + my ($file) = $_[0]; + if (!$embed_css) { + print OUT "\n"; + } else { + print OUT < + + + +EOF +; + } +} + + +sub tableSearch { + print OUT < +EOF +; + my ($file) = $_[0]; + open(IN, $file) or die "Unable to read file $file\n"; + while (my $line = ) { + if ($debug_js) { + $line =~ s/DEBUG/$JsLog/g; + } else { + # remove debugging stuff + $line =~ s/DEBUG\(.*\);//g; + $line =~ s/(\s*\/\/.*)$//; +# $line =~ s/\s+/ /; + next if $line =~ /^\s*$/; + } + print OUT $line; + } + close(IN); + print OUT < + +
+
+
+ FILTER +
+

+

+EOF +; +} + + +sub tableHeader { + print OUT < + + Year +
Title
+ Mesh + Tex + Anim + Stat + Engine +
Developer
+ +EOF +; +} + + +sub tableFooter { + my $supported = $partSupp + $fullSupp; + print OUT <  + + + + + + +
 
+

Year: By clicking on the year for an entry, it will take you to the thread on the form that talks about this game.

+

Title: By clicking on the title of a game, it will take you to the Wikipedia information for that game. If the Wikipedia page does not exist it will take you to their website or other press release.

+

Developer: By clicking on Developer for an entry it will take you to the Wikipedia information for that developer. If the Wikipedia page does not exist it will take you to their website or other related information.

+

Other columns: Mesh: skeletal mesh, Tex: texture, Anim: skeletal animation, Stat: static mesh.

+
+ + + + Total games: ${supported} supported (${fullSupp} fully), ${notSupp} unsupported + + + +EOF +; +} + + +#------------------------------------------------------------------------------ +# Company urls +#------------------------------------------------------------------------------ + +%compUrls = (); + +sub readCompanies { + my ($file) = $_[0]; + open(IN, $file) or die "Unable to read file $file\n"; + + while (getline()) + { + my ($comp, $url) = $line =~ /(.+?) = (\S+)/x; + $compUrls{$comp} = $url; + } + + close(IN); +} + + +#------------------------------------------------------------------------------ +# Main code +#------------------------------------------------------------------------------ + +# parsing state +@lines = (); +$engine = ""; +$year = 0; + +# statistics +$fullSupp = 0; # number of fully supported games in total +$partSupp = 0; # number of partially supported games +$notSupp = 0; # number of unsupported games +$lastEngine = ""; +$yearGames = 0; # number of supported games in the current year + +sub yesno { + my ($v) = $_[0]; + return "YES" if ($v eq "Y"); + return "NO" if ($v eq "N"); + return $v; +} + + +sub flushYearStats { + if ($yearGames) { + printf(" %d %3d\n", $year, $yearGames); + $yearGames = 0; + } + if ($engine ne $lastEngine) { + $lastEngine = $engine; + printf("\n%s\n", $engine); + } +} + +sub flushGame { + my ($cmd, $val) = $lines[0] =~ /^ \[ (.+) \s* = \s* (.+) \] $/x; + if (defined($cmd) && defined($val)) { + # command + printf("COMMAND: [%s] = [%s]\n", $cmd, $val) if $debug; + if ($cmd =~ /engine/i) { + flushYearStats(); + $engine = $val; +print OUT <  + +
$val
+ +EOF +; + } elsif ($cmd =~ /year/i) { + flushYearStats(); + $year = $val; +print OUT <  + +
$year
+ +   +EOF +; + } else { + die "Unknown command: $cmd\n"; + } + } else { + # game + my ($game) = $lines[0] =~ /\[ \s* (.*) \s* \]/x; + my $caps = $lines[1]; + printf("GAME: [%s] [%s]\n", $game, $caps) if $debug; + my ($c1, $c2, $c3, $c4, $ver) = $caps =~ /^ (\S+) \s+ (\S+) \s+ (\S+) \s+ (\S+) \s+ (\S+) $/x; + my $color = ""; + my $note = ""; + if (defined($c1) && defined($ver)) { # everything is defined + # none + } else { + ($note, $ver) = $caps =~ /^ (\S+) \s+ (\S+) $/x; + if ($note =~ /unsupported/i) { + $c1 = $c2 = $c3 = $c4 = "N"; + #?? can add "all" etc + } else { + die "Unknown caps: \"$caps\" ($note)"; + } + } + if (($c1 =~ /[-Y]/i) && ($c2 =~ /[-Y]/i) && ($c3 =~ /[-Y]/i) && ($c4 =~ /[-Y]/i)) { + $color = "#BBFFBB"; + $fullSupp = $fullSupp + 1; + $yearGames++; + } elsif (($c1 =~ /[-N]/i) && ($c2 =~ /[-N]/i) && ($c3 =~ /[-N]/i) && ($c4 =~ /[-N]/i)) { + $color = "#FFBBBB"; + $notSupp = $notSupp + 1; + } else { + $partSupp = $partSupp + 1; + $yearGames++; + } + my $company = $lines[2]; + my $url1 = ""; + my $url2 = ""; + if (defined($lines[3])) { + $url1 = $lines[3]; + if (defined($lines[4])) { + $url2 = $lines[4]; + } + } + $url1 = "" if $url1 eq "-"; + $newWindow = " target=\"_blank\""; + if ($color ne "") { + print OUT " \n"; + } else { + print OUT " \n"; + } + if ($url2 ne "") { + print OUT " $year\n"; + } else { + print OUT " $year\n"; + } + + if ($url1 ne "") { + print OUT " \n"; + } else { + print OUT "
$game
\n"; + } + printf OUT " %s%s%s%s%s\n", yesno($c1), yesno($c2), yesno($c3), yesno($c4), $ver; + my $compUrl = $compUrls{$company}; + if (defined($compUrl)) { + print OUT " \n" + } else { + print OUT "
$company
\n" + } + print OUT " \n"; + + } + + @lines = (); +} + +sub process { + my ($file) =@_; + open(IN, $file) or die "Unable to read file $file\n"; + + while (getline()) + { + if ($line =~ /\[.*\]/) { + if (@lines) { + # new game or command + flushGame(@lines); + } + } + push @lines, $line + } + flushGame($lines); + + close(IN); +} + + +readCompanies("developers.ini"); + +open(OUT, ">$OUT") or die "Unable to create file $OUT\n"; +styleSheet("style.css"); +tableSearch("filter.js"); +tableHeader(); + +process("table.ini"); + +tableFooter(); +close(OUT); + +flushYearStats(); +printf("\nFound %d supported games (%d fully supported) + %d unsupported\n", $partSupp + $fullSupp, $fullSupp, $notSupp); diff --git a/Tools/PackageExtract/t.bat b/Tools/PackageExtract/t.bat index 9fe3a4c5..e9a7c503 100644 --- a/Tools/PackageExtract/t.bat +++ b/Tools/PackageExtract/t.bat @@ -1,10 +1,10 @@ -@echo off - -rm extract.exe -bash build.sh - -rem extract.exe "C:\!UE3-u\Core.u" -rem extract.exe "C:\!UE3-u\CH_Necris.upk" -rem extract.exe C:/!bioshock/Core.U -rem extract.exe "C:\GAMES\Unreal Anthology\UT2004\Animations\HumanMaleA.ukx" -extract.exe -list -filter=Texture2D D:\GAMES\UT3\UTGame\CookedPC\Characters\CH_All.upk +@echo off + +rm extract.exe +bash build.sh + +rem extract.exe "C:\!UE3-u\Core.u" +rem extract.exe "C:\!UE3-u\CH_Necris.upk" +rem extract.exe C:/!bioshock/Core.U +rem extract.exe "C:\GAMES\Unreal Anthology\UT2004\Animations\HumanMaleA.ukx" +extract.exe -list -filter=Texture2D D:\GAMES\UT3\UTGame\CookedPC\Characters\CH_All.upk diff --git a/Tools/PackageTool/t.bat b/Tools/PackageTool/t.bat index 7504abc9..208f9422 100644 --- a/Tools/PackageTool/t.bat +++ b/Tools/PackageTool/t.bat @@ -1,6 +1,6 @@ -@echo off - -rm pkgtool.exe -bash build.sh - -pkgtool.exe C:\GAMES\Unreal\UT2004 +@echo off + +rm pkgtool.exe +bash build.sh + +pkgtool.exe C:\GAMES\Unreal\UT2004 diff --git a/Tools/PackageUnpack/t.bat b/Tools/PackageUnpack/t.bat index 15473f35..23e7846a 100644 --- a/Tools/PackageUnpack/t.bat +++ b/Tools/PackageUnpack/t.bat @@ -1,11 +1,11 @@ -@echo off - -rm decompress.exe -bash build.sh - -set decfile=C:\!umodel-data\Borderlands\W_Startup_INT.upk -::set C:\!umodel-data\Bioshock\Core.U -::set C:\!umodel-data\Lineage2\animations\LineageDecos.ukx - -if not "%1"=="" set decfile="%1" -decompress %decfile% +@echo off + +rm decompress.exe +bash build.sh + +set decfile=C:\!umodel-data\Borderlands\W_Startup_INT.upk +::set C:\!umodel-data\Bioshock\Core.U +::set C:\!umodel-data\Lineage2\animations\LineageDecos.ukx + +if not "%1"=="" set decfile="%1" +decompress %decfile% diff --git a/Tools/TypeInfo/t.bat b/Tools/TypeInfo/t.bat index 134e72e6..12984c33 100644 --- a/Tools/TypeInfo/t.bat +++ b/Tools/TypeInfo/t.bat @@ -1,15 +1,15 @@ -@echo off - -rm typeinfo.exe -bash build.sh - -::typeinfo.exe "C:\GAMES\Unreal Anthology\UT2004\System\Core.u" -::typeinfo.exe "C:\GAMES\Unreal Anthology\UT2004\System\Engine.u" -::typeinfo.exe C:\!umodel-data\UnrealChampionship2\System\Core.u -::typeinfo.exe C:\!umodel-data\GearsOfWar2_X360\Core.xxx -::typeinfo.exe "C:\GAMES\UT3\UTGame\CookedPC\Core.u" -::typeinfo.exe "C:\GAMES\UT3\UTGame\CookedPC\Engine.u" -::typeinfo.exe ..\..\data\3\Batman2\Engine.upk -::typeinfo.exe -text ..\..\data\3\Alice\AliceGame.u -::typeinfo.exe -lzo ..\..\data\3\Bioshock3\XCore.xxx -typeinfo ..\..\data\3\Thief\Core.u +@echo off + +rm typeinfo.exe +bash build.sh + +::typeinfo.exe "C:\GAMES\Unreal Anthology\UT2004\System\Core.u" +::typeinfo.exe "C:\GAMES\Unreal Anthology\UT2004\System\Engine.u" +::typeinfo.exe C:\!umodel-data\UnrealChampionship2\System\Core.u +::typeinfo.exe C:\!umodel-data\GearsOfWar2_X360\Core.xxx +::typeinfo.exe "C:\GAMES\UT3\UTGame\CookedPC\Core.u" +::typeinfo.exe "C:\GAMES\UT3\UTGame\CookedPC\Engine.u" +::typeinfo.exe ..\..\data\3\Batman2\Engine.upk +::typeinfo.exe -text ..\..\data\3\Alice\AliceGame.u +::typeinfo.exe -lzo ..\..\data\3\Bioshock3\XCore.xxx +typeinfo ..\..\data\3\Thief\Core.u diff --git a/Tools/UmdExtract/t.bat b/Tools/UmdExtract/t.bat index c032cf52..4ccf897a 100644 --- a/Tools/UmdExtract/t.bat +++ b/Tools/UmdExtract/t.bat @@ -1,6 +1,6 @@ -@echo off - -rm unumd.exe -bash build.sh - -unumd.exe -path="E:\Projects\UModel\data\.possible\Splinter Cell Conviction" +@echo off + +rm unumd.exe +bash build.sh + +unumd.exe -path="E:\Projects\UModel\data\.possible\Splinter Cell Conviction" diff --git a/Tools/unpack_obb.pl b/Tools/unpack_obb.pl index ab25f122..0710cf3c 100644 --- a/Tools/unpack_obb.pl +++ b/Tools/unpack_obb.pl @@ -1,100 +1,100 @@ -#!/usr/bin/perl -w - -#------------------------------------------------------------------------------ -# Unpacker for Unreal engine 3 Android OBB archives -#------------------------------------------------------------------------------ - - -sub ReadInt -{ - my $data; - sysread(IN, $data, 4) or die "Problem reading file\n"; - return unpack("l", $data); -} - -sub ReadInt64 -{ - my $i1 = ReadInt(); - my $i2 = ReadInt(); - die "Int64 with non-zero HIDWORD" if $i2 != 0; - return $i1; -} - -sub ReadString -{ - my $data; - my $len = ReadInt(); - sysread(IN, $data, $len); - return $data; -} - -# recursive mkdir -sub MakeDir -{ - my $fulldir = $_[0]; - my $dir = '.'; - for my $d (split('/', $fulldir)) - { - $dir .= '/' . $d; - mkdir($dir, '0777'); - } -} - - -# open archive -$filename = $ARGV[0]; -open(IN, $filename) or die "Unable to open file \"$filename\"\n"; -binmode(IN); - -# file ID -sysread(IN, $id, 13); -die "Wrong file format\n" if $id ne "UE3AndroidOBB"; - -# read archive directory -$count = ReadInt(); - -@filenames = (); -@positions = (); -@lens = (); - -for ($i = 0; $i < $count; $i++) -{ - $filename = ReadString(); - $position = ReadInt64(); - $len = ReadInt(); - printf("%08X %8X %20s\n", $position, $len, $filename); - push @filenames, $filename; - push @positions, $position; - push @lens, $len; -} - -printf("%d files total\n", $count); - - -# extract files -for ($i = 0; $i < $count; $i++) -{ - sysseek(IN, $positions[$i], 0); - sysread(IN, $data, $lens[$i]); - my $filename = $filenames[$i]; - $filename =~ s/\\/\//g; # replace slashes - $filename =~ s/^\.\.\///; # remove "../" at beginning - - # create a directory for file - if ($filename =~ /.*\/.*/) - { - # has slashes inside, make a directory - my ($dirname) = $filename =~ /(.*)\/[^\/]+/; - MakeDir($dirname); - } - - - # write file - open(F, ">$filename") or die "Unable to create file $filename\n"; - binmode(F); - syswrite(F, $data); - close(F); -} - -# close archive -close(IN); +#!/usr/bin/perl -w + +#------------------------------------------------------------------------------ +# Unpacker for Unreal engine 3 Android OBB archives +#------------------------------------------------------------------------------ + + +sub ReadInt +{ + my $data; + sysread(IN, $data, 4) or die "Problem reading file\n"; + return unpack("l", $data); +} + +sub ReadInt64 +{ + my $i1 = ReadInt(); + my $i2 = ReadInt(); + die "Int64 with non-zero HIDWORD" if $i2 != 0; + return $i1; +} + +sub ReadString +{ + my $data; + my $len = ReadInt(); + sysread(IN, $data, $len); + return $data; +} + +# recursive mkdir +sub MakeDir +{ + my $fulldir = $_[0]; + my $dir = '.'; + for my $d (split('/', $fulldir)) + { + $dir .= '/' . $d; + mkdir($dir, '0777'); + } +} + + +# open archive +$filename = $ARGV[0]; +open(IN, $filename) or die "Unable to open file \"$filename\"\n"; +binmode(IN); + +# file ID +sysread(IN, $id, 13); +die "Wrong file format\n" if $id ne "UE3AndroidOBB"; + +# read archive directory +$count = ReadInt(); + +@filenames = (); +@positions = (); +@lens = (); + +for ($i = 0; $i < $count; $i++) +{ + $filename = ReadString(); + $position = ReadInt64(); + $len = ReadInt(); + printf("%08X %8X %20s\n", $position, $len, $filename); + push @filenames, $filename; + push @positions, $position; + push @lens, $len; +} + +printf("%d files total\n", $count); + + +# extract files +for ($i = 0; $i < $count; $i++) +{ + sysseek(IN, $positions[$i], 0); + sysread(IN, $data, $lens[$i]); + my $filename = $filenames[$i]; + $filename =~ s/\\/\//g; # replace slashes + $filename =~ s/^\.\.\///; # remove "../" at beginning + + # create a directory for file + if ($filename =~ /.*\/.*/) + { + # has slashes inside, make a directory + my ($dirname) = $filename =~ /(.*)\/[^\/]+/; + MakeDir($dirname); + } + + + # write file + open(F, ">$filename") or die "Unable to create file $filename\n"; + binmode(F); + syswrite(F, $data); + close(F); +} + +# close archive +close(IN); diff --git a/Unreal/Shaders/make.pl b/Unreal/Shaders/make.pl index 7bf4202a..b808df34 100644 --- a/Unreal/Shaders/make.pl +++ b/Unreal/Shaders/make.pl @@ -1,134 +1,137 @@ -#!/usr/bin/perl -w - -#?? take "OUT" from commandline + take directory from commandline -$EXTS = "vert|frag|ush"; -$OUT = "../Shaders.h"; - -$inComment = 0; - -sub getline { - while ($line = ) - { - # remove CR/LF - $line =~ s/\r//; - $line =~ s/\n//; - # remove comments - if ($inComment) - { - if ($line =~ /.*\*\//) # close comment - { - $line =~ s/^.*\*\///; - $inComment = 0; # ... and continue parsing here - } - else - { - $line = "\\n"; # continue comment - return 1; - } - } - $line =~ s/\/\*.*\*\///g; # remove /* ... */ in a single line - if ($line =~ /\/\*/) - { - $inComment = 1; # open comment - $line =~ s/\/\*.*$//; # ... and continue parsing to remove extra spaces etc - } -# $line =~ s/\/\*.*$//; - $line =~ s/\s*\/\/.*//; - # remove traling and leading spaces - $line =~ s/^[\s\t]+//; - $line =~ s/[\s\t]+$//; - # remove cosmetic whitespaces - $line =~ s/[\s\t]*([=*+\-,(){}#])[\s\t]*/$1/g; - $line =~ s/[\s\t]+/\ /g; - # replace escape chars - $line =~ s/\t/\\t/g; - $line =~ s/\"/\\\"/g; - # add "\n" - $line .= "\\n"; - return 1; - } - return 0; -} - - -sub process { - my ($file) =@_; - open(IN, $file) or die "Unable to read file $file\n"; - my $name = $file; - $name =~ s/\./_/; - print(OUT "\n// $file\nstatic const char ${name}[] = \"${file}\\x00\""); - my $accum = ""; - while (getline()) - { - if (length($accum) + length($line) < 80) - { - $accum .= $line; - next; - } - print(OUT "\n\"$accum\""); - $accum = $line; - } - print(OUT "\n\"$accum\"") if ($accum ne ""); - print(OUT ";\n\n"); - close(IN); -} - -# return file modification time -sub FileTime { - my @s = stat($_[0]) or die "File \"${_[0]}\" was not found\n"; - return $s[9]; -} - - - -opendir(DIR, "."); -@filelist = readdir(DIR); -closedir(DIR); - -$ThisExec = $0; # $PROGRAM_NAME does not works -$ExecTime = FileTime($ThisExec); - -my $rebuild = 0; -if (!-f $OUT) { - print STDERR "$OUT does not exists, creating ...\n"; - $rebuild = 1; -} else { - $OutTime = FileTime($OUT); - if ($ExecTime > $OutTime) { - print STDERR "Updated this script, rebuilding $OUT ...\n"; - $rebuild = 1; - } -} - - -for $f (@filelist) -{ - if ($f =~ /.*\.($EXTS)$/) { - my $ShaderTime = FileTime($f); - if ($ShaderTime > $OutTime) { - print STDERR "$f is updated, rebuilding $OUT ...\n"; - $rebuild = 1; - } - } -} - -if ($rebuild == 0) { -# print STDERR "$OUT is up to date.\n"; - exit; -} - -open(OUT, ">$OUT") or die "Unable to create file $OUT\n"; -print OUT <) + { + # remove CR/LF + $line =~ s/\r//; + $line =~ s/\n//; + # remove comments + if ($inComment) + { + if ($line =~ /.*\*\//) # close comment + { + $line =~ s/^.*\*\///; + $inComment = 0; # ... and continue parsing here + } + else + { + $line = "\\n"; # continue comment + return 1; + } + } + $line =~ s/\/\*.*\*\///g; # remove /* ... */ in a single line + if ($line =~ /\/\*/) + { + $inComment = 1; # open comment + $line =~ s/\/\*.*$//; # ... and continue parsing to remove extra spaces etc + } +# $line =~ s/\/\*.*$//; + $line =~ s/\s*\/\/.*//; + # remove traling and leading spaces + $line =~ s/^[\s\t]+//; + $line =~ s/[\s\t]+$//; + # remove cosmetic whitespaces + $line =~ s/[\s\t]*([=*+\-,(){}#])[\s\t]*/$1/g; + $line =~ s/[\s\t]+/\ /g; + # replace escape chars + $line =~ s/\t/\\t/g; + $line =~ s/\"/\\\"/g; + # add "\n" + $line .= "\\n"; + return 1; + } + return 0; +} + + +sub process { + my ($file) =@_; + open(IN, $file) or die "Unable to read file $file\n"; + my $name = $file; + $name =~ s/\./_/; + print(OUT "\n// $file\nstatic const char ${name}[] = \"${file}\\x00\""); + my $accum = ""; + while (getline()) + { + if (length($accum) + length($line) < 80) + { + $accum .= $line; + next; + } + print(OUT "\n\"$accum\""); + $accum = $line; + } + print(OUT "\n\"$accum\"") if ($accum ne ""); + print(OUT ";\n\n"); + close(IN); +} + +# return file modification time +sub FileTime { + my @s = stat($_[0]) or die "File \"${_[0]}\" was not found\n"; + return $s[9]; +} + + + +opendir(DIR, "."); +@filelist = readdir(DIR); +closedir(DIR); + +$ThisExec = $0; # $PROGRAM_NAME does not works +$ExecTime = FileTime($ThisExec); + +my $rebuild = 0; +if (!-f $OUT) { + print STDERR "$OUT does not exists, creating ...\n"; + $rebuild = 1; +} else { + $OutTime = FileTime($OUT); + if ($ExecTime > $OutTime) { + print STDERR "Updated this script, rebuilding $OUT ...\n"; + $rebuild = 1; + } +} + + +if ($rebuild == 0) { + # verify individual file times + for $f (@filelist) + { + if ($f =~ /.*\.($EXTS)$/) { + my $ShaderTime = FileTime($f); + if ($ShaderTime > $OutTime) { + print STDERR "$f is updated, rebuilding $OUT ...\n"; + $rebuild = 1; + } + } + } +} + +if ($rebuild == 0) { +# print STDERR "$OUT is up to date.\n"; + exit; +} + +open(OUT, ">$OUT") or die "Unable to create file $OUT\n"; +print OUT <