550 if (u == NULL) { |
550 if (u == NULL) { |
551 DeleteDisasterVeh(v); |
551 DeleteDisasterVeh(v); |
552 return; |
552 return; |
553 } |
553 } |
554 |
554 |
555 InitializeDisasterVehicle(u, -6*16, v->y_pos, 135, 5, 11); |
555 InitializeDisasterVehicle(u, -6 * 16, v->y_pos, 135, DIR_SW, 11); |
556 u->u.disaster.unk2 = v->index; |
556 u->u.disaster.unk2 = v->index; |
557 |
557 |
558 w = ForceAllocateSpecialVehicle(); |
558 w = ForceAllocateSpecialVehicle(); |
559 if (w == NULL) |
559 if (w == NULL) |
560 return; |
560 return; |
561 |
561 |
562 u->next = w; |
562 u->next = w; |
563 InitializeDisasterVehicle(w, -6*16, v->y_pos, 0, 5, 12); |
563 InitializeDisasterVehicle(w, -6 * 16, v->y_pos, 0, DIR_SW, 12); |
564 w->vehstatus |= VS_DISASTER; |
564 w->vehstatus |= VS_DISASTER; |
565 } else if (v->current_order.station < 1) { |
565 } else if (v->current_order.station < 1) { |
566 |
566 |
567 int x = TileX(v->dest_tile) * 16; |
567 int x = TileX(v->dest_tile) * 16; |
568 int y = TileY(v->dest_tile) * 16; |
568 int y = TileY(v->dest_tile) * 16; |
718 x = (TileX(st->xy) + 2) * 16; |
718 x = (TileX(st->xy) + 2) * 16; |
719 break; |
719 break; |
720 } |
720 } |
721 } |
721 } |
722 |
722 |
723 InitializeDisasterVehicle(v, x, 0, 135, 3, 0); |
723 InitializeDisasterVehicle(v, x, 0, 135, DIR_SE, 0); |
724 |
724 |
725 // Allocate shadow too? |
725 // Allocate shadow too? |
726 u = ForceAllocateSpecialVehicle(); |
726 u = ForceAllocateSpecialVehicle(); |
727 if (u != NULL) { |
727 if (u != NULL) { |
728 v->next = u; |
728 v->next = u; |
729 InitializeDisasterVehicle(u, x, 0, 0, 3, 1); |
729 InitializeDisasterVehicle(u, x, 0, 0, DIR_SE, 1); |
730 u->vehstatus |= VS_DISASTER; |
730 u->vehstatus |= VS_DISASTER; |
731 } |
731 } |
732 } |
732 } |
733 |
733 |
734 static void Disaster1_Init(void) |
734 static void Disaster1_Init(void) |
739 if (v == NULL) |
739 if (v == NULL) |
740 return; |
740 return; |
741 |
741 |
742 x = TileX(Random()) * 16 + 8; |
742 x = TileX(Random()) * 16 + 8; |
743 |
743 |
744 InitializeDisasterVehicle(v, x, 0, 135, 3, 2); |
744 InitializeDisasterVehicle(v, x, 0, 135, DIR_SE, 2); |
745 v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2); |
745 v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2); |
746 v->age = 0; |
746 v->age = 0; |
747 |
747 |
748 // Allocate shadow too? |
748 // Allocate shadow too? |
749 u = ForceAllocateSpecialVehicle(); |
749 u = ForceAllocateSpecialVehicle(); |
750 if (u != NULL) { |
750 if (u != NULL) { |
751 v->next = u; |
751 v->next = u; |
752 InitializeDisasterVehicle(u,x,0,0,3,3); |
752 InitializeDisasterVehicle(u, x, 0, 0, DIR_SE, 3); |
753 u->vehstatus |= VS_DISASTER; |
753 u->vehstatus |= VS_DISASTER; |
754 } |
754 } |
755 } |
755 } |
756 |
756 |
757 static void Disaster2_Init(void) |
757 static void Disaster2_Init(void) |
778 return; |
778 return; |
779 |
779 |
780 x = (MapSizeX() + 9) * 16 - 1; |
780 x = (MapSizeX() + 9) * 16 - 1; |
781 y = TileY(found->xy) * 16 + 37; |
781 y = TileY(found->xy) * 16 + 37; |
782 |
782 |
783 InitializeDisasterVehicle(v,x,y, 135,1,4); |
783 InitializeDisasterVehicle(v, x, y, 135, DIR_NE, 4); |
784 |
784 |
785 u = ForceAllocateSpecialVehicle(); |
785 u = ForceAllocateSpecialVehicle(); |
786 if (u != NULL) { |
786 if (u != NULL) { |
787 v->next = u; |
787 v->next = u; |
788 InitializeDisasterVehicle(u,x,y,0,3,5); |
788 InitializeDisasterVehicle(u, x, y, 0, DIR_SE, 5); |
789 u->vehstatus |= VS_DISASTER; |
789 u->vehstatus |= VS_DISASTER; |
790 } |
790 } |
791 } |
791 } |
792 |
792 |
793 static void Disaster3_Init(void) |
793 static void Disaster3_Init(void) |
814 return; |
814 return; |
815 |
815 |
816 x = -16 * 16; |
816 x = -16 * 16; |
817 y = TileY(found->xy) * 16 + 37; |
817 y = TileY(found->xy) * 16 + 37; |
818 |
818 |
819 InitializeDisasterVehicle(v,x,y, 135,5,6); |
819 InitializeDisasterVehicle(v, x, y, 135, DIR_SW, 6); |
820 |
820 |
821 u = ForceAllocateSpecialVehicle(); |
821 u = ForceAllocateSpecialVehicle(); |
822 if (u != NULL) { |
822 if (u != NULL) { |
823 v->next = u; |
823 v->next = u; |
824 InitializeDisasterVehicle(u,x,y,0,5,7); |
824 InitializeDisasterVehicle(u, x, y, 0, DIR_SW, 7); |
825 u->vehstatus |= VS_DISASTER; |
825 u->vehstatus |= VS_DISASTER; |
826 |
826 |
827 w = ForceAllocateSpecialVehicle(); |
827 w = ForceAllocateSpecialVehicle(); |
828 if (w != NULL) { |
828 if (w != NULL) { |
829 u->next = w; |
829 u->next = w; |
830 InitializeDisasterVehicle(w,x,y,140,5,8); |
830 InitializeDisasterVehicle(w, x, y, 140, DIR_SW, 8); |
831 } |
831 } |
832 } |
832 } |
833 } |
833 } |
834 |
834 |
835 static void Disaster4_Init(void) |
835 static void Disaster4_Init(void) |
840 if (v == NULL) return; |
840 if (v == NULL) return; |
841 |
841 |
842 x = TileX(Random()) * 16 + 8; |
842 x = TileX(Random()) * 16 + 8; |
843 |
843 |
844 y = MapMaxX() * 16 - 1; |
844 y = MapMaxX() * 16 - 1; |
845 InitializeDisasterVehicle(v, x, y, 135, 7, 9); |
845 InitializeDisasterVehicle(v, x, y, 135, DIR_NW, 9); |
846 v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2); |
846 v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2); |
847 v->age = 0; |
847 v->age = 0; |
848 |
848 |
849 // Allocate shadow too? |
849 // Allocate shadow too? |
850 u = ForceAllocateSpecialVehicle(); |
850 u = ForceAllocateSpecialVehicle(); |
851 if (u != NULL) { |
851 if (u != NULL) { |
852 v->next = u; |
852 v->next = u; |
853 InitializeDisasterVehicle(u,x,y,0,7,10); |
853 InitializeDisasterVehicle(u, x, y, 0, DIR_NW, 10); |
854 u->vehstatus |= VS_DISASTER; |
854 u->vehstatus |= VS_DISASTER; |
855 } |
855 } |
856 } |
856 } |
857 |
857 |
858 // Submarine type 1 |
858 // Submarine type 1 |
859 static void Disaster5_Init(void) |
859 static void Disaster5_Init(void) |
860 { |
860 { |
861 Vehicle *v = ForceAllocateSpecialVehicle(); |
861 Vehicle *v = ForceAllocateSpecialVehicle(); |
862 int x,y; |
862 int x,y; |
863 byte dir; |
863 Direction dir; |
864 uint32 r; |
864 uint32 r; |
865 |
865 |
866 if (v == NULL) return; |
866 if (v == NULL) return; |
867 |
867 |
868 r = Random(); |
868 r = Random(); |
869 x = TileX(r) * 16 + 8; |
869 x = TileX(r) * 16 + 8; |
870 |
870 |
871 y = 8; |
871 if (r & 0x80000000) { |
872 dir = 3; |
872 y = MapMaxX() * 16 - 8 - 1; |
873 if (r & 0x80000000) { y = MapMaxX() * 16 - 8 - 1; dir = 7; } |
873 dir = DIR_NW; |
874 InitializeDisasterVehicle(v, x, y, 0, dir,13); |
874 } else { |
|
875 y = 8; |
|
876 dir = DIR_SE; |
|
877 } |
|
878 InitializeDisasterVehicle(v, x, y, 0, dir, 13); |
875 v->age = 0; |
879 v->age = 0; |
876 } |
880 } |
877 |
881 |
878 // Submarine type 2 |
882 // Submarine type 2 |
879 static void Disaster6_Init(void) |
883 static void Disaster6_Init(void) |
880 { |
884 { |
881 Vehicle *v = ForceAllocateSpecialVehicle(); |
885 Vehicle *v = ForceAllocateSpecialVehicle(); |
882 int x,y; |
886 int x,y; |
883 byte dir; |
887 Direction dir; |
884 uint32 r; |
888 uint32 r; |
885 |
889 |
886 if (v == NULL) return; |
890 if (v == NULL) return; |
887 |
891 |
888 r = Random(); |
892 r = Random(); |
889 x = TileX(r) * 16 + 8; |
893 x = TileX(r) * 16 + 8; |
890 |
894 |
891 y = 8; |
895 if (r & 0x80000000) { |
892 dir = 3; |
896 y = MapMaxX() * 16 - 8 - 1; |
893 if (r & 0x80000000) { y = MapMaxX() * 16 - 8 - 1; dir = 7; } |
897 dir = DIR_NW; |
894 InitializeDisasterVehicle(v, x, y, 0, dir,14); |
898 } else { |
|
899 y = 8; |
|
900 dir = DIR_SE; |
|
901 } |
|
902 InitializeDisasterVehicle(v, x, y, 0, dir, 14); |
895 v->age = 0; |
903 v->age = 0; |
896 } |
904 } |
897 |
905 |
898 static void Disaster7_Init(void) |
906 static void Disaster7_Init(void) |
899 { |
907 { |