コード例 #1
0
void CDesignCollection::Reinit (void)

//	Reinit
//
//	Reinitialize all types

	{
	int i;

	//	Reinitialize some global classes

	CStationType::Reinit();

	//	For reinit that requires two passes

	for (i = 0; i < GetCount(); i++)
		{
		CDesignType *pType = GetEntry(i);
		pType->PrepareReinit();
		}

	//	Reinit design

	for (i = 0; i < GetCount(); i++)
		{
		CDesignType *pType = GetEntry(i);
		pType->Reinit();
		}
	}
コード例 #2
0
bool CPlayerGameStats::AddMatchingKeyEvents (const CString &sNodeID, const CDesignTypeCriteria &Crit, TArray<SKeyEventStats> *pEventList, TArray<SKeyEventStatsResult> *retList) const

//	AddMatchingKeyEvents
//
//	Adds all of the matching events from pEventList to the result

	{
	int i;

	for (i = 0; i < pEventList->GetCount(); i++)
		{
		SKeyEventStats *pStats = &pEventList->GetAt(i);

		CDesignType *pType = g_pUniverse->FindDesignType(pStats->dwObjUNID);
		if (pType == NULL)
			continue;

		if (pType->MatchesCriteria(Crit))
			{
			SKeyEventStatsResult *pResult = retList->Insert();
			pResult->sNodeID = sNodeID;
			pResult->pStats = pStats;
			pResult->bMarked = false;
			}
		}

	return true;
	}
コード例 #3
0
ファイル: CSpaceObjectTrade.cpp プロジェクト: bmer/Mammoth
bool CSpaceObject::GetDeviceRemovePrice (const CItem &Item, DWORD dwFlags, int *retiPrice, DWORD *retdwPriceFlags)

//	GetDeviceRemovePrice
//
//	Returns the price to install the given device

	{
	if (IsAbandoned())
		return false;

	//	See if we have an override

	CTradingDesc *pTradeOverride = GetTradeDescOverride();
	if (pTradeOverride && pTradeOverride->GetDeviceRemovePrice(this, Item, dwFlags, retiPrice, retdwPriceFlags))
		return true;

	//	Otherwise, ask our design type

	CDesignType *pType = GetType();
	if (pType == NULL)
		return false;

	CTradingDesc *pTrade = pType->GetTradingDesc();
	if (pTrade && pTrade->GetDeviceRemovePrice(this, Item, dwFlags, retiPrice, retdwPriceFlags))
		return true;

	//	Otherwise, we do not remove

	return false;
	}
コード例 #4
0
ファイル: CCUtil.cpp プロジェクト: alanhorizon/Transcendence
ALERROR GetEconomyUNIDOrDefault (CCodeChain &CC, ICCItem *pItem, DWORD *retdwUNID)
	{
	if (pItem == NULL || pItem->IsNil())
		{
		if (retdwUNID)
			*retdwUNID = 0;
		}
	else if (pItem->IsInteger())
		{
		CDesignType *pType = g_pUniverse->FindDesignType(pItem->GetIntegerValue());
		if (pType == NULL)
			return ERR_FAIL;

		if (retdwUNID)
			*retdwUNID = pType->GetUNID();
		}
	else
		{
		CEconomyType *pEconomy = g_pUniverse->FindEconomyType(pItem->GetStringValue());
		if (pEconomy == NULL)
			return ERR_FAIL;

		if (retdwUNID)
			*retdwUNID = pEconomy->GetUNID();
		}

	return NOERROR;
	}
コード例 #5
0
ファイル: CSpaceObjectTrade.cpp プロジェクト: bmer/Mammoth
int CSpaceObject::GetTradeMaxLevel (ETradeServiceTypes iService)

//	GetTradeMaxLevel
//
//	Returns the max tech level for this service.

	{
	int iMaxLevel = -1;

	//	See if we have an override

	CTradingDesc *pTradeOverride = GetTradeDescOverride();
	if (pTradeOverride)
		{
		int iLevel = pTradeOverride->GetMaxLevelMatched(iService);
		if (iLevel > iMaxLevel)
			iMaxLevel = iLevel;
		}

	//	Ask base type

	CDesignType *pType = GetType();
	CTradingDesc *pTrade = (pType ? pType->GetTradingDesc() : NULL);
	if (pTrade)
		{
		int iLevel = pTrade->GetMaxLevelMatched(iService);
		if (iLevel > iMaxLevel)
			iMaxLevel = iLevel;
		}

	return iMaxLevel;
	}
コード例 #6
0
ファイル: CSpaceObjectTrade.cpp プロジェクト: bmer/Mammoth
void CSpaceObject::UpdateTradeExtended (const CTimeSpan &ExtraTime)

//	UpdateTradeExtended
//
//	Update trade after a long time.

	{
	//	Refresh inventory, if necessary

	CTradingDesc *pTradeOverride = GetTradeDescOverride();
	CDesignType *pType = GetType();
	CTradingDesc *pTrade = (pType ? pType->GetTradingDesc() : NULL);
	if ((pTrade || pTradeOverride) && ExtraTime.Days() > 0 && !IsAbandoned())
		{
		//	Compute the percent of the inventory that need to refresh

		int iRefreshPercent;
		if (ExtraTime.Days() >= DAYS_TO_REFRESH_INVENTORY)
			iRefreshPercent = 100;
		else
			iRefreshPercent = 100 * ExtraTime.Days() / DAYS_TO_REFRESH_INVENTORY;

		//	Do it

		if (pTradeOverride)
			pTradeOverride->RefreshInventory(this, iRefreshPercent);

		if (pTrade)
			pTrade->RefreshInventory(this, iRefreshPercent);
		}
	}
コード例 #7
0
ファイル: CDesignTable.cpp プロジェクト: bmer/Mammoth
ALERROR CDesignTable::Merge (const CDynamicDesignTable &Source, CDesignList *ioOverride)

//	Merge
//
//	Merge the given table into ours.

	{
	DEBUG_TRY

	int i;

	for (i = 0; i < Source.GetCount(); i++)
		{
		CDesignType *pNewType = Source.GetType(i);

		//	If this is an override then we put it on a different table and
		//	leave the type alone.

		if (pNewType->IsModification())
			{
			if (ioOverride)
				ioOverride->AddEntry(pNewType);
			}

		//	Otherwise, add or replace

		else
			AddOrReplaceEntry(pNewType);
		}

	return NOERROR;

	DEBUG_CATCH
	}
コード例 #8
0
void CDesignCollection::FireOnGlobalPaneInit (void *pScreen, CDesignType *pRoot, const CString &sScreen, const CString &sPane)

//	FireOnGlobalPaneInit
//
//	Give other design types a way to override screens

	{
	int i;
	CString sError;

	//	Generate a screen UNID that contains both the screen UNID and a local screen

	CString sScreenUNID = CDockScreenType::GetStringUNID(pRoot, sScreen);
	DWORD dwRootUNID = (pRoot ? pRoot->GetUNID() : 0);

	//	Fire all events

	for (i = 0; i < m_EventsCache[evtOnGlobalDockPaneInit]->GetCount(); i++)
		{
		SEventHandlerDesc Event;
		CDesignType *pType = m_EventsCache[evtOnGlobalDockPaneInit]->GetEntry(i, &Event);

		if (pType->FireOnGlobalDockPaneInit(Event,
				pScreen,
				dwRootUNID,
				sScreenUNID,
				sPane,
				&sError) != NOERROR)
			kernelDebugLogMessage("%s", sError.GetASCIIZPointer());
		}
	}
コード例 #9
0
ファイル: CExtension.cpp プロジェクト: bmer/Mammoth
void CExtension::CleanUpXML (void)

//	CleanUpXML
//
//	Deletes XML representation.

	{
	int i;

	if (m_pRootXML)
		{
		delete m_pRootXML;
		m_pRootXML = NULL;
		}

	for (i = 0; i < m_ModuleXML.GetCount(); i++)
		delete m_ModuleXML[i];

	m_ModuleXML.DeleteAll();

	//	Remove references to XML

	for (i = 0; i < m_DesignTypes.GetCount(); i++)
		{
		CDesignType *pType = m_DesignTypes.GetEntry(i);
		pType->SetXMLElement(NULL);
		}
	}
コード例 #10
0
CEffectCreator *CEffectCreator::FindEffectCreator (const CString &sUNID)

//	FindEffectCreator
//
//	Finds the effect creator from a complex UNID (or NULL if not found)

	{
	//	A complex UNID looks like this:
	//
	//	For effects:
	//
	//	{unid}
	//
	//	"12345"					= Effect UNID 12345
	//	"12345/0"				= Effect UNID 12345; variant 0
	//	"12345/d:h"				= Effect UNID 12345; damage; hit effect
	//
	//	For overlays:
	//
	//	{unid}:e
	//	{unid}:h
	//
	//	For shields:
	//
	//	{unid}:h
	//	"12345:h"				= Shield UNID 12345; Hit effect
	//
	//	For system maps:
	//
	//	{unid}/{nodeID}
	//	{unid}/{nodeID}[/{nodeID}]
	//
	//	For weapons:
	//
	//	{unid}/{var}[/f{frag}]:(e | h | f)
	//
	//	"12345/0:e"				= Weapon UNID 12345; variant 0; Bullet effect
	//	"12345/0/f0:h"			= Weapon UNID 12345; variant 0; fragment 0; Hit Effect
	//

	//	First we parse the UNID

	char *pPos = sUNID.GetASCIIZPointer();
	DWORD dwUNID = strParseInt(pPos, 0, &pPos);

	//	Look for the design type

	CDesignType *pDesign = g_pUniverse->FindDesignType(dwUNID);
	if (pDesign == NULL)
		return NULL;

	//	Allow the design type to parse the remainder of the UNID

	return pDesign->FindEffectCreatorInType(CString(pPos));
	}
コード例 #11
0
void CPlayerGameStats::OnKeyEvent (EEventTypes iType, CSpaceObject *pObj, DWORD dwCauseUNID)

//	OnKeyEvent
//
//	Adds a key event involving an object

	{
	ASSERT(pObj);

	CSystem *pSystem = pObj->GetSystem();
	if (pSystem == NULL)
		return;

	//	Get the NodeID where the event happened

	CTopologyNode *pNode = pSystem->GetTopology();
	if (pNode == NULL)
		return;

	const CString &sNodeID = pNode->GetID();

	//	Get the object's type

	CDesignType *pType = pObj->GetType();
	if (pType == NULL)
		return;

	//	Get the object's name

	DWORD dwNameFlags;
	CString sName = pObj->GetName(&dwNameFlags);
	
	//	If the object name is the same as the type name then we don't bother
	//	storing it in the event (to save memory)

	if (strEquals(sName, pType->GetTypeName()))
		{
		sName = NULL_STR;
		dwNameFlags = 0;
		}

	//	Look for the list of events for this NodeID

	TArray<SKeyEventStats> *pEventList = m_KeyEventStats.Set(sNodeID);
	SKeyEventStats *pStats = pEventList->Insert();
	pStats->iType = iType;
	pStats->dwTime = g_pUniverse->GetTicks();
	pStats->dwObjUNID = pObj->GetType()->GetUNID();
	pStats->sObjName = sName;
	pStats->dwObjNameFlags = dwNameFlags;
	pStats->dwCauseUNID = dwCauseUNID;
	}
コード例 #12
0
ファイル: CDesignCollection.cpp プロジェクト: bmer/Mammoth
void CDesignCollection::NotifyTopologyInit (void)

//	NotifyTopologyInit
//
//	Notify all types that the topology has been initialized.

	{
	int i;

	for (i = 0; i < m_AllTypes.GetCount(); i++)
		{
		CDesignType *pType = m_AllTypes.GetEntry(i);
		pType->TopologyInitialized();
		}
	}
コード例 #13
0
void CDesignCollection::FireGetGlobalAchievements (CGameStats &Stats)

//	FireGetGlobalAchievements
//
//	Fire event to fill achievements

	{
	int i;

	for (i = 0; i < m_EventsCache[evtGetGlobalAchievements]->GetCount(); i++)
		{
		CDesignType *pType = m_EventsCache[evtGetGlobalAchievements]->GetEntry(i);

		pType->FireGetGlobalAchievements(Stats);
		}
	}
コード例 #14
0
ファイル: CSpaceObjectTrade.cpp プロジェクト: bmer/Mammoth
void CSpaceObject::UpdateTrade (SUpdateCtx &Ctx, int iInventoryRefreshed)

//	UpdateTrade
//
//	Updates trading directives. This creates new inventory, if necessary.

	{
	DEBUG_TRY

	//	Update override first

	CTradingDesc *pTradeOverride = GetTradeDescOverride();
	if (pTradeOverride)
		{
		pTradeOverride->OnUpdate(this);

		if (!IsPlayerDocked())
			pTradeOverride->RefreshInventory(this, iInventoryRefreshed);
		}

	//	Handle base

	CDesignType *pType = GetType();
	CTradingDesc *pTrade = (pType ? pType->GetTradingDesc() : NULL);
	if (pTrade)
		{
		//	If we have a trade desc override, then don't update. [Otherwise
		//	we will replenish currency at double the rate.]

		if (pTradeOverride == NULL)
			pTrade->OnUpdate(this);

		//	But we still need to refresh inventory, since the base 
		//	may contain items not in the override.
		//
		//	LATER: Note that this doesn't handle the case where we try
		//	to override a specific item. The fix is to add the concept
		//	of overriding directly into the class.

		if (!IsPlayerDocked())
			pTrade->RefreshInventory(this, iInventoryRefreshed);
		}

	DEBUG_CATCH
	}
コード例 #15
0
ファイル: CSpaceObjectTrade.cpp プロジェクト: bmer/Mammoth
CEconomyType *CSpaceObject::GetDefaultEconomy (void)

//	GetDefaultEconomy
//
//	Returns the default economy

	{
	CTradingDesc *pTradeOverride = GetTradeDescOverride();
	if (pTradeOverride)
		return pTradeOverride->GetEconomyType();

	CDesignType *pType = GetType();
	CTradingDesc *pTrade = (pType ? pType->GetTradingDesc() : NULL);
	if (pTrade)
		return pTrade->GetEconomyType();

	return CEconomyType::AsType(g_pUniverse->FindDesignType(DEFAULT_ECONOMY_UNID));
	}
コード例 #16
0
void CDesignCollection::FireOnGlobalUniverseSave (void)

//	FireOnGlobalUniverseSave
//
//	Notify all types that the universe is about to be saved to disk

	{
	int i;

	CString sError;
	for (i = 0; i < m_EventsCache[evtOnGlobalUniverseSave]->GetCount(); i++)
		{
		SEventHandlerDesc Event;
		CDesignType *pType = m_EventsCache[evtOnGlobalUniverseSave]->GetEntry(i, &Event);

		pType->FireOnGlobalUniverseSave(Event);
		}
	}
コード例 #17
0
void CDesignCollection::FireOnGlobalUniverseCreated (void)

//	FireOnGlobalUniverseCreated
//
//	Notify all types that the universe has been created

	{
	int i;

	CString sError;
	for (i = 0; i < m_EventsCache[evtOnGlobalUniverseCreated]->GetCount(); i++)
		{
		SEventHandlerDesc Event;
		CDesignType *pType = m_EventsCache[evtOnGlobalUniverseCreated]->GetEntry(i, &Event);

		pType->FireOnGlobalUniverseCreated(Event);
		}
	}
コード例 #18
0
ファイル: CSpaceObjectTrade.cpp プロジェクト: bmer/Mammoth
DWORD CSpaceObject::GetDefaultEconomyUNID (void)

//	GetDefaultEconomyUNID
//
//	Returns the default economy
	
	{
	CTradingDesc *pTradeOverride = GetTradeDescOverride();
	if (pTradeOverride)
		return pTradeOverride->GetEconomyType()->GetUNID();

	CDesignType *pType = GetType();
	CTradingDesc *pTrade = (pType ? pType->GetTradingDesc() : NULL);
	if (pTrade)
		return pTrade->GetEconomyType()->GetUNID();

	return DEFAULT_ECONOMY_UNID;
	}
コード例 #19
0
ALERROR CDesignCollection::FireOnGlobalTypesInit (SDesignLoadCtx &Ctx)

//	FireOnGlobalTypesInit
//
//	Give each type a chance to create dynamic types before we bind.

	{
	ALERROR error;
	int i;

	for (i = 0; i < m_AllTypes.GetCount(); i++)
		{
		CDesignType *pType = m_AllTypes.GetEntry(i);
		if (error = pType->FireOnGlobalTypesInit(Ctx))
			return error;
		}

	return NOERROR;
	}
コード例 #20
0
void CDesignCollection::FireOnGlobalObjDestroyed (SDestroyCtx &Ctx)

//	FireOnGlobalObjDestroyed
//
//	Gives other types a notification when an object is destroyed

	{
	int i;

	//	Fire all events

	for (i = 0; i < m_EventsCache[evtOnGlobalObjDestroyed]->GetCount(); i++)
		{
		SEventHandlerDesc Event;
		CDesignType *pType = m_EventsCache[evtOnGlobalObjDestroyed]->GetEntry(i, &Event);

		pType->FireOnGlobalObjDestroyed(Event, Ctx);
		}
	}
コード例 #21
0
bool CDesignCollection::FireGetGlobalDockScreen (CSpaceObject *pObj, CString *retsScreen, int *retiPriority)

//	FireGetGlobalDockScreen
//
//	Allows types to override the dock screen for an object

	{
	int i;
	int iBestPriority = -1;
	CString sBestScreen;

	//	Loop over all types and get the highest priority screen

	for (i = 0; i < m_EventsCache[evtGetGlobalDockScreen]->GetCount(); i++)
		{
		SEventHandlerDesc Event;
		CDesignType *pType = m_EventsCache[evtGetGlobalDockScreen]->GetEntry(i, &Event);

		int iPriority;
		CString sScreen;
		if (pType->FireGetGlobalDockScreen(Event, pObj, &sScreen, &iPriority)
				&& iPriority > iBestPriority)
			{
			iBestPriority = iPriority;
			sBestScreen = sScreen;
			}
		}

	//	If none found, then we're done

	if (iBestPriority == -1)
		return false;

	//	Otherwise, return screen

	if (retsScreen)
		*retsScreen = sBestScreen;

	if (retiPriority)
		*retiPriority = iBestPriority;

	return true;
	}
コード例 #22
0
ファイル: CDesignCollection.cpp プロジェクト: bmer/Mammoth
void CDesignCollection::FireOnGlobalMarkImages (void)

//	FireOnGlobalMarkImages
//
//	Allows types to mark images

	{
	int i;

	//	Fire all events

	for (i = 0; i < m_EventsCache[evtOnGlobalMarkImages]->GetCount(); i++)
		{
		SEventHandlerDesc Event;
		CDesignType *pType = m_EventsCache[evtOnGlobalMarkImages]->GetEntry(i, &Event);

		pType->FireOnGlobalMarkImages(Event);
		}
	}
コード例 #23
0
ファイル: CDesignCollection.cpp プロジェクト: bmer/Mammoth
void CDesignCollection::FireOnGlobalSystemStopped (void)

//	FireOnGlobalSystemStopped
//
//	Notify all types that a system has stopped

	{
	int i;

	//	Fire all events

	for (i = 0; i < m_EventsCache[evtOnGlobalSystemStopped]->GetCount(); i++)
		{
		SEventHandlerDesc Event;
		CDesignType *pType = m_EventsCache[evtOnGlobalSystemStopped]->GetEntry(i, &Event);

		pType->FireOnGlobalSystemStopped(Event);
		}
	}
コード例 #24
0
ファイル: CDesignCollection.cpp プロジェクト: bmer/Mammoth
void CDesignCollection::FireOnGlobalUpdate (int iTick)

//	FireOnGlobalUpdate
//
//	Types get a chance to do whatever they want once every 15 ticks.

	{
	int i;

	CString sError;
	for (i = 0; i < m_EventsCache[evtOnGlobalUpdate]->GetCount(); i++)
		{
		SEventHandlerDesc Event;
		CDesignType *pType = m_EventsCache[evtOnGlobalUpdate]->GetEntry(i, &Event);

		if ((((DWORD)iTick + pType->GetUNID()) % GLOBAL_ON_UPDATE_CYCLE) == 0)
			pType->FireOnGlobalUpdate(Event);
		}
	}
コード例 #25
0
ファイル: SimTables.cpp プロジェクト: bmer/Transmuter
void AccumulateSystem (CTopologyNode *pNode, CSystem *pSystem, TSortMap<DWORD, STypeInfo> &AllTypes)
	{
	int j;

	int iSystemLevel = pSystem->GetLevel();

	//	Add the encounters to the appropriate tables

	for (j = 0; j < pSystem->GetObjectCount(); j++)
		{
		CSpaceObject *pObj = pSystem->GetObject(j);

		if (pObj)
			{
			//	Add this encounter to the table

			CDesignType *pType;
			if ((pType = pObj->GetEncounterInfo()) || (pType = pObj->GetType()))
				{
				STypeInfo *pInfo = AllTypes.SetAt(pType->GetUNID());
				pInfo->iTotalCount++;
				pInfo->PerLevel[iSystemLevel]++;
				}

			//	Enumerate the items in this object

			CItemListManipulator ItemList(pObj->GetItemList());
			ItemList.ResetCursor();
			while (ItemList.MoveCursorForward())
				{
				const CItem &Item(ItemList.GetItemAtCursor());

				if (!Item.IsInstalled() && !Item.IsDamaged())
					{
					STypeInfo *pInfo = AllTypes.SetAt(Item.GetType()->GetUNID());
					pInfo->iTotalCount += Item.GetCount();
					pInfo->PerLevel[iSystemLevel] += Item.GetCount();
					}
				}
			}
		}
	}
コード例 #26
0
ファイル: CSpaceObjectTrade.cpp プロジェクト: bmer/Mammoth
bool CSpaceObject::GetArmorRepairPrice (const CItem &Item, int iHPToRepair, DWORD dwFlags, int *retiPrice)

//	GetArmorRepairPrice
//
//	Returns the price to repair the given number of HP for the given armor item.

	{
	if (IsAbandoned())
		return false;

	//	See if we have an override

	CTradingDesc *pTradeOverride = GetTradeDescOverride();
	if (pTradeOverride && pTradeOverride->GetArmorRepairPrice(this, Item, iHPToRepair, dwFlags, retiPrice))
		return true;

	//	Otherwise, ask our design type

	CDesignType *pType = GetType();
	if (pType == NULL)
		return false;

	CTradingDesc *pTrade = pType->GetTradingDesc();
	if (pTrade && pTrade->GetArmorRepairPrice(this, Item, iHPToRepair, dwFlags, retiPrice))
		return true;

	//	For compatibility, any ship prior to version 23 has a default.
	//	[For API Version 23 and above, ships must have a <Trade> descriptor.]

	if (pType->GetAPIVersion() < 23
			&& pType->GetType() == designShipClass)
		{
		if (retiPrice)
			*retiPrice = CTradingDesc::CalcPriceForService(serviceRepairArmor, this, Item, iHPToRepair, dwFlags);

		return true;
		}

	//	Otherwise, we do not repair

	return false;
	}
コード例 #27
0
ファイル: Stats.cpp プロジェクト: AvanWolf/Transcendence
void AddTypesUsedRecursive (CUniverse &Universe, DWORD dwUNID, TSortMap<DWORD, bool> *retTypesUsed)
	{
	int i;

	//	If already added, don't bother

	if (retTypesUsed->Find(dwUNID))
		return;

	CDesignType *pType = Universe.FindDesignType(dwUNID);
	if (pType == NULL)
		return;

	retTypesUsed->SetAt(dwUNID, true);

	//	Recurse

	TSortMap<DWORD, bool> TypesUsed;
	pType->AddTypesUsed(&TypesUsed);
	for (i = 0; i < TypesUsed.GetCount(); i++)
		AddTypesUsedRecursive(Universe, TypesUsed.GetKey(i), retTypesUsed);
	}
コード例 #28
0
ファイル: CSpaceObjectTrade.cpp プロジェクト: bmer/Mammoth
bool CSpaceObject::GetDeviceInstallPrice (const CItem &Item, DWORD dwFlags, int *retiPrice, CString *retsReason, DWORD *retdwPriceFlags)

//	GetDeviceInstallPrice
//
//	Returns the price to install the given device

	{
	//	Defaults to no reason

	if (retsReason)
		*retsReason = NULL_STR;

	if (IsAbandoned())
		return false;

	//	See if we have an override

	CTradingDesc *pTradeOverride = GetTradeDescOverride();
	if (pTradeOverride && pTradeOverride->GetDeviceInstallPrice(this, Item, dwFlags, retiPrice, retsReason, retdwPriceFlags))
		return true;

	//	Otherwise, ask our design type

	CDesignType *pType = GetType();
	if (pType == NULL)
		{
		if (retsReason)
			*retsReason = CONSTLIT("Unknown item.");
		return false;
		}

	CTradingDesc *pTrade = pType->GetTradingDesc();
	if (pTrade && pTrade->GetDeviceInstallPrice(this, Item, dwFlags, retiPrice, retsReason, retdwPriceFlags))
		return true;

	//	Otherwise, we do not install

	return false;
	}
コード例 #29
0
ファイル: CDesignCollection.cpp プロジェクト: bmer/Mammoth
bool CDesignCollection::FireGetGlobalPlayerPriceAdj (ETradeServiceTypes iService, CSpaceObject *pProvider, const CItem &Item, ICCItem *pData, int *retiPriceAdj)

//	FireGetGlobalPlayerPriceAdj
//
//	Returns a price adjustment for the player, given a service, a provider,
//	and an item.

	{
	int i;

	//	Fire all events

	int iPriceAdj = 100;
	for (i = 0; i < m_EventsCache[evtGetGlobalPlayerPriceAdj]->GetCount(); i++)
		{
		SEventHandlerDesc Event;
		CDesignType *pType = m_EventsCache[evtGetGlobalPlayerPriceAdj]->GetEntry(i, &Event);

		int iSinglePriceAdj;
		if (pType->FireGetGlobalPlayerPriceAdj(Event, iService, pProvider, Item, pData, &iSinglePriceAdj))
			{
			if (iSinglePriceAdj < 0)
				{
				iPriceAdj = -1;
				break;
				}
			else
				iPriceAdj = iPriceAdj * iSinglePriceAdj / 100;
			}
		}

	//	Done

	if (retiPriceAdj)
		*retiPriceAdj = (iPriceAdj < 0 ? -1 : iPriceAdj);

	return (iPriceAdj != 100);
	}
コード例 #30
0
CAdventureDesc *CDesignCollection::FindAdventureForExtension (DWORD dwUNID) const

//	FindAdventureForExtension
//
//	Returns the adventure desc that belongs to the given extension.
//	(Or NULL if not found).

	{
	int i;

	SExtensionDesc *pExtension = FindExtension(dwUNID);
	if (pExtension == NULL || pExtension->iType != extAdventure)
		return NULL;

	for (i = 0; i < pExtension->Table.GetCount(); i++)
		{
		CDesignType *pType = pExtension->Table.GetEntry(i);
		if (pType->GetType() ==	designAdventureDesc)
			return CAdventureDesc::AsType(pType);
		}

	return NULL;
	}