Skip to content

Commit

Permalink
Merge pull request #13 from Jagerente/community-servers
Browse files Browse the repository at this point in the history
Community servers
  • Loading branch information
Jagerente authored Jan 5, 2022
2 parents 77302a5 + 7e80c7f commit 137e016
Show file tree
Hide file tree
Showing 5 changed files with 287 additions and 114 deletions.
43 changes: 24 additions & 19 deletions Source/FengGameManagerMKII.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class FengGameManagerMKII : MonoBehaviour
{
public static readonly string applicationId = "f1f6195c-df4a-40f9-bae5-4744c32901ef";
public static readonly string applicationId = string.Empty;
public static Hashtable banHash;
public static Hashtable boolVariables;
public static Dictionary<string, GameObject> CachedPrefabs;
Expand Down Expand Up @@ -1908,12 +1908,12 @@ public void NOTSpawnPlayerRC(string id)

public void OnConnectedToMaster()
{
print("OnConnectedToMaster");
Print("OnConnectedToMaster");
}

public void OnConnectedToPhoton()
{
print("OnConnectedToPhoton");
Print("OnConnectedToPhoton");
}

public void OnConnectionFail(DisconnectCause cause)
Expand All @@ -1927,7 +1927,7 @@ public void OnConnectionFail(DisconnectCause cause)
break;
}

print("OnConnectionFail : " + cause);
Print("OnConnectionFail : " + cause);
Screen.lockCursor = false;
Screen.showCursor = true;
IN_GAME_MAIN_CAMERA.gametype = GAMETYPE.STOP;
Expand All @@ -1945,17 +1945,17 @@ public void OnCreatedRoom()
kicklist = new ArrayList();
racingResult = new ArrayList();
teamScores = new int[2];
print("OnCreatedRoom");
Print("OnCreatedRoom");
}

public void OnCustomAuthenticationFailed()
{
print("OnCustomAuthenticationFailed");
Print("OnCustomAuthenticationFailed");
}

public void OnDisconnectedFromPhoton()
{
print("OnDisconnectedFromPhoton");
Print("OnDisconnectedFromPhoton");
Screen.lockCursor = false;
Screen.showCursor = true;
}
Expand Down Expand Up @@ -2113,7 +2113,7 @@ public void oneTitanDown(string name1, bool onPlayerLeave)

public void OnFailedToConnectToPhoton()
{
print("OnFailedToConnectToPhoton");
Print("OnFailedToConnectToPhoton");
}

public void OnJoinedLobby()
Expand All @@ -2127,14 +2127,19 @@ public void OnJoinedLobby()
RejoinRegion = PhotonNetwork.networkingPeer.MasterServerAddress.Split(':')[0].Replace("wss://", string.Empty).Replace("ws://", string.Empty);
}

private void Print(object msg)
{
print($"{DateTime.Now:T} | INFO | {msg}");
}

public void OnJoinedRoom()
{
HERO.PlayersSkins = new Dictionary<int, string>();
Logger.LogChat(Logger.ChatLogPath, PhotonNetwork.room);
maxPlayers = PhotonNetwork.room.maxPlayers;
playerList = string.Empty;
char[] separator = { "`"[0] };
print("OnJoinedRoom " + PhotonNetwork.room.name + " >>>> " + LevelInfo.getInfo(PhotonNetwork.room.name.Split(separator)[1]).mapName);
Print(DateTime.Now + "OnJoinedRoom " + PhotonNetwork.room.name + " >>>> " + LevelInfo.getInfo(PhotonNetwork.room.name.Split(separator)[1]).mapName);
RejoinRoom = PhotonNetwork.networkingPeer.mRoomToGetInto;
gameTimesUp = false;
char[] chArray3 = { "`"[0] };
Expand Down Expand Up @@ -2217,7 +2222,7 @@ public void OnJoinedRoom()

public void OnLeftLobby()
{
print("OnLeftLobby");
Print("OnLeftLobby");
}

public void OnLeftRoom()
Expand Down Expand Up @@ -2290,7 +2295,7 @@ public void OnMasterClientSwitched(PhotonPlayer newMasterClient)

public void OnPhotonCreateRoomFailed()
{
print("OnPhotonCreateRoomFailed");
Print("OnPhotonCreateRoomFailed");
}

public void OnPhotonCustomRoomPropertiesChanged()
Expand Down Expand Up @@ -2320,17 +2325,17 @@ public void OnPhotonCustomRoomPropertiesChanged()

public void OnPhotonInstantiate()
{
print("OnPhotonInstantiate");
Print("OnPhotonInstantiate");
}

public void OnPhotonJoinRoomFailed()
{
print("OnPhotonJoinRoomFailed");
Print("OnPhotonJoinRoomFailed");
}

public void OnPhotonMaxCccuReached()
{
print("OnPhotonMaxCccuReached");
Print("OnPhotonMaxCccuReached");
}

private IEnumerator OnPlayerConnected(PhotonPlayer player)
Expand Down Expand Up @@ -2626,12 +2631,12 @@ public void OnPhotonPlayerPropertiesChanged(object[] playerAndUpdatedProps)

public void OnPhotonRandomJoinFailed()
{
print("OnPhotonRandomJoinFailed");
Print("OnPhotonRandomJoinFailed");
}

public void OnPhotonSerializeView()
{
print("OnPhotonSerializeView");
Print("OnPhotonSerializeView");
}

public void OnReceivedRoomListUpdate()
Expand All @@ -2657,7 +2662,7 @@ public void OnUpdate()

public void OnUpdatedFriendList()
{
print("OnUpdatedFriendList");
Print("OnUpdatedFriendList");
}

public int operantType(string str, int condition)
Expand Down Expand Up @@ -7622,7 +7627,7 @@ private void ignorePlayerArray(int[] IDS, PhotonMessageInfo info)

private void kickPhotonPlayer(string name)
{
print("KICK " + name + "!!!");
Print("KICK " + name + "!!!");
foreach (var player in PhotonNetwork.playerList)
{
if (player.ID.ToString() == name && !player.isMasterClient)
Expand Down Expand Up @@ -8898,7 +8903,7 @@ private void refreshPVPStatus(int score1, int score2)
[RPC]
private void refreshPVPStatus_AHSS(int[] score1)
{
print(score1);
Print(score1);
teamScores = score1;
}

Expand Down
40 changes: 34 additions & 6 deletions Source/GGM/GUI/Pages/Multiplayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,19 @@ internal class Multiplayer : Page
private static Vector2 CreateMapSlider;
private static Vector2 PresetsSlider;

private static int Server;
private static readonly string[] Servers = { "Offline", "Europe", "US", "Asia", "Japan" };
private static readonly string[] ServersAdresses = new string[] { string.Empty, "eu", "us", "asia", "jp" };
private static Regions Server;
private static int ChosenServer;

private enum Regions
{
Offline,
EU,
USA,
Asia,
SouthAmerica
}

private static readonly string[] Servers = { "Offline", "Europe", "USA", "Asia", "South America" };
private static string KeyWords;
private static bool[] Map;
private static readonly string[] Maps = { "The City", "The City III", "The Forest", "The Forest II", "The Forest III", "The Forest IV - LAVA", "Annie", "Annie II", "Colossal Titan", "Colossal Titan II", "Trost", "Trost II", "Racing - Akina", "Outside The Walls", "Cave Fight", "House Fight", "Custom", "Custom (No PT)" };
Expand All @@ -37,7 +47,7 @@ internal class Multiplayer : Page
private float timeToUpdate;
private List<RoomInfo> servers = new List<RoomInfo>();
private bool connected;
private int connectedServer;
private Regions connectedServer;
private static int Page;
private static int MapToCreate;
private static string ServerNameToCreate;
Expand Down Expand Up @@ -256,7 +266,8 @@ private void OnGUI()
GUILayout.BeginHorizontal();
{
GUILayout.FlexibleSpace();
Grid(string.Empty, ref Server, Servers, width: BoxWidth / 2f, height: 25);
Grid(string.Empty, ref ChosenServer, Servers, width: BoxWidth / 2f, height: 25);
Server = (Regions)ChosenServer;
CheckIfNeedConnect();
GUILayout.FlexibleSpace();
}
Expand Down Expand Up @@ -497,7 +508,24 @@ private void Update()
{
if (!connected && Server > 0)
{
PhotonNetwork.ConnectToMaster($"app-{ServersAdresses[Server]}.exitgamescloud.com", NetworkingPeer.ProtocolToNameServerPort[PhotonNetwork.networkingPeer.UsedProtocol], FengGameManagerMKII.applicationId, UIMainReferences.ServerKey);
switch (Server)
{
case Regions.EU:
PhotonNetwork.ConnectToMaster("135.125.239.180", NetworkingPeer.ProtocolToNameServerPort[PhotonNetwork.networkingPeer.UsedProtocol], FengGameManagerMKII.applicationId, UIMainReferences.ServerKey);
break;
case Regions.USA:
PhotonNetwork.ConnectToMaster("142.44.242.29", NetworkingPeer.ProtocolToNameServerPort[PhotonNetwork.networkingPeer.UsedProtocol], FengGameManagerMKII.applicationId, UIMainReferences.ServerKey);
break;
case Regions.Asia:
PhotonNetwork.ConnectToMaster("51.79.164.137", NetworkingPeer.ProtocolToNameServerPort[PhotonNetwork.networkingPeer.UsedProtocol], FengGameManagerMKII.applicationId, UIMainReferences.ServerKey);
break;
case Regions.SouthAmerica:
PhotonNetwork.ConnectToMaster("172.107.193.233", NetworkingPeer.ProtocolToNameServerPort[PhotonNetwork.networkingPeer.UsedProtocol], FengGameManagerMKII.applicationId, UIMainReferences.ServerKey);
break;
default:
Server = Regions.EU;
break;
}
}

UpdateRoomList();
Expand Down
49 changes: 36 additions & 13 deletions Source/HERO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public class HERO : MonoBehaviour
{
private HERO_STATE _state;
private bool animationStopped = false;
private bool almostSingleHook;
private string attackAnimation;
private int attackLoop;
Expand Down Expand Up @@ -785,6 +786,12 @@ public void ClearPopup()

public void continueAnimation()
{
if (!animationStopped)
{
return;
}
animationStopped = false;

foreach (AnimationState animationState in animation)
{
if (animationState.speed == 1f)
Expand Down Expand Up @@ -1912,26 +1919,33 @@ private void FixedUpdate()
currentCamera.GetComponent<Camera>().fieldOfView = Settings.CameraFOVSetting;
}

if (flag2)
if (!_cancelGasDisable)
{
useGas(useGasSpeed * Time.deltaTime);
if (!smoke_3dmg.enableEmission && IN_GAME_MAIN_CAMERA.gametype != GAMETYPE.SINGLE && photonView.isMine)
if (flag2)
{
object[] parameters = { true };
photonView.RPC("net3DMGSMOKE", PhotonTargets.Others, parameters);
useGas(useGasSpeed * Time.deltaTime);
if (!smoke_3dmg.enableEmission && IN_GAME_MAIN_CAMERA.gametype != GAMETYPE.SINGLE && photonView.isMine)
{
object[] parameters = { true };
photonView.RPC("net3DMGSMOKE", PhotonTargets.Others, parameters);
}

smoke_3dmg.enableEmission = true;
}
else
{
if (smoke_3dmg.enableEmission && IN_GAME_MAIN_CAMERA.gametype != GAMETYPE.SINGLE && photonView.isMine)
{
object[] objArray3 = { false };
photonView.RPC("net3DMGSMOKE", PhotonTargets.Others, objArray3);
}

smoke_3dmg.enableEmission = true;
smoke_3dmg.enableEmission = false;
}
}
else
{
if (smoke_3dmg.enableEmission && IN_GAME_MAIN_CAMERA.gametype != GAMETYPE.SINGLE && photonView.isMine)
{
object[] objArray3 = { false };
photonView.RPC("net3DMGSMOKE", PhotonTargets.Others, objArray3);
}

smoke_3dmg.enableEmission = false;
_cancelGasDisable = false;
}

if (currentSpeed > 80f)
Expand Down Expand Up @@ -2347,6 +2361,8 @@ public void lateUpdate()
}
}

private bool _cancelGasDisable = false;

public void launch(Vector3 des, bool left = true, bool leviMode = false)
{
if (isMounted)
Expand Down Expand Up @@ -3944,6 +3960,11 @@ private void OnDestroy()

public void pauseAnimation()
{
if (animationStopped)
{
return;
}

foreach (AnimationState animationState in animation)
{
animationState.speed = 0f;
Expand All @@ -3953,6 +3974,8 @@ public void pauseAnimation()
{
photonView.RPC("netPauseAnimation", PhotonTargets.Others);
}

animationStopped = true;
}

public void playAnimation(string aniName)
Expand Down
12 changes: 10 additions & 2 deletions Source/NetworkingPeer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,17 @@ public void ChangeLocalID(int newID)

public void checkLAN()
{
if (FengGameManagerMKII.OnPrivateServer && MasterServerAddress != null && MasterServerAddress != string.Empty && mGameserver != null && mGameserver != string.Empty && MasterServerAddress.Contains(":") && mGameserver.Contains(":"))
if (mGameserver.Contains("127.0.0.1"))
{
mGameserver = MasterServerAddress.Split(':')[0] + ":" + mGameserver.Split(':')[1];
int addressIndex = TransportProtocol >= ConnectionProtocol.WebSocket ? 1 : 0;
string actualAddress = MasterServerAddress.Split(':')[addressIndex];

if (addressIndex > 0)
{
actualAddress = actualAddress.Substring(2);
}

this.mGameserver = mGameserver.Replace("127.0.0.1", actualAddress);
}
}

Expand Down
Loading

0 comments on commit 137e016

Please sign in to comment.