Class: WolfRpg::Database::Type
- Inherits:
-
Object
- Object
- WolfRpg::Database::Type
- Defined in:
- lib/wolfrpg/database.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#description ⇒ Object
Returns the value of attribute description.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#name ⇒ Object
Returns the value of attribute name.
-
#unknown1 ⇒ Object
Returns the value of attribute unknown1.
Instance Method Summary collapse
- #dump_dat(coder) ⇒ Object
- #dump_project(coder) ⇒ Object
-
#initialize(coder) ⇒ Type
constructor
Initialize from project file IO.
-
#read_dat(coder) ⇒ Object
Read the rest of the data from the dat file.
Constructor Details
#initialize(coder) ⇒ Type
Initialize from project file IO
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/wolfrpg/database.rb', line 79 def initialize(coder) @name = coder.read_string @fields = Array.new(coder.read_int) @fields.each_index do |i| @fields[i] = Field.new(coder) end @data = Array.new(coder.read_int) @data.each_index do |i| @data[i] = Data.new(coder) end @description = coder.read_string # Add misc data to fields. It's separated for some reason. # This appears to always be 0x64, but save it anyway @field_type_list_size = coder.read_int index = 0 while index < @fields.size @fields[index].type = coder.read_byte index += 1 end coder.skip(@field_type_list_size - index) coder.read_int.times do |i| @fields[i].unknown1 = coder.read_string end coder.read_int.times do |i| @fields[i].string_args = Array.new(coder.read_int) @fields[i].string_args.each_index do |j| @fields[i].string_args[j] = coder.read_string end end coder.read_int.times do |i| @fields[i].args = Array.new(coder.read_int) @fields[i].args.each_index do |j| @fields[i].args[j] = coder.read_int end end coder.read_int.times do |i| @fields[i].default_value = coder.read_int end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
74 75 76 |
# File 'lib/wolfrpg/database.rb', line 74 def data @data end |
#description ⇒ Object
Returns the value of attribute description.
75 76 77 |
# File 'lib/wolfrpg/database.rb', line 75 def description @description end |
#fields ⇒ Object
Returns the value of attribute fields.
73 74 75 |
# File 'lib/wolfrpg/database.rb', line 73 def fields @fields end |
#name ⇒ Object
Returns the value of attribute name.
72 73 74 |
# File 'lib/wolfrpg/database.rb', line 72 def name @name end |
#unknown1 ⇒ Object
Returns the value of attribute unknown1.
76 77 78 |
# File 'lib/wolfrpg/database.rb', line 76 def unknown1 @unknown1 end |
Instance Method Details
#dump_dat(coder) ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/wolfrpg/database.rb', line 185 def dump_dat(coder) coder.write(DAT_TYPE_SEPARATOR) coder.write_int(@unknown1) coder.write_int(@fields.size) @fields.each do |field| field.dump_dat(coder) end coder.write_int(@data.size) @data.each do |datum| datum.dump_dat(coder) end end |
#dump_project(coder) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/wolfrpg/database.rb', line 122 def dump_project(coder) coder.write_string(@name) coder.write_int(@fields.size) @fields.each do |field| field.dump_project(coder) end coder.write_int(@data.size) @data.each do |datum| datum.dump_project(coder) end coder.write_string(@description) # Dump misc field data coder.write_int(@field_type_list_size) index = 0 while index < @fields.size coder.write_byte(@fields[index].type) index += 1 end while index < @field_type_list_size coder.write_byte(0) index += 1 end coder.write_int(@fields.size) @fields.each do |field| coder.write_string(field.unknown1) end coder.write_int(@fields.size) @fields.each do |field| coder.write_int(field.string_args.size) field.string_args.each do |arg| coder.write_string(arg) end end coder.write_int(@fields.size) @fields.each do |field| coder.write_int(field.args.size) field.args.each do |arg| coder.write_int(arg) end end coder.write_int(@fields.size) @fields.each do |field| coder.write_int(field.default_value) end end |
#read_dat(coder) ⇒ Object
Read the rest of the data from the dat file
170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/wolfrpg/database.rb', line 170 def read_dat(coder) coder.verify(DAT_TYPE_SEPARATOR) @unknown1 = coder.read_int fields_size = coder.read_int @fields = @fields[0, fields_size] if fields_size != @fields.size @fields.each do |field| field.read_dat(coder) end data_size = coder.read_int @data = @data[0, data_size] if data_size != @data.size @data.each do |datum| datum.read_dat(coder, @fields) end end |