[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netPanzer-CVS] netpanzer/src Lib/Exception.cpp Lib/Log.cpp Lib...
From: |
Ivo Danihelka |
Subject: |
[netPanzer-CVS] netpanzer/src Lib/Exception.cpp Lib/Log.cpp Lib... |
Date: |
Fri, 19 Sep 2003 20:05:29 -0400 |
CVSROOT: /cvsroot/netpanzer
Module name: netpanzer
Branch:
Changes by: Ivo Danihelka <address@hidden> 03/09/19 20:05:29
Modified files:
src/Lib : Exception.cpp Log.cpp Log.hpp
src/Lib/2D : PackedSurface.cpp Surface.cpp
src/NetPanzer/Core: main.cpp
src/NetPanzer/Interfaces: GameManager.cpp GameManager.hpp
Log message:
New command line option -g --debug.
Fixed typo loadAll .til/.bmp
Fixed use of uninitialised value for alloc memory.
Fixed dedicated server game type choose.
MapSelectionView::loadMaps still stay buggy.
Patches:
Index: netpanzer/src/Lib/2D/PackedSurface.cpp
diff -u netpanzer/src/Lib/2D/PackedSurface.cpp:1.13
netpanzer/src/Lib/2D/PackedSurface.cpp:1.14
--- netpanzer/src/Lib/2D/PackedSurface.cpp:1.13 Fri Sep 19 11:03:14 2003
+++ netpanzer/src/Lib/2D/PackedSurface.cpp Fri Sep 19 20:05:29 2003
@@ -202,8 +202,8 @@
}
if (version > CURRENT_PAK_VERSION) {
delete file;
- throw Exception("PAK file version of '%s' is newer(%d) than the .exe
- (%d) you are using, which only supports up to version",
+ throw Exception("PAK file version of '%s' is newer(%d) than "
+ "the currently supported version(%d)",
filename, version, CURRENT_PAK_VERSION);
}
file->read(&pix, sizeof(pix), 1);
Index: netpanzer/src/Lib/2D/Surface.cpp
diff -u netpanzer/src/Lib/2D/Surface.cpp:1.24
netpanzer/src/Lib/2D/Surface.cpp:1.25
--- netpanzer/src/Lib/2D/Surface.cpp:1.24 Fri Sep 19 11:22:30 2003
+++ netpanzer/src/Lib/2D/Surface.cpp Fri Sep 19 20:05:29 2003
@@ -2843,10 +2843,10 @@
Surface tempSurface;
iXY maxSize;
for(char** file = list; *file != 0; file++) {
- std::string name = path;
- name += *file;
- if(name.find(".til") != std::string::npos) {
- filenames.push_back(name);
+ std::string name = path;
+ name += *file;
+ if(name.find(".til") != std::string::npos) {
+ filenames.push_back(name);
// Get the max image size.
if (!tempSurface.loadTIL(name.c_str())) {
@@ -2858,7 +2858,7 @@
if (maxSize.y < tempSurface.getPix().y) {
maxSize.y = tempSurface.getPix().y;
}
- }
+ }
}
FileSystem::freeList(list);
@@ -2896,12 +2896,12 @@
std::vector<std::string> filenames;
Surface tempSurface;
- iXY maxSize;
+ iXY maxSize(0, 0);
for(char** file = list; *file != 0; file++) {
- std::string name = path;
- name += *file;
- if(name.find(".til") != std::string::npos) {
- filenames.push_back(name);
+ std::string name = path;
+ name += *file;
+ if(name.find(".bmp") != std::string::npos) {
+ filenames.push_back(name);
// Get the max image size.
tempSurface.loadBMP(name.c_str());
@@ -2911,7 +2911,7 @@
if (maxSize.y < tempSurface.getPix().y) {
maxSize.y = tempSurface.getPix().y;
}
- }
+ }
}
FileSystem::freeList(list);
Index: netpanzer/src/Lib/Exception.cpp
diff -u netpanzer/src/Lib/Exception.cpp:1.3 netpanzer/src/Lib/Exception.cpp:1.4
--- netpanzer/src/Lib/Exception.cpp:1.3 Tue Sep 16 16:16:09 2003
+++ netpanzer/src/Lib/Exception.cpp Fri Sep 19 20:05:28 2003
@@ -36,7 +36,7 @@
Exception::Exception(const Exception& other)
{
size_t len = strlen(other.message);
- message = new char[len];
+ message = new char[len+1];
memcpy(message, other.message, len+1);
}
Index: netpanzer/src/Lib/Log.cpp
diff -u netpanzer/src/Lib/Log.cpp:1.6 netpanzer/src/Lib/Log.cpp:1.7
--- netpanzer/src/Lib/Log.cpp:1.6 Wed Sep 17 20:41:59 2003
+++ netpanzer/src/Lib/Log.cpp Fri Sep 19 20:05:28 2003
@@ -21,10 +21,11 @@
#include <stdarg.h>
#include <errno.h>
#include <string.h>
+#include <string>
#include "Log.hpp"
#ifdef DO_LOGGING
-Logger logger;
+Logger LOGGER;
#endif
// like syslog levels
@@ -71,8 +72,10 @@
{
va_list ap;
+ std::string buffer("DEBUG: ");
+ buffer.append(fmt);
va_start(ap, fmt);
- log(Logger::LEVEL_DEBUG, fmt, ap);
+ log(Logger::LEVEL_DEBUG, buffer.c_str(), ap);
va_end(ap);
}
//-----------------------------------------------------------------
Index: netpanzer/src/Lib/Log.hpp
diff -u netpanzer/src/Lib/Log.hpp:1.6 netpanzer/src/Lib/Log.hpp:1.7
--- netpanzer/src/Lib/Log.hpp:1.6 Thu Sep 18 13:44:17 2003
+++ netpanzer/src/Lib/Log.hpp Fri Sep 19 20:05:28 2003
@@ -32,8 +32,8 @@
Logger();
~Logger();
- void setLogLevel(int logLevel);
- int getLogLevel();
+ void setLogLevel(int logLevel) { m_logLevel = logLevel; }
+ int getLogLevel() { return m_logLevel; }
void debug(const char *fmt, ...)
__attribute__((format (__printf__, 2, 3)));
@@ -49,9 +49,9 @@
FILE* m_logfile;
};
-extern Logger logger;
+extern Logger LOGGER;
#ifdef DO_LOGGING
-#define LOG(x) logger.info x
+#define LOG(x) LOGGER.info x
#else
#define LOG(x)
#endif // DO_LOGGING
Index: netpanzer/src/NetPanzer/Core/main.cpp
diff -u netpanzer/src/NetPanzer/Core/main.cpp:1.7
netpanzer/src/NetPanzer/Core/main.cpp:1.8
--- netpanzer/src/NetPanzer/Core/main.cpp:1.7 Tue Sep 16 16:16:12 2003
+++ netpanzer/src/NetPanzer/Core/main.cpp Fri Sep 19 20:05:29 2003
@@ -112,16 +112,24 @@
// Parse commandline
using namespace optionmm;
command_line commandline(PACKAGE_NAME, PACKAGE_VERSION,
- "Copyright(c) 1998 Pyrosoft Inc. and others", "",
argc, argv);
+ "Copyright(c) 1998 Pyrosoft Inc. and others", "", argc, argv);
option<bool, false, false> dedicated_option('d', "dedicated",
"run as dedicated server", false);
commandline.add(&dedicated_option);
- option<int> port_option('p', "port", "run server on specific
port", 0);
+ option<int> port_option('p', "port", "run server on specific port", 0);
commandline.add(&port_option);
+ option<bool, false, false> debug_option('g', "debug",
+ "enable debug output", false);
+ commandline.add(&debug_option);
if(!commandline.process() || commandline.help() || commandline.version())
exit(0);
+
+ if (debug_option.value()) {
+ LOGGER.setLogLevel(Logger::LEVEL_DEBUG);
+ LOGGER.debug("debug option enabled");
+ }
// Initialize SDL
SDL_Init(SDL_INIT_TIMER);
Index: netpanzer/src/NetPanzer/Interfaces/GameManager.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.45
netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.46
--- netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.45 Thu Sep 18
13:44:18 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameManager.cpp Fri Sep 19 20:05:29 2003
@@ -640,16 +640,6 @@
}
// ******************************************************************
-void GameManager::dedicatedLoadGameData()
-{
- UnitProfileInterface::loadUnitProfiles();
- LoadUnitSurfaces();
- UNIT_FLAGS_SURFACE.loadAllBMPInDirectory("pics/flags/");
- if(UNIT_FLAGS_SURFACE.getFrameCount() == 0)
- throw Exception("Couldn't find any flag in pics/flags/.");
-}
-
-// ******************************************************************
bool GameManager::startGameMapLoad( char *map_file_path, unsigned long
partitions, int *result_code )
{
int check_return_code;
@@ -768,7 +758,7 @@
FileSystem::mkdir("config");
GameConfig::initialize("config/netpanzer-dedicated.cfg");
initializeSoundSubSystem(); // we load a dummy sound driver
- dedicatedLoadGameData();
+ loadGameData();
initializeGameObjects();
initializeGameLogic();
initializeNetworkSubSystem();
@@ -1424,18 +1414,18 @@
GameConfig::SetNumberUnits( units );
}
- int game_type;
+ int game_type = 1;
do {
printf( "Game Type\n" );
printf( "(1) Objective \n");
printf( "(2) Frag Limit \n" );
printf( "(3) Time Limit \n" );
- printf( "Choose : " );
+ printf( "Choose <1>: " );
fflush(stdout);
readString(input_str, 256, stdin);
sscanf( input_str, "%d", &game_type );
- } while( (game_type < 1) && (game_type > 3) );
+ } while( (game_type < 1) || (game_type > 3) );
switch( game_type ) {
case 1 : {
Index: netpanzer/src/NetPanzer/Interfaces/GameManager.hpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameManager.hpp:1.11
netpanzer/src/NetPanzer/Interfaces/GameManager.hpp:1.12
--- netpanzer/src/NetPanzer/Interfaces/GameManager.hpp:1.11 Thu Sep 18
13:44:18 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameManager.hpp Fri Sep 19 20:05:29 2003
@@ -113,7 +113,6 @@
static void dedicatedLoadGameMap( char *map_file_path );
static bool loadGameData();
- static void dedicatedLoadGameData();
static void initializeGameLogic();
static void reinitializeGameLogic();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [netPanzer-CVS] netpanzer/src Lib/Exception.cpp Lib/Log.cpp Lib...,
Ivo Danihelka <=