Made the direction info more meaningful.

develop
Japa 2015-11-03 18:49:17 +05:30
parent b4b90465c2
commit f5ca3f9e7b
2 changed files with 93 additions and 8 deletions

@ -92,6 +92,14 @@ enum WorldPoles
BOTH_POLES = 3; BOTH_POLES = 3;
} }
enum BuildingDirection
{
NORTH = 0;
EAST = 1;
SOUTH = 2;
WEST = 3;
}
message Tiletype message Tiletype
{ {
required int32 id = 1; required int32 id = 1;
@ -132,7 +140,7 @@ message BuildingInstance
optional uint32 building_flags = 10; optional uint32 building_flags = 10;
optional bool is_room = 11; optional bool is_room = 11;
optional BuildingExtents room = 12; optional BuildingExtents room = 12;
optional int32 direction = 13; //Doesn't mean anything forall buildings optional BuildingDirection direction = 13; //Doesn't mean anything for most buildings
} }
message MapBlock message MapBlock

@ -254,7 +254,6 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
} }
} }
remote_build->set_direction(0);
switch (type) switch (type)
{ {
@ -308,7 +307,26 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
{ {
auto actual = strict_virtual_cast<df::building_siegeenginest>(local_build); auto actual = strict_virtual_cast<df::building_siegeenginest>(local_build);
if (actual) if (actual)
remote_build->set_direction(actual->facing); {
auto facing = actual->facing;
switch (facing)
{
case df::building_siegeenginest::Left:
remote_build->set_direction(WEST);
break;
case df::building_siegeenginest::Up:
remote_build->set_direction(NORTH);
break;
case df::building_siegeenginest::Right:
remote_build->set_direction(EAST);
break;
case df::building_siegeenginest::Down:
remote_build->set_direction(SOUTH);
break;
default:
break;
}
}
} }
break; break;
case df::enums::building_type::Trap: case df::enums::building_type::Trap:
@ -335,7 +353,26 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
{ {
auto actual = strict_virtual_cast<df::building_screw_pumpst>(local_build); auto actual = strict_virtual_cast<df::building_screw_pumpst>(local_build);
if (actual) if (actual)
remote_build->set_direction(actual->direction); {
auto direction = actual->direction;
switch (direction)
{
case df::enums::screw_pump_direction::FromNorth:
remote_build->set_direction(NORTH);
break;
case df::enums::screw_pump_direction::FromEast:
remote_build->set_direction(EAST);
break;
case df::enums::screw_pump_direction::FromSouth:
remote_build->set_direction(SOUTH);
break;
case df::enums::screw_pump_direction::FromWest:
remote_build->set_direction(WEST);
break;
default:
break;
}
}
} }
break; break;
case df::enums::building_type::Construction: case df::enums::building_type::Construction:
@ -356,7 +393,12 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
{ {
auto actual = strict_virtual_cast<df::building_axle_horizontalst>(local_build); auto actual = strict_virtual_cast<df::building_axle_horizontalst>(local_build);
if (actual) if (actual)
remote_build->set_direction(actual->is_vertical); {
if(actual->is_vertical)
remote_build->set_direction(NORTH);
else
remote_build->set_direction(EAST);
}
} }
break; break;
case df::enums::building_type::AxleVertical: case df::enums::building_type::AxleVertical:
@ -365,14 +407,30 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
{ {
auto actual = strict_virtual_cast<df::building_water_wheelst>(local_build); auto actual = strict_virtual_cast<df::building_water_wheelst>(local_build);
if (actual) if (actual)
remote_build->set_direction(actual->is_vertical); {
if (actual->is_vertical)
remote_build->set_direction(NORTH);
else
remote_build->set_direction(EAST);
}
} }
break; break;
case df::enums::building_type::Windmill: case df::enums::building_type::Windmill:
{ {
auto actual = strict_virtual_cast<df::building_windmillst>(local_build); auto actual = strict_virtual_cast<df::building_windmillst>(local_build);
if (actual) if (actual)
remote_build->set_direction(actual->orient_angle); {
if (actual->orient_x < 0)
remote_build->set_direction(WEST);
else if (actual->orient_x > 0)
remote_build->set_direction(EAST);
else if (actual->orient_y < 0)
remote_build->set_direction(NORTH);
else if (actual->orient_y > 0)
remote_build->set_direction(SOUTH);
else
remote_build->set_direction(EAST);
}
} }
break; break;
case df::enums::building_type::TractionBench: case df::enums::building_type::TractionBench:
@ -389,7 +447,26 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
{ {
auto actual = strict_virtual_cast<df::building_rollersst>(local_build); auto actual = strict_virtual_cast<df::building_rollersst>(local_build);
if (actual) if (actual)
remote_build->set_direction(actual->direction); {
auto direction = actual->direction;
switch (direction)
{
case df::enums::screw_pump_direction::FromNorth:
remote_build->set_direction(NORTH);
break;
case df::enums::screw_pump_direction::FromEast:
remote_build->set_direction(EAST);
break;
case df::enums::screw_pump_direction::FromSouth:
remote_build->set_direction(SOUTH);
break;
case df::enums::screw_pump_direction::FromWest:
remote_build->set_direction(WEST);
break;
default:
break;
}
}
} }
break; break;
default: default: