public bool Show(InitStatus status) { if (TryGetInfoBarHost(out var host)) { switch (status) { case InitStatus.Upgraded: return(ShowInfoBar(host, new InfoBarModel( new[] { new InfoBarTextSpan(R.T_CodistUpdated.Replace("<VERSION>", Config.CurrentVersion)), new InfoBarHyperlink(R.CMD_SeeWhatsNew, "New"), new InfoBarTextSpan(R.T_Or), new InfoBarHyperlink(R.CMD_DismissNotification, "Close") }, KnownMonikers.StatusInformation))); case InitStatus.FirstLoad: return(ShowInfoBar(host, new InfoBarModel( new[] { new InfoBarTextSpan(R.T_CodistFirstRun), new InfoBarHyperlink(R.CMD_LearnMore, "More"), new InfoBarTextSpan(R.T_Or), new InfoBarHyperlink(R.CMD_DismissNotification, "Close") }, KnownMonikers.StatusInformation))); } } return(false); }
/// <summary> /// Method executes when smart control point notices that /// a upnp media server has left the network. /// </summary> /// <param name="sender"></param> /// <param name="device"></param> private void RemoveServer(UPnPSmartControlPoint sender, UPnPDevice device) { string udn = device.UniqueDeviceName; CpMediaServer removeThis = null; lock (LockHashes) { if (UdnToInitStatus.Contains(udn)) { InitStatus status = (InitStatus)UdnToInitStatus[udn]; } if (UdnToServer.Contains(udn)) { removeThis = (CpMediaServer)UdnToServer[udn]; UdnToServer.Remove(udn); } } if (this.OnServerGone != null) { this.OnServerGone(this, device); } if (removeThis != null) { if (this.OnCpServerRemoved != null) { this.OnCpServerRemoved(this, removeThis); } } System.GC.Collect(); }
void IStoreListener.OnInitialized(IStoreController controller, IExtensionProvider extensions) { DebugLog("IAP Manager successfully initialized"); storeController = controller; googlePlay = extensions.GetExtension <Google.Play.Billing.IGooglePlayStoreExtensions>(); if (deferPurchaseCompatible) { // enable deferred purchases IPurchasingModule googlePlayModule = Google.Play.Billing.GooglePlayStoreModule.Instance(); var configurationBuilder = ConfigurationBuilder.Instance(googlePlayModule); configurationBuilder.Configure <Google.Play.Billing.IGooglePlayConfiguration>().EnableDeferredPurchase(); // Notify callback for when purchases are deferred to a parent. googlePlay.SetDeferredPurchaseListener(product => { DebugLog("Purchase request deferred to parent."); OnPurchaseDeferred?.Invoke(product); }); } initStatus = InitStatus.Ok; onInitDone?.Invoke(initStatus); onInitDone = null; }
/// <summary> /// Initialization failed. /// This is NOT called when device is offline. /// Device will continuously try to init until device is online. /// </summary> void IStoreListener.OnInitializeFailed(InitializationFailureReason error) { Debug.LogWarning($"IAP init error: {error}"); switch (error) { case InitializationFailureReason.AppNotKnown: initStatus = InitStatus.AppNotKnown; break; case InitializationFailureReason.NoProductsAvailable: initStatus = InitStatus.NoProductsAvailable; break; case InitializationFailureReason.PurchasingUnavailable: initStatus = InitStatus.PurchasingUnavailable; break; default: initStatus = InitStatus.PurchasingUnavailable; break; } // GooglePlay may re-initialize automatically. // OnInitDone callback may be unavailable. onInitDone?.Invoke(initStatus); onInitDone = null; }
/// <summary> /// Initializes coco launcher with specified configuration file. /// </summary> /// <param name="json_config_file">Configuration file with which to initialize coco</param> /// <param name="initialize_web_server">Specify weather to initialize stats web server.</param> public static void Start(string json_config_file, bool initialize_web_server) { // -- Ensure mask exists EnsureMaskExists(); // -- Initialize library InitStatus result = meta_init(json_config_file); if (result != InitStatus.NO_ERROR) { Debug.LogError("Meta initialization result: " + result); return; } // -- Initialize web server if (initialize_web_server && false) // TODO: Find source of crash. { bool init = meta_start_web_server(7777); if (!init) { Debug.LogError("Failed to start web server"); } } // -- Start Coco meta_start(true); Application.runInBackground = true; }
/// <summary> /// Initialization failed. /// This is NOT called when device is offline. /// Device will continuously try to init until device is online. /// </summary> void IStoreListener.OnInitializeFailed(InitializationFailureReason error) { Debug.LogWarning($"IAP init error: {error}"); switch (error) { case InitializationFailureReason.AppNotKnown: initStatus = InitStatus.AppNotKnown; break; case InitializationFailureReason.NoProductsAvailable: initStatus = InitStatus.NoProductsAvailable; break; case InitializationFailureReason.PurchasingUnavailable: initStatus = InitStatus.PurchasingUnavailable; break; default: initStatus = InitStatus.Unknown; break; } onInitDone?.Invoke(initStatus); onInitDone = null; }
void IStoreListener.OnInitialized(IStoreController controller, IExtensionProvider extensions) { storeController = controller; apple = extensions.GetExtension <IAppleExtensions>(); initStatus = InitStatus.Ok; // Notify callback for when purchases are deferred to a parent. if (deferPurchaseCompatible) { apple.RegisterPurchaseDeferredListener(product => { DebugLog("Purchase request deferred to parent."); OnPurchaseDeferred?.Invoke(product); }); } if (promotionalPurchaseCompatible) { foreach (var item in controller.products.all) { if (item.availableToPurchase) { // Set all these products to be visible in the user's App Store apple.SetStorePromotionVisibility(item, AppleStorePromotionVisibility.Show); } } } DebugLog("IAP Manager successfully initialized"); onInitDone?.Invoke(initStatus); onInitDone = null; }
/// <summary> /// Finds the current life bar object and stores it inside the player status /// </summary> public void Init(InitStatus initStatus) { if (initStatus == InitStatus.UNKNOWN) { return; } this.lifeBar = this.InstantiateLifeBarForPlayer(initStatus); this.lifeBar.gameObject.SetActive(true); }
private void PerformInit() { // get framework-specific project node XmlNode projectNode = _frameworkNode.SelectSingleNode("nant:project", NamespaceManager); if (projectNode == null) { throw new ArgumentException("No <project> node is defined."); } // create XmlDocument from project node XmlDocument projectDoc = new XmlDocument(); projectDoc.LoadXml(projectNode.OuterXml); // create and execute project Project frameworkProject = new Project(projectDoc); frameworkProject.BaseDirectory = AppDomain.CurrentDomain.BaseDirectory; frameworkProject.Execute(frameworkProject.RootTargetCallStack); XmlNode runtimeNode = _frameworkNode.SelectSingleNode("runtime", NamespaceManager); if (runtimeNode != null) { _runtime = new Runtime(); _runtime.Parent = _runtime.Project = frameworkProject; _runtime.CallStack = frameworkProject.RootTargetCallStack; _runtime.NamespaceManager = NamespaceManager; _runtime.Initialize(runtimeNode, this); } string sdkDir = GetXmlAttributeValue(_frameworkNode, "sdkdirectory"); try { sdkDir = new PropertyAccessor(frameworkProject, frameworkProject.RootTargetCallStack).ExpandProperties(sdkDir, Location.UnknownLocation); } catch (BuildException) { // do nothing with this exception as a framework is still // considered valid if the sdk directory is not available // or not configured correctly } // the sdk directory does not actually have to exist for a // framework to be considered valid if (sdkDir != null && Directory.Exists(sdkDir)) { _sdkDirectory = new DirectoryInfo(sdkDir); } _project = frameworkProject; _status = InitStatus.Initialized; }
void EndInitStatus() { lock (StaticCriticalSection) { if (InitStatus == null) { return; } InitStatus.Dismiss(); InitStatus = null; } }
void IStoreListener.OnInitialized(IStoreController controller, IExtensionProvider extensions) { Debug.Log("IAP Manager successfully initialized"); storeController = controller; amazon = extensions.GetExtension <IAmazonExtensions>(); initStatus = InitStatus.Ok; onInitDone?.Invoke(initStatus); onInitDone = null; }
internal void Validate() { if (_status == InitStatus.Valid) { return; } Init(); // reset status to avoid status check in properties from getting // triggered _status = InitStatus.Initialized; try { // verify if framework directory is configured, and indirectly // check if it exists if (FrameworkDirectory == null) { throw new ArgumentException("The \"frameworkdirectory\" " + "attribute does not exist, or has no value."); } // verify if framework assembly directory is configured, and // indirectly check if it exists if (FrameworkAssemblyDirectory == null) { throw new ArgumentException("The \"frameworkassemblydirectory\" " + "attribute does not exist, or has no value."); } // verify if version is configured if (Version == null) { throw new ArgumentException("The \"version\" attribute " + "does not exist, or has no value."); } // verify if clrversion is configured if (ClrVersion == null) { throw new ArgumentException("The \"clrversion\" attribute " + "does not exist, or has no value."); } // mark framework valid _status = InitStatus.Valid; } catch (Exception ex) { _status = InitStatus.Invalid; throw new BuildException(string.Format(CultureInfo.InvariantCulture, "{0} ({1}) is not installed, or not correctly configured.", Description, Name), Location.UnknownLocation, ex); } }
private static void ReleaseInitByte(ref InitStatus initByte, object mutex) { lock (mutex) { bool hasWaiting = initByte.HasFlag(InitStatus.Waiting); initByte = InitStatus.Complete; if (hasWaiting) { Monitor.PulseAll(mutex); } } }
public static InitStatus operator +(InitStatus s1, InitStatus s2) { InitStatus status = new InitStatus(); status.armor = s1.armor + s2.armor; status.attackDamage = s1.attackDamage + s2.attackDamage; status.attackSpeed = s1.attackSpeed * s2.attackSpeed; status.cost = s1.cost + s2.cost; status.health = s1.health + s2.health; status.magicResist = s1.magicResist + s2.magicResist; status.movementSpeed = s1.movementSpeed + s2.movementSpeed; return(status); }
/// <summary> /// Executes when the ConnectionManager events for the first time. /// </summary> /// <param name="sender"></param> /// <param name="newVal"></param> private void Sink_OnCmEvented(CpConnectionManager sender, string newVal) { sender.OnStateVariable_SourceProtocolInfo -= new CpConnectionManager.StateVariableModifiedHandler_SourceProtocolInfo(this.Sink_OnCmEvented); string udn = sender.GetUPnPService().ParentDevice.UniqueDeviceName; lock (LockHashes) { InitStatus status = (InitStatus)UdnToInitStatus[udn]; if (status != null) { status.ZeroMeansDone--; status.EventedCM = true; this.ProcessInitStatusChange(udn); } } }
/// <summary> /// Executes when the ConnectionManager service returns on the subscribe status. /// </summary> /// <param name="sender"></param> /// <param name="success"></param> private void Sink_OnCmServiceSubscribe(CpConnectionManager sender, bool success) { sender.OnSubscribe -= new CpConnectionManager.SubscribeHandler(this.Sink_OnCmServiceSubscribe); string udn = sender.GetUPnPService().ParentDevice.UniqueDeviceName; lock (LockHashes) { InitStatus status = (InitStatus)UdnToInitStatus[udn]; if (status != null) { status.ZeroMeansDone--; status.SubcribeCM = success; this.ProcessInitStatusChange(udn); } } }
/// <summary> /// Executes when the ContentDirectory events for the first time. /// </summary> /// <param name="sender"></param> /// <param name="newVal"></param> private void Sink_OnCdEvented(CpContentDirectory sender, UInt32 newVal) { sender.OnStateVariable_SystemUpdateID -= new CpContentDirectory.StateVariableModifiedHandler_SystemUpdateID(this.Sink_OnCdEvented); string udn = sender.GetUPnPService().ParentDevice.UniqueDeviceName; lock (LockHashes) { InitStatus status = (InitStatus)UdnToInitStatus[udn]; if (status != null) { status.ZeroMeansDone--; status.EventedCD = true; this.ProcessInitStatusChange(udn); } } }
/// <summary> /// Initialize Hermes IAP. /// </summary> /// <param name="iapBuilder">Builder data used to create instance.</param> /// <param name="onDone">Callback when initialization is done.</param> public void Init(IAPBuilder iapBuilder, Action <InitStatus> onDone) { if (IsInit) { onDone(initStatus); return; } if (onInitDone != null) { Debug.LogWarning("Hermes is already in the process of initializing."); onDone(InitStatus.Initializing); return; } appleTangleData = iapBuilder.AppleTangleData ?? null; var module = iapBuilder.PurchasingModule ?? StandardPurchasingModule.Instance(); var builder = ConfigurationBuilder.Instance(module); appleConfig = builder.Configure <IAppleConfiguration>(); // Verify if purchases are possible on this iOS device. if (!appleConfig.canMakePayments) { initStatus = InitStatus.PurchasingDisabled; onDone(InitStatus.PurchasingDisabled); return; } // Add Products to store. foreach (var key in iapBuilder.Products.Keys) { builder.AddProduct(key, iapBuilder.Products[key]); } deferPurchaseCompatible = iapBuilder.DeferredPurchaseCompatible; promotionalPurchaseCompatible = iapBuilder.PromotionalPurchaseCompatible; if (promotionalPurchaseCompatible) { appleConfig.SetApplePromotionalPurchaseInterceptorCallback(OnPromotionalPurchase); onPromotionalPurchase = iapBuilder.OnPromotionalPurchase; } onInitDone = onDone; UnityPurchasing.Initialize(this, builder); }
/// <summary> /// Instanciates and returns the lifebar object for the corresponding player /// </summary> /// <returns></returns> private LifeBar InstantiateLifeBarForPlayer(InitStatus initStatus) { switch (initStatus) { case InitStatus.PLAYER_ONE: var lifeBar = Instantiate(this.lifeBarP1).gameObject.GetComponentInChildren <LifeBar>(); lifeBar.SetPlayerName(PlayerInformation.playerName); return(lifeBar); case InitStatus.PLAYER_TWO: var lifeBar2 = Instantiate(this.lifeBarP2).gameObject.GetComponentInChildren <LifeBar>(); lifeBar2.SetPlayerName(PlayerInformation.playerName + "Player Two"); return(lifeBar2); } return(null); }
/// <summary> /// When a MediaServer device is found, we add it to a temp list. /// Then we attempt to subscribe to its services. /// </summary> /// <param name="sender">the smart cp that found the device</param> /// <param name="device">the mediaserver device</param> private void Temporary_AddServer(UPnPSmartControlPoint sender, UPnPDevice device) { if (this.OnServerSeen != null) { this.OnServerSeen(this, device); } UPnPService sCD = device.GetServices(CpContentDirectory.SERVICE_NAME)[0]; UPnPService sCM = device.GetServices(CpConnectionManager.SERVICE_NAME)[0]; CpMediaServer newServer; try { newServer = new CpMediaServer(device); } catch (UPnPCustomException) { newServer = null; } if (newServer != null) { InitStatus status = new InitStatus(); status.SubcribeCD = false; status.SubcribeCM = false; status.EventedCD = false; status.EventedCM = false; status.Server = newServer; lock (LockHashes) { UdnToInitStatus[device.UniqueDeviceName] = status; } newServer.ConnectionManager.OnSubscribe += new CpConnectionManager.SubscribeHandler(this.Sink_OnCmServiceSubscribe); newServer.ContentDirectory.OnSubscribe += new CpContentDirectory.SubscribeHandler(this.Sink_OnCdServiceSubscribe); newServer.ConnectionManager.OnStateVariable_SourceProtocolInfo += new CpConnectionManager.StateVariableModifiedHandler_SourceProtocolInfo(this.Sink_OnCmEvented); newServer.ContentDirectory.OnStateVariable_SystemUpdateID += new CpContentDirectory.StateVariableModifiedHandler_SystemUpdateID(this.Sink_OnCdEvented); newServer.ConnectionManager._subscribe(600); newServer.ContentDirectory._subscribe(600); } }
private static bool AcquireInitByte(ref InitStatus initByte, object mutex) { lock (mutex) { while (initByte.HasFlag(InitStatus.Pending)) { initByte |= InitStatus.Waiting; Monitor.Wait(mutex); } if (initByte == InitStatus.Complete) { return(false); } initByte = InitStatus.Pending; return(true); } }
protected FrameworkInfo(SerializationInfo info, StreamingContext context) { _name = info.GetString("Name"); _family = info.GetString("Family"); _description = info.GetString("Description"); _status = (InitStatus) info.GetValue("Status", typeof(InitStatus)); _clrType = (ClrType) info.GetValue("ClrType", typeof(ClrType)); _version = (Version) info.GetValue("Version", typeof(Version)); _clrVersion = (Version) info.GetValue("ClrVersion", typeof(Version)); _vendor = (VendorType) info.GetValue("Vendor", typeof(VendorType)); if (_status != InitStatus.Valid) { return; } _frameworkDirectory = (DirectoryInfo) info.GetValue("FrameworkDirectory", typeof(DirectoryInfo)); _sdkDirectory = (DirectoryInfo) info.GetValue("SdkDirectory", typeof(DirectoryInfo)); _frameworkAssemblyDirectory = (DirectoryInfo) info.GetValue("FrameworkAssemblyDirectory", typeof(DirectoryInfo)); _runtime = (Runtime) info.GetValue("Runtime", typeof(Runtime)); _project = (Project) info.GetValue("Project", typeof(Project)); _taskAssemblies = (FileSet) info.GetValue("TaskAssemblies", typeof(FileSet)); _referenceAssemblies = (FileSet[]) info.GetValue("ReferenceAssemblies", typeof(FileSet[])); _toolPaths = (string[]) info.GetValue("ToolPaths", typeof(string[])); }
/// <summary> /// 预处理,启动内部服务,构筑运行环境,仅调用一次 /// </summary> public static void Init() { if (InitStatus != InitStatus.None) { return; } lock (LockObj) { if (InitStatus != InitStatus.None) { return; } InitStatus = InitStatus.Initing; } LogProxy.Info(SERVICESBEGININIT); try { ServicesLoad(); ServicesInit(); ServicesRun(); } catch (Exception ex) { InitStatus = InitStatus.Fail; LogProxy.Fatal(ex, true); } InitStatus = InitStatus.Complete; LogProxy.Info(SERVICESENDINIT); }
public static Status Initialize(InitStatus init) { Status temp = new Status(); temp.health = init.health; temp.Maxhealth = init.health; temp.healthRegen = init.healthRegen; temp.cost = init.cost; temp.maxCost = init.cost; temp.costRegen = init.costRegen; temp.attackDamage = init.attackDamage; temp.attackSpeed = init.attackSpeed; temp.armor = init.armor; temp.magicResist = init.magicResist; temp.movementSpeed = init.movementSpeed; temp.killGold = init.killGold; temp.killExperience = 40; return(temp); }
/// <summary> /// /// </summary> /// <param name="initStatus"></param> /// <returns></returns> public IPresenter.InitServerDelegate CheckStatusInitServer(InitStatus initStatus) { return null; }
/// <summary> /// total reinitialisation, check and fill quests to arrays /// </summary> public static void Init() { // second initialisation exclude if ( status != InitStatus.None || World.Loading ) return; status = InitStatus.Started; bool haveExeption = false; bool haveWarns = false; try // strongly recomended to use (for exclude server crush if uncorrect scripts) { BaseQuest[] allQuests = GetAllQuestsInWorld(); BaseCreature[] allCreatures = GetAllCreaturesInWorld(); //sort all Creatures by ID Hashtable SortedCreatures = new Hashtable(); foreach ( BaseCreature bc in allCreatures ) { if ( !SortedCreatures.ContainsKey( bc.Id ) ) { SortedCreatures.Add( (int)bc.Id, bc ); } else { if ( bc.Id>0 ) { string text = string.Format( "* {0} is already have ( [{2}].Id = {1} )", bc.GetType().Name, bc.Id, ((BaseCreature)(SortedCreatures[bc.Id])).GetType().Name ); string data1 = string.Format( "\t> Check this creatureId \"{0}\" in each script", bc.Id ); AddErr( text, data1 ); } } if ( bc.Quests != null && ( bc.GetType().Name != "BaseNPC" ) && bc.Quests.Length > 0 ) { string text = string.Format( "* {0} already have Quests line", bc.GetType().Name ); string data1 = string.Format( "\t> Need remove/remark this line \"Quests = new ...\"" ); string data2 = string.Format( "\t-> remark mean \"//Quests = new ...\"" ); AddErr( text, data1, data2 ); } } // some text output if ( errors.Count > 0 ) { errors.Insert( 0, "" ); errors.Insert( 0, "Start checking Creatures [Server.Creatures]" ); AddErrHeader( "" ); AddErrHeader( "Start checking Quests [Server.Quests]" ); AddErrHeader( "" ); haveWarns = true; } // checking and fill quest arrays foreach ( BaseQuest bq in allQuests ) { CheckQuest( SortedCreatures, bq.NPCId, bq, true, "NPCId" ); //checks NPC Id CheckQuest( SortedCreatures, bq.NPCTargetId, bq, false, "NpcTargetId" ); //checks Target Id if ( !bq.QuestIsBugged ) { if ( bq.PreviousQuest > 0 && !QuestExists( bq.PreviousQuest ) ) //checks PreviousQuest { string text = string.Format( "* {0} have bad link to PreviousQuest (prev quest is not exist)", bq.GetType().Name ); string data1 = string.Format( "\t> Try do quest by number {0}", bq.PreviousQuest ); string data2 = string.Format( "\t> Or comment this line \"previousQuest = {0};\"", bq.PreviousQuest ); AddErr( text, data1, data2 ); } if ( bq.NextQuest > 0 && !QuestExists( bq.NextQuest )) //checks NextQuest { string text = string.Format( "* {0} have bad link to NextQuest (next quest is not exist)", bq.GetType().Name ); string data1 = string.Format( "\t> Try do quest by number {0}", bq.NextQuest ); string data2 = string.Format( "\t> Or comment this line \"nextQuest = {0};\"", bq.NextQuest ); AddErr( text, data1, data2 ); } if ( bq.QuestFlags == 0 ) //checks for bad questflag { string text = string.Format( "* {0} have bad questFlags ( value is 0 )", bq.GetType().Name ); string data1 = string.Format( "\t> Try change value to \"questFlags = 0x20;\"" ); AddErr( text, data1 ); } } } // some text output if ( errors.Count > 0 && !haveWarns ) { errors.Insert( 0, "" ); errors.Insert( 0, "Start checking Quests [Server.Quests]" ); } // optimisations (this operation allow use this code convertions only one time and then free some processor time ) // int[] -> BaseQuest[] for each NPC Hashtable tmp = new Hashtable(); foreach ( int cId in _NPCQuests.Keys ) { ArrayList list = (ArrayList)_NPCQuests[ cId ]; ArrayList quests = new ArrayList(); foreach ( int qId in list ) { BaseQuest bq = World.CreateQuestById( qId ); if ( bq != null ) quests.Add( bq ); } tmp.Add( cId, (BaseQuest[])quests.ToArray( typeof( BaseQuest ) ) ); } _NPCQuests.Clear(); _NPCQuests = tmp; //End Of Optimisations } catch ( Exception e ) { haveExeption = true; AddErrHeader( "" ); AddErrHeader( "Exeption: {0}", e ); AddErrHeader( "" ); AddErrHeader( "message: {0}", e.Message ); AddErrHeader( "source: {0}", e.Source ); AddErrHeader( "stack trace: {0}", e.StackTrace ); AddErrHeader( "inner exeption: {0}", e.InnerException ); AddErrHeader( "target site: {0}", e.TargetSite ); AddErrHeader( "help link: {0}", e.HelpLink ); } finally { } // each NPC can use this section after initialisations if ( !haveExeption ) status = InitStatus.Done; // if have exeprion - not allow use quests }
/// <summary> /// total reinitialisation, check and fill quests to arrays /// </summary> public static void Init() { // second initialisation exclude if (status != InitStatus.None || World.Loading) { return; } status = InitStatus.Started; bool haveExeption = false; bool haveWarns = false; try // strongly recomended to use (for exclude server crush if uncorrect scripts) { BaseQuest[] allQuests = GetAllQuestsInWorld(); BaseCreature[] allCreatures = GetAllCreaturesInWorld(); //sort all Creatures by ID Hashtable SortedCreatures = new Hashtable(); foreach (BaseCreature bc in allCreatures) { if (!SortedCreatures.ContainsKey(bc.Id)) { SortedCreatures.Add((int)bc.Id, bc); } else { if (bc.Id > 0) { string text = string.Format("* {0} is already have ( [{2}].Id = {1} )", bc.GetType().Name, bc.Id, ((BaseCreature)(SortedCreatures[bc.Id])).GetType().Name); string data1 = string.Format("\t> Check this creatureId \"{0}\" in each script", bc.Id); AddErr(text, data1); } } if (bc.Quests != null && (bc.GetType().Name != "BaseNPC") && bc.Quests.Length > 0) { string text = string.Format("* {0} already have Quests line", bc.GetType().Name); string data1 = string.Format("\t> Need remove/remark this line \"Quests = new ...\""); string data2 = string.Format("\t-> remark mean \"//Quests = new ...\""); AddErr(text, data1, data2); } } // some text output if (errors.Count > 0) { errors.Insert(0, ""); errors.Insert(0, "Start checking Creatures [Server.Creatures]"); AddErrHeader(""); AddErrHeader("Start checking Quests [Server.Quests]"); AddErrHeader(""); haveWarns = true; } // checking and fill quest arrays foreach (BaseQuest bq in allQuests) { CheckQuest(SortedCreatures, bq.NPCId, bq, true, "NPCId"); //checks NPC Id CheckQuest(SortedCreatures, bq.NPCTargetId, bq, false, "NpcTargetId"); //checks Target Id if (!bq.QuestIsBugged) { if (bq.PreviousQuest > 0 && !QuestExists(bq.PreviousQuest)) //checks PreviousQuest { string text = string.Format("* {0} have bad link to PreviousQuest (prev quest is not exist)", bq.GetType().Name); string data1 = string.Format("\t> Try do quest by number {0}", bq.PreviousQuest); string data2 = string.Format("\t> Or comment this line \"previousQuest = {0};\"", bq.PreviousQuest); AddErr(text, data1, data2); } if (bq.NextQuest > 0 && !QuestExists(bq.NextQuest)) //checks NextQuest { string text = string.Format("* {0} have bad link to NextQuest (next quest is not exist)", bq.GetType().Name); string data1 = string.Format("\t> Try do quest by number {0}", bq.NextQuest); string data2 = string.Format("\t> Or comment this line \"nextQuest = {0};\"", bq.NextQuest); AddErr(text, data1, data2); } if (bq.QuestFlags == 0) //checks for bad questflag { string text = string.Format("* {0} have bad questFlags ( value is 0 )", bq.GetType().Name); string data1 = string.Format("\t> Try change value to \"questFlags = 0x20;\""); AddErr(text, data1); } } } // some text output if (errors.Count > 0 && !haveWarns) { errors.Insert(0, ""); errors.Insert(0, "Start checking Quests [Server.Quests]"); } // optimisations (this operation allow use this code convertions only one time and then free some processor time ) // int[] -> BaseQuest[] for each NPC Hashtable tmp = new Hashtable(); foreach (int cId in _NPCQuests.Keys) { ArrayList list = (ArrayList)_NPCQuests[cId]; ArrayList quests = new ArrayList(); foreach (int qId in list) { BaseQuest bq = World.CreateQuestById(qId); if (bq != null) { quests.Add(bq); } } tmp.Add(cId, (BaseQuest[])quests.ToArray(typeof(BaseQuest))); } _NPCQuests.Clear(); _NPCQuests = tmp; //End Of Optimisations } catch (Exception e) { haveExeption = true; AddErrHeader(""); AddErrHeader("Exeption: {0}", e); AddErrHeader(""); AddErrHeader("message: {0}", e.Message); AddErrHeader("source: {0}", e.Source); AddErrHeader("stack trace: {0}", e.StackTrace); AddErrHeader("inner exeption: {0}", e.InnerException); AddErrHeader("target site: {0}", e.TargetSite); AddErrHeader("help link: {0}", e.HelpLink); } finally { } // each NPC can use this section after initialisations if (!haveExeption) { status = InitStatus.Done; // if have exeprion - not allow use quests } }
private void PerformInit() { // get framework-specific project node XmlNode projectNode = _frameworkNode.SelectSingleNode("nant:project", NamespaceManager); if (projectNode == null) throw new ArgumentException("No <project> node is defined."); // create XmlDocument from project node XmlDocument projectDoc = new XmlDocument(); projectDoc.LoadXml(projectNode.OuterXml); // create and execute project Project frameworkProject = new Project(projectDoc); frameworkProject.BaseDirectory = AppDomain.CurrentDomain.BaseDirectory; frameworkProject.Execute(); XmlNode runtimeNode = _frameworkNode.SelectSingleNode ("runtime", NamespaceManager); if (runtimeNode != null) { _runtime = new Runtime (); _runtime.Parent = _runtime.Project = frameworkProject; _runtime.NamespaceManager = NamespaceManager; _runtime.Initialize(runtimeNode, frameworkProject.Properties, this); } string sdkDir = GetXmlAttributeValue(_frameworkNode, "sdkdirectory"); try { sdkDir = frameworkProject.ExpandProperties(sdkDir, Location.UnknownLocation); } catch (BuildException) { // do nothing with this exception as a framework is still // considered valid if the sdk directory is not available // or not configured correctly } // the sdk directory does not actually have to exist for a // framework to be considered valid if (sdkDir != null && Directory.Exists(sdkDir)) _sdkDirectory = new DirectoryInfo(sdkDir); _project = frameworkProject; _status = InitStatus.Initialized; }
/// <summary> /// Whenever Sink_Onxxx method executes, it calls this method to /// determine whether a server has been upgraded from non-good /// to good status. /// </summary> /// <param name="udn"></param> private void ProcessInitStatusChange(string udn) { CpMediaServer addedThis = null; InitStatus status = null; lock (LockHashes) { status = (InitStatus)UdnToInitStatus[udn]; if (status != null) { if (status.ZeroMeansDone == 0) { if ( (status.EventedCD) && (status.EventedCM) && (status.SubcribeCD) && (status.SubcribeCM) ) { // We were evented for both services // and we subscribed successfully, // so we're good to go. UdnToInitStatus.Remove(udn); UdnToServer[udn] = status.Server; addedThis = status.Server; } else { // we didn't subscribe successfully // or we never got evented after // we subscribed... but this // code should never execute because // we will have never decremented // ZeroMeansDone==0 } } if (addedThis == null) { if (BadServersAreGoodServersToo) { // but since we're configured to be // nice to crappy servers that // don't event properly... we'll // promote the server to full status UdnToInitStatus.Remove(udn); UdnToServer[udn] = status.Server; addedThis = status.Server; } } } } if (addedThis != null) { if (this.OnCpServerAdded != null) { this.OnCpServerAdded(this, addedThis); } } }