| 524 | } |
| 525 | |
| 526 | void CWorldObjectsPlayerDialog::OnKillfocusPshipNameEdit() { |
| 527 | CEdit *ebox; |
| 528 | int n = D3EditState.current_ship; |
| 529 | char name[PAGENAME_LEN]; |
| 530 | mngs_Pagelock pl; |
| 531 | |
| 532 | // Make sure we have this ship locked, if not reset name and bail |
| 533 | int p = mng_FindTrackLock(Ships[n].name, PAGETYPE_SHIP); |
| 534 | if (p == -1) { |
| 535 | OutrageMessageBox("You must lock this ship if you wish to change its name."); |
| 536 | CEdit *ebox = (CEdit *)GetDlgItem(IDC_PSHIP_NAME_EDIT); |
| 537 | ebox->SetWindowText(Ships[n].name); |
| 538 | return; |
| 539 | } |
| 540 | |
| 541 | // Get the new name |
| 542 | ebox = (CEdit *)GetDlgItem(IDC_PSHIP_NAME_EDIT); |
| 543 | ebox->GetWindowText(name, PAGENAME_LEN); |
| 544 | |
| 545 | // Check to see if there is already a ship with this name. If so, reset and bail |
| 546 | if (FindShipName(name) != -1) { |
| 547 | OutrageMessageBox("There already is a ship with that name...choose another name."); |
| 548 | |
| 549 | CEdit *ebox = (CEdit *)GetDlgItem(IDC_PSHIP_NAME_EDIT); |
| 550 | ebox->SetWindowText(Ships[n].name); |
| 551 | return; |
| 552 | } |
| 553 | |
| 554 | if (!mng_MakeLocker()) |
| 555 | return; |
| 556 | |
| 557 | // Check to see if this page exists on the network. If so, we have to |
| 558 | // rename it so we can prevent havoc |
| 559 | strcpy(pl.name, Ships[n].name); |
| 560 | pl.pagetype = PAGETYPE_SHIP; |
| 561 | |
| 562 | int ret = mng_CheckIfPageOwned(&pl, TableUser); |
| 563 | if (ret < 0) |
| 564 | OutrageMessageBox(ErrorString); |
| 565 | else if (ret == 1) |
| 566 | mng_RenamePage(Ships[n].name, name, PAGETYPE_SHIP); |
| 567 | else if (ret == 2) { |
| 568 | // This page has never been checked in, replace only local copy |
| 569 | |
| 570 | char oldname[PAGENAME_LEN]; |
| 571 | strcpy(oldname, Ships[n].name); |
| 572 | strcpy(Ships[n].name, name); |
| 573 | |
| 574 | mng_ReplacePage(oldname, Ships[n].name, n, PAGETYPE_SHIP, 1); |
| 575 | } else if (ret == 0) { |
| 576 | OutrageMessageBox("You don't own this page. Get Jason now!"); |
| 577 | mng_FreeTrackLock(p); |
| 578 | return; |
| 579 | } |
| 580 | |
| 581 | // Finally, copy our new name to the appropriate arrays |
| 582 | strcpy(GlobalTrackLocks[p].name, name); |
| 583 | strcpy(Ships[n].name, name); |
nothing calls this directly
no test coverage detected