[E2] - Hopefully fixed the applyTorque crash. Only time will tell.

- Minor bugfix to tables.

[Wire] Added piano sounds!

[title]Fixed applyTorque crash - piano sounds![/title]
This commit is contained in:
Divran 2012-04-15 20:52:28 +00:00
parent 173d3bdaed
commit 238942a13d
4 changed files with 26 additions and 4 deletions

View File

@ -397,18 +397,31 @@ end
__e2setcost(30) -- temporary
local function check( v )
return -math.huge < v[1] and v[1] < math.huge and
-math.huge < v[2] and v[2] < math.huge and
-math.huge < v[3] and v[3] < math.huge and
end
e2function void entity:applyForce(vector force)
if not validPhysics(this) then return nil end
if not isOwner(self, this) then return nil end
local phys = this:GetPhysicsObject()
phys:ApplyForceCenter(Vector(force[1],force[2],force[3]))
if check( force ) then
local phys = this:GetPhysicsObject()
phys:ApplyForceCenter(Vector(force[1],force[2],force[3]))
end
end
e2function void entity:applyOffsetForce(vector force, vector position)
if not validPhysics(this) then return nil end
if not isOwner(self, this) then return nil end
local phys = this:GetPhysicsObject()
phys:ApplyForceOffset(Vector(force[1],force[2],force[3]), Vector(position[1],position[2],position[3]))
if check(force) and check(position) then
local phys = this:GetPhysicsObject()
phys:ApplyForceOffset(Vector(force[1],force[2],force[3]), Vector(position[1],position[2],position[3]))
end
end
e2function void entity:applyAngForce(angle angForce)
@ -416,6 +429,7 @@ e2function void entity:applyAngForce(angle angForce)
if not isOwner(self, this) then return nil end
if angForce[1] == 0 and angForce[2] == 0 and angForce[3] == 0 then return end
if not check(angForce) then return end
local phys = this:GetPhysicsObject()
@ -452,6 +466,7 @@ e2function void entity:applyTorque(vector torque)
if not isOwner(self, this) then return end
if torque[1] == 0 and torque[2] == 0 and torque[3] == 0 then return end
if not check( torque ) then return end
local phys = this:GetPhysicsObject()

View File

@ -871,16 +871,19 @@ local tostring_typeid = {
e2function table invert(array arr)
local ret = table.Copy(DEFAULT)
local c = 0
local size = 0
for i,v in ipairs(arr) do
c = c + 1
local tostring_this = tostrings[type(v)]
if tostring_this then
ret.s[tostring_this(v)] = i
ret.stypes[tostring_this(v)] = "n"
size = size + 1
elseif (checkOwner(self)) then
self.player:ChatPrint("E2: invert(R): Invalid type ("..type(v)..") in array. Ignored.")
end
end
ret.size = size
self.prf = self.prf + c * opcost
return ret
end
@ -890,6 +893,7 @@ end
e2function table invert(table tbl)
local ret = table.Copy(DEFAULT)
local c = 0
local size = 0
for i,v in pairs(tbl.n) do
c = c + 1
local typeid = tbl.ntypes[i]
@ -897,6 +901,7 @@ e2function table invert(table tbl)
if tostring_this then
ret.s[tostring_this(v)] = i
ret.stypes[tostring_this(v)] = "n"
size = size + 1
elseif (checkOwner(self)) then
self.player:ChatPrint("E2: invert(T): Invalid type ("..typeid..") in table. Ignored.")
end
@ -908,11 +913,13 @@ e2function table invert(table tbl)
if tostring_this then
ret.s[tostring_this(v)] = i
ret.stypes[tostring_this(v)] = "s"
size = size + 1
elseif (checkOwner(self)) then
self.player:ChatPrint("E2: invert(T): Invalid type ("..typeid..") in table. Ignored.")
end
end
self.prf = self.prf + c * opcost
ret.size = size
return ret
end

Binary file not shown.

Binary file not shown.