Use memcpy instead of copying data manually

This commit is contained in:
Broxzier 2017-01-24 00:40:39 +01:00 committed by Michał Janiszewski
parent f7ae3065f9
commit ff1e5c7675
2 changed files with 6 additions and 19 deletions

View File

@ -694,23 +694,16 @@ static void window_tile_inspector_copy_element(rct_window *w)
static void window_tile_inspector_paste_element(rct_window *w)
{
// Construct the data to send using the surface's properties
sint32 bytes[2] = { 0 };
bytes[0] |= tileInspectorCopiedElement.type << 24;
bytes[0] |= tileInspectorCopiedElement.flags << 16;
bytes[0] |= tileInspectorCopiedElement.base_height << 8;
bytes[0] |= tileInspectorCopiedElement.clearance_height;
bytes[1] |= tileInspectorCopiedElement.properties.surface.slope << 24;
bytes[1] |= tileInspectorCopiedElement.properties.surface.terrain << 16;
bytes[1] |= tileInspectorCopiedElement.properties.surface.grass_length << 8;
bytes[1] |= tileInspectorCopiedElement.properties.surface.ownership;
sint32 data[2];
memcpy(&data[0], &tileInspectorCopiedElement, 8);
game_do_command(
TILE_INSPECTOR_ANY_PASTE,
GAME_COMMAND_FLAG_APPLY,
windowTileInspectorTileX | (windowTileInspectorTileY << 8),
bytes[0],
data[0],
GAME_COMMAND_MODIFY_TILE,
bytes[1],
data[1],
0
);
}

View File

@ -5642,14 +5642,8 @@ void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx
case TILE_INSPECTOR_ANY_PASTE:
{
rct_map_element element_to_paste;
element_to_paste.type = *edx >> 24;
element_to_paste.flags = *edx >> 16;
element_to_paste.base_height = *edx >> 8;
element_to_paste.clearance_height = *edx;
element_to_paste.properties.surface.slope = *edi >> 24;
element_to_paste.properties.surface.terrain = *edi >> 16;
element_to_paste.properties.surface.grass_length = *edi >> 8;
element_to_paste.properties.surface.ownership = *edi;
sint32 data[] = { *edx, *edi };
memcpy(&element_to_paste, data, 8);
*ebx = tile_inspector_paste_element_at(x, y, element_to_paste, flags);
return;
}