client.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* $Id: client.h,v 1.43 2001/04/29 22:24:37 kilobug Exp $ */
  2. #ifndef __PROLO_CLIENT_H__
  3. #define __PROLO_CLIENT_H__
  4. #define MINI_MAP_SIZE 200
  5. #define MAP_SIZE 500
  6. #define WANT_PROTOCOL_VERSION 1
  7. #define DIVID_PULSE_MINI 1/* 6 */
  8. #define PULSE_SAT 0xFF/*7F*/
  9. #define SPRITE_COLOR_DIV 4
  10. #include "../netlib/net.h"
  11. #include "../general.h"
  12. #include "../gtkutil/gtkutil.h"
  13. typedef enum _obj_type_t { obj_r4d2 = 0, obj_akx = 1 } obj_type_t;
  14. typedef enum _obj_act_t { act_akx_move = 0, act_akx_pulse = 1,
  15. act_akx_link = 2 } obj_act_t;
  16. #define SQR(X) ((X) * (X))
  17. typedef struct _image_t
  18. {
  19. int sx;
  20. int sy;
  21. guchar *data;/* en 32bits R8 G8 B8 A8*/
  22. char *name;
  23. } image_t;
  24. typedef struct _player_t
  25. {
  26. int id;
  27. char *name;
  28. float score;
  29. guchar colors[3];
  30. image_t *r4d2;
  31. image_t *akx;
  32. GdkColor *gdkcol;
  33. } player_t;
  34. typedef struct _obj_t
  35. {
  36. int id;
  37. obj_type_t type;
  38. float posx, posy;
  39. int team_id;
  40. gboolean changed;
  41. obj_act_t action;
  42. int target;
  43. float tx, ty;
  44. float angle;
  45. } obj_t;
  46. typedef struct _map_t
  47. {
  48. int nb_players;
  49. int nb_turns, turn_num;
  50. int nb_objects, nb_akx, nb_r4d2;
  51. float sizex, sizey;
  52. player_t **players;
  53. obj_t **objects;
  54. char *sand_file;
  55. image_t *background;
  56. } map_t;
  57. typedef struct _turn_t
  58. {
  59. int nbt;
  60. int spd;
  61. int gtkto;
  62. int st_turns;
  63. enum { tt_pause, tt_skip, tt_fwd } mode;
  64. } turn_t;
  65. typedef struct _stat_t
  66. {
  67. GtkWidget *pl, *stat, *r4d2, *akx, *menu;
  68. gboolean on;
  69. } stat_t;
  70. typedef struct _conf_t
  71. {
  72. int socket;
  73. FILE *file;
  74. gboolean debug;
  75. const char *host;
  76. int port;
  77. GtkWidget *status, *window, *conf;
  78. GtkWidget *main, *mini, *pl, *turn_bar;
  79. GtkTooltips *tooltips;
  80. map_t *map;
  81. int gdk_io_id;
  82. gboolean ready, connected, terminated;
  83. turn_t turn;
  84. stat_t stat;
  85. int big_ofs_x, big_ofs_y;
  86. int mini_center_x, mini_center_y;
  87. float big_zoom, log_big_zoom;
  88. gboolean big_radar;
  89. gboolean big_pulse;
  90. guchar *screen;
  91. guchar *convtb;
  92. image_t *r4d2;
  93. image_t *akx;
  94. image_t *background;
  95. } conf_t;
  96. extern conf_t *gl_config;
  97. /*
  98. ** Init
  99. */
  100. conf_t *init(int argc, char **argv);
  101. void create_gtk_stuff(conf_t *conf);
  102. void byebye(GtkWidget *widget, conf_t *conf);
  103. void network_error(net_type_t get, net_type_t wanted, void *data);
  104. void do_connect(conf_t *conf);
  105. gint idle_connect(void *conf); /* Always returns FALSE for gtk_idle */
  106. void callback_connect(GtkWidget *widget, void *conf);
  107. void send_goodbye(conf_t *conf);
  108. void load_map(conf_t *conf);
  109. void destroy_map(conf_t *conf);
  110. void get_object_param(int fd, obj_t *obj, conf_t *conf);
  111. void allow_new_turn(conf_t *conf);
  112. void close_socket(conf_t *conf);
  113. void protocol_error(conf_t *conf, const char *msg);
  114. gboolean tb_new_turn(void *conf);
  115. guchar *gen_minimap(const conf_t *conf, gboolean force);
  116. guchar *gen_bigmap(conf_t *conf, gboolean force);
  117. guchar *gen_bigmap2(conf_t *conf, gboolean force);
  118. void gen_colors(int id, int nbr, player_t *play);
  119. void scroll_bigmap(conf_t *conf, float x, float y);
  120. image_t *load_picture(const char *filename, const char *mask);
  121. void destroy_picture(image_t *pic);
  122. image_t *tint_picture(const image_t *src, guchar *col);
  123. image_t *dup_picture(const image_t *src);
  124. int fast_sqrt(unsigned int a);
  125. #include "client_gtk.h"
  126. #endif