mirror of
https://github.com/glest/glest-source.git
synced 2025-08-23 08:22:50 +02:00
added more debugging for error conditions
This commit is contained in:
@@ -186,6 +186,7 @@ private:
|
||||
struct Data{
|
||||
int8 messageType;
|
||||
uint8 commandCount;
|
||||
//int8 commandCount;
|
||||
int32 frameCount;
|
||||
NetworkCommand commands[maxCommandCount];
|
||||
};
|
||||
@@ -216,7 +217,7 @@ public:
|
||||
|
||||
class NetworkMessageText: public NetworkMessage{
|
||||
private:
|
||||
static const int maxStringSize= 64;
|
||||
static const int maxStringSize= 128;
|
||||
|
||||
private:
|
||||
struct Data{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
||||
// Copyright (C) 2001-2008 Martio Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
@@ -43,6 +43,8 @@ CommandClass CommandType::getClass() const{
|
||||
}
|
||||
|
||||
void CommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
this->id= id;
|
||||
name= n->getChild("name")->getAttribute("value")->getRestrictedValue();
|
||||
|
||||
@@ -66,6 +68,8 @@ void CommandType::load(int id, const XmlNode *n, const string &dir, const TechTr
|
||||
string name= upgradeReqNode->getAttribute("name")->getRestrictedValue();
|
||||
upgradeReqs.push_back(ft->getUpgradeType(name));
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
@@ -336,6 +340,8 @@ void BuildCommandType::update(UnitUpdater *unitUpdater, Unit *unit) const{
|
||||
}
|
||||
|
||||
void BuildCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
CommandType::load(id, n, dir, tt, ft, ut);
|
||||
|
||||
//move
|
||||
@@ -379,6 +385,8 @@ void BuildCommandType::load(int id, const XmlNode *n, const string &dir, const T
|
||||
builtSounds[i]= sound;
|
||||
}
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
string BuildCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
|
||||
@@ -492,6 +500,8 @@ void RepairCommandType::update(UnitUpdater *unitUpdater, Unit *unit) const{
|
||||
|
||||
void RepairCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut){
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
CommandType::load(id, n, dir, tt, ft, ut);
|
||||
|
||||
//move
|
||||
@@ -508,6 +518,8 @@ void RepairCommandType::load(int id, const XmlNode *n, const string &dir, const
|
||||
const XmlNode *unitNode= unitsNode->getChild("unit", i);
|
||||
repairableUnits.push_back(ft->getUnitType(unitNode->getAttribute("name")->getRestrictedValue()));
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
string RepairCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
|
||||
@@ -558,7 +570,9 @@ void ProduceCommandType::update(UnitUpdater *unitUpdater, Unit *unit) const{
|
||||
}
|
||||
|
||||
void ProduceCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut){
|
||||
CommandType::load(id, n, dir, tt, ft, ut);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
CommandType::load(id, n, dir, tt, ft, ut);
|
||||
|
||||
//produce
|
||||
string skillName= n->getChild("produce-skill")->getAttribute("value")->getRestrictedValue();
|
||||
@@ -566,6 +580,8 @@ void ProduceCommandType::load(int id, const XmlNode *n, const string &dir, const
|
||||
|
||||
string producedUnitName= n->getChild("produced-unit")->getAttribute("name")->getRestrictedValue();
|
||||
producedUnit= ft->getUnitType(producedUnitName);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
string ProduceCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
|
||||
@@ -671,7 +687,9 @@ void MorphCommandType::update(UnitUpdater *unitUpdater, Unit *unit) const{
|
||||
}
|
||||
|
||||
void MorphCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut){
|
||||
CommandType::load(id, n, dir, tt, ft, ut);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
CommandType::load(id, n, dir, tt, ft, ut);
|
||||
|
||||
//morph skill
|
||||
string skillName= n->getChild("morph-skill")->getAttribute("value")->getRestrictedValue();
|
||||
@@ -683,6 +701,8 @@ void MorphCommandType::load(int id, const XmlNode *n, const string &dir, const T
|
||||
|
||||
//discount
|
||||
discount= n->getChild("discount")->getAttribute("value")->getIntValue();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
string MorphCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
||||
// Copyright (C) 2001-2008 Martio Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
@@ -36,6 +36,8 @@ FactionType::FactionType(){
|
||||
//load a faction, given a directory
|
||||
void FactionType::load(const string &dir, const TechTree *techTree, Checksum* checksum){
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
name= lastDir(dir);
|
||||
|
||||
Logger::getInstance().add("Faction type: "+ formatString(name), true);
|
||||
@@ -117,6 +119,8 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
|
||||
music= new StrSound();
|
||||
music->open(dir+"/"+musicNode->getAttribute("path")->getRestrictedValue());
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
FactionType::~FactionType(){
|
||||
@@ -131,6 +135,12 @@ const UnitType *FactionType::getUnitType(const string &name) const{
|
||||
return &unitTypes[i];
|
||||
}
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
|
||||
for(int i=0; i<unitTypes.size();i++){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName().c_str());
|
||||
}
|
||||
|
||||
throw runtime_error("Unit not found: "+name);
|
||||
}
|
||||
|
||||
@@ -140,6 +150,12 @@ const UpgradeType *FactionType::getUpgradeType(const string &name) const{
|
||||
return &upgradeTypes[i];
|
||||
}
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
|
||||
for(int i=0; i<upgradeTypes.size();i++){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),i,upgradeTypes[i].getName().c_str());
|
||||
}
|
||||
|
||||
throw runtime_error("Upgrade not found: "+name);
|
||||
}
|
||||
|
||||
|
@@ -100,6 +100,8 @@ void UnitType::preLoad(const string &dir){
|
||||
|
||||
void UnitType::load(int id,const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum){
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
this->id= id;
|
||||
string path;
|
||||
|
||||
@@ -382,6 +384,8 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, const Fa
|
||||
catch(const exception &e){
|
||||
throw runtime_error("Error loading UnitType: " + path + "\n" + e.what());
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
// ==================== get ====================
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
||||
// Copyright (C) 2001-2008 Martio Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
@@ -48,6 +48,8 @@ void UpgradeType::preLoad(const string &dir){
|
||||
}
|
||||
|
||||
void UpgradeType::load(const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
string path;
|
||||
|
||||
Logger::getInstance().add("Upgrade type: "+ formatString(name), true);
|
||||
@@ -123,6 +125,8 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, const Factio
|
||||
catch(const exception &e){
|
||||
throw runtime_error("Error loading UpgradeType: "+ dir + "\n" +e.what());
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
string UpgradeType::getReqDesc() const{
|
||||
|
@@ -332,6 +332,8 @@ bool World::toRenderUnit(const Unit *unit) const{
|
||||
}
|
||||
|
||||
void World::createUnit(const string &unitName, int factionIndex, const Vec2i &pos){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] unitName [%s] factionIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,unitName.c_str(),factionIndex);
|
||||
|
||||
if(factionIndex<factions.size()){
|
||||
Faction* faction= &factions[factionIndex];
|
||||
const FactionType* ft= faction->getType();
|
||||
@@ -352,6 +354,8 @@ void World::createUnit(const string &unitName, int factionIndex, const Vec2i &po
|
||||
{
|
||||
throw runtime_error("Invalid faction index in createUnitAtPosition: " + intToStr(factionIndex));
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void World::giveResource(const string &resourceName, int factionIndex, int amount){
|
||||
|
@@ -47,8 +47,6 @@
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
|
||||
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Platform;
|
||||
|
@@ -84,7 +84,7 @@ void SystemFlags::Close() {
|
||||
currentDebugLog.fileStream->close();
|
||||
}
|
||||
delete currentDebugLog.fileStream;
|
||||
delete currentDebugLog.mutex;
|
||||
//delete currentDebugLog.mutex;
|
||||
}
|
||||
currentDebugLog.fileStream = NULL;
|
||||
currentDebugLog.fileStreamOwner = false;
|
||||
@@ -143,7 +143,7 @@ void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) {
|
||||
currentDebugLog2.fileStream != NULL) {
|
||||
currentDebugLog.fileStream = currentDebugLog2.fileStream;
|
||||
currentDebugLog.fileStreamOwner = false;
|
||||
currentDebugLog.mutex = currentDebugLog2.mutex;
|
||||
//currentDebugLog.mutex = currentDebugLog2.mutex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -189,17 +189,17 @@ void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) {
|
||||
currentDebugLog.fileStream = new std::ofstream();
|
||||
currentDebugLog.fileStream->open(debugLog.c_str(), ios_base::out | ios_base::trunc);
|
||||
currentDebugLog.fileStreamOwner = true;
|
||||
currentDebugLog.mutex = new Mutex();
|
||||
//currentDebugLog.mutex = new Mutex();
|
||||
}
|
||||
|
||||
printf("Opening logfile [%s] type = %d, currentDebugLog.fileStreamOwner = %d\n",debugLog.c_str(),type, currentDebugLog.fileStreamOwner);
|
||||
|
||||
currentDebugLog.mutex->p();
|
||||
//currentDebugLog.mutex->p();
|
||||
|
||||
(*currentDebugLog.fileStream) << "Starting Mega-Glest logging for type: " << type << "\n";
|
||||
(*currentDebugLog.fileStream).flush();
|
||||
|
||||
currentDebugLog.mutex->v();
|
||||
//currentDebugLog.mutex->v();
|
||||
}
|
||||
|
||||
//printf("Logfile is open [%s]\n",SystemFlags::debugLogFile);
|
||||
@@ -208,12 +208,12 @@ void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) {
|
||||
|
||||
assert(currentDebugLog.fileStream != NULL);
|
||||
|
||||
currentDebugLog.mutex->p();
|
||||
//currentDebugLog.mutex->p();
|
||||
|
||||
(*currentDebugLog.fileStream) << "[" << szBuf2 << "] " << szBuf;
|
||||
(*currentDebugLog.fileStream).flush();
|
||||
|
||||
currentDebugLog.mutex->v();
|
||||
//currentDebugLog.mutex->v();
|
||||
}
|
||||
// output to console
|
||||
else {
|
||||
|
Reference in New Issue
Block a user