ArgumentParser.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Media;
  2. using NTERA.EmuEra.Game.EraEmu.GameData;
  3. using NTERA.EmuEra.Game.EraEmu.Sub;
  4. namespace NTERA.EmuEra.Game.EraEmu.GameProc.Function
  5. {
  6. //1756 LogicalLineParserから分離。処理をArgumentBuilderに分割
  7. internal static partial class ArgumentParser
  8. {
  9. public static bool SetArgumentTo(InstructionLine line)
  10. {
  11. if (line == null)
  12. return false;
  13. if (line.Argument != null)
  14. return true;
  15. if (line.IsError)
  16. return false;
  17. if (!Program.DebugMode && line.Function.IsDebug())
  18. {//非DebugモードでのDebug系命令。何もしないので引数解析も不要
  19. line.Argument = null;
  20. return true;
  21. }
  22. Argument arg = null;
  23. string errmes = null;
  24. try
  25. {
  26. arg = line.Function.ArgBuilder.CreateArgument(line, GlobalStatic.EMediator);
  27. }
  28. catch (EmueraException e)
  29. {
  30. errmes = e.Message;
  31. goto error;
  32. }
  33. if (arg == null)
  34. {
  35. if (!line.IsError)
  36. {
  37. errmes = "命令の引数解析中に特定できないエラーが発生";
  38. goto error;
  39. }
  40. return false;
  41. }
  42. line.Argument = arg;
  43. if (arg == null)
  44. line.IsError = true;
  45. return true;
  46. error:
  47. SystemSounds.Hand.Play();
  48. line.IsError = true;
  49. line.ErrMes = errmes;
  50. ParserMediator.Warn(errmes, line, 2, true, false);
  51. return false;
  52. }
  53. }
  54. }