Skip to content

Commit 2d4f115

Browse files
committed
Sync with diff on server box
aka Light's fixes
1 parent 0a04655 commit 2d4f115

13 files changed

Lines changed: 54 additions & 33 deletions

src/main/NGECore.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public class NGECore {
113113

114114
private volatile boolean isShuttingDown = false;
115115

116+
private long galacticTime = System.currentTimeMillis();
117+
116118
private ConcurrentHashMap<IoSession, Client> clients = new ConcurrentHashMap<IoSession, Client>();
117119

118120
// Database
@@ -542,5 +544,9 @@ public void initiateShutdown() {
542544

543545
}
544546

547+
public long getGalacticTime() {
548+
return System.currentTimeMillis() - this.galacticTime;
549+
}
550+
545551
}
546552

src/resources/common/SpawnPoint.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
import engine.resources.scene.Point3D;
2727
import engine.resources.scene.Quaternion;
28+
import java.util.Random;
29+
import main.NGECore;
30+
import services.TerrainService;
2831

2932
@Persistent
3033
public class SpawnPoint {
@@ -80,4 +83,24 @@ public void setCellNumber(int cellNumber) {
8083
this.cellNumber = cellNumber;
8184
}
8285

86+
public Point3D getRandomPosition(float minDistance, float maxDistance) {
87+
Random random = new Random();
88+
float distance = random.nextInt((int)(maxDistance - minDistance) + 1) + minDistance;
89+
float angle = (float)(random.nextInt(360) * 0.0174532925199433D);
90+
float x = (float)(this.position.x + distance * Math.cos(angle));
91+
float z = (float)(this.position.z + distance * Math.sin(angle));
92+
93+
return new Point3D(x, 0.0F, z);
94+
}
95+
96+
public static Point3D getRandomPosition(Point3D position, float minDistance, float maxDistance, int planetId) {
97+
Random random = new Random();
98+
float distance = random.nextInt((int)(maxDistance - minDistance) + 1) + minDistance;
99+
float angle = (float)(random.nextInt(360) * 0.0174532925199433D);
100+
float x = (float)(position.x + distance * Math.cos(angle));
101+
float z = (float)(position.z + distance * Math.sin(angle));
102+
103+
return new Point3D(x, NGECore.getInstance().terrainService.getHeight(planetId, x, z), z);
104+
}
105+
83106
}

src/resources/objects/ObjectMessageBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public IoBuffer createBaseline(String objectType, byte viewType, IoBuffer data,
6363
}
6464

6565
public IoBuffer createDelta(String objectType, byte viewType, short updateCount, short updateType, IoBuffer data, int size) {
66-
IoBuffer buffer = bufferPool.allocate(27 + size, false).order(ByteOrder.LITTLE_ENDIAN);
66+
IoBuffer buffer = bufferPool.allocate(23 + size, false).order(ByteOrder.LITTLE_ENDIAN);
6767

6868
buffer.putShort((short) 5);
6969
buffer.putInt(Opcodes.DeltasMessage);

src/resources/objects/guild/GuildMessageBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public IoBuffer buildBaseline6() {
7777
for (Entry<String, OtherServerGCWZonePercent> entry : guilds.getOtherServerGCWTotalPercentMap().entries()) capacity += (11 + entry.getKey().length() + entry.getValue().getBytes().length);
7878

7979
IoBuffer buffer = bufferPool.allocate(capacity, false).order(ByteOrder.LITTLE_ENDIAN);
80+
buffer.setAutoExpand(true);
8081
buffer.putShort((short) 9); // Object Count
8182
buffer.putInt(guilds.getServerId());
8283
buffer.put(getAsciiString(guilds.getSTFFile()));

src/resources/objects/player/PlayerMessageBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ public IoBuffer buildIgnoreRemoveDelta(List<String> ignoreList) {
611611
}
612612

613613
public IoBuffer buildFlagBitmask(int bitmask) {
614-
IoBuffer buffer = bufferPool.allocate(30, false).order(ByteOrder.LITTLE_ENDIAN);
614+
IoBuffer buffer = bufferPool.allocate(20, false).order(ByteOrder.LITTLE_ENDIAN);
615615
buffer.putInt(4);
616616
buffer.putInt(bitmask);
617617
buffer.putInt(0);

src/resources/objects/player/PlayerObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public void setTotalPlayTime(int totalPlayTime) {
195195
synchronized(objectMutex) {
196196
this.totalPlayTime = totalPlayTime;
197197
}
198-
getContainer().notifyObservers(messageBuilder.buildTotalPlayTimeDelta(totalPlayTime), true);
198+
notifyObservers(messageBuilder.buildTotalPlayTimeDelta(totalPlayTime), true);
199199
}
200200

201201
public String getHome() {

src/resources/objects/tangible/TangibleMessageBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public IoBuffer buildBaseline3() {
6363
buffer.putInt(0);
6464
buffer.putInt(0);
6565

66-
buffer.putInt(0);
67-
//buffer.putInt(tangible.getOptionsBitmask());
66+
//buffer.putInt(0);
67+
buffer.putInt(tangible.getOptionsBitmask());
6868
buffer.putInt(0); // number of item uses
6969
buffer.putInt(tangible.getConditionDamage());
7070
buffer.putInt(tangible.getMaxDamage());

src/resources/objects/tangible/TangibleObject.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,6 @@ public void sendBaselines(Client destination) {
357357

358358
destination.getSession().write(messageBuilder.buildBaseline3());
359359
destination.getSession().write(messageBuilder.buildBaseline6());
360-
destination.getSession().write(messageBuilder.buildBaseline8());
361-
destination.getSession().write(messageBuilder.buildBaseline9());
362360

363361
if(getPvPBitmask() != 0) {
364362
UpdatePVPStatusMessage upvpm = new UpdatePVPStatusMessage(getObjectID());

src/services/CharacterService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public void handlePacket(IoSession session, IoBuffer data) throws Exception {
230230
object.setCustomName(clientCreateCharacter.getName());
231231
object.setHeight(clientCreateCharacter.getScale());
232232
object.setPersistent(true);
233-
object.setPosition(new Point3D(3528, 0, -4804));
233+
object.setPosition(SpawnPoint.getRandomPosition(new Point3D(3528, 0, -4804), (float) 0.5, 3, core.terrainService.getPlanetByName("tatooine").getID()));
234234
object.setCashCredits(100);
235235
object.setBankCredits(1000);
236236
object.setOptionsBitmask(Options.ATTACKABLE);

src/services/ConnectionService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,6 @@ public void disconnect(IoSession session) {
219219
core.chatService.playerStatusChange(objectShortName, (byte) 0);
220220
}
221221

222-
session.suspendWrite();
223-
224222
long parentId = object.getParentId();
225223

226224
if(object.getContainer() == null) {
@@ -243,6 +241,7 @@ public void disconnect(IoSession session) {
243241
ghost.toggleFlag(PlayerFlags.LD);
244242

245243
object.setAttachment("disconnectTask", null);
244+
object.setAttachment("buffWorkshop", null);
246245
object.createTransaction(core.getCreatureODB().getEnvironment());
247246
core.getCreatureODB().put(object, Long.class, CreatureObject.class, object.getTransaction());
248247
object.getTransaction().commitSync();

0 commit comments

Comments
 (0)