//-----------------------------------------------------------------------------
// Purpose: Special implementation of UpdateChild for the world object. This
//			notifies the document that an object's bounding box has changed.
// Input  : pChild - 
//-----------------------------------------------------------------------------
void CMapWorld::UpdateChild(CMapClass *pChild)
{
	if ( CMapClass::s_bLoadingVMF )
		return;
	
	// Recalculate the bounds of this child's branch.
	pChild->CalcBounds(TRUE);

	// Recalculate own bounds
	CalcBounds( FALSE );

	//
	// Relink the child in the culling tree.
	//
	if (m_pCullTree != NULL)
	{
		m_pCullTree->UpdateCullTreeObjectRecurse(pChild);
	}

	//
	// Notify the document that an object in the world has changed.
	//
	if (!IsTemporary()) // HACK: check to avoid prefab objects ending up in the doc's update list
	{
		CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
		if (pDoc != NULL)
		{
			pDoc->UpdateObject(pChild);
		}
	}
}
void StringVarMap::Save(NVSESerializationInterface* intfc)
{
	Clean();

	intfc->OpenRecord('STVS', 0);

	if (m_state) {
		for (std::map<UInt32, StringVar*>::iterator iter = m_state->vars.begin();
				iter != m_state->vars.end();
				iter++)
		{
			if (IsTemporary(iter->first))	// don't save temp strings
				continue;

			intfc->OpenRecord('STVR', 0);
			UInt8 modIndex = iter->second->GetOwningModIndex();

			intfc->WriteRecordData(&modIndex, sizeof(UInt8));
			intfc->WriteRecordData(&iter->first, sizeof(UInt32));
			UInt16 len = iter->second->GetLength();
			intfc->WriteRecordData(&len, sizeof(len));
			intfc->WriteRecordData(iter->second->GetCString(), len);
		}
	}
	intfc->OpenRecord('STVE', 0);
}
void ETHScriptEntity::Kill()
{
	if (!IsTemporary())
	{
		ForceSFXStop();
	}
	m_isAlive = false;
}
bool TESForm::SetEditorID(const char* EditorID)
{
	if (IsTemporary() && EditorID == nullptr)
	{
		this->editorID.Clear();
		return true;
	}

	SME_ASSERT(EditorID);
	return thisCall<bool>(0x00497670, this, EditorID);
}
Example #5
0
void Entity::SerializeToXML(QDomDocument &doc, QDomElement &base_element, bool serializeTemporary) const
{
    QDomElement entity_elem = doc.createElement("entity");
    entity_elem.setAttribute("id", QString::number(Id()));
    entity_elem.setAttribute("sync", BoolToString(IsReplicated()));
    if (serializeTemporary)
        entity_elem.setAttribute("temporary", BoolToString(IsTemporary()));

    for (ComponentMap::const_iterator i = components_.begin(); i != components_.end(); ++i)
            i->second->SerializeTo(doc, entity_elem, serializeTemporary);

    base_element.appendChild(entity_elem);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool RecursionElimination::IsTailCallWithAccumulator(CallInstr* callInstr, 
                                                     ReturnInstr* retInstr,
                                                     TailCallInfo& info) {
    // If we don't have a returned value we have nothing to do.
    if(callInstr->IsVoid() || retInstr->IsVoid()) {
        return false;
    }

    // Walk from the call until we reach the return instruction.
    // Collect any 'add'/'fadd' or 'mul'/'fmul' instruction on the way,
    // and give up if we see something invalid/dangerous.
    bool sawAdd = false;
    bool sawMul = false;
    auto currentOp = callInstr->ResultOp();

    while(currentOp && currentOp->HasSingleUser()) {
        DebugValidator::IsTrue(currentOp->IsTemporary());
        auto user = currentOp->As<Temporary>()->GetUser(0);

        if((user->IsMul() || user->IsFmul()) && 
           (sawAdd == false)) {
            // Add the multiplier to the list.
            auto multiplier = user->GetSourceOp(0) == currentOp ?
                              user->GetSourceOp(1) : user->GetSourceOp(0);
            currentOp = user->GetDestinationOp();

            // Make sure that the multiplier doesn't change
            // the value after the first iteration.
           
            if(CollectCallInvariant(multiplier, callInstr, info, false)) {
                sawMul = true;
            }
            else return false;
        }
        else if(user->IsAdd() || user->IsFadd()) {
            // Add the addend to the list.
            auto addend = user->GetSourceOp(0) == currentOp ?
                          user->GetSourceOp(1) : user->GetSourceOp(0);
            currentOp = user->GetDestinationOp();

            // Make sure that the multiplier doesn't change
            // the value after the first iteration.
            if(CollectCallInvariant(addend, callInstr, info, true)) {
                sawAdd = true;
            }
            else return false;
        }
        else if(user == retInstr) {
            // We reached the 'ret' instruction,
            // it means that all is OK.
            break;
        }
        else {
            // We have an invalid instruction, or a situation
            // like 'mul' after we already saw an 'add'.
            return false; 
        }
    }

    info.TailCall = callInstr;
    info.TailReturn = retInstr;
    return true;
}