mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-09-11 21:45:26 -04:00
Fixed friends list causing issues when adding other players and relogging
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
from intents.chat import ChatAvatarRequestIntent
|
||||
from intents.chat import ChatBroadcastIntent
|
||||
from resources.encodables import ProsePackage
|
||||
from intents.chat.ChatAvatarRequestIntent.RequestType import TARGET_STATUS
|
||||
import sys
|
||||
from intents.chat.ChatAvatarRequestIntent.RequestType import FRIEND_ADD_TARGET
|
||||
|
||||
def execute(galacticManager, player, target, args):
|
||||
ghost = player.getPlayerObject()
|
||||
@@ -19,11 +18,8 @@ def execute(galacticManager, player, target, args):
|
||||
return
|
||||
|
||||
if galacticManager.getPlayerManager().playerExists(name) is False:
|
||||
ChatBroadcastIntent(player, ProsePackage("@cmnty:friend_duplicate", "TT", name)).broadcast()
|
||||
ChatBroadcastIntent(player, ProsePackage("@cmnty:friend_not_found", "TT", name)).broadcast()
|
||||
return
|
||||
|
||||
ghost.addFriend(name)
|
||||
ChatBroadcastIntent(player, ProsePackage("@cmnty:friend_added", "TT", name)).broadcast()
|
||||
|
||||
ChatAvatarRequestIntent(player, name, TARGET_STATUS).broadcast()
|
||||
ChatAvatarRequestIntent(player, name, FRIEND_ADD_TARGET).broadcast()
|
||||
return
|
||||
|
||||
@@ -61,6 +61,8 @@ public class ChatAvatarRequestIntent extends Intent{
|
||||
|
||||
public enum RequestType {
|
||||
TARGET_STATUS,
|
||||
FRIEND_ADD_TARGET,
|
||||
FRIEND_REMOVE_TARGET,
|
||||
IGNORE_ADD_TARGET,
|
||||
IGNORE_REMOVE_TARGET
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 /// Project SWG /// www.projectswg.com
|
||||
*
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies.
|
||||
* Our goal is to create an emulator which will provide a server for players to
|
||||
* continue playing a game similar to the one they used to play. We are basing
|
||||
* it on the final publish of the game prior to end-game events.
|
||||
*
|
||||
* This file is part of Holocore.
|
||||
*
|
||||
* --------------------------------------------------------------------------------
|
||||
*
|
||||
* Holocore is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Holocore is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Holocore. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
|
||||
package network.packets.swg.zone.chat;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* @author Waverunner
|
||||
*/
|
||||
public class ChatOnAddFriend extends SWGPacket {
|
||||
private static final int CRC = 0x2B2A0D94;
|
||||
|
||||
public ChatOnAddFriend() {}
|
||||
|
||||
@Override
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer bb = ByteBuffer.allocate(14);
|
||||
addShort(bb, 3);
|
||||
addInt(bb, CRC);
|
||||
addLong(bb, 0);
|
||||
return bb;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 /// Project SWG /// www.projectswg.com
|
||||
*
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies.
|
||||
* Our goal is to create an emulator which will provide a server for players to
|
||||
* continue playing a game similar to the one they used to play. We are basing
|
||||
* it on the final publish of the game prior to end-game events.
|
||||
*
|
||||
* This file is part of Holocore.
|
||||
*
|
||||
* --------------------------------------------------------------------------------
|
||||
*
|
||||
* Holocore is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Holocore is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Holocore. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
|
||||
package network.packets.swg.zone.chat;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* @author Waverunner
|
||||
*/
|
||||
public class ChatOnChangeFriendStatus extends SWGPacket {
|
||||
public static final int CRC = 0x54336726;
|
||||
|
||||
private String galaxy;
|
||||
private String friendName;
|
||||
private boolean remove;
|
||||
private long playerID;
|
||||
|
||||
public ChatOnChangeFriendStatus(long playerID, String galaxy, String friendName, boolean remove) {
|
||||
this.playerID = playerID;
|
||||
this.galaxy = galaxy;
|
||||
this.friendName = friendName;
|
||||
this.remove = remove;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer bb = ByteBuffer.allocate(32 + galaxy.length() + friendName.length());
|
||||
addShort(bb, ((short) 0x06));
|
||||
addInt(bb, CRC);
|
||||
addLong(bb, playerID);
|
||||
addAscii(bb, "SWG");
|
||||
addAscii(bb, galaxy);
|
||||
addAscii(bb, friendName);
|
||||
addInt(bb, 0);
|
||||
addInt(bb, (remove ? 1 : 0));
|
||||
addByte(bb, 0);
|
||||
return bb;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import intents.chat.ChatBroadcastIntent;
|
||||
import intents.chat.PersistentMessageIntent;
|
||||
import intents.chat.SpatialChatIntent;
|
||||
import intents.network.GalacticPacketIntent;
|
||||
import intents.player.ZonePlayerSwapIntent;
|
||||
import intents.server.ServerStatusIntent;
|
||||
import network.packets.Packet;
|
||||
import network.packets.swg.SWGPacket;
|
||||
@@ -42,6 +43,8 @@ import network.packets.swg.zone.chat.ChatDeletePersistentMessage;
|
||||
import network.packets.swg.zone.chat.ChatFriendsListUpdate;
|
||||
import network.packets.swg.zone.chat.ChatInstantMessageToCharacter;
|
||||
import network.packets.swg.zone.chat.ChatInstantMessageToClient;
|
||||
import network.packets.swg.zone.chat.ChatOnAddFriend;
|
||||
import network.packets.swg.zone.chat.ChatOnChangeFriendStatus;
|
||||
import network.packets.swg.zone.chat.ChatOnSendInstantMessage;
|
||||
import network.packets.swg.zone.chat.ChatOnSendPersistentMessage;
|
||||
import network.packets.swg.zone.chat.ChatPersistentMessageToClient;
|
||||
@@ -89,6 +92,7 @@ public class ChatService extends Service {
|
||||
registerForIntent(ChatBroadcastIntent.TYPE);
|
||||
registerForIntent(ServerStatusIntent.TYPE);
|
||||
registerForIntent(ChatAvatarRequestIntent.TYPE);
|
||||
registerForIntent(ZonePlayerSwapIntent.TYPE);
|
||||
mails.load();
|
||||
mails.traverse(new Traverser<Mail>() {
|
||||
@Override
|
||||
@@ -197,7 +201,7 @@ public class ChatService extends Service {
|
||||
broadcastGalaxyMessage(i.getMessage());
|
||||
break;
|
||||
case PERSONAL:
|
||||
broadcastPersonalMessage(i.getProse(), i.getBroadcaster());
|
||||
broadcastPersonalMessage(i.getProse(), i.getBroadcaster(), i.getMessage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -211,9 +215,29 @@ public class ChatService extends Service {
|
||||
break;
|
||||
case IGNORE_ADD_TARGET:
|
||||
break;
|
||||
case FRIEND_ADD_TARGET:
|
||||
handleAddFriend(i.getPlayer(), i.getTarget());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAddFriend(Player player, String target) {
|
||||
PlayerObject ghost = player.getPlayerObject();
|
||||
if (ghost == null)
|
||||
return;
|
||||
|
||||
ChatOnChangeFriendStatus friendStatus = new ChatOnChangeFriendStatus(
|
||||
player.getCreatureObject().getObjectId(), player.getGalaxyName(), target, false);
|
||||
|
||||
player.sendPacket(new ChatOnAddFriend(), friendStatus);
|
||||
|
||||
ghost.addFriend(target);
|
||||
|
||||
new ChatBroadcastIntent(player, new ProsePackage("@cmnty:friend_added", "TT", target)).broadcast();
|
||||
|
||||
sendTargetAvatarStatus(player, target);
|
||||
}
|
||||
|
||||
private void handleChatRoomListRequest(Player player, ChatRequestRoomList request) {
|
||||
|
||||
}
|
||||
@@ -378,9 +402,11 @@ public class ChatService extends Service {
|
||||
new NotifyPlayersPacketIntent(packet).broadcast();
|
||||
}
|
||||
|
||||
private void broadcastPersonalMessage(ProsePackage prose, Player player) {
|
||||
OutOfBand pckg = new OutOfBand(prose);
|
||||
player.sendPacket(new ChatSystemMessage(SystemChatType.SCREEN_AND_CHAT, pckg));
|
||||
private void broadcastPersonalMessage(ProsePackage prose, Player player, String message) {
|
||||
if (prose != null)
|
||||
player.sendPacket(new ChatSystemMessage(SystemChatType.SCREEN_AND_CHAT, new OutOfBand(prose)));
|
||||
else
|
||||
player.sendPacket(new ChatSystemMessage(SystemChatType.SCREEN_AND_CHAT, message));
|
||||
}
|
||||
|
||||
private void sendPersistentMessageHeaders(Player player, String galaxy) {
|
||||
|
||||
Reference in New Issue
Block a user