bugfixes for the reported issues

This commit is contained in:
RandomityGuy 2024-07-21 12:26:10 +05:30
parent 5a6c8ae6e1
commit 3d065c116e
11 changed files with 70 additions and 32 deletions

View file

@ -7,7 +7,7 @@ new SimGroup(MissionGroup) {
desc = "Find the gems in the maze of roads!"; desc = "Find the gems in the maze of roads!";
radiusFromGem = "20"; radiusFromGem = "20";
gameMode = "Hunt"; gameMode = "Hunt";
level = "5"; level = "4";
type = "Intermediate"; type = "Intermediate";
time = "300000"; time = "300000";
maxGemsPerSpawn = "6"; maxGemsPerSpawn = "6";

View file

@ -262,6 +262,9 @@ class MarbleGame {
if (paused && world._ready) { if (paused && world._ready) {
Console.log("Game paused"); Console.log("Game paused");
world.setCursorLock(false); world.setCursorLock(false);
if (Util.isTouchDevice()) {
this.touchInput.movementInput.forceRelease();
}
if (world.isMultiplayer) { if (world.isMultiplayer) {
exitGameDlg = new MPExitGameDlg(() -> { exitGameDlg = new MPExitGameDlg(() -> {
canvas.popDialog(exitGameDlg); canvas.popDialog(exitGameDlg);

View file

@ -1,5 +1,6 @@
package src; package src;
import net.NetPacket.ExplodableUpdatePacket;
import net.TrapdoorPredictionStore; import net.TrapdoorPredictionStore;
import shapes.Explodable; import shapes.Explodable;
import net.ExplodablePredictionStore; import net.ExplodablePredictionStore;
@ -563,10 +564,10 @@ class MarbleWorld extends Scheduler {
interior.onLevelStart(); interior.onLevelStart();
for (shape in this.dtsObjects) for (shape in this.dtsObjects)
shape.onLevelStart(); shape.onLevelStart();
// if (this.isMultiplayer && Net.isClient) if (this.isMultiplayer && Net.isClient && !_skipPreGame)
// NetCommands.clientIsReady(Net.clientId); NetCommands.clientIsReady(Net.clientId);
if (this.isMultiplayer && Net.isHost) { if (this.isMultiplayer && Net.isHost) {
// NetCommands.clientIsReady(-1); // NetCommands.clientIsReady(-1);
// Sort all the marbles so that they are updated in a deterministic order // Sort all the marbles so that they are updated in a deterministic order
this.marbles.sort((a, b) -> @:privateAccess { this.marbles.sort((a, b) -> @:privateAccess {
@ -591,6 +592,7 @@ class MarbleWorld extends Scheduler {
_skipPreGame = false; _skipPreGame = false;
this.setCursorLock(true); this.setCursorLock(true);
NetCommands.requestMidGameJoinState(Net.clientId); NetCommands.requestMidGameJoinState(Net.clientId);
NetCommands.clientIsReady(Net.clientId);
} }
} }
this.gameMode.onMissionLoad(); this.gameMode.onMissionLoad();
@ -1417,7 +1419,11 @@ class MarbleWorld extends Scheduler {
// Marble states // Marble states
for (marb in this.marbles) { for (marb in this.marbles) {
var oldFlags = @:privateAccess marb.netFlags; var oldFlags = @:privateAccess marb.netFlags;
@:privateAccess marb.netFlags = MarbleNetFlags.DoBlast | MarbleNetFlags.DoMega | MarbleNetFlags.DoHelicopter | MarbleNetFlags.PickupPowerup | MarbleNetFlags.GravityChange | MarbleNetFlags.UsePowerup; @:privateAccess marb.netFlags = MarbleNetFlags.DoBlast | MarbleNetFlags.DoMega | MarbleNetFlags.DoHelicopter | MarbleNetFlags.DoShockAbsorber | MarbleNetFlags.DoSuperBounce | MarbleNetFlags.PickupPowerup | MarbleNetFlags.GravityChange | MarbleNetFlags.UsePowerup;
if (oldFlags & MarbleNetFlags.UpdateTrapdoor > 0) {
@:privateAccess marb.netFlags |= MarbleNetFlags.UpdateTrapdoor;
}
var innerMove = @:privateAccess marb.lastMove; var innerMove = @:privateAccess marb.lastMove;
if (innerMove == null) { if (innerMove == null) {
@ -1452,6 +1458,19 @@ class MarbleWorld extends Scheduler {
} }
} }
// Explosion states
for (exp in this.explodables) {
if (this.timeState.ticks < (exp.lastContactTick + exp.renewTime >> 5)) {
var b = new OutputBitStream();
b.writeByte(NetPacketType.ExplodableUpdate);
var explPacket = new ExplodableUpdatePacket();
explPacket.explodableId = exp.netId;
explPacket.serverTicks = timeState.ticks;
explPacket.serialize(b);
packets.push(b.getBytes());
}
}
// Scoreboard! // Scoreboard!
var b = new OutputBitStream(); var b = new OutputBitStream();
b.writeByte(NetPacketType.ScoreBoardInfo); b.writeByte(NetPacketType.ScoreBoardInfo);

View file

@ -422,8 +422,8 @@ class Settings {
levelStatistics.set(key, value); levelStatistics.set(key, value);
} }
} }
if (json.serverSettings != null) { if (json.server != null) {
serverSettings = json.serverSettings; serverSettings = json.server;
} }
#if js #if js
if (serverSettings.oldSpawns == null) { if (serverSettings.oldSpawns == null) {

View file

@ -1,5 +1,6 @@
package gui; package gui;
import net.ClientConnection;
import net.NetCommands; import net.NetCommands;
import net.Net; import net.Net;
import h2d.filter.DropShadow; import h2d.filter.DropShadow;
@ -91,6 +92,7 @@ class MPKickBanDlg extends GuiImage {
var playerList = new GuiTextListCtrl(markerFelt18, playerNames, 0); var playerList = new GuiTextListCtrl(markerFelt18, playerNames, 0);
playerList.position = new Vector(120, 60); playerList.position = new Vector(120, 60);
playerList.extent = new Vector(188, 180); playerList.extent = new Vector(188, 180);
playerList.scrollable = true;
playerList.textYOffset = -6; playerList.textYOffset = -6;
playerList.onSelectedFunc = (sel) -> { playerList.onSelectedFunc = (sel) -> {
kickBtn.disabled = false; kickBtn.disabled = false;
@ -106,6 +108,8 @@ class MPKickBanDlg extends GuiImage {
playerList.setTexts(playerNames); playerList.setTexts(playerNames);
kickBtn.disabled = true; kickBtn.disabled = true;
NetCommands.getKickedClient(Net.clientIdMap.get(playerToKick)); NetCommands.getKickedClient(Net.clientIdMap.get(playerToKick));
var cc = cast(Net.clientIdMap.get(playerToKick), ClientConnection);
cc.socket.close();
} }
} }
} }

View file

@ -289,6 +289,8 @@ class MPPreGameDlg extends GuiControl {
playerListLeft.setTexts(playerListCompiled); playerListLeft.setTexts(playerListCompiled);
playerListRight.setTexts(playerListStateCompiled); playerListRight.setTexts(playerListStateCompiled);
playerListContainer.setScrollMax(playerListLeft.calculateFullHeight());
if (playerListArr.length == 1) { if (playerListArr.length == 1) {
// Disable spectating // Disable spectating
Net.hostSpectate = false; Net.hostSpectate = false;

View file

@ -120,10 +120,19 @@ class HuntMode extends NullMode {
override function getSpawnTransform() { override function getSpawnTransform() {
var idx = Net.connectedServerInfo.competitiveMode ? idealSpawnIndex : Math.floor(rng2.randRange(0, playerSpawnPoints.length - 1)); var idx = Net.connectedServerInfo.competitiveMode ? idealSpawnIndex : Math.floor(rng2.randRange(0, playerSpawnPoints.length - 1));
if (!Net.connectedServerInfo.competitiveMode) { if (!Net.connectedServerInfo.competitiveMode) {
while (spawnPointTaken[idx]) { var allTaken = true;
idx = Math.floor(rng2.randRange(0, playerSpawnPoints.length - 1)); for (spw in spawnPointTaken) {
if (!spw) {
allTaken = false;
break;
}
}
if (!allTaken) {
while (spawnPointTaken[idx]) {
idx = Math.floor(rng2.randRange(0, playerSpawnPoints.length - 1));
}
spawnPointTaken[idx] = true;
} }
spawnPointTaken[idx] = true;
} }
var randomSpawn = playerSpawnPoints[idx]; var randomSpawn = playerSpawnPoints[idx];

View file

@ -9,6 +9,7 @@ import src.TimeState;
enum abstract GameplayState(Int) from Int to Int { enum abstract GameplayState(Int) from Int to Int {
var UNKNOWN; var UNKNOWN;
var LOBBY; var LOBBY;
var LOADING;
var GAME; var GAME;
} }

View file

@ -433,6 +433,10 @@ class Net {
for (dc => cc in clients) { for (dc => cc in clients) {
if (cc is ClientConnection) { if (cc is ClientConnection) {
var conn = cast(cc, ClientConnection); var conn = cast(cc, ClientConnection);
if (Net.isHost && conn.state == LOADING)
continue;
if (Net.isClient && MarbleGame.instance.world != null && !MarbleGame.instance.world._ready)
continue; // We still loading, don't disconnect
if (conn.needsTimeoutWarn(t)) { if (conn.needsTimeoutWarn(t)) {
conn.didWarnTimeout = true; conn.didWarnTimeout = true;
if (Net.isClient) { if (Net.isClient) {

View file

@ -160,28 +160,7 @@ class NetCommands {
@:rpc(client) public static function clientIsReady(clientId:Int) { @:rpc(client) public static function clientIsReady(clientId:Int) {
if (Net.isHost) { if (Net.isHost) {
if (Net.serverInfo.state == "WAITING") { Net.clientIdMap[clientId].state = GAME;
Console.log('Client ${clientId} is ready!');
if (clientId != -1)
Net.clientIdMap[clientId].ready();
else
Net.hostReady = true;
var allReady = true;
for (id => client in Net.clientIdMap) {
if (client.state != GameplayState.GAME) {
allReady = false;
break;
}
}
if (allReady && Net.hostReady) {
if (MarbleGame.instance.world != null) {
Console.log('All are ready, starting');
MarbleGame.instance.world.allClientsReady();
}
Net.serverInfo.state = "PLAYING";
MasterServerClient.instance.sendServerInfo(Net.serverInfo); // notify the server of the playing state
}
} else {}
} }
} }

View file

@ -22,6 +22,8 @@ class MovementInput {
public var value:Vector = new Vector(); public var value:Vector = new Vector();
var releaseFn:() -> Void;
var touchId = -1; var touchId = -1;
public function new() { public function new() {
@ -69,6 +71,11 @@ class MovementInput {
var stopped = false; var stopped = false;
releaseFn = () -> {
stopped = true;
collider.stopCapture();
}
collider.startCapture((emove) -> { collider.startCapture((emove) -> {
if (e.touchId != emove.touchId) { if (e.touchId != emove.touchId) {
emove.propagate = true; emove.propagate = true;
@ -124,6 +131,16 @@ class MovementInput {
} }
} }
public function forceRelease() {
releaseFn();
this.area.graphics.alpha = 0;
this.joystick.graphics.alpha = 0;
pressed = false;
this.value = new Vector(0, 0);
}
public function add(parentGui:GuiControl) { public function add(parentGui:GuiControl) {
parentGui.addChild(this.area); parentGui.addChild(this.area);
added = true; added = true;