/**********************************************************************
 *
 *   FreeDoko a Doppelkopf-Game
 *    
 *   Copyright (C) 2001-2005  by Diether Knof and Borg Enders
 *
 *   This program is free software; you can redistribute it and/or 
 *   modify it under the terms of the GNU General Public License as 
 *   published by the Free Software Foundation; either version 2 of 
 *   the License, or (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details. 
 *   You can find this license in the file 'gpl.txt'.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 *   MA  02111-1307  USA
 *
 *  Contact:
 *    Diether Knof dknof@gmx.de
 *    Borg Enders  borg@borgsoft.de
 *
 ********************************************************************/

#include "constants.h"

#include "bug_report.h"
#include "../party/party.h"
#include "../ui/ui.h"

#include "translator.h"

OS_NS::BugReport bug_report;

/**
 **
 ** create a bug report and informs the user
 **
 ** @param	message	the message for the bug report
 **
 ** @return	-
 **
 ** @version	0.5.4
 **
 ** @author	Diether Knof
 **
 **/
void
create_assertion_bug_report(string const& message)
{
  DEBUG_CALLING(INFO_BUG_REPORT,
		"create_assertion_bug_report(message)");

  // always ouput the error message on stderr
  cerr << message << '\n';

  static bool already_running = false;
  if (already_running) {
    cerr << ::translator("_bug found: automatic report creation failed_");

    cerr << ::translator("Trying to output the seed: %useed%",
		       ::party.seed())
      << endl;
    cerr << ::translator("Trying to output the startplayer: %ustartplayer%",
		       ::party.startplayer())
      << endl;

#ifdef ASSERTION_GENERATES_SEGFAULT
    {
      cerr << '\n'
	<< ::translator("Creating segmentation fault.") << endl;
      int const n = *(static_cast<int*>(NULL));
      (void)(n);
    }
#endif // #ifdef ASSERTION_GENERATES_SEGFAULT

    exit(EXIT_FAILURE);
  } // if (already_running)
  already_running = true;

  ::ui->error(message);

  already_running = false;

  DEBUG_RETURNING(VOID,
		  INFO_BUG_REPORT,
		  "create_assertion_bug_report(message)");
} // void create_assertion_bug_report(string const& message)

