Files
Server/src/engine/net/client/msg/chat/ChatGlobalMsg.java
T

90 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.chat;
import engine.net.AbstractConnection;
import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter;
import engine.net.client.Protocol;
import engine.objects.AbstractCharacter;
import engine.objects.AbstractWorldObject;
2023-06-07 13:37:43 -04:00
import engine.server.world.WorldServer;
2022-04-30 09:41:17 -04:00
public class ChatGlobalMsg extends AbstractChatMsg {
2023-07-15 09:23:48 -04:00
/**
* This is the general purpose constructor.
*/
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
//chat global is using leader channel protocolMsg now.
public ChatGlobalMsg(AbstractWorldObject source, String message) {
super(Protocol.LEADERCHANNELMESSAGE, source, message);
}
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 ChatGlobalMsg(AbstractConnection origin, ByteBufferReader reader) {
super(Protocol.LEADERCHANNELMESSAGE, origin, reader);
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
/**
* Copy constructor
*/
public ChatGlobalMsg(ChatGlobalMsg msg) {
super(msg);
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
/**
* Deserializes the subclass specific items from the supplied ByteBufferReader.
*/
@Override
protected void _deserialize(ByteBufferReader reader) {
this.sourceType = reader.getInt();
this.sourceID = reader.getInt();
this.unknown01 = reader.getInt();
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
this.message = reader.getString();
this.sourceName = reader.getString();
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
this.unknown02 = reader.getInt();
reader.getInt();
reader.getInt();
reader.getInt();
}
/**
* Serializes the subclass specific items to the supplied ByteBufferWriter.
*/
@Override
protected void _serialize(ByteBufferWriter writer) {
writer.putInt(this.sourceType);
writer.putInt(this.sourceID);
writer.putInt(this.unknown01);
writer.putString(this.message);
if (this.source == null) {
// TODO log error here
writer.putString("");
writer.putInt(0);
} else {
2023-06-07 13:37:43 -04:00
writer.putString(((AbstractCharacter) this.source).getFirstName());
writer.putInt(WorldServer.worldMapID);
2023-07-15 09:23:48 -04:00
}
writer.putInt(0);
writer.putInt(0);
writer.putInt(0);
}
2022-04-30 09:41:17 -04:00
}