Advertisement
Rochet2

Untitled

Sep 18th, 2014
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.78 KB | None | 0 0
  1. if(true) then
  2. return end
  3.  
  4. -- Define what to find, remove the find table to find all
  5. local find = {
  6.     SpellSchoolMask = true,
  7.     CorpseType = true,
  8.     GOState = true,
  9.     LootState = true,
  10.     WeatherType = true,
  11.     SelectAggroTarget = true,
  12.     TeamId = true,
  13.     QuestFlags = true,
  14.     RemoveMethod = true, -- this exists only on tc based sources
  15.     UnitState = true,
  16.     SpellSchools = true,
  17.    
  18.     Team = true,
  19.     BattleGroundBracketId = true,
  20.     BattleGroundTypeId = true,
  21.     BattleGroundStatus = true,
  22.     Locales = true,
  23.     OpcodesList = true,
  24.     BanMode = true,
  25.     MailStationery = true,
  26.     EnchantmentSlot = true,
  27.     InventoryResult = true,
  28.     TempSummonType = true, -- trinity to be followed
  29.     Gender = true,
  30.     Races = true,
  31.     Classes = true,
  32.     Powers = true,
  33.     ItemQualities = true,
  34.     CharacterSlot = true,
  35.     Language = true,
  36.     NPCFlags = true,
  37.     UnitFlags = true,
  38.     EObjectFields = true,
  39.     EItemFields = true,
  40.     EUnitFields = true,
  41.     EGameObjectFields = true,
  42. }
  43.  
  44. -- Paths to sources (key is name and value is path
  45. local PATH = {
  46.     tcwotlk = "E:/Cores/Eluna/trin_wotlk/source/src",
  47.     tccata = "E:/Cores/Eluna/trin_cata/source/src",
  48.     mzero = "E:/Cores/Eluna/mang_zero/src",
  49.     czero = "E:/Cores/Eluna/mang_classic/src",
  50.     cone = "E:/Cores/Eluna/mang_tbc/src",
  51.     ctwo = "E:/Cores/Eluna/mang_wotlk/src",
  52. }
  53.  
  54. -- scroll to bottom for output folder
  55.  
  56. -- utility
  57. local function WriteFile(path, str)
  58.     local f = assert(io.open(path, "w"))
  59.     f:write(str)
  60.     f:close()
  61. end
  62. local function OpenFile(path)
  63.     local f = assert(io.open(path, "r"))
  64.     local str = f:read("*all")
  65.     f:close()
  66.     return str
  67. end
  68. local function scandir(path, files)
  69.     local f = io.popen('dir "'..path..'" /b')
  70.     if (not f) then return files end
  71.    
  72.     for name in f:lines() do
  73.         if (name:find("%.")) then
  74.             if (name:find("%.h$")) then
  75.                 table.insert(files, path.."/"..name)
  76.             end
  77.         else
  78.             scandir(path.."/"..name, files)
  79.         end
  80.     end
  81.     f:close()
  82.     return files
  83. end
  84.  
  85. for srcname, path in pairs(PATH) do
  86.     local Files = scandir(path, {})
  87.  
  88.     local enums = {}
  89.     local found = {}
  90.     for k,v in ipairs(Files) do
  91.         for code, name in OpenFile(v):gmatch("(enum%s+([%w_]+)[%s\n]+%b{})") do
  92.             if (not find or find[name]) then
  93.                 table.insert(enums, code)
  94.                 found[name] = code
  95.             end
  96.         end
  97.     end
  98.     for k,v in pairs(find) do
  99.         if(not found[k]) then
  100.             print("Could not find "..k.." from "..srcname.." at "..path)
  101.         end
  102.     end
  103.     table.sort(enums)
  104.  
  105.     -- Output file path
  106.     WriteFile("output/"..srcname.."_enums.lua", table.concat(enums, "\n\n"))
  107. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement