mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-27 13:11:42 +00:00
fix blast and respawn mp bugs
This commit is contained in:
parent
2b4eb2ca4c
commit
bac95e7881
5 changed files with 31 additions and 27 deletions
|
|
@ -618,7 +618,7 @@ class Marble extends GameObject {
|
||||||
}
|
}
|
||||||
for (marble in level.marbles) {
|
for (marble in level.marbles) {
|
||||||
if (marble != cast this) {
|
if (marble != cast this) {
|
||||||
var force = marble.getForce(this.collider.transform.getPosition(), timeState.ticks);
|
var force = marble.getForce(this.collider.transform.getPosition(), Net.isHost ? timeState.ticks : serverTicks);
|
||||||
A = A.add(force.multiply(1 / mass));
|
A = A.add(force.multiply(1 / mass));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2223,7 +2223,7 @@ class Marble extends GameObject {
|
||||||
if (this.level.isMultiplayer) {
|
if (this.level.isMultiplayer) {
|
||||||
if (this.blastTicks < (7500 >> 5))
|
if (this.blastTicks < (7500 >> 5))
|
||||||
return false;
|
return false;
|
||||||
this.blastUseTick = timeState.ticks;
|
this.blastUseTick = Net.isHost ? timeState.ticks : serverTicks;
|
||||||
if (!this.isNetUpdate)
|
if (!this.isNetUpdate)
|
||||||
this.netFlags |= MarbleNetFlags.DoBlast;
|
this.netFlags |= MarbleNetFlags.DoBlast;
|
||||||
var amount = this.blastTicks / (30000 >> 5);
|
var amount = this.blastTicks / (30000 >> 5);
|
||||||
|
|
|
||||||
|
|
@ -571,7 +571,7 @@ class MarbleWorld extends Scheduler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!full) {
|
if (!full) {
|
||||||
var respawnT = this.gameMode.getRespawnTransform();
|
var respawnT = this.gameMode.getRespawnTransform(marble);
|
||||||
if (respawnT != null) {
|
if (respawnT != null) {
|
||||||
respawn(marble, respawnT.position, respawnT.orientation, respawnT.up);
|
respawn(marble, respawnT.position, respawnT.orientation, respawnT.up);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1212,34 +1212,37 @@ class MarbleWorld extends Scheduler {
|
||||||
// clientMarbles[Net.clientIdMap[client]].unpackUpdate(lastMove);
|
// clientMarbles[Net.clientIdMap[client]].unpackUpdate(lastMove);
|
||||||
// needsPrediction |= 1 << client;
|
// needsPrediction |= 1 << client;
|
||||||
// arr.insert(0, lastMove);
|
// arr.insert(0, lastMove);
|
||||||
if (ourMove.serverTicks == lastMove.serverTicks) {
|
var clientMarble = clientMarbles[Net.clientIdMap[client]];
|
||||||
if (ourMoveStruct != null) {
|
if (clientMarble != null) {
|
||||||
var otherPred = predictions.retrieveState(clientMarbles[Net.clientIdMap[client]], ourMoveStruct.timeState.ticks);
|
if (ourMove.serverTicks == lastMove.serverTicks) {
|
||||||
if (otherPred != null) {
|
if (ourMoveStruct != null) {
|
||||||
if (otherPred.getError(lastMove) > 0.1) {
|
var otherPred = predictions.retrieveState(clientMarble, ourMoveStruct.timeState.ticks);
|
||||||
Debug.drawSphere(@:privateAccess clientMarbles[Net.clientIdMap[client]].newPos, 0.2, 0.5);
|
if (otherPred != null) {
|
||||||
// trace('Prediction error: ${otherPred.getError(lastMove)}');
|
if (otherPred.getError(lastMove) > 0.1) {
|
||||||
|
// Debug.drawSphere(@:privateAccess clientMarbles[Net.clientIdMap[client]].newPos, 0.2, 0.5);
|
||||||
|
// trace('Prediction error: ${otherPred.getError(lastMove)}');
|
||||||
|
// trace('Desync for tick ${ourMoveStruct.timeState.ticks}');
|
||||||
|
clientMarble.unpackUpdate(lastMove);
|
||||||
|
needsPrediction |= 1 << client;
|
||||||
|
arr.packets.insert(0, lastMove);
|
||||||
|
predictions.clearStatesAfterTick(clientMarbles[Net.clientIdMap[client]], ourMoveStruct.timeState.ticks);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Debug.drawSphere(@:privateAccess clientMarbles[Net.clientIdMap[client]].newPos, 0.2, 0.5);
|
||||||
// trace('Desync for tick ${ourMoveStruct.timeState.ticks}');
|
// trace('Desync for tick ${ourMoveStruct.timeState.ticks}');
|
||||||
clientMarbles[Net.clientIdMap[client]].unpackUpdate(lastMove);
|
clientMarble.unpackUpdate(lastMove);
|
||||||
needsPrediction |= 1 << client;
|
needsPrediction |= 1 << client;
|
||||||
arr.packets.insert(0, lastMove);
|
arr.packets.insert(0, lastMove);
|
||||||
predictions.clearStatesAfterTick(clientMarbles[Net.clientIdMap[client]], ourMoveStruct.timeState.ticks);
|
predictions.clearStatesAfterTick(clientMarble, ourMoveStruct.timeState.ticks);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Debug.drawSphere(@:privateAccess clientMarbles[Net.clientIdMap[client]].newPos, 0.2, 0.5);
|
// Debug.drawSphere(@:privateAccess clientMarbles[Net.clientIdMap[client]].newPos, 0.2, 0.5);
|
||||||
// trace('Desync for tick ${ourMoveStruct.timeState.ticks}');
|
// trace('Desync in General');
|
||||||
clientMarbles[Net.clientIdMap[client]].unpackUpdate(lastMove);
|
clientMarble.unpackUpdate(lastMove);
|
||||||
needsPrediction |= 1 << client;
|
needsPrediction |= 1 << client;
|
||||||
arr.packets.insert(0, lastMove);
|
arr.packets.insert(0, lastMove);
|
||||||
predictions.clearStatesAfterTick(clientMarbles[Net.clientIdMap[client]], ourMoveStruct.timeState.ticks);
|
// predictions.clearStatesAfterTick(clientMarbles[Net.clientIdMap[client]], ourMoveStruct.timeState.ticks);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Debug.drawSphere(@:privateAccess clientMarbles[Net.clientIdMap[client]].newPos, 0.2, 0.5);
|
|
||||||
// trace('Desync in General');
|
|
||||||
clientMarbles[Net.clientIdMap[client]].unpackUpdate(lastMove);
|
|
||||||
needsPrediction |= 1 << client;
|
|
||||||
arr.packets.insert(0, lastMove);
|
|
||||||
// predictions.clearStatesAfterTick(clientMarbles[Net.clientIdMap[client]], ourMoveStruct.timeState.ticks);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import h3d.Quat;
|
||||||
import h3d.Vector;
|
import h3d.Vector;
|
||||||
import src.MarbleWorld;
|
import src.MarbleWorld;
|
||||||
import src.Mission;
|
import src.Mission;
|
||||||
|
import src.Marble;
|
||||||
|
|
||||||
enum ScoreType {
|
enum ScoreType {
|
||||||
Time;
|
Time;
|
||||||
|
|
@ -15,7 +16,7 @@ enum ScoreType {
|
||||||
|
|
||||||
interface GameMode {
|
interface GameMode {
|
||||||
public function getSpawnTransform():{position:Vector, orientation:Quat, up:Vector};
|
public function getSpawnTransform():{position:Vector, orientation:Quat, up:Vector};
|
||||||
public function getRespawnTransform():{position:Vector, orientation:Quat, up:Vector};
|
public function getRespawnTransform(marble:Marble):{position:Vector, orientation:Quat, up:Vector};
|
||||||
public function missionScan(mission:Mission):Void;
|
public function missionScan(mission:Mission):Void;
|
||||||
public function getStartTime():Float;
|
public function getStartTime():Float;
|
||||||
public function timeMultiplier():Float;
|
public function timeMultiplier():Float;
|
||||||
|
|
|
||||||
|
|
@ -221,8 +221,8 @@ class HuntMode extends NullMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override function getRespawnTransform() {
|
override function getRespawnTransform(marble:Marble) {
|
||||||
var lastContactPos = this.level.marble.lastContactPosition;
|
var lastContactPos = marble.lastContactPosition;
|
||||||
if (lastContactPos == null) {
|
if (lastContactPos == null) {
|
||||||
return getSpawnTransform();
|
return getSpawnTransform();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class NullMode implements GameMode {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRespawnTransform():{up:Vector, position:Vector, orientation:Quat} {
|
public function getRespawnTransform(marble:Marble):{up:Vector, position:Vector, orientation:Quat} {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue