Files
Server/src/engine/net/client/msg/TaxCityMsg.java
T

115 lines
3.4 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.gameManager.BuildingManager;
import engine.net.AbstractConnection;
import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter;
import engine.net.client.Protocol;
import engine.objects.Building;
import engine.objects.GuildTag;
public class TaxCityMsg extends ClientNetMsg {
2023-07-15 09:23:48 -04:00
private int buildingID;
private int msgType;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
public TaxCityMsg(Building building, int msgType) {
super(Protocol.TAXCITY);
this.buildingID = building.getObjectUUID();
this.msgType = msgType;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
public TaxCityMsg() {
super(Protocol.TAXCITY);
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
/**
* 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 TaxCityMsg(AbstractConnection origin, ByteBufferReader reader) {
super(Protocol.TAXCITY, origin, reader);
}
//CALL THIS AFTER SANITY CHECKS AND BEFORE UPDATING HEALTH/GOLD.
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
/**
* Deserializes the subclass specific items from the supplied NetMsgReader.
*/
@Override
protected void _deserialize(ByteBufferReader reader) {
this.msgType = reader.getInt();
reader.getInt(); //object Type.. always building
this.buildingID = reader.getInt();
reader.getInt();
reader.getInt();
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
reader.getInt();
reader.getInt();
reader.getInt();
reader.getInt();
reader.getInt();
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
reader.getInt();
reader.getInt();
reader.getInt();
reader.getInt();
reader.getInt();
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
// Precache and configure this message before we serialize it
2022-04-30 09:41:17 -04:00
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
2023-07-15 09:23:48 -04:00
writer.putInt(0);
writer.putInt(GameObjectType.Building.ordinal());
writer.putInt(this.buildingID);
Building building = BuildingManager.getBuildingFromCache(this.buildingID);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
writer.putInt(0);
writer.putFloat(.2f);
GuildTag._serializeForDisplay(building.getGuild().getGuildTag(), writer);
GuildTag._serializeForDisplay(building.getGuild().getGuildTag(), writer);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
public int getGuildID() {
return buildingID;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
public int getMsgType() {
return msgType;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
public void setMsgType(int msgType) {
this.msgType = msgType;
}
2022-04-30 09:41:17 -04:00
}