Skip to content

Commit

Permalink
Test asEP_DISALLOW_VALUE_ASSIGN_FOR_REF_TYPE
Browse files Browse the repository at this point in the history
  • Loading branch information
1vanK committed Nov 7, 2024
1 parent cb2bdc1 commit f58b1db
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
Binary file modified res/exp_atlas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions res/exp_atlas.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0"?>
<tiles>
<tile x="2" y="2" width="16" height="32" />
<tile x="22" y="2" width="16" height="32" />
<tile x="42" y="2" width="16" height="32" />
<tile x="62" y="2" width="16" height="32" />
<tile x="2" y="38" width="16" height="32" />
<tile x="22" y="38" width="16" height="32" />
<tile x="42" y="38" width="16" height="32" />
<tile x="62" y="38" width="16" height="32" />
<tile x="2" y="2" width="20" height="36" />
<tile x="26" y="2" width="20" height="36" />
<tile x="50" y="2" width="20" height="36" />
<tile x="74" y="2" width="20" height="36" />
<tile x="2" y="42" width="20" height="36" />
<tile x="26" y="42" width="20" height="36" />
<tile x="50" y="42" width="20" height="36" />
<tile x="74" y="42" width="20" height="36" />
</tiles>
10 changes: 6 additions & 4 deletions res/main.as
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
array<array<Image@>>@ split(Image@ img, ivec2 tile_size)
array<array<Image@>@>@ split(Image@ img, ivec2 tile_size)
{
if (tile_size.x <= 0 || tile_size.y <= 0)
throw("split(): tile_size.x <= 0 || tile_size.y <= 0");

ivec2 num_tiles = img.size() / tile_size;

array<array<Image@>> ret(num_tiles.y, array<Image@>(num_tiles.x));
array<array<Image@>@> ret(num_tiles.y, array<Image@>(num_tiles.x));

for (int index_y = 0; index_y < num_tiles.y; ++index_y)
{
Expand Down Expand Up @@ -33,7 +33,7 @@ int ceil_power_of_2(int n)
return ret;
}

void join_tiles(array<array<Image@>>@ tiles, Image@&out atlas, XmlDocument@&out xml_doc, int border_size = 0)
void join_tiles(array<array<Image@>@>@ tiles, Image@&out atlas, XmlDocument@&out xml_doc, int border_size = 0)
{
int num_tiles_y = tiles.size();

Expand Down Expand Up @@ -85,7 +85,9 @@ void main()
string exp_atlas_xml_path = base_path + "exp_atlas.xml";

Image@ src_atlas = Image::from_file(src_atlas_path);
Image@[][]@ tiles = split(src_atlas, src_tile_size);
Image@[]@[]@ tiles = split(src_atlas, src_tile_size);

tiles[0][0].save_png(base_path + "tile_0_0.png");

// Расширяем каждый тайл
for (uint index_y = 0; index_y < tiles.size(); ++index_y)
Expand Down
Binary file added res/tile_0_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ i32 main()
Log log(get_base_path() + "log.txt");

asIScriptEngine* as_engine = asCreateScriptEngine();
//as_engine->SetEngineProperty(asEP_ALLOW_IMPLICIT_HANDLE_TYPES, true);
as_engine->SetEngineProperty(asEP_DISALLOW_VALUE_ASSIGN_FOR_REF_TYPE, true);

i32 r = as_engine->SetMessageCallback(asFUNCTION(message_callback), 0, asCALL_CDECL);
if (r < 0)
{
Expand Down

0 comments on commit f58b1db

Please sign in to comment.