OSDN Git Service

Nazghul-0.7.1
[nazghul-jp/nazghul-jp.git] / src / terrain_map.h
1 //
2 // nazghul - an old-school RPG engine
3 // Copyright (C) 2002, 2003 Gordon McNutt
4 //
5 // This program is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by the Free
7 // Software Foundation; either version 2 of the License, or (at your option)
8 // any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13 // more details.
14 //
15 // You should have received a copy of the GNU General Public License along with
16 // this program; if not, write to the Free Foundation, Inc., 59 Temple Place,
17 // Suite 330, Boston, MA 02111-1307 USA
18 //
19 // Gordon McNutt
20 // gmcnutt@users.sourceforge.net
21 //
22 #ifndef terrain_map_h
23 #define terrain_map_h
24
25 #include "macros.h"
26
27 BEGIN_DECL
28
29 #include <stdio.h>
30
31 #include "list.h"
32
33 extern char *TERRAIN_MAP_MAGIC;
34
35 struct terrain_map {
36         char *tag;
37         int w;
38         int h;
39         struct terrain_palette * palette;
40         struct terrain **terrain;
41
42         void *handle;  /* pointer to session handle */
43         int saved;     /* 1 iff already saved       */
44         int refcount;
45
46         /* added to support composite maps */
47         int submap_w;        /* submap width      */
48         int submap_h;        /* submap height     */
49         char composite : 1;  /* save as composite */
50 };
51
52 extern struct terrain_map *terrain_map_new(const char *tag, 
53                                            unsigned int w, 
54                                            unsigned int h,
55                                            struct terrain_palette * pal);
56 #define terrain_map_ref(map) ((map)->refcount++)
57 extern void terrain_map_unref(struct terrain_map *map);
58 extern struct terrain_map *terrain_map_clone(struct terrain_map *orig, 
59                                              const char *tag);
60 extern void terrain_map_rotate(struct terrain_map *map, int degree);
61 extern void terrain_map_blit(struct terrain_map *dest, int dest_x,
62                              int dest_y, struct terrain_map *src,
63                              int src_x, int src_y, int w, int h);
64 extern void terrain_map_fill(struct terrain_map *map, int x, int y, int w, int h, struct terrain *fill);
65 extern void terrain_map_print(FILE * fp, int indent,
66                               struct terrain_map *map);
67 extern void print_horizontal_guideline (FILE * fp, int indent, 
68                                         struct terrain_map *map);
69
70 extern void terrain_map_save(struct save *, void *val);
71 extern void terrain_map_blend(struct terrain_map *map, 
72                               struct terrain *inf,
73                               int n_nonsup,
74                               struct terrain **nonsup,
75                               struct terrain *range[16]);
76
77
78 static inline void terrain_map_set_terrain(struct terrain_map *map, int x, int y, struct terrain *val)
79 {
80     map->terrain[y * map->w + x] = val;
81
82 }
83
84 static inline struct terrain *terrain_map_get_terrain(struct terrain_map *map, int x, int y)
85 {
86     return map->terrain[y * map->w + x];
87 }
88
89
90 END_DECL
91
92 #endif