Пример #1
0
 public static void Save(object state)
 {
     foreach (KeyValuePair <string, GsidInfo> pair in dict)
     {
         if (pair.Value.Modified)
         {
             pair.Value.Modified = false;
             RoomStore.WriteRoomGsid(pair.Key, pair.Value.Gsid);
         }
     }
 }
Пример #2
0
        private static void updateRoomHome(string name)
        {
            RoomInfoEntity entity = RoomStore.GetRoom(name);

            if (entity != null)
            {
                int num_of_paths = DrawingStore.GetNumberOfPaths(entity.HomeX, entity.HomeY);
                if (num_of_paths < Config.MOVE_HOME_THRESHOLD)
                {
                    return;
                }

#if GO_SLOWER
                num_of_paths = DrawingStore.GetNumberOfPaths(entity.HomeX, entity.HomeY + 1);
                if (num_of_paths < Config.MOVE_HOME_THRESHOLD)
                {
                    return;
                }

                num_of_paths = DrawingStore.GetNumberOfPaths(entity.HomeX, entity.HomeY - 1);
                if (num_of_paths < Config.MOVE_HOME_THRESHOLD)
                {
                    return;
                }
#endif
                if (entity.HomeX < 0)
                {
                    if (entity.HomeY < 0)
                    {
                        entity.HomeX--;
                    }
                    else
                    {
                        entity.HomeY++;
                    }
                }
                else
                if (entity.HomeY < 0)
                {
                    entity.HomeY--;
                }
                else
                {
                    entity.HomeX++;
                }

                Warehouse.RoomsTable.Execute(TableOperation.Replace(entity));                      // Throws StorageException ((412) Precondition Failed) if the entity is modified in between.

                RoomsPond.Notify(name);
            }
        }
Пример #3
0
        private static RoomInfo insertNew(string key, string name)
        {
            RoomInfoEntity entity = RoomStore.GetRoom(name);                            // if concurrency happens, this will be done more than once.

            if (entity != null)
            {
                RoomInfo obj = new RoomInfo(entity);

                HttpRuntime.Cache.Insert(key, obj, null, DateTime.Now.AddSeconds(Config.DEFAULT_CACHE_SECONDS),
                                         Cache.NoSlidingExpiration, CacheItemPriority.Default, removedCallback);
                return(obj);
            }
            // expires after some time for multi-node synchronization (unreliable).
            return(null);
        }
Пример #4
0
        public bool CreateRoom(string name, int size, int attr)
        {
            if (name.Length > 100 || name.Length < 1)
            {
                return(false);
            }
            if (!Util.WithinCharSetUserName(name))
            {
                return(false);
            }

            if (size != 3 && size != 5 && size != 7 && size != 9)
            {
                return(false);
            }

            return(RoomStore.CreateRoom(name, size, attr));
        }
Пример #5
0
        private static GsidInfo read(string room_name)
        {
            int gsid = RoomStore.ReadRoomGsid(room_name);

            return(new GsidInfo(gsid));
        }