Skip to content

Commit

Permalink
bug fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
guidota committed Apr 24, 2019
1 parent 51e2694 commit 306dd87
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions client/src/game/managers/WorldManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public static int getNetworkedEntity(int networkId) {
return networkedEntities.get(networkId);
}

public static boolean hasNetworkedEntity(int networkId) {
return networkedEntities.containsKey(networkId);
}

public static Set<Integer> getEntities() {
return new HashSet<>(networkedEntities.values());
}
Expand Down
17 changes: 12 additions & 5 deletions client/src/game/network/GameNotificationProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,19 @@ public void processNotification(InventoryUpdate inventoryUpdate) {

@Override
public void processNotification(MovementNotification movementNotification) {
int playerId = WorldManager.getNetworkedEntity(movementNotification.getPlayerId());
E(playerId).aOPhysics();
E(playerId).movementAdd(movementNotification.getDestination());
if (WorldManager.hasNetworkedEntity(movementNotification.getPlayerId())) {
int playerId = WorldManager.getNetworkedEntity(movementNotification.getPlayerId());
E(playerId).aOPhysics();
E(playerId).movementAdd(movementNotification.getDestination());
}
}

@Override
public void processNotification(FXNotification fxNotification) {
int target = WorldManager.getNetworkedEntity(fxNotification.getTarget());
E(target).fXAddFx(fxNotification.getFxGrh());
if (WorldManager.hasNetworkedEntity(fxNotification.getTarget())) {
int target = WorldManager.getNetworkedEntity(fxNotification.getTarget());
E(target).fXAddFx(fxNotification.getFxGrh());
}
}

private void addComponentsToEntity(Entity newEntity, EntityUpdate entityUpdate) {
Expand All @@ -90,6 +94,9 @@ private void addComponentsToEntity(Entity newEntity, EntityUpdate entityUpdate)
}

private void updateEntity(EntityUpdate entityUpdate) {
if (WorldManager.hasNetworkedEntity(entityUpdate.entityId)) {
return;
}
int entityId = WorldManager.getNetworkedEntity(entityUpdate.entityId);
Entity entity = WorldManager.getWorld().getEntity(entityId);
EntityEdit edit = entity.edit();
Expand Down

0 comments on commit 306dd87

Please sign in to comment.