Ejemplo n.º 1
0
BroadPhase::BroadPhase(void) : needsResync(false)
{
    first = 0;
    second = 1;
    third = 2;
    overlapMask = (unsigned char*)malloc(sizeof(unsigned char) * 2500);
    for (int i = 0; i < 8; ++i)
    {
        overlapBitMask[i] = 1 << i;
    }
    maxPairs = 10000;
    maskByteSize = 2500;
    for (int i = 0; i < 10; ++i)
    {
        bodies.push_back(new RigidBody());
    }
    memset(overlapMask, 0, sizeof(unsigned char) * maskByteSize);
    SetMask(0, 4, 1);
    SetMask(5, 5, 0);
    SetMask(1, 4, 0);
    SetMask(2, 6, 1);
    if (!CheckMask(0, 4, 1) || !CheckMask(5, 5, 0) || !CheckMask(1, 4, 0) || !CheckMask(2, 6, 1))
    {
        int k = 0;
    }
    if (CheckMask(3, 7, 1) || CheckMask(2, 8, 0) || CheckMask(3, 1, 1) || CheckMask(2, 9, 9))
    {
        int k = 0;
    }
    for (int i = 0; i < 10; ++i)
    {
        delete bodies[i];
    }
    bodies.clear();
}
Ejemplo n.º 2
0
bool Filter_c::CheckAnySequence ( const wchar_t * szFileStart, const wchar_t * szFilterStart ) const
{
	Assert ( szFileStart && szFilterStart );
	const wchar_t * szPattern = szFilterStart;

	// determine pattern to match
	while ( *szPattern && *szPattern != L'*' && *szPattern != L'?' && *szPattern != L'[' )
		++szPattern;

	// match a pattern
	int iPatternLen = szPattern - szFilterStart;
	const wchar_t * szMatch = szFileStart;
	while ( ( szMatch = TryToMatch ( szFilterStart, iPatternLen, szMatch ) ) != NULL )
	{
		if ( CheckMask ( szMatch + iPatternLen, szFilterStart + iPatternLen, false ) )
			return true;

		if ( *szMatch )
			++szMatch;
		else
			break;
	}

	return false;
}
Ejemplo n.º 3
0
bool Filter_c::FitsMask ( const wchar_t * szFile, const wchar_t * szMask ) const
{
	Str_c sNameToMatch ( szFile );
	if ( sNameToMatch.Find ( L'.' ) == -1 )
		sNameToMatch += L".";

	return CheckMask ( sNameToMatch, szMask, true );
}
Ejemplo n.º 4
0
void MaskedDateReader :: SetMask( const string & mask ) {

    if ( mask.size() != 5 ) {
        CSVTHROW( "Invalid date mask: " << mask );
    }

    mSep[0] = mSep[1] = "";

    mDMY[0] = CheckMask( mask[0] );
    mSep[0] += mask[1];
    mDMY[1] = CheckMask( mask[2] );
    mSep[1] += mask[3];
    mDMY[2] = CheckMask( mask[4] );

    if ( isalnum( mSep[0][0] ) || isalnum( mSep[1][0] ) ) {
        CSVTHROW( "Invalid separator in date mask: " << mask );
    }

    int n = 'd' + 'm' + 'y';
    if ( mDMY[0] + mDMY[1] + mDMY[2] != n ) {
        CSVTHROW( "Invalid date mask: " << mask );
    }
}
Ejemplo n.º 5
0
void CTextureAssembler::AccumulateRMResources(hgeResourceManager *rm, int resgroup, char *mask_set, bool bMaskInclusive)
{
    ResDesc *resdesc;

    // RES_SPRITE
    resdesc = rm->res[7];

    while(resdesc)
    {
        if(!resgroup || resdesc->resgroup == resgroup)
            if(CheckMask(resdesc->name, mask_set, bMaskInclusive))
                if(!FindObj(obj_list, resdesc->name))
                {
                    obj_list.push_back(new CSpriteObject((hgeSprite *)resdesc->Get(rm), resdesc->name, resdesc->resgroup, false));
                }

        resdesc = resdesc->next;
    }
}
Ejemplo n.º 6
0
////////////////////////////////////////////////////////////
// output func
HLog& HLog::Output(int type, char const* fmt, ...) {
    // check input
    if (!base_type::good()) return *this;
    if (!CheckMask(type)) return *this;
    if (fmt == NULL) return *this;

    // get user-define content
    char tmp[MAX_LOG_SIZE];
    va_list ap;
    va_start(ap, fmt);
    vsnprintf(tmp, sizeof(tmp), fmt, ap);
    va_end(ap);

    // do ouotput
    base_type::write(tmp, strnlen(tmp, sizeof(tmp)));
    base_type::flush();

    return *this;
}
Ejemplo n.º 7
0
/// Returns true, if coast on the map tile field
bool CMapField::RockOnMap() const
{
	return CheckMask(MapFieldRocks);
}
Ejemplo n.º 8
0
/// Returns true, if water on the map tile field
bool CMapField::ForestOnMap() const
{
	return CheckMask(MapFieldForest);
}
Ejemplo n.º 9
0
/// Returns true, if coast on the map tile field
bool CMapField::CoastOnMap() const
{
	return CheckMask(MapFieldCoastAllowed);
}
Ejemplo n.º 10
0
/// Returns true, if water on the map tile field
bool CMapField::WaterOnMap() const
{
	return CheckMask(MapFieldWaterAllowed);
}
Ejemplo n.º 11
0
void BroadPhase::GenerateCollisions()
{
    int numPairs = bodies.size() * bodies.size();
    memset(overlapMask, 0, sizeof(unsigned char) * maskByteSize);
    pairs.clear();
    if (numPairs > maxPairs)
        ReallocateMask();

    if (bodies.size() * 2 < entries[0].size())
    {
        GenerateEntries();
    }
    else if(newBodies.size() > 0)
    {
        UpdateEntries();
        AddEntries();	//this way the newly added entries won't get updated since they will already be up to date
    }
    else
    {
        UpdateEntries();
    }
    SortEntries();

    indexActive.clear();

    for (int i = 0; i < entries[first].size(); ++i)
    {
        if (entries[first][i].start)
        {
            indexActive.push_back(entries[first][i].index);
            for (int j = 0; j < indexActive.size() - 1; ++j)
            {
                SetMask(entries[first][i].index, indexActive[j], 0);
            }
        }
        else
        {
            for (int j = 0; j < indexActive.size(); ++j)
            {
                if (indexActive[j] == entries[first][i].index)
                    indexActive.erase(indexActive.begin() + j);
            }
        }
    }

    for (int i = 0; i < entries[second].size(); ++i)
    {
        if (entries[second][i].start)
        {
            indexActive.push_back(entries[second][i].index);
            for (int j = 0; j < indexActive.size() - 1; ++j)
            {
                SetMask(entries[second][i].index, indexActive[j], 1);
            }
        }
        else
        {
            for (int j = 0; j < indexActive.size(); ++j)
            {
                if (indexActive[j] == entries[second][i].index)
                    indexActive.erase(indexActive.begin() + j);
            }
        }
    }

    for (int i = 0; i < entries[third].size(); ++i)
    {
        if (entries[third][i].start)
        {
            indexActive.push_back(entries[third][i].index);
            for (int j = 0; j < indexActive.size() - 1; ++j)
            {
                if (CheckMask(entries[third][i].index, indexActive[j], 0) && CheckMask(entries[third][i].index, indexActive[j], 1))
                {
                    BroadPhasePair pair;
                    pair.p1 = bodies[entries[third][i].index];
                    pair.p2 = bodies[indexActive[j]];
                    pair.p1->SetDebugColour(Vec4(1, 0, 0, 1));
                    pair.p2->SetDebugColour(Vec4(1, 0, 0, 1));
                    pairs.push_back(pair);
                }
            }
        }
        else
        {
            for (int j = 0; j < indexActive.size(); ++j)
            {
                if (indexActive[j] == entries[third][i].index)
                    indexActive.erase(indexActive.begin() + j);
            }
        }
    }
}
Ejemplo n.º 12
0
void CTextureAssembler::AccumulateFileResources(char *wildcard, int resgroup, char *mask_set, bool bMaskInclusive)
{
    HANDLE				hSearch;
    WIN32_FIND_DATA		SearchData;
    char				filename[MAX_PATH];
    char				temp[MAX_PATH];
    char				*buf;

    HTEXTURE			tex;
    hgeSprite			*spr;


    hSearch = FindFirstFile(wildcard, &SearchData);

    if(hSearch == INVALID_HANDLE_VALUE)
    {
        SysLog("Can't find the path: %s\n", wildcard);
        return;
    }

    do
    {
        // recurse subfolders

        if(SearchData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {
            if(SearchData.cFileName[0] == '.') continue;

            strcpy(filename, wildcard);
            buf=strrchr(filename, '\\');
            if(!buf) buf=filename;
            else buf++;

            strcpy(temp, buf);
            strcpy(buf, SearchData.cFileName);
            strcat(filename, "\\");
            strcat(filename, temp);

            AccumulateFileResources(filename, resgroup, mask_set, bMaskInclusive);
        }

        // process a file

        else
        {
            if(CheckMask(SearchData.cFileName, mask_set, bMaskInclusive))
                if(!FindObj(obj_list, SearchData.cFileName))
                {
                    strcpy(filename, wildcard);
                    buf=strrchr(filename, '\\');
                    if(!buf) buf=filename;
                    else buf++;
                    strcpy(buf, SearchData.cFileName);

                    tex = hge->Texture_Load(filename);
                    if(!tex)
                    {
                        SysLog("Can't load texture: %s\n", filename);
                        continue;
                    }

                    spr = new hgeSprite(tex, 0, 0,
                                        (float)hge->Texture_GetWidth(tex, true),
                                        (float)hge->Texture_GetHeight(tex, true));

                    buf = new char[strlen(SearchData.cFileName)+1];
                    strcpy(buf, SearchData.cFileName);

                    obj_list.push_back(new CSpriteObject(spr, buf, resgroup, true));
                }
        }

    } while(FindNextFile(hSearch, &SearchData));

    FindClose(hSearch);
}
Ejemplo n.º 13
0
static void HandleAlarm(int sig)
{
    printf("Got VTALRM\n");
    CheckMask();
}
Ejemplo n.º 14
0
static void HandleSegv(int sig)
{
    printf("Got SEGV\n");
    CheckMask();
    exit(0);
}