Merge branch 'master' of github.com:ProjectSWGCore/NGECore2

This commit is contained in:
darkk1138
2013-12-09 22:54:57 +01:00
18 changed files with 125 additions and 191 deletions
-68
View File
@@ -1,68 +0,0 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.objects;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import org.python.google.common.collect.ArrayListMultimap;
import org.python.google.common.collect.Multimap;
import com.sleepycat.persist.model.Persistent;
import com.sleepycat.persist.model.PersistentProxy;
@Persistent(proxyFor=Multimap.class)
public class MultimapProxy<K, V> implements PersistentProxy<Multimap<K, V>> {
private int size = 0;
private K[] keys;
private V[] values;
private MultimapProxy() { }
public void initializeProxy(Multimap<K, V> object) {
List<K> keyList = new ArrayList<K>();
List<V> valueList = new ArrayList<V>();
for (Entry<K, V> entry : object.entries()) {
keyList.add(entry.getKey());
valueList.add(entry.getValue());
}
size = object.entries().size();
keys = keyList.toArray(keys);
values = valueList.toArray(values);
}
public Multimap<K, V> convertProxy() {
Multimap<K, V> map = ArrayListMultimap.create();
for (int i = 0; i < size; i++) {
map.put(keys[i], values[i]);
}
return map;
}
}
+46 -12
View File
@@ -28,6 +28,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import main.NGECore;
@@ -66,6 +67,7 @@ import protocol.swg.objectControllerObjects.DataTransform;
import protocol.swg.objectControllerObjects.DataTransformWithParent;
import protocol.swg.objectControllerObjects.TargetUpdate;
import resources.objects.building.BuildingObject;
import resources.objects.cell.CellObject;
import resources.objects.creature.CreatureObject;
import resources.objects.player.PlayerObject;
@@ -175,23 +177,46 @@ public class SimulationService implements INetworkDispatch {
public boolean add(SWGObject object, float x, float y, boolean notifyObservers) {
object.setIsInQuadtree(true);
core.objectService.loadServerTemplate(object);
boolean success = quadTrees.get(object.getPlanet().getName()).put(x, y, object);
if(success && notifyObservers) {
Point3D pos = new Point3D(x, 0, y);
Collection<SWGObject> newAwareObjects = get(object.getPlanet(), x, y, 512);
for(Iterator<SWGObject> it = newAwareObjects.iterator(); it.hasNext();) {
SWGObject obj = it.next();
if(obj.getAttachment("bigSpawnRange") == null && obj.getWorldPosition().getDistance(pos) > 200)
continue;
if(object.getClient() != null)
object.makeAware(obj);
if(obj.getClient() != null)
obj.makeAware(object);
if(success) {
Vector<SWGObject> childObjects = (Vector<SWGObject>) object.getAttachment("childObjects");
if(childObjects != null) {
addChildObjects(object, childObjects);
object.setAttachment("childObjects", null);
}
if(notifyObservers) {
Point3D pos = new Point3D(x, 0, y);
Collection<SWGObject> newAwareObjects = get(object.getPlanet(), x, y, 512);
for(Iterator<SWGObject> it = newAwareObjects.iterator(); it.hasNext();) {
SWGObject obj = it.next();
if(obj.getAttachment("bigSpawnRange") == null && obj.getWorldPosition().getDistance(pos) > 200)
continue;
if(object.getClient() != null)
object.makeAware(obj);
if(obj.getClient() != null)
obj.makeAware(object);
}
}
}
return success;
}
public void addChildObjects(SWGObject object, Vector<SWGObject> childObjects) {
for(SWGObject childObject : childObjects) {
if(childObject.getAttachment("cellNumber") == null)
add(childObject, childObject.getWorldPosition().x, childObject.getWorldPosition().z, true);
else {
BuildingObject building = (BuildingObject) object;
CellObject cell = building.getCellByCellNumber((Integer) childObject.getAttachment("cellNumber"));
if(cell == null)
continue;
cell.add(childObject);
}
}
}
public boolean move(SWGObject object, int oldX, int oldY, int newX, int newY) {
if(quadTrees.get(object.getPlanet().getName()).remove(oldX, oldY, object)) {
@@ -419,7 +444,16 @@ public class SimulationService implements INetworkDispatch {
}
});
objControllerOpcodes.put(ObjControllerOpcodes.HOVER_TARGET, new INetworkRemoteEvent() {
@Override
public void handlePacket(IoSession session, IoBuffer data) throws Exception {
}
});
}
@Override
+6 -5
View File
@@ -54,12 +54,13 @@ public class FactionService implements INetworkDispatch {
this.core = core;
try {
/* Temporarily commented until another commit
StfTable stf = new StfTable("string/en/faction/faction_names.stf");
/*
StfTable stf = new StfTable("clientdata/string/en/faction/faction_names.stf");
for (int s = 1; s < strings.length; s++) {
if (strings[0] != null) {
String faction = ((String) strings[s][0]);
for (int s = 1; s < stf.getRowCount(); s++) {
String faction = stf.getStringById(s).getKey();
if (faction != null && faction != "") {
factionMap.put(faction, CRC.StringtoCRC(faction));
}
}
+31 -14
View File
@@ -33,6 +33,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -643,29 +644,45 @@ public class ObjectService implements INetworkDispatch {
* @param position The position as an offset to the parent object.
* @param orientation The orientation as an offset to the parent object.
*/
public void createChildObject(SWGObject parent, String template, Point3D position, Quaternion orientation) {
public void createChildObject(SWGObject parent, String template, Point3D position, Quaternion orientation, int cellNumber) {
if(cellNumber == -1) {
float radians = parent.getRadians();
Point3D parentPos = parent.getWorldPosition();
float radians = parent.getRadians();
Point3D parentPos = parent.getWorldPosition();
float x = (float) ((Math.cos(radians) * position.x) + (Math.sin(radians) * position.z));
float y = position.y + parentPos.y;
float z = (float) ((Math.cos(radians) * position.z) - (Math.sin(radians) * position.x));
x += parentPos.x;
z += parentPos.z;
position = new Point3D(x, y, z);
orientation = MathUtilities.rotateQuaternion(orientation, radians, new Point3D(0, 1, 0));
}
float x = (float) ((Math.cos(radians) * position.x) + (Math.sin(radians) * position.z));
float y = position.y + parentPos.y;
float z = (float) ((Math.cos(radians) * position.z) - (Math.sin(radians) * position.x));
x += parentPos.x;
z += parentPos.z;
position = new Point3D(x, y, z);
orientation = MathUtilities.rotateQuaternion(orientation, radians, new Point3D(0, 1, 0));
SWGObject child = createObject(template, 0, parent.getPlanet(), position, orientation);
core.simulationService.add(child, x, z);
if(parent.getAttachment("childObjects") == null)
parent.setAttachment("childObjects", new Vector<SWGObject>());
((Vector<SWGObject>) parent.getAttachment("childObjects")).add(child);
if(cellNumber != -1)
child.setAttachment("cellNumber", cellNumber);
//core.simulationService.add(child, x, z);
}
public void createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw) {
createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0));
createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), -1);
}
public void createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw, int cellNumber) {
createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), cellNumber);
}
public void loadBuildoutObjects(Planet planet) throws InstantiationException, IllegalAccessException {