MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / notifySeatsWithVision

Method notifySeatsWithVision

source/spells/Spell.cpp:93–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93void Spell::notifySeatsWithVision(const std::vector<Seat*>& seats)
94{
95 // For spells, we want the caster and his allies to always have vision even if they
96 // don't see the tile the spell is on. Of course, vision on the tile is not given by the spell
97 // We notify seats that lost vision
98 for(std::vector<Seat*>::iterator it = mSeatsWithVisionNotified.begin(); it != mSeatsWithVisionNotified.end();)
99 {
100 Seat* seat = *it;
101 // If the seat is still in the list, nothing to do
102 if(std::find(seats.begin(), seats.end(), seat) != seats.end())
103 {
104 ++it;
105 continue;
106 }
107
108 // If the seat is the spell caster we don't remove vision
109 if(getSeat() == seat)
110 {
111 ++it;
112 continue;
113 }
114
115 // If the seat is a spell caster ally, we don't remove vision
116 if(getSeat()->isAlliedSeat(seat))
117 {
118 ++it;
119 continue;
120 }
121
122 // we remove vision
123 it = mSeatsWithVisionNotified.erase(it);
124
125 if(seat->getPlayer() == nullptr)
126 continue;
127 if(!seat->getPlayer()->getIsHuman())
128 continue;
129
130 fireRemoveEntity(seat);
131 }
132
133 // We notify seats that gain vision
134 for(Seat* seat : seats)
135 {
136 // If the seat was already in the list, nothing to do
137 if(std::find(mSeatsWithVisionNotified.begin(), mSeatsWithVisionNotified.end(), seat) != mSeatsWithVisionNotified.end())
138 continue;
139
140 mSeatsWithVisionNotified.push_back(seat);
141
142 if(seat->getPlayer() == nullptr)
143 continue;
144 if(!seat->getPlayer()->getIsHuman())
145 continue;
146
147 fireAddEntity(seat, false);
148 }
149
150 // We give vision to the spell caster and his allies

Calls 3

isAlliedSeatMethod · 0.80
getIsHumanMethod · 0.80
getPlayerMethod · 0.45

Tested by

no test coverage detected