File: global.C

package info (click to toggle)
flying 6.20-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 752 kB
  • ctags: 1,873
  • sloc: cpp: 10,966; makefile: 189
file content (383 lines) | stat: -rw-r--r-- 11,580 bytes parent folder | download | duplicates (4)
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#ifndef _global_h
#	include "global.h"
#endif

//
// Im Modul global.C werden s�mtliche Spielparameter wie Gr��en,
// Kr�fte ... festgehalten, damit sie an einer lokalen Stelle zugreifbar
// sind. Die zugeordneten Werte sind Voreinstellungen, die durch eine
// Konfigurationsdatei (wenn vorhanden) �berschrieben werden k�nnen.
//

#ifndef _real_h
#	include "real.h"
#endif
#ifndef _cannon_h
#	include "cannon.h"
#endif
#ifndef _carrom_h
#	include "carrom.h"
#endif
#ifndef _game_h
#	include "game.h"
#endif
#ifndef _goal_h
#	include "goal.h"
#endif
#ifndef _hockey_h
#	include "hockey.h"
#endif
#ifndef _curling_h
#	include "curling.h"
#endif
#ifndef _pball_h
#	include "pball.h"
#endif
#ifndef _pool_h
#	include "pool.h"
#endif
#ifndef _pool8_h
#	include "pool8.h"
#endif
#ifndef _snooker_h
#	include "snooker.h"
#endif
#ifndef _pocket_h
#	include "pocket.h"
#endif


Real Billard::PresetA			= -25.0;
Real Billard::PresetHaft		= 5.0;
#ifndef __TURBOC__
Real Billard::SlowGranularity	= 0.25;
#else
Real Billard::SlowGranularity	= 0.5;
#endif
Real Billard::FrameOffset		= 20.0;
Real Billard::InnerCushion		=  4.0;
Real Billard::OuterCushion		=  8.0;



Real Cannon::BallRadius		=   6.15 / 2;
Real Cannon::TableWidth		= 224.0;
Real Cannon::TableHeight	= 112.0;


Real Carrom::Offset           = 0.01;
Real Carrom::PresetA				= -400.0;
Real Carrom::PresetHaft			= 5.0;
Real Carrom::SlowGranularity	= 0.125;
Real Carrom::FrameOffset		= 14.0;
Real Carrom::ToPocket			=  2.0;
Real Carrom::Cushion				=  6.0;
Real Carrom::TableWidth			= 73.0;
Real Carrom::TableHeight		= 73.0;
Real Carrom::PocketRadius		=  6.20 / 2;
Real Carrom::StoneRadius		=  3.30 / 2;
Real Carrom::StrikerRadius		=  4.35 / 2;
Real Carrom::StoneWeight		=  4.;		//  4 g
Real Carrom::StrikerWeight		= 10.;		// 10 g

Real Carrom::ChargeGranularity	= 0.05;	// seconds
Real Carrom::ChargeSpeed			= 400.;	// Charge per second
Real Carrom::MaxCharge				= 400.;
Real Carrom::ShootTime				= 0.1;	// seconds
Real Carrom::PocketFrame	= 2.0;
Real Carrom::PocketWidth	= 8.5;

Real CarromDemo::PresetA			= 0.0;
Real CarromDemo::SlowGranularity	= 1.0;



Real Game::PresetA			= -10.0;
Real Game::PresetHaft		= 10.0;
Real Game::SlowGranularity	= 0.1;
Real Game::NormalBallSize	= 1.2;

#ifndef __TURBOC__
Real Game::ChargeGranularity	= 0.01;	// seconds
Real Game::ChargeSpeed			= 250.;	// Charge per second
Real Game::MaxCharge				= 300.;
Real Game::ShootTime				= 0.1;	// seconds
#else
Real Game::ChargeGranularity	= 0.05;	// seconds
Real Game::ChargeSpeed			= 250.;	// Charge per second
Real Game::MaxCharge				= 300.;
Real Game::ShootTime				= 0.2;	// seconds
#endif


Real Hockey::PresetA				= -100.0;
Real Hockey::PresetHaft			= 5.;
Real Hockey::SlowGranularity	= 0.125;
Real Hockey::FrameOffset		=   5.0;
Real Hockey::TableWidth			=  100.0;
Real Hockey::TableHeight		=   70.0;
Real Hockey::GoalSize			=  20.0;
Real Hockey::DiscRadius			=   4.0;
Real Hockey::HandRadius			=   6.0;
Real Hockey::DiscWeight			=  4.;		//  4 g
Real Hockey::HandWeight			= 10.;		// 10 g
Real Hockey::GoalFrame			= 0.9;
Real Hockey::GoalHeight			= 10.0;
Real TestHockey::PresetA			= -400.0;
Real TestHockey::SlowGranularity	= 0.01;


Real Curling::PresetA				= -50.0;
Real Curling::PresetHaft			= 5.;
Real Curling::SlowGranularity	= 0.125;
Real Curling::FrameOffset		=   0.0;
Real Curling::TableWidth			=  100.0;
Real Curling::TableHeight		=   40.0;
Real Curling::GoalSize			=  20.0;
Real Curling::Offset					=  0.5;
Real Curling::CurlRadius			=  2.0;
Real Curling::CurlWeight			=  4.;		//  4 g
Real Curling::KeeperFrame			= 0.9;
Real Curling::KeeperHeight			= 6.0;


Real Pool::Offset       = 0.05;
Real Pool::EdgeRadius	= 0.3;
Real Pool::EdgeAngle		= 50.;
Real Pool::MidAngle		= 30.;
Real Pool::TableWidth	= 200.0;
Real Pool::TableHeight	= 100.0;
Real Pool::PocketRadius	=   8.00 / 2.;
Real Pool::BallRadius	=   5.72 / 2.;
Real Pool::PocketFrame  = 2.0;
Real Pool::PocketHeight   = 10.0;

Real Pool8Demo::PresetA			= 0.0;
Real Pool8Demo::SlowGranularity	= 1.0;

Real PBallTop::WarpTime				= 0.02;	// Zeit zum Sprung auf Cursorposition
Real PBallTop::LockedQueueDelay	= 0.25;	// Nachlauf des gelock'ten Queue

Real Snooker::TableWidth	= 350.0;
Real Snooker::TableHeight	= 175.0;
Real Snooker::BallRadius	=   5.24 / 2;

Real SnookerDemo::PresetA			= 0.0;
Real SnookerDemo::SlowGranularity	= 1.0;


/* ========================================================================== */
/* ====                DO NOT EDIT BEYOND THIS LINE                      ==== */
/* ========================================================================== */

typedef struct {
	const char	*name;
	Real			*val_addr;
} KonfiParam;

static KonfiParam konfi[] = {
{ "Billard::FrameOffset",  &Billard::FrameOffset },
{ "Billard::InnerCushion",  &Billard::InnerCushion },
{ "Billard::OuterCushion",  &Billard::OuterCushion },
{ "Billard::PresetA",  &Billard::PresetA },
{ "Billard::PresetHaft",  &Billard::PresetHaft },
{ "Billard::SlowGranularity",  &Billard::SlowGranularity },
{ "Cannon::BallRadius",  &Cannon::BallRadius },
{ "Cannon::TableHeight",  &Cannon::TableHeight },
{ "Cannon::TableWidth",  &Cannon::TableWidth },
{ "Carrom::ChargeGranularity",  &Carrom::ChargeGranularity },
{ "Carrom::ChargeSpeed",  &Carrom::ChargeSpeed },
{ "Carrom::Cushion",  &Carrom::Cushion },
{ "Carrom::FrameOffset",  &Carrom::FrameOffset },
{ "Carrom::MaxCharge",  &Carrom::MaxCharge },
{ "Carrom::Offset",  &Carrom::Offset },
{ "Carrom::PocketFrame",  &Carrom::PocketFrame },
{ "Carrom::PocketRadius",  &Carrom::PocketRadius },
{ "Carrom::PocketWidth",  &Carrom::PocketWidth },
{ "Carrom::PresetA",  &Carrom::PresetA },
{ "Carrom::PresetHaft",  &Carrom::PresetHaft },
{ "Carrom::ShootTime",  &Carrom::ShootTime },
{ "Carrom::SlowGranularity",  &Carrom::SlowGranularity },
{ "Carrom::StoneRadius",  &Carrom::StoneRadius },
{ "Carrom::StoneWeight",  &Carrom::StoneWeight },
{ "Carrom::StrikerRadius",  &Carrom::StrikerRadius },
{ "Carrom::StrikerWeight",  &Carrom::StrikerWeight },
{ "Carrom::TableHeight",  &Carrom::TableHeight },
{ "Carrom::TableWidth",  &Carrom::TableWidth },
{ "Carrom::ToPocket",  &Carrom::ToPocket },
{ "CarromDemo::PresetA",  &CarromDemo::PresetA },
{ "CarromDemo::SlowGranularity",  &CarromDemo::SlowGranularity },
{ "Curling::CurlRadius",  &Curling::CurlRadius },
{ "Curling::CurlWeight",  &Curling::CurlWeight },
{ "Curling::FrameOffset",  &Curling::FrameOffset },
{ "Curling::GoalSize",  &Curling::GoalSize },
{ "Curling::KeeperFrame",  &Curling::KeeperFrame },
{ "Curling::KeeperHeight",  &Curling::KeeperHeight },
{ "Curling::Offset",  &Curling::Offset },
{ "Curling::PresetA",  &Curling::PresetA },
{ "Curling::PresetHaft",  &Curling::PresetHaft },
{ "Curling::SlowGranularity",  &Curling::SlowGranularity },
{ "Curling::TableHeight",  &Curling::TableHeight },
{ "Curling::TableWidth",  &Curling::TableWidth },
{ "Game::ChargeGranularity",  &Game::ChargeGranularity },
{ "Game::ChargeSpeed",  &Game::ChargeSpeed },
{ "Game::MaxCharge",  &Game::MaxCharge },
{ "Game::NormalBallSize",  &Game::NormalBallSize },
{ "Game::PresetA",  &Game::PresetA },
{ "Game::PresetHaft",  &Game::PresetHaft },
{ "Game::ShootTime",  &Game::ShootTime },
{ "Game::SlowGranularity",  &Game::SlowGranularity },
{ "Hockey::DiscRadius",  &Hockey::DiscRadius },
{ "Hockey::DiscWeight",  &Hockey::DiscWeight },
{ "Hockey::FrameOffset",  &Hockey::FrameOffset },
{ "Hockey::GoalFrame",  &Hockey::GoalFrame },
{ "Hockey::GoalHeight",  &Hockey::GoalHeight },
{ "Hockey::GoalSize",  &Hockey::GoalSize },
{ "Hockey::HandRadius",  &Hockey::HandRadius },
{ "Hockey::HandWeight",  &Hockey::HandWeight },
{ "Hockey::PresetA",  &Hockey::PresetA },
{ "Hockey::PresetHaft",  &Hockey::PresetHaft },
{ "Hockey::SlowGranularity",  &Hockey::SlowGranularity },
{ "Hockey::TableHeight",  &Hockey::TableHeight },
{ "Hockey::TableWidth",  &Hockey::TableWidth },
{ "PBallTop::LockedQueueDelay",  &PBallTop::LockedQueueDelay },
{ "PBallTop::WarpTime",  &PBallTop::WarpTime },
{ "Pool8Demo::PresetA",  &Pool8Demo::PresetA },
{ "Pool8Demo::SlowGranularity",  &Pool8Demo::SlowGranularity },
{ "Pool::BallRadius",  &Pool::BallRadius },
{ "Pool::EdgeAngle",  &Pool::EdgeAngle },
{ "Pool::EdgeRadius",  &Pool::EdgeRadius },
{ "Pool::MidAngle",  &Pool::MidAngle },
{ "Pool::Offset",  &Pool::Offset },
{ "Pool::PocketFrame",  &Pool::PocketFrame },
{ "Pool::PocketHeight",  &Pool::PocketHeight },
{ "Pool::PocketRadius",  &Pool::PocketRadius },
{ "Pool::TableHeight",  &Pool::TableHeight },
{ "Pool::TableWidth",  &Pool::TableWidth },
{ "Snooker::BallRadius",  &Snooker::BallRadius },
{ "Snooker::TableHeight",  &Snooker::TableHeight },
{ "Snooker::TableWidth",  &Snooker::TableWidth },
{ "SnookerDemo::PresetA",  &SnookerDemo::PresetA },
{ "SnookerDemo::SlowGranularity",  &SnookerDemo::SlowGranularity },
{ "TestHockey::PresetA",  &TestHockey::PresetA },
{ "TestHockey::SlowGranularity",  &TestHockey::SlowGranularity },
{ 0, 0 }			// end konfi
};

void show_defaults() {
	for (unsigned i=0;i<sizeof(konfi)/sizeof(KonfiParam)-1U;i++) {
		printf( "%s = %g\n", konfi[i].name, (double)*konfi[i].val_addr );
	}
}

void load_konfi() {
FILE		*fp;
char		buffer[80];

	fp = fopen( PRESET_FILE, "r" );
	if (!fp) {
		sprintf(buffer,"%s/%s",DATA_DIRECTORY,PRESET_FILE);
		fp = fopen( buffer, "r" );
		if (!fp)		return;
	}

	while( fgets( buffer, sizeof(buffer), fp )) {
		if (strstr(buffer,"::")) {
			char *ptr = buffer;
			while( (ptr)&&!isspace(*ptr)&&*ptr!='=' )		ptr++;
			if (!ptr)			break;
			*ptr++ = '\0';
			while( (ptr)&&isspace(*ptr)||*ptr=='=' )   	ptr++;
			if (!ptr)			break;

			int i;
			for (i=sizeof(konfi)/sizeof(KonfiParam)-2;i>=0;i--) {
				if (!strcmp(buffer,konfi[i].name)) {
					(*konfi[i].val_addr) = Real(atof(ptr));
					break;
				}
			}
			if (i<0) {
				printf( "%s: unknown parameter in %s", PRESET_FILE, buffer );
			}
		}
	}
	fclose(fp);
}

#ifdef DEBUG

/* ========================================================================== */

typedef struct {
	const char		*name;
	unsigned long	mask;
} DebugFlag;

static DebugFlag dbg[] = {
{ "AbortCalc",  AbortCalc },
{ "AbortReCalc",  AbortReCalc },
{ "AfterCollision",  AfterCollision },
{ "BMover",  BMover },
{ "BState",  BState },
{ "BeforCollision",  BeforCollision },
{ "CheckBoundary",  CheckBoundary },
{ "CollCalc",  CollCalc },
{ "ForceCalc",  ForceCalc },
{ "GameState",  GameState },
{ "Intro",  Intro },
{ "Loops",  Loops },
{ "Motion",  Motion },
{ "MoveAll",  MoveAll },
{ "ObjectInfo",  ObjectInfo },
{ "PBallHit",  PBallHit },
{ "PointerMove",  PointerMove },
{ "ShowColors",  ShowColors },
{ "ShowLight",  ShowLight },
{ "ShowRings",  ShowRings },
{ "ShowTurns",  ShowTurns },
{ "StickLevel",  StickLevel },
{ "Sync",  Sync },
{ "TCTrace",  TCTrace },
{ "UnixTrace",  UnixTrace },
{ "XWallHit",  XWallHit },
{ "YWallHit",  YWallHit },
{ "__Moves",  __Moves },
{ "__Rings",  __Rings },
{ "__ShowAll",  __ShowAll },
{ "xdb",  xdb },
{ "xwd",  xwd },
{ 0, 0 }		// end dbg
};

void show_flags() {
int	width = 0;

	for (int i=0;i<sizeof(dbg)/sizeof(DebugFlag)-1;i++) {
		if (strlen(dbg[i].name)>width)		width = strlen(dbg[i].name);
	}
	width++;
	int cols = 79/width;
	int rows = (sizeof(dbg)/sizeof(DebugFlag)-1)/cols+1;
	for (int r=0;r<rows;r++) {
		for (int c=0;c<cols;c++) {
			int entry = rows*c+r;
			if (entry<sizeof(dbg)/sizeof(DebugFlag)-1)
								printf( "%-*s", width, dbg[entry].name );
		}
		printf( "\n" );
	}
}

int set_debug( const char *flag_name ) {
	for (int i=0;i<sizeof(dbg)/sizeof(DebugFlag)-1;i++) {
		if (!strcmp(flag_name,dbg[i].name)) {
			debug |= dbg[i].mask;
			return 0;
		}
	}
	return 1;
}


#endif