| 1426 | } |
| 1427 | |
| 1428 | bool CScriptLevelInterface::DeleteScript() { |
| 1429 | CCheckListBox *list = (CCheckListBox *)GetDlgItem(IDC_LIST_CHECKEDOUT); |
| 1430 | int listbox_size = list->GetCount(); |
| 1431 | int list_size = 0; |
| 1432 | int i; |
| 1433 | for (i = 0; i < listbox_size; i++) { |
| 1434 | if (list->GetCheck(i)) { |
| 1435 | list_size++; |
| 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | if (list_size == 0) |
| 1440 | return false; |
| 1441 | int *index_map = (int *)mem_malloc(list_size * sizeof(int)); |
| 1442 | if (!index_map) |
| 1443 | return false; |
| 1444 | |
| 1445 | int index = 0; |
| 1446 | for (i = 0; i < listbox_size; i++) { |
| 1447 | if (list->GetCheck(i)) { |
| 1448 | index_map[index] = i; |
| 1449 | index++; |
| 1450 | } |
| 1451 | } |
| 1452 | |
| 1453 | if (!mng_MakeLocker()) { |
| 1454 | mem_free(index_map); |
| 1455 | return false; |
| 1456 | } |
| 1457 | |
| 1458 | int j; |
| 1459 | bool changed = false; |
| 1460 | char buffer[_MAX_PATH + 200]; |
| 1461 | char tempbuffer[_MAX_PATH]; |
| 1462 | char savename[_MAX_PATH]; |
| 1463 | |
| 1464 | for (i = 0; i < list_size; i++) { |
| 1465 | index = index_map[i]; |
| 1466 | |
| 1467 | list->GetText(index, tempbuffer); |
| 1468 | strcpy(savename, tempbuffer); |
| 1469 | strcat(tempbuffer, ".cpp"); |
| 1470 | |
| 1471 | // this item is checked...we wish to delete |
| 1472 | sprintf(buffer, "Are you sure you want to delete script source file\n%s?", tempbuffer); |
| 1473 | if (MessageBox(buffer, "Friendly Warning", MB_YESNO) == IDYES) { |
| 1474 | // go ahead and delete the sucker! |
| 1475 | char t[256]; |
| 1476 | sprintf(t, "Deleting: %s", tempbuffer); |
| 1477 | SetStatus(t); |
| 1478 | |
| 1479 | if (DeleteGamefile(tempbuffer)) |
| 1480 | changed = true; |
| 1481 | } |
| 1482 | |
| 1483 | // ok, now see if there was a DLL too |
| 1484 | strcpy(tempbuffer, savename); |
| 1485 | strcat(tempbuffer, ".dll"); |
nothing calls this directly
no test coverage detected