void MakeToFunc(int i,int j,int k) { int conv_type; char *len_msg,*conv_msg; /* destination = i, source = j, type = k */ GenName(i,j,k); pr(dfd,"{\n"); /* check if we need network byte swaps */ if (strstr(aitName[i],"16")) { len_msg="16"; conv_type=AIT_SWAP_16; } else if(strstr(aitName[i],"32")) { len_msg="32"; conv_type=AIT_SWAP_32; } else if(strstr(aitName[i],"64")) { len_msg="64"; conv_type=AIT_SWAP_64; } else { len_msg=""; conv_type=AIT_SWAP_NONE; } if (strstr(aitName[i],"Float")) conv_msg="Float"; else conv_msg="Order"; GenVars(i,j); if(i==j || conv_type==AIT_SWAP_NONE) { if(conv_type!=AIT_SWAP_NONE) { pr(dfd,"\tfor(i=0;i<c;i++)\n"); pr(dfd,"\t\taitToNet%s%s",conv_msg,len_msg); pr(dfd,"((aitUint%s*)&d_val[i],",len_msg); pr(dfd,"(aitUint%s*)&s_val[i]);\n",len_msg); } else { pr(dfd,"\tfor(i=0;i<c;i++)\n"); pr(dfd,"\t\td_val[i]=(%s)(s_val[i]);\n",aitName[i]); } } else { /* cast first to correct type, then swap */ pr(dfd,"\t%s temp;\n\n",aitName[i]); pr(dfd,"\tfor(i=0;i<c;i++) {\n"); pr(dfd,"\t\ttemp=(%s)s_val[i];\n",aitName[i]); pr(dfd,"\t\taitToNet%s%s",conv_msg,len_msg); pr(dfd,"((aitUint%s*)&d_val[i],",len_msg); pr(dfd,"(aitUint%s*)&temp);\n",len_msg); pr(dfd,"\t}\n"); } pr(dfd,"\treturn (int) (sizeof(%s)*c);\n",aitName[i]); pr(dfd,"}\n"); }
CGUIimageGrid::CGUIimageGrid(int x, int y, int _cols, int _rows, int size) { GenName("ImageGrid",Count++); type = imageGrid; cols = _cols; rows = _rows; cellSize = size; SetPos(x,y,cols*cellSize,rows*cellSize); highlightColour = UIblue; selectColour = UIyellow; resizeGrid(); tilesheet = noTileset; selected = NONE; borderWidth = 1; cellScale = 1; }
void MakeNormalFunc(int i,int j,int k) { GenName(i,j,k); pr(dfd,"{\n"); if(i==j) pr(dfd,"\tmemcpy(d,s,c*sizeof(%s));\n",aitName[i]); else { GenVars(i,j); pr(dfd,"\tfor(i=0;i<c;i++)\n"); pr(dfd,"\t\td_val[i]=(%s)(s_val[i]);\n",aitName[i]); } pr(dfd,"\treturn (int) (sizeof(%s)*c);\n",aitName[i]); pr(dfd,"}\n"); }
Reference* NodeFactory::CreateRef(Definition* pParentDef) { CStringW name = GenName(); Reference* pRef = DNew Reference(this, name); m_nodes.SetAt(name, pRef); m_newnodes.AddTail(name); if(pParentDef) { pParentDef->AddTail(pRef); pRef->m_parent = pParentDef; } return pRef; }
Definition* NodeFactory::CreateDef(Reference* pParentRef, CStringW type, CStringW name, NodePriority priority) { Definition* pDef = NULL; if(name.IsEmpty()) { name = GenName(); } else { pDef = GetDefByName(name); if(pDef) { if(!pDef->m_predefined) { throw Exception(_T("redefinition of '%s' is not allowed"), CString(name)); } if(!pDef->IsTypeUnknown() && !pDef->IsType(type)) { throw Exception(_T("cannot redefine type of %s to %s"), CString(name), CString(type)); } } } if(!pDef) { pDef = DNew Definition(this, name); m_nodes.SetAt(name, pDef); m_newnodes.AddTail(name); if(pParentRef) { pParentRef->AddTail(pDef); pDef->m_parent = pParentRef; } } pDef->m_type = type; pDef->m_priority = priority; pDef->m_predefined = m_predefined; return pDef; }
bool SectorRandomSystemsGenerator::Apply(Random& rng, RefCountedPtr<Galaxy> galaxy, RefCountedPtr<Sector> sector, GalaxyGenerator::SectorConfig* config) { /* Always place random systems outside the core custom-only region */ if (config->isCustomOnly) return true; const int sx = sector->sx; const int sy = sector->sy; const int sz = sector->sz; const int customCount = static_cast<Uint32>(sector->m_systems.size()); const Sint64 dist = (1 + sx*sx + sy*sy + sz*sz); const Sint64 freq = (1 + sx * sx + sy * sy); const int numSystems = (rng.Int32(4,20) * galaxy->GetSectorDensity(sx, sy, sz)) >> 8; sector->m_systems.reserve(numSystems); for (int i=0; i<numSystems; i++) { Sector::System s(sector.Get(), sx, sy, sz, customCount + i); switch (rng.Int32(15)) { case 0: s.m_numStars = 4; break; case 1: case 2: s.m_numStars = 3; break; case 3: case 4: case 5: case 6: s.m_numStars = 2; break; default: s.m_numStars = 1; break; } s.m_pos.x = rng.Double(Sector::SIZE); s.m_pos.y = rng.Double(Sector::SIZE); s.m_pos.z = rng.Double(Sector::SIZE); /* * 0 - ~500ly from sol: explored * ~500ly - ~700ly (65-90 sectors): gradual * ~700ly+: unexplored */ if (((dist <= Square(90)) && ( dist <= Square(65) || rng.Int32(dist) <= Square(40))) || galaxy->GetFactions()->IsHomeSystem(SystemPath(sx, sy, sz, customCount + i))) s.m_explored = StarSystem::eEXPLORED_AT_START; else s.m_explored = StarSystem::eUNEXPLORED; // Frequencies are low enough that we probably don't need this anymore. if (freq > Square(10)) { const Uint32 weight = rng.Int32(1000000); if (weight < 1) { s.m_starType[0] = SystemBody::TYPE_STAR_IM_BH; // These frequencies are made up } else if (weight < 3) { s.m_starType[0] = SystemBody::TYPE_STAR_S_BH; } else if (weight < 5) { s.m_starType[0] = SystemBody::TYPE_STAR_O_WF; } else if (weight < 8) { s.m_starType[0] = SystemBody::TYPE_STAR_B_WF; } else if (weight < 12) { s.m_starType[0] = SystemBody::TYPE_STAR_M_WF; } else if (weight < 15) { s.m_starType[0] = SystemBody::TYPE_STAR_K_HYPER_GIANT; } else if (weight < 18) { s.m_starType[0] = SystemBody::TYPE_STAR_G_HYPER_GIANT; } else if (weight < 23) { s.m_starType[0] = SystemBody::TYPE_STAR_O_HYPER_GIANT; } else if (weight < 28) { s.m_starType[0] = SystemBody::TYPE_STAR_A_HYPER_GIANT; } else if (weight < 33) { s.m_starType[0] = SystemBody::TYPE_STAR_F_HYPER_GIANT; } else if (weight < 41) { s.m_starType[0] = SystemBody::TYPE_STAR_B_HYPER_GIANT; } else if (weight < 48) { s.m_starType[0] = SystemBody::TYPE_STAR_M_HYPER_GIANT; } else if (weight < 58) { s.m_starType[0] = SystemBody::TYPE_STAR_K_SUPER_GIANT; } else if (weight < 68) { s.m_starType[0] = SystemBody::TYPE_STAR_G_SUPER_GIANT; } else if (weight < 78) { s.m_starType[0] = SystemBody::TYPE_STAR_O_SUPER_GIANT; } else if (weight < 88) { s.m_starType[0] = SystemBody::TYPE_STAR_A_SUPER_GIANT; } else if (weight < 98) { s.m_starType[0] = SystemBody::TYPE_STAR_F_SUPER_GIANT; } else if (weight < 108) { s.m_starType[0] = SystemBody::TYPE_STAR_B_SUPER_GIANT; } else if (weight < 158) { s.m_starType[0] = SystemBody::TYPE_STAR_M_SUPER_GIANT; } else if (weight < 208) { s.m_starType[0] = SystemBody::TYPE_STAR_K_GIANT; } else if (weight < 250) { s.m_starType[0] = SystemBody::TYPE_STAR_G_GIANT; } else if (weight < 300) { s.m_starType[0] = SystemBody::TYPE_STAR_O_GIANT; } else if (weight < 350) { s.m_starType[0] = SystemBody::TYPE_STAR_A_GIANT; } else if (weight < 400) { s.m_starType[0] = SystemBody::TYPE_STAR_F_GIANT; } else if (weight < 500) { s.m_starType[0] = SystemBody::TYPE_STAR_B_GIANT; } else if (weight < 700) { s.m_starType[0] = SystemBody::TYPE_STAR_M_GIANT; } else if (weight < 800) { s.m_starType[0] = SystemBody::TYPE_STAR_O; // should be 1 but that is boring } else if (weight < 2000) { // weight < 1300 / 20500 s.m_starType[0] = SystemBody::TYPE_STAR_B; } else if (weight < 8000) { // weight < 7300 s.m_starType[0] = SystemBody::TYPE_STAR_A; } else if (weight < 37300) { // weight < 37300 s.m_starType[0] = SystemBody::TYPE_STAR_F; } else if (weight < 113300) { // weight < 113300 s.m_starType[0] = SystemBody::TYPE_STAR_G; } else if (weight < 234300) { // weight < 234300 s.m_starType[0] = SystemBody::TYPE_STAR_K; } else if (weight < 250000) { // weight < 250000 s.m_starType[0] = SystemBody::TYPE_WHITE_DWARF; } else if (weight < 900000) { //weight < 900000 s.m_starType[0] = SystemBody::TYPE_STAR_M; } else { s.m_starType[0] = SystemBody::TYPE_BROWN_DWARF; } } else { const Uint32 weight = rng.Int32(1000000); if (weight < 100) { // should be 1 but that is boring s.m_starType[0] = SystemBody::TYPE_STAR_O; } else if (weight < 1300) { s.m_starType[0] = SystemBody::TYPE_STAR_B; } else if (weight < 7300) { s.m_starType[0] = SystemBody::TYPE_STAR_A; } else if (weight < 37300) { s.m_starType[0] = SystemBody::TYPE_STAR_F; } else if (weight < 113300) { s.m_starType[0] = SystemBody::TYPE_STAR_G; } else if (weight < 234300) { s.m_starType[0] = SystemBody::TYPE_STAR_K; } else if (weight < 250000) { s.m_starType[0] = SystemBody::TYPE_WHITE_DWARF; } else if (weight < 900000) { s.m_starType[0] = SystemBody::TYPE_STAR_M; } else { s.m_starType[0] = SystemBody::TYPE_BROWN_DWARF; } } //Output("%d: %d%\n", sx, sy); if (s.m_numStars > 1) { s.m_starType[1] = SystemBody::BodyType(rng.Int32(SystemBody::TYPE_STAR_MIN, s.m_starType[0])); if (s.m_numStars > 2) { s.m_starType[2] = SystemBody::BodyType(rng.Int32(SystemBody::TYPE_STAR_MIN, s.m_starType[0])); s.m_starType[3] = SystemBody::BodyType(rng.Int32(SystemBody::TYPE_STAR_MIN, s.m_starType[2])); } } if ((s.m_starType[0] <= SystemBody::TYPE_STAR_A) && (rng.Int32(10)==0)) { // make primary a giant. never more than one giant in a system if (freq > Square(10)) { const Uint32 weight = rng.Int32(1000); if (weight >= 999) { s.m_starType[0] = SystemBody::TYPE_STAR_B_HYPER_GIANT; } else if (weight >= 998) { s.m_starType[0] = SystemBody::TYPE_STAR_O_HYPER_GIANT; } else if (weight >= 997) { s.m_starType[0] = SystemBody::TYPE_STAR_K_HYPER_GIANT; } else if (weight >= 995) { s.m_starType[0] = SystemBody::TYPE_STAR_B_SUPER_GIANT; } else if (weight >= 993) { s.m_starType[0] = SystemBody::TYPE_STAR_O_SUPER_GIANT; } else if (weight >= 990) { s.m_starType[0] = SystemBody::TYPE_STAR_K_SUPER_GIANT; } else if (weight >= 985) { s.m_starType[0] = SystemBody::TYPE_STAR_B_GIANT; } else if (weight >= 980) { s.m_starType[0] = SystemBody::TYPE_STAR_O_GIANT; } else if (weight >= 975) { s.m_starType[0] = SystemBody::TYPE_STAR_K_GIANT; } else if (weight >= 950) { s.m_starType[0] = SystemBody::TYPE_STAR_M_HYPER_GIANT; } else if (weight >= 875) { s.m_starType[0] = SystemBody::TYPE_STAR_M_SUPER_GIANT; } else { s.m_starType[0] = SystemBody::TYPE_STAR_M_GIANT; } } else if (freq > Square(5)) s.m_starType[0] = SystemBody::TYPE_STAR_M_GIANT; else s.m_starType[0] = SystemBody::TYPE_STAR_M; //Output("%d: %d%\n", sx, sy); } s.m_name = GenName(galaxy, *sector, s, customCount + i, rng); //Output("%s: \n", s.m_name.c_str()); sector->m_systems.push_back(s); } return true; }
//////////////////////// Sector Sector::Sector(int x, int y, int z) { unsigned long _init[4] = { Uint32(x), Uint32(y), Uint32(z), UNIVERSE_SEED }; sx = x; sy = y; sz = z; MTRand rng(_init, 4); MTRand rand(UNIVERSE_SEED); GetCustomSystems(); /* Always place random systems outside the core custom-only region */ if ((x < -CUSTOM_ONLY_RADIUS) || (x > CUSTOM_ONLY_RADIUS-1) || (y < -CUSTOM_ONLY_RADIUS) || (y > CUSTOM_ONLY_RADIUS-1) || (z < -CUSTOM_ONLY_RADIUS) || (z > CUSTOM_ONLY_RADIUS-1)) { int numSystems = (rng.Int32(4,20) * Galaxy::GetSectorDensity(x, y, z)) >> 8; for (int i=0; i<numSystems; i++) { System s; switch (rng.Int32(15)) { case 0: s.numStars = 4; break; case 1: case 2: s.numStars = 3; break; case 3: case 4: case 5: case 6: s.numStars = 2; break; default: s.numStars = 1; break; } s.p.x = rng.Double(SIZE); s.p.y = rng.Double(SIZE); s.p.z = rng.Double(SIZE); s.seed = 0; s.customSys = 0; double spec = rng.Double(1000000.0); // frequencies from wikipedia /*if (spec < 100) { // should be 1 but that is boring s.starType[0] = SystemBody::TYPE_STAR_O; } else if (spec < 1300) { s.starType[0] = SystemBody::TYPE_STAR_B; } else if (spec < 7300) { s.starType[0] = SystemBody::TYPE_STAR_A; } else if (spec < 37300) { s.starType[0] = SystemBody::TYPE_STAR_F; } else if (spec < 113300) { s.starType[0] = SystemBody::TYPE_STAR_G; } else if (spec < 234300) { s.starType[0] = SystemBody::TYPE_STAR_K; } else if (spec < 250000) { s.starType[0] = SystemBody::TYPE_WHITE_DWARF; } else if (spec < 900000) { s.starType[0] = SystemBody::TYPE_STAR_M; } else { s.starType[0] = SystemBody::TYPE_BROWN_DWARF; }*/ //if ((sx > 50) || (sx < -50) || // (sy > 50) || (sy < -50)) // Frequencies are low enough that we probably don't need this anymore. if (isqrt(1+sx*sx+sy*sy) > 10) { if (spec < 1) { s.starType[0] = SystemBody::TYPE_STAR_IM_BH; // These frequencies are made up } else if (spec < 3) { s.starType[0] = SystemBody::TYPE_STAR_S_BH; } else if (spec < 5) { s.starType[0] = SystemBody::TYPE_STAR_O_WF; } else if (spec < 8) { s.starType[0] = SystemBody::TYPE_STAR_B_WF; } else if (spec < 12) { s.starType[0] = SystemBody::TYPE_STAR_M_WF; } else if (spec < 15) { s.starType[0] = SystemBody::TYPE_STAR_K_HYPER_GIANT; } else if (spec < 18) { s.starType[0] = SystemBody::TYPE_STAR_G_HYPER_GIANT; } else if (spec < 23) { s.starType[0] = SystemBody::TYPE_STAR_O_HYPER_GIANT; } else if (spec < 28) { s.starType[0] = SystemBody::TYPE_STAR_A_HYPER_GIANT; } else if (spec < 33) { s.starType[0] = SystemBody::TYPE_STAR_F_HYPER_GIANT; } else if (spec < 41) { s.starType[0] = SystemBody::TYPE_STAR_B_HYPER_GIANT; } else if (spec < 48) { s.starType[0] = SystemBody::TYPE_STAR_M_HYPER_GIANT; } else if (spec < 58) { s.starType[0] = SystemBody::TYPE_STAR_K_SUPER_GIANT; } else if (spec < 68) { s.starType[0] = SystemBody::TYPE_STAR_G_SUPER_GIANT; } else if (spec < 78) { s.starType[0] = SystemBody::TYPE_STAR_O_SUPER_GIANT; } else if (spec < 88) { s.starType[0] = SystemBody::TYPE_STAR_A_SUPER_GIANT; } else if (spec < 98) { s.starType[0] = SystemBody::TYPE_STAR_F_SUPER_GIANT; } else if (spec < 108) { s.starType[0] = SystemBody::TYPE_STAR_B_SUPER_GIANT; } else if (spec < 158) { s.starType[0] = SystemBody::TYPE_STAR_M_SUPER_GIANT; } else if (spec < 208) { s.starType[0] = SystemBody::TYPE_STAR_K_GIANT; } else if (spec < 250) { s.starType[0] = SystemBody::TYPE_STAR_G_GIANT; } else if (spec < 300) { s.starType[0] = SystemBody::TYPE_STAR_O_GIANT; } else if (spec < 350) { s.starType[0] = SystemBody::TYPE_STAR_A_GIANT; } else if (spec < 400) { s.starType[0] = SystemBody::TYPE_STAR_F_GIANT; } else if (spec < 500) { s.starType[0] = SystemBody::TYPE_STAR_B_GIANT; } else if (spec < 700) { s.starType[0] = SystemBody::TYPE_STAR_M_GIANT; } else if (spec < 800) { s.starType[0] = SystemBody::TYPE_STAR_O; // should be 1 but that is boring } else if (spec < 2000) { // spec < 1300 / 20500 s.starType[0] = SystemBody::TYPE_STAR_B; } else if (spec < 8000) { // spec < 7300 s.starType[0] = SystemBody::TYPE_STAR_A; } else if (spec < 37300) { // spec < 37300 s.starType[0] = SystemBody::TYPE_STAR_F; } else if (spec < 113300) { // spec < 113300 s.starType[0] = SystemBody::TYPE_STAR_G; } else if (spec < 234300) { // spec < 234300 s.starType[0] = SystemBody::TYPE_STAR_K; } else if (spec < 250000) { // spec < 250000 s.starType[0] = SystemBody::TYPE_WHITE_DWARF; } else if (spec < 900000) { //spec < 900000 s.starType[0] = SystemBody::TYPE_STAR_M; } else { s.starType[0] = SystemBody::TYPE_BROWN_DWARF; } } else { if (spec < 100) { // should be 1 but that is boring s.starType[0] = SystemBody::TYPE_STAR_O; } else if (spec < 1300) { s.starType[0] = SystemBody::TYPE_STAR_B; } else if (spec < 7300) { s.starType[0] = SystemBody::TYPE_STAR_A; } else if (spec < 37300) { s.starType[0] = SystemBody::TYPE_STAR_F; } else if (spec < 113300) { s.starType[0] = SystemBody::TYPE_STAR_G; } else if (spec < 234300) { s.starType[0] = SystemBody::TYPE_STAR_K; } else if (spec < 250000) { s.starType[0] = SystemBody::TYPE_WHITE_DWARF; } else if (spec < 900000) { s.starType[0] = SystemBody::TYPE_STAR_M; } else { s.starType[0] = SystemBody::TYPE_BROWN_DWARF; } } //printf("%d: %d%\n", sx, sy); if (s.numStars > 1) { s.starType[1] = SystemBody::BodyType(rng.Int32(SystemBody::TYPE_STAR_MIN, s.starType[0])); if (s.numStars > 2) { s.starType[2] = SystemBody::BodyType(rng.Int32(SystemBody::TYPE_STAR_MIN, s.starType[0])); s.starType[3] = SystemBody::BodyType(rng.Int32(SystemBody::TYPE_STAR_MIN, s.starType[2])); } } if ((s.starType[0] <= SystemBody::TYPE_STAR_A) && (rng.Int32(10)==0)) { // make primary a giant. never more than one giant in a system // while if (isqrt(1+sx*sx+sy*sy) > 10) { if (rand.Int32(0,1000) >= 999) { s.starType[0] = SystemBody::TYPE_STAR_B_HYPER_GIANT; } else if (rand.Int32(0,1000) >= 998) { s.starType[0] = SystemBody::TYPE_STAR_O_HYPER_GIANT; } else if (rand.Int32(0,1000) >= 997) { s.starType[0] = SystemBody::TYPE_STAR_K_HYPER_GIANT; } else if (rand.Int32(0,1000) >= 995) { s.starType[0] = SystemBody::TYPE_STAR_B_SUPER_GIANT; } else if (rand.Int32(0,1000) >= 993) { s.starType[0] = SystemBody::TYPE_STAR_O_SUPER_GIANT; } else if (rand.Int32(0,1000) >= 990) { s.starType[0] = SystemBody::TYPE_STAR_K_SUPER_GIANT; } else if (rand.Int32(0,1000) >= 985) { s.starType[0] = SystemBody::TYPE_STAR_B_GIANT; } else if (rand.Int32(0,1000) >= 980) { s.starType[0] = SystemBody::TYPE_STAR_O_GIANT; } else if (rand.Int32(0,1000) >= 975) { s.starType[0] = SystemBody::TYPE_STAR_K_GIANT; } else if (rand.Int32(0,1000) >= 950) { s.starType[0] = SystemBody::TYPE_STAR_M_HYPER_GIANT; } else if (rand.Int32(0,1000) >= 875) { s.starType[0] = SystemBody::TYPE_STAR_M_SUPER_GIANT; } else { s.starType[0] = SystemBody::TYPE_STAR_M_GIANT; } } else if (isqrt(1+sx*sx+sy*sy) > 5) s.starType[0] = SystemBody::TYPE_STAR_M_GIANT; else s.starType[0] = SystemBody::TYPE_STAR_M; //printf("%d: %d%\n", sx, sy); } s.name = GenName(s, rng); //printf("%s: \n", s.name.c_str()); m_systems.push_back(s); } }
//////////////////////// Sector Sector::Sector(const SystemPath& path) : m_factionsAssigned(false) { PROFILE_SCOPED() Uint32 _init[4] = { Uint32(path.sectorX), Uint32(path.sectorY), Uint32(path.sectorZ), UNIVERSE_SEED }; Random rng(_init, 4); sx = path.sectorX; sy = path.sectorY; sz = path.sectorZ; GetCustomSystems(rng); int customCount = m_systems.size(); /* Always place random systems outside the core custom-only region */ if ((path.sectorX < -CUSTOM_ONLY_RADIUS) || (path.sectorX > CUSTOM_ONLY_RADIUS-1) || (path.sectorY < -CUSTOM_ONLY_RADIUS) || (path.sectorY > CUSTOM_ONLY_RADIUS-1) || (path.sectorZ < -CUSTOM_ONLY_RADIUS) || (path.sectorZ > CUSTOM_ONLY_RADIUS-1)) { int numSystems = (rng.Int32(4,20) * Galaxy::GetSectorDensity(path.sectorX, path.sectorY, path.sectorZ)) >> 8; for (int i=0; i<numSystems; i++) { System s(sx, sy, sz, customCount + i); switch (rng.Int32(15)) { case 0: s.numStars = 4; break; case 1: case 2: s.numStars = 3; break; case 3: case 4: case 5: case 6: s.numStars = 2; break; default: s.numStars = 1; break; } s.p.x = rng.Double(SIZE); s.p.y = rng.Double(SIZE); s.p.z = rng.Double(SIZE); s.seed = 0; s.customSys = 0; /* * 0 - ~500ly from sol: explored * ~500ly - ~700ly (65-90 sectors): gradual * ~700ly+: unexplored */ int dist = isqrt(1 + sx*sx + sy*sy + sz*sz); s.explored = ((dist <= 90) && ( dist <= 65 || rng.Int32(dist) <= 40)) || Faction::IsHomeSystem(SystemPath(sx, sy, sz, customCount + i)); Uint32 weight = rng.Int32(1000000); // Frequencies are low enough that we probably don't need this anymore. if (isqrt(1+sx*sx+sy*sy) > 10) { if (weight < 1) { s.starType[0] = SystemBody::TYPE_STAR_IM_BH; // These frequencies are made up } else if (weight < 3) { s.starType[0] = SystemBody::TYPE_STAR_S_BH; } else if (weight < 5) { s.starType[0] = SystemBody::TYPE_STAR_O_WF; } else if (weight < 8) { s.starType[0] = SystemBody::TYPE_STAR_B_WF; } else if (weight < 12) { s.starType[0] = SystemBody::TYPE_STAR_M_WF; } else if (weight < 15) { s.starType[0] = SystemBody::TYPE_STAR_K_HYPER_GIANT; } else if (weight < 18) { s.starType[0] = SystemBody::TYPE_STAR_G_HYPER_GIANT; } else if (weight < 23) { s.starType[0] = SystemBody::TYPE_STAR_O_HYPER_GIANT; } else if (weight < 28) { s.starType[0] = SystemBody::TYPE_STAR_A_HYPER_GIANT; } else if (weight < 33) { s.starType[0] = SystemBody::TYPE_STAR_F_HYPER_GIANT; } else if (weight < 41) { s.starType[0] = SystemBody::TYPE_STAR_B_HYPER_GIANT; } else if (weight < 48) { s.starType[0] = SystemBody::TYPE_STAR_M_HYPER_GIANT; } else if (weight < 58) { s.starType[0] = SystemBody::TYPE_STAR_K_SUPER_GIANT; } else if (weight < 68) { s.starType[0] = SystemBody::TYPE_STAR_G_SUPER_GIANT; } else if (weight < 78) { s.starType[0] = SystemBody::TYPE_STAR_O_SUPER_GIANT; } else if (weight < 88) { s.starType[0] = SystemBody::TYPE_STAR_A_SUPER_GIANT; } else if (weight < 98) { s.starType[0] = SystemBody::TYPE_STAR_F_SUPER_GIANT; } else if (weight < 108) { s.starType[0] = SystemBody::TYPE_STAR_B_SUPER_GIANT; } else if (weight < 158) { s.starType[0] = SystemBody::TYPE_STAR_M_SUPER_GIANT; } else if (weight < 208) { s.starType[0] = SystemBody::TYPE_STAR_K_GIANT; } else if (weight < 250) { s.starType[0] = SystemBody::TYPE_STAR_G_GIANT; } else if (weight < 300) { s.starType[0] = SystemBody::TYPE_STAR_O_GIANT; } else if (weight < 350) { s.starType[0] = SystemBody::TYPE_STAR_A_GIANT; } else if (weight < 400) { s.starType[0] = SystemBody::TYPE_STAR_F_GIANT; } else if (weight < 500) { s.starType[0] = SystemBody::TYPE_STAR_B_GIANT; } else if (weight < 700) { s.starType[0] = SystemBody::TYPE_STAR_M_GIANT; } else if (weight < 800) { s.starType[0] = SystemBody::TYPE_STAR_O; // should be 1 but that is boring } else if (weight < 2000) { // weight < 1300 / 20500 s.starType[0] = SystemBody::TYPE_STAR_B; } else if (weight < 8000) { // weight < 7300 s.starType[0] = SystemBody::TYPE_STAR_A; } else if (weight < 37300) { // weight < 37300 s.starType[0] = SystemBody::TYPE_STAR_F; } else if (weight < 113300) { // weight < 113300 s.starType[0] = SystemBody::TYPE_STAR_G; } else if (weight < 234300) { // weight < 234300 s.starType[0] = SystemBody::TYPE_STAR_K; } else if (weight < 250000) { // weight < 250000 s.starType[0] = SystemBody::TYPE_WHITE_DWARF; } else if (weight < 900000) { //weight < 900000 s.starType[0] = SystemBody::TYPE_STAR_M; } else { s.starType[0] = SystemBody::TYPE_BROWN_DWARF; } } else { if (weight < 100) { // should be 1 but that is boring s.starType[0] = SystemBody::TYPE_STAR_O; } else if (weight < 1300) { s.starType[0] = SystemBody::TYPE_STAR_B; } else if (weight < 7300) { s.starType[0] = SystemBody::TYPE_STAR_A; } else if (weight < 37300) { s.starType[0] = SystemBody::TYPE_STAR_F; } else if (weight < 113300) { s.starType[0] = SystemBody::TYPE_STAR_G; } else if (weight < 234300) { s.starType[0] = SystemBody::TYPE_STAR_K; } else if (weight < 250000) { s.starType[0] = SystemBody::TYPE_WHITE_DWARF; } else if (weight < 900000) { s.starType[0] = SystemBody::TYPE_STAR_M; } else { s.starType[0] = SystemBody::TYPE_BROWN_DWARF; } } //Output("%d: %d%\n", sx, sy); if (s.numStars > 1) { s.starType[1] = SystemBody::BodyType(rng.Int32(SystemBody::TYPE_STAR_MIN, s.starType[0])); if (s.numStars > 2) { s.starType[2] = SystemBody::BodyType(rng.Int32(SystemBody::TYPE_STAR_MIN, s.starType[0])); s.starType[3] = SystemBody::BodyType(rng.Int32(SystemBody::TYPE_STAR_MIN, s.starType[2])); } } if ((s.starType[0] <= SystemBody::TYPE_STAR_A) && (rng.Int32(10)==0)) { // make primary a giant. never more than one giant in a system // while if (isqrt(1+sx*sx+sy*sy) > 10) { weight = rng.Int32(1000); if (weight >= 999) { s.starType[0] = SystemBody::TYPE_STAR_B_HYPER_GIANT; } else if (weight >= 998) { s.starType[0] = SystemBody::TYPE_STAR_O_HYPER_GIANT; } else if (weight >= 997) { s.starType[0] = SystemBody::TYPE_STAR_K_HYPER_GIANT; } else if (weight >= 995) { s.starType[0] = SystemBody::TYPE_STAR_B_SUPER_GIANT; } else if (weight >= 993) { s.starType[0] = SystemBody::TYPE_STAR_O_SUPER_GIANT; } else if (weight >= 990) { s.starType[0] = SystemBody::TYPE_STAR_K_SUPER_GIANT; } else if (weight >= 985) { s.starType[0] = SystemBody::TYPE_STAR_B_GIANT; } else if (weight >= 980) { s.starType[0] = SystemBody::TYPE_STAR_O_GIANT; } else if (weight >= 975) { s.starType[0] = SystemBody::TYPE_STAR_K_GIANT; } else if (weight >= 950) { s.starType[0] = SystemBody::TYPE_STAR_M_HYPER_GIANT; } else if (weight >= 875) { s.starType[0] = SystemBody::TYPE_STAR_M_SUPER_GIANT; } else { s.starType[0] = SystemBody::TYPE_STAR_M_GIANT; } } else if (isqrt(1+sx*sx+sy*sy) > 5) s.starType[0] = SystemBody::TYPE_STAR_M_GIANT; else s.starType[0] = SystemBody::TYPE_STAR_M; //Output("%d: %d%\n", sx, sy); } s.name = GenName(s, customCount + i, rng); //Output("%s: \n", s.name.c_str()); m_systems.push_back(s); } }
/* ** PrintGen() prints a generator. */ void PrintGen(gen g) { fprintf(OutFp, "%s", GenName(g)); }
CGUIcontainer::CGUIcontainer(int x, int y, int w, int h) : CGUIsysContainer(x,y,w,h) { GenName("Container",Count++); borderWidth = 1; }
void UploadXML::Add(GPXRow *row) { kGUIXMLItem *point; double lat,lon; kGUIString name; kGUIString hint; kGUIString fullname; WPVERIFY_DEF def; static char validchars[]={" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwnyz0123456789"}; /* am I full already? */ if(m_numpoints==m_maxpoints) return; point=m_root->AddChild("wpt"); lat=row->m_llcoord.GetLat(); lon=row->m_llcoord.GetLon(); point->AddParm("lat",lat); point->AddParm("lon",lon); hint.SetString(row->m_hint.GetString()); hint.Clean(validchars); switch(m_nameformat) { case UPNAME_WAYNAME: name.SetString(row->m_wptname.GetString()); break; case UPNAME_TRUNCATE: case UPNAME_DROPVOWELS: name.SetString(row->m_name.GetString()); break; } fullname.SetString(name.GetString()); GenName(&name); def.found=false; def.lat=lat; def.lon=lon; m_names.Add(name.GetString(),&def); /* check hash table fo collisions */ point->AddChild("name",name.GetString()); fullname.Clean(validchars); // point->AddChild("desc",fullname.GetString()); // point->AddChild("cmt",fullname.GetString()); point->AddChild("desc",hint.GetString()); point->AddChild("cmt",hint.GetString()); point->AddChild("sym","Geocache"); /* hmmmm */ AddToBounds(lat,lon); if(++m_numpoints==m_maxpoints) return; if(m_addchildren==true && row->m_numchildren) { /* download child waypoints too */ unsigned int c; GPXChild *cc; for(c=0;c<row->m_numchildren;++c) { cc=row->m_children.GetEntry(c); point=m_root->AddChild("wpt"); lat=cc->GetLat(); lon=cc->GetLon(); point->AddParm("lat",lat); point->AddParm("lon",lon); switch(m_nameformat) { case 0: name.SetString(cc->GetWptName()); break; case 1: case 2: name.SetString(cc->GetName()); break; } GenName(&name); def.found=false; def.lat=lat; def.lon=lon; m_names.Add(name.GetString(),&def); point->AddChild("name",name.GetString()); point->AddChild("desc",name.GetString()); point->AddChild("cmt",name.GetString()); point->AddChild("sym","Geocache"); /* todo: other? */ ++m_numchildpoints; AddToBounds(lat,lon); if(++m_numpoints==m_maxpoints) break; } } }