wow_dbc 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/ext/wow_dbc/wow_dbc.c +34 -0
- data/lib/wow_dbc/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfaf18639315c2569395c416447ee1eb2d647497de512b0e717585b02678264d
|
4
|
+
data.tar.gz: 4d51845c28b8724a3d4ff3f672b499f727f5ad65bd3e3c9d116c4962d239691f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72da2052394e199fc40bd3a1aae3b54bbe1eb008c3431ce512dfd560230d2b42d7169e6ec68343efe5c7aad9d36a343205e18539a08e26b8b2df850e6c1e6146
|
7
|
+
data.tar.gz: a5bb33a31ca06b09775309fcd3f56ecc509f4ce08475bcd0df40a7d9aa9d0075e1194fbda498db3143cb7ae61a3ac5c7170608f84de2278ebb9f42b26abd725d
|
data/README.md
CHANGED
@@ -78,9 +78,12 @@ puts "Newly created item: #{new_item}"
|
|
78
78
|
# Delete an item (be careful with this!)
|
79
79
|
# dbc.delete_record(new_item_index)
|
80
80
|
|
81
|
-
# Write changes back to the file
|
81
|
+
# Write changes back to the same file(update)
|
82
82
|
dbc.write
|
83
83
|
|
84
|
+
# Write to a new file
|
85
|
+
dbc.write_to('path/to/your/NewItem.dbc')
|
86
|
+
|
84
87
|
# Reading header information
|
85
88
|
header = dbc.header
|
86
89
|
puts "Total items: #{header[:record_count]}"
|
@@ -89,7 +92,7 @@ puts "Fields per item: #{header[:field_count]}"
|
|
89
92
|
# Finding all two-handed weapons
|
90
93
|
two_handed_weapons = dbc.find_by(:inventory_type, 17) # 17 represents Two-Hand weapons
|
91
94
|
|
92
|
-
puts
|
95
|
+
puts 'Two-handed weapons:'
|
93
96
|
two_handed_weapons.each do |item|
|
94
97
|
puts "Item ID: #{item[:id]}, Class: #{item[:class]}, Subclass: #{item[:subclass]}, Display ID: #{item[:displayid]}"
|
95
98
|
end
|
data/ext/wow_dbc/wow_dbc.c
CHANGED
@@ -344,6 +344,39 @@ static VALUE dbc_find_by(VALUE self, VALUE field, VALUE value) {
|
|
344
344
|
return result;
|
345
345
|
}
|
346
346
|
|
347
|
+
static VALUE dbc_write_to(VALUE self, VALUE new_filepath) {
|
348
|
+
DBCFile *dbc;
|
349
|
+
TypedData_Get_Struct(self, DBCFile, &dbc_data_type, dbc);
|
350
|
+
|
351
|
+
Check_Type(new_filepath, T_STRING);
|
352
|
+
const char *path = StringValueCStr(new_filepath);
|
353
|
+
|
354
|
+
FILE *file = fopen(path, "wb");
|
355
|
+
if (!file) {
|
356
|
+
rb_raise(rb_eIOError, "Could not open file for writing: %s", path);
|
357
|
+
}
|
358
|
+
|
359
|
+
if (fwrite(&dbc->header, sizeof(DBCHeader), 1, file) != 1) {
|
360
|
+
fclose(file);
|
361
|
+
rb_raise(rb_eIOError, "Failed to write DBC header");
|
362
|
+
}
|
363
|
+
|
364
|
+
for (uint32_t i = 0; i < dbc->header.record_count; i++) {
|
365
|
+
if (fwrite(dbc->records[i], sizeof(uint32_t), dbc->header.field_count, file) != dbc->header.field_count) {
|
366
|
+
fclose(file);
|
367
|
+
rb_raise(rb_eIOError, "Failed to write DBC record");
|
368
|
+
}
|
369
|
+
}
|
370
|
+
|
371
|
+
if (fwrite(dbc->string_block, 1, dbc->header.string_block_size, file) != dbc->header.string_block_size) {
|
372
|
+
fclose(file);
|
373
|
+
rb_raise(rb_eIOError, "Failed to write DBC string block");
|
374
|
+
}
|
375
|
+
|
376
|
+
fclose(file);
|
377
|
+
return self;
|
378
|
+
}
|
379
|
+
|
347
380
|
void Init_wow_dbc(void) {
|
348
381
|
rb_mWowDBC = rb_define_module("WowDBC");
|
349
382
|
rb_cDBCFile = rb_define_class_under(rb_mWowDBC, "DBCFile", rb_cObject);
|
@@ -351,6 +384,7 @@ void Init_wow_dbc(void) {
|
|
351
384
|
rb_define_method(rb_cDBCFile, "initialize", dbc_initialize, 2);
|
352
385
|
rb_define_method(rb_cDBCFile, "read", dbc_read, 0);
|
353
386
|
rb_define_method(rb_cDBCFile, "write", dbc_write, 0);
|
387
|
+
rb_define_method(rb_cDBCFile, "write_to", dbc_write_to, 1);
|
354
388
|
rb_define_method(rb_cDBCFile, "create_record", dbc_create_record, 0);
|
355
389
|
rb_define_method(rb_cDBCFile, "create_record_with_values", dbc_create_record_with_values, 1);
|
356
390
|
rb_define_method(rb_cDBCFile, "update_record", dbc_update_record, 3);
|
data/lib/wow_dbc/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wow_dbc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sebi
|
@@ -9,7 +9,21 @@ autorequire:
|
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2024-09-22 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake-compiler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.7
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.2.7
|
13
27
|
description: WowDBC provides a Ruby interface to read, write, and manipulate World
|
14
28
|
of Warcraft DBC (Database Client) files. It offers efficient CRUD operations and
|
15
29
|
seamless integration with Ruby projects, making it ideal for WoW addon development,
|