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

Method firePickupEntity

source/entities/GameEntity.cpp:154–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154void GameEntity::firePickupEntity(Player* playerPicking)
155{
156 int seatId = playerPicking->getSeat()->getId();
157 GameEntityType entityType = getObjectType();
158 const std::string& entityName = getName();
159 for(std::vector<Seat*>::iterator it = mSeatsWithVisionNotified.begin(); it != mSeatsWithVisionNotified.end();)
160 {
161 Seat* seat = *it;
162 if(seat->getPlayer() == nullptr)
163 {
164 ++it;
165 continue;
166 }
167 if(!seat->getPlayer()->getIsHuman())
168 {
169 ++it;
170 continue;
171 }
172
173 // For other players than the one picking up the entity, we send a remove message
174 if(seat->getPlayer() != playerPicking)
175 {
176 fireRemoveEntity(seat);
177 it = mSeatsWithVisionNotified.erase(it);
178 continue;
179 }
180
181 ++it;
182
183 // If the creature was picked up by a human, we send an async message
184 if(playerPicking->getIsHuman())
185 {
186 ServerNotification serverNotification(
187 ServerNotificationType::entityPickedUp, seat->getPlayer());
188 serverNotification.mPacket << seatId << entityType << entityName;
189 ODServer::getSingleton().sendAsyncMsg(serverNotification);
190 }
191 else
192 {
193 ServerNotification* serverNotification = new ServerNotification(
194 ServerNotificationType::entityPickedUp, seat->getPlayer());
195 serverNotification->mPacket << seatId << entityType << entityName;
196 ODServer::getSingleton().queueServerNotification(serverNotification);
197 }
198 }
199
200 for(auto it = mGameEntityListeners.begin(); it != mGameEntityListeners.end();)
201 {
202 GameEntityListener* listener = *it;
203 if(listener->notifyPickedUp(this))
204 {
205 ++it;
206 continue;
207 }
208
209 it = mGameEntityListeners.erase(it);
210 }
211}

Callers 1

pickUpEntityMethod · 0.80

Calls 7

getIsHumanMethod · 0.80
sendAsyncMsgMethod · 0.80
getIdMethod · 0.45
getSeatMethod · 0.45
getPlayerMethod · 0.45
notifyPickedUpMethod · 0.45

Tested by

no test coverage detected