Fixed GroundToCursor code to use client-side entity id and pass along server-side entity id

This commit is contained in:
Collin Smith 2020-06-05 13:28:38 -07:00
parent ae00373f8a
commit d6e973f2f2
2 changed files with 8 additions and 3 deletions

View File

@ -83,7 +83,6 @@ public class ClientNetworkReceiver extends IntervalSystem {
private static final boolean DEBUG_PACKET = DEBUG && !true;
private static final boolean DEBUG_SYNC = DEBUG && !true;
// protected ComponentMapper<Networked> mNetworked;
protected ComponentMapper<CofReference> mCofReference;
protected ComponentMapper<CofComponents> mCofComponents;
protected ComponentMapper<CofTransforms> mCofTransforms;
@ -422,7 +421,8 @@ public class ClientNetworkReceiver extends IntervalSystem {
private void GroundToCursor(D2GS packet) {
GroundToCursor groundToCursor = (GroundToCursor) packet.data(new GroundToCursor());
items.groundToCursor(Riiablo.game.player, groundToCursor.itemId());
int entityId = syncIds.get(groundToCursor.itemId());
items.groundToCursor(Riiablo.game.player, entityId);
}
private void CursorToGround(D2GS packet) {

View File

@ -2,9 +2,11 @@ package com.riiablo.engine.client;
import com.google.flatbuffers.FlatBufferBuilder;
import com.artemis.ComponentMapper;
import com.artemis.annotations.Wire;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.net.Socket;
import com.riiablo.engine.server.component.Networked;
import com.riiablo.item.BodyLoc;
import com.riiablo.item.StoreLoc;
import com.riiablo.net.packet.d2gs.BeltToCursor;
@ -28,6 +30,8 @@ import java.nio.channels.WritableByteChannel;
public class NetworkedClientItemManager extends ClientItemManager {
private static final String TAG = "NetworkedClientItemManager";
protected ComponentMapper<Networked> mNetworked;
@Wire(name = "client.socket")
protected Socket socket;
@ -50,8 +54,9 @@ public class NetworkedClientItemManager extends ClientItemManager {
@Override
public void groundToCursor(int entityId) {
int serverId = mNetworked.get(entityId).serverId;
FlatBufferBuilder builder = obtainBuilder();
int dataOffset = GroundToCursor.createGroundToCursor(builder, entityId);
int dataOffset = GroundToCursor.createGroundToCursor(builder, serverId);
wrapAndSend(builder, D2GSData.GroundToCursor, dataOffset);
}