/*** Functions for loading/checking the different pub/map files ***/ //tries to load the map that MainPlayer.ActiveCharacter is hanging out on private bool _tryLoadMap(int mapID = -1) { try { if (mapID < 0) { mapID = MainPlayer.ActiveCharacter.CurrentMap; } string mapFile = Path.Combine("maps", string.Format("{0,5:D5}.emf", mapID)); if (!MapCache.ContainsKey(mapID)) { MapCache.Add(mapID, new MapFile(mapFile)); } else { MapCache[mapID] = new MapFile(mapFile); } //map renderer construction moved to be more closely coupled to loading of the map (m_mapRender ?? (m_mapRender = new EOMapRenderer(EOGame.Instance, m_api))).SetActiveMap(MapCache[mapID]); } catch { return(false); } return(true); }
/*** Functions for loading/checking the different pub/map files ***/ //tries to load the map that MainPlayer.ActiveCharacter is hanging out on private bool _tryLoadMap(int mapID = -1) { try { if (mapID < 0) { mapID = MainPlayer.ActiveCharacter.CurrentMap; } string mapFile = Path.Combine("maps", string.Format("{0,5:D5}.emf", mapID)); if (!MapCache.ContainsKey(mapID)) { MapCache.Add(mapID, new MapFile(mapFile)); } else { MapCache[mapID] = new MapFile(mapFile); } } catch { return(false); } return(true); }
public bool CheckMap(short mapID, byte[] mapRid, int mapFileSize) { NeedMap = -1; string mapFile = string.Format("maps\\{0,5:D5}.emf", mapID); if (!Directory.Exists("maps") || !File.Exists(mapFile)) { Directory.CreateDirectory("maps"); NeedMap = mapID; return(false); } //try to load the map if it isn't cached. on failure, set needmap if (!MapCache.ContainsKey(mapID)) { NeedMap = _tryLoadMap(mapID) ? -1 : mapID; } //on success of file load, check the rid and the size of the file if (MapCache.ContainsKey(mapID)) { for (int i = 0; i < 4; ++i) { if (MapCache[mapID].Rid[i] != mapRid[i]) { NeedMap = mapID; break; } } if (NeedMap == -1 && MapCache[mapID].FileSize != mapFileSize) { NeedMap = mapID; } } //return true if the map is not needed return(NeedMap == -1); }
//--------------------------------------------------------------------- // remove数据 Task IGrainDCacheMaster.removeFromMasteSlave(string key) { if (MapCache.ContainsKey(key)) { MapCache.Remove(key); } for (int i = 1; i <= SlaveCount; i++) { SB.Clear(); SB.Append(MasterName); SB.Append("_"); SB.Append(GrainDCache.SLAVE_MAP_NAME); SB.Append("_"); SB.Append(GrainDCache.SLAVE_ROOT_DEEP); SB.Append("_"); SB.Append(i); var grain_slave = this.GrainFactory.GetGrain <IGrainDCacheSlave>(SB.ToString()); grain_slave.removeFromSlave(key); } return(TaskDone.Done); }