[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netPanzer-CVS] netpanzer/src ChangeLog Makefile Lib/FileSystem...
From: |
Ivo Danihelka |
Subject: |
[netPanzer-CVS] netpanzer/src ChangeLog Makefile Lib/FileSystem... |
Date: |
Sat, 20 Sep 2003 18:40:16 -0400 |
CVSROOT: /cvsroot/netpanzer
Module name: netpanzer
Branch:
Changes by: Ivo Danihelka <address@hidden> 03/09/20 18:40:15
Modified files:
src : ChangeLog Makefile
src/Lib : FileSystem.cpp
src/NetPanzer/Interfaces: GameConfig.cpp GameConfig.hpp
GameManager.cpp
Added files:
src/Lib/Xml : XmlConfig.cpp XmlConfig.hpp XmlParser.cpp
XmlParser.hpp XmlStore.cpp XmlStore.hpp
Log message:
- load/save GameConfig in XML format
- modified FileSystem::getRealName() function
Patches:
Index: netpanzer/src/ChangeLog
diff -u netpanzer/src/ChangeLog:1.27 netpanzer/src/ChangeLog:1.28
--- netpanzer/src/ChangeLog:1.27 Thu Sep 18 13:44:17 2003
+++ netpanzer/src/ChangeLog Sat Sep 20 18:40:15 2003
@@ -1,4 +1,8 @@
-18-Sepby Matthias Braun
+21-Sep-2003 by Ivo Danihelka
+-solved the higher resolutions problem in MainMenu
+-load/save GameConfig in XML format
+
+18-Sep-2003 by Matthias Braun
-fixed the Choice-reset problem
-removed lots of options from visualsview
-changed sound back to 8 channels at 22k, no need to blow too much resources
Index: netpanzer/src/Lib/FileSystem.cpp
diff -u netpanzer/src/Lib/FileSystem.cpp:1.6
netpanzer/src/Lib/FileSystem.cpp:1.7
--- netpanzer/src/Lib/FileSystem.cpp:1.6 Tue Sep 16 16:16:09 2003
+++ netpanzer/src/Lib/FileSystem.cpp Sat Sep 20 18:40:15 2003
@@ -100,7 +100,11 @@
std::string FileSystem::getRealName(const char* filename)
{
const char* dir = PHYSFS_getRealDir(filename);
+ if (dir == 0) {
+ throw Exception("no such path '%s'", filename);
+ }
std::string realname = dir;
+ realname += PHYSFS_getDirSeparator();
realname += filename;
return realname;
}
Index: netpanzer/src/Makefile
diff -u netpanzer/src/Makefile:1.16 netpanzer/src/Makefile:1.17
--- netpanzer/src/Makefile:1.16 Fri Sep 19 11:22:30 2003
+++ netpanzer/src/Makefile Sat Sep 20 18:40:15 2003
@@ -2,7 +2,7 @@
DIRS = . Lib Lib/2D Lib/Environment Lib/Interfaces Lib/Particles \
Lib/PObject/Classes Lib/PObject/Templates Lib/Types Lib/View \
- Lib/optionmm \
+ Lib/optionmm Lib/Xml \
NetPanzer/Classes NetPanzer/Classes/Weapons \
NetPanzer/Classes/Network \
NetPanzer/Views/MainMenu NetPanzer/Views/MainMenu/Options \
@@ -19,8 +19,9 @@
CFLAGS += -Wall -g3 -O2 $(foreach dir, $(INCLUDEDIRS), -I$(dir))
GOAL = ../netpanzer
-LINKFLAGS += -g3 `sdl-config --libs` -lSDL_net -lSDL_mixer -lSDL_image -lphysfs
-CFLAGS += `sdl-config --cflags` -D${SYSTEM}
+LINKFLAGS += -g3 `sdl-config --libs` -lSDL_net -lSDL_mixer -lSDL_image \
+ -lphysfs `xml2-config --libs`
+CFLAGS += `sdl-config --cflags` `xml2-config --cflags` -D${SYSTEM}
ifeq ($(PROFILING),yes)
CFLAGS += -pg
Index: netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp:1.7
netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp:1.8
--- netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp:1.7 Tue Sep 16
16:16:12 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp Sat Sep 20 18:40:15 2003
@@ -21,6 +21,8 @@
#include "Log.hpp"
#include "Exception.hpp"
#include "GameConfig.hpp"
+#include "XmlConfig.hpp"
+#include "XmlStore.hpp"
std::string GameConfig::configfile;
char GameConfig::UnitColor;
@@ -155,52 +157,55 @@
void GameConfig::loadConfig()
{
- ReadFile* file = FileSystem::openRead(configfile.c_str());
+ const char *xmlfile = FileSystem::getRealName(configfile.c_str()).c_str();
+ XmlConfig config(xmlfile);
- // XXX loadin/saving would be nicer in human readable form (XML?)
-
- int configversion = file->readSLE16();
- if(configversion != CONFIG_VERSION)
- throw Exception("wrong config file version");
-
- UnitColor = file->read8();
- GameMode = file->read8();
- GameType = file->read8();
- NumberPlayers = file->readSLE16();
- NumberUnits = file->readSLE16();
- NumberInitialUnits = file->readSLE16();
-
- // TODO lots of other stuff :)
- screen_resolution = file->readSLE32();
- screen_fullscreen = file->read8();
- display_shadows_flag = file->read8();
- display_unit_flags = file->read8();
-
- // TODO lots of other stuff :)
+ int configversion = config.readInt("version");
+ if (configversion != CONFIG_VERSION) {
+ throw Exception("wrong config file version, %d!=%d",
+ configversion, CONFIG_VERSION);
+ }
- delete file;
+ XmlConfig game = config.getChild("game");
+ GameMode = game.readInt("mode");
+ GameType = game.readInt("type");
+ NumberPlayers = game.readInt("players");
+ NumberUnits = game.readInt("units");
+ NumberInitialUnits = game.readInt("init_units");
+
+ XmlConfig visuals = config.getChild("visuals");
+ screen_resolution = visuals.readInt("resolution");
+ screen_fullscreen = visuals.readInt("fullscreen");
+ display_shadows_flag = visuals.readInt("shadows_flag");
+ display_unit_flags = visuals.readInt("unit_flags");
+ UnitColor = visuals.readInt("unit_color");
}
void GameConfig::saveConfig()
{
- WriteFile* file = FileSystem::openWrite(configfile.c_str());
+ XmlStore xmlStore("netpanzer");
+ xmlStore.writeInt("version", CONFIG_VERSION);
- file->writeSLE16(CONFIG_VERSION);
-
- file->write8(UnitColor);
- file->write8(GameMode);
- file->write8(GameType);
- file->writeSLE16(NumberPlayers);
- file->writeSLE16(NumberUnits);
- file->writeSLE16(NumberInitialUnits);
-
- // TODO lots of other stuff :)
- file->writeSLE32(screen_resolution);
- file->write8(screen_fullscreen);
- file->write8(display_shadows_flag);
- file->write8(display_unit_flags);
-
- delete file;
+ XmlStore game = xmlStore.createChild("game");
+ game.writeInt("mode", GameMode);
+ game.writeInt("type", GameType);
+ game.writeInt("players", NumberPlayers);
+ game.writeInt("units", NumberUnits);
+ game.writeInt("init_units", NumberInitialUnits);
+
+ XmlStore visuals = xmlStore.createChild("visuals");
+ visuals.writeInt("resolution", screen_resolution);
+ visuals.writeInt("fullscreen", screen_fullscreen);
+ visuals.writeInt("shadows_flag", display_shadows_flag);
+ visuals.writeInt("unit_flags", display_unit_flags);
+ visuals.writeInt("unit_color", UnitColor);
+
+ if (!FileSystem::exists(configfile.c_str())) {
+ // hack, touch file
+ delete FileSystem::openWrite(configfile.c_str());
+ }
+ const char *xmlfile = FileSystem::getRealName(configfile.c_str()).c_str();
+ xmlStore.save(xmlfile);
}
void GameConfig::setGameMapName( char *map_name )
Index: netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp:1.8
netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp:1.9
--- netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp:1.8 Tue Sep 16
16:16:12 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp Sat Sep 20 18:40:15 2003
@@ -131,7 +131,7 @@
#define _GAME_CONFIG_ATTACK_NOTIFICATION_TIME_LIMIT_LOWER 2
// Remember to change this, when the config changes!
-#define CONFIG_VERSION 000001
+#define CONFIG_VERSION 1
class GameConfig
{
Index: netpanzer/src/NetPanzer/Interfaces/GameManager.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.47
netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.48
--- netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.47 Sat Sep 20
13:52:46 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameManager.cpp Sat Sep 20 18:40:15 2003
@@ -736,7 +736,7 @@
try {
if(!FileSystem::exists("config"))
FileSystem::mkdir("config");
- GameConfig::initialize("config/netpanzer.cfg");
+ GameConfig::initialize("config/netpanzer.xml");
initializeSoundSubSystem();
initializeVideoSubSystem();
loadGameData();