481 goto restart_search; |
481 goto restart_search; |
482 } |
482 } |
483 } |
483 } |
484 } |
484 } |
485 |
485 |
486 /** Delete all windows of a player. We identify windows of a player |
486 /** Delete all windows of a company. We identify windows of a company |
487 * by looking at the caption colour. If it is equal to the player ID |
487 * by looking at the caption colour. If it is equal to the company ID |
488 * then we say the window belongs to the player and should be deleted |
488 * then we say the window belongs to the company and should be deleted |
489 * @param id PlayerID player identifier */ |
489 * @param id company identifier */ |
490 void DeletePlayerWindows(PlayerID id) |
490 void DeleteCompanyWindows(CompanyID id) |
491 { |
491 { |
492 Window* const *wz; |
492 Window* const *wz; |
493 |
493 |
494 restart_search: |
494 restart_search: |
495 /* When we find the window to delete, we need to restart the search |
495 /* When we find the window to delete, we need to restart the search |
501 delete w; |
501 delete w; |
502 goto restart_search; |
502 goto restart_search; |
503 } |
503 } |
504 } |
504 } |
505 |
505 |
506 /* Also delete the player specific windows, that don't have a player-colour */ |
506 /* Also delete the company specific windows, that don't have a company-colour */ |
507 DeleteWindowById(WC_BUY_COMPANY, id); |
507 DeleteWindowById(WC_BUY_COMPANY, id); |
508 } |
508 } |
509 |
509 |
510 /** Change the owner of all the windows one player can take over from another |
510 /** Change the owner of all the windows one company can take over from another |
511 * player in the case of a company merger. Do not change ownership of windows |
511 * company in the case of a company merger. Do not change ownership of windows |
512 * that need to be deleted once takeover is complete |
512 * that need to be deleted once takeover is complete |
513 * @param old_player PlayerID of original owner of the window |
513 * @param old_owner original owner of the window |
514 * @param new_player PlayerID of the new owner of the window */ |
514 * @param new_owner the new owner of the window */ |
515 void ChangeWindowOwner(PlayerID old_player, PlayerID new_player) |
515 void ChangeWindowOwner(Owner old_owner, Owner new_owner) |
516 { |
516 { |
517 Window* const *wz; |
517 Window* const *wz; |
518 |
518 |
519 FOR_ALL_WINDOWS(wz) { |
519 FOR_ALL_WINDOWS(wz) { |
520 Window *w = *wz; |
520 Window *w = *wz; |
521 |
521 |
522 if (w->caption_color != old_player) continue; |
522 if (w->caption_color != old_owner) continue; |
523 |
523 |
524 switch (w->window_class) { |
524 switch (w->window_class) { |
525 case WC_PLAYER_COLOR: |
525 case WC_COMPANY_COLOR: |
526 case WC_FINANCES: |
526 case WC_FINANCES: |
527 case WC_STATION_LIST: |
527 case WC_STATION_LIST: |
528 case WC_TRAINS_LIST: |
528 case WC_TRAINS_LIST: |
529 case WC_ROADVEH_LIST: |
529 case WC_ROADVEH_LIST: |
530 case WC_SHIPS_LIST: |
530 case WC_SHIPS_LIST: |
1633 |
1633 |
1634 /* |
1634 /* |
1635 * During the generation of the world, there might be |
1635 * During the generation of the world, there might be |
1636 * another thread that is currently building for example |
1636 * another thread that is currently building for example |
1637 * a road. To not interfere with those tasks, we should |
1637 * a road. To not interfere with those tasks, we should |
1638 * NOT change the _current_player here. |
1638 * NOT change the _current_company here. |
1639 * |
1639 * |
1640 * This is not necessary either, as the only events that |
1640 * This is not necessary either, as the only events that |
1641 * can be handled are the 'close application' events |
1641 * can be handled are the 'close application' events |
1642 */ |
1642 */ |
1643 if (!IsGeneratingWorld()) _current_player = _local_player; |
1643 if (!IsGeneratingWorld()) _current_company = _local_company; |
1644 |
1644 |
1645 /* Setup event */ |
1645 /* Setup event */ |
1646 uint16 key = GB(raw_key, 0, 16); |
1646 uint16 key = GB(raw_key, 0, 16); |
1647 uint16 keycode = GB(raw_key, 16, 16); |
1647 uint16 keycode = GB(raw_key, 16, 16); |
1648 |
1648 |
1912 |
1912 |
1913 /* |
1913 /* |
1914 * During the generation of the world, there might be |
1914 * During the generation of the world, there might be |
1915 * another thread that is currently building for example |
1915 * another thread that is currently building for example |
1916 * a road. To not interfere with those tasks, we should |
1916 * a road. To not interfere with those tasks, we should |
1917 * NOT change the _current_player here. |
1917 * NOT change the _current_company here. |
1918 * |
1918 * |
1919 * This is not necessary either, as the only events that |
1919 * This is not necessary either, as the only events that |
1920 * can be handled are the 'close application' events |
1920 * can be handled are the 'close application' events |
1921 */ |
1921 */ |
1922 if (!IsGeneratingWorld()) _current_player = _local_player; |
1922 if (!IsGeneratingWorld()) _current_company = _local_company; |
1923 |
1923 |
1924 /* Mouse event? */ |
1924 /* Mouse event? */ |
1925 MouseClick click = MC_NONE; |
1925 MouseClick click = MC_NONE; |
1926 if (_left_button_down && !_left_button_clicked) { |
1926 if (_left_button_down && !_left_button_clicked) { |
1927 click = MC_LEFT; |
1927 click = MC_LEFT; |