mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-22 13:48:25 +07:00
Improved glitchy interpolation / Updated uCore
This commit is contained in:
@ -27,7 +27,7 @@ allprojects {
|
|||||||
gdxVersion = '1.9.8'
|
gdxVersion = '1.9.8'
|
||||||
roboVMVersion = '2.3.0'
|
roboVMVersion = '2.3.0'
|
||||||
aiVersion = '1.8.1'
|
aiVersion = '1.8.1'
|
||||||
uCoreVersion = '7673041e62'
|
uCoreVersion = '05f51b183e'
|
||||||
|
|
||||||
getVersionString = {
|
getVersionString = {
|
||||||
String buildVersion = getBuildVersion()
|
String buildVersion = getBuildVersion()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.core;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.Base64Coder;
|
import com.badlogic.gdx.utils.Base64Coder;
|
||||||
import com.badlogic.gdx.utils.IntSet;
|
import com.badlogic.gdx.utils.IntSet;
|
||||||
@ -175,7 +176,7 @@ public class NetClient extends Module {
|
|||||||
ui.loadfrag.hide();
|
ui.loadfrag.hide();
|
||||||
ui.join.hide();
|
ui.join.hide();
|
||||||
Net.setClientLoaded(true);
|
Net.setClientLoaded(true);
|
||||||
Call.connectConfirm();
|
Gdx.app.postRunnable(Call::connectConfirm);
|
||||||
Timers.runTask(40f, Platform.instance::updateRPC);
|
Timers.runTask(40f, Platform.instance::updateRPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.anuke.mindustry.core;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Queue;
|
||||||
import com.badlogic.gdx.utils.TimeUtils;
|
import com.badlogic.gdx.utils.TimeUtils;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.util.Log;
|
import io.anuke.ucore.util.Log;
|
||||||
@ -10,7 +10,7 @@ import static io.anuke.mindustry.Vars.control;
|
|||||||
import static io.anuke.mindustry.Vars.logic;
|
import static io.anuke.mindustry.Vars.logic;
|
||||||
|
|
||||||
public class ThreadHandler {
|
public class ThreadHandler {
|
||||||
private final Array<Runnable> toRun = new Array<>();
|
private final Queue<Runnable> toRun = new Queue<>();
|
||||||
private final ThreadProvider impl;
|
private final ThreadProvider impl;
|
||||||
private float delta = 1f;
|
private float delta = 1f;
|
||||||
private float smoothDelta = 1f;
|
private float smoothDelta = 1f;
|
||||||
@ -33,7 +33,7 @@ public class ThreadHandler {
|
|||||||
public void run(Runnable r){
|
public void run(Runnable r){
|
||||||
if(enabled) {
|
if(enabled) {
|
||||||
synchronized (toRun) {
|
synchronized (toRun) {
|
||||||
toRun.add(r);
|
toRun.addLast(r);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
r.run();
|
r.run();
|
||||||
@ -51,7 +51,7 @@ public class ThreadHandler {
|
|||||||
public void runDelay(Runnable r){
|
public void runDelay(Runnable r){
|
||||||
if(enabled) {
|
if(enabled) {
|
||||||
synchronized (toRun) {
|
synchronized (toRun) {
|
||||||
toRun.add(r);
|
toRun.addLast(r);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
Gdx.app.postRunnable(r);
|
Gdx.app.postRunnable(r);
|
||||||
@ -103,7 +103,7 @@ public class ThreadHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean doInterpolate(){
|
public boolean doInterpolate(){
|
||||||
return enabled && Math.abs(Gdx.graphics.getFramesPerSecond() - getTPS()) > 15;
|
return enabled && Gdx.graphics.getFramesPerSecond() - getTPS() > 20 && getTPS() < 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOnThread(){
|
public boolean isOnThread(){
|
||||||
@ -119,13 +119,12 @@ public class ThreadHandler {
|
|||||||
Runnable r;
|
Runnable r;
|
||||||
synchronized (toRun){
|
synchronized (toRun){
|
||||||
if(toRun.size > 0){
|
if(toRun.size > 0){
|
||||||
r = toRun.pop();
|
r = toRun.removeFirst();
|
||||||
}else{
|
}else{
|
||||||
r = null;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(r == null) break;
|
|
||||||
r.run();
|
r.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,7 +542,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
pointerY = vec.y;
|
pointerY = vec.y;
|
||||||
updateShooting();
|
updateShooting();
|
||||||
|
|
||||||
movement.limit(speed);
|
movement.limit(speed * Timers.delta());
|
||||||
|
|
||||||
if(getCarrier() == null){
|
if(getCarrier() == null){
|
||||||
velocity.add(movement);
|
velocity.add(movement);
|
||||||
@ -751,13 +751,12 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
public void write(DataOutput buffer) throws IOException {
|
public void write(DataOutput buffer) throws IOException {
|
||||||
super.writeSave(buffer, !isLocal);
|
super.writeSave(buffer, !isLocal);
|
||||||
buffer.writeUTF(name); //TODO writing strings is very inefficient
|
buffer.writeUTF(name); //TODO writing strings is very inefficient
|
||||||
buffer.writeBoolean(isAdmin);
|
buffer.writeByte(Bits.toByte(isAdmin) | (Bits.toByte(dead) << 1) | (Bits.toByte(isBoosting) << 2));
|
||||||
buffer.writeInt(Color.rgba8888(color));
|
buffer.writeInt(Color.rgba8888(color));
|
||||||
buffer.writeBoolean(dead);
|
|
||||||
buffer.writeByte(mech.id);
|
buffer.writeByte(mech.id);
|
||||||
buffer.writeBoolean(isBoosting);
|
|
||||||
buffer.writeInt(mining == null ? -1 : mining.packedPosition());
|
buffer.writeInt(mining == null ? -1 : mining.packedPosition());
|
||||||
buffer.writeInt(spawner);
|
buffer.writeInt(spawner);
|
||||||
|
buffer.writeShort((short)(baseRotation * 2));
|
||||||
|
|
||||||
writeBuilding(buffer);
|
writeBuilding(buffer);
|
||||||
}
|
}
|
||||||
@ -767,17 +766,19 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
float lastx = x, lasty = y, lastrot = rotation;
|
float lastx = x, lasty = y, lastrot = rotation;
|
||||||
super.readSave(buffer);
|
super.readSave(buffer);
|
||||||
name = buffer.readUTF();
|
name = buffer.readUTF();
|
||||||
isAdmin = buffer.readBoolean();
|
byte bools = buffer.readByte();
|
||||||
|
isAdmin = (bools & 1) != 0;
|
||||||
|
dead = (bools & 2) != 0;
|
||||||
|
boolean boosting = (bools & 4) != 0;
|
||||||
color.set(buffer.readInt());
|
color.set(buffer.readInt());
|
||||||
dead = buffer.readBoolean();
|
|
||||||
mech = Upgrade.getByID(buffer.readByte());
|
mech = Upgrade.getByID(buffer.readByte());
|
||||||
boolean boosting = buffer.readBoolean();
|
|
||||||
int mine = buffer.readInt();
|
int mine = buffer.readInt();
|
||||||
spawner = buffer.readInt();
|
spawner = buffer.readInt();
|
||||||
|
float baseRotation = buffer.readShort()/2f;
|
||||||
|
|
||||||
readBuilding(buffer, !isLocal);
|
readBuilding(buffer, !isLocal);
|
||||||
|
|
||||||
interpolator.read(lastx, lasty, x, y, time, rotation);
|
interpolator.read(lastx, lasty, x, y, time, rotation, baseRotation);
|
||||||
rotation = lastrot;
|
rotation = lastrot;
|
||||||
|
|
||||||
if(isLocal){
|
if(isLocal){
|
||||||
|
@ -38,11 +38,12 @@ public class Interpolator {
|
|||||||
|
|
||||||
public void update(){
|
public void update(){
|
||||||
|
|
||||||
|
/*
|
||||||
if(pos.dst(target) > 128){
|
if(pos.dst(target) > 128){
|
||||||
pos.set(target);
|
pos.set(target);
|
||||||
lastUpdated = 0;
|
lastUpdated = 0;
|
||||||
updateSpacing = 16;
|
updateSpacing = 16;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if(lastUpdated != 0 && updateSpacing != 0){
|
if(lastUpdated != 0 && updateSpacing != 0){
|
||||||
float timeSinceUpdate = TimeUtils.timeSinceMillis(lastUpdated);
|
float timeSinceUpdate = TimeUtils.timeSinceMillis(lastUpdated);
|
||||||
|
Reference in New Issue
Block a user