# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python:
import os

builder.SetBuildFolder('packages')

ModPackages = {
  'cstrike': 'cstrike',
  'dod': 'dod',
  'esf': 'esf',
  'ns': 'ns',
  'tfc': 'tfc',
  'tfcx': 'tfc',
  'ts': 'ts',
}

folder_list = [
    'base/addons/amxmodx',
    'base/addons/amxmodx/configs',
    'base/addons/amxmodx/data',
    'base/addons/amxmodx/data/gamedata',
    'base/addons/amxmodx/data/gamedata/common.games',
    'base/addons/amxmodx/data/gamedata/common.games/entities.games',
    'base/addons/amxmodx/data/gamedata/common.games/entities.games/cstrike',
    'base/addons/amxmodx/data/gamedata/common.games/entities.games/dod',
    'base/addons/amxmodx/data/gamedata/common.games/entities.games/tfc',
    'base/addons/amxmodx/data/gamedata/common.games/entities.games/gearbox',
    'base/addons/amxmodx/data/gamedata/common.games/entities.games/valve',
    'base/addons/amxmodx/data/gamedata/common.games/hostages.games',
    'base/addons/amxmodx/data/gamedata/common.games/hostages.games/cstrike',
    'base/addons/amxmodx/data/gamedata/common.games/others.games',
    'base/addons/amxmodx/data/gamedata/common.games/others.games/cstrike',
    'base/addons/amxmodx/data/gamedata/common.games/gamerules.games',
    'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/cstrike',
    'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/dod',
    'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/tfc',
    'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/gearbox',
    'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/valve',
    'base/addons/amxmodx/data/gamedata/modules.games',
    'base/addons/amxmodx/data/lang',
    'base/addons/amxmodx/dlls',
    'base/addons/amxmodx/logs',
    'base/addons/amxmodx/modules',
    'base/addons/amxmodx/plugins',
    'base/addons/amxmodx/scripting',
    'base/addons/amxmodx/scripting/include',
    'base/addons/amxmodx/scripting/testsuite',
    'cstrike/addons/amxmodx/configs',
    'cstrike/addons/amxmodx/data',
    'cstrike/addons/amxmodx/plugins',
    'cstrike/addons/amxmodx/modules',
    'cstrike/addons/amxmodx/scripting',
    'dod/addons/amxmodx/configs',
    'dod/addons/amxmodx/data',
    'dod/addons/amxmodx/plugins',
    'dod/addons/amxmodx/modules',
    'dod/addons/amxmodx/scripting',
    'esf/addons/amxmodx/configs',
    'esf/addons/amxmodx/plugins',
    'esf/addons/amxmodx/scripting',
    'ns/addons/amxmodx/configs',
    'ns/addons/amxmodx/plugins',
    'ns/addons/amxmodx/modules',
    'ns/addons/amxmodx/scripting',
    'tfc/addons/amxmodx/configs',
    'tfc/addons/amxmodx/data',
    'tfc/addons/amxmodx/plugins',
    'tfc/addons/amxmodx/modules',
    'tfc/addons/amxmodx/scripting',
    'ts/addons/amxmodx/configs',
    'ts/addons/amxmodx/data',
    'ts/addons/amxmodx/plugins',
    'ts/addons/amxmodx/modules',
    'ts/addons/amxmodx/scripting',
]

def split_all(path):
  parts = []
  while True:
    head, tail = os.path.split(path)
    if head == path or tail == path:
      parts.insert(0, path)
      break
    path = head
    parts.insert(0, tail)
  return parts

def copy_binary(source, dest):
  builder.AddCopy(source.binary, dest)

# Create the distribution folder hierarchy.
folder_map = {}
for folder in folder_list:
  norm_folder = os.path.normpath(folder)
  folder_map[folder] = builder.AddFolder(norm_folder)

# Do all straight-up file copies from the source tree.
def CopyFiles(src, dest, files):
  if not dest:
    dest = src
  dest_entry = folder_map[dest]
  for source_file in files:
    source_path = os.path.join(builder.sourcePath, src, source_file)
    builder.AddCopy(source_path, dest_entry)

# Copy core dlls.
for dll in AMXX.binaries:
  copy_binary(dll, folder_map['base/addons/amxmodx/dlls'])

# Copy modules.
for module in AMXX.modules:
  parts = split_all(module.binary.path)
  if parts[1] in ModPackages:
    package = ModPackages[parts[1]]
  else:
    package = 'base'
  copy_binary(module, folder_map[package + '/addons/amxmodx/modules'])

# Copy the compiler.
builder.AddCopy(AMXX.amxxpc.binary, folder_map['base/addons/amxmodx/scripting'])
builder.AddCopy(AMXX.libpc300.binary, folder_map['base/addons/amxmodx/scripting'])

# Copy plugins.
StatsPlugins = ['csstats.amxx']
for amxx_file in AMXX.plugins:
  amxx_entry = AMXX.plugins[amxx_file]
  package = os.path.dirname(amxx_file)
  output_folder = '/addons/amxmodx/plugins'
  if not len(package):
    package = 'base'
  else:
    # Ugh - statsx plugins go into a random folder.
    name = os.path.basename(amxx_file)
    if name == package + 'stats.amxx' or name in StatsPlugins:
      output_folder = '/addons/amxmodx/data'

  builder.AddCopy(amxx_entry, folder_map[package + output_folder])

  # If it was in a mod package, we can cheat and copy it to scripting since
  # none of them are multi-file.
  if package != 'base':
    base_file, _ = os.path.splitext(os.path.basename(amxx_file))
    source_file = os.path.join(
      builder.sourcePath,
      'plugins',
      package,
      base_file + '.sma'
    )
    builder.AddCopy(source_file, folder_map[package + '/addons/amxmodx/scripting'])

# Copy the generated version .inc.
for generated_header in AMXX.generated_headers:
  if 'amxmodx_version.inc' in generated_header.path:
    builder.AddCopy(generated_header, folder_map['base/addons/amxmodx/scripting/include'])
    break

# Copy WinCSX.
if builder.target_platform == 'windows':
  builder.AddCopy(AMXX.csx_app.binary, folder_map['cstrike/addons/amxmodx/data'])

# Copy configuration files for each mod.
configs = [
  'amxx.cfg',
  'clcmds.ini',
  'cmds.ini',
  'configs.ini',
  'core.ini',
  'custommenuitems.cfg',
  'cvars.ini',
  'hamdata.ini',
  'maps.ini',
  'miscstats.ini',
  'modules.ini',
  'plugins.ini',
  'speech.ini',
  'sql.cfg',
  'users.ini',
  'cstrike/amxx.cfg',
  'cstrike/cmds.ini',
  'cstrike/core.ini',
  'cstrike/cvars.ini',
  'cstrike/maps.ini',
  'cstrike/modules.ini',
  'cstrike/plugins.ini',
  'cstrike/stats.ini',
  'dod/core.ini',
  'dod/cvars.ini',
  'dod/maps.ini',
  'dod/modules.ini',
  'dod/plugins.ini',
  'esf/modules.ini',
  'esf/plugins.ini',
  'ns/amxx.cfg',
  'ns/clcmds.ini',
  'ns/cmds.ini',
  'ns/cvars.ini',
  'ns/maps.ini',
  'ns/modules.ini',
  'ns/plugins.ini',
  'ns/speech.ini',
  'ns/users.ini',
  'tfc/core.ini',
  'tfc/cvars.ini',
  'tfc/maps.ini',
  'tfc/modules.ini',
  'tfc/plugins.ini',
  'ts/core.ini',
  'ts/maps.ini',
  'ts/modules.ini',
  'ts/plugins.ini',
]
for config in configs:
  cfg_folder, cfg_file = os.path.split(config)
  if len(cfg_folder):
    out_folder = cfg_folder + '/addons/amxmodx/configs'
  else:
    out_folder = 'base/addons/amxmodx/configs'
  builder.AddCopy(
    source = os.path.join(builder.sourcePath, 'configs', config),
    output_path = folder_map[out_folder]
  )

# Copy core scripting files.
scripting_files = [
  'admin.sma',
  'adminchat.sma',
  'admincmd.sma',
  'adminhelp.sma',
  'adminslots.sma',
  'adminvote.sma',
  'antiflood.sma',
  'cmdmenu.sma',
  'imessage.sma',
  'mapchooser.sma',
  'mapsmenu.sma',
  'menufront.sma',
  'multilingual.sma',
  'nextmap.sma',
  'pausecfg.sma',
  'plmenu.sma',
  'scrollmsg.sma',
  'statscfg.sma',
  'telemenu.sma',
  'timeleft.sma',
  'pluginmenu.sma',
  'testsuite/admins_test.sma',
  'testsuite/arraytest.sma',
  'testsuite/callfunc_test.sma',
  'testsuite/datapack_test.sma',
  'testsuite/fakemeta_tests.sma',
  'testsuite/fmttest.sma',
  'testsuite/fwdtest1.sma',
  'testsuite/fwdtest2.sma',
  'testsuite/hashing_test.sma',
  'testsuite/json_test.sma',
  'testsuite/logtest.sma',
  'testsuite/menutest.sma',
  'testsuite/native_test.sma',
  'testsuite/nvault_test.sma',
  'testsuite/regex_test.sma',
  'testsuite/sorttest.sma',
  'testsuite/strbreak.sma',
  'testsuite/sqlxtest.sma',
  'testsuite/sqlxtest.sq3',
  'testsuite/sqlxtest.sql',
  'testsuite/trietest.sma',
  'testsuite/utf8test.sma',
  'testsuite/stacktest.sma',
  'testsuite/textparse_test.sma',
  'testsuite/textparse_test.cfg',
  'testsuite/textparse_test.ini',
  'testsuite/request_frame_test.sma',
  'testsuite/menu_page_callback_test.sma',
  'include/amxconst.inc',
  'include/amxmisc.inc',
  'include/amxmodx.inc',
  'include/core.inc',
  'include/csstats.inc',
  'include/csstats_const.inc',
  'include/cstrike.inc',
  'include/cstrike_const.inc',
  'include/csx.inc',
  'include/cvars.inc',
  'include/datapack.inc',
  'include/dbi.inc',
  'include/dodconst.inc',
  'include/dodfun.inc',
  'include/dodstats.inc',
  'include/dodx.inc',
  'include/engine.inc',
  'include/engine_const.inc',
  'include/engine_stocks.inc',
  'include/esf.inc',
  'include/esf_const.inc',
  'include/fakemeta.inc',
  'include/fakemeta_const.inc',
  'include/fakemeta_stocks.inc',
  'include/file.inc',
  'include/float.inc',
  'include/fun.inc',
  'include/gameconfig.inc',
  'include/geoip.inc',
  'include/json.inc',
  'include/lang.inc',
  'include/ns.inc',
  'include/ns_const.inc',
  'include/nvault.inc',
  'include/regex.inc',
  'include/sockets.inc',
  'include/string.inc',
  'include/string_const.inc',
  'include/string_stocks.inc',
  'include/tfcconst.inc',
  'include/tfcstats.inc',
  'include/tfcx.inc',
  'include/tsconst.inc',
  'include/tsfun.inc',
  'include/tsstats.inc',
  'include/tsx.inc',
  'include/vault.inc',
  'include/xs.inc',
  'include/cellarray.inc',
  'include/cellstack.inc',
  'include/celltrie.inc',
  'include/fakemeta_util.inc',
  'include/ham_const.inc',
  'include/hamsandwich.inc',
  'include/hlsdk_const.inc',
  'include/message_const.inc',
  'include/message_stocks.inc',
  'include/messages.inc',
  'include/newmenus.inc',
  'include/sorting.inc',
  'include/sqlx.inc',
  'include/textparse_ini.inc',
  'include/textparse_smc.inc',
  'include/time.inc',
  'include/vector.inc',
]
for filename in scripting_files:
  output_folder = 'base/addons/amxmodx/scripting'
  inner_folder = os.path.dirname(filename)
  if len(inner_folder):
    output_folder += '/' + inner_folder
  builder.AddCopy(
    source = os.path.join(builder.sourcePath, 'plugins', filename),
    output_path = folder_map[output_folder]
  )

# Copy weird things.
weirdfiles = [
  ('modules/geoip/GeoLite2-Country.mmdb', 'base/addons/amxmodx/data'),
  ('plugins/esf/ESF_mod_tutorial.txt', 'esf/addons/amxmodx/scripting'),
]

if builder.target_platform == 'windows':
  weirdfiles += [
    ('plugins/compile.exe', 'base/addons/amxmodx/scripting'),
  ]
else:
  weirdfiles += [
    ('plugins/compile.sh', 'base/addons/amxmodx/scripting'),
  ]

for source, dest in weirdfiles:
  builder.AddCopy(
    source = os.path.join(builder.sourcePath, source),
    output_path = folder_map[dest]
  )

# Copy language data.
datafiles = [
  'admin.txt',
  'adminchat.txt',
  'admincmd.txt',
  'adminhelp.txt',
  'adminslots.txt',
  'adminvote.txt',
  'antiflood.txt',
  'cmdmenu.txt',
  'common.txt',
  'imessage.txt',
  'languages.txt',
  'mapchooser.txt',
  'mapsmenu.txt',
  'menufront.txt',
  'miscstats.txt',
  'multilingual.txt',
  'nextmap.txt',
  'pausecfg.txt',
  'plmenu.txt',
  'restmenu.txt',
  'scrollmsg.txt',
  'stats_dod.txt',
  'statscfg.txt',
  'statsx.txt',
  'telemenu.txt',
  'timeleft.txt',
  'time.txt',
]
for datafile in datafiles:
  builder.AddCopy(
    source = os.path.join(builder.sourcePath, 'plugins', 'lang', datafile),
    output_path = folder_map['base/addons/amxmodx/data/lang']
  )


CopyFiles('gamedata/modules.games', 'base/addons/amxmodx/data/gamedata/modules.games',
  [
    'master.games.txt',
    'game.cstrike.txt',
  ]
)

CopyFiles('gamedata/common.games', 'base/addons/amxmodx/data/gamedata/common.games',
  [
    'master.games.txt',
    'functions.engine.txt',
    'globalvars.engine.txt',
  ]
)

CopyFiles('gamedata/common.games/hostages.games/cstrike', 'base/addons/amxmodx/data/gamedata/common.games/hostages.games/cstrike',
  [
    'offsets-chostageimprov.txt',
    'offsets-chostagemanager.txt',
    'offsets-hostagefollowstate.txt',
    'offsets-simplestatemachine.txt',
  ]
)

CopyFiles('gamedata/common.games/others.games/cstrike', 'base/addons/amxmodx/data/gamedata/common.games/others.games/cstrike',
  [
    'offsets-csound.txt',
    'offsets-cunifiedsignals.txt',
    'offsets-cvoicegamemgr.txt',
  ]
)

CopyFiles('gamedata/common.games/entities.games/cstrike', 'base/addons/amxmodx/data/gamedata/common.games/entities.games/cstrike',
  [
    'offsets-cairtank.txt',
    'offsets-cak47.txt',
    'offsets-cambientgeneric.txt',
    'offsets-carmoury.txt',
    'offsets-caug.txt',
    'offsets-cautotrigger.txt',
    'offsets-cawp.txt',
    'offsets-cbaseanimating.txt',
    'offsets-cbasebutton.txt',
    'offsets-cbasedelay.txt',
    'offsets-cbasedoor.txt',
    'offsets-cbaseentity.txt',
    'offsets-cbasegrencatch.txt',
    'offsets-cbasemonster.txt',
    'offsets-cbaseplattrain.txt',
    'offsets-cbaseplayer.txt',
    'offsets-cbaseplayeritem.txt',
    'offsets-cbaseplayerweapon.txt',
    'offsets-cbasetoggle.txt',
    'offsets-cbombglow.txt',
    'offsets-cbot.txt',
    'offsets-cbreakable.txt',
    'offsets-cbubbling.txt',
    'offsets-cc4.txt',
    'offsets-cchangelevel.txt',
    'offsets-cclientfog.txt',
    'offsets-ccsbot.txt',
    'offsets-ccycler.txt',
    'offsets-ccyclersprite.txt',
    'offsets-cdeadhev.txt',
    'offsets-cdeagle.txt',
    'offsets-celite.txt',
    'offsets-cenvexplosion.txt',
    'offsets-cenvfunnel.txt',
    'offsets-cenvglobal.txt',
    'offsets-cenvsound.txt',
    'offsets-cenvspark.txt',
    'offsets-cfamas.txt',
    'offsets-cfiveseven.txt',
    'offsets-cfrictionmodifier.txt',
    'offsets-cfuncmortarfield.txt',
    'offsets-cfuncplatrot.txt',
    'offsets-cfuncrotating.txt',
    'offsets-cfunctank.txt',
    'offsets-cfunctankcontrols.txt',
    'offsets-cfunctanklaser.txt',
    'offsets-cfunctrackchange.txt',
    'offsets-cfunctracktrain.txt',
    'offsets-cfunctrain.txt',
    'offsets-cfuncvehicle.txt',
    'offsets-cfuncweaponcheck.txt',
    'offsets-cg3sg1.txt',
    'offsets-cgalil.txt',
    'offsets-cgameplayerequip.txt',
    'offsets-cgameplayerzone.txt',
    'offsets-cgameteammaster.txt',
    'offsets-cgametext.txt',
    'offsets-cgib.txt',
    'offsets-cgibshooter.txt',
    'offsets-cglock18.txt',
    'offsets-cglow.txt',
    'offsets-cgrenade.txt',
    'offsets-cguntarget.txt',
    'offsets-chegrenade.txt',
    'offsets-chostage.txt',
    'offsets-cknife.txt',
    'offsets-claser.txt',
    'offsets-clight.txt',
    'offsets-clightning.txt',
    'offsets-cm249.txt',
    'offsets-cm3.txt',
    'offsets-cm4a1.txt',
    'offsets-cmac10.txt',
    'offsets-cmapinfo.txt',
    'offsets-cmomentarydoor.txt',
    'offsets-cmomentaryrotbutton.txt',
    'offsets-cmortar.txt',
    'offsets-cmp5n.txt',
    'offsets-cmultimanager.txt',
    'offsets-cmultisource.txt',
    'offsets-cp228.txt',
    'offsets-cp90.txt',
    'offsets-cpathcorner.txt',
    'offsets-cpathtrack.txt',
    'offsets-cpendulum.txt',
    'offsets-cplattrigger.txt',
    'offsets-cpushable.txt',
    'offsets-crecharge.txt',
    'offsets-crevertsaved.txt',
    'offsets-cruleentity.txt',
    'offsets-cscout.txt',
    'offsets-csg550.txt',
    'offsets-csg552.txt',
    'offsets-csmokegrenade.txt',
    'offsets-csoundent.txt',
    'offsets-cspeaker.txt',
    'offsets-csprite.txt',
    'offsets-ctesteffect.txt',
    'offsets-ctmp.txt',
    'offsets-ctriggercamera.txt',
    'offsets-ctriggerchangetarget.txt',
    'offsets-ctriggerrelay.txt',
    'offsets-cump45.txt',
    'offsets-cusp.txt',
    'offsets-cwallhealth.txt',
    'offsets-cweaponbox.txt',
    'offsets-cweaponcycler.txt',
    'offsets-cworlditem.txt',
    'offsets-cwreckage.txt',
    'offsets-cwshield.txt',
    'offsets-cxm1014.txt',
  ]
)

CopyFiles('gamedata/common.games/entities.games/dod', 'base/addons/amxmodx/data/gamedata/common.games/entities.games/dod',
  [
    'offsets-c30cal.txt',
    'offsets-calliedbarney.txt',
    'offsets-calliedgrunt.txt',
    'offsets-cambientgeneric.txt',
    'offsets-careacapture.txt',
    'offsets-cautotrigger.txt',
    'offsets-caxisgrunt.txt',
    'offsets-cbar.txt',
    'offsets-cbaseanimating.txt',
    'offsets-cbasebutton.txt',
    'offsets-cbasedelay.txt',
    'offsets-cbasedmstart.txt',
    'offsets-cbasedoor.txt',
    'offsets-cbaseentity.txt',
    'offsets-cbasemonster.txt',
    'offsets-cbaseplattrain.txt',
    'offsets-cbaseplayer.txt',
    'offsets-cbaseplayeritem.txt',
    'offsets-cbaseplayerweapon.txt',
    'offsets-cbasetoggle.txt',
    'offsets-cbaseturret.txt',
    'offsets-cbazooka.txt',
    'offsets-cbipodweapon.txt',
    'offsets-cbreakable.txt',
    'offsets-cbren.txt',
    'offsets-cbubbling.txt',
    'offsets-cchangelevel.txt',
    'offsets-ccinemonster.txt',
    'offsets-ccontroller.txt',
    'offsets-ccontrollerheadball.txt',
    'offsets-ccontrollerzapball.txt',
    'offsets-ccontrolpoint.txt',
    'offsets-ccontrolpointmaster.txt',
    'offsets-ccycler.txt',
    'offsets-ccyclersprite.txt',
    'offsets-cdeadalliedgrunt.txt',
    'offsets-cdeadaxisgrunt.txt',
    'offsets-cdeadhev.txt',
    'offsets-cdodammobox.txt',
    'offsets-cdodcamera.txt',
    'offsets-cdoddetect.txt',
    'offsets-cdodgrenade.txt',
    'offsets-cdodpararoundtimer.txt',
    'offsets-cdodpointrelay.txt',
    'offsets-cdodpreround.txt',
    'offsets-cdodroundtimer.txt',
    'offsets-cdodstatmgr.txt',
    'offsets-cenfield.txt',
    'offsets-cenvcustomize.txt',
    'offsets-cenvexplosion.txt',
    'offsets-cenvfunnel.txt',
    'offsets-cenvglobal.txt',
    'offsets-cenvmodel.txt',
    'offsets-cenvrain.txt',
    'offsets-cenvsound.txt',
    'offsets-cenvspark.txt',
    'offsets-cenvstate.txt',
    'offsets-cfade.txt',
    'offsets-cfg42.txt',
    'offsets-cfrictionmodifier.txt',
    'offsets-cfuncmortarfield.txt',
    'offsets-cfuncplatrot.txt',
    'offsets-cfuncrotating.txt',
    'offsets-cfunctank.txt',
    'offsets-cfunctankcontrols.txt',
    'offsets-cfunctanklaser.txt',
    'offsets-cfunctrackchange.txt',
    'offsets-cfunctracktrain.txt',
    'offsets-cfunctrain.txt',
    'offsets-cgamecounterset.txt',
    'offsets-cgameplayerequip.txt',
    'offsets-cgameplayerhurt.txt',
    'offsets-cgameplayerzone.txt',
    'offsets-cgameteammaster.txt',
    'offsets-cgameteamset.txt',
    'offsets-cgametext.txt',
    'offsets-cgarand.txt',
    'offsets-cgib.txt',
    'offsets-cgibshooter.txt',
    'offsets-cglow.txt',
    'offsets-cgreasegun.txt',
    'offsets-cgrenade.txt',
    'offsets-cguntarget.txt',
    'offsets-chandgrenade.txt',
    'offsets-chandgrenadeex.txt',
    'offsets-cinfogroup.txt',
    'offsets-ck43.txt',
    'offsets-ckar.txt',
    'offsets-claser.txt',
    'offsets-clight.txt',
    'offsets-clightning.txt',
    'offsets-clocation.txt',
    'offsets-cluger.txt',
    'offsets-cm1carbine.txt',
    'offsets-cmeleeweapon.txt',
    'offsets-cmessage.txt',
    'offsets-cmg34.txt',
    'offsets-cmg42.txt',
    'offsets-cmomentarydoor.txt',
    'offsets-cmomentaryrotbutton.txt',
    'offsets-cmortar.txt',
    'offsets-cmp40.txt',
    'offsets-cmp44.txt',
    'offsets-cmultialias.txt',
    'offsets-cmultimanager.txt',
    'offsets-cmultisource.txt',
    'offsets-cnodeent.txt',
    'offsets-cnodeviewer.txt',
    'offsets-cobject.txt',
    'offsets-cobjectcapture.txt',
    'offsets-cparticleshooter.txt',
    'offsets-cpathcorner.txt',
    'offsets-cpathtrack.txt',
    'offsets-cpendulum.txt',
    'offsets-cpiat.txt',
    'offsets-cpistol.txt',
    'offsets-cplattrigger.txt',
    'offsets-cpschreck.txt',
    'offsets-cpushable.txt',
    'offsets-crat.txt',
    'offsets-crevertsaved.txt',
    'offsets-croach.txt',
    'offsets-crocketshooter.txt',
    'offsets-cruleentity.txt',
    'offsets-csandbag.txt',
    'offsets-csarge.txt',
    'offsets-cscopedkar.txt',
    'offsets-cscoreevent.txt',
    'offsets-cscriptedsentence.txt',
    'offsets-cshake.txt',
    'offsets-csoundent.txt',
    'offsets-cspeaker.txt',
    'offsets-cspring.txt',
    'offsets-csprite.txt',
    'offsets-csquadmonster.txt',
    'offsets-cstatewatcher.txt',
    'offsets-csten.txt',
    'offsets-cstickgrenade.txt',
    'offsets-cstickgrenadeex.txt',
    'offsets-ctalkmonster.txt',
    'offsets-ctesteffect.txt',
    'offsets-ctesthull.txt',
    'offsets-cthompson.txt',
    'offsets-ctriggercamera.txt',
    'offsets-ctriggerchangetarget.txt',
    'offsets-ctriggerlightstyle.txt',
    'offsets-ctriggerpush.txt',
    'offsets-ctriggerrelay.txt',
    'offsets-ctriggersetpatrol.txt',
    'offsets-cturret.txt',
    'offsets-cweaponbox.txt',
    'offsets-cweaponcycler.txt',
    'offsets-cweathersystem.txt',
    'offsets-cwebley.txt',
    'offsets-cworld.txt',
    'offsets-cworlditem.txt',
    'offsets-cwreckage.txt',
  ]
)

CopyFiles('gamedata/common.games/entities.games/tfc', 'base/addons/amxmodx/data/gamedata/common.games/entities.games/tfc',
  [
    'offsets-cactanimating.txt',
    'offsets-cairtank.txt',
    'offsets-cambientgeneric.txt',
    'offsets-careadef.txt',
    'offsets-cautotrigger.txt',
    'offsets-cbaseanimating.txt',
    'offsets-cbasebutton.txt',
    'offsets-cbasedelay.txt',
    'offsets-cbasedoor.txt',
    'offsets-cbaseentity.txt',
    'offsets-cbasemonster.txt',
    'offsets-cbaseplattrain.txt',
    'offsets-cbaseplayer.txt',
    'offsets-cbaseplayeritem.txt',
    'offsets-cbaseplayerweapon.txt',
    'offsets-cbasetoggle.txt',
    'offsets-cbaseturret.txt',
    'offsets-cbreakable.txt',
    'offsets-cbubbling.txt',
    'offsets-cchangelevel.txt',
    'offsets-ccinemonster.txt',
    'offsets-ccrowbar.txt',
    'offsets-ccycler.txt',
    'offsets-ccyclersprite.txt',
    'offsets-cdeadhev.txt',
    'offsets-cdetpack.txt',
    'offsets-cdispenserrefillthinker.txt',
    'offsets-cenvexplosion.txt',
    'offsets-cenvfunnel.txt',
    'offsets-cenvglobal.txt',
    'offsets-cenvsound.txt',
    'offsets-cenvspark.txt',
    'offsets-cfrictionmodifier.txt',
    'offsets-cfuncmortarfield.txt',
    'offsets-cfuncplatrot.txt',
    'offsets-cfuncrotating.txt',
    'offsets-cfunctank.txt',
    'offsets-cfunctankcontrols.txt',
    'offsets-cfunctanklaser.txt',
    'offsets-cfunctrackchange.txt',
    'offsets-cfunctracktrain.txt',
    'offsets-cfunctrain.txt',
    'offsets-cgib.txt',
    'offsets-cgibshooter.txt',
    'offsets-cglow.txt',
    'offsets-cgrenade.txt',
    'offsets-cguntarget.txt',
    'offsets-chandgrenade.txt',
    'offsets-citem.txt',
    'offsets-citemammo.txt',
    'offsets-citemarmor.txt',
    'offsets-citemhealth.txt',
    'offsets-claser.txt',
    'offsets-clight.txt',
    'offsets-clightning.txt',
    'offsets-cmomentarydoor.txt',
    'offsets-cmomentaryrotbutton.txt',
    'offsets-cmortar.txt',
    'offsets-cmultimanager.txt',
    'offsets-cmultisource.txt',
    'offsets-cnodeent.txt',
    'offsets-cnodeviewer.txt',
    'offsets-cpathcorner.txt',
    'offsets-cpathtrack.txt',
    'offsets-cpendulum.txt',
    'offsets-cplattrigger.txt',
    'offsets-cpushable.txt',
    'offsets-crecharge.txt',
    'offsets-crevertsaved.txt',
    'offsets-cscriptedsentence.txt',
    'offsets-csoundent.txt',
    'offsets-cspeaker.txt',
    'offsets-csprite.txt',
    'offsets-csquadmonster.txt',
    'offsets-ctalkmonster.txt',
    'offsets-ctelefragdeath.txt',
    'offsets-ctesteffect.txt',
    'offsets-ctesthull.txt',
    'offsets-ctfassaultc.txt',
    'offsets-ctfautorifle.txt',
    'offsets-ctfaxe.txt',
    'offsets-ctfcaltrop.txt',
    'offsets-ctfconcussiongrenade.txt',
    'offsets-ctfdispenser.txt',
    'offsets-ctfempgrenade.txt',
    'offsets-ctfflame.txt',
    'offsets-ctfflamethrower.txt',
    'offsets-ctfflamethrowerburst.txt',
    'offsets-ctfgasgrenade.txt',
    'offsets-ctfgoalitem.txt',
    'offsets-ctfgrenade.txt',
    'offsets-ctfgrenadelauncher.txt',
    'offsets-ctfincendiaryc.txt',
    'offsets-ctfincendiarycrocket.txt',
    'offsets-ctfknife.txt',
    'offsets-ctfmedikit.txt',
    'offsets-ctfnailgun.txt',
    'offsets-ctfnailgunnail.txt',
    'offsets-ctfnapalmgrenade.txt',
    'offsets-ctfprimegrenade.txt',
    'offsets-ctfrailgun.txt',
    'offsets-ctfrpg.txt',
    'offsets-ctfrpgrocket.txt',
    'offsets-ctfsentrygun.txt',
    'offsets-ctfshotgun.txt',
    'offsets-ctfsniperrifle.txt',
    'offsets-ctfspawn.txt',
    'offsets-ctfsupernailgun.txt',
    'offsets-ctfsupershotgun.txt',
    'offsets-ctfteleporter.txt',
    'offsets-ctftranq.txt',
    'offsets-ctriggercamera.txt',
    'offsets-ctriggerchangetarget.txt',
    'offsets-ctriggerrelay.txt',
    'offsets-cturret.txt',
    'offsets-cwallhealth.txt',
    'offsets-cweaponbox.txt',
    'offsets-cweaponcycler.txt',
    'offsets-cworlditem.txt',
    'offsets-cwreckage.txt',
    'offsets-cxenplight.txt',
    'offsets-cxenspore.txt',
    'offsets-cxensporelarge.txt',
    'offsets-cxentree.txt',
  ]
)

CopyFiles('gamedata/common.games/entities.games/gearbox', 'base/addons/amxmodx/data/gamedata/common.games/entities.games/gearbox',
  [
    'offsets-cactanimating.txt',
    'offsets-cagrunt.txt',
    'offsets-cairtank.txt',
    'offsets-cambientgeneric.txt',
    'offsets-capache.txt',
    'offsets-capachehvr.txt',
    'offsets-cautotrigger.txt',
    'offsets-cbarnacle.txt',
    'offsets-cbarney.txt',
    'offsets-cbaseanimating.txt',
    'offsets-cbasebutton.txt',
    'offsets-cbasedelay.txt',
    'offsets-cbasedmstart.txt',
    'offsets-cbasedoor.txt',
    'offsets-cbaseentity.txt',
    'offsets-cbasemonster.txt',
    'offsets-cbaseplattrain.txt',
    'offsets-cbaseplayer.txt',
    'offsets-cbaseplayeritem.txt',
    'offsets-cbaseplayerweapon.txt',
    'offsets-cbasetoggle.txt',
    'offsets-cbaseturret.txt',
    'offsets-cbigmomma.txt',
    'offsets-cblowercannon.txt',
    'offsets-cbmortar.txt',
    'offsets-cbreakable.txt',
    'offsets-cbubbling.txt',
    'offsets-cbullsquid.txt',
    'offsets-cchangelevel.txt',
    'offsets-ccinemonster.txt',
    'offsets-ccleansuitscientist.txt',
    'offsets-ccontroller.txt',
    'offsets-ccontrollerheadball.txt',
    'offsets-ccontrollerzapball.txt',
    'offsets-ccrossbow.txt',
    'offsets-ccrossbowbolt.txt',
    'offsets-ccrowbar.txt',
    'offsets-ccycler.txt',
    'offsets-ccyclersprite.txt',
    'offsets-cdeadbarney.txt',
    'offsets-cdeadcleansuitscientist.txt',
    'offsets-cdeadgonome.txt',
    'offsets-cdeadhev.txt',
    'offsets-cdeadhfgrunt.txt',
    'offsets-cdeadhgrunt.txt',
    'offsets-cdeadhgruntally.txt',
    'offsets-cdeadhoundeye.txt',
    'offsets-cdeadislave.txt',
    'offsets-cdeadmofassassin.txt',
    'offsets-cdeadotis.txt',
    'offsets-cdeadscientist.txt',
    'offsets-cdeadshocktrooper.txt',
    'offsets-cdeadzombiesoldier.txt',
    'offsets-cdisplacer.txt',
    'offsets-cdisplacerball.txt',
    'offsets-cdrillsergeant.txt',
    'offsets-ceagle.txt',
    'offsets-cegon.txt',
    'offsets-celectrifiedwire.txt',
    'offsets-cenvexplosion.txt',
    'offsets-cenvfunnel.txt',
    'offsets-cenvglobal.txt',
    'offsets-cenvshooter.txt',
    'offsets-cenvsound.txt',
    'offsets-cenvspark.txt',
    'offsets-cflockingflyer.txt',
    'offsets-cflockingflyerflock.txt',
    'offsets-cflyingmonster.txt',
    'offsets-cfrictionmodifier.txt',
    'offsets-cfuncmortarfield.txt',
    'offsets-cfuncplatrot.txt',
    'offsets-cfuncrotating.txt',
    'offsets-cfunctank.txt',
    'offsets-cfunctankcontrols.txt',
    'offsets-cfunctanklaser.txt',
    'offsets-cfunctrackchange.txt',
    'offsets-cfunctracktrain.txt',
    'offsets-cfunctrain.txt',
    'offsets-cgameplayerequip.txt',
    'offsets-cgameplayerzone.txt',
    'offsets-cgameteammaster.txt',
    'offsets-cgametext.txt',
    'offsets-cgargantua.txt',
    'offsets-cgauss.txt',
    'offsets-cgenericitem.txt',
    'offsets-cgenericmonster.txt',
    'offsets-cgib.txt',
    'offsets-cgibshooter.txt',
    'offsets-cglock.txt',
    'offsets-cglow.txt',
    'offsets-cgman.txt',
    'offsets-cgrapple.txt',
    'offsets-cgrappletip.txt',
    'offsets-cgrenade.txt',
    'offsets-cguntarget.txt',
    'offsets-chassassin.txt',
    'offsets-cheadcrab.txt',
    'offsets-chfgrunt.txt',
    'offsets-chfgruntrepel.txt',
    'offsets-chgrunt.txt',
    'offsets-chgruntally.txt',
    'offsets-chgruntallyrepel.txt',
    'offsets-chgruntrepel.txt',
    'offsets-chgun.txt',
    'offsets-chornet.txt',
    'offsets-choundeye.txt',
    'offsets-chudicontrigger.txt',
    'offsets-cichthyosaur.txt',
    'offsets-cinfobm.txt',
    'offsets-cislave.txt',
    'offsets-citemctf.txt',
    'offsets-citemspawnctf.txt',
    'offsets-cknife.txt',
    'offsets-claser.txt',
    'offsets-cleech.txt',
    'offsets-clight.txt',
    'offsets-clightning.txt',
    'offsets-cm249.txt',
    'offsets-cmofassassin.txt',
    'offsets-cmofassassinrepel.txt',
    'offsets-cmomentarydoor.txt',
    'offsets-cmomentaryrotbutton.txt',
    'offsets-cmonstermaker.txt',
    'offsets-cmortar.txt',
    'offsets-cmortarshell.txt',
    'offsets-cmp5.txt',
    'offsets-cmultimanager.txt',
    'offsets-cmultisource.txt',
    'offsets-cnihilanth.txt',
    'offsets-cnihilanthhvr.txt',
    'offsets-cnodeent.txt',
    'offsets-cnodeviewer.txt',
    'offsets-cofallymonster.txt',
    'offsets-cofbabyvoltigore.txt',
    'offsets-cofblackopsapache.txt',
    'offsets-cofblackopsapachehvr.txt',
    'offsets-cofblackopsosprey.txt',
    'offsets-cofchargedbolt.txt',
    'offsets-coffunctank.txt',
    'offsets-coffunctankcontrols.txt',
    'offsets-coffunctanklaser.txt',
    'offsets-cofgeneworm.txt',
    'offsets-cofgenewormcloud.txt',
    'offsets-cofgenewormspawn.txt',
    'offsets-cofgonome.txt',
    'offsets-cofgonomeguts.txt',
    'offsets-cofinfopw.txt',
    'offsets-cofmedically.txt',
    'offsets-cofmedicallyrepel.txt',
    'offsets-cofnuclearbomb.txt',
    'offsets-cofnuclearbombtimer.txt',
    'offsets-cofpitworm.txt',
    'offsets-cofpitwormgibshooter.txt',
    'offsets-cofpitwormup.txt',
    'offsets-cofshockroach.txt',
    'offsets-cofskeleton.txt',
    'offsets-cofsquadtalkmonster.txt',
    'offsets-coftorchally.txt',
    'offsets-coftorchallyrepel.txt',
    'offsets-coftriggergenewormhit.txt',
    'offsets-cofvoltigore.txt',
    'offsets-cop4mortar.txt',
    'offsets-cop4mortarcontroller.txt',
    'offsets-cosprey.txt',
    'offsets-cotis.txt',
    'offsets-cpathcorner.txt',
    'offsets-cpathtrack.txt',
    'offsets-cpendulum.txt',
    'offsets-cpenguin.txt',
    'offsets-cpenguingrenade.txt',
    'offsets-cpipewrench.txt',
    'offsets-cpitdrone.txt',
    'offsets-cpitdronespike.txt',
    'offsets-cplattrigger.txt',
    'offsets-cpushable.txt',
    'offsets-cpython.txt',
    'offsets-crecharge.txt',
    'offsets-crecruit.txt',
    'offsets-crevertsaved.txt',
    'offsets-croach.txt',
    'offsets-crope.txt',
    'offsets-cropesample.txt',
    'offsets-cropesegment.txt',
    'offsets-crpg.txt',
    'offsets-crpgrocket.txt',
    'offsets-cruleentity.txt',
    'offsets-cscientist.txt',
    'offsets-cscriptedsentence.txt',
    'offsets-cshockbeam.txt',
    'offsets-cshockrifle.txt',
    'offsets-cshocktrooper.txt',
    'offsets-cshocktrooperrepel.txt',
    'offsets-cshotgun.txt',
    'offsets-csittingcleansuitscientist.txt',
    'offsets-csittingscientist.txt',
    'offsets-csniperrifle.txt',
    'offsets-csoundent.txt',
    'offsets-cspeaker.txt',
    'offsets-cspore.txt',
    'offsets-csporeammo.txt',
    'offsets-csporelauncher.txt',
    'offsets-csprite.txt',
    'offsets-cspritetrain.txt',
    'offsets-csquadmonster.txt',
    'offsets-csqueak.txt',
    'offsets-csqueakgrenade.txt',
    'offsets-csquidspit.txt',
    'offsets-ctalkmonster.txt',
    'offsets-ctentacle.txt',
    'offsets-ctesteffect.txt',
    'offsets-ctesthull.txt',
    'offsets-ctfdetect.txt',
    'offsets-ctfgoal.txt',
    'offsets-ctfgoalflag.txt',
    'offsets-ctfspawn.txt',
    'offsets-ctriggercamera.txt',
    'offsets-ctriggerchangetarget.txt',
    'offsets-ctriggerctfgeneric.txt',
    'offsets-ctriggerplayerfreeze.txt',
    'offsets-ctriggerrelay.txt',
    'offsets-ctripmine.txt',
    'offsets-ctripminegrenade.txt',
    'offsets-cturret.txt',
    'offsets-cwallhealth.txt',
    'offsets-cweaponbox.txt',
    'offsets-cweaponcycler.txt',
    'offsets-cworlditem.txt',
    'offsets-cwreckage.txt',
    'offsets-cxenplight.txt',
    'offsets-cxenspore.txt',
    'offsets-cxensporelarge.txt',
    'offsets-cxentree.txt',
    'offsets-czombie.txt',
    'offsets-czombiebarney.txt',
    'offsets-czombiesoldier.txt',
  ]
)

CopyFiles('gamedata/common.games/entities.games/valve', 'base/addons/amxmodx/data/gamedata/common.games/entities.games/valve',
  [
    'offsets-cactanimating.txt',
    'offsets-cagrunt.txt',
    'offsets-cairtank.txt',
    'offsets-cambientgeneric.txt',
    'offsets-capache.txt',
    'offsets-capachehvr.txt',
    'offsets-cautotrigger.txt',
    'offsets-cbarnacle.txt',
    'offsets-cbarney.txt',
    'offsets-cbaseanimating.txt',
    'offsets-cbasebutton.txt',
    'offsets-cbasedelay.txt',
    'offsets-cbasedoor.txt',
    'offsets-cbaseentity.txt',
    'offsets-cbasemonster.txt',
    'offsets-cbaseplattrain.txt',
    'offsets-cbaseplayer.txt',
    'offsets-cbaseplayeritem.txt',
    'offsets-cbaseplayerweapon.txt',
    'offsets-cbasetoggle.txt',
    'offsets-cbaseturret.txt',
    'offsets-cbigmomma.txt',
    'offsets-cbmortar.txt',
    'offsets-cbreakable.txt',
    'offsets-cbubbling.txt',
    'offsets-cbullsquid.txt',
    'offsets-cchangelevel.txt',
    'offsets-ccinemonster.txt',
    'offsets-ccontroller.txt',
    'offsets-ccontrollerheadball.txt',
    'offsets-ccontrollerzapball.txt',
    'offsets-ccrossbow.txt',
    'offsets-ccrossbowbolt.txt',
    'offsets-ccrowbar.txt',
    'offsets-ccycler.txt',
    'offsets-ccyclersprite.txt',
    'offsets-cdeadbarney.txt',
    'offsets-cdeadhev.txt',
    'offsets-cdeadhgrunt.txt',
    'offsets-cdeadscientist.txt',
    'offsets-cegon.txt',
    'offsets-cenvexplosion.txt',
    'offsets-cenvfunnel.txt',
    'offsets-cenvglobal.txt',
    'offsets-cenvsound.txt',
    'offsets-cenvspark.txt',
    'offsets-cflockingflyer.txt',
    'offsets-cflockingflyerflock.txt',
    'offsets-cflyingmonster.txt',
    'offsets-cfrictionmodifier.txt',
    'offsets-cfuncmortarfield.txt',
    'offsets-cfuncplatrot.txt',
    'offsets-cfuncrotating.txt',
    'offsets-cfunctank.txt',
    'offsets-cfunctankcontrols.txt',
    'offsets-cfunctanklaser.txt',
    'offsets-cfunctrackchange.txt',
    'offsets-cfunctracktrain.txt',
    'offsets-cfunctrain.txt',
    'offsets-cgameplayerequip.txt',
    'offsets-cgameplayerzone.txt',
    'offsets-cgameteammaster.txt',
    'offsets-cgametext.txt',
    'offsets-cgargantua.txt',
    'offsets-cgauss.txt',
    'offsets-cgib.txt',
    'offsets-cgibshooter.txt',
    'offsets-cglock.txt',
    'offsets-cglow.txt',
    'offsets-cgman.txt',
    'offsets-cgrenade.txt',
    'offsets-cguntarget.txt',
    'offsets-chassassin.txt',
    'offsets-chgrunt.txt',
    'offsets-chgruntrepel.txt',
    'offsets-chgun.txt',
    'offsets-chornet.txt',
    'offsets-choundeye.txt',
    'offsets-cichthyosaur.txt',
    'offsets-cinfobm.txt',
    'offsets-cislave.txt',
    'offsets-claser.txt',
    'offsets-cleech.txt',
    'offsets-clight.txt',
    'offsets-clightning.txt',
    'offsets-cmomentarydoor.txt',
    'offsets-cmomentaryrotbutton.txt',
    'offsets-cmonstermaker.txt',
    'offsets-cmortar.txt',
    'offsets-cmp5.txt',
    'offsets-cmultimanager.txt',
    'offsets-cmultisource.txt',
    'offsets-cnihilanth.txt',
    'offsets-cnihilanthhvr.txt',
    'offsets-cnodeent.txt',
    'offsets-cnodeviewer.txt',
    'offsets-cosprey.txt',
    'offsets-cpathcorner.txt',
    'offsets-cpathtrack.txt',
    'offsets-cpendulum.txt',
    'offsets-cplattrigger.txt',
    'offsets-cpushable.txt',
    'offsets-cpython.txt',
    'offsets-crecharge.txt',
    'offsets-crevertsaved.txt',
    'offsets-croach.txt',
    'offsets-crpg.txt',
    'offsets-crpgrocket.txt',
    'offsets-cruleentity.txt',
    'offsets-cscientist.txt',
    'offsets-cscriptedsentence.txt',
    'offsets-cshotgun.txt',
    'offsets-csittingscientist.txt',
    'offsets-csoundent.txt',
    'offsets-cspeaker.txt',
    'offsets-csprite.txt',
    'offsets-csquadmonster.txt',
    'offsets-csqueak.txt',
    'offsets-csqueakgrenade.txt',
    'offsets-csquidspit.txt',
    'offsets-ctalkmonster.txt',
    'offsets-ctentacle.txt',
    'offsets-ctesteffect.txt',
    'offsets-ctesthull.txt',
    'offsets-ctriggercamera.txt',
    'offsets-ctriggerchangetarget.txt',
    'offsets-ctriggerrelay.txt',
    'offsets-ctripmine.txt',
    'offsets-ctripminegrenade.txt',
    'offsets-cturret.txt',
    'offsets-cwallhealth.txt',
    'offsets-cweaponbox.txt',
    'offsets-cweaponcycler.txt',
    'offsets-cworlditem.txt',
    'offsets-cwreckage.txt',
    'offsets-cxenplight.txt',
    'offsets-cxentree.txt',
    'offsets-czombie.txt',
  ]
)

CopyFiles('gamedata/common.games/gamerules.games', 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games',
  [
    'master.games.txt',
  ]
)

CopyFiles('gamedata/common.games/gamerules.games/cstrike', 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/cstrike',
  [
    'offsets-cgamerules.txt',
    'offsets-chalflifemultiplay.txt',
    'offsets-chalflifetraining.txt',
  ]
)

CopyFiles('gamedata/common.games/gamerules.games/dod', 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/dod',
  [
    'offsets-cdodteamplay.txt',
    'offsets-cspdodrules.txt',
  ]
)

CopyFiles('gamedata/common.games/gamerules.games/gearbox', 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/gearbox',
  [
    'offsets-chalflifecoopplay.txt',
    'offsets-chalflifectfplay.txt',
    'offsets-chalflifemultiplay.txt',
    'offsets-chalflifeteamplay.txt',
  ]
)

CopyFiles('gamedata/common.games/gamerules.games/tfc', 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/tfc',
  [
    'offsets-chalflifemultiplay.txt',
    'offsets-chalflifeteamplay.txt',
    'offsets-cteamfortress.txt',
  ]
)

CopyFiles('gamedata/common.games/gamerules.games/valve', 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/valve',
  [
    'offsets-chalflifemultiplay.txt',
    'offsets-chalflifeteamplay.txt',
  ]
)

# Copy license files
licenses = [
  'ACKNOWLEDGEMENTS.txt',
  'GPLv2.txt',
  'GPLv3.txt',
  'LICENSE.txt',
]

for license in licenses:
  builder.AddCopy(
    source = os.path.join(builder.sourcePath, 'public', 'licenses', license),
    output_path = folder_map['base/addons/amxmodx']
  )