[DGD] Re: supporting both dgd and dgd net with a single driver.c

Felix A. Croes felix at dworkin.nl
Sun Nov 2 12:54:17 CET 1997


Gregory D Lewis <glewis at maths.adelaide.edu.au> wrote:
> Wim van der Vegt wrote:
> > 
> > OOps, the thing below SEEMED to work. So my question remains, how do i
> > support both dgd and dgdnet with a single driver object. Problem is that the
> > open_port is unkown to dgd and a call needs to be done to it for dgdnet to
> > accept players.
> > 
>
> "catch" the call.  I.e. make the line in driver.c
>
>    catch(open_port("telnet", 6047));
>
> If you're not using networking, it won't work.  If you are, it will.  Either 
> way the desired effect occurs.  

Neither #ifdefs nor catch are going to work here.  If there is no
open_port() kfun, then the code will not compile.

The only solution is to open the port from a different object, which is
not compiled unless the open_port() function is known to exist.

    if (sscanf(status()[ST_VERSION], "%*s.net") != 0) {
	compile_object(PORT_OBJECT)->open("telnet", 6047);
    }

Dworkin



More information about the DGD mailing list