Esempio n. 1
0
void 
network_new_city (int* originx, int* originy, int random_village)
{
  MsgBuf msg;
  MSG_OPCODE(&msg) = MSG_NEW_CITY;
  MSG_LENGTH(&msg) = 0;
  net_send_message (sock, &msg);
}
Esempio n. 2
0
void
network_unrequest_mini_screen (void)
{
    MsgBuf msg;
    MSG_OPCODE(&msg) = MSG_MINI_SCRN_END;
    MSG_LENGTH(&msg) = 0;
    net_send_message (sock, &msg);
}
Esempio n. 3
0
/* ---------------------------------------------------------------------- *
 * Public Functions -- Outgoing messages
 * ---------------------------------------------------------------------- */
void 
network_join_game (void)
{
  MsgBuf msg;
  MSG_OPCODE(&msg) = MSG_JOIN;
  MSG_LENGTH(&msg) = 0;
  net_send_message (sock, &msg);
}
Esempio n. 4
0
void 
network_do_coal_survey (void)
{
    MsgBuf msg;
    MSG_OPCODE(&msg) = MSG_DO_COAL_SURVEY;
    MSG_LENGTH(&msg) = 0;
    net_send_message (sock, &msg);
}
Esempio n. 5
0
void
network_unrequest_mappoint_stats (void)
{
    MsgBuf msg;
    MSG_OPCODE(&msg) = MSG_MPS_END;
    MSG_LENGTH(&msg) = 0;
    net_send_message (sock, &msg);
}
Esempio n. 6
0
void
network_request_mini_screen (int mini_type)
{
    MsgBuf msg;
    Int32* msgp = (Int32*) MSG_BODY(&msg);
    MSG_OPCODE(&msg) = MSG_MINI_SCRN_REQ;
    MSG_LENGTH(&msg) = 1 * sizeof(Int32);
    *msgp++ = htonl(mini_type);
    net_send_message (sock, &msg);
}
Esempio n. 7
0
void 
network_launch_rocket (int x, int y)
{
    MsgBuf msg;
    Int32* msgp = (Int32*) MSG_BODY(&msg);
    MSG_OPCODE(&msg) = MSG_LAUNCH_ROCKET;
    MSG_LENGTH(&msg) = 2 * sizeof(Int32);
    *msgp++ = htonl(x);
    *msgp++ = htonl(y);
    net_send_message (sock, &msg);
}
Esempio n. 8
0
void
network_request_mappoint_stats (int x, int y)
{
  MsgBuf msg;
  Int32* msgp = (Int32*) MSG_BODY(&msg);
  MSG_OPCODE(&msg) = MSG_MPS_REQ;
  MSG_LENGTH(&msg) = 2 * sizeof(Int32);
  *msgp++ = htonl(x);
  *msgp++ = htonl(y);
  net_send_message (sock, &msg);
}
Esempio n. 9
0
void
network_send_flags (int x, int y)
{
    MsgBuf msg;
    Int32* msgp = (Int32*) MSG_BODY(&msg);
    MSG_OPCODE(&msg) = MSG_SEND_FLAGS;
    MSG_LENGTH(&msg) = 3 * sizeof(Int32);
    *msgp++ = htonl(x);
    *msgp++ = htonl(y);
    *msgp++ = htonl(MP_INFO(x,y).flags);
    net_send_message (sock, &msg);
}
Esempio n. 10
0
void
network_bulldoze_item (int x, int y)
{
  MsgBuf msg;
  Int32* msgp = (Int32*) MSG_BODY(&msg);

  MSG_OPCODE(&msg) = MSG_BULLDOZE_ITEM;
  MSG_LENGTH(&msg) = 2 * sizeof(Int32);
  *msgp++ = htonl(x);
  *msgp++ = htonl(y);
  net_send_message (sock, &msg);
}
Esempio n. 11
0
int client_recv_udp_msg(socket_t *sock,socket_t *from,char *data,int data_len,uint16_t *session_id,uint8_t *cmd_type,uint16_t *length)
{
	char buf[MSG_LEN];
	msg_hdr_t *hdr_ptr;
	char *msg_ptr;
	int ret ;

	hdr_ptr = (msg_hdr_t *)buf;
	msg_ptr = buf + sizeof(msg_hdr_t);


	ret = sock_recv(sock,from,buf,sizeof(buf));
	if(ret < 0)
		return -1;
	if(ret == 0)
		return -2;
	if(ret < sizeof(msg_hdr_t))
		return -3;

	uint8_t version;
	version = MSG_VERSION(hdr_ptr);
	if(version != P_VERSION)
	{
		if(g_debug)
		{
			printf("Recv UDP MSG Unknow Version[%02x\n]",version);
		}
		return -4;
	}
	*cmd_type = MSG_CMD(hdr_ptr);
	*session_id = MSG_SESSION(hdr_ptr);
	*length = MSG_LENGTH(hdr_ptr);
	
	if(ret - MSG_HEAD_LENGTH != *length)
		return -1;

	*length = MIN(data_len,*length);
	memcpy(data,msg_ptr,*length);

	if(g_debug)
	{
		/*
		printf("---------- Recv UDP Packet -----------------\n");
		printf("session_id [%d]\n",*session_id);
		printf("cmd_type [%02x]\n",*cmd_type);
		printf("udp data length [%d]\n",*length);
		printf("msg [%s]\n\n",msg_ptr);
		*/
	}

	return 0;
}
Esempio n. 12
0
void
network_place_item (int x, int y, int selected_type)
{
  MsgBuf msg;
  Int32* msgp = (Int32*) MSG_BODY(&msg);

  MSG_OPCODE(&msg) = MSG_PLACE_ITEM;
  MSG_LENGTH(&msg) = 3 * sizeof(Int32);
  *msgp++ = htonl(x);
  *msgp++ = htonl(y);
  *msgp++ = htonl(selected_type);
  net_send_message (sock, &msg);
}
Esempio n. 13
0
void
network_request_main_screen (void)
{
  MsgBuf msg;
  Int32* msgp = (Int32*) MSG_BODY(&msg);
  MSG_OPCODE(&msg) = MSG_MAIN_SCRN_REQ;
  MSG_LENGTH(&msg) = 4 * sizeof(Int32);
  *msgp++ = htonl(main_screen_originx);
  *msgp++ = htonl(main_screen_originy);
#if defined (commentout)
  /* GCS FIX: Need to give server right size of main screen */
  *msgp++ = htonl(MAIN_WIN_W / 16);
  *msgp++ = htonl(MAIN_WIN_H / 16);
#endif
  net_send_message (sock, &msg);
}