Beispiel #1
0
			public uint WriteFields(IO.EndianWriter stream, Compiler comp)
			{
				uint fieldsAddress = stream.PositionUnsigned;

				WriteFieldsRecursive(stream, comp, mFields);

				stream.Write(comp.TypeIndexTerminator); stream.Write((int)0); stream.Write((int)0);
				return fieldsAddress;
			}
Beispiel #2
0
			static void WriteFieldsRecursive(IO.EndianWriter stream, Compiler comp, List<Import.Field> fields)
			{
				Field temp = new Field();
				foreach (Import.Field f in fields)
				{
					if (f.TypeIndex == comp.TypeIndexStruct)
					{
						var import = comp.OwnerState.Importer as Import;
						Import.TagStruct ts;
						// Assert that the field references a valid definition
						if (import.Structs.TryGetValue(f.Definition, out ts))
							WriteFieldsRecursive(stream, comp, ts.Fields.Fields);
						else
							Debug.Assert.If(false, "Field '{0}' references an undefined tag struct '{1}'",
								comp.Strings[f.Name], f.ToString());
					}
					else
					{
						// StringId support is a hack based on tag_reference fields
						// We internally define the tag reference definition, so we must internally add it
						if (f.TypeIndex == comp.TypeIndexStringId)
							f.ChangeDefinition(Import.kStringIdFieldDefinitionName);

						temp.Reset(f);
						temp.Write(stream);

						// While the initial part of the StringId hack is based on a tag_reference field,
						// we use an additional 32 bits for the string_id handle (instead of playing with
						// the tag_reference's tag_index member). This is seen as padding by the editor
						if (f.TypeIndex == comp.TypeIndexStringId)
						{
							temp.Reset((comp.OwnerState.Importer as Halo1.CheApe.Import).StringIdFieldHandlePadding);
							temp.Write(stream);
						}
					}
				}
			}