Exemple #1
0
void Coord::SetNeighbourList()
{
    //unsigned int step = MAX_NEIGHBOURS + 1;
	for(Crd coord = 0; coord < GetCount(); coord++)
	{
		Crd *head = GetNeighbourList(coord);
		int count = 0;
		for(Crd neighbour = 0; neighbour < GetCount(); neighbour++)
		{
			//policko neni samo sobe sousedem
			int dist = GetDistance(coord, neighbour);
			if( abs(dist) == 1 )
			{
				*head = neighbour;
				head++;
				//neighbourList[coord * step + count] = neighbour;
				count++;
			}
		}
		*head = GetBadCoord();
		if( count < 3)
			throw _Exception("Every coord must have at least 3 neighbours.");
		//neighbourList[coord * step + count]	= GetBadCoord();//oznacuje konec seznamu
	}
}
Exemple #2
0
	ObjectCache(DispatchT obj, NameT name) : _obj(obj), _cache(0), _name(name) {

		tTJSVariant layer;
		TVPExecuteExpression(TJS_W("Layer"), &layer);
		tTJSVariant var;
		if (TJS_SUCCEEDED(layer.AsObjectNoAddRef()->PropGet(TJS_IGNOREPROP, name, NULL, &var, layer.AsObjectNoAddRef()))) _cache = var;
		else _Exception(TJS_W("FAILED: get property object :"));
	}
    void throwException(char const* format, ...)
    {
        va_list arglist;

        va_start(arglist, format);

        char buff[1024] = { 0 };

        vsprintf(buff, format, arglist);

        va_end(arglist);

        throw _Exception(buff);
    }
Exemple #4
0
void Coord::Set(unsigned int width, unsigned int height)
{
	Coord::width = width;
	Coord::height = height;
	Coord::count = width * height;
	unsigned int maxSize = static_cast<unsigned int>( pow(2.0,static_cast<double>(8*sizeof(char))) / 2 - 1);
	if( std::max(width,height) > maxSize)
	{
		char str[256];
		sprintf_s(str,sizeof(str),"Playing board too big, max size is %u",maxSize);
		throw _Exception(str);
	}

	Dealloc();
	distance = new char[count * count];
	direction = new Direction[count * count];
	neighbourList = new Crd[count * (MAX_NEIGHBOURS + 1)];
	influencyList = new Crd[count* directionCount  *(MAX_INFLUENCES_DIRECTION  + 1)];
	SetDistanceDirection();
	SetDirectionShift();
	SetNeighbourList();
	SetInfluencyList();
}
Exemple #5
0
	inline VariantT operator ()(int numparams, VariantT **param) {
		VariantT var;
		if (TJS_FAILED(_cache->FuncCall(0, 0, 0, &var, numparams, param, _obj)))
			_Exception(TJS_W("FAILED: function call :"));
		return var;
	}
Exemple #6
0
	inline VariantT GetValue() const {
		VariantT var;
		if (TJS_FAILED(_cache->PropGet(0, 0, 0, &var, _obj)))
			_Exception(TJS_W("FAILED: get property value :"));
		return var;
	}
Exemple #7
0
	ObjectCache(DispatchT obj, NameT name) : _obj(obj), _cache(0), _name(name) {
		tTJSVariant var;
		if (TJS_SUCCEEDED(obj->PropGet(TJS_IGNOREPROP, name, NULL, &var, _obj))) _cache = var;
		else _Exception(TJS_W("FAILED: get property object :"));
	}
Exemple #8
0
	inline void SetValue(int n) const {
		VariantT var = n;
		if (TJS_FAILED(_cache->PropSet(0, 0, 0, &var, _obj)))
			_Exception(TJS_W("FAILED: get property value :"));
	}