[Gcblue-commits] gcb_wx/src/database tcLauncherDBObject.cpp,1.16,1.17
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-06-25 22:10:47
|
Update of /cvsroot/gcblue/gcb_wx/src/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21991/src/database Modified Files: tcLauncherDBObject.cpp Log Message: Fixed bug with crashing when too many range circles were displayed Index: tcLauncherDBObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcLauncherDBObject.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcLauncherDBObject.cpp 1 Jun 2005 00:13:29 -0000 1.16 --- tcLauncherDBObject.cpp 25 Jun 2005 22:10:34 -0000 1.17 *************** *** 2,6 **** ** @file tcLauncherDBObject.cpp */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** @file tcLauncherDBObject.cpp */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 43,47 **** namespace database { ! /** * workaround for write serialization issue --- 43,111 ---- namespace database { ! /** ! * This can be a substitute for IsItemCompatible by testing != 0 ! * @see IsItemCompatible ! */ ! unsigned short tcLauncherDBObject::GetCapacityForItem(const std::string& item) const ! { ! unsigned nTypes = childClassList.size(); ! for (unsigned k=0; k<nTypes; k++) ! { ! if (item == childClassList[k]) ! { ! wxASSERT(childClassList.size() == childCapacityList.size()); ! return childCapacityList[k]; ! } ! } ! ! return 0; ! } ! ! unsigned short tcLauncherDBObject::GetConfigurationCapacity(unsigned int idx) const ! { ! wxASSERT(idx < childCapacityList.size()); ! return childCapacityList[idx]; ! } ! ! const std::string& tcLauncherDBObject::GetConfigurationClass(unsigned int idx) const ! { ! wxASSERT(idx < childClassList.size()); ! return childClassList[idx]; ! } ! ! unsigned int tcLauncherDBObject::GetNumberConfigurations() const ! { ! return childClassList.size(); ! } ! ! ! unsigned short tcLauncherDBObject::GetDefaultChildCapacity() const ! { ! if (childCapacityList.size() == 0) ! { ! return 0; ! } ! else ! { ! return childCapacityList[0]; ! } ! } ! ! /** ! * @returns first configuration in childClassList as a default, or "" if error ! */ ! const char* tcLauncherDBObject::GetDefaultChildClass() const ! { ! static std::string errorString = ""; ! if (childClassList.size() == 0) ! { ! return errorString.c_str(); ! } ! else ! { ! return childClassList[0].c_str(); ! } ! } ! /** * workaround for write serialization issue *************** *** 60,64 **** tcDatabaseObject::PrintToFile(file); ! s.Format(" child class:%s mnCapacity:%d\n", mzChildClass.mz,mnCapacity); file.WriteString(s.GetBuffer()); } --- 124,129 ---- tcDatabaseObject::PrintToFile(file); ! s.Format(" default child class: %s mnCapacity:%d\n", ! GetDefaultChildClass(), GetDefaultChildCapacity()); file.WriteString(s.GetBuffer()); } *************** *** 66,69 **** --- 131,136 ---- int tcLauncherDBObject::Serialize(tcFile& file, bool mbLoad, UINT32 anVersion) { + wxASSERT(false); // not updated + /* tcDatabaseObject::Serialize(file,mbLoad, anVersion); if (mbLoad) *************** *** 90,93 **** --- 157,161 ---- } } + */ return true; } *************** *** 95,98 **** --- 163,168 ---- int tcLauncherDBObject::SerializeCSV(CsvTranslator *csv, bool mbLoad) { + wxASSERT(false); // not updated + /* tcDatabaseObject::SerializeCSV(csv, mbLoad); if (mbLoad) *************** *** 141,144 **** --- 211,215 ---- csv->WriteLine(); } + */ return 1; } *************** *** 156,168 **** localNode->SetAttribute("cycleTime", cycleTime); - localNode->SetAttribute("capacity", (int)mnCapacity); - localNode->SetAttribute("childClass", mzChildClass.mz); localNode->SetAttribute("fcSensorClass", fireControlSensorClass); ! for(unsigned int i=0;(i<mnConfigurations)&&(i<MAX_LAUNCHER_CONFIGURATIONS);i++) { TiXmlElement* childNode = node->InsertEndChild(TiXmlElement("config"))->ToElement(); ! childNode->SetAttribute("capacity", (int)maCapacity[i]); ! childNode->SetAttribute("childClass", maChildClass[i].mz); } --- 227,237 ---- localNode->SetAttribute("cycleTime", cycleTime); localNode->SetAttribute("fcSensorClass", fireControlSensorClass); ! for(unsigned int i=0;(i<childClassList.size())&&(i<MAX_LAUNCHER_CONFIGURATIONS);i++) { TiXmlElement* childNode = node->InsertEndChild(TiXmlElement("config"))->ToElement(); ! childNode->SetAttribute("capacity", (int)childCapacityList[i]); ! childNode->SetAttribute("childClass", childClassList[i].c_str()); } *************** *** 174,182 **** int tcLauncherDBObject::WriteCSVHeader(database::CsvTranslator *csv) { tcDatabaseObject::WriteCSVHeader(csv); *csv << "Cycle time"; - *csv << "Basic capacity"; - *csv << "Basic class"; *csv << "Fire control sensor class"; --- 243,251 ---- int tcLauncherDBObject::WriteCSVHeader(database::CsvTranslator *csv) { + wxASSERT(false); // not updated + /* tcDatabaseObject::WriteCSVHeader(csv); *csv << "Cycle time"; *csv << "Fire control sensor class"; *************** *** 191,194 **** --- 260,264 ---- csv->WriteLine(); + */ return 1; } *************** *** 206,221 **** columnString += "CycleTime_s number(5),"; columnString += "IsAutoPoint number(1),"; - columnString += "BasicCap number(4),"; - columnString += "BasicClass varchar(30),"; columnString += "FireControlSens varchar(30),"; for(unsigned i=0;i<MAX_LAUNCHER_CONFIGURATIONS;i++) { ! tcString s; ! s.Format("Cap%d number(4),",i+1); columnString += s.GetBuffer(); ! s.Format("Class%d varchar(30)",i+1); columnString += s.GetBuffer(); if (i < MAX_LAUNCHER_CONFIGURATIONS - 1) columnString += ","; } --- 276,290 ---- columnString += "CycleTime_s number(5),"; columnString += "IsAutoPoint number(1),"; columnString += "FireControlSens varchar(30),"; for(unsigned i=0;i<MAX_LAUNCHER_CONFIGURATIONS;i++) { ! tcString s; ! s.Format("Class%d varchar(30),",i+1); columnString += s.GetBuffer(); ! s.Format("Cap%d number(4)",i+1); columnString += s.GetBuffer(); + if (i < MAX_LAUNCHER_CONFIGURATIONS - 1) columnString += ","; } *************** *** 228,249 **** cycleTime = entry.GetDouble("CycleTime_s"); isAutoPoint = entry.GetInt("IsAutoPoint") != 0; - mnCapacity = entry.GetInt("BasicCap"); - mzChildClass = entry.GetString("BasicClass").c_str(); fireControlSensorClass = entry.GetString("FireControlSens"); - mnConfigurations = 0; for (unsigned i=0;i<MAX_LAUNCHER_CONFIGURATIONS;i++) { tcString s; ! ! s.Format("Cap%d", i+1); ! maCapacity[mnConfigurations] = entry.GetInt(s.GetBuffer()); ! s.Format("Class%d", i+1); ! maChildClass[mnConfigurations] = entry.GetString(s.GetBuffer()).c_str(); ! ! if (strlen(maChildClass[mnConfigurations].mz) > 2) { ! mnConfigurations++; } } --- 297,316 ---- cycleTime = entry.GetDouble("CycleTime_s"); isAutoPoint = entry.GetInt("IsAutoPoint") != 0; fireControlSensorClass = entry.GetString("FireControlSens"); for (unsigned i=0;i<MAX_LAUNCHER_CONFIGURATIONS;i++) { tcString s; ! s.Format("Class%d", i+1); ! std::string classString = entry.GetString(s.GetBuffer()); ! ! s.Format("Cap%d", i+1); ! unsigned short capacity = entry.GetInt(s.GetBuffer()); ! ! if (classString.size() > 2) { ! childClassList.push_back(classString); ! childCapacityList.push_back(capacity); } } *************** *** 260,278 **** s << cycleTime << ","; s << isAutoPoint << ","; - s << mnCapacity << ","; - s << "'" << mzChildClass.mz << "',"; s << "'" << fireControlSensorClass << "',"; for(unsigned i=0;i<MAX_LAUNCHER_CONFIGURATIONS;i++) { ! if (i < mnConfigurations) { ! s << (long)maCapacity[i] << ","; ! s << "'" << maChildClass[i].mz << "'"; } else { s << "0,"; - s << "''"; } --- 327,343 ---- s << cycleTime << ","; s << isAutoPoint << ","; s << "'" << fireControlSensorClass << "',"; for(unsigned i=0;i<MAX_LAUNCHER_CONFIGURATIONS;i++) { ! if (i < childClassList.size()) { ! s << "'" << childClassList[i] << "'"; ! s << (long)childCapacityList[i] << ","; } else { + s << "''"; s << "0,"; } *************** *** 287,304 **** cycleTime(0), isAutoPoint(false), ! mnCapacity(0), ! mzChildClass("NOCHILDCLASS"), ! fireControlSensorClass(""), ! mnConfigurations(0) { mzClass = "Default Launcher"; mnClassID = DTYPE_LAUNCHER; - - for(unsigned i=0;i<MAX_LAUNCHER_CONFIGURATIONS;i++) - { - maChildClass[i] = ""; - maCapacity[i] = 0; - } - } --- 352,359 ---- cycleTime(0), isAutoPoint(false), ! fireControlSensorClass("") { mzClass = "Default Launcher"; mnClassID = DTYPE_LAUNCHER; } *************** *** 306,321 **** : tcDatabaseObject(obj), cycleTime(obj.cycleTime), ! mzChildClass(obj.mzChildClass), ! mnCapacity(obj.mnCapacity), ! mnConfigurations(obj.mnConfigurations), fireControlSensorClass(obj.fireControlSensorClass) { mnClassID = DTYPE_LAUNCHER; - - for(unsigned i=0;i<MAX_LAUNCHER_CONFIGURATIONS;i++) - { - maChildClass[i] = obj.maChildClass[i]; - maCapacity[i] = obj.maCapacity[i]; - } } --- 361,369 ---- : tcDatabaseObject(obj), cycleTime(obj.cycleTime), ! childClassList(obj.childClassList), ! childCapacityList(obj.childCapacityList), fireControlSensorClass(obj.fireControlSensorClass) { mnClassID = DTYPE_LAUNCHER; } |