Commit 820ae940 authored by 神楽坂玲奈's avatar 神楽坂玲奈

remove command.shell, make command line arguments more stable

parent d84dde14
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
using UnityEngine.Networking;
using Debug = UnityEngine.Debug;
public class Menu : WindowServantSP
{
......@@ -38,11 +37,6 @@ public class Menu : WindowServantSP
Program.charge();
}
public override void hide()
{
base.hide();
}
private IEnumerator checkUpdate()
{
yield return new WaitForSeconds(1);
......@@ -91,7 +85,6 @@ public class Menu : WindowServantSP
public override void preFrameFunction()
{
base.preFrameFunction();
checkCommend();
if (Program.noAccess && !msgPermissionShowed)
{
msgPermissionShowed = true;
......@@ -112,7 +105,11 @@ public class Menu : WindowServantSP
Program.I().quit();
Program.Running = false;
TcpHelper.SaveRecord();
Process.GetCurrentProcess().Kill();
#if UNITY_EDITOR
EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
private void onClickOnline()
......@@ -144,111 +141,4 @@ public class Menu : WindowServantSP
{
Program.I().shiftToServant(Program.I().selectDeck);
}
public static void deleteShell()
{
try
{
if (File.Exists("commamd.shell")) File.Delete("commamd.shell");
}
catch (Exception)
{
}
}
public static void checkCommend()
{
if (Program.TimePassed() - lastTime > 1000)
{
lastTime = Program.TimePassed();
if (Program.I().selectDeck == null) return;
if (Program.I().selectReplay == null) return;
if (Program.I().puzzleMode == null) return;
if (Program.I().selectServer == null) return;
try
{
if (File.Exists("commamd.shell") == false) File.Create("commamd.shell").Close();
}
catch (Exception e)
{
Program.noAccess = true;
Debug.Log(e);
}
var all = "";
try
{
all = File.ReadAllText("commamd.shell", Encoding.UTF8);
var parmChars = all.ToCharArray();
var inQuote = false;
for (var index = 0; index < parmChars.Length; index++)
{
if (parmChars[index] == '"')
{
inQuote = !inQuote;
parmChars[index] = '\n';
}
if (!inQuote && parmChars[index] == ' ')
parmChars[index] = '\n';
}
var mats = new string(parmChars).Split(new[] {'\n'}, StringSplitOptions.RemoveEmptyEntries);
if (mats.Length > 0)
switch (mats[0])
{
case "online":
if (mats.Length == 5)
{
UIHelper.iniFaces(); //加载用户头像
Program.I().selectServer.KF_onlineGame(mats[1], mats[2], mats[3], mats[4]);
}
if (mats.Length == 6)
{
UIHelper.iniFaces();
Program.I().selectServer.KF_onlineGame(mats[1], mats[2], mats[3], mats[4], mats[5]);
}
break;
case "edit":
if (mats.Length == 2) Program.I().selectDeck.KF_editDeck(mats[1]); //编辑卡组
break;
case "replay":
if (mats.Length == 2)
{
UIHelper.iniFaces();
Program.I().selectReplay.KF_replay(mats[1]); //编辑录像
}
break;
case "puzzle":
if (mats.Length == 2)
{
UIHelper.iniFaces();
Program.I().puzzleMode.KF_puzzle(mats[1]); //运行残局
}
break;
}
}
catch (Exception e)
{
Program.noAccess = true;
Debug.Log(e);
}
try
{
if (all != "")
if (File.Exists("commamd.shell"))
File.WriteAllText("commamd.shell", "");
}
catch (Exception e)
{
Program.noAccess = true;
Debug.Log(e);
}
}
}
}
\ No newline at end of file
......@@ -49,6 +49,7 @@ public static class TcpHelper
}
catch (Exception e)
{
Debug.LogError(e);
Program.DEBUGLOG("onDisConnected 10");
}
......@@ -224,6 +225,14 @@ public static class TcpHelper
}
}
// public static void SendSync(Package message)
// {
// if (tcpClient != null && tcpClient.Connected)
// {
// sender(message);
// }
// }
private static void sender(object o)
{
try
......@@ -238,6 +247,7 @@ public static class TcpHelper
b.Write(BitConverter.GetBytes((byte) message.Fuction), 0, 1);
b.Write(data, 0, data.Length);
var s = memstream.ToArray();
Debug.Log(BitConverter.ToString(s));
tcpClient.Client.Send(s);
}
}
......
......@@ -28,18 +28,6 @@ public class Ocgcore : ServantWithCardDescription
private readonly List<gameCard> allCardsInSelectMessage = new List<gameCard>();
public List<GameObject> allChainPanelFixedContainer = new List<GameObject>();
private arrow Arrow;
private autoForceChainHandlerType autoForceChainHandler = autoForceChainHandlerType.manDoAll;
private float camera_max = -17.5f;
private float camera_min = -17.5f;
public bool cantCheckGrave;
public List<gameCard> cards = new List<gameCard>();
private readonly List<gameCard> cardsForConfirm = new List<gameCard>();
private readonly List<gameCard> cardsInChain = new List<gameCard>();
......@@ -53,6 +41,31 @@ public class Ocgcore : ServantWithCardDescription
private readonly List<gameCard> cardsSelectable = new List<gameCard>();
private readonly List<gameCard> cardsSelected = new List<gameCard>();
private readonly List<int> ES_searchCode = new List<int>();
private readonly List<sortResult> ES_sortCurrent = new List<sortResult>();
private readonly List<sortResult> ES_sortResult = new List<sortResult>();
private readonly List<int> keys = new List<int>();
private readonly List<linkMask> linkMaskList = new List<linkMask>();
private readonly List<Package> Packages_ALL = new List<Package>();
private readonly List<placeSelector> placeSelectors = new List<placeSelector>();
public List<GameObject> allChainPanelFixedContainer = new List<GameObject>();
private arrow Arrow;
private autoForceChainHandlerType autoForceChainHandler = autoForceChainHandlerType.manDoAll;
private float camera_max = -17.5f;
private float camera_min = -17.5f;
public bool cantCheckGrave;
public List<gameCard> cards = new List<gameCard>();
private bool clearAllShowedB;
private bool clearTimeFlag;
private int code_for_show;
......@@ -82,8 +95,6 @@ public class Ocgcore : ServantWithCardDescription
private string ES_phaseString = "";
private readonly List<int> ES_searchCode = new List<int>();
private string ES_selectHint = "";
private int Es_selectMSGHintData;
private int Es_selectMSGHintPlayer;
......@@ -91,10 +102,6 @@ public class Ocgcore : ServantWithCardDescription
private string ES_selectUnselectHint = "";
private readonly List<sortResult> ES_sortCurrent = new List<sortResult>();
private readonly List<sortResult> ES_sortResult = new List<sortResult>();
private int ES_sortSum;
private string ES_turnString = "";
......@@ -113,8 +120,6 @@ public class Ocgcore : ServantWithCardDescription
public bool isFirst;
public bool isObserver;
private readonly List<int> keys = new List<int>();
private int keysTempCount;
private float lastAlpha;
private int lastExcitedController = -1;
......@@ -132,8 +137,6 @@ public class Ocgcore : ServantWithCardDescription
public int life_1;
private readonly List<linkMask> linkMaskList = new List<linkMask>();
public int lpLimit = 8000;
public int MasterRule;
......@@ -155,12 +158,9 @@ public class Ocgcore : ServantWithCardDescription
public string name_1_tag = "";
private List<Package> Packages = new List<Package>();
private readonly List<Package> Packages_ALL = new List<Package>();
public bool paused;
private readonly List<placeSelector> placeSelectors = new List<placeSelector>();
private bool replayShowAll;
private bool reportShowAll;
......@@ -2356,8 +2356,7 @@ public class Ocgcore : ServantWithCardDescription
Program.I().camera_main_2d.ScreenToWorldPoint(point),
new Vector3(0, 0, 0),
true,
Program.I().ui_main_2d,
true
Program.I().ui_main_2d
).GetComponent<lazyWin>();
}
else
......@@ -2368,8 +2367,7 @@ public class Ocgcore : ServantWithCardDescription
Program.I().camera_main_2d.ScreenToWorldPoint(point),
new Vector3(0, 0, 0),
true,
Program.I().ui_main_2d,
true
Program.I().ui_main_2d
).GetComponent<lazyWin>();
UIHelper.InterGameObject(winCaculator.gameObject);
winCaculator.input.value = UIHelper.getTimeString();
......@@ -6839,7 +6837,6 @@ public class Ocgcore : ServantWithCardDescription
public override void show()
{
if (isShowed) Menu.deleteShell();
base.show();
Program.I().light.transform.eulerAngles = new Vector3(50, -50, 0);
Program.cameraPosition = new Vector3(0, 23, -18.5f - 3.2f * (Program.fieldSize - 1f) / 0.21f);
......
......@@ -19,8 +19,7 @@ public class Program : MonoBehaviour
public Light light;
public AudioSource audio;
[Header("容器")]
public GameObject ui_back_ground_2d;
[Header("容器")] public GameObject ui_back_ground_2d;
public GameObject ui_windows_2d;
public GameObject ui_main_2d;
public GameObject ui_container_3d;
......@@ -28,31 +27,27 @@ public class Program : MonoBehaviour
public GameObject ui_main_3d;
public Camera camera_main_3d;
[Header("ui_back_ground_2d")]
public Camera camera_back_ground_2d;
[Header("ui_back_ground_2d")] public Camera camera_back_ground_2d;
public GameObject mod_simple_ngui_background_texture;
public GameObject new_ui_cardDescription;
public GameObject new_ui_search;
public gameInfo new_ui_gameInfo;
[Header("ui_windows_2d")]
public Camera camera_windows_2d;
[Header("ui_windows_2d")] public Camera camera_windows_2d;
public GameObject new_ui_menu;
public GameObject remaster_deckManager;
public GameObject new_ui_selectServer;
public GameObject remaster_replayManager;
public GameObject remaster_puzzleManager;
public GameObject new_ui_aiRoom;
[Header("ui_main_2d")]
public Camera camera_main_2d;
[Header("ui_main_2d")] public Camera camera_main_2d;
public GameObject new_ui_setting;
public GameObject new_bar_room;
public GameObject new_ui_searchDetailed;
public GameObject new_ui_book;
[Header("其他")]
public GameObject mouseParticle;
[Header("其他")] public GameObject mouseParticle;
[Header("Prefab")] public facer face;
public AudioClip zhankai;
......@@ -121,7 +116,7 @@ public class Program : MonoBehaviour
public GameObject mod_ocgcore_ss_p_sum_effect;
public GameObject mod_ocgcore_ss_dark_hole;
public GameObject mod_ocgcore_ss_link_mark;
public GameObject new_ui_cardOnSearchList;
public GameObject new_bar_editDeck;
public GameObject new_bar_changeSide;
......@@ -286,17 +281,12 @@ public class Program : MonoBehaviour
private void initialize()
{
// go(1, () =>
// {
UIHelper.iniFaces();
initializeALLcameras();
fixALLcamerasPreFrame();
backGroundPic = new BackGroundPic();
servants.Add(backGroundPic);
backGroundPic.fixScreenProblem();
// });
// go(300, () =>
// {
InterString.initialize("config/translation.conf");
GameTextureManager.initialize();
Config.initialize("config/config.conf");
......@@ -393,8 +383,6 @@ public class Program : MonoBehaviour
initializeALLservants();
loadResources();
readParams();
// });
}
private void readParams()
......@@ -413,8 +401,6 @@ public class Program : MonoBehaviour
if (args[i].ToLower() == "-n" && args.Length > i + 1)
{
nick = args[++i];
if (nick.Contains(" "))
nick = "\"" + nick + "\"";
}
if (args[i].ToLower() == "-h" && args.Length > i + 1) host = args[++i];
......@@ -422,29 +408,21 @@ public class Program : MonoBehaviour
if (args[i].ToLower() == "-w" && args.Length > i + 1)
{
password = args[++i];
if (password.Contains(" "))
password = "\"" + password + "\"";
}
if (args[i].ToLower() == "-d" && args.Length > i + 1)
{
deck = args[++i];
if (deck.Contains(" "))
deck = "\"" + deck + "\"";
}
if (args[i].ToLower() == "-r" && args.Length > i + 1)
{
replay = args[++i];
if (replay.Contains(" "))
replay = "\"" + replay + "\"";
}
if (args[i].ToLower() == "-s" && args.Length > i + 1)
{
puzzle = args[++i];
if (puzzle.Contains(" "))
puzzle = "\"" + puzzle + "\"";
}
if (args[i].ToLower() == "-j")
......@@ -454,32 +432,29 @@ public class Program : MonoBehaviour
}
}
var cmdFile = "commamd.shell";
if (join)
{
File.WriteAllText(cmdFile, "online " + nick + " " + host + " " + port + " 0x233 " + password,
Encoding.UTF8);
shiftToServant(selectServer);
selectServer.KF_onlineGame(nick, host, port, "0x233", password);
exitOnReturn = true;
}
else if (deck != null)
{
File.WriteAllText(cmdFile, "edit " + deck, Encoding.UTF8);
selectDeck.KF_editDeck(deck);
exitOnReturn = true;
}
else if (replay != null)
{
File.WriteAllText(cmdFile, "replay " + replay, Encoding.UTF8);
selectReplay.KF_replay(replay);
exitOnReturn = true;
}
else if (puzzle != null)
{
File.WriteAllText(cmdFile, "puzzle " + puzzle, Encoding.UTF8);
puzzleMode.KF_puzzle(puzzle);
exitOnReturn = true;
}
}
private static int lastChargeTime;
public static void charge()
......@@ -799,7 +774,8 @@ public class Program : MonoBehaviour
// mouseParticle = Instantiate(new_mouse);
instance = this;
initialize();
go(500, () => { gameStart(); });
gameStart();
readParams();
}
private int preWid;
......@@ -941,7 +917,6 @@ public class Program : MonoBehaviour
//adeUnityEngine.Debug.Log(e);
}
Menu.deleteShell();
foreach (var zip in GameZipManager.Zips) zip.Dispose();
}
......
......@@ -15,12 +15,6 @@ public class AIRoom : WindowServantSP
RMSshow_none(InterString.Get("AI模式还在开发中,您在AI模式下遇到的BUG不会在联机的时候出现。"));
}
public override void preFrameFunction()
{
base.preFrameFunction();
Menu.checkCommend();
}
#region ui
private UIselectableList superScrollView;
......
......@@ -53,7 +53,6 @@ public class Room : WindowServantSP
public override void show()
{
if (isShowed) Menu.deleteShell();
base.show();
Program.I().ocgcore.returnServant = Program.I().selectServer;
Program.I().ocgcore.handler = handler;
......
......@@ -9,19 +9,17 @@ using YGOSharp.OCGWrapper.Enums;
public class selectDeck : WindowServantSP
{
private readonly cardPicLoader[] quickCards = new cardPicLoader[200];
private readonly string sort = "sortByTimeDeck";
private UIDeckPanel deckPanel;
private string deckSelected = "";
private string preString = "";
private readonly cardPicLoader[] quickCards = new cardPicLoader[200];
private UIInput searchInput;
private readonly string sort = "sortByTimeDeck";
private UIselectableList superScrollView;
public override void initialize()
......@@ -74,7 +72,6 @@ public class selectDeck : WindowServantSP
public override void preFrameFunction()
{
base.preFrameFunction();
Menu.checkCommend();
if (searchInput.value != preString)
{
preString = searchInput.value;
......
......@@ -28,12 +28,6 @@ public class puzzleMode : WindowServantSP
selectedString = superScrollView.selectedString;
}
public override void preFrameFunction()
{
base.preFrameFunction();
Menu.checkCommend();
}
public void KF_puzzle(string name)
{
launch("puzzle/" + name + ".lua");
......
......@@ -8,13 +8,12 @@ using GameMessage = YGOSharp.OCGWrapper.Enums.GameMessage;
public class selectReplay : WindowServantSP
{
private readonly string sort = "sortByTimeReplay";
private bool opYRP;
private PrecyOcg precy;
private string selectedTrace = "";
private readonly string sort = "sortByTimeReplay";
private UIselectableList superScrollView;
public override void initialize()
......@@ -340,12 +339,6 @@ public class selectReplay : WindowServantSP
selectedTrace = superScrollView.selectedString;
}
public override void preFrameFunction()
{
base.preFrameFunction();
Menu.checkCommend();
}
public void KF_replay(string name, bool god = false)
{
try
......
......@@ -77,12 +77,6 @@ public class SelectServer : WindowServantSP
Program.charge();
}
public override void preFrameFunction()
{
base.preFrameFunction();
Menu.checkCommend();
}
private void printFile(bool first)
{
list.Clear();
......@@ -143,7 +137,7 @@ public class SelectServer : WindowServantSP
for (var i = 0; i < list.items.Count; i++) all += list.items[i] + "\r\n";
File.WriteAllText("config/hosts.conf", all);
printFile(false);
new Thread(() => { TcpHelper.@join(ipString, name, portString, pswString, versionString); }).Start();
new Thread(() => { TcpHelper.join(ipString, name, portString, pswString, versionString); }).Start();
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment