**********************************************************

** Big Maps Projects code (incl. Multiplayer v1.5 **
**********************************************************
- Merged Big Maps Project code from BMP+MP trunk (Revision: 3340)
o Complete SVN Revision history: https://81.169.133.124/source/ja2/branches/Wanne/JA2%201.13%20MP
- Before THIS merge, I made a branch of the existing 1.13 source
o SVN Branch: https://81.169.133.124/source/ja2/branches/JA2_rev.3336/src
- Removed old VS 6.0 and VS 2003 project and solutions files, because compilation is broken long time ago
- I will add VS 2010 projects and solution file in the next few days

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@3341 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2010-02-28 18:38:52 +00:00
parent a98c44ac78
commit 14750c6903
461 changed files with 23615 additions and 120157 deletions
+6 -6
View File
@@ -11,30 +11,30 @@ CHPTimer::~CHPTimer()
{
}
void CHPTimer::StartTimer()
void CHPTimer::startTimer()
{
#ifdef WIN32
QueryPerformanceCounter(&tick);
#elif LINUX
#elif __linux__
gettimeofday(&t1,0);
#endif
}
void CHPTimer::StopTimer()
void CHPTimer::stopTimer()
{
#ifdef WIN32
QueryPerformanceCounter(&tick2);
#elif LINUX
#elif __linux__
gettimeofday(&t2,0);
#endif
}
double CHPTimer::GetElapsedTimeInSeconds()
double CHPTimer::getElapsedTimeInSeconds()
{
#ifdef WIN32
return (double)(tick2.QuadPart - tick.QuadPart)/(double)ticksPerSecond.QuadPart;
#elif LINUX
#elif __linux__
return (double)(t2.tv_usec - t1.tv_usec)/1000000.0;
#endif
}
+5 -5
View File
@@ -3,7 +3,7 @@
#ifdef WIN32
#include <Windows.h>
#elif LINUX
#elif __linux__
#include <sys/time.h>
#endif
@@ -13,15 +13,15 @@ public:
CHPTimer();
~CHPTimer();
void StartTimer();
void StopTimer();
void startTimer();
void stopTimer();
double GetElapsedTimeInSeconds();
double getElapsedTimeInSeconds();
protected:
#ifdef WIN32
LARGE_INTEGER ticksPerSecond;
LARGE_INTEGER tick,tick2;
#elif LINUX
#elif __linux__
timeval t1,t2;
#endif
};
+24 -25
View File
@@ -5,25 +5,20 @@
#include "../File/vfs_file.h"
#include <sstream>
CProf* g_Profiler = NULL;
class CProfileStarter
{
public:
CProfileStarter()
{
CProf::GetProf();
CProf::getProf();
}
};
static CProfileStarter starter;
CProf* CProf::GetProf()
CProf& CProf::getProf()
{
if(!g_Profiler)
{
g_Profiler = new CProf();
}
return g_Profiler;
static CProf* _prof = new CProf;
return *_prof;
}
CProf::CProf()
@@ -32,7 +27,7 @@ CProf::CProf()
_nextMarker = 0;
}
void CProf::Clear()
void CProf::clear()
{
for(unsigned int i = 0; i < _nextMarker; ++i)
{
@@ -46,27 +41,27 @@ void CProf::Clear()
}
CProf::tMarkerID CProf::RegisterMarker(const char *marker)
CProf::tMarkerID CProf::registerMarker(const char *marker)
{
m_vMarker[_nextMarker].markername = marker;
return _nextMarker++;
}
void CProf::StartMarker(tMarkerID id)
void CProf::startMarker(tMarkerID id)
{
m_vMarker[id].timer.StartTimer();
m_vMarker[id].timer.startTimer();
}
void CProf::StopMarker(tMarkerID id, bool success)
void CProf::stopMarker(tMarkerID id, bool success)
{
m_vMarker[id].timer.StopTimer();
m_vMarker[id].time += m_vMarker[id].timer.GetElapsedTimeInSeconds();
m_vMarker[id].timer.stopTimer();
m_vMarker[id].time += m_vMarker[id].timer.getElapsedTimeInSeconds();
m_vMarker[id].call_count++;
if(success) m_vMarker[id].success_count++;
else m_vMarker[id].fail_count++;
}
inline std::string MultChar(std::string::value_type c, unsigned int multiplicity)
inline std::string multChar(std::string::value_type c, unsigned int multiplicity)
{
std::string s;
s.resize(multiplicity);
@@ -88,16 +83,16 @@ inline long double oneDigit(long double number)
return (temp / 10.0);
}
bool CProf::PrintProfilerState(vfs::Path const& file)
bool CProf::printProfilerState(vfs::Path const& file)
{
vfs::CFile oFile(file);
if(!oFile.OpenWrite(true,true))
if(!oFile.openWrite(true,true))
{
return false;
}
// get largest value
long double max_time = 0;
unsigned int max_prefix = 0;
std::string::size_type max_prefix = 0;
for(unsigned int i=0; i<m_vMarker.size(); ++i)
{
if(m_vMarker[i].time > max_time)
@@ -122,7 +117,7 @@ bool CProf::PrintProfilerState(vfs::Path const& file)
if(m_vMarker[i].markername.length() < WIDTH)
{
unsigned int space = WIDTH - m_vMarker[i].markername.length();
line << m_vMarker[i].markername << MultChar(' ',space) << " | ";
line << m_vMarker[i].markername << multChar(' ',space) << " | ";
}
else
{
@@ -134,15 +129,19 @@ bool CProf::PrintProfilerState(vfs::Path const& file)
ld_success = perCent(m_vMarker[i].success_count,m_vMarker[i].call_count);
ld_failure = perCent(m_vMarker[i].fail_count,m_vMarker[i].call_count);
line << "[" << oneDigit(ld_success) << "|" << oneDigit(ld_failure) << "] "
<< MultChar('*', num_stars) << MultChar(' ', WIDTH - num_stars) << " | ";
<< multChar('*', num_stars) << multChar(' ', WIDTH - num_stars) << " | ";
}
line << "C: " << m_vMarker[i].call_count << ", T: " << m_vMarker[i].time << std::endl;
//line << std::endl;
}
vfs::UInt32 written;
std::string useless_copy = line.str();
oFile.Write(useless_copy.c_str(), useless_copy.length()*sizeof(std::string::value_type),written);
oFile.Close();
oFile.write(useless_copy.c_str(), (vfs::size_t)(useless_copy.length()*sizeof(std::string::value_type)));
oFile.close();
return true;
}
void DumpProfileState(vfs::Path const& path)
{
CProf::getProf().printProfilerState(path);
}
+35 -13
View File
@@ -3,16 +3,17 @@
#include "HPTimer.h"
#include "../vfs_types.h"
#include "../vfs_path.h"
#include <string>
#include <vector>
#define DO_PROFILE 1
#if DO_PROFILE
#define REGISTERMARKER(id,name) static CProf::tMarkerID id = g_Profiler->RegisterMarker(name)
#define STARTMARKER(id) (g_Profiler->StartMarker(id))
#define STOPMARKER(id,success) (g_Profiler->StopMarker(id,success))
#define REGISTERMARKER(id,name) static CProf::tMarkerID id = CProf::getProf().registerMarker(name)
#define STARTMARKER(id) (CProf::getProf().startMarker(id))
#define STOPMARKER(id,success) (CProf::getProf().stopMarker(id,success))
#define DUMPPROFILERSTATSTOFILE(file) if(g_Profiler){g_Profiler->PrintProfilerState(file);}
#define DUMPPROFILERSTATSTOFILE(file) CProf::getProf().printProfilerState(file)
#else
#define REGISTERMARKER(id,name)
#define STARTMARKER(id)
@@ -22,20 +23,20 @@
#endif
class CProf
class VFS_API CProf
{
public:
typedef unsigned int tMarkerID;
static CProf* GetProf();
static CProf& getProf();
void Clear();
void clear();
tMarkerID RegisterMarker(const char *marker);
tMarkerID registerMarker(const char *marker);
void StartMarker(tMarkerID id);
void StopMarker(tMarkerID id, bool success);
void startMarker(tMarkerID id);
void stopMarker(tMarkerID id, bool success);
bool PrintProfilerState(vfs::Path const& file);
bool printProfilerState(vfs::Path const& file);
private:
CProf();
@@ -43,16 +44,37 @@ private:
{
MARKER() : call_count(0), success_count(0), fail_count(0), time(0.0) {};
std::string markername;
long double time;
unsigned long call_count;
unsigned long success_count;
unsigned long fail_count;
long double time;
CHPTimer timer;
};
std::vector<MARKER> m_vMarker;
unsigned int _nextMarker;
};
extern CProf* g_Profiler;
class ProfileMarker
{
public:
ProfileMarker(CProf::tMarkerID id, bool default_exit=true)
: _id(id), _exit_success(default_exit)
{
STARTMARKER(_id);
}
~ProfileMarker()
{
STOPMARKER(_id,_exit_success);
}
void exit(bool success)
{
_exit_success = success;
}
private:
CProf::tMarkerID _id;
bool _exit_success;
};
VFS_API void DumpProfileState(vfs::Path const& path);
#endif // _PROF_H_