Exemple #1
0
/*
 *	hashbuild() -- build a new hash index.
 *
 *		We use a global variable to record the fact that we're creating
 *		a new index.  This is used to avoid high-concurrency locking,
 *		since the index won't be visible until this transaction commits
 *		and since building is guaranteed to be single-threaded.
 */
Datum
hashbuild(PG_FUNCTION_ARGS)
{
	Relation	heap = (Relation) PG_GETARG_POINTER(0);
	Relation	index = (Relation) PG_GETARG_POINTER(1);
	IndexInfo  *indexInfo = (IndexInfo *) PG_GETARG_POINTER(2);
	double		reltuples;
	HashBuildState buildstate;

	/*
	 * We expect to be called exactly once for any index relation. If
	 * that's not the case, big trouble's what we have.
	 */
	if (RelationGetNumberOfBlocks(index) != 0)
		elog(ERROR, "index \"%s\" already contains data",
			 RelationGetRelationName(index));

	/* initialize the hash index metadata page */
	_hash_metapinit(index);

	/* build the index */
	buildstate.indtuples = 0;

	/* do the heap scan */
	reltuples = IndexBuildHeapScan(heap, index, indexInfo,
								hashbuildCallback, (void *) &buildstate);

	/*
	 * Since we just counted the tuples in the heap, we update its stats
	 * in pg_class to guarantee that the planner takes advantage of the
	 * index we just created.  But, only update statistics during normal
	 * index definitions, not for indices on system catalogs created
	 * during bootstrap processing.  We must close the relations before
	 * updating statistics to guarantee that the relcache entries are
	 * flushed when we increment the command counter in UpdateStats(). But
	 * we do not release any locks on the relations; those will be held
	 * until end of transaction.
	 */
	if (IsNormalProcessingMode())
	{
		Oid			hrelid = RelationGetRelid(heap);
		Oid			irelid = RelationGetRelid(index);

		heap_close(heap, NoLock);
		index_close(index);
		UpdateStats(hrelid, reltuples);
		UpdateStats(irelid, buildstate.indtuples);
	}

	PG_RETURN_VOID();
}
Exemple #2
0
void StatBooster::ProcessKeyStrokes(HANDLE processHandle, HWND windowHandle, int memoryAddress, bool &stopped, bool &active, bool &activeStatusChanged, CharStats *charStats, CharStats *storedCharStats, Stats *stats, POINT &store_btn_coord, POINT &recall_btn_coord, POINT &reroll_btn_coord)
{
	int escKeyState = GetAsyncKeyState(VK_ESCAPE);
	int f1KeyState = GetKeyState(VK_F1);
	int f2KeyState = GetAsyncKeyState(VK_F2);
	int f5KeyState = GetAsyncKeyState(VK_F5);
	int f6KeyState = GetAsyncKeyState(VK_F6);
	int f7KeyState = GetAsyncKeyState(VK_F7);
	int f8KeyState = GetAsyncKeyState(VK_F8);

	if (escKeyState != 0)
	{
		stopped = true;
	}
	if (f1KeyState == 0 || f1KeyState == 1)
	{
		if (active != (f1KeyState == 1))
		{
			active = (f1KeyState == 1);
			activeStatusChanged = true;
		}
	}
	if (f2KeyState != 0 && !charStats->isBg1TomesUsed())
	{
		charStats->setBg1TomesUsed(true);
		system("cls");
		UpdateStats(processHandle, memoryAddress, charStats, stats, true);
		AddBG1TomeStats(processHandle, memoryAddress, charStats->getStrength(), charStats->getDexterity(), charStats->getConstitution(), charStats->getIntelligence(), charStats->getWisdom(), charStats->getCharisma());
		UpdateStats(processHandle, memoryAddress, charStats, stats, false);
		PrintStats(charStats, storedCharStats, stats);
	}
	if (f5KeyState != 0)
	{
		UpdateMouseCoord(windowHandle, store_btn_coord);
	}
	if (f6KeyState != 0)
	{
		UpdateMouseCoord(windowHandle, recall_btn_coord);
	}
	if (f7KeyState != 0)
	{
		UpdateMouseCoord(windowHandle, reroll_btn_coord);
	}
	if (f8KeyState != 0)
	{
		storedCharStats->reset();
		system("cls");
		PrintStats(charStats, storedCharStats, stats);
	}
}
/**
**  Init unit types.
*/
void InitUnitTypes(int reset_player_stats)
{
	for (size_t i = 0; i < UnitTypes.size(); ++i) {
		CUnitType &type = *UnitTypes[i];
		Assert(type.Slot == (int)i);

		if (type.Animations == NULL) {
			DebugPrint(_("unit-type '%s' without animations, ignored.\n") _C_ type.Ident.c_str());
			continue;
		}
		//  Add idents to hash.
		UnitTypeMap[type.Ident] = UnitTypes[i];

		// Determine still frame
		type.StillFrame = GetStillFrame(type);

		// Lookup BuildingTypes
		for (std::vector<CBuildRestriction *>::iterator b = type.BuildingRules.begin();
			 b < type.BuildingRules.end(); ++b) {
			(*b)->Init();
		}

		// Lookup AiBuildingTypes
		for (std::vector<CBuildRestriction *>::iterator b = type.AiBuildingRules.begin();
			 b < type.AiBuildingRules.end(); ++b) {
			(*b)->Init();
		}
	}

	// LUDO : called after game is loaded -> don't reset stats !
	UpdateStats(reset_player_stats); // Calculate the stats
}
Exemple #4
0
void
DeckLibraryTab::Update ()
{
    UpdateCardList();
    UpdateTotalCardCount();
    UpdateStats();
}
void LayerPanel::UpdateSelection(void)
{
    TileLayer *activeLayer = NULL;
    uint32 a = _engine->GetDrawPanel()->GetActiveLayerId();
    for(uint32 i = 0; i < LAYER_MAX; i++)
    {
        TileLayer *layer = _engine->GetLayerMgr()->GetLayer(i);
        uint8 alpha = layer->visible ? 255 : 150;
        if(i == a)
        {
            activeLayer = layer;
            btnLayers[i]->setBaseColor(gcn::Color(180,255,180,alpha));
        }
        else
        {
            btnLayers[i]->setBaseColor(gcn::Color(128,128,144,alpha));
        }
        btnLayers[i]->setCaption(layer->name);
    }
    ASSERT(activeLayer);

    char buf[30];
    sprintf(buf, a < 10 ? "Layer 0%u:" : "Layer %u:", a);
    lDesc->setCaption(buf);

    tfName->setText(activeLayer->name);
    cbVisible->setSelected(activeLayer->visible);

    UpdateStats(activeLayer);
}
Exemple #6
0
void ValuesTable::UpdateProbesValues(int index, bool &stats_updated, bool &view_updated) {

	for (int i = index - m_draw->m_draws_controller->GetFilter() ; i <= m_draw->m_draws_controller->GetFilter() + index; ++i) {
		if (i < 0 || i >= (int)m_values.size())
			continue;

		ValueInfo& n = m_values.at(i);
		if (i == index) {
			if (n.n_count != 2 * m_draw->m_draws_controller->GetFilter()) {
				n.state = ValueInfo::NEIGHBOUR_WAIT;
				continue;
			}
		} else {
			++n.n_count;
			if (n.state != ValueInfo::NEIGHBOUR_WAIT || n.n_count < 2 * m_draw->m_draws_controller->GetFilter())
				continue;
		}
	
		n.state = ValueInfo::PRESENT;

		CalculateProbeValue(i);

		if (i >= m_view.Start() && i <= m_view.End()) {
			m_draw->m_observers->NotifyNewData(m_draw, i - m_view.Start());
			view_updated = true;
		}

		if (i >= m_stats.Start() && i <= m_stats.End()) {
			UpdateStats(i);
			stats_updated = true;
		}
	}

}
Exemple #7
0
/*------------------------------------------------------------------------------
-- FUNCTION:    Stats
--
-- DATE:        Nov 18, 2010
--
-- REVISIONS:   (Date and Description)
--
-- DESIGNER:	Marcel Vangrootheest
--
-- PROGRAMMER:  Marcel Vangrootheest
--
-- INTERFACE:   BOOL CALLBACK Stats (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
--                              hDlg	- handle to the Dialog
--								message - the message received
--								wParam  - contents vary based on the message
--								lParam  - contents vary based on the message
--
-- RETURNS:     BOOL - returns true if the message was handled.
-- 
-- NOTES:	This is the Dialog process for the Statistics Box.
--              
--
------------------------------------------------------------------------------*/
BOOL CALLBACK Stats (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
    PWNDDATA	pwd = (PWNDDATA) GetWindowLongPtr(GetParent(hDlg), 0);
    
    switch (message)
    {
    case WM_INITDIALOG:
        return TRUE;
    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
			case IDC_CLEAR_STATS:
				NUM_FILES = 0;
				SENT_ACK = 0;
				REC_ACK = 0;
				SENT_EOT = 0;
				REC_EOT = 0;
				SENT_RVI = 0;
				REC_RVI = 0;
				DOWN_FRAMES = 0;
				UP_FRAMES = 0;
				DOWN_FRAMES_ACKD = 0;
				UP_FRAMES_ACKD = 0;
				UpdateStats(GetParent(hDlg));
				return TRUE;
		}
		return FALSE;
	case WM_CLOSE:
		ShowWindow(hDlg, SW_HIDE);
		return TRUE;
	}
	return FALSE;
}
bool Pet::UpdateAllStats()
{
    for (int i = STAT_STRENGTH; i < MAX_STATS; ++i)
        UpdateStats(Stats(i));

    for (uint32 i = 0; i <= sChrPowerTypesStore.GetNumRows(); i++)
    {
        ChrPowerTypesEntry const* cEntry = sChrPowerTypesStore.LookupEntry(i);

        if (!cEntry)
            continue;

        if (getClass() != cEntry->classId)
            continue;

        if (cEntry->power == 10)
            continue;

        SetMaxPower(Powers(cEntry->power),  uint32(GetCreatePowers(Powers(cEntry->power))));
    }

    for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
        UpdateResistances(i);

    return true;
}
Exemple #9
0
void Ship::Init()
{
	// XXX the animation namespace must match that in LuaConstants
	// note: this must be set before generating the collision mesh
	// (which happens in SetModel()) and before rendering
	GetLmrObjParams().animationNamespace = "ShipAnimation";
	GetLmrObjParams().equipment = &m_equipment;

	const ShipType &stype = GetShipType();

	// Dirty hack: Always use gear-down mesh for collision detection
	// necessary because some ships have non-docking meshes too large for docking
	float temp = GetLmrObjParams().animValues[ANIM_WHEEL_STATE];
	GetLmrObjParams().animValues[ANIM_WHEEL_STATE] = 1.0f;
	SetModel(stype.lmrModelName.c_str());
	GetLmrObjParams().animValues[ANIM_WHEEL_STATE] = temp;

	SetMassDistributionFromModel();
	UpdateStats();
	m_stats.hull_mass_left = float(stype.hullMass);
	m_stats.shield_mass_left = 0;
	m_hyperspace.now = false;			// TODO: move this on next savegame change, maybe
	m_hyperspaceCloud = 0;

	m_landingGearAnimation = 0;
	SceneGraph::Model *nmodel = dynamic_cast<SceneGraph::Model*>(GetModel());
	if (nmodel) {
		m_landingGearAnimation = nmodel->FindAnimation("gear_down");
	}
}
int udpioSend(UDPIO *up, UINT32 ip, int port, char *buf, int buflen)
{
int sent;
LOGIO *lp;
struct sockaddr_in addr;
static int alen = sizeof(struct sockaddr_in);
static char *fid = "udpioSend";

    if (up == NULL || buf == NULL) {
        errno = EINVAL;
        lp = (up == NULL) ? NULL : up->lp;
        logioMsg(lp, LOG_ERR, "%s: NULL input not allowed", fid);
        return -1;
    }

    memset((void *) &addr, 0, sizeof(struct sockaddr_in));
    addr.sin_family      = AF_INET;
    addr.sin_addr.s_addr = htonl(ip);
    addr.sin_port        = htons((short) port);

    sent = SENDTO(up->sd, buf, buflen, 0, &addr, alen);
    UpdateStats(&up->stats.xmit, sent, utilTimeStamp());

    return sent;
}
Exemple #11
0
void AGameObject::PostInitializeComponents()
{
  //LOG( "%s [%s]->AGameObject::PostInitializeComponents()", *GetName(), *Name );
  Super::PostInitializeComponents();

  if( RootComponent )
  {
    // Initialize position, but put object on the ground
    SetPosition( GetActorLocation() );

    // Attach contact function to all bounding components.
    if( hitBox ) {
      hitBox->OnComponentBeginOverlap.AddDynamic( this, &AGameObject::OnHitContactBegin );
      hitBox->OnComponentEndOverlap.AddDynamic( this, &AGameObject::OnHitContactEnd );
    }
    else error( "NO HITBOX" );
    if( repulsionBounds ) {
      repulsionBounds->OnComponentBeginOverlap.AddDynamic( this, &AGameObject::OnRepulsionContactBegin );
      repulsionBounds->OnComponentEndOverlap.AddDynamic( this, &AGameObject::OnRepulsionContactEnd );
    }
    else error( "NO REPULSIONBOUNDS" );
  }
  else
  {
    error( FS( "RootComponent wasn't set in PostInitializeComponents()" ) );
  }

  UpdateStats( 0.f );
  Hp = Stats.HpMax;
  Speed = 0.f;

  Recovering = 1;
  //InitIcons();
}
Exemple #12
0
/*****************************************************************************
 * Render: display previously rendered output
 *****************************************************************************
 * This function sends the currently rendered image to Crop image, waits
 * until it is displayed and switches the two rendering buffers, preparing next
 * frame.
 *****************************************************************************/
static void Render( vout_thread_t *p_vout, picture_t *p_pic )
{
    picture_t *p_outpic = NULL;
    int i_plane;

    if( p_vout->p_sys->b_changed )
    {
        return;
    }

    while( ( p_outpic =
                 vout_CreatePicture( p_vout->p_sys->p_vout, 0, 0, 0 )
           ) == NULL )
    {
        if( !vlc_object_alive (p_vout) || p_vout->b_error )
        {
            vout_DestroyPicture( p_vout->p_sys->p_vout, p_outpic );
            return;
        }

        msleep( VOUT_OUTMEM_SLEEP );
    }

    p_outpic->date = p_pic->date;
    vout_LinkPicture( p_vout->p_sys->p_vout, p_outpic );

    for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
    {
        uint8_t *p_in, *p_out, *p_out_end;
        int i_in_pitch = p_pic->p[i_plane].i_pitch;
        const int i_out_pitch = p_outpic->p[i_plane].i_pitch;
        const int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;

        p_in = p_pic->p[i_plane].p_pixels
                /* Skip the right amount of lines */
                + i_in_pitch * ( p_pic->p[i_plane].i_visible_lines *
                                 p_vout->p_sys->i_y / p_vout->output.i_height )
                /* Skip the right amount of columns */
                + i_in_pitch * p_vout->p_sys->i_x / p_vout->output.i_width;

        p_out = p_outpic->p[i_plane].p_pixels;
        p_out_end = p_out + i_out_pitch * p_outpic->p[i_plane].i_visible_lines;

        while( p_out < p_out_end )
        {
            vlc_memcpy( p_out, p_in, i_copy_pitch );
            p_in += i_in_pitch;
            p_out += i_out_pitch;
        }
    }

    vout_UnlinkPicture( p_vout->p_sys->p_vout, p_outpic );
    vout_DisplayPicture( p_vout->p_sys->p_vout, p_outpic );

    /* The source image may still be in the cache ... parse it! */
    vlc_mutex_lock( &p_vout->p_sys->lock );
    if( p_vout->p_sys->b_autocrop )
        UpdateStats( p_vout, p_pic );
    vlc_mutex_unlock( &p_vout->p_sys->lock );
}
CmpStatement::ReturnStatus
CmpStatement::process (const CmpMessageUpdateHist& statement)
{
  // A pointer to user SQL query is stored in CmpStatement; if an exception is
  // thrown the user query is copied from here. It is reset upon return from
  // the UpdateStats() method.
  
  char *userStr= new (heap()) char[2000];
#pragma nowarn(1506)   // warning elimination 
  Int32 len=strlen(statement.data());
#pragma warn(1506)  // warning elimination 

  if (len > 1999)
    len=1999;

  strncpy(userStr, statement.data(), len);
  userStr[len]='\0'; 

  sqlTextStr_ = userStr;

  if (UpdateStats(statement.data()))
     {
       sqlTextStr_=NULL;
       return CmpStatement_ERROR;
     }

  sqlTextStr_=NULL;
  return CmpStatement_SUCCESS;
}
Exemple #14
0
/*------------------------------------------------------------------------------
-- FUNCTION:    UpdateStatStruct
--
-- DATE:        Dec 02, 2010
--
-- REVISIONS:   
--				
-- DESIGNER:    Dean Morin
--
-- PROGRAMMER:  Dean Morin
--
-- INTERFACE:   UpdateStatStruct(HWND hWnd, WPARAM stat, LPARAM attribute)
--						hWnd		- the handle to the window
--						stat		- the stat category to update
--						attribute	- info on how to alter the stat
--
-- RETURNS:     VOID.
--
-- NOTES:
--              Updates the stats structure.
------------------------------------------------------------------------------*/
VOID UpdateStatStruct(HWND hWnd, WPARAM stat, LPARAM attribute) {
    PWNDDATA pwd = (PWNDDATA) GetWindowLongPtr(hWnd, 0);
    
    switch (stat) {

        case STAT_STATE:
            DL_STATE = attribute;
            SendMessage(pwd->hDlgDebug, WM_USER, 0, 0);
            break;
        
        case ACK:
            if (attribute == SENT) {
                SENT_ACK++;
            } else {
                REC_ACK++;
            }
            break;

        case EOT:
            if (attribute == SENT) {
                SENT_EOT++;
            } else {
                REC_EOT++;
            }
            break;
        
        case RVI:
            if (attribute == SENT) {
                SENT_RVI++;	
            } else {
                REC_RVI++;		
            }
            break;
        
        case STAT_FRAME:
            if (attribute == SENT) {
                UP_FRAMES++;
            } else {
                DOWN_FRAMES++;
            }
            break;

        case STAT_FRAMEACKD:
            if (attribute == SENT) {
                pwd->FTPQueueSize--;
                UP_FRAMES_ACKD++;
            } else {
                pwd->PTFQueueSize++;
                DOWN_FRAMES_ACKD++;
            }
            break;
       
        case STAT_FILE:
            NUM_FILES++;
            break;
    }
    UpdateStats(hWnd);
}
static void RecalcStats(struct QuantizedValue *q)
{
	if (q)
	{
		UpdateStats(q);
		RecalcStats(q->Children[0]);
		RecalcStats(q->Children[1]);
	}
}
Exemple #16
0
void SocketEngine::GetStats(float &kbitpersec_in, float &kbitpersec_out, float &kbitpersec_total)
{
	UpdateStats(0, 0); /* Forces emptying of the values if its been more than a second */
	float in_kbit = indata * 8;
	float out_kbit = outdata * 8;
	kbitpersec_total = ((in_kbit + out_kbit) / 1024);
	kbitpersec_in = in_kbit / 1024;
	kbitpersec_out = out_kbit / 1024;
}
Exemple #17
0
void ValuesTable::RecalculateStats() {
	ClearStats();

	size_t s,e;
	s = m_stats.Start(); 
	e = m_stats.End();

	for (size_t i = s; i <= e; ++i) 
		UpdateStats(i);
}
void CDlgConnectionSpeedInfo::OnTimer(UINT_PTR nIDEvent)
{
	if (nIDEvent == 1)
	{
		UpdateStats ();
		UpdateEnabled ();
	}

	CDialog::OnTimer(nIDEvent);
}
void CHUDTeamInstantAction::Update(float fDeltaTime)
{
	if(!m_animTIAScore.IsLoaded() || !m_animTIAScore.GetVisible())
		return;

	UpdateStats();

	m_animTIAScore.GetFlashPlayer()->Advance(fDeltaTime);
	m_animTIAScore.GetFlashPlayer()->Render();
}
void ReliabilitySystem::Update(float deltaTime) {
	FunctionLock lock(thisLock);
	acks.clear();
	AdvanceQueueTime(deltaTime);
	UpdateQueues();
	UpdateStats();
#ifdef NET_UNIT_TEST
	Validate();
#endif
}
Exemple #21
0
/**
 * 
 * There may be more than one of these.
 */
void* ProcessPackets(void* v) {
	PacketRec*	p;
	int		PacketSlot;

	DEBUGPATH;

	pthread_setspecific (Globals.DThreadsKey, v);

	while (!Globals.Done) {
		PacketSlot = PopFromPending();

		if (PacketSlot == PACKET_NONE)
			break;

		pthread_mutex_lock (&PLimitMutex);

		if (Globals.PacketLimit == 0){
			printf("Packet Limit Reached\n");
			Globals.Done=TRUE;
		}

		if (Globals.PacketLimit > 0)
			Globals.PacketLimit--;

		pthread_mutex_unlock (&PLimitMutex);

		p=&Globals.Packets[PacketSlot];

		#ifdef DEBUG
		printf("++++++++++++++++++++++++++++++++%u\n",p->PacketNum);
		#endif

		if (p->tv.tv_sec)
			HandleTimers(p->tv.tv_sec);

		if (!Decode(Globals.DecoderRoot, PacketSlot)) {
			printf("Error Processing Packet\n");
		}

		UpdateStats (PacketSlot);

		if (!BitFieldIsEmpty(p->RuleBits,Globals.NumRules)) {
			#ifdef DEBUG
			printf("There are rule matches\n");
			#endif
			AddPacketToWaiting (PacketSlot);
		} else {
			RouteAndSend(PacketSlot);
		}

		/* And we are done with this packet */
	}

	return NULL;
}
int udpioRecv(UDPIO *up, char *buf, int buflen)
{
LOGIO *lp;
int error, got;
INT32 width;
fd_set fds;
static int len = sizeof(struct sockaddr_in);
static char *fid = "udpioRecv";

    if (up == NULL || buf == NULL) {
        errno = EINVAL;
        lp = (up == NULL) ? NULL : up->lp;
        logioMsg(lp, LOG_ERR, "%s: NULL input not allowed", fid);
        return -1;
    }

    if (buflen < 1) {
        logioMsg(up->lp, LOG_ERR, "%s: illegal buflen '%d'", fid, buflen);
        return -1;
    }

    if (up->sd == INVALID_SOCKET) {
        logioMsg(up->lp, LOG_ERR, "%s: invalid socket", fid, buflen);
        errno = EINVAL;
        return -1;
    }

    width = getdtablesize();
    FD_ZERO(&fds);
    FD_SET(up->sd, &fds);
    got = 0;

    while (got == 0) {
        error = select(width, &fds, NULL, NULL, &up->to);
        if (error > 0) {
            got = RECVFROM(up->sd, buf, buflen, 0, &up->peer.addr, &len);
            if (got > 0) {
                inet_ntop(AF_INET, &up->peer.addr, up->peer.ident, MAXPATHLEN);
            } else {
                logioMsg(up->lp, LOG_INFO, "%s: RECVFROM: %s", fid, strerror(errno));
                if (errno != EAGAIN && errno != EINTR) return -1;
            }
        } else if (error == 0) {
            errno = ETIMEDOUT;
            return 0;
        } else if (errno != EAGAIN && errno != EINTR) {
            logioMsg(up->lp, LOG_INFO, "%s: select: %s", fid, strerror(errno));
            return -1;
        }
    }
    UpdateStats(&up->stats.recv, got, utilTimeStamp());

    return got;
}
Exemple #23
0
bool Guardian::UpdateAllStats()
{ 
    for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
        UpdateStats(Stats(i));

    for (uint8 i = POWER_MANA; i < MAX_POWERS; ++i)
        UpdateMaxPower(Powers(i));

    UpdateAllResistances();
    return true;
}
bool ScreenNetEvaluation::MenuUp( const InputEventPlus &input )
{
	if( m_iActivePlayers == 0 || !m_bHasStats )
		return false;

	COMMAND( m_textUsers[m_iCurrentPlayer], "DeSel" );
	m_iCurrentPlayer = (m_iCurrentPlayer + m_iActivePlayers - 1) % m_iActivePlayers;
	COMMAND( m_textUsers[m_iCurrentPlayer], "Sel" );
	UpdateStats();
	return true;
}
BOOL CDlgConnectionSpeedInfo::OnInitDialog()
{
	CDialog::OnInitDialog();

	UpdateStats ();
	SetTimer (1, 1000, NULL);

	ApplyLanguage ();
	UpdateEnabled ();

	return TRUE; 
}
bool StDevFilter::IngestValue(double depth) {
  bool retval = false;
  UpdateStats(depth);
  #if DEBUG
  std::cout << "Ingesting Value: " << depth << std::endl;
  #endif

  if (fabs(m_mean - depth) <= m_stdev * m_std_limit) {
    m_filtered_depth = depth;
    retval = true;
  }
  #if DEBUG
  std::cout << "Filtered depth: " << m_filtered_depth
    << " Mean depth: " << m_mean
    << " Stdev depth: " << m_stdev
    << " a: " << m_a << std::endl;
  #endif
  return retval;
  /* Old Method
  // Reject depths that are rejected by the sonar (0 depth)
  MOOSTrace("SonarFilt - Injesting Depth\n");
  if (depth > 0) {
    double std = GetStDev(&m_all_depths);
    // Need to add values before we can compute stdev
    if (m_all_depths.size() >= 2) {
      MOOSTrace("SonarFilt - Testing StDev\n");
      // Only call a depth good if it is within the stdev limit
      //TODO: Maybe add a fixed factor since the stdev could be low (zero)
      if (depth <= (m_last_valid_depth + std * m_std_limit) &&
        depth >= (m_last_valid_depth - std * m_std_limit)) {
        MOOSTrace("SonarFilt - Have Valid Depth: %0.2f\n", depth);
        m_fresh_depth = true;
        m_cycles_since_last = 0;
        m_last_valid_depth = depth;
      } else {
        MOOSTrace("SonarFilt - Throwing Out Invalid Depth: %0.2f \n", depth);
        if (++m_cycles_since_last > 10) {
          m_last_valid_depth = GetMean(&m_all_depths);
          m_cycles_since_last = 0;
        }
      }
    } else {
      m_last_valid_depth = depth;
    }
    //Add it anyway in case this is a trend
    m_all_depths.push_front(depth);
    if (m_all_depths.size() > m_filter_len) {
      m_all_depths.pop_back();
    }
  }
  */
}
Exemple #27
0
           /*duration is in hour increments*/
void Rest(Hero *hero,int duration,int resttype)
{
  float quality;
  UpdateStats(hero);
  if(resttype == 0)quality = 0.1;
  else quality = 0.3;
  hero->health += (hero->healthmax * quality) * duration;
  hero->mana += (hero->manamax * quality) * duration;
  hero->stamina += (hero->staminamax * quality) * duration * 2;
  if(hero->health > hero->healthmax)hero->health = hero->healthmax;
  if(hero->mana > hero->manamax)hero->mana = hero->manamax;
  if(hero->stamina > hero->staminamax)hero->stamina = hero->staminamax;
}
Exemple #28
0
void AGameObject::Move( float t )
{
  MoveCounters( t );
  
  if( CheckDead( t ) )  return;
  CheckNextCommand();
  
  UpdateStats( t );
  RecomputePath(); // Recomputes path towards destination, if applicable
  Walk( t );   // Walk towards destination

  FlushPosition();
}
Exemple #29
0
bool Pet::UpdateAllStats()
{
    for (int i = STAT_STRENGTH; i < MAX_STATS; ++i)
        UpdateStats(Stats(i));

    for(int i = POWER_MANA; i < MAX_POWERS; ++i)
        UpdateMaxPower(Powers(i));

    for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
        UpdateResistances(i);

    return true;
}
void CHLTVClientState::RunFrame()
{
	CBaseClientState::RunFrame();

	if ( m_NetChannel && m_NetChannel->IsTimedOut() && IsConnected() )
	{
		ConMsg ("\nSourceTV connection timed out.\n");
		Disconnect();
		return;
	}

	UpdateStats();
}