Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Made Independent faction have light pink text!

Correct the distance calculation.
Also fix a crash I'd missed earlier.
  • Loading branch information...
commit 33927d8d4fd854729c88f4349b84fc217e643c99 1 parent 5681b0a
Andrew Copland authored
Showing with 11 additions and 10 deletions.
  1. +1 −0  data/factions/00_default.lua
  2. +7 −7 src/Factions.cpp
  3. +3 −3 src/Polit.cpp
1  data/factions/00_default.lua
View
@@ -5,5 +5,6 @@ local f = Faction:new('Independent')
:expansionRate(2.0)
:military_name('Independent Space Fleet')
:police_name('Police')
+ :colour(1.0,0.71,0.76) -- 255, 182, 193
f:add_to_factions('Independent')
14 src/Factions.cpp
View
@@ -314,7 +314,6 @@ const Uint32 Faction::GetNumFactions()
const Uint32 Faction::GetNearestFactionIndex(const SystemPath& sysPath)
{
// Iterate through all of the factions and find the one nearest to the system we're checking it against.
- const vector3f sysPos(sysPath.sectorX, sysPath.sectorY, sysPath.sectorZ);
const Faction *pFoundFaction = nullptr;
Sint32 nearestDistance = INT_MAX;
@@ -346,14 +345,15 @@ const Uint32 Faction::GetNearestFactionIndex(const SystemPath& sysPath)
}
// get the distance
- const vector3f hm(ptr->homeworld.sectorX, ptr->homeworld.sectorY, ptr->homeworld.sectorZ);
- const Sint32 distance = (sysPos - hm).Length();
-
- //
- double radius = (current_year - ptr->foundingDate) * ptr->expansionRate;
+ const Sector sec1(ptr->homeworld.sectorX, ptr->homeworld.sectorY, ptr->homeworld.sectorZ);
+ const Sector sec2(sysPath.sectorX, sysPath.sectorY, sysPath.sectorZ);
+ const double distance = Sector::DistanceBetween(&sec1, ptr->homeworld.systemIndex, &sec2, sysPath.systemIndex);
+ // calculate the current radius the faction occupies
+ const double facRadius = (current_year - ptr->foundingDate) * ptr->expansionRate;
+
// check we've found a closer faction
- if( distance <= radius && distance < nearestDistance ) {
+ if( (distance <= facRadius) && (distance < nearestDistance) ) {
nearestDistance = distance;
pFoundFaction = ptr;
ret_index = index;
6 src/Polit.cpp
View
@@ -245,9 +245,9 @@ bool IsCommodityLegal(const StarSystem *s, const Equip::Type t)
if (a == GOV_NONE) return true;
const Uint32 b = s_govDesc[a].faction;
- const Faction *ptr = Faction::GetFaction( b );
-
- if( b != UINT_MAX && ptr ) {
+ if( b != UINT_MAX ) {
+ const Faction *ptr = Faction::GetFaction( b );
+ assert(ptr);
Faction::EquipProbMap::const_iterator iter = ptr->equip_legality.find(t);
if( iter != ptr->equip_legality.end() ) {
Faction::ProbEqualityPair per = (*iter).second;
Please sign in to comment.
Something went wrong with that request. Please try again.