Add active state to some building types.

develop
Japa 2017-05-22 22:03:12 +05:30
parent 5831665231
commit 3f98cd3da0
2 changed files with 37 additions and 0 deletions

@ -172,6 +172,7 @@ message BuildingInstance
optional BuildingExtents room = 12; optional BuildingExtents room = 12;
optional BuildingDirection direction = 13; //Doesn't mean anything for most buildings optional BuildingDirection direction = 13; //Doesn't mean anything for most buildings
repeated BuildingItem items = 14; repeated BuildingItem items = 14;
optional int32 active = 15;
} }
message RiverEdge message RiverEdge

@ -6,13 +6,17 @@
#include "df/building_bridgest.h" #include "df/building_bridgest.h"
#include "df/building_def_furnacest.h" #include "df/building_def_furnacest.h"
#include "df/building_def_workshopst.h" #include "df/building_def_workshopst.h"
#include "df/building_doorst.h"
#include "df/building_floodgatest.h"
#include "df/building_rollersst.h" #include "df/building_rollersst.h"
#include "df/building_screw_pumpst.h" #include "df/building_screw_pumpst.h"
#include "df/building_siegeenginest.h" #include "df/building_siegeenginest.h"
#include "df/building_water_wheelst.h" #include "df/building_water_wheelst.h"
#include "df/building_wellst.h" #include "df/building_wellst.h"
#include "df/building_windmillst.h" #include "df/building_windmillst.h"
#include "df/building_workshopst.h"
#include "df/world.h" #include "df/world.h"
#include "df/machine.h"
#include "modules/Buildings.h" #include "modules/Buildings.h"
@ -304,9 +308,29 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
case df::enums::building_type::Shop: case df::enums::building_type::Shop:
break; break;
case df::enums::building_type::Door: case df::enums::building_type::Door:
{
auto actual = strict_virtual_cast<df::building_doorst>(local_build);
if (actual)
{
if (actual->door_flags.bits.closed)
remote_build->set_active(1);
else
remote_build->set_active(0);
}
break; break;
}
case df::enums::building_type::Floodgate: case df::enums::building_type::Floodgate:
{
auto actual = strict_virtual_cast<df::building_floodgatest>(local_build);
if (actual)
{
if (actual->gate_flags.bits.closed)
remote_build->set_active(1);
else
remote_build->set_active(0);
}
break; break;
}
case df::enums::building_type::Box: case df::enums::building_type::Box:
break; break;
case df::enums::building_type::Weaponrack: case df::enums::building_type::Weaponrack:
@ -314,7 +338,15 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
case df::enums::building_type::Armorstand: case df::enums::building_type::Armorstand:
break; break;
case df::enums::building_type::Workshop: case df::enums::building_type::Workshop:
{
auto actual = strict_virtual_cast<df::building_workshopst>(local_build);
if (actual && actual->machine.machine_id >= 0)
{
auto mach = df::machine::find(actual->machine.machine_id);
remote_build->set_active(mach->flags.bits.active);
}
break; break;
}
case df::enums::building_type::Cabinet: case df::enums::building_type::Cabinet:
break; break;
case df::enums::building_type::Statue: case df::enums::building_type::Statue:
@ -350,6 +382,10 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
default: default:
break; break;
} }
if (actual->gate_flags.bits.closed)
remote_build->set_active(1);
else
remote_build->set_active(0);
} }
} }
break; break;