Esempio n. 1
0
        public static void Remap_Init(Mobile from)
        {
            RCDCaller = from;

            // Load the remap data into memory
            string sRemapFile = "Data/RCDMapData.txt";
            bool   bLoadRes   = LoadRemapData(sRemapFile);


            if (!bLoadRes || RCDData.Count == 0)
            {
                RCDCaller.SendMessage(string.Format("Failed to load remap data from {0}!", sRemapFile));
                return;
            }

            // First off, get a list of all the containers we're going
            // to work through and record the serial numbers

            RCDConlist = new ArrayList();

            foreach (Item item in World.Items.Values)
            {
                if (item is Container)
                {
                    RCDConlist.Add(item.Serial);
                }
            }

            // Retrieve enumerator for this collection
            RCDEnum = RCDConlist.GetEnumerator();

            // Make sure we have something on the enumerator
            if (RCDEnum == null)
            {
                RCDCaller.SendMessage("Null enumerator detected! Cannot proceed!");
                return;
            }

            // Open up the file so we don't have to perform extra
            // I/O throughout the search

            RCDLogger = new LogHelper("remapcommdeeds.log", RCDCaller, true);

            // Kick off everything

            RCDProcessed = 0;
            RCDActivated = true;
            RCDTimer     = new Remap_Timer();
            RCDTimer.Start();

            RCDCaller.SendMessage("Remapping {0} commodity deeds...", RCDConlist.Count);
        }
Esempio n. 2
0
        public static void Remap_Process()
        {
            RCDCaller.SendMessage(string.Format("Processing next {0} containers...", RCDProcRate));

            // Loop through the next load of serial numbers, unfreezing each container in
            // turn and matching it against out stored list

            int idone  = 0;
            int itotal = RCDConlist.Count;
            int endpos = RCDProcessed + RCDProcRate;

            while (RCDProcessed < endpos && RCDProcessed < itotal)
            {
                RCDProcessed++;
                idone++;

                RCDEnum.MoveNext();

                // Use the serial number to find the item in the world
                Item item = World.FindItem((Serial)RCDEnum.Current);

                // Make sure it still exists
                if (item == null)
                {
                    continue;
                }

                if (item is Container)
                {
                    // It's still there!
                    Container cont = (Container)item;

                    // Rehydrate it if necessary
                    if (cont.CanFreezeDry)
                    {
                        cont.Rehydrate();
                    }

                    ArrayList ContQueue = new ArrayList();

                    foreach (Item content in cont.Items)
                    {
                        ContQueue.Add(content);
                    }

                    while (ContQueue.Count > 0)
                    {
                        Item content;

                        // Make sure the object in the queue is still an item

                        if (ContQueue[0] is Item)
                        {
                            content = (Item)ContQueue[0];
                            ContQueue.RemoveAt(0);
                        }
                        else
                        {
                            ContQueue.RemoveAt(0);
                            continue;
                        }

                        if (content is CommodityDeed)
                        {
                            // Check it against the ones we loaded into memory on init

                            bool match = false;
                            int  ipos;

                            for (ipos = 0; ipos < RCDData.Count; ipos++)
                            {
                                if (RCDData[ipos].ToString().IndexOf(content.Serial.ToString()) > -1)
                                {
                                    // We have a match, so break the loop

                                    match = true;
                                    break;
                                }
                            }
                            if (match)
                            {
                                if (RCDEncode(((CommodityDeed)content), RCDData[ipos].ToString()))
                                {
                                    // We were successfully able to encode the deed
                                    RCDData.Remove(RCDData[ipos]);
                                }
                                else
                                {
                                    // We failed to encode the deed
                                    continue;
                                }
                            }
                        }
                        else if (content is Container)
                        {
                            foreach (Item ci in ((Container)content).Items)
                            {
                                // Queue it up!
                                ContQueue.Add(ci);
                            }
                        }
                    }
                }
            }

            // Re-process any left in the RCDData list to ensure that they
            // cannot be located outside of rehydrated containers

            for (int ipos = 0; ipos < RCDData.Count; ipos++)
            {
                string sbase = RCDData[ipos].ToString().Substring(2, 8);
                int    iserial;

                // Try and convert serial string into a value

                try
                {
                    iserial = Int32.Parse(sbase, System.Globalization.NumberStyles.HexNumber);
                }
                catch
                {
                    Console.WriteLine("Failed to convert serial into a value!");

                    RCDLogger.Log(LogType.Text,
                                  string.Format("INVALID SERIAL DETECTED - :{0}:", sbase));

                    RCDCaller.SendMessage("Warning! Invalid serial detected... see logfile!");

                    // Loop to next data entry
                    continue;
                }

                Item item = World.FindItem(iserial);

                // Make sure it still exists
                if (item == null)
                {
                    continue;
                }

                // If it's a commodity deed, try and encode
                if (item is CommodityDeed)
                {
                    if (RCDEncode(((CommodityDeed)item), RCDData[ipos].ToString()))
                    {
                        RCDData.Remove(RCDData[ipos]);
                    }
                }
            }

            // Adam: tell the caller this run has completed
            RCDCaller.SendMessage(string.Format("Finished processing {0} containers.", RCDProcRate));

            if (RCDProcessed == itotal)
            {
                Remap_Finish();

                // Adam: tell the caller we are done.
                RCDCaller.SendMessage("Commodity deed processing complete.");
            }
            else
            {
                // Set up another timer to re-call another process run
                RCDTimer = new Remap_Timer();
                RCDTimer.Start();
            }
        }
Esempio n. 3
0
		public static void Remap_Process()
		{	
			RCDCaller.SendMessage( string.Format("Processing next {0} containers...", RCDProcRate) );

			// Loop through the next load of serial numbers, unfreezing each container in
			// turn and matching it against out stored list

			int idone  = 0;
			int itotal = RCDConlist.Count;
			int endpos = RCDProcessed + RCDProcRate;
			            
			while( RCDProcessed < endpos && RCDProcessed < itotal)
			{
				RCDProcessed++;
				idone++;

				RCDEnum.MoveNext();

				// Use the serial number to find the item in the world
				Item item = World.FindItem((Serial)RCDEnum.Current);

				// Make sure it still exists
				if( item == null )
					continue;
				                                                                
				if( item is Container )
				{
					// It's still there!
					Container cont = (Container) item;
					
					// Rehydrate it if necessary
					if( cont.CanFreezeDry )
						cont.Rehydrate();

					ArrayList ContQueue = new ArrayList();
                    					
					foreach( Item content in cont.Items )
						ContQueue.Add( content );
					
					while( ContQueue.Count > 0 )
					{
						Item content;

						// Make sure the object in the queue is still an item

						if( ContQueue[0] is Item )
						{
							content = (Item) ContQueue[0];
							ContQueue.RemoveAt(0);
						}
						else
						{
							ContQueue.RemoveAt(0);
							continue;
						}

						if( content is CommodityDeed )
						{
							// Check it against the ones we loaded into memory on init

							bool match = false;
							int ipos;

							for( ipos=0; ipos < RCDData.Count; ipos++ )
							{
								if( RCDData[ipos].ToString().IndexOf(content.Serial.ToString()) > -1 )
								{
									// We have a match, so break the loop
							
									match = true;
									break;       
								}
							}
							if( match )
							{
								if( RCDEncode( ((CommodityDeed) content), RCDData[ipos].ToString()) )
								{
									// We were successfully able to encode the deed
									RCDData.Remove( RCDData[ipos] );
								}
								else
								{
									// We failed to encode the deed
									continue;
								}
							}
						}
						else if( content is Container )
						{
							foreach( Item ci in ((Container) content).Items )
							{
								// Queue it up!
								ContQueue.Add( ci );
							}
						}
					}
				}
			}

			// Re-process any left in the RCDData list to ensure that they
			// cannot be located outside of rehydrated containers

			for( int ipos=0; ipos < RCDData.Count; ipos++ )
			{
				string sbase = RCDData[ipos].ToString().Substring(2,8);
				int iserial;

				// Try and convert serial string into a value
				
				try
				{
					iserial = Int32.Parse(sbase, System.Globalization.NumberStyles.HexNumber);
				}
				catch
				{
					Console.WriteLine("Failed to convert serial into a value!");
					
					RCDLogger.Log(LogType.Text,  
						string.Format("INVALID SERIAL DETECTED - :{0}:", sbase ));								

					RCDCaller.SendMessage( "Warning! Invalid serial detected... see logfile!" );

					// Loop to next data entry
					continue;
				}
						
				Item item = World.FindItem( iserial );

				// Make sure it still exists
				if( item == null )
					continue;

				// If it's a commodity deed, try and encode
				if( item is CommodityDeed )
					if( RCDEncode( ((CommodityDeed) item), RCDData[ipos].ToString() ))
						RCDData.Remove( RCDData[ipos] );

			}

			// Adam: tell the caller this run has completed
			RCDCaller.SendMessage( string.Format("Finished processing {0} containers.", RCDProcRate) );

			if( RCDProcessed == itotal )
			{
				Remap_Finish();

				// Adam: tell the caller we are done.
				RCDCaller.SendMessage( "Commodity deed processing complete." );

			}
			else
			{
				// Set up another timer to re-call another process run
				RCDTimer = new Remap_Timer();
				RCDTimer.Start();
			}

		}
Esempio n. 4
0
		public static void Remap_Init( Mobile from )
		{
			RCDCaller = from;
			
			// Load the remap data into memory
			string sRemapFile =  "Data/RCDMapData.txt";
			bool bLoadRes = LoadRemapData( sRemapFile );

            	
			if( !bLoadRes || RCDData.Count == 0 )
			{
				RCDCaller.SendMessage( string.Format("Failed to load remap data from {0}!", sRemapFile) );
				return;
			}
            
			// First off, get a list of all the containers we're going
			// to work through and record the serial numbers

			RCDConlist = new ArrayList();
            
			foreach( Item item in World.Items.Values )
			{
				if( item is Container )
					RCDConlist.Add( item.Serial );
			}

			// Retrieve enumerator for this collection
			RCDEnum = RCDConlist.GetEnumerator();

			// Make sure we have something on the enumerator
			if( RCDEnum == null )
			{
				RCDCaller.SendMessage("Null enumerator detected! Cannot proceed!");
				return;
			}

			// Open up the file so we don't have to perform extra
			// I/O throughout the search

			RCDLogger = new LogHelper("remapcommdeeds.log", RCDCaller, true);
            			
			// Kick off everything

			RCDProcessed = 0;
			RCDActivated = true;
			RCDTimer = new Remap_Timer();
			RCDTimer.Start();

			RCDCaller.SendMessage( "Remapping {0} commodity deeds...", RCDConlist.Count );
			
		}