| 04-17-2007, 03:30 PM | #1 |
I wanna know what exactly happens when structs are destroyed. I have made a struct for vector, for my motion system. Everything works well, it's fast and all. But the array index keeps rising slowly... even after the vectors are destroyed. So when it raches its max it crashes. Also i noticed that if i did set x = A.x where A.x is another struct. and then if i do: set x = 20 A.x will still be the same, not changed. I didnt not create new A.x, so how come x and A.x isnt the same. But anyway, the question on top is most important |
| 04-17-2007, 03:53 PM | #2 | |
destroy recycles ids, if it was failing to grim would have already found the problem so it is something specific with your code so I got to see what you are doing. Quote:
This does not make any sense at all. Please elaborate. |
| 04-18-2007, 12:32 AM | #3 |
JASS:static method CreateNormal takes real x, real y returns vector local vector vn = vector.create() local vector v1 = vector.create() local vector v2 = vector.create() //--- get points A,B,C to make a trangle local real Ax = x local real Ay = y local real Az //--- local real Bx = x+1 local real By = y local real Bz //--- local real Cx = x local real Cy = y+1 local real Cz //--- calculate call MoveLocation(TempLocation,Ax,Ay) set Az = GetLocationZ(TempLocation) call MoveLocation(TempLocation,Bx,By) set Bz = GetLocationZ(TempLocation) call MoveLocation(TempLocation,Cx,Cy) set Cz = GetLocationZ(TempLocation) //---------------------------------// call v1.Set(Bx-Ax,By-Ay,Bz-Az) call v2.Set(Cx-Ax,Cy-Ay,Cz-Az) set vn = v1.CrossProduct(v2) call v1.destroy() call v2.destroy() return vn endmethod |
| 04-18-2007, 01:15 AM | #4 |
all structs of the same type share a common index... I believe that is how it works. Meaning that if you are leaking any vectors anywhere, it would be normal for the index of new vectors to keep rising. You are most likely leaking vectors somewhere else. |
| 04-18-2007, 02:20 AM | #5 | |
Quote:
In other words, just do set A.x = value if nothing makes sense. |
| 04-18-2007, 03:40 AM | #6 | |
Quote:
A single-member struct can be treated as a pointer. |
| 04-18-2007, 03:49 AM | #7 |
In purpose, but not syntactically-you have only values-so Mad[Lion]'s (syntactic) example can't behave like shared mutable state. Property pointers though could get silly. |
| 04-18-2007, 12:31 PM | #8 | |
Quote:
a thank you, this explains... I was confused, since this is OO and i have been doing OO only in C++, so when i do OO here too i think of references and pointers. But ofc :P They all are copies of indexes But as my example is there, can u guys find any leak on vector tat was created? |
| 04-18-2007, 12:37 PM | #9 |
You have a leak in another place |
| 04-18-2007, 12:56 PM | #10 |
ok i have these in another place, and when i check, it seems like the normal vector vN isnt deleted, the number keeps rising. JASS:
set vN = vector.CreateNormal(uX,uY)
(...display vN seems to keep rising)
call vN.destroy()
|
| 04-18-2007, 12:58 PM | #11 |
... find all the places where you create a vector |
| 04-18-2007, 01:13 PM | #12 |
this is the only place where it leaks.... besides if this isnt the only place. It is the main place, if i dont run these 2 lines, nothing learks. And here it runs the CreateNormal function. So i cant see that there is something else to look at also this is the function tat has these lines: JASS:function BasicBounce takes nothing returns nothing local integer Mi = OOMS_CurrentMotionObject local motion M = OOMS_MotionObjects[Mi] local vector x local vector vN local particle p = M.Particle local unit P = p.Unit local real uX = GetUnitX(P) local real uY = GetUnitY(P) local real uZ local real tZ //terrain Z call MoveLocation(OOMS_TempLocation,uX,uY) set tZ = GetLocationZ(OOMS_TempLocation) set uZ = tZ+GetUnitFlyHeight(P) //if close enough to terrain, lets bounce if (uZ<=tZ+0.01) then set vN = vector.CreateNormal(uX,uY) //set x = M.vV //set M.vV = x.Project(vN) //call M.vV.Amplify(0.70) //call x.destroy() call vN.destroy() //if (M.vV.Length()<=2.5) then // call M.destroy() endif endif set P = null endfunction |
| 04-18-2007, 01:30 PM | #13 |
JASS:
static method CreateNormal takes real x, real y returns vector
local vector vn = vector.create()
local vector v1 = vector.create()
local vector v2 = vector.create()
//--- get points A,B,C to make a trangle
local real Ax = x
local real Ay = y
local real Az
//---
local real Bx = x+1
local real By = y
local real Bz
//---
local real Cx = x
local real Cy = y+1
local real Cz
//--- calculate
call MoveLocation(TempLocation,Ax,Ay)
set Az = GetLocationZ(TempLocation)
call MoveLocation(TempLocation,Bx,By)
set Bz = GetLocationZ(TempLocation)
call MoveLocation(TempLocation,Cx,Cy)
set Cz = GetLocationZ(TempLocation)
//---------------------------------//
call v1.Set(Bx-Ax,By-Ay,Bz-Az)
call v2.Set(Cx-Ax,Cy-Ay,Cz-Az)
set vn = v1.CrossProduct(v2)
call v1.destroy()
call v2.destroy()
return vn
endmethod |
| 04-18-2007, 02:20 PM | #14 |
oh right :) fuck how can i not see tat |
