ftp.nice.ch/pub/next/games/card/Zenda.NIHS.bs.tar.gz#/Zenda/Source/Referee/RefereeListener.m

This is RefereeListener.m in view mode; [Download] [Up]

#import <appkit/appkit.h>
#import "RefereeListener.h"
#import <mach.h>
#import <sys/message.h>
#import <servers/netname.h>
extern port_t name_server_port;
extern id NXResponsibleDelegate();
@implementation  RefereeListener :Listener
{}
static NXRemoteMethod *remoteMethods = NULL;
#define REMOTEMETHODS 15
+ (void)initialize 
/* */
{
    if (!remoteMethods) {
	remoteMethods =
	(NXRemoteMethod *) malloc((REMOTEMETHODS+1)*sizeof(NXRemoteMethod));
	remoteMethods[0].key = 
	@selector(remotePlayGameWith:atHost:myPullCard:myPushCard:hisPullCard:hisPushCard:);
	remoteMethods[0].types = "cciiii";
	remoteMethods[1].key = 
	@selector(remotePlayRandomGameWith:atHost:myPullCard:myPushCard:hisPullCard:hisPushCard:);
	remoteMethods[1].types = "cciiii";
	remoteMethods[2].key = 
	@selector(remoteReportGameInfoFrom:side1:side2:push1:pull1:push2:pull2:choice1:choice2:payoff:);
	remoteMethods[2].types = "iiiiiiiiii";
	remoteMethods[3].key = 
	@selector(remoteComputePayoffs);
	remoteMethods[3].types = "";
	remoteMethods[4].key = 
	@selector(remoteCheckInPlayer:atHost:);
	remoteMethods[4].types = "cc";
	remoteMethods[5].key = 
	@selector(remoteMySidePaymentIs:);
	remoteMethods[5].types = "i";
	remoteMethods[6].key = 
	@selector(remoteMyChoiceIs:);
	remoteMethods[6].types = "i";
	remoteMethods[7].key = 
	@selector(remotePlayerNumberIs:);
	remoteMethods[7].types = "i";
	remoteMethods[8].key = 
	@selector(remoteReportChoiceBy:cardPlayed:);
	remoteMethods[8].types = "ii";
	remoteMethods[9].key = 
	@selector(remoteReportPaymentBy:amount:);
	remoteMethods[9].types = "ii";
	remoteMethods[10].key = 
	@selector(remoteStartPhaseTwo);
	remoteMethods[10].types = "";
	remoteMethods[11].key = 
	@selector(remoteReportPlayerInfo:Name:Phone:SS:);
	remoteMethods[11].types = "iccc";
	remoteMethods[12].key = 
	@selector(remoteGameIsOver);
	remoteMethods[12].types = "";
	remoteMethods[13].key = 
	@selector(remotePlayerReset);
	remoteMethods[13].types = "";
	remoteMethods[14].key = 
	@selector(remoteNudge);
	remoteMethods[14].types = "";
	remoteMethods[REMOTEMETHODS].key = NULL;
    }
}
-(int)remotePlayGameWith : (char *) opponentName
	atHost : (char *) opponentHost
	myPullCard : (int) mypull
	myPushCard : (int) mypush
	hisPullCard : (int) hispull
	hisPushCard : (int) hispush
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remotePlayGameWith:atHost:myPullCard:myPushCard:hisPullCard:hisPushCard:)))
	return [_NXd remotePlayGameWith : opponentName
		atHost : opponentHost
		myPullCard : mypull
		myPushCard : mypush
		hisPullCard : hispull
		hisPushCard : hispush];
    return -1;
}

-(int)remotePlayRandomGameWith : (char *) opponentName
	atHost : (char *) opponentHost
	myPullCard : (int) mypull
	myPushCard : (int) mypush
	hisPullCard : (int) hispull
	hisPushCard : (int) hispush
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remotePlayRandomGameWith:atHost:myPullCard:myPushCard:hisPullCard:hisPushCard:)))
	return [_NXd remotePlayRandomGameWith : opponentName
		atHost : opponentHost
		myPullCard : mypull
		myPushCard : mypush
		hisPullCard : hispull
		hisPushCard : hispush];
    return -1;
}

-(int)remoteReportGameInfoFrom : (int) num
	side1 : (int) s1
	side2 : (int) s2
	push1 : (int) ps1
	pull1 : (int) pl1
	push2 : (int) ps2
	pull2 : (int) pl2
	choice1 : (int) ch1
	choice2 : (int) ch2
	payoff : (int) pay
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remoteReportGameInfoFrom:side1:side2:push1:pull1:push2:pull2:choice1:choice2:payoff:)))
	return [_NXd remoteReportGameInfoFrom : num
		side1 : s1
		side2 : s2
		push1 : ps1
		pull1 : pl1
		push2 : ps2
		pull2 : pl2
		choice1 : ch1
		choice2 : ch2
		payoff : pay];
    return -1;
}

-(int)remoteComputePayoffs
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remoteComputePayoffs)))
	return [_NXd remoteComputePayoffs];
    return -1;
}

-(int)remoteCheckInPlayer : (char *) name
	atHost : (char *) host
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remoteCheckInPlayer:atHost:)))
	return [_NXd remoteCheckInPlayer : name
		atHost : host];
    return -1;
}

-(int)remoteMySidePaymentIs : (int) sidePayment
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remoteMySidePaymentIs:)))
	return [_NXd remoteMySidePaymentIs : sidePayment];
    return -1;
}

-(int)remoteMyChoiceIs : (int) choice
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remoteMyChoiceIs:)))
	return [_NXd remoteMyChoiceIs : choice];
    return -1;
}

-(int)remotePlayerNumberIs : (int) num
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remotePlayerNumberIs:)))
	return [_NXd remotePlayerNumberIs : num];
    return -1;
}

-(int)remoteReportChoiceBy : (int) playerNum
	cardPlayed : (int) hisChoice
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remoteReportChoiceBy:cardPlayed:)))
	return [_NXd remoteReportChoiceBy : playerNum
		cardPlayed : hisChoice];
    return -1;
}

-(int)remoteReportPaymentBy : (int) playerNum
	amount : (int) sidePayment
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remoteReportPaymentBy:amount:)))
	return [_NXd remoteReportPaymentBy : playerNum
		amount : sidePayment];
    return -1;
}

-(int)remoteStartPhaseTwo
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remoteStartPhaseTwo)))
	return [_NXd remoteStartPhaseTwo];
    return -1;
}

-(int)remoteReportPlayerInfo : (int) num
	Name : (char *) str1
	Phone : (char *) str2
	SS : (char *) str3
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remoteReportPlayerInfo:Name:Phone:SS:)))
	return [_NXd remoteReportPlayerInfo : num
		Name : str1
		Phone : str2
		SS : str3];
    return -1;
}

-(int)remoteGameIsOver
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remoteGameIsOver)))
	return [_NXd remoteGameIsOver];
    return -1;
}

-(int)remotePlayerReset
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remotePlayerReset)))
	return [_NXd remotePlayerReset];
    return -1;
}

-(int)remoteNudge
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(remoteNudge)))
	return [_NXd remoteNudge];
    return -1;
}

- (int) performRemoteMethod : (NXRemoteMethod *) method
                  paramList : (NXParamValue *) paramList {
/* */
    switch (method - remoteMethods) {
    case 0:
	return [self remotePlayGameWith : paramList[0].bval.p
		atHost : paramList[1].bval.p
		myPullCard : paramList[2].ival
		myPushCard : paramList[3].ival
		hisPullCard : paramList[4].ival
		hisPushCard : paramList[5].ival];
    case 1:
	return [self remotePlayRandomGameWith : paramList[0].bval.p
		atHost : paramList[1].bval.p
		myPullCard : paramList[2].ival
		myPushCard : paramList[3].ival
		hisPullCard : paramList[4].ival
		hisPushCard : paramList[5].ival];
    case 2:
	return [self remoteReportGameInfoFrom : paramList[0].ival
		side1 : paramList[1].ival
		side2 : paramList[2].ival
		push1 : paramList[3].ival
		pull1 : paramList[4].ival
		push2 : paramList[5].ival
		pull2 : paramList[6].ival
		choice1 : paramList[7].ival
		choice2 : paramList[8].ival
		payoff : paramList[9].ival];
    case 3:
	return [self remoteComputePayoffs];
    case 4:
	return [self remoteCheckInPlayer : paramList[0].bval.p
		atHost : paramList[1].bval.p];
    case 5:
	return [self remoteMySidePaymentIs : paramList[0].ival];
    case 6:
	return [self remoteMyChoiceIs : paramList[0].ival];
    case 7:
	return [self remotePlayerNumberIs : paramList[0].ival];
    case 8:
	return [self remoteReportChoiceBy : paramList[0].ival
		cardPlayed : paramList[1].ival];
    case 9:
	return [self remoteReportPaymentBy : paramList[0].ival
		amount : paramList[1].ival];
    case 10:
	return [self remoteStartPhaseTwo];
    case 11:
	return [self remoteReportPlayerInfo : paramList[0].ival
		Name : paramList[1].bval.p
		Phone : paramList[2].bval.p
		SS : paramList[3].bval.p];
    case 12:
	return [self remoteGameIsOver];
    case 13:
	return [self remotePlayerReset];
    case 14:
	return [self remoteNudge];
    default:
	return [super performRemoteMethod : method paramList : paramList];
    }
}
- (NXRemoteMethod *) remoteMethodFor: (SEL) aSel {
/* */
    NXRemoteMethod *rm;
    if (rm = NXRemoteMethodFromSel(aSel,remoteMethods))
        return rm;
    return [super remoteMethodFor : aSel];
}
@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.