MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / CanDestroy

Method CanDestroy

engine/Poseidon/UI/Map/UIArcade.cpp:1033–1138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1031}
1032
1033bool DisplayArcadeUnit::CanDestroy()
1034{
1035 if (!Display::CanDestroy())
1036 {
1037 return false;
1038 }
1039
1040 if (_exit == IDC_OK)
1041 {
1042 CEdit* edit = dynamic_cast<CEdit*>(GetCtrl(IDC_ARCUNIT_TEXT));
1043 if (edit)
1044 {
1045 RString text = edit->GetText();
1046 if (text.GetLength() > 0)
1047 {
1048 if (!GWorld->GetGameState()->IdtfGoodName(text))
1049 {
1050 CreateMsgBox(MB_BUTTON_OK, LocalizeString(IDS_MSG_VEH_NAME));
1051 return false;
1052 }
1053 // check if text is not used
1054 for (int i = 0; i < _template->groups.Size(); i++)
1055 {
1056 ArcadeGroupInfo& gInfo = _template->groups[i];
1057 for (int j = 0; j < gInfo.units.Size(); j++)
1058 {
1059 if (i == _indexGroup && j == _index)
1060 {
1061 continue;
1062 }
1063 if (stricmp(text, gInfo.units[j].name) == 0)
1064 {
1065 CreateMsgBox(MB_BUTTON_OK, LocalizeString(IDS_MSG_VEH_TEXT_USED));
1066 return false;
1067 }
1068 }
1069 for (int j = 0; j < gInfo.sensors.Size(); j++)
1070 {
1071 if (stricmp(text, gInfo.sensors[j].name) == 0)
1072 {
1073 CreateMsgBox(MB_BUTTON_OK, LocalizeString(IDS_MSG_VEH_TEXT_USED));
1074 return false;
1075 }
1076 }
1077 }
1078 for (int j = 0; j < _template->emptyVehicles.Size(); j++)
1079 {
1080 if (_indexGroup == -1 && j == _index)
1081 {
1082 continue;
1083 }
1084 if (stricmp(text, _template->emptyVehicles[j].name) == 0)
1085 {
1086 CreateMsgBox(MB_BUTTON_OK, LocalizeString(IDS_MSG_VEH_TEXT_USED));
1087 return false;
1088 }
1089 }
1090 for (int j = 0; j < _template->sensors.Size(); j++)

Callers

nothing calls this directly

Calls 14

GetCtrlFunction · 0.85
LocalizeStringFunction · 0.85
IdtfGoodNameMethod · 0.80
CheckExecuteMethod · 0.80
GetLastErrorTextMethod · 0.80
SetCaretPosMethod · 0.80
GetLastErrorPosMethod · 0.80
CheckEvaluateBoolMethod · 0.80
stricmpFunction · 0.50
GetTextMethod · 0.45
GetLengthMethod · 0.45
GetGameStateMethod · 0.45

Tested by

no test coverage detected