[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netPanzer-CVS] netpanzer/src/NetPanzer Interfaces/BaseGameMana...
From: |
Matthias Braun |
Subject: |
[netPanzer-CVS] netpanzer/src/NetPanzer Interfaces/BaseGameMana... |
Date: |
Sat, 22 Nov 2003 07:38:24 -0500 |
CVSROOT: /cvsroot/netpanzer
Module name: netpanzer
Branch:
Changes by: Matthias Braun <address@hidden> 03/11/22 07:38:23
Modified files:
src/NetPanzer/Interfaces: BaseGameManager.cpp ConfigVariable.cpp
ConfigVariable.hpp GameConfig.cpp
GameConfig.hpp
src/NetPanzer/Views/Game: GameInfoView.cpp GameToolbarView.cpp
MiniMapView.cpp
src/NetPanzer/Views/MainMenu/Multi: FlagSelectionView.cpp
Log message:
Removed gameconfig->configfileread again.
Instead I introduced a defaultvalue attribute to each configvariable.
This
solution is more correct since a config file could miss some fields. In
this
case only a few variables have their default values.
Patches:
Index: netpanzer/src/NetPanzer/Interfaces/BaseGameManager.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/BaseGameManager.cpp:1.6
netpanzer/src/NetPanzer/Interfaces/BaseGameManager.cpp:1.7
--- netpanzer/src/NetPanzer/Interfaces/BaseGameManager.cpp:1.6 Sat Nov 22
04:46:40 2003
+++ netpanzer/src/NetPanzer/Interfaces/BaseGameManager.cpp Sat Nov 22
07:38:22 2003
@@ -144,7 +144,7 @@
if(UNIT_FLAGS_SURFACE.getFrameCount() == 0) {
throw Exception("Couldn't find any flag in pics/flags/.");
}
- if(!gameconfig->configfileexists) {
+ if(gameconfig->playerflag.isDefaultValue()) {
gameconfig->playerflag=rand()%UNIT_FLAGS_SURFACE.getFrameCount();
}
}
Index: netpanzer/src/NetPanzer/Interfaces/ConfigVariable.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/ConfigVariable.cpp:1.3
netpanzer/src/NetPanzer/Interfaces/ConfigVariable.cpp:1.4
--- netpanzer/src/NetPanzer/Interfaces/ConfigVariable.cpp:1.3 Sat Nov 22
04:13:57 2003
+++ netpanzer/src/NetPanzer/Interfaces/ConfigVariable.cpp Sat Nov 22
07:38:23 2003
@@ -4,7 +4,7 @@
#include "ConfigVariable.hpp"
ConfigVariable::ConfigVariable(const std::string& newname)
- : name(newname)
+ : name(newname), defaultvalue(true)
{
}
Index: netpanzer/src/NetPanzer/Interfaces/ConfigVariable.hpp
diff -u netpanzer/src/NetPanzer/Interfaces/ConfigVariable.hpp:1.4
netpanzer/src/NetPanzer/Interfaces/ConfigVariable.hpp:1.5
--- netpanzer/src/NetPanzer/Interfaces/ConfigVariable.hpp:1.4 Sat Nov 22
04:13:57 2003
+++ netpanzer/src/NetPanzer/Interfaces/ConfigVariable.hpp Sat Nov 22
07:38:23 2003
@@ -30,9 +30,18 @@
const std::string& getName() const
{ return name; }
+
+ /** Does this variable contain a default value or was is loaded from disk?
+ */
+ bool isDefaultValue() const
+ { return defaultvalue; }
+
+ void setNonDefaultValue()
+ { defaultvalue = false; }
private:
std::string name;
+ bool defaultvalue;
};
class ConfigInt : public ConfigVariable
Index: netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp:1.21
netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp:1.22
--- netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp:1.21 Sat Nov 22
04:46:40 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp Sat Nov 22 07:38:23 2003
@@ -98,7 +98,6 @@
radar_resizerate("resizerate", 400, 10, 1000)
{
configfile = newconfigfile;
- configfileexists = false;
//gamesettings.push_back(&hostorjoin);
@@ -199,7 +198,6 @@
loadSettings(config, "interface", interfacesettings);
loadSettings(config, "radar", radarsettings);
loadSettings(config, "server", serversettings);
- configfileexists = true;
}
void GameConfig::loadSettings(XmlConfig& config, const char* name,
@@ -239,6 +237,9 @@
if(confstring)
*confstring =
section.readString(confstring->getName().c_str());
+
+ // we have a value from config file in the variable now
+ var->setNonDefaultValue();
} catch(Exception& e) {
LOG(("Skipping config '%s': %s", var->getName().c_str(),
e.what()));
Index: netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp:1.17
netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp:1.18
--- netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp:1.17 Sat Nov 22
04:46:40 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp Sat Nov 22 07:38:23 2003
@@ -107,8 +107,6 @@
void loadConfig();
void saveConfig();
- bool configfileexists; // whether we loaded from a config file
-
// game Settings
ConfigInt hostorjoin; //1=host, 2=join
Index: netpanzer/src/NetPanzer/Views/Game/GameInfoView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/GameInfoView.cpp:1.14
netpanzer/src/NetPanzer/Views/Game/GameInfoView.cpp:1.15
--- netpanzer/src/NetPanzer/Views/Game/GameInfoView.cpp:1.14 Sat Nov 22
05:00:22 2003
+++ netpanzer/src/NetPanzer/Views/Game/GameInfoView.cpp Sat Nov 22 07:38:23 2003
@@ -80,7 +80,7 @@
//resizeClientArea(iXY(100, 2 * 2 + 12 * 3 + 8));
resizeClientArea(iXY(140, 2 * 2 + 12 * 5 + 8));
- if(!gameconfig->configfileexists) {
+ if(gameconfig->gameinfoposition.isDefaultValue()) {
// Start it in the top-left corner.
iXY pos(screen->getPixX() - getSize().x,0);
gameconfig->gameinfoposition=pos;
Index: netpanzer/src/NetPanzer/Views/Game/GameToolbarView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/GameToolbarView.cpp:1.10
netpanzer/src/NetPanzer/Views/Game/GameToolbarView.cpp:1.11
--- netpanzer/src/NetPanzer/Views/Game/GameToolbarView.cpp:1.10 Sat Nov 22
05:00:22 2003
+++ netpanzer/src/NetPanzer/Views/Game/GameToolbarView.cpp Sat Nov 22
07:38:23 2003
@@ -216,7 +216,7 @@
resizeClientArea(iXY(117, pos.y));
- if(!gameconfig->configfileexists) {
+ if(gameconfig->toolbarposition.isDefaultValue()) {
// Start it in the bottom-left corner.
iXY pos=screen->getPix() - getSize();
gameconfig->toolbarposition=pos;
Index: netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp:1.23
netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp:1.24
--- netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp:1.23 Sat Nov 22
05:00:22 2003
+++ netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp Sat Nov 22 07:38:23 2003
@@ -65,11 +65,12 @@
//iXY size = miniMap->getPix();
iXY size(((const iXY &)gameconfig->minimapsize)+iXY(2,2));
resize(size);
- if(gameconfig->configfileexists) {
- moveTo(gameconfig->minimapposition);
- } else {
- moveTo(gameconfig->minimapposition=iXY(0, screen->getPix().y - 196));
+
+ if(gameconfig->minimapposition.isDefaultValue()) {
+ gameconfig->minimapposition = iXY(0, screen->getPix().y - 196);
}
+ moveTo(gameconfig->minimapposition);
+ checkArea(screen->getPix());
//int xOffset = size.x;
//int yOffset = 0;
Index: netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp:1.17
netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp:1.18
--- netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp:1.17
Sat Nov 22 04:46:41 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp Sat Nov
22 07:38:23 2003
@@ -95,12 +95,11 @@
}
playerFlag.setFrame(0);
- if(!gameconfig->configfileexists) {
+ if(gameconfig->playerflag.isDefaultValue()) {
// new player, no flag...
gameconfig->playerflag=rand()%playerFlag.getFrameCount();
}
playerFlagSelected = gameconfig->playerflag;
-
} // end FlagSelectionView::init
// doDraw