/* If the si is negative, set the homeworld to our best shot at a system path pointing to a valid system, close to passed co-ordinates. Otherwise trust the caller, and just set the system path for the co-ordinates. Used by the Lua interface, to support autogenerated factions. */ void Faction::SetBestFitHomeworld(Sint32 x, Sint32 y, Sint32 z, Sint32 si, Uint32 bi, Sint32 axisChange) { // search for a home system until we either find one sutiable, hit one of the axes, // or hit the edge of inhabited space Uint32 i = 0; RefCountedPtr<StarSystem> sys; while (si < 0 && (abs(x) != 90 && abs(y) != 90 && abs(z) != 90) && ( x != 0 && y != 0 && z != 0 )) { // search for a suitable homeworld in the current sector Sector sec(x,y,z); Uint32 candidateSi = 0; while (candidateSi < sec.m_systems.size()) { sys = StarSystem::GetCached(SystemPath(x,y,z,candidateSi)); if (sys->m_spaceStations.size() > 0) { si = Sint32(candidateSi); break; } candidateSi++; } // set the co-ordinates of the next sector to examine, cycling through x, y and z if (si < 0 && i%3==0) { if (x >= 0) { x = x + axisChange; } else { x = x - axisChange; }; } else if (si < 0 && i%3==1) { if (y >= 0) { y = y + axisChange; } else { y = y - axisChange; }; } else if (si < 0 && i%3==2) { if (z >= 0) { z = z + axisChange; } else { z = z - axisChange; }; } i++; } homeworld = SystemPath(x, y, z, si); }
void SystemInfoView::UpdateIconSelections() { m_selectedBodyPath = SystemPath(); for (auto& bodyIcon : m_bodyIcons) { bodyIcon.second->SetSelected(false); RefCountedPtr<StarSystem> currentSys = Pi::game->GetSpace()->GetStarSystem(); if (currentSys && currentSys->GetPath() == m_system->GetPath()) { //navtarget can be only set in current system if (Body* navtarget = Pi::player->GetNavTarget()) { const SystemPath& navpath = navtarget->GetSystemBody()->GetPath(); if (bodyIcon.first == navpath.bodyIndex) { bodyIcon.second->SetSelectColor(Color(0, 255, 0, 255)); bodyIcon.second->SetSelected(true); m_selectedBodyPath = navpath; } } } else { SystemPath selected = Pi::sectorView->GetSelected(); if (selected.IsSameSystem(m_system->GetPath()) && !selected.IsSystemPath()) { if (bodyIcon.first == selected.bodyIndex) { bodyIcon.second->SetSelectColor(Color(64, 96, 255, 255)); bodyIcon.second->SetSelected(true); m_selectedBodyPath = selected; } } } } }
bool CheckSystemBitmaps() { TCHAR srcdir[MAX_PATH]; TCHAR srcfile[MAX_PATH]; SystemPath(srcdir, _T(LKD_BITMAPS)); _stprintf(srcfile,TEXT("%s%s_BITMAPSH"),srcdir, _T(DIRSEP)); return lk::filesystem::exist(srcfile); }
bool CheckSystemDefaultMenu() { TCHAR srcdir[MAX_PATH]; TCHAR srcfile[MAX_PATH]; SystemPath(srcdir, _T(LKD_SYSTEM)); _stprintf(srcfile,TEXT("%s%sDEFAULT_MENU.TXT"),srcdir, _T(DIRSEP)); return lk::filesystem::exist(srcfile); }
// This is used by LoadFromXML function only void LocalPathS(TCHAR *buffer, const TCHAR* file) { SystemPath(buffer, TEXT(LKD_DIALOGS)); TCHAR* ptr = buffer + _tcslen(buffer) -1; if(*ptr != _T('\\')) { _tcscat(buffer, _T(DIRSEP)); } switch(AircraftCategory) { case umGlider: _tcscat(buffer,_T("GLIDER\\")); break; case umParaglider: _tcscat(buffer,_T("PARAGLIDER\\")); break; case umCar: _tcscat(buffer,_T("CAR\\")); break; case umGAaircraft: _tcscat(buffer,_T("GA\\")); break; default: break; } const TCHAR* ptr2 = file; while( (*ptr2) == _T('\\') && (*ptr2) ) { ++ptr2; } _tcscat(buffer,ptr2); lk::filesystem::fixPath(buffer); }
void GetSysPolitStarSystem(const StarSystem *s, const fixed human_infestedness, SysPolit &outSysPolit) { SystemPath path = s->GetPath(); const Uint32 _init[5] = { Uint32(path.sectorX), Uint32(path.sectorY), Uint32(path.sectorZ), path.systemIndex, POLIT_SEED }; Random rand(_init, 5); const Sector* sec = Sector::cache.GetCached(path); GovType a = GOV_INVALID; /* from custom system definition */ if (sec->m_systems[path.systemIndex].customSys) { Polit::GovType t = sec->m_systems[path.systemIndex].customSys->govType; a = t; } if (a == GOV_INVALID) { if (path == SystemPath(0,0,0,0)) { a = Polit::GOV_EARTHDEMOC; } else if (human_infestedness > 0) { // attempt to get the government type from the faction a = s->GetFaction()->PickGovType(rand); // if that fails, either no faction or a faction with no gov types, then pick something at random if (a == GOV_INVALID) { a = static_cast<GovType>(rand.Int32(GOV_RAND_MIN, GOV_RAND_MAX)); } } else { a = GOV_NONE; } } outSysPolit.govType = a; outSysPolit.lawlessness = s_govDesc[a].baseLawlessness * rand.Fixed(); }
bool CheckDataDir() { TCHAR srcdir[MAX_PATH]; TCHAR srcfile[MAX_PATH]; SystemPath(srcdir,_T(LKD_SYSTEM)); _stprintf(srcfile,TEXT("%s%s_SYSTEM"),srcdir, _T(DIRSEP)); return lk::filesystem::exist(srcfile); }
SystemPath SystemPath::Parse(const char * const str) { assert(str); // syspath = '('? [+-]? [0-9]+ [, +-] [0-9]+ [, +-] [0-9]+ ')'? // with whitespace allowed between tokens const char *s = str; int x, y, z; while (isspace(*s)) { ++s; } if (*s == '(') { ++s; } x = ParseInt(s); // note: ParseInt (actually, strtol) skips leading whitespace itself while (isspace(*s)) { ++s; } if (*s == ',' || *s == '.') { ++s; } y = ParseInt(s); while (isspace(*s)) { ++s; } if (*s == ',' || *s == '.') { ++s; } z = ParseInt(s); while (isspace(*s)) { ++s; } if (*s == ')') { ++s; } while (isspace(*s)) { ++s; } if (*s) // extra unexpected text after the system path throw SystemPath::ParseFailure(); else return SystemPath(x, y, z); }
void Game::CreatePlayer() { // XXX this should probably be in lua somewhere // XXX no really, it should. per system hacks? oh my. SystemPath startPath = m_space->GetStarSystem()->GetPath(); if (startPath.IsSameSystem(SystemPath(-2,1,90,0))) { // Lave m_player.Reset(new Player("cobra3")); m_player->m_equipment.Set(Equip::SLOT_ENGINE, 0, Equip::DRIVE_CLASS3); m_player->m_equipment.Set(Equip::SLOT_LASER, 0, Equip::PULSECANNON_1MW); m_player->m_equipment.Add(Equip::HYDROGEN, 2); m_player->m_equipment.Add(Equip::MISSILE_GUIDED); m_player->m_equipment.Add(Equip::MISSILE_GUIDED); m_player->m_equipment.Add(Equip::SCANNER); } else { m_player.Reset(new Player("eagle_lrf")); m_player->m_equipment.Set(Equip::SLOT_ENGINE, 0, Equip::DRIVE_CLASS1); m_player->m_equipment.Set(Equip::SLOT_LASER, 0, Equip::PULSECANNON_1MW); m_player->m_equipment.Add(Equip::HYDROGEN, 1); m_player->m_equipment.Add(Equip::ATMOSPHERIC_SHIELDING); m_player->m_equipment.Add(Equip::MISSILE_GUIDED); m_player->m_equipment.Add(Equip::MISSILE_GUIDED); m_player->m_equipment.Add(Equip::AUTOPILOT); m_player->m_equipment.Add(Equip::SCANNER); } m_player->UpdateStats(); m_player->SetMoney(10000); }
void GetSysPolitStarSystem(const StarSystem *s, const fixed human_infestedness, SysPolit &outSysPolit) { SystemPath path = s->GetPath(); const unsigned long _init[5] = { Uint32(path.sectorX), Uint32(path.sectorY), Uint32(path.sectorZ), path.systemIndex, POLIT_SEED }; MTRand rand(_init, 5); Sector sec(path.sectorX, path.sectorY, path.sectorZ); GovType a = GOV_INVALID; /* from custom system definition */ if (sec.m_systems[path.systemIndex].customSys) { Polit::GovType t = sec.m_systems[path.systemIndex].customSys->govType; a = t; } if (a == GOV_INVALID) { if (path == SystemPath(0,0,0,0)) { a = Polit::GOV_EARTHDEMOC; } else if (human_infestedness > 0) { a = static_cast<GovType>(rand.Int32(GOV_RAND_MIN, GOV_RAND_MAX)); } else { a = GOV_NONE; } } outSysPolit.govType = a; outSysPolit.lawlessness = s_govDesc[a].baseLawlessness * rand.Fixed(); }
void SectorPersistenceGenerator::SetExplored(Sector::System* sys, StarSystem::ExplorationState e, double time) { Sint32 date; if (e != StarSystem::eUNEXPLORED) { int year, month, day; Time::DateTime dt = Time::DateTime(3200,1,1,0,0,0) + Time::TimeDelta(time, Time::Second); dt.GetDateParts(&year, &month, &day); date = day | month << 5 | year << 9; } m_exploredSystems.Set(SystemPath(sys->sx, sys->sy, sys->sz, sys->idx), (e == StarSystem::eUNEXPLORED) ? -1 : date); }
const SystemPath CustomSystem::GetPathForCustomSystem(const CustomSystem* cs) { const std::list<const CustomSystem*> cslist = GetCustomSystemsForSector(cs->sectorX, cs->sectorY, cs->sectorZ); int idx = 0; for (std::list<const CustomSystem*>::const_iterator i = cslist.begin(); i != cslist.end(); ++i) { if (!(*i)->name.compare(cs->name)) break; idx++; } assert(idx < static_cast<int>(cslist.size())); return SystemPath(cs->sectorX, cs->sectorY, cs->sectorZ, idx); }
void Galaxy::Dump(FILE* file, Sint32 centerX, Sint32 centerY, Sint32 centerZ, Sint32 radius) { for (Sint32 sx = centerX - radius; sx <= centerX + radius; ++sx) { for (Sint32 sy = centerY - radius; sy <= centerY + radius; ++sy) { for (Sint32 sz = centerZ - radius; sz <= centerZ + radius; ++sz) { RefCountedPtr<const Sector> sector = Pi::GetGalaxy()->GetSector(SystemPath(sx, sy, sz)); sector->Dump(file); } m_starSystemAttic.ClearCache(); } } }
bool CheckFilesystemWritable() { TCHAR srcdir[MAX_PATH]; TCHAR srcfile[MAX_PATH]; SystemPath(srcdir, _T(LKD_SYSTEM)); _stprintf(srcfile,TEXT("%s%sEmptyTest.txt"),srcdir, _T(DIRSEP)); FILE *stream; stream=_tfopen(srcfile,_T("a")); if (stream==NULL) return false; bool success = fprintf(stream,"FILESYSTEM WRITE CHECK, THIS FILE CAN BE REMOVED ANY TIME\n") >= 0; success &= fclose(stream) == 0; return(success); }
// return true if loaded file, false if not loaded bool LoadChecklist(short checklistmode) { TCHAR filename[MAX_PATH]; switch(checklistmode) { // notepad case 0: LocalPath(filename, TEXT(LKD_CONF)); _tcscat(filename,_T(DIRSEP)); _tcscat(filename,_T(LKF_CHECKLIST)); _stprintf(NoteModeTitle,_T("%s"),gettext(_T("_@M878_"))); // notepad #ifdef __linux__ return LoadUtfChecklist(filename); #else return LoadAsciiChecklist(filename); #endif // logbook TXT case 1: LocalPath(filename, TEXT(LKD_LOGS)); _tcscat(filename,_T(DIRSEP)); _tcscat(filename,_T(LKF_LOGBOOKTXT)); _stprintf(NoteModeTitle,_T("%s"),gettext(_T("_@M1748_"))); // logbook return LoadUtfChecklist(filename); // logbook LST case 2: LocalPath(filename, TEXT(LKD_LOGS)); _tcscat(filename,_T(DIRSEP)); _tcscat(filename,_T(LKF_LOGBOOKLST)); _stprintf(NoteModeTitle,_T("%s"),gettext(_T("_@M1748_"))); // logbook return LoadUtfChecklist(filename); break; case 3: SystemPath(filename, TEXT(LKD_SYSTEM)); _tcscat(filename,_T(DIRSEP)); _tcscat(filename,_T(LKF_CREDITS)); _stprintf(NoteModeTitle,_T("%s"),gettext(_T("Credits"))); #ifdef __linux__ return LoadUtfChecklist(filename); #else return LoadAsciiChecklist(filename); #endif break; default: StartupStore(_T("... Invalid checklist mode (%d)%s"),checklistmode,NEWLINE); return false; } }
bool SectorPersistenceGenerator::Apply(Random& rng, RefCountedPtr<Galaxy> galaxy, RefCountedPtr<Sector> sector, GalaxyGenerator::SectorConfig* config) { if (galaxy->IsInitialized()) { for (Sector::System& secsys : sector->m_systems) { Sint32 exploredTime = m_exploredSystems.Get(SystemPath(secsys.sx, secsys.sy, secsys.sz, secsys.idx), -1); if (exploredTime == 0) { secsys.m_explored = StarSystem::eEXPLORED_AT_START; secsys.m_exploredTime = 0.0; } else if (exploredTime > 0) { int year = exploredTime >> 9; int month = (exploredTime >> 5) & 0xf; int day = exploredTime & 0x1f; Time::DateTime dt(year, month, day); secsys.m_explored = StarSystem::eEXPLORED_BY_PLAYER; secsys.m_exploredTime = dt.ToGameTime(); } } }
SystemPath Entity::getSystemPath() const { System* aSystem( getSuperSystem() ); if ( !aSystem ) { THROW_EXCEPTION( IllegalOperation, "no system is associated" ); } if ( aSystem == this ) { return SystemPath(); } SystemPath aSystemPath( aSystem->getSystemPath() ); aSystemPath.push_back( aSystem->getID() ); return aSystemPath; }
// return true if loaded file, false if not loaded bool LoadChecklist(short checklistmode) { TCHAR filename[MAX_PATH]; switch(checklistmode) { // notepad case 0: LocalPath(filename, TEXT(LKD_CONF)); _tcscat(filename,_T(DIRSEP)); _tcscat(filename,_T(LKF_CHECKLIST)); _stprintf(NoteModeTitle,_T("%s"),MsgToken(878)); // notepad if (LoadUtfChecklist(filename,false)) return true; // if no user file, look for demo file LocalPath(filename, TEXT(LKD_CONF)); _tcscat(filename,_T(DIRSEP)); _tcscat(filename,_T(LKF_CHECKLISTDEMO)); return LoadUtfChecklist(filename,true); // logbook TXT case 1: LocalPath(filename, TEXT(LKD_LOGS)); _tcscat(filename,_T(DIRSEP)); _tcscat(filename,_T(LKF_LOGBOOKTXT)); _stprintf(NoteModeTitle,_T("%s"),MsgToken(1748)); // logbook return LoadUtfChecklist(filename,true); // logbook LST case 2: LocalPath(filename, TEXT(LKD_LOGS)); _tcscat(filename,_T(DIRSEP)); _tcscat(filename,_T(LKF_LOGBOOKLST)); _stprintf(NoteModeTitle,_T("%s"),MsgToken(1748)); // logbook return LoadUtfChecklist(filename,true); break; case 3: SystemPath(filename, TEXT(LKD_SYSTEM)); _tcscat(filename,_T(DIRSEP)); _tcscat(filename,_T(LKF_CREDITS)); _stprintf(NoteModeTitle,_T("%s"),gettext(_T("Credits"))); return LoadUtfChecklist(filename,true); break; default: StartupStore(_T("... Invalid checklist mode (%d)%s"),checklistmode,NEWLINE); return false; } }
void FullID::parse( String const& fullidstring ) { // empty FullID string is invalid if( fullidstring == "" ) { THROW_EXCEPTION( BadID, "empty FullID string" ); } String aString( fullidstring ); eraseWhiteSpaces( aString ); // ignore leading white spaces String::size_type aFieldStart( 0 ); String::size_type aFieldEnd( aString.find_first_of( DELIMITER, aFieldStart ) ); if( aFieldEnd == String::npos ) { THROW_EXCEPTION( BadID, "no ':' in the FullID string [" + aString + "]" ); } String aTypeString( aString.substr( aFieldStart, aFieldEnd - aFieldStart ) ); theEntityType = EntityType( aTypeString ); aFieldStart = aFieldEnd + 1; aFieldEnd = aString.find_first_of( DELIMITER, aFieldStart ); if( aFieldEnd == String::npos ) { THROW_EXCEPTION( BadID, "only one ':' in the FullID string [" + aString + "]" ); } theSystemPath = SystemPath( aString.substr( aFieldStart, aFieldEnd - aFieldStart ) ); aFieldStart = aFieldEnd + 1; // drop trailing string after extra ':'(if this is FullPN), // or go to the end aFieldEnd = aString.find_first_of( DELIMITER, aFieldStart ); theID = aString.substr( aFieldStart, aFieldEnd - aFieldStart ); }
static int l_csys_add_to_sector(lua_State *L) { CustomSystem **csptr = l_csys_check_ptr(L, 1); int x = luaL_checkinteger(L, 2); int y = luaL_checkinteger(L, 3); int z = luaL_checkinteger(L, 4); const vector3d *v = LuaVector::CheckFromLua(L, 5); (*csptr)->sectorX = x; (*csptr)->sectorY = y; (*csptr)->sectorZ = z; (*csptr)->pos = vector3f(*v); //printf("l_csys_add_to_sector: %s added to %d, %d, %d\n", (*csptr)->name.c_str(), x, y, z); s_sectorMap[SystemPath(x, y, z)].push_back(*csptr); *csptr = 0; return 0; }
static int l_csys_add_to_sector(lua_State *L) { CustomSystem **csptr = l_csys_check_ptr(L, 1); int x = luaL_checkinteger(L, 2); int y = luaL_checkinteger(L, 3); int z = luaL_checkinteger(L, 4); const vector3d *v = LuaVector::CheckFromLua(L, 5); (*csptr)->sectorX = x; (*csptr)->sectorY = y; (*csptr)->sectorZ = z; (*csptr)->pos = vector3f(*v); //Output("l_csys_add_to_sector: %s added to %d, %d, %d\n", (*csptr)->name.c_str(), x, y, z); s_activeCustomSystemsDatabase->AddCustomSystem(SystemPath(x, y, z), *csptr); *csptr = 0; return 0; }
SoundGlobalInit::SoundGlobalInit() { // Consider using BogoMips to decide the buffer chunk size, shortest is fastest if( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 1, 1024 ) != -1 ) { bSoundInit = true; } else { StartupStore(_T("ERROR Failed to initialize Audio Mixer <%s>%s"),Mix_GetError(),NEWLINE); StartupStore(_T("------ LK8000 SOUNDS NOT WORKING!%s"),NEWLINE); } if(bSoundInit) { TCHAR srcfile[MAX_PATH]; SystemPath(szSoundPath,TEXT(LKD_SOUNDS)); _stprintf(srcfile,TEXT("%s%s_SOUNDS"), szSoundPath, _T(DIRSEP)); if ( lk::filesystem::exist(srcfile) ) { bSoundFile = true; } else { StartupStore(_T("ERROR NO SOUNDS DIRECTORY CHECKFILE <%s>%s"),srcfile,NEWLINE); StartupStore(_T("------ LK8000 SOUNDS NOT WORKING!%s"),NEWLINE); } } }
const std::string SectorRandomSystemsGenerator::GenName(RefCountedPtr<Galaxy> galaxy, const Sector& sec, Sector::System &sys, int si, Random &rng) { std::string name; const int sx = sec.sx; const int sy = sec.sy; const int sz = sec.sz; const int dist = std::max(std::max(abs(sx),abs(sy)),abs(sz)); int chance = 100; switch (sys.m_starType[0]) { case SystemBody::TYPE_STAR_O: case SystemBody::TYPE_STAR_B: break; case SystemBody::TYPE_STAR_A: chance += dist; break; case SystemBody::TYPE_STAR_F: chance += 2*dist; break; case SystemBody::TYPE_STAR_G: chance += 4*dist; break; case SystemBody::TYPE_STAR_K: chance += 8*dist; break; case SystemBody::TYPE_STAR_O_GIANT: case SystemBody::TYPE_STAR_B_GIANT: chance = 50; break; case SystemBody::TYPE_STAR_A_GIANT: chance = int(0.2*dist); break; case SystemBody::TYPE_STAR_F_GIANT: chance = int(0.4*dist); break; case SystemBody::TYPE_STAR_G_GIANT: chance = int(0.5*dist); break; case SystemBody::TYPE_STAR_K_GIANT: case SystemBody::TYPE_STAR_M_GIANT: chance = dist; break; case SystemBody::TYPE_STAR_O_SUPER_GIANT: case SystemBody::TYPE_STAR_B_SUPER_GIANT: chance = 10; break; case SystemBody::TYPE_STAR_A_SUPER_GIANT: case SystemBody::TYPE_STAR_F_SUPER_GIANT: case SystemBody::TYPE_STAR_G_SUPER_GIANT: case SystemBody::TYPE_STAR_K_SUPER_GIANT: chance = 15; break; case SystemBody::TYPE_STAR_M_SUPER_GIANT: chance = 20; break; case SystemBody::TYPE_STAR_O_HYPER_GIANT: case SystemBody::TYPE_STAR_B_HYPER_GIANT: case SystemBody::TYPE_STAR_A_HYPER_GIANT: case SystemBody::TYPE_STAR_F_HYPER_GIANT: case SystemBody::TYPE_STAR_G_HYPER_GIANT: case SystemBody::TYPE_STAR_K_HYPER_GIANT: case SystemBody::TYPE_STAR_M_HYPER_GIANT: chance = 1; break; //Should give a nice name almost all the time default: chance += 16*dist; break; } Uint32 weight = rng.Int32(chance); if (weight < 500 || galaxy->GetFactions()->IsHomeSystem(SystemPath(sx, sy, sz, si))) { /* well done. you get a real name */ int len = rng.Int32(2,3); for (int i=0; i<len; i++) { name += sys_names[rng.Int32(0,SYS_NAME_FRAGS-1)]; } name[0] = toupper(name[0]); return name; } else if (weight < 800) { char buf[128]; snprintf(buf, sizeof(buf), "MJBN %d%+d%+d", rng.Int32(10,999),sx,sy); // MJBN -> Morton Jordan Bennett Norris return buf; } else if (weight < 1200) { char buf[128]; snprintf(buf, sizeof(buf), "SC %d%+d%+d", rng.Int32(1000,9999),sx,sy); return buf; } else { char buf[128]; snprintf(buf, sizeof(buf), "DSC %d%+d%+d", rng.Int32(1000,9999),sx,sy); return buf; } }
bool SectorCustomSystemsGenerator::Apply(Random& rng, RefCountedPtr<Galaxy> galaxy, RefCountedPtr<Sector> sector, GalaxyGenerator::SectorConfig* config) { const int sx = sector->sx; const int sy = sector->sy; const int sz = sector->sz; const Sint64 dist = (1 + sx*sx + sy*sy + sz*sz); if ((sx >= -m_customOnlyRadius) && (sx <= m_customOnlyRadius-1) && (sy >= -m_customOnlyRadius) && (sy <= m_customOnlyRadius-1) && (sz >= -m_customOnlyRadius) && (sz <= m_customOnlyRadius-1)) config->isCustomOnly = true; const std::vector<const CustomSystem*> &systems = galaxy->GetCustomSystems()->GetCustomSystemsForSector(sx, sy, sz); if (systems.size() == 0) return true; Uint32 sysIdx = 0; for (std::vector<const CustomSystem*>::const_iterator it = systems.begin(); it != systems.end(); ++it, ++sysIdx) { const CustomSystem *cs = *it; Sector::System s(sector.Get(), sx, sy, sz, sysIdx); s.m_pos = Sector::SIZE*cs->pos; s.m_name = cs->name; s.m_other_names = cs->other_names; for (s.m_numStars=0; s.m_numStars<cs->numStars; s.m_numStars++) { if (cs->primaryType[s.m_numStars] == 0) break; s.m_starType[s.m_numStars] = cs->primaryType[s.m_numStars]; } s.m_customSys = cs; s.m_seed = cs->seed; if (cs->want_rand_explored) { /* * 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, sysIdx))) s.m_explored = StarSystem::eEXPLORED_AT_START; else s.m_explored = StarSystem::eUNEXPLORED; } else { if (cs->explored) s.m_explored = StarSystem::eEXPLORED_AT_START; else s.m_explored = StarSystem::eUNEXPLORED; } sector->m_systems.push_back(s); } return true; }
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; }
/* * Method: GetNearbySystems * * Get a list of nearby <StarSystems> that match some criteria * * > systems = system:GetNearbySystems(range, filter) * * Parameters: * * range - distance from this system to search, in light years * * filter - an optional function. If specified the function will be called * once for each candidate system with the <StarSystem> object * passed as the only parameter. If the filter function returns * true then the system will be included in the array returned by * <GetNearbySystems>, otherwise it will be omitted. If no filter * function is specified then all systems in range are returned. * * Return: * * systems - an array of systems in range that matched the filter * * Availability: * * alpha 10 * * Status: * * experimental */ static int l_starsystem_get_nearby_systems(lua_State *l) { PROFILE_SCOPED() LUA_DEBUG_START(l); const StarSystem *s = LuaObject<StarSystem>::CheckFromLua(1); const double dist_ly = luaL_checknumber(l, 2); bool filter = false; if (lua_gettop(l) >= 3) { luaL_checktype(l, 3, LUA_TFUNCTION); // any type of function filter = true; } lua_newtable(l); const SystemPath &here = s->GetPath(); const int here_x = here.sectorX; const int here_y = here.sectorY; const int here_z = here.sectorZ; const Uint32 here_idx = here.systemIndex; RefCountedPtr<const Sector> here_sec = Pi::GetGalaxy()->GetSector(here); const int diff_sec = int(ceil(dist_ly/Sector::SIZE)); for (int x = here_x-diff_sec; x <= here_x+diff_sec; x++) { for (int y = here_y-diff_sec; y <= here_y+diff_sec; y++) { for (int z = here_z-diff_sec; z <= here_z+diff_sec; z++) { RefCountedPtr<const Sector> sec = Pi::GetGalaxy()->GetSector(SystemPath(x, y, z)); for (unsigned int idx = 0; idx < sec->m_systems.size(); idx++) { if (x == here_x && y == here_y && z == here_z && idx == here_idx) continue; if (Sector::DistanceBetween(here_sec, here_idx, sec, idx) > dist_ly) continue; RefCountedPtr<StarSystem> sys = Pi::GetGalaxy()->GetStarSystem(SystemPath(x, y, z, idx)); if (filter) { lua_pushvalue(l, 3); LuaObject<StarSystem>::PushToLua(sys.Get()); lua_call(l, 1, 1); if (!lua_toboolean(l, -1)) { lua_pop(l, 1); continue; } lua_pop(l, 1); } lua_pushinteger(l, lua_rawlen(l, -1)+1); LuaObject<StarSystem>::PushToLua(sys.Get()); lua_rawset(l, -3); } } } } LUA_DEBUG_END(l, 1); return 1; }
void SystemInfoView::SystemChanged(const SystemPath &path) { DeleteAllChildren(); m_tabs = 0; m_bodyIcons.clear(); if (!path.HasValidSystem()) return; m_system = StarSystemCache::GetCached(path); m_sbodyInfoTab = new Gui::Fixed(float(Gui::Screen::GetWidth()), float(Gui::Screen::GetHeight()-100)); if (m_system->GetUnexplored()) { Add(m_sbodyInfoTab, 0, 0); std::string _info = Lang::UNEXPLORED_SYSTEM_STAR_INFO_ONLY; Gui::Label *l = (new Gui::Label(_info))->Color(255,255,0); m_sbodyInfoTab->Add(l, 35, 300); m_selectedBodyPath = SystemPath(); ShowAll(); return; } m_econInfoTab = new Gui::Fixed(float(Gui::Screen::GetWidth()), float(Gui::Screen::GetHeight()-100)); Gui::Fixed *demographicsTab = new Gui::Fixed(); m_tabs = new Gui::Tabbed(); m_tabs->AddPage(new Gui::Label(Lang::PLANETARY_INFO), m_sbodyInfoTab); m_tabs->AddPage(new Gui::Label(Lang::ECONOMIC_INFO), m_econInfoTab); m_tabs->AddPage(new Gui::Label(Lang::DEMOGRAPHICS), demographicsTab); Add(m_tabs, 0, 0); m_sbodyInfoTab->onMouseButtonEvent.connect(sigc::mem_fun(this, &SystemInfoView::OnClickBackground)); int majorBodies, starports, onSurface; { float pos[2] = { 0, 0 }; float psize = -1; majorBodies = starports = onSurface = 0; PutBodies(m_system->GetRootBody().Get(), m_econInfoTab, 1, pos, majorBodies, starports, onSurface, psize); majorBodies = starports = onSurface = 0; pos[0] = pos[1] = 0; psize = -1; PutBodies(m_system->GetRootBody().Get(), m_sbodyInfoTab, 1, pos, majorBodies, starports, onSurface, psize); majorBodies = starports = onSurface = 0; pos[0] = pos[1] = 0; psize = -1; PutBodies(m_system->GetRootBody().Get(), demographicsTab, 1, pos, majorBodies, starports, onSurface, psize); } std::string _info = stringf( Lang::STABLE_SYSTEM_WITH_N_MAJOR_BODIES_STARPORTS, formatarg("bodycount", majorBodies), formatarg("body(s)", std::string(majorBodies == 1 ? Lang::BODY : Lang::BODIES)), formatarg("portcount", starports), formatarg("starport(s)", std::string(starports == 1 ? Lang::STARPORT : Lang::COUNT_STARPORTS))); if (starports > 0) _info += stringf(Lang::COUNT_ON_SURFACE, formatarg("surfacecount", onSurface)); _info += ".\n\n"; _info += m_system->GetLongDescription(); { // astronomical body info tab m_infoBox = new Gui::VBox(); Gui::HBox *scrollBox = new Gui::HBox(); scrollBox->SetSpacing(5); m_sbodyInfoTab->Add(scrollBox, 35, 250); Gui::VScrollBar *scroll = new Gui::VScrollBar(); Gui::VScrollPortal *portal = new Gui::VScrollPortal(730); scroll->SetAdjustment(&portal->vscrollAdjust); Gui::Label *l = (new Gui::Label(_info))->Color(255,255,0); m_infoBox->PackStart(l); portal->Add(m_infoBox); scrollBox->PackStart(scroll); scrollBox->PackStart(portal); } { // economy tab Gui::HBox *scrollBox2 = new Gui::HBox(); scrollBox2->SetSpacing(5); m_econInfoTab->Add(scrollBox2, 35, 300); Gui::VScrollBar *scroll2 = new Gui::VScrollBar(); Gui::VScrollPortal *portal2 = new Gui::VScrollPortal(730); scroll2->SetAdjustment(&portal2->vscrollAdjust); scrollBox2->PackStart(scroll2); scrollBox2->PackStart(portal2); m_econInfo = new Gui::Label(""); m_econInfoTab->Add(m_econInfo, 35, 250); Gui::Fixed *f = new Gui::Fixed(); m_econMajImport = new Gui::Label(""); m_econMinImport = new Gui::Label(""); m_econMajExport = new Gui::Label(""); m_econMinExport = new Gui::Label(""); m_econIllegal = new Gui::Label(""); m_econMajImport->Color(255,255,0); m_econMinImport->Color(255,255,0); m_econMajExport->Color(255,255,0); m_econMinExport->Color(255,255,0); m_econIllegal->Color(255,255,0); f->Add(m_econMajImport, 0, 0); f->Add(m_econMinImport, 150, 0); f->Add(m_econMajExport, 300, 0); f->Add(m_econMinExport, 450, 0); f->Add(m_econIllegal, 600, 0); portal2->Add(f); UpdateEconomyTab(); } { Gui::Fixed *col1 = new Gui::Fixed(); demographicsTab->Add(col1, 200, 300); Gui::Fixed *col2 = new Gui::Fixed(); demographicsTab->Add(col2, 400, 300); const float YSEP = Gui::Screen::GetFontHeight() * 1.2f; col1->Add((new Gui::Label(Lang::SYSTEM_TYPE))->Color(255,255,0), 0, 0); col2->Add(new Gui::Label(m_system->GetShortDescription()), 0, 0); col1->Add((new Gui::Label(Lang::GOVERNMENT_TYPE))->Color(255,255,0), 0, 2*YSEP); col2->Add(new Gui::Label(m_system->GetSysPolit().GetGovernmentDesc()), 0, 2*YSEP); col1->Add((new Gui::Label(Lang::ECONOMY_TYPE))->Color(255,255,0), 0, 3*YSEP); col2->Add(new Gui::Label(m_system->GetSysPolit().GetEconomicDesc()), 0, 3*YSEP); col1->Add((new Gui::Label(Lang::ALLEGIANCE))->Color(255,255,0), 0, 4*YSEP); col2->Add(new Gui::Label(m_system->GetFaction()->name.c_str()), 0, 4*YSEP); col1->Add((new Gui::Label(Lang::POPULATION))->Color(255,255,0), 0, 5*YSEP); std::string popmsg; fixed pop = m_system->GetTotalPop(); if (pop >= fixed(1,1)) { popmsg = stringf(Lang::OVER_N_BILLION, formatarg("population", pop.ToInt32())); } else if (pop >= fixed(1,1000)) { popmsg = stringf(Lang::OVER_N_MILLION, formatarg("population", (pop*1000).ToInt32())); } else if (pop != fixed(0)) { popmsg = Lang::A_FEW_THOUSAND; } else { popmsg = Lang::NO_REGISTERED_INHABITANTS; } col2->Add(new Gui::Label(popmsg), 0, 5*YSEP); col1->Add((new Gui::Label(Lang::SECTOR_COORDINATES))->Color(255,255,0), 0, 6*YSEP); col2->Add(new Gui::Label(stringf("%0{d}, %1{d}, %2{d}", path.sectorX, path.sectorY, path.sectorZ)), 0, 6*YSEP); col1->Add((new Gui::Label(Lang::SYSTEM_NUMBER))->Color(255,255,0), 0, 7*YSEP); col2->Add(new Gui::Label(stringf("%0", path.systemIndex)), 0, 7*YSEP); } UpdateIconSelections(); ShowAll(); }
// This will NOT be called from PC versions short InstallSystem() { TCHAR srcdir[MAX_PATH]; TCHAR srcfile[MAX_PATH]; #ifdef WIN32 TCHAR dstdir[MAX_PATH]; TCHAR maindir[MAX_PATH]; TCHAR dstfile[MAX_PATH]; TCHAR tbuf[MAX_PATH*3]; dstdir[0]='\0'; #endif bool failure=false; #if TESTBENCH StartupStore(_T(". Welcome to InstallSystem v1.2%s"),NEWLINE); #endif SystemPath(srcdir,TEXT(LKD_SYSTEM)); // We now test for a single file existing inside the directory, called _DIRECTORYNAME // because GetFileAttributes can be very slow or hang if checking a directory. In any case testing a file is // much more faster. _stprintf(srcfile,TEXT("%s%s_SYSTEM"),srcdir, _T(DIRSEP)); if ( !lk::filesystem::exist(srcfile) ) { StartupStore(_T("------ InstallSystem ERROR could not find valid system directory <%s>%s"),srcdir,NEWLINE); // 091104 StartupStore(_T("------ Missing checkfile <%s>%s"),srcfile,NEWLINE); failure=true; } else { #if TESTBENCH StartupStore(_T(". InstallSystem source directory <%s> is available%s"),srcdir,NEWLINE); #endif } if ( failure ) { StartupStore(_T("------ WARNING: NO font will be installed on device (and thus wrong text size displayed)%s"),NEWLINE); return 5; // 091109 } else { #if defined(PNA) && defined(UNDER_CE) if (GlobalModelType == MODELTYPE_PNA_HP31X) { // 091109 StartupStore(_T(". InstallSystem checking desktop links for HP31X%s"),NEWLINE); _stprintf(dstdir,TEXT("\\Windows\\Desktop")); if ( !lk::filesystem::isDirectory(dstdir) ) { // FIX StartupStore(_T("------ Desktop directory <%s> NOT found! Is this REALLY an HP31X?%s"),dstdir,NEWLINE); } else { _stprintf(srcfile,TEXT("%s\\LK8_HP310.lnk"),srcdir); _stprintf(dstfile,TEXT("%s\\LK8000.lnk"),dstdir); if ( lk::filesystem::exist(dstfile) ) { StartupStore(_T(". Link to LK8000 already found on the desktop, ok.%s"),NEWLINE); } else { StartupStore(_T(". Installing <%s>%s"),srcfile,NEWLINE); if (!lk::filesystem::copyFile(srcfile,dstfile,true)) { StartupStore(_T("------ Could not install in <%s>. Strange.%s"),dstfile,NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T(". Installed <%s> link.%s"),dstfile,NEWLINE); } #if 0 _stprintf(srcfile,TEXT("%s\\LK8SIM_HP310.lnk"),srcdir); _stprintf(dstfile,TEXT("%s\\SIM.lnk"),dstdir); if ( lk::filesystem::exist(dstfile) ) { StartupStore(_T(". Link to SIM LK8000 already found on the desktop, ok.%s"),NEWLINE); } else { StartupStore(_T(". Installing <%s>%s"),srcfile,NEWLINE); if (!lk::filesystem::copyFile(srcfile,dstfile,true)) { StartupStore(_T("------ Could not install in <%s>. Strange.%s"),dstfile,NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T(". Installed <%s> link.%s"),dstfile,NEWLINE); } #endif _stprintf(srcfile,TEXT("%s\\BT_HP310.lnk"),srcdir); _stprintf(dstfile,TEXT("%s\\BlueTooth.lnk"),dstdir); if ( lk::filesystem::exist(dstfile) ) { StartupStore(_T(". Link to BlueTooth already found on the desktop, ok.%s"),NEWLINE); } else { StartupStore(_T(". Installing <%s>%s"),srcfile,NEWLINE); if (!lk::filesystem::copyFile(srcfile,dstfile,true)) { StartupStore(_T("------ Could not install in <%s>. Strange.%s"),dstfile,NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T(". Installed <%s> link.%s"),dstfile,NEWLINE); } _stprintf(srcfile,TEXT("%s\\NAV_HP310.lnk"),srcdir); _stprintf(dstfile,TEXT("%s\\CarNav.lnk"),dstdir); if ( lk::filesystem::exist(dstfile) ) { StartupStore(_T(". Link to Car Navigator already found on the desktop, ok.%s"),NEWLINE); } else { StartupStore(_T(". Installing <%s>%s"),srcfile,NEWLINE); if (!lk::filesystem::copyFile(srcfile,dstfile,true)) { StartupStore(_T("------ Could not install in <%s>. Strange.%s"),dstfile,NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T(". Installed <%s> link.%s"),dstfile,NEWLINE); } _stprintf(srcfile,TEXT("%s\\TLOCK_HP310.lnk"),srcdir); _stprintf(dstfile,TEXT("%s\\TouchLock.lnk"),dstdir); if ( lk::filesystem::exist(dstfile) ) { StartupStore(_T(". Link to TouchLock already found on the desktop, ok.%s"),NEWLINE); } else { StartupStore(_T(". Installing <%s>%s"),srcfile,NEWLINE); if (!lk::filesystem::copyFile(srcfile,dstfile,true)) { StartupStore(_T("------ Could not install in <%s>. Strange.%s"),dstfile,NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T(". Installed <%s> link.%s"),dstfile,NEWLINE); } } } #endif } #ifdef WIN32 // search for the main system directory on the real device // Remember that SHGetSpecialFolder works differently on CE platforms, and you cannot check for result. // We need to verify if directory does really exist. // SHGetSpecialFolderPath(MainWindow, dstdir, CSIDL_WINDOWS, false); if ( _tcslen(dstdir) <6) { _stprintf(tbuf,_T("------ InstallSystem PROBLEM: cannot locate the Windows folder, got string:<%s>%s"),dstdir,NEWLINE); StartupStore(tbuf); StartupStore(_T("------ InstallSystem attempting to use default \"\\Windows\" but no warranty!%s"),NEWLINE); _stprintf(dstdir,TEXT("\\Windows")); // 091118 } else { StartupStore(_T(". InstallSystem: Windows path reported from device is: <%s>%s"),dstdir,NEWLINE); } _tcscpy(maindir,dstdir); // we are shure that \Windows does exist already. TCHAR fontdir[MAX_PATH]; fontdir[0] = _T('\0'); dstdir[0] = _T('\0'); #ifdef PNA if ( GetFontPath(fontdir) == FALSE ) { StartupStore(_T(". Special RegKey for fonts not found on this PNA, using standard folder.%s"), NEWLINE); // SHGetSpecialFolderPath(MainWindow, dstdir, CSIDL_FONTS, false); if ( _tcslen(dstdir) <5 ) { _stprintf(tbuf,_T("------ PROBLEM: cannot locate the Fonts folder, got string:<%s>%s"),dstdir,NEWLINE); StartupStore(tbuf); _stprintf(tbuf,_T("------ Attempting to use directory <%s> as a fallback%s"),maindir,NEWLINE); StartupStore(tbuf); _tcscpy(dstdir,maindir); } } else { StartupStore(_T(". RegKey Font directory is <%s>%s"),fontdir,NEWLINE); lk::filesystem::createDirectory(fontdir); _tcscpy(dstdir,fontdir); } #else UNUSED(fontdir); // this is not working correctly on PNA, it is reporting Windows Fonts even with another value in regkey SHGetSpecialFolderPath(MainWindow.Handle(), dstdir, CSIDL_FONTS, false); if ( _tcslen(dstdir) <5 ) { _stprintf(tbuf,_T("------ PROBLEM: cannot locate the Fonts folder, got string:<%s>%s"),dstdir,NEWLINE); StartupStore(tbuf); _stprintf(tbuf,_T("------ Attempting to use directory <%s> as a fallback%s"),maindir,NEWLINE); StartupStore(tbuf); _tcscpy(dstdir,maindir); } #endif _stprintf(tbuf,_T(". InstallSystem: Copy/Check Fonts from <%s> to <%s>%s"), srcdir, dstdir,NEWLINE); StartupStore(tbuf); // on PNAs sometimes FolderPath is reported correctly, but the directory is not existing! // this is not needed really on PNA, but doesnt hurt lk::filesystem::createDirectory(dstdir); // 100820 // we cannot check directory existance without the risk of hanging for many seconds // we can only rely on singe real file existance, not on directories #if TESTBENCH StartupStore(_T(". Checking TAHOMA font%s"),NEWLINE); #endif _stprintf(srcfile,TEXT("%s\\TAHOMA.TTF"),srcdir); _stprintf(dstfile,TEXT("%s\\TAHOMA.TTF"),dstdir); if ( lk::filesystem::exist(dstfile) ) { #if TESTBENCH StartupStore(_T(". Font TAHOMA.TTF is already installed%s"),NEWLINE); #endif } else { if ( !lk::filesystem::copyFile(srcfile,dstfile,false) ) { StartupStore(_T("------ Could not copy TAHOMA.TTF on device, not good.%s"),NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T("... Font TAHOMA.TTF installed on device%s"),NEWLINE); } // not needed, cannot overwrite tahoma while in use! Tahoma bold not used for some reason in this case. // Problem solved, look at FontPath !! #if TESTBENCH StartupStore(_T(". Checking TAHOMABD font%s"),NEWLINE); #endif _stprintf(srcfile,TEXT("%s\\TAHOMABD.TTF"),srcdir); _stprintf(dstfile,TEXT("%s\\TAHOMABD.TTF"),dstdir); if ( lk::filesystem::exist(dstfile) ) { #if TESTBENCH StartupStore(_T(". Font TAHOMABD.TTF is already installed%s"),NEWLINE); #endif } else { if ( !lk::filesystem::copyFile(srcfile,dstfile,false)) { StartupStore(_T("------ Could not copy TAHOMABD.TTF on device, not good.%s"),NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T("... Font TAHOMABD.TTF installed on device%s"),NEWLINE); } #endif #if TESTBENCH StartupStore(_T(". InstallSystem completed OK%s"),NEWLINE); #endif return 0; }
Sector::~Sector() { if (m_cache) m_cache->RemoveFromAttic(SystemPath(sx, sy, sz)); }
SystemPath System::getSystemPath() const { return isRootSystem() ? SystemPath(): Entity::getSystemPath(); }