Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2000:
[Freeciv-Dev] working version of civserver_readline (I hope)
Home

[Freeciv-Dev] working version of civserver_readline (I hope)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] working version of civserver_readline (I hope)
From: Tomasz Wegrzanowski <maniek@xxxxxxxx>
Date: Sun, 30 Jan 2000 22:08:34 +0100

With this version I was able to set up rules, play and finish game.
So it may be called working.

BTW 1:
When I bribe a city (CVS version), fields around it don't become
visible. It wasn't issue in mpciv1 nor mpciv2.

BTW 2:
There should be button `Refresh All' in city report (F1).
After revolution report is not automagicaly updated, so it is
100% wrong.

*** START ***
#!/usr/bin/perl -w
# Wraper over civserver to use readline facilites
# Copyright (c) 2000 Tomasz Węgrzanowski <maniek@xxxxxxxx>
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# On Debian GNU/Linux systems, the complete text of the GNU General
# Public License can be found in `/usr/share/common-licenses/GPL'.

use Term::ReadLine;
use IPC::Open3;
pipe CS_W,CS_E;
open3 \*CS_W,\*CS_E,\*CS_E,"civserver @ARGV >&2";

$SIG{'INT'} = \&finish;
my $term = new Term::ReadLine 'Freeciv server';
my $prompt = 'freeciv> ';

while (1) {
  $read = sysread (CS_E,$ans,4096);
  exit unless ($read);
READMORE:
  if ($ans =~ />\s$/ ) {
    $ans =~ s/>\s$//;
    print $ans;
    print CS_W ($term->readline ($prompt)),"\n";
  }
  else {
    if ($ans =~ /\n>?$/ ) {
      my $readcont = sysread (CS_E,$anscont,4096);
      exit unless ($readcont);
      $ans .= $anscont;
      goto READMORE;
    }
    print $ans;
  }
}

sub finish {
print "Exiting at user's request\n";
print CS_W "quit\n";
close CS_W;
exit;
}
**** END ****

[Prev in Thread] Current Thread [Next in Thread]