The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
synced_checkup.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef SYNCED_CHECKUP_H_INCLUDED
16 #define SYNCED_CHECKUP_H_INCLUDED
17 
18 class config;
19 struct map_location;
20 /**
21  A class to check whether the results that were calculated in the replay match the results calculated during the original game.
22  note, that you shouldn't add new checkups to existent user actions or you might break replay compability by bringing the [checkups] tag of older saves in unorder.
23 
24  so if you really want to add new checkups, you should wrap your checkup_instance->... call in a if(resources::state_of_game->classification.version ....) or similar.
25 */
26 class checkup
27 {
28 public:
29  checkup();
30  virtual ~checkup();
31  /**
32  Compares data to the results calculated during the original game.
33  It's undefined whether this function also compares calculated results from different clients in a mp game.
34  returns whether the two config objects are equal.
35  */
36  virtual bool local_checkup(const config& expected_data, config& real_data) = 0;
37 };
38 
39 /**
40  This checkup compares whether the results calculated during the original game match the ones calculated during replay.
41  Whether this checkup also compares the calculated results of different clients in a a mp game depends on whether
42  there was already data sended about the current synced command.
43 */
44 class synced_checkup : public checkup
45 {
46 public:
48  virtual ~synced_checkup();
49  virtual bool local_checkup(const config& expected_data, config& real_data);
50 private:
52  unsigned int pos_;
53 };
54 
55 class ignored_checkup : public checkup
56 {
57 public:
59  virtual ~ignored_checkup();
60  /**
61  always returns true
62  */
63  virtual bool local_checkup(const config& expected_data, config& real_data);
64 };
65 /**
66  This checkup always compares the results in from different clients in a mp game but it also causes more network overhead.
67 */
68 class mp_debug_checkup : public checkup
69 {
70 public:
72  virtual ~mp_debug_checkup();
73  virtual bool local_checkup(const config& expected_data, config& real_data);
74 };
75 
76 /*
77  this is a synced_checkup during a synced context otherwise a invalid_checkup object.
78 */
79 
81 
82 #endif
unsigned int pos_
virtual bool local_checkup(const config &expected_data, config &real_data)
Compares data to the results calculated during the original game.
virtual ~synced_checkup()
This checkup compares whether the results calculated during the original game match the ones calculat...
virtual ~checkup()
GLuint buffer
Definition: glew.h:1648
Encapsulates the map of the game.
Definition: location.hpp:38
virtual bool local_checkup(const config &expected_data, config &real_data)
Compares data to the results calculated during the original game.
A class to check whether the results that were calculated in the replay match the results calculated ...
virtual ~ignored_checkup()
checkup * checkup_instance
virtual bool local_checkup(const config &expected_data, config &real_data)
always returns true
synced_checkup(config &buffer)
virtual bool local_checkup(const config &expected_data, config &real_data)=0
Compares data to the results calculated during the original game.
virtual ~mp_debug_checkup()
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
This checkup always compares the results in from different clients in a mp game but it also causes mo...