private static bool ParseValuesUpdateBlock(GenericReader gr, StringBuilder sb, StreamWriter swe, StreamWriter data, ObjectTypes objectTypeId, UpdateTypes updatetype, WoWObject obj) { sb.AppendLine("=== values_update_block_start ==="); byte blocks_count = gr.ReadByte(); // count of update blocks (4 bytes for each update block) sb.AppendLine("Bit mask blocks count: " + blocks_count); int[] updatemask = new int[blocks_count]; // create array of update blocks for (int j = 0; j < blocks_count; j++) { updatemask[j] = gr.ReadInt32(); // populate array of update blocks with data } Mask = new BitArray(updatemask); int reallength = Mask.Count; // bitmask size (bits) int bitmask_max_size = 0; uint values_end = 0; switch (objectTypeId) { case ObjectTypes.TYPEID_ITEM: bitmask_max_size = 64; values_end = UpdateFieldsLoader.ITEM_END; break; case ObjectTypes.TYPEID_CONTAINER: bitmask_max_size = 160; values_end = UpdateFieldsLoader.CONTAINER_END; break; case ObjectTypes.TYPEID_UNIT: bitmask_max_size = 256; values_end = UpdateFieldsLoader.UNIT_END; break; case ObjectTypes.TYPEID_PLAYER: bitmask_max_size = 1536; // 2.3.2 - 1472 values_end = UpdateFieldsLoader.PLAYER_END; break; case ObjectTypes.TYPEID_GAMEOBJECT: bitmask_max_size = 32; values_end = UpdateFieldsLoader.GO_END; break; case ObjectTypes.TYPEID_DYNAMICOBJECT: bitmask_max_size = 32; values_end = UpdateFieldsLoader.DO_END; break; case ObjectTypes.TYPEID_CORPSE: bitmask_max_size = 64; values_end = UpdateFieldsLoader.CORPSE_END; break; } if (reallength > bitmask_max_size) { long pos = gr.BaseStream.Position; swe.WriteLine("error position {0}", pos.ToString("X2")); swe.WriteLine("error while parsing {0} values update block, count {1}", objectTypeId, reallength); return(false); } for (int index = 0; index < reallength; index++) { if (index > values_end) { break; } if (Mask[index]) { UpdateField uf = new UpdateField(); switch (objectTypeId) { case ObjectTypes.TYPEID_ITEM: case ObjectTypes.TYPEID_CONTAINER: uf = UpdateFieldsLoader.item_uf[index]; break; case ObjectTypes.TYPEID_UNIT: case ObjectTypes.TYPEID_PLAYER: uf = UpdateFieldsLoader.unit_uf[index]; break; case ObjectTypes.TYPEID_GAMEOBJECT: uf = UpdateFieldsLoader.go_uf[index]; break; case ObjectTypes.TYPEID_DYNAMICOBJECT: uf = UpdateFieldsLoader.do_uf[index]; break; case ObjectTypes.TYPEID_CORPSE: uf = UpdateFieldsLoader.corpse_uf[index]; break; } ReadAndDumpField(uf, sb, gr, updatetype, data, obj); } } if ((objectTypeId == ObjectTypes.TYPEID_GAMEOBJECT || objectTypeId == ObjectTypes.TYPEID_UNIT) && (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2) && obj.IsNew) { obj.Save(); } sb.AppendLine("=== values_update_block_end ==="); return(true); }