Skip to content
This repository
Browse code

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
authored August 03, 2012
20  lua/entities/gmod_wire_expression2/init.lua
@@ -362,6 +362,24 @@ function ENT:ResetContext()
362 362
 	self.error = false
363 363
 end
364 364
 
  365
+function ENT:IsCodeDifferent( buffer, includes )
  366
+	-- First check the main file
  367
+	if self.original ~= buffer then return true end
  368
+
  369
+	-- First compare one way
  370
+	for k,v in pairs( self.inc_files ) do
  371
+		if includes[k] ~= v then return true end
  372
+	end
  373
+
  374
+	-- Then compare the other way, too
  375
+	for k,v in pairs( includes ) do
  376
+		if self.inc_files[k] ~= v then return true end
  377
+	end
  378
+
  379
+	-- All code is identical.
  380
+	return false
  381
+end
  382
+
365 383
 function ENT:Setup(buffer, includes, restore, forcecompile)
366 384
 	if self.script then
367 385
 		self:PCallHook('destruct')
@@ -369,7 +387,7 @@ function ENT:Setup(buffer, includes, restore, forcecompile)
369 387
 
370 388
 	self.uid = self.player:UniqueID()
371 389
 
372  
-	if (self.original != buffer or forcecompile) then
  390
+	if forcecompile or self:IsCodeDifferent( buffer, includes ) then
373 391
 		self:CompileCode( buffer, includes )
374 392
 	else
375 393
 		self:ResetContext()

0 notes on commit f37118c

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