From aa1924d11d4d9b66e579c3043cf7175cedee37c1 Mon Sep 17 00:00:00 2001 From: avolkov Date: Wed, 18 Jan 2006 05:53:02 +0000 Subject: [PATCH] Fixed searching for clusters with no Alpha stars (Corvi) git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2191 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/planets/pstarmap.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/sc2/src/sc2code/planets/pstarmap.c b/sc2/src/sc2code/planets/pstarmap.c index 4d3715677..44aef6d99 100644 --- a/sc2/src/sc2code/planets/pstarmap.c +++ b/sc2/src/sc2code/planets/pstarmap.c @@ -878,6 +878,29 @@ SplitStarName (STAR_SEARCH_STATE *pSS) pSS->PrefixLen = utf8StringCount (pSS->Prefix); } +static int +GetFirstClusterStar (BYTE Postfix) +{ + int i; + int min = -1; + int min_pref = 1000; + STAR_DESCPTR SDPtr; + + for (i = 0, SDPtr = star_array; i < NUM_SOLAR_SYSTEMS; ++i, ++SDPtr) + { + if (SDPtr->Postfix != Postfix) + continue; + + if (SDPtr->Prefix < min_pref) + { + min_pref = SDPtr->Prefix; + min = i; + } + } + + return min; +} + static int FindNextStar (STAR_SEARCH_STATE *pSS, int from, BOOLEAN WithinClust) { @@ -920,8 +943,8 @@ FindNextStar (STAR_SEARCH_STATE *pSS, int from, BOOLEAN WithinClust) if (!pSS->Prefix) { // searching for cluster name only - // only return Alpha stars - if (SDPtr->Prefix == 1) + // return only the first stars in a cluster + if (i == GetFirstClusterStar (SDPtr->Postfix)) break; else continue;