29.07 - Header, Functions & Global Variables

---------------
WAYNE'S WORLD GENERATOR VERSION 29.07 - "THE ATLAS OF HABITABLE WORLDS"
// (c) Wayne Eddy, 59 Cunnington Street, Bundaberg East, Queensland, Australia.
// last updated, 5 September 2008
//---------------

// GENERAL NOTES

// Method
// 1. Grow Catchments over Priority Strings.
// 2. Generate elevations approximately 40km apart
// 3. Zoom using areas of influence with 40km side length
// 4. flow points can be special, specific or ordinary
// 5. use the priority array to store info on flow point terrain type
// 6. special flow points will be given a terrain type in the range (1-999) which will reference an array that can point to multiple megafeatures - a major confluence for example needs to point to two rivers.

// Definitions
// Flow Point - any one of the ~333800 points on the surface of the sphere
// Ring - a ring of equally spaced flow points at a given latitude
// Area of Influence (AOI) - a (usually hexagonal) area around a flow point
// Mega Feature - a feature such as a desert or a lake spread over multiple areas of influence.

// Books
// 1. Atlas of Habitable Worlds
// 2. Catalog of Known Lifeforms
// 3. Book of Deeds

// This Program relies on the following files to operate:
// cp3240mt.dll
// vcl35.bpl
// borlndmm.dll
// Don't think I need the above dll's since I changed to Turbo C++ for vers 29
// animal_names.dic
// names1.dic

// 513 rings

// TO DO LIST

/*
1. Filler Triangle Function
2. Fix gaps on westerm side of view when zoomed way in
3. Break coastal influence areas into two polygons
4. Plot Megafeatures. (Lakes, Rivers & Sea Ice & Glaciers)
Plot Hemispheres
Delete old code
Pick best view point by testing hits in 8 vertical lines.
Group Seeds
Number seas while elevation<0
Number catchments as soon as elevation>0
Plug (single pixel) holes near coast in reversed model - or widen or bulldoze path to Ocean.
Increase no of possible worlds above 5500000
Ice Caps
Short cut to the sea later if a river passes near the coast.
Elevation profile.
Randomise length of ammend check.
Give strings a width // plot strings
*/

---------------
HEADER FILES
//---------------

#include <vcl.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#include <fstream.h>
#include <condefs.h>
#include <dir.h>
#pragma hdrstop
#include "Xenosphere1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"

---------------
GLOBAL VARIABLES
//---------------

// VERSION 29 GLOBAL VARIABLES
double Scale;
double Xx, Yy;
double XXx, YYy;
double Qx, Qy;
double Global_Peakosity;
int influences[5];
int Lp[60][2];
int Inlets;
int Lo[60][2]; // Outlets
int Outlets;
int COUNTER; // diagnostic tool
double Vertexes[101][2];
double glob_elev[240]; // ww -> zz
int Vorder[8];
int InOut[6];

// VERSION 28 GLOBAL VARIABLES
double hickle[42][42]; // probably delete
double line_forty_elev[41]; // probably delete
int spot_tt[41][41]; // probably delete
int ttc[81][81]; // catchment
double ttp[81][81]; // terrain type ???
double tte[81][81]; // elevation
double ttz[81][81]; // flow direction
int Errr;
double hxc, hyc, he, lxc, lyc, le, xc, yc; // for function 73
double VC[3][2];
double VE[6];
double RE[10];
double FE[3]; // final elevation
int Stage;
double pop_ttz_seed;

// VERSION 27 GLOBAL VARIABLES
int catchment_no[333810];
int dfs[333810]; // distance from sea
int priority[333810];
double tse[333810]; //point elevation
int gtt[333810]; // global terrain type - TRY TO REUSE PRIORITY
int points[515];
int cum_points[515];
double ring_lat[515];
int ts_sosyedi[6];
int ts_sostype[6];
int ts_n_sosyedi;
int ts_nseeds;
int ts_nseas;
int ts_seedno[10000];
int ts_seano[40];
int tsl, ts_land, ts_mount; (0 = world ocean, 333800 = world desert)
int ts_high;
int ts_low;
int ts_sea;
int hi;
int stack[333800];
int stackpos;
int next_catch_num;
int catch_size[57000];
int catch_type[57000]; // 3 = inland sea/lake
int centroid_catch[57000];
int catch_max_dfs[57000];
double catch_max_elev[57000];
double max_max_elev;
int amount_land2;
int sea_level;
int plot_mode=1;
double elevation_profile[9];
int method; // 0 - old two step process; 1 - new one step process
int n_low_points=0;
double push;
double max_flatten; // delete me
int l_sea_string[40];
int number_of_islands;
int size_island[1001];
int y_centroid[1001], x_centroid[1001];
double gravity;
int n_moons;
double size_moon[10];
int n_continents;
int sp_major_river[40000]; // biggest seen = 36,000
int n_major_rivers, sp_major_rivers;
double snow_line;
double snowline[2];
double globfx, globfy;
double glob_dub;
int glob_x[2201], glob_y[2201];
int glob_int;
double direction_range;
int max_chain_length;
int nplates;
int plates[3][57];
int nmountains;
int init_modp;
double insert_frac;
double how_internal;
double percent_lakes;
int lfs;
double conch;
int approx_sl_priority;
double sq_e[130][130];
int sq_f[130][130];
int sq_g[130][130];
int sq_h[130][130];
double line_e[129];
int line_f[129];
int lmountains;
int spm;
double Rloc[4];
double average_elevation[4];
double Current_X[2], Current_Y[2];
int out_lok[4][2];
int noutz;
int river_se[16][2];
double delete_me_in_2008[3][129];
int in_or_out[6];
int Out_Coord[20][2];
int In_Coord[20][2];
int Out_Num;
int In_Num;
int Riv_Num;
double Delta;
double Out_elev[13];
double In_elev[13];
double FD; // Used by Function 51
int adj_catch[25];
int dummy; // use for tempory break points

// VERSION 26.2 GLOBAL VARIABLES
double world;
int xxxx;
double xx[10];
double wrv[20];
double Radius;
double Cent_Elev;
int sst[17];
double Ch[4];
double temp[3];
char Planet_Name[40];
int world_type;
int reverse;
int purge_coast;
int bottom_right;
double fX[1001], fY[1001];
int features[20000];
int cfen; // current feature number
int stackpos1, stackpos_c, stackpos2;
int snow;
double Snow;
int nch, nmt;
int contours;
int type;
int gcw; // ghost continent width
double stretch_factor;
double key1, key2, key3, key4;
double Key[20];
int gap;
double skiphood;
int skt; // skiptype
int hpx[301], hpl[301], hpw[301], hpm[301], hpmode[301];
int hpy[301]; // delete me if you have deleted 1. Define World
int nrange;
int mrxc[201], mryc[201]; // Mountain Range Centroid
int tx[201], ty[201], tno; // snake mountains - DELETE ME
int npx, npy;
char Sea_Name[40];
int seano[141];
double seanodiv;
int WW=1024; // world width
int MR; // decides if mountain ranges should be less random than normal.
int area[1001];
int fcentroid[1001];
int fcentscore[1001];
int fxmax[1001];
int fymax[1001], fxmin[1001], fymin[1001]; // Can eventually be deleted
double dnom[4];
int NF;
double roughness[4];
int mbl; // multiplier bas level
int Nwords;
double ZR; // zoom randomizer
double ZR_b; // zoom randomizer
int dbcfii; // don't bother checking for islands if river level is more than "dbcfii" below sea level;
double Zoom_B[129][129];
double Edge[129];
double a_Key, b_Key;
int current_lok;
String Feature_Names[501];
int lrgd[129][129];
int well_thank_god_for_that=0;
double Rxforty[4]; Ryforty[4];
char Feature_Name[40];
int shadow, render;
int rivcol;
double pi;
int plotmode2=1;
String cfname = "file name";
String names ="Names.txt";
char name2[10];
char name[30];
int ccno=0; // current catchment number;
int seacolour=0;
int riverx[12], rivery[12];
int globx, globy;
int cnLV;
int nt[3][8];
char grid[8][2];
char letters[26][2];
char consanants[40][2][4];
char vowels[30][2][3];
char prefixes[20][7];
char suffixes[20][10];
double planet[15];
int grid_on;
int text_slot[8][32];
//int Y;
String Words[1000];

---------------
FUNCTIONS
---------------
PP. Search & Replace
int pp_search_and_replace(int pp_was, int pp_is, int pp_mode);
// QQ. Next Point on Perimeter
int qq_next_point_on_perimeter(int qq_x, int qq_y, int qq_mode);
// RR. Thread
int rr_thread(int rr_jj, int rr_mode);
// SS. Fill Chevron
int ss_fill_chevron(int ss_point);
// TT. Calc Relev
double tt_calc_relev(double tt_elev, double tt_lat, double tt_long, double tt_seed, int tt_tt);
// UU. Plot Point
int uu_plot_point(int uu_x, int uu_y, int uu_code, int uu_mode);
// VV. Plot Chevron
int vv_plot_chevron(double vv_left, double vv_bottom, double vv_width, int vv_mode);
// WW. Interpolate
int ww_interpolate(double ww_ei, double ww_ef, int ww_np, double ww_min_low, double ww_max_low, int ww_mode, double ww_seed);
// XX. Plot tte
int xx_plot_tte();
// yy. Plot Polygon
yy_plot_polygon(int yy_p_colour, int yy_n_vertexes, int yy_mode);
// zz. Populate Rectangle
int zz_pop_rect(int zz_point, int zz_mode);

// 1. Sosyedi
int TS_sosyedi_1(int ts_point_1);
// 1. Generate Initial Variables
int f_giv1();
// 2. Set Psuedo Random Number Generator
int f_setrandom2(double seed2);
// 2. Grow_Continents
int TS_grow_continents_1();
// 3. Plot World
int TS_plot_world_3();
// 3. Psuedo Random Number Generator
double f_xxx3();
// 4. Plot World
int TS_plot_world_4();
// 4. Update Stats
int updatestats4();
// 5. Ammend Try
int ammend_try(int try5, int mode5);
// 5. Simple Random Number Generator
double f_srng5(double a5, double b5, double c5, double d5, double mult5);
// 5. World Stats
int worldstats5();
// 6. Plot Demispheres
int TS_plot_demispheres_6();
// 6. Label Seas
int label_seas6();
// 7. Point Elevation
double point_elevation7(int point_pos7);
// 8. Set Priorities
int set_priorities_8();
// 8. Very Simple Random Number Generator
double f_r8(double a8, int b8);
// 9. Return Ring Number
int ring_number9(int p_number9);
// 10. Generate Sea Seeds
int gen_sea_seeds10();
// 11. Populate Triangle with Elevations // VERSION 28
int Pte(int mode11);
// 12. Plot Catchments
int TS_plot_catchments_12();
// 13. Catalog Islands
int catalog_islands_13();
// 14. Plot Major Rivers
int plot_major_rivers_14();
// 15. R15 - Another Weak Random Number Generator
double R15(int seed15, double Seed15);
// 16. Calculate the longitude & latitude of a point
int long_lat_point_16(int point16);
// 17. Map Tectonic Plates
int map_tectonic_plates_17();
// 18. Plot Priorities
int TS_plot_priorities_18();
// 19. Add Mountains
int add_mountains_19(int sp19, int j19);
// 20. Populate ttz
int pop_ttz_20(int a20, int b20, int c20);
// 21. Assign Edge Elevations
int assign_edge_elevations_21(int mode21);
// 22. Populate Line
int pop_line_22(double length22, double st_elev22, double end_elev22, double riv_elev22, double drop22, int mode22);
// 23. Stage Two
int stage_two_23(int cp23, double left23, double bottom23, double width23);
// 24. Blanket
int blanket_24();
// 25. Clear Screen
int clear_screen();
// 26. Greyout
int greyout();
// 27. Thread
int thread_27(int jj27, int mode27);
// 28. Plot Blanket
int plot_blanket_28(double bl28);
// 29. Auto Zoom
int auto_zoom_29(double xcc29, double ycc29, double scale29, int projection29);
// 30. Catalog Features
int d_catalog_features30();
int catalog_features30(int mode30);
// 31. Populate grid for Batch Plotting
int popgrid();
// 32. Plot Point
int plot_point_32(int x32, int y32, double elev32, int code32);
// 33. Flow Grid 128
int flow_grid_33();
// 34. Test for end point of river
int test_for_end_point_34(int riv_no34);
// 35. Generate World Parameters
int generate_world_parameters(int mode35);
// 36. Real Point Elevation
double real_point_elevation_36(int p36, double e36, int mode36);
// 37. Pseudo Random Number Generator
int setrandom();
// 38. Set Pseudo Random Number Generator
double xxx();
// 39. Direction
int direction_39(int x39, int y39);
// 40. Adjacent Elevation
double adjacent_elev_40(int x40, int y40);
// 41. Map Creeks
int map_creeks_41(int mode41);
// 42. Whiteout
int whiteout42(int kulla42);
// 42. Whiteout
int whiteout(int kulla);
// 43. Maximum Rise
double maximum_rise_43(int p43);
// 44. Fill Square
fill_square_44(int mode44);
// 45. Command Window
int commands();
// 46. Direction
direction_46(int x46, int y46, double frac46);
// 47. Direction
int direction_47(int x47, int y47);
// 48. A not very random number generator
double weak_random(double d48);
// 49. Another Random Number Generator
double arng(double s1, double s2, double s3, double s4, double mult);
// 50. Load Words
int load_words50(String fn50, int j50);
// 51. Flow Direction
int f_direction_51(int x51, int y51);
// 52. Flow Grid Boundaries
int fgb_52();
// 53. Flow Grid Boundary Direction
int fgb_direction_53(int x53, int y53);
// 54. Intermediate Elevation
double intermediate_elevation_54(double min_elev54, double av_elev54, int mode54);
// 55. Assign Name
int assign_name(double seid1, double seid2, int ntype);
// 56. Save a thousand names
int save_a_thousand();
// 57. Search
int search();
// 58. Write World Name
int write_world_name58();
// 58. WRITE WORLD NAME
int write_world_name();
// 59. Search for World
int search_for(char pn59[40]);
// 60. Calculate Elevation
double elevation_60(double elev_a_60, double elev_b_60, double max_slope60, int dist60, int mode60);
// 61. Next Point
int next_point_61(int x61, int y61, int clock61);
// 62. Where on Perimeter
int where_on_perim_62(int x62, int y62);
// 63. Best Option (Version 28)
int best_option_63(double c63, double oa63, double ob63, double oc63, double od63);
// 64. Plot Brass Monkey
int brass_monkey_64(int mode64);
// 65. Assign Elevations to Edge Points
int edge_elevations65(double elev_a65, double elev_b65, double elev_c65);
// 66. Define Coastline
int define_coastline66(double elev_a66, double elev_b66, double elev_c66, int inverted66);
// 67. Clear Spot TT
int clear_spot_tt67(int mode67);
// 68. Set Pen Colour
int set_pen_colour(int setpc, int setshadow);
// 69. EMPTY TEXT SLOT
int empty_text_slot();
// 70. CHECK TEXT SLOT
int check_text_slot(int Txsl, int Tysl);
// 71. Clear ttp
int clear_ttp71(double val71);
// 72. Plot ttp
int plot_ttp72(int x72,int y72,int off72,int inverted72, int mode72);
73. Elevation of a point between two points
double e73();
74. Row_of_triangle
int row_of_triangle74(int seed74);
75. Plot Triangle
int plot_triangle75(double left75, double bottom75, double width75, int mode75);
76 Plot Rectangle
int plot_rectangle76(double lat76, double long76, double width76);
77 Set Vertex Values
int set_vertex_values77(int point77, int updown77);
79 Which Way
int whichway_79(int x79, int y79);

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License