1 /* -*- Mode: C++; c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil -*-
2  *
3  * Quadra, an action puzzle game
4  * Copyright (C) 1998-2000  Ludus Design
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 #ifndef _HEADER_RECORDING
21 #define _HEADER_RECORDING
22 
23 #include <vector>
24 
25 #include "types.h"
26 #include "net_stuff.h"
27 #include "buf.h"
28 
29 class Res_compress;
30 class Res;
31 class Canvas;
32 class Packet_gameserver;
33 
34 class Recording {
35 	char playername[40];
36 	int score, lines, level;
37 	/*
38 	Voici les hunks:
39 		0: start_for_single: un seed pis 3 repeatspeeds
40 		1: single_start: un numero de player
41 		2: game_begin: les touches d'une game single
42 		3: game_stop: les infos d'une game single
43 	 11: write_packet: un numero de frame d'overmind (Dword), la size d'un packet (Word) pis le packet
44 	 13: summary: size (Dword) et du texte (� la Qserv)
45 	*/
46 	void write_hunk(Byte h);
47 	void end_single(Canvas *c);
48 public:
49 	Dword frame;
50 	void step();
51 	Res_compress *res;
52 	Recording();
53 	virtual ~Recording();
54 	void start_for_multi(Packet* p);
55 	void write_packet(Packet* p);
56 	bool create(const char *n);
57 	void end_multi();
58 	void write_summary();
59 };
60 
61 class Demo_packet {
62 public:
63 	Dword frame;
64 	Packet* p;
65 	Demo_packet(const Demo_packet& dp);
66 	Demo_packet(Dword pframe, Packet* pp);
67 	virtual ~Demo_packet();
68 };
69 
70 class Dict;
71 class Game;
72 
73 class Playback {
74 	Res *res;
75 	bool *verification_flag;
76 	Byte read_hunk();
77 	void read_all(); //Sole caller of next 6
78 	void read_seed();
79 	void read_single();
80 	void read_data();
81 	void read_info();
82 	void read_packet();
83 	void read_summary();
84 	Buf data;
85 	Dword nextByte;
86 	std::vector<Demo_packet*> packets;
87 public:
88 	Byte single_player;
89 	Packet_gameserver *packet_gameserver;
90 	Dict *sum;
91 	bool single();
92 	bool old_mode;
93 	bool valid;
94 	bool completed;
95 	bool auto_demo;
96 	void create_game();
97 	void shit_skipper2000(bool remove_chat);
98 	int seed;
99 	struct {
100 		char name[40];
101 		int color, shadow, smooth, repeat;
102 	} player[3];
103 	int score, lines, level, multi_level;
104 	Playback(Res* r);
105 	virtual ~Playback();
106 	void set_verification_flag(bool *p);
107 	bool verify_summary(const Game *game);
108 	Byte get_byte();
109 	bool check_scores(Canvas* c);
110 	Demo_packet next_packet();
111 	void remove_packet();
112 };
113 
114 extern Recording *recording;
115 extern Playback *playback;
116 
117 #endif
118