Skip to content

Commit

Permalink
Made the direction info more meaningful.
Browse files Browse the repository at this point in the history
  • Loading branch information
Japa committed Nov 3, 2015
1 parent b4b9046 commit f5ca3f9
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 8 deletions.
10 changes: 9 additions & 1 deletion plugins/proto/RemoteFortressReader.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ enum WorldPoles
BOTH_POLES = 3;
}

enum BuildingDirection
{
NORTH = 0;
EAST = 1;
SOUTH = 2;
WEST = 3;
}

message Tiletype
{
required int32 id = 1;
Expand Down Expand Up @@ -132,7 +140,7 @@ message BuildingInstance
optional uint32 building_flags = 10;
optional bool is_room = 11;
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
Expand Down
91 changes: 84 additions & 7 deletions plugins/remotefortressreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
}
}

remote_build->set_direction(0);

switch (type)
{
Expand Down Expand Up @@ -308,7 +307,26 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
{
auto actual = strict_virtual_cast<df::building_siegeenginest>(local_build);
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;
case df::enums::building_type::Trap:
Expand All @@ -335,7 +353,26 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
{
auto actual = strict_virtual_cast<df::building_screw_pumpst>(local_build);
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;
case df::enums::building_type::Construction:
Expand All @@ -356,7 +393,12 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
{
auto actual = strict_virtual_cast<df::building_axle_horizontalst>(local_build);
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;
case df::enums::building_type::AxleVertical:
Expand All @@ -365,14 +407,30 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
{
auto actual = strict_virtual_cast<df::building_water_wheelst>(local_build);
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;
case df::enums::building_type::Windmill:
{
auto actual = strict_virtual_cast<df::building_windmillst>(local_build);
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;
case df::enums::building_type::TractionBench:
Expand All @@ -389,7 +447,26 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
{
auto actual = strict_virtual_cast<df::building_rollersst>(local_build);
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;
default:
Expand Down

0 comments on commit f5ca3f9

Please sign in to comment.