Пример #1
0
        public static Setup MakeSimpleSetup(uint gfxObjID)
        {
            var setup = new Setup();

            setup.NumParts = 1;
            setup.Parts    = new List <PhysicsPart>(1);

            var gfxObj = (Collision.GfxObj)DBObj.Get(new QualifiedDataID(6, gfxObjID));

            if (gfxObj != null)
            {
                if (gfxObj.PhysicsSphere != null)
                {
                    setup.SortingSphere = gfxObj.PhysicsSphere;
                }
                else
                {
                    setup.SortingSphere = gfxObj.DrawingSphere;
                }
            }

            var part = new PhysicsPart();

            part.GfxObj = gfxObj;
            setup.Parts.Add(part);

            var placementType = new PlacementType();

            //placementType.AnimFrame.NumParts = 1;
            setup.PlacementFrames.Add((int)gfxObjID, placementType);
            return(setup);
        }
Пример #2
0
        public void set_animation_id(uint animID)
        {
            var anim = (DatLoader.FileTypes.Animation)DBObj.Get(new QualifiedDataID(8, animID));

            Anim = new Animation(anim);
            if (Anim == null)
            {
                return;
            }

            if (HighFrame < 0)
            {
                HighFrame = Anim.NumFrames - 1;
            }

            if (LowFrame >= Anim.NumFrames)
            {
                LowFrame = Anim.NumFrames - 1;
            }

            if (HighFrame >= Anim.NumFrames)
            {
                HighFrame = Anim.NumFrames - 1;
            }

            if (LowFrame > HighFrame)
            {
                HighFrame = LowFrame;
            }
        }
Пример #3
0
        public static GfxObj Get(uint gfxObjID)
        {
            Requests++;

            //if (Requests % 100 == 0)
            //Console.WriteLine($"GfxObjCache: Requests={Requests}, Hits={Hits}");

            if (GfxObjs.TryGetValue(gfxObjID, out var result))
            {
                if (result.TryGetTarget(out var target))
                {
                    Hits++;
                    return(target);
                }
            }

            var _gfxObj = DBObj.GetGfxObj(gfxObjID);

            // not cached, add it
            var gfxObj = new GfxObj(_gfxObj);

            //gfxObj = GfxObjs.GetOrAdd(_gfxObj.Id, gfxObj);
            GfxObjs[_gfxObj.Id] = new WeakReference <GfxObj>(gfxObj);
            return(gfxObj);
        }
Пример #4
0
        public void set_animation_id(uint animID)
        {
            var anim = DBObj.GetAnimation(animID);

            Anim = new Animation(anim);
            if (Anim == null)
            {
                return;
            }

            if (HighFrame < 0)
            {
                HighFrame = Anim.NumFrames - 1;
            }

            if (LowFrame >= Anim.NumFrames)
            {
                LowFrame = Anim.NumFrames - 1;
            }

            if (HighFrame >= Anim.NumFrames)
            {
                HighFrame = Anim.NumFrames - 1;
            }

            if (LowFrame > HighFrame)
            {
                HighFrame = LowFrame;
            }
        }
Пример #5
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");

                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSession();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseDeveloperExceptionPage();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });

            using var scope = app.ApplicationServices.CreateScope();
            {
                AppDBContent content = scope.ServiceProvider.GetRequiredService <AppDBContent>();
                DBObj.initial(content);
            }
        }
Пример #6
0
        public bool LoadGfxObjArray(uint rootObjectID /*, GfxObjDegradeInfo newDegrades*/)
        {
            var gfxObj = (DatLoader.FileTypes.GfxObj)DBObj.Get(new QualifiedDataID(6, rootObjectID));

            GfxObj = GfxObjCache.Get(gfxObj);
            // degrades omitted
            return(GfxObj != null);
        }
Пример #7
0
        public bool InitEnd()
        {
            if (TexGID != 0)
            {
                BaseTexture = new ImgTex(DBObj.GetSurfaceTexture(TexGID));
            }

            return(BaseTexture != null);
        }
Пример #8
0
        public void Test1()
        {
            String       str = "[{\"isDelete\":0,\"objuuid\":\"y9zGSfaAwbsHYBjDAg4PdA\",\"uuid\":51,\"table\":\"mainSync\",\"data\":\"\",\"id\":51}]";
            List <DBObj> obj = DBObj.FromJsonLst(str);

            Assert.AreEqual(0, obj[0].isDelete);
            Assert.AreEqual("y9zGSfaAwbsHYBjDAg4PdA", obj[0].objuuid);
            Assert.AreEqual(51, obj[0].id);
        }
Пример #9
0
        public static List <DBObj> SelectDBObj(int id, int take, String filePath)
        {
            var conn = OpenDB(filePath);

            if (conn == null)
            {
                return(null);
            }
            try
            {
                List <DBObj>  res = new List <DBObj>();
                SQLiteCommand cmd = conn.CreateCommand();
                cmd.CommandText = "select id,data,isDelete,objuuid from t_main where id >=" + id + " order by id limit 0," + take + ";";
                SQLiteDataReader sr = cmd.ExecuteReader();
                while (sr.Read())
                {
                    DBObj obj = new DBObj()
                    {
                        id       = sr.GetInt64(0),
                        data     = sr.GetString(1),
                        isDelete = sr.GetInt32(2),
                        objuuid  = sr.GetString(3)
                    };
                    res.Add(obj);
                }
                sr.Close();
                cmd.Dispose();
                return(res);
            }
            finally
            {
                try
                {
                    conn.Close();
                    conn.Dispose();
                    System.Data.SQLite.SQLiteConnection.ClearAllPools();
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                catch (Exception e)
                {
                }
            }
        }
Пример #10
0
        public static GfxObj Get(uint gfxObjID)
        {
            Requests++;

            //if (Requests % 100 == 0)
            //Console.WriteLine($"GfxObjCache: Requests={Requests}, Hits={Hits}");

            if (GfxObjs.TryGetValue(gfxObjID, out var result))
            {
                Hits++;
                return(result);
            }

            var _gfxObj = DBObj.GetGfxObj(gfxObjID);

            // not cached, add it
            var gfxObj = new GfxObj(_gfxObj);

            gfxObj = GfxObjs.GetOrAdd(_gfxObj.Id, gfxObj);
            return(gfxObj);
        }
Пример #11
0
 public bool SetInfo(uint emitterID)
 {
     return(SetInfo(new ParticleEmitterInfo(DBObj.GetParticleEmitterInfo(emitterID))));
 }
Пример #12
0
 public static Setup Get(uint setupID)
 {
     return((Setup)DBObj.Get(new QualifiedDataID(7, setupID)));
 }
Пример #13
0
        public IActionResult Index(String code, String DBName, long localMaxId,
                                   String uuid, String Data, String restore, String localUUID, String uploadUUID)
        {
            var filePath = Configs.uploadFilePath;

            filePath = _hostingEnvironment.WebRootPath.TrimEnd('\\', '/')
                       + "/" + filePath.TrimEnd('\\', '/') + "/";
            System.IO.Directory.CreateDirectory(filePath);

            Response.ContentType = "text/plain;charset=utf-8";
            Response.Headers.Add("Access-Control-Allow-Origin", "*");
            Response.Headers.Add("Access-Control-Allow-Methods", "POST");
            Response.Headers.Add("Access-Control-Allow-Headers", "x-requested-with,content-type");

            String ml = filePath + "/" + code + "/";

            System.IO.Directory.CreateDirectory(ml);

            String       path   = filePath + "/" + code + "/" + DBName + ".db";
            var          locker = SqliteLock.getLockObj(path);
            long         lastID = 0L;
            UploadResult resObj = new UploadResult();

            lock (locker)
            {
                lastID = OpSqlite.getMaxID(path) ?? 0;
                String dbUUid = OpSqlite.getQuickSaveValue("uuid", path);

                resObj.status = (-9);
                resObj.uuid   = (dbUUid);
                var iswrite     = true;
                var isUUIDMatch = dbUUid == (uuid) || string.IsNullOrEmpty(uuid);
                if (!isUUIDMatch || lastID < localMaxId)
                {
                    if ((isUUIDMatch && lastID < localMaxId) || (!isUUIDMatch && (lastID == 0L) && "1" != (restore)))
                    {
                        resObj.status = (-2);
                        resObj.lastId = (lastID);
                        iswrite       = false;
                    }
                    else if ("1" == (restore) && (lastID == 0))
                    {
                        OpSqlite.QuickSave("uuid", uuid, path);
                    }
                    else
                    {
                        resObj.status = (-1);
                        iswrite       = false;
                    }
                }
                if (iswrite)
                {
                    List <DBObj> db = DBObj.FromJsonLst(Data);
                    if (db != null && db.Count > 0)
                    {
                        long insertResult = OpSqlite.InsertDBObjLst(db, path, localUUID, uploadUUID, "1" == (restore));
                        if (insertResult != 0)
                        {
                            resObj.status = (1);
                            for (int i = 0; i < db.Count; i++)
                            {
                                db[(i)].data = ("");
                                if ("1" != (restore))
                                {
                                    db[(i)].id = (insertResult++);
                                }
                            }
                            resObj.data = (db);
                        }
                        if ("1" == (restore))
                        {
                            lastID = OpSqlite.getMaxID(path) ?? 0;
                        }
                        else
                        {
                            lastID = insertResult - 1;
                        }
                    }
                }
            }
            if (lastID != 0L)
            {
                LastID.setLastId(path, lastID);
            }
            new Thread(async delegate()
            {
                await WebSocketHandler.sendMsg(DBName, code);
            }).Start();

            return(Json(resObj));
        }
Пример #14
0
        public static long InsertDBObjLst(List <DBObj> objLst, String filePath, String localUUID, String uploadUUID,
                                          bool isRestore)
        {
            var conn = OpenDB(filePath);

            if (conn == null)
            {
                return(0);
            }

            try
            {
                long res = 0;

                String sql0 = "select a.pvalue vala,b.pvalue valb from t_quickSave a inner join t_quickSave b on a.pkey='"
                              + fzr(localUUID) + "' and b.pkey='" + fzr(localUUID) + "_0';";
                var stmt0 = conn.CreateCommand();
                stmt0.CommandText = sql0;
                var rs0 = stmt0.ExecuteReader();
                if (rs0.Read())
                {
                    if (uploadUUID == (rs0.GetString(0)))
                    {
                        res = long.Parse(rs0.GetString(1));
                    }
                }
                rs0.Close();
                stmt0.Dispose();
                if (res == 0)
                {
                    using (var tra = conn.BeginTransaction())
                    {
                        for (int i = 0; i < objLst.Count; i++)
                        {
                            DBObj  obj = objLst[i];
                            String sql = "";
                            if (obj.isDelete == 1)
                            {
                                sql += "delete from t_main_temp where objuuid='" + fzr(obj.objuuid) + "';";
                                sql += "insert into t_main_temp(objuuid,data) select objuuid,data from t_main where objuuid='"
                                       + fzr(obj.objuuid) + "';";
                            }
                            if (!isRestore)
                            {
                                sql += "insert into t_main(isDelete,objuuid,data) values(" + obj.isDelete + ",'"
                                       + fzr(obj.objuuid) + "','" + fzr(obj.data) + "');";
                            }
                            else
                            {
                                sql += "insert into t_main(id,isDelete,objuuid,data) values(" + obj.id + ","
                                       + obj.isDelete + ",'" + fzr(obj.objuuid) + "','" + fzr(obj.data) + "');";
                            }
                            if (obj.isDelete == 1)
                            {
                                sql += "update t_main set data=(select data from t_main_temp where objuuid='"
                                       + fzr(obj.objuuid) + "') where objuuid='" + fzr(obj.objuuid) + "';";
                                sql += "delete from t_main_temp where objuuid='" + fzr(obj.objuuid) + "';";
                            }
                            sql += "select last_insert_rowid()";
                            var stmt = conn.CreateCommand();
                            stmt.CommandText = sql;

                            var rs = stmt.ExecuteReader();
                            if (rs.Read())
                            {
                                long newID = rs.GetInt64(0);
                                rs.Close();
                                stmt.Dispose();
                                if (res == 0)
                                {
                                    res = newID;
                                }
                                sql = "insert into t_main_deleteHistory(newid,oldid) select " + newID
                                      + ",id from t_main where objuuid='" + fzr(obj.objuuid) + "' and id!=" + newID
                                      + ";";
                                sql += "delete from t_main where objuuid='" + fzr(obj.objuuid) + "' and id!=" + newID
                                       + ";";

                                var stmt3 = conn.CreateCommand();
                                stmt3.CommandText = sql;
                                stmt3.ExecuteNonQuery();
                                stmt3.Dispose();
                            }
                            else
                            {
                                rs.Close();
                                stmt.Dispose();
                            }
                        }
                        String sql2 = "delete from t_quickSave where  pkey='" + fzr(localUUID) + "';";
                        sql2 += "delete from t_quickSave where  pkey='" + fzr(localUUID) + "_0';";
                        sql2 += "insert into t_quickSave (pkey,pvalue) values('" + fzr(localUUID) + "','" + fzr(uploadUUID)
                                + "');";
                        sql2 += "insert into t_quickSave (pkey,pvalue) values('" + fzr(localUUID) + "_0','" + res + "');";
                        var stmt2 = conn.CreateCommand();
                        stmt2.CommandText = sql2;
                        stmt2.ExecuteNonQuery();
                        stmt2.Dispose();
                        tra.Commit();
                    }
                }
                return(res);
            }
            finally
            {
                try
                {
                    conn.Close();
                    conn.Dispose();
                    System.Data.SQLite.SQLiteConnection.ClearAllPools();
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                catch (Exception e)
                {
                }
            }
        }