Feature #359 ยป 0052-networking-Clear-trailing-spaces.patch
| common/networking/connection.c | ||
|---|---|---|
|
if (FD_ISSET(pc->sock, &writefs)) {
|
||
|
nblock = MIN(buf->ndata-start, MAX_LEN_PACKET);
|
||
|
log_debug("trying to write %d limit=%d", nblock, limit);
|
||
|
if ((nput = fc_writesocket(pc->sock,
|
||
|
if ((nput = fc_writesocket(pc->sock,
|
||
|
(const char *)buf->data+start, nblock)) == -1) {
|
||
|
#ifdef NONBLOCKING_SOCKETS
|
||
|
if (errno == EWOULDBLOCK || errno == EAGAIN) {
|
||
| ... | ... | |
|
conn_list_size(game.all_connections),
|
||
|
MAX_LEN_NAME-1, fc_strncasequotecmp,
|
||
|
effectivestrlenquote, user_name, &ind);
|
||
|
|
||
|
if (*result < M_PRE_AMBIGUOUS) {
|
||
|
return conn_list_get(game.all_connections, ind);
|
||
|
} else {
|
||
| ... | ... | |
|
if (*pconn->username != '\0') {
|
||
|
fc_snprintf(buffer, sizeof(buffer), _("%s from %s"),
|
||
|
pconn->username, pconn->addr);
|
||
|
pconn->username, pconn->addr);
|
||
|
} else {
|
||
|
sz_strlcpy(buffer, "server");
|
||
|
}
|
||
| common/networking/packets.c | ||
|---|---|---|
|
if (!pc->used) {
|
||
|
return NULL; /* connection was closed, stop reading */
|
||
|
}
|
||
|
|
||
|
if (pc->buffer->ndata < data_type_size(pc->packet_header.length)) {
|
||
|
/* Not got enough for a length field yet */
|
||
|
return NULL;
|
||
| ... | ... | |
|
} while (error != Z_OK);
|
||
|
buffer->ndata -= whole_packet_len;
|
||
|
/*
|
||
|
/*
|
||
|
* Remove the packet with the compressed data and shift all the
|
||
|
* remaining data to the front.
|
||
|
* remaining data to the front.
|
||
|
*/
|
||
|
memmove(buffer->data, buffer->data + whole_packet_len, buffer->ndata);
|
||
| ... | ... | |
|
*/
|
||
|
memmove(buffer->data + decompressed_size, buffer->data, buffer->ndata);
|
||
|
/*
|
||
|
/*
|
||
|
* Copy the uncompressed data.
|
||
|
*/
|
||
|
memcpy(buffer->data, decompressed, decompressed_size);
|
||
| ... | ... | |
|
free(decompressed);
|
||
|
buffer->ndata += decompressed_size;
|
||
|
|
||
|
log_compress("COMPRESS: decompressed %ld into %ld",
|
||
|
compressed_size, decompressed_size);
|
||
| ... | ... | |
|
pc->incoming_packet_notify(pc, utype.type, whole_packet_len);
|
||
|
}
|
||
|
#if PACKET_SIZE_STATISTICS
|
||
|
#if PACKET_SIZE_STATISTICS
|
||
|
{
|
||
|
static struct {
|
||
|
int counter;
|
||
| ... | ... | |
|
}
|
||
|
memcpy((char *) (pplayer->attribute_block_buffer.data) + chunk->offset,
|
||
|
chunk->data, chunk->chunk_length);
|
||
|
|
||
|
if (chunk->offset + chunk->chunk_length == chunk->total_length) {
|
||
|
/* Received full attribute block */
|
||
|
if (pplayer->attribute_block.data != NULL) {
|
||
| ... | ... | |
|
}
|
||
|
pplayer->attribute_block.data = pplayer->attribute_block_buffer.data;
|
||
|
pplayer->attribute_block.length = pplayer->attribute_block_buffer.length;
|
||
|
|
||
|
pplayer->attribute_block_buffer.data = NULL;
|
||
|
pplayer->attribute_block_buffer.length = 0;
|
||
|
}
|
||
| common/networking/packets.def | ||
|---|---|---|
|
Typedef lines:
|
||
|
==============
|
||
|
|
||
|
Start with "type" and have the format "type <alias> = <src>". You
|
||
|
can now use <alias> at every place a type is expected. Nested type
|
||
|
defs are possible.
|
||
| ... | ... | |
|
A packet definition starts with a header line, contains variable
|
||
|
field declarations, and ends with a single line containing the word
|
||
|
"end".
|
||
|
|
||
|
PACKET_<PACKET_NAME>=<packet num>; [<packet flags>]
|
||
|
<type1> <field1>; [<field flags>]
|
||
|
<type2> <field2>; [<field flags>]
|
||
| ... | ... | |
|
PACKET_PROCESSING_FINISHED, PACKET_SERVER_JOIN_REQ and
|
||
|
PACKET_SERVER_JOIN_REPLY are excluded here. These packets should
|
||
|
never change their number. The packet number can be freely chosen
|
||
|
as long as it is below 65536 and unique. For backward compatibility
|
||
|
as long as it is below 65536 and unique. For backward compatibility
|
||
|
reasons, packets used for the initial protocol (notably before
|
||
|
checking the capabilities) must be in range 0-255.
|
||
| ... | ... | |
|
as a parameter, it takes the fields of the packet as parameters.
|
||
|
lsend: request the creation of a lsend_packet_* function. This
|
||
|
function sends to list of connections instead of just one
|
||
|
function sends to list of connections instead of just one
|
||
|
connection, which is the case for the other send functions.
|
||
|
cs: a packet which is sent from the client to the server
|
||
| ... | ... | |
|
PLACE_TYPE type;
|
||
|
# Meaning of num:
|
||
|
# - if type == SSHIP_ACT_PLACE_STRUCTURAL:
|
||
|
# - if type == SSHIP_ACT_PLACE_STRUCTURAL:
|
||
|
# index to sship->structure[]
|
||
|
# - if type != SSHIP_ACT_PLACE_STRUCTURAL:
|
||
|
# new value for sship->fuel etc; should be just one more than
|
||
| ... | ... | |
|
BOOL is_playable;
|
||
|
BARBARIAN_TYPE barbarian_type;
|
||
|
|
||
|
UINT8 nsets;
|
||
|
UINT8 sets[MAX_NUM_NATION_SETS:nsets];
|
||
| ... | ... | |
|
end
|
||
|
PACKET_RULESET_CITY = 149; sc, lsend
|
||
|
UINT8 style_id;
|
||
|
UINT8 style_id;
|
||
|
STRING name[MAX_LEN_NAME];
|
||
|
STRING rule_name[MAX_LEN_NAME];
|
||
|
STRING citizens_graphic[MAX_LEN_NAME];
|
||
| ... | ... | |
|
end
|
||
|
PACKET_RULESET_MUSIC = 240; sc, lsend
|
||
|
UINT8 id;
|
||
|
UINT8 id;
|
||
|
STRING music_peaceful[MAX_LEN_NAME];
|
||
|
STRING music_combat[MAX_LEN_NAME];
|
||
|
UINT8 reqs_count;
|
||
| ... | ... | |
|
/*********************************************************
|
||
|
Below are the packets that control single-player mode.
|
||
|
Below are the packets that control single-player mode.
|
||
|
*********************************************************/
|
||
|
PACKET_SINGLE_WANT_HACK_REQ = 160; cs, handle-per-conn
|
||
|
STRING token[MAX_LEN_NAME];
|
||
| ... | ... | |
|
end
|
||
|
PACKET_EDIT_PLAYER = 216; cs, handle-per-conn, lsend
|
||
|
PLAYER id; key
|
||
|
PLAYER id; key
|
||
|
STRING name[MAX_LEN_NAME];
|
||
|
STRING username[MAX_LEN_NAME];
|
||
|
STRING ranked_username[MAX_LEN_NAME];
|
||