Merge branch 'quality_assurance' of bitbucket.org:projectswg/holocore into quality_assurance

This commit is contained in:
Obique PSWG
2015-08-18 09:01:00 -05:00
12 changed files with 61 additions and 207 deletions
+1 -5
View File
@@ -1,5 +1 @@
<<<<<<< Updated upstream
# 12/08/2015 21:56:03 CDT
=======
# 15/08/2015 18:18:06 CDT
>>>>>>> Stashed changes
# 18/08/2015 08:24:35 EDT
+1 -5
View File
@@ -1,8 +1,4 @@
<<<<<<< Updated upstream
# 12/08/2015 21:56:03 CDT
=======
# 15/08/2015 18:18:06 CDT
>>>>>>> Stashed changes
# 18/08/2015 08:24:35 EDT
AUTO-LOGIN=0
LOGIN-PORT=44453
LOGIN-SERVER-ID=1
+1 -5
View File
@@ -1,8 +1,4 @@
<<<<<<< Updated upstream
# 12/08/2015 21:56:03 CDT
=======
# 15/08/2015 18:18:06 CDT
>>>>>>> Stashed changes
# 18/08/2015 08:24:35 EDT
CLEAN-CHARACTER-DATA=0
ENABLE-LOGGING=true
GALAXY-MAX-CHARACTERS=1000000
+1 -1
View File
@@ -22,4 +22,4 @@ BeastMastery Beast Mastery chat for this galaxy
Auction Auction chat for this galaxy
GuildLeader Guild leader chat for this galaxy
Mayor Mayor chat for this galaxy
Trader Trader chat for this galaxy
Trader Trader chat for this galaxy
+1 -1
View File
@@ -11,4 +11,4 @@ naboo
rori
tatooine
talus
yavin4
yavin4
+1 -1
View File
@@ -104,4 +104,4 @@ object/building/mustafar/structures/must_mining_clone_marker.iff cloningfacilit
object/building/naboo/rori_restuss_starport.iff starport
object/building/naboo/rori_restuss_shuttleport.iff shuttleport
object/building/dathomir/dathomir_quarantine_zone_starport.iff starport
object/building/dathomir/dathomir_quarantine_zone_cantina.iff cantina
object/building/dathomir/dathomir_quarantine_zone_cantina.iff cantina
+1 -1
View File
@@ -34,4 +34,4 @@ dathomir Trade Outpost 599 3071
dathomir Quarentine Zone -5780 -6550
dathomir Science Outpost -85 -1600
lok Nym's Stronghold 440 5029
lok Imperial Outpost -1920 -3084
lok Imperial Outpost -1920 -3084
@@ -28,21 +28,20 @@
package network.packets.swg.zone.chat;
import network.packets.swg.SWGPacket;
import resources.chat.ChatAvatar;
import java.nio.ByteBuffer;
public class ChatFriendsListUpdate extends SWGPacket {
public static final int CRC = getCrc("ChatFriendsListUpdate");
private String galaxy;
private String friendName;
private ChatAvatar friend;
private boolean online;
public ChatFriendsListUpdate() {}
public ChatFriendsListUpdate(String galaxy, String friendName, boolean online) {
this.galaxy = galaxy;
this.friendName = friendName;
public ChatFriendsListUpdate(ChatAvatar friend, boolean online) {
this.friend = friend;
this.online = online;
}
@@ -53,26 +52,20 @@ public class ChatFriendsListUpdate extends SWGPacket {
public void decode(ByteBuffer data) {
if (!super.decode(data, CRC))
return;
// TODO: Use ChatAvatar
getAscii(data); // SWG
galaxy = getAscii(data);
friendName = getAscii(data);
friend = getEncodable(data, ChatAvatar.class);
online = getBoolean(data);
}
public ByteBuffer encode() {
int stringLength = 9 + galaxy.length() + friendName.length();
ByteBuffer data = ByteBuffer.allocate(stringLength + 7);
ByteBuffer data = ByteBuffer.allocate(7 + friend.encode().length);
addShort (data, 3);
addInt (data, CRC);
addAscii (data, "SWG");
addAscii (data, galaxy);
addAscii (data, friendName);
addEncodable(data, friend);
addBoolean(data, online);
return data;
}
public String getFriendName() {
return friendName;
public ChatAvatar getFriend() {
return friend;
}
}
@@ -1,50 +0,0 @@
/*******************************************************************************
* 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 {
public 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;
}
}
@@ -1,73 +0,0 @@
/*******************************************************************************
* 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;
import java.util.List;
/**
* @author Waverunner
*/
public class ChatOnGetFriendsList extends SWGPacket {
public static final int CRC = 0xE97AB594;
private List<String> friends;
private String galaxy;
private long objectId;
public ChatOnGetFriendsList(long objectId, String galaxy, List<String> friends) {
this.objectId = objectId;
this.galaxy = galaxy;
this.friends = friends;
}
@Override
public ByteBuffer encode() {
int additional = galaxy.length() + 9;
int length = 0;
for (String friend : friends) {
length += friend.length() + additional;
}
ByteBuffer bb = ByteBuffer.allocate(18 + length);
addShort(bb, 3);
addInt(bb, CRC);
addLong(bb, objectId);
addInt(bb, friends.size());
for (String friend : friends) {
addAscii(bb, "SWG");
addAscii(bb, galaxy);
addAscii(bb, friend);
}
return bb;
}
}
+20 -12
View File
@@ -72,13 +72,13 @@ public final class ServerFactory extends DataFactory {
File iff = new File(name);
if (!iff.exists()) {
convertSif(path, name);
convertSdf(path, name);
System.out.println("Created Server Datatable: " + name);
Log.i("ServerFactory", "Created Server Datatable: %s", name);
} else {
File sif = path.toFile();
if (sif.lastModified() > iff.lastModified()) {
convertSif(path, name);
convertSdf(path, name);
System.out.println("Updated Server Datatable: " + name);
Log.i("ServerFactory", "Updated Server Datatable: %s", name);
}
@@ -99,7 +99,7 @@ public final class ServerFactory extends DataFactory {
});
}
private void convertSif(Path sif, String newPath) {
private void convertSdf(Path sif, String newPath) {
SWGFile swgFile = new SWGFile(newPath, "DTII");
DatatableData data = (DatatableData) createDataObject(swgFile);
@@ -128,6 +128,7 @@ public final class ServerFactory extends DataFactory {
lineNum++;
if (lineNum == 0) {
columnNames = row.split("\t");
itr.remove();
} else if (lineNum == 1) {
columnTypes = row.split("\t");
for (int i = 0; i < columnTypes.length; i++) {
@@ -141,18 +142,19 @@ public final class ServerFactory extends DataFactory {
defaultValues.add("");
}
}
itr.remove();
}
itr.remove();
}
if (columnNames == null || columnTypes == null) {
System.err.println("Failed to convert sif " + sif.getFileName());
System.err.println("Failed to convert sdf " + sif.getFileName());
return;
}
table = new Object[rows.size()][columnTypes.length];
for (int i = 0; i < rows.size(); i++) {
System.out.println(rows.get(i));
createDatatableRow(i, rows.get(i), columnTypes, table, defaultValues);
}
@@ -177,14 +179,20 @@ public final class ServerFactory extends DataFactory {
if (val.isEmpty() && !defValues.get(t).isEmpty())
val = defValues.get(t);
switch(type) {
case "b": table[rowNum][t] = Boolean.valueOf(val); break;
case "h":
case "i": table[rowNum][t] = Integer.valueOf(val); break;
case "f": table[rowNum][t] = Float.valueOf(val); break;
case "s": table[rowNum][t] = val; break;
default: System.err.println("Don't know how to parse type " + type); break;
try {
switch(type) {
case "b": table[rowNum][t] = Boolean.valueOf(val); break;
case "h":
case "i": table[rowNum][t] = Integer.valueOf(val); break;
case "f": table[rowNum][t] = Float.valueOf(val); break;
case "s": table[rowNum][t] = val; break;
default: System.err.println("Don't know how to parse type " + type); break;
}
} catch (NumberFormatException e) {
Log.e("ServerFactory:createDatableRow", "Cannot format string %s to a number", val);
e.printStackTrace();
}
}
}
+24 -36
View File
@@ -43,6 +43,7 @@ import network.packets.swg.zone.chat.ChatSystemMessage.SystemChatType;
import network.packets.swg.zone.object_controller.SpatialChat;
import resources.Galaxy;
import resources.Terrain;
import resources.chat.ChatAvatar;
import resources.chat.ChatResult;
import resources.collections.SWGList;
import resources.control.Intent;
@@ -176,14 +177,14 @@ public class ChatManager extends Manager {
break;
case PE_FIRST_ZONE:
sendPersistentMessageHeaders(player, intent.getGalaxy());
updateChatAvatarStatus(player, intent.getGalaxy(), true);
updateChatAvatarStatus(player, true);
if (player.getPlayerObject() != null)
roomService.enterChatChannels(player, player.getPlayerObject().getJoinedChannels());
break;
case PE_LOGGED_OUT:
if (player.getCreatureObject() == null)
break;
updateChatAvatarStatus(player, intent.getGalaxy(), false);
updateChatAvatarStatus(player, false);
break;
default: break;
}
@@ -208,9 +209,11 @@ public class ChatManager extends Manager {
private void handleChatAvatarStatusRequestIntent(ChatAvatarRequestIntent i) {
switch (i.getRequestType()) {
case TARGET_STATUS:
sendTargetAvatarStatus(i.getPlayer(), i.getTarget());
case TARGET_STATUS: {
Player player = i.getPlayer();
sendTargetAvatarStatus(player, new ChatAvatar(0, i.getTarget(), player.getGalaxyName()));
break;
}
case IGNORE_REMOVE_TARGET:
break;
case IGNORE_ADD_TARGET:
@@ -235,7 +238,6 @@ public class ChatManager extends Manager {
return;
SWGList<String> friends = (SWGList<String>) ghost.getFriendsList();
player.sendPacket(new ChatOnGetFriendsList(player.getCreatureObject().getObjectId(), player.getGalaxyName(), friends));
friends.sendRefreshedListData(ghost);
}
@@ -245,14 +247,9 @@ public class ChatManager extends Manager {
if (ghost == null)
return;
ChatOnChangeFriendStatus friendStatus = new ChatOnChangeFriendStatus(
player.getCreatureObject().getObjectId(), player.getGalaxyName(), target, true);
player.sendPacket(friendStatus);
ghost.removeFriend(target);
new ChatBroadcastIntent(player, new ProsePackage("@cmnty:friend_removed", "TT", target)).broadcast();
new ChatBroadcastIntent(player, new ProsePackage("StringId", "@cmnty:friend_removed", "TT", target)).broadcast();
}
private void handleAddFriend(Player player, String target) {
@@ -264,27 +261,22 @@ public class ChatManager extends Manager {
return;
if (ghost.getFriendsList().contains(target)) {
new ChatBroadcastIntent(player, new ProsePackage("@cmnty:friend_duplicate", "TT", target)).broadcast();
new ChatBroadcastIntent(player, new ProsePackage("StringId", "@cmnty:friend_duplicate", "TT", target)).broadcast();
return;
}
if (!player.getPlayerManager().playerExists(target)) {
new ChatBroadcastIntent(player, new ProsePackage("@cmnty:friend_not_found", "TT", target)).broadcast();
new ChatBroadcastIntent(player, new ProsePackage("StringId", "@cmnty:friend_not_found", "TT", target)).broadcast();
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("StringId", "@cmnty:friend_added", "TT", target)).broadcast();
Player targetPlayer = player.getPlayerManager().getPlayerByCreatureFirstName(target);
if (targetPlayer != null && targetPlayer.getPlayerState() == PlayerState.ZONED_IN)
player.sendPacket(new ChatFriendsListUpdate(player.getGalaxyName(), target, true));
ghost.addFriend(target);
new ChatBroadcastIntent(player, new ProsePackage("@cmnty:friend_added", "TT", target)).broadcast();
player.sendPacket(new ChatFriendsListUpdate(new ChatAvatar(0, target, targetPlayer.getGalaxyName()), true));
}
private void handleSpatialChat(SpatialChatIntent i) {
@@ -387,48 +379,44 @@ public class ChatManager extends Manager {
/* Friends */
private void updateChatAvatarStatus(Player player, String galaxy, boolean online) {
private void updateChatAvatarStatus(Player player, boolean online) {
PlayerManager playerManager = player.getPlayerManager();
String firstName = player.getCharacterName().toLowerCase();
if (firstName.contains(" "))
firstName = firstName.substring(0, firstName.indexOf(' '));
ChatAvatar avatar = ChatAvatar.getFromPlayer(player);
String galaxy = player.getGalaxyName();
if (online) {
PlayerObject playerObject = player.getPlayerObject();
if (playerObject != null && playerObject.getFriendsList().size() <= 0) {
for (String friend : playerObject.getFriendsList()) {
sendTargetAvatarStatus(player, friend);
sendTargetAvatarStatus(player, new ChatAvatar(0, friend, galaxy));
}
}
}
final ChatFriendsListUpdate update = new ChatFriendsListUpdate(galaxy, firstName, online);
final ChatFriendsListUpdate update = new ChatFriendsListUpdate(avatar, online);
playerManager.notifyPlayers(playerNotified -> {
if (playerNotified.getPlayerState() != PlayerState.ZONED_IN)
return false;
PlayerObject playerObject = playerNotified.getPlayerObject();
if (playerObject == null || playerObject.getFriendsList().size() <= 0)
return false;
return playerObject != null && playerObject.getFriendsList().contains(update.getFriend().getName());
List<String> friends = playerObject.getFriendsList();
return friends.contains(update.getFriendName());
}, update);
}
private void sendTargetAvatarStatus(Player player, String target) {
private void sendTargetAvatarStatus(Player player, ChatAvatar target) {
PlayerObject object = player.getPlayerObject();
if (object == null)
return;
Player targetPlayer = player.getPlayerManager().getPlayerByCreatureFirstName(target);
Player targetPlayer = player.getPlayerManager().getPlayerByCreatureFirstName(target.getName());
boolean online = true;
if (targetPlayer == null || targetPlayer.getPlayerState() != PlayerState.ZONED_IN)
online = false;
ChatFriendsListUpdate update = new ChatFriendsListUpdate(player.getGalaxyName(), target, online);
player.sendPacket(update);
player.sendPacket(new ChatFriendsListUpdate(target, online));
}
private void broadcastAreaMessage(String message, Player broadcaster) {