Skip to content
Browse files

E2 - edited includes being discarded fixed

E2: Fixed a problem where edited included files would be discarded unless the main file was also edited. Thanks to Walas for finding it.
  • Loading branch information...
1 parent a0e6287 commit f37118cb1c1695d5248197ca3f9641faae55fffd @Divran Divran committed Aug 3, 2012
Showing with 19 additions and 1 deletion.
  1. +19 −1 lua/entities/gmod_wire_expression2/init.lua
View
20 lua/entities/gmod_wire_expression2/init.lua
@@ -362,14 +362,32 @@ function ENT:ResetContext()
self.error = false
end
+function ENT:IsCodeDifferent( buffer, includes )
+ -- First check the main file
+ if self.original ~= buffer then return true end
+
+ -- First compare one way
+ for k,v in pairs( self.inc_files ) do
+ if includes[k] ~= v then return true end
+ end
+
+ -- Then compare the other way, too
+ for k,v in pairs( includes ) do
+ if self.inc_files[k] ~= v then return true end
+ end
+
+ -- All code is identical.
+ return false
+end
+
function ENT:Setup(buffer, includes, restore, forcecompile)
if self.script then
self:PCallHook('destruct')
end
self.uid = self.player:UniqueID()
- if (self.original != buffer or forcecompile) then
+ if forcecompile or self:IsCodeDifferent( buffer, includes ) then
self:CompileCode( buffer, includes )
else
self:ResetContext()

0 comments on commit f37118c

Please sign in to comment.
Something went wrong with that request. Please try again.