mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
fix the weird shader bug finally and a few reported MP bugs
This commit is contained in:
parent
0c7286cf62
commit
42b1c634f4
5 changed files with 93 additions and 20 deletions
|
|
@ -466,11 +466,59 @@ class DifBuilder {
|
||||||
colliderSurface.originalIndices = [];
|
colliderSurface.originalIndices = [];
|
||||||
colliderSurface.originalSurfaceIndex = surfaceindex;
|
colliderSurface.originalSurfaceIndex = surfaceindex;
|
||||||
|
|
||||||
var pc0 = geo.points[geo.windings[surface.windingStart + 1]];
|
// Pick the three non-collinear points
|
||||||
var pc1 = geo.points[geo.windings[surface.windingStart + 0]];
|
|
||||||
var pc2 = geo.points[geo.windings[surface.windingStart + 2]];
|
|
||||||
|
|
||||||
var texPlanes = geo.texGenEQs[surface.texGenIndex];
|
var texPlanes = geo.texGenEQs[surface.texGenIndex];
|
||||||
|
|
||||||
|
var startIdx = 0;
|
||||||
|
while (true) {
|
||||||
|
var pc0 = geo.points[geo.windings[surface.windingStart + startIdx + 1]];
|
||||||
|
var pc1 = geo.points[geo.windings[surface.windingStart + startIdx]];
|
||||||
|
var pc2 = geo.points[geo.windings[surface.windingStart + startIdx + 2]];
|
||||||
|
|
||||||
|
var tc0 = new Vector(texPlanes.planeX.x * pc0.x
|
||||||
|
+ texPlanes.planeX.y * pc0.y
|
||||||
|
+ texPlanes.planeX.z * pc0.z
|
||||||
|
+ texPlanes.planeX.d,
|
||||||
|
texPlanes.planeY.x * pc0.x
|
||||||
|
+ texPlanes.planeY.y * pc0.y
|
||||||
|
+ texPlanes.planeY.z * pc0.z
|
||||||
|
+ texPlanes.planeY.d, 0, 0);
|
||||||
|
var tc1 = new Vector(texPlanes.planeX.x * pc1.x
|
||||||
|
+ texPlanes.planeX.y * pc1.y
|
||||||
|
+ texPlanes.planeX.z * pc1.z
|
||||||
|
+ texPlanes.planeX.d,
|
||||||
|
texPlanes.planeY.x * pc1.x
|
||||||
|
+ texPlanes.planeY.y * pc1.y
|
||||||
|
+ texPlanes.planeY.z * pc1.z
|
||||||
|
+ texPlanes.planeY.d, 0, 0);
|
||||||
|
var tc2 = new Vector(texPlanes.planeX.x * pc2.x
|
||||||
|
+ texPlanes.planeX.y * pc2.y
|
||||||
|
+ texPlanes.planeX.z * pc2.z
|
||||||
|
+ texPlanes.planeX.d,
|
||||||
|
texPlanes.planeY.x * pc2.x
|
||||||
|
+ texPlanes.planeY.y * pc2.y
|
||||||
|
+ texPlanes.planeY.z * pc2.z
|
||||||
|
+ texPlanes.planeY.d, 0, 0);
|
||||||
|
|
||||||
|
var edge1 = new Vector(pc1.x - pc0.x, tc1.x - tc0.x, tc1.y - tc0.y);
|
||||||
|
var edge2 = new Vector(pc2.x - pc0.x, tc2.x - tc0.x, tc2.y - tc0.y);
|
||||||
|
var cp = edge1.cross(edge2);
|
||||||
|
|
||||||
|
if (cp.lengthSq() > 1e-12) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
startIdx += 3;
|
||||||
|
if (startIdx >= surface.windingCount) {
|
||||||
|
startIdx = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pc0 = geo.points[geo.windings[surface.windingStart + startIdx + 1]];
|
||||||
|
var pc1 = geo.points[geo.windings[surface.windingStart + startIdx]];
|
||||||
|
var pc2 = geo.points[geo.windings[surface.windingStart + startIdx + 2]];
|
||||||
|
|
||||||
var tc0 = new Vector(texPlanes.planeX.x * pc0.x
|
var tc0 = new Vector(texPlanes.planeX.x * pc0.x
|
||||||
+ texPlanes.planeX.y * pc0.y
|
+ texPlanes.planeX.y * pc0.y
|
||||||
+ texPlanes.planeX.z * pc0.z
|
+ texPlanes.planeX.z * pc0.z
|
||||||
|
|
|
||||||
|
|
@ -76,12 +76,14 @@ class GuiMLTextListCtrl extends GuiControl {
|
||||||
textObjs.push(tobj);
|
textObjs.push(tobj);
|
||||||
|
|
||||||
if (this.scrollable) {
|
if (this.scrollable) {
|
||||||
if (this.flow.contains(tobj))
|
if (this.flow != null) {
|
||||||
this.flow.removeChild(tobj);
|
if (this.flow.contains(tobj))
|
||||||
|
this.flow.removeChild(tobj);
|
||||||
|
|
||||||
this.flow.addChild(tobj);
|
this.flow.addChild(tobj);
|
||||||
|
|
||||||
this.flow.getProperties(tobj).isAbsolute = true;
|
this.flow.getProperties(tobj).isAbsolute = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.texts = texts;
|
this.texts = texts;
|
||||||
|
|
|
||||||
|
|
@ -152,8 +152,6 @@ class MultiplayerLevelSelectGui extends GuiImage {
|
||||||
playerWnd.extent = new Vector(640, 480);
|
playerWnd.extent = new Vector(640, 480);
|
||||||
innerCtrl.addChild(playerWnd);
|
innerCtrl.addChild(playerWnd);
|
||||||
|
|
||||||
custSelected = false;
|
|
||||||
|
|
||||||
var playerListArr = [];
|
var playerListArr = [];
|
||||||
if (Net.isHost) {
|
if (Net.isHost) {
|
||||||
playerListArr.push({
|
playerListArr.push({
|
||||||
|
|
@ -240,7 +238,7 @@ class MultiplayerLevelSelectGui extends GuiImage {
|
||||||
customList.extent = new Vector(550, 2880);
|
customList.extent = new Vector(550, 2880);
|
||||||
customList.scrollable = true;
|
customList.scrollable = true;
|
||||||
customList.onSelectedFunc = (idx) -> {
|
customList.onSelectedFunc = (idx) -> {
|
||||||
NetCommands.setLobbyCustLevelName(MPCustoms.missionList[idx].title);
|
NetCommands.setLobbyCustLevelName(MPCustoms.missionList[idx].path);
|
||||||
custSelected = true;
|
custSelected = true;
|
||||||
custSelectedIdx = idx;
|
custSelectedIdx = idx;
|
||||||
custPath = MPCustoms.missionList[idx].path;
|
custPath = MPCustoms.missionList[idx].path;
|
||||||
|
|
@ -427,13 +425,24 @@ class MultiplayerLevelSelectGui extends GuiImage {
|
||||||
};
|
};
|
||||||
|
|
||||||
setLevelStr = (str) -> {
|
setLevelStr = (str) -> {
|
||||||
levelSelectOpts.optionText.text.text = str;
|
var cust = MPCustoms.missionList.filter(x -> x.path == str)[0];
|
||||||
updatePlayerCountFn(0, 0, 0, 0);
|
levelSelectOpts.optionText.text.text = cust.title;
|
||||||
|
custSelected = true;
|
||||||
|
custPath = str;
|
||||||
|
if (Net.isHost) {
|
||||||
|
updateLobbyNames();
|
||||||
|
} else
|
||||||
|
updatePlayerCountFn(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var customIsSelected = custSelected == true;
|
||||||
levelSelectOpts.setCurrentOption(currentSelectionStatic);
|
levelSelectOpts.setCurrentOption(currentSelectionStatic);
|
||||||
setLevel(currentSelectionStatic);
|
setLevel(currentSelectionStatic);
|
||||||
innerCtrl.addChild(levelSelectOpts);
|
innerCtrl.addChild(levelSelectOpts);
|
||||||
|
|
||||||
|
if (customIsSelected) {
|
||||||
|
setLevelStr(custPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override function onResize(width:Int, height:Int) {
|
override function onResize(width:Int, height:Int) {
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,10 @@ class Net {
|
||||||
|
|
||||||
var closing = false;
|
var closing = false;
|
||||||
|
|
||||||
|
isMP = true;
|
||||||
|
isHost = false;
|
||||||
|
isClient = true;
|
||||||
|
|
||||||
var closeFunc = (msg:String, forceShow:Bool) -> {
|
var closeFunc = (msg:String, forceShow:Bool) -> {
|
||||||
if (closing)
|
if (closing)
|
||||||
return;
|
return;
|
||||||
|
|
@ -204,6 +208,9 @@ class Net {
|
||||||
var loadGui = new MultiplayerLoadingGui(msg);
|
var loadGui = new MultiplayerLoadingGui(msg);
|
||||||
MarbleGame.canvas.setContent(loadGui);
|
MarbleGame.canvas.setContent(loadGui);
|
||||||
loadGui.setErrorStatus(msg);
|
loadGui.setErrorStatus(msg);
|
||||||
|
} else {
|
||||||
|
var loadGui = cast(MarbleGame.canvas.content, MultiplayerLoadingGui);
|
||||||
|
loadGui.setErrorStatus(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -297,7 +304,7 @@ class Net {
|
||||||
}
|
}
|
||||||
|
|
||||||
var onDatachannelClose = (dc:RTCDataChannel) -> {
|
var onDatachannelClose = (dc:RTCDataChannel) -> {
|
||||||
closeFunc("Server closed", true);
|
closeFunc("Disconnected", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var onDatachannelError = (msg:String) -> {
|
var onDatachannelError = (msg:String) -> {
|
||||||
|
|
@ -329,10 +336,6 @@ class Net {
|
||||||
clientDatachannelUnreliable.onError = (msg) -> {
|
clientDatachannelUnreliable.onError = (msg) -> {
|
||||||
onDatachannelError(msg);
|
onDatachannelError(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
isMP = true;
|
|
||||||
isHost = false;
|
|
||||||
isClient = true;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -356,6 +359,7 @@ class Net {
|
||||||
Net.lobbyHostReady = false;
|
Net.lobbyHostReady = false;
|
||||||
Net.lobbyClientReady = false;
|
Net.lobbyClientReady = false;
|
||||||
Net.hostReady = false;
|
Net.hostReady = false;
|
||||||
|
MultiplayerLevelSelectGui.custSelected = false;
|
||||||
}
|
}
|
||||||
if (Net.isHost) {
|
if (Net.isHost) {
|
||||||
NetCommands.serverClosed();
|
NetCommands.serverClosed();
|
||||||
|
|
@ -375,6 +379,7 @@ class Net {
|
||||||
Net.lobbyHostReady = false;
|
Net.lobbyHostReady = false;
|
||||||
Net.lobbyClientReady = false;
|
Net.lobbyClientReady = false;
|
||||||
Net.hostReady = false;
|
Net.hostReady = false;
|
||||||
|
MultiplayerLevelSelectGui.custSelected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -562,7 +567,11 @@ class Net {
|
||||||
|
|
||||||
static function onClientHandshakeComplete(conn:ClientConnection) {
|
static function onClientHandshakeComplete(conn:ClientConnection) {
|
||||||
// Send our current mission to connecting client
|
// Send our current mission to connecting client
|
||||||
NetCommands.setLobbyLevelIndexClient(conn, MultiplayerLevelSelectGui.currentSelectionStatic);
|
if (MultiplayerLevelSelectGui.custSelected) {
|
||||||
|
NetCommands.setLobbyCustLevelNameClient(conn, MultiplayerLevelSelectGui.custPath);
|
||||||
|
} else {
|
||||||
|
NetCommands.setLobbyLevelIndexClient(conn, MultiplayerLevelSelectGui.currentSelectionStatic);
|
||||||
|
}
|
||||||
|
|
||||||
if (serverInfo.state == "PLAYING") { // We initiated the game, directly add in the marble
|
if (serverInfo.state == "PLAYING") { // We initiated the game, directly add in the marble
|
||||||
if (MultiplayerLevelSelectGui.custSelected) {
|
if (MultiplayerLevelSelectGui.custSelected) {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ class NetCommands {
|
||||||
@:rpc(server) public static function setLobbyCustLevelName(str:String) {
|
@:rpc(server) public static function setLobbyCustLevelName(str:String) {
|
||||||
if (MultiplayerLevelSelectGui.setLevelFn != null) {
|
if (MultiplayerLevelSelectGui.setLevelFn != null) {
|
||||||
MultiplayerLevelSelectGui.setLevelStr(str);
|
MultiplayerLevelSelectGui.setLevelStr(str);
|
||||||
|
} else {
|
||||||
|
MultiplayerLevelSelectGui.custSelected = true;
|
||||||
|
MultiplayerLevelSelectGui.custPath = str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,7 +116,8 @@ 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" && MarbleGame.instance.world != null) {
|
if (Net.serverInfo.state == "WAITING") {
|
||||||
|
Console.log('Client ${clientId} is ready!');
|
||||||
if (clientId != -1)
|
if (clientId != -1)
|
||||||
Net.clientIdMap[clientId].ready();
|
Net.clientIdMap[clientId].ready();
|
||||||
else
|
else
|
||||||
|
|
@ -127,6 +131,7 @@ class NetCommands {
|
||||||
}
|
}
|
||||||
if (allReady && Net.hostReady) {
|
if (allReady && Net.hostReady) {
|
||||||
if (MarbleGame.instance.world != null) {
|
if (MarbleGame.instance.world != null) {
|
||||||
|
Console.log('All are ready, starting');
|
||||||
MarbleGame.instance.world.allClientsReady();
|
MarbleGame.instance.world.allClientsReady();
|
||||||
}
|
}
|
||||||
Net.serverInfo.state = "PLAYING";
|
Net.serverInfo.state = "PLAYING";
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue