Handling of fixed-point height [NPCs]

This commit is contained in:
AdAstra-LD
2023-04-21 02:41:17 +02:00
parent 2dbb5af387
commit 4fa85f2c80
2 changed files with 7 additions and 5 deletions

View File

@@ -5908,7 +5908,9 @@ namespace DSPRE {
owYMapUpDown.Value = selectedOw.yMapPosition;
owXMatrixUpDown.Value = selectedOw.xMatrixPosition;
owYMatrixUpDown.Value = selectedOw.yMatrixPosition;
owZPositionUpDown.Value = selectedOw.zPosition;
int zFld = (selectedOw.zPosition >> 4) /*convert from overworld units to fx*/;
owZPositionUpDown.Value = zFld / 0x1000; //then convert from fixed point to decimal
/*ID, Flag and Script number controls */
owIDNumericUpDown.Value = selectedOw.owID;
@@ -6095,7 +6097,8 @@ namespace DSPRE {
return;
}
currentEvFile.overworlds[selection].zPosition = (short)owZPositionUpDown.Value;
int zFld = (short)owZPositionUpDown.Value >> 4; //decimal to overworld units
currentEvFile.overworlds[selection].zPosition = zFld * 0x1000; //overworld units to fixed point
}
private void owXMatrixUpDown_ValueChanged(object sender, EventArgs e) {
int selection = overworldsListBox.SelectedIndex;

View File

@@ -119,7 +119,7 @@ namespace DSPRE.ROMFiles {
public short xMapPosition;
public short yMapPosition;
public short zPosition;
public int zPosition; //fixed point!
public ushort xMatrixPosition;
public ushort yMatrixPosition;
#endregion
@@ -292,8 +292,7 @@ namespace DSPRE.ROMFiles {
xMatrixPosition = (ushort)(xPosition / MapFile.mapSize);
yMatrixPosition = (ushort)(yPosition / MapFile.mapSize);
zPosition = reader.ReadInt16();
unknown3 = reader.ReadUInt16();
zPosition = reader.ReadInt32();
}
}
public Overworld(int owID, int xMatrixPosition, int yMatrixPosition) {