void CStarmap::RecalcRangePoints() { //memset(m_AIRangePoints, 0, STARMAP_SECTORS_HCOUNT * STARMAP_SECTORS_VCOUNT * sizeof(short)); for(int i=0;i<STARMAP_SECTORS_HCOUNT;i++) for(int j=0;j<STARMAP_SECTORS_VCOUNT;j++) m_AIRangePoints.at(CoordsToIndex(i, j))=0; // komplette Starmap durchlaufen, Werte aus Effektivitätsgründen nur für Sektoren innerhalb der gegebenen // Reichweite berechnen for (char x = 0; x < STARMAP_SECTORS_HCOUNT; x++) for (char y = 0; y < STARMAP_SECTORS_VCOUNT; y++) if (m_Range.at(CoordsToIndex(x, y)) >= m_nAIRange) { // für Sektoren innerhalb der gegebenen Reichweite Bewertung neu berechnen, die sich ergibt, // wenn hier ein Außenposten gebaut würde m_AIRangePoints.at(CoordsToIndex(x, y)) = 0; // lokale Rangemap durchlaufen for (char mx = -m_RangeMap.x0; mx < m_RangeMap.w - m_RangeMap.x0; mx++) for (char my = -m_RangeMap.y0; my < m_RangeMap.h - m_RangeMap.y0; my++) { Sector mpt(x + mx, y + my); if (mpt.is_in_rect(0, 0, STARMAP_SECTORS_HCOUNT, STARMAP_SECTORS_VCOUNT)) { // Gebietszuwachs ermitteln m_AIRangePoints.at(CoordsToIndex(x, y)) += max(GetRangeMapValue(mx, my) - m_Range.at(CoordsToIndex(mpt.x, mpt.y)), 0); } } } }
bool is_our_file(const char *filename, VFSFile &file) { try { MPTWrap mpt(file); return true; } catch(MPTWrap::InvalidFile) { return false; } }
void CStarmap::RecalcConnectionPoints() { //memset(m_AINeighbourCount, 0, STARMAP_SECTORS_HCOUNT * STARMAP_SECTORS_VCOUNT * sizeof(unsigned char)); for(int i=0;i<STARMAP_SECTORS_HCOUNT;i++) for(int j=0;j<STARMAP_SECTORS_VCOUNT;j++) m_AINeighbourCount.at(CoordsToIndex(i, j))=0; //memset(m_AIConnectionPoints, 0, STARMAP_SECTORS_HCOUNT * STARMAP_SECTORS_VCOUNT * sizeof(short)); for(int i=0;i<STARMAP_SECTORS_HCOUNT;i++) for(int j=0;j<STARMAP_SECTORS_VCOUNT;j++) m_AIConnectionPoints.at(CoordsToIndex(i, j))=0; // für Sektoren, die außerhalb der Reichweite liegen, die Anzahl der Nachbarn innerhalb der Reichweite neu bestimmen for (char x = 0; x < STARMAP_SECTORS_HCOUNT; x++) for (char y = 0; y < STARMAP_SECTORS_VCOUNT; y++) if (m_Range.at(CoordsToIndex(x, y)) >= m_nAIRange) { // Nachbaranzahl für Nachbarsektoren von (x, y), die außerhalb der Reichweite liegen, hochzählen for (int nx = -1; nx <= 1; nx++) for (int ny = -1; ny <= 1; ny++) { Sector npt(x + nx, y + ny); if (npt.is_in_rect(0, 0, STARMAP_SECTORS_HCOUNT, STARMAP_SECTORS_VCOUNT) && m_Range.at(CoordsToIndex(npt.x, npt.y)) < m_nAIRange) { // (npt.x, npt.y) ist jetzt immer != (x, y) m_AINeighbourCount.at(CoordsToIndex(npt.x, npt.y))++; } } } // Bewertungen für Zusammenhang neu berechnen for (char x = 0; x < STARMAP_SECTORS_HCOUNT; x++) for (char y = 0; y < STARMAP_SECTORS_VCOUNT; y++) if (m_Range.at(CoordsToIndex(x, y)) >= m_nAIRange) { // für Sektoren (x, y) innerhalb der Reichweite die lokale Rangemap durchlaufen for (char mx = -m_RangeMap.x0; mx < m_RangeMap.w - m_RangeMap.x0; mx++) for (char my = -m_RangeMap.y0; my < m_RangeMap.h - m_RangeMap.y0; my++) { Sector mpt(x + mx, y + my); if (mpt.is_in_rect(0, 0, STARMAP_SECTORS_HCOUNT, STARMAP_SECTORS_VCOUNT)) { // für die (x, y) umgebenden Sektoren deren Anzahl der Nachbarn innerhalb der Reichweite // verwerten: ist diese Anzahl hoch, befindet sich in der Nähe von (x, y) ein weiteres // Gebiet innerhalb der Reichweite, das mit dem Gebiet von (x, y) nicht "direkt" zusammenhängt m_AIConnectionPoints.at(CoordsToIndex(x, y)) += m_AINeighbourCount.at(CoordsToIndex(mpt.x, mpt.y)) * GetRangeMapValue(mx, my); } } } }
bool read_tag(const char *filename, VFSFile &file, Tuple &tuple, Index<char> *) { try { MPTWrap mpt(file); tuple.set_filename(filename); tuple.set_format(mpt.format().c_str(), mpt.channels(), mpt.rate(), 0); tuple.set_int(Tuple::Length, mpt.duration()); if(!mpt.title().empty()) tuple.set_str(Tuple::Title, mpt.title().c_str()); return true; } catch(MPTWrap::InvalidFile) { return false; } }
bool play(const char *filename, VFSFile &file) { force_apply = true; try { MPTWrap mpt(file); open_audio(FMT_FLOAT, 44100, 2); while(!check_stop()) { unsigned char buffer[65536]; std::int64_t n; int seek_value = check_seek(); if(seek_value >= 0) mpt.seek(seek_value); if(force_apply) { mpt.set_interpolator(aud_get_int(PACKAGE, SETTING_INTERPOLATOR)); mpt.set_stereo_separation(aud_get_int(PACKAGE, SETTING_STEREO_SEPARATION)); force_apply = false; } n = mpt.read(buffer, sizeof buffer); if(n == 0) break; write_audio(buffer, n); } return true; } catch(MPTWrap::InvalidFile) { return false; } }