A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

gui_con_locater.lua - Stikked
From Cute Echidna, 12 Years ago, written in Lua.
Embed
  1. local version = "0.95"
  2.  
  3. function widget:GetInfo()
  4.   return {
  5.     name      = "Constructor locater",
  6.     desc      = "Version " .. version .. ". Shows graphics around your constructors on demand to " ..
  7.     "make finding them faster" ,
  8.     author    = "Sphiloth aka. Alcur",
  9.     date      = "Aug 3, 2012",
  10.     license   = "BSD 3-clause with unsanctioned use aiming for profit forbidden",
  11.     layer     = 0,
  12.     enabled   = false
  13.   }
  14. end
  15.  
  16. include"keysym.h.lua"
  17.  
  18.  
  19.  
  20.  
  21.  
  22. -- options begin
  23.  
  24. -- how many sides the marker "circles" will have
  25. local circleDivs = 4
  26.  
  27. -- how fast the constructor-indicating graphics blink
  28. local aniSpeed = 0.25
  29.  
  30. -- color 1 for the constructor-indicating graphics
  31. local red1 = 1
  32. local green1 = 0.5
  33. local blue1 = 0
  34.  
  35. -- color 2 for the constructor-indicating graphics
  36. local red2 = 0
  37. local green2 = 0.5
  38. local blue2 = 1
  39.  
  40. -- if the camera aka. in-game view is below this height the constructor-indicating graphics
  41. -- are disabled
  42. local minActivationHeight = 0
  43.  
  44. -- if the camera is above this height the constructor-indicating graphics are shown.
  45. -- Type "false" or "nil" (without the quotation marks) to disable
  46. local activationHeight = nil
  47.  
  48. -- the keys that activate the constructor-indicating graphics
  49. local activationKeyTable = {
  50.     [KEYSYMS.Q] = true,
  51.     [KEYSYMS.SPACE] = true
  52. }
  53.  
  54. -- enabling this means having your cursor on a constructor activates
  55. -- the constructor-indicating graphics
  56. local activateOnMouseOver = false
  57.  
  58. -- enabling this causes the widget to draw only on the mini map
  59. local miniMapOnly = false
  60.  
  61. -- options end
  62.  
  63.  
  64.  
  65.  
  66.  
  67. local widgetName = widget:GetInfo().name
  68.  
  69. local abs = math.abs
  70. local floor = math.floor
  71. local pi = math.pi
  72. local cos = math.cos
  73. local sin = math.sin
  74. local insert = table.insert
  75. local remove = table.remove
  76. local bit_inv = math.bit_inv
  77.  
  78. local glDrawGroundCircle = gl.DrawGroundCircle
  79. local glLineWidth = gl.LineWidth
  80. local glColor = gl.Color
  81. local glCreateList = gl.CreateList
  82. local glCallList = gl.CallList
  83. local glDeleteList = gl.DeleteList
  84. local glVertex = gl.Vertex
  85. local glDrawListAtUnit = gl.DrawListAtUnit
  86. local glDrawFuncAtUnit = gl.DrawFuncAtUnit
  87. local glBeginEnd = gl.BeginEnd
  88. local glTranslate = gl.Translate
  89. local glScale = gl.Scale
  90. local glRotate = gl.Rotate
  91. local glPopMatrix = gl.PopMatrix
  92. local glPushMatrix = gl.PushMatrix
  93.  
  94.  
  95. local DiffTimers = Spring.DiffTimers
  96. local GetTimer = Spring.GetTimer
  97. local GetGameSeconds = Spring.GetGameSeconds
  98. local IsGUIHidden = Spring.IsGUIHidden
  99. local GetTeamUnits = Spring.GetTeamUnits
  100. local myTeam = Spring.GetMyTeamID()
  101. local GetUnitDefID = Spring.GetUnitDefID
  102. local GetCameraPosition = Spring.GetCameraPosition
  103. local GetGroundNormal = Spring.GetGroundNormal
  104. local GetGroundHeight = Spring.GetGroundHeight
  105. local TraceScreenRay = Spring.TraceScreenRay
  106. local IsUnitInView = Spring.IsUnitInView
  107. local IsUnitIcon = Spring.IsUnitIcon
  108. local GetUnitPosition = Spring.GetUnitPosition
  109. local GetUnitBasePosition = Spring.GetUnitBasePosition
  110. local GetFPS = Spring.GetFPS
  111. local Echo = Spring.Echo
  112.  
  113. local canDraw = false
  114. local unitListIndex = 0
  115. local radstep = (2.0 * pi) / circleDivs
  116. local radInDeg = 180/pi
  117. local red = red1
  118. local green = green1
  119. local blue = blue1
  120. local mapSizeX, mapSizeZ = Game.mapSizeX, Game.mapSizeZ
  121. local circleGlList
  122. local aniFactor = 1
  123. local aniDelta = aniSpeed
  124. local mobileConDefIdTable = {}
  125. local conMemoTable = {}
  126. local keyPressed = false
  127. local above = false
  128. local useSecColors = true
  129. local lastTime
  130.  
  131.  
  132.  
  133. function append(list, value)
  134.   --Echo(widgetName .. ': entered "' .. debug.getinfo(1, "n").name .. '"')
  135.   list[#list+1] = value
  136. end
  137.  
  138. function contains(list, entry)
  139.   --Echo(widgetName .. ': entered "' .. debug.getinfo(1, "n").name .. '"')
  140.   for i = 1, #list do
  141.     if list[i] == entry then return true end
  142.   end
  143.   return false
  144. end
  145.  
  146. function radToDeg(rad)
  147.     return rad*radInDeg
  148. end
  149.  
  150. function makeCircle(x, y, z, scale)
  151.     function  circleLines()
  152.         for i = 1, circleDivs do
  153.             local a = (i * radstep)
  154.             glVertex(sin(a)*scale + x,
  155.             y, cos(a)*scale + z)
  156.         end    
  157.     end
  158.  
  159.     glBeginEnd(GL.LINE_LOOP, circleLines)
  160. end
  161.  
  162.  
  163. function isMobileCon(unitDef)
  164.     return unitDef.isBuilder and unitDef.canMove and not unitDef.isBuilding
  165. end
  166.  
  167.  
  168.  
  169. function worldToMiniMapPos(x, z, mmxsize, mmzsize)
  170.  
  171.     --Echo(widgetName .. ": sx*mmxsize/vxsize, sy*mmysize/vysize = " .. sx*mmxsize/vxsize .. ", " .. sy*mmysize/vysize)
  172.  
  173.     return x*mmxsize/mapSizeX, z*mmzsize/mapSizeZ
  174.  
  175. end
  176.  
  177.  
  178. function isDeltaTimeHighEnough()
  179.     local curTime = GetTimer()
  180.  
  181.     if DiffTimers(curTime, lastTime) >= drawInterval then
  182.         lastTime = curTime
  183.         return true
  184.        
  185.     end
  186.     return false
  187. end
  188.  
  189. function areConditionsMet()
  190.     local cx, cy, cz = GetCameraPosition()
  191.  
  192.     if (keyPressed or above or (activationHeight and cy >= activationHeight)) and
  193.         cy >= minActivationHeight and not IsGUIHidden() then
  194.         return true
  195.     end
  196.     return false
  197. end
  198.  
  199.  
  200. function loadClasses()
  201.  
  202.   List = {}
  203.  
  204.   function List:new(contents)
  205.     local o = {}
  206.  
  207.  
  208.  
  209.     setmetatable(o, self)
  210.  
  211.     o.contents = contents or {}
  212.     o.locked = false
  213.  
  214.  
  215.     self.__index = function (table, key)
  216.       if type(key) == "number" then
  217.         return table:get(key)
  218.       else
  219.         return rawget(self, key)
  220.       end
  221.     end
  222.  
  223.  
  224.     return o
  225.   end
  226.  
  227.   function List:get(key)
  228.     if key == nil then
  229.       return self.contents
  230.     elseif type(key) == "number" then
  231.       return self.contents[key]
  232.     end
  233.   end
  234.  
  235.  
  236.   function List:len()
  237.     return #self:get()
  238.   end
  239.  
  240.   function List:insert(pos, val)
  241.     if not val then
  242.       self:append(pos)
  243.     else
  244.       insert(self:get(), pos, val)
  245.     end
  246.   end
  247.  
  248.  
  249.   function List:replace(pos, val)
  250.     if not val then
  251.       self:get()[self:len()] = val
  252.     else
  253.       self:get()[pos] = val
  254.     end
  255.   end
  256.  
  257.   function List:setContents(list)
  258.     self.contents = list
  259.   end
  260.  
  261.   function List:__newindex(key, value)
  262.     if type(key) == "number" then
  263.       self:replace(key, value)
  264.     else
  265.       rawset(self, key, value)
  266.     end
  267.   end
  268.  
  269.   function List:append(val)
  270.     append(self:get(), val)
  271.   end
  272.  
  273.   function List:remove(k)
  274.     if type(k) == "number" then
  275.       return remove(self:get(), k)
  276.     end
  277.   end
  278.  
  279.   function List:search(entry)
  280.     local value
  281.     local key
  282.     for i = 1, self:len() do
  283.       if self:get(i) == entry then value = entry; key = i end
  284.     end
  285.     return key, value
  286.   end
  287.  
  288.   function List:find(entry)
  289.     local tempT = self:get()
  290.     local value
  291.     local key
  292.     for i = 1, self:len() do
  293.       if tempT[i] == entry then value = entry; key = i end
  294.     end
  295.     return key, value
  296.   end
  297.  
  298.   function List:contains(entry)
  299.     local tempT = self:get()
  300.     for i = 1, self:len() do
  301.       if tempT[i] == entry then return true end
  302.     end
  303.     return false
  304.   end
  305.  
  306.   function List:removeByValue(entry)
  307.     local k, v = self:search(entry)
  308.     return self:remove(k)
  309.   end
  310.  
  311.   function List:lock()
  312.     if self:isLocked() then
  313.       error('unable to lock an already locked List object')
  314.     end
  315.     self.locked = true
  316.   end
  317.  
  318.   function List:unlock()
  319.     if not self:isLocked() then
  320.       error('unable to unlock an already unlocked List object')
  321.     end
  322.     self.locked = false
  323.   end
  324.  
  325.   function List:isLocked()
  326.     return self.locked
  327.   end
  328.  
  329. end
  330.  
  331. loadClasses()
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338. local conList = List:new()
  339.  
  340.  
  341.  
  342. function fillConList(unitIdList)
  343.     if conList[1] then return end
  344.     local unit
  345.     local unitDef
  346.     local unitDefId
  347.     local unitPos = {}
  348.     local curUnitIdList = unitIdList or Spring.GetAllUnits()
  349.     --Echo(widgetName .. ": #curUnitIdList = " .. #curUnitIdList)
  350.     for i = 1, #curUnitIdList do
  351.         unit = curUnitIdList[i]
  352.         unitDefId = GetUnitDefID(unit)
  353.         unitDef = UnitDefs[unitDefId]
  354.         if not conMemoTable[unit] and mobileConDefIdTable[unitDefId] then
  355.             --Echo(widgetName .. ": new builder found")
  356.             addToConTables(unit)
  357.         end
  358.     end
  359.  
  360. end
  361.  
  362. function addToConTables(unitId)
  363.     if not unitId then return end
  364.     conList:insert(unitId)
  365.     conMemoTable[unitId] = true
  366. end
  367.  
  368. function removeFromConTables(unitId, unitListIndex)
  369.     if unitListIndex then
  370.         conList:remove(unitListIndex)
  371.     elseif unitId then
  372.         conList:removeByValue(unitId)
  373.     else
  374.         return
  375.     end
  376.     conMemoTable[unitId] = nil
  377.     --Echo(widgetName .. ": removed " .. tostring(unitId) .. ", " ..
  378.     --tostring(unitListIndex))
  379. end
  380.  
  381.  
  382.  
  383.  
  384. function widget:DrawInMiniMap(sx, sy)
  385.  
  386.  
  387.     if areConditionsMet() then
  388.  
  389.         local cx, cy, cz = GetCameraPosition()
  390.  
  391.         glLineWidth(1)
  392.  
  393.         glColor(red, green, blue, aniFactor*0.4)
  394.  
  395.         local max = conList:len()
  396.  
  397.         for i = 1, max do
  398.  
  399.             local unit = conList[i]
  400.             --Echo(widgetName .. ": unit = " .. unit)
  401.  
  402.             if not unit then
  403.                 --Echo(widgetName .. ": could not get unit id (DrawInMiniMap)")
  404.             else
  405.            
  406.                 local ux, uy, uz = GetUnitBasePosition(unit)
  407.                
  408.  
  409.                 if not ux then
  410.                     --Echo(widgetName .. ": could not get unit coordinates (DrawInMiniMap)")
  411.                     removeFromConTables(unit)
  412.                 else
  413.                     local mmux, mmuz = worldToMiniMapPos(ux, uz, sx, sy)
  414.  
  415.                     gl.Rect(mmux - 5, sy-mmuz - 5, mmux + 5, sy-mmuz + 5)
  416.  
  417.                 end
  418.             end          
  419.         end    
  420.     end
  421. end
  422.  
  423. function rewindAnimation()
  424.     if aniFactor < 1 then
  425.         aniFactor = 1
  426.         useSecColors = true
  427.         aniDelta = aniSpeed
  428.         red = red1
  429.         green = green1    
  430.         blue = blue1
  431.     end
  432. end
  433.  
  434.  
  435. function widget:DrawWorld()
  436.  
  437.  
  438.     if not miniMapOnly and areConditionsMet() then
  439.         local cx, cy, cz = GetCameraPosition()
  440.        
  441.  
  442.         local camFactor
  443.         local camYDiff
  444.  
  445.  
  446.         if aniFactor < 0 then
  447.             aniDelta = aniSpeed
  448.             if useSecColors then
  449.                 red = red2
  450.                 green = green2
  451.                 blue = blue2
  452.             else
  453.                 red = red1
  454.                 green = green1    
  455.                 blue = blue1
  456.             end
  457.             useSecColors = not useSecColors
  458.         elseif aniFactor > 1 then
  459.             aniDelta = -aniSpeed
  460.         end
  461.  
  462.         aniFactor = aniFactor + aniDelta
  463.  
  464.        
  465.         glLineWidth(2.5)
  466.  
  467.         camFactor = cy/200+25
  468.  
  469.         if camFactor < 50 then
  470.             camFactor = 50
  471.         end
  472.  
  473.         glColor(red, green, blue, aniFactor)
  474.  
  475.         local max = conList:len()
  476.  
  477.         for i = 1, max do
  478.  
  479.  
  480.             local unit = conList[i]
  481.  
  482.             if not unit then
  483.                 --Echo(widgetName .. ": could not get unit id (DrawWorld)")
  484.             else
  485.             --Echo(widgetName .. ": unit = " .. unit)
  486.                 if IsUnitInView(unit) then
  487.                     local ux, uy, uz = GetUnitBasePosition(unit)
  488.  
  489.                     if not ux then
  490.                         --Echo(widgetName .. ": could not get unit coordinates (DrawWorld)")
  491.                         removeFromConTables(unit)
  492.                     else
  493.                         if IsUnitIcon(unit) then
  494.                             --Echo(widgetName .. ": using inefficient drawing method")  
  495.                             makeCircle(ux, uy, uz, camFactor)
  496.                         else
  497.                             --Echo(widgetName .. ": using efficient drawing method")        
  498.                             glDrawListAtUnit(unit, circleGlList, false, camFactor,
  499.                             camFactor, camFactor)
  500.                         end
  501.                     end
  502.                 end
  503.             end
  504.         end
  505.  
  506.        
  507.     else
  508.         rewindAnimation()
  509.     end
  510.  
  511. end
  512.  
  513. function widget:KeyPress(key, mods, isRepeat)
  514.  
  515.     if activationKeyTable[key] and isRepeat == false then
  516.  
  517.         fillConList()
  518.    
  519.         keyPressed = true
  520.     end
  521.  
  522. end
  523.  
  524. function widget:KeyRelease(key)
  525.  
  526.     if activationKeyTable[key] then
  527.         keyPressed = false
  528.         rewindAnimation()
  529.     end
  530.  
  531.  
  532.  
  533. end
  534.  
  535.  
  536.  
  537. function widget:UnitDestroyed(unitId, unitDefId)
  538.     if conMemoTable[unitId] then
  539.         removeFromConTables(unitId)
  540.     end
  541. end
  542.  
  543.  
  544. function widget:UnitFinished(unitId, unitDefId)
  545.     if mobileConDefIdTable[unitDefId] then
  546.         addToConTables(unitId)
  547.     end
  548. end
  549.  
  550. function widget:UnitTaken(unitId, unitDefId)
  551.     if mobileConDefIdTable[unitDefId] then
  552.         addToConTables(unitId)
  553.     end
  554. end
  555.  
  556. function widget:UnitGiven(unitId, unitDefId)
  557.     if conMemoTable[unitId] then
  558.         removeFromConTables(unitId)
  559.     end
  560. end
  561.  
  562. function widget:IsAbove(x, y)
  563.  
  564.     if not activateOnMouseOver then
  565.         return
  566.     end
  567.  
  568.     local class, info = TraceScreenRay(x, y)
  569.  
  570.     if class == "unit" then
  571.         local unitDefId = GetUnitDefID(info)
  572.         if mobileConDefIdTable[unitDefId] then
  573.             fillConList()
  574.  
  575.             above = true
  576.         end
  577.          
  578.     elseif above then
  579.         above = false
  580.         rewindAnimation()
  581.     end
  582.  
  583. end
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590. function widget:Initialize()
  591.  
  592.     circleGlList = glCreateList(makeCircle, 0, 0, 0, 1)
  593.  
  594.     lastTime = GetTimer()
  595.  
  596.     for k,v in pairs(UnitDefs) do
  597.         if isMobileCon(v) then
  598.             mobileConDefIdTable[k] = true
  599.             --Echo(widgetName .. ": mobile con added to table")
  600.         end
  601.     end
  602.  
  603. end