Crossfire Server, Trunk
RandomMaps.h
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #ifndef RANDOM_MAPS_H
14 #define RANDOM_MAPS_H
15 
16 #include "assets/AssetWrapper.h"
18 #include "RandomMap.h"
19 
20 class RandomMaps : public AssetWrapper {
21  Q_OBJECT
22 public:
24  connect(maps, SIGNAL(mapAdded(CREMapInformation *)), this, SLOT(mapAdded(CREMapInformation *)));
25  setProperty(tipProperty, tr("Display all random maps."));
26  }
27 
28  virtual QString displayName() const override { return tr("Random maps"); }
29 
30  virtual int childrenCount() const override { refresh(); return myCache.size(); }
31  virtual AssetWrapper *child(int child) override { refresh(); return myCache[child]; }
32  virtual int childIndex(AssetWrapper *child) override { refresh(); return myCache.indexOf(static_cast<RandomMap *>(child)); }
33 
34 protected slots:
36  if (!map->randomMaps().empty()) {
37  myNeedRefresh = true;
38  }
39  }
40 
41 private:
43  mutable bool myNeedRefresh;
44  mutable QList<RandomMap *> myCache;
45 
46  void refresh() const {
47  if (myNeedRefresh) {
48  myNeedRefresh = false;
50  }
51  }
52 };
53 
54 #endif /* RANDOM_MAPS_H */
RandomMaps::child
virtual AssetWrapper * child(int child) override
Definition: RandomMaps.h:31
AssetWrapper::tipProperty
static const char * tipProperty
Definition: AssetWrapper.h:34
RandomMaps::displayName
virtual QString displayName() const override
Definition: RandomMaps.h:28
RandomMaps::childrenCount
virtual int childrenCount() const override
Definition: RandomMaps.h:30
RandomMap.h
RandomMaps::childIndex
virtual int childIndex(AssetWrapper *child) override
Definition: RandomMaps.h:32
CREMapInformationManager
Definition: CREMapInformationManager.h:27
RandomMaps
Definition: RandomMaps.h:20
AssetWrapper
Definition: AssetWrapper.h:25
RandomMaps::RandomMaps
RandomMaps(AssetWrapper *parent, CREMapInformationManager *maps)
Definition: RandomMaps.h:23
disinfect.map
map
Definition: disinfect.py:4
RandomMap
Definition: RandomMap.h:24
RandomMaps::refresh
void refresh() const
Definition: RandomMaps.h:46
CREMapInformationManager::randomMaps
QList< RandomMap * > randomMaps()
Definition: CREMapInformationManager.cpp:804
maps
this information may not reflect the current implementation This brief document is meant to describe the operation of the crossfire as well as the form of the data The metaserver listens on port for tcp and on port for udp packets The server sends updates to the metaserver via udp The metaserver only does basic checking on the data that server sends It trusts the server for the ip name it provides The metaserver does add the ip address and also tracks the idle time(time since last packet received). The client gets its information from the metaserver through connecting by means of tcp. The client should retrieve http the body s content type is text plain The current metaserver implementation is in Perl But the metaserver could be in any language perl is fast enough for the amount of data that is being exchanged The response includes zero or more server entries Each entry begins with the line START_SERVER_DATA and ends with the line END_SERVER_DATA Between these lines key value pairs("key=value") may be present. The entries are sent in arbitrary order. A client should apply some ordering when displaying the entries to the user. TODO b additional information outside BEGIN_SERVER_DATA END_SERVER_DATA maps
Definition: arch-handbook.txt:189
RandomMaps::myCache
QList< RandomMap * > myCache
Definition: RandomMaps.h:44
CREMapInformation
Definition: CREMapInformation.h:27
CREMapInformationManager.h
RandomMaps::myMaps
CREMapInformationManager * myMaps
Definition: RandomMaps.h:42
RandomMaps::myNeedRefresh
bool myNeedRefresh
Definition: RandomMaps.h:43
RandomMaps::mapAdded
void mapAdded(CREMapInformation *map)
Definition: RandomMaps.h:35
AssetWrapper.h
connect
Definition: connect.py:1