summaryrefslogtreecommitdiff
path: root/src/uqm/supermelee/melee.h
blob: e6026a39f2c7e4edb6f785e2132885f74fc4e1c0 (plain)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//Copyright Paul Reiche, Fred Ford. 1992-2002

/*
 *  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 of the License, 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.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef UQM_SUPERMELEE_MELEE_H_
#define UQM_SUPERMELEE_MELEE_H_

#include "../init.h"
#include "libs/gfxlib.h"
#include "libs/mathlib.h"
#include "libs/sndlib.h"
#include "libs/timelib.h"
#include "libs/reslib.h"
#include "netplay/packet.h"
		// for NetplayAbortReason and NetplayResetReason.

#if defined(__cplusplus)
extern "C" {
#endif

typedef struct melee_state MELEE_STATE;

#define NUM_MELEE_ROWS 2
#define NUM_MELEE_COLUMNS 7
//#define NUM_MELEE_COLUMNS 6
#define MELEE_FLEET_SIZE (NUM_MELEE_ROWS * NUM_MELEE_COLUMNS)
#define ICON_WIDTH 16
#define ICON_HEIGHT 16

extern FRAME PickMeleeFrame;

#define PICK_BG_COLOR    BUILD_COLOR (MAKE_RGB15 (0x00, 0x01, 0x0F), 0x01)
#define PICK_VALUE_COLOR BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C)
		// Used for the current fleet value in the next ship selection
		// in SuperMelee.

#define MAX_TEAM_CHARS 30
#define NUM_PICK_COLS 5
#define NUM_PICK_ROWS 5

typedef BYTE MELEE_OPTIONS;

#if defined(__cplusplus)
}
#endif

#include "loadmele.h"
#include "meleesetup.h"
#include "meleeship.h"

#if defined(__cplusplus)
extern "C" {
#endif

struct melee_state
{
	BOOLEAN (*InputFunc) (struct melee_state *pInputState);

	BOOLEAN Initialized;
	BOOLEAN meleeStarted;
	MELEE_OPTIONS MeleeOption;
	COUNT side;
	COUNT row;
	COUNT col;
	MeleeSetup *meleeSetup;
	struct melee_load_state load;
	MeleeShip currentShip;
			// The ship currently displayed. Not really needed.
			// Also the current ship position when selecting a ship.
	COUNT CurIndex;
#define MELEE_STATE_INDEX_DONE ((COUNT) -1)
			// Current position in the team string when editing it.
			// Set to MELEE_STATE_INDEX_DONE when done.
	BOOLEAN buildPickConfirmed;
			// Used by DoPickShip () to communicate to the calling
			// function BuildPickShip() whether a ship has been selected
			// to add to the fleet, or whether the operation has been
			// cancelled. If a ship was selected, it is set in
			// currentShip.
	RandomContext *randomContext;
			/* RNG state for all local random decisions, i.e. those
			 * decisions that are not shared among network parties. */
	TimeCount LastInputTime;

	MUSIC_REF hMusic;
};

extern void Melee (void);

// Some prototypes for use by loadmele.c:
BOOLEAN DoMelee (MELEE_STATE *pMS);
void DrawMeleeIcon (COUNT which_icon);
void GetShipBox (RECT *pRect, COUNT side, COUNT row, COUNT col);
void RepairMeleeFrame (const RECT *pRect);
void DrawMeleeShipStrings (MELEE_STATE *pMS, MeleeShip NewStarShip);
extern FRAME MeleeFrame;
void Melee_flashSelection (MELEE_STATE *pMS);

COUNT GetShipValue (MeleeShip StarShip);

void updateRandomSeed (MELEE_STATE *pMS, COUNT side, DWORD seed);
void confirmationCancelled(MELEE_STATE *pMS, COUNT side);
void connectedFeedback (NetConnection *conn);
void abortFeedback (NetConnection *conn, NetplayAbortReason reason);
void resetFeedback (NetConnection *conn, NetplayResetReason reason,
		bool byRemote);
void errorFeedback (NetConnection *conn);
void closeFeedback (NetConnection *conn);

bool Melee_LocalChange_ship (MELEE_STATE *pMS, COUNT side,
		FleetShipIndex index, MeleeShip ship);
bool Melee_LocalChange_teamName (MELEE_STATE *pMS, COUNT side,
		const char *name);
bool Melee_LocalChange_fleet (MELEE_STATE *pMS, size_t teamNr,
		const MeleeShip *fleet);
bool Melee_LocalChange_team (MELEE_STATE *pMS, size_t teamNr,
		const MeleeTeam *team);

void Melee_bootstrapSyncTeam (MELEE_STATE *pMS, size_t teamNr);

void Melee_RemoteChange_ship (MELEE_STATE *pMS, NetConnection *conn,
		COUNT side, FleetShipIndex index, MeleeShip ship);
void Melee_RemoteChange_teamName (MELEE_STATE *pMS, NetConnection *conn,
		COUNT side, const char *name);

#if defined(__cplusplus)
}
#endif

#endif /* UQM_MELEE_H_ */