Back to index

supertuxkart  0.5+dfsg1
cup_data.cpp
Go to the documentation of this file.
00001 //  $Id: cup_data.cpp 2111 2008-05-31 07:04:30Z cosmosninja $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2004-2005 Ingo Ruhnke <grumbel@gmx.de>
00005 //  Copyright (C) 2006      Joerg Henrichs, Ingo Ruhnke <grumbel@gmx.de>
00006 //
00007 //  This program is free software; you can redistribute it and/or
00008 //  modify it under the terms of the GNU General Public License
00009 //  as published by the Free Software Foundation; either version 2
00010 //  of the License, or (at your option) any later version.
00011 //
00012 //  This program is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU General Public License
00018 //  along with this program; if not, write to the Free Software
00019 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 
00021 #include <iostream>
00022 #include <stdexcept>
00023 #include "file_manager.hpp"
00024 #include "lisp/parser.hpp"
00025 #include "lisp/lisp.hpp"
00026 #include "cup_data.hpp"
00027 
00028 CupData::CupData(const std::string filename_)
00029 {
00030     m_filename = filename_;
00031     const lisp::Lisp* lisp = 0;
00032     try
00033     {
00034         lisp::Parser parser;
00035         lisp = parser.parse(file_manager->getConfigFile(m_filename));
00036 
00037         lisp = lisp->getLisp("supertuxkart-cup");
00038         if(!lisp)
00039         {
00040             throw std::runtime_error("No supertuxkart-cup node");
00041         }
00042 
00043         lisp->get      ("name",        m_name        );
00044         lisp->get      ("description", m_description );
00045         lisp->get      ("herring",     m_herring_style);
00046         lisp->getVector("tracks",      m_tracks      );
00047         lisp->getVector("laps",        m_laps        );
00048     }
00049     catch(std::exception& err)
00050     {
00051         fprintf(stderr, "Error while reading cup file '%s'\n", filename_.c_str());
00052         fprintf(stderr, err.what());
00053         fprintf(stderr, "\n");
00054     }
00055 
00056     delete lisp;
00057 }
00058 
00059 /* EOF */