![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <cmath>#include <cstdint>#include <cstring>#include <QtEndian>#include "support.h"#include "events.h"#include "player.h"#include "requirements.h"#include "tech.h"#include "unit.h"#include "worklist.h"#include "cm.h"#include "dataio.h"
Include dependency graph for dataio_raw.cpp:Go to the source code of this file.
Macros | |
| #define | FIELD_RANGE_TEST(_test_, _action_, _format_, ...) |
Functions | |
| static bool | get_conv (char *dst, size_t ndst, const char *src, size_t nsrc) |
| Returns FALSE if the destination isn't large enough or the source was bad. More... | |
| void | dio_set_put_conv_callback (DIO_PUT_CONV_FUN fun) |
| Sets string conversion callback to be used when putting text. More... | |
| void | dio_set_get_conv_callback (DIO_GET_CONV_FUN fun) |
| Sets string conversion callback to use when getting text. More... | |
| bool | dataio_get_conv_callback (char *dst, size_t ndst, const char *src, size_t nsrc) |
| Call the get_conv callback. More... | |
| static bool | enough_space (struct raw_data_out *dout, size_t size) |
| Returns TRUE iff the output has size bytes available. More... | |
| static bool | enough_data (struct data_in *din, size_t size) |
| Returns TRUE iff the input contains size unread bytes. More... | |
| void | dio_output_init (struct raw_data_out *dout, void *destination, size_t dest_size) |
| Initializes the output to the given output buffer and the given buffer size. More... | |
| size_t | dio_output_used (struct raw_data_out *dout) |
| Return the maximum number of bytes used. More... | |
| void | dio_output_rewind (struct raw_data_out *dout) |
| Rewinds the stream so that the put-functions start from the beginning. More... | |
| void | dio_input_init (struct data_in *din, const void *src, size_t src_size) |
| Initializes the input to the given input buffer and the given number of valid input bytes. More... | |
| void | dio_input_rewind (struct data_in *din) |
| Rewinds the stream so that the get-functions start from the beginning. More... | |
| size_t | dio_input_remaining (struct data_in *din) |
| Return the number of unread bytes. More... | |
| size_t | data_type_size (enum data_type type) |
| Return the size of the data_type in bytes. More... | |
| bool | dio_input_skip (struct data_in *din, size_t size) |
| Skips 'n' bytes. More... | |
| void | dio_put_uint8_raw (struct raw_data_out *dout, int value) |
| Insert value using 8 bits. More... | |
| void | dio_put_uint16_raw (struct raw_data_out *dout, int value) |
| Insert value using 16 bits. More... | |
| void | dio_put_uint32_raw (struct raw_data_out *dout, int value) |
| Insert value using 32 bits. More... | |
| void | dio_put_type_raw (struct raw_data_out *dout, enum data_type type, int value) |
| Insert value using 'size' bits. More... | |
| void | dio_put_sint8_raw (struct raw_data_out *dout, int value) |
| Insert value using 8 bits. More... | |
| void | dio_put_sint16_raw (struct raw_data_out *dout, int value) |
| Insert value using 16 bits. More... | |
| void | dio_put_sint32_raw (struct raw_data_out *dout, int value) |
| Insert value using 32 bits. More... | |
| void | dio_put_bool8_raw (struct raw_data_out *dout, bool value) |
| Insert value 0 or 1 using 8 bits. More... | |
| void | dio_put_bool32_raw (struct raw_data_out *dout, bool value) |
| Insert value 0 or 1 using 32 bits. More... | |
| void | dio_put_ufloat_raw (struct raw_data_out *dout, float value, int float_factor) |
| Insert a float number, which is multiplied by 'float_factor' before being encoded into an uint32. More... | |
| void | dio_put_sfloat_raw (struct raw_data_out *dout, float value, int float_factor) |
| Insert a float number, which is multiplied by 'float_factor' before being encoded into a sint32. More... | |
| void | dio_put_memory_raw (struct raw_data_out *dout, const void *value, size_t size) |
| Insert block directly from memory. More... | |
| void | dio_put_string_raw (struct raw_data_out *dout, const char *value) |
| Insert nullptr-terminated string. More... | |
| void | dio_put_cm_parameter_raw (struct raw_data_out *dout, const struct cm_parameter *param) |
| Insert cm_parameter struct. More... | |
| void | dio_put_unit_order_raw (struct raw_data_out *dout, const struct unit_order *order) |
| Insert the given unit_order struct/. More... | |
| void | dio_put_worklist_raw (struct raw_data_out *dout, const struct worklist *pwl) |
| Insert number of worklist items as 8 bit value and then insert 8 bit kind and 8 bit number for each worklist item. More... | |
| bool | dio_get_uint8_raw (struct data_in *din, int *dest) |
| Receive uint8 value to dest. More... | |
| bool | dio_get_uint16_raw (struct data_in *din, int *dest) |
| Receive uint16 value to dest. More... | |
| bool | dio_get_uint32_raw (struct data_in *din, int *dest) |
| Receive uint32 value to dest. More... | |
| bool | dio_get_type_raw (struct data_in *din, enum data_type type, int *dest) |
| Receive value using 'size' bits to dest. More... | |
| bool | dio_get_bool8_raw (struct data_in *din, bool *dest) |
| Take boolean value from 8 bits. More... | |
| bool | dio_get_bool32_raw (struct data_in *din, bool *dest) |
| Take boolean value from 32 bits. More... | |
| bool | dio_get_ufloat_raw (struct data_in *din, float *dest, int float_factor) |
| Get an unsigned float number, which have been multiplied by 'float_factor' and encoded into an uint32 by dio_put_ufloat_raw(). More... | |
| bool | dio_get_sfloat_raw (struct data_in *din, float *dest, int float_factor) |
| Get a signed float number, which have been multiplied by 'float_factor' and encoded into a sint32 by dio_put_sfloat(). More... | |
| bool | dio_get_sint8_raw (struct data_in *din, int *dest) |
| Take value from 8 bits. More... | |
| bool | dio_get_sint16_raw (struct data_in *din, int *dest) |
| Take value from 16 bits. More... | |
| bool | dio_get_sint32_raw (struct data_in *din, int *dest) |
| Take value from 32 bits. More... | |
| bool | dio_get_memory_raw (struct data_in *din, void *dest, size_t dest_size) |
| Take memory block directly. More... | |
| bool | dio_get_string_raw (struct data_in *din, char *dest, size_t max_dest_size) |
| Take string. More... | |
| bool | dio_get_cm_parameter_raw (struct data_in *din, struct cm_parameter *param) |
| Get city manager parameters. More... | |
| bool | dio_get_unit_order_raw (struct data_in *din, struct unit_order *order) |
| Take unit_order struct and put it in the provided orders. More... | |
| bool | dio_get_worklist_raw (struct data_in *din, struct worklist *pwl) |
| Take worklist item count and then kind and number for each item, and put them to provided worklist. More... | |
| bool | dio_get_action_probability_raw (struct data_in *din, struct act_prob *aprob) |
| De-serialize an action probability. More... | |
| void | dio_put_action_probability_raw (struct raw_data_out *dout, const struct act_prob *aprob) |
| Serialize an action probability. More... | |
| bool | dio_get_requirement_raw (struct data_in *din, struct requirement *preq) |
| De-serialize a requirement. More... | |
| void | dio_put_requirement_raw (struct raw_data_out *dout, const struct requirement *preq) |
| Serialize a requirement. More... | |
Variables | |
| static DIO_PUT_CONV_FUN | put_conv_callback = nullptr |
| static DIO_GET_CONV_FUN | get_conv_callback = get_conv |
| #define FIELD_RANGE_TEST | ( | _test_, | |
| _action_, | |||
| _format_, | |||
| ... | |||
| ) |
Definition at line 67 of file dataio_raw.cpp.
| size_t data_type_size | ( | enum data_type | type | ) |
Return the size of the data_type in bytes.
Definition at line 193 of file dataio_raw.cpp.
Referenced by conn_compression_flush(), and get_packet_from_connection_raw().
| bool dataio_get_conv_callback | ( | char * | dst, |
| size_t | ndst, | ||
| const char * | src, | ||
| size_t | nsrc | ||
| ) |
Call the get_conv callback.
Definition at line 112 of file dataio_raw.cpp.
De-serialize an action probability.
Definition at line 861 of file dataio_raw.cpp.
| bool dio_get_bool32_raw | ( | struct data_in * | din, |
| bool * | dest | ||
| ) |
Take boolean value from 32 bits.
Definition at line 601 of file dataio_raw.cpp.
| bool dio_get_bool8_raw | ( | struct data_in * | din, |
| bool * | dest | ||
| ) |
Take boolean value from 8 bits.
Definition at line 581 of file dataio_raw.cpp.
Referenced by dio_get_cm_parameter_raw(), dio_get_requirement_raw(), and cma_yoloswag::get_parameter().
| bool dio_get_cm_parameter_raw | ( | struct data_in * | din, |
| struct cm_parameter * | param | ||
| ) |
Get city manager parameters.
Definition at line 763 of file dataio_raw.cpp.
| bool dio_get_memory_raw | ( | struct data_in * | din, |
| void * | dest, | ||
| size_t | dest_size | ||
| ) |
Take memory block directly.
Definition at line 710 of file dataio_raw.cpp.
Referenced by attribute_get().
| bool dio_get_requirement_raw | ( | struct data_in * | din, |
| struct requirement * | preq | ||
| ) |
De-serialize a requirement.
Definition at line 890 of file dataio_raw.cpp.
| bool dio_get_sfloat_raw | ( | struct data_in * | din, |
| float * | dest, | ||
| int | float_factor | ||
| ) |
Get a signed float number, which have been multiplied by 'float_factor' and encoded into a sint32 by dio_put_sfloat().
Definition at line 638 of file dataio_raw.cpp.
| bool dio_get_sint16_raw | ( | struct data_in * | din, |
| int * | dest | ||
| ) |
Take value from 16 bits.
Definition at line 671 of file dataio_raw.cpp.
Referenced by dio_get_cm_parameter_raw(), dio_get_type_raw(), dio_get_unit_order_raw(), and cma_yoloswag::get_parameter().
| bool dio_get_sint32_raw | ( | struct data_in * | din, |
| int * | dest | ||
| ) |
Take value from 32 bits.
Definition at line 689 of file dataio_raw.cpp.
Referenced by dio_get_requirement_raw(), dio_get_sfloat_raw(), dio_get_type_raw(), and dio_get_unit_order_raw().
| bool dio_get_sint8_raw | ( | struct data_in * | din, |
| int * | dest | ||
| ) |
Take value from 8 bits.
Definition at line 653 of file dataio_raw.cpp.
Referenced by dio_get_type_raw(), and dio_get_unit_order_raw().
| bool dio_get_string_raw | ( | struct data_in * | din, |
| char * | dest, | ||
| size_t | max_dest_size | ||
| ) |
Receive value using 'size' bits to dest.
Definition at line 555 of file dataio_raw.cpp.
Referenced by get_packet_from_connection_raw(), and packet_check().
| bool dio_get_ufloat_raw | ( | struct data_in * | din, |
| float * | dest, | ||
| int | float_factor | ||
| ) |
Get an unsigned float number, which have been multiplied by 'float_factor' and encoded into an uint32 by dio_put_ufloat_raw().
Definition at line 622 of file dataio_raw.cpp.
| bool dio_get_uint16_raw | ( | struct data_in * | din, |
| int * | dest | ||
| ) |
Receive uint16 value to dest.
Definition at line 513 of file dataio_raw.cpp.
Referenced by dio_get_cm_parameter_raw(), dio_get_sint16_raw(), dio_get_type_raw(), and remove_packet_from_buffer().
| bool dio_get_uint32_raw | ( | struct data_in * | din, |
| int * | dest | ||
| ) |
Receive uint32 value to dest.
Definition at line 534 of file dataio_raw.cpp.
Referenced by attribute_get(), dio_get_bool32_raw(), dio_get_sint32_raw(), dio_get_type_raw(), dio_get_ufloat_raw(), and get_packet_from_connection_raw().
| bool dio_get_uint8_raw | ( | struct data_in * | din, |
| int * | dest | ||
| ) |
Receive uint8 value to dest.
Definition at line 492 of file dataio_raw.cpp.
Referenced by dio_get_action_probability_raw(), dio_get_bool8_raw(), dio_get_requirement_raw(), dio_get_sint8_raw(), dio_get_type_raw(), dio_get_unit_order_raw(), dio_get_worklist_raw(), get_lanserver_announcement(), and cma_yoloswag::get_parameter().
| bool dio_get_unit_order_raw | ( | struct data_in * | din, |
| struct unit_order * | order | ||
| ) |
Take unit_order struct and put it in the provided orders.
Definition at line 801 of file dataio_raw.cpp.
Take worklist item count and then kind and number for each item, and put them to provided worklist.
Definition at line 826 of file dataio_raw.cpp.
| void dio_input_init | ( | struct data_in * | din, |
| const void * | src, | ||
| size_t | src_size | ||
| ) |
Initializes the input to the given input buffer and the given number of valid input bytes.
Definition at line 169 of file dataio_raw.cpp.
Referenced by attribute_get(), get_lanserver_announcement(), get_packet_from_connection_raw(), cma_yoloswag::get_parameter(), and remove_packet_from_buffer().
| size_t dio_input_remaining | ( | struct data_in * | din | ) |
Return the number of unread bytes.
Definition at line 185 of file dataio_raw.cpp.
Referenced by dio_get_string_raw(), enough_data(), get_packet_from_connection_raw(), and packet_check().
| void dio_input_rewind | ( | struct data_in * | din | ) |
Rewinds the stream so that the get-functions start from the beginning.
Definition at line 180 of file dataio_raw.cpp.
Referenced by packet_check().
| bool dio_input_skip | ( | struct data_in * | din, |
| size_t | size | ||
| ) |
Skips 'n' bytes.
Definition at line 216 of file dataio_raw.cpp.
| void dio_output_init | ( | struct raw_data_out * | dout, |
| void * | destination, | ||
| size_t | dest_size | ||
| ) |
Initializes the output to the given output buffer and the given buffer size.
Definition at line 144 of file dataio_raw.cpp.
Referenced by attribute_set(), fcUdpScan::begin_scan(), conn_compression_flush(), send_lanserver_response(), server_packet_input(), and cma_yoloswag::set_parameter().
| void dio_output_rewind | ( | struct raw_data_out * | dout | ) |
Rewinds the stream so that the put-functions start from the beginning.
Definition at line 163 of file dataio_raw.cpp.
Referenced by server_packet_input().
| size_t dio_output_used | ( | struct raw_data_out * | dout | ) |
Return the maximum number of bytes used.
Definition at line 157 of file dataio_raw.cpp.
Referenced by fcUdpScan::begin_scan(), send_lanserver_response(), server_packet_input(), and cma_yoloswag::set_parameter().
| void dio_put_action_probability_raw | ( | struct raw_data_out * | dout, |
| const struct act_prob * | aprob | ||
| ) |
Serialize an action probability.
Definition at line 880 of file dataio_raw.cpp.
| void dio_put_bool32_raw | ( | struct raw_data_out * | dout, |
| bool | value | ||
| ) |
Insert value 0 or 1 using 32 bits.
Definition at line 357 of file dataio_raw.cpp.
Referenced by server_packet_input().
| void dio_put_bool8_raw | ( | struct raw_data_out * | dout, |
| bool | value | ||
| ) |
Insert value 0 or 1 using 8 bits.
Definition at line 346 of file dataio_raw.cpp.
Referenced by dio_put_cm_parameter_raw(), dio_put_requirement_raw(), and cma_yoloswag::set_parameter().
| void dio_put_cm_parameter_raw | ( | struct raw_data_out * | dout, |
| const struct cm_parameter * | param | ||
| ) |
Insert cm_parameter struct.
Definition at line 436 of file dataio_raw.cpp.
| void dio_put_memory_raw | ( | struct raw_data_out * | dout, |
| const void * | value, | ||
| size_t | size | ||
| ) |
Insert block directly from memory.
Definition at line 406 of file dataio_raw.cpp.
Referenced by attribute_set(), and dio_put_string_raw().
| void dio_put_requirement_raw | ( | struct raw_data_out * | dout, |
| const struct requirement * | preq | ||
| ) |
Serialize a requirement.
Definition at line 917 of file dataio_raw.cpp.
| void dio_put_sfloat_raw | ( | struct raw_data_out * | dout, |
| float | value, | ||
| int | float_factor | ||
| ) |
Insert a float number, which is multiplied by 'float_factor' before being encoded into a sint32.
Definition at line 388 of file dataio_raw.cpp.
| void dio_put_sint16_raw | ( | struct raw_data_out * | dout, |
| int | value | ||
| ) |
Insert value using 16 bits.
May overflow.
Definition at line 326 of file dataio_raw.cpp.
Referenced by dio_put_cm_parameter_raw(), dio_put_type_raw(), dio_put_unit_order_raw(), and cma_yoloswag::set_parameter().
| void dio_put_sint32_raw | ( | struct raw_data_out * | dout, |
| int | value | ||
| ) |
Insert value using 32 bits.
May overflow.
Definition at line 334 of file dataio_raw.cpp.
Referenced by dio_put_requirement_raw(), dio_put_sfloat_raw(), dio_put_type_raw(), and dio_put_unit_order_raw().
| void dio_put_sint8_raw | ( | struct raw_data_out * | dout, |
| int | value | ||
| ) |
Insert value using 8 bits.
May overflow.
Definition at line 318 of file dataio_raw.cpp.
Referenced by dio_put_type_raw(), and dio_put_unit_order_raw().
| void dio_put_string_raw | ( | struct raw_data_out * | dout, |
| const char * | value | ||
| ) |
Insert nullptr-terminated string.
Conversion callback is used if set.
Definition at line 418 of file dataio_raw.cpp.
Referenced by send_lanserver_response(), and server_packet_input().
| void dio_put_type_raw | ( | struct raw_data_out * | dout, |
| enum data_type | type, | ||
| int | value | ||
| ) |
| void dio_put_ufloat_raw | ( | struct raw_data_out * | dout, |
| float | value, | ||
| int | float_factor | ||
| ) |
Insert a float number, which is multiplied by 'float_factor' before being encoded into an uint32.
Definition at line 369 of file dataio_raw.cpp.
| void dio_put_uint16_raw | ( | struct raw_data_out * | dout, |
| int | value | ||
| ) |
Insert value using 16 bits.
May overflow.
Definition at line 248 of file dataio_raw.cpp.
Referenced by conn_compression_flush(), dio_put_cm_parameter_raw(), dio_put_sint16_raw(), dio_put_type_raw(), and server_packet_input().
| void dio_put_uint32_raw | ( | struct raw_data_out * | dout, |
| int | value | ||
| ) |
Insert value using 32 bits.
May overflow.
Definition at line 267 of file dataio_raw.cpp.
Referenced by attribute_set(), conn_compression_flush(), dio_put_bool32_raw(), dio_put_sint32_raw(), dio_put_type_raw(), and dio_put_ufloat_raw().
| void dio_put_uint8_raw | ( | struct raw_data_out * | dout, |
| int | value | ||
| ) |
Insert value using 8 bits.
May overflow.
Definition at line 229 of file dataio_raw.cpp.
Referenced by fcUdpScan::begin_scan(), dio_put_action_probability_raw(), dio_put_bool8_raw(), dio_put_requirement_raw(), dio_put_sint8_raw(), dio_put_type_raw(), dio_put_unit_order_raw(), dio_put_worklist_raw(), send_lanserver_response(), server_packet_input(), and cma_yoloswag::set_parameter().
| void dio_put_unit_order_raw | ( | struct raw_data_out * | dout, |
| const struct unit_order * | order | ||
| ) |
Insert the given unit_order struct/.
Definition at line 460 of file dataio_raw.cpp.
| void dio_put_worklist_raw | ( | struct raw_data_out * | dout, |
| const struct worklist * | pwl | ||
| ) |
Insert number of worklist items as 8 bit value and then insert 8 bit kind and 8 bit number for each worklist item.
Definition at line 475 of file dataio_raw.cpp.
| void dio_set_get_conv_callback | ( | DIO_GET_CONV_FUN | fun | ) |
Sets string conversion callback to use when getting text.
Definition at line 104 of file dataio_raw.cpp.
Referenced by charsets_init().
| void dio_set_put_conv_callback | ( | DIO_PUT_CONV_FUN | fun | ) |
Sets string conversion callback to be used when putting text.
Definition at line 76 of file dataio_raw.cpp.
Referenced by charsets_init().
|
static |
Returns TRUE iff the input contains size unread bytes.
Definition at line 135 of file dataio_raw.cpp.
Referenced by dio_get_memory_raw(), dio_get_string_raw(), dio_get_uint16_raw(), dio_get_uint32_raw(), dio_get_uint8_raw(), and dio_input_skip().
|
static |
Returns TRUE iff the output has size bytes available.
Definition at line 121 of file dataio_raw.cpp.
Referenced by dio_put_memory_raw(), dio_put_uint16_raw(), dio_put_uint32_raw(), and dio_put_uint8_raw().
|
static |
Returns FALSE if the destination isn't large enough or the source was bad.
This is default get_conv_callback.
Definition at line 85 of file dataio_raw.cpp.
|
static |
Definition at line 48 of file dataio_raw.cpp.
Referenced by dataio_get_conv_callback(), dio_get_string_raw(), and dio_set_get_conv_callback().
|
static |
Definition at line 47 of file dataio_raw.cpp.
Referenced by dio_put_string_raw(), and dio_set_put_conv_callback().