# Path: omnitool/database.py
# def get_custom_db(txt):
# def parse():


from struct import unpack, pack, Struct
from .database import items, rev_items, multitiles
import sys


for name, form, l in formats:
    s = Struct(form)

    def make_local(s, l):
        def generic(f):
            return s.unpack(f.read(l))[0]

        return generic

    globals()["get_g%s" % name] = make_local(s, l)

### Parser end ###


### content parser for .wld structures ###

def get_item(f):
    amount = get_gbyte(f)
    if amount:
        return amount, items[get_int(f)], get_gbyte(f)
    else:
        return 0, None


def set_items(f, items):
    for item in items:
        f.write(set_byte(item[0]))  #amount
        if item[0]:

# Path: omnitool/database.py
# def get_custom_db(txt):
# def parse():


# Path: omnitool/tlib.py
from struct import unpack, pack, Struct
from .database import items, rev_items, multitiles
import sys



for name, form, l in formats:
    s = Struct(form)

    def make_local(s, l):
        def generic(f):
            return s.unpack(f.read(l))[0]

        return generic

    globals()["get_g%s" % name] = make_local(s, l)

### Parser end ###


### content parser for .wld structures ###

def get_item(f):
    amount = get_gbyte(f)
    if amount:
        return amount, items[get_int(f)], get_gbyte(f)
    else:
        return 0, None


def set_items(f, items):
    for item in items:
        f.write(set_byte(item[0]))  #amount
        if item[0]:

            f.write(set_int(rev_items[item[1]]))  #itemid