nwn-lib 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/Rakefile +1 -1
- data/lib/nwn/gff.rb +34 -3
- metadata +2 -2
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ include FileUtils
|
|
9
9
|
# Configuration
|
10
10
|
##############################################################################
|
11
11
|
NAME = "nwn-lib"
|
12
|
-
VERS = "0.3.
|
12
|
+
VERS = "0.3.2"
|
13
13
|
CLEAN.include ["**/.*.sw?", "pkg", ".config", "rdoc", "coverage"]
|
14
14
|
RDOC_OPTS = ["--quiet", "--line-numbers", "--inline-source", '--title', \
|
15
15
|
'nwn-lib: a ruby library for accessing NWN resource files', \
|
data/lib/nwn/gff.rb
CHANGED
@@ -385,6 +385,37 @@ class NWN::Gff::Struct
|
|
385
385
|
def method_missing meth, *a, &block
|
386
386
|
@hash.method(meth).call(*a, &block)
|
387
387
|
end
|
388
|
+
|
389
|
+
# Sets a NWN::Gff::Element on this struct.
|
390
|
+
# Overwrites existing labels.
|
391
|
+
|
392
|
+
# args can be the following:
|
393
|
+
# * A single NWN::Gff::Element
|
394
|
+
# * A single NWN::Gff::Struct, in which case it will be merged into this one
|
395
|
+
# * label, type
|
396
|
+
# * label, type, value
|
397
|
+
def set *args
|
398
|
+
if args.size == 1
|
399
|
+
arg = args[0]
|
400
|
+
case arg
|
401
|
+
when NWN::Gff::Struct
|
402
|
+
@hash.merge!(addme)
|
403
|
+
|
404
|
+
when NWN::Gff::Element
|
405
|
+
@hash[arg.label] = arg
|
406
|
+
else
|
407
|
+
raise ArgumentError, "Cannot determine how to handle #{arg.class.to_s}."
|
408
|
+
end
|
409
|
+
|
410
|
+
elsif args.size == 2 || args.size == 3
|
411
|
+
element = NWN::Gff::Element.new(*args)
|
412
|
+
|
413
|
+
@hash[element.label] = element
|
414
|
+
else
|
415
|
+
raise ArgumentError, "Cannot determine how to handle #{args.inspect}."
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
388
419
|
end
|
389
420
|
|
390
421
|
# A CExoLocString is a localised CExoString.
|
@@ -518,13 +549,13 @@ class NWN::Gff::Reader
|
|
518
549
|
raise GffError, "Label index #{label_index} outside of label array" if
|
519
550
|
label_index > @labels.size
|
520
551
|
|
521
|
-
|
522
|
-
ComplexTypes.index(type) && data_or_offset > @field_data.size
|
552
|
+
label = @labels[label_index]
|
523
553
|
|
524
554
|
raise GffError, "Unknown field type #{type}." unless Types[type]
|
525
555
|
type = Types[type]
|
526
556
|
|
527
|
-
label
|
557
|
+
raise GffError, "Field '#{label}' (type: #{type} )data offset #{data_or_offset} outside of field data block (#{@field_data.size})" if
|
558
|
+
ComplexTypes.index(type) && data_or_offset > @field_data.size
|
528
559
|
|
529
560
|
value = case type
|
530
561
|
when :byte, :char
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: nwn-lib
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.3.
|
7
|
-
date: 2008-07-
|
6
|
+
version: 0.3.2
|
7
|
+
date: 2008-07-10 00:00:00 +02:00
|
8
8
|
summary: a ruby library for accessing Neverwinter Nights resource files
|
9
9
|
require_paths:
|
10
10
|
- lib
|