00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <config.h>
00035
00036 #include "file.h"
00037 #include "land.h"
00038 #include "misc.h"
00039 #include "nat.h"
00040 #include "nsc.h"
00041 #include "path.h"
00042 #include "prototypes.h"
00043 #include "sect.h"
00044 #include "xy.h"
00045
00046 int
00047 adj_units(coord x, coord y, natid own)
00048 {
00049 int i;
00050 struct sctstr sect;
00051
00052 for (i = DIR_FIRST; i <= DIR_LAST; i++) {
00053 getsect(x + diroff[i][0], y + diroff[i][1], §);
00054 if (has_units(sect.sct_x, sect.sct_y, own, 0))
00055 return 1;
00056 }
00057 return 0;
00058 }
00059
00060 int
00061 has_units(coord x, coord y, natid cn, struct lndstr *lp)
00062 {
00063 int n;
00064 struct lndstr land;
00065
00066 for (n = 0; ef_read(EF_LAND, n, &land); n++) {
00067 if (land.lnd_x != x || land.lnd_y != y)
00068 continue;
00069 if (lp) {
00070
00071
00072 if (lp->lnd_uid == land.lnd_uid)
00073 continue;
00074 }
00075 if (land.lnd_own == cn)
00076 return 1;
00077 }
00078
00079 return 0;
00080 }
00081
00082 int
00083 has_units_with_mob(coord x, coord y, natid cn)
00084 {
00085 struct nstr_item ni;
00086 struct lndstr land;
00087
00088 snxtitem_xy(&ni, EF_LAND, x, y);
00089 while (nxtitem(&ni, &land)) {
00090 if (land.lnd_own != cn)
00091 continue;
00092 if (land.lnd_mobil > 0)
00093 return 1;
00094 }
00095
00096 return 0;
00097 }
00098
00099
00100
00101
00102 int
00103 has_helpful_engineer(coord x, coord y, natid cn)
00104 {
00105 struct nstr_item ni;
00106 struct lndstr land;
00107
00108 snxtitem_xy(&ni, EF_LAND, x, y);
00109 while (nxtitem(&ni, &land)) {
00110 if (land.lnd_own != cn && getrel(getnatp(land.lnd_own), cn) != ALLIED)
00111 continue;
00112 if (lchr[(int)land.lnd_type].l_flags & L_ENGINEER)
00113 return 1;
00114 }
00115
00116 return 0;
00117 }