rem: (pStr - pPSD->MineralText[1].pStr) - 1;
add: utf8StringCountN( pPSD->MineralText[1].pStr, pStr - 1);
context: CheckObjectCollision (COUNT index){	INTERSECT_CONTROL LanderControl;	MEM_HANDLE LanderHandle;	PPRIMITIVE pPrim, pLanderPrim;	PPLANETSIDE_DESC pPSD;	if (index != END_OF_LIST)	{		pLanderPrim = &DisplayArray[index];		LanderControl.IntersectStamp = pLanderPrim->Object.Stamp;		index = GetPredLink (GetPrimLinks (pLanderPrim));	}	else	{		pLanderPrim = 0;		LanderControl.IntersectStamp.origin.x = SURFACE_WIDTH >> 1;		LanderControl.IntersectStamp.origin.y = SURFACE_HEIGHT >> 1;		LanderControl.IntersectStamp.frame = LanderFrame[0];		index = GetSuccLink (DisplayLinks);	}	pPSD = (PPLANETSIDE_DESC)pMenuState->ModuleFrame;	LanderControl.EndPoint = LanderControl.IntersectStamp.origin;	LanderHandle = GetFrameHandle (LanderControl.IntersectStamp.frame);	for (; index != END_OF_LIST; index = GetPredLink (GetPrimLinks (pPrim)))	{		INTERSECT_CONTROL ElementControl;		HELEMENT hElement, hNextElement;		pPrim = &DisplayArray[index];		ElementControl.IntersectStamp = pPrim->Object.Stamp;		ElementControl.EndPoint = ElementControl.IntersectStamp.origin;		if (GetFrameHandle (ElementControl.IntersectStamp.frame)				== LanderHandle)		{			CheckObjectCollision (index);			continue;		}		if (!DrawablesIntersect (&LanderControl,				&ElementControl, MAX_TIME_VALUE))			continue;		for (hElement = GetHeadElement (); hElement; hElement = hNextElement)		{			ELEMENTPTR ElementPtr;			LockElement (hElement, &ElementPtr);			hNextElement = GetSuccElement (ElementPtr);			if (&DisplayArray[ElementPtr->PrimIndex] == pLanderPrim)			{				ElementPtr->state_flags |= DISAPPEARING;				UnlockElement (hElement);				continue;			}						if (&DisplayArray[ElementPtr->PrimIndex] != pPrim					|| !(ElementPtr->state_flags & BAD_GUY))			{				UnlockElement (hElement);				continue;			}			{				COUNT scan, NumRetrieved;				SIZE which_node;				scan = LOBYTE (ElementPtr->life_span);				if (pLanderPrim == 0)				{					if (HIBYTE (pMenuState->delta_item) == 0							|| pPSD->InTransit)						break;					if (ElementPtr->state_flags & FINITE_LIFE)					{						/* A natural disaster */						scan = ElementPtr->mass_points;						switch (scan)						{							case EARTHQUAKE_DISASTER:							case LAVASPOT_DISASTER:								if ((BYTE)TFB_Random () < (256 >> 2))									DeltaLanderCrew (-1, scan);								break;						}						UnlockElement (hElement);						continue;					}					else if (scan == ENERGY_SCAN)					{						if (ElementPtr->mass_points == 1)						{							DWORD TimeIn;							/* Ran into Spathi on Pluto */							TimeIn = GetTimeCounter ();							which_node = 8;							do							{								DeltaLanderCrew (-1, LANDER_INJURED);								SleepThreadUntil (TimeIn + ONE_SECOND / 20);								TimeIn = GetTimeCounter();							} while (HIBYTE (pMenuState->delta_item) && --which_node);						}						if (HIBYTE (pMenuState->delta_item)								&& pSolarSysState->SysInfo.PlanetInfo.DiscoveryString								&& CurStarDescPtr->Index != ANDROSYNTH_DEFINED)						{							UnbatchGraphics ();							DoDiscoveryReport (MenuSounds);							BatchGraphics ();						}						if (ElementPtr->mass_points == 0)						{							DestroyStringTable (ReleaseStringTable (									pSolarSysState->SysInfo.PlanetInfo.DiscoveryString									));							pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0;							UnlockElement (hElement);							continue;						}					}					else if (scan == BIOLOGICAL_SCAN							&& ElementPtr->hit_points)					{						BYTE danger_vals[] =						{							0, 6, 13, 26						};						int creatureIndex = ElementPtr->mass_points								& ~CREATURE_AWARE;						int dangerLevel =								(CreatureData[creatureIndex].Attributes &								DANGER_MASK) >> DANGER_SHIFT;						if (((COUNT)TFB_Random () & 127) <								danger_vals[dangerLevel])						{							PlaySound (SetAbsSoundIndex (									LanderSounds, BIOLOGICAL_DISASTER									), NotPositional (), NULL, GAME_SOUND_PRIORITY);							DeltaLanderCrew (-1, BIOLOGICAL_DISASTER);						}						UnlockElement (hElement);						continue;					}					NumRetrieved = ElementPtr->mass_points;				}					/* if a natural disaster */				else if (ElementPtr->state_flags & FINITE_LIFE)				{					UnlockElement (hElement);					continue;				}				else				{					BYTE value;					if (scan == ENERGY_SCAN)					{						UnlockElement (hElement);						break;					}					else if (scan == BIOLOGICAL_SCAN							&& (value = LONIBBLE (CreatureData[							ElementPtr->mass_points							& ~CREATURE_AWARE							].ValueAndHitPoints)))					{						if (ElementPtr->hit_points)						{							if (--ElementPtr->hit_points == 0)							{								ElementPtr->mass_points = value;								DisplayArray[										ElementPtr->PrimIndex										].Object.Stamp.frame =										pSolarSysState->PlanetSideFrame[0];							}							else if (CreatureData[									ElementPtr->mass_points									& ~CREATURE_AWARE									].Attributes & SPEED_MASK)							{								COUNT angle;								angle = FACING_TO_ANGLE (GetFrameIndex (										LanderControl.IntersectStamp.frame										) - ANGLE_TO_FACING (FULL_CIRCLE));								DeltaVelocityComponents (										&ElementPtr->velocity,										COSINE (angle, WORLD_TO_VELOCITY (1)),										SINE (angle, WORLD_TO_VELOCITY (1))										);								ElementPtr->thrust_wait = 0;								ElementPtr->mass_points |= CREATURE_AWARE;							}							SetPrimType (pPrim, STAMPFILL_PRIM);							SetPrimColor (pPrim, WHITE_COLOR);							PlaySound (SetAbsSoundIndex (									LanderSounds, LANDER_HITS),									NotPositional (), NULL,									GAME_SOUND_PRIORITY);						}						UnlockElement (hElement);						break;					}					NumRetrieved = 0;				}				if (NumRetrieved)				{					switch (scan)					{						case ENERGY_SCAN:							break;						case MINERAL_SCAN:							if (pPSD->ElementLevel < pPSD->MaxElementLevel)							{								if (pPSD->ElementLevel										+ NumRetrieved > pPSD->MaxElementLevel)									NumRetrieved = (COUNT)(pPSD->MaxElementLevel											- pPSD->ElementLevel);								FillLanderHold (pPSD, scan, NumRetrieved);								if (scan == MINERAL_SCAN)								{									BYTE EType;									UNICODE ch, *pStr;									EType = ElementPtr->turn_wait;									pPSD->ElementAmounts[											ElementCategory (EType)											] += NumRetrieved;									pPSD->NumFrames = NUM_TEXT_FRAMES;									wsprintf (pPSD->AmountBuf, "%u", NumRetrieved);									pStr = GAME_STRING (EType + ELEMENTS_STRING_BASE);									pPSD->MineralText[0].baseline.x =											(SURFACE_WIDTH >> 1)											+ (ElementControl.EndPoint.x											- LanderControl.EndPoint.x);									pPSD->MineralText[0].baseline.y =											(SURFACE_HEIGHT >> 1)											+ (ElementControl.EndPoint.y											- LanderControl.EndPoint.y);									pPSD->MineralText[0].CharCount = (COUNT)~0;									pPSD->MineralText[1].pStr = pStr;									while ((ch = *pStr++) && ch != ' ')										;									if (ch == '\0')									{										pPSD->MineralText[1].CharCount = (COUNT)~0;										pPSD->MineralText[2].CharCount = 0;									}									else									{										pPSD->MineralText[1].CharCount =												(pStr - pPSD->MineralText[1].pStr) - 1;										pPSD->MineralText[2].pStr = pStr;										pPSD->MineralText[2].CharCount = (COUNT)~0;									}								}								break;							}							PlaySound (SetAbsSoundIndex (									LanderSounds, LANDER_FULL									), NotPositional (), NULL, GAME_SOUND_PRIORITY);							continue;						case BIOLOGICAL_SCAN:							if (pPSD->BiologicalLevel < MAX_SCROUNGED)							{								if (pPSD->BiologicalLevel										+ NumRetrieved > MAX_SCROUNGED)									NumRetrieved = (COUNT)(											MAX_SCROUNGED											- pPSD->BiologicalLevel											);								FillLanderHold (pPSD, scan, NumRetrieved);								break;							}							PlaySound (SetAbsSoundIndex (									LanderSounds, LANDER_FULL									), NotPositional (), NULL, GAME_SOUND_PRIORITY);							continue;					}				}				which_node = HIBYTE (ElementPtr->life_span) - 1;				pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[scan] |=						(1L << which_node);				pSolarSysState->CurNode = (COUNT)~0;				(*pSolarSysState->GenFunc) ((BYTE)(scan + GENERATE_MINERAL));				if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[scan] &						(1L << which_node)))				{					if (DestroyStringTable (ReleaseStringTable (							pSolarSysState->SysInfo.PlanetInfo.DiscoveryString							)))						pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0;				}				else				{					if (NumRetrieved && scan == ENERGY_SCAN)						pPSD->InTransit = TRUE;					SET_GAME_STATE (PLANETARY_CHANGE, 1);					ElementPtr->state_flags |= DISAPPEARING;				}				UnlockElement (hElement);			}		}	}}