Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21076/src/scriptinterface
Modified Files:
tcPlatformInterface.cpp tcPlatformInterfaceExtensionB.cpp
Log Message:
Magazine class tcStores and related
Index: tcPlatformInterface.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterface.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** tcPlatformInterface.cpp 23 Nov 2004 23:30:57 -0000 1.29
--- tcPlatformInterface.cpp 29 Nov 2004 03:55:05 -0000 1.30
***************
*** 44,47 ****
--- 44,48 ----
#include "tcLauncherState.h"
#include "tcLauncher.h"
+ #include "tcStores.h"
***************
*** 555,558 ****
--- 556,689 ----
}
+
+ /**
+ *
+ */
+ int tcPlatformInterface::GetLauncherTypesCount(int anLauncher)
+ {
+ if (tcLauncher* launcher = mpPlatformObj->GetLauncher(anLauncher))
+ {
+ return (int)launcher->GetCompatibleCount();
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ /**
+ *
+ */
+ std::string tcPlatformInterface::GetLauncherTypeName(int anLauncher, int anType)
+ {
+ if (tcLauncher* launcher = mpPlatformObj->GetLauncher(anLauncher))
+ {
+ return launcher->GetCompatibleName(anType);
+ }
+ else
+ {
+ return std::string("Error");
+ }
+ }
+
+ /**
+ * true if any of the magazines on the platform can accept the item
+ */
+ bool tcPlatformInterface::CanMagazineAcceptItem(std::string item)
+ {
+ unsigned int nMagazines = mpPlatformObj->GetMagazineCount();
+ for (unsigned int n=0; n<nMagazines; n++)
+ {
+ tcStores* mag = mpPlatformObj->GetMagazine(n);
+ if (!mag->IsFull() && mag->IsCompatible(item)) return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ */
+ int tcPlatformInterface::GetMagazineQuantity(std::string item)
+ {
+ int quantity = 0;
+ unsigned int nMagazines = mpPlatformObj->GetMagazineCount();
+ for (unsigned int n=0; n<nMagazines; n++)
+ {
+ tcStores* mag = mpPlatformObj->GetMagazine(n);
+ quantity += mag->CurrentItemQuantity(item);
+ }
+ return quantity;
+ }
+
+ /**
+ *
+ */
+ void tcPlatformInterface::LoadLauncher(int anLauncher, std::string item)
+ {
+ // verify launcher is empty and item is compatible with launcher
+ tcLauncher* launcher = mpPlatformObj->GetLauncher(anLauncher);
+ if (!launcher) return;
+ if (launcher->mnCurrent)
+ {
+ return;
+ }
+
+ bool found = false;
+ int nTypes = (int)launcher->GetCompatibleCount();
+ for (int k=0; (k<nTypes) && !found; k++)
+ {
+ if (launcher->GetCompatibleName(unsigned(k)) == item)
+ {
+ found = true;
+ }
+ }
+ if (!found)
+ {
+ return;
+ }
+
+
+ unsigned int nMagazines = mpPlatformObj->GetMagazineCount();
+ for (unsigned int n=0; n<nMagazines; n++)
+ {
+ tcStores* mag = mpPlatformObj->GetMagazine(n);
+ if (mag->CurrentItemQuantity(item))
+ {
+ mag->LoadLauncher(anLauncher, item);
+ return;
+ }
+ }
+
+ // error not found
+ }
+
+ /**
+ *
+ */
+ void tcPlatformInterface::UnloadLauncher(int anLauncher)
+ {
+ tcLauncher* launcher = mpPlatformObj->GetLauncher(anLauncher);
+ if (!launcher) return;
+ if (!launcher->mpChildDBObj) return;
+
+ std::string item = launcher->mpChildDBObj->mzClass.mz;
+
+ unsigned int nMagazines = mpPlatformObj->GetMagazineCount();
+ for (unsigned int n=0; n<nMagazines; n++)
+ {
+ tcStores* mag = mpPlatformObj->GetMagazine(n);
+ if (!mag->IsFull() && mag->IsCompatible(item))
+ {
+ mag->UnloadLauncher(anLauncher);
+ return;
+ }
+ }
+
+ // error not found
+ }
+
+
+
+
bool tcPlatformInterface::HasOrders()
{
Index: tcPlatformInterfaceExtensionB.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterfaceExtensionB.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** tcPlatformInterfaceExtensionB.cpp 23 Nov 2004 23:30:58 -0000 1.16
--- tcPlatformInterfaceExtensionB.cpp 29 Nov 2004 03:55:05 -0000 1.17
***************
*** 98,101 ****
--- 98,109 ----
.def("GetLauncherInterceptTime", &tcPlatformInterface::GetLauncherInterceptTime)
+ .def("GetLauncherTypesCount", &tcPlatformInterface::GetLauncherTypesCount)
+ .def("GetLauncherTypeName", &tcPlatformInterface::GetLauncherTypeName)
+ .def("CanMagazineAcceptItem", &tcPlatformInterface::CanMagazineAcceptItem)
+ .def("GetMagazineQuantity", &tcPlatformInterface::GetMagazineQuantity)
+ .def("LoadLauncher", &tcPlatformInterface::LoadLauncher)
+ .def("UnloadLauncher", &tcPlatformInterface::UnloadLauncher)
+
+
// orders
.def("AddNavOrder",&tcPlatformInterface::AddNavOrder)
|