浏览代码

feat: 为了支持 Windows 而做的适应性改造,尽可能去掉了不必要的 #script 指令

dzp 2 年之前
父节点
当前提交
beabfe9386
共有 5 个文件被更改,包括 42 次插入35 次删除
  1. 1 3
      framework/log.tin
  2. 30 12
      framework/main.tin
  3. 1 8
      framework/utils.tin
  4. 8 10
      plugins/basic/login.tin
  5. 2 2
      plugins/lib/ui/tmux.tin

+ 1 - 3
framework/log.tin

@@ -26,9 +26,7 @@ PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
 #func {InitLog} {
     #local path {%1};
 
-    #local output {};
-    #script output {test -d var && echo true || echo false};
-    #if { "$output[1]" == "true" } {
+    #if { @existsDir{var} } {
         #var gLog[PATH] {var/log};
     };
     #else {

+ 30 - 12
framework/main.tin

@@ -97,6 +97,32 @@ PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
     };
 };
 
+#func {existsFile} {
+    #local file {%0};
+    #var tmpSize {0};
+    #line quiet #scan file {$file} {#var tmpSize &2};
+    #local tmp {$tmpSize};
+    #unvar tmpSize;
+    #if { $tmp > 0 } {
+        #return 1;
+    };
+    #else {
+        #return 0;
+    };
+};
+
+#func {existsDir} {
+    #local dir {%0};
+    #local output {};
+    #line quiet #scan dir {$dir} output;
+    #if { &output[] > 0 } {
+        #return 1;
+    };
+    #else {
+        #return 0;
+    };
+};
+
 #nop 优先加载 var/$file(玩家自定义文件),其次加载 mud/$file(MUDLIB 相关文件);
 #alias {load-file} {
     #local file {%1};
@@ -106,17 +132,13 @@ PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
         #return;
     };
 
-    #local output {};
-    #script output {test -f var/$file && echo true || echo false};
-    #if { "$output[1]" == "true" } {
+    #if { @existsFile{var/$file} } {
         #read var/$file;
         #return;
     };
 
     #if { "$gCurrentMUDLIB" != "" } {
-        #local output {};
-        #script output {test -f mud/$gCurrentMUDLIB/$file && echo true || echo false};
-        #if { "$output[1]" == "true" } {
+        #if { @existsFile{mud/$gCurrentMUDLIB/$file} } {
             #read mud/$gCurrentMUDLIB/$file;
             #return;
         };
@@ -126,15 +148,11 @@ PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
 
     #replace file {.tin$} {.extra.tin};
 
-    #local output {};
-    #script output {test -f mud/$gCurrentMUDLIB/$file && echo true || echo false};
-    #if { "$output[1]" == "true" } {
+    #if { @existsFile{mud/$gCurrentMUDLIB/$file} } {
         #read mud/$gCurrentMUDLIB/$file;
     };
 
-    #local output {};
-    #script output {test -f var/$file && echo true || echo false};
-    #if { "$output[1]" == "true" } {
+    #if { @existsFile{var/$file} } {
         #read var/$file;
     };
 };

+ 1 - 8
framework/utils.tin

@@ -68,13 +68,6 @@ PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
     #return 0;
 };
 
-#func {existsFile} {
-    #local file {%1};
-    #local output {};
-    #script output {test -f $file && echo 1 || test -f var/$file && echo 1 || echo 0};
-    #return $output[1];
-};
-
 #func {existsJobPlugin} {
     #local job {%1};
     #return {@existsPlugin{job/$job}};
@@ -101,7 +94,7 @@ PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
 #func {mkdir} {
     #local dir {%1};
     #local output {};
-    #script output {mkdir -p $dir 2>/dev/null && test -d $dir && echo 1 || echo 0};
+    #line quiet #script output {mkdir -p $dir 2>/dev/null && test -d $dir && echo 1 || echo 0};
     #return $output[1];
 };
 

+ 8 - 10
plugins/basic/login.tin

@@ -86,9 +86,7 @@ PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
 
     #local id-file {ids/$login[user][id]};
 
-    #local output {};
-    #script output {test -d var/ids && echo true || echo false};
-    #if { "$output[1]" == "true" } {
+    #if { @existsDir{var/ids} } {
         #local id-file {var/$id-file};
     };
 
@@ -96,11 +94,11 @@ PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
         #return;
     };
 
-    #script output {cp ids/$gCurrentMUDLIB $id-file};
-    #script output {sed -i.bak 's/^#var user\[id\]       {.*};$/#var user[id]       {$login[user][id]};/' $id-file};
-    #script output {sed -i.bak 's/^#var user\[name\]     {.*};$/#var user[name]     {};/' $id-file};
-    #script output {sed -i.bak 's/^#var user\[passwd\]   {.*};$/#var user[passwd]   {$login[user][passwd]};/' $id-file};
-    #script output {sed -i.bak '/^#nop 上面三处修改完毕之后,请删除下面这行文字:;$/d' $id-file};
-    #script output {sed -i.bak '/^#var user\[manual\]   {true};$/d' $id-file};
-    #script output {rm ${id-file}.bak};
+    #line quiet #script output {cp ids/$gCurrentMUDLIB $id-file};
+    #line quiet #script output {sed -i.bak 's/^#var user\[id\]       {.*};$/#var user[id]       {$login[user][id]};/' $id-file};
+    #line quiet #script output {sed -i.bak 's/^#var user\[name\]     {.*};$/#var user[name]     {};/' $id-file};
+    #line quiet #script output {sed -i.bak 's/^#var user\[passwd\]   {.*};$/#var user[passwd]   {$login[user][passwd]};/' $id-file};
+    #line quiet #script output {sed -i.bak '/^#nop 上面三处修改完毕之后,请删除下面这行文字:;$/d' $id-file};
+    #line quiet #script output {sed -i.bak '/^#var user\[manual\]   {true};$/d' $id-file};
+    #line quiet #script output {rm ${id-file}.bak};
 };

+ 2 - 2
plugins/lib/ui/tmux.tin

@@ -92,8 +92,8 @@ PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
     };
 
     #local file {tmux/$char[档案][账号]/game-border};
-    #script {tmp} {echo '$line' > $file};
-    #script {tmp} {tmux refresh 2>/dev/null};
+    #line quiet #script {tmp} {echo '$line' > $file};
+    #line quiet #script {tmp} {tmux refresh 2>/dev/null};
 };
 
 #func {TMUX} {