Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit f37118cb1c1695d5248197ca3f9641faae55fffd 1 parent a0e6287
Divran Divran authored
Showing with 19 additions and 1 deletion.
  1. +19 −1 lua/entities/gmod_wire_expression2/init.lua
20 lua/entities/gmod_wire_expression2/init.lua
View
@@ -362,6 +362,24 @@ 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')
@@ -369,7 +387,7 @@ function ENT:Setup(buffer, includes, restore, forcecompile)
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()
Please sign in to comment.
Something went wrong with that request. Please try again.