libspades
Ace of Spades library
libspades.h
1#ifndef LIBSPADES_CLIENT_LIBSPADES_H
2#define LIBSPADES_CLIENT_LIBSPADES_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include "../commit.h"
8#include "../config.h"
9
10#include "../common/colors.h"
11#include "../common/cp437.h"
12#include "../common/protocol.h"
13#include "../common/serverlist.h"
14#include "gamestate.h"
15
19
20struct Vectorf {
21 float x;
22 float y;
23 float z;
24};
25
26struct Vector32 {
27 uint32_t x;
28 uint32_t y;
29 uint32_t z;
30};
31
33 uint8_t x;
34 uint8_t y;
35 uint8_t z;
36};
37
39 int8_t x;
40 int8_t y;
41 int8_t z;
42};
43
44enum LibspadesConnectReturn {
45 LibspadesConnectReturnSuccess = 0,
46 LibspadesConnectReturnHostError = -1,
47 LibspadesConnectReturnPeerError = -2,
50 LibspadesConnectReturnTimedOut = -3,
53 LibspadesConnectReturnKicked = -4,
55 LibspadesConnectReturnCompressorError = -5
56};
57
58enum LibspadesSendPacketReturn {
59 LibspadesSendPacketReturnSuccess = 0,
60 LibspadesSendPacketReturnPacketCreateError = -1,
61 LibspadesSendPacketReturnSendError = -2
62};
63
64char *libspades_chat_to_csUTF8(const struct PacketChatMessage *packet, const size_t length);
65extern void libspades_reload_weapon(struct GameState *gameState);
66/* DEPRECATED: use shortplayerdata or change weapon and change team */
67/* void libspades_change_weapon_and_team(int8_t team, enum WeaponType weapon,
68 * struct GameState* gameState); */
69extern void libspades_change_team(int8_t team, struct GameState *gameState);
70extern void libspades_change_weapon(enum WeaponType weapon, struct GameState *gameState);
71extern void libspades_change_tool(enum ItemType tool, struct GameState *gameState);
72
73/* int libspades_init(struct GameState* gameState); */ /* TODO: make the
74 * gamestate maker and
75 * replace this with
76 * that.
77 */
78extern enum LibspadesConnectReturn libspades_connect(ENetAddress address,
79 enum ProtocolVersion protocolVersion,
80 struct GameState *gameState);
81extern void libspades_disconnect(struct GameState *gameState);
82int libspades_parse_aos_identifier(const char *identifier,
83 ENetAddress *address,
84 enum ProtocolVersion *protocolVersion);
85extern int libspades_parse_protocol_string(const char *protocolString, enum ProtocolVersion *protocolVersion);
88extern enum LibspadesSendPacketReturn libspades_send_packet(void *data, size_t length, struct GameState *gameState);
89int libspades_join_game(const char *name, uint8_t team, enum WeaponType weapon, struct GameState *gameState);
90void libspades_send_chat(const char *data, enum ChatType type, struct GameState *gameState);
91void libspades_restock(struct GameState *gameState);
92void libspades_point_at_position(struct Vectorf position, struct GameState *gameState);
93void libspades_block_line(struct Vector32 start, struct Vector32 end, uint8_t playerID, struct GameState *gameState);
94void libspades_set_block_color(uint8_t b, uint8_t g, uint8_t r, struct GameState *gameState);
95int libspades_host_service(enet_uint32 maximumDelayTimeMilliseconds,
96 ENetEvent *returnEvent,
97 struct GameState *gameState);
98void libspades_wait_map_download_complete(struct GameState *gameState);
99
100#ifdef __cplusplus
101}
102#endif
103#endif
The main data structure for libspades clients.
Definition gamestate.h:33
Sends a message in chat.
Definition protocol.h:524
Definition libspades.h:26
Definition libspades.h:32
Definition libspades.h:38
Definition libspades.h:20