From: Anders R. <ma...@us...> - 2007-04-04 21:21:49
|
Update of /cvsroot/planeshift/planeshift/src/npcclient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14836/src/npcclient Modified Files: npcclient.cpp Log Message: - Fixed wrong calculation of limits for locate operations in npc client. Index: npcclient.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/npcclient/npcclient.cpp,v retrieving revision 1.141 retrieving revision 1.142 diff -C2 -d -r1.141 -r1.142 *** npcclient.cpp 4 Apr 2007 18:41:02 -0000 1.141 --- npcclient.cpp 4 Apr 2007 21:21:49 -0000 1.142 *************** *** 1326,1331 **** if (found) { ! float min_range = range*range; // Working with Squared values ! if (range == -1) min_range = -1; // -1*-1 = 1, will use -1 later int min_i = -1; --- 1326,1330 ---- if (found) { ! float min_range = range; int min_i = -1; *************** *** 1343,1347 **** if (min_i > -1) // found closest one { ! if (found_range) *found_range = sqrt(min_range); return found->locs[(size_t)min_i]; --- 1342,1346 ---- if (min_i > -1) // found closest one { ! if (found_range) *found_range = min_range; return found->locs[(size_t)min_i]; *************** *** 1362,1373 **** if (found) { - float min_range = range*range; // Working with Squared values - if (range == -1) min_range = -1; // -1*-1 = 1, will use -1 later - for (size_t i=0; i<found->locs.GetSize(); i++) { float dist2 = GetWorld()->Distance(pos,sector,found->locs[i]->pos,found->locs[i]->GetSector(engine)); ! if (min_range < 0 || dist2 < min_range) { nearby.Push(found->locs[i]); --- 1361,1369 ---- if (found) { for (size_t i=0; i<found->locs.GetSize(); i++) { float dist2 = GetWorld()->Distance(pos,sector,found->locs[i]->pos,found->locs[i]->GetSector(engine)); ! if (range < 0 || dist2 < range) { nearby.Push(found->locs[i]); *************** *** 1393,1398 **** Waypoint *wp; ! float min_range = range*range; // Working with Squared values ! if (range == -1) min_range = -1; // -1*-1 = 1, will use -1 later Waypoint *min_wp = NULL; --- 1389,1393 ---- Waypoint *wp; ! float min_range = range; Waypoint *min_wp = NULL; *************** *** 1408,1412 **** } } ! if (min_wp && found_range) *found_range = sqrt(min_range); return min_wp; --- 1403,1407 ---- } } ! if (min_wp && found_range) *found_range = min_range; return min_wp; *************** *** 1421,1432 **** csArray<float> dist; - float min_range = range*range; // Working with Squared values - if (range == -1) min_range = -1; // -1*-1 = 1, will use -1 later - for (wp = iter.First(); wp; wp = ++iter) { float dist2 = GetWorld()->Distance(v,sector,wp->loc.pos,wp->GetSector(engine)); ! if (min_range < 0 || dist2 < min_range) { nearby.Push(wp); --- 1416,1424 ---- csArray<float> dist; for (wp = iter.First(); wp; wp = ++iter) { float dist2 = GetWorld()->Distance(v,sector,wp->loc.pos,wp->GetSector(engine)); ! if (range < 0 || dist2 < range) { nearby.Push(wp); *************** *** 1858,1862 **** LocationPerception pcpt_sensed("location sensed",loc->name, loc->locs[i]); ! TriggerEvent(NULL, &pcpt_sensed, LONG_RANGE_PERCEPTION, &loc->locs[i]->pos, loc->locs[i]->GetSector(engine)); // Broadcast } } --- 1850,1855 ---- LocationPerception pcpt_sensed("location sensed",loc->name, loc->locs[i]); ! TriggerEvent(NULL, &pcpt_sensed, loc->locs[i]->radius + LONG_RANGE_PERCEPTION, ! &loc->locs[i]->pos, loc->locs[i]->GetSector(engine)); // Broadcast } } |