Revised map saving a lot...

This commit is contained in:
Ognjen Milan Robovic 2024-05-25 03:00:30 -04:00
parent d675ce7467
commit f4453d06a3
7 changed files with 34 additions and 25 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ source/*.o
source/*.ali
xhads
temporary/
map/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -70,6 +70,8 @@ package chad is
procedure draw_pepe;
procedure draw_alice;
--~procedure save_value_data (file : in ; data : in value);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end chad;

View File

@ -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));

View File

@ -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;

View File

@ -326,8 +326,6 @@ begin
world.save ("heyo");
core.save ("test.a", null, 0);
--~world.mapshot (folder & "/mapshot.png");
------------------------------------------------------------------------------------------

View File

@ -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 & "'.");
--