예제 #1
0
static void ShowBJ(void)
{
    if ((ReadTick()-BJTime) >= 20) {		/* Time to draw a BJ? */
        BJTime = ReadTick();				/* Set the new time */
        if (WhichBJ!=2) {			/* Thumbs up? */
            WhichBJ ^= 1;			/* Nope, toggle breathing */
        }
        DrawInterMisPic(WhichBJ);
    }
}
예제 #2
0
int TRI_LoadStateReplicationApplier (TRI_vocbase_t* vocbase,
                                     TRI_replication_applier_state_t* state) {
  TRI_json_t* json;
  TRI_json_t* serverId;
  char* filename;
  int res;
  
  TRI_InitStateReplicationApplier(state);
  filename = GetStateFilename(vocbase);

  if (filename == NULL) {
    return TRI_ERROR_OUT_OF_MEMORY;
  }

  LOG_TRACE("looking for replication state file '%s'", filename);

  if (! TRI_ExistsFile(filename)) {
    TRI_FreeString(TRI_CORE_MEM_ZONE, filename);

    return TRI_ERROR_FILE_NOT_FOUND;
  }
  
  LOG_TRACE("replication state file '%s' found", filename);

  json  = TRI_JsonFile(TRI_CORE_MEM_ZONE, filename, NULL);
  TRI_FreeString(TRI_CORE_MEM_ZONE, filename);

  if (! TRI_IsArrayJson(json)) {
    if (json != NULL) {
      TRI_FreeJson(TRI_CORE_MEM_ZONE, json);
    }

    return TRI_ERROR_REPLICATION_INVALID_APPLIER_STATE;
  }

  res = TRI_ERROR_NO_ERROR;

  // read the server id
  serverId = TRI_LookupArrayJson(json, "serverId");

  if (! TRI_IsStringJson(serverId)) {
    res = TRI_ERROR_REPLICATION_INVALID_APPLIER_STATE;
  }
  else {
    state->_serverId = TRI_UInt64String2(serverId->_value._string.data, 
                                         serverId->_value._string.length - 1);
  }

  if (res == TRI_ERROR_NO_ERROR) {
    // read the ticks
    res |= ReadTick(json, "lastAppliedContinuousTick", &state->_lastAppliedContinuousTick); 

    // set processed = applied
    state->_lastProcessedContinuousTick = state->_lastAppliedContinuousTick;
  }

  TRI_FreeJson(TRI_CORE_MEM_ZONE, json);
  
  LOG_TRACE("replication state file read successfully");

  return res;
}
예제 #3
0
void LevelCompleted(void)
{
    Word k;

    /* setup */

    ParTime = MapListPtr->InfoArray[gamestate.mapon].ParTime;
    BonusScore = 0;		/* Init the bonus */

    IntermissionHack = TRUE;	/* Hack to keep score from drawing twice */
    NumberIndex = 47;		/* Hack to draw score using an alternate number set */
    NewGameWindow(1);		/* Force 512 mode screen */

    DisplayScreen(rIntermission, rInterPal);
    BlastScreen();

    InitInterMisPic();

    WhichBJ = 0;		/* Init BJ */
    BJTime = ReadTick()-50;		/* Force a redraw */
    BlastScreen();		/* Draw the screen */
    ShowBJ();			/* Draw BJ */
    StartSong(SongListPtr[1]);	/* Play the intermission song */
    SetAPalette(rInterPal);	/* Set the palette */
    DrawIScore();			/* Draw the current score */
    FlushKeys();			/* Flush the keyboard buffer */

    /* First an initial pause */

    BJBreath(60);

    /* Display Par Time, Player's Time, and show bonus if any. */

    if (gamestate.playtime>=(100*60*60UL)) {
        k =(99*60)+59;
    } else {
        k = gamestate.playtime/60;
    }
    DrawTime(TIMEX,TIMEY,k);		/* How much time has elapsed? */
    DrawTime(TIMEX,TIMEY2,ParTime);

    if (k < ParTime) {
        k = (ParTime-k) * 50;		/* 50 points per second */
        BonusScore += k;		/* Add to the bonus */
        DrawIBonus();			/* Draw the bonus */
        PlaySound(SND_EXTRA);
        BJBreath(60);			/* Breath a little */
    }

    /* Show ratios for "terminations", treasure, and secret stuff. */
    /* If 100% on all counts, Perfect Bonus! */

    k=0;		/* Not perfect (Yet) */
    RollRatio(RATIOX,RATIOY,(gamestate.treasurecount*100)/gamestate.treasuretotal);
    if (gamestate.treasurecount == gamestate.treasuretotal) {
        k++;			/* Perfect treasure */
    }
    if (!NoEnemies) {
        RollRatio(RATIOX,RATIOY2,(gamestate.killcount*100)/gamestate.killtotal);
        if (gamestate.killcount == gamestate.killtotal) {
            k++;			/* Perfect kills */
        }
    }
    RollRatio(RATIOX,RATIOY3,(gamestate.secretcount*100)/gamestate.secrettotal);
    if (gamestate.secretcount == gamestate.secrettotal) {
        k++;			/* Perfect secret */
    }
    if (BonusScore) {	/* Did you get a bonus? */
        RollScore();
        BJBreath(60);
    }
    if (k==3) {
        WhichBJ = 2;	/* Draw thumbs up for BJ */
        PlaySound(SND_THUMBSUP);
    }
    do {
        ShowBJ();		/* Animate BJ */
    } while (!WaitTicksEvent(1));		/* Wait for a keypress */

    FadeToBlack();		/* Fade away */

    FreeInitMisPic();
    IntermissionHack = FALSE;		/* Release the hack */
    NumberIndex = 36;			/* Restore the index */
}