Class: WolfRpg::GameDat
- Inherits:
-
Object
- Object
- WolfRpg::GameDat
- Defined in:
- lib/wolfrpg/game_dat.rb
Constant Summary collapse
- SEED_INDICES =
[0, 8, 6]
Instance Attribute Summary collapse
-
#default_pc_graphic ⇒ Object
Returns the value of attribute default_pc_graphic.
-
#file_version ⇒ Object
only a guess.
-
#font ⇒ Object
Returns the value of attribute font.
-
#subfonts ⇒ Object
Returns the value of attribute subfonts.
-
#title ⇒ Object
Returns the value of attribute title.
-
#unknown1 ⇒ Object
Returns the value of attribute unknown1.
-
#unknown2 ⇒ Object
Returns the value of attribute unknown2.
-
#unknown3 ⇒ Object
Returns the value of attribute unknown3.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #dump(filename) ⇒ Object
- #encrypted? ⇒ Boolean
-
#initialize(filename) ⇒ GameDat
constructor
XSEED_INDICES = [3, 4, 5].
Constructor Details
#initialize(filename) ⇒ GameDat
XSEED_INDICES = [3, 4, 5]
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/wolfrpg/game_dat.rb', line 22 def initialize(filename) FileCoder.open(filename, :read, SEED_INDICES) do |coder| if coder.encrypted? @crypt_header = coder.crypt_header else coder.verify(MAGIC_NUMBER) end #TODO what is most of the junk in this file? @unknown1 = coder.read_byte_array @file_version = coder.read_int @title = coder.read_string if (magic_string = coder.read_string) != MAGIC_STRING raise "magic string invalid (got #{magic_string})" end @unknown2 = coder.read_byte_array @font = coder.read_string @subfonts = Array.new(3) @subfonts.each_index do |i| @subfonts[i] = coder.read_string end @default_pc_graphic = coder.read_string if @file_version >= 9 @version = coder.read_string else @version = '' end # This is the size of the file minus one. # We don't need it, so discard it. coder.skip(4) # We don't care about the rest of this file for translation # purposes. # Someday we will know what the hell is stored in here... But not today. @unknown3 = coder.read end end |
Instance Attribute Details
#default_pc_graphic ⇒ Object
Returns the value of attribute default_pc_graphic.
11 12 13 |
# File 'lib/wolfrpg/game_dat.rb', line 11 def default_pc_graphic @default_pc_graphic end |
#file_version ⇒ Object
only a guess
6 7 8 |
# File 'lib/wolfrpg/game_dat.rb', line 6 def file_version @file_version end |
#font ⇒ Object
Returns the value of attribute font.
9 10 11 |
# File 'lib/wolfrpg/game_dat.rb', line 9 def font @font end |
#subfonts ⇒ Object
Returns the value of attribute subfonts.
10 11 12 |
# File 'lib/wolfrpg/game_dat.rb', line 10 def subfonts @subfonts end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'lib/wolfrpg/game_dat.rb', line 7 def title @title end |
#unknown1 ⇒ Object
Returns the value of attribute unknown1.
5 6 7 |
# File 'lib/wolfrpg/game_dat.rb', line 5 def unknown1 @unknown1 end |
#unknown2 ⇒ Object
Returns the value of attribute unknown2.
8 9 10 |
# File 'lib/wolfrpg/game_dat.rb', line 8 def unknown2 @unknown2 end |
#unknown3 ⇒ Object
Returns the value of attribute unknown3.
13 14 15 |
# File 'lib/wolfrpg/game_dat.rb', line 13 def unknown3 @unknown3 end |
#version ⇒ Object
Returns the value of attribute version.
12 13 14 |
# File 'lib/wolfrpg/game_dat.rb', line 12 def version @version end |
Instance Method Details
#dump(filename) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/wolfrpg/game_dat.rb', line 63 def dump(filename) FileCoder.open(filename, :write, SEED_INDICES, @crypt_header) do |coder| coder.write(MAGIC_NUMBER) unless encrypted? coder.write_byte_array(@unknown1) coder.write_int(@file_version) coder.write_string(@title) coder.write_string(MAGIC_STRING) coder.write_byte_array(@unknown2) coder.write_string(@font) @subfonts.each do |subfont| coder.write_string(subfont) end coder.write_string(@default_pc_graphic) coder.write_string(@version) if @file_version >= 9 coder.write_int(coder.tell + 4 + @unknown3.bytesize - 1) coder.write(@unknown3) end end |
#encrypted? ⇒ Boolean
15 16 17 |
# File 'lib/wolfrpg/game_dat.rb', line 15 def encrypted? @crypt_header != nil end |