1
0
Fork 0

Make FCS rooms numbering dynamic.

master
Jonathan Naylor 3 years ago
parent f0868dd4ba
commit 1456810fa9

@ -19,6 +19,6 @@
#if !defined(VERSION_H) #if !defined(VERSION_H)
#define VERSION_H #define VERSION_H
const char* VERSION = "20210922"; const char* VERSION = "20211108";
#endif #endif

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016-2020 by Jonathan Naylor G4KLX * Copyright (C) 2016-2021 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -252,13 +252,19 @@ bool CYSFReflectors::load()
} }
} }
unsigned int id = 10U; unsigned int id = 9U;
for (std::vector<std::pair<std::string, std::string>>::const_iterator it = m_fcsRooms.cbegin(); it != m_fcsRooms.cend(); ++it, id++) { for (std::vector<std::pair<std::string, std::string>>::const_iterator it1 = m_fcsRooms.cbegin(); it1 != m_fcsRooms.cend(); ++it1) {
bool used;
do {
id++;
used = findById(id);
} while (used);
char text[10U]; char text[10U];
::sprintf(text, "%05u", id); ::sprintf(text, "%05u", id);
std::string name = it->first; std::string name = it1->first;
std::string desc = it->second; std::string desc = it1->second;
CYSFReflector* refl = new CYSFReflector; CYSFReflector* refl = new CYSFReflector;
refl->m_id = text; refl->m_id = text;
@ -303,6 +309,19 @@ CYSFReflector* CYSFReflectors::findById(const std::string& id)
return NULL; return NULL;
} }
bool CYSFReflectors::findById(unsigned int id) const
{
char text[10U];
::sprintf(text, "%05u", id);
for (std::vector<CYSFReflector*>::const_iterator it = m_newReflectors.cbegin(); it != m_newReflectors.cend(); ++it) {
if (text == (*it)->m_id)
return true;
}
return false;
}
CYSFReflector* CYSFReflectors::findByName(const std::string& name) CYSFReflector* CYSFReflectors::findByName(const std::string& name)
{ {
std::string fullName = name; std::string fullName = name;

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016-2020 by Jonathan Naylor G4KLX * Copyright (C) 2016-2021 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -94,6 +94,8 @@ private:
std::vector<CYSFReflector*> m_search; std::vector<CYSFReflector*> m_search;
bool m_makeUpper; bool m_makeUpper;
CTimer m_timer; CTimer m_timer;
bool findById(unsigned int id) const;
}; };
#endif #endif

Loading…
Cancel
Save