summaryrefslogtreecommitdiff
path: root/extractor
diff options
context:
space:
mode:
Diffstat (limited to 'extractor')
-rw-r--r--extractor/extractor_interface.gd26
-rw-r--r--extractor/gnd_format.gd6
-rw-r--r--extractor/grf.gd39
-rw-r--r--extractor/rsm_format.gd12
-rw-r--r--extractor/rsw_format.gd20
5 files changed, 59 insertions, 44 deletions
diff --git a/extractor/extractor_interface.gd b/extractor/extractor_interface.gd
index e987ed3..4d74a20 100644
--- a/extractor/extractor_interface.gd
+++ b/extractor/extractor_interface.gd
@@ -2,9 +2,11 @@ extends Control
func _ready() -> void:
+ pass
+
var grf = GRF.open("res://client_data/data.grf")
- grf.extract()#"user://client_data")
- #grf.convert()#"user://client_data")
+ #grf.extract("res://client_data")
+ grf.convert("res://client_data")
#Sprite.from_bytes(FileAccess.get_file_as_bytes("res://client_data/data/sprite/cursors.spr"))
#ActionFormat.from_bytes(
@@ -22,12 +24,12 @@ func _ready() -> void:
#FileAccess.get_file_as_bytes("res://client_data/data/int_land02.gnd")
#)
#)
- var rsw = RSWFormat.from_bytes(
- ByteStream.from_bytes(
- #FileAccess.get_file_as_bytes("res://client_data/data/int_land02.rsw")
- FileAccess.get_file_as_bytes("res://client_data/data/pay_dun00.rsw")
- )
- )
+ #var rsw = RSWFormat.from_bytes(
+ #ByteStream.from_bytes(
+ ##FileAccess.get_file_as_bytes("res://client_data/data/int_land02.rsw")
+ #FileAccess.get_file_as_bytes("res://client_data/data/pay_dun00.rsw")
+ #)
+ #)
#RSMFormat.from_bytes(
#ByteStream.from_bytes(
##FileAccess.get_file_as_bytes("res://client_data/data/model/prontera/chair_01.rsm")
@@ -37,7 +39,7 @@ func _ready() -> void:
#)
#)
- var scene_root := rsw.convert("pay_dun00", "res://client_data")
- var scene := PackedScene.new()
- scene.pack(scene_root)
- ResourceSaver.save(scene, "res://extractor/test/pay_dun00.tscn")
+ #var scene_root := rsw.convert("pay_dun00", "res://client_data")
+ #var scene := PackedScene.new()
+ #scene.pack(scene_root)
+ #ResourceSaver.save(scene, "res://extractor/test/pay_dun00.tscn")
diff --git a/extractor/gnd_format.gd b/extractor/gnd_format.gd
index faad9ae..c49bce6 100644
--- a/extractor/gnd_format.gd
+++ b/extractor/gnd_format.gd
@@ -91,7 +91,7 @@ static func from_bytes(bytes: ByteStream) -> GNDFormat:
gnd_format.texture_paths = []
for _n in gnd_format.texture_count:
gnd_format.texture_paths.append(
- bytes.get_string_from_ascii(gnd_format.texture_path_length)
+ bytes.get_string_from_ro(gnd_format.texture_path_length)
)
gnd_format.light_map_slice_count = bytes.decode_s32()
@@ -162,6 +162,10 @@ func convert(data_path: String) -> GridMap:
var cubes := get_cubes()
+ var cache := {}
+ # TODO: use texture_index and surface uvs as key
+ # TODO: for deduplication of cell items (as long as other sides aren't accounted for..)
+
for x in width:
for y in height:
var cube = cubes[x + y * width]
diff --git a/extractor/grf.gd b/extractor/grf.gd
index 84918de..5b7046f 100644
--- a/extractor/grf.gd
+++ b/extractor/grf.gd
@@ -156,7 +156,7 @@ class FileEntry:
var file_access: FileAccess
-static func open(path: String):
+static func open(path: String) -> GRF:
var grf = GRF.new()
grf.file_access = FileAccess.open(path, FileAccess.ModeFlags.READ)
@@ -203,13 +203,6 @@ func extract(destination: String = "user://client_data"):
base_directory.make_dir_recursive(file_path.get_base_dir())
var file = FileAccess.open("%s/%s" % [destination, file_path], FileAccess.WRITE_READ)
-
- #if file_path.ends_with(".bmp"):
- #var img := Image.create_empty(1, 1, false, Image.FORMAT_RGBA8)
- #img.load_bmp_from_buffer(file_entry.get_contents(file_access))
- #img.save_png(file.get_path())
- #return
- #else:
file.store_buffer(file_entry.get_contents(file_access))
extracted_file.emit(idx)
@@ -234,27 +227,38 @@ func convert(destination: String = "res://client_data"):
# BMP
if file_path.ends_with(".bmp"):
+ #continue
if not FileAccess.file_exists("%s/%s" % [destination, file_path]):
continue
+ # load existing bmp files, so language specific overwrites are kept
+
+ var texture: CompressedTexture2D = load("%s/%s" % [destination, file_path])
+ if not texture:
+ # TODO: check if .godot/imported file is there (alrdy sufficient?)
+ continue
+
+ var texture_image := texture.get_image()
+ texture_image.decompress()
var image := BMPTexture.convert_image(
- Image.load_from_file("%s/%s" % [destination, file_path]),
+ texture_image,
[Color.MAGENTA]
)
image.save_png("%s/%s" % [destination, file_path.replace(".bmp", ".png")])
+
continue
# Sprite.spr and Action.act
- var player_head_path_part = "¸Ó¸®Åë"
- var player_body_path_part = "¸öÅë"
+ var player_head_path_part = "머리통"
+ var player_body_path_part = "몸통"
- if file_path.ends_with(".spr") and file_path.contains(player_head_path_part):
+ if file_path.ends_with(".spr"): #and (file_path.contains(player_head_path_part) or file_path.contains(player_body_path_part)):
continue
var sprite = SpriteFormat.from_bytes(file_entry.get_contents(file_access))
sprite.save_to_file(base_file_directory_path)
- elif file_path.ends_with(".act") and file_path.contains(player_head_path_part): #or file_path.contains(player_body_path_part):
+ elif file_path.ends_with(".act") and file_path.contains("cursors"): #and (file_path.contains(player_head_path_part) or file_path.contains(player_body_path_part)):
#continue
if not FileAccess.file_exists("%s/000.png.import" % base_file_directory_path):
continue
@@ -269,6 +273,7 @@ func convert(destination: String = "res://client_data"):
ResourceSaver.save(scene, "%s/actions.tscn" % base_file_directory_path)
+ continue
# Map.rsw and .gnd and .gat
if file_path.ends_with(".rsw") and (file_path.contains("pay_dun") or file_path.contains("iz_int") or file_path.contains("int_land")):
@@ -281,5 +286,9 @@ func convert(destination: String = "res://client_data"):
static func decode_string(bytes: PackedByteArray):
- # TODO: use iconv to decode EUC-KR
- return bytes.get_string_from_ascii()
+ Engine.print_error_messages = false
+ var string := bytes.get_string_from_multibyte_char("EUC-KR")
+ Engine.print_error_messages = true
+ if string.is_empty():
+ return bytes.get_string_from_ascii()
+ return string
diff --git a/extractor/rsm_format.gd b/extractor/rsm_format.gd
index 7eb41f0..7f16368 100644
--- a/extractor/rsm_format.gd
+++ b/extractor/rsm_format.gd
@@ -92,17 +92,17 @@ static func from_bytes(bytes: ByteStream) -> RSMFormat:
rsm_format.texture_names = [] as Array[String]
for _n in rsm_format.texture_count:
- rsm_format.texture_names.append(bytes.get_string_from_ascii(40))
+ rsm_format.texture_names.append(bytes.get_string_from_ro(40))
if version.lower_than(2, 2):
- rsm_format.root_node_name = bytes.get_string_from_ascii(40)
+ rsm_format.root_node_name = bytes.get_string_from_ro(40)
if version.higher_than(2, 1): # >= 2.2
rsm_format.root_node_count = bytes.decode_u32()
rsm_format.root_node_names = [] as Array[String]
for _n in rsm_format.root_node_count:
- rsm_format.root_node_names.append(bytes.get_string_from_ascii(40))
+ rsm_format.root_node_names.append(bytes.get_string_from_ro(40))
rsm_format.node_count = bytes.decode_u32()
rsm_format.nodes = [] as Array[ModelNode]
@@ -253,7 +253,7 @@ class ModelNode:
var node = ModelNode.new()
node.node_name = bytes.get_string_from_utf8(40)
- node.parent_node_name = bytes.get_string_from_ascii(40)
+ node.parent_node_name = bytes.get_string_from_ro(40)
if version.lower_than(2, 3): # < 2.3
node.texture_count = bytes.decode_u32()
@@ -267,7 +267,7 @@ class ModelNode:
node.texture_names = [] as Array[String]
for _n in node.texture_name_count:
- node.texture_names.append(bytes.get_string_from_ascii(40))
+ node.texture_names.append(bytes.get_string_from_ro(40))
node.offset_matrix = [] as Array[Vector3]
for _in in 3:
@@ -362,7 +362,7 @@ class ModelNode:
node.translate(translation_2)
if rotation_axis != Vector3.ZERO:
- node.rotate_object_local(rotation_axis, rotation_angle)
+ node.rotation = (rotation_axis * rotation_angle) * Vector3(1,-1,1)
node.scale = scale
diff --git a/extractor/rsw_format.gd b/extractor/rsw_format.gd
index 1066168..7e70850 100644
--- a/extractor/rsw_format.gd
+++ b/extractor/rsw_format.gd
@@ -122,14 +122,14 @@ func convert(name: String, data_path: String) -> Node3D:
if not FileAccess.file_exists(model_file_path):
continue
- var rsm := RSMFormat.from_bytes(ByteStream.from_bytes(FileAccess.get_file_as_bytes(model_file_path)))
+ var rsm := RSMFormat.from_bytes(ByteStream.from_bytes(
+ FileAccess.get_file_as_bytes(model_file_path)
+ ))
var model_root := Node3D.new()
model_root.name = resource.name
model_root.position = resource.get_position() * Vector3(-1, 1, 1)
- model_root.rotate_x(deg_to_rad(resource.get_rotation().x))
- model_root.rotate_y(deg_to_rad(resource.get_rotation().y))
- model_root.rotate_z(deg_to_rad(resource.get_rotation().z))
+ model_root.rotation_degrees = resource.get_rotation() * Vector3(-1,1,-1)
model_root.scale = resource.get_scale()
node.add_child(model_root)
@@ -399,11 +399,11 @@ class Animated3DModel extends MapResource:
static func from_bytes(bytes: ByteStream) -> Animated3DModel:
var resource = Animated3DModel.new()
- resource.name = bytes.get_string_from_ascii(40)
+ resource.name = bytes.get_string_from_ro(40)
resource.animation_type = bytes.decode_u32()
resource.animation_speed_percent = bytes.decode_float()
resource.collision_flags = bytes.decode_u32()
- resource.model_file = bytes.get_string_from_ascii(80)
+ resource.model_file = bytes.get_string_from_ro(80)
resource.root_node_name = bytes.get_string_from_utf8(80)
resource.position_x = bytes.decode_float()
resource.position_y = bytes.decode_float()
@@ -464,7 +464,7 @@ class DynamicLightSource extends MapResource:
static func from_bytes(bytes: ByteStream) -> DynamicLightSource:
var resource = DynamicLightSource.new()
- resource.name = bytes.get_string_from_ascii(80)
+ resource.name = bytes.get_string_from_ro(80)
resource.position_x = bytes.decode_float()
resource.position_y = bytes.decode_float()
resource.position_z = bytes.decode_float()
@@ -530,8 +530,8 @@ class SpatialAudioSource extends MapResource:
static func from_bytes(bytes: ByteStream) -> SpatialAudioSource:
var resource = SpatialAudioSource.new()
- resource.name = bytes.get_string_from_ascii(80)
- resource.audio_file = bytes.get_string_from_ascii(80)
+ resource.name = bytes.get_string_from_ro(80)
+ resource.audio_file = bytes.get_string_from_ro(80)
resource.position_x = bytes.decode_float()
resource.position_y = bytes.decode_float()
resource.position_z = bytes.decode_float()
@@ -595,7 +595,7 @@ class ParticleEffectEmitter extends MapResource:
static func from_bytes(bytes: ByteStream) -> ParticleEffectEmitter:
var resource = ParticleEffectEmitter.new()
- resource.name = bytes.get_string_from_ascii(80)
+ resource.name = bytes.get_string_from_ro(80)
resource.position_x = bytes.decode_float()
resource.position_y = bytes.decode_float()
resource.position_z = bytes.decode_float()