public unsafe void Load(int map) { IndexMap im = GetIndex(map); if (im.MapAddress != 0) { MapBlock block = Marshal.PtrToStructure <MapBlock>((IntPtr)im.MapAddress); int bx = X * 8; int by = Y * 8; for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { int pos = y * 8 + x; ushort tileID = (ushort)(block.Cells[pos].TileID & 0x3FFF); sbyte z = block.Cells[pos].Z; Tile tile = Tiles[x][y]; LandTiles info = TileData.LandData[tileID]; tile.Graphic = tileID; tile.Position = new Position((ushort)(bx + x), (ushort)(by + y), z); tile.AverageZ = z; tile.MinZ = z; tile.IsStretched = info.TexID == 0 && TileData.IsWet((long)info.Flags); tile.AddGameObject(tile); tile.Calculate(); } } if (im.StaticAddress != 0) { StaticsBlock *sb = (StaticsBlock *)im.StaticAddress; if (sb != null) { int count = (int)im.StaticCount; for (int i = 0; i < count; i++, sb++) { if (sb->Color > 0 && sb->Color != 0xFFFF) { ushort x = sb->X; ushort y = sb->Y; int pos = y * 8 + x; if (pos >= 64) { continue; } sbyte z = sb->Z; Static staticObject = new Static(sb->Color, sb->Hue, pos) { Position = new Position((ushort)(bx + x), (ushort)(by + y), z) }; if (TileData.IsAnimated((long)staticObject.ItemData.Flags)) { staticObject.Effect = new AnimatedItemEffect(staticObject, staticObject.Graphic, staticObject.Hue, -1); } //Service.Get<EffectManager>().Add(GraphicEffectType.FixedXYZ, Serial.Invalid, Serial.Invalid, staticObject.Graphic, staticObject.Hue, staticObject.Position, Position.Invalid, 0, -1, false, false, false, GraphicEffectBlendMode.Normal); Tiles[x][y].AddGameObject(staticObject); } } } } } }
// internal methods internal BulkWriteUpsert WithMappedIndex(IndexMap indexMap) { var mappedIndex = indexMap.Map(_index); return((_index == mappedIndex) ? this : new BulkWriteUpsert(mappedIndex, _id)); }
public static BulkWriteBatchResult Create( bool isOrdered, IList <WriteRequest> requests, BsonDocument writeCommandResponse, IndexMap indexMap, Batch <WriteRequest> nextBatch) { var writeErrors = CreateWriteErrors(writeCommandResponse); var writeConcernError = CreateWriteConcernError(writeCommandResponse); var processedRequests = CreateProcessedRequests(requests, writeErrors, isOrdered); var unprocessedRequests = CreateUnprocessedRequests(requests, writeErrors, isOrdered); var upserts = CreateUpserts(writeCommandResponse); var n = writeCommandResponse.GetValue("n", 0).ToInt64(); var matchedCount = 0L; var deletedCount = 0L; var insertedCount = 0L; long?modifiedCount = 0L; var firstRequest = requests.FirstOrDefault(); if (firstRequest != null) { switch (firstRequest.RequestType) { case WriteRequestType.Delete: deletedCount = n; break; case WriteRequestType.Insert: insertedCount = n; break; case WriteRequestType.Update: matchedCount = n - upserts.Count(); BsonValue nModified; if (writeCommandResponse.TryGetValue("nModified", out nModified)) { modifiedCount = nModified.ToInt64(); } else { modifiedCount = null; } break; } } return(new BulkWriteBatchResult( requests.Count, processedRequests, unprocessedRequests, matchedCount, deletedCount, insertedCount, modifiedCount, upserts, writeErrors, writeConcernError, indexMap, nextBatch)); }
public void should_throw_if_max_auto_merge_is_larger_than_map_value() { Assert.Throws <CorruptIndexException>(() => IndexMap.FromFile(_filename, maxAutoMergeLevel: 5)); }
public unsafe void Load(int map) { IndexMap im = GetIndex(map); if (im.MapAddress != 0) { MapBlock *block = (MapBlock *)im.MapAddress; MapCells *cells = (MapCells *)&block->Cells; int bx = X * 8; int by = Y * 8; for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { int pos = y * 8 + x; ushort tileID = (ushort)(cells[pos].TileID & 0x3FFF); sbyte z = cells[pos].Z; Land land = new Land(tileID) { Graphic = tileID, AverageZ = z, MinZ = z, }; ushort tileX = (ushort)(bx + x); ushort tileY = (ushort)(by + y); land.Calculate(tileX, tileY, z); land.Position = new Position(tileX, tileY, z); land.AddToTile(Tiles[x, y]); } } if (im.StaticAddress != 0) { StaticsBlock *sb = (StaticsBlock *)im.StaticAddress; if (sb != null) { int count = (int)im.StaticCount; for (int i = 0; i < count; i++, sb++) { if (sb->Color != 0 && sb->Color != 0xFFFF) { ushort x = sb->X; ushort y = sb->Y; int pos = y * 8 + x; if (pos >= 64) { continue; } sbyte z = sb->Z; ushort staticX = (ushort)(bx + x); ushort staticY = (ushort)(by + y); Static staticObject = new Static(sb->Color, sb->Hue, pos) { Position = new Position(staticX, staticY, z) }; if (staticObject.ItemData.IsAnimated) { World.AddEffect(new AnimatedItemEffect(staticObject, staticObject.Graphic, staticObject.Hue, -1)); } else { staticObject.AddToTile(Tiles[x, y]); } } } } } //CreateLand(); } }
public unsafe void LoadMap(int i) { if (i < 0 || i > 5 || _filesMap[i] == null) { i = 0; } if (BlockData[i] != null || _filesMap[i] == null) { return; } int mapblocksize = UnsafeMemoryManager.SizeOf <MapBlock>(); int staticidxblocksize = UnsafeMemoryManager.SizeOf <StaidxBlock>(); int staticblocksize = UnsafeMemoryManager.SizeOf <StaticsBlock>(); int width = MapBlocksSize[i, 0]; int height = MapBlocksSize[i, 1]; int maxblockcount = width * height; BlockData[i] = new IndexMap[maxblockcount]; UOFile file = _filesMap[i]; UOFile fileidx = _filesIdxStatics[i]; UOFile staticfile = _filesStatics[i]; ulong staticidxaddress = (ulong)fileidx.StartAddress; ulong endstaticidxaddress = staticidxaddress + (ulong)fileidx.Length; ulong staticaddress = (ulong)staticfile.StartAddress; ulong endstaticaddress = staticaddress + (ulong)staticfile.Length; ulong mapddress = (ulong)file.StartAddress; ulong endmapaddress = mapddress + (ulong)file.Length; ulong uopoffset = 0; int fileNumber = -1; bool isuop = file is UOFileUop; for (int block = 0; block < maxblockcount; block++) { ulong realmapaddress = 0, realstaticaddress = 0; uint realstaticcount = 0; int blocknum = block; if (isuop) { blocknum &= 4095; int shifted = block >> 12; if (fileNumber != shifted) { fileNumber = shifted; if (shifted < file.Entries.Length) { uopoffset = (ulong)file.Entries[shifted].Offset; } } } ulong address = mapddress + uopoffset + (ulong)(blocknum * mapblocksize); if (address < endmapaddress) { realmapaddress = address; } ulong stidxaddress = staticidxaddress + (ulong)(block * staticidxblocksize); StaidxBlock *bb = (StaidxBlock *)stidxaddress; if (stidxaddress < endstaticidxaddress && bb->Size > 0 && bb->Position != 0xFFFFFFFF) { ulong address1 = staticaddress + bb->Position; if (address1 < endstaticaddress) { realstaticaddress = address1; realstaticcount = (uint)(bb->Size / staticblocksize); if (realstaticcount > 1024) { realstaticcount = 1024; } } } ref var data = ref BlockData[i][block]; data.MapAddress = realmapaddress; data.StaticAddress = realstaticaddress; data.StaticCount = realstaticcount; data.OriginalMapAddress = realmapaddress; data.OriginalStaticAddress = realstaticaddress; data.OriginalStaticCount = realstaticcount; }
public void when_indexmap_file_is_garbage() { File.WriteAllText(_indexMapFileName, "alkfjasd;lkf\nasdfasdf\n"); Assert.Throws <CorruptIndexException>(() => IndexMap.FromFile(_indexMapFileName, maxTablesPerLevel: 2)); }
public IndexMap CreateIndexMap(FactDeclaration factDeclaration) { return(IndexMap.CreateMap(_parameters, _parameters)); }
public ArgumentMap(IndexMap factMap, int count) { FactMap = factMap; Count = count; }
public void throw_corruptedindexexception_if_prepare_checkpoint_is_minus_one_and_there_are_ptables_in_indexmap() { CreateArtificialIndexMapFile(_indexMapFileName, -1, 0, _ptableFileName); Assert.Throws <CorruptIndexException>(() => IndexMap.FromFile(_indexMapFileName, x => false, 2)); }
public void Setup() { _map = IndexMap.FromFile("thisfiledoesnotexist"); }
public void throw_corruptedindexexception_when_prepare_checkpoint_is_less_than_minus_one() { CreateArtificialIndexMapFile(_indexMapFileName, -2, 0, null); Assert.Throws <CorruptIndexException>(() => IndexMap.FromFile(_indexMapFileName, x => false, 2)); }
public IOWriteResult Write(TextWriter writer, List <WriteMesh> vMeshes, WriteOptions options) { int nAccumCountV = 1; // OBJ indices always start at 1 int nAccumCountUV = 1; // collect materials string sMaterialLib = ""; int nHaveMaterials = 0; if (options.bWriteMaterials && options.MaterialFilePath.Length > 0) { List <GenericMaterial> vMaterials = MeshIOUtil.FindUniqueMaterialList(vMeshes); IOWriteResult ok = write_materials(vMaterials, options); if (ok.code == IOCode.Ok) { sMaterialLib = Path.GetFileName(options.MaterialFilePath); nHaveMaterials = vMeshes.Count; } } if (options.AsciiHeaderFunc != null) { writer.WriteLine(options.AsciiHeaderFunc()); } if (sMaterialLib != "") { writer.WriteLine("mtllib {0}", sMaterialLib); } for (int mi = 0; mi < vMeshes.Count; ++mi) { IMesh mesh = vMeshes[mi].Mesh; bool bVtxColors = options.bPerVertexColors && mesh.HasVertexColors; bool bNormals = options.bPerVertexNormals && mesh.HasVertexNormals; // use separate UV set if we have it, otherwise write per-vertex UVs if we have those bool bVtxUVs = options.bPerVertexUVs && mesh.HasVertexUVs; if (vMeshes[mi].UVs != null) { bVtxUVs = false; } int[] mapV = new int[mesh.MaxVertexID]; // write vertices for this mesh foreach (int vi in mesh.VertexIndices()) { mapV[vi] = nAccumCountV++; Vector3D v = mesh.GetVertex(vi); if (bVtxColors) { Vector3D c = mesh.GetVertexColor(vi); writer.WriteLine("v {0} {1} {2} {3:F8} {4:F8} {5:F8}", v[0], v[1], v[2], c[0], c[1], c[2]); } else { writer.WriteLine("v {0} {1} {2}", v[0], v[1], v[2]); } if (bNormals) { Vector3D n = mesh.GetVertexNormal(vi); writer.WriteLine("vn {0:F10} {1:F10} {2:F10}", n[0], n[1], n[2]); } if (bVtxUVs) { Vector2F uv = mesh.GetVertexUV(vi); writer.WriteLine("vt {0:F10} {1:F10}", uv.x, uv.y); } } // write independent UVs for this mesh, if we have them IIndexMap mapUV = (bVtxUVs) ? new IdentityIndexMap() : null; DenseUVMesh uvSet = null; if (vMeshes[mi].UVs != null) { uvSet = vMeshes[mi].UVs; int nUV = uvSet.UVs.Length; IndexMap fullMap = new IndexMap(false, nUV); // [TODO] do we really need a map here? is just integer shift, no? for (int ui = 0; ui < nUV; ++ui) { writer.WriteLine("vt {0:F8} {1:F8}", uvSet.UVs[ui].x, uvSet.UVs[ui].y); fullMap[ui] = nAccumCountUV++; } mapUV = fullMap; } // check if we need to write usemtl lines for this mesh bool bWriteMaterials = nHaveMaterials > 0 && vMeshes[mi].TriToMaterialMap != null && vMeshes[mi].Materials != null; // various ways we can write triangles to minimize state changes... // [TODO] support writing materials when mesh has groups!! if (options.bWriteGroups && mesh.HasTriangleGroups) { write_triangles_bygroup(writer, mesh, mapV, uvSet, mapUV, bNormals); } else { write_triangles_flat(writer, vMeshes[mi], mapV, uvSet, mapUV, bNormals, bWriteMaterials); } } return(new IOWriteResult(IOCode.Ok, "")); }
internal Activation(ICompiledRule compiledRule, Tuple tuple, IndexMap factMap) { CompiledRule = compiledRule; Tuple = tuple; FactMap = factMap; }
public static BulkWriteBatchResult Create( WriteRequest request, WriteConcernResult writeConcernResult, WriteConcernException writeConcernException, IndexMap indexMap) { var processedRequests = new[] { request }; var unprocessedRequests = __noWriteRequests; BsonValue upsertId = null; var documentsAffected = 0L; if (writeConcernResult != null) { upsertId = writeConcernResult.Upserted; documentsAffected = writeConcernResult.DocumentsAffected; var updateRequest = request as UpdateRequest; if (upsertId == null && documentsAffected == 1 && updateRequest != null && updateRequest.IsUpsert && !writeConcernResult.UpdatedExisting) { // Get the _id field first from the Update document // and then from the Query document. upsertId = updateRequest.Update.ToBsonDocument().GetValue("_id", null) ?? updateRequest.Criteria.ToBsonDocument().GetValue("_id", null); } } var upserts = (upsertId == null) ? __noUpserts : new[] { new BulkWriteOperationUpsert(0, upsertId) }; var writeErrors = __noWriteErrors; BulkWriteConcernError writeConcernError = null; if (writeConcernException != null) { var getLastErrorResponse = writeConcernResult.Response; if (IsGetLasterrorResponseAWriteConcernError(getLastErrorResponse)) { writeConcernError = CreateWriteConcernErrorFromGetLastErrorResponse(getLastErrorResponse); } else { writeErrors = new[] { CreateWriteErrorFromGetLastErrorResponse(getLastErrorResponse) }; } } if (request.RequestType == WriteRequestType.Insert && writeErrors.Count == 0) { documentsAffected = 1; // note: DocumentsAffected is 0 for inserts } var matchedCount = 0L; var deletedCount = 0L; var insertedCount = 0L; long?modifiedCount = 0L; switch (request.RequestType) { case WriteRequestType.Delete: deletedCount = documentsAffected; break; case WriteRequestType.Insert: insertedCount = documentsAffected; break; case WriteRequestType.Update: matchedCount = documentsAffected - upserts.Count(); modifiedCount = null; // getLasterror does not report this value break; } return(new BulkWriteBatchResult( 1, // batchCount processedRequests, unprocessedRequests, matchedCount, deletedCount, insertedCount, modifiedCount, upserts, writeErrors, writeConcernError, indexMap)); }
public AggregateExpression(LambdaExpression expression, FastDelegate <Func <object[], object> > compiledExpression, IndexMap factMap) { _expression = expression; _factMap = factMap; _compiledExpression = compiledExpression; }
public void Setup() { _map = IndexMap.FromFile("shitbird"); }
public void Setup() { _map = IndexMap.FromFile(_file, x => false); _map.EnterUnsafeState(new FileInfo(_file).DirectoryName); }
public void when_indexmap_file_exists_but_is_empty() { File.WriteAllText(_indexMapFileName, ""); Assert.Throws <CorruptIndexException>(() => IndexMap.FromFile(_indexMapFileName, maxTablesPerLevel: 2)); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); _filename = GetTempFilePath(); _finalmergefile = GetTempFilePath(); _finalmergefile2 = GetTempFilePath(); _map = IndexMapTestFactory.FromFile(_filename); var memtable = new HashListMemTable(_ptableVersion, maxSize: 10); memtable.Add(0, 1, 0); var guidFilename = new GuidFilenameProvider(PathName); _result = _map.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 0, 0, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), guidFilename, _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 1, 2, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), new FakeFilenameProvider(_finalmergefile, _finalmergefile2), _ptableVersion, 4, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); }
public CompiledRule(IRuleDefinition definition, IEnumerable <Declaration> declarations, IEnumerable <IRuleAction> actions, IRuleFilter filter, IndexMap factMap) { Definition = definition; Filter = filter; FactMap = factMap; _declarations = new List <Declaration>(declarations); _actions = new List <IRuleAction>(actions); foreach (var ruleAction in _actions) { ActionTriggers |= ruleAction.Trigger; } }
internal unsafe void ReloadBlock(int map, int blocknum) { int mapblocksize = UnsafeMemoryManager.SizeOf <MapBlock>(); int staticidxblocksize = UnsafeMemoryManager.SizeOf <StaidxBlock>(); int staticblocksize = UnsafeMemoryManager.SizeOf <StaticsBlock>(); UOFile file = _filesMap[map]; UOFile fileidx = _filesIdxStatics[map]; UOFile staticfile = _filesStatics[map]; ulong staticidxaddress = (ulong)fileidx.StartAddress; ulong endstaticidxaddress = staticidxaddress + (ulong)fileidx.Length; ulong staticaddress = (ulong)staticfile.StartAddress; ulong endstaticaddress = staticaddress + (ulong)staticfile.Length; ulong mapddress = (ulong)file.StartAddress; ulong endmapaddress = mapddress + (ulong)file.Length; ulong uopoffset = 0; int fileNumber = -1; bool isuop = file is UOFileUop; ulong realmapaddress = 0, realstaticaddress = 0; uint realstaticcount = 0; int block = blocknum; if (isuop) { blocknum &= 4095; int shifted = block >> 12; if (fileNumber != shifted) { fileNumber = shifted; if (shifted < file.Entries.Length) { uopoffset = (ulong)file.Entries[shifted].Offset; } } } ulong address = mapddress + uopoffset + (ulong)(blocknum * mapblocksize); if (address < endmapaddress) { realmapaddress = address; } ulong stidxaddress = staticidxaddress + (ulong)(block * staticidxblocksize); StaidxBlock *bb = (StaidxBlock *)stidxaddress; if (stidxaddress < endstaticidxaddress && bb->Size > 0 && bb->Position != 0xFFFFFFFF) { ulong address1 = staticaddress + bb->Position; if (address1 < endstaticaddress) { realstaticaddress = address1; realstaticcount = (uint)(bb->Size / staticblocksize); if (realstaticcount > 1024) { realstaticcount = 1024; } } } BlockData[map][block] = new IndexMap(realmapaddress, realstaticaddress, realstaticcount, realmapaddress, realstaticaddress, realstaticcount); }
public void should_open_if_auto_merge_levels_match() { Assert.DoesNotThrow(() => IndexMap.FromFile(_filename, maxAutoMergeLevel: 4)); }
public unsafe void Load(int map) { IndexMap im = GetIndex(map); if (im.MapAddress != 0) { MapBlock *block = (MapBlock *)im.MapAddress; MapCells *cells = (MapCells *)&block->Cells; int bx = X * 8; int by = Y * 8; for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { int pos = y * 8 + x; ushort tileID = (ushort)(cells[pos].TileID & 0x3FFF); sbyte z = cells[pos].Z; LandTiles info = TileData.LandData[tileID]; Land land = new Land(tileID) { Graphic = tileID, AverageZ = z, MinZ = z, IsStretched = info.TexID == 0 && TileData.IsWet(info.Flags), }; ushort tileX = (ushort)(bx + x); ushort tileY = (ushort)(by + y); land.Calculate(tileX, tileY, z); land.Position = new Position(tileX, tileY, z); } } if (im.StaticAddress != 0) { StaticsBlock *sb = (StaticsBlock *)im.StaticAddress; if (sb != null) { int count = (int)im.StaticCount; for (int i = 0; i < count; i++, sb++) { if (sb->Color > 0 && sb->Color != 0xFFFF) { ushort x = sb->X; ushort y = sb->Y; int pos = y * 8 + x; if (pos >= 64) { continue; } sbyte z = sb->Z; Static staticObject = new Static(sb->Color, sb->Hue, pos) { Position = new Position((ushort)(bx + x), (ushort)(by + y), z) }; if (TileData.IsAnimated(staticObject.ItemData.Flags)) { staticObject.Effect = new AnimatedItemEffect(staticObject, staticObject.Graphic, staticObject.Hue, -1); } } } } } } }
private unsafe void Load() { int size = FileManager.Map.MapsDefaultSize[World.MapIndex, 0] * FileManager.Map.MapsDefaultSize[World.MapIndex, 1]; ushort[] buffer = new ushort[size]; int maxBlock = size - 1; for (int bx = 0; bx < FileManager.Map.MapBlocksSize[World.MapIndex, 0]; bx++) { int mapX = bx * 8; for (int by = 0; by < FileManager.Map.MapBlocksSize[World.MapIndex, 1]; by++) { IndexMap indexMap = World.Map.GetIndex(bx, by); if (indexMap.MapAddress == 0) { continue; } int mapY = by * 8; MapBlock info = new MapBlock(); MapCells *infoCells = (MapCells *)&info.Cells; MapBlock *mapBlock = (MapBlock *)indexMap.MapAddress; MapCells *cells = (MapCells *)&mapBlock->Cells; int pos = 0; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { ref MapCells cell = ref cells[pos]; ref MapCells infoCell = ref infoCells[pos]; infoCell.TileID = cell.TileID; infoCell.Z = cell.Z; pos++; } } StaticsBlock *sb = (StaticsBlock *)indexMap.StaticAddress; if (sb != null) { int count = (int)indexMap.StaticCount; for (int c = 0; c < count; c++) { StaticsBlock staticBlock = sb[c]; if (staticBlock.Color > 0 && staticBlock.Color != 0xFFFF && !GameObjectHelper.IsNoDrawable(staticBlock.Color)) { pos = staticBlock.Y * 8 + staticBlock.X; ref MapCells cell = ref infoCells[pos]; if (cell.Z <= staticBlock.Z) { cell.TileID = (ushort)(staticBlock.Color + 0x4000); cell.Z = staticBlock.Z; } } } }
public Parser(IndexMap idxMap) { _idxMap = idxMap; _stream = new TokenStream(this); _reader = new Serialize.TextReader(_stream); }
// internal methods internal BulkWriteError WithMappedIndex(IndexMap indexMap) { var mappedIndex = indexMap.Map(_index); return((_index == mappedIndex) ? this : new BulkWriteError(mappedIndex, Category, Code, Message, Details)); }
public RuleAction(LambdaExpression expression, FastDelegate <Action <IContext, object[]> > compiledExpression, IndexMap factIndexMap, IndexMap dependencyIndexMap) { _expression = expression; _factIndexMap = factIndexMap; _dependencyIndexMap = dependencyIndexMap; _compiledExpression = compiledExpression; }
public static BulkWriteBatchResult Create( WriteRequest request, WriteConcernResult writeConcernResult, WriteConcernException writeConcernException, IndexMap indexMap) { var processedRequests = new[] { request }; var unprocessedRequests = Enumerable.Empty <WriteRequest>(); var upsertId = (writeConcernResult == null) ? null : writeConcernResult.Upserted; var upserts = (upsertId == null) ? Enumerable.Empty <BulkWriteUpsert>() : new[] { new BulkWriteUpsert(0, upsertId) }; var writeErrors = __noWriteErrors; WriteConcernError writeConcernError = null; Batch <WriteRequest> nextBatch = null; if (writeConcernException != null) { var getLastErrorResponse = writeConcernResult.Response; if (IsGetLasterrorResponseAWriteConcernError(getLastErrorResponse)) { writeConcernError = CreateWriteConcernErrorFromGetLastErrorResponse(getLastErrorResponse); } else { writeErrors = new[] { CreateWriteErrorFromGetLastErrorResponse(getLastErrorResponse) }; } } var documentsAffected = (writeConcernResult == null) ? 0 : writeConcernResult.DocumentsAffected; if (request.RequestType == WriteRequestType.Insert && writeErrors.Count == 0) { documentsAffected = 1; // note: DocumentsAffected is 0 for inserts } var matchedCount = 0L; var deletedCount = 0L; var insertedCount = 0L; long?modifiedCount = 0L; switch (request.RequestType) { case WriteRequestType.Delete: deletedCount = documentsAffected; break; case WriteRequestType.Insert: insertedCount = documentsAffected; break; case WriteRequestType.Update: matchedCount = documentsAffected - upserts.Count(); modifiedCount = null; // getLasterror does not report this value break; } return(new BulkWriteBatchResult( 1, // batchCount processedRequests, unprocessedRequests, matchedCount, deletedCount, insertedCount, modifiedCount, upserts, writeErrors, writeConcernError, indexMap, nextBatch)); }
public static ScavengeResult Success(IndexMap scavengedMap, PTable oldTable, PTable newTable, long spaceSaved, int level, int index) { return(new ScavengeResult(scavengedMap, true, oldTable, newTable, spaceSaved, level, index)); }