Exemple #1
0
        /// Methods to do:
        /// Read Item
        /// Write Item
        /// Return Dynel Item (placing on the ground)
        public AONanos ShallowCopy()
        {
            AONanos it = new AONanos();
            it.ID = ID;

            foreach (AOItemAttribute ai in Attack)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat = ai.Stat;
                z.Value = ai.Value;
                it.Attack.Add(z);
            }

            foreach (AOItemAttribute ai in Defend)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat = ai.Stat;
                z.Value = ai.Value;
                it.Defend.Add(z);
            }

            foreach (AOItemAttribute ai in Stats)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat = ai.Stat;
                z.Value = ai.Value;
                it.Stats.Add(z);
            }

            foreach (AOEvents ev in Events)
            {
                AOEvents newEV = new AOEvents();
                foreach (AOFunctions aof in ev.Functions)
                {
                    AOFunctions newAOF = new AOFunctions();
                    foreach (AORequirements aor in aof.Requirements)
                    {
                        AORequirements newAOR = new AORequirements();
                        newAOR.ChildOperator = aor.ChildOperator;
                        newAOR.Operator = aor.Operator;
                        newAOR.Statnumber = aor.Statnumber;
                        newAOR.Target = aor.Target;
                        newAOR.Value = aor.Value;
                        newAOF.Requirements.Add(newAOR);
                    }

                    foreach (object ob in aof.Arguments)
                    {
                        if (ob.GetType() == typeof (string))
                        {
                            string z = (string) ob;
                            newAOF.Arguments.Add(z);
                        }
                        if (ob.GetType() == typeof (int))
                        {
                            int i = (int) ob;
                            newAOF.Arguments.Add(i);
                        }
                        if (ob.GetType() == typeof (Single))
                        {
                            Single s = (Single) ob;
                            newAOF.Arguments.Add(s);
                        }
                    }
                    newAOF.dolocalstats = aof.dolocalstats;
                    newAOF.FunctionType = aof.FunctionType;
                    newAOF.Target = aof.Target;
                    newAOF.TickCount = aof.TickCount;
                    newAOF.TickInterval = aof.TickInterval;
                    newEV.Functions.Add(newAOF);
                }
                newEV.EventType = ev.EventType;
                it.Events.Add(newEV);
            }


            it.flags = flags;
            it.Instance = Instance;
            it.ItemType = ItemType;
            it.NCUCost = NCUCost;

            return it;
        }
Exemple #2
0
        public static void Convertnanos()
        {
            SqlWrapper sql = new SqlWrapper();
            DataTable dt_items = sql.ReadDatatable("SELECT * FROM nanos order by aoid asc");

            Stream sf = new FileStream("nanos.dat", FileMode.Create);

            ZOutputStream ds = new ZOutputStream(sf, zlibConst.Z_BEST_COMPRESSION);
            MemoryStream sm = new MemoryStream();

            //DeflateStream sm = new DeflateStream(sf, CompressionMode.Compress);



            BinaryFormatter bf = new BinaryFormatter();

            Console.WriteLine("Processing data... This will take a while!");
            List<AONanos> ITEMS = new List<AONanos>();
            int count = dt_items.Rows.Count;
            int oldperc = 0;
            int countall = 0;
            byte[] buffer = BitConverter.GetBytes(maxnum);
            sm.Write(buffer, 0, buffer.Length);
            if (File.Exists("nanos2.dat"))
            {
                NanoHandler.CacheAllNanos("nanos2.dat");
                foreach (AONanos aoi in NanoHandler.NanoList)
                {
                    ITEMS.Add(aoi);
                    if (ITEMS.Count == maxnum)
                    {
                        bf.Serialize(sm, ITEMS);
                        sm.Flush();
                        ITEMS.Clear();
                        countall += maxnum;
                    }
                }
            }
            else
            {
                foreach (DataRow itemrow in dt_items.Rows)
                {
                    AONanos _item = new AONanos();
                    _item.ID = (Int32)itemrow[0];
                    _item.NCUCost = (Int32)itemrow[2];
                    _item.ItemType = (Int32)itemrow[3];

                    DataTable dt_itemevents = sql.ReadDatatable("SELECT * FROM nano_events WHERE nanoid=" + _item.ID + " ORDER BY eventid asc");

                    foreach (DataRow eventrow in dt_itemevents.Rows)
                    {
                        AOEvents aoe = new AOEvents();
                        aoe.EventType = (Int32)eventrow[2];
                        int eventid = (Int32)eventrow["eventid"];

                        DataTable dt_itemeventfunctions = sql.ReadDatatable("SELECT * FROM nano_functions WHERE nanoid=" + _item.ID + " AND eventid=" + eventid + " ORDER BY functionid asc");

                        foreach (DataRow eventfunctionrow in dt_itemeventfunctions.Rows)
                        {
                            int eventfuncid = (Int32)eventfunctionrow["functionid"];
                            AOFunctions aof = new AOFunctions();
                            aof.FunctionType = (Int32)eventfunctionrow[3];
                            aof.Target = (Int32)eventfunctionrow[4];
                            aof.TickCount = (Int32)eventfunctionrow[5];
                            aof.TickInterval = (uint)(Int32)eventfunctionrow[6];

                            DataTable functionargs = sql.ReadDatatable("SELECT * FROM nano_function_arguments WHERE functionid=" + eventfuncid + " AND eventid=" + eventid + " AND nanoid=" + _item.ID + " ORDER BY attrid asc");

                            foreach (DataRow attrs in functionargs.Rows)
                            {
                                if (!(attrs["argvalint"] is DBNull))
                                {
                                    aof.Arguments.Add((Int32)attrs["argvalint"]);
                                }
                                else
                                    if (!(attrs["argvalsingle"] is DBNull))
                                    {
                                        aof.Arguments.Add((Single)(float)attrs["argvalsingle"]);
                                    }
                                    else
                                        if (!(attrs["argvalstring"] is DBNull))
                                        {
                                            string s = attrs["argvalstring"].ToString();
                                            aof.Arguments.Add(s);
                                        }
                                        else
                                            throw (new NotSupportedException("No Argument value given, all NULL: " + _item.ID));
                            }

                            DataTable reqs = sql.ReadDatatable("SELECT * from  nano_function_reqs WHERE functionid=" + eventfuncid + " AND eventid=" + eventid + " AND nanoid=" + _item.ID + " ORDER BY reqid asc");

                            foreach (DataRow rrow in reqs.Rows)
                            {
                                AORequirements aor = new AORequirements();
                                aor.Statnumber = (Int32)rrow["attrnum"];
                                aor.Value = (Int32)rrow["attrval"];
                                aor.Target = (Int32)rrow["target"];
                                aor.Operator = (Int32)rrow["operator"];
                                aor.ChildOperator = (Int32)rrow["child_op"];
                                aof.Requirements.Add(aor);
                            }

                            aoe.Functions.Add(aof);
                        }

                        _item.Events.Add(aoe);
                    }

                    DataTable dt_actions = sql.ReadDatatable("SELECT * FROM nano_actions WHERE nanoid=" + _item.ID);

                    foreach (DataRow acrow in dt_actions.Rows)
                    {
                        AOActions aoa = new AOActions();
                        aoa.ActionType = (Int32)acrow["actionnum"];

                        DataTable reqs = sql.ReadDatatable("SELECT * FROM nano_action_reqs WHERE nanoid=" + _item.ID + " AND actionid=" + ((Int32)acrow["actionid"]) + " ORDER BY reqid ASC");

                        foreach (DataRow rrow in reqs.Rows)
                        {
                            AORequirements aor = new AORequirements();
                            aor.Statnumber = (Int32)rrow["attrnum"];
                            aor.Value = (Int32)rrow["attrval"];
                            aor.Target = (Int32)rrow["target"];
                            aor.Operator = (Int32)rrow["operator"];
                            aor.ChildOperator = (Int32)rrow["child_op"];
                            aoa.Requirements.Add(aor);
                        }
                        _item.Actions.Add(aoa);
                    }

                    DataTable dtdef = sql.ReadDatatable("SELECT * FROM nano_defense_attributes where nanoid=" + _item.ID + " ORDER BY defenseid asc");

                    foreach (DataRow defrow in dtdef.Rows)
                    {
                        AOItemAttribute aoia = new AOItemAttribute();
                        aoia.Stat = (Int32)defrow["num"];
                        aoia.Value = (Int32)defrow["value"];
                        _item.Defend.Add(aoia);
                    }

                    DataTable dtatt = sql.ReadDatatable("select * FROM nano_attack_attributes where nanoid=" + _item.ID + " ORDER BY attackid asc");
                    foreach (DataRow defrow in dtatt.Rows)
                    {
                        AOItemAttribute aoia = new AOItemAttribute();
                        aoia.Stat = (Int32)defrow["num"];
                        aoia.Value = (Int32)defrow["value"];
                        _item.Defend.Add(aoia);
                    }

                    DataTable attributes = sql.ReadDatatable("SELECT * FROM nano_attributes WHERE nanoid=" + _item.ID + " ORDER BY attributeid asc");
                    foreach (DataRow atrow in attributes.Rows)
                    {
                        AOItemAttribute aoia = new AOItemAttribute();
                        aoia.Stat = (Int32)atrow["num"];
                        aoia.Value = (Int32)atrow["value"];
                        _item.Stats.Add(aoia);
                    }


                    ITEMS.Add(_item);

                    int perc = Convert.ToInt32(Math.Floor((double)(ITEMS.Count + countall) / count * 100.0));
                    if (perc != oldperc)
                    {
                        Console.Write("\rDone " + perc.ToString().PadLeft(3) + "%");
                        oldperc = perc;
                    }
                    if (ITEMS.Count == maxnum)
                    {
                        bf.Serialize(sm, ITEMS);
                        sm.Flush();
                        ITEMS.Clear();
                        countall += maxnum;
                    }
                }
            }
            bf.Serialize(sm, ITEMS);
            sm.Seek(0, SeekOrigin.Begin);
            Console.WriteLine();
            CopyStream(sm, ds);
            sm.Close();
            ds.Close();
        }
Exemple #3
0
        /// Methods to do:
        /// Read Item
        /// Write Item
        /// Return Dynel Item (placing on the ground)
        public AONanos ShallowCopy()
        {
            AONanos it = new AONanos();

            it.ID = ID;

            foreach (AOItemAttribute ai in Attack)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat  = ai.Stat;
                z.Value = ai.Value;
                it.Attack.Add(z);
            }

            foreach (AOItemAttribute ai in Defend)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat  = ai.Stat;
                z.Value = ai.Value;
                it.Defend.Add(z);
            }

            foreach (AOItemAttribute ai in Stats)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat  = ai.Stat;
                z.Value = ai.Value;
                it.Stats.Add(z);
            }

            foreach (AOEvents ev in Events)
            {
                AOEvents newEV = new AOEvents();
                foreach (AOFunctions aof in ev.Functions)
                {
                    AOFunctions newAOF = new AOFunctions();
                    foreach (AORequirements aor in aof.Requirements)
                    {
                        AORequirements newAOR = new AORequirements();
                        newAOR.ChildOperator = aor.ChildOperator;
                        newAOR.Operator      = aor.Operator;
                        newAOR.Statnumber    = aor.Statnumber;
                        newAOR.Target        = aor.Target;
                        newAOR.Value         = aor.Value;
                        newAOF.Requirements.Add(newAOR);
                    }

                    foreach (object ob in aof.Arguments.Values)
                    {
                        if (ob.GetType() == typeof(string))
                        {
                            string z = (string)ob;
                            newAOF.Arguments.Values.Add(z);
                        }
                        if (ob.GetType() == typeof(int))
                        {
                            int i = (int)ob;
                            newAOF.Arguments.Values.Add(i);
                        }
                        if (ob.GetType() == typeof(Single))
                        {
                            Single s = (Single)ob;
                            newAOF.Arguments.Values.Add(s);
                        }
                    }
                    newAOF.dolocalstats = aof.dolocalstats;
                    newAOF.FunctionType = aof.FunctionType;
                    newAOF.Target       = aof.Target;
                    newAOF.TickCount    = aof.TickCount;
                    newAOF.TickInterval = aof.TickInterval;
                    newEV.Functions.Add(newAOF);
                }
                newEV.EventType = ev.EventType;
                it.Events.Add(newEV);
            }


            it.flags    = flags;
            it.Instance = Instance;
            it.ItemType = ItemType;
            it.NCUCost  = NCUCost;

            return(it);
        }