split server #3
This commit is contained in:
parent
8f8abfa0d3
commit
19f3813338
6 changed files with 83 additions and 5 deletions
|
@ -405,6 +405,7 @@ public class Game implements IThreadListener {
|
|||
|
||||
private ServerProcess server;
|
||||
private String serverInfo;
|
||||
private int lastTickTime = -1;
|
||||
private AudioInterface audio;
|
||||
private long start;
|
||||
private boolean cfgDirty;
|
||||
|
@ -476,6 +477,7 @@ public class Game implements IThreadListener {
|
|||
this.theWorld = null;
|
||||
this.thePlayer = null;
|
||||
this.serverInfo = null;
|
||||
this.lastTickTime = -1;
|
||||
this.soundManager.stopSounds();
|
||||
}
|
||||
|
||||
|
@ -1609,6 +1611,13 @@ public class Game implements IThreadListener {
|
|||
this.serverInfo = info;
|
||||
}
|
||||
|
||||
public void setLastTick(int time) {
|
||||
if(this.lastTickTime >= 0) {
|
||||
this.lastTicked = System.currentTimeMillis();
|
||||
this.lastTickTime = time;
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePlayerMoveState()
|
||||
{
|
||||
this.moveStrafe = 0.0F;
|
||||
|
@ -2076,7 +2085,7 @@ public class Game implements IThreadListener {
|
|||
return;
|
||||
this.frameWait = 50000000L - ((n - (this.frameLast + this.frameWait)) < 50000000L ? (n - (this.frameLast + this.frameWait)) : 0L);
|
||||
this.frameLast = n;
|
||||
this.tickTimes[this.tickIndex++] = this.server == null ? 0 : this.server.getLastTick();
|
||||
this.tickTimes[this.tickIndex++] = this.lastTickTime;
|
||||
if(this.tickIndex == 240) {
|
||||
this.tickIndex = 0;
|
||||
}
|
||||
|
@ -2613,6 +2622,18 @@ public class Game implements IThreadListener {
|
|||
Game.this.logFeed("Spieler-Info in Overlay: %s", (Game.this.debugPlayer ^= true) ? "an" : "aus");
|
||||
}
|
||||
});
|
||||
this.registerDebug(Keysym.OE, "Tick-Profiler umschalten", new DebugRunner() {
|
||||
public void execute(Keysym key) {
|
||||
if(Game.this.lastTickTime >= 0) {
|
||||
Game.this.performAction(Action.STOP_PROFILING);
|
||||
Game.this.lastTickTime = -1;
|
||||
}
|
||||
else {
|
||||
Game.this.performAction(Action.START_PROFILING);
|
||||
Game.this.lastTickTime = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean handleDebugKey(Keysym key) {
|
||||
|
@ -3169,7 +3190,7 @@ public class Game implements IThreadListener {
|
|||
Drawing.drawText("60ms", 2, h - 60 - 14, 0xffE0E0E0);
|
||||
Drawing.drawTextRight("ms/Frame", 238, h - 60 - 14, 0xffE0E0E0);
|
||||
|
||||
if(this.server != null) {
|
||||
if(this.lastTickTime >= 0) {
|
||||
this.updateTick();
|
||||
Drawing.drawRect(w - 240, h - 74, 240, 60, 0x90505050);
|
||||
x = w - 240;
|
||||
|
|
|
@ -96,6 +96,7 @@ import game.packet.SPacketMessage;
|
|||
import game.packet.SPacketMultiBlockChange;
|
||||
import game.packet.SPacketPlayerPosLook;
|
||||
import game.packet.SPacketRespawn;
|
||||
import game.packet.SPacketServerTick;
|
||||
import game.packet.SPacketSetExperience;
|
||||
import game.packet.SPacketSkin;
|
||||
import game.packet.SPacketSpawnMob;
|
||||
|
@ -927,6 +928,12 @@ public class ClientPlayer extends NetHandler
|
|||
this.gameController.setTicked(packetIn.getServerinfo());
|
||||
}
|
||||
|
||||
public void handleServerTick(SPacketServerTick packet)
|
||||
{
|
||||
NetHandler.checkThread(packet, this, this.gameController);
|
||||
this.gameController.setLastTick(packet.getTime());
|
||||
}
|
||||
|
||||
// public void handleCompass(SPacketCompass packetIn)
|
||||
// {
|
||||
// NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
|
|
|
@ -75,6 +75,7 @@ import game.packet.SPacketMessage;
|
|||
import game.packet.SPacketMultiBlockChange;
|
||||
import game.packet.SPacketPlayerPosLook;
|
||||
import game.packet.SPacketRespawn;
|
||||
import game.packet.SPacketServerTick;
|
||||
import game.packet.SPacketSetExperience;
|
||||
import game.packet.SPacketSkin;
|
||||
import game.packet.SPacketSpawnMob;
|
||||
|
@ -179,6 +180,7 @@ public enum PacketRegistry
|
|||
// this.server(SPacketNotify.class);
|
||||
this.server(SPacketDimensionName.class);
|
||||
this.server(SPacketCharacterList.class);
|
||||
this.server(SPacketServerTick.class);
|
||||
this.server(SPacketLoading.class);
|
||||
|
||||
this.client(CPacketKeepAlive.class);
|
||||
|
|
|
@ -101,6 +101,7 @@ import game.packet.SPacketMapChunkBulk;
|
|||
import game.packet.SPacketMessage;
|
||||
import game.packet.SPacketMessage.Type;
|
||||
import game.packet.SPacketPlayerPosLook;
|
||||
import game.packet.SPacketServerTick;
|
||||
import game.packet.SPacketSetExperience;
|
||||
import game.packet.SPacketSkin;
|
||||
import game.packet.SPacketTrades;
|
||||
|
@ -188,6 +189,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
private int ping;
|
||||
private boolean deleted;
|
||||
private String password;
|
||||
private boolean profiling;
|
||||
|
||||
private int selectionDim = Integer.MIN_VALUE;
|
||||
private ClipboardBlock[][][] clipboard;
|
||||
|
@ -274,8 +276,8 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
this.pingKey = (int)this.lastPingTime;
|
||||
this.sendPacket(new SPacketKeepAlive(this.pingKey));
|
||||
}
|
||||
// if(this.local)
|
||||
|
||||
if(this.admin && this.profiling)
|
||||
this.sendPacket(new SPacketServerTick((int)this.server.getLastTick()));
|
||||
if(this.respawnTimer > 0) {
|
||||
if(--this.respawnTimer == 0) {
|
||||
this.respawnPlayer();
|
||||
|
@ -2896,6 +2898,16 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
}
|
||||
break;
|
||||
|
||||
case START_PROFILING:
|
||||
if(this.admin)
|
||||
this.profiling = true;
|
||||
break;
|
||||
|
||||
case STOP_PROFILING:
|
||||
if(this.admin)
|
||||
this.profiling = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Ungültige Aktion!");
|
||||
}
|
||||
|
|
|
@ -95,7 +95,9 @@ public class CPacketAction implements Packet<Player>
|
|||
PERF,
|
||||
MAGNET,
|
||||
// SET_VIEWDIST,
|
||||
WARP_MODE;
|
||||
WARP_MODE,
|
||||
START_PROFILING,
|
||||
STOP_PROFILING;
|
||||
// SHUTDOWN;
|
||||
}
|
||||
}
|
||||
|
|
34
java/src/game/packet/SPacketServerTick.java
Normal file
34
java/src/game/packet/SPacketServerTick.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package game.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import game.network.ClientPlayer;
|
||||
import game.network.Packet;
|
||||
import game.network.PacketBuffer;
|
||||
|
||||
public class SPacketServerTick implements Packet<ClientPlayer> {
|
||||
private int time;
|
||||
|
||||
public SPacketServerTick() {
|
||||
}
|
||||
|
||||
public SPacketServerTick(int time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.time = buf.readInt();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
buf.writeInt(this.time);
|
||||
}
|
||||
|
||||
public void processPacket(ClientPlayer handler) {
|
||||
handler.handleServerTick(this);
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return this.time;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue