Files
prestonbane/src/engine/net/client/msg/VisualUpdateMessage.java
T

94 lines
3.0 KiB
Java
Raw Normal View History

2022-04-30 09:41:17 -04:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.msg;
import engine.Enum.GameObjectType;
import engine.exception.SerializationException;
import engine.net.AbstractConnection;
import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter;
import engine.net.client.Protocol;
import engine.objects.AbstractGameObject;
import engine.objects.Building;
public class VisualUpdateMessage extends ClientNetMsg {
2023-07-15 09:23:48 -04:00
private int effectType;
private AbstractGameObject ago;
private Building building;
/**
* This constructor is used by NetMsgFactory. It attempts to deserialize the
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
* past the limit) then this constructor Throws that Exception to the
* caller.
*/
public VisualUpdateMessage(AbstractConnection origin, ByteBufferReader reader) {
super(Protocol.VISUALUPDATE, origin, reader);
}
public VisualUpdateMessage() {
super(Protocol.VISUALUPDATE);
}
public VisualUpdateMessage(AbstractGameObject ago, int visualID) {
super(Protocol.VISUALUPDATE);
if (ago == null)
return;
this.effectType = visualID;
this.ago = ago;
}
/**
* Deserializes the subclass specific items from the supplied NetMsgReader.
*/
@Override
protected void _deserialize(ByteBufferReader reader) {
}
2022-04-30 09:41:17 -04:00
public void configure() {
if (this.ago.getObjectType() == GameObjectType.Building)
2023-07-15 09:23:48 -04:00
this.building = (Building) this.ago;
2022-04-30 09:41:17 -04:00
else
this.building = null;
}
2023-07-15 09:23:48 -04:00
/**
* Serializes the subclass specific items to the supplied NetMsgWriter.
*/
@Override
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
2022-04-30 09:41:17 -04:00
if (this.building == null) {
writer.putInt(4);
writer.putInt(0);
writer.putInt(this.effectType);
writer.putInt(ago.getObjectType().ordinal());
writer.putInt(ago.getObjectUUID());
writer.putInt(0);
return;
}
2023-07-15 09:23:48 -04:00
writer.putShort((short) 100);
writer.putShort((short) 120);
2022-04-30 09:41:17 -04:00
writer.putInt(1);
writer.putInt(this.building.getObjectType().ordinal());
writer.putInt(this.building.getObjectUUID());
writer.putInt(this.effectType);
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
}