bool addSingleBuildingConfig( TiXmlElement* elemRoot, vector<BuildingConfiguration>* knownBuildings ){ const char* strName = elemRoot->Attribute("name"); const char* strGameID = elemRoot->Attribute("game_type"); const char* strGameSub = elemRoot->Attribute("game_subtype"); const char* strGameCustom = elemRoot->Attribute("game_custom"); if (strName == NULL || strGameID == NULL || strName[0] == 0 || strGameID[0] == 0) { contentError("<building> node must have name and game_type attributes",elemRoot); return false; } building_type::building_type main_type = (building_type::building_type) INVALID_INDEX; int subtype = INVALID_INDEX; string game_type_s; FOR_ENUM_ITEMS(building_type,i) { game_type_s = strGameID; if (game_type_s == ENUM_KEY_STR(building_type,i)) { main_type = i; break; } }
void AI::handle_pause_event(color_ostream & out, df::report *announce) { // unsplit announce text std::string fulltext = announce->text; auto idx = std::find(world->status.announcements.rbegin(), world->status.announcements.rend(), announce); while (announce->flags.bits.continuation) { idx++; if (idx == world->status.announcements.rend()) break; announce = *idx; fulltext = announce->text + " " + fulltext; } debug(out, "pause: " + fulltext); switch (announce->type) { case announcement_type::MEGABEAST_ARRIVAL: { debug(out, "pause: uh oh, megabeast..."); bool found = false; for (auto it = world->units.active.rbegin(); it != world->units.active.rend(); it++) { if ((*it)->flags2.bits.visitor_uninvited) { pop->military_all_squads_attack_unit(out, *it); found = true; break; } } if (!found) { debug(out, "[ERROR] could not find megabeast"); } break; } case announcement_type::BERSERK_CITIZEN: debug(out, "pause: berserk"); break; case announcement_type::UNDEAD_ATTACK: debug(out, "pause: i see dead people"); break; case announcement_type::CAVE_COLLAPSE: debug(out, "pause: kevin?"); break; case announcement_type::DIG_CANCEL_DAMP: case announcement_type::DIG_CANCEL_WARM: camera->ignore_pause(); debug(out, "pause: lazy miners"); break; case announcement_type::BIRTH_CITIZEN: debug(out, "pause: newborn"); break; case announcement_type::BIRTH_ANIMAL: break; case announcement_type::D_MIGRANTS_ARRIVAL: case announcement_type::D_MIGRANT_ARRIVAL: case announcement_type::MIGRANT_ARRIVAL: case announcement_type::NOBLE_ARRIVAL: case announcement_type::FORT_POSITION_SUCCESSION: debug(out, "pause: more minions"); break; case announcement_type::DIPLOMAT_ARRIVAL: case announcement_type::LIAISON_ARRIVAL: case announcement_type::CARAVAN_ARRIVAL: case announcement_type::TRADE_DIPLOMAT_ARRIVAL: debug(out, "pause: visitors"); break; case announcement_type::STRANGE_MOOD: case announcement_type::MOOD_BUILDING_CLAIMED: case announcement_type::ARTIFACT_BEGUN: case announcement_type::MADE_ARTIFACT: debug(out, "pause: mood"); break; case announcement_type::FEATURE_DISCOVERY: case announcement_type::STRUCK_DEEP_METAL: debug(out, "pause: dig dig dig"); break; case announcement_type::TRAINING_FULL_REVERSION: debug(out, "pause: born to be wild"); break; case announcement_type::NAMED_ARTIFACT: debug(out, "pause: hallo"); break; default: { const static std::string prefix("AMBUSH"); std::string type(ENUM_KEY_STR(announcement_type, announce->type)); if (std::mismatch(prefix.begin(), prefix.end(), type.begin()).first == prefix.end()) { debug(out, "pause: an ambush!"); } else { debug(out, "pause: unhandled pausing event " + type); // return; } break; } } if (announcements->flags[announce->type].bits.DO_MEGA) { timeout_sameview([](color_ostream & out) { unpause(); }); } else { unpause(); } }