File: barriers.h

package info (click to toggle)
scummvm 2.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 450,580 kB
  • sloc: cpp: 4,299,825; asm: 28,322; python: 12,901; sh: 11,302; java: 9,289; xml: 7,895; perl: 2,639; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (150 lines) | stat: -rw-r--r-- 4,974 bytes parent folder | download | duplicates (3)
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
145
146
147
148
149
150
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * Additional copyright for this file:
 * Copyright (C) 1999-2000 Revolution Software Ltd.
 * This code is based on source code created by Revolution Software,
 * used with permission.
 *
 * 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 3 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, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef ICB_BARRIERS_H
#define ICB_BARRIERS_H

#include "engines/icb/common/px_rcutypes.h"
#include "engines/icb/common/px_linkeddatafile.h"
#include "engines/icb/common/px_route_barriers.h"

namespace ICB {

#define MAX_slices 10

//+1 for dummy top floor ceiling
#define MAX_heights (MAX_slices + 1)

#define MAX_floors 48

// this is the master number of objects -
// The +3 & ~3 - means it is rounded up to be a multiple of 4
#define MAX_props ((116 + 3) & ~3)

#define MAX_parents_per_anim_slice 24
//#define   MAX_bars_per_parent 96
#define MAX_props_per_parent 16

#define MAX_animating_props 24
#define MAX_bars_per_prop 60

#define MAX_child_groups_per_parent 16

#define MAX_prop_abars (MAX_animating_props * MAX_bars_per_prop)

//--------------------------------------------------------------------------------------
class _animating_parent { // contains all of the abarriers that lie within this parent space - for each we record its associated prop and
	                  // state so we know when each is in scope
public:
	uint8 num_props;
	uint8 prop_number[MAX_props_per_parent];
};

class _animating_barrier_slice { // contains a list of parents that lie within the slice
	                         // and a list of props within the slice
public:
	_animating_parent *anim_parents[MAX_parents_per_anim_slice];

	uint8 num_props_in_slice;
	uint8 prop_list[MAX_props];
};

class _anim_prop_info { // contains a list of all the abars for the prop
public:
	uint8 barriers_per_state;
	uint8 total_states;   // temp - could be removed
	uint16 *barrier_list; // pointer into 'prop_abar_table'
};

class _barrier_handler {

public:
	void ___init();

	void Form_route_barrier_list(PXreal x, PXreal y, PXreal z, PXreal x2, PXreal z2);
	void Form_parent_barrier_list(PXreal x, PXreal y, PXreal z);

	ParentBox *Fetch_parent_box_for_xyz(PXreal x, PXreal y, PXreal z, uint32 &par_num, uint32 &slice_num);
	ParentBox *Fetch_parent_num_on_slice_y(uint32 requested_parent, PXreal y);
	uint32 Fetch_number_of_child_boxes(ParentBox *parent);
	ChildGroup *Fetch_child_box(ParentBox *parent, uint32 child);
	RouteBarrier *Fetch_barrier(uint32 num);
	uint32 Fetch_total_barriers();
	LinkedDataFile *Get_barrier_pointer() const { return raw_barriers; }
	void Prepare_animating_barriers();
	uint32 Get_anim_barriers(uint32 n, uint32 *oThisCubesBarriers, uint32 slice);

	void Set_route_barrier_mask(int32 left, int32 right, int32 top, int32 bottom);
	void Clear_route_barrier_mask();

	_animating_barrier_slice anim_slices[MAX_slices];

	_anim_prop_info anim_prop_info[MAX_props];

	uint16 prop_abar_table[MAX_animating_props * MAX_bars_per_prop];

	uint8 parents_used;                              // count how many of table are used
	_animating_parent anim_parent_table[MAX_floors]; // storage

	// raw barriers
	LinkedDataFile *raw_barriers; // raw route barriers used for routing/line of sight and maybe shadow geometry

	uint32 total_barriers;

	// route barrier wrapper file
	LinkedDataFile *route_wrapper;

	uint32 total_slices; // useful out of file

	bool8 barrier_mask;
	DXrect mask;
};

inline void _barrier_handler::Set_route_barrier_mask(int32 left, int32 right, int32 top, int32 bottom) {
	// certain route building will provide an inner rect that barriers must lie within
	barrier_mask = TRUE8;

	mask.left = left;
	mask.right = right;
	mask.top = top;
	mask.bottom = bottom;
}

inline void _barrier_handler::Clear_route_barrier_mask() {
	// cancel inner route barrier mask

	barrier_mask = FALSE8;
}

inline uint32 _barrier_handler::Fetch_number_of_child_boxes(ParentBox *parent) { return (parent->num_childgroups); }

inline ChildGroup *_barrier_handler::Fetch_child_box(ParentBox *parent, uint32 child) { return ((ChildGroup *)(((uint8 *)parent) + parent->childgroups[child])); }

inline uint32 _barrier_handler::Fetch_total_barriers() { return (total_barriers); }

} // End of namespace ICB

#endif