Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4032 in orxonox.OLD


Ignore:
Timestamp:
May 4, 2005, 1:57:55 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: orxonox now starts the Gui by default, and also if orxonox shuts down unexpected

Location:
orxonox/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/gui/gui/orxonox_gui_gtk.cc

    r4031 r4032  
    5050#endif /* HAVE_GTHREAD */
    5151  gtk_init(&argc, &argv);
    52 
    5352#include "rc"
    5453  gtk_rc_parse_string( rc_string );
  • orxonox/trunk/src/orxonox.cc

    r4010 r4032  
    3737
    3838#include <string.h>
     39
    3940int verbose = 4;
    4041
     
    4647Orxonox::Orxonox ()
    4748{
     49  ResourceManager::touchFile("~/.orxonox/orxonox.lock");
     50
    4851  pause = false;
    4952}
     
    6164  delete ResourceManager::getInstance(); // deletes the Resource Manager
    6265  delete TextEngine::getInstance();
     66
     67  ResourceManager::deleteFile("~/.orxonox/orxonox.lock");
    6368}
    6469
     
    302307
    303308  int i;
    304   for(i = 0; i < argc; ++i)
     309  for(i = 1; i < argc; ++i)
    305310    {
    306311      if(! strcmp( "--help", argv[i])) return startHelp();
    307312      else if(! strcmp( "--benchmark", argv[i])) return startBenchmarks();
     313     
     314      else PRINTF(2)("Orxonox does not understand the arguments %s\n", argv[i]);
    308315    }
    309316
    310   PRINTF(2)("Orxonox does not understand the arguments");
    311317  return startOrxonox(argc, argv);
    312318}
     
    316322int startHelp()
    317323{
    318   printf("orxonox: starts the orxonox game - rules\n");
    319   printf("usage: orxonox [arg]\n\n");
    320   printf("valid options:\n");
    321   printf(" --benchmark\tstarts the orxonox benchmark\n");
    322   printf(" --help \tshows this menu\n");
     324  PRINT(0)("orxonox: starts the orxonox game - rules\n");
     325  PRINT(0)("usage: orxonox [arg]\n\n");
     326  PRINT(0)("valid options:\n");
     327  PRINT(0)(" --benchmark\tstarts the orxonox benchmark\n");
     328  PRINT(0)(" --help \tshows this menu\n");
    323329}
    324330
     
    326332int startOrxonox(int argc, char** argv)
    327333{
    328   printf(">>> Starting Orxonox <<<\n");
     334  // checking for existence of the configuration-files
     335  if (!ResourceManager::isFile("~/.orxonox/orxonox.conf") || ResourceManager::isFile("~/.orxonox/orxonox.lock"))
     336    {
     337      if (ResourceManager::isFile("~/.orxonox/orxonox.lock"))
     338        ResourceManager::deleteFile("~/.orxonox/orxonox.lock");
     339      if (system("./orxonoxGui --gui") == -1)
     340        system ("orxonoxGui --gui");
     341      return 0;
     342    }
     343 
     344  PRINT(0)(">>> Starting Orxonox <<<\n");
    329345  Orxonox *orx = Orxonox::getInstance();
    330346 
    331347  if((*orx).init(argc, argv) == -1)
    332348    {
    333       printf("! Orxonox initialization failed\n");
     349      PRINTF(1)("! Orxonox initialization failed\n");
    334350      return -1;
    335351    }
  • orxonox/trunk/src/util/resource_manager.cc

    r3983 r4032  
    510510    }
    511511
    512   stat(tmpDirName, &status);
    513   if (status.st_mode & (S_IFDIR
     512  if(!stat(tmpDirName, &status))
     513    {
     514      if (status.st_mode & (S_IFDIR
    514515#ifndef __WIN32__
    515                         | S_IFLNK
     516                            | S_IFLNK
    516517#endif
    517                         ))
    518     {
    519       delete tmpDirName;
    520       return true;
    521     }
    522   else
    523     {
    524       delete tmpDirName;
    525       return false;
    526     }
     518                            ))
     519        {
     520          delete tmpDirName;
     521          return true;
     522        }
     523      else
     524        {
     525          delete tmpDirName;
     526          return false;
     527        }
     528    }
     529  else
     530    return false;
    527531}
    528532
     
    534538bool ResourceManager::isFile(const char* fileName)
    535539{
     540  char* tmpFileName = ResourceManager::homeDirCheck(fileName);
     541  // actually checks the File
    536542  struct stat status;
    537   stat(fileName, &status);
    538   if (status.st_mode & (S_IFREG
     543  if (!stat(tmpFileName, &status))
     544    {
     545      if (status.st_mode & (S_IFREG
    539546#ifndef __WIN32__
    540                         | S_IFLNK
     547                            | S_IFLNK
    541548#endif
    542                         ))
    543     return true;
    544   else
    545     return false;
    546 }
     549                            ))
     550        {
     551          delete tmpFileName;
     552          return true;
     553        }
     554      else
     555        {
     556          delete tmpFileName;
     557          return false;
     558        }
     559    }
     560  else
     561    {
     562      delete tmpFileName;
     563      return false;
     564    }
     565}
     566
     567bool ResourceManager::touchFile(const char* fileName)
     568{
     569  char* tmpName = ResourceManager::homeDirCheck(fileName);
     570
     571  FILE* stream;
     572  if( (stream = fopen (tmpName, "w")) == NULL)
     573    {
     574      PRINTF(1)("could not open %s fro writing\n", fileName);
     575      return false;
     576    }
     577   
     578  delete tmpName;
     579}
     580
     581bool ResourceManager::deleteFile(const char* fileName)
     582{
     583  char* tmpName = ResourceManager::homeDirCheck(fileName);
     584  unlink(tmpName);
     585  delete tmpName;
     586}
     587
     588char* ResourceManager::homeDirCheck(const char* name)
     589{
     590  char* retName;
     591  if (!strncmp(name, "~/", 2))
     592    {
     593      char tmpFileName[500];
     594#ifdef __WIN32__
     595      strcpy(tmpFileName, getenv("USERPROFILE"));
     596#else
     597      strcpy(tmpFileName, getenv("HOME"));
     598#endif
     599      retName = new char[strlen(tmpFileName)+strlen(name)];
     600      sprintf(retName, "%s%s", tmpFileName, name+1);
     601    }
     602  else
     603    {
     604      retName = new char[strlen(name)+1];
     605      strcpy(retName, name);
     606    }
     607  return retName;
     608}
     609
     610
    547611
    548612/**
  • orxonox/trunk/src/util/resource_manager.h

    r3983 r4032  
    7878  // utility functions of this class
    7979  static bool isDir(const char* directory);
    80   static bool isFile(const char* directory);
     80  static bool isFile(const char* fileName);
     81  static bool touchFile(const char* fileName);
     82  static bool deleteFile(const char* fileName);
    8183
    8284 private:
     
    9294  Resource* locateResourceByPointer(const void* pointer);
    9395 
     96  static char* homeDirCheck(const char* name);
    9497};
    9598
Note: See TracChangeset for help on using the changeset viewer.