mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-21 20:18:14 +07:00
Added networking for dynamic objects
Added networking for dynamic objects Fixed disconnecting players not being removed from player ids table NetworkSynchronizer conditionally processes based on if any players are connected Disabled AIStepper when game is connected to a socket
This commit is contained in:
parent
5d51a1c160
commit
ea040c318e
@ -113,6 +113,7 @@ public class ServerEntityFactory extends EntityFactory {
|
||||
int id = createMonster(map, zone, monstats, x, y);
|
||||
mDS1ObjectWrapper.create(id).set(preset.getDS1(), object);
|
||||
if (object.path != null) mPathWrapper.create(id).path = object.path;
|
||||
mNetworked.create(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -531,8 +531,10 @@ public class GameScreen extends ScreenAdapter implements GameLoadingScreen.Loada
|
||||
if (!DEBUG_TOUCHPAD && Gdx.app.getType() == Application.ApplicationType.Desktop) {
|
||||
builder.with(new CursorMovementSystem());
|
||||
}
|
||||
if (socket == null) {
|
||||
builder.with(new AIStepper());
|
||||
}
|
||||
builder
|
||||
.with(new AIStepper())
|
||||
.with(new Pathfinder())
|
||||
|
||||
.with(new SoundEmitterHandler())
|
||||
|
@ -459,7 +459,7 @@ public class D2GS extends ApplicationAdapter {
|
||||
outPackets.offer(broadcast);
|
||||
|
||||
world.delete(entityId);
|
||||
player.put(id, Engine.INVALID_ENTITY);
|
||||
player.remove(id, Engine.INVALID_ENTITY);
|
||||
synchronized (clients) {
|
||||
clients[id] = null;
|
||||
numClients--;
|
||||
|
@ -26,12 +26,16 @@ public class NetworkSynchronizer extends IteratingSystem {
|
||||
@Wire(name = "player")
|
||||
protected IntIntMap players;
|
||||
|
||||
@Override
|
||||
protected boolean checkProcessing() {
|
||||
return players.size > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void process(int entityId) {
|
||||
D2GS sync = sync(entityId);
|
||||
int id = players.findKey(entityId, -1);
|
||||
assert id != -1;
|
||||
boolean success = outPackets.offer(com.riiablo.server.d2gs.D2GS.Packet.obtain(~(1 << id), sync));
|
||||
boolean success = outPackets.offer(com.riiablo.server.d2gs.D2GS.Packet.obtain(id != -1 ? ~(1 << id) : 0xFFFFFFFF, sync));
|
||||
assert success;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user