コード例 #1
0
ファイル: mech.events.c プロジェクト: fstltna/Battletech-MUX
void mech_fall_event(EVENT * e)
{
    MECH *mech = (MECH *) e->data;
    int fallspeed = (int) e->data2;
    int fallen_elev;

    if (Started(mech) && fallspeed >= 0)
	return;
    if (fallspeed <= 0 && (!Started(mech) || !(FlyingT(mech)) ||
	    ((AeroFuel(mech) <= 0) && !AeroFreeFuel(mech)) ||
	    ((MechType(mech) == CLASS_VTOL) &&
		(SectIsDestroyed(mech, ROTOR)))))
	fallspeed -= FALL_ACCEL;
    else
	fallspeed += FALL_ACCEL;
    MarkForLOSUpdate(mech);
    if (MechsElevation(mech) > abs(fallspeed)) {
	MechZ(mech) -= abs(fallspeed);
	MechFZ(mech) = MechZ(mech) * ZSCALE;
	MECHEVENT(mech, EVENT_FALL, mech_fall_event, FALL_TICK, fallspeed);
	return;
    }
    /* Time to hit da ground */
    fallen_elev = factoral(abs(fallspeed));
    mech_notify(mech, MECHALL, "You hit the ground!");
    MechLOSBroadcast(mech, "hits the ground!");
    MechFalls(mech, fallen_elev, 0);
    MechStatus(mech) &= ~JUMPING;
}
コード例 #2
0
int RaptorServer::Start( std::string name )
{
	Data.Properties["name"] = name;
	
	if( IsRunning() )
	{
		Net.SendAllReconnect();
		StopAndWait();
		SDL_Delay( 200 );
	}
	
	Net.NetRate = NetRate;
	Net.UseOutThreads = UseOutThreads;
	
	if( !( Thread = SDL_CreateThread( RaptorServerThread, this ) ) )
	{
		fprintf( stderr, "SDL_CreateThread: %s\n", SDLNet_GetError() );
		return -1;
	}
	
	State = Raptor::State::CONNECTED;
	Started();
	
	return 0;
}
コード例 #3
0
ファイル: failures.c プロジェクト: chazu/btmux
void FailureComputerShutdown(MECH * mech, int weapnum, int weaptype,
							 int section, int critical, int roll,
							 int *modifier, int *type)
{
	if(Started(mech))
		mech_shutdown(mech->mynum, mech, "");
}
コード例 #4
0
ファイル: glue.c プロジェクト: chazu/btmux
static int
load_update4(void *key, void *data, int depth, void *arg)
{
	XCODE *const xcode_obj = data;

	if (xcode_obj->type == GTYPE_MECH) {
		MECH *const mech = (MECH *)xcode_obj;
		MAP *map;

		if (!(map = getMap(mech->mapindex))) {
			/* Ugly kludge */
			if ((map = getMap(Location(mech->mynum))))
				mech_Rsetmapindex(GOD, mech, tprintf("%d",
				                  Location(mech->mynum)));
			if (!(map = getMap(mech->mapindex)))
				return 1;
		}

		if (!Started(mech))
			return 1;
		StartSeeing(mech);
		UpdateRecycling(mech);
		MaybeMove(mech);
	}
	return 1;
}
コード例 #5
0
ファイル: mech.events.c プロジェクト: fstltna/Battletech-MUX
void mech_plos_event(EVENT * e)
{
    MECH *mech = (MECH *) e->data, *target;
    MAP *map;
    int mapvis;
    int maplight;
    float range;
    int i;

    if (!Started(mech))
	return;
    if (!(map = getMap(mech->mapindex)))
	return;
    MECHEVENT(mech, EVENT_PLOS, mech_plos_event, PLOS_TICK, 0);
    if (!MechPNumSeen(mech) && !(MechSpecials(mech) & AA_TECH))
	return;
    mapvis = map->mapvis;
    maplight = map->maplight;
    MechPNumSeen(mech) = 0;
    for (i = 0; i < map->first_free; i++)
	if (map->mechsOnMap[i] > 0 && map->mechsOnMap[i] != mech->mynum)
	    if (!(map->LOSinfo[mech->mapnumber][i] & MECHLOSFLAG_SEEN)) {
		target = FindObjectsData(map->mechsOnMap[i]);
		if (!target)
		    continue;
		range = FlMechRange(map, mech, target);
		MechPNumSeen(mech)++;
		Sensor_DoWeSeeNow(mech, &map->LOSinfo[mech->mapnumber][i],
		    range, -1, -1, target, mapvis, maplight,
		    map->cloudbase, 1, 0);

	    }
}
コード例 #6
0
ファイル: fileparser.cpp プロジェクト: jajuha01/ImageMap
void FileParser::SearchFiles()
{
    QDir directoryToStart(path);
    FindFilesFromDir(directoryToStart);
    emit Started(FileAmount());
    GetGPSData();
}
コード例 #7
0
ファイル: CSOverlay.cpp プロジェクト: ASchurman/Dissent
 void CSOverlay::GroupUpdated()
 {
   GroupHolder *gh = qobject_cast<GroupHolder *>(sender());
   _group = gh->GetGroup();
   if(Started()) {
     _csca->UpdateGroup(_group);
   }
 }
コード例 #8
0
///\brief Performs Torc specific thread initialisation.
void TorcQThread::Initialise(void)
{
    RegisterLoggingThread();
    qsrand(QDateTime::currentDateTime().toTime_t() ^ QTime::currentTime().msec());

    Start();

    emit Started();
}
コード例 #9
0
ファイル: mech.events.c プロジェクト: fstltna/Battletech-MUX
void mech_lateral_event(EVENT * e)
{
    MECH *mech = (MECH *) e->data;
    int latmode = (int) e->data2;

    if (!mech || !Started(mech))
	return;
    mech_notify(mech, MECHALL,
	tprintf("Lateral movement mode change to %s completed.",
	    lateral_modes[latmode].full));
    MechLateral(mech) = lateral_modes[latmode].ofs;
}
コード例 #10
0
void QmitkToolPairNavigationView::SetNavigationUp()
{
  if (m_Source.IsNotNull())
    if (m_Source->IsTracking())
      return;

  mitk::DataStorage* ds = this->GetDefaultDataStorage();
  if (ds == NULL)
  {
    QMessageBox::warning(NULL, "ToolPairNavigation: Error", "can not access DataStorage. Navigation not possible");
    return;
  }

  //1. build up the filter pipeline
  try
  {
    this->SetupIGTPipeline();
  }
  catch(std::exception& e)
  {
    QMessageBox::warning(NULL, "ToolPairNavigation: Error", QString("Error while building the IGT-Pipeline: %1").arg(e.what()));
    this->DestroyIGTPipeline();
    return;
  }
  catch (...)
  {
    QMessageBox::warning(NULL, "ToolPairNavigation: Error", QString("Error while building the IGT-Pipeline."));
    this->DestroyIGTPipeline();
    return;
  }

  //2. start IGT pipeline to display tracking devices (20 Hz update rate -> 50 msec timeout)
  try
  {
    // setup for the bundle's update timer widget
    m_Controls.m_RenderingTimerWidget->SetPurposeLabelText(QString("Navigation"));
    m_Controls.m_RenderingTimerWidget->SetTimerInterval( 50 );

    connect( m_Controls.m_RenderingTimerWidget->GetUpdateTimer() , SIGNAL(timeout()) , this, SLOT (RenderScene()) );
    connect( m_Controls.m_RenderingTimerWidget, SIGNAL(Started()), this, SLOT(StartNavigation()));
    connect( m_Controls.m_RenderingTimerWidget, SIGNAL(Stopped()) , this, SLOT (StopNavigation()));
    connect( m_Controls.m_RenderingTimerWidget, SIGNAL(Stopped()) , m_DistanceWidget, SLOT (SetDistanceLabelValuesInvalid()));

  }
  catch(std::exception& e)
  {
    QMessageBox::warning(NULL, "ToolPairNavigation: Error", QString("Error while starting the IGT-Pipeline: %1").arg(e.what()));
    this->m_Controls.m_RenderingTimerWidget->StopTimer();
    this->DestroyIGTPipeline();
    return;
  }
}
コード例 #11
0
int JtEventServer::EventLoop()
{
	//默认存在一个定时器
	//////JtEventTimer *Timer = new JtEventTimer();
	//////Timer->OnAddToServer(this);

	pEventPairPipe = new JtEventPairPipe();
	pEventPairPipe->AddToServer(this);
	
	//jtprintf("[%s]event_base_dispatch before\n", __FUNCTION__);

	Started();

	//int res = event_base_loop(base,EVLOOP_NO_EXIT_ON_EMPTY);
	int res = event_base_dispatch(base);
	if(res==0)
	{
		jtprintf("[%s]event_base_dispatch out res %d\n", __FUNCTION__, res);
	}
	else if(res==-1)
	{
		jtprintf("[%s]event_base_dispatch error res %d\n", __FUNCTION__, res);
	}
	else if(res==1)
	{
		jtprintf("[%s]event_base_dispatch no event res %d\n", __FUNCTION__, res);
	}
	else
	{
		jtprintf("[%s]event_base_dispatch res %d\n", __FUNCTION__, res);
	}
	
	/////delete Timer;
	delete pEventPairPipe;
	pEventPairPipe = NULL;
	//必须先移除所有的事件,然后再调用event_base_free
	event_base_free(base);

	base = NULL;
	//

	return 0;
}
コード例 #12
0
ファイル: ds.bay.c プロジェクト: gtaylor/btmux
static void mech_enterbay_event(MUXEVENT * e)
{
	MECH *mech = (MECH *) e->data, *ds, *tmpm = NULL;
	long ref = (long) e->data2;
	long bayn;
	int x = 5, y = 5;
	MAP *tmpmap;

	if(!Started(mech) || Uncon(mech) || Jumping(mech) ||
	   (MechType(mech) == CLASS_MECH && (Fallen(mech) || Standing(mech))) ||
	   OODing(mech) || (fabs(MechSpeed(mech)) * 5 >= MMaxSpeed(mech) &&
						fabs(MMaxSpeed(mech)) >= MP1)
	   || (MechType(mech) == CLASS_VTOL && AeroFuel(mech) <= 0))
		return;
	tmpmap = getMap(ref);
	if(!(ds = getMech(tmpmap->onmap)))
		return;
	if(!Find_DS_Bay_In_MechHex(mech, ds, &bayn))
		return;
	/* whee */
	ref = AeroBay(ds, bayn);
	StopBSuitSwarmers(FindObjectsData(mech->mapindex), mech, 1);
	mech_notify(mech, MECHALL, "You enter the bay.");
	MechLOSBroadcast(mech, tprintf("has entered %s at %d,%d.",
								   GetMechID(ds), MechX(mech), MechY(mech)));
	MarkForLOSUpdate(mech);
	if(MechType(mech) == CLASS_MW && !In_Character(ref)) {
		enter_mw_bay(mech, ref);
		return;
	}
	if(MechCarrying(mech) > 0)
		tmpm = getMech(MechCarrying(mech));
	mech_Rsetmapindex(GOD, (void *) mech, tprintf("%d", ref));
	mech_Rsetxy(GOD, (void *) mech, tprintf("%d %d", x, y));
	MechLOSBroadcast(mech, "has entered the bay.");
	loud_teleport(mech->mynum, ref);
	if(tmpm) {
		mech_Rsetmapindex(GOD, (void *) tmpm, tprintf("%d", ref));
		mech_Rsetxy(GOD, (void *) tmpm, tprintf("%d %d", x, y));
		loud_teleport(tmpm->mynum, ref);
	}
}
コード例 #13
0
ファイル: mech.events.c プロジェクト: fstltna/Battletech-MUX
void aero_move_event(EVENT * e)
{
    MECH *mech = (MECH *) e->data;

    if (!Landed(mech)) {
	/* Returns 1 only if we
	   1) Ran out of fuel, and
	   2) Were VTOL, and
	   3) Crashed 
	 */
	if (FuelCheck(mech))
	    return;
	/* Genuine CHEAT :-) */
	if (Started(mech)) {
	    aero_UpdateHeading(mech);
	    aero_UpdateSpeed(mech);
	}
	if (Fallen(mech))
	    MechStartFZ(mech) = MechStartFZ(mech) - 1;
	move_mech(mech);
	if (IsDS(mech) && MechZ(mech) <= (MechElevation(mech) + 5) &&
	    ((event_tick / WEAPON_TICK) % 10) == 0)
	    DS_BlastNearbyMechsAndTrees(mech,
		"You are hit by the DropShip's plasma exhaust!",
		"is hit directly by DropShip's exhaust!",
		"You are hit by the DropShip's plasma exhaust!",
		"is hit by DropShip's exhaust!", "light up and burn.", 8);
	MECHEVENT(mech, EVENT_MOVE, aero_move_event, MOVE_TICK, 0);
    } else if (Landed(mech) && !Fallen(mech) && RollingT(mech)) {
	UpdateHeading(mech);
	UpdateSpeed(mech);
	move_mech(mech);
	if (fabs(MechSpeed(mech)) > 0.0 ||
	    fabs(MechDesiredSpeed(mech)) > 0.0 ||
	    MechDesiredFacing(mech) != MechFacing(mech))
	    if (!FuelCheck(mech))
		MECHEVENT(mech, EVENT_MOVE, aero_move_event, MOVE_TICK, 0);
    }
}
コード例 #14
0
void QmitkIGTTrackingLabView::CreateConnections()
{
  connect( m_ToolBox, SIGNAL(currentChanged(int)), this, SLOT(OnToolBoxCurrentChanged(int)) );

  //connect( m_NDIConfigWidget, SIGNAL(Connected()), m_RenderingTimerWidget, SLOT(EnableWidget()) );
  connect( m_NDIConfigWidget, SIGNAL(Disconnected()), this, SLOT(OnTrackerDisconnected()) );
  connect( m_NDIConfigWidget, SIGNAL(Connected()), this, SLOT(OnSetupNavigation()) );
  connect( m_NDIConfigWidget, SIGNAL(SignalToolNameChanged(int, QString)), this, SLOT(OnChangeToolName(int, QString)) );
  connect( m_NDIConfigWidget, SIGNAL(SignalLoadTool(int, mitk::DataNode::Pointer)), this, SLOT(OnToolLoaded(int, mitk::DataNode::Pointer)) );
  connect( m_NDIConfigWidget, SIGNAL(ToolsAdded(QStringList)), this, SLOT(OnToolsAdded(QStringList)) );
  connect( m_NDIConfigWidget, SIGNAL(RepresentationChanged( int ,mitk::Surface::Pointer )), this, SLOT(ChangeToolRepresentation( int, mitk::Surface::Pointer )));

  connect( m_RegistrationWidget, SIGNAL(AddedTrackingFiducial()), this, SLOT(OnAddRegistrationTrackingFiducial()) );
  connect( m_RegistrationWidget, SIGNAL(PerformFiducialRegistration()), this, SLOT(OnRegisterFiducials()) );

  connect( m_RenderingTimerWidget, SIGNAL(Started()), this, SLOT(OnStartNavigation()) );
  connect( m_RenderingTimerWidget, SIGNAL(Stopped()), this, SLOT(OnStopNavigation()) );

  connect( m_VirtualViewToolSelectionWidget, SIGNAL(SignalUseTool(int, bool)), this, SLOT(OnVirtualCamera(int, bool)));

  connect( m_PermanentRegistrationToolSelectionWidget, SIGNAL(SignalUseTool(int, bool)), this, SLOT(OnPermanentRegistration(int, bool)) );

}
コード例 #15
0
void PlaylistContainer::SetManager(PlaylistManager* manager) {
  manager_ = manager;
  ui_->tab_bar->SetManager(manager);

  connect(ui_->tab_bar, SIGNAL(CurrentIdChanged(int)), manager,
          SLOT(SetCurrentPlaylist(int)));
  connect(ui_->tab_bar, SIGNAL(Rename(int, QString)), manager,
          SLOT(Rename(int, QString)));
  connect(ui_->tab_bar, SIGNAL(Close(int)), manager, SLOT(Close(int)));
  connect(ui_->tab_bar, SIGNAL(PlaylistFavorited(int, bool)), manager,
          SLOT(Favorite(int, bool)));

  connect(ui_->tab_bar, SIGNAL(PlaylistOrderChanged(QList<int>)), manager,
          SLOT(ChangePlaylistOrder(QList<int>)));

  connect(manager, SIGNAL(CurrentChanged(Playlist*)),
          SLOT(SetViewModel(Playlist*)));
  connect(manager, SIGNAL(PlaylistAdded(int, QString, bool)),
          SLOT(PlaylistAdded(int, QString, bool)));
  connect(manager, SIGNAL(PlaylistManagerInitialized()), SLOT(Started()));
  connect(manager, SIGNAL(PlaylistClosed(int)), SLOT(PlaylistClosed(int)));
  connect(manager, SIGNAL(PlaylistRenamed(int, QString)),
          SLOT(PlaylistRenamed(int, QString)));
}
コード例 #16
0
ファイル: mech.events.c プロジェクト: fstltna/Battletech-MUX
int calcStaggerBTHMod(MECH * mech)
{
    int bthMod = 0;
    int tonnageMod = 0;

    if (!Started(mech)) {
	bthMod = 999;
    } else {
	bthMod = StaggerLevel(mech);

	if (MechTons(mech) <= 35)
	    tonnageMod = 1;
	else if (MechTons(mech) <= 55)
	    tonnageMod = 0;
	else if (MechTons(mech) <= 75)
	    tonnageMod = -1;
	else
	    tonnageMod = -2;

	bthMod += tonnageMod;
    }

    return bthMod;
}
コード例 #17
0
  void BufferEdgeListener::CreateEdgeTo(const Address &to)
  {
    if(Stopped()) {
      qWarning() << "Cannot CreateEdgeTo Stopped EL";
      return;
    }

    if(!Started()) {
      qWarning() << "Cannot CreateEdgeTo non-Started EL";
      return;
    }

    const BufferAddress &rem_ba = static_cast<const BufferAddress &>(to);
    BufferEdgeListener *remote_el = _el_map.value(rem_ba.GetId());
    if(remote_el == 0) {
      qDebug() << "Attempting to create an Edge to an EL that doesn't exist from " <<
        GetAddress().ToString() << " to " << to.ToString();
      ProcessEdgeCreationFailure(to, "No such peer");
      return;
    }

    int delay = Dissent::Utils::Random::GetInstance().GetInt(10, 50);
    BufferEdge *local_edge(new BufferEdge(GetAddress(), remote_el->GetAddress(), true, delay));
    BufferEdge *remote_edge(new BufferEdge(remote_el->GetAddress(), GetAddress(), false, delay));

    QSharedPointer<BufferEdge> ledge(local_edge);
    SetSharedPointer(ledge);
    QSharedPointer<BufferEdge> redge(remote_edge);
    SetSharedPointer(redge);

    local_edge->SetRemoteEdge(redge);
    remote_edge->SetRemoteEdge(ledge);

    ProcessNewEdge(ledge);
    remote_el->ProcessNewEdge(redge);
  }
コード例 #18
0
ファイル: mech.events.c プロジェクト: fstltna/Battletech-MUX
void MaybeRecycle(MECH * mech, int wticks)
{
    int nr, dat;

    if (!(Started(mech) && !Destroyed(mech)))
	return;
    nr = NextRecycle(mech);
    UpdateRecycling(mech);
    if (nr < 0)
	MechLWRT(mech) = event_tick;
    if (nr < 0 || nr > ((wticks + 1) * WEAPON_TICK)) {
	dat = MAX(1, wticks * WEAPON_TICK);
	MECHEVENT(mech, EVENT_RECYCLE, mech_recycle_event, dat, 0);
#ifdef WEAPON_RECYCLE_DEBUG
	SendDebug(tprintf("%6d Recycle event for #%d set in %ds.",
		event_tick, mech->mynum, dat));
#endif
    }
#ifdef WEAPON_RECYCLE_DEBUG
    else
	SendDebug(tprintf("%6d Recycle event for #%d exists at %d secs",
		event_tick, mech->mynum, nr));
#endif
}
コード例 #19
0
ファイル: mech.events.c プロジェクト: fstltna/Battletech-MUX
void mech_unjam_ammo_event(EVENT * objEvent)
{
    MECH *objMech = (MECH *) objEvent->data;	/* get the mech */
    int wWeapNum = (int) objEvent->data2;	/* and now the weapon number */
    int wSect, wSlot, wWeapStatus, wWeapIdx;
    int ammoLoc, ammoCrit, ammoLeft;
    int wRoll = 0;
    int wRollNeeded = 0;

    if (Uncon(objMech) || !Started(objMech))
	return;

    wWeapStatus =
	FindWeaponNumberOnMech(objMech, wWeapNum, &wSect, &wSlot);

    if (wWeapStatus == TIC_NUM_DESTROYED)	/* return if the weapon has been destroyed */
	return;

    wWeapIdx = FindWeaponIndex(objMech, wWeapNum);
    ammoLeft =
	FindAmmoForWeapon_sub(objMech, wSect, wSlot, wWeapIdx, 0, &ammoLoc,
	&ammoCrit, 0, 0);

    if (!ammoLeft) {
	SetPartTempNuke(objMech, wSect, wSlot, 0);

	mech_notify(objMech, MECHALL,
	    tprintf
	    ("You finish bouncing around and realize you nolonger have ammo for your %s!",
		get_parts_long_name(I2Weapon(wWeapIdx), 0)));
	return;
    }

    if (MechWeapons[wWeapStatus].special & RAC) {
	wRoll = Roll();
	wRollNeeded = FindPilotGunnery(objMech, wWeapStatus) + 3;

	mech_notify(objMech, MECHPILOT,
	    "You make a roll to unjam the weapon!");
	mech_notify(objMech, MECHPILOT,
	    tprintf("Modified Gunnery Skill: BTH %d\tRoll: %d",
		wRollNeeded, wRoll));

	if (wRoll < wRollNeeded) {
	    mech_notify(objMech, MECHALL,
		"Your attempt to remove the jammed slug fails. You'll need to try again to clear it.");
	    return;
	}
    } else {
	if (!MadePilotSkillRoll(objMech, 0)) {
	    mech_notify(objMech, MECHALL,
		"Your attempt to remove the jammed slug fails. You'll need to try again to clear it.");
	    return;
	}
    }

    SetPartTempNuke(objMech, wSect, wSlot, 0);
    mech_notify(objMech, MECHALL,
	tprintf("You manage to clear the jam on your %s!",
	    get_parts_long_name(I2Weapon(wWeapIdx), 0)));
    MechLOSBroadcast(objMech, "ejects a mangled shell!");

    SetPartData(objMech, ammoLoc, ammoCrit, GetPartData(objMech, ammoLoc,
	    ammoCrit) - 1);
}
コード例 #20
0
ファイル: glue.c プロジェクト: chazu/btmux
static int
load_update1(void *key, void *data, int depth, void *arg)
{
	const dbref key_val = (dbref)key;
	XCODE *const xcode_obj = data;
	FILE *const fp = arg;

	MAP *map;
	int doh;
	char mapbuffer[MBUF_SIZE];
	MECH *mech;
	int i;
	int ctemp;

	switch (xcode_obj->type) {
	case GTYPE_MAP:
		map = (MAP *)xcode_obj;
		memset(map->mapobj, 0, sizeof(map->mapobj));
		map->map = NULL;
		strcpy(mapbuffer, map->mapname);
		doh = (map->flags & MAPFLAG_MAPO);
		if(strcmp(map->mapname, "Default Map"))
			map_loadmap(1, map, mapbuffer);
		if(!strcmp(map->mapname, "Default Map") || !map->map)
			initialize_map_empty(map, key_val);
		if(!feof(fp)) {
			load_mapdynamic(fp, map);
			if(!feof(fp))
				if(doh)
					load_mapobjs(fp, map);
		}
		if(feof(fp)) {
			map->first_free = 0;
			map->mechflags = NULL;
			map->mechsOnMap = NULL;
			map->LOSinfo = NULL;
		}
		debug_fixmap(GOD, map, NULL);
		break;

	case GTYPE_MECH:
		mech = (MECH *)xcode_obj;
		if(!(FlyingT(mech) && !Landed(mech))) {
			MechDesiredSpeed(mech) = 0;
			MechSpeed(mech) = 0;
			MechVerticalSpeed(mech) = 0;
		}
		ctemp = MechCocoon(mech);
		if(MechCocoon(mech)) {
			MechCocoon(mech) = 0;
			initiate_ood((dbref) GOD, mech, tprintf("%d %d %d", MechX(mech), MechY(mech), MechZ(mech)));
			MechCocoon(mech) = ctemp;
		}

		if(!FlyingT(mech) && Started(mech) && Jumping(mech))
			mech_Rsetxy(GOD, (void *) mech, tprintf("%d %d", MechX(mech),MechY(mech)));
	
		MechStatus(mech) &= ~(BLINDED | UNCONSCIOUS | JUMPING | TOWED);
		MechSpecials2(mech) &=
			~(ECM_ENABLED | ECM_DISTURBANCE | ECM_PROTECTED |
			  ECCM_ENABLED | ANGEL_ECM_ENABLED | ANGEL_ECCM_ENABLED |
			  ANGEL_ECM_PROTECTED | ANGEL_ECM_DISTURBED);
		MechCritStatus(mech) &= ~(JELLIED | LOAD_OK | OWEIGHT_OK | SPEED_OK);
		MechWalkXPFactor(mech) = 999;
		MechCarrying(mech) = -1;
		MechBoomStart(mech) = 0;
		MechC3iNetworkSize(mech) = -1;
		MechHeatLast(mech) = 0;
		MechCommLast(mech) = 0;
		// ClearStaggerDamage
		mech->rd.staggerDamageList = NULL;
		if(!(MechXPMod(mech)))
			MechXPMod(mech) = 1;		
		for(i = 0; i < FREQS; i++)
			if(mech->freq[i] < 0)
				mech->freq[i] = 0;
		break;
	}
	return 1;
}
コード例 #21
0
ファイル: serverdlg.cpp プロジェクト: dafx/Jamulus
/* Implementation *************************************************************/
CServerDlg::CServerDlg ( CServer*        pNServP,
                         CSettings*      pNSetP,
                         const bool      bStartMinimized,
                         QWidget*        parent,
                         Qt::WindowFlags f )
    : QDialog                  ( parent, f ),
      pServer                  ( pNServP ),
      pSettings                ( pNSetP ),
      BitmapSystemTrayInactive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreyArrow.png" ) ),
      BitmapSystemTrayActive   ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenArrow.png" ) )
{
    setupUi ( this );


    // Add help text to controls -----------------------------------------------
    // client list
    lvwClients->setWhatsThis ( tr ( "<b>Client List:</b> The client list "
        "shows all clients which are currently connected to this server. Some "
        "informations about the clients like the IP address and name are given "
        "for each connected client." ) );

    lvwClients->setAccessibleName ( tr ( "Connected clients list view" ) );

    // start minimized on operating system start
    chbStartOnOSStart->setWhatsThis ( tr ( "<b>Start Minimized on Operating "
        "System Start:</b> If the start minimized on operating system start "
        "check box is checked, the " ) + APP_NAME + tr ( " server will be "
        "started when the operating system starts up and is automatically "
        "minimized to a system task bar icon." ) );

    // register server flag
    chbRegisterServer->setWhatsThis ( tr ( "<b>Register Server Status:</b> If "
        "the register server check box is checked, this server registers "
        "itself at the central server so that all " ) + APP_NAME +
        tr ( " users can see the server in the connect dialog server list and "
        "connect to it. The registering of the server is renewed periodically "
        "to make sure that all servers in the connect dialog server list are "
        "actually available." ) );

    // central server address
    QString strCentrServAddr = tr ( "<b>Central Server Address:</b> The "
        "Central server address is the IP address or URL of the central server "
        "at which this server is registered. If the Default check box is "
        "checked, the default central server address is shown read-only." );

    lblCentralServerAddress->setWhatsThis ( strCentrServAddr );
    chbDefaultCentralServer->setWhatsThis ( strCentrServAddr );
    edtCentralServerAddress->setWhatsThis ( strCentrServAddr );

    chbDefaultCentralServer->setAccessibleName (
        tr ( "Default central server check box" ) );

    edtCentralServerAddress->setAccessibleName (
        tr ( "Central server address line edit" ) );

    // server name
    QString strServName = tr ( "<b>Server Name:</b> The server name identifies "
        "your server in the connect dialog server list at the clients. If no "
        "name is given, the IP address is shown instead." );

    lblServerName->setWhatsThis ( strServName );
    edtServerName->setWhatsThis ( strServName );

    edtServerName->setAccessibleName ( tr ( "Server name line edit" ) );

    // location city
    QString strLocCity = tr ( "<b>Location City:</b> The city in which this "
        "server is located can be set here. If a city name is entered, it "
        "will be shown in the connect dialog server list at the clients." );

    lblLocationCity->setWhatsThis ( strLocCity );
    edtLocationCity->setWhatsThis ( strLocCity );

    edtLocationCity->setAccessibleName ( tr (
        "City where the server is located line edit" ) );

    // location country
    QString strLocCountry = tr ( "<b>Location country:</b> The country in "
        "which this server is located can be set here. If a country is "
        "entered, it will be shown in the connect dialog server list at the "
        "clients." );

    lblLocationCountry->setWhatsThis ( strLocCountry );
    cbxLocationCountry->setWhatsThis ( strLocCountry );

    cbxLocationCountry->setAccessibleName ( tr (
        "Country where the server is located combo box" ) );


    // check if system tray icon can be used
    bSystemTrayIconAvaialbe = SystemTrayIcon.isSystemTrayAvailable();

    // init system tray icon
    if ( bSystemTrayIconAvaialbe )
    {
        // prepare context menu to be added to the system tray icon
        pSystemTrayIconMenu = new QMenu ( this );

        pSystemTrayIconMenu->addAction ( tr ( "E&xit" ),
            this, SLOT ( OnSysTrayMenuExit() ) );

        pSystemTrayIconMenu->addSeparator();

        pSystemTrayIconMenu->addAction (
            tr ( "&Hide " ) + APP_NAME + tr ( " server" ),
            this, SLOT ( OnSysTrayMenuHide() ) );

        pSystemTrayIconMenu->setDefaultAction ( pSystemTrayIconMenu->addAction (
            tr ( "&Open " ) + APP_NAME + tr ( " server" ),
            this, SLOT ( OnSysTrayMenuOpen() ) ) );

        SystemTrayIcon.setContextMenu ( pSystemTrayIconMenu );

        // set tool text
        SystemTrayIcon.setToolTip ( QString ( APP_NAME ) + tr ( " server" ) );

        // show icon of state "inactive"
        SystemTrayIcon.setIcon ( QIcon ( BitmapSystemTrayInactive ) );
        SystemTrayIcon.show();
    }

    // act on "start minimized" flag (note, this has to be done after setting
    // the correct value for the system tray icon availablility)
    if ( bStartMinimized )
    {
        showMinimized();
    }

    // set text for version and application name
    lblNameVersion->setText ( QString ( APP_NAME ) +
        tr ( " server " ) + QString ( VERSION ) );

    // set up list view for connected clients
    lvwClients->setColumnWidth ( 0, 170 );
    lvwClients->setColumnWidth ( 1, 130 );
    lvwClients->clear();


// TEST workaround for resize problem of window after iconize in task bar
lvwClients->setMinimumWidth ( 170 + 130 + 60 + 205 );
lvwClients->setMinimumHeight ( 140 );


    // insert items in reverse order because in Windows all of them are
    // always visible -> put first item on the top
    vecpListViewItems.Init ( MAX_NUM_CHANNELS );
    for ( int i = MAX_NUM_CHANNELS - 1; i >= 0; i-- )
    {
        vecpListViewItems[i] = new QTreeWidgetItem ( lvwClients );
        vecpListViewItems[i]->setHidden ( true );
    }

    // update default central server address check box
    if ( pServer->GetUseDefaultCentralServerAddress() )
    {
        chbDefaultCentralServer->setCheckState ( Qt::Checked );
    }
    else
    {
        chbDefaultCentralServer->setCheckState ( Qt::Unchecked );
    }

    // update server name line edit
    edtServerName->setText ( pServer->GetServerName() );

    // update server city line edit
    edtLocationCity->setText ( pServer->GetServerCity() );

    // load country combo box with all available countries
    cbxLocationCountry->setInsertPolicy ( QComboBox::NoInsert );
    cbxLocationCountry->clear();

    for ( int iCurCntry = static_cast<int> ( QLocale::AnyCountry );
          iCurCntry < static_cast<int> ( QLocale::LastCountry ); iCurCntry++ )
    {
        // add all countries except of the "Default" country
        if ( static_cast<QLocale::Country> ( iCurCntry ) != QLocale::AnyCountry )
        {
            // store the country enum index together with the string (this is
            // important since we sort the combo box items later on)
            cbxLocationCountry->addItem ( QLocale::countryToString (
                static_cast<QLocale::Country> ( iCurCntry ) ), iCurCntry );
        }
    }

    // sort country combo box items in alphabetical order
    cbxLocationCountry->model()->sort ( 0, Qt::AscendingOrder );

    // select current country
    cbxLocationCountry->setCurrentIndex (
        cbxLocationCountry->findData (
        static_cast<int> ( pServer->GetServerCountry() ) ) );

    // update register server check box
    if ( pServer->GetServerListEnabled() )
    {
        chbRegisterServer->setCheckState ( Qt::Checked );
    }
    else
    {
        chbRegisterServer->setCheckState ( Qt::Unchecked );
    }

    // update start minimized check box (only available for Windows)
#ifndef _WIN32
    chbStartOnOSStart->setVisible ( false );
#else
    const bool bCurAutoStartMinState = pServer->GetAutoRunMinimized();

    if ( bCurAutoStartMinState )
    {
        chbStartOnOSStart->setCheckState ( Qt::Checked );
    }
    else
    {
        chbStartOnOSStart->setCheckState ( Qt::Unchecked );
    }

    // modify registry according to setting (this is just required in case a
    // user has changed the registry by hand)
    ModifyAutoStartEntry ( bCurAutoStartMinState );
#endif

    // update GUI dependencies
    UpdateGUIDependencies();

    // set window title
    setWindowTitle ( APP_NAME + tr ( " Server" ) );


    // View menu  --------------------------------------------------------------
    QMenu* pViewMenu = new QMenu ( "&Window", this );

    pViewMenu->addAction ( tr ( "E&xit" ), this,
        SLOT ( close() ), QKeySequence ( Qt::CTRL + Qt::Key_Q ) );


    // Main menu bar -----------------------------------------------------------
    pMenu = new QMenuBar ( this );

    pMenu->addMenu ( pViewMenu );
    pMenu->addMenu ( new CHelpMenu ( this ) );

    // Now tell the layout about the menu
    layout()->setMenuBar ( pMenu );


    // Connections -------------------------------------------------------------
    // check boxes
    QObject::connect ( chbRegisterServer, SIGNAL ( stateChanged ( int ) ),
        this, SLOT ( OnRegisterServerStateChanged ( int ) ) );

    QObject::connect ( chbDefaultCentralServer, SIGNAL ( stateChanged ( int ) ),
        this, SLOT ( OnDefaultCentralServerStateChanged ( int ) ) );

    QObject::connect ( chbStartOnOSStart, SIGNAL ( stateChanged ( int ) ),
        this, SLOT ( OnStartOnOSStartStateChanged ( int ) ) );

    // line edits
    QObject::connect ( edtCentralServerAddress, SIGNAL ( editingFinished() ),
        this, SLOT ( OnCentralServerAddressEditingFinished() ) );

    QObject::connect ( edtServerName, SIGNAL ( textChanged ( const QString& ) ),
        this, SLOT ( OnServerNameTextChanged ( const QString& ) ) );

    QObject::connect ( edtLocationCity, SIGNAL ( textChanged ( const QString& ) ),
        this, SLOT ( OnLocationCityTextChanged ( const QString& ) ) );

    // combo boxes
    QObject::connect ( cbxLocationCountry, SIGNAL ( activated ( int ) ),
        this, SLOT ( OnLocationCountryActivated ( int ) ) );

    // timers
    QObject::connect ( &Timer, SIGNAL ( timeout() ), this, SLOT ( OnTimer() ) );

    // other
    QObject::connect ( pServer, SIGNAL ( Started() ),
        this, SLOT ( OnServerStarted() ) );

    QObject::connect ( pServer, SIGNAL ( Stopped() ),
        this, SLOT ( OnServerStopped() ) );

    QObject::connect ( QCoreApplication::instance(), SIGNAL ( aboutToQuit() ),
        this, SLOT ( OnAboutToQuit() ) );

    QObject::connect ( &SystemTrayIcon,
        SIGNAL ( activated ( QSystemTrayIcon::ActivationReason ) ),
        this, SLOT ( OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ) ) );


    // Timers ------------------------------------------------------------------
    // start timer for GUI controls
    Timer.start ( GUI_CONTRL_UPDATE_TIME );
}
コード例 #22
0
ファイル: mech.c3.misc.c プロジェクト: chazu/btmux
MECH *getOtherMechInNetwork(MECH * mech, int wIdx, int tCheckECM,
							int tCheckStarted, int tCheckUncon, int tIsC3)
{
	MECH *tempMech;
	dbref refOtherMech;
	int networkSize;

	networkSize =
		(tIsC3 ? MechC3NetworkSize(mech) : MechC3iNetworkSize(mech));

	if((wIdx >= networkSize) || (wIdx < 0))
		return NULL;

	refOtherMech =
		(tIsC3 ? MechC3NetworkElem(mech, wIdx) : MechC3iNetworkElem(mech,
																	wIdx));

	if(refOtherMech > 0) {
		tempMech = getMech(refOtherMech);

		if(!tempMech)
			return NULL;

		if(MechTeam(tempMech) != MechTeam(mech))
			return NULL;

		if(tempMech->mapindex != mech->mapindex)
			return NULL;

		if(Destroyed(tempMech))
			return NULL;

		if(tIsC3) {
			if(!HasC3(tempMech))	/* Sanity check */
				return NULL;

			if(C3Destroyed(tempMech))
				return NULL;
		} else {
			if(!HasC3i(tempMech))	/* Sanity check */
				return NULL;

			if(C3iDestroyed(tempMech))
				return NULL;
		}

		if(tCheckECM)
			if(AnyECMDisturbed(tempMech))
				return NULL;

		if(tCheckStarted)
			if(!Started(tempMech))
				return NULL;

		if(tCheckUncon)
			if(Uncon(tempMech))
				return NULL;

		return tempMech;
	}

	return NULL;
}
コード例 #23
0
ファイル: mech.c3i.c プロジェクト: fstltna/Battletech-MUX
void mech_c3i_join_leave(dbref player, void *data, char *buffer)
{
    MECH *mech = (MECH *) data, *target;
    MAP *objMap;
    char *args[2];
    dbref refTarget;
    int LOS = 1;
    float range = 0.0;

    cch(MECH_USUALO);

    DOCHECK(mech_parseattributes(buffer, args, 2) != 1,
	"Invalid number of arguments to function!");

    DOCHECK(!HasC3i(mech), "This unit is not equipped with C3i!");
    DOCHECK(C3iDestroyed(mech), "Your C3i system is destroyed!");
    DOCHECK(AnyECMDisturbed(mech),
	"Your C3i system is not currently operational!");

    validateC3iNetwork(mech);

    /* Clear our C3i Network */
    if (!strcmp(args[0], "-")) {
	if (MechC3iNetworkSize(mech) <= 0) {
	    mech_notify(mech, MECHALL,
		"You are not connected to a C3i network!");

	    return;
	}

	clearC3iNetwork(mech, 1);

	mech_notify(mech, MECHALL, "You disconnect from the C3i network.");

	return;
    }

    /* Well, if we're here then we wanna connect to a network */
    /* Let's check to see if we're already in one... can't be in two at the same time */
    DOCHECK(MechC3iNetworkSize(mech) > 0,
	"You are already in a C3i network!");

    objMap = getMap(mech->mapindex);

    /* Find who we're trying to connect to */
    refTarget = FindTargetDBREFFromMapNumber(mech, args[0]);
    target = getMech(refTarget);

    if (target) {
	LOS =
	    InLineOfSight(mech, target, MechX(target), MechY(target),
	    range);
    } else
	refTarget = 0;

    DOCHECK((refTarget < 1) ||
	!LOS, "That is not a valid targetID. Try again.");
    DOCHECK(MechTeam(mech) != MechTeam(target),
	"You can't use the C3i network of unfriendly units!");
    DOCHECK(mech == target, "You can't connect to yourself!");
    DOCHECK(Destroyed(target), "That unit is destroyed!");
    DOCHECK(!Started(target), "That unit is not started!");
    DOCHECK(!HasC3i(target),
	"That unit does not appear to be equipped with C3i!");

    /* validate the network of our target */
    validateC3iNetwork(target);
    DOCHECK(MechC3iNetworkSize(target) >= C3I_NETWORK_SIZE,
	"That unit's C3i network is operating at maximum capacity!");

    /* Connect us up */
    mech_notify(mech, MECHALL, tprintf("You connect to %s's C3i network.",
	    GetMechToMechID(mech, target)));

    addMechToC3iNetwork(target, mech);
}