31 #define _CRT_SECURE_NO_DEPRECATE 39 #define HB_MAGIC_COLOR 999 40 #define HB_MAGIC_PAINTER_BIT 0x40000000 80 double l_inc = 50.0/((double)
hb_hedges.size());
81 double l_count = 0.001;
83 for (
unsigned int i=0; i<
hb_hedges.size(); i++ ) {
85 if ( l_count > 1.0 ) {
122 while ( l_color > l_min ) {
141 for (
int j=0; j<
hb_size; j++ ) {
143 printf(
"Oh dear!\n");
149 sprintf( ffname,
"test%02d.ppm", i);
156 hb_dump_map( 0,
hb_width, 0, hb_height, ffname,
false );
163 for (
unsigned int i=0; i<
m_elems.size(); i++ ) {
164 if (
m_elems[i]->GetArea() < 0.9 &&
168 printf(
"Warning: Polygon %6d of type %s came up with area %3.2f!\n",
206 if ( l_val >= 0 && l_val <
HB_MAGIC ) {
228 static LE* l_curr_ele = NULL;
251 bool l_found =
false;
255 for (
int l_y=0; l_y<
hb_height; l_y++ ) {
256 for (
int l_x=0; l_x<
hb_width; l_x++ ) {
257 if (
hb_map[ l_y*hb_width + l_x ] == a_poly_num ) {
278 for (
unsigned int i=0; i<
m_elems.size(); i++ ) {
291 for (
int i=0; i<
hb_size; i++ ) {
303 if (
hb_map[l_coord] < 0 )
316 if (
hb_map[l_coord] < 0 ) {
317 hb_map[l_coord] = a_orig_poly_number;
341 bool l_has_neighbour =
false;
351 l_has_neighbour =
true;
358 l_has_neighbour =
true;
365 l_has_neighbour =
true;
373 l_has_neighbour =
true;
380 l_has_neighbour =
true;
389 l_has_neighbour =
true;
396 l_has_neighbour =
true;
403 l_has_neighbour =
true;
408 return l_has_neighbour;
420 if (
hb_map[ l_coord ] == a_poly_num ) {
440 hb_map[ l_coord ] = a_color;
453 int a_neighbour_color )
455 bool l_neighbour_has_color =
false;
461 if ( a_x >= 0 && a_y >= 0 &&
463 l_neighbour_has_color =
true;
469 l_neighbour_has_color =
true;
476 l_neighbour_has_color =
true;
484 l_neighbour_has_color =
true;
491 l_neighbour_has_color =
true;
503 l_neighbour_has_color =
true;
509 l_neighbour_has_color =
true;
516 l_neighbour_has_color =
true;
521 return l_neighbour_has_color;
532 bool l_at_least_one =
false;
538 l_at_least_one =
true;
543 return l_at_least_one;
558 if ( a_x >= 0 && a_y >= 0 ) {
574 if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
583 if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
591 if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
604 if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
611 if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
618 if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
632 double l_up = 10000.0 - l_hb;
634 double l_length = (double)(random( (
int)l_hb )) * 0.0001 *
636 double l_hb_remain = 0.0;
637 double l_up_remain = 0.0;
648 if ( l_length >= 1.0 ) {
660 l_hb_remain = l_length;
661 l_length = (double)(random( (
int)l_up )) * 0.0001 *
665 l_up_remain = l_length;
666 l_length = (double)(random( (
int)l_hb )) * 0.0001 *
695 if (
hb_map[ l_coord ] == a_color ) {
699 hb_map[ l_coord ] = l_max;
706 hb_map[ l_coord ] = -a_color;
717 for (
int i=0; i<
hb_size; i++ ) {
727 #define SV_UINT32 unsigned int 729 #define SV_UINT8 unsigned char 733 const unsigned int hb_dump_colors [
tole_Foobar] = {
772 void Landscape::hb_dump_map(
int a_beginx,
int a_width,
773 int a_beginy,
int a_height,
775 bool a_high_numbers )
780 if ( linebuffer == NULL ) {
781 printf(
"hb_dump_color_map(): Out of memory!\n",
786 FILE* l_file = fopen( a_filename,
"w" );
788 printf(
"hb_dump_color_map(): Unable to open file for writing: %s\n",
793 fprintf( l_file,
"P6\n%d %d %d\n",
798 for (
int line=a_beginy; line< a_beginy + a_height; line++ ) {
800 for (
int column=a_beginx; column < a_beginx + a_width; column++ ) {
801 int localcolor = hb_dump_color( column, line, a_high_numbers );
802 linebuffer [ i++ ] = localcolor & 0xff;
803 linebuffer [ i++ ] = (localcolor >> 8) & 0xff;
804 linebuffer [ i++ ] = (localcolor >> 16) & 0xff;
806 fwrite( linebuffer,
sizeof(
SV_UINT8), linesize, l_file );
814 inline int Landscape::hb_dump_color(
int a_x,
int a_y,
815 bool a_high_numbers )
827 [l_map_val]]->GetElementType() ];
830 return 0x00ffffff - 32*l_map_val;
#define HB_MAGIC_PAINTER_BIT
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
int GetPoly(void)
Returns the polyref number for this polygon.
std::string PolytypeToString(TTypesOfLandscapeElement a_le_type)
bool hb_HasOtherNeighbour(int a_x, int a_y)
vector< LE * > hb_new_hbs
void hb_MarkTopFromLocalMax(int a_color)
Integer configurator entry class.
bool hb_FindBoundingBox(int a_poly_num)
static CfgInt l_map_art_hb_tran_prob("MAP_ART_HB_TRAN_PROB", CFG_CUSTOM, 30)
static CfgInt l_map_art_hb_nums("MAP_ART_HB_NUMS", CFG_CUSTOM, 3)
void hb_DownPolyNumbers(void)
int hb_MaxUnpaintedNegNeighbour(int a_x, int a_y)
void hb_MarkTheBresenhamWay(void)
int * GetMagicP(int a_x, int a_y)
bool hb_HasNeighbourColor(int a_x, int a_y, int a_neighbour_color)
void hb_RestoreHedgeCore(int a_orig_poly_number)
int hb_first_free_poly_num
RasterMap * m_land
The big map.
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
void hb_ClearPolygon(int a_poly_num)
bool hb_PaintWhoHasNeighbourColor(int a_neighbour_color, int a_new_color)
void hb_GenerateHBPolys(void)
int hb_StripingDist(void)
void hb_UpPolyNumbers(void)
Double configurator entry class.
bool hb_MapBorder(int a_x, int a_y)
void hb_PaintBorder(int a_color)
void hb_ResetColorBits(void)
static CfgFloat l_map_art_hb_width("MAP_ART_HB_WIDTH", CFG_CUSTOM, 0.3)
static CfgFloat l_map_art_hb_core_thres("MAP_ART_HB_STRIPE_THRES", CFG_CUSTOM, 0.4)
static CfgFloat l_map_art_hb_seg_len("MAP_ART_HB_SEG_LEN", CFG_CUSTOM, 100.0)
LE * NewElement(TTypesOfLandscapeElement a_type)
void hb_AddNewHedgebanks(int a_orig_poly_num)