Skip to content

Commit

Permalink
Cleaved up excessive logging
Browse files Browse the repository at this point in the history
  • Loading branch information
AMacro committed Jul 14, 2024
1 parent c30a2e4 commit 633bdc0
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 83 deletions.
14 changes: 7 additions & 7 deletions Multiplayer/Components/MainMenu/HostGamePane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,36 +103,36 @@ private void BuildUI()
GameObject dividerPrefab = goMMC.FindChildByName("Divider");
if (dividerPrefab == null)
{
Debug.Log("Divider not found!");
Multiplayer.LogError("Divider not found!");
return;
}

GameObject cbPrefab = goMMC.FindChildByName("CheckboxFreeCam");
if (cbPrefab == null)
{
Debug.Log("CheckboxFreeCam not found!");
Multiplayer.LogError("CheckboxFreeCam not found!");
return;
}

GameObject sliderPrefab = goMMC.FindChildByName("SliderLimitSession");
if (sliderPrefab == null)
{
Debug.Log("SliderLimitSession not found!");
Multiplayer.LogError("SliderLimitSession not found!");
return;
}

GameObject inputPrefab = MainMenuThingsAndStuff.Instance.renamePopupPrefab.gameObject.FindChildByName("TextFieldTextIcon");
if (inputPrefab == null)
{
Debug.Log("TextFieldTextIcon not found!");
Multiplayer.LogError("TextFieldTextIcon not found!");
return;
}


lcInstance = goMMC.FindChildByName("PaneRight Launcher").GetComponent<LauncherController>();
if (lcInstance == null)
{
Debug.Log("No Run Button");
Multiplayer.LogError("No Run Button");
return;
}
Sprite playSprite = lcInstance.runButton.FindChildByName("[icon]").GetComponent<Image>().sprite;
Expand Down Expand Up @@ -331,7 +331,7 @@ private void ValidateInputs(string text)

startButton.ToggleInteractable(valid);

Debug.Log($"Validated: {valid}");
//Multiplayer.Log($"HostPane validated: {valid}");
}


Expand Down Expand Up @@ -391,7 +391,7 @@ private void StartClick()


var ContinueGameRequested = lcInstance.GetType().GetMethod("OnRunClicked", BindingFlags.NonPublic | BindingFlags.Instance);
Debug.Log($"OnRunClicked exists: {ContinueGameRequested != null}");
//Multiplayer.Log($"OnRunClicked exists: {ContinueGameRequested != null}");
ContinueGameRequested?.Invoke(lcInstance, null);
}

Expand Down
2 changes: 1 addition & 1 deletion Multiplayer/Components/MainMenu/MainMenuThingsAndStuff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void SwitchToMenu(byte index)
[CanBeNull]
public Popup ShowRenamePopup()
{
Debug.Log("public Popup ShowRenamePopup() ...");
Multiplayer.Log("public Popup ShowRenamePopup() ...");
return ShowPopup(renamePopupPrefab);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void HandleAction(PopupClosedByAction action)
RequestAbortion();
return;
default:
Debug.LogError(string.Format("Unhandled action {0}", action), this);
Multiplayer.LogError(string.Format("Unhandled action {0}", action));
break;
}
}
Expand Down
76 changes: 20 additions & 56 deletions Multiplayer/Components/MainMenu/ServerBrowserPane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,44 +71,8 @@ public class ServerBrowserPane : MonoBehaviour

private void Awake()
{
Multiplayer.Log("MultiplayerPane Awake()");
/*
*
* Temp testing code
*
*/
//Multiplayer.Log("MultiplayerPane Awake()");

//GameObject chat = new GameObject("ChatUI", typeof(ChatGUI));
//chat.transform.SetParent(GameObject.Find("MenuOpeningScene").transform,false);

//////////Debug.Log("Instantiating Overlay");
//////////GameObject overlay = new GameObject("Overlay", typeof(ChatGUI));
//////////GameObject parent = GameObject.Find("MenuOpeningScene");
//////////if (parent != null)
//////////{
////////// overlay.transform.SetParent(parent.transform, false);
////////// Debug.Log("Overlay parent set to MenuOpeningScene");
//////////}
//////////else
//////////{
////////// Debug.LogError("MenuOpeningScene not found");
//////////}

//////////Debug.Log("Overlay instantiated with components:");
//////////foreach (Transform child in overlay.transform)
//////////{
////////// Debug.Log("Child: " + child.name);
////////// foreach (Transform grandChild in child)
////////// {
////////// Debug.Log("GrandChild: " + grandChild.name);
////////// }
//////////}

/*
*
* End Temp testing code
*
*/
CleanUI();
BuildUI();

Expand All @@ -119,12 +83,12 @@ private void Awake()

private void OnEnable()
{
Multiplayer.Log("MultiplayerPane OnEnable()");
//Multiplayer.Log("MultiplayerPane OnEnable()");
if (!this.parentScroller)
{
Multiplayer.Log("Find ScrollRect");
//Multiplayer.Log("Find ScrollRect");
this.parentScroller = this.gridView.GetComponentInParent<ScrollRect>();
Multiplayer.Log("Found ScrollRect");
//Multiplayer.Log("Found ScrollRect");
}
this.SetupListeners(true);
this.serverIDOnRefresh = "";
Expand Down Expand Up @@ -376,7 +340,7 @@ private void JoinAction()

private void DirectAction()
{
Debug.Log($"DirectAction()");
//Debug.Log($"DirectAction()");
buttonDirectIP.ToggleInteractable(false);
buttonJoin.ToggleInteractable(false) ;

Expand All @@ -388,23 +352,23 @@ private void DirectAction()

private void IndexChanged(AGridView<IServerBrowserGameDetails> gridView)
{
Debug.Log($"Index: {gridView.SelectedModelIndex}");
//Debug.Log($"Index: {gridView.SelectedModelIndex}");
if (serverRefreshing)
return;

if (gridView.SelectedModelIndex >= 0)
{
Debug.Log($"Selected server: {gridViewModel[gridView.SelectedModelIndex].Name}");
//Debug.Log($"Selected server: {gridViewModel[gridView.SelectedModelIndex].Name}");

selectedServer = gridViewModel[gridView.SelectedModelIndex];

UpdateDetailsPane();

//Check if we can connect to this server

Debug.Log($"server: \"{selectedServer.GameVersion}\" \"{selectedServer.MultiplayerVersion}\"");
Debug.Log($"client: \"{BuildInfo.BUILD_VERSION_MAJOR.ToString()}\" \"{Multiplayer.ModEntry.Version.ToString()}\"");
Debug.Log($"result: \"{selectedServer.GameVersion == BuildInfo.BUILD_VERSION_MAJOR.ToString()}\" \"{selectedServer.MultiplayerVersion == Multiplayer.ModEntry.Version.ToString()}\"");
Multiplayer.Log($"Server: \"{selectedServer.GameVersion}\" \"{selectedServer.MultiplayerVersion}\"");
Multiplayer.Log($"Client: \"{BuildInfo.BUILD_VERSION_MAJOR.ToString()}\" \"{Multiplayer.ModEntry.Version.ToString()}\"");
Multiplayer.Log($"Result: \"{selectedServer.GameVersion == BuildInfo.BUILD_VERSION_MAJOR.ToString()}\" \"{selectedServer.MultiplayerVersion == Multiplayer.ModEntry.Version.ToString()}\"");

bool canConnect = selectedServer.GameVersion == BuildInfo.BUILD_VERSION_MAJOR.ToString() &&
selectedServer.MultiplayerVersion == Multiplayer.ModEntry.Version.ToString();
Expand All @@ -425,7 +389,7 @@ private void UpdateDetailsPane()

if (selectedServer != null)
{
Debug.Log("Prepping Data");
//Multiplayer.Log("Prepping Data");
serverName.text = selectedServer.Name;

//note: built-in localisations have a trailing colon e.g. 'Game mode:'
Expand All @@ -442,14 +406,14 @@ private void UpdateDetailsPane()
details += "<br>";
details += selectedServer.ServerDetails;

Debug.Log("Finished Prepping Data");
//Multiplayer.Log("Finished Prepping Data");
detailsPane.text = details;
}
}

private void ShowIpPopup()
{
Debug.Log("In ShowIpPpopup");
Multiplayer.Log("In ShowIpPpopup");
var popup = MainMenuThingsAndStuff.Instance.ShowRenamePopup();
if (popup == null)
{
Expand Down Expand Up @@ -568,15 +532,15 @@ private void ShowPasswordPopup()
private void HandleConnectionEstablished()
{
// Connection established, handle the UI or game state accordingly
Debug.Log("Connection established!");
Multiplayer.Log("Connection established!");
// HideConnectingPopup(); // Hide the connecting message
}

// Example of handling connection failure
private void HandleConnectionFailed()
{
// Connection failed, show an error message or handle the failure scenario
Debug.LogError("Connection failed!");
Multiplayer.LogError("Connection failed!");
// ShowConnectionFailedPopup();
}

Expand All @@ -592,21 +556,21 @@ IEnumerator GetRequest(string uri)

if (webRequest.isNetworkError)
{
Debug.Log(pages[page] + ": Error: " + webRequest.error);
Multiplayer.LogError(pages[page] + ": Error: " + webRequest.error);
}
else
{
Debug.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text);
Multiplayer.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text);

LobbyServerData[] response;

response = Newtonsoft.Json.JsonConvert.DeserializeObject<LobbyServerData[]>(webRequest.downloadHandler.text);

Debug.Log($"servers: {response.Length}");
Multiplayer.Log($"Serverbrowser servers: {response.Length}");

foreach (LobbyServerData server in response)
{
Debug.Log($"Name: {server.Name}\tIP: {server.ip}");
Multiplayer.Log($"Server name: {server.Name}\tIP: {server.ip}");
}

if (response.Length == 0)
Expand Down Expand Up @@ -686,7 +650,7 @@ private void FillDummyServers()
item.MultiplayerVersion = UnityEngine.Random.Range(1, 10) > 3 ? Multiplayer.ModEntry.Version.ToString() : "0.1.0";


Debug.Log(item.HasPassword);
//Debug.Log(item.HasPassword);
gridViewModel.Add(item);
}

Expand Down
2 changes: 1 addition & 1 deletion Multiplayer/Components/Networking/Jobs/NetworkedJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private void Start()
//station.logicStation.AddJobToStation(job);
if (station.logicStation.availableJobs.Contains(job))
{
Debug.LogError("Trying to add the same job[" + job.ID + "] multiple times to station! Skipping, trying to recover.");
Multiplayer.LogError("Trying to add the same job[" + job.ID + "] multiple times to station! Skipping, trying to recover.");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Multiplayer/Networking/Managers/Server/NetworkServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected override void Subscribe()

private void OnLoaded()
{
Debug.Log($"Server loaded, isSinglePlayer: {isSinglePlayer} isPublic: {isPublic}");
//Debug.Log($"Server loaded, isSinglePlayer: {isSinglePlayer} isPublic: {isPublic}");
if (!isSinglePlayer && isPublic)
{
lobbyServerManager = NetworkLifecycle.Instance.GetOrAddComponent<LobbyServerManager>();
Expand Down
5 changes: 1 addition & 4 deletions Multiplayer/Patches/MainMenu/LauncherControllerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ private static void SetData(LauncherController __instance, UIStartGameData start

private static void HostAction()
{
// Implement host action logic here
Debug.Log("Host button clicked.");


//Debug.Log("Host button clicked.");

RightPaneController_OnEnable_Patch.uIMenuController.SwitchMenu(RightPaneController_OnEnable_Patch.hostMenuIndex);

Expand Down
13 changes: 1 addition & 12 deletions Multiplayer/Utils/Csv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,38 @@ public static class Csv
/// </summary>
public static ReadOnlyDictionary<string, Dictionary<string, string>> Parse(string data)
{
Multiplayer.Log("CSV.Parse()");
// Split the input data into lines
string[] separators = new string[] { "\r\n", "\n" };
string[] lines = data.Split(separators, StringSplitOptions.RemoveEmptyEntries);

// Use an OrderedDictionary to preserve the insertion order of keys
var columns = new OrderedDictionary();

Multiplayer.Log($"Parsing Line 0: <<<<{lines[0]}>>>>");

// Parse the header line to get the column keys
List<string> keys = ParseLine(lines[0]);
foreach (string key in keys)
{
Multiplayer.Log($"Adding key: {key}");
if (!string.IsNullOrWhiteSpace(key))
columns.Add(key, new Dictionary<string, string>());
}

Multiplayer.Log("Columns added");

// Iterate through the remaining lines (rows)
for (int i = 1; i < lines.Length; i++)
{
Multiplayer.Log($"Parsing line: {i}");
string line = lines[i];
List<string> values = ParseLine(line);
Multiplayer.Log($"Parsed line: {i}");

if (values.Count == 0 || string.IsNullOrWhiteSpace(values[0]))
continue;

Multiplayer.Log($"Not-skipped line: {i}");

string rowKey = values[0];

// Add the row values to the appropriate column dictionaries
for (int j = 0; j < values.Count && j < keys.Count; j++)
{
Multiplayer.Log($"Looping line: {j}, key: {keys[j]}");
string columnKey = keys[j];
if (!string.IsNullOrWhiteSpace(columnKey))
{
Multiplayer.Log($"Checking Dict: {j}, value: {values[j]}");
var columnDict = (Dictionary<string, string>)columns[columnKey];
columnDict[rowKey] = values[j];
}
Expand Down

0 comments on commit 633bdc0

Please sign in to comment.