The Battle for Wesnoth  1.19.7+dev
synced_checkup.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2024
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 class config;
19 /**
20  A class to check whether the results that were calculated in the replay match the results calculated during the original game.
21  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.
22 
23  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.
24 */
25 class checkup
26 {
27 public:
28  checkup();
29  virtual ~checkup();
30  /**
31  Compares data to the results calculated during the original game.
32  It's undefined whether this function also compares calculated results from different clients in a mp game.
33  returns whether the two config objects are equal.
34  */
35  virtual bool local_checkup(const config& expected_data, config& real_data) = 0;
36 };
37 
38 /**
39  This checkup compares whether the results calculated during the original game match the ones calculated during replay.
40  Whether this checkup also compares the calculated results of different clients in a a mp game depends on whether
41  there was already data sent about the current synced command.
42 */
43 class synced_checkup : public checkup
44 {
45 public:
46  synced_checkup(config& buffer);
47  virtual ~synced_checkup();
48  virtual bool local_checkup(const config& expected_data, config& real_data);
49 private:
51  unsigned int pos_;
52 };
53 
54 class ignored_checkup : public checkup
55 {
56 public:
58  virtual ~ignored_checkup();
59  /**
60  always returns true
61  */
62  virtual bool local_checkup(const config& expected_data, config& real_data);
63 };
64 /**
65  This checkup always compares the results in from different clients in a mp game but it also causes more network overhead.
66 */
67 class mp_debug_checkup : public checkup
68 {
69 public:
71  virtual ~mp_debug_checkup();
72  virtual bool local_checkup(const config& expected_data, config& real_data);
73 };
74 
75 /*
76  this is a synced_checkup during a synced context otherwise a invalid_checkup object.
77 */
78 
A class to check whether the results that were calculated in the replay match the results calculated ...
virtual ~checkup()
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:172
virtual ~ignored_checkup()
virtual bool local_checkup(const config &expected_data, config &real_data)
always returns true
This checkup always compares the results in from different clients in a mp game but it also causes mo...
virtual ~mp_debug_checkup()
virtual bool local_checkup(const config &expected_data, config &real_data)
Compares data to the results calculated during the original game.
This checkup compares whether the results calculated during the original game match the ones calculat...
synced_checkup(config &buffer)
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()
checkup * checkup_instance