int main(int argc, char *argv[])
{
	Stack stack;
	Element item;
	memset(&stack, 0x00, sizeof(Stack));

	item.key = 1;
	printf("Add 1st element into the stack. \n");
	AddStack(&stack, item);
	PrintStack(&stack);

	item.key = 2;
	printf("Add 2nd element into the stack. \n");
	AddStack(&stack, item);
	PrintStack(&stack);

	item.key = 3;
	printf("Add 3rd element into the stack. \n");
	AddStack(&stack, item);
	PrintStack(&stack);

	item.key = 4;
	printf("Add 4th element into the stack. \n");
	AddStack(&stack, item);
	PrintStack(&stack);

	printf("Delete the top element from the stack. \n");
	item = DeleteStack(&stack);
	printf("Delete %d \n", item.key);

	PrintStack(&stack);

	printf("Destroy the stack. \n");
	DestroyStack(&stack);

	
	return 0;
}
Example #2
0
void IPCStackEvent(int argc, char** argv, PLSOBJECT Object)
{
	char* Name = argv[0];
	LSTypeDefinition* Type = pLSInterface->FindLSType(argv[1]);
	char* SubType = argv[2];
	char* Method = argv[3];

	LSOBJECT Stackobject;
	if((Stackobject.Ptr = FindStack(Name)) == 0)
	{
		Stackobject.Ptr = new LSStack(Type, SubType);
		AddStack(Name, (LSStack*)Stackobject.Ptr);
	}
	pStackType->GetMethodEx(Stackobject.GetObjectData(), Method, argc - 4, &argv[4]);
}
Example #3
0
CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock)
{
    if (m_next != NULL) 
    {
        if ( m_next == EOX )
        {
            m_next = NULL;
            return EOX;
        }
        return m_next;                // included in an existing stack
    }
    CBotStack*    p = AddStack(NULL, bBlock);
    p->m_call = instr;
    p->m_bFunc = 2;    // special
    return    p;
}
Example #4
0
void Bag::sellItem(int ID, int amount, char SID) // sell item in bag (pop), SID of the shop
{
	TradeCalculation* tempList;

	RemoveItem(ID, amount);

	if (ItemS[ID - 1].PID != SID)
	{
		SharedData::GetInstance()->SD_bitcoins += (ItemS[ID - 1].bitcoin * amount * 2);
	}
	else
	{
		AddStack(ID, amount, SID);
		SharedData::GetInstance()->SD_bitcoins += (ItemS[ID - 1].bitcoin * amount);
	}
	clearSlot_reLocation();
}
Example #5
0
////////////////////////////////////////
/// DEFAULT PROGRESS CONTOL STACK //////
////////////////////////////////////////
void StyleProgress::CreateDefaultStack()
{
	// define the rects
	GetClientRect(m_ProgRect); CRect EffRect(m_ProgRect); CRect TopRect(m_ProgRect); 

	// some adustments
	EffRect.DeflateRect(1, 1); 
	TopRect.DeflateRect(1, 1); 

	//=============== Background Layers ===================//
	Stack ProgressBack(m_ProgRect, m_BackColor);

	ProgressBack.SetShape(ROUNDRECT, 1);
	ProgressBack.SetOuterBorder(1, RGB(0xB2, 0xB2, 0xB2));
	ProgressBack.SetMiddleBorder(1, Clr(100,White));
	
	ProgressBack.FillBar(EffRect, LEFT_EDGE, 8, Clr(40,Black), Clr(0,Black));
	ProgressBack.FillBar(EffRect, RIGHT_EDGE, 8, Clr(0,Black), Clr(40,Black));

	float btprof[3] = { 0.0f, 0.20f, 1.0f };
	ProgressBack.FillBar(EffRect, TOP_EDGE, 6, Clr(200,White), Clr(241,White), Clr(40,White), btprof);
	float bbprof[3] = { 0.0f, 0.80f, 1.0f };
	ProgressBack.FillBar(EffRect, BOTTOM_EDGE, 6, Clr(0,White), Clr(100,White), Clr(80,White), bbprof);

	//=========== Foreground Layers ======================//

	Stack ProgressFront(TopRect);
	ProgressFront.FillSolid(TopRect, m_ForeColor);

	// top and bottom

	float tprof[3] = { 0.0f, 0.15f, 1.0f };

	ProgressFront.FillBar(TopRect, TOP_EDGE, 6, Clr(180,White), Clr(200,White), Clr(128,White), tprof);
	ProgressFront.FillBar(TopRect, BOTTOM_EDGE, 6, Clr(0,White), Clr(100,White));

	float lprof[3] = { 0.0f, 0.15f, 1.0f };
	float rprof[3] = { 0.0f, 0.85f, 1.0f };

	ProgressFront.FillBar(TopRect, LEFT_EDGE, 20, Clr(20,Black), Clr(40,Black), Clr(0,Black), lprof);
	ProgressFront.FillBar(TopRect, RIGHT_EDGE, 20, Clr(0,Black), Clr(40,Black), Clr(20,Black), rprof);

	// add it to the style
	AddStack(ProgressBack);
	AddStepStack(ProgressFront);
}
Example #6
0
bool CBotStack::RestoreState(FILE* pf, CBotStack* &pStack)
{
    unsigned short    w;

    pStack = NULL;
    if (!ReadWord(pf, w)) return false;
    if ( w == 0 ) return true;

#if    STACKMEM
    if ( this == NULL ) pStack = FirstStack();
    else pStack = AddStack();
#else
    pStack = new CBotStack(this);
#endif

    if ( w == 2 )
    {
        if (!pStack->RestoreState(pf, pStack->m_next2)) return false;
    }

    if (!ReadWord(pf, w)) return false;            // is a local block
    pStack->m_bBlock = w;

    if (!ReadWord(pf, w)) return false;            // in what state ?
    pStack->SetState(static_cast<short>(w));                    // in a good state

    if (!ReadWord(pf, w)) return false;            // dont delete?
                                                // uses more

    if (!ReadWord(pf, w)) return false;            // step by step
    pStack->m_step = w;

    if (!CBotVar::RestoreState(pf, pStack->m_var)) return false;    // temp variable
    if (!CBotVar::RestoreState(pf, pStack->m_listVar)) return false;// local variables

    return pStack->RestoreState(pf, pStack->m_next);
}
Example #7
0
int  CTabBarClass::UpdateAddTab(HANDLE hUpdate, int& tabIdx, int& nCurTab, bool& bStackChanged, CVirtualConsole* pVCon, DWORD nFlags/*UpdateAddTabFlags*/)
{
	CRealConsole *pRCon = pVCon->RCon();
	if (!pRCon)
	{
		_ASSERTE(pRCon!=NULL);
		return 0;
	}

	bool bVConActive = pVCon->isActive(false);
	bool bAllWindows = (gpSet->bShowFarWindows && !(pRCon->GetActiveTabType() & fwt_ModalFarWnd));
	int rFrom = bAllWindows ? 0 : pRCon->GetActiveTab();
	int rFound = 0;

	for (int I = rFrom; bAllWindows || !rFound; I++)
	{
		#ifdef _DEBUG
			if (this != gpConEmu->mp_TabBar)
			{
				_ASSERTE(this == gpConEmu->mp_TabBar);
			}
			MCHKHEAP;
		#endif

		// Check first, if the tab exists
		CTab tab(__FILE__,__LINE__);
		if (!pRCon->GetTab(I, tab))
			break;

		// bShowFarWindows проверяем, чтобы не проколоться с недоступностью единственного таба
		if (gpSet->bHideDisabledTabs && gpSet->bShowFarWindows)
		{
			if (!pRCon->CanActivateFarWindow(I))
				continue;
		}


		#ifdef _DEBUG
			if (this != gpConEmu->mp_TabBar)
			{
				_ASSERTE(this == gpConEmu->mp_TabBar);
			}
			MCHKHEAP;
		#endif

		// Additional flags (to add or not to add)
		if (nFlags & (uat_PanelsOrModalsOnly|uat_PanelsOnly))
		{
			if ((tab->Type() != fwt_Panels))
			{
				if (nFlags & uat_PanelsOnly)
					continue;
				if (!(tab->Flags() & fwt_ModalFarWnd))
					continue;
				// Редакторы/вьюверы из "far /e ..." здесь НЕ добавлять!
				// Они либо показываются как "Консоль" (без сплитов)
				// Либо как отдельный таб редактора
				if (!pRCon->isFarPanelAllowed())
					continue;
			}
		}
		if (nFlags & uat_NonModals)
		{
			// Смысл в том, что если VCon активна,
			// то модальный редактор показан *первой* вкладкой группы (вместо панелей).
			// Для НЕ активных VCon - модальный редактор нужно все-равно допихнуть в табы,
			// а то таб этого редактор вообще не будет виден пользователю.
			if (bVConActive && (tab->Flags() & fwt_ModalFarWnd) && pRCon->isFarPanelAllowed())
				continue;
		}
		if (nFlags & uat_NonPanels)
		{
			if ((tab->Type() == fwt_Panels) && pRCon->isFarPanelAllowed())
				continue;
		}

		// Prepare tab to display
		WARNING("TabIcon, trim words?");
		int iTabIcon = PrepareTab(tab, pVCon);

		#if 0
		vct.pVCon = pVCon;
		vct.nFarWindowId = I;
		#endif


		m_Tabs.UpdateAppend(hUpdate, tab, FALSE);

		// Физически (WinAPI) добавляет закладку, или меняет (при необходимости) заголовок существующей
		mp_Rebar->AddTabInt(tab->GetLabel(), tabIdx, (tab->Flags() & fwt_Elevated)==fwt_Elevated, iTabIcon);

		// Add current (selected) tab to the top of recent stack
		if ((tab->Flags() & fwt_CurrentFarWnd) && bVConActive)
		{
			// !!! RCon must return ONLY ONE active tab !!!
			// with only temorarily exception during edit/view activation from panels

			#ifdef _DEBUG
			static int iFails = 0;
			if (nCurTab == -1)
			{
				iFails = 0;
			}
			else
			{
				_ASSERTE((nCurTab == -1) || (nCurTab == 0 && iFails == 0 && tab->Type() == fwt_Panels));
				iFails++;
			}
			#endif

			nCurTab = tabIdx;
			if (AddStack(tab))
				bStackChanged = true;
		}

		rFound++;
		tabIdx++;


		#ifdef _DEBUG
			if (this != gpConEmu->mp_TabBar)
			{
				_ASSERTE(this == gpConEmu->mp_TabBar);
			}
		#endif
	}

	return rFound;
}
Example #8
0
bool IPCStackType::GetMethod(LSOBJECTDATA &ObjectData, PLSTYPEMETHOD pMethod, int argc, char *argv[])
{
/*******************************************
 * Parameters
 *
 * [in] LSOBJECTDATA ObjectData: ObjectData is a 32-bit value that can be accessed in any number of different ways
 *        by way of union.  Most commonly, ObjectData.Ptr, ObjectData.DWord, or ObjectData.CharPtr are useful.  This
 *        value is the representation of some object of this object type.  "ipcfoo" works on IPCFoo*
 *        so ObjectData is a IPCFoo*
 *
 * [in] PLSTYPEMETHOD pMethod: pMethod is a pointer to the information on the method to be retrieved, including its
 *        Name and ID.  We use the ID in a switch statement in order to quickly process the method, since the Name
 *        has already been resolved by the LavishScript engine.
 *
 * [in] int argc, char *argv[]: argc and argv are *nearly* standard C console program parameters.  The difference here
 *        is that the name of the method is NOT given as the first argument (in contrast to LavishScript commands).
 *        Therefore, argc is 0 unless arguments are specifically given to the method retrieval.
 */

/*******************************************
 * Return Value
 *
 * The return value for this function is very simple.  If the method execution fails for any reason, OR the object
 * is destroyed during execution, return false.  Otherwise, return true (indicating the object still exists AND
 * the method execution succeeded).
 *
 */
	/* Validate the pointer */
	if (!pStack)
		return false;

	/* Perform the given member retrieval */
	switch(pMethod->ID)
	{
	case Push:
		pStack->Stack->Push(argc, argv);
		StackRelay(pStack->IPCName, pStack->Type->GetName(), pStack->SubType, "Stack", argc, argv);
		return true;
	case Pop:
		pStack->Stack->Pop();
		StackRelay(pStack->IPCName, pStack->Type->GetName(), pStack->SubType, "DeStack", argc, argv);
		return true;
	case Clear:
		pStack->Stack->Clear();
		StackRelay(pStack->IPCName, pStack->Type->GetName(), pStack->SubType, "Clear", argc, argv);
		return true;
	case Set:
	case SetIPCName:
		if(argc)
		{
			LSStack *newStack;
			strncpy(pStack->IPCName, argv[0], sizeof(pStack->IPCName));
			if((newStack=FindStack(pStack->IPCName))==0)
			{
				newStack = new LSStack(pStack->Type, pStack->SubType);
				AddStack(pStack->IPCName, newStack);
			}
			pStack->Stack = newStack;
			return true;
		}
		return false;
	case GetIterator:
		LSOBJECT iteratorobject;
		if(argc)
		{
			//printf("%s %s %d", argv[0], pStack->IPCName, pStack->Stack->GetContainerUsed());
			if(pLSInterface->DataParse(argv[0], iteratorobject))
			{
				return InitializeIterator(pStack->Stack, 0, iteratorobject);
			}
		}
		return false;
	}
	return false;
}