Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encapsular connectionId dentro de Network #401

Merged
merged 3 commits into from
Apr 21, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Desacoplar connectionId de Drop Item
matisandacz committed Apr 21, 2022
commit df4434c15b7355ae9929695b6bd11562ede7230f
9 changes: 5 additions & 4 deletions server/src/server/systems/network/ServerRequestProcessor.java
Original file line number Diff line number Diff line change
@@ -188,10 +188,11 @@ public void processRequest(NpcInteractionRequest npcInteractionRequest, int conn
}
}

// Todo: esta bien que este metodo reciba un playerId?
// Todo: Creo que es un bug y deberia recibir un connectionId como todos los demas.
@Override
public void processRequest(@NotNull DropItem dropItem, int playerId) {
playerActionSystem.drop(playerId, dropItem.getCount(), dropItem.getPosition(), dropItem.getSlot());
public void processRequest(@NotNull DropItem dropItem, int connectionId) {
if (serverSystem.connectionHasPlayer(connectionId)) {
int playerId = serverSystem.getPlayerByConnection(connectionId);
playerActionSystem.drop(playerId, dropItem.getCount(), dropItem.getPosition(), dropItem.getSlot());
}
}
}
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ public void drop(int playerId, int count, WorldPos position, int slot) {
bag.remove(slot);
}
update.add(slot, bag.items[slot]); // should remove item if count <= 0
serverSystem.sendByConnectionId(serverSystem.getConnectionByPlayer(playerId), update);
serverSystem.sendByPlayerId(playerId, update);

// Add new obj component.entity to world
int object = world.create();