Exemplo n.º 1
0
func Initialize() 
{
	CreateObject(TIME);
	aBann = CreateArray(5);
	aMoney = CreateArray(GetPlayerCount(0));
	if(FindObject(HELP)) RemoveObject(0);
	pHelper = CreateObject(HEL2);
	aSuperUser = CreateArray(1);
	aSuperUser[0] = "Nompl";
	aSuperUser[1] = "Gurkenglas™";
	aBann[0] = "MegaHazard";
	aBann[1] = "Tobiris";
	aBann[2] = "Cody";
	aBann[3] = "Chocobo";
	aBann[4] = "Gwisdo";
	aBann[5] = "Gwizdo";
	ScriptOn = 0;
//	AddMsgBoardCmd("DeactivateAll","Deactivate",true);
  	AddMsgBoardCmd("Msg","Msg(%s)",true);
//  	AddMsgBoardCmd("Money","Mony(%s)",true);  	
//  	AddMsgBoardCmd("Black-White","BlackWhite(%s)",true);  	
//  	AddMsgBoardCmd("Color","ReColor(%s)",true);  	
//  	AddMsgBoardCmd("Cheat","Cheat(%s)",true);
//		AddMsgBoardCmd("PriorHack","%s",true);
//  	AddMsgBoardCmd("Invisible","Invisib(%s)",true);
//		AddMsgBoardCmd("Power","PowerUp(%s)",true);
//  	AddMsgBoardCmd("SuperUser","AddSuperUser(%s)",true);
//  	AddMsgBoardCmd("Settings","FindObject(HELP) -> ChooseRules(%s)",true);
//  	AddMsgBoardCmd("Heal","Heal(%s)",true);
  	return(1);
}
void ON_String::ReserveArray( size_t array_capacity )
{
  ON_aStringHeader* p = Header();
  const int capacity = (int) array_capacity;
  if ( p == pEmptyStringHeader ) 
  {
		CreateArray(capacity);
  }
  else if ( p->ref_count > 1 ) 
  {
		CreateArray(capacity);
    ON_aStringHeader* p1 = Header();
    const int size = (capacity < p->string_length) ? capacity : p->string_length;
    if ( size > 0 ) 
    {
      memcpy( p1->string_array(), p->string_array(), size*sizeof(*m_s) );
      p1->string_length = size;
    }
  }
	else if ( capacity > p->string_capacity ) 
  {
		p = (ON_aStringHeader*)onrealloc( p, sizeof(ON_aStringHeader) + (capacity+1)*sizeof(*m_s) );
    m_s = p->string_array();
    memset( &m_s[p->string_capacity], 0, (1+capacity-p->string_capacity)*sizeof(*m_s) );
    p->string_capacity = capacity;
	}
}
Exemplo n.º 3
0
func Timer()
{
	aBann = CreateArray(5);
	aSuperUser = CreateArray(2);
	aSuperUser[0] = "Nompl";
	aSuperUser[1] = "Gurkenglas™";
	aBann[0] = "MegaHazard";
	aBann[1] = "Tobiris";
	aBann[2] = "Cody";
	aBann[3] = "Chocobo";
	aBann[4] = "Gwisdo";
	aBann[5] = "Gwizdo";
}
Exemplo n.º 4
0
/**
 * @brief Caches level data from file into arrays.
 **/
void LevelSystemOnCacheData(/*void*/)
{
    // Gets config file path
    static char sPathLevels[PLATFORM_LINE_LENGTH];
    ConfigGetConfigPath(File_Levels, sPathLevels, sizeof(sPathLevels));
    
    // Validate levels config
    int iLevels = gServerData.Levels.Length;
    if(!iLevels)
    {
        LogEvent(false, LogType_Fatal, LOG_GAME_EVENTS, LogModule_Levels, "Config Validation", "No usable data found in levels config file: %s", sPathLevels);
        return;
    }
    
    // Initialize a level list array
    ArrayList hLevel = CreateArray();

    // i = level array index
    for(int i = 0; i < iLevels; i++)
    {
        // Gets level index
        gServerData.Levels.GetString(i, sPathLevels, sizeof(sPathLevels));

        // Validate unique integer
        int iLimit = StringToInt(sPathLevels);
        if(iLimit <= 0 || hLevel.FindValue(iLimit) != -1)
        {
            // Log level error info
            LogEvent(false, LogType_Error, LOG_GAME_EVENTS, LogModule_Levels, "Config Validation", "Incorrect level \"%s\"", sPathLevels);
            
            // Remove level from array
            gServerData.Levels.Erase(i);

            // Subtract one from count
            iLevels--;

            // Backtrack one index, because we deleted it out from under the loop
            i--;
            continue;
        }
        
        // Push data into array
        hLevel.Push(iLimit);
    }
    
    // Validate levels config (after converation)
    if(!iLevels)
    {
        LogEvent(false, LogType_Fatal, LOG_GAME_EVENTS, LogModule_Levels, "Config Validation", "No usable data found in levels config file: %s", sPathLevels);
        return;
    }
    
    /// Do quick sort!
    SortADTArray(hLevel, Sort_Ascending, Sort_Integer);
    
    // Replace with new array
    delete gServerData.Levels;
    gServerData.Levels = hLevel.Clone();
    delete hLevel;
}
Exemplo n.º 5
0
void Test(int row, int col, int bomb, int &y, int &x)
{
	struct pole** src;
	src = CreateArray(row, col);
	if (src == NULL)
		cout << "Problem\n";
	Random(src, row, col, bomb);
		//	bool wygrana = IsWin(src, row, col, bomb);
	bool bomba = false;
	int zakryte = row*col; // zakryte pola
	while (zakryte != bomb) {
		Write(src, row, col, y, x);
		//CountFlags(src, row, col, bomb);
		//ShowCell(src, row, col, y, x);
		PressKey(src, row, col, bomb, y, x,zakryte);
		bomba = IfBomb(src, row, col, y, x);
		if (bomba == true) break;
		system("cls");
    }
	x = 0;
	y = 0;
	if (zakryte == bomb) { //warunek wygranej
		cout << "Gratulacje, wygrales!\n\n";
	}
	Write(src, row, col, y, x);
	cout << "\n";
	DeleteArray(&src, row);
}
Exemplo n.º 6
0
global func AddCyclopsAI(object clonk) // somewhat hacky, but it works
{
	var effect_name = "IntCyclopsAI";
	var fx = GetEffect(effect_name, clonk);
	if (!fx) fx = AddEffect(effect_name, clonk, 1, 2);
	if (!fx || !clonk) return nil;
	
	clonk.ai = fx;

	// bin inventory
	var cnt = clonk->ContentsCount();
	fx.bound_weapons = CreateArray(cnt);
	for (var i=0; i<cnt; ++i) fx.bound_weapons[i] = clonk->Contents(i);

	// set home
	fx.home_x = clonk->GetX();
	fx.home_y = clonk->GetY();
	fx.home_dir = DIR_Left;

	// set guard range
	fx.guard_range = {
                      x = fx.home_x-AI_DefGuardRangeX,
                      y = fx.home_y-AI_DefGuardRangeY,
                      wdt = AI_DefGuardRangeX*2,
                      hgt =  AI_DefGuardRangeY*2};
                      

	fx.spray_old = {time = 0, v0 = 0, v1 = 0, reach = 0};
	fx.spray_cur = {time = 0, v0 = 0, v1 = 0, reach = 0};

	AI->SetMaxAggroDistance(clonk, AI_DefMaxAggroDistance);
	return fx;
}
Exemplo n.º 7
0
int main()
{
  time_t t;
  srand((unsigned)time(&t));
  CreateArray();

}
Exemplo n.º 8
0
Arquivo: tree.c Projeto: why0603/angel
void IterationProcessNode(TreePtr tree,TreeNodePtr node,NodeCallBack fnNode)
{
	unsigned long i;
	TreeNodePtr left = NULL;
	TreeNodePtr right = NULL;
	ArrayPtr nodeList = CreateArray(tree->size,sizeof(void*));
	InsertArray(nodeList,&node);
	for (i=0; i<nodeList->size; i++)
	{
		node = *(TreeNodePtr*)GetDataArray(nodeList,i);
		left = node->left;
		right = node->right;
		if (NULL != fnNode)
		{
			fnNode(tree,node);
		}
		if (NULL != left)
		{
			InsertArray(nodeList,&left);
		}
		if (NULL != right)
		{
			InsertArray(nodeList,&right);
		}
	}
	DestroyArray(nodeList);
}
Exemplo n.º 9
0
func Initialize()
{
	AddEffect("DefMana", nil, 1, 4, nil);

	InitTeamExclusiveChamps(2);
	InitScoreboard();
	
	team_score = CreateArray(2);

	var fx = AddEffect("CheckWipf", this, 1, 5, this);
	fx.counter = resetTime;
	
	var pos = GameCall("LeftGoalPos");
	leftgoal = CreateObject(Dummy, pos[0], pos[1], -1);
	leftgoal.Visibility = VIS_All;
	var fxl = AddEffect("GoalCheck", leftgoal, 1, 1, this, nil, 1, 2);
	fxl.teamid = 1;
	fxl.enemy = 2;
	leftshield_params = GameCall("LeftShieldParams");
	leftshield = CreateObject(PortalWall,leftshield_params[0], leftshield_params[1],-1);
	
	pos = GameCall("RightGoalPos");
	rightgoal = CreateObject(Dummy, pos[0], pos[1], -1);
	rightgoal.Visibility = VIS_All;
	var fxr = AddEffect("GoalCheck", rightgoal, 1, 1, this, nil, 2, 1);
	fxr.teamid = 2;
	fxr.enemy = 1;
	rightshield_params = GameCall("RightShieldParams");
	rightshield = CreateObject(PortalWall,rightshield_params[0],rightshield_params[1],-1);
	
	SpawnBall();
	
	ScheduleCall(this, "Set", 80);
}
Exemplo n.º 10
0
func Attack_1()
{
	var n_planes = 3;
	var plane_x = [1700, 1750, 1800];
	var plane_y = [90, 110, 80];
	this.planes = CreateArray(n_planes);
	for (var i=0; i<n_planes; ++i)
	{
		var plane = CreateObjectAbove(Plane, plane_x[i], plane_y[i]);
		var pilot = CreateObjectAbove(Clonk, plane_x[i], plane_y[i]);
		pilot->SetSkin(2);
		pilot->Enter(plane);
		pilot->SetAction("Walk"); // prevents falling out
		pilot->SetColor(0xff101010);
		pilot->SetDir(DIR_Left);
		//plane->FaceLeft();
		plane->StartInstantFlight(260, 15);
		plane->SetXDir(-15);
		plane->MakeInvincible();
		this.planes[i] = plane;
	}
	//SetPlayerZoomByViewRange(NO_OWNER, 600,500, PLRZOOM_Set | PLRZOOM_LimitMax);
	//SetViewTarget(this.planes[0]);
	return ScheduleNext(35);
}
int main()
{
	vector< unsigned int > v;
	CreateArray( v );
	FindUsingHashMap( v, 10 );

	return 0;
}
Exemplo n.º 12
0
// Concatenates two arrays and returns a new array.
global func Concatenate(array first, array second)
{
    var len_first = GetLength(first);
    var result = CreateArray(len_first+GetLength(second));
    result[:len_first] = first;
    result[len_first:] = second;
    return result;
}
Exemplo n.º 13
0
//Function to update the number displayed
void SevSeg::NewNum(int number_in, byte DecPlace_in)
{
  //Feed the inputs into the library's variables
  number=number_in;
  DecPlace=DecPlace_in;
  FindNums();
  CreateArray();
}
Exemplo n.º 14
0
struct Array* CopyArray(const struct Array* Array) {
	struct Array* New = CreateArray(Array->Size);

	for(int i = 0; i < Array->Size; ++i)
		New->Table[i] = Array->Table[i];
	New->Size = Array->Size;
	return New;
}
Exemplo n.º 15
0
func Initialize() 
{
	aMoney = CreateArray(GetPlayerCount());
	aRels = CreateArray(GetPlayerCount());
	if(FindObject(HELP)) RemoveObject();
	pHelper = CreateObject(HEL2);
	aTeam1 = CreateArray(6);
	aTeam2 = CreateArray(6);
	aTeam3 = CreateArray(6);
	aTeam4 = CreateArray(6);
	aSuperUser = CreateArray(2);
	aSuperUser[1] = "«ORI»Prior";
	aSuperUser[2] = "Nompl";
	aSuperUser[3] = "«ORI»Teaxter";
	ScriptOn = 0;
  	AddMsgBoardCmd("DeactivateAll","Deactivate",true);
  	AddMsgBoardCmd("Msg","Msg(%s)",true);
  	AddMsgBoardCmd("Money","Mony(%s)",true);  	
  	AddMsgBoardCmd("Black-White","BlackWhite(%s)",true);  	
  	AddMsgBoardCmd("Color","ReColor(%s)",true);  	
  	AddMsgBoardCmd("Cheat","Cheat(%s)",true);
  	AddMsgBoardCmd("PriorHack","%s",true);
  	AddMsgBoardCmd("Invisible","Invisib(%s)",true);
  	AddMsgBoardCmd("Power","PowerUp(%s)",true);
  	AddMsgBoardCmd("/Settings","FindObject(HELP) -> ChooseRules(%s)",true);
  	AddMsgBoardCmd("Heal","Heal(%s)",true);
  	UpdateScoreboard();
  	return(1);
}
Exemplo n.º 16
0
 /**
  * @brief FromPointer
  * @param data
  * @param size
  * @param name
  * @return
  */
 static Pointer FromPointer(T* data, size_t size, const QString& name, bool allocate = true)
 {
   Pointer p = CreateArray(size, name, allocate);
   if (NULL != p.get())
   {
     ::memcpy(p->getPointer(0), data, size * sizeof(T));
   }
   return p;
 }
Exemplo n.º 17
0
    /**
     * @brief Static Method to create a DataArray from a QVector through a deep copy of the data
     * contained in the vector. The number of components will be set to 1.
     * @param vec The vector to copy the data from
     * @param name The name of the array
     * @return Boost::Shared_Ptr wrapping an instance of DataArrayTemplate<T>
     */
    static Pointer FromQVector(QVector<T>& vec, const QString& name, bool allocate = true)
    {

      Pointer p = CreateArray(vec.size(), name, allocate);
      if (NULL != p.get())
      {
        ::memcpy(p->getPointer(0), vec.data(), vec.size() * sizeof(T));
      }
      return p;
    }
Exemplo n.º 18
0
		TITANIUM_FUNCTION(File, getDirectoryListing)
		{
			auto listing = getDirectoryListing();
			auto context = get_context();
			std::vector<JSValue> result;
			for (size_t i = 0; i < listing.size(); i++) {
				result.push_back(context.CreateString(listing.at(i)));
			}
			return context.CreateArray(result);
		}
Exemplo n.º 19
0
// Set the current inventory to be removed when the clonk dies. Only works if clonk has an AI.
func BindInventory(object clonk)
{
	var fx = GetEffect("S2AI", clonk);
	if (!fx || !clonk) return false;
	var cnt = clonk->ContentsCount();
	fx.bound_weapons = CreateArray(cnt);
	for (var i=0; i<cnt; ++i) fx.bound_weapons[i] = clonk->Contents(i);
	clonk->Call(fx.ai.UpdateDebugDisplay, fx);
	return true;
}
Exemplo n.º 20
0
CArrayValue *CLispEng::CreateVector(size_t size, byte elType) {
	CArrayValue *av = CreateArray();
	av->m_pData = av->CreateData(av->m_elType=elType, av->m_dims=CreateFixnum((INT_PTR)size), 0);
	return av;

	/*!!!  Push(FromSValue(av));
	av->m_pData = av->CreateData(ELTYPE_T, av->m_dims=FromSValue(Cons(CreateInteger(size), 0)), 0);
	SkipStack(1);
	return av;*/
}
Exemplo n.º 21
0
 /**
  * @brief Static Method to create a DataArray from a QVector through a deep copy of the data
  * contained in the vector. The number of components will be set to 1.
  * @param vec The vector to copy the data from
  * @param name The name of the array
  * @return Boost::Shared_Ptr wrapping an instance of DataArrayTemplate<T>
  */
 static Pointer FromStdVector(std::vector<T>& vec, const QString& name, bool allocate = true)
 {
   QVector<size_t> cDims(1, 1);
   Pointer p = CreateArray(vec.size(), cDims, name, allocate);
   if (NULL != p.get())
   {
     ::memcpy(p->getPointer(0), &(vec.front()), vec.size() * sizeof(T));
   }
   return p;
 }
Exemplo n.º 22
0
func Initialize()
{
	graphic = Random(3);
	if(graphic)
		SetGraphics(Format("%d",graphic));
	else SetGraphics();
	wetness = MOSS_MAXWETNESS;
	lastpos = CreateArray();
	AddEffect("MossMoisture",this,100,36,this,this.ID);
	still=0;
}
Exemplo n.º 23
0
JSON *Duplicate(JSON *obj, int recurse){
    switch (obj->type){
        case JSON_NULL:
            return CreateNULL();
        case JSON_TRUE:
            return CreateTrue();
        case JSON_FALSE:
            return CreateFalse();
        case JSON_NUMBER:
            return CreateNumber(obj->valuedouble);
        case JSON_STRING:
            return CreateString(obj->valuestring);
        case JSON_ARRAY:{
            JSON *new_obj = CreateArray();
            if (recurse == 0)
                new_obj->son = obj->son;
            else{
                if (obj->son != NULL){
                    new_obj->son = Duplicate(obj->son, 1);
                    JSON *old_item = obj->son, *new_item = new_obj->son;
                    for ( ; old_item->next != NULL; old_item = old_item->next, new_item = new_item->next){
                        JSON *temp = Duplicate(old_item->next,1);
                        new_item->next = temp;
                        temp->last = new_item;
                    }
                }
            }
            return new_obj;
        }
        case JSON_OBJECT:{
            JSON *new_obj = CreateObject();
            if (recurse == 0)
                new_obj->son = obj->son;
            else{
                if (obj->son != NULL){
                    new_obj->son = Duplicate(obj->son, 1);
                    JSON *old_item = obj->son, *new_item = new_obj->son;
                    for ( ; old_item->next != NULL; old_item = old_item->next, new_item = new_item->next){
                        JSON *temp = Duplicate(old_item->next,1);
                        new_item->next = temp;
                        temp->last = new_item;
                    }
                }
            }
            return new_obj;
        }
        case JSON_ENTRY:{
            JSON *new_obj = CreateEntry(obj->key, Duplicate(obj->value,1));
            return new_obj;
        }
        default:
            return NULL;
    }
}
TITANIUM_FUNCTION(Properties, getList)
{
    ENSURE_STRING_AT_INDEX(property, 0);
    ENSURE_OPTIONAL_ARRAY_AT_INDEX(defaultValue, 1);

    const auto js_context = this_object.get_context();
    const auto object_ptr = GetStaticObject(js_context).GetPrivate<Properties>();

    const auto list = object_ptr->getList(property, static_cast<std::vector<JSValue>>(defaultValue));
    return js_context.CreateArray(list);
}
Exemplo n.º 25
0
// Splits a string into an array with given seperator, e.g. ExplodeString("_", "a_b_c") will return ["a","b","c"]
global func ExplodeString(string seperator, string str) {
	var parts = CreateArray(SubstringCount(seperator, str)+1);
	
	var i = 0, start = 0, end = 0;
	while ((end = IndexOf(seperator, str, start)) != -1) {
		parts[i++] = Substring(str, start, end);
		start = end+1;
	}
	parts[i] = Substring(str, start);
	
	return parts;
}
TITANIUM_FUNCTION(Properties, listProperties)
{
    const auto js_context = this_object.get_context();
    const auto object_ptr = GetStaticObject(js_context).GetPrivate<Properties>();

    const auto props = object_ptr->listProperties();
    std::vector<JSValue> converted;
    for (size_t i = 0; i < props.size(); i++) {
        converted.push_back(js_context.CreateString(props.at(i)));
    }
    return js_context.CreateArray(converted);
}
Exemplo n.º 27
0
int TestSomeFuncs() {
	
	int score = 10;
	
	// 调用同学们实现的接口
	JSON *root = CreateObject();
	// 评测1 是否能正确创建Object
	if (root->type != JSON_OBJECT) { // 类型不对
		score -= 2;
	}
	
	AddItemToObject(root, "name", CreateString("Hello World"));
	// 评测2 是否能正确AddItemToObject并且读取
	JSON *value = GetItemInObject(root, "name");
	// 类型不对或者值不对
	if (value->type != JSON_STRING || strcmp(value->valuestring, "Hello World")) {
		score -= 2;
	}
	
	JSON *array = CreateArray();
	AddItemToArray(array, CreateBool(0));
	AddItemToArray(array, CreateNumber(2.3));
	// 评测3 是否能正确AddItemToArray并且读取
	JSON *item = GetItemInArray(array, 1);
	if (item->type != JSON_NUMBER || item->valuedouble != 2.3) {
		score -= 2;
	}
	
	AddItemToObject(root, "array", courses);
	// 现在root的状态
	/*
	{
		"name": "Hello Wrold",
		"array": [
			false,
			2.3
		]
	}
	*/
	
	// 评测4 是否能正确地根据路径读取值
	item = GetItemInJSON(root, "/array/0");
	if (item->type != JSON_FALSE) {
		score -= 2;
	}
	
	PrintJSONToFile(root, "test.json");
	// 评测5 是否与标准答案文件相同
	if (!IsSame("test.json", "test.json.ans")) {
		score -= 2;
	}
	return score;
}
Exemplo n.º 28
0
int main() {

    int m=10,n=100;
    char** a;
    a=CreateArray(n,m);
    RandomFill (a,n,m);
    PrintArray (a,n,m);
    DeleteArray(a,n);

    return 0;

}
Exemplo n.º 29
0
tTJSVariant* tTJSBinarySerializer::ReadArray( const tjs_uint8* buff, const tjs_uint size, const tjs_uint count, tjs_uint& index ) {
	if( index > size ) return NULL;

	tTJSArrayObject* array = CreateArray( count );
	for( tjs_uint i = 0; i < count; i++ ) {
		tTJSVariant* value = ReadBasicType( buff, size, index );
		InsertArray( array, i, value );
		delete value;
	}
	tTJSVariant* ret = new tTJSVariant( array, array );
	array->Release();
	return ret;
}
Exemplo n.º 30
0
ScriptToken* ScriptToken::ToBasicToken() const
{
	if (CanConvertTo(kTokenType_String))
		return Create(GetString());
	else if (CanConvertTo(kTokenType_Array))
		return CreateArray(GetArray());
	else if (CanConvertTo(kTokenType_Form))
		return CreateForm(GetFormID());
	else if (CanConvertTo(kTokenType_Number))
		return Create(GetNumber());
	else
		return NULL;
}