Permalink
Browse files

Support for avatar_gen_taisho_mp.officer.unit_variant

  • Loading branch information...
1 parent 8e0580f commit eaf9dad3e91280317abfc870e508d147ef4a2a93 @taw committed Mar 28, 2011
Showing with 20 additions and 4 deletions.
  1. +14 −3 unit_variant/uv_pack
  2. +6 −1 unit_variant/uv_unpack
View
@@ -17,21 +17,32 @@ class UnitVariant
@data = eval(txt)
end
def version
- @data[0]
+ @version ||= @data[0]
+ end
+ def extra
+ if version == 2
+ @data[1]
+ else
+ @data
+ end
end
def header_size
version == 0 ? 20 : 24
end
def categories
- @categories ||= @data[1..-1]
+ @categories ||= if version == 2
+ @data[2..-1]
+ else
+ @data[1..-1]
+ end
end
def divider
header_size + categories.size * (512 + 4*4)
end
def header
out = "VRNT"
out << [version, categories.size, header_size, divider].pack("V*")
- out << [1].pack("V") if version == 2
+ out << [extra].pack("V") if version == 2
out
end
def s256(str)
View
@@ -64,7 +64,11 @@ class UnitVariant
fail "Wrong header size" unless get_u == (@version == 0 ? 20 : 24)
divider = get_u
- fail "Wrong entry count for version 2" unless get_u == 1 if @version == 2
+ if @version == 2
+ @extra = get_u
+ else
+ @extra = nil
+ end
equipment = parse_equipment(divider)
@@ -89,6 +93,7 @@ class UnitVariant
version, categories = parse
out = "[\n"
out << " #{version},\n"
+ out << " #{@extra},\n" if @extra
categories.each do |cat_num, cat_name, *equipment|
line = " [#{cat_num}, #{cat_name.inspect}"
lines_eq = equipment.map{|eq| " #{eq.inspect}" }

0 comments on commit eaf9dad

Please sign in to comment.