From c5efbc13a13e13de9e440bac797506ae5f61a4ae Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Sun, 10 Feb 2019 02:08:56 -0800 Subject: [PATCH] Fixed single player character animations Fixed issue with single player player entity creation by blocking some packets Fixed issue with character colormap transforms not working as intended for 0x7 Small fix for in-game chat box printing enters -- need to block key commands while typing Added padding to in-game chat box Removed shift to not move in-town (was not working as intended anyways) --- core/src/gdx/diablo/codec/Animation.java | 8 +-- core/src/gdx/diablo/entity/Entity.java | 3 ++ core/src/gdx/diablo/entity/Player.java | 5 +- core/src/gdx/diablo/screen/GameScreen.java | 63 ++++++++++++++++++++-- 4 files changed, 68 insertions(+), 11 deletions(-) diff --git a/core/src/gdx/diablo/codec/Animation.java b/core/src/gdx/diablo/codec/Animation.java index 7cbff818..9f12feb9 100644 --- a/core/src/gdx/diablo/codec/Animation.java +++ b/core/src/gdx/diablo/codec/Animation.java @@ -394,16 +394,16 @@ public class Animation extends BaseDrawable { } public void setTransform(Index colormap, int id) { - //if (colormap != null) System.out.println("----> " + colormap + "; " + id); - transform = colormap; + transform = colormap; transformColor = colormap == null ? 0 : id; } public void setTransform(byte packedTransform) { - if ((packedTransform & 0xFF) == 0xFF) { + int transform = packedTransform & 0xFF; + if (transform == 0xFF) { setTransform(null, 0); } else { - setTransform(Diablo.colormaps.get(packedTransform >>> 5), packedTransform & 0x1F); + setTransform(Diablo.colormaps.get(transform >>> 5), transform & 0x1F); } } diff --git a/core/src/gdx/diablo/entity/Entity.java b/core/src/gdx/diablo/entity/Entity.java index 68f2ca52..6f79c882 100644 --- a/core/src/gdx/diablo/entity/Entity.java +++ b/core/src/gdx/diablo/entity/Entity.java @@ -67,6 +67,8 @@ public class Entity { StringBuilder builder = new StringBuilder(); if (bits == NONE) { builder.append("NONE"); + } else if (bits == ALL) { + builder.append("ALL"); } else { if ((bits & HD) == HD) builder.append("HD").append("|"); if ((bits & TR) == TR) builder.append("TR").append("|"); @@ -270,6 +272,7 @@ public class Entity { byte transform = getTransform(comp); animation.getLayer(c).setTransform(transform); + System.out.println(comp + " transform " + transform + " " + ((transform & 0xFF) >>> 5) + "|" + (transform & 0x1f)); /* if (item != null) { // FIXME: colors don't look right for sorc Tirant circlet changing hair color diff --git a/core/src/gdx/diablo/entity/Player.java b/core/src/gdx/diablo/entity/Player.java index 33727a49..a96b0786 100644 --- a/core/src/gdx/diablo/entity/Player.java +++ b/core/src/gdx/diablo/entity/Player.java @@ -99,7 +99,7 @@ public class Player extends Entity { private void loadEquipped(EnumMap items) { equipped.putAll(items); - for (Map.Entry entry : equipped.entrySet()) { + for (Map.Entry entry : items.entrySet()) { entry.getValue().load(); //if (DEBUG_EQUIPPED) Gdx.app.debug(TAG, entry.getKey() + ": " + entry.getValue()); } @@ -134,7 +134,7 @@ public class Player extends Entity { //invalidate(); //setArmType(slot, item.base.alternateGfx); int components = loc.components(); - if (components > 0) dirty |= components; + dirty |= components; updateWeaponClass(); notifySlotChanged(loc, oldItem, item); @@ -194,6 +194,7 @@ public class Player extends Entity { return Diablo.cofs.chars_cof; } + @Override public void update() { if (ignoreUpdate) { super.update(); diff --git a/core/src/gdx/diablo/screen/GameScreen.java b/core/src/gdx/diablo/screen/GameScreen.java index 21b37192..784a5420 100644 --- a/core/src/gdx/diablo/screen/GameScreen.java +++ b/core/src/gdx/diablo/screen/GameScreen.java @@ -122,7 +122,56 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable this.fontColor = Diablo.colors.white; this.background = new PaletteIndexedColorDrawable(Diablo.colors.modal); this.cursor = new TextureRegionDrawable(Diablo.textures.white); - }}); + + float padding = 4; + background.setLeftWidth(padding); + background.setTopHeight(padding); + background.setRightWidth(padding); + background.setBottomHeight(padding); + }}) { + //boolean newlyVisible = false; + + { + writeEnters = false; + //setTextFieldFilter(new TextFieldFilter() { + // @Override + // public boolean acceptChar(TextField textField, char c) { + // return c != ENTER_ANDROID && c != ENTER_DESKTOP; + // } + //}); + /*setTextFieldListener(new TextFieldListener() { + @Override + public void keyTyped(TextField textField, char c) { + if (c == ENTER_ANDROID || c == ENTER_DESKTOP) { + //if (newlyVisible) { + // newlyVisible = false; + // return; + //} + + String text = input.getText(); + if (!text.isEmpty()) { + Gdx.app.debug(TAG, text); + Message message = new Message(player.stats.getName(), text); + out.println(Packets.build(message)); + input.setText(""); + } + + input.setVisible(false); + } + } + });*/ + } + + //@Override + //public void setVisible(boolean visible) { + //if (visible && !isVisible()) { + // newlyVisible = true; + //} + + // super.setVisible(visible); + //} + }; + input.setDebug(true); input.setSize(Diablo.VIRTUAL_WIDTH * 0.75f, Diablo.fonts.fontformal12.getLineHeight() * 3); input.setPosition(Diablo.VIRTUAL_WIDTH_CENTER - input.getWidth() / 2, 100); input.setAlignment(Align.topLeft); @@ -201,7 +250,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable public void changed(ChangeEvent event, Actor actor) { float x = touchpad.getKnobPercentX(); float y = touchpad.getKnobPercentY(); - if (x == 0 && y == 0 || UIUtils.shift()) { + if (x == 0 && y == 0) { player.setMode("TN"); return; //} else if (-0.5f < x && x < 0.5f @@ -424,9 +473,13 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable Gdx.app.log(TAG, "connecting to " + socket.getRemoteAddress() + "..."); in = IOUtils.buffer(new InputStreamReader(socket.getInputStream())); out = new PrintWriter(socket.getOutputStream(), true); - - String connect = Packets.build(new Connect(player)); - out.println(connect); + if (!(socket instanceof PipedSocket)) { + String connect = Packets.build(new Connect(player)); + out.println(connect); + } else { + String connectResponse = Packets.build(new ConnectResponse(1)); + out.println(connectResponse); + } } updateTask = Timer.schedule(new Timer.Task() {