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

Function getVerb

library/modules/EventManager.cpp:1247–1277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1245}
1246
1247static std::string getVerb(df::unit* unit, const std::string &reportStr) {
1248 std::string result(reportStr);
1249 std::string name = unit->name.first_name + " ";
1250 bool match = strncmp(result.c_str(), name.c_str(), name.length()) == 0;
1251 if ( match ) {
1252 result = result.substr(name.length());
1253 result = result.substr(0,result.length()-1);
1254 return result;
1255 }
1256 //use profession name
1257 name = "The " + Units::getProfessionName(unit) + " ";
1258 match = strncmp(result.c_str(), name.c_str(), name.length()) == 0;
1259 if ( match ) {
1260 result = result.substr(name.length());
1261 result = result.substr(0,result.length()-1);
1262 return result;
1263 }
1264
1265 if ( unit->id != 0 ) {
1266 return "";
1267 }
1268
1269 std::string you = "You ";
1270 match = strncmp(result.c_str(), name.c_str(), name.length()) == 0;
1271 if ( match ) {
1272 result = result.substr(name.length());
1273 result = result.substr(0,result.length()-1);
1274 return result;
1275 }
1276 return "";
1277}
1278
1279static InteractionData getAttacker(color_ostream& out, df::report* attackEvent, df::unit* lastAttacker, df::report* defendEvent, vector<df::unit*>& relevantUnits) {
1280 vector<df::unit*> attackers = relevantUnits;

Callers 1

getAttackerFunction · 0.85

Calls 2

c_strMethod · 0.80
lengthMethod · 0.80

Tested by

no test coverage detected