| 871 | } |
| 872 | |
| 873 | bool AIMap::ProcessChange() |
| 874 | { |
| 875 | AI_ERROR(_dirty.GetXRange() == LandRange); |
| 876 | AI_ERROR(_dirty.GetYRange() == LandRange); |
| 877 | |
| 878 | if (_changesQueue.Size() < 1) |
| 879 | { |
| 880 | return false; // done |
| 881 | } |
| 882 | AITargetChange& info = _changesQueue[0]; |
| 883 | if (Glob.time < info.time) |
| 884 | { |
| 885 | return false; // cannot continue |
| 886 | } |
| 887 | int x = info.x; |
| 888 | int z = info.z; |
| 889 | const VehicleType* type = info.type; |
| 890 | BYTE dirty; |
| 891 | if (info.enemy) |
| 892 | { |
| 893 | dirty = DIRTY_ENEMY; |
| 894 | } |
| 895 | else |
| 896 | { |
| 897 | dirty = DIRTY_UNKNOWN; |
| 898 | } |
| 899 | int i, j, r; |
| 900 | int xMin, xMax, zMin, zMax; |
| 901 | |
| 902 | float maxRange = -FLT_MAX; |
| 903 | for (int w = 0; w < type->NWeaponSystems(); w++) |
| 904 | { |
| 905 | const WeaponType* weapon = type->GetWeaponSystem(w); |
| 906 | for (int i = 0; i < weapon->_muzzles.Size(); i++) |
| 907 | { |
| 908 | const MuzzleType* muzzle = weapon->_muzzles[i]; |
| 909 | const MagazineType* magazine = muzzle->_typicalMagazine; |
| 910 | if (!magazine) |
| 911 | { |
| 912 | continue; |
| 913 | } |
| 914 | for (int j = 0; j < magazine->_modes.Size(); j++) |
| 915 | { |
| 916 | const AmmoType* ammo = magazine->_modes[j]->_ammo; |
| 917 | if (ammo) |
| 918 | { |
| 919 | saturateMax(maxRange, ammo->maxRange); |
| 920 | } |
| 921 | } |
| 922 | } |
| 923 | } |
| 924 | if (maxRange < 0) |
| 925 | { |
| 926 | goto ExitProcessChange; |
| 927 | } |
| 928 | r = toIntCeil(maxRange * InvLandGrid); |
| 929 | |
| 930 | xMin = x - r; |
no test coverage detected