From: <geo...@us...> - 2013-06-06 21:05:20
|
Revision: 6118 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=6118&view=rev Author: geoffthemedio Date: 2013-06-06 21:05:11 +0000 (Thu, 06 Jun 2013) Log Message: ----------- Added extra field visibility range check to include fields of which any part is within detection range for an empire, rather than only testing the centre of the field. Modified Paths: -------------- trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2013-06-06 02:33:28 UTC (rev 6117) +++ trunk/FreeOrion/universe/Universe.cpp 2013-06-06 21:05:11 UTC (rev 6118) @@ -1818,6 +1818,72 @@ } } + /** sets visibility of field objects for empires based on input locations + * and stealth of fields in supplied ObjectMap and input empire detection + * ranges at locations. the rules for detection of fields are more + * permissive than other object types, so a special function for them is + * needed in addition to SetEmpireObjectVisibilitiesFromRanges(...) */ + void SetEmpireFieldVisibilitiesFromRanges( + const std::map<int, std::map<std::pair<double, double>, float> >& + empire_location_detection_ranges, + const ObjectMap& objects) + { + std::vector<const Field*> fields = objects.FindObjects<Field>(); + Universe& universe = GetUniverse(); + + for (std::map<int, std::map<std::pair<double, double>, float> >::const_iterator + detecting_empire_it = empire_location_detection_ranges.begin(); + detecting_empire_it != empire_location_detection_ranges.end(); + ++detecting_empire_it) + { + int detecting_empire_id = detecting_empire_it->first; + double detection_strength = 0.0; + const Empire* empire = Empires().Lookup(detecting_empire_id); + if (!empire) + continue; + const Meter* meter = empire->GetMeter("METER_DETECTION_STRENGTH"); + if (!meter) + continue; + detection_strength = meter->Current(); + + // get empire's locations of detection ranges + const std::map<std::pair<double, double>, float>& detector_position_ranges = + detecting_empire_it->second; + + // for each field, try to find a detector position in range for this empire + for (ObjectMap::const_iterator<Field> field_it = objects.const_begin<Field>(); + field_it != objects.const_end<Field>(); ++field_it) + { + const Field* field = *field_it; + if (field->GetMeter(METER_STEALTH)->Current() > detection_strength) + continue; + double field_size = field->GetMeter(METER_SIZE)->Current(); + const std::pair<double, double> object_pos(field->X(), field->Y()); + + // search through detector positions until one is found in range + for (std::map<std::pair<double, double>, float>::const_iterator + detector_position_it = detector_position_ranges.begin(); + detector_position_it != detector_position_ranges.end(); + ++detector_position_it) + { + // check range for this detector location, for field of this + // size, against distance between field and detector + float detector_range = detector_position_it->second; + const std::pair<double, double>& detector_pos = detector_position_it->first; + double x_dist = detector_pos.first - object_pos.first; + double y_dist = detector_pos.second - object_pos.second; + double dist = std::sqrt(x_dist*x_dist + y_dist*y_dist); + double effective_dist = dist - field_size; + if (effective_dist > detector_range) + continue; // object out of range + + universe.SetEmpireObjectVisibility(detecting_empire_id, field->ID(), + VIS_PARTIAL_VISIBILITY); + } + } + } + } + /** sets visibility of objects for empires based on input locations of * potentially detectable objects (if in range) and and input empire * detection ranges at locations. */ @@ -2237,6 +2303,7 @@ SetEmpireObjectVisibilitiesFromRanges(empire_position_detection_ranges, empire_position_potentially_detectable_objects); + SetEmpireFieldVisibilitiesFromRanges(empire_position_detection_ranges, Objects()); SetSameSystemPlanetsVisible(Objects()); |
From: <Bi...@us...> - 2013-06-08 19:03:14
|
Revision: 6130 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=6130&view=rev Author: Bigjoe5 Date: 2013-06-08 19:03:07 +0000 (Sat, 08 Jun 2013) Log Message: ----------- - Removed a call to FindObjects<Field>(), the result of which was unused. Modified Paths: -------------- trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2013-06-08 18:08:22 UTC (rev 6129) +++ trunk/FreeOrion/universe/Universe.cpp 2013-06-08 19:03:07 UTC (rev 6130) @@ -1828,7 +1828,6 @@ empire_location_detection_ranges, const ObjectMap& objects) { - std::vector<const Field*> fields = objects.FindObjects<Field>(); Universe& universe = GetUniverse(); for (std::map<int, std::map<std::pair<double, double>, float> >::const_iterator |
From: <geo...@us...> - 2013-07-04 01:05:58
|
Revision: 6222 http://sourceforge.net/p/freeorion/code/6222 Author: geoffthemedio Date: 2013-07-04 01:05:53 +0000 (Thu, 04 Jul 2013) Log Message: ----------- Rewrote fleet special case staleness determination, taking into account destroyed ships, to hopefully fix issue with empty fleets appearing in-game after their ships were destroyed. Modified Paths: -------------- trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2013-07-04 00:54:36 UTC (rev 6221) +++ trunk/FreeOrion/universe/Universe.cpp 2013-07-04 01:05:53 UTC (rev 6222) @@ -2477,8 +2477,7 @@ } } - // fleets that are not visible and that contain no non-stale ships are - // stale + // fleets that are not visible and that contain no ships or only stale ships are stale for (ObjectMap::const_iterator<> obj_it = latest_known_objects.const_begin(); obj_it != latest_known_objects.const_end(); ++obj_it) { @@ -2491,36 +2490,51 @@ if (!fleet) continue; int fleet_id = obj_it->ID(); - // are there any non-stale contained ships? - bool non_stale_contained_ship = false; + + // destroyed? not stale + if (destroyed_set.find(fleet_id) != destroyed_set.end()) { + stale_set.insert(fleet_id); + continue; + } + + // no ships? -> stale + if (fleet->Empty()) { + stale_set.insert(fleet_id); + continue; + } const std::set<int>& ship_ids = fleet->ShipIDs(); + + bool fleet_stale = true; + // check each ship. if any are visible or not visible but not stale, + // fleet is not stale for (std::set<int>::const_iterator ship_it = ship_ids.begin(); ship_it != ship_ids.end(); ++ship_it) { int ship_id = *ship_it; - // is supposedly contained fleet unknown or not in this fleet? - // if not known or not in this fleet, doesn't make fleet non-stale const Ship* ship = latest_known_objects.Object<Ship>(ship_id); + + // if ship doesn't think it's in this fleet, doesn't count. if (!ship || ship->FleetID() != fleet_id) continue; - // is contained ship visible? If so, makes fleet non-stale + // if ship is destroyed, doesn't count + if (destroyed_set.find(ship_id) != destroyed_set.end()) + continue; + + // is contained ship visible? If so, fleet is not stale. ObjectVisibilityMap::const_iterator vis_it = vis_map.find(ship_id); if (vis_it != vis_map.end() && vis_it->second > VIS_NO_VISIBILITY) { - non_stale_contained_ship = true; + fleet_stale = false; break; } - // contained ship is not visible. if it is also stale, then it - // doesn't make fleet non-stale - if (stale_set.find(ship_id) != stale_set.end()) - continue; - - // ship is not stale, so its fleet non-stale - non_stale_contained_ship = true; - break; + // is contained ship not visible and not stale? if so, fleet is not stale + if (stale_set.find(ship_id) == stale_set.end()) { + fleet_stale = false; + break; + } } - if (!non_stale_contained_ship) + if (fleet_stale) stale_set.insert(fleet_id); } |
From: <geo...@us...> - 2013-07-27 10:18:27
|
Revision: 6270 http://sourceforge.net/p/freeorion/code/6270 Author: geoffthemedio Date: 2013-07-27 10:18:23 +0000 (Sat, 27 Jul 2013) Log Message: ----------- minor grooming Modified Paths: -------------- trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2013-07-27 10:16:54 UTC (rev 6269) +++ trunk/FreeOrion/universe/Universe.cpp 2013-07-27 10:18:23 UTC (rev 6270) @@ -1085,7 +1085,9 @@ // apply all meters' discrepancies std::map<MeterType, double>& meter_map = dis_it->second; - for(std::map<MeterType, double>::iterator meter_it = meter_map.begin(); meter_it != meter_map.end(); ++meter_it) { + for (std::map<MeterType, double>::iterator meter_it = meter_map.begin(); + meter_it != meter_map.end(); ++meter_it) + { MeterType type = meter_it->first; double discrepancy = meter_it->second; @@ -1095,7 +1097,9 @@ if (meter) { if (GetOptionsDB().Get<bool>("verbose-logging")) - Logger().debugStream() << "object " << obj_id << " has meter " << type << ": discrepancy: " << discrepancy << " and : " << meter->Dump(); + Logger().debugStream() << "object " << obj_id << " has meter " << type + << ": discrepancy: " << discrepancy + << " and : " << meter->Dump(); meter->AddToCurrent(discrepancy); |
From: <geo...@us...> - 2013-11-10 11:45:39
|
Revision: 6505 http://sourceforge.net/p/freeorion/code/6505 Author: geoffthemedio Date: 2013-11-10 11:45:35 +0000 (Sun, 10 Nov 2013) Log Message: ----------- Minor logging tweaks. Modified Paths: -------------- trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2013-11-10 04:32:46 UTC (rev 6504) +++ trunk/FreeOrion/universe/Universe.cpp 2013-11-10 11:45:35 UTC (rev 6505) @@ -1542,10 +1542,14 @@ m_marked_destroyed.clear(); m_marked_for_victory.clear(); std::map<std::string, Effect::TargetSet> executed_nonstacking_effects; + bool log_verbose = GetOptionsDB().Get<bool>("verbose-logging"); for (Effect::TargetsCauses::const_iterator targets_it = targets_causes.begin(); targets_it != targets_causes.end(); ++targets_it) { + if (log_verbose) + Logger().debugStream() << " * * * * * * * * * * * (new effects group log entry)"; + TemporaryPtr<const UniverseObject> source = GetUniverseObject(targets_it->first.source_object_id); ScopedTimer update_timer("Universe::ExecuteEffects effgrp (source " + (source ? source->Name() : "No Source!") + @@ -1577,7 +1581,7 @@ continue; Effect::TargetsAndCause filtered_targets_and_cause(targets, targets_and_cause.effect_cause); - if (GetOptionsDB().Get<bool>("verbose-logging")) { + if (log_verbose) { Logger().debugStream() << "ExecuteEffects effectsgroup: \n" << effects_group->Dump(); Logger().debugStream() << "ExecuteEffects Targets before: "; for (Effect::TargetSet::const_iterator t_it = targets.begin(); t_it != targets.end(); ++t_it) @@ -1601,11 +1605,10 @@ effects_group->Execute( sourced_effects_group.source_object_id, filtered_targets_and_cause.target_set); } - if (GetOptionsDB().Get<bool>("verbose-logging")) { + if (log_verbose) { Logger().debugStream() << "ExecuteEffects Targets after: "; for (Effect::TargetSet::const_iterator t_it = targets.begin(); t_it != targets.end(); ++t_it) Logger().debugStream() << " ... " << (*t_it)->Dump(); - Logger().debugStream() << " * * * * * *"; } // if this EffectsGroup belongs to a stacking group, add the objects just affected by it to executed_nonstacking_effects |
From: <geo...@us...> - 2013-11-26 08:57:51
|
Revision: 6539 http://sourceforge.net/p/freeorion/code/6539 Author: geoffthemedio Date: 2013-11-26 08:57:49 +0000 (Tue, 26 Nov 2013) Log Message: ----------- Tweaks to Universe effect code to avoid unnecessary repeat lookups of objects by ID number. Modified Paths: -------------- trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2013-11-26 07:56:17 UTC (rev 6538) +++ trunk/FreeOrion/universe/Universe.cpp 2013-11-26 08:57:49 UTC (rev 6539) @@ -832,13 +832,12 @@ void Universe::ApplyAllEffectsAndUpdateMeters() { ScopedTimer timer("Universe::ApplyAllEffectsAndUpdateMeters"); - std::vector<int> object_ids = m_objects.FindObjectIDs(); // cache all activation and scoping condition results before applying // Effects, since the application of these Effects may affect the activation // and scoping evaluations Effect::TargetsCauses targets_causes; - GetEffectsAndTargets(targets_causes, object_ids); + GetEffectsAndTargets(targets_causes); // revert all current meter values (which are modified by effects) to // their initial state for this turn, so that max/target/unpaired meter @@ -890,13 +889,10 @@ void Universe::ApplyMeterEffectsAndUpdateMeters() { ScopedTimer timer("Universe::ApplyMeterEffectsAndUpdateMeters on all objects"); - std::vector<int> object_ids = m_objects.FindObjectIDs(); Effect::TargetsCauses targets_causes; - GetEffectsAndTargets(targets_causes, object_ids); + GetEffectsAndTargets(targets_causes); - std::vector<TemporaryPtr<UniverseObject> > objects = m_objects.FindObjects(object_ids); - - for (std::vector<TemporaryPtr<UniverseObject> >::iterator it = objects.begin(); it != objects.end(); ++it) { + for (ObjectMap::iterator<> it = m_objects.begin(); it != m_objects.end(); ++it) { (*it)->ResetTargetMaxUnpairedMeters(); (*it)->ResetPairedActiveMeters(); } @@ -904,7 +900,7 @@ it->second->ResetMeters(); ExecuteEffects(targets_causes, true, true, false, true); - for (std::vector<TemporaryPtr<UniverseObject> >::iterator it = objects.begin(); it != objects.end(); ++it) + for (ObjectMap::iterator<> it = m_objects.begin(); it != m_objects.end(); ++it) (*it)->ClampMeters(); // clamp max, target and unpaired meters to [DEFAULT_VALUE, LARGE_VALUE] and active meters with max meters to [DEFAULT_VALUE, max] } @@ -1042,10 +1038,16 @@ if (objects_vec.empty()) return; - for (std::vector<int>::const_iterator obj_it = objects_vec.begin(); obj_it != objects_vec.end(); ++obj_it) { - int obj_id = *obj_it; - TemporaryPtr<UniverseObject> obj = m_objects.Object(obj_id); + // get all pointers to objects once, to avoid having to do so repeatedly + // when iterating over the list in the following code + std::vector<TemporaryPtr<UniverseObject> > object_ptrs = m_objects.FindObjects(objects_vec); + for (std::vector<TemporaryPtr<UniverseObject> >::iterator obj_it = object_ptrs.begin(); + obj_it != object_ptrs.end(); ++obj_it) + { + TemporaryPtr<UniverseObject> obj = *obj_it; + int obj_id = obj->ID(); + // Reset max meters to DEFAULT_VALUE and current meters to initial value at start of this turn obj->ResetTargetMaxUnpairedMeters(); obj->ResetPairedActiveMeters(); @@ -1059,7 +1061,7 @@ info.meter_change = meter->Current() - Meter::DEFAULT_VALUE; info.running_meter_total = meter->Current(); - if (info.meter_change > 0.0) + if (info.meter_change > 0.0f) m_effect_accounting_map[obj_id][type].push_back(info); } } @@ -1067,10 +1069,9 @@ if (GetOptionsDB().Get<bool>("verbose-logging")) { Logger().debugStream() << "UpdateMeterEstimatesImpl after resetting meters objects:"; - for (std::vector<int>::const_iterator it = objects_vec.begin(); it != objects_vec.end(); ++it) { - if (TemporaryPtr<const UniverseObject> obj = GetUniverseObject(*it)) - Logger().debugStream() << obj->Dump(); - } + for (std::vector<TemporaryPtr<UniverseObject> >::iterator obj_it = object_ptrs.begin(); + obj_it != object_ptrs.end(); ++obj_it) + { Logger().debugStream() << (*obj_it)->Dump(); } } // cache all activation and scoping condition results before applying Effects, since the application of @@ -1083,19 +1084,20 @@ if (GetOptionsDB().Get<bool>("verbose-logging")) { Logger().debugStream() << "UpdateMeterEstimatesImpl after executing effects objects:"; - for (std::vector<int>::const_iterator it = objects_vec.begin(); it != objects_vec.end(); ++it) { - if (TemporaryPtr<const UniverseObject> obj = GetUniverseObject(*it)) - Logger().debugStream() << obj->Dump(); - } + for (std::vector<TemporaryPtr<UniverseObject> >::iterator obj_it = object_ptrs.begin(); + obj_it != object_ptrs.end(); ++obj_it) + { Logger().debugStream() << (*obj_it)->Dump(); } } // Apply known discrepancies between expected and calculated meter maxes at start of turn. This // accounts for the unknown effects on the meter, and brings the estimate in line with the actual // max at the start of the turn if (!m_effect_discrepancy_map.empty()) { - for (std::vector<int>::const_iterator obj_it = objects_vec.begin(); obj_it != objects_vec.end(); ++obj_it) { - int obj_id = *obj_it; - TemporaryPtr<UniverseObject> obj = m_objects.Object(obj_id); + for (std::vector<TemporaryPtr<UniverseObject> >::iterator obj_it = object_ptrs.begin(); + obj_it != object_ptrs.end(); ++obj_it) + { + TemporaryPtr<UniverseObject> obj = *obj_it; + int obj_id = obj->ID(); // check if this object has any discrepancies Effect::DiscrepancyMap::iterator dis_it = m_effect_discrepancy_map.find(obj_id); @@ -1134,19 +1136,20 @@ } // clamp meters to valid range of max values, and so current is less than max - for (std::vector<int>::const_iterator obj_it = objects_vec.begin(); obj_it != objects_vec.end(); ++obj_it) { + for (std::vector<TemporaryPtr<UniverseObject> >::iterator obj_it = object_ptrs.begin(); + obj_it != object_ptrs.end(); ++obj_it) + { // currently this clamps all meters, even if not all meters are being processed by this function... // but that shouldn't be a problem, as clamping meters that haven't changed since they were last // updated should have no effect - m_objects.Object(*obj_it)->ClampMeters(); + (*obj_it)->ClampMeters(); } if (GetOptionsDB().Get<bool>("verbose-logging")) { Logger().debugStream() << "UpdateMeterEstimatesImpl after discrepancies and clamping objects:"; - for (std::vector<int>::const_iterator it = objects_vec.begin(); it != objects_vec.end(); ++it) { - if (TemporaryPtr<const UniverseObject> obj = GetUniverseObject(*it)) - Logger().debugStream() << obj->Dump(); - } + for (std::vector<TemporaryPtr<UniverseObject> >::iterator obj_it = object_ptrs.begin(); + obj_it != object_ptrs.end(); ++obj_it) + { Logger().debugStream() << (*obj_it)->Dump(); } } } @@ -1176,22 +1179,16 @@ return; // transfer target objects from input vector to a set - Effect::TargetSet all_potential_targets; - all_potential_targets.reserve(target_objects.size()); - for (std::vector<int>::const_iterator it = target_objects.begin(); it != target_objects.end(); ++it) - all_potential_targets.push_back(m_objects.Object(*it)); + Effect::TargetSet all_potential_targets = m_objects.FindObjects(target_objects); if (GetOptionsDB().Get<bool>("verbose-logging")) { Logger().debugStream() << "target objects:"; - for (std::vector<int>::const_iterator it = target_objects.begin(); it != target_objects.end(); ++it) { - if (TemporaryPtr<const UniverseObject> obj = GetUniverseObject(*it)) - Logger().debugStream() << obj->Dump(); - } + for (Effect::TargetSet::const_iterator it = all_potential_targets.begin(); + it != all_potential_targets.end(); ++it) + { Logger().debugStream() << (*it)->Dump(); } } - boost::timer type_timer; - // caching space for each source object's results of finding matches for // scope conditions. Index INVALID_OBJECT_ID stores results for // source-invariant conditions @@ -1201,6 +1198,9 @@ cached_source_condition_matches[INVALID_OBJECT_ID]; + boost::timer type_timer; + + // 1) EffectsGroups from Species if (GetOptionsDB().Get<bool>("verbose-logging")) Logger().debugStream() << "Universe::GetEffectsAndTargets for SPECIES"; |
From: <geo...@us...> - 2013-11-28 11:18:59
|
Revision: 6547 http://sourceforge.net/p/freeorion/code/6547 Author: geoffthemedio Date: 2013-11-28 11:18:56 +0000 (Thu, 28 Nov 2013) Log Message: ----------- Minor tweaks to GetConditionMatches (used for caching results). Modified Paths: -------------- trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2013-11-28 11:17:35 UTC (rev 6546) +++ trunk/FreeOrion/universe/Universe.cpp 2013-11-28 11:18:56 UTC (rev 6547) @@ -1425,6 +1425,8 @@ } namespace { + Effect::TargetSet EMPTY_TARGET_SET; + Effect::TargetSet& GetConditionMatches(const Condition::ConditionBase* cond, std::map<const Condition::ConditionBase*, Effect::TargetSet>& cached_condition_matches, @@ -1433,8 +1435,11 @@ Effect::TargetSet& target_objects) { if (!cond) - return cached_condition_matches[0]; // empty TargetSet + return EMPTY_TARGET_SET; + // have to iterate through cached condition matches, rather than using + // find, since there is no operator< for comparing conditions by value + // and by pointer is irrelivant. for (std::map<const Condition::ConditionBase*, Effect::TargetSet>::iterator it = cached_condition_matches.begin(); it != cached_condition_matches.end(); ++it) { |
From: <ve...@us...> - 2014-01-06 13:11:00
|
Revision: 6610 http://sourceforge.net/p/freeorion/code/6610 Author: vezzra Date: 2014-01-06 13:10:56 +0000 (Mon, 06 Jan 2014) Log Message: ----------- changes missing in previous commit Modified Paths: -------------- trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2014-01-06 13:09:57 UTC (rev 6609) +++ trunk/FreeOrion/universe/Universe.cpp 2014-01-06 13:10:56 UTC (rev 6610) @@ -789,6 +789,7 @@ if (ship_design) { if (m_last_allocated_design_id + 1 < MAX_ID) { m_ship_designs[++m_last_allocated_design_id] = ship_design; + ship_design->SetID(m_last_allocated_design_id); retval = m_last_allocated_design_id; } else { // we'll probably never execute this branch, considering how many IDs are available // find a hole in the assigned IDs in which to place the object @@ -796,6 +797,7 @@ for (ShipDesignMap::iterator it = m_ship_designs.begin(); it != m_ship_designs.end(); ++it) { if (1 < it->first - last_id_seen) { m_ship_designs[last_id_seen + 1] = ship_design; + ship_design->SetID(last_id_seen + 1); retval = last_id_seen + 1; break; } |
From: <dil...@us...> - 2014-02-17 23:32:51
|
Revision: 6915 http://sourceforge.net/p/freeorion/code/6915 Author: dilvish-fo Date: 2014-02-17 23:32:45 +0000 (Mon, 17 Feb 2014) Log Message: ----------- fix by cami for a bug in the Universe jump distance calculations Modified Paths: -------------- trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2014-02-17 19:32:33 UTC (rev 6914) +++ trunk/FreeOrion/universe/Universe.cpp 2014-02-17 23:32:45 UTC (rev 6915) @@ -788,11 +788,12 @@ // threads waiting for the same row will see a cache hit typedef boost::iterator_property_map<std::vector<short>::iterator, boost::identity_property_map> DistancePropertyMap; - std::vector<short> private_distance_buffer(m_system_jumps.size()); + std::vector<short> private_distance_buffer(m_system_jumps.size(), SHRT_MAX); DistancePropertyMap distance_property_map(private_distance_buffer.begin()); boost::distance_recorder<DistancePropertyMap, boost::on_tree_edge> distance_recorder(distance_property_map); // FIXME: dont compute m_system_jumps[i][j] again as m_system_jumps[j][i] + private_distance_buffer[smaller_index] = 0; boost::breadth_first_search(m_graph_impl->system_graph, smaller_index, boost::visitor(boost::make_bfs_visitor(distance_recorder))); jumps = private_distance_buffer[other_index]; cache.swap_and_unlock_row(smaller_index, private_distance_buffer, cache_guard); |
From: <geo...@us...> - 2014-04-03 16:12:49
|
Revision: 7009 http://sourceforge.net/p/freeorion/code/7009 Author: geoffthemedio Date: 2014-04-03 16:12:44 +0000 (Thu, 03 Apr 2014) Log Message: ----------- Modified Universe::RecursiveDestroy to remove a destroyed system from all other systems' starlanes. This prevents a crash when reinitializaing the system graphs on the server after executing effects in which a system is destroyed. Modified Paths: -------------- trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2014-04-02 12:55:40 UTC (rev 7008) +++ trunk/FreeOrion/universe/Universe.cpp 2014-04-03 16:12:44 UTC (rev 7009) @@ -3196,7 +3196,18 @@ Destroy(*it); retval.insert(*it); } - // then system itself + + // remove any starlane connections to this system + int this_sys_id = obj_system->ID(); + std::vector<TemporaryPtr<System> > all_systems = m_objects.FindObjects<System>(); + for (std::vector<TemporaryPtr<System> >::iterator sys_it = all_systems.begin(); + sys_it != all_systems.end(); ++sys_it) + { + TemporaryPtr<System> sys = *sys_it; + sys->RemoveStarlane(this_sys_id); + } + + // then destroy system itself Destroy(object_id); retval.insert(object_id); // don't need to bother with removing things from system, fleets, or |
From: <geo...@us...> - 2014-04-03 19:54:52
|
Revision: 7010 http://sourceforge.net/p/freeorion/code/7010 Author: geoffthemedio Date: 2014-04-03 19:54:49 +0000 (Thu, 03 Apr 2014) Log Message: ----------- Made destroying a system also destroy fleets moving on connected starlanes. Modified Paths: -------------- trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2014-04-03 16:12:44 UTC (rev 7009) +++ trunk/FreeOrion/universe/Universe.cpp 2014-04-03 19:54:49 UTC (rev 7010) @@ -3207,6 +3207,17 @@ sys->RemoveStarlane(this_sys_id); } + // remove fleets / ships moving along destroyed starlane + std::vector<TemporaryPtr<Fleet> > all_fleets = m_objects.FindObjects<Fleet>(); + for (std::vector<TemporaryPtr<Fleet> >::iterator flt_it = all_fleets.begin(); + flt_it != all_fleets.end(); ++flt_it) + { + TemporaryPtr<Fleet> fleet = *flt_it; + if (fleet->NextSystemID() == this_sys_id || + fleet->PreviousSystemID() == this_sys_id) + { RecursiveDestroy(fleet->ID()); } + } + // then destroy system itself Destroy(object_id); retval.insert(object_id); |
From: <geo...@us...> - 2014-04-03 20:09:02
|
Revision: 7011 http://sourceforge.net/p/freeorion/code/7011 Author: geoffthemedio Date: 2014-04-03 20:08:59 +0000 (Thu, 03 Apr 2014) Log Message: ----------- Additional safety check to make sure only fleets outside systems are destroyed when systems connected to lanes are destroyed. Modified Paths: -------------- trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2014-04-03 19:54:49 UTC (rev 7010) +++ trunk/FreeOrion/universe/Universe.cpp 2014-04-03 20:08:59 UTC (rev 7011) @@ -3213,8 +3213,9 @@ flt_it != all_fleets.end(); ++flt_it) { TemporaryPtr<Fleet> fleet = *flt_it; - if (fleet->NextSystemID() == this_sys_id || - fleet->PreviousSystemID() == this_sys_id) + if (fleet->SystemID() == INVALID_OBJECT_ID && ( + fleet->NextSystemID() == this_sys_id || + fleet->PreviousSystemID() == this_sys_id)) { RecursiveDestroy(fleet->ID()); } } |
From: <geo...@us...> - 2014-08-09 09:21:22
|
Revision: 7422 http://sourceforge.net/p/freeorion/code/7422 Author: geoffthemedio Date: 2014-08-09 09:21:19 +0000 (Sat, 09 Aug 2014) Log Message: ----------- Made design serialization always include monster designs. Modified Paths: -------------- trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2014-08-09 08:53:30 UTC (rev 7421) +++ trunk/FreeOrion/universe/Universe.cpp 2014-08-09 09:21:19 UTC (rev 7422) @@ -3474,6 +3474,14 @@ } else { designs_to_serialize.clear(); + // add generic monster ship designs so they always appear in players' pedias + for (ShipDesignMap::const_iterator it = m_ship_designs.begin(); it != m_ship_designs.end(); ++it) { + ShipDesign* design = it->second; + if (design->IsMonster() && design->DesignedByEmpire() == ALL_EMPIRES) + designs_to_serialize[design->ID()] = design; + } + + // get empire's known ship designs std::map<int, std::set<int> >::const_iterator it = m_empire_known_ship_design_ids.find(encoding_empire); if (it == m_empire_known_ship_design_ids.end()) return; // no known designs to serialize |