Beispiel #1
0
void CSovereign::InitRelationships (void)

//	InitRelationships
//
//	Initialize relationships from XML element

	{
	int i;

	DeleteRelationships();

	if (m_pInitialRelationships)
		{
		for (i = 0; i < m_pInitialRelationships->GetContentElementCount(); i++)
			{
			CXMLElement *pRelDesc = m_pInitialRelationships->GetContentElement(i);
			CSovereign *pTarget = g_pUniverse->FindSovereign(pRelDesc->GetAttributeInteger(SOVEREIGN_ATTRIB));
			if (pTarget)
				{
				CString sDisposition = pRelDesc->GetAttribute(DISPOSITION_ATTRIB);
				if (strEquals(sDisposition, DISP_FRIEND))
					SetDispositionTowards(pTarget, dispFriend);
				else if (strEquals(sDisposition, DISP_NEUTRAL))
					SetDispositionTowards(pTarget, dispNeutral);
				else if (strEquals(sDisposition, DISP_ENEMY))
					SetDispositionTowards(pTarget, dispEnemy);
				}
			}
		}
	}
Beispiel #2
0
ALERROR CDeviceClass::ParseLinkedFireOptions (SDesignLoadCtx &Ctx, const CString &sDesc, DWORD *retdwOptions)

//	ParseLinkedFireOptions
//
//	Parses a linked-fire options string.

	{
	DWORD dwOptions = 0;

	if (sDesc.IsBlank())
		;
	else if (strEquals(sDesc, LINKED_FIRE_ALWAYS))
		dwOptions |= CDeviceClass::lkfAlways;
	else if (strEquals(sDesc, LINKED_FIRE_TARGET))
		dwOptions |= CDeviceClass::lkfTargetInRange;
	else if (strEquals(sDesc, LINKED_FIRE_ENEMY))
		dwOptions |= CDeviceClass::lkfEnemyInRange;
	else
		{
		Ctx.sError = strPatternSubst(CONSTLIT("Invalid linkedFire option: %s"), sDesc);
		return ERR_FAIL;
		}

	*retdwOptions = dwOptions;

	return NOERROR;
	}
Beispiel #3
0
BeamTypes CBeamEffectCreator::ParseBeamType (const CString &sValue)

//	ParseBeamType
//
//	Parses the beam type parameter

	{
	if (strEquals(sValue, BEAM_TYPE_LASER))
		return beamLaser;
	else if (strEquals(sValue, BEAM_TYPE_LIGHTNING))
		return beamLightning;
	else if (strEquals(sValue, BEAM_TYPE_LIGHTNING_BOLT))
		return beamLightningBolt;
	else if (strEquals(sValue, BEAM_TYPE_HEAVY_BLASTER))
		return beamHeavyBlaster;
	else if (strEquals(sValue, BEAM_TYPE_GREEN_PARTICLE))
		return beamGreenParticle;
	else if (strEquals(sValue, BEAM_TYPE_BLUE_PARTICLE))
		return beamBlueParticle;
	else if (strEquals(sValue, BEAM_TYPE_BLASTER))
		return beamBlaster;
	else if (strEquals(sValue, BEAM_TYPE_STAR_BLASTER))
		return beamStarBlaster;
	else if (strEquals(sValue, BEAM_TYPE_GREEN_LIGHTNING))
		return beamGreenLightning;
	else if (strEquals(sValue, BEAM_TYPE_PARTICLE))
		return beamParticle;
	else
		return beamUnknown;
	}
Beispiel #4
0
void CGameSettings::SetValue (int iOption, const CString &sValue, bool bSetSettings)

//	SetValue
//
//	Sets the boolean, integer, or string value of the option

	{
	switch (g_OptionData[iOption].iType)
		{
		case optionBoolean:
			m_Options[iOption].bValue = (strEquals(sValue, CONSTLIT("true")) || strEquals(sValue, CONSTLIT("on")) || strEquals(sValue, CONSTLIT("yes")));
			break;

		case optionInteger:
			m_Options[iOption].iValue = strToInt(sValue, 0);
			break;

		case optionString:
			m_Options[iOption].sValue = sValue;
			break;

		default:
			ASSERT(false);
		}

	//	Set the settings value, if appropriate

	if (bSetSettings)
		m_Options[iOption].sSettingsValue = sValue;
	}
Beispiel #5
0
ALERROR WriteModuleImages (CXMLElement *pModule, const CString &sFolder, CSymbolTable &Resources, CDataFile &Out)
	{
	ALERROR error;
	int i;

	for (i = 0; i < pModule->GetContentElementCount(); i++)
		{
		CXMLElement *pItem = pModule->GetContentElement(i);
		if (strEquals(pItem->GetTag(), TAG_IMAGES))
			{
			CString sSubFolder = pathAddComponent(sFolder, pItem->GetAttribute(ATTRIB_FOLDER));

			if (error = WriteModuleImages(pItem, sSubFolder, Resources, Out))
				return error;
			}
		else if (strEquals(pItem->GetTag(), TAG_IMAGE))
			{
			CString sFilename = pItem->GetAttribute(ATTRIB_BITMAP);
			if (!sFilename.IsBlank())
				{
				if (error = WriteResource(sFilename, sFolder, Resources, Out))
					continue;
				}

			sFilename = pItem->GetAttribute(ATTRIB_BITMASK);
			if (!sFilename.IsBlank())
				{
				if (error = WriteResource(sFilename, sFolder, Resources, Out))
					continue;
				}
			}
		}

	return NOERROR;
	}
Beispiel #6
0
void CTranscendenceWnd::OnCommandIntro (const CString &sCmd, void *pData)

//	OnCommandIntro
//
//	Handle commands from Reanimator, etc.

	{
	if (strEquals(sCmd, CMD_TOGGLE_MUSIC))
		{
		m_pTC->SetOptionBoolean(CGameSettings::noMusic, !m_pTC->GetOptionBoolean(CGameSettings::noMusic));
		SetMusicOption();
		}

	else if (strEquals(sCmd, CMD_TOGGLE_DEBUG))
		{
		m_pTC->GetModel().SetDebugMode(!m_pTC->GetModel().GetDebugMode());
		SetDebugOption();
		}

	else if (strEquals(sCmd, CMD_OPEN_NEWS))
		{
		if (!m_sNewsURL.IsBlank())
			sysOpenURL(m_sNewsURL);
		}
	}
Beispiel #7
0
ALERROR WriteSubModules (CTDBCompiler &Ctx, 
						 CXMLElement *pModule,
						 const CString &sFolder, 
						 CDataFile &Out)
	{
	int i, j;

	for (i = 0; i < pModule->GetContentElementCount(); i++)
		{
		CXMLElement *pItem = pModule->GetContentElement(i);

		if (strEquals(pItem->GetTag(), TAG_MODULES))
			{
			for (j = 0; j < pItem->GetContentElementCount(); j++)
				{
				CXMLElement *pDesc = pItem->GetContentElement(j);

				CString sFilename = pDesc->GetAttribute(ATTRIB_FILENAME);
				if (WriteModule(Ctx, sFilename, sFolder, Out) != NOERROR)
					continue;
				}
			}
		else if (strEquals(pItem->GetTag(), TAG_MODULE))
			{
			CString sFilename = pItem->GetAttribute(ATTRIB_FILENAME);
			if (WriteModule(Ctx, sFilename, sFolder, Out) != NOERROR)
				continue;
			}
		}

	return NOERROR;
	}
ALERROR CLoginSession::OnCommand (const CString &sCmd, void *pData)

//	OnCommand
//
//	Handle a command

	{
	if (strEquals(sCmd, CMD_ALL_TASKS_DONE))
		{
		StopPerformance(ID_CTRL_WAIT);
		ShowInitialDlg();
		}

	else if (strEquals(sCmd, CMD_CANCEL))
		CmdCancel();

	else if (strEquals(sCmd, CMD_REGISTER))
		CmdRegister();

	else if (strEquals(sCmd, CMD_REGISTER_COMPLETE))
		CmdRegisterComplete((CRegisterUserTask *)pData);

	else if (strEquals(sCmd, CMD_SIGN_IN))
		CmdSignIn();

	else if (strEquals(sCmd, CMD_SIGN_IN_COMPLETE))
		CmdSignInComplete((CSignInUserTask *)pData);

	else if (strEquals(sCmd, CMD_SWITCH_TO_LOGIN))
		{
		StopPerformance(ID_DLG_REGISTER);

		const CVisualPalette &VI = m_HI.GetVisuals();
		IAnimatron *pDlg;

		CreateDlgSignIn(VI, &pDlg);
		m_iCurrent = dlgSignIn;
		StartPerformance(pDlg, ID_DLG_SIGN_IN, CReanimator::SPR_FLAG_DELETE_WHEN_DONE);
		}

	else if (strEquals(sCmd, CMD_SWITCH_TO_REGISTER))
		{
		StopPerformance(ID_DLG_SIGN_IN);

		const CVisualPalette &VI = m_HI.GetVisuals();
		IAnimatron *pDlg;

		CreateDlgRegister(VI, &pDlg);
		m_iCurrent = dlgRegister;
		StartPerformance(pDlg, ID_DLG_REGISTER, CReanimator::SPR_FLAG_DELETE_WHEN_DONE);
		}

	else if (strEquals(sCmd, CMD_PASSWORD_RESET))
		CmdPasswordReset();

	else if (strEquals(sCmd, CMD_TOS))
		sysOpenURL(CONSTLIT("http://www.kronosaur.com/legal/TermsofService.html"));

	return NOERROR;
	}
Beispiel #9
0
ALERROR WriteModuleSounds (CTDBCompiler &Ctx, CXMLElement *pModule, const CString &sFolder, CDataFile &Out)
	{
	ALERROR error;
	int i;

	for (i = 0; i < pModule->GetContentElementCount(); i++)
		{
		CXMLElement *pItem = pModule->GetContentElement(i);
		if (strEquals(pItem->GetTag(), TAG_SOUNDS))
			{
			CString sSubFolder = pathAddComponent(sFolder, pItem->GetAttribute(ATTRIB_FOLDER));

			if (error = WriteModuleSounds(Ctx, pItem, sSubFolder, Out))
				return error;
			}
		else if (strEquals(pItem->GetTag(), TAG_SOUND))
			{
			CString sFilename = pItem->GetAttribute(ATTRIB_FILENAME);
			if (error = WriteResource(Ctx, sFilename, sFolder, false, Out))
				continue;
			}
		}

	return NOERROR;
	}
Beispiel #10
0
ALERROR CFlareEffectCreator::OnEffectCreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, const CString &sUNID)

//	OnEffectCreateFromXML
//
//	Initializes from XML

{
    CString sStyle = pDesc->GetAttribute(STYLE_ATTRIB);
    if (strEquals(sStyle, STYLE_FADING_BLAST))
        m_iStyle = styleFadingBlast;
    else if (strEquals(sStyle, STYLE_FLICKER))
        m_iStyle = styleFlicker;
    else if (sStyle.IsBlank() || strEquals(sStyle, STYLE_PLAIN))
        m_iStyle = stylePlain;
    else
    {
        Ctx.sError = strPatternSubst(CONSTLIT("Invalid Flare style: %s"), sStyle);
        return ERR_FAIL;
    }

    m_iRadius = pDesc->GetAttributeIntegerBounded(RADIUS_ATTRIB, 0, -1, 100);
    m_iLifetime = pDesc->GetAttributeIntegerBounded(LIFETIME_ATTRIB, 0, -1, 1);
    m_rgbPrimaryColor = ::LoadRGBColor(pDesc->GetAttribute(PRIMARY_COLOR_ATTRIB));

    CString sAttrib;
    if (pDesc->FindAttribute(SECONDARY_COLOR_ATTRIB, &sAttrib))
        m_rgbSecondaryColor = ::LoadRGBColor(sAttrib);
    else
        m_rgbSecondaryColor = m_rgbPrimaryColor;

    return NOERROR;
}
Beispiel #11
0
bool CReactorClass::FindDataField (const ReactorDesc &Desc, const CString &sField, CString *retsValue)

//	FindDataField
//
//	Finds a data field for the reactor desc.

	{
	if (strEquals(sField, FIELD_POWER))
		*retsValue = strFromInt(Desc.iMaxPower * 100);
	else if (strEquals(sField, FIELD_FUEL_CRITERIA))
		{
		if (Desc.pFuelCriteria)
			*retsValue = CItem::GenerateCriteria(*Desc.pFuelCriteria);
		else
			*retsValue = strPatternSubst(CONSTLIT("f L:%d-%d;"), Desc.iMinFuelLevel, Desc.iMaxFuelLevel);
		}
	else if (strEquals(sField, FIELD_FUEL_EFFICIENCY))
		*retsValue = strFromInt(Desc.iPowerPerFuelUnit);
	else if (strEquals(sField, FIELD_FUEL_CAPACITY))
		*retsValue = strFromInt(Desc.iMaxFuel / FUEL_UNITS_PER_STD_ROD);
	else
		return false;

	return true;
	}
void XKMSRecoverRequestImpl::load(void) {

	if (m_msg.mp_messageAbstractTypeElement == NULL) {

		// Attempt to load an empty element
		throw XSECException(XSECException::XKMSError,
			"XKMSRecoverRequest::load - called on empty DOM");

	}

	if (!strEquals(getXKMSLocalName(m_msg.mp_messageAbstractTypeElement), 
									XKMSConstants::s_tagRecoverRequest)) {
	
		throw XSECException(XSECException::XKMSError,
			"XKMSRecoverRequest::load - called on incorrect node");
	
	}

	// Load the base message
	m_request.load();

	// Now check for any RecoverKeyBinding elements
	DOMElement * tmpElt = findFirstElementChild(m_msg.mp_messageAbstractTypeElement);
	while (tmpElt != NULL && !strEquals(getXKMSLocalName(tmpElt), XKMSConstants::s_tagRecoverKeyBinding)) {
		tmpElt = findNextElementChild(tmpElt);
	}

	if (tmpElt != NULL) {

		XSECnew(mp_recoverKeyBinding, XKMSRecoverKeyBindingImpl(m_msg.mp_env, tmpElt));
		mp_recoverKeyBinding->load();

		tmpElt = findNextElementChild(tmpElt);

	}
	else {

		throw XSECException(XSECException::ExpectedXKMSChildNotFound,
			"XKMSRecoverRequest::load - Expected RecoverKeyBinding node");
	
	}

	// Authentication Element 

	if (tmpElt != NULL && strEquals(getXKMSLocalName(tmpElt), XKMSConstants::s_tagAuthentication)) {

		XSECnew(mp_authentication, XKMSAuthenticationImpl(m_msg.mp_env, tmpElt));
		mp_authentication->load(mp_recoverKeyBinding->getId());

	}
	else {

		throw XSECException(XSECException::ExpectedXKMSChildNotFound,
			"XKMSRecoverRequest::load - Expected Authentication node");
	
	}

}
Beispiel #13
0
END_TEST

START_TEST(test_strEquals)
{
    fail_unless(!strEquals("foo", "bar"), NULL);
    fail_unless(!strEquals("foo", NULL), NULL);
    fail_unless(strEquals("foo", "foo"), NULL);
    fail_unless(!strEquals("foo", "Foo"), NULL);
}
Beispiel #14
0
void CAeonView::CreateSecondaryData (const CTableDimensions &PrimaryDims, const CRowKey &PrimaryKey, CDatum dFullData, SEQUENCENUMBER RowID, CDatum *retdData)

//	CreateSecondaryData
//
//	Creates the data for a secondary view row.

	{
	int i, j;
	CComplexStruct *pData = new CComplexStruct;

	//	If the list of columns is empty then we just add the primary key

	if (m_Columns.GetCount() == 0)
		pData->SetElement(FIELD_PRIMARY_KEY, PrimaryKey.AsDatum(PrimaryDims));

	//	Otherwise we add all the fields listed in the columns array

	else
		{
		for (i = 0; i < m_Columns.GetCount(); i++)
			{
			//	The special string "primaryKey" means that we insert the 
			//	primary key as a special field.

			if (strEquals(m_Columns[i], FIELD_PRIMARY_KEY))
				pData->SetElement(FIELD_PRIMARY_KEY, PrimaryKey.AsDatum(PrimaryDims));

			//	The special string "*" means that we insert all existing
			//	fields.

			else if (strEquals(m_Columns[i], STR_ALL_COLUMNS))
				{
				for (j = 0; j < dFullData.GetCount(); j++)
					{
					CDatum dKey = dFullData.GetKey(j);
					CDatum dValue = dFullData.GetElement(j);

					if (!dValue.IsNil())
						pData->SetElement(dKey, dValue);
					}
				}

			//	Add the field by name.

			else
				{
				CDatum dColData = dFullData.GetElement(m_Columns[i]);
				if (!dColData.IsNil())
					pData->SetElement(m_Columns[i], dColData);
				}
			}
		}

	//	Done

	*retdData = CDatum(pData);
	}
Beispiel #15
0
ICCItem *CDeviceClass::GetItemProperty (CItemCtx &Ctx, const CString &sName)

//	GetItemProperty
//
//	Returns the item property. Subclasses should call this if they do not
//	understand the property.

	{
	CCodeChain &CC = g_pUniverse->GetCC();

	//	Get the device

	CInstalledDevice *pDevice = Ctx.GetDevice();

	//	Get the property

	if (strEquals(sName, PROPERTY_CAN_BE_DISABLED))
		return (pDevice ? CC.CreateBool(pDevice->CanBeDisabled(Ctx)) : CC.CreateBool(CanBeDisabled(Ctx)));

	else if (strEquals(sName, PROPERTY_ENABLED))
		return (pDevice ? CC.CreateBool(pDevice->IsEnabled()) : CC.CreateNil());

	else if (strEquals(sName, PROPERTY_POS))
		{
		if (pDevice == NULL)
			return CC.CreateNil();

		//	Create a list

		ICCItem *pResult = CC.CreateLinkedList();
		if (pResult->IsError())
			return pResult;

		CCLinkedList *pList = (CCLinkedList *)pResult;

		//	List contains angle, radius, and optional z

		pList->AppendInteger(CC, pDevice->GetPosAngle());
		pList->AppendInteger(CC, pDevice->GetPosRadius());
		if (pDevice->GetPosZ() != 0)
			pList->AppendInteger(CC, pDevice->GetPosZ());

		//	Done

		return pResult;
		}

	else if (strEquals(sName, PROPERTY_SECONDARY))
		return (pDevice ? CC.CreateBool(pDevice->IsSecondaryWeapon()) : CC.CreateNil());

	else if (m_pItemType)
		return CreateResultFromDataField(CC, m_pItemType->GetDataField(sName));

	else
		return CC.CreateNil();
	}
Beispiel #16
0
NS_IMETHODIMP ExternalWrapper::CanCallMethod(const nsIID * iid,
        const PRUnichar *methodName, char **_retval) {
    Debug::log(Debug::Spam) << "ExternalWrapper::CanCallMethod" << Debug::flush;
    if (strEquals(methodName, "connect") || strEquals(methodName, "init")) {
        *_retval = cloneAllAccess();
    } else {
        *_retval = nsnull;
    }
    return NS_OK;
}
Beispiel #17
0
ALERROR CSovereign::OnCreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)

//	OnCreateFromXML
//
//	Create from XML

	{
	int i;

	//	Initialize

	m_sName = pDesc->GetAttribute(CONSTLIT(g_NameAttrib));

	//	Alignment

	CString sAlignment = pDesc->GetAttribute(ALIGNMENT_ATTRIB);
	if (strEquals(sAlignment, CONSTRUCTIVE_CHAOS_ALIGN))
		m_iAlignment = alignConstructiveChaos;
	else if (strEquals(sAlignment, CONSTRUCTIVE_ORDER_ALIGN))
		m_iAlignment = alignConstructiveOrder;
	else if (strEquals(sAlignment, NEUTRAL_ALIGN))
		m_iAlignment = alignNeutral;
	else if (strEquals(sAlignment, DESTRUCTIVE_ORDER_ALIGN))
		m_iAlignment = alignDestructiveOrder;
	else if (strEquals(sAlignment, DESTRUCTIVE_CHAOS_ALIGN))
		m_iAlignment = alignDestructiveChaos;
	else
		return ERR_FAIL;

	//	Load language

	CXMLElement *pLanguage = pDesc->GetContentElementByTag(LANGUAGE_TAG);
	if (pLanguage)
		{
		int iCount = pLanguage->GetContentElementCount();
		for (i = 0; i < iCount; i++)
			{
			CXMLElement *pItem = pLanguage->GetContentElement(i);
			CString *pText = new CString(pItem->GetAttribute(TEXT_ATTRIB));
			DWORD dwID = pItem->GetAttributeInteger(ID_ATTRIB);
			if (dwID != 0)
				m_Language.AddEntry(dwID, pText);
			}
		}

	//	Load relationships

	m_pInitialRelationships = pDesc->GetContentElementByTag(RELATIONSHIPS_TAG);
	if (m_pInitialRelationships)
		m_pInitialRelationships = m_pInitialRelationships->OrphanCopy();

	//	Done

	return NOERROR;
	}
Beispiel #18
0
void OutputTable (SItemTableCtx &Ctx, const SItemTypeList &ItemList)
	{
	int i, j;

	if (ItemList.GetCount() == 0)
		return;

	//	Output each row

	for (i = 0; i < ItemList.GetCount(); i++)
		{
		CItemType *pType = ItemList[i];

		for (j = 0; j < Ctx.Cols.GetCount(); j++)
			{
			if (j != 0)
				printf("\t");

			const CString &sField = Ctx.Cols[j];

			//	Get the field value

			CString sValue;
			CItem Item(pType, 1);
			CItemCtx ItemCtx(Item);
			CCodeChainCtx CCCtx;

			ICCItem *pResult = Item.GetProperty(&CCCtx, ItemCtx, sField);

			if (pResult->IsNil())
				sValue = NULL_STR;
			else
				sValue = pResult->Print(&g_pUniverse->GetCC(), PRFLAG_NO_QUOTES | PRFLAG_ENCODE_FOR_DISPLAY);

			pResult->Discard(&g_pUniverse->GetCC());

			//	Format the value

			if (strEquals(sField, FIELD_AVERAGE_DAMAGE) || strEquals(sField, FIELD_POWER_PER_SHOT))
				printf("%.2f", strToInt(sValue, 0, NULL) / 1000.0);
			else if (strEquals(sField, FIELD_POWER))
				printf("%.1f", strToInt(sValue, 0, NULL) / 1000.0);
			else if (strEquals(sField, FIELD_TOTAL_COUNT))
				{
				SDesignTypeInfo *pInfo = Ctx.TotalCount.GetAt(pType->GetUNID());
				double rCount = (pInfo ? pInfo->rPerGameMeanCount : 0.0);
				printf("%.2f", rCount);
				}
			else
				printf(sValue.GetASCIIZPointer());
			}

		printf("\n");
		}
	}
Beispiel #19
0
END_TEST

START_TEST(test_strSplit)
{
    char *string;
    char **list;
    size_t size;

    string = strCreate();
    strCopy(string, "foo bar hurz furz");
    list = strSplit(" ", string, -1, &size);
    fail_unless(size == 4, NULL);
    fail_unless(strEquals(list[0], "foo"), NULL);
    fail_unless(strEquals(list[1], "bar"), NULL);
    fail_unless(strEquals(list[2], "hurz"), NULL);
    fail_unless(strEquals(list[3], "furz"), NULL);
    listFreeWithItems(list, &size);
    list = strSplit(" ", string, 0, &size);
    fail_unless(size == 0, NULL);
    listFreeWithItems(list, &size);
    list = strSplit(" ", string, 2, &size);
    fail_unless(size == 2, NULL);
    fail_unless(strEquals(list[0], "foo"), NULL);
    fail_unless(strEquals(list[1], "bar hurz furz"), NULL);
    listFreeWithItems(list, &size);
    strCopy(string, "foo bar hurz bar furz");
    list = strSplit("bar", string, 3, &size);
    fail_unless(size == 3, NULL);
    fail_unless(strEquals(list[0], "foo "), NULL);
    fail_unless(strEquals(list[1], " hurz "), NULL);
    fail_unless(strEquals(list[2], " furz"), NULL);
    listFreeWithItems(list, &size);
}
CString CPlayerGameStats::GetKeyEventStat (const CString &sStat, const CString &sNodeID, const CDesignTypeCriteria &Crit) const

//	GetKeyEventStat
//
//	Returns the given key event stat

	{
	int i;

	//	Get the list of stats

	TArray<SKeyEventStatsResult> List;
	if (!GetMatchingKeyEvents(sNodeID, Crit, &List))
		return NIL_VALUE;

	if (strEquals(sStat, OBJS_DESTROYED_STAT))
		{
		//	Mark the events that we're interested in

		for (i = 0; i < List.GetCount(); i++)
			List[i].bMarked = ((List[i].pStats->iType == eventEnemyDestroyedByPlayer) 
					|| (List[i].pStats->iType == eventFriendDestroyedByPlayer)
					|| (List[i].pStats->iType == eventMajorDestroyed));

		//	Done

		return GenerateKeyEventStat(List);
		}
	else if (strEquals(sStat, ENEMY_OBJS_DESTROYED_STAT))
		{
		//	Mark the events that we're interested in

		for (i = 0; i < List.GetCount(); i++)
			List[i].bMarked = (List[i].pStats->iType == eventEnemyDestroyedByPlayer);

		//	Done

		return GenerateKeyEventStat(List);
		}
	else if (strEquals(sStat, FRIENDLY_OBJS_DESTROYED_STAT))
		{
		//	Mark the events that we're interested in

		for (i = 0; i < List.GetCount(); i++)
			List[i].bMarked = (List[i].pStats->iType == eventFriendDestroyedByPlayer);

		//	Done

		return GenerateKeyEventStat(List);
		}
	else
		return NULL_STR;
	}
CSpaceObject *IDockScreenDisplay::EvalListSource (const CString &sString, CString *retsError)

//	EvalListSource
//
//	Returns the object from which we should display items

	{
	char *pPos = sString.GetPointer();

	//	See if we need to evaluate

	if (*pPos == '=')
		{
		CCodeChainCtx Ctx;
		Ctx.SetScreen(this);
		Ctx.SaveAndDefineSourceVar(m_pLocation);
		Ctx.SaveAndDefineDataVar(m_pData);

		ICCItem *pExp = Ctx.Link(sString, 1, NULL);

		ICCItem *pResult = Ctx.Run(pExp);	//	LATER:Event
		Ctx.Discard(pExp);

		if (pResult->IsError())
			{
			*retsError = pResult->GetStringValue();
			Ctx.Discard(pResult);
			return NULL;
			}

		//	Convert to an object pointer

		CSpaceObject *pSource;
		if (strEquals(pResult->GetStringValue(), DATA_FROM_PLAYER))
			pSource = m_pPlayer->GetShip();
		else if (strEquals(pResult->GetStringValue(), DATA_FROM_STATION)
				|| strEquals(pResult->GetStringValue(), DATA_FROM_SOURCE))
			pSource = m_pLocation;
		else
			pSource = Ctx.AsSpaceObject(pResult);

		Ctx.Discard(pResult);
		return pSource;
		}

	//	Otherwise, compare to constants

	else if (strEquals(sString, DATA_FROM_PLAYER))
		return m_pPlayer->GetShip();
	else
		return m_pLocation;
	}
Beispiel #22
0
void CAniRichText::OnPropertyChanged (const CString &sName)

//	OnPropertyChanged
//
//	Property has changed

	{
	if (strEquals(sName, PROP_TEXT) 
			|| strEquals(sName, PROP_SCALE) 
			|| strEquals(sName, PROP_TEXT_ALIGN_HORZ)
			|| strEquals(sName, PROP_TEXT_ALIGN_VERT))
		m_bInvalid = true;
	}
ALERROR CDesignCollection::LoadEntryFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, CDesignType **retpType)

//	LoadEntryFromXML
//
//	Load an entry into the collection

	{
	ALERROR error;

	//	Load topology

	if (strEquals(pDesc->GetTag(), STAR_SYSTEM_TOPOLOGY_TAG)
			|| strEquals(pDesc->GetTag(), SYSTEM_TOPOLOGY_TAG))
		{
		if (Ctx.pExtension)
			//	If we're in an extension (Adventure) then load into the extension
			error = Ctx.pExtension->Topology.LoadFromXML(Ctx, pDesc, NULL_STR);
		else
			//	Otherwise, load into the base game
			error = m_BaseTopology.LoadFromXML(Ctx, pDesc, NULL_STR);

		if (error)
			return error;

		//	There is no type for topologies

		if (retpType)
			*retpType = NULL;
		}

	//	Load standard design elements

	else
		{
		CDesignType *pEntry;

		if (error = CDesignType::CreateFromXML(Ctx, pDesc, &pEntry))
			return error;

		if (error = AddEntry(Ctx, pEntry))
			{
			delete pEntry;
			return error;
			}

		if (retpType)
			*retpType = pEntry;
		}

	return NOERROR;
	}
ALERROR CDesignCollection::LoadEntryFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)

//	LoadEntryFromXML
//
//	Load an entry into the collection

	{
	ALERROR error;

	//	Load topology

	if (strEquals(pDesc->GetTag(), STAR_SYSTEM_TOPOLOGY_TAG)
			|| strEquals(pDesc->GetTag(), SYSTEM_TOPOLOGY_TAG))
		{
		if (Ctx.pExtension)
			//	If we're in an extension (Adventure) then load into the extension
			error = Ctx.pExtension->Topology.LoadFromXML(Ctx, pDesc);
		else
			//	Otherwise, load into the base game
			error = m_BaseTopology.LoadFromXML(Ctx, pDesc);

		if (error)
			return error;
		}

	//	Load standard design elements

	else
		{
		CDesignType *pEntry;

		try
			{
			if (error = CDesignType::CreateFromXML(Ctx, pDesc, &pEntry))
				return error;
			}
		catch (...)
			{
			Ctx.sError = strPatternSubst(CONSTLIT("Crash loading: %x"), pDesc->GetAttributeInteger(CONSTLIT("UNID")));
			return ERR_FAIL;
			}

		if (error = AddEntry(Ctx, pEntry))
			{
			delete pEntry;
			return error;
			}
		}

	return NOERROR;
	}
Beispiel #25
0
END_TEST

START_TEST(test_strCopy)
{
    char *string;

    string = strCreate();
    strCopy(string, "foo");
    fail_unless(strEquals(string, "foo"), NULL);
    strCopy(string, "bar");
    fail_unless(strEquals(string, "bar"), NULL);
    strCopy(string, "");
    fail_unless(strEquals(string, ""), NULL);
}
ALERROR CProfileSession::OnCommand (const CString &sCmd, void *pData)

//	OnCommand
//
//	Handle a command

	{
	if (strEquals(sCmd, CMD_READ_COMPLETE))
		CmdReadComplete((CReadProfileTask *)pData);
	else if (strEquals(sCmd, CMD_CLOSE_SESSION))
		m_HI.ClosePopupSession();

	return NOERROR;
	}
Beispiel #27
0
void CEsperEngine::MsgEsperStartListener (const SArchonMessage &Msg)

//	MsgEsperStartListener
//
//	Esper.startListener {name} {port} [{protocol}]

	{
	CSmartLock Lock(m_cs);

	//	If we're in shutdown, then ignore this message

	if (m_bShutdown)
		return;

	//	Get some parameters

	CString sName = Msg.dPayload.GetElement(0);
	CString sProtocol = Msg.dPayload.GetElement(2);

	//	Get the type from the protocol

	CEsperConnection::ETypes iType;
	if (sProtocol.IsEmpty() || strEquals(sProtocol, PROTOCOL_RAW))
		iType = CEsperConnection::typeRawIn;
	else if (strEquals(sProtocol, PROTOCOL_AMP1))
		iType = CEsperConnection::typeAMP1In;
	else if (strEquals(sProtocol, PROTOCOL_TLS))
		iType = CEsperConnection::typeTLSIn;
	else
		{
		SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, strPattern(ERR_UNKNOWN_PROTOCOL, sProtocol), Msg);
		return;
		}

	//	Make sure that we don't already have a listener with this name

	if (sName.IsEmpty() || FindListener(sName))
		{
		SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, 
				(sName.IsEmpty() ? ERR_INVALID_LISTENER_NAME : ERR_DUPLICATE_LISTENER_NAME), 
				Msg);
		return;
		}

	//	Add a new thread (array takes ownership of the context)

	CEsperListenerThread *pThread = new CEsperListenerThread(this, iType, Msg);
	m_Listeners.Insert(pThread);
	pThread->Start();
	}
Beispiel #28
0
END_TEST

START_TEST(test_strReplace)
{
    char *string;

    string = strCreate();
    strCopy(string, "foobarfoo");
    strReplace(string, "foo", "xyz");
    fail_unless(strEquals(string, "xyzbarxyz"), NULL);
    strCopy(string, "foobarfoo");
    strReplace(string, "bar", "xyz");
    fail_unless(strEquals(string, "fooxyzfoo"), NULL);
    strCopy(string, "foobar");
    strReplace(string, "foo", "xyz");
    fail_unless(strEquals(string, "xyzbar"), NULL);
    strReplace(string, "foo", "xyz");
    fail_unless(strEquals(string, "xyzbar"), NULL);
    strReplace(string, "xyz", "");
    fail_unless(strEquals(string, "bar"), NULL);
    strReplace(string, "bar", "foo");
    fail_unless(strEquals(string, "foo"), NULL);
    strReplace(string, "foo", "");
    fail_unless(strEquals(string, ""), NULL);
    strReplace(string, "foo", "bar");
    fail_unless(strEquals(string, ""), NULL);
}
Beispiel #29
0
bool XSECEnv::isRegisteredIdAttributeNameNS(const XMLCh * ns, const XMLCh * name) const {

	int sz = (int) m_idAttributeNameList.size();

	for (int i = 0; i < sz; ++i) {
		if (m_idAttributeNameList[i]->m_useNamespace &&
			strEquals(m_idAttributeNameList[i]->mp_namespace, ns) &&
			strEquals(m_idAttributeNameList[i]->mp_name, name))
			return true;
	}

	return false;

}
ALERROR ITopologyProcessor::CreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, const CString &sUNID, ITopologyProcessor **retpProc)

//	CreateFromXML
//
//	Creates a new processor based on the XML tag

	{
	ALERROR error;
	ITopologyProcessor *pProc;

	//	Create the approprate class

	if (strEquals(pDesc->GetTag(), ATTRIBUTES_TAG))
		pProc = new CApplySystemProc;
	else if (strEquals(pDesc->GetTag(), CONQUER_NODES_TAG))
		pProc = new CConquerNodesProc;
	else if (strEquals(pDesc->GetTag(), DISTRIBUTE_NODES_TAG))
		pProc = new CDistributeNodesProc;
	else if (strEquals(pDesc->GetTag(), FILL_NODES_TAG))
		pProc = new CFillNodesProc;
	else if (strEquals(pDesc->GetTag(), GROUP_TAG))
		pProc = new CGroupTopologyProc;
	else if (strEquals(pDesc->GetTag(), LOCATE_NODES_TAG))
		pProc = new CLocateNodesProc;
	else if (strEquals(pDesc->GetTag(), PARTITION_NODES_TAG))
		pProc = new CPartitionNodesProc;
	else if (strEquals(pDesc->GetTag(), RANDOM_POINTS_TAG))
		pProc = new CRandomPointsProc;
	else if (strEquals(pDesc->GetTag(), SYSTEM_TAG))
		pProc = new CApplySystemProc;
	else if (strEquals(pDesc->GetTag(), TABLE_TAG))
		pProc = new CTableTopologyProc;
	else
		{
		Ctx.sError = strPatternSubst(CONSTLIT("Unknown topology processor element: <%s>"), pDesc->GetTag());
		return ERR_FAIL;
		}

	//	Load it

	if (error = pProc->InitFromXML(Ctx, pDesc, sUNID))
		return error;

	//	Done

	*retpProc = pProc;

	return NOERROR;
	}