Freeciv-3.1
|
#include "dataio.h"
#include "fcintl.h"
#include "genhash.h"
#include "log.h"
#include "mem.h"
#include "packets.h"
#include "client_main.h"
#include "attribute.h"
#include "spechash.h"
Go to the source code of this file.
Data Structures | |
struct | attr_key |
Macros | |
#define | log_attribute log_debug |
#define | SPECHASH_TAG attribute |
#define | SPECHASH_IKEY_TYPE struct attr_key * |
#define | SPECHASH_IDATA_TYPE void * |
#define | SPECHASH_IKEY_VAL attr_key_val |
#define | SPECHASH_IKEY_COMP attr_key_comp |
#define | SPECHASH_IKEY_COPY attr_key_dup |
#define | SPECHASH_IKEY_FREE attr_key_destroy |
#define | SPECHASH_IDATA_FREE free |
#define | attribute_hash_values_iterate(hash, pvalue) TYPED_HASH_DATA_ITERATE(void *, hash, pvalue) |
#define | attribute_hash_values_iterate_end HASH_DATA_ITERATE_END |
#define | attribute_hash_iterate(hash, pkey, pvalue) TYPED_HASH_ITERATE(const struct attr_key *, void *, hash, pkey, pvalue) |
#define | attribute_hash_iterate_end HASH_ITERATE_END |
Enumerations | |
enum | attribute_serial { A_SERIAL_FAIL , A_SERIAL_OK , A_SERIAL_OLD } |
Functions | |
static genhash_val_t | attr_key_val (const struct attr_key *pkey) |
static bool | attr_key_comp (const struct attr_key *pkey1, const struct attr_key *pkey2) |
static struct attr_key * | attr_key_dup (const struct attr_key *pkey) |
static void | attr_key_destroy (struct attr_key *pkey) |
void | attribute_init (void) |
void | attribute_free (void) |
static enum attribute_serial | serialize_hash (const struct attribute_hash *hash, void **pdata, int *pdata_length) |
static enum attribute_serial | unserialize_hash (struct attribute_hash *hash, const void *data, size_t data_length) |
void | attribute_flush (void) |
void | attribute_restore (void) |
void | attribute_set (int key, int id, int x, int y, size_t data_length, const void *const data) |
size_t | attribute_get (int key, int id, int x, int y, size_t max_data_length, void *data) |
void | attr_unit_set (enum attr_unit what, int unit_id, size_t data_length, const void *const data) |
size_t | attr_unit_get (enum attr_unit what, int unit_id, size_t max_data_length, void *data) |
void | attr_unit_set_int (enum attr_unit what, int unit_id, int data) |
size_t | attr_unit_get_int (enum attr_unit what, int unit_id, int *data) |
void | attr_city_set (enum attr_city what, int city_id, size_t data_length, const void *const data) |
size_t | attr_city_get (enum attr_city what, int city_id, size_t max_data_length, void *data) |
void | attr_city_set_int (enum attr_city what, int city_id, int data) |
size_t | attr_city_get_int (enum attr_city what, int city_id, int *data) |
void | attr_player_set (enum attr_player what, int player_id, size_t data_length, const void *const data) |
size_t | attr_player_get (enum attr_player what, int player_id, size_t max_data_length, void *data) |
void | attr_tile_set (enum attr_tile what, int x, int y, size_t data_length, const void *const data) |
size_t | attr_tile_get (enum attr_tile what, int x, int y, size_t max_data_length, void *data) |
Variables | |
static struct attribute_hash * | attribute_hash = NULL |
#define attribute_hash_iterate | ( | hash, | |
pkey, | |||
pvalue | |||
) | TYPED_HASH_ITERATE(const struct attr_key *, void *, hash, pkey, pvalue) |
Definition at line 64 of file attribute.c.
#define attribute_hash_iterate_end HASH_ITERATE_END |
Definition at line 66 of file attribute.c.
#define attribute_hash_values_iterate | ( | hash, | |
pvalue | |||
) | TYPED_HASH_DATA_ITERATE(void *, hash, pvalue) |
Definition at line 61 of file attribute.c.
#define attribute_hash_values_iterate_end HASH_DATA_ITERATE_END |
Definition at line 63 of file attribute.c.
#define log_attribute log_debug |
Definition at line 33 of file attribute.c.
#define SPECHASH_IDATA_FREE free |
Definition at line 59 of file attribute.c.
#define SPECHASH_IDATA_TYPE void * |
Definition at line 54 of file attribute.c.
#define SPECHASH_IKEY_COMP attr_key_comp |
Definition at line 56 of file attribute.c.
#define SPECHASH_IKEY_COPY attr_key_dup |
Definition at line 57 of file attribute.c.
#define SPECHASH_IKEY_FREE attr_key_destroy |
Definition at line 58 of file attribute.c.
#define SPECHASH_IKEY_TYPE struct attr_key * |
Definition at line 53 of file attribute.c.
#define SPECHASH_IKEY_VAL attr_key_val |
Definition at line 55 of file attribute.c.
#define SPECHASH_TAG attribute |
Definition at line 52 of file attribute.c.
enum attribute_serial |
Enumerator | |
---|---|
A_SERIAL_FAIL | |
A_SERIAL_OK | |
A_SERIAL_OLD |
Definition at line 35 of file attribute.c.
size_t attr_city_get | ( | enum attr_city | what, |
int | city_id, | ||
size_t | max_data_length, | ||
void * | data | ||
) |
Get city related attribute
Definition at line 491 of file attribute.c.
Referenced by attr_city_get_int(), and cma_get_parameter().
size_t attr_city_get_int | ( | enum attr_city | what, |
int | city_id, | ||
int * | data | ||
) |
Get city related integer attribute
Definition at line 508 of file attribute.c.
void attr_city_set | ( | enum attr_city | what, |
int | city_id, | ||
size_t | data_length, | ||
const void *const | data | ||
) |
Set city related attribute
Definition at line 482 of file attribute.c.
Referenced by attr_city_set_int(), city_remove(), cma_set_parameter(), and release_city().
void attr_city_set_int | ( | enum attr_city | what, |
int | city_id, | ||
int | data | ||
) |
Set city related integer attribute
Definition at line 500 of file attribute.c.
Compare-function for the keys in the hash table.
Definition at line 82 of file attribute.c.
|
static |
Free an attribute key.
Definition at line 105 of file attribute.c.
Duplicate an attribute key.
Definition at line 94 of file attribute.c.
|
static |
Hash function for attribute_hash.
Definition at line 74 of file attribute.c.
size_t attr_player_get | ( | enum attr_player | what, |
int | player_id, | ||
size_t | max_data_length, | ||
void * | data | ||
) |
Get player related attribute
Definition at line 525 of file attribute.c.
void attr_player_set | ( | enum attr_player | what, |
int | player_id, | ||
size_t | data_length, | ||
const void *const | data | ||
) |
Set player related attribute
Definition at line 516 of file attribute.c.
size_t attr_tile_get | ( | enum attr_tile | what, |
int | x, | ||
int | y, | ||
size_t | max_data_length, | ||
void * | data | ||
) |
Get tile related attribute
Definition at line 543 of file attribute.c.
void attr_tile_set | ( | enum attr_tile | what, |
int | x, | ||
int | y, | ||
size_t | data_length, | ||
const void *const | data | ||
) |
Set tile related attribute
Definition at line 534 of file attribute.c.
size_t attr_unit_get | ( | enum attr_unit | what, |
int | unit_id, | ||
size_t | max_data_length, | ||
void * | data | ||
) |
Get unit related attribute
Definition at line 457 of file attribute.c.
Referenced by attr_unit_get_int().
size_t attr_unit_get_int | ( | enum attr_unit | what, |
int | unit_id, | ||
int * | data | ||
) |
Get unit related integer attribute
Definition at line 474 of file attribute.c.
void attr_unit_set | ( | enum attr_unit | what, |
int | unit_id, | ||
size_t | data_length, | ||
const void *const | data | ||
) |
Set unit related attribute
Definition at line 448 of file attribute.c.
Referenced by attr_unit_set_int().
void attr_unit_set_int | ( | enum attr_unit | what, |
int | unit_id, | ||
int | data | ||
) |
Set unit related integer attribute
Definition at line 466 of file attribute.c.
void attribute_flush | ( | void | ) |
Send current state to the server. Note that the current implementation will send all attributes to the server.
Definition at line 327 of file attribute.c.
Referenced by client_exit(), disconnect_from_server(), send_save_game(), and send_turn_done().
void attribute_free | ( | void | ) |
Frees the attribute module.
Definition at line 123 of file attribute.c.
Referenced by client_game_free(), and client_game_reset().
size_t attribute_get | ( | int | key, |
int | id, | ||
int | x, | ||
int | y, | ||
size_t | max_data_length, | ||
void * | data | ||
) |
Low-level function to get an attribute. If data hasn't enough space to hold the attribute data isn't set to the attribute. Returns the actual size of the attribute. Can be zero if the attribute is unset. To get the size of an attribute use size = attribute_get(key, id, x, y, 0, NULL)
Definition at line 415 of file attribute.c.
Referenced by attr_city_get(), attr_player_get(), attr_tile_get(), and attr_unit_get().
void attribute_init | ( | void | ) |
Initializes the attribute module.
Definition at line 114 of file attribute.c.
Referenced by client_game_init(), and client_game_reset().
void attribute_restore | ( | void | ) |
Recreate the attribute set from the player's attribute_block. Shouldn't be used by normal code.
Definition at line 354 of file attribute.c.
Referenced by handle_player_attribute_chunk().
void attribute_set | ( | int | key, |
int | id, | ||
int | x, | ||
int | y, | ||
size_t | data_length, | ||
const void *const | data | ||
) |
Low-level function to set an attribute. If data_length is zero the attribute is removed.
Definition at line 383 of file attribute.c.
Referenced by attr_city_set(), attr_player_set(), attr_tile_set(), and attr_unit_set().
|
static |
Serialize an attribute hash for network/storage.
Definition at line 134 of file attribute.c.
Referenced by attribute_flush().
|
static |
This data was serialized (above), sent as an opaque data packet to the server, stored in a savegame, retrieved from the savegame, sent as an opaque data packet back to the client, and now is ready to be restored. Check everything!
Definition at line 230 of file attribute.c.
Referenced by attribute_restore().
|
static |
Definition at line 69 of file attribute.c.
Referenced by attribute_flush(), attribute_free(), attribute_get(), attribute_init(), attribute_restore(), and attribute_set().