public void drawmap(GOut g) {
        int x, y, i;
        int stw, sth;
        Coord oc, tc, ctc, sc;

        if (Config.profile)
            curf = prof.new Frame();
        //Kerri
        Coord mouseTilePos = Coord.z;
        if (mousepos != null && Config.assign_to_tile)
            mouseTilePos = mouseAtTile.div(tileSize);
        stw = (tileSize.x * 4) - 2;
        sth = tileSize.y * 2;
        oc = viewoffset(sz, mc);
        tc = mc.div(tileSize);
        tc.x += -(sz.x / (2 * stw)) - (sz.y / (2 * sth)) - 2;
        tc.y += (sz.x / (2 * stw)) - (sz.y / (2 * sth));
        for (y = 0; y < (sz.y / sth) + 2; y++) {
            for (x = 0; x < (sz.x / stw) + 3; x++) {
                for (i = 0; i < 2; i++) {
                    ctc = tc.add(new Coord(x + y, -x + y + i));
                    sc = m2s(ctc.mul(tileSize)).add(oc);
                    sc.x -= tileSize.x * 2;
                    drawtile(g, ctc, sc);
                    sc.x += tileSize.x * 2;
                    if (!Config.newclaim) {
                        drawol(g, ctc, sc);
                    }
                    if (mousepos != null && Config.assign_to_tile)
                        if (mouseTilePos.y == ctc.y && mouseTilePos.x == ctc.x)
                            drawTileSelection(g, ctc, sc);
                }
            }
        }//for
        //Kerri for JSRect
        if (JSBotUtils.rectOffset != null && JSBotUtils.rectSize != null) {
            if (JSBotUtils.rectSize.x > 0 && JSBotUtils.rectSize.y > 0) {
                for (y = 0; y < (sz.y / sth) + 2; y++) {
                    for (x = 0; x < (sz.x / stw) + 3; x++) {
                        for (i = 0; i < 2; i++) {
                            ctc = tc.add(new Coord(x + y, -x + y + i));
                            sc = m2s(ctc.mul(tileSize)).add(oc);
                            sc.x -= tileSize.x * 2;
                            sc.x += tileSize.x * 2;
                            if (JSBotUtils.MyCoord().div(tileSize).add(JSBotUtils.rectOffset).x == ctc.x &&
                                    JSBotUtils.MyCoord().div(tileSize).add(JSBotUtils.rectOffset).y == ctc.y)
                                drawJSRect(g, sc, JSBotUtils.rectSize);
                        }
                    }
                }
            }
        }//for
		
		/* PF Draw Map */
        if (draw_pf_map) {
            int[][] map = APXUtils.PF_Map();
            int dim = APXUtils.PF_Dim();
            Coord qcoord;
            for (int vx = 0; vx < dim; vx++) {
                for (int vy = 0; vy < dim; vy++) {
                    int type = map[vx][vy];
                    Color qcolor = type == APXUtils.PF_MAP_CELL_FREE ? Color.green : Color.red;
                    qcoord = APXUtils._pf_map2real_stored(new Coord(vx, vy));
                    drawQuad(g, m2s(qcoord.sub(MCache.tileSize.div(2))).add(oc), qcolor);
                }
            }
        }

        if (Config.newclaim) {
            drawols(g, oc);
        }
        if (Config.grid) {
            g.chcolor(new Color(40, 40, 40));
            Coord c1, c2, d;
            d = tc.mul(tileSize);
            int hy = (sz.y / sth) * tileSize.y;
            int hx = (sz.x / stw) * tileSize.x;
            c1 = d.add(0, 0);
            c2 = d.add(5 * hx / 2, 0);
            for (y = d.y - hy; y < d.y + hy; y = y + tileSize.y) {
                c1.y = y;
                c2.y = c1.y;
                g.line(m2s(c1).add(oc), m2s(c2).add(oc), 1);
            }
            c1 = d.add(0, -hy);
            c2 = d.add(0, hy);

            for (x = d.x; x < d.x + 5 * hx / 2; x = x + tileSize.x) {
                c1.x = x;
                c2.x = c1.x;
                g.line(m2s(c1).add(oc), m2s(c2).add(oc), 1);
            }
            g.chcolor();
        }
        if (curf != null)
            curf.tick("map");

        if (Config.showRadius)
            drawObjectRadius(g);
        else
            drawPlaceObjectEffect(g);

        if (Config.showBeast) {
            drawBeastRadius(g);
        }
        drawCuriosities(g);
        drawtracking(g);

        if (curf != null)
            curf.tick("plobeff");

        final List<Sprite.Part> sprites = new ArrayList<Sprite.Part>();
        ArrayList<Speaking> speaking = new ArrayList<Speaking>();
        ArrayList<KinInfo> kin = new ArrayList<KinInfo>();
        class GobMapper implements Sprite.Drawer {
            Gob cur = null;
            Sprite.Part.Effect fx = null;
            int szo = 0;

            public void chcur(Gob cur) {
                this.cur = cur;
                GobHealth hlt = cur.getattr(GobHealth.class);
                fx = null;
                if (hlt != null)
                    fx = hlt.getfx();
                if (cur.highlight != null) {
                    long t = System.currentTimeMillis() - cur.highlight.time;
                    if (t > 5000) {
                        cur.highlight = null;
                    }
                }
                if (cur.highlight != null) {
                    fx = cur.highlight;
                }
                Following flw = cur.getattr(Following.class);
                szo = 0;
                if (flw != null)
                    szo = flw.szo;
            }

            public void addpart(Sprite.Part p) {
                p.effect = fx;
                if ((p.ul.x >= sz.x) || (p.ul.y >= sz.y) || (p.lr.x < 0)
                        || (p.lr.y < 0))
                    return;
                sprites.add(p);
                p.owner = cur;
                p.szo = szo;
            }
        }

        //Kerri
        if (KerriUtils.iObj.size() > 0) {
            g.chcolor(20, 20, 250, 108);
            synchronized (glob.oc) {
                for (Gob gob : glob.oc) {
                    if (KerriUtils.iObj.contains(Integer.valueOf(gob.id))) {
                        Resource.Neg neg = gob.getneg();
                        if (neg == null) {
                            continue;
                        }
                        if ((neg.bs.x > 0) && (neg.bs.y > 0)) {
                            Coord c1 = gob.position().add(neg.bc);
                            Coord c2 = c1.add(neg.bs);
                            g.frect(m2s(c1).add(oc), m2s(new Coord(c2.x, c1.y))
                                    .add(oc), m2s(c2).add(oc),
                                    m2s(new Coord(c1.x, c2.y)).add(oc));
                        }
                    }
                }
            }
            g.chcolor();
        }

        if (ui.modctrl) {
            g.chcolor(20, 20, 250, 108);
            synchronized (glob.oc) {
                for (Gob gob : glob.oc) {
                    if (gob.id == 0) {
                        Resource.Neg neg = gob.getneg();
                        if (neg == null) {
                            continue;
                        }
                        if ((neg.bs.x > 0) && (neg.bs.y > 0)) {
                            Coord c1 = gob.position().add(neg.bc);
                            Coord c2 = c1.add(neg.bs);
                            g.frect(m2s(c1).add(oc), m2s(new Coord(c2.x, c1.y))
                                    .add(oc), m2s(c2).add(oc),
                                    m2s(new Coord(c1.x, c2.y)).add(oc));
                        }
                        break;
                    }
                }
            }
            g.chcolor();
        }

        if (Config.showHidden && Config.hide) {
            if (!Config.aimacrazyman)
                g.chcolor(Config.hideColor);
            synchronized (glob.oc) {
                for (Gob gob : glob.oc) {
                    if (Config.aimacrazyman) {
                        Random r = new Random();
                        g.chcolor(r.nextInt(255), r.nextInt(255), r.nextInt(255), r.nextInt(255));
                    }
                    Resource res = gob.getres();
                    if (!Config.hide_all) {
                        if (!gob.hide || ((res != null) && (res.skiphighlight)))
                            continue;
                    }
                    if (res.name != null && res.name.contains("gfx/arch/sign")) {
                        Coord c1 = gob.position();
                        Coord c2 = c1.add(new Coord(2, 2));
                        g.frect(m2s(c1).add(oc), m2s(new Coord(c2.x, c1.y))
                                .add(oc), m2s(c2).add(oc),
                                m2s(new Coord(c1.x, c2.y)).add(oc));
                    }
                    Resource.Neg neg = gob.getneg();
                    if (neg == null) {
                        continue;
                    }
                    if ((neg.bs.x > 0) && (neg.bs.y > 0)) {
                        Coord c1 = gob.position().add(neg.bc);
                        Coord c2 = c1.add(neg.bs);
                        g.frect(m2s(c1).add(oc), m2s(new Coord(c2.x, c1.y))
                                .add(oc), m2s(c2).add(oc),
                                m2s(new Coord(c1.x, c2.y)).add(oc));
                    }
                }
            }
            g.chcolor();
        }

        GobMapper drawer = new GobMapper();
        synchronized (glob.oc) {
            for (Gob gob : glob.oc) {
                Integer tmp /*lol*/ = Integer.valueOf(gob.id);
                if (ui.modctrl && gob.id == 0) continue;
                if (KerriUtils.iObj.contains(tmp)) continue;
                Resource res = gob.getres();
                if (res != null) {
                    if (res.name.contains("gfx/terobjs/clue")) {
                        //scent checker
                        LinkedList<Gob.Overlay> olays = (LinkedList<haven.Gob.Overlay>) gob.ols;
                        int scent = olays.get(0).sdt.uint16K();
                        if (KerriUtils.isAssault(scent) && Config.hideAsslt) continue;
                        if (KerriUtils.isTheft(scent) && Config.hideTheft) continue;
                        if (KerriUtils.isTresspass(scent) && Config.hideTressp) continue;
                        if (KerriUtils.isVandalism(scent) && Config.hideVand) continue;
                        if (KerriUtils.isBattery(scent) && Config.hideBatt) continue;
                        if (KerriUtils.isMurder(scent) && Config.hideMurd) continue;
                        //System.out.println(scent);
                    }
                }
                drawer.chcur(gob);
                Coord dc = m2s(gob.position()).add(oc);
                gob.sc = dc;
                gob.drawsetup(drawer, dc, sz);
                Speaking s = gob.getattr(Speaking.class);
                if (s != null)
                    speaking.add(s);
                KinInfo k = gob.getattr(KinInfo.class);
                if (k != null)
                    kin.add(k);
            }
            if (curf != null)
                curf.tick("setup");
            Collections.sort(sprites, Sprite.partidcmp);
            {
                Sprite.Part[] clickable = new Sprite.Part[sprites.size()];
                for (int o = 0, u = clickable.length - 1; o < clickable.length; o++, u--)
                    clickable[u] = sprites.get(o);
                this.clickable = clickable;
            }
            if (curf != null)
                curf.tick("sort");
            //Kerri
            if (pmousepos != null)
                objectUnderMouse = gobatpos(pmousepos);
            else
                objectUnderMouse = null;
            obscured = findobsc();
            if (curf != null)
                curf.tick("obsc");
            for (Sprite.Part part : sprites) {
                if (part.effect != null)
                    part.draw(part.effect.apply(g));
                else
                    part.draw(g);
            }
            for (Sprite.Part part : obscured) {
                GOut g2 = new GOut(g);
                GobHealth hlt;
                if ((part.owner != null)
                        && (part.owner instanceof Gob)
                        && ((hlt = ((Gob) part.owner).getattr(GobHealth.class)) != null))
                    g2.chcolor(255, (int) (hlt.asfloat() * 255), 0, 255);
                else
                    g2.chcolor(255, 255, 0, 255);
                part.drawol(g2);
            }

            if (curf != null)
                curf.tick("draw");
            g.image(mask, Coord.z);
            long now = System.currentTimeMillis();
            RootWidget.names_ready = (RootWidget.screenshot && Config.sshot_nonames);
            if (!RootWidget.names_ready) {
                for (KinInfo k : kin) {
                    Tex t = k.rendered();
                    Coord gc = k.gob.sc;
                    String name = k.gob.resname();
                    boolean isother = name.contains("hearth")
                            || name.contains("skeleton");
                    if (gc.isect(Coord.z, sz)) {
                        if (k.seen == 0)
                            k.seen = now;
                        int tm = (int) (now - k.seen);
                        Color show = null;
                        boolean auto = (k.type & 1) == 0;
                        if ((isother && Config.showOtherNames)
                                || (!isother && Config.showNames)
                                || (k.gob == objectUnderMouse)) {
                            show = Color.WHITE;
                        } else if (auto && (tm < 7500)) {
                            show = Utils.clipcol(255, 255, 255,
                                    255 - ((255 * tm) / 7500));
                        }
                        if (show != null) {
                            g.chcolor(show);
                            g.image(t, gc.add(-t.sz().x / 2, -40 - t.sz().y));
                            g.chcolor();
                        }
                    } else {
                        k.seen = 0;
                    }
                }
            }
            for (Speaking s : speaking) {
                s.draw(g, s.gob.sc.add(s.off));
            }
            if (curf != null) {
                curf.tick("aux");
                curf.fin();
                curf = null;
            }
            if (Config.show_gob_health) {
                for (Gob gob : glob.oc) {
                    GobHealth hlt = gob.getattr(GobHealth.class);
                    if (hlt != null) {
                        int percent = (int) (hlt.asfloat() * 100);
                        if (percent < 100) {
                            g.atext(Integer.toString(percent) + "%", gob.sc, 0,
                                    1);
                        }
                    }
                }
            }
        }
    }