The Battle for Wesnoth  1.15.2+dev
synced_checkup.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2018 by David White <dave@whitevine.net>
3  Part of the Battle for Wesnoth Project https://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 #pragma once
16 
17 class config;
18 /**
19  A class to check whether the results that were calculated in the replay match the results calculated during the original game.
20  note, that you shouldn't add new checkups to existent user actions or you might break replay compatibility by bringing the [checkups] tag of older saves in unorder.
21 
22  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.
23 */
24 class checkup
25 {
26 public:
27  checkup();
28  virtual ~checkup();
29  /**
30  Compares data to the results calculated during the original game.
31  It's undefined whether this function also compares calculated results from different clients in a mp game.
32  returns whether the two config objects are equal.
33  */
34  virtual bool local_checkup(const config& expected_data, config& real_data) = 0;
35 };
36 
37 /**
38  This checkup compares whether the results calculated during the original game match the ones calculated during replay.
39  Whether this checkup also compares the calculated results of different clients in a a mp game depends on whether
40  there was already data sent about the current synced command.
41 */
42 class synced_checkup : public checkup
43 {
44 public:
45  synced_checkup(config& buffer);
46  virtual ~synced_checkup();
47  virtual bool local_checkup(const config& expected_data, config& real_data);
48 private:
50  unsigned int pos_;
51 };
52 
53 class ignored_checkup : public checkup
54 {
55 public:
57  virtual ~ignored_checkup();
58  /**
59  always returns true
60  */
61  virtual bool local_checkup(const config& expected_data, config& real_data);
62 };
63 /**
64  This checkup always compares the results in from different clients in a mp game but it also causes more network overhead.
65 */
66 class mp_debug_checkup : public checkup
67 {
68 public:
70  virtual ~mp_debug_checkup();
71  virtual bool local_checkup(const config& expected_data, config& real_data);
72 };
73 
74 /*
75  this is a synced_checkup during a synced context otherwise a invalid_checkup object.
76 */
77 
unsigned int pos_
This checkup compares whether the results calculated during the original game match the ones calculat...
virtual ~checkup()
A class to check whether the results that were calculated in the replay match the results calculated ...
checkup * checkup_instance
virtual bool local_checkup(const config &expected_data, config &real_data)=0
Compares data to the results calculated during the original game.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
This checkup always compares the results in from different clients in a mp game but it also causes mo...