File: attribute.h

package info (click to toggle)
freeciv 3.2.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 286,492 kB
  • sloc: ansic: 484,452; cpp: 37,766; sh: 10,374; makefile: 7,425; python: 2,938; xml: 652; sed: 11
file content (103 lines) | stat: -rw-r--r-- 3,250 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/***********************************************************************
 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
***********************************************************************/
#ifndef FC__ATTRIBUTE_H
#define FC__ATTRIBUTE_H

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include <stddef.h>             /* size_t */

/*
 * If 4 byte wide signed int is used this gives 20 object types with
 * 100 million keys each.
 */
enum attr_object_type_start_keys {
  ATTR_UNIT_START = 0 * 100 * 1000 * 1000,
  ATTR_CITY_START = 1 * 100 * 1000 * 1000,
  ATTR_PLAYER_START = 2 * 100 * 1000 * 1000,
  ATTR_TILE_START = 3 * 100 * 1000 * 1000
};

enum attr_unit {
  ATTR_UNIT_DUMMY = ATTR_UNIT_START
};

enum attr_city {
  ATTR_CITY_CMA_PARAMETER = ATTR_CITY_START,
  ATTR_CITY_CMAFE_PARAMETER
};

enum attr_player {
    ATTR_PLAYER_DUMMY = ATTR_PLAYER_START
};

enum attr_tile {
    ATTR_TILE_DUMMY = ATTR_TILE_START
};

/*
 * Generic methods.
 */
void attribute_init(void);
void attribute_free(void);
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);

/*
 * Special methods for units.
 */
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);


/*
 * Special methods for cities.
 */
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);

/*
 * Special methods for players.
 */
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);

/*
 * Special methods for tiles.
 */
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);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* FC__ATTRIBUTE_H */