home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR10 / TLXTW110.ZIP / TWLOGOFF.SLT < prev    next >
Text File  |  1993-08-22  |  16KB  |  396 lines

  1. // Twlogoff.slt
  2. //
  3. // Congratulations!  You have been recruited into the wonderful world of
  4. // Telix SALT programming.  This files requires editing to work
  5. // properly.
  6. //
  7. // This script requires editing for each particular BBS.
  8. // You only need to edit three small sections:
  9. //     1. do_bbs() function
  10. //     2. Offline_maintenance() function
  11. //     3. comment out line 289 (approximatelly)
  12. //
  13. // Each section is commented describing what it does.
  14. //
  15. // What this script does:
  16. //
  17. // This script will be called from DNINTG (Ctrl-D, Download Interrogation
  18. // Reports) or CIM_WARP (Ctrl-L, Level Diagram Generator) if you choose to do
  19. // so.
  20. //
  21. // It exits Tradewars from the "Command [TL=" prompt, (cloaks or remains on a
  22. // planet) then logs off the BBS and runs CRAI and anything else you want to
  23. // do. (Can be run offline if you just want to do the offline stuff) You can
  24. // run Ctrl-D and gather all the reports and after its finished it will call
  25. // this script that will log you off the BBS and do any maintenance you want
  26. // to do, all automatically.
  27. //
  28. //  (Stuff I do, you may/will have to change some of this,
  29. //   all this is done in the Offline_maintenance() function)
  30. //
  31. // Moves the capture file from d:\cap to the game's directory
  32. // Stuffs the keyboard and runs Twassist
  33. // Calls Twastlog.slc
  34. // Calls Crai,
  35. // Runs Twlog
  36. //
  37. // See also line 289 (approximatelly)
  38. ///////////////////////////////////////////////////////////////////////////////
  39. int     a, b, dr, f, fd, fs, h, i, s, x, y,
  40.         stat, t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,
  41.     old_chk_key, tm, chrcolor, statline, statline_color,
  42.         key = 0;
  43. str
  44.     f1[64], buf[255], drs[3], tmpbuf[30],
  45.         bbsname[8], shortname[3],
  46.         planet_remain[64],
  47.         planet_no[5],
  48.         gamedir[64];
  49.  
  50. do_bbs()          // Edit this
  51. {
  52.   if ( !carrier() ) return;
  53.   substr( _entry_name, 0, 4, bbsname); strupper( bbsname );
  54. ///////////////////////////////////////////////////////////////////////////////
  55. //  Enter the first four characters from the BBS in all CAPITOL LETTERS below.
  56. //  followed by the prompts that will get you off the BBS.
  57. //
  58. //      This is what must be done after you see the "Returning to BBS"
  59. //      message to get you off the BBS.
  60. //
  61. //       first 4 chars of BBS name from the dialing directory. (all CAPS)
  62. //             │
  63. //             └───┬──┐         whatever gets you off (the BBS).
  64. //                 │  │    ┌──────────────────────────────────────────┐
  65. //                 │  │    │                                          │
  66. ///////////////////////////////////////////////////////////////////////////////
  67.       if(bbsname=="19TH"){ waitfor("Menu"  ,30);delay_scr(10);cputs("GY");   delay_scr(50); }
  68.  else if(bbsname=="CAST"){ waitfor("Menu"  ,30);delay_scr(10);cputs("GY");   delay_scr(50); }
  69.  else if(bbsname=="CHES"){ waitfor("ce ]?" ,30);delay_scr(10);cputs("G^MY^M"); delay_scr(50); }
  70.  else if(bbsname=="COMP"){ waitfor("mand?" ,30);delay_scr(10);cputs("G^M");  delay_scr(50); }
  71.  else if(bbsname=="HITC"){ waitfor("wars"  ,30);delay_scr(10);cputs("!YN");  delay_scr(50); }
  72.  else if(bbsname=="JUNG"){ waitfor("Main"  ,30);delay_scr(10);cputs("-");    delay_scr(50); }
  73.  else if(bbsname=="MARI"){ waitfor("Menu"  ,60);delay_scr(10);cputs("GY");   delay_scr(50); }
  74.  else if(bbsname=="QUAD"){ waitfor("it be" ,60);delay_scr(10);cputs("MQ");   delay_scr(50); }
  75.  else if(bbsname=="ROBI"){ waitfor("Menu"  ,60);delay_scr(10);cputs("Q");
  76.                            waitfor("Menu"  ,60);delay_scr(10);cputs("GY");   delay_scr(50); }
  77.  else if(bbsname=="TERM"){ waitfor("Menu"  ,30);delay_scr(10);cputs("Q-");   delay_scr(50); }
  78.  else if(bbsname=="TWIL"){ waitfor("Queen" ,60);delay_scr(10);cputs("/O");   delay_scr(50); }
  79.  
  80.  else if(bbsname=="TEST")  return -2;
  81.  else {
  82.        soft_wind("BBSname not defined in TWLogoff.slt", 40 ); return -3;
  83.       }
  84. }// end of do_bbs()
  85. ///////////////////////////////////////////////////////////////////////////////
  86. //  This section does all the offline maintenance.
  87. //  This is all the stuff *I* do.  You can delete anything you want or add
  88. //  more here.
  89. //  (note:  keyin is a keyboard stuffer.  Stuffing the keyboard seems to
  90. //   be particular to each machine's setup/configuration. so you may need
  91. //   to stuff more or less, or delete it.  There are many different keyboard
  92. //   stuffers available on many BBS'es.
  93.  
  94. Offline_maintenance() // Edit this
  95. {                         //
  96.   if ( carrier() ) hangup(); capture("*close*"); //
  97.                          //
  98.   newdir( gamedir );                 //
  99.   if(filefind("d:\cap",0) > 0)                   //<─┐
  100.     {                         //  │ copy the capture file
  101.       fcopy( "d:\cap", "cap" );                  //  │ to the game's directory
  102.       fdelete("d:\cap");                         //  │
  103.     }                         //<─┘
  104.                          //
  105.    call("crai");                                 //    run crai
  106.    newdir( gamedir );                 //
  107.                          //
  108.    run("keyin", "/cr-mecap/cr-" ,0);             //<─┐
  109.    run("keyin", " /cr-/cr-/cr-/cr-/cr-/cr-" ,0); //  │ stuff the keyboard
  110.    run("keyin", " q/cr-/cr-x");                  //  │ and run Twassist.
  111.    run("twassist"," twassist", 0);               //<─┘
  112.                          //
  113.    call("Twastlog");                             //<── reads twassist.log
  114.    newdir( gamedir );                 //    looking for blocked
  115.                          //    ports. (see TWASTLOG.SLT)
  116.                          //
  117.    buf = " cap ";                                //<── runs Twlog - Stephen
  118.    strcat( buf, shortname );             //    Whitis' program,
  119.    run( "twlog ", buf);                          //    TWLOG080.*
  120.                          //
  121.    newdir( gamedir );                 //
  122.    buf = " cap";                                 //
  123.    strcat( buf, shortname );             //
  124.    run( "c:\qc25\tw\read", buf, 0 );             //
  125.                          //
  126.    prints(""); pstra("Calling hangup...", 3 );   //<── call hangup.slc
  127.    call("hangup");                               //
  128.                          //
  129.    newdir( _telix_dir );             //
  130.                          //
  131. }//  end of Offline_maintenance()                //
  132. //////////////////////////////////////////////////////////////////////////////
  133. //                         Soft Wind
  134. soft_wind(str message, int duration)
  135. {
  136.  int old_chk_key;  old_chk_key = _scr_chk_key;  _scr_chk_key = 0;
  137.  int l, h, x, y, key = 0, ts;
  138.  cursor_onoff(0);
  139.  x=getx(); y=gety();
  140.  l = strlen(message)/2;
  141.  h = vsavearea(37-l, 10, 43+l, 14);
  142.  box(37-l, 10, 43+l, 14, 3, 0, 5 );
  143.  pstraxy(message, 40-l  , 12, 11 );
  144.  ts = timer_start(duration);
  145.  while( !key && !time_up(ts)) key=inkey();
  146.  vrstrarea(h);
  147.  cursor_onoff(1);
  148.  gotoxy(x,y);
  149.  timer_free(ts);
  150.  _scr_chk_key = old_chk_key;
  151.  if (key > 0) return key;
  152.  return key;
  153. }
  154. //////////////////////////////////////////////////////////////////////////////
  155. //              Soft_wind() with countdown timer tenth/sec.
  156. soft_wind_timer(str message, int duration)
  157. {
  158.  _scr_chk_key=old_chk_key; _scr_chk_key = 0; cursor_onoff(0);
  159.  int l, x, y, h, key, tstart, tleft;
  160.  str tlefts[5];
  161.  l = strlen(message)/2;
  162.  x=getx(); y=gety();
  163.  h = vsavearea(37-l, 10, 43+l, 14);
  164.  box(37-l, 10, 43+l, 14, 3, 0, 31);
  165.  pstraxy(message, 40-l  , 12, 30 );
  166.  tstart = timer_start(duration);
  167.   while( !key && !time_up(tstart) && carrier() )
  168.    {
  169.     key=inkey();
  170.     tleft = ( duration - timer_total(tstart) ) ;
  171.     itos(tleft, tlefts);
  172.     strcat(tlefts, " ");
  173.     inschrs(" ", tlefts, 0, 1);
  174.     inschrs(".", tlefts, strlen(tlefts) - 2, 1);
  175.     l = 40 - strlen(tlefts) / 2;
  176.     pstraxy(tlefts, l, 13, 30);
  177.    }
  178.  vrstrarea(h);
  179.  gotoxy(x,y);
  180.  cursor_onoff(1);
  181.  timer_free(tstart);
  182.  _scr_chk_key = old_chk_key;
  183.  if ( key > 0 ) return key;
  184.  else return(-1);
  185. }
  186. //////////////////////////////////////////////////////////////////////////////
  187. fill_spaces()           // Filters out characters illegal in DOS filenames.
  188. {
  189. int i;
  190. str chr[1];
  191. int count = 0;
  192. while (count < 6)
  193. {    if (count == 0) chr = ".";
  194. else if (count == 1) chr = "+";
  195. else if (count == 2) chr = " ";
  196. else if (count == 3) chr = "?";
  197. else if (count == 4) chr = "*";
  198. else if (count == 5) chr = "/";
  199. i=0; while (1) { i = strpos(bbsname, chr, i); if (i == -1) break;
  200.                  setchr(bbsname, i ,'_'); i = i + 1;  } ++count; } return; }
  201. ///////////////////////////////////////////////////////////////////////////////
  202. //                  Check Row and Color of Status Line
  203. chk_stat ( int statchk )
  204. {  gotoxy(67, statchk);
  205.    if ((vgetchr() & 255) == 79 ){  Statline = statchk; statline_color = vgetchr()/256; }
  206.    else return(-1);
  207. }
  208. ///////////////////////////////////////////////////////////////////////////////
  209. //                        Check Prompt and ANSI
  210. chk_prompt(str prompt)
  211. {  _scr_chk_key = old_chk_key; _scr_chk_key = 0; cursor_onoff(0);
  212.    int l, h, key, ts;    str promptbuf[20];
  213.    l = strlen( prompt );  x=getx(); y=gety();  vgetchrs(0, y, promptbuf, 0, l);
  214.    gotoxy(2,y);  chrcolor = vgetchr() / 256;  gotoxy(x,y); //  get color attr
  215.    if (strcmpi(prompt, promptbuf) != 0) return(-1);
  216.    // if (chrcolor != 7 ) pstra("ANSI is ON", 31);  // Clear the Status Line
  217.    // x=getx(); y=gety();pstraxy("                                                      │", 0, statline, statline_color);gotoxy(x,y);
  218.    cursor_onoff(1); _scr_chk_key = old_chk_key;  return;
  219. }
  220. ///////////////////////////////////////////////////////////////////////////////
  221. str    Buffer[16384];
  222. fcopy(str Infname, str Outfname )
  223. {
  224.  cursor_onoff(0);
  225.  
  226.  int    a, b, fs, fp, h, i, g, gpos, l,
  227.     text_color = 15,
  228.     box_color  =  1,
  229.     hi_color   = 30,
  230.     lo_color   =  7,
  231.     Infile, Outfile, BytesRead;
  232.  
  233.  str    fsbuf[10], fps[12];
  234.  
  235.  a = 20; b =  8; gpos = a+2;
  236.  h = vsavearea( a-18, b-1,a+58,b+7 ); box(  a-18 ,b-1,a+58,b+7, 2, 0,box_color);
  237.  pstraxy( "╡", a+44, b-1,box_color);pstra(" Fcopy ",text_color);pstra("╞",box_color);
  238.  pstraxy("From :  ", a+2,b+1,text_color); pstra( Infname , lo_color);
  239.  pstraxy("To   :  ", a+2,b+2,text_color); pstra( Outfname, lo_color);
  240.  pstraxy("Bytes:  ", a+2,b+3,text_color);
  241.  pstraxy("░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░", a+2,b+6,31);
  242.  fs = filesize( Infname );  itos( fs, fsbuf );
  243.  if ( (Infile=fopen(Infname, "r")) != -1 )
  244.   {
  245.    if ( (Outfile=fopen(Outfname, "w")) != -1 )
  246.      {
  247.       while ( !feof(Infile) )
  248.     {
  249.       Bytesread = fread(Buffer, 16384, Infile);
  250.       /////////////////////// Bytes, Percentage, Bar Graph /////////////////////
  251.       fp =    ftell(Infname);
  252.       if (fp == 0) fp = 1;
  253.       itos(fp, fps); pstraxy(fps, a+10, b+3,lo_color);           //  bytes of
  254.       pstra(" of ",lo_color); pstra(fsbuf,lo_color); pstra(" bytes",lo_color);  //  bytes
  255.       g = fp * 35 / fs;                     //  graph
  256.       // fp = fp * 100 / fs; itos(fp, fps);             //    %
  257.       for(i = gpos; i <= gpos + g; ++i) pstraxy("▓", i, b+6, 14);// graph
  258.       // pstraxy(fps, a+18, b+4, 30); pstra(" %", 30);          //  %
  259.       /////////////////////////////////////////////////////////////////////////////
  260.       fwrite(Buffer, BytesRead, Outfile);
  261.     }
  262.       fclose(Outfile);
  263.      }
  264.   fclose(Infile);
  265.  }
  266.  cursor_onoff(1); vrstrarea( h );
  267. }
  268. ///////////////////////////////////////////////////////////////////////////////
  269. Remain_on_Planet()
  270. {
  271. track_free(0);
  272. t1 = track("abort", 0);
  273. t2 = track("Planet command", 0);
  274. t3 = track("turning to", 0);
  275. t4 = track("not in this", 0);
  276. cputs("L");
  277. while( carrier() )
  278.  {      terminal(); stat=track_hit(0); if(!stat) continue;
  279.   else if (stat == t1) { track_free(t1); delay_scr(dr); cputs(planet_no);
  280.                          if ( stoi( planet_no) < 200 ) cputc(13);
  281.                        }
  282.   else if (stat == t2) { track_free(t2); cputs("C" );
  283.                          if ( chrcolor != 7 ) cputs(" ");
  284.              cputs("RYY");
  285.                          if ( chrcolor != 7 ) cputs(" ");
  286.                        }
  287.   else if (stat == t3)     break;
  288.   else if (stat == t4) { track_free(0); return -1; }
  289.   }
  290.  track_free(0); return;
  291. }
  292. ///////////////////////////////////////////////////////////////////////////////
  293. main()
  294. {
  295. update_term();
  296. ///////////////////////////////////////////////////////////////////////////////
  297. //
  298. //  Delete this line after you have edited do_bbs() and Offline_maintenance()
  299. //  above.  This is the only line you have to edit in this section.
  300. //
  301. //  --------------------------------
  302. //  registration
  303.   
  304.       soft_wind("You must edit TWLOGOFF.SLT first", 50 ); return -1;
  305.   
  306. //  registration
  307. //  --------------------------------
  308. //
  309. //
  310. ///////////////////////////////////////////////////////////////////////////////
  311.    int old_chk_key; old_chk_key=_scr_chk_key; _scr_chk_key=0;
  312. if (carrier()) ustamp("++ TLXTW : TWLogoff ONline  - ", 1, 0);
  313.   else         ustamp("++ TLXTW : TWLogoff OFFline - ", 1, 0);
  314.    ustamp( _entry_name, 0, 1 );
  315. if (getenv("f1", f1)  < 1) { soft_wind("F1 environment variable not found",25);  _scr_chk_key=1; return(-1); }
  316. i = strlen(f1); if (subchr(f1, i - 1) != '\') copystr("\", f1, i, 1);
  317. if ( getenv("Temp", planet_remain) < 1 )
  318.      { soft_wind("TEMP environment variable not found",25); _scr_chk_key=1; return(-1); }
  319. if( subchr( planet_remain, strlen(planet_remain) -1 ) != '\' )
  320.     strcat( planet_remain, "\" );
  321. strcat( planet_remain, "planet.tmp" );
  322. if (getenv("dr", drs) < 1) { soft_wind("DR environment variable not found", 25); _scr_chk_key=1; return(-1); }
  323. dr = stoi(drs);
  324. if ( _entry_name == "" )
  325.  if (call("bbsname") == -1) { _scr_chk_key = 1; return(-1); }
  326.    bbsname = _entry_name; fill_spaces();
  327. strcat(f1, bbsname);
  328. if ( !filefind( f1, 16 ) )
  329.  if (call("bbsname") == -1) { _scr_chk_key = 1; return(-1); }
  330. strcat(f1, "\");
  331. gamedir = f1;
  332. x=getx(); y=gety();if (chk_stat(0) == -1)chk_stat(24); gotoxy(x,y);
  333. x=getx();y=gety();pstraxy("Calling Twlogoff                                      │", 0,statline,statline_color); pstraxy(_entry_name, 17, statline, statline_color);gotoxy(x,y);
  334. substr ( bbsname, 0, 3, shortname );
  335.  
  336. delay_scr(dr);
  337. if(carrier())
  338. {   if (chk_prompt("Command [TL") < 0 )
  339.      {    while( cinp_cnt() ) terminal();
  340.     delay_scr(20);
  341.      }
  342.   if (chk_prompt("Command [TL") < 0 ){soft_wind("Get to the ^0034Command [TL=^0034 prompt first.", 25);return(-1);}
  343. }
  344.  
  345. if ( filefind( planet_remain, 0 ) > 0 )
  346.    {
  347.     if ((f = fopen( planet_remain, "r" ) ) != 0 )
  348.        {  a=0;
  349.         while( !feof(f) )
  350.                {
  351.                 fgets( buf, 64, f ); ++a;
  352.                 if ( a == 1 )
  353.           { strupper( buf );
  354.             substr( _entry_name, 0, strlen(_entry_name), tmpbuf );
  355.             strupper( tmpbuf );
  356.            if (( strcmpi( buf, tmpbuf )) != 0 )
  357.               {
  358.                prints("");
  359.                pstra("Entryname doesn't match Planet.tmp file", 7); prints("");
  360.                pstra("_Entry_name= ", 7); pstra( tmpbuf, 7 ); prints("");
  361.                pstra("Planet.tmp = ", 7); pstra( buf, 7 );    prints("");
  362.                        fclose(f);
  363.                        return -1;
  364.                       }
  365.                    }
  366.                 planet_no = buf;
  367.                }
  368.        } fclose( f );  fdelete( planet_remain );
  369.     }
  370. if ( planet_no )
  371.   {
  372.     f = Remain_on_Planet();
  373.     if ( f < 0 ) { _scr_chk_key=old_chk_key; return -1; }
  374.   }
  375. else
  376. {
  377.  t1 = track("med? (Y/N)?", 0);
  378.  t2 = track("king Device?", 0);
  379.  t3 = track("turning to", 0);
  380. _scr_chk_key = 1;
  381.  cputs("Q");
  382. while(carrier() && inkey() != 27 )
  383.   {  terminal(); stat=track_hit(0); if(!stat) continue;
  384.      else if (stat == t1) { track_free(t1); delay_scr(dr); cputs("Y"); }
  385.      else if (stat == t2) { track_free(t2); delay_scr(dr); cputs("Y"); }
  386.      else if (stat == t3) { track_free(0); _scr_chk_key=old_chk_key; capture("*close*");
  387.                 break;  }
  388.   }
  389. }
  390. i = do_bbs(); if ( i == -2 ) return -2;
  391.      else if ( i == -3 ) return -3;
  392. if (soft_wind_timer("Waiting to hang up....",50) < 0)
  393.     Offline_maintenance();
  394. timer_free(tm); _scr_chk_key=old_chk_key; return;
  395. }
  396.