Debian Codegraph @

src/cdogs/defs.h

raw symbols SCIP
1 /*
2 C-Dogs SDL
3 A port of the legendary (and fun) action/arcade cdogs.
4 Copyright (C) 1995 Ronny Wester
5 Copyright (C) 2003 Jeremy Chin
6 Copyright (C) 2003-2007 Lucas Martin-King
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 This file incorporates work covered by the following copyright and
23 permission notice:
24
25 Copyright (c) 2014-2015, 2017-2018, 2021 Cong Xu
26 All rights reserved.
27
28 Redistribution and use in source and binary forms, with or without
29 modification, are permitted provided that the following conditions are met:
30
31 Redistributions of source code must retain the above copyright notice, this
32 list of conditions and the following disclaimer.
33 Redistributions in binary form must reproduce the above copyright notice,
34 this list of conditions and the following disclaimer in the documentation
35 and/or other materials provided with the distribution.
36
37 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
41 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
43 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
44 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
45 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
47 POSSIBILITY OF SUCH DAMAGE.
48 */
49 #pragma once
50
51 #include "vector.h"
52
53 // Defines
54 #define BODY_UNARMED 0
55 #define BODY_ARMED 1
56 #define BODY_COUNT 2
57
58 #define MAX_BARRELS 2
59
60 // Commands
61 #define CMD_LEFT 1
62 #define CMD_RIGHT 2
63 #define CMD_UP 4
64 #define CMD_DOWN 8
65 #define CMD_BUTTON1 16
66 #define CMD_BUTTON2 32
67 #define CMD_MAP 64
68 #define CMD_ESC 128
69 #define CMD_GRENADE 256
70
71 // Command macros
72 #define Left(x) (((x)&CMD_LEFT) != 0)
73 #define Right(x) (((x)&CMD_RIGHT) != 0)
74 #define Up(x) (((x)&CMD_UP) != 0)
75 #define Down(x) (((x)&CMD_DOWN) != 0)
76 #define Button1(x) (((x)&CMD_BUTTON1) != 0)
77 #define Button2(x) (((x)&CMD_BUTTON2) != 0)
78 #define AnyButton(x) (((x) & (CMD_BUTTON1 | CMD_BUTTON2 | CMD_GRENADE)) != 0)
79 #define CMD_DIRECTIONS (CMD_LEFT | CMD_RIGHT | CMD_UP | CMD_DOWN)
80 #define CMD_HAS_DIRECTION(x) ((x)&CMD_DIRECTIONS)
81
82 // Reverse directions for command
83 int CmdGetReverse(int cmd);
84
85 // Directions
86 typedef enum
87 {
88 DIRECTION_UP,
89 DIRECTION_UPRIGHT,
90 DIRECTION_RIGHT,
91 DIRECTION_DOWNRIGHT,
92 DIRECTION_DOWN,
93 DIRECTION_DOWNLEFT,
94 DIRECTION_LEFT,
95 DIRECTION_UPLEFT,
96 DIRECTION_COUNT
97 } direction_e;
98
99 typedef enum
100 {
101 SPECIAL_NONE,
102 SPECIAL_FLAME,
103 SPECIAL_POISON,
104 SPECIAL_PETRIFY,
105 SPECIAL_CONFUSE
106 } special_damage_e;
107 special_damage_e StrSpecialDamage(const char *s);
108
109 #define Z_FACTOR 16 // the number of increments used for Z
110
111 extern int cmd2dir[16];
112 extern int dir2cmd[8];
113 extern float dir2radians[8];
114
115 #define CmdToDirection(c) cmd2dir[(c)&15]
116 #define DirectionToCmd(d) dir2cmd[(d)&7]
117
118 struct vec2 Vec2FromRadiansScaled(const float radians);
119 struct vec2 Vec2FromRadians(const float radians);
120 struct vec2i Vec2iFromDirection(const direction_e d);
121 direction_e RadiansToDirection(const double r);
122 direction_e DirectionOpposite(const direction_e d);
123 direction_e DirectionMirrorX(const direction_e d);
124 direction_e DirectionRotate(const direction_e d, const int dClockwise);
125
126 // Quarter of a full pos, for movement
127 #define EPSILON_POS (1.0f / 256.0f / 4.0f)