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 "misc.h"
00038 #include "nat.h"
00039 #include "sect.h"
00040
00041 char *relates[] = {
00042
00043 "At War", "Sitzkrieg", "Mobilizing", "Hostile", "Neutral", "Friendly",
00044 "Allied"
00045 };
00046
00047 char *
00048 cname(natid n)
00049 {
00050 struct natstr *np;
00051
00052 if ((np = getnatp(n)) == 0)
00053 return 0;
00054 return np->nat_cnam;
00055 }
00056
00057 char *
00058 relatename(struct natstr *np, natid other)
00059 {
00060 return relates[getrel(np, other)];
00061 }
00062
00063 char *
00064 rejectname(struct natstr *np, natid other)
00065 {
00066 static char *rejects[] = {
00067
00068 " YES YES YES YES",
00069 " NO YES YES YES",
00070 " YES NO YES YES",
00071 " NO NO YES YES",
00072 " YES YES NO YES",
00073 " NO YES NO YES",
00074 " YES NO NO YES",
00075 " NO NO NO YES",
00076 " YES YES YES NO ",
00077 " NO YES YES NO ",
00078 " YES NO YES NO ",
00079 " NO NO YES NO ",
00080 " YES YES NO NO ",
00081 " NO YES NO NO ",
00082 " YES NO NO NO ",
00083 " NO NO NO NO "
00084 };
00085
00086 return rejects[getrejects(other, np)];
00087 }
00088
00089 char *
00090 natstate(struct natstr *np)
00091 {
00092 static char *stnam[] = {
00093
00094 "FREE", "VISITOR", "VISITOR", "SANCTUARY", "ACTIVE", "DEITY"
00095 };
00096 return stnam[np->nat_stat];
00097 }
00098
00099
00100 int
00101 getrel(struct natstr *np, natid them)
00102 {
00103 return np->nat_relate[them];
00104 }
00105
00106 int
00107 getrejects(natid them, struct natstr *np)
00108 {
00109 return np->nat_rejects[them];
00110 }
00111
00112 void
00113 agecontact(struct natstr *np)
00114 {
00115 int them;
00116
00117 for (them = 1; them < MAXNOC; ++them) {
00118 if (them != np->nat_cnum && np->nat_contact[them]) {
00119 --np->nat_contact[them];
00120 }
00121 }
00122 }
00123
00124 int
00125 getcontact(struct natstr *np, natid them)
00126 {
00127 return np->nat_contact[them];
00128 }
00129
00130 void
00131 putrel(struct natstr *np, natid them, int relate)
00132 {
00133 np->nat_relate[them] = relate;
00134 }
00135
00136 void
00137 putreject(struct natstr *np, natid them, int how, int what)
00138 {
00139 if (how)
00140 np->nat_rejects[them] |= what;
00141 else
00142 np->nat_rejects[them] &= what;
00143 }
00144
00145 void
00146 putcontact(struct natstr *np, natid them, int contact)
00147 {
00148 if (CANT_HAPPEN(contact < 0))
00149 contact = 0;
00150 if (CANT_HAPPEN(contact > 255))
00151 contact = 255;
00152
00153 if (np->nat_contact[them] < contact)
00154 np->nat_contact[them] = contact;
00155 }
00156
00157 int
00158 influx(struct natstr *np)
00159 {
00160 struct sctstr sect;
00161
00162 getsect(np->nat_xcap, np->nat_ycap, §);
00163 if (sect.sct_own != np->nat_cnum ||
00164 (sect.sct_type != SCT_CAPIT && sect.sct_type != SCT_MOUNT &&
00165 sect.sct_type != SCT_SANCT) ||
00166 (np->nat_flags & NF_SACKED))
00167 return 1;
00168 else
00169 return 0;
00170 }