Merged projectswg/holocore into development

This commit is contained in:
Z61
2015-05-29 06:42:57 -04:00
13 changed files with 80 additions and 63 deletions
+3 -3
View File
@@ -1,11 +1,11 @@
### **Branch** ###
**Development:** Upload your Pull Requests here so it can be tested
**Quality Assurance:** Upload your Pull Requests here so it can be tested
**Development:** This is the main working space
**Master:** Tested and approved commits will be moved to this branch (Test Center)
**Release:** This is the live version of latest code run on Live Server (Tydirium)
--------------------------------------------------------------------------------
![holocore.png](https://bitbucket.org/repo/norXdj/images/3473411954-holocore.png)
+1
View File
@@ -0,0 +1 @@
# 29/05/2015 00:41:40 CDT
+10
View File
@@ -0,0 +1,10 @@
# 29/05/2015 00:41:40 CDT
AUTO-LOGIN=0
LOGIN-PORT=44453
LOGIN-SERVER-ID=1
LOGIN-SERVER-NAME=LoginServer
LOGIN-VERSION-CHECKS=true
MAX-PACKET-SIZE=496
SESSION-TOKEN-LENGTH=24
ZONE-SERVER-ID=1
ZONE-SERVER-NAME=Localhost
+8 -15
View File
@@ -1,18 +1,11 @@
#Fri May 22 01:51:04 CDT 2015
# 29/05/2015 00:41:40 CDT
CLEAN-CHARACTER-DATA=0
LOAD-BUILDOUTS=false
LOCAL-USER=nge
LOGIN-SERVER-NAME=LoginServer
AUTO-LOGIN=0
SESSION-TOKEN-LENGTH=24
LOGIN-PORT=44453
PACKET-DEBUG=false
MAX-PACKET-SIZE=496
LOCAL-DB=nge
LOGIN-SERVER-ID=1
WIPE-ODB-FILES=0
LOCAL-PASS=nge
ENABLE-LOGGING=true
GALAXY-MAX-CHARACTERS=2
GALAXY-MAX-ONLINE=3000
ENABLE-LOGGING=true
LOGIN-VERSION-CHECKS=true
LOAD-BUILDOUTS=false
LOCAL-DB=nge
LOCAL-PASS=nge
LOCAL-USER=nge
PACKET-DEBUG=false
WIPE-ODB-FILES=0
+6 -1
View File
@@ -28,7 +28,12 @@
package resources.config;
public enum ConfigFile {
PRIMARY ("nge.cfg");
/** Meant for general purpose configuration or debugging */
PRIMARY ("cfg/nge.cfg"),
/** Meant for networking-related configuration. Includes Login and Zone configuration */
NETWORK ("cfg/network.cfg"),
/** Meant for specific in-game features that may be better disabled or tweaked */
FEATURES("cfg/features.cfg");
private String filename;
@@ -154,7 +154,7 @@ final class ServerPublicInterface {
}
private InetAddress getBindAddr() {
Config c = DataManager.getInstance().getConfig(ConfigFile.PRIMARY);
Config c = DataManager.getInstance().getConfig(ConfigFile.NETWORK);
try {
if (c.containsKey("BIND-ADDR"))
return InetAddress.getByName(c.getString("BIND-ADDR", "127.0.0.1"));
+30 -26
View File
@@ -50,6 +50,7 @@ import resources.network.BaselineBuilder;
import resources.network.DeltaBuilder;
import resources.player.Player;
import resources.player.PlayerState;
import resources.server_info.Log;
import utilities.Encoder.StringType;
public class SWGObject implements Serializable, Comparable<SWGObject> {
@@ -110,19 +111,17 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
int arrangementId = getArrangementId(object);
if (arrangementId == -1) {
containedObjects.put(object.getObjectId(), object);
object.parent = this;
object.containerPermissions.setOwner(objectId);
return true;
}
// Not a child object, so time to check the slots!
} else {
// Not a child object, so time to check the slots!
// Check to make sure this object is able to go into a slot in the parent
List<String> requiredSlots = object.getArrangement().get(arrangementId - 4);
// Note that some objects don't have a descriptor, meaning it has no slots
// Check to make sure this object is able to go into a slot in the parent
List<String> requiredSlots = object.getArrangement().get(arrangementId - 4);
// Note that some objects don't have a descriptor, meaning it has no slots
// Add object to the slot
for (String requiredSlot : requiredSlots) {
slots.put(requiredSlot, object);
// Add object to the slot
for (String requiredSlot : requiredSlots) {
slots.put(requiredSlot, object);
}
}
object.parent = this;
@@ -139,13 +138,11 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
// This object is a container object, so remove it from the container
if (object.getSlotArrangement() == -1) {
containedObjects.remove(object.objectId);
object.parent = null;
return;
}
for (String slot : (slotArrangement == -1 ?
object.getArrangement().get(0) : object.getArrangement().get(slotArrangement - 4))) {
slots.put(slot, null);
} else {
for (String slot : (slotArrangement == -1 ?
object.getArrangement().get(0) : object.getArrangement().get(slotArrangement - 4))) {
slots.put(slot, null);
}
}
object.parent = null;
@@ -175,7 +172,7 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
// TODO Slot occupation check, old version was not working properly, always returning SLOT_OCCUPIED
// Get a pre-parent-removal list of the observers so we can send create/destroy/update messages
List<SWGObject> oldObservers = getObjectsAware();
List<SWGObject> oldObservers = getChildrenAwareness();
// Remove this object from the old parent if one exists
if (parent != null) {
@@ -185,7 +182,7 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
container.addObject(this);
// Observer notification
sendUpdatedContainment(oldObservers, new ArrayList<>(container.getObjectsAware()));
sendUpdatedContainment(oldObservers, new ArrayList<>(container.getChildrenAwareness()));
return ContainerResult.SUCCESS;
}
@@ -472,6 +469,7 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
}
protected void createObject(Player target) {
Log.i("ContainerPermissions", "Sending baselines for %s with owner %s to %s", this, this.getOwner(), target);
sendSceneCreateObject(target);
createChildrenObjects(target);
target.sendPacket(new SceneEndBaselines(getObjectId()));
@@ -487,14 +485,14 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
awarenessOutOfRange(o);
}
}
public List <SWGObject> getObjectsAware() {
synchronized (objectsAware) {
return Collections.unmodifiableList(getChildrenAwareness());
return Collections.unmodifiableList(objectsAware);
}
}
private List<SWGObject> getChildrenAwareness() {
public List<SWGObject> getChildrenAwareness() {
List<SWGObject> awareness = new ArrayList<>(objectsAware);
if (getParent() != null && !(awareness.contains(getParent())))
@@ -519,6 +517,8 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
if (p == null || p.getPlayerState() != PlayerState.ZONED_IN)
continue;
p.sendPacket(packets);
//System.out.println("Sent " + packets + " for " + this + " to objAware " + obj);
}
List<SWGObject> childrenAwareness = getChildrenAwareness();
@@ -526,19 +526,23 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
childrenAwareness.remove(this); // Remove self since only observers being notified
for (SWGObject childObserver : childrenAwareness) {
if (childObserver == null)
if (childObserver == null || childObserver == this)
continue;
Player p = childObserver.getOwner();
if (p == null || p.getPlayerState() != PlayerState.ZONED_IN)
if (p == null || getOwner() == p || p.getPlayerState() != PlayerState.ZONED_IN)
continue;
p.sendPacket(packets);
//System.out.println("Sent " + packets + " of " + this + " to child " + childObserver);
}
SWGObject parent = getParent();
if(parent != null)
if(parent != null) {
parent.sendObservers(packets);
//System.out.println("Sent " + packets + " to observers of " + this);
}
}
}
@@ -122,7 +122,7 @@ public class NetworkClientManager extends Manager {
outPacket.setCrcLength(2);
outPacket.setEncryptionFlag((short) 1);
outPacket.setXorLength((byte) 4);
outPacket.setUdpSize(getConfig(ConfigFile.PRIMARY).getInt("MAX-PACKET-SIZE", 496));
outPacket.setUdpSize(getConfig(ConfigFile.NETWORK).getInt("MAX-PACKET-SIZE", 496));
sendPacket(client.getNetworkId(), outPacket);
}
@@ -72,13 +72,13 @@ public class NetworkListenerService extends Service {
@Override
public boolean initialize() {
Config primary = getConfig(ConfigFile.PRIMARY);
int packetSize = primary.getInt("MAX-PACKET-SIZE", 496);
InetAddress loginBind = getBindAddr(primary, "LOGIN-BIND-ADDR", "BIND-ADDR");
InetAddress zoneBind = getBindAddr(primary, "ZONE-BIND-ADDR", "BIND-ADDR");
InetAddress pingBind = getBindAddr(primary, "PING-BIND-ADDR", "BIND-ADDR");
Config network = getConfig(ConfigFile.NETWORK);
int packetSize = network.getInt("MAX-PACKET-SIZE", 496);
InetAddress loginBind = getBindAddr(network, "LOGIN-BIND-ADDR", "BIND-ADDR");
InetAddress zoneBind = getBindAddr(network, "ZONE-BIND-ADDR", "BIND-ADDR");
InetAddress pingBind = getBindAddr(network, "PING-BIND-ADDR", "BIND-ADDR");
boolean init = true;
init = login.initialize(loginBind, primary.getInt("LOGIN-PORT", 44453), packetSize) && init;
init = login.initialize(loginBind, network.getInt("LOGIN-PORT", 44453), packetSize) && init;
init = zone.initialize(zoneBind, galaxy.getZonePort(), packetSize) && init;
init = ping.initialize(pingBind, galaxy.getPingPort(), packetSize) && init;
return super.initialize() && isOperational() && init;
+5 -3
View File
@@ -253,10 +253,12 @@ public class ObjectManager extends Manager {
if (parent instanceof CreatureObject) {
((CreatureObject) parent).removeEquipment(object);
}
parent.removeObject(object);
}
object.sendObserversAndSelf(new SceneDestroyObject(objId));
object.sendObservers(new SceneDestroyObject(objId));
parent.removeObject(object);
} else {
object.sendObservers(new SceneDestroyObject(objId));
}
// Finally, remove from the awareness tree
deleteObject(object.getObjectId());
+5 -5
View File
@@ -96,7 +96,7 @@ public class LoginService extends Service {
getGalaxies = local.prepareStatement("SELECT * FROM galaxies");
getCharacters = local.prepareStatement("SELECT * FROM characters WHERE userid = ?");
deleteCharacter = local.prepareStatement("DELETE FROM CHARACTERS WHERE id = ?");
autoLogin = (getConfig(ConfigFile.PRIMARY).getInt("AUTO-LOGIN", 0) == 1 ? true : false);
autoLogin = (getConfig(ConfigFile.NETWORK).getInt("AUTO-LOGIN", 0) == 1 ? true : false);
return super.initialize();
}
@@ -113,14 +113,14 @@ public class LoginService extends Service {
}
private String getServerString() {
Config c = getConfig(ConfigFile.PRIMARY);
Config c = getConfig(ConfigFile.NETWORK);
String name = c.getString("LOGIN-SERVER-NAME", "LoginServer");
int id = c.getInt("LOGIN-SERVER-ID", 1);
return name + ":" + id;
}
private void sendServerInfo(Player player) {
Config c = getConfig(ConfigFile.PRIMARY);
Config c = getConfig(ConfigFile.NETWORK);
String name = c.getString("LOGIN-SERVER-NAME", "LoginServer");
int id = c.getInt("LOGIN-SERVER-ID", 1);
sendPacket(player.getNetworkId(), new ServerString(name + ":" + id));
@@ -141,7 +141,7 @@ public class LoginService extends Service {
System.err.println("Player cannot login when " + player.getPlayerState());
return;
}
final boolean doClientCheck = getConfig(ConfigFile.PRIMARY).getBoolean("LOGIN-VERSION-CHECKS", true);
final boolean doClientCheck = getConfig(ConfigFile.NETWORK).getBoolean("LOGIN-VERSION-CHECKS", true);
if (doClientCheck)
Log.d("LoginService", "Running login checks for %s", id.getUsername());
else
@@ -185,7 +185,7 @@ public class LoginService extends Service {
private void onSuccessfulLogin(ResultSet user, Player player, LoginClientId id) throws SQLException {
player.setUsername(id.getUsername());
player.setUserId(user.getInt("id"));
int tokenLength = getConfig(ConfigFile.PRIMARY).getInt("SESSION-TOKEN-LENGTH", 24);
int tokenLength = getConfig(ConfigFile.NETWORK).getInt("SESSION-TOKEN-LENGTH", 24);
byte [] sessionToken = new byte[tokenLength];
random.nextBytes(sessionToken);
player.setSessionToken(sessionToken);
+3 -1
View File
@@ -35,6 +35,7 @@ import java.util.Locale;
import java.util.Map;
import network.packets.Packet;
import network.packets.soe.SessionRequest;
import network.packets.soe.Disconnect.DisconnectReason;
import network.packets.swg.login.ClientIdMsg;
import network.packets.swg.zone.insertion.SelectCharacter;
@@ -238,7 +239,8 @@ public class PlayerManager extends Manager {
loginService.handlePacket(gpi, player, packet);
else if (type == ServerType.ZONE)
zoneService.handlePacket(gpi, player, networkId, packet);
}
} else if (type == ServerType.ZONE && packet instanceof SessionRequest)
zoneService.handlePacket(gpi, player, networkId, packet);
}
private void onNotifyPlayersPacketIntent(NotifyPlayersPacketIntent nppi) {
+1 -1
View File
@@ -239,7 +239,7 @@ public class ZoneService extends Service {
}
private void sendServerInfo(Galaxy galaxy, long networkId) {
Config c = getConfig(ConfigFile.PRIMARY);
Config c = getConfig(ConfigFile.NETWORK);
String name = c.getString("ZONE-SERVER-NAME", galaxy.getName());
int id = c.getInt("ZONE-SERVER-ID", galaxy.getId());
sendPacket(networkId, new ServerString(name + ":" + id));