Beispiel #1
0
int main(int argc, char **argv)
{
    int rc;
    char buf[128];
    PHYSFS_file *f;

    if (!PHYSFS_init(argv[0]))
    {
        con_printf(CON_CRITICAL, "PHYSFS_init(): %s\n", PHYSFS_getLastError());
        return(1);
    } /* if */

    if (!PHYSFS_addToSearchPath(".", 1))
    {
        con_printf(CON_CRITICAL, "PHYSFS_addToSearchPath(): %s\n", PHYSFS_getLastError());
        PHYSFS_deinit();
        return(1);
    } /* if */

    if (!PHYSFS_setWriteDir("."))
    {
        con_printf(CON_CRITICAL, "PHYSFS_setWriteDir(): %s\n", PHYSFS_getLastError());
        PHYSFS_deinit();
        return(1);
    } /* if */

    if (!PHYSFS_mkdir("/a/b/c"))
    {
        con_printf(CON_CRITICAL, "PHYSFS_mkdir(): %s\n", PHYSFS_getLastError());
        PHYSFS_deinit();
        return(1);
    } /* if */

    if (!PHYSFS_mkdir("/a/b/C"))
    {
        con_printf(CON_CRITICAL, "PHYSFS_mkdir(): %s\n", PHYSFS_getLastError());
        PHYSFS_deinit();
        return(1);
    } /* if */

    f = PHYSFS_openWrite("/a/b/c/x.txt");
    PHYSFS_close(f);
    if (f == NULL)
    {
        con_printf(CON_CRITICAL, "PHYSFS_openWrite(): %s\n", PHYSFS_getLastError());
        PHYSFS_deinit();
        return(1);
    } /* if */

    f = PHYSFS_openWrite("/a/b/C/X.txt");
    PHYSFS_close(f);
    if (f == NULL)
    {
        con_printf(CON_CRITICAL, "PHYSFS_openWrite(): %s\n", PHYSFS_getLastError());
        PHYSFS_deinit();
        return(1);
    } /* if */

    strcpy(buf, "/a/b/c/x.txt");
    rc = PHYSFSEXT_locateCorrectCase(buf);
    if ((rc != 0) || (strcmp(buf, "/a/b/c/x.txt") != 0))
        con_printf(CON_DEBUG,"test 1 failed\n");

    strcpy(buf, "/a/B/c/x.txt");
    rc = PHYSFSEXT_locateCorrectCase(buf);
    if ((rc != 0) || (strcmp(buf, "/a/b/c/x.txt") != 0))
        con_printf(CON_DEBUG,"test 2 failed\n");

    strcpy(buf, "/a/b/C/x.txt");
    rc = PHYSFSEXT_locateCorrectCase(buf);
    if ((rc != 0) || (strcmp(buf, "/a/b/C/X.txt") != 0))
        con_printf(CON_DEBUG,"test 3 failed\n");

    strcpy(buf, "/a/b/c/X.txt");
    rc = PHYSFSEXT_locateCorrectCase(buf);
    if ((rc != 0) || (strcmp(buf, "/a/b/c/x.txt") != 0))
        con_printf(CON_DEBUG,"test 4 failed\n");

    strcpy(buf, "/a/b/c/z.txt");
    rc = PHYSFSEXT_locateCorrectCase(buf);
    if ((rc != -1) || (strcmp(buf, "/a/b/c/z.txt") != 0))
        con_printf(CON_DEBUG,"test 5 failed\n");

    strcpy(buf, "/A/B/Z/z.txt");
    rc = PHYSFSEXT_locateCorrectCase(buf);
    if ((rc != -2) || (strcmp(buf, "/a/b/Z/z.txt") != 0))
        con_printf(CON_DEBUG,"test 6 failed\n");

    con_printf(CON_DEBUG,"Testing completed.\n");
    con_printf(CON_DEBUG,"  If no errors were reported, you're good to go.\n");

    PHYSFS_delete("/a/b/c/x.txt");
    PHYSFS_delete("/a/b/C/X.txt");
    PHYSFS_delete("/a/b/c");
    PHYSFS_delete("/a/b/C");
    PHYSFS_delete("/a/b");
    PHYSFS_delete("/a");
    PHYSFS_deinit();
    return(0);
} /* main */
Beispiel #2
0
 virtual void TearDown() {
     ASSERT_NE(0, PHYSFS_deinit());
     glfwTerminate();
     window = nullptr;
 }
int main(int argc, char **argv)
{
    char *buf = NULL;
    int rc = 0;

#if (defined __MWERKS__)
    extern tSIOUXSettings SIOUXSettings;
    SIOUXSettings.asktosaveonclose = 0;
    SIOUXSettings.autocloseonquit = 1;
    SIOUXSettings.rows = 40;
    SIOUXSettings.columns = 120;
#endif

    printf("\n");

    if (!PHYSFS_init(argv[0]))
    {
        printf("PHYSFS_init() failed!\n  reason: %s.\n", PHYSFS_getLastError());
        return(1);
    } /* if */

    output_versions();
    output_archivers();

    open_history_file();

    printf("Enter commands. Enter \"help\" for instructions.\n");

    do
    {
#if (defined PHYSFS_HAVE_READLINE)
        buf = readline("> ");
#else
        int i;
        buf = (char *) malloc(512);
        memset(buf, '\0', 512);
        printf("> ");
        for (i = 0; i < 511; i++)
        {
            int ch = fgetc(stdin);
            if (ch == EOF)
            {
                strcpy(buf, "quit");
                break;
            } /* if */
            else if ((ch == '\n') || (ch == '\r'))
            {
                buf[i] = '\0';
                break;
            } /* else if */
            else if (ch == '\b')
            {
                if (i > 0)
                    i--;
            } /* else if */
            else
            {
                buf[i] = (char) ch;
            } /* else */
        } /* for */
#endif

        rc = process_command(buf);
        if (buf != NULL)
            free(buf);
    } while (rc);

    if (!PHYSFS_deinit())
        printf("PHYSFS_deinit() failed!\n  reason: %s.\n", PHYSFS_getLastError());

    if (history_file)
        fclose(history_file);

/*
    printf("\n\ntest_physfs written by ryan c. gordon.\n");
    printf(" it makes you shoot teh railgun bettar.\n");
*/

    return(0);
} /* main */
Virtual_file_system::~Virtual_file_system()
{
	PHYSFS_deinit();
}
Beispiel #5
0
int main(int argc, char ** argv)
{
    // number of arguments to skip before the script's real arguments
    int skip_arg = 1;

    // init physfs
    if(!PHYSFS_init(argv[0]))
    {
        fprintf(stderr, "physfs init failed: %s", PHYSFS_getLastError());
        return 1;
    }

    // get executable path
    const char *directory = PHYSFS_getBaseDir();
    const char *executable = basename(argv[0]);
    char *path = malloc(strlen(directory) + strlen(executable) + 1);
    strcpy(path, directory);
    strcat(path, executable);
    // try to mount the executable as an archive, on failure try to mount the
    // first argument instead
    if(!PHYSFS_mount(path, "/", 0))
    {
        skip_arg = skip_arg + 1;
        if(argc < 2 || !PHYSFS_mount(argv[1], "/", 0))
        {
            fprintf(stderr, "no archive found in the executable nor in the "
                    "first argument\n");
            return 1;
        }
    }
    free(path);

    // load lua and libraries
    lua_State *L = lua_open();
    luaL_openlibs(L);
    init_physfs_loader(L);
    init_preloaders(L);
    
    // load arguments (and pre-arguments) into a global 'arg' table
    lua_newtable(L);
    for(int i = 0; i < argc; i++)
    {
        lua_pushstring(L, argv[i]);
        lua_rawseti(L, -2, i - skip_arg + 1);
    }
    lua_setglobal(L, "arg");

    // open app, with error reporting
    lua_getglobal(L, "debug");
    lua_getfield(L, -1, "traceback");

    lua_pushcfunction(L, seed_loadfile);
    lua_pushstring(L, "init.lua");
    int error = lua_pcall(L, 1, 1, 0); // load file

    if(!error)
    {
        // load command-line arguments as function arguments
        lua_checkstack(L, argc - skip_arg);
        for(int i = 1; i <= argc - skip_arg; i++)
            lua_pushstring(L, argv[i + skip_arg - 1]);
        error = lua_pcall(L, argc - skip_arg, 0, -2);  // run the result
    }

    if(error)
        fprintf(stderr, "%s\n", lua_tostring(L, -1));

    lua_close(L);
    PHYSFS_deinit();
    return error;
}
// Destructor
j1FileSystem::~j1FileSystem()
{
	PHYSFS_deinit();
}
Beispiel #7
0
	VFS::~VFS()
	{
		// Clean PhysFs up.
		PHYSFS_deinit();
	}
Beispiel #8
0
int main(int argc, char *argv[])
{
 char opt;
 static struct option long_options[] =
 {
  {"item", 0, 0, 'i'},
  {"monster", 0, 0, 'm'},
  {"spell", 0, 0, 's'},
  {"map", 1, 0, 'p'},
  {"editmap", 1, 0, 'e'},
  {"ascii", 0, 0, 'a'},
  {"xml", 1, 0, 'x'},
  {"multiplier", 1, 0, 'u'},
  {0, 0, 0, 0}
 };

 bool utf8 = true;
 int mode = MODE_STANDARD;
 char *mapFile = NULL;
 char *xmlFile = NULL;
 int multiplier = 0;
 std::string libDir(TOSTRING(BTBUILDERDIR));
 while ((opt = getopt_long(argc,argv,"imsap:x:e:l:u:", long_options, NULL)) != EOF)
 {
  switch (opt)
  {
   case 'i':
    mode = MODE_ITEM;
    break;
   case 'm':
    mode = MODE_MONSTER;
    break;
   case 's':
    mode = MODE_SPELL;
    break;
   case 'p':
    mode = MODE_MAP;
    if (optarg)
    {
     mapFile = strdup(optarg);
    }
    break;
   case 'e':
    mode = MODE_EDITMAP;
    if (optarg)
    {
     mapFile = strdup(optarg);
    }
    break;
   case 'l':
    if (optarg)
    {
     libDir = optarg;
    }
    break;
   case 'a':
    utf8 = false;
    break;
   case 'x':
    if (optarg)
    {
     xmlFile = strdup(optarg);
    }
    break;
   case 'u':
    if (optarg)
    {
     multiplier = atol(optarg);
    }
    break;
   default:
    break;
  }
 }

 BTMainScreen mainScreen(argv[0], libDir, multiplier);
 if (optind >= argc)
 {
  if (mode != MODE_STANDARD)
   return 0;
  mainScreen.run();
  return 0;
 }
 else if (mode == MODE_STANDARD)
 {
  std::string moduleFile("module/");
  moduleFile += argv[optind];
  moduleFile += ".xml";
  mainScreen.runModule(moduleFile);
  return 0;
 }
 else if (mode == MODE_EDITMAP)
 {
  std::string moduleFile("module/");
  moduleFile += argv[optind];
  moduleFile += ".xml";
  mainScreen.editModule(moduleFile, mapFile);
  return 0;
 }
 std::string moduleFile("module/");
 moduleFile += argv[optind];
 moduleFile += ".xml";
 BTModule module;
 mainScreen.loadModule(moduleFile, module);
 BTGame game(&module);
 BTFactory<BTMonster> &monList(game.getMonsterList());
 BTFactory<BTItem> &itmList(game.getItemList());
 BTFactory<BTSpell, BTSpell1> &splList(game.getSpellList());
 int i;
 if (mode == MODE_MONSTER)
 {
  if (xmlFile)
  {
   monList.save(xmlFile);
  }
  else
  {
   for (i = 0; i < monList.size(); i++)
   {
    BTMonster &mon(monList[i]);
    printf("Name: %s\n", mon.getName().c_str());
    printf("Illusion: %s   Base armor class: %d\n",
      (mon.isIllusion() ? "Yes" : "No"), (mon.getAc() - 10) * -1);
    printf("Level: %d   Thaumaturgical resistance: %d\n", mon.getLevel(),
      mon.getMagicResistance());
    printf("Starting distance (*10'): %d   Moves per round: %d\n",
      mon.getStartDistance(), mon.getMove());
    printf("Hit points: %dd%d   Combat options: ", mon.getHp().getNumber(),
      mon.getHp().getType());
    IShort combatAction = mon.getCombatAction(0);
    for (int a = 1; a < 4; ++a)
     if (combatAction != mon.getCombatAction(a))
      combatAction = -1;
    if (-1 == combatAction)
     printf("Multiple\n");
    else
     printf("%s\n", combatActions[combatAction]);
    printf("Rate of attacks: %d   Damage dice: %dd%d\n",
      mon.getRateAttacks(), mon.getMeleeDamage().getNumber(),
      mon.getMeleeDamage().getType());
    printf("Extra damage: %s\n", extraDamage[mon.getMeleeExtra()]);
    printf("Attack message: <monster> %s <opponent>\n", mon.getMeleeMessage());
    printf("Extra ranged attack information -\n");
    printf("   Type: %s", rangedTypes[mon.getRangedType()]);
    switch (mon.getRangedType())
    {
     case BTRANGEDTYPE_MAGIC:
      printf(": %s", splList[mon.getRangedSpell()].getCode());
     case BTRANGEDTYPE_FOE:
     case BTRANGEDTYPE_GROUP:
      printf("   Message: <monster> %s <opponent>\n", mon.getRangedMessage());
      printf("   Damage: %dd%d   Extra damage: %s   Range: %d",
        mon.getRangedDamage().getNumber(),  mon.getRangedDamage().getType(),
        extraDamage[mon.getRangedExtra()], mon.getRange());
      break;
     default:
      break;
    }
    printf("\n");
    printf("Upper limit appearing: %d  Gold: %dd%d   Picture number: %d\n",
      mon.getMaxAppearing(), mon.getGold().getNumber(),
      mon.getGold().getType(), mon.getPicture());
    printf("\n");
   }
  }
 }
 else if (mode == MODE_SPELL)
 {
  if (xmlFile)
  {
   splList.save(xmlFile);
  }
  else
  {
   BTSpellListCompare compare;
   BTSortedFactory<BTSpell, BTSpell1> sortedSplList(&splList, &compare);
   IShort caster = -1;
   IShort level = -1;
   for (i = 0; i < sortedSplList.size(); i++)
   {
    BTSpell &mon(sortedSplList[i]);
    if ((caster != mon.getCaster()) || (level != mon.getLevel()))
    {
     if (caster != mon.getCaster())
     {
      caster = mon.getCaster();
      BTJobList& jobList = BTGame::getGame()->getJobList();
      int j;
      for (j = 0; j < jobList.size(); ++j)
      {
       if (jobList[j]->getSkill(caster) != NULL)
        break;
      }
      printf("Class:  %s\n", ((j < jobList.size()) ? BTGame::getGame()->getJobList()[j]->name : "Unknown"));
     }
     level = mon.getLevel();
     printf("Level: %d\n\n", level);
    }
    printf("Name: %s\n", mon.getName().c_str());
    printf("Code: %s\n", mon.getCode());
    printf("Points: %d   Range: %d   Extra range: %s\n", mon.getSp(),
      mon.getRange() * 10, effectiveRanges[mon.getEffectiveRange()]);
    printf("Target: %s\n", areaEffect[mon.getArea()]);
    printf("Effect: %s <target>\n", mon.getEffect());
    printf("Duration: %s\n", durations[mon.getDuration()]);
    printf("%s", mon.describeManifest().data());
/*    printf("Type: %s", spellTypes[mon.getType()]);
    switch (mon.getType())
    {
     case BTSPELLTYPE_SUMMONILLUSION:
     case BTSPELLTYPE_SUMMONMONSTER:
      printf("   Name: %s", monList[mon.getExtra()].getName().c_str());
      break;
     case BTSPELLTYPE_ARMORBONUS:
     case BTSPELLTYPE_HITBONUS:
      printf("   Bonus: %d", mon.getExtra());
      break;
     case BTSPELLTYPE_PUSH:
      printf("   Distance: %d", mon.getExtra());
      break;
     case BTSPELLTYPE_REGENBARD:
      printf("   Amount: %d", mon.getExtra());
      break;
     default:
      break;
    }
    printf("\nDice: %dd%d   Duration: %s\n", mon.getDice().getNumber(),
      mon.getDice().getType(), durations[mon.getDuration()]);
*/    printf("\n");
   }
  }
 }
 else if (mode == MODE_ITEM)
 {
  if (xmlFile)
  {
   itmList.save(xmlFile);
  }
  else
  {
   for (i = 0; i < itmList.size(); i++)
   {
    BTItem &mon(itmList[i]);
    printf("Name: %s\n", mon.getName().c_str());
    printf("Type: %s\n", itemTypes[mon.getType()]);
    printf("Price: %d   User class: Multiple\n", mon.getPrice());
    printf("Armor bonus: %d   Hit bonus: %d\n", mon.getArmorPlus(),
      mon.getHitPlus());
    printf("Damage dice: %dd%d\n", mon.getDamage().getNumber(),
      mon.getDamage().getType());
    printf("Extra special damage: %s   Special damage likelihood: %d%%\n",
      extraDamage[mon.getXSpecial()], mon.getChanceXSpecial());
    if (BTTIMESUSABLE_UNLIMITED == mon.getTimesUsable())
     printf("Times useable: (unlimited)");
    else
     printf("Times useable: %d", mon.getTimesUsable());
    printf("   Spell cast: %s\n",
      ((mon.getSpellCast() == BTITEMCAST_NONE) ? "(none)" :
      splList[mon.getSpellCast()].getName().c_str()));
    printf("Cause: <member> %s <opponent>\n", mon.getCause());
    printf("Effect: %s <damage>\n", mon.getEffect());
    printf("\n");
   }
  }
 }
 else if (mode == MODE_MAP)
 {
  int x, y;
  IShort index;
  if (mapFile)
   game.loadMap(mapFile);
  BTMap &gameMap = *game.getMap();
  if (xmlFile)
  {
   XMLSerializer parser;
   parser.add("map", &gameMap);
   parser.write(xmlFile, true);
  }
  else
  {
   printf("Name: %s\n", gameMap.getName());
   printf("Type: %s   Level: %d\n", game.getPsuedo3DConfigList().getName(gameMap.getType()).c_str(), gameMap.getLevel());
   printf("Monster difficulty: %d   Chance of encounter: %d%%\n", gameMap.getMonsterLevel(), gameMap.getMonsterChance());
   printf("File: %s\n\n", gameMap.getFilename());
   for (y = 0; y < gameMap.getYSize(); y++)
   {
    printf(" ");
    for (x = 0; x < gameMap.getXSize(); x++)
    {
     index = 0;
     if ((y > 0) && (gameMap.getSquare(y - 1, x).getWall(BTDIRECTION_WEST) > 0))
     {
      index += 1 << BTDIRECTION_NORTH;
     }
     if ((x > 0) && (gameMap.getSquare(y, x - 1).getWall(BTDIRECTION_NORTH) > 0))
     {
      index += 1 << BTDIRECTION_WEST;
     }
     if (gameMap.getSquare(y, x).getWall(BTDIRECTION_NORTH) > 0)
     {
      index += 1 << BTDIRECTION_EAST;
     }
     if (gameMap.getSquare(y, x).getWall(BTDIRECTION_WEST) > 0)
     {
      index += 1 << BTDIRECTION_SOUTH;
     }
     if (utf8)
      printf("%s%s", cornerWallsUTF8[index], upperWallsUTF8[gameMap.getSquare(y, x).getWall(BTDIRECTION_NORTH)]);
     else
      printf("%c%c", cornerWalls[index], upperWalls[gameMap.getSquare(y, x).getWall(BTDIRECTION_NORTH)]);
    }
    index = 0;
    if ((y > 0) && (gameMap.getSquare(y - 1, gameMap.getXSize() - 1).getWall(BTDIRECTION_EAST) > 0))
    {
     index += 1 << BTDIRECTION_NORTH;
    }
    if (gameMap.getSquare(y, gameMap.getXSize() - 1).getWall(BTDIRECTION_NORTH) > 0)
    {
     index += 1 << BTDIRECTION_WEST;
    }
    if (gameMap.getSquare(y, gameMap.getXSize() - 1).getWall(BTDIRECTION_EAST) > 0)
    {
     index += 1 << BTDIRECTION_SOUTH;
    }
    if (utf8)
     printf("%s \n", cornerWallsUTF8[index]);
    else
     printf("%c \n", cornerWalls[index]);
    printf(" ");
    for (x = 0; x < gameMap.getXSize(); x++)
    {
     index = gameMap.getSquare(y, x).getSpecial();
     if (utf8)
      printf("%s%c", sideWallsUTF8[gameMap.getSquare(y, x).getWall(BTDIRECTION_WEST)],
        (index < 0 ) ? ' ' : ((index < 26) ? 'A' + index : 'a' - 26 + index));
     else
      printf("%c%c", sideWalls[gameMap.getSquare(y, x).getWall(BTDIRECTION_WEST)],
        (index < 0 ) ? ' ' : ((index < 26) ? 'A' + index : 'a' - 26 + index));
    }
    if (utf8)
     printf("%s \n", sideWallsUTF8[gameMap.getSquare(y, gameMap.getXSize() - 1).getWall(BTDIRECTION_EAST)]);
    else
     printf("%c \n", sideWalls[gameMap.getSquare(y, gameMap.getXSize() - 1).getWall(BTDIRECTION_EAST)]);
   }
   printf(" ");
   for (x = 0; x < gameMap.getXSize(); x++)
   {
    index = 0;
    if (gameMap.getSquare(gameMap.getYSize() - 1, x).getWall(BTDIRECTION_WEST) > 0)
    {
     index += 1 << BTDIRECTION_NORTH;
    }
    if ((x > 0) && (gameMap.getSquare(gameMap.getYSize() - 1, x - 1).getWall(BTDIRECTION_SOUTH) > 0))
    {
     index += 1 << BTDIRECTION_WEST;
    }
    if (gameMap.getSquare(gameMap.getYSize() - 1, x).getWall(BTDIRECTION_SOUTH) > 0)
    {
     index += 1 << BTDIRECTION_EAST;
    }
    if (utf8)
     printf("%s%s", cornerWallsUTF8[index], upperWallsUTF8[gameMap.getSquare(gameMap.getYSize() - 1, x).getWall(BTDIRECTION_SOUTH)]);
    else
     printf("%c%c", cornerWalls[index], upperWalls[gameMap.getSquare(gameMap.getYSize() - 1, x).getWall(BTDIRECTION_SOUTH)]);
   }
   index = 0;
   if (gameMap.getSquare(gameMap.getYSize() - 1, gameMap.getXSize() - 1).getWall(BTDIRECTION_EAST) > 0)
   {
    index += 1 << BTDIRECTION_NORTH;
   }
   if (gameMap.getSquare(gameMap.getYSize() - 1, gameMap.getXSize() - 1).getWall(BTDIRECTION_SOUTH) > 0)
   {
    index += 1 << BTDIRECTION_WEST;
   }
   if (utf8)
    printf("%s \n", cornerWallsUTF8[index]);
   else
    printf("%c \n", cornerWalls[index]);
   printf("\nDefined special squares:\n\n\n");
   for (int i = 0; i < 30; i++)
   {
    const BTSpecial *sp = gameMap.getSpecial(i);
    if (NULL != sp)
    {
     printf("%c. ", (i < 26) ? 'A' + i : 'a' - 26 + i);
     sp->print(stdout);
     printf("\n");
    }
   }
  }
 }
 PHYSFS_deinit();
 return 0;
}
Beispiel #9
0
FileSystem::~FileSystem()
{
	if (!PHYSFS_deinit())
		std::cout << "PHYSFS_deinit() failed!\n reason: " << PHYSFS_getLastError() << "." << std::endl;
}
void shutdown()
{
    PHYSFS_deinit();
}
void FileManager::OnDeInit()
{
	PHYSFS_deinit();
}
Beispiel #12
0
//==================================================
//! Non-inline destructor
//==================================================
System::VFS::~VFS() {
	// Deinitialize PhysicsFS
	PHYSFS_deinit();
}
FileSystem::~FileSystem()
{
	if (PHYSFS_isInit() != 0)
		PHYSFS_deinit();
}
void ResourceManager::terminate()
{
    PHYSFS_deinit();
}
Beispiel #15
0
int main(int argc, char** argv) 
{
  int result = 0;
    
  try {
    Console::instance = new Console();
//  srand(time(0));            // this breaks repeatability in random numbers
    init_physfs(argv[0]);
    init_sdl();
    
    timelog("controller");
    main_controller = new JoystickKeyboardController();    
    timelog("config");
    init_config();
    timelog("tinygettext");
    init_tinygettext();
    timelog("commandline");
    if(parse_commandline(argc, argv))
      return 0;
    timelog("audio");
    init_audio();
    timelog("video");
    init_video();
    Console::instance->init_graphics(); 
    timelog("scripting");
    Scripting::init_squirrel(config->enable_script_debugger);
    timelog("resources");
    load_shared(); 
    timelog(0);

    main_loop = new MainLoop(); 
    if(config->start_level != "") {
      // we have a normal path specified at commandline not physfs paths.
      // So we simply mount that path here...
      std::string dir = FileSystem::dirname(config->start_level);
      PHYSFS_addToSearchPath(dir.c_str(), true);

      init_rand();        // play_demo sets seed, record_demo uses it

      if(config->start_level.size() > 4 &&
              config->start_level.compare(config->start_level.size() - 5, 5, ".stwm") == 0) {
          main_loop->push_screen(new WorldMapNS::WorldMap(
                      FileSystem::basename(config->start_level)));
      } else {
        std::auto_ptr<GameSession> session (
                new GameSession(FileSystem::basename(config->start_level)));
        
        if(config->start_demo != "")
          session->play_demo(config->start_demo);

        if(config->record_demo != "")
          session->record_demo(config->record_demo);
        main_loop->push_screen(session.release());
      }
    } else {
      init_rand();
      main_loop->push_screen(new TitleScreen());
    }

    main_loop->run();

  } catch(std::exception& e) {
    log_fatal << "Unexpected exception: " << e.what() << std::endl;
    result = 1;
  } catch(...) {
    log_fatal << "Unexpected exception" << std::endl;
    result = 1;
  }

  delete main_loop;
  main_loop = NULL;

  free_options_menu();
  unload_shared();
  quit_audio();

  if(config)
    config->save();
  delete config;
  config = NULL;
  delete main_controller;
  main_controller = NULL;
  delete Console::instance;
  Console::instance = NULL;
  Scripting::exit_squirrel();
  delete texture_manager;
  texture_manager = NULL;
  SDL_Quit();
  PHYSFS_deinit();
  
  return result;
}
 void deinit()
 {
   if (!PHYSFS_deinit())
     throw Exception(PHYSFS_getLastError());
 }
Beispiel #17
0
void physfs_shutdown()
{
    PHYSFS_deinit();
}
Beispiel #18
0
bool Resources::Close() {
    PHYSFS_deinit();
    return PTrue;
}
Beispiel #19
0
ResourceCache::~ResourceCache() {
	PHYSFS_deinit();
	al_shutdown_image_addon();
}
Beispiel #20
0
static void PHYSFSX_deinit()
{
	PHYSFS_deinit();
}
Beispiel #21
0
 ~PhysfsSubsystem()
 {
   PHYSFS_deinit();
 }
Beispiel #22
0
int main(int argc, char* argv[])
{
  logger = new Logger();

  // parse options; set some defaults; control required ones
  parseOptions(argc, argv, options);

  if (options.printHelpAndExit) {
    printHelp();
    return(0);
  }

  if (options.effectX == 0)
    options.effectX = options.winWidth / 2;
  if (options.effectY == 0)
    options.effectY = options.winHeight / 2;
  if (options.effectFile.empty()) {
    logger->error("Please, specify particle effect definition file.");
    return(1);
  }

  PHYSFS_init(argv[0]);

  logger->log("-> initialize engine");
  initEngine();

  effectViewer->setEffectPosition(options.effectX, options.effectY);
  effectViewer->setBackgroundColour(options.backgroundColour);

  startEffect();

  logger->log("-> game loop");

  SDL_Event event;
  bool quit = false;

  // event loop
  while (true) {
    while (SDL_PollEvent(&event)) {
      if (event.type == SDL_QUIT) {
	quit = true;
      } else if (event.type == SDL_KEYDOWN) {
	switch (event.key.keysym.sym) {
	case SDLK_ESCAPE:
	case SDLK_q:
	  quit = true;
	case SDLK_r:
	  // start new effect
	  startEffect();
	  break;
	case SDLK_n:
	  // delete all particles and start new effect
	  effectViewer->cleanParticles();
	  startEffect();
	  break;
	}
      }
    }

    // std::cout << m->getNumSprites() << std::endl;

    gui->logic();
    gui->draw();
    graphics->updateScreen();

    // end if particle effect has ended
    if (effectViewer->isEffectOver()) {
      if (options.quitOnEffectEnd) {
	quit = true;
      } else if (options.loop) {
	startEffect();
      }
    }

    if (quit) {
      break;
    }

    SDL_Delay(10);
  }

  logger->log("-> game loop ended");

  logger->log("-> exit engine");
  exitEngine();

  logger->log("-> done.");

  delete logger;

  PHYSFS_deinit();
  return(0);
}