source: trunk/src/tiler.cpp @ 172

Last change on this file since 172 was 172, checked in by sam, 11 years ago

Move _strncasecmp define from forge.cpp/tiler.cpp to dict.cpp.

  • Property svn:keywords set to Id
File size: 1017 bytes
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#include "core.h"
11
12/*
13 * Tiler implementation class
14 */
15
16static class TilerData
17{
18    friend class Tiler;
19
20public:
21    Dict tilesets;
22}
23tilerdata;
24
25static TilerData * const data = &tilerdata;
26
27/*
28 * Public Tiler class
29 */
30
31int Tiler::Register(char const *path)
32{
33    int id = data->tilesets.MakeSlot(path);
34
35    if (!data->tilesets.GetEntity(id))
36    {
37        TileSet *tileset = new TileSet(path);
38        data->tilesets.SetEntity(id, tileset);
39    }
40
41    return id + 1; /* ID 0 is for the empty tileset */
42}
43
44void Tiler::Deregister(int id)
45{
46    data->tilesets.RemoveSlot(id - 1); /* ID 0 is for the empty tileset */
47}
48
49void Tiler::BlitTile(uint32_t code, int x, int y, int z, int o)
50{
51    int id = (code >> 16) - 1; /* ID 0 is for the empty tileset */
52
53    TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id);
54    tileset->BlitTile(code & 0xffff, x, y, z, o);
55}
56
Note: See TracBrowser for help on using the repository browser.