34 static GQuark mape_mapgen_error_quark()
36 return g_quark_from_static_string(
"MAPE_MAPGEN_ERROR");
39 static void mape_mapgen_read_color(guint8* dest,
44 const gchar* texture_name;
45 const gchar* material_name;
46 const gchar* first_tex_separator;
48 gchar* own_texture_name;
54 dest[matnum * 4 + 1] = 100;
55 dest[matnum * 4 + 2] = 100;
56 dest[matnum * 4 + 3] = 255;
65 own_texture_name = NULL;
66 if(texture_name != NULL)
71 first_tex_separator = strchr(texture_name,
'-');
72 if(first_tex_separator != NULL)
74 own_texture_name = g_strndup(
76 first_tex_separator - texture_name
79 texture_name = own_texture_name;
103 dest[matnum * 4 + 1] = 100;
104 dest[matnum * 4 + 2] = 100;
105 dest[matnum * 4 + 3] = 255;
115 if(texture_name != NULL)
122 dest[matnum * 4 + 1] = (color ) & 0xff;
123 dest[matnum * 4 + 2] = (color >> 8) & 0xff;
124 dest[matnum * 4 + 3] = (color >> 16) & 0xff;
127 g_free(own_texture_name);
190 fprintf(stderr,
"Failed to load Objects.ocd/Libraries.ocd/Map.ocd/Script.c: %s\n", error->message);
230 const gchar* script_path,
238 const char* error_message;
239 unsigned int out_width;
240 unsigned int out_height;
243 const unsigned char* in_p;
245 unsigned int in_rowstride;
247 guint8 matclrs[256 * 4];
278 g_assert_not_reached();
287 mape_mapgen_error_quark(),
300 pixbuf = gdk_pixbuf_new(
312 mape_mapgen_error_quark(),
314 "Insufficient memory is available"
321 out_p = gdk_pixbuf_get_pixels(pixbuf);
323 out_rowstride = gdk_pixbuf_get_rowstride(pixbuf);
325 datawidth = gdk_pixbuf_get_width(pixbuf) * 3;
326 memset(matclrs, 0,
sizeof(matclrs) );
328 for(y = 0; y < out_height; ++y)
330 for(x = 0; x < out_width; ++x)
334 if(matclrs[matnum * 4] == 0)
336 mape_mapgen_read_color(
344 matclrs[matnum * 4] = 1;
347 out_p[0] = matclrs[matnum * 4 + 1];
348 out_p[1] = matclrs[matnum * 4 + 2];
349 out_p[2] = matclrs[matnum * 4 + 3];
354 in_p += in_rowstride - out_width;
355 out_p += out_rowstride - datawidth;
typedefG_BEGIN_DECLS struct _C4GroupHandle C4GroupHandle
MapeGroup * mape_group_open_child(MapeGroup *group, const gchar *entry, GError **error)
typedefG_BEGIN_DECLS struct _C4MapgenHandle C4MapgenHandle
unsigned int c4_mapgen_handle_get_height(C4MapgenHandle *mapgen)
void c4_mapgen_handle_init_script_engine()
const char * c4_mapgen_handle_get_error(C4MapgenHandle *mapgen)
const unsigned char * c4_mapgen_handle_get_map(C4MapgenHandle *mapgen)
void c4_mapgen_handle_deinit_script_engine()
C4MapgenHandle * c4_mapgen_handle_new_script(const char *filename, const char *source, C4MaterialMapHandle *material_map, C4TextureMapHandle *texture_map, unsigned int map_width, unsigned int map_height)
unsigned int c4_mapgen_handle_get_width(C4MapgenHandle *mapgen)
void c4_mapgen_handle_free(C4MapgenHandle *mapgen)
C4MapgenHandle * c4_mapgen_handle_new(const char *filename, const char *source, const char *script_path, C4MaterialMapHandle *material_map, C4TextureMapHandle *texture_map, unsigned int map_width, unsigned int map_height)
void c4_mapgen_handle_set_map_library(C4GroupHandle *group_handle)
unsigned int c4_mapgen_handle_get_rowstride(C4MapgenHandle *mapgen)
C4TextureMapHandle * _mape_texture_map_get_handle(MapeTextureMap *map)
void mape_mapgen_deinit()
C4GroupHandle * _mape_group_get_handle(MapeGroup *group)
GdkPixbuf * mape_mapgen_render(const gchar *filename, const gchar *source, MapeMapgenType type, const gchar *script_path, MapeMaterialMap *material_map, MapeTextureMap *texture_map, guint width, guint height, GError **error)
gboolean mape_mapgen_init(GError **error)
void mape_mapgen_set_root_group(MapeGroup *group)
C4MaterialMapHandle * _mape_material_map_get_handle(MapeMaterialMap *map)
enum _MapeMapgenType MapeMapgenType
@ MAPE_MAPGEN_ERROR_COMPILE
@ MAPE_MAPGEN_ERROR_MEMORY
@ MAPE_MAPGEN_LANDSCAPE_TXT
struct _C4MaterialMapHandle C4MaterialMapHandle
const gchar * mape_material_get_texture_overlay(const MapeMaterial *material)
MapeMaterial * mape_material_map_get_material_by_name(MapeMaterialMap *map, const gchar *name)
struct _MapeMaterial MapeMaterial
typedefG_BEGIN_DECLS struct _C4TextureMapHandle C4TextureMapHandle
const gchar * mape_texture_map_get_texture_name_from_mapping(MapeTextureMap *texture_map, guint index)
const gchar * mape_texture_map_get_material_name_from_mapping(MapeTextureMap *texture_map, guint index)
GdkPixbuf * mape_texture_map_lookup_texture(MapeTextureMap *texture_map, const gchar *name)
guint32 mape_texture_map_get_average_texture_color(MapeTextureMap *texture_map, const gchar *name)