Author: ATracer
(2010/03/14 13:21) Almost 2 years ago
small fixes in respawn service and SM_ABNORMAL_ packets.
46
import com.aionemu.gameserver.utils.PacketSendUtility;
47
import com.aionemu.gameserver.utils.ThreadPoolManager;
48
import com.aionemu.gameserver.world.World;
49
import com.aionemu.gameserver.world.WorldMap;
50
import com.aionemu.gameserver.world.WorldMapInstance;
51
import com.aionemu.gameserver.world.zone.ZoneName;
52
import com.google.inject.Inject;
43
44
45
16
*/
17
package com.aionemu.gameserver.controllers.effect;
18
19
import java.util.ArrayList;
20
import java.util.Iterator;
21
import java.util.List;
import java.util.Map;
22
import java.util.concurrent.ConcurrentHashMap;
23
24
...
126
129
127
public void broadCastEffects()
130
128
{
131
132
List<Effect> effects = getAbnormalEffects();
PacketSendUtility.broadcastPacket(getOwner(),
133
new SM_ABNORMAL_EFFECT(getOwner().getObjectId(), abnormals,
134
new SM_ABNORMAL_EFFECT(getOwner().getObjectId(), abnormals, effects));
abnormalEffectMap.values().toArray(new Effect[abnormalEffectMap.size()])));
}
135
136
/**
137
138
141
139
public void sendEffectIconsTo(Player player)
142
140
143
144
PacketSendUtility.sendPacket(player, new SM_ABNORMAL_EFFECT(getOwner().getObjectId(),
145
abnormals, abnormalEffectMap.values().toArray(new Effect[abnormalEffectMap.size()])));
146
abnormals, effects));
147
148
149
246
250
247
public void updatePlayerEffectIconsImpl()
251
248
252
253
254
249
PacketSendUtility.sendPacket((Player) owner,
255
new SM_ABNORMAL_STATE(abnormalEffectMap.values().toArray(new Effect[abnormalEffectMap.size()]), abnormals));
256
new SM_ABNORMAL_STATE(effects, abnormals));
257
258
259
private List<Effect> getAbnormalEffects()
260
261
List<Effect> effects = new ArrayList<Effect>();
262
Iterator<Effect> iterator = iterator();
263
while(iterator.hasNext())
264
265
Effect effect = iterator.next();
266
if(effect != null)
267
effects.add(effect);
268
269
return effects;
270
271
272
* ABNORMAL EFFECTS
273
274
291
310
292
return abnormals;
311
293
312
313
314
315
*
316
* @return
317
318
public Iterator<Effect> iterator()
319
320
return abnormalEffectMap.values().iterator();
321
294
322
295
323
29
import javax.xml.bind.annotation.XmlType;
30
31
import com.aionemu.commons.utils.Rnd;
32
import com.aionemu.gameserver.model.gameobjects.VisibleObject;
import com.aionemu.gameserver.spawnengine.SpawnHandlerType;
33
34
35
212
lastSpawnedTemplate.remove(instanceIndex);
213
214
215
216
217
* Check whether pool size is equal to number of defined objects
218
* For such pools no exchange template should be done
219
220
221
222
public boolean isFullPool()
223
224
return pool == objects.size();
225
226
227
228
* @param visibleObject
229
230
public synchronized void exchangeSpawn(VisibleObject visibleObject)
231
232
if(isFullPool())
233
return;
234
235
int instanceId = visibleObject.getInstanceId();
236
SpawnTemplate nextSpawn = getNextAvailableTemplate(instanceId);
237
if(nextSpawn != null)
238
visibleObject.setSpawn(nextSpawn);
239
240
241
package com.aionemu.gameserver.network.aion.serverpackets;
import java.nio.ByteBuffer;
import java.util.Collection;
import com.aionemu.gameserver.network.aion.AionConnection;
import com.aionemu.gameserver.network.aion.AionServerPacket;
private int effectedId;
private int abnormals;
private Effect[] effects;
private Collection<Effect> effects;
public SM_ABNORMAL_EFFECT(int effectedId, int abnormals, Effect[] effects)
public SM_ABNORMAL_EFFECT(int effectedId, int abnormals, Collection<Effect> effects)
36
this.effects = effects;
37
this.abnormals = abnormals;
38
writeD(buf, 0); //unk
writeD(buf, abnormals); //unk
writeH(buf, effects.length); //effects size
writeH(buf, effects.size()); //effects size
for(Effect effect : effects)
53
28
public class SM_ABNORMAL_STATE extends AionServerPacket
public SM_ABNORMAL_STATE(Effect[] effects, int abnormals)
public SM_ABNORMAL_STATE(Collection<Effect> effects, int abnormals)
41
protected void writeImpl(AionConnection con, ByteBuffer buf)
42
writeD(buf, abnormals);
writeH(buf, effects.length);
writeH(buf, effects.size());
world.setPosition(player, entryPoint.getMapId(), 1, entryPoint.getX(), entryPoint.getY(),
entryPoint.getZ(), player.getHeading());
* @param worldId
* @param instanceId
public boolean isInstanceExist(int worldId, int instanceId)
return world.getWorldMap(worldId).getWorldMapInstanceById(instanceId) != null;
import com.aionemu.gameserver.model.gameobjects.player.PlayerCommonData;
import com.aionemu.gameserver.model.gameobjects.player.Storage;
import com.aionemu.gameserver.model.gameobjects.player.StorageType;
import com.aionemu.gameserver.model.templates.item.ItemQuality;
39
import com.aionemu.gameserver.model.templates.mail.MailMessage;
40
import com.aionemu.gameserver.network.aion.serverpackets.SM_DELETE_ITEM;
import com.aionemu.gameserver.network.aion.serverpackets.SM_INVENTORY_UPDATE;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.templates.spawn.SpawnTemplate;
import com.aionemu.gameserver.model.templates.spawn.SpawnTime;
25
26
import com.aionemu.gameserver.utils.gametime.DayTime;
27
import com.aionemu.gameserver.utils.gametime.GameTimeManager;
* @author ATracer
public class RespawnService
private static final int DECAY_DEFAULT_DELAY = 20000;
@Inject
private InstanceService instanceService;
74
77
75
78
76
79
//TODO remove this if/else
80
int worldId = visibleObject.getSpawn().getWorldId();
if(visibleObject.getSpawn().isNoRespawn(instanceId))
81
boolean instanceExists = instanceService.isInstanceExist(worldId, instanceId);
82
83
if(visibleObject.getSpawn().isNoRespawn(instanceId) || !instanceExists)
84
visibleObject.getController().delete();
85
86
else
87
88
exchangeSpawnTemplate(visibleObject);
89
visibleObject.getSpawn().getSpawnGroup().exchangeSpawn(visibleObject);
world.setPosition(visibleObject, visibleObject.getSpawn().getWorldId(), visibleObject.getSpawn().getX(), visibleObject.getSpawn().getY(), visibleObject.getSpawn().getZ(), visibleObject.getSpawn().getHeading());
90
world.setPosition(visibleObject, worldId, visibleObject.getSpawn().getX(), visibleObject.getSpawn().getY(), visibleObject.getSpawn().getZ(), visibleObject.getSpawn().getHeading());
//call onRespawn before actual spawning
91
visibleObject.getController().onRespawn();
92
world.spawn(visibleObject);
93
94
95
private synchronized void exchangeSpawnTemplate(final VisibleObject visibleObject)
SpawnTemplate nextSpawn = visibleObject.getSpawn().getSpawnGroup().getNextAvailableTemplate(instanceId);
96
97
98
99
100
}, interval * 1000);
101
import com.aionemu.gameserver.world.WorldMap;import com.aionemu.gameserver.world.WorldMap;{{new SM_ABNORMAL_EFFECT(getOwner().getObjectId(), abnormals, effects));abnormalEffectMap.values().toArray(new Effect[abnormalEffectMap.size()])));{{abnormals, abnormalEffectMap.values().toArray(new Effect[abnormalEffectMap.size()])));abnormals, effects));{{new SM_ABNORMAL_STATE(abnormalEffectMap.values().toArray(new Effect[abnormalEffectMap.size()]), abnormals));new SM_ABNORMAL_STATE(effects, abnormals));{{{{{{{{{private Effect[] effects;private Collection<Effect> effects;public SM_ABNORMAL_EFFECT(int effectedId, int abnormals, Effect[] effects)public SM_ABNORMAL_EFFECT(int effectedId, int abnormals, Collection<Effect> effects){{writeH(buf, effects.length); //effects sizewriteH(buf, effects.size()); //effects size{{{{private Effect[] effects;private Collection<Effect> effects;public SM_ABNORMAL_STATE(Effect[] effects, int abnormals)public SM_ABNORMAL_STATE(Collection<Effect> effects, int abnormals){{{{writeH(buf, effects.length);writeH(buf, effects.size());{{{import com.aionemu.gameserver.model.templates.item.ItemQuality;import com.aionemu.gameserver.model.templates.spawn.SpawnTemplate;{{//TODO remove this if/elseint worldId = visibleObject.getSpawn().getWorldId();if(visibleObject.getSpawn().isNoRespawn(instanceId))boolean instanceExists = instanceService.isInstanceExist(worldId, instanceId);if(visibleObject.getSpawn().isNoRespawn(instanceId) || !instanceExists){{{{exchangeSpawnTemplate(visibleObject);visibleObject.getSpawn().getSpawnGroup().exchangeSpawn(visibleObject);world.setPosition(visibleObject, visibleObject.getSpawn().getWorldId(), visibleObject.getSpawn().getX(), visibleObject.getSpawn().getY(), visibleObject.getSpawn().getZ(), visibleObject.getSpawn().getHeading());world.setPosition(visibleObject, worldId, visibleObject.getSpawn().getX(), visibleObject.getSpawn().getY(), visibleObject.getSpawn().getZ(), visibleObject.getSpawn().getHeading());private synchronized void exchangeSpawnTemplate(final VisibleObject visibleObject){int instanceId = visibleObject.getInstanceId();SpawnTemplate nextSpawn = visibleObject.getSpawn().getSpawnGroup().getNextAvailableTemplate(instanceId);if(nextSpawn != null)visibleObject.setSpawn(nextSpawn);}