MCPcopy Create free account
hub / github.com/DFHack/dfhack / get_trap_str

Function get_trap_str

plugins/blueprint.cpp:820–859  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

818}
819
820static const char * get_trap_str(df::building *b) {
821 df::building_trapst *trap = virtual_cast<df::building_trapst>(b);
822 if (!trap)
823 return "~";
824
825 switch (trap->trap_type) {
826 case trap_type::StoneFallTrap: return "Ts";
827 case trap_type::WeaponTrap: return "Tw";
828 case trap_type::Lever: return "Tl";
829 case trap_type::PressurePlate: return "Tp";
830 case trap_type::CageTrap: return "Tc";
831 case trap_type::TrackStop:
832 {
833 ostringstream buf;
834 buf << "CS";
835 if (trap->track_stop_info.track_flags.bits.use_dump) {
836 if (trap->track_stop_info.dump_x_shift == 0) {
837 buf << "d";
838 if (trap->track_stop_info.dump_y_shift > 0)
839 buf << "d";
840 } else {
841 buf << "ddd";
842 if (trap->track_stop_info.dump_x_shift < 0)
843 buf << "d";
844 }
845 }
846
847 // each case falls through and is additive
848 switch (trap->track_stop_info.friction) {
849 case 10: buf << "a";
850 case 50: buf << "a";
851 case 500: buf << "a";
852 case 10000: buf << "a";
853 }
854 return cache(buf);
855 }
856 default:
857 return "~";
858 }
859}
860
861static const char * get_screw_pump_str(df::building *b) {
862 df::building_screw_pumpst *sp = virtual_cast<df::building_screw_pumpst>(b);

Callers 1

get_build_keysFunction · 0.85

Calls 1

cacheFunction · 0.85

Tested by

no test coverage detected