/**
 * Returns number dropped. Check to confirm that all went.
 * Concern in doing this is that we don't want to mess up the iterators.
 * Also need to be sure that no one else is using the iterators.
 */
bool Element::dropVec( int msg, const vector< const ConnTainer* >& vec )
{
	if ( vec.size() == 0 )
		return 0;

	if ( !validMsg( msg ) )
		return 0;

	if ( msg >= 0 ) {
		Msg* m = varMsg( msg );
		assert ( m != 0 );
		vector< const ConnTainer* >::const_iterator i;
		for ( i = vec.begin(); i != vec.end(); i++ ) {
			bool ret = m->drop( ( *i )->e1(), *i );
			assert( ret );
		}
		return 1;
	} else {
		vector< ConnTainer* >* ctv = getDest( msg );
		assert ( ctv->size() >= vec.size() );
		vector< const ConnTainer* >::const_iterator i;
		for ( i = vec.begin(); i != vec.end(); i++ ) {
			int otherMsg = ( *i )->msg1();
			Element* otherElement = ( *i )->e1();
			Msg* om = otherElement->varMsg( otherMsg );
			assert( om );
			bool ret = om->drop( otherElement, *i );
			assert( ret );
		}
		return 1;
	}
	return 0;
}
Example #2
0
void InstArithmetic::dump(const Cfg *Func) const {
  Ostream &Str = Func->getContext()->getStrDump();
  dumpDest(Func);
  Str << " = " << InstArithmeticAttributes[getOp()].DisplayString << " "
      << getDest()->getType() << " ";
  dumpSources(Func);
}
Example #3
0
void InstCast::dump(const Cfg *Func) const {
  Ostream &Str = Func->getContext()->getStrDump();
  dumpDest(Func);
  Str << " = " << InstCastAttributes[getCastKind()].DisplayString << " "
      << getSrc(0)->getType() << " ";
  dumpSources(Func);
  Str << " to " << getDest()->getType();
}
Example #4
0
void InstLoad::dump(const Cfg *Func) const {
  Ostream &Str = Func->getContext()->getStrDump();
  dumpDest(Func);
  Type Ty = getDest()->getType();
  Str << " = load " << Ty << "* ";
  dumpSources(Func);
  Str << ", align " << typeAlignInBytes(Ty);
}
Example #5
0
void InstFakeDef::emit(const Cfg *Func) const {
  Ostream &Str = Func->getContext()->getStrEmit();
  Str << "\t# ";
  getDest()->emit(Func);
  Str << " = def.pseudo ";
  emitSources(Func);
  Str << "\n";
}
Example #6
0
void cTmpEff::Reverse()
{
	int s = calcCharFromSer(getDest());

	P_CHAR pc_s = MAKE_CHARREF_LR(s);
	switch(num)
	{
	case 1:	pc_s->priv2 &= 0xFD;	break;
	case 2:	pc_s->fixedlight='\xFF';break;
	case 3:	pc_s->chgDex(more1);	break;
	case 4:	pc_s->in+=more1;		break;
	case 5:	pc_s->st+=more1;		break;
	case 6:	pc_s->chgDex(-1 * more1);break;
	case 7:	pc_s->in-=more1;		break;
	case 8:	pc_s->st-=more1;		break;
	case 11:
		pc_s->st-=more1;
		pc_s->chgDex(-1 * more2);
		pc_s->in-=more3;
		break;
	case 12:
		pc_s->st+=more1;
		pc_s->chgDex(more2);
		pc_s->in+=more3;
		break;
	case 18: //Polymorph spell by AntiChrist
		if(pc_s->polymorph)
		{
			pc_s->id1=pc_s->xid1;
			pc_s->id2=pc_s->xid2;
			pc_s->polymorph=false;
			teleport(s);
		}
		break;
	case 19: //Incognito spell by AntiChrist
		reverseIncognito(pc_s);
		break;

	case 21:
		int toDrop;
		toDrop = more1; //Effect->more1;
		if( ( pc_s->baseskill[PARRYING] - toDrop ) < 0 )
			pc_s->baseskill[PARRYING] = 0;
		else
			pc_s->baseskill[PARRYING] -= toDrop;
		
	default:
		clConsole.send("ERROR: Fallout of switch\n"); //Morrolan
		return;
	}//switch
	
	Items->CheckEquipment(s); //AntiChrist - checks equipments for stats requirements
}
Example #7
0
void InstPhi::dump(const Cfg *Func) const {
  Ostream &Str = Func->getContext()->getStrDump();
  dumpDest(Func);
  Str << " = phi " << getDest()->getType() << " ";
  for (SizeT I = 0; I < getSrcSize(); ++I) {
    if (I > 0)
      Str << ", ";
    Str << "[ ";
    getSrc(I)->dump(Func);
    Str << ", %" << Labels[I]->getName() << " ]";
  }
}
Example #8
0
void InstCall::dump(const Cfg *Func) const {
  Ostream &Str = Func->getContext()->getStrDump();
  if (getDest()) {
    dumpDest(Func);
    Str << " = ";
  }
  Str << "call ";
  if (getDest())
    Str << getDest()->getType();
  else
    Str << "void";
  Str << " ";
  getCallTarget()->dump(Func);
  Str << "(";
  for (SizeT I = 0; I < getNumArgs(); ++I) {
    if (I > 0)
      Str << ", ";
    Str << getArg(I)->getType() << " ";
    getArg(I)->dump(Func);
  }
  Str << ")";
}
Example #9
0
// Change "a=phi(...)" to "a_phi=phi(...)" and return a new
// instruction "a=a_phi".
Inst *InstPhi::lower(Cfg *Func, CfgNode *Node) {
  Variable *Dest = getDest();
  assert(Dest);
  IceString PhiName = Dest->getName() + "_phi";
  Variable *NewSrc = Func->makeVariable(Dest->getType(), Node, PhiName);
  this->Dest = NewSrc;
  InstAssign *NewInst = InstAssign::create(Func, Dest, NewSrc);
  // Set Dest and NewSrc to have affinity with each other, as a hint
  // for register allocation.
  Dest->setPreferredRegister(NewSrc, false);
  NewSrc->setPreferredRegister(Dest, false);
  Dest->replaceDefinition(NewInst, Node);
  return NewInst;
}
bool Element::drop( int msg, unsigned int doomed )
{
	if ( !validMsg( msg ) )
		return 0;
	if ( msg >= 0 ) {
		return varMsg( msg )->drop( this, doomed );
	} else {
		cout << "Not sure what to do here, as the lookup is non-sequential\n";
		vector< ConnTainer* >* ctv = getDest( msg );
		if ( doomed >= ctv->size() )
			return 0;
	}
	return 0;
}
bool Element::dropAll( int msg )
{
	if ( !validMsg( msg ) )
		return 0;
	if ( msg >= 0 ) {
		varMsg( msg )->dropAll( this );
		return 1;
	} else {
		vector< ConnTainer* >* ctv = getDest( msg );
		vector< ConnTainer* >::iterator k;
		for ( k = ctv->begin(); k != ctv->end(); k++ ) {
			bool ret = Msg::innerDrop( ( *k )->e1(), ( *k )->msg1(), *k );
			if ( ret )
				delete ( *k );
			else
				cout << "Error: Element::dropAll(): innerDrop failed\n";
			*k = 0;
		}
		ctv->resize( 0 );
		// I could erase the entry in the dest_ map too. Later.
		return 1;
	}
}
Example #12
0
//preconditions: none
//postconditions: prints out the word object
//description: cout overloaded operator
void word::print(void) const
{
	cout << getSrc() << ":" << getDest() << endl;
}
Example #13
0
void InstAssign::dump(const Cfg *Func) const {
  Ostream &Str = Func->getContext()->getStrDump();
  dumpDest(Func);
  Str << " = " << getDest()->getType() << " ";
  dumpSources(Func);
}
Example #14
0
void cTmpEff::Expire()
{
    int k;

    P_CHAR pc_s = FindCharBySerial(getDest());
    if (   num != 9		// grinding
            && num != 10	// create potion
            && num != 13	// door close
            && num != 14	// training dummy
            && num != 17)	// explosion
    {
        //Added by TANiS to fix errors, memory corruption and door auto-close 10-6-98
        // Check to see if it's a dead char and delete the wrong effect, or if it's just
        // a door auto-close effect and process it the right way.
        if ( pc_s == NULL )
        {
            return;		// just remove this effect
        } //End of TANiS' change
    }

    switch(num)
    {
    case 1:
        if (pc_s->priv2&0x02)
        {
            pc_s->priv2 &= 0xFD;
            int sk=calcSocketFromChar((pc_s));
            if (sk!=-1) sysmessage(sk, "You are no longer frozen.");
            Magic->afterParticles(38, pc_s);
        }
        break;
    case 2:
        pc_s->fixedlight='\xFF';
        dolight(calcSocketFromChar((pc_s)), worldbrightlevel);
        break;
    case 3:
        pc_s->chgDex(more1);
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 4:
        pc_s->in+=more1;
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 5:
        pc_s->st+=more1;
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 6:
        pc_s->chgDex(-1 * more1);
        pc_s->stm=min(pc_s->stm, (int)pc_s->effDex());
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 7:
        pc_s->in-=more1;
        pc_s->mn=min(pc_s->mn, pc_s->in);
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 8:
        pc_s->st-=more1;
        pc_s->hp=min(pc_s->hp, pc_s->st);
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 9:
        if (more1 == 0)
        {
            if (more2!=0)
            {
                sprintf((char*)temp, "*%s continues grinding.*", pc_s->name.c_str());
                npcemoteall(pc_s, (char*)temp,1);
            }
            soundeffect2(pc_s, 0x0242);
        }
        break;
    case 10:
    {
        pc_s = FindCharBySerial(getSour());
        P_ITEM pMortar = FindItemBySerial(getDest());
        if(pMortar != NULL) //AntiChrist - to prevent crashes
            Skills->CreatePotion(pc_s, more1, more2, pMortar);
    }
    break;
    case 11:
        pc_s->st-=more1;
        pc_s->hp=min(pc_s->hp, pc_s->st);
        pc_s->chgDex(-1 * more2);
        pc_s->stm=min(pc_s->stm, (int)pc_s->effDex());
        pc_s->in-=more3;
        pc_s->mn=min(pc_s->mn, pc_s->in);
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 12:
        pc_s->st+=more1;
        pc_s->chgDex(more2);
        pc_s->in+=more3;
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 13:
    {
        P_ITEM pDoor = FindItemBySerial(getDest());// door
        if (pDoor)
        {
            if (pDoor->dooropen==0)
                break;
            pDoor->dooropen=0;
            dooruse(calcSocketFromChar((pc_s)), pDoor);
        }
        break;
    }
    case 14: //- training dummies Tauriel check to see if item moved or not before searching for it
    {
        P_ITEM pTrainDummy = FindItemBySerial(getDest());
        if (pTrainDummy)
        {
            if (pTrainDummy->id()==0x1071)
            {
                pTrainDummy->setId(0x1070);
                pTrainDummy->gatetime=0;
                RefreshItem(pTrainDummy);//AntiChrist
            }
            else if (pTrainDummy->id()==0x1075)
            {
                pTrainDummy->setId(0x1074);
                pTrainDummy->gatetime=0;
                RefreshItem(pTrainDummy);//AntiChrist
            }
        }
    }
    break;
    case 15: //reactive armor
        pc_s->ra=0;
        break;
    case 16: //Explosion potion messages	Tauriel
        sprintf((char*)temp, "%i", more3);
        sysmessage(calcSocketFromChar((pc_s)), (char*)temp); // crashfix, LB
        break;
    case 17: //Explosion potion explosion	Tauriel
        pc_s = FindCharBySerial(getSour());
        explodeitem(calcSocketFromChar((pc_s)), FindItemBySerial(getDest())); //explode this item
        break;
    case 18: //Polymorph spell by AntiChrist 9/99
        if(pc_s->polymorph)//let's ensure it's under polymorph effect!
        {
            pc_s->setId(pc_s->xid);
            pc_s->polymorph=false;
            teleport(pc_s);
        }
        break;
    case 19: //Incognito spell by AntiChrist 12/99
        reverseIncognito(pc_s);
        break;

    case 20: // LSD potions, LB 5'th nov 1999
    {
        k=calcSocketFromChar((pc_s));
        if (k==-1) return;
        LSD[k]=0;
        sysmessage(k,"LSD has worn off");
        pc_s->stm=3; // stamina near 0
        pc_s->mn=3;
        pc_s->hp=pc_s->hp/7;
        impowncreate(k, pc_s, 0);
        all_items(k); // absolutely necassairy here !!!
        AllCharsIterator it;
        for (it.Begin(); !it.atEnd(); it++) // that hurts, but there's no other good way
        {
            P_CHAR pc = it.GetData();
            if (chardist( pc_s, pc ) < 15 && ( online(pc) || pc->isNpc() ) )
                updatechar(pc);
        }
    }
    break;

    case 21:
        int toDrop;
        toDrop = more1; //Effect->more1;
        if( ( pc_s->baseskill[PARRYING] - toDrop ) < 0 )
            pc_s->baseskill[PARRYING] = 0;
        else
            pc_s->baseskill[PARRYING] -= toDrop;
        break;

    case 33: // delayed hiding for gms after flamestrike effect
        k=calcSocketFromChar((pc_s));
        sysmessage(k,"You have hidden yourself well.");
        pc_s->hidden=1;
        updatechar(pc_s);
        break;

    case 34: // delayed unhide for gms
        // Changed to be uniform with delayed hideing  (Aldur)
        k = calcSocketFromChar((pc_s));
        sysmessage(k, "You are now visible.");
        pc_s->hidden = 0;
        updatechar(pc_s);
        break;

    case 35: //heals some pf - solarin
        int iHp;
        iHp=(int)more1;
        pc_s->hp+=iHp;
        updatestats(pc_s, 0);
        if (!more2)
            tempeffect(pc_s, pc_s, 35, more1+1, 1, more3, 0);
        break;

    default:
        LogErrorVar("Fallout of switch (num = %i).", num);
        break;
    }
    Items->CheckEquipment(pc_s); //AntiChrist - checks equipments for stats requirements
}
Example #15
0
void Inst::dumpDest(const Cfg *Func) const {
  if (getDest())
    getDest()->dump(Func);
}
void VisitorLandsideBehavior::writeCurrentLogItem(PaxLandsideBehavior* pOwnerPax,Point _OwnerPreLocation, theVisitorLogNum logNum/* = secondLog*/,MobDir emWalk/* = FORWARD*/)
{
	ASSERT(firstLog == logNum || secondLog == logNum);

	if (pOwnerPax == NULL)
		return;

	Point OwnerLocation;
	OwnerLocation.init(pOwnerPax->getPoint().n[VX],pOwnerPax->getPoint().n[VY],pOwnerPax->getPoint().n[VZ]); 

	if( _OwnerPreLocation == OwnerLocation )return;



	// use vector(_OwnerPreLocation -> OwnerLocation) as passenger direction
	Point paxDirection(_OwnerPreLocation, OwnerLocation);
	Point paxLogPoint = (firstLog == logNum)?_OwnerPreLocation:OwnerLocation;

	CNonPaxRelativePosSpec* pNonPaxRelPosSpec = m_pPerson->GetTerminal()->GetNonPaxRelativePosSpec();
	ASSERT( NULL != pNonPaxRelPosSpec );
	CPoint2008 ptRelatePos;
	ARCVector4 rotation;
	bool bRes = pNonPaxRelPosSpec->GetNonPaxRelatePosition(ptRelatePos, rotation, m_pPerson->getType().GetTypeIndex());
	if (bRes)
	{
		Point vectorLat( ptRelatePos.getX(),ptRelatePos.getY(), 0.0);
		double dAngle = GetRotateAngle(emWalk);
		Point dir(paxDirection);
		dir.rotate(dAngle);
		dir.Normalize();
		vectorLat.rotate(dir, paxLogPoint);

		//	location = vectorLat;
		ARCVector3 vectorPt;
		vectorPt.n[VX] = vectorLat.getX();
		vectorPt.n[VY] = vectorLat.getY();
		vectorPt.n[VZ] = paxLogPoint.getZ();
		setLocation(vectorPt);
		SetRelativePosition(paxDirection,paxLogPoint,emWalk);
	}
	else
	{
		switch( m_pPerson->getType().GetTypeIndex() )
		{
		case 1:	//visitor  // left
			{
				Point vectorLat( paxDirection.perpendicular() );
				vectorLat.length(100.0);
				setLocation(paxLogPoint + vectorLat);
				setDestination(getPoint());
				break;
			}
		case 2:	//checked bag	//front
			{
				paxDirection.length(25.0);//( 150.0 );
				setDestination(paxLogPoint + paxDirection);
				setLocation(paxLogPoint + paxDirection);
				break;
			}
		case 3:	//hand bag	// left
			{
				Point vectorLat( paxDirection.perpendicular() );
				vectorLat.length(20.0);
				setLocation(paxLogPoint + vectorLat);
				setDestination(paxLogPoint + vectorLat);
				break;
			}
		case 4:	//carte		// front
			{
				paxDirection.length( 100.0 );
				setDestination(paxLogPoint + paxDirection);
				setLocation(paxLogPoint + paxDirection);
				break;
			}
		case 6: //dog		//right_front
			{
				Point vectorLat( paxDirection.perpendicular() );
				vectorLat.length(-100.0);
				setDestination(paxLogPoint + vectorLat);
				paxDirection.length( 100.0 );
				setDestination(paxDirection + getDest());
				setLocation(getDest());
				break;
			}
		default: //other visitor
			{
				paxDirection.length(25.0);//( 150.0 );
				setDestination(paxLogPoint + paxDirection);
				setLocation(getDest());
				break;
			}
		}	
		SetFollowerDestination( getPoint(), getDest(), Person::m_pRotation );
	}

}
//////////////////////////////////////////////////////////////////////////
//write log, called by owned passenger
bool VisitorLandsideBehavior::WriteVisitorTrack( const ARCVector3& pax_pre_location,PaxLandsideBehavior* pOwnerPax,ElapsedTime time, bool _bBackup /*= false*/, bool bOffset /*= true*/ )
{
	MobEventStruct track;
	track.time = (long)time;
	track.state = m_pPerson->getState();
	track.procNumber = -1;
	track.bDynamicCreatedProc = FALSE;
	track.followowner	= true;
	track.reason = -1;
	track.backup = _bBackup;
	track.m_IsRealZ = TRUE;


	////resource index 
	//if(pLandsideBehavior->GetCurrentResource())
	//	track.procNumber = pLandsideBehavior->GetCurrentResource()->GetResourceID();
	//else
	track.procNumber = -1;

	track.state = pOwnerPax->getState();
	setState(pOwnerPax->getState());
	Point _OwnerPreLocation;
	_OwnerPreLocation.init(pax_pre_location.n[VX],pax_pre_location.n[VY],pax_pre_location.n[VZ]);

	ARCVector3 vectorLocation;
	vectorLocation = getPoint();
	//ASSERT(m_type.GetTypeIndex() != 0);
	CNonPaxRelativePosSpec* pNonPaxRelPosSpec = m_pPerson->GetTerminal()->GetNonPaxRelativePosSpec();
	ASSERT( NULL != pNonPaxRelPosSpec );
	CPoint2008 ptRelatePos;
	ARCVector4 rotation;
	pNonPaxRelPosSpec->GetNonPaxRelatePosition(ptRelatePos, rotation, m_pPerson->getType().GetTypeIndex() );
	track.m_bWithOwner = true;
	track.m_bVisible = pNonPaxRelPosSpec->GetTypeItemVisible(m_pPerson->getType().GetTypeIndex());


	/////////////////////////////////////////////////////////
			// pretrack
	long lLogCount = m_pPerson->getLogEntry().getCurrentCount();

	Point pre_location;
	pre_location.init(getPoint().n[VX],getPoint().n[VY],getPoint().n[VZ]);
	//get pretrack if it exist
	MobEventStruct *PreTrack = m_pPerson->getLogEntry().getPreEvent();	
	//if( lLogCount >=1 )
	//{
	//	PreTrack = m_pPerson->getLogEntry().getEvent( lLogCount-1 );	
	//}


	if(  PreTrack == NULL || PreTrack->followowner == false )
	{
		if( getPoint() != getDest() )
		{
			ARCVector3 vectorPt(getPoint(), getDest()); 
			Point vector;
			vector.init(vectorPt.n[VX],vectorPt.n[VY],vectorPt.n[VZ]);
			Point latPoint (vector.perpendicular());
			latPoint.length (m_pPerson->getSideStep());

			setLocation(getDest()+latPoint);
			setDestination(getPoint());
		}
	}
	else	//PreTrack.followowner = true
	{
		//write the first log item
		if(pOwnerPax) 
		{
			writeCurrentLogItem(pOwnerPax,_OwnerPreLocation, firstLog);
			
			MobEventStruct evntItem = *PreTrack;

			// add the first log entry
			evntItem.x = static_cast<float>(getPoint().n[VX]);
			evntItem.y = static_cast<float>(getPoint().n[VY]);
			//evntItem.z = static_cast<short>(getPoint().n[VZ]);
			
			//if the previous item is terminal log
			//here need to set the flag to real Z
			//evntItem.m_IsRealZ = TRUE;
			//evntItem.m_RealZ= static_cast<float>(getPoint().n[VZ]);
		
			m_pPerson->getLogEntry().addEvent (evntItem);
		}

		// use following code to repeat last log for all follower one by one
		RepeatFollowersLastLogWithNewDest();		

		// write the second log item
		writeCurrentLogItem(pOwnerPax,_OwnerPreLocation, secondLog);
	}	


	track.x = static_cast<float>(getPoint().n[VX]);
	track.y = static_cast<float>(getPoint().n[VY]);
	track.z = static_cast<short>(getPoint().n[VZ]);
	track.m_RealZ = (float)ptRelatePos.getZ() + track.z;
	/////////////////////////////////////////////////////////
	m_pPerson->getLogEntry().addEvent (track);
	//TRACE("\r\n 2Time: %d   X = %f, Y = %f, Z = %f \r\n", track.time, track.x, track.y, track.z);
	writeFollowerLog(time,_bBackup, bOffset);
	return true;
}