Example #1
0
void CClause::RecalculateRelationsCoordinates(int iClause)
{
	for(SVI pSynVar = m_SynVariants.begin() ; pSynVar != m_SynVariants.end(); pSynVar++ )
	{
		CMorphVariant& V = *pSynVar;
        for(int i = 0 ; i < V.m_vectorGroups.m_Relations.size() ; i++ )
		{
			CRelation& rel = V.m_vectorGroups.m_Relations[i];

			if( GetUnitType(UnitNoByWordNo(rel.m_iFirstWord)) == EClause ) 
			{
				rel.m_iFirstWord = FillRelNodeByClauseUnit(V, UnitNoByWordNo(rel.m_iFirstWord), rel.m_SourceClause );
				rel.m_SourceType = EClause;
			}
			else
				rel.m_SourceClause.m_iClauseNo = iClause;

			if( GetUnitType(UnitNoByWordNo(rel.m_iLastWord)) == EClause )
			{
				rel.m_iLastWord = FillRelNodeByClauseUnit(V, UnitNoByWordNo(rel.m_iLastWord), rel.m_TargetClause );
				rel.m_TargetType = EClause;					 
			}
			else
				rel.m_TargetClause.m_iClauseNo = iClause;
			rel.AssertValid();
			if ( -1 == rel.m_iLastWord || -1 == rel.m_iFirstWord )
				m_pSent->OutputErrorString("Syntactic relations coordinates for Semantics are wrong!");
		}
	}
}
Example #2
0
void CStructure::InstallUpdate(CNetworkParameters* p)
{
	size_t x = p->ui2;
	size_t y = p->ui3;

	CUpdateItem* pUpdate = &DigitanksGame()->GetUpdateGrid()->m_aUpdates[x][y];

	if (pUpdate->m_eStructure != GetUnitType())
		return;

	switch (pUpdate->m_eUpdateType)
	{
	case UPDATETYPE_BANDWIDTH:
		m_flBandwidth += pUpdate->m_flValue;
		break;

	case UPDATETYPE_PRODUCTION:
		m_flPowerProduced += pUpdate->m_flValue;
		break;

	case UPDATETYPE_FLEETSUPPLY:
		m_iFleetSupply += (size_t)pUpdate->m_flValue;
		break;

	case UPDATETYPE_SUPPORTENERGY:
		m_iEnergyBonus += (size_t)pUpdate->m_flValue;
		break;

	case UPDATETYPE_SUPPORTRECHARGE:
		m_flRechargeBonus += (float)pUpdate->m_flValue;
		break;
	}
}
Example #3
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CUnitBase::OnRestore()
{
	BaseClass::OnRestore();

#ifndef CLIENT_DLL
	OnUnitTypeChanged( GetUnitType() );
#endif // CLIENT_DLL
}
Example #4
0
Unit* UnitListComponent::GetReadUnitReference(INT32 UnitRef)
{
	ERROR2IF(pDocUnitList == NULL,FALSE,"UnitListComponent::GetReadUnitReference called with no doc unit list pointer");

TRACEUSER( "Neville", _T("GetReadUnitReference for ref %d\n"), UnitRef);
	// First check to see if the unit refers to any of the built in units.
	// These will have negative record numbers
	Unit			   *pUnit = NULL;
	if (UnitRef <= 0)
	{
		UnitType type = GetUnitType(UnitRef);

		// If we succesfully converted the unit into a type then find the unit
		if (type != NOTYPE)
		{
			// Find this unit type in the current document list
			pUnit = pDocUnitList->FindUnit(type);
		}
		else
			ERROR2(NULL,"BitmapListComponent::GetReadBitmapReference negative UnitRef is unknown");
	}
	else
	{
		// Try and find the specified record number in our loaded user unit list
		CMapLongToPtr::const_iterator iter = pImpUserUnitMap->find( UnitRef );
		/*BOOL			ok =*/ pImpUserUnitMap->end();/* != iter;*/
		pUnit = (Unit *)iter->second;
		// if ok then pUnit will be the pointer to the required unit
		// so return this.
		// if not ok then pUnit will still be null.
				
		// If not found then this is a problem as a bitmap must have been defined before its being
		// referenced 
		if (pUnit == NULL)
		{
			// If we have a pFilter then ask the default warning handle to append our message
			if (pCamFilter)
			{
				if (!WarnedBefore)
				{
					pCamFilter->AppendWarning(_R(IDS_NATIVE_UNITSWARNING));
					WarnedBefore = TRUE;
				}

				// Now use a default unit instead, we will use the default page display units
				UnitType PageUnits = pDocUnitList->GetPageUnits();	// The units used to display page measurements
				pUnit = pDocUnitList->FindUnit(PageUnits);	
			}
			else
				ERROR2IF(pUnit == NULL,NULL,"BitmapListComponent::GetReadUnitReference UnitRef cannot be found");
		}
	}

	return pUnit;
}
Example #5
0
void CStructure::DownloadComplete(size_t x, size_t y)
{
	CUpdateItem* pItem = &DigitanksGame()->GetUpdateGrid()->m_aUpdates[x][y];

	if (pItem->m_eStructure != GetUnitType())
		return;

	if (pItem->m_eUpdateClass != UPDATECLASS_STRUCTUREUPDATE)
		return;

	InstallUpdate(x, y);
}
Example #6
0
void CDigitanksEntity::Rescue(CDigitanksEntity* pOther)
{
	if (!m_bImprisoned)
		return;

	if (!pOther)
		return;

	if (!pOther->GetPlayerOwner())
		return;

	if (!pOther->GetPlayerOwner()->IsHumanControlled())
		return;

	// Only suppliers can free structures other than CPUs. Otherwise they'd just go bunk again immediately.
	if (GetUnitType() != STRUCTURE_CPU && dynamic_cast<CStructure*>(this) && !dynamic_cast<CSupplier*>(pOther))
		return;

	if (GetUnitType() == STRUCTURE_CPU)
		pOther->GetDigitanksPlayer()->AddPower(5);

	pOther->GetDigitanksPlayer()->AddUnit(this);

	DigitanksWindow()->GetHUD()->AddPowerupNotification(this, POWERUP_TANK);

	m_bImprisoned = false;
	m_bTakeDamage = true;

	StartTurn();

	CallOutput("OnRescue");

	m_hCageParticles.SetActive(false);

	m_flNextDirtyArea = GameServer()->GetGameTime();
}
Example #7
0
void CDigitanksEntity::RenderAvailableArea(int iArea)
{
	float flAvailableArea = AvailableArea(iArea);

	if (flAvailableArea == 0)
		return;

	float flScoutScale = 1.0f;

	// Scouts have very tall ones so we can see them underneath on the ground.
	if (GetUnitType() == UNIT_SCOUT)
		flScoutScale = 10;

	if (dynamic_cast<CStructure*>(this) && DigitanksGame()->GetControlMode() == MODE_AIM)
		flScoutScale = 10;

	CGameRenderingContext c(GameServer()->GetRenderer(), true);
	c.Translate(GetGlobalOrigin());
	c.Scale(flAvailableArea, flAvailableArea*flScoutScale, flAvailableArea);
	c.RenderSphere();
}
/*
** Incoming on the ROUTE_RUP
** I wrote this while I was tired. Forgive me.
*/
int RIORouteRup( struct rio_info *p, uint Rup, struct Host *HostP, PKT *PacketP )
{
  struct PktCmd *PktCmdP = (struct PktCmd *)PacketP->data;
  struct PktCmd_M *PktReplyP;
  struct CmdBlk *CmdBlkP;
  struct Port *PortP;
  struct Map *MapP;
  struct Top *TopP;
  int ThisLink, ThisLinkMin, ThisLinkMax;
  int port;
  int Mod, Mod1, Mod2;
  ushort RtaType;
  uint RtaUniq;
  uint ThisUnit, ThisUnit2;	/* 2 ids to accommodate 16 port RTA */
  uint OldUnit, NewUnit, OldLink, NewLink;
  char *MyType, *MyName;
  int Lies;
  unsigned long flags;

#ifdef STACK
    RIOStackCheck("RIORouteRup");
#endif
#ifdef CHECK
    CheckPacketP(PacketP);
    CheckHostP(HostP);
    CheckRup(Rup);
    CheckHost(Host);
#endif
  /*
  ** Is this unit telling us it's current link topology?
  */
  if ( RBYTE(PktCmdP->Command) == ROUTE_TOPOLOGY )
  {
    MapP = HostP->Mapping;

    /*
    ** The packet can be sent either by the host or by an RTA.
    ** If it comes from the host, then we need to fill in the
    ** Topology array in the host structure. If it came in
    ** from an RTA then we need to fill in the Mapping structure's
    ** Topology array for the unit.
    */
    if ( Rup >= (ushort)MAX_RUP )
    {
      ThisUnit = HOST_ID;
      TopP = HostP->Topology;
      MyType = "Host";
      MyName = HostP->Name;
      ThisLinkMin = ThisLinkMax = Rup - MAX_RUP;
    }
    else
    {
      ThisUnit = Rup+1;
      TopP = HostP->Mapping[Rup].Topology;
      MyType = "RTA";
      MyName = HostP->Mapping[Rup].Name;
      ThisLinkMin = 0;
      ThisLinkMax = LINKS_PER_UNIT - 1;
    }

    /*
    ** Lies will not be tolerated.
    ** If any pair of links claim to be connected to the same
    ** place, then ignore this packet completely.
    */
    Lies = 0;
    for ( ThisLink=ThisLinkMin + 1; ThisLink <= ThisLinkMax; ThisLink++)
    {
      /*
      ** it won't lie about network interconnect, total disconnects
      ** and no-IDs. (or at least, it doesn't *matter* if it does)
      */
      if ( RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) > (ushort)MAX_RUP )
	  continue;

      for ( NewLink=ThisLinkMin; NewLink < ThisLink; NewLink++ )
      {
        if ( (RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) ==
              RBYTE(PktCmdP->RouteTopology[NewLink].Unit)) &&
	     (RBYTE(PktCmdP->RouteTopology[ThisLink].Link) ==
              RBYTE(PktCmdP->RouteTopology[NewLink].Link)) )
	{
          Lies++;
	}
      }
    }

    if ( Lies )
    {
      rio_dprintk (RIO_DEBUG_ROUTE, "LIES! DAMN LIES! %d LIES!\n",Lies);
      rio_dprintk (RIO_DEBUG_ROUTE, "%d:%c %d:%c %d:%c %d:%c\n",
          RBYTE(PktCmdP->RouteTopology[0].Unit), 
	  'A'+RBYTE(PktCmdP->RouteTopology[0].Link),
          RBYTE(PktCmdP->RouteTopology[1].Unit),
	  'A'+RBYTE(PktCmdP->RouteTopology[1].Link),
          RBYTE(PktCmdP->RouteTopology[2].Unit),
	  'A'+RBYTE(PktCmdP->RouteTopology[2].Link),
          RBYTE(PktCmdP->RouteTopology[3].Unit),
	  'A'+RBYTE(PktCmdP->RouteTopology[3].Link));
      return TRUE;
    }

    /*
    ** now, process each link.
    */
    for ( ThisLink=ThisLinkMin; ThisLink <= ThisLinkMax; ThisLink++)
    {
      /*
      ** this is what it was connected to
      */
      OldUnit = TopP[ThisLink].Unit;
      OldLink = TopP[ThisLink].Link;

      /*
      ** this is what it is now connected to
      */
      NewUnit = RBYTE(PktCmdP->RouteTopology[ThisLink].Unit);
      NewLink = RBYTE(PktCmdP->RouteTopology[ThisLink].Link);

      if ( OldUnit != NewUnit || OldLink != NewLink )
      {
	/*
	** something has changed!
	*/

        if ( NewUnit > MAX_RUP &&
	     NewUnit != ROUTE_DISCONNECT &&
	     NewUnit != ROUTE_NO_ID &&
	     NewUnit != ROUTE_INTERCONNECT )
	{
	    rio_dprintk (RIO_DEBUG_ROUTE, "I have a link from %s %s to unit %d:%d - I don't like it.\n",
		  MyType,
		  MyName,
		  NewUnit,
		  NewLink);
	}
	else
	{
	  /*
	  ** put the new values in
	  */
	  TopP[ThisLink].Unit = NewUnit;
	  TopP[ThisLink].Link = NewLink;

	  RIOSetChange(p);

	  if ( OldUnit <= MAX_RUP )
	  {
	    /*
	    ** If something has become bust, then re-enable them messages
	    */
	    if (! p->RIONoMessage)
		RIOConCon(p,HostP,ThisUnit,ThisLink,OldUnit,OldLink,DISCONNECT);
	  }

	  if ( ( NewUnit <= MAX_RUP ) && !p->RIONoMessage )
	    RIOConCon(p,HostP,ThisUnit,ThisLink,NewUnit,NewLink,CONNECT);

	  if ( NewUnit == ROUTE_NO_ID )
	    rio_dprintk (RIO_DEBUG_ROUTE, "%s %s (%c) is connected to an unconfigured unit.\n",
		    MyType,MyName,'A'+ThisLink);

	  if ( NewUnit == ROUTE_INTERCONNECT )
	  {
	    if (! p->RIONoMessage)
		cprintf("%s '%s' (%c) is connected to another network.\n", MyType,MyName,'A'+ThisLink);
	  }

	  /*
	  ** perform an update for 'the other end', so that these messages
	  ** only appears once. Only disconnect the other end if it is pointing
	  ** at us!
	  */
	  if ( OldUnit == HOST_ID )
	  {
	    if ( HostP->Topology[OldLink].Unit == ThisUnit &&
		 HostP->Topology[OldLink].Link == ThisLink )
	    {
	      rio_dprintk (RIO_DEBUG_ROUTE, "SETTING HOST (%c) TO DISCONNECTED!\n", OldLink+'A');
	      HostP->Topology[OldLink].Unit = ROUTE_DISCONNECT;
	      HostP->Topology[OldLink].Link = NO_LINK;
	    }
	    else
	    {
	      rio_dprintk (RIO_DEBUG_ROUTE, "HOST(%c) WAS NOT CONNECTED TO %s (%c)!\n",
		    OldLink+'A',HostP->Mapping[ThisUnit-1].Name,ThisLink+'A');
	    }
	  }
	  else if ( OldUnit <= MAX_RUP )
	  {
	    if ( HostP->Mapping[OldUnit-1].Topology[OldLink].Unit == ThisUnit &&
	         HostP->Mapping[OldUnit-1].Topology[OldLink].Link == ThisLink )
	    {
	      rio_dprintk (RIO_DEBUG_ROUTE, "SETTING RTA %s (%c) TO DISCONNECTED!\n",
				   HostP->Mapping[OldUnit-1].Name,OldLink+'A');
	      HostP->Mapping[OldUnit-1].Topology[OldLink].Unit=ROUTE_DISCONNECT;
	      HostP->Mapping[OldUnit-1].Topology[OldLink].Link=NO_LINK;
	    }
	    else
	    {
	      rio_dprintk (RIO_DEBUG_ROUTE, "RTA %s (%c) WAS NOT CONNECTED TO %s (%c)\n",
			    HostP->Mapping[OldUnit-1].Name,OldLink+'A',
			    HostP->Mapping[ThisUnit-1].Name,ThisLink+'A');
	    }
	  }
	  if ( NewUnit == HOST_ID )
	  {
	    rio_dprintk (RIO_DEBUG_ROUTE, "MARKING HOST (%c) CONNECTED TO %s (%c)\n",
				NewLink+'A',MyName,ThisLink+'A');
	    HostP->Topology[NewLink].Unit = ThisUnit;
	    HostP->Topology[NewLink].Link = ThisLink;
	  }
	  else if ( NewUnit <= MAX_RUP )
	  {
	    rio_dprintk (RIO_DEBUG_ROUTE, "MARKING RTA %s (%c) CONNECTED TO %s (%c)\n",
	      HostP->Mapping[NewUnit-1].Name,NewLink+'A',MyName,ThisLink+'A');
	    HostP->Mapping[NewUnit-1].Topology[NewLink].Unit=ThisUnit;
	    HostP->Mapping[NewUnit-1].Topology[NewLink].Link=ThisLink;
	  }
	}
	RIOSetChange(p);
	RIOCheckIsolated(p, HostP, OldUnit );
      }
    }
    return TRUE;
  }

  /*
  ** The only other command we recognise is a route_request command
  */
  if ( RBYTE(PktCmdP->Command) != ROUTE_REQUEST )
  {
    rio_dprintk (RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %d ROUTE_RUP\n", 
	   RBYTE(PktCmdP->Command),Rup,(int)HostP);
    return TRUE;
  }
      
  RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) +
	    (RBYTE(PktCmdP->UniqNum[1]) << 8) +
	    (RBYTE(PktCmdP->UniqNum[2]) << 16) +
	    (RBYTE(PktCmdP->UniqNum[3]) << 24);

  /*
  ** Determine if 8 or 16 port RTA
  */
  RtaType = GetUnitType(RtaUniq);

  rio_dprintk (RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq);

  Mod = RBYTE(PktCmdP->ModuleTypes);
  Mod1 = LONYBLE(Mod);
  if (RtaType == TYPE_RTA16)
  {
    /*
    ** Only one ident is set for a 16 port RTA. To make compatible
    ** with 8 port, set 2nd ident in Mod2 to the same as Mod1.
    */
    Mod2 = Mod1;
    rio_dprintk (RIO_DEBUG_ROUTE, "Backplane type is %s (all ports)\n",
     p->RIOModuleTypes[Mod1].Name);
  }
  else
  {
    Mod2 = HINYBLE(Mod);
    rio_dprintk (RIO_DEBUG_ROUTE, "Module types are %s (ports 0-3) and %s (ports 4-7)\n",
     p->RIOModuleTypes[Mod1].Name, p->RIOModuleTypes[Mod2].Name);
  }

  if ( RtaUniq == 0xffffffff )
  {
      ShowPacket( DBG_SPECIAL, PacketP );
  }

  /*
  ** try to unhook a command block from the command free list.
  */
  if ( !(CmdBlkP = RIOGetCmdBlk()) )
  {
    rio_dprintk (RIO_DEBUG_ROUTE, "No command blocks to route RTA! come back later.\n");
    return 0;
  }

  /*
  ** Fill in the default info on the command block
  */
  CmdBlkP->Packet.dest_unit = Rup;
  CmdBlkP->Packet.dest_port = ROUTE_RUP;
  CmdBlkP->Packet.src_unit = HOST_ID;
  CmdBlkP->Packet.src_port = ROUTE_RUP;
  CmdBlkP->Packet.len = PKT_CMD_BIT | 1;
  CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL;
  PktReplyP = (struct PktCmd_M *)CmdBlkP->Packet.data;

  if (! RIOBootOk(p, HostP, RtaUniq))
  {
    rio_dprintk (RIO_DEBUG_ROUTE, "RTA %x tried to get an ID, but does not belong - FOAD it!\n",
	  RtaUniq);
    PktReplyP->Command = ROUTE_FOAD;
    HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
    RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
    return TRUE;
  }

  /*
  ** Check to see if the RTA is configured for this host
  */
  for ( ThisUnit=0; ThisUnit<MAX_RUP; ThisUnit++ )
  {
    rio_dprintk (RIO_DEBUG_ROUTE, "Entry %d Flags=%s %s UniqueNum=0x%x\n",
			ThisUnit,
			HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE ?
					    "Slot-In-Use":"Not In Use",
			HostP->Mapping[ThisUnit].Flags & SLOT_TENTATIVE ? 
					    "Slot-Tentative":"Not Tentative",
			HostP->Mapping[ThisUnit].RtaUniqueNum);

    /*
    ** We have an entry for it.
    */
    if ( (HostP->Mapping[ThisUnit].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) &&
         (HostP->Mapping[ThisUnit].RtaUniqueNum == RtaUniq) )
    {
      if (RtaType == TYPE_RTA16)
      {
	  ThisUnit2 = HostP->Mapping[ThisUnit].ID2 - 1;
          rio_dprintk (RIO_DEBUG_ROUTE, "Found unit 0x%x at slots %d+%d\n",
					    RtaUniq,ThisUnit,ThisUnit2);
      }
      else
          rio_dprintk (RIO_DEBUG_ROUTE, "Found unit 0x%x at slot %d\n",
					    RtaUniq,ThisUnit);
      /*
      ** If we have no knowledge of booting it, then the host has
      ** been re-booted, and so we must kill the RTA, so that it
      ** will be booted again (potentially with new bins)
      ** and it will then re-ask for an ID, which we will service.
      */
      if ( (HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && 
	  !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED) )
      {
	if ( !(HostP->Mapping[ThisUnit].Flags & MSG_DONE) )
	{
	    if ( !p->RIONoMessage )
	        cprintf("RTA '%s' is being updated.\n",HostP->Mapping[ThisUnit].Name);
	    HostP->Mapping[ThisUnit].Flags |= MSG_DONE;
	}
	PktReplyP->Command = ROUTE_FOAD;
	HostP->Copy("RT_FOAD",PktReplyP->CommandText,7);
	RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
	return TRUE;
      }

      /*
      ** Send the ID (entry) to this RTA. The ID number is implicit as
      ** the offset into the table. It is worth noting at this stage
      ** that offset zero in the table contains the entries for the
      ** RTA with ID 1!!!!
      */
      PktReplyP->Command = ROUTE_ALLOCATE;
      PktReplyP->IDNum   = ThisUnit+1;
      if (RtaType == TYPE_RTA16)
      {
        if (HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE)
	    /*
	    ** Adjust the phb and tx pkt dest_units for 2nd block of 8
	    ** only if the RTA has ports associated (SLOT_IN_USE)
	    */
	    RIOFixPhbs(p, HostP, ThisUnit2);
	    PktReplyP->IDNum2  = ThisUnit2+1;
	    rio_dprintk (RIO_DEBUG_ROUTE, "RTA '%s' has been allocated IDs %d+%d\n",
	          HostP->Mapping[ThisUnit].Name, PktReplyP->IDNum, PktReplyP->IDNum2);
      }
      else
      {
	    PktReplyP->IDNum2 = ROUTE_NO_ID;
	    rio_dprintk (RIO_DEBUG_ROUTE, "RTA '%s' has been allocated ID %d\n",
	          HostP->Mapping[ThisUnit].Name,PktReplyP->IDNum);
      }
      HostP->Copy("RT_ALLOCAT",PktReplyP->CommandText,10);

      RIOQueueCmdBlk( HostP, Rup, CmdBlkP);

      /*
      ** If this is a freshly booted RTA, then we need to re-open
      ** the ports, if any where open, so that data may once more
      ** flow around the system!
      */
      if ( (HostP->Mapping[ThisUnit].Flags & RTA_NEWBOOT) &&
	   (HostP->Mapping[ThisUnit].SysPort != NO_PORT) )
      {
	/*
	** look at the ports associated with this beast and
	** see if any where open. If they was, then re-open
	** them, using the info from the tty flags.
	*/
	for ( port=0; port<PORTS_PER_RTA; port++ )
	{
	  PortP = p->RIOPortp[port+HostP->Mapping[ThisUnit].SysPort];
	  if ( PortP->State & (RIO_MOPEN|RIO_LOPEN) )
	  {
	    rio_dprintk (RIO_DEBUG_ROUTE, "Re-opened this port\n");
	    rio_spin_lock_irqsave(&PortP->portSem, flags);
	    PortP->MagicFlags |= MAGIC_REBOOT;
	    rio_spin_unlock_irqrestore(&PortP->portSem, flags);
	  }
	}
	if (RtaType == TYPE_RTA16)
	{
	  for ( port=0; port<PORTS_PER_RTA; port++ )
	  {
	    PortP = p->RIOPortp[port+HostP->Mapping[ThisUnit2].SysPort];
	    if ( PortP->State & (RIO_MOPEN|RIO_LOPEN) )
	    {
	      rio_dprintk (RIO_DEBUG_ROUTE, "Re-opened this port\n");
	      rio_spin_lock_irqsave(&PortP->portSem, flags);
	      PortP->MagicFlags |= MAGIC_REBOOT;
	      rio_spin_unlock_irqrestore(&PortP->portSem, flags);
	    }
	  }
	}
      }

      /*
      ** keep a copy of the module types!
      */
      HostP->UnixRups[ThisUnit].ModTypes = Mod;
      if (RtaType == TYPE_RTA16)
	      HostP->UnixRups[ThisUnit2].ModTypes = Mod;

      /*
      ** If either of the modules on this unit is read-only or write-only
      ** or none-xprint, then we need to transfer that info over to the
      ** relevant ports.
      */
      if ( HostP->Mapping[ThisUnit].SysPort != NO_PORT )
      {
        for ( port=0; port<PORTS_PER_MODULE; port++ )
	{
	  p->RIOPortp[port+HostP->Mapping[ThisUnit].SysPort]->Config &= ~RIO_NOMASK;
	  p->RIOPortp[port+HostP->Mapping[ThisUnit].SysPort]->Config |=
	   p->RIOModuleTypes[Mod1].Flags[port];
	  p->RIOPortp[port+PORTS_PER_MODULE+HostP->Mapping[ThisUnit].SysPort]->Config &= ~RIO_NOMASK;
	  p->RIOPortp[port+PORTS_PER_MODULE+HostP->Mapping[ThisUnit].SysPort]->Config |= p->RIOModuleTypes[Mod2].Flags[port];
	}
	if (RtaType == TYPE_RTA16)
	{
          for ( port=0; port<PORTS_PER_MODULE; port++ )
	  {
	    p->RIOPortp[port+HostP->Mapping[ThisUnit2].SysPort]->Config &= ~RIO_NOMASK;
	    p->RIOPortp[port+HostP->Mapping[ThisUnit2].SysPort]->Config |= p->RIOModuleTypes[Mod1].Flags[port];
	    p->RIOPortp[port+PORTS_PER_MODULE+HostP->Mapping[ThisUnit2].SysPort]->Config &= ~RIO_NOMASK;
	    p->RIOPortp[port+PORTS_PER_MODULE+HostP->Mapping[ThisUnit2].SysPort]->Config |= p->RIOModuleTypes[Mod2].Flags[port];
          }
	}
      }

      /*
      ** Job done, get on with the interrupts!
      */
      return TRUE;
    }
  }
  /*
  ** There is no table entry for this RTA at all.
  **
  ** Lets check to see if we actually booted this unit - if not,
  ** then we reset it and it will go round the loop of being booted
  ** we can then worry about trying to fit it into the table.
  */
  for ( ThisUnit=0; ThisUnit<HostP->NumExtraBooted; ThisUnit++ )
    if ( HostP->ExtraUnits[ThisUnit] == RtaUniq )
      break;
  if ( ThisUnit == HostP->NumExtraBooted && ThisUnit != MAX_EXTRA_UNITS )
  {
    /*
    ** if the unit wasn't in the table, and the table wasn't full, then
    ** we reset the unit, because we didn't boot it.
    ** However, if the table is full, it could be that we did boot
    ** this unit, and so we won't reboot it, because it isn't really
    ** all that disasterous to keep the old bins in most cases. This
    ** is a rather tacky feature, but we are on the edge of reallity
    ** here, because the implication is that someone has connected
    ** 16+MAX_EXTRA_UNITS onto one host.
    */
    static int UnknownMesgDone = 0;

    if ( !UnknownMesgDone )
    {
	if (! p->RIONoMessage)
	    cprintf("One or more unknown RTAs are being updated.\n");
	UnknownMesgDone = 1;
    }

    PktReplyP->Command = ROUTE_FOAD;
    HostP->Copy("RT_FOAD",PktReplyP->CommandText,7);
  }
  else
  {
    /*
    ** we did boot it (as an extra), and there may now be a table
    ** slot free (because of a delete), so we will try to make
    ** a tentative entry for it, so that the configurator can see it
    ** and fill in the details for us.
    */
    if (RtaType == TYPE_RTA16)
    {
	if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0)
	{
	    RIODefaultName(p, HostP, ThisUnit);
	    FillSlot(ThisUnit, ThisUnit2, RtaUniq, HostP);
	}
    }
    else
    {
	if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0)
	{
	    RIODefaultName(p, HostP, ThisUnit);
	    FillSlot(ThisUnit, 0, RtaUniq, HostP);
	}
    }
    PktReplyP->Command = ROUTE_USED;
    HostP->Copy("RT_USED",PktReplyP->CommandText,7);
  }
  RIOQueueCmdBlk( HostP, Rup, CmdBlkP);
  return TRUE;
}
Example #9
0
template<class T> void HTMLElementDisplay<T>::Notify(Notifier *who, NotifyEvent *what)
{
	if (what && (who == mpHtmlElement))
	{
		const WebRect * tmpRect = 	&(((DisplayElement *)(this))->mRect);
		switch (what->event)
		{
		case NOTIFY_PARENT_STYLE_CHANGE:  // intentional fall-through
		case NOTIFY_FORMAT_STYLE_CHANGE:  // intentional fall-through
		case NOTIFY_STYLE_CHANGE:
		{
			WEBC_BOOL invalidated = WEBC_FALSE;
			PresetWebRect oldRect(tmpRect);
			if (SetElementStyle())
			{
				oldRect.Or(tmpRect);
				T::InvalidateRect(&oldRect);
				invalidated = WEBC_TRUE;
			}

			WEBC_UINT16 visible = GetVisibility();
			WEBC_UINT16 display = GetUnitType();
			WEBC_UINT16 position = GetPosition();

			if (InvalidateTUMirror())
			{
				if (!invalidated)
				{
					T::Invalidate();
					invalidated = WEBC_TRUE;
				}

				// GetHTMLParentDisplay will work even if we happen to be
				//  disconnected from the display tree at the moment.
				DisplayElement *parent = GetHTMLParentDisplay();
				if (parent)
				{
					NotifyEvent what(NOTIFIER_TYPE_TEXT_UNIT, NOTIFY_STYLE_CHANGE);
					what.data.oldStyle.display = display;
					what.data.oldStyle.position = position;
					parent->Notify((TextUnit *) this, &what);
				}
			}

			if (!invalidated)
			{
				if (visible != GetVisibility())
				{
					T::Invalidate();
					invalidated = WEBC_TRUE;
				}
			}
			break;
		}

		case NOTIFY_PARENT_DISPLAY_STYLE_CHANGE:  // intentional fall-through
		case NOTIFY_DISPLAY_STYLE_CHANGE:
		{
			WEBC_BOOL invalidated = WEBC_FALSE;
			PresetWebRect oldRect(tmpRect);
			if (SetElementStyle())
			{
				oldRect.Or(tmpRect);
				T::InvalidateRect(&oldRect);
				invalidated = WEBC_TRUE;
			}

			if (InvalidateVisibility())
			{
				if (!invalidated)
				{
					T::Invalidate();
					invalidated = WEBC_TRUE;
				}
			}

			if (InvalidateZIndex())
			{
				DisplayElement *parent = GetHTMLParentDisplay();
				if (parent)
				{
					NotifyEvent what(NOTIFIER_TYPE_TEXT_UNIT, NOTIFY_ZINDEX_CHANGE);
					parent->Notify((TextUnit*) this, &what);
				}

				if (!invalidated)
				{
					T::Invalidate();
					invalidated = WEBC_TRUE;
				}
			}
			break;
		}

		default:
			break;
		}
	}

	T::Notify(who, what);
}
Example #10
0
CPLErr GDALPamRasterBand::CloneInfo( GDALRasterBand *poSrcBand, 
                                     int nCloneFlags )

{
    int bOnlyIfMissing = nCloneFlags & GCIF_ONLY_IF_MISSING;
    int bSuccess;
    int nSavedMOFlags = GetMOFlags();

    PamInitialize();

/* -------------------------------------------------------------------- */
/*      Supress NotImplemented error messages - mainly needed if PAM    */
/*      disabled.                                                       */
/* -------------------------------------------------------------------- */
    SetMOFlags( nSavedMOFlags | GMO_IGNORE_UNIMPLEMENTED );

/* -------------------------------------------------------------------- */
/*      Metadata                                                        */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_BAND_METADATA )
    {
        if( poSrcBand->GetMetadata() != NULL )
        {
            if( !bOnlyIfMissing 
             || CSLCount(GetMetadata()) != CSLCount(poSrcBand->GetMetadata()) )
            {
                SetMetadata( poSrcBand->GetMetadata() );
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      Band description.                                               */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_BAND_DESCRIPTION )
    {
        if( strlen(poSrcBand->GetDescription()) > 0 )
        {
            if( !bOnlyIfMissing || strlen(GetDescription()) == 0 )
                GDALPamRasterBand::SetDescription( poSrcBand->GetDescription());
        }
    }

/* -------------------------------------------------------------------- */
/*      NODATA                                                          */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_NODATA )
    {
        double dfNoData = poSrcBand->GetNoDataValue( &bSuccess );
        
        if( bSuccess )
        {
            if( !bOnlyIfMissing 
                || GetNoDataValue( &bSuccess ) != dfNoData 
                || !bSuccess )
                GDALPamRasterBand::SetNoDataValue( dfNoData );
        }
    }

/* -------------------------------------------------------------------- */
/*      Offset/scale                                                    */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_SCALEOFFSET )
    {
        double dfOffset = poSrcBand->GetOffset( &bSuccess );
        
        if( bSuccess )
        {
            if( !bOnlyIfMissing || GetOffset() != dfOffset )
                GDALPamRasterBand::SetOffset( dfOffset );
        }

        double dfScale = poSrcBand->GetScale( &bSuccess );
        
        if( bSuccess )
        {
            if( !bOnlyIfMissing || GetScale() != dfScale )
                GDALPamRasterBand::SetScale( dfScale );
        }
    }

/* -------------------------------------------------------------------- */
/*      Unittype.                                                       */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_UNITTYPE )
    {
        if( strlen(poSrcBand->GetUnitType()) > 0 )
        {
            if( !bOnlyIfMissing 
                || !EQUAL(GetUnitType(),poSrcBand->GetUnitType()) )
            {
                GDALPamRasterBand::SetUnitType( poSrcBand->GetUnitType() );
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      ColorInterp                                                     */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_COLORINTERP )
    {
        if( poSrcBand->GetColorInterpretation() != GCI_Undefined )
        {
            if( !bOnlyIfMissing
                || poSrcBand->GetColorInterpretation() 
                != GetColorInterpretation() )
                GDALPamRasterBand::SetColorInterpretation( 
                    poSrcBand->GetColorInterpretation() );
        }
    }

/* -------------------------------------------------------------------- */
/*      color table.                                                    */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_COLORTABLE )
    {
        if( poSrcBand->GetColorTable() != NULL )
        {
            if( !bOnlyIfMissing || GetColorTable() == NULL )
            {
                GDALPamRasterBand::SetColorTable( 
                    poSrcBand->GetColorTable() );
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      Raster Attribute Table.                                         */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_RAT )
    {
        const GDALRasterAttributeTable *poRAT = poSrcBand->GetDefaultRAT();

        if( poRAT != NULL )
        {
            if( !bOnlyIfMissing || GetDefaultRAT() == NULL )
            {
                GDALPamRasterBand::SetDefaultRAT( poRAT );
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      Restore MO flags.                                               */
/* -------------------------------------------------------------------- */
    SetMOFlags( nSavedMOFlags );

    return CE_None;
}
Example #11
0
float CStructure::ConstructionCost() const
{
	return DigitanksGame()->GetConstructionCost(GetUnitType());
}
Example #12
0
void CStructure::DrawSchema(int x, int y, int w, int h)
{
	CRenderingContext c(GameServer()->GetRenderer(), true);
	c.SetBlend(BLEND_ALPHA);
	c.SetColor(Color(255, 255, 255));

	float flYPosition = (float)y + h;
	float flXPosition = (float)x + w + 20;

	int iIconFontSize = 11;
	tstring sFont = "text";
	float flIconFontHeight = glgui::RootPanel()->GetFontHeight(sFont, iIconFontSize) + 2;

	if (IsConstructing())
	{
		tstring sTurns = tsprintf(tstring("Turns To Construct: %d"), GetTurnsRemainingToConstruct());
		float flWidth = glgui::RootPanel()->GetTextWidth(sTurns, sTurns.length(), sFont, iIconFontSize);
		glgui::CLabel::PaintText(sTurns, sTurns.length(), sFont, iIconFontSize, flXPosition - flWidth, (float)y);
		return;
	}

	if (IsUpgrading())
	{
		tstring sTurns = tsprintf(tstring("Turns To Upgrade: %d"), GetTurnsRemainingToUpgrade());
		float flWidth = glgui::RootPanel()->GetTextWidth(sTurns, sTurns.length(), sFont, iIconFontSize);
		glgui::CLabel::PaintText(sTurns, sTurns.length(), sFont, iIconFontSize, flXPosition - flWidth, (float)y);
		return;
	}

	if (GetUnitType() == STRUCTURE_CPU)
	{
		CCPU* pCPU = static_cast<CCPU*>(this);
		if (pCPU->IsProducing())
		{
			tstring sTurns = "Rogue: 1";	// It only ever takes one turn to make a rogue.
			float flWidth = glgui::RootPanel()->GetTextWidth(sTurns, sTurns.length(), sFont, iIconFontSize);
			glgui::CLabel::PaintText(sTurns, sTurns.length(), sFont, iIconFontSize, flXPosition - flWidth, (float)y);
		}
	}
	else if (GetUnitType() == STRUCTURE_TANKLOADER || GetUnitType() == STRUCTURE_INFANTRYLOADER || GetUnitType() == STRUCTURE_ARTILLERYLOADER)
	{
		CLoader* pLoader = static_cast<CLoader*>(this);
		if (pLoader->IsProducing())
		{
			tstring sUnit;
			if (pLoader->GetBuildUnit() == UNIT_INFANTRY)
				sUnit = "Resistor";
			else if (pLoader->GetBuildUnit() == UNIT_ARTILLERY)
				sUnit = "Artillery";
			else
				sUnit = "Digitank";

			tstring sTurns = tsprintf(sUnit + ": %d", pLoader->GetTurnsRemainingToProduce());
			float flWidth = glgui::RootPanel()->GetTextWidth(sTurns, sTurns.length(), sFont, iIconFontSize);
			glgui::CLabel::PaintText(sTurns, sTurns.length(), sFont, iIconFontSize, flXPosition - flWidth, (float)y);
		}
	}

	if (Bandwidth() > 0)
	{
		tstring sBandwidth = tsprintf(tstring(": %.1f"), Bandwidth());
		float flWidth = glgui::RootPanel()->GetTextWidth(sBandwidth, sBandwidth.length(), sFont, iIconFontSize);

		DigitanksWindow()->GetHUD()->PaintHUDSheet("BandwidthIcon", flXPosition - flWidth - flIconFontHeight, flYPosition - flIconFontHeight + 5, flIconFontHeight, flIconFontHeight);

		glgui::CLabel::PaintText(sBandwidth, sBandwidth.length(), sFont, iIconFontSize, flXPosition - flWidth, flYPosition);

		flYPosition -= flIconFontHeight;
	}

	if (FleetPoints() > 0)
	{
		tstring sFleetPoints = tsprintf(tstring(": %d"), FleetPoints());
		float flWidth = glgui::RootPanel()->GetTextWidth(sFleetPoints, sFleetPoints.length(), sFont, iIconFontSize);

		DigitanksWindow()->GetHUD()->PaintHUDSheet("FleetPointsIcon", flXPosition - flWidth - flIconFontHeight, flYPosition - flIconFontHeight + 5, flIconFontHeight, flIconFontHeight);

		glgui::CLabel::PaintText(sFleetPoints, sFleetPoints.length(), sFont, iIconFontSize, flXPosition - flWidth, flYPosition);

		flYPosition -= flIconFontHeight;
	}

	if (Power() > 0)
	{
		tstring sPower = tsprintf(tstring(": %.1f"), Power());
		float flWidth = glgui::RootPanel()->GetTextWidth(sPower, sPower.length(), sFont, iIconFontSize);

		DigitanksWindow()->GetHUD()->PaintHUDSheet("PowerIcon", (flXPosition - flWidth - flIconFontHeight), (flYPosition - flIconFontHeight) + 5, flIconFontHeight, flIconFontHeight);

		glgui::CLabel::PaintText(sPower, sPower.length(), sFont, iIconFontSize, flXPosition - flWidth, flYPosition);

		flYPosition -= flIconFontHeight;
	}
}
Example #13
0
int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP)
{
    struct Port *PortP;
    unsigned int SubEnt;
    unsigned int HostPort;
    unsigned int SysPort;
    u16 RtaType;
    unsigned long flags;

    ;

    /*
     ** We need to tell the UnixRups which sysport the rup corresponds to
     */
    HostP->UnixRups[HostMapP->ID - 1].BaseSysPort = HostMapP->SysPort;

    if (HostMapP->SysPort == NO_PORT)
        return (0);

    RtaType = GetUnitType(HostMapP->RtaUniqueNum);
    ;

    /*
     ** now map each of its eight ports
     */
    for (SubEnt = 0; SubEnt < PORTS_PER_RTA; SubEnt++) {
        ;
        SysPort = HostMapP->SysPort + SubEnt;	/* portnumber within system */
        /* portnumber on host */

        HostPort = (HostMapP->ID - 1) * PORTS_PER_RTA + SubEnt;

        ;
        PortP = p->RIOPortp[SysPort];
        ;

        /*
         ** Point at all the real neat data structures
         */
        rio_spin_lock_irqsave(&PortP->portSem, flags);
        PortP->HostP = HostP;
        PortP->Caddr = HostP->Caddr;

        /*
         ** The PhbP cannot be filled in yet
         ** unless the host has been booted
         */
        if ((HostP->Flags & RUN_STATE) == RC_RUNNING) {
            struct PHB __iomem *PhbP = PortP->PhbP = &HostP->PhbP[HostPort];
            PortP->TxAdd = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_add));
            PortP->TxStart = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_start));
            PortP->TxEnd = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_end));
            PortP->RxRemove = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_remove));
            PortP->RxStart = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_start));
            PortP->RxEnd = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_end));
        } else
            PortP->PhbP = NULL;

        /*
         ** port related flags
         */
        PortP->HostPort = HostPort;
        /*
         ** For each part of a 16 port RTA, RupNum is ID - 1.
         */
        PortP->RupNum = HostMapP->ID - 1;
        if (HostMapP->Flags & RTA16_SECOND_SLOT) {
            PortP->ID2 = HostMapP->ID2 - 1;
            PortP->SecondBlock = 1;
        } else {
            PortP->ID2 = 0;
            PortP->SecondBlock = 0;
        }
        PortP->RtaUniqueNum = HostMapP->RtaUniqueNum;

        /*
         ** If the port was already mapped then thats all we need to do.
         */
        if (PortP->Mapped) {
            rio_spin_unlock_irqrestore(&PortP->portSem, flags);
            continue;
        } else
            HostMapP->Flags &= ~RTA_NEWBOOT;

        PortP->State = 0;
        PortP->Config = 0;
        /*
         ** Check out the module type - if it is special (read only etc.)
         ** then we need to set flags in the PortP->Config.
         ** Note: For 16 port RTA, all ports are of the same type.
         */
        if (RtaType == TYPE_RTA16) {
            PortP->Config |= p->RIOModuleTypes[HostP->UnixRups[HostMapP->ID - 1].ModTypes].Flags[SubEnt % PORTS_PER_MODULE];
        } else {
            if (SubEnt < PORTS_PER_MODULE)
                PortP->Config |= p->RIOModuleTypes[LONYBLE(HostP->UnixRups[HostMapP->ID - 1].ModTypes)].Flags[SubEnt % PORTS_PER_MODULE];
            else
                PortP->Config |= p->RIOModuleTypes[HINYBLE(HostP->UnixRups[HostMapP->ID - 1].ModTypes)].Flags[SubEnt % PORTS_PER_MODULE];
        }

        /*
         ** more port related flags
         */
        PortP->PortState = 0;
        PortP->ModemLines = 0;
        PortP->ModemState = 0;
        PortP->CookMode = COOK_WELL;
        PortP->ParamSem = 0;
        PortP->FlushCmdBodge = 0;
        PortP->WflushFlag = 0;
        PortP->MagicFlags = 0;
        PortP->Lock = 0;
        PortP->Store = 0;
        PortP->FirstOpen = 1;

        /*
         ** Buffers 'n things
         */
        PortP->RxDataStart = 0;
        PortP->Cor2Copy = 0;
        PortP->Name = &HostMapP->Name[0];
        PortP->statsGather = 0;
        PortP->txchars = 0;
        PortP->rxchars = 0;
        PortP->opens = 0;
        PortP->closes = 0;
        PortP->ioctls = 0;
        if (PortP->TxRingBuffer)
            memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
        else if (p->RIOBufferSize) {
            PortP->TxRingBuffer = kzalloc(p->RIOBufferSize, GFP_KERNEL);
        }
        PortP->TxBufferOut = 0;
        PortP->TxBufferIn = 0;
        PortP->Debug = 0;
        /*
         ** LastRxTgl stores the state of the rx toggle bit for this
         ** port, to be compared with the state of the next pkt received.
         ** If the same, we have received the same rx pkt from the RTA
         ** twice. Initialise to a value not equal to PHB_RX_TGL or 0.
         */
        PortP->LastRxTgl = ~(u8) PHB_RX_TGL;

        /*
         ** and mark the port as usable
         */
        PortP->Mapped = 1;
        rio_spin_unlock_irqrestore(&PortP->portSem, flags);
    }
    if (HostMapP->SysPort < p->RIOFirstPortsMapped)
        p->RIOFirstPortsMapped = HostMapP->SysPort;
    if (HostMapP->SysPort > p->RIOLastPortsMapped)
        p->RIOLastPortsMapped = HostMapP->SysPort;

    return 0;
}
Example #14
0
int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT __iomem * PacketP)
{
	struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *) PacketP->data;
	struct PktCmd_M *PktReplyP;
	struct CmdBlk *CmdBlkP;
	struct Port *PortP;
	struct Map *MapP;
	struct Top *TopP;
	int ThisLink, ThisLinkMin, ThisLinkMax;
	int port;
	int Mod, Mod1, Mod2;
	unsigned short RtaType;
	unsigned int RtaUniq;
	unsigned int ThisUnit, ThisUnit2;	
	unsigned int OldUnit, NewUnit, OldLink, NewLink;
	char *MyType, *MyName;
	int Lies;
	unsigned long flags;

	
	if (readb(&PktCmdP->Command) == ROUTE_TOPOLOGY) {
		MapP = HostP->Mapping;

		
		if (Rup >= (unsigned short) MAX_RUP) {
			ThisUnit = HOST_ID;
			TopP = HostP->Topology;
			MyType = "Host";
			MyName = HostP->Name;
			ThisLinkMin = ThisLinkMax = Rup - MAX_RUP;
		} else {
			ThisUnit = Rup + 1;
			TopP = HostP->Mapping[Rup].Topology;
			MyType = "RTA";
			MyName = HostP->Mapping[Rup].Name;
			ThisLinkMin = 0;
			ThisLinkMax = LINKS_PER_UNIT - 1;
		}

		
		Lies = 0;
		for (ThisLink = ThisLinkMin + 1; ThisLink <= ThisLinkMax; ThisLink++) {
			
			if (readb(&PktCmdP->RouteTopology[ThisLink].Unit) > (unsigned short) MAX_RUP)
				continue;

			for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) {
				if ((readb(&PktCmdP->RouteTopology[ThisLink].Unit) == readb(&PktCmdP->RouteTopology[NewLink].Unit)) && (readb(&PktCmdP->RouteTopology[ThisLink].Link) == readb(&PktCmdP->RouteTopology[NewLink].Link))) {
					Lies++;
				}
			}
		}

		if (Lies) {
			rio_dprintk(RIO_DEBUG_ROUTE, "LIES! DAMN LIES! %d LIES!\n", Lies);
			rio_dprintk(RIO_DEBUG_ROUTE, "%d:%c %d:%c %d:%c %d:%c\n",
				    readb(&PktCmdP->RouteTopology[0].Unit),
				    'A' + readb(&PktCmdP->RouteTopology[0].Link),
				    readb(&PktCmdP->RouteTopology[1].Unit),
				    'A' + readb(&PktCmdP->RouteTopology[1].Link), readb(&PktCmdP->RouteTopology[2].Unit), 'A' + readb(&PktCmdP->RouteTopology[2].Link), readb(&PktCmdP->RouteTopology[3].Unit), 'A' + readb(&PktCmdP->RouteTopology[3].Link));
			return 1;
		}

		
		for (ThisLink = ThisLinkMin; ThisLink <= ThisLinkMax; ThisLink++) {
			
			OldUnit = TopP[ThisLink].Unit;
			OldLink = TopP[ThisLink].Link;

			
			NewUnit = readb(&PktCmdP->RouteTopology[ThisLink].Unit);
			NewLink = readb(&PktCmdP->RouteTopology[ThisLink].Link);

			if (OldUnit != NewUnit || OldLink != NewLink) {
				

				if (NewUnit > MAX_RUP && NewUnit != ROUTE_DISCONNECT && NewUnit != ROUTE_NO_ID && NewUnit != ROUTE_INTERCONNECT) {
					rio_dprintk(RIO_DEBUG_ROUTE, "I have a link from %s %s to unit %d:%d - I don't like it.\n", MyType, MyName, NewUnit, NewLink);
				} else {
					
					TopP[ThisLink].Unit = NewUnit;
					TopP[ThisLink].Link = NewLink;

					RIOSetChange(p);

					if (OldUnit <= MAX_RUP) {
						
						if (!p->RIONoMessage)
							RIOConCon(p, HostP, ThisUnit, ThisLink, OldUnit, OldLink, DISCONNECT);
					}

					if ((NewUnit <= MAX_RUP) && !p->RIONoMessage)
						RIOConCon(p, HostP, ThisUnit, ThisLink, NewUnit, NewLink, CONNECT);

					if (NewUnit == ROUTE_NO_ID)
						rio_dprintk(RIO_DEBUG_ROUTE, "%s %s (%c) is connected to an unconfigured unit.\n", MyType, MyName, 'A' + ThisLink);

					if (NewUnit == ROUTE_INTERCONNECT) {
						if (!p->RIONoMessage)
							printk(KERN_DEBUG "rio: %s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink);
					}

					
					if (OldUnit == HOST_ID) {
						if (HostP->Topology[OldLink].Unit == ThisUnit && HostP->Topology[OldLink].Link == ThisLink) {
							rio_dprintk(RIO_DEBUG_ROUTE, "SETTING HOST (%c) TO DISCONNECTED!\n", OldLink + 'A');
							HostP->Topology[OldLink].Unit = ROUTE_DISCONNECT;
							HostP->Topology[OldLink].Link = NO_LINK;
						} else {
							rio_dprintk(RIO_DEBUG_ROUTE, "HOST(%c) WAS NOT CONNECTED TO %s (%c)!\n", OldLink + 'A', HostP->Mapping[ThisUnit - 1].Name, ThisLink + 'A');
						}
					} else if (OldUnit <= MAX_RUP) {
						if (HostP->Mapping[OldUnit - 1].Topology[OldLink].Unit == ThisUnit && HostP->Mapping[OldUnit - 1].Topology[OldLink].Link == ThisLink) {
							rio_dprintk(RIO_DEBUG_ROUTE, "SETTING RTA %s (%c) TO DISCONNECTED!\n", HostP->Mapping[OldUnit - 1].Name, OldLink + 'A');
							HostP->Mapping[OldUnit - 1].Topology[OldLink].Unit = ROUTE_DISCONNECT;
							HostP->Mapping[OldUnit - 1].Topology[OldLink].Link = NO_LINK;
						} else {
							rio_dprintk(RIO_DEBUG_ROUTE, "RTA %s (%c) WAS NOT CONNECTED TO %s (%c)\n", HostP->Mapping[OldUnit - 1].Name, OldLink + 'A', HostP->Mapping[ThisUnit - 1].Name, ThisLink + 'A');
						}
					}
					if (NewUnit == HOST_ID) {
						rio_dprintk(RIO_DEBUG_ROUTE, "MARKING HOST (%c) CONNECTED TO %s (%c)\n", NewLink + 'A', MyName, ThisLink + 'A');
						HostP->Topology[NewLink].Unit = ThisUnit;
						HostP->Topology[NewLink].Link = ThisLink;
					} else if (NewUnit <= MAX_RUP) {
						rio_dprintk(RIO_DEBUG_ROUTE, "MARKING RTA %s (%c) CONNECTED TO %s (%c)\n", HostP->Mapping[NewUnit - 1].Name, NewLink + 'A', MyName, ThisLink + 'A');
						HostP->Mapping[NewUnit - 1].Topology[NewLink].Unit = ThisUnit;
						HostP->Mapping[NewUnit - 1].Topology[NewLink].Link = ThisLink;
					}
				}
				RIOSetChange(p);
				RIOCheckIsolated(p, HostP, OldUnit);
			}
		}
		return 1;
	}

	
	if (readb(&PktCmdP->Command) != ROUTE_REQUEST) {
		rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %p ROUTE_RUP\n", readb(&PktCmdP->Command), Rup, HostP);
		return 1;
	}

	RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);

	
	RtaType = GetUnitType(RtaUniq);

	rio_dprintk(RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq);

	Mod = readb(&PktCmdP->ModuleTypes);
	Mod1 = LONYBLE(Mod);
	if (RtaType == TYPE_RTA16) {
		
		Mod2 = Mod1;
		rio_dprintk(RIO_DEBUG_ROUTE, "Backplane type is %s (all ports)\n", p->RIOModuleTypes[Mod1].Name);
	} else {
		Mod2 = HINYBLE(Mod);
		rio_dprintk(RIO_DEBUG_ROUTE, "Module types are %s (ports 0-3) and %s (ports 4-7)\n", p->RIOModuleTypes[Mod1].Name, p->RIOModuleTypes[Mod2].Name);
	}

	
	if (!(CmdBlkP = RIOGetCmdBlk())) {
		rio_dprintk(RIO_DEBUG_ROUTE, "No command blocks to route RTA! come back later.\n");
		return 0;
	}

	
	CmdBlkP->Packet.dest_unit = Rup;
	CmdBlkP->Packet.dest_port = ROUTE_RUP;
	CmdBlkP->Packet.src_unit = HOST_ID;
	CmdBlkP->Packet.src_port = ROUTE_RUP;
	CmdBlkP->Packet.len = PKT_CMD_BIT | 1;
	CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL;
	PktReplyP = (struct PktCmd_M *) CmdBlkP->Packet.data;

	if (!RIOBootOk(p, HostP, RtaUniq)) {
		rio_dprintk(RIO_DEBUG_ROUTE, "RTA %x tried to get an ID, but does not belong - FOAD it!\n", RtaUniq);
		PktReplyP->Command = ROUTE_FOAD;
		memcpy(PktReplyP->CommandText, "RT_FOAD", 7);
		RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
		return 1;
	}

	
	for (ThisUnit = 0; ThisUnit < MAX_RUP; ThisUnit++) {
		rio_dprintk(RIO_DEBUG_ROUTE, "Entry %d Flags=%s %s UniqueNum=0x%x\n",
			    ThisUnit, HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE ? "Slot-In-Use" : "Not In Use", HostP->Mapping[ThisUnit].Flags & SLOT_TENTATIVE ? "Slot-Tentative" : "Not Tentative", HostP->Mapping[ThisUnit].RtaUniqueNum);

		
		if ((HostP->Mapping[ThisUnit].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (HostP->Mapping[ThisUnit].RtaUniqueNum == RtaUniq)) {
			if (RtaType == TYPE_RTA16) {
				ThisUnit2 = HostP->Mapping[ThisUnit].ID2 - 1;
				rio_dprintk(RIO_DEBUG_ROUTE, "Found unit 0x%x at slots %d+%d\n", RtaUniq, ThisUnit, ThisUnit2);
			} else
				rio_dprintk(RIO_DEBUG_ROUTE, "Found unit 0x%x at slot %d\n", RtaUniq, ThisUnit);
			
			if ((HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED)) {
				if (!(HostP->Mapping[ThisUnit].Flags & MSG_DONE)) {
					if (!p->RIONoMessage)
						printk(KERN_DEBUG "rio: RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name);
					HostP->Mapping[ThisUnit].Flags |= MSG_DONE;
				}
				PktReplyP->Command = ROUTE_FOAD;
				memcpy(PktReplyP->CommandText, "RT_FOAD", 7);
				RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
				return 1;
			}

			
			PktReplyP->Command = ROUTE_ALLOCATE;
			PktReplyP->IDNum = ThisUnit + 1;
			if (RtaType == TYPE_RTA16) {
				if (HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE)
					
					RIOFixPhbs(p, HostP, ThisUnit2);
				PktReplyP->IDNum2 = ThisUnit2 + 1;
				rio_dprintk(RIO_DEBUG_ROUTE, "RTA '%s' has been allocated IDs %d+%d\n", HostP->Mapping[ThisUnit].Name, PktReplyP->IDNum, PktReplyP->IDNum2);
			} else {
				PktReplyP->IDNum2 = ROUTE_NO_ID;
				rio_dprintk(RIO_DEBUG_ROUTE, "RTA '%s' has been allocated ID %d\n", HostP->Mapping[ThisUnit].Name, PktReplyP->IDNum);
			}
			memcpy(PktReplyP->CommandText, "RT_ALLOCAT", 10);

			RIOQueueCmdBlk(HostP, Rup, CmdBlkP);

			
			if ((HostP->Mapping[ThisUnit].Flags & RTA_NEWBOOT) && (HostP->Mapping[ThisUnit].SysPort != NO_PORT)) {
				
				for (port = 0; port < PORTS_PER_RTA; port++) {
					PortP = p->RIOPortp[port + HostP->Mapping[ThisUnit].SysPort];
					if (PortP->State & (RIO_MOPEN | RIO_LOPEN)) {
						rio_dprintk(RIO_DEBUG_ROUTE, "Re-opened this port\n");
						rio_spin_lock_irqsave(&PortP->portSem, flags);
						PortP->MagicFlags |= MAGIC_REBOOT;
						rio_spin_unlock_irqrestore(&PortP->portSem, flags);
					}
				}
				if (RtaType == TYPE_RTA16) {
					for (port = 0; port < PORTS_PER_RTA; port++) {
						PortP = p->RIOPortp[port + HostP->Mapping[ThisUnit2].SysPort];
						if (PortP->State & (RIO_MOPEN | RIO_LOPEN)) {
							rio_dprintk(RIO_DEBUG_ROUTE, "Re-opened this port\n");
							rio_spin_lock_irqsave(&PortP->portSem, flags);
							PortP->MagicFlags |= MAGIC_REBOOT;
							rio_spin_unlock_irqrestore(&PortP->portSem, flags);
						}
					}
				}
			}

			
			HostP->UnixRups[ThisUnit].ModTypes = Mod;
			if (RtaType == TYPE_RTA16)
				HostP->UnixRups[ThisUnit2].ModTypes = Mod;

			
			if (HostP->Mapping[ThisUnit].SysPort != NO_PORT) {
				for (port = 0; port < PORTS_PER_MODULE; port++) {
					p->RIOPortp[port + HostP->Mapping[ThisUnit].SysPort]->Config &= ~RIO_NOMASK;
					p->RIOPortp[port + HostP->Mapping[ThisUnit].SysPort]->Config |= p->RIOModuleTypes[Mod1].Flags[port];
					p->RIOPortp[port + PORTS_PER_MODULE + HostP->Mapping[ThisUnit].SysPort]->Config &= ~RIO_NOMASK;
					p->RIOPortp[port + PORTS_PER_MODULE + HostP->Mapping[ThisUnit].SysPort]->Config |= p->RIOModuleTypes[Mod2].Flags[port];
				}
				if (RtaType == TYPE_RTA16) {
					for (port = 0; port < PORTS_PER_MODULE; port++) {
						p->RIOPortp[port + HostP->Mapping[ThisUnit2].SysPort]->Config &= ~RIO_NOMASK;
						p->RIOPortp[port + HostP->Mapping[ThisUnit2].SysPort]->Config |= p->RIOModuleTypes[Mod1].Flags[port];
						p->RIOPortp[port + PORTS_PER_MODULE + HostP->Mapping[ThisUnit2].SysPort]->Config &= ~RIO_NOMASK;
						p->RIOPortp[port + PORTS_PER_MODULE + HostP->Mapping[ThisUnit2].SysPort]->Config |= p->RIOModuleTypes[Mod2].Flags[port];
					}
				}
			}

			
			return 1;
		}
	}
	
	for (ThisUnit = 0; ThisUnit < HostP->NumExtraBooted; ThisUnit++)
		if (HostP->ExtraUnits[ThisUnit] == RtaUniq)
			break;
	if (ThisUnit == HostP->NumExtraBooted && ThisUnit != MAX_EXTRA_UNITS) {
		
		static int UnknownMesgDone = 0;

		if (!UnknownMesgDone) {
			if (!p->RIONoMessage)
				printk(KERN_DEBUG "rio: One or more unknown RTAs are being updated.\n");
			UnknownMesgDone = 1;
		}

		PktReplyP->Command = ROUTE_FOAD;
		memcpy(PktReplyP->CommandText, "RT_FOAD", 7);
	} else {
		
		if (RtaType == TYPE_RTA16) {
			if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) {
				RIODefaultName(p, HostP, ThisUnit);
				rio_fill_host_slot(ThisUnit, ThisUnit2, RtaUniq, HostP);
			}
		} else {
			if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) {
				RIODefaultName(p, HostP, ThisUnit);
				rio_fill_host_slot(ThisUnit, 0, RtaUniq, HostP);
			}
		}
		PktReplyP->Command = ROUTE_USED;
		memcpy(PktReplyP->CommandText, "RT_USED", 7);
	}
	RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
	return 1;
}