コード例 #1
0
			// log and write 関数
			void log_writeData(clock::time_point time_, T1 data1_, T2 data2_){
				if(is_active()){
					ofs << time_to_ymd(time_) << Separator << time_to_hms(time_);
					ofs << Separator << data1_;
					ofs << Separator << data2_;
					ofs << std::endl;
				}
			}
コード例 #2
0
				// log and write 関数
				void log_writeData(clock::time_point time_, const data& data_){
					if(is_active()){
						ofs << time_to_ymd(time_) << "\t" << time_to_hms(time_);
						ofs << "\t" << time_to_hms(data_.getUTC());
						ofs << "\t" << data_.getPos().y << "\t" << data_.getPos().x;
						ofs << "\t" << data_.getHeight();
						ofs << "\t" << data_.getUseGPS();
						ofs << "\t" << data_.getFail() << "\t" << data_.getErr();
						ofs << std::endl;
						/*
						ofs << time_to_hms(time_) << FILE_DEVIDE_CHARS << data_.getUseGPS()
						<< FILE_DEVIDE_CHARS << data_.getPos().x << FILE_DEVIDE_CHARS << data_.getPos().y
						<< FILE_DEVIDE_CHARS << data_.getHeight() << FILE_DEVIDE_CHARS << time_to_hms(data_.getUTC())
						<< FILE_DEVIDE_CHARS << data_.getFail() << FILE_DEVIDE_CHARS << data_.getErr()
						<< std::endl;
						*/
					}
				}
コード例 #3
0
ファイル: output-sdl.c プロジェクト: Chronster/curseofwar
void output_sdl (SDL_Surface *tileset, SDL_Surface *typeface, SDL_Surface *uisurf, SDL_Surface *screen, 
    struct state *s, struct ui *ui,
    int variant[MAX_WIDTH][MAX_HEIGHT], int pop_variant[MAX_WIDTH][MAX_HEIGHT], int ktime) {

  /* Clear screen */
  SDL_Rect rect = {0, 0, screen->w, screen->h};
  SDL_FillRect(screen, &rect, (SDL_MapRGB(screen->format, 20, 20, 20)));

  /* Draw */
  int i=0,j=0,k=0;
  int srci=0, srcj=0;

  /* cliffs variables */
  int cliff_buf[MAX_CLIFF];

  for (j=0; j<s->grid.height; ++j) {
    for (i=-1; i<s->grid.width+1; ++i) {
      /* cliffs */
      if (is_a_cliff(i, j, &s->grid, cliff_buf)) {
        for(k=0; k<MAX_CLIFF; ++k) {
          if (cliff_buf[k]) {
            blit_subpic (tileset, screen, 7+k, 0, POSX(ui, i), POSY(j));
          }
        }
        continue;
      }

      if (!is_within_the_grid(i,j,&s->grid)) {
        continue;
      }

      /* normal tiles */
      int owner = s->grid.tiles[i][j].pl;
      int done = 0; 
      switch (s->grid.tiles[i][j].cl) {
        case abyss: break; 
        default:
          /* draw grass */
          blit_subpic (tileset, screen, 0 + variant[i][j]%6, 0 + variant[i][j]/6%3, POSX(ui,i), POSY(j));
          /* draw everything else */
          switch (s->grid.tiles[i][j].cl) {
            case village: 
              srci=0; srcj=7 + 3*owner; 
              break;
            case town: 
              srci=1; srcj=7 + 3*owner; 
              break;
            case castle: 
              srci=2; srcj=7 + 3*owner; 
              break;
            case mountain: case mine:
              srci=0 + variant[i][j]%5; 
              srcj=5; break;
            case grassland: 
              {
                /* drawing population */
                int pop = s->grid.tiles[i][j].units[owner][citizen];
                if (pop > 0) {
                  srci = 0 + pop_to_symbol(pop);
                  srcj = 8 + 3*(owner);
                  blit_subpic_noise (tileset, screen, srci, srcj, POSX(ui, i), POSY(j), pop_variant[i][j]);
                  if (rand()%20 == 0) {
                    int d = 1;
                    if (owner != s->controlled) d = 11;
                    pop_variant[i][j] = (pop_variant[i][j] + d) % 10000;
                  }
                }
              }
              done = 1;
            default:
              done = 1;
          }
          if (!done) {
            blit_subpic_2h (tileset, screen, srci, srcj, POSX(ui, i), POSY(j));
            if (s->grid.tiles[i][j].cl == mine) {
              if (s->grid.tiles[i][j].pl > 0)
                /* add a currency sign if its mining */
                blit_subpic_2h (tileset, screen, 5, 5, POSX(ui, i), POSY(j));
              else
                /* no currency sign */
                blit_subpic (tileset, screen, 5, 5, POSX(ui, i), POSY(j));
            }
          }
      }
      /* flags */
      int p;
      for (p=0; p<MAX_PLAYER; ++p) {
        if (p != s->controlled) {
          if (s->fg[p].flag[i][j] != 0 && ((ktime/5 + p) / 5)%10 < 10) {
            blit_subpic_2h (tileset, screen, 4, 7+3*p, POSX(ui, i), POSY(j));
          }
        }
        else 
          if (s->fg[p].flag[i][j] != 0) {
            blit_subpic_2h (tileset, screen, 3, 7+3*p, POSX(ui, i), POSY(j));
          }
      }

    }
  }


  /* draw cursor */
  blit_subpic_2h (tileset, screen, 6, 5, POSX(ui, ui->cursor.i-1), POSY(ui->cursor.j));
  blit_subpic_2h (tileset, screen, 7, 5, POSX(ui, ui->cursor.i), POSY(ui->cursor.j));
  blit_subpic_2h (tileset, screen, 8, 5, POSX(ui, ui->cursor.i+1), POSY(ui->cursor.j));

  /* Text */
  int screen_y = (POSY(s->grid.height) + 1) * TILE_HEIGHT;

  char buf[128];
  output_string(typeface, screen, "Gold: ", TILE_WIDTH, screen_y);
  sprintf(buf, "%li     ", s->country[s->controlled].gold);
  output_string_alt(typeface, s->controlled, screen, buf, TILE_WIDTH + 6*TYPE_WIDTH, screen_y);
  
  sprintf(buf, "Prices: 150 300 600");
  output_string(typeface, screen, buf, TILE_WIDTH, screen_y + 1*TYPE_HEIGHT);
  
  int y,m,d;
  time_to_ymd(s->time, &y, &m, &d);

  output_string(typeface, screen, "Date: ", TILE_WIDTH + 54*TYPE_WIDTH, screen_y + 0*TYPE_HEIGHT);
  sprintf(buf, "%i-%02i-%02i", y, m, d);
  output_string_alt(typeface, s->controlled, screen, buf, TILE_WIDTH + 60*TYPE_WIDTH, screen_y + 0*TYPE_HEIGHT);
  
  output_string(typeface, screen, "Speed:", TILE_WIDTH + 54*TYPE_WIDTH, screen_y + 1*TYPE_HEIGHT);
  switch(s->speed){
    case sp_fastest: sprintf(buf,"Fastest"); break;
    case sp_faster:  sprintf(buf,"Faster "); break;
    case sp_fast:    sprintf(buf,"Fast   "); break;
    case sp_normal:  sprintf(buf,"Normal "); break;
    case sp_slow:    sprintf(buf,"Slow   "); break;
    case sp_slower:  sprintf(buf,"Slower "); break;
    case sp_slowest: sprintf(buf,"Slowest"); break;
    case sp_pause:   sprintf(buf,"Pause  "); break;
  }
  output_string(typeface, screen, buf, TILE_WIDTH + 61*TYPE_WIDTH, screen_y + 1*TYPE_HEIGHT);


  sprintf(buf, "Population:");
  output_string(typeface, screen, buf, TILE_WIDTH + 23*TYPE_WIDTH, screen_y + 0*TYPE_HEIGHT);
  int p;
  for (p=1; p<MAX_PLAYER; ++p) {
    sprintf(buf, "%3i", s->grid.tiles[ui->cursor.i][ui->cursor.j].units[p][citizen]);
    output_string_alt(typeface, p, screen, buf, 
      TILE_WIDTH + (23 + 4*(p-1))*TYPE_WIDTH, screen_y + 1*TYPE_HEIGHT);
  }

  output_string(typeface, screen, "[Space] flag", 
      TILE_WIDTH + 0*TYPE_WIDTH, screen_y + 3*TYPE_HEIGHT);
  output_string(typeface, screen, "[R] or [V] build", 
      TILE_WIDTH + 27*TYPE_WIDTH, screen_y + 3*TYPE_HEIGHT);
  output_string(typeface, screen, "[X],[C] mass remove", 
      TILE_WIDTH + 0*TYPE_WIDTH, screen_y + 4*TYPE_HEIGHT);
  
  output_string(typeface, screen, "[S] slower [F] faster", 
      TILE_WIDTH + 54*TYPE_WIDTH, screen_y + 3*TYPE_HEIGHT);
  output_string(typeface, screen, "[P] pause", 
      TILE_WIDTH + 54*TYPE_WIDTH, screen_y + 4*TYPE_HEIGHT);

  /* line */
  int line_width=555;
  struct SDL_Rect src_line_rect = {0, 0, line_width, 1};
  struct SDL_Rect dst_line_rect = {TILE_WIDTH + 75*TYPE_WIDTH/2 - line_width/2, screen_y + (TYPE_HEIGHT*5/2), line_width, 1};
  SDL_BlitSurface(uisurf, &src_line_rect, screen, &dst_line_rect);

}
コード例 #4
0
			// log and write 関数
			void log_writeData(clock::time_point time_, double data_){
				if(is_active()){
					ofs << time_to_ymd(time_) << Separator << time_to_hms(time_) << Separator << data_ << std::endl;
				}
			}