Пример #1
0
unsigned int XYd::Hash(const XYd *p)
{
	unsigned int h,temp;
	temp=HashDouble(p->x);
	h=sdbm_hash(&temp,sizeof(unsigned int));
	temp=HashDouble(p->y);
	h=sdbm_hash(&temp,sizeof(unsigned int),h);
	return(h);
}
char *WorldObject::LogState( char *_message )
{
    static char s_result[1024];
    
    static char buf1[32], buf2[32], buf3[32], buf4[32];

    sprintf( s_result, "%sWOBJ Type[%d] Id[%d] pos[%s,%s,%s], vel[%s]",
                        (_message)?_message:"",
                        m_type,
                        m_id.GetUniqueId(),
                        HashDouble( m_pos.x, buf1 ),
                        HashDouble( m_pos.y, buf2 ),
                        HashDouble( m_pos.z, buf3 ),
                        HashDouble( m_vel.x + m_vel.y + m_vel.z, buf4 ) );

    return s_result;
}
char *Entity::LogState( char *_message )
{
    static char s_result[1024];

    static char buf1[32], buf2[32], buf3[32], buf4[32], buf5[32];

    sprintf( s_result, "%sENT Type[%s] Id[%d] pos[%s,%s,%s], vel[%s] front[%s]",
                        (_message)?_message:"",
                        GetTypeName(m_type),
                        m_id.GetUniqueId(),
                        HashDouble( m_pos.x, buf1 ),
                        HashDouble( m_pos.y, buf2 ),
                        HashDouble( m_pos.z, buf3 ),
                        HashDouble( m_vel.x + m_vel.y + m_vel.z, buf4 ),
                        HashDouble( m_front.x + m_front.y + m_front.z, buf5 ) );

    return s_result;
}
char *Building::LogState( char *_message )
{
    static char s_result[1024];

    static char buf1[32], buf2[32], buf3[32], buf4[32], buf5[32], buf6[32], buf7[32];

    sprintf( s_result, "%sBUILDING Type[%s] Id[%d] pos[%s,%s,%s], vel[%s] front[%s] centre[%s], radius[%s]",
                        (_message)?_message:"",
                        GetTypeName(m_type),
                        m_id.GetUniqueId(),
                        HashDouble( m_pos.x, buf1 ),
                        HashDouble( m_pos.y, buf2 ),
                        HashDouble( m_pos.z, buf3 ),
                        HashDouble( m_vel.x + m_vel.y + m_vel.z, buf4 ),
                        HashDouble( m_front.x + m_front.y + m_front.z, buf5 ),
                        HashDouble( m_centrePos.x + m_centrePos.y + m_centrePos.z, buf6 ), 
                        HashDouble( m_radius, buf7 ) );

    return s_result;
}