636 * if p1 = 1, then: |
637 * if p1 = 1, then: |
637 * - p2 = months left before engine expires to replace it |
638 * - p2 = months left before engine expires to replace it |
638 * if p1 = 2, then |
639 * if p1 = 2, then |
639 * - p2 = minimum amount of money available |
640 * - p2 = minimum amount of money available |
640 * if p1 = 3, then: |
641 * if p1 = 3, then: |
|
642 * - p1 bits 8-15 = engine group |
641 * - p2 bits 0-15 = old engine type |
643 * - p2 bits 0-15 = old engine type |
642 * - p2 bits 16-31 = new engine type |
644 * - p2 bits 16-31 = new engine type |
643 * if p1 = 4, then: |
645 * if p1 = 4, then: |
644 * - p1 bit 15 = enable engine renewal |
646 * - p1 bit 15 = enable engine renewal |
645 * - p1 bits 16-31 = months left before engine expires to replace it |
647 * - p1 bits 16-31 = months left before engine expires to replace it |
691 } |
693 } |
692 break; |
694 break; |
693 case 3: { |
695 case 3: { |
694 EngineID old_engine_type = GB(p2, 0, 16); |
696 EngineID old_engine_type = GB(p2, 0, 16); |
695 EngineID new_engine_type = GB(p2, 16, 16); |
697 EngineID new_engine_type = GB(p2, 16, 16); |
|
698 GroupID id_g = GB(p1, 16, 16); |
696 int32 cost; |
699 int32 cost; |
697 |
700 |
|
701 if (!IsValidGroupID(id_g) && !IsDefaultGroupID(id_g)) return CMD_ERROR; |
698 if (new_engine_type != INVALID_ENGINE) { |
702 if (new_engine_type != INVALID_ENGINE) { |
699 /* First we make sure that it's a valid type the user requested |
703 /* First we make sure that it's a valid type the user requested |
700 * check that it's an engine that is in the engine array */ |
704 * check that it's an engine that is in the engine array */ |
701 if (!IsEngineIndex(new_engine_type)) |
705 if (!IsEngineIndex(new_engine_type)) |
702 return CMD_ERROR; |
706 return CMD_ERROR; |
712 |
716 |
713 /* make sure that the player can actually buy the new engine */ |
717 /* make sure that the player can actually buy the new engine */ |
714 if (!HASBIT(GetEngine(new_engine_type)->player_avail, _current_player)) |
718 if (!HASBIT(GetEngine(new_engine_type)->player_avail, _current_player)) |
715 return CMD_ERROR; |
719 return CMD_ERROR; |
716 |
720 |
717 cost = AddEngineReplacementForPlayer(p, old_engine_type, new_engine_type, flags); |
721 cost = AddEngineReplacementForPlayer(p, old_engine_type, new_engine_type, id_g, flags); |
718 } else { |
722 } else { |
719 cost = RemoveEngineReplacementForPlayer(p, old_engine_type, flags); |
723 cost = RemoveEngineReplacementForPlayer(p, old_engine_type,id_g, flags); |
720 } |
724 } |
721 |
725 |
722 if (IsLocalPlayer()) InvalidateAutoreplaceWindow(old_engine_type); |
726 if (IsLocalPlayer()) InvalidateAutoreplaceWindow(old_engine_type); |
723 |
727 |
724 return cost; |
728 return cost; |
899 /* Remove the company */ |
903 /* Remove the company */ |
900 ChangeOwnershipOfPlayerItems(p->index, PLAYER_SPECTATOR); |
904 ChangeOwnershipOfPlayerItems(p->index, PLAYER_SPECTATOR); |
901 p->is_active = false; |
905 p->is_active = false; |
902 } |
906 } |
903 RemoveAllEngineReplacementForPlayer(p); |
907 RemoveAllEngineReplacementForPlayer(p); |
|
908 RemoveAllGroupsForPlayer(p); |
904 |
909 |
905 } break; |
910 } break; |
906 |
911 |
907 case 3: { /* Merge a company (#1) into another company (#2), elimination company #1 */ |
912 case 3: { /* Merge a company (#1) into another company (#2), elimination company #1 */ |
908 PlayerID pid_old = (PlayerID)GB(p2, 0, 16); |
913 PlayerID pid_old = (PlayerID)GB(p2, 0, 16); |
1107 |
1112 |
1108 SLE_VAR(Player, current_loan, SLE_INT32), |
1113 SLE_VAR(Player, current_loan, SLE_INT32), |
1109 |
1114 |
1110 SLE_VAR(Player, player_color, SLE_UINT8), |
1115 SLE_VAR(Player, player_color, SLE_UINT8), |
1111 SLE_VAR(Player, player_money_fraction, SLE_UINT8), |
1116 SLE_VAR(Player, player_money_fraction, SLE_UINT8), |
1112 SLE_VAR(Player, avail_railtypes, SLE_UINT8), |
1117 SLE_CONDVAR(Player, avail_railtypes, SLE_UINT8, 0, 57), |
1113 SLE_VAR(Player, block_preview, SLE_UINT8), |
1118 SLE_VAR(Player, block_preview, SLE_UINT8), |
1114 |
1119 |
1115 SLE_VAR(Player, cargo_types, SLE_UINT16), |
1120 SLE_VAR(Player, cargo_types, SLE_UINT16), |
1116 SLE_CONDVAR(Player, location_of_house, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), |
1121 SLE_CONDVAR(Player, location_of_house, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), |
1117 SLE_CONDVAR(Player, location_of_house, SLE_UINT32, 6, SL_MAX_VERSION), |
1122 SLE_CONDVAR(Player, location_of_house, SLE_UINT32, 6, SL_MAX_VERSION), |