diff --git a/.gitignore b/.gitignore index d6bd88c..8d805e6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ source/*.o source/*.ali xhads temporary/ +map/ diff --git a/map/heyo.png b/map/heyo.png deleted file mode 100644 index c38408d..0000000 Binary files a/map/heyo.png and /dev/null differ diff --git a/source/chad.ads b/source/chad.ads index ca6c8e9..d781e04 100644 --- a/source/chad.ads +++ b/source/chad.ads @@ -70,6 +70,8 @@ package chad is procedure draw_pepe; procedure draw_alice; + --~procedure save_value_data (file : in ; data : in value); + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ end chad; diff --git a/source/core.adb b/source/core.adb index 218577f..a0bac0b 100644 --- a/source/core.adb +++ b/source/core.adb @@ -147,21 +147,6 @@ package body core is ------------------------------------------------------------------------------------------ - procedure save (file_name : in string; data : in ray.pointer; size : in natural) is - package io is new ada.sequential_io (integer); - -- - file : io.file_type; - begin - io.create (file, io.out_file, file_name); - io.write (file, 255); - io.write (file, 0); - io.write (file, 0); - io.write (file, 255); - io.close (file); - end save; - - ------------------------------------------------------------------------------------------ - function c_string (ada_string : string) return string is begin return (ada_string & character'val (0)); diff --git a/source/core.ads b/source/core.ads index 4607e68..2da86d7 100644 --- a/source/core.ads +++ b/source/core.ads @@ -67,6 +67,8 @@ package core is size : vector := (0, 0); end record; + package io is new ada.sequential_io (integer); + ------------------------------------------------------------------------------------------ folder : constant string := "."; @@ -123,8 +125,6 @@ package core is procedure dash; procedure semi_dash; - procedure save (file_name : in string; data : in ray.pointer; size : in natural); - function c_string (ada_string : in string) return string; function random (minimum, maximum : in integer) return integer; diff --git a/source/main.adb b/source/main.adb index 5cc80fd..e8f12de 100644 --- a/source/main.adb +++ b/source/main.adb @@ -326,8 +326,6 @@ begin world.save ("heyo"); - core.save ("test.a", null, 0); - --~world.mapshot (folder & "/mapshot.png"); ------------------------------------------------------------------------------------------ diff --git a/source/world.adb b/source/world.adb index 0025d09..94c447e 100644 --- a/source/world.adb +++ b/source/world.adb @@ -172,16 +172,39 @@ package body world is ------------------------------------------------------------------------------------------ procedure save (file_name : in string) is - begin - core.create_image (map.width, map.height); + procedure save_entity (here : in core.io.file_type; data : in entity_trait) is + begin + core.io.write (here, data.index); + core.io.write (here, data.state); + core.io.write (here, data.x); + core.io.write (here, data.y); + end save_entity; -- - for vertical in 0 .. map.height - 1 loop - for horizontal in 0 .. map.width - 1 loop - core.draw_pixel (horizontal, vertical, (140, 140, 140, 255)); + file : core.io.file_type; + begin + core.io.create (file, core.io.out_file, core.folder & "/map/" & file_name); + -- + core.io.write (file, biome'pos (map.kind)); + core.io.write (file, map.width); + core.io.write (file, map.height); + core.io.write (file, map.chad_count); + core.io.write (file, map.chad_limit); + -- + for x in 0 .. map.width - 1 loop + for y in 0 .. map.height - 1 loop + core.io.write (file, map.earth (x, y)); + core.io.write (file, boolean'pos (map.clips (x, y))); + core.io.write (file, boolean'pos (map.views (x, y))); end loop; end loop; -- - core.export_image (core.folder & "/map/" & file_name & ".png"); + for index in 1 .. landmark_limit loop save_entity (file, map.landmarks (index)); end loop; + for index in 1 .. location_limit loop save_entity (file, map.locations (index)); end loop; + for index in 1 .. construction_limit loop save_entity (file, map.constructions (index)); end loop; + for index in 1 .. equipment_limit loop save_entity (file, map.equipments (index)); end loop; + for index in 1 .. unit_limit loop save_entity (file, map.units (index)); end loop; + -- + core.io.close (file); -- core.echo (core.success, "Saved current map as '" & file_name & "'."); --