Store levels edited by the user in $HOME
[kball.git] / src / mytracer.cpp
blob66827d5a3544d4c5e731d6fbb1e04906a8f3236a
1 // ------------------------------------------------------------------
2 // mytracer.cpp
3 // ------------------------------------------------------------------
4 // This implements a tracer for debugging the game
5 // Basically, it records events on disk, so we can trace where the hell
6 // the bastard is crashing!
7 // ------------------------------------------------------------------
8 // Developed By Kronoman - Copyright (c) 2004
9 // In loving memory of my father
10 // ------------------------------------------------------------------
12 #include "mytracer.h"
14 bool CMyTracer::DISABLE_TRACE = false;
17 CMyTracer::CMyTracer()
19 // nothing to do
22 CMyTracer::~CMyTracer()
24 // nothing to do
27 void CMyTracer::add(string txt)
29 if (DISABLE_TRACE) return;
31 FILE *fp;
32 fp = fopen(TRACE_SAVE_IN_FILE, "a");
33 if (fp == NULL) return; // crap! can't save
35 fprintf(fp,"%s\n", txt.c_str());
36 fclose(fp);
39 void CMyTracer::add(const char *msg, ...)
41 if (DISABLE_TRACE) return;
43 char buf[4096];
45 /* parse the variable parameters */
46 va_list ap;
47 va_start(ap, msg);
48 vsprintf(buf, msg, ap); // this is ANSI, POSIX, I hope... :O
49 va_end(ap);
51 this->add(string(buf));
54 void CMyTracer::reset()
56 if (DISABLE_TRACE) return;
58 FILE *fp;
59 fp = fopen(TRACE_SAVE_IN_FILE, "w");
60 if (fp == NULL) return;
62 fclose(fp);