Beispiel #1
0
//
//	.ini ファイルから読み出し
//
void get_inifile(void)
{
	TCHAR temp[MAX_PATH];

	GetPrivateProfileString(HEADER, KEY_EXE, _T(""), exe_name, MAX_PATH, ini_name);
	GetPrivateProfileString(HEADER, KEY_OPTION, _T(""), temp, MAX_PATH, ini_name);
	// 2009/8/26
	if(GetPrivateProfileInt(HEADER, KEY_ENCODE, 0, ini_name) == 0) {
		lstrcpy(option_name, temp);
	} else {
		decode_copy(option_name, temp);
	}
	GetPrivateProfileString(HEADER, KEY_NAME, _T(""), service_name, MAX_PATH, ini_name);
	GetPrivateProfileString(HEADER, KEY_DESCRIPTION, _T(""), description_name, MAX_PATH, ini_name);
	// 2002/6/19
	end_pattern = GetPrivateProfileInt(HEADER, KEY_END, END_SYS_AND_CLOSE, ini_name);
	auto_flag = GetPrivateProfileInt(HEADER, KEY_AUTO, 1, ini_name);
	desktop_flag = GetPrivateProfileInt(HEADER, KEY_DESKTOP, 0, ini_name);
	retry_flag = GetPrivateProfileInt(HEADER, KEY_RETRY, 0, ini_name);
}
void reDraw()
{
	if(isInHole[5]=='y' && ((isInHole[1]=='y' && isInHole[2]=='y') || (isInHole[3]=='y' && isInHole[4]=='y') ))
	{
		if(score_2p[0] > score_2p[1]) printf("PLAYER1 WINS\n");
		else if(score_2p[0] < score_2p[1]) printf("PLAYER2 WINS\n");
		else printf("TIE!!\n");
	}
	char buffer[256];
	int i,n;
	//draw dir arrows
	if(dir == 'y' && chance[1] == 'y')
	{
		glColor3f(0.0f,0.0f,0.0f);
		glBegin(GL_LINE_STRIP);
		glVertex3f(dir_x,dir_y,-5.0f);
		glVertex3f(X[0],Y[0],-5.0f);
		glEnd();
	}
	//condition for collision
	check_collision(Vx,Vy,r_str,r_cn);
	//striker
	if(isInHole[0] == 'n')  check_str_wall(Vx,Vy);
	//condition for striker going into the holes
	if((distance(X[0],Y[0],1.69f,1.69f)<=0.11f||distance(X[0],Y[0],1.69f,-1.69f)<=0.11f||distance(X[0],Y[0],-1.69f,-1.69f)<=0.11f||
	distance(X[0],Y[0],-1.69f,1.69f)<=0.11f))
	{
		isInHole[0]='y';
		X[0] = 2.0f;
		Y[0] = 2.0f;
		Vx[0] = 0.0f;
		Vy[0] = 0.0f;
	}
	if(isInHole[0]=='n') //draw striker
	{
		glColor3f(0.8f,0.5f,0.2f);
		drawDisc(X[0],Y[0],r_str,1000);
		glColor3f(0.8f,0.2f,0.2f);
		drawDisc(X[0],Y[0],r_str-0.04f,1000);
		glColor3f(0.8f,0.5f,0.2f);
		drawDisc(X[0],Y[0],r_str-0.05f,1000);
		glColor3f(0.8f,0.2f,0.2f);
		drawDisc(X[0],Y[0],0.01f,1000);
	}
	//coins
	for(i=1;i<6;i++)
	{
		glColor3f(0.0f,0.0f,1.0f);
		if(isInHole[i] == 'n') check_cn_wall(Vx,Vy,i);//for striking with wall
		//condition for coin1 going into holes
		if((distance(X[i],Y[i],1.69f,1.69f)<=0.11f||distance(X[i],Y[i],1.69f,-1.69f)<=0.11f||distance(X[i],Y[i],-1.69f,-1.69f)<=0.11f||
		distance(X[i],Y[i],-1.69f,1.69f)<=0.11f))
		{	
			isInHole[i]='y';
			X[i] = 2.0f;
			Y[i] = 2.0f;
			Vx[i] = 0.0f;
			Vy[i] = 0.0f;
		}
		if(isInHole[i] == 'n')
		{
			if(i==1 || i==2)//black coins			
			{
				glColor3f(0.19f,0.19f,0.19f);
				drawDisc(X[i],Y[i],r_cn,1000);
				glColor3f(0.8f,0.2f,0.2f);
				drawDisc(X[i],Y[i],r_cn-0.03f,1000);
				glColor3f(0.19f,0.19f,0.19f);
				drawDisc(X[i],Y[i],r_cn-0.04f,1000);
				glColor3f(0.8f,0.2f,0.2f);
				drawDisc(X[i],Y[i],0.01f,1000);
			}
			if(i==3 || i==4)//white coins
			{
				glColor3f(0.76f,0.76f,0.76f);
				drawDisc(X[i],Y[i],r_cn,1000);
				glColor3f(0.8f,0.2f,0.2f);
				drawDisc(X[i],Y[i],r_cn-0.03f,1000);
				glColor3f(0.76f,0.76f,0.76f);
				drawDisc(X[i],Y[i],r_cn-0.04f,1000);
				glColor3f(0.8f,0.2f,0.2f);
				drawDisc(X[i],Y[i],0.01f,1000);
			}
			if(i==5)
			{
				glColor3f(0.8f,0.0f,0.0f);
				drawDisc(X[i],Y[i],r_cn,1000);
				glColor3f(0.8f,0.2f,0.2f);
				drawDisc(X[i],Y[i],r_cn-0.03f,1000);
				glColor3f(0.8f,0.0f,0.0f);
				drawDisc(X[i],Y[i],r_cn-0.04f,1000);
				glColor3f(0.8f,0.2f,0.2f);
				drawDisc(X[i],Y[i],0.01f,1000);
			}
		}
	}
	//variable alpha exists so as to make sure that board is made once and then it waits for data
	if(chance[1]=='n')
	{
		if(alpha!=0 && isStrikerHitByOther=='n')
		{
			bzero(buffer,256);
			n = read(sockfd,buffer,255);
    			if (n < 0) 
        	 	error("ERROR reading from socket");//data reading
        	 	//perform decode
        	 	decode_copy(buffer);
			dir = 'n';
		}
		alpha=1;
	}	
	update_chance(Vx,Vy,chance);
}
Beispiel #3
0
/*
 * Encode ALLOCATE request
 */
static void nfs4_xdr_enc_allocate(struct rpc_rqst *req,
				  struct xdr_stream *xdr,
				  struct nfs42_falloc_args *args)
{
	struct compound_hdr hdr = {
		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
	};

	encode_compound_hdr(xdr, req, &hdr);
	encode_sequence(xdr, &args->seq_args, &hdr);
	encode_putfh(xdr, args->falloc_fh, &hdr);
	encode_allocate(xdr, args, &hdr);
	encode_getfattr(xdr, args->falloc_bitmask, &hdr);
	encode_nops(&hdr);
}

/*
 * Encode COPY request
 */
static void nfs4_xdr_enc_copy(struct rpc_rqst *req,
			      struct xdr_stream *xdr,
			      struct nfs42_copy_args *args)
{
	struct compound_hdr hdr = {
		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
	};

	encode_compound_hdr(xdr, req, &hdr);
	encode_sequence(xdr, &args->seq_args, &hdr);
	encode_putfh(xdr, args->src_fh, &hdr);
	encode_savefh(xdr, &hdr);
	encode_putfh(xdr, args->dst_fh, &hdr);
	encode_copy(xdr, args, &hdr);
	encode_nops(&hdr);
}

/*
 * Encode DEALLOCATE request
 */
static void nfs4_xdr_enc_deallocate(struct rpc_rqst *req,
				    struct xdr_stream *xdr,
				    struct nfs42_falloc_args *args)
{
	struct compound_hdr hdr = {
		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
	};

	encode_compound_hdr(xdr, req, &hdr);
	encode_sequence(xdr, &args->seq_args, &hdr);
	encode_putfh(xdr, args->falloc_fh, &hdr);
	encode_deallocate(xdr, args, &hdr);
	encode_getfattr(xdr, args->falloc_bitmask, &hdr);
	encode_nops(&hdr);
}

/*
 * Encode SEEK request
 */
static void nfs4_xdr_enc_seek(struct rpc_rqst *req,
			      struct xdr_stream *xdr,
			      struct nfs42_seek_args *args)
{
	struct compound_hdr hdr = {
		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
	};

	encode_compound_hdr(xdr, req, &hdr);
	encode_sequence(xdr, &args->seq_args, &hdr);
	encode_putfh(xdr, args->sa_fh, &hdr);
	encode_seek(xdr, args, &hdr);
	encode_nops(&hdr);
}

/*
 * Encode LAYOUTSTATS request
 */
static void nfs4_xdr_enc_layoutstats(struct rpc_rqst *req,
				     struct xdr_stream *xdr,
				     struct nfs42_layoutstat_args *args)
{
	int i;

	struct compound_hdr hdr = {
		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
	};

	encode_compound_hdr(xdr, req, &hdr);
	encode_sequence(xdr, &args->seq_args, &hdr);
	encode_putfh(xdr, args->fh, &hdr);
	WARN_ON(args->num_dev > PNFS_LAYOUTSTATS_MAXDEV);
	for (i = 0; i < args->num_dev; i++)
		encode_layoutstats(xdr, args, &args->devinfo[i], &hdr);
	encode_nops(&hdr);
}

/*
 * Encode CLONE request
 */
static void nfs4_xdr_enc_clone(struct rpc_rqst *req,
			       struct xdr_stream *xdr,
			       struct nfs42_clone_args *args)
{
	struct compound_hdr hdr = {
		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
	};

	encode_compound_hdr(xdr, req, &hdr);
	encode_sequence(xdr, &args->seq_args, &hdr);
	encode_putfh(xdr, args->src_fh, &hdr);
	encode_savefh(xdr, &hdr);
	encode_putfh(xdr, args->dst_fh, &hdr);
	encode_clone(xdr, args, &hdr);
	encode_getfattr(xdr, args->dst_bitmask, &hdr);
	encode_nops(&hdr);
}

static int decode_allocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
{
	return decode_op_hdr(xdr, OP_ALLOCATE);
}

static int decode_write_response(struct xdr_stream *xdr,
				 struct nfs42_write_res *res)
{
	__be32 *p;

	p = xdr_inline_decode(xdr, 4 + 8 + 4);
	if (unlikely(!p))
		goto out_overflow;

	/*
	 * We never use asynchronous mode, so warn if a server returns
	 * a stateid.
	 */
	if (unlikely(*p != 0)) {
		pr_err_once("%s: server has set unrequested "
				"asynchronous mode\n", __func__);
		return -EREMOTEIO;
	}
	p++;
	p = xdr_decode_hyper(p, &res->count);
	res->verifier.committed = be32_to_cpup(p);
	return decode_verifier(xdr, &res->verifier.verifier);

out_overflow:
	print_overflow_msg(__func__, xdr);
	return -EIO;
}

static int decode_copy_requirements(struct xdr_stream *xdr,
				    struct nfs42_copy_res *res) {
	__be32 *p;

	p = xdr_inline_decode(xdr, 4 + 4);
	if (unlikely(!p))
		goto out_overflow;

	res->consecutive = be32_to_cpup(p++);
	res->synchronous = be32_to_cpup(p++);
	return 0;
out_overflow:
	print_overflow_msg(__func__, xdr);
	return -EIO;
}

static int decode_copy(struct xdr_stream *xdr, struct nfs42_copy_res *res)
{
	int status;

	status = decode_op_hdr(xdr, OP_COPY);
	if (status == NFS4ERR_OFFLOAD_NO_REQS) {
		status = decode_copy_requirements(xdr, res);
		if (status)
			return status;
		return NFS4ERR_OFFLOAD_NO_REQS;
	} else if (status)
		return status;

	status = decode_write_response(xdr, &res->write_res);
	if (status)
		return status;

	return decode_copy_requirements(xdr, res);
}

static int decode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
{
	return decode_op_hdr(xdr, OP_DEALLOCATE);
}

static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res)
{
	int status;
	__be32 *p;

	status = decode_op_hdr(xdr, OP_SEEK);
	if (status)
		return status;

	p = xdr_inline_decode(xdr, 4 + 8);
	if (unlikely(!p))
		goto out_overflow;

	res->sr_eof = be32_to_cpup(p++);
	p = xdr_decode_hyper(p, &res->sr_offset);
	return 0;

out_overflow:
	print_overflow_msg(__func__, xdr);
	return -EIO;
}

static int decode_layoutstats(struct xdr_stream *xdr)
{
	return decode_op_hdr(xdr, OP_LAYOUTSTATS);
}

static int decode_clone(struct xdr_stream *xdr)
{
	return decode_op_hdr(xdr, OP_CLONE);
}

/*
 * Decode ALLOCATE request
 */
static int nfs4_xdr_dec_allocate(struct rpc_rqst *rqstp,
				 struct xdr_stream *xdr,
				 struct nfs42_falloc_res *res)
{
	struct compound_hdr hdr;
	int status;

	status = decode_compound_hdr(xdr, &hdr);
	if (status)
		goto out;
	status = decode_sequence(xdr, &res->seq_res, rqstp);
	if (status)
		goto out;
	status = decode_putfh(xdr);
	if (status)
		goto out;
	status = decode_allocate(xdr, res);
	if (status)
		goto out;
	decode_getfattr(xdr, res->falloc_fattr, res->falloc_server);
out:
	return status;
}

/*
 * Decode COPY response
 */
static int nfs4_xdr_dec_copy(struct rpc_rqst *rqstp,
			     struct xdr_stream *xdr,
			     struct nfs42_copy_res *res)
{
	struct compound_hdr hdr;
	int status;

	status = decode_compound_hdr(xdr, &hdr);
	if (status)
		goto out;
	status = decode_sequence(xdr, &res->seq_res, rqstp);
	if (status)
		goto out;
	status = decode_putfh(xdr);
	if (status)
		goto out;
	status = decode_savefh(xdr);
	if (status)
		goto out;
	status = decode_putfh(xdr);
	if (status)
		goto out;
	status = decode_copy(xdr, res);
out:
	return status;
}

/*
 * Decode DEALLOCATE request
 */
static int nfs4_xdr_dec_deallocate(struct rpc_rqst *rqstp,
				   struct xdr_stream *xdr,
				   struct nfs42_falloc_res *res)
{
	struct compound_hdr hdr;
	int status;

	status = decode_compound_hdr(xdr, &hdr);
	if (status)
		goto out;
	status = decode_sequence(xdr, &res->seq_res, rqstp);
	if (status)
		goto out;
	status = decode_putfh(xdr);
	if (status)
		goto out;
	status = decode_deallocate(xdr, res);
	if (status)
		goto out;
	decode_getfattr(xdr, res->falloc_fattr, res->falloc_server);
out:
	return status;
}

/*
 * Decode SEEK request
 */
static int nfs4_xdr_dec_seek(struct rpc_rqst *rqstp,
			     struct xdr_stream *xdr,
			     struct nfs42_seek_res *res)
{
	struct compound_hdr hdr;
	int status;

	status = decode_compound_hdr(xdr, &hdr);
	if (status)
		goto out;
	status = decode_sequence(xdr, &res->seq_res, rqstp);
	if (status)
		goto out;
	status = decode_putfh(xdr);
	if (status)
		goto out;
	status = decode_seek(xdr, res);
out:
	return status;
}

/*
 * Decode LAYOUTSTATS request
 */
static int nfs4_xdr_dec_layoutstats(struct rpc_rqst *rqstp,
				    struct xdr_stream *xdr,
				    struct nfs42_layoutstat_res *res)
{
	struct compound_hdr hdr;
	int status, i;

	status = decode_compound_hdr(xdr, &hdr);
	if (status)
		goto out;
	status = decode_sequence(xdr, &res->seq_res, rqstp);
	if (status)
		goto out;
	status = decode_putfh(xdr);
	if (status)
		goto out;
	WARN_ON(res->num_dev > PNFS_LAYOUTSTATS_MAXDEV);
	for (i = 0; i < res->num_dev; i++) {
		status = decode_layoutstats(xdr);
		if (status)
			goto out;
	}
out:
	res->rpc_status = status;
	return status;
}

/*
 * Decode CLONE request
 */
static int nfs4_xdr_dec_clone(struct rpc_rqst *rqstp,
			      struct xdr_stream *xdr,
			      struct nfs42_clone_res *res)
{
	struct compound_hdr hdr;
	int status;

	status = decode_compound_hdr(xdr, &hdr);
	if (status)
		goto out;
	status = decode_sequence(xdr, &res->seq_res, rqstp);
	if (status)
		goto out;
	status = decode_putfh(xdr);
	if (status)
		goto out;
	status = decode_savefh(xdr);
	if (status)
		goto out;
	status = decode_putfh(xdr);
	if (status)
		goto out;
	status = decode_clone(xdr);
	if (status)
		goto out;
	status = decode_getfattr(xdr, res->dst_fattr, res->server);

out:
	res->rpc_status = status;
	return status;
}