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 #include "zValidator.h"
00029
00030
00031
00032
00033 zValidator::zValidator(Triad _positive, Triad _marked)
00034 : selectors(),
00035 monitorInfluences(),
00036 zoneInfluences(),
00037 positive(_positive),
00038 marked(_marked)
00039 { }
00040
00041 zValidator::zValidator(zValidator const &other):
00042 selectors( other.selectors ),
00043 monitorInfluences( other.monitorInfluences ),
00044 zoneInfluences( other.zoneInfluences ),
00045 positive( other.getPositive() ),
00046 marked( other.getMarked() )
00047 { }
00048
00049
00050 void zValidator::operator=(zValidator const &other)
00051 {
00052 if (this != &other) {
00053 positive = other.getPositive();
00054 marked = other.getMarked();
00055 }
00056 }
00057
00058 zValidator *zValidator::copy(void) const {
00059 return new zValidator(*this);
00060 }
00061
00062 bool
00063 zValidator::isOwner(ePlayerNetID *possibleOwner, gVectorExtra< nNetObjectID > &owners)
00064 {
00065 gVectorExtra< nNetObjectID >::iterator iter;
00066 for (iter = owners.begin();
00067 iter != owners.end();
00068 ++iter)
00069 {
00070 if (bool(sn_netObjects[(*iter)]) && (*iter == possibleOwner->ID()) )
00071 return true;
00072 }
00073 return false;
00074 }
00075
00076 bool
00077 zValidator::isTeamOwner(eTeam *possibleTeamOwner, gVectorExtra< nNetObjectID > &teamOwners)
00078 {
00079 gVectorExtra< nNetObjectID >::iterator iter;
00080 for (iter = teamOwners.begin();
00081 iter != teamOwners.end();
00082 ++iter)
00083 {
00084
00085 bool isValidID = ( (*iter) == 0 || bool(sn_netObjects[(*iter)]));
00086 if ( isValidID && (*iter == possibleTeamOwner->ID()) )
00087 return true;
00088 }
00089 return false;
00090 }
00091
00092 void
00093 zValidator::validate(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, Triggerer possibleUser, const tPolynomial<nMessage> &tpValue) {
00094
00095 if (isValid(owners, teamOwners, possibleUser.who) && validateTriad(possibleUser.positive, positive) && validateTriad(possibleUser.marked, marked)) {
00096 zSelectorPtrs::const_iterator iterSelector;
00097 for (iterSelector=selectors.begin();
00098 iterSelector!=selectors.end();
00099 ++iterSelector)
00100 {
00101 (*iterSelector)->apply(owners, teamOwners, possibleUser.who);
00102 }
00103
00104 zMonitorInfluencePtrs::const_iterator iterMonitorInfluence;
00105 for (iterMonitorInfluence=monitorInfluences.begin();
00106 iterMonitorInfluence!=monitorInfluences.end();
00107 ++iterMonitorInfluence)
00108 {
00109 (*iterMonitorInfluence)->apply(owners, teamOwners, possibleUser.who, tpValue);
00110 }
00111
00112 zZoneInfluencePtrs::const_iterator iterZoneInfluence;
00113 for (iterZoneInfluence=zoneInfluences.begin();
00114 iterZoneInfluence!=zoneInfluences.end();
00115 ++iterZoneInfluence)
00116 {
00117
00118 (*iterZoneInfluence)->apply( tpValue );
00119 }
00120 }
00121 }
00122
00123
00124
00125
00126 zValidator * zValidatorAll::create(Triad _positive, Triad _marked)
00127 {
00128 return new zValidatorAll(_positive, _marked);
00129 }
00130
00131 zValidatorAll::zValidatorAll(Triad _positive, Triad _marked):
00132 zValidator(_positive, _marked)
00133 { }
00134
00135 zValidatorAll::zValidatorAll(zValidatorAll const &other):
00136 zValidator(other)
00137 { }
00138
00139 void zValidatorAll::operator=(zValidatorAll const &other)
00140 {
00141 this->zValidator::operator=(other);
00142 }
00143
00144 zValidator *zValidatorAll::copy(void) const {
00145 return new zValidatorAll(*this);
00146 }
00147
00148
00149
00150
00151 zValidator * zValidatorOwner::create(Triad _positive, Triad _marked)
00152 {
00153 return new zValidatorOwner(_positive, _marked);
00154 }
00155
00156 zValidatorOwner::zValidatorOwner(Triad _positive, Triad _marked):
00157 zValidator(_positive, _marked)
00158 { }
00159
00160 zValidatorOwner::zValidatorOwner(zValidatorOwner const &other):
00161 zValidator(other)
00162 { }
00163
00164 void zValidatorOwner::operator=(zValidatorOwner const &other)
00165 {
00166 this->zValidator::operator=(other);
00167 }
00168
00169 zValidator *zValidatorOwner::copy(void) const {
00170 return new zValidatorOwner(*this);
00171 }
00172
00173 bool
00174 zValidatorOwner::isValid(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle* possibleUser)
00175 {
00176 return isOwner(possibleUser->Player(), owners);
00177 }
00178
00179
00180
00181
00182 zValidator * zValidatorOwnerTeam::create(Triad _positive, Triad _marked)
00183 {
00184 return new zValidatorOwnerTeam(_positive, _marked);
00185 }
00186
00187 zValidatorOwnerTeam::zValidatorOwnerTeam(Triad _positive, Triad _marked):
00188 zValidator(_positive, _marked)
00189 { }
00190
00191 zValidatorOwnerTeam::zValidatorOwnerTeam(zValidatorOwnerTeam const &other):
00192 zValidator(other)
00193 { }
00194
00195 void zValidatorOwnerTeam::operator=(zValidatorOwnerTeam const &other)
00196 {
00197 this->zValidator::operator=(other);
00198 }
00199
00200 zValidator *zValidatorOwnerTeam::copy(void) const {
00201 return new zValidatorOwnerTeam(*this);
00202 }
00203
00204 bool
00205 zValidatorOwnerTeam::isValid(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle* possibleUser)
00206 {
00207 return isTeamOwner(possibleUser->Player()->CurrentTeam(), teamOwners);
00208 }
00209
00210
00211
00212
00213 zValidator * zValidatorAllButOwner::create(Triad _positive, Triad _marked)
00214 {
00215 return new zValidatorAllButOwner(_positive, _marked);
00216 }
00217
00218 zValidatorAllButOwner::zValidatorAllButOwner(Triad _positive, Triad _marked):
00219 zValidator(_positive, _marked)
00220 { }
00221
00222 zValidatorAllButOwner::zValidatorAllButOwner(zValidatorAllButOwner const &other):
00223 zValidator(other)
00224 { }
00225
00226 void zValidatorAllButOwner::operator=(zValidatorAllButOwner const &other)
00227 {
00228 this->zValidator::operator=(other);
00229 }
00230
00231 zValidator *zValidatorAllButOwner::copy(void) const {
00232 return new zValidatorAllButOwner(*this);
00233 }
00234
00235 bool
00236 zValidatorAllButOwner::isValid(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle* possibleUser)
00237 {
00238 return !isOwner(possibleUser->Player(), owners);
00239 }
00240
00241
00242
00243
00244 zValidator * zValidatorAllButTeamOwner::create(Triad _positive, Triad _marked)
00245 {
00246 return new zValidatorAllButTeamOwner(_positive, _marked);
00247 }
00248
00249 zValidatorAllButTeamOwner::zValidatorAllButTeamOwner(Triad _positive, Triad _marked):
00250 zValidator(_positive, _marked)
00251 { }
00252
00253 zValidatorAllButTeamOwner::zValidatorAllButTeamOwner(zValidatorAllButTeamOwner const &other):
00254 zValidator(other)
00255 { }
00256
00257 void zValidatorAllButTeamOwner::operator=(zValidatorAllButTeamOwner const &other)
00258 {
00259 this->zValidator::operator=(other);
00260 }
00261
00262 zValidator *zValidatorAllButTeamOwner::copy(void) const {
00263 return new zValidatorAllButTeamOwner(*this);
00264 }
00265
00266 bool
00267 zValidatorAllButTeamOwner::isValid(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle* possibleUser)
00268 {
00269 return !isTeamOwner(possibleUser->Player()->CurrentTeam(), teamOwners);
00270 }
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327