forked from MagicBane/Server
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
197 lines
6.0 KiB
197 lines
6.0 KiB
3 years ago
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||
|
// Magicbane Emulator Project © 2013 - 2022
|
||
|
// www.magicbane.com
|
||
|
|
||
|
|
||
|
package engine.net.client.msg;
|
||
|
|
||
|
import engine.Enum;
|
||
|
import engine.gameManager.DbManager;
|
||
|
import engine.net.AbstractConnection;
|
||
|
import engine.net.ByteBufferReader;
|
||
|
import engine.net.ByteBufferWriter;
|
||
|
import engine.net.client.Protocol;
|
||
|
import engine.objects.*;
|
||
|
|
||
|
|
||
1 year ago
|
public class ViewResourcesMsg extends ClientNetMsg {
|
||
3 years ago
|
|
||
2 years ago
|
//resource hashes
|
||
|
//0001240F
|
||
|
//002339C7 (locked)
|
||
|
//00263669
|
||
|
//00270DC3
|
||
|
//002D6DEF
|
||
|
//047636B3 (locked)
|
||
|
//047B0CC1
|
||
|
//04AB3761
|
||
|
//1AF5DB3A
|
||
|
//47033237
|
||
|
//4F8EFB0F
|
||
|
//5B57C3E4
|
||
|
//86A0AC24
|
||
|
//9705591E
|
||
|
//98378CB4
|
||
|
//98D78D15
|
||
|
//A0703E8C (locked)
|
||
|
//A0DA3807
|
||
|
//A1723A93
|
||
|
//A26E59CF
|
||
|
//D665C60F
|
||
|
//E3D05AE3
|
||
|
//ED13904D
|
||
|
|
||
|
private Guild guild;
|
||
|
private Building warehouseBuilding;
|
||
|
private Warehouse warehouseObject;
|
||
|
private PlayerCharacter player;
|
||
|
private City city;
|
||
|
|
||
|
/**
|
||
|
* This is the general purpose constructor.
|
||
|
*/
|
||
|
|
||
1 year ago
|
public ViewResourcesMsg(PlayerCharacter player) {
|
||
2 years ago
|
super(Protocol.VIEWRESOURCES);
|
||
|
this.guild = null;
|
||
|
this.player = player;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 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.
|
||
|
*/
|
||
1 year ago
|
public ViewResourcesMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||
2 years ago
|
super(Protocol.VIEWRESOURCES, origin, reader);
|
||
|
}
|
||
|
|
||
|
public boolean configure() {
|
||
|
|
||
|
if (this.warehouseBuilding.getParentZone() == null)
|
||
|
return false;
|
||
|
|
||
2 years ago
|
this.city = (City) DbManager.getObject(Enum.GameObjectType.City, this.warehouseBuilding.getParentZone().playerCityUUID);
|
||
2 years ago
|
|
||
|
if (this.city == null)
|
||
|
return false;
|
||
|
|
||
1 year ago
|
this.warehouseObject = this.city.warehouse;
|
||
3 years ago
|
|
||
|
return this.warehouseObject != null;
|
||
|
}
|
||
|
|
||
2 years ago
|
/**
|
||
|
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||
|
*/
|
||
|
@Override
|
||
|
protected void _serialize(ByteBufferWriter writer) {
|
||
|
|
||
1 year ago
|
writer.putInt(warehouseObject.resources.size());
|
||
2 years ago
|
|
||
1 year ago
|
for (Enum.ResourceType resourceType : (warehouseObject.resources.keySet())) {
|
||
2 years ago
|
|
||
1 year ago
|
writer.putInt(resourceType.hash);
|
||
1 year ago
|
writer.putInt((warehouseObject.resources.get(resourceType)));
|
||
2 years ago
|
|
||
|
|
||
1 year ago
|
if (Warehouse.isResourceLocked(warehouseObject, resourceType) == true)
|
||
2 years ago
|
writer.put((byte) 1);
|
||
|
else
|
||
|
writer.put((byte) 0);
|
||
|
}
|
||
|
|
||
1 year ago
|
writer.putInt(warehouseObject.resources.size());
|
||
2 years ago
|
|
||
1 year ago
|
for (Enum.ResourceType resourceType : warehouseObject.resources.keySet()) {
|
||
|
|
||
1 year ago
|
writer.putInt(resourceType.hash);
|
||
2 years ago
|
writer.putInt(0); //available?
|
||
1 year ago
|
writer.putInt(resourceType.deposit_limit); //max?
|
||
2 years ago
|
}
|
||
|
GuildTag._serializeForDisplay(guild.getGuildTag(), writer);
|
||
|
|
||
|
// Serialize what tags? Errant?
|
||
|
|
||
|
writer.putInt(16);
|
||
|
writer.putInt(16);
|
||
|
writer.putInt(16);
|
||
|
writer.putInt(0);
|
||
|
writer.putInt(0);
|
||
|
|
||
|
if (GuildStatusController.isTaxCollector(player.getGuildStatus())) {
|
||
|
writer.putInt(1);
|
||
|
writer.putString("Deposit");
|
||
|
writer.putInt(-1760114543);
|
||
|
writer.putInt(1);
|
||
|
writer.put((byte) 0);
|
||
|
|
||
|
} else if (this.player.getGuild().equals(warehouseBuilding.getGuild()) && (GuildStatusController.isInnerCouncil(this.player.getGuildStatus()))) {
|
||
|
writer.putInt(4);
|
||
|
writer.putString("Lock");
|
||
|
writer.putInt(2393548);
|
||
|
writer.putInt(1); //locked? on/off
|
||
|
writer.put((byte) 0);
|
||
|
writer.putString("Deposit");
|
||
|
writer.putInt(-1760114543);
|
||
|
|
||
|
writer.putInt(1);
|
||
|
writer.put((byte) 0);
|
||
|
writer.putString("Manage Mines");
|
||
|
writer.putInt(-820683698);
|
||
|
writer.putInt(1);
|
||
|
writer.put((byte) 0);
|
||
|
writer.putString("Withdraw");
|
||
|
writer.putInt(-530228289);
|
||
|
writer.putInt(1);
|
||
|
writer.put((byte) 0);
|
||
|
} else {
|
||
|
writer.putInt(2);
|
||
|
writer.putString("Lock");
|
||
|
writer.putInt(2393548);
|
||
|
writer.putInt(0); //locked? on/off
|
||
|
writer.put((byte) 0);
|
||
|
writer.putString("Deposit");
|
||
|
writer.putInt(-1760114543);
|
||
|
writer.putInt(1);
|
||
|
writer.put((byte) 0);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||
|
*/
|
||
|
@Override
|
||
|
protected void _deserialize(ByteBufferReader reader) {
|
||
|
reader.getInt();
|
||
|
reader.getInt();
|
||
|
reader.getInt();
|
||
|
reader.getInt();
|
||
|
reader.getInt();
|
||
|
reader.getInt();
|
||
|
reader.getInt();
|
||
|
reader.getInt();
|
||
|
reader.getInt();
|
||
|
reader.getInt();
|
||
|
reader.getInt();
|
||
|
reader.getInt();
|
||
|
reader.getInt();
|
||
|
// this.locX = reader.getFloat();
|
||
|
// this.locY = reader.getFloat();
|
||
|
// this.locZ = reader.getFloat();
|
||
|
// this.name = reader.getString();
|
||
|
// this.unknown01 = reader.getInt();
|
||
|
}
|
||
|
|
||
|
public void setGuild(Guild guild) {
|
||
|
this.guild = guild;
|
||
|
}
|
||
|
|
||
|
public void setWarehouseBuilding(Building warehouseBuilding) {
|
||
|
this.warehouseBuilding = warehouseBuilding;
|
||
|
}
|
||
3 years ago
|
}
|