Esempio n. 1
0
int festring::SplitString(const festring& Source,
                          std::vector<festring>& StringVector,
                          sizetype Length, sizetype Marginal)
{
    if(!Length)
        ABORT("Illegal Length 0 passed to festring::SplitString()!");

    if(Marginal >= Length)
        ABORT("Illegal festring::SplitString() call:"
              "Marginal must be less than Length!");

    festring CopyOfSource(Source);

    if(StringVector.empty())
        StringVector.push_back(festring());
    else
        StringVector[0].Empty();

    SplitString(CopyOfSource, StringVector[0], Length);
    sizetype Size = 1;

    while(!CopyOfSource.IsEmpty())
    {
        if(StringVector.size() <= Size)
            StringVector.push_back(festring());

        festring& String = StringVector[Size++];
        String.Assign(Marginal, ' ');
        SplitString(CopyOfSource, String, Length - Marginal);
    }

    return Size;
}
Esempio n. 2
0
void ivanconfig::Initialize()
{
  configsystem::AddOption(&DefaultName);
  configsystem::AddOption(&DefaultPetName);
  configsystem::AddOption(&AutoSaveInterval);
  configsystem::AddOption(&Contrast);
  configsystem::AddOption(&WarnAboutDanger);
  configsystem::AddOption(&AutoDropLeftOvers);
  configsystem::AddOption(&LookZoom);
  configsystem::AddOption(&UseAlternativeKeys);
#ifndef __DJGPP__
  configsystem::AddOption(&FullScreenMode);
#endif
#if defined(WIN32) || defined(__DJGPP__)
  configsystem::SetConfigFileName("ivan.cfg");
#else
  configsystem::SetConfigFileName(festring(getenv("HOME")) + "/.ivan.conf");
#endif
  configsystem::Load();
  CalculateContrastLuminance();
}
Esempio n. 3
0
truth highscore::Add(long NewScore, const festring& NewEntry,
		     time_t NewTime, long NewRandomID)
{
  for(uint c = 0; c < Score.size(); ++c)
    if(Score[c] < NewScore)
    {
      Entry.insert(Entry.begin() + c, NewEntry);
      Score.insert(Score.begin() + c, NewScore);
      Time.insert(Time.begin() + c, NewTime);
      RandomID.insert(RandomID.begin() + c, NewRandomID);

      if(Score.size() > MAX_HIGHSCORES)
      {
	Entry.resize(MAX_HIGHSCORES, festring());
	Score.resize(MAX_HIGHSCORES);
	Time.resize(MAX_HIGHSCORES);
	RandomID.resize(MAX_HIGHSCORES);
      }

      LastAdd = c;
      return true;
    }

  if(Score.size() < MAX_HIGHSCORES)
  {
    LastAdd = Score.size();
    Entry.push_back(NewEntry);
    Score.push_back(NewScore);
    Time.push_back(NewTime);
    RandomID.push_back(NewRandomID);
    return true;
  }
  else
  {
    LastAdd = MAX_HIGHSCORES;
    return false;
  }
}
Esempio n. 4
0
int OutputHTML(festring InputFilename)
{
  highscore Input;
  Input.Load(InputFilename);
  std::cout << "<TABLE BORDER=3> \n <TR> <TH>Rank</TH> <TH>Who</TH> <TH>Score</TH>\n";

  for(int c = 0; c < Input.GetSize();++c)
  {
    festring Rank,Score;
    Score << Input.GetScore(c);
    Rank << c + 1 << festring(".");
    std::cout
      << std::string("<TR> <TD>")
      << Rank.CStr()
      << std::string("</TD> <TD>")
      << Input.GetEntry(c).CStr()
      << std::string("</TD> <TD>")
      << Score.CStr()
      << std::string("</TD> </TR>\n");
  }
  std::cout << "</TABLE>";
  return 0;
}
Esempio n. 5
0
File: audio.cpp Progetto: Azba/ivan
int audio::Loop(void *ptr)
{

   std::vector<unsigned char> message;
   // Note On: 144, 64, 90

   while(1)
   {
      if( Tracks.size() && (PlaybackState & PLAYING) )
      {
         isTrackPlaying = true;
         int randomIndex = rand() % Tracks.size();
         CurrentTrack = Tracks[randomIndex]->GetFilename();

         festring MusDir = game::GetMusicDir();
         festring MusFile = MusDir + festring(CurrentTrack);

         PlayMIDIFile( (char*)MusFile.CStr(), 1);
      }
      isTrackPlaying = false;
      SDL_Delay(1);
   }
   return 0;
}
Esempio n. 6
0
int Main(int argc, char **argv)
{
  if(argc > 1 && festring(argv[1]) == "--version")
  {
    std::cout << "Iter Vehemens ad Necem version " << IVAN_VERSION << std::endl;
    return 0;
  }

#ifdef __DJGPP__

  /* Saves numlock state and toggles it off */

  char ShiftByteState = _farpeekb(_dos_ds, 0x417);
  _farpokeb(_dos_ds, 0x417, 0);

#endif /* __DJGPP__ */

  femath::SetSeed(time(0));
  game::InitGlobalValueMap();
  scriptsystem::Initialize();
  databasesystem::Initialize();
  game::InitLuxTable();
  ivanconfig::Initialize();
  igraph::Init();
  game::CreateBusyAnimationCache();
  globalwindowhandler::SetQuitMessageHandler(game::HandleQuitMessage);
  msgsystem::Init();
  protosystem::Initialize();
  igraph::LoadMenu();

  for(;;)
  {
    int Select = iosystem::Menu(igraph::GetMenuGraphic(),
				v2(RES.X / 2, RES.Y / 2 - 20),
				CONST_S("\r"),
				CONST_S("Start Game\rContinue Game\r"
					"Configuration\rHighscores\r"
					"Quit\r"),
				LIGHT_GRAY,
				CONST_S("Released under the GNU\r"
					"General Public License\r"
					"More info: see COPYING\r"),
				CONST_S("IVAN v" IVAN_VERSION "\r"));

    switch(Select)
    {
     case 0:
      if(game::Init())
      {
	igraph::UnLoadMenu();

	game::Run();
	game::DeInit();
	igraph::LoadMenu();
      }

      break;
     case 1:
      {
	festring LoadName = iosystem::ContinueMenu(WHITE, LIGHT_GRAY, game::GetSaveDir());

	if(LoadName.GetSize())
	{
	  LoadName.Resize(LoadName.GetSize() - 4);

	  if(game::Init(LoadName))
	  {
	    igraph::UnLoadMenu();
	    game::Run();
	    game::DeInit();
	    igraph::LoadMenu();
	  }
	}

	break;
      }
     case 2:
      ivanconfig::Show();
      break;
     case 3:
      {
	highscore HScore;
	HScore.Draw();
	break;
      }
     case 4:

#ifdef __DJGPP__

      /* Loads numlock state */

      _farpokeb(_dos_ds, 0x417, ShiftByteState);

#endif

      return 0;
    }
  }
}
Esempio n. 7
0
int main(int argc, char** argv)
{
  if(argc == 3)
  {
    festring Arg = festring(argv[1]);

    if(Arg == "-l")
    {
      highscore Input(argv[2]);

      if(!Input.GetSize()) {
        std::cout << "No games. No winners.\n";
      }
      std::cout << std::endl;

      for(festring::sizetype c = 0; c < Input.GetSize(); ++c)
        std::cout << c + 1 << " " << Input.GetEntry(c).CStr() << " " << Input.GetScore(c) << "\n";

      return 0;
    } else if(Arg == "-h")
    {
      return OutputHTML(argv[2]);
    }
    else if(Arg == "-d")
    {
      if(!DebugDraw(argv[2]))
      {
        std::cout << "\nProblem showing version number\n";
        return 1;
      }
      return 0;
    }
    else
      return 1;
  }

  if(argc == 4)
  {
    highscore Input;
    Input.Load(argv[1]);

    if(!Input.CheckVersion())
    {
      std::cout << "Version check not ok with " << argv[1] << std::endl;
      return 2;
    }

    highscore Output;
    Output.Load(argv[2]);

    if(!Output.CheckVersion())
    {
      std::cout << "Version check not ok with " << argv[2] << std::endl;
      return 2;
    }
    if(!Input.MergeToFile(&Output))
      std::cout << "\n All entries also found in " << argv[2] << ". Oh well.\n";

    Output.Save(argv[3]);
    return 0;
  }

  std::cout << "\nTo list scores in highscore file:\n"
               "    mihail -l [filename]"
               "\n\nTo merge 2 files\n"
               "    mihail [1st input filename] [2nd input filename] [output filename]"
               "\n\nTo give version number of highscore file\n"
               "    mihail -d [filename]\n"
               "Notice that first filename in merges gives also version number\n";
  return 1;
}