EntityX# or EntityPitch# etc. bug
Blitz3D Forums/Blitz3D Beginners Area/EntityX# or EntityPitch# etc. bug
| ||
When i save my world (entity info) and i load it again, all the entities are placed wierd. But then when i save, and load them again, they're on their places again. Code: Function Save() f=WriteFile("World.ent") WriteByte f,Asc("W") WriteByte f,Asc("L") WriteByte f,Asc("D") WriteFloat f,1.0 For e.Entity = Each Entity WriteByte f,Asc("M") ; Mesh WriteString f,e\Mesh$ WriteString f,e\Path$ WriteFloat f,EntityX#(e\Ent) WriteFloat f,EntityY#(e\Ent) WriteFloat f,EntityZ#(e\Ent) WriteFloat f,EntityPitch#(e\Ent) WriteFloat f,EntityYaw#(e\Ent) WriteFloat f,EntityRoll#(e\Ent) WriteFloat f,EntityScaleX#(e\Ent) WriteFloat f,EntityScaleY#(e\Ent) WriteFloat f,EntityScaleZ#(e\Ent) Next CloseFile f End Function Function Load() f=ReadFile("World.ent") ReadByte f:ReadByte f:ReadByte f If ReadFloat(f)<>1.0 Then RuntimeError "Wrong file version!" Repeat Select Chr$(ReadByte(f)) Case "M" e.Entity = New Entity e\Mesh$=ReadString(f) e\Path$=ReadString(f) e\Ent = LoadMesh(e\path$+"\"+e\mesh$) If e\Ent = 0 Then RuntimeError "Mesh doesent exist: "+CurrentDir()+"\"+e\path$+"\"+e\mesh$ PositionEntity e\Ent,ReadFloat(f),ReadFloat(f),ReadFloat(f) RotateEntity e\Ent,ReadFloat(f),ReadFloat(f),ReadFloat(f) ScaleEntity e\Ent,ReadFloat(f),ReadFloat(f),ReadFloat(f) Default RuntimeError "Version data and Entity Data doesn't match! Unknown entity type." End Select Until Eof(f) CloseFile f End Function |
| ||
I've found the bug!!! If i swap EntityX# and EntityZ# then it works! Maybe the command EntityX really is EntityZ and twice. :) WinXp SP2, AMD 64 3200+, 1024MB DDR2, GeForce 6800, DX 9.0c |
| ||
Your problem lies with these lines: PositionEntity e\Ent,ReadFloat(f),ReadFloat(f),ReadFloat(f) The ReadFloat() parts aren't guaranteed to be executed in a left to right order. You should read into temp variables first. This is expected behaviour. |
| ||
i'll try. :) How do you post links in your log? Sorry, but im new in Blitz Forums. |
| ||
What are the forum codes? |