bool psMerchantInfo::Load(PID pid)
{
    bool is_merchant = false;
    
    Result merchant_categories(db->Select("SELECT * from merchant_item_categories where player_id=%u", pid.Unbox()));
    if (merchant_categories.IsValid())
    {
        int i;
        int count=merchant_categories.Count();

        for (i=0;i<count;i++)
        {
            psItemCategory * category = FindCategory(atoi(merchant_categories[i]["category_id"]));
            if (!category)
            {
                Error1("Error! Category could not be loaded. Skipping.\n");
                continue;
            }
            categories.Push(category);
            is_merchant = true;
        }
    }

    return is_merchant;
}
Пример #2
0
void CSoundComponent::PauseCategory(bool pause,const char* catName)
{
	XACTCATEGORY cat=FindCategory( catName );
	if (cat==XACTINDEX_INVALID)
		FAIL(catName,"No such XACT category name");
	//TODO(Pause the category);
	mpXEngine->Pause(cat, pause);
}
Пример #3
0
void CSoundComponent::SetVolume(float volume,const char* catName)
{
	XACTCATEGORY cat=FindCategory( catName );
	if (cat==XACTINDEX_INVALID)
		FAIL(catName,"No such XACT category name");
	//TODO(Set the volume);
	mpXEngine->SetVolume(cat, volume);
}
Пример #4
0
void CSoundComponent::StopCategory(const char* catName)
{
	XACTCATEGORY cat=FindCategory( catName );
	if (cat==XACTINDEX_INVALID)
		FAIL(catName,"No such XACT category name");
	//TODO(Stop the category);
	mpXEngine->Stop(cat, 0);
}
Пример #5
0
//
//    FindField
//	  =========
//
//    Find the specified User Defined Data Field given its name and category in delimited format of
//		category|field
//
CUserDataField*	CUserDataCategoryList::FindField (LPCSTR categoryName ,LPCSTR fieldName)
{
	// First find the category
	CUserDataCategory* pCategory = FindCategory(categoryName);
	if (pCategory == NULL)
		return NULL;
		
	// Now find the field in the category
	return pCategory->FindField(fieldName);	
}
Пример #6
0
void CTravelTab::OnSelchangedCategorytree(NMHDR* pNMHDR, LRESULT* pResult) 
{
	UNREFERENCED_PARAMETER(pResult);
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;

	this->m_clcLocations.SetHotItem(-1);

	HTREEITEM hSelectedItem = NULL;
	HTREEITEM hParentItem = NULL;
	this->m_clcLocations.DeleteAllItems();
	this->m_csCoords.SetWindowText("");
	this->m_cbRemoveLoc.EnableWindow(FALSE);
	this->m_cbEditLoc.EnableWindow(FALSE);

	if (pNMTreeView != NULL)
	{
		HTREEITEM hOldItem = pNMTreeView->itemOld.hItem;
		if (hOldItem != NULL)
			this->m_ctcCategoryTree.SetItemState(hOldItem, 0, TVIS_BOLD);
	}

	hSelectedItem = this->m_ctcCategoryTree.GetSelectedItem();
	this->m_ctcCategoryTree.SetItemState(hSelectedItem, TVIS_BOLD, TVIS_BOLD);
	hParentItem = this->m_ctcCategoryTree.GetParentItem(hSelectedItem);

	if (hParentItem != NULL)
	{
		CString csParent = this->m_ctcCategoryTree.GetItemText(hParentItem);
		CString csSelected = this->m_ctcCategoryTree.GetItemText(hSelectedItem);
		CCategory * pCategory = FindCategory(&Main->m_pScripts->m_olAreas, csParent);
		if (pCategory == NULL)
			return;
		CSubsection * pSubsection = FindSubsection(pCategory, csSelected);
	if (!pSubsection->m_ItemList.IsEmpty())
		{
			POSITION pos = pSubsection->m_ItemList.GetHeadPosition();
			int iCount = 0;
			while (pos != NULL)
			{
				CSObject * pObject = (CSObject *) pSubsection->m_ItemList.GetNext(pos);
				this->m_clcLocations.InsertItem(iCount, pObject->m_csDescription, 0);
				CString cs_ItemID = pObject->m_csID;
				cs_ItemID.MakeLower();
				this->m_clcLocations.SetItemText(iCount, 1, cs_ItemID);
				this->m_clcLocations.SetItemData(iCount, (DWORD_PTR)pObject);
				iCount++;
			}
		}
	}

	iLocSort = 1;
	iCoordSort = 1;
	this->m_clcLocations.SortItems(CompareFunc, 0);		// Sort by Description
	iLocSort = -1;
}
Пример #7
0
bool RuleManager::ListRules(const char *catname, std::vector<const char *> &into) {
	CategoryType cat = InvalidCategory;
	if(catname != nullptr) {
		cat = FindCategory(catname);
		if(cat == InvalidCategory) {
			_log(RULES__ERROR, "Unable to find category '%s'", catname);
			return(false);
		}
	}
	int r;
	int rcount = CountRules();
	for(r = 0; r < rcount; r++) {
		const RuleInfo &rule = s_RuleInfo[r];
		if(catname == nullptr || cat == rule.category) {
			into.push_back(rule.name);
		}
	}
	return(true);
}
Пример #8
0
bool RuleManager::ListRules(const char *catname, std::vector<const char *> &into) {
	CategoryType cat = InvalidCategory;
	if (catname != nullptr) {
		cat = FindCategory(catname);
		if (cat == InvalidCategory) {
			Log.Out(Logs::Detail, Logs::Rules, "Unable to find category '%s'", catname);
			return(false);
		}
	}
	int i;
	int rule_count = CountRules();
	for (i = 0; i < rule_count; i++) {
		const RuleInfo &rule = s_RuleInfo[i];
		if (catname == nullptr || cat == rule.category) {
			into.push_back(rule.name);
		}
	}
	return(true);
}
Пример #9
0
void CTravelTab::OnExitQuicklist() 
{
	HTREEITEM hSelectedItem = NULL;
	HTREEITEM hParentItem = NULL;

	m_clcLocations.SetHotItem(-1);
	m_clcLocations.DeleteAllItems();
	m_csCoords.SetWindowText("");

	hSelectedItem = this->m_ctcCategoryTree.GetSelectedItem();
	hParentItem = this->m_ctcCategoryTree.GetParentItem(hSelectedItem);

	if (hParentItem != NULL)
	{
		CString csParent = this->m_ctcCategoryTree.GetItemText(hParentItem);
		CString csSelected = this->m_ctcCategoryTree.GetItemText(hSelectedItem);
		CCategory * pCategory = FindCategory(&Main->m_pScripts->m_olAreas, csParent);
		if (pCategory == NULL)
			return;
		CSubsection * pSubsection = FindSubsection(pCategory, csSelected);
		if (!pSubsection->m_ItemList.IsEmpty())
		{
			POSITION pos = pSubsection->m_ItemList.GetHeadPosition();
			int iCount = 0;
			while (pos != NULL)
			{
				CSObject * pObject = (CSObject *) pSubsection->m_ItemList.GetNext(pos);
				this->m_clcLocations.InsertItem(iCount, pObject->m_csDescription, iCount);
				CString cs_ItemID = pObject->m_csID;
				cs_ItemID.MakeLower();
				this->m_clcLocations.SetItemText(iCount, 1, cs_ItemID);
				this->m_clcLocations.SetItemData(iCount, (DWORD_PTR)pObject);
				iCount++;
			}
		}
	}

	iLocSort = 1;
	iCoordSort = 1;
	this->m_clcLocations.SortItems(CompareFunc, 0);
	iLocSort = -1;
}
Пример #10
0
bool RuleSet::FixRules() {
  isFixed = true;
  for (int i=0; i<nRules; i++) {
    Rule *r = rules[i]; 
    if (r->Id() && r->Id()->RuleNo() < 0) {
      Message(MSG_WARNING, "help rule", r->Name(), "is not defined");
      isFixed = false;
    } else 
      r->ResolveHelpRules();
    for (RuleTerm *rt = r->FirstRuleTerm(); rt; rt = rt->Next())
      if (rt->GetJump() && rt->GetJump()->GetId()->GetRuleIndex() <= i) {
	Message(MSG_WARNING, r->Name(), "jumps backwards");
	isFixed = false;
      }
    if (!r->IsHelpRule()) {
      if (!r->CategoryName()) {
	Message(MSG_WARNING, "rule", r->Name(), "has no category");
	//isFixed = false;
      } else {
	Category *cat = FindCategory(r->CategoryName());
	if (!cat) {
	  Message(MSG_WARNING, "category", r->CategoryName(), "never declared");
	  isFixed = false;
	} else 
	  for (RuleTerm *rt = r->FirstRuleTerm(); rt; rt = rt->Next())
	    rt->category = cat;
      }
      if (r->FirstRuleTerm() && !r->FirstRuleTerm()->IsScrutinizing() &&
	  r->FirstRuleTerm()->GetInfo()) {
	Message(MSG_WARNING, r->Name(), ", only scrutinizing rules can have info");
	isFixed = false;
      }
    }
  }
  return isFixed;
}
Пример #11
0
int AddClip(char* filename)
{
    CLIP_INFO* pinfo;
    CATEGORY_INFO* cat;
    char buf[256];
    char *p;
    char *s;
    int i;
    s = strrchr(filename, '/');
    if (!(s++)) s = filename;
    if (s[5] == ' ' && atoi(s) > 0) s += 5;
    while (*s == ' ') s++;
    if (*s == '.') return -1;
    pinfo = (CLIP_INFO*)malloc(sizeof(CLIP_INFO));
    pinfo->next = 0;
    pinfo->filename = filename;
    p = strrchr(s, '[');
    if (p)
    {
        // get category
        strcpy(buf, p + 1);
        p = strchr(buf, ']');
        if (p) *p = 0;
        cat = FindCategory(buf);

        // get title
        strcpy(buf, s);
        p = strchr(buf, '[');
        while (--p >= buf && *p == ' ');
        *(p + 1) = 0;
        pinfo->title = FilterDup(buf);
    }
    else
    {
        strcpy(buf, s);
        s = buf;
        if (p = strstr(s, " - "))
        {
            *p = 0;
            cat = FindCategory(s);
            s = p + 3;
            p = strrchr(s, '.');
            if (p) *p = 0;
            pinfo->title = FilterDup(s);
        }
        else if ((p = strchr(s, '-')) || (p = strchr(s, ' ')))
        {
            *p = 0;
            cat = FindCategory(s);
            for (s = p + 1; *s == '-' || *s == ' '; s++);
            p = strrchr(s, '.');
            if (p) *p = 0;
            pinfo->title = FilterDup(s);
        }
        else
        {
            cat = FindCategory(0);
            p = strrchr(s, '.');
            if (p) *p = 0;
            pinfo->title = FilterDup(s);
        }
    }
    pinfo->hash = cat->hash * 10000 + GetTitleHash(pinfo);
    for (i = 0, p = pinfo->title; *p && *p != '(' && *p != '['; p++)
    {
        if (*p < 0)
        {
            p++;
            i++;
        }
        else if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <='Z') || (*p >= '0' && *p <='9'))
        {
            i++;
        }
    }
    pinfo->chars = i;
    charsinfo[(i > MAX_CHARS || i < 1) ? 0 : i]++;

    while (IsHashed(pinfo->hash, 1))
    {
        CATEGORY_INFO* excat;
        CLIP_INFO* exclip = GetClipByHash(pinfo->hash, &excat);
        if (!exclip) break;
        if (excat == cat && !strcmp(exclip->title, pinfo->title))
        {
            fprintf(fpdup, "<li>%06d %s [ <a href='/vodstream?file=%s'>%s</a> ] [ <a href='/vodstream?file=%s'>%s</a> ]</li>\n",
                    pinfo->hash, cat->name, exclip->filename, exclip->title, pinfo->filename, pinfo->title);
        }
        else
        {
            //printf("HASH FAULT @ %06d Exist: %s - %s New: %s - %s\n", pinfo->hash, cat->name, exclip->title, cat->name, pinfo->title);
        }
        pinfo->hash++;
    }

    // add clip to category
    if (!cat->clips)
    {
        cat->clips = pinfo;
    }
    else
    {
        CLIP_INFO *ptr = cat->clips;
        CLIP_INFO *prev = 0;
        for (;;)
        {
            int n = strcmp(ptr->title, pinfo->title);
            if (n > 0)
            {
                if (!prev)
                {
                    pinfo->next = cat->clips;
                    cat->clips = pinfo;
                }
                else
                {
                    pinfo->next = prev->next;
                    prev->next = pinfo;
                }
                break;
            }
            if (!ptr->next)
            {
                ptr->next = pinfo;
                break;
            }
            prev = ptr;
            ptr = ptr->next;
        }
    }
    return 0;
}
Пример #12
0
void CTravelTab::OnEditLoc() 
{
	int iSel = m_clcLocations.GetNextItem(-1, LVNI_SELECTED);
	if (iSel == -1)
		return;

	CSObject * pLoc = (CSObject *) m_clcLocations.GetItemData(iSel);
	if ( !pLoc )
		return;

	CAddDestination dlgAdd;
	dlgAdd.m_pCategoryList = &Main->m_pScripts->m_olAreas;

	dlgAdd.m_csDescription = pLoc->m_csDescription;
	dlgAdd.m_csCategory = pLoc->m_csCategory;
	dlgAdd.m_csSubsection = pLoc->m_csSubsection;

	CString csCoords, csMap;
	m_csCoords.GetWindowText(csCoords);
	m_ceMapPlane.GetWindowTextA(csMap);
	dlgAdd.m_csXCoord = csCoords.SpanExcluding(",");
	dlgAdd.m_csYCoord = csCoords.Mid(csCoords.Find(",") + 1);
	dlgAdd.m_csZCoord = dlgAdd.m_csYCoord.Mid(dlgAdd.m_csYCoord.Find(",") + 1);
	dlgAdd.m_csYCoord = dlgAdd.m_csYCoord.SpanExcluding(",");
	dlgAdd.m_csPlane = csMap;

	if (dlgAdd.DoModal() == IDOK)
	{
		OnRemoveLoc();
		CString csCategory = dlgAdd.m_csCategory;
		CString csSubsection = dlgAdd.m_csSubsection;
		CString csDescription = dlgAdd.m_csDescription;
		CString csX = dlgAdd.m_csXCoord;
		CString csY = dlgAdd.m_csYCoord;
		CString csZ = dlgAdd.m_csZCoord;
		CString csM = dlgAdd.m_csPlane;
		CString csPoint;
		csPoint.Format("%s,%s,%s", csX, csY, csZ);

		// Make sure an entry with this name doesn't already exist
		CCategory * pCategory = FindCategory(&Main->m_pScripts->m_olAreas, csCategory);
		CSObject * pObj = NULL;
		if (pCategory != NULL)
		{
			CSubsection * pSubsection = FindSubsection(pCategory, csSubsection);
			if (pSubsection != NULL)
			{
				POSITION pos = pSubsection->m_ItemList.GetHeadPosition();
				while ( pos )
				{
					CSObject * pObject = (CSObject *) pSubsection->m_ItemList.GetNext(pos);
					if ( pObject != NULL )
					{
						if ( pObject->m_csDescription == csDescription )
						{
							pObj = pObject;
							break;
						}
						continue;
					}
				}
			}
		}
		
		if (pObj != NULL)
		{
			AfxMessageBox("An entry with that name already exists.", MB_OK);
			return;
		}
		CSObject * pLoc = new CSObject;
		pLoc->m_bCustom = true;
		pLoc->m_csCategory = csCategory;
		pLoc->m_csSubsection = csSubsection;
		pLoc->m_csDescription = csDescription;
		pLoc->m_bType = TYPE_AREA;
		pLoc->m_csID = csPoint;
		pLoc->m_csDisplay = csM;

		Main->m_pScripts->m_aAreas.Add(pLoc);
		CString csKey;
		csKey.Format("%s\\%s\\%s\\%s",REGKEY_LOCATION, csCategory, csSubsection, csDescription);
		Main->PutRegistryString("Point", csPoint, hRegLocation, csKey);
		Main->PutRegistryString("Map", csM, hRegLocation, csKey);
		pCategory = FindCategory(&Main->m_pScripts->m_olAreas, pLoc->m_csCategory);
		pSubsection = FindSubsection(pCategory, pLoc->m_csSubsection);
		if ( pSubsection->m_ItemList.IsEmpty() )
			pSubsection->m_ItemList.AddHead( pLoc );
		else
			pSubsection->m_ItemList.AddTail( pLoc );

		FillCategoryTree();
		SelectTreeItem(csCategory, csSubsection);
	}
}
Пример #13
0
void CTravelTab::OnRemoveLoc() 
{
	CString csCategory;
	CString csSubsection;
	CString csDescription;

	HTREEITEM hCategory, hSubsection;
	hSubsection = this->m_ctcCategoryTree.GetSelectedItem();
	if (hSubsection != NULL)
	{
		hCategory = this->m_ctcCategoryTree.GetParentItem(hSubsection);
		if (hCategory == NULL)
			return;
	}

	csCategory = this->m_ctcCategoryTree.GetItemText(hCategory);
	csSubsection = this->m_ctcCategoryTree.GetItemText(hSubsection);
	int iItemSel = this->m_clcLocations.GetNextItem(-1, LVNI_SELECTED);
	if (iItemSel == -1)
		return;
	
	CCategory * pCategory = FindCategory(&Main->m_pScripts->m_olAreas, csCategory, false);
	CSubsection * pSubsection = FindSubsection(pCategory, csSubsection, false);

	CSObject * pLoc = (CSObject *)this->m_clcLocations.GetItemData(iItemSel);

	csDescription = pLoc->m_csDescription;

	POSITION pos = pSubsection->m_ItemList.Find(pLoc);
	if ( pos )
		pSubsection->m_ItemList.RemoveAt(pos);

	for ( int i = 0; i < Main->m_pScripts->m_aAreas.GetSize(); i++ )
	{
		CSObject * pTest = (CSObject *) Main->m_pScripts->m_aAreas.GetAt(i);
		if ( pTest == pLoc )
		{
			Main->m_pScripts->m_aAreas.RemoveAt(i);
			delete pLoc;
			break;
		}
	}
	CString csKey;
	csKey.Format("%s\\%s\\%s\\%s", REGKEY_LOCATION, csCategory, csSubsection, csDescription);
	Main->DeleteRegistryKey(csKey);

	if ( pSubsection->m_ItemList.IsEmpty() )
	{
		csKey.Format("%s\\%s\\%s", REGKEY_LOCATION, csCategory, csSubsection);
		Main->DeleteRegistryKey(csKey);
		POSITION pos = pCategory->m_SubsectionList.Find(pSubsection);
		if ( pos )
			pCategory->m_SubsectionList.RemoveAt(pos);
	}

	if ( pCategory->m_SubsectionList.IsEmpty() )
	{
		csKey.Format("%s\\%s", REGKEY_LOCATION, csCategory);
		Main->DeleteRegistryKey(csKey);
		POSITION pos = Main->m_pScripts->m_olAreas.Find(pCategory);
		if ( pos )
			Main->m_pScripts->m_olAreas.RemoveAt(pos);
	}

	FillCategoryTree();
	SelectTreeItem(csCategory, csSubsection);
}
Пример #14
0
void CTravelTab::Find(CString csString, int iCrit, bool bPrevious)
{
	CString csCategory,csSubsection;
	if ( csString != "" )
	{
		// this is a new search
		hCat = this->m_ctcCategoryTree.GetRootItem();
		hSub = this->m_ctcCategoryTree.GetChildItem( hCat );
		csCategory = this->m_ctcCategoryTree.GetItemText(hCat);
		csSubsection = this->m_ctcCategoryTree.GetItemText(hSub);
		pCategory = FindCategory(&Main->m_pScripts->m_olAreas, csCategory);
		pSubsection = FindSubsection(pCategory, csSubsection);
		pos = pSubsection->m_ItemList.GetHeadPosition();
		csString.MakeLower();
		this->m_csSearchValue = csString;
		this->m_iSearchCrit = iCrit;
	}

	while ( hCat != NULL )
	{
		if (pCategory != NULL)
		{
			while ( hSub != NULL )
			{
				if (pSubsection != NULL)
				{
					if (!pSubsection->m_ItemList.IsEmpty())
					{
						while (pos != NULL)
						{
							CSObject * pItem = NULL;
							if ( !bPrevious )
								pItem = (CSObject *) pSubsection->m_ItemList.GetNext(pos);
							else
								pItem = (CSObject *) pSubsection->m_ItemList.GetPrev(pos);
							CString csValue;
							if (this->m_iSearchCrit == 2)
								csValue = pItem->m_csDescription;
							else if (this->m_iSearchCrit == 1)
								csValue = pItem->m_csValue;
							else
								csValue = pItem->m_csID;
							csValue.MakeLower();
							CSObject * pSelection = NULL;
							if ( csValue.Find( this->m_csSearchValue ) != -1 )
								pSelection = pItem;

							if ( pSelection != NULL )
							{
								this->m_ctcCategoryTree.SelectItem( hSub );
								for ( int i = 0; i < this->m_clcLocations.GetItemCount(); i++ )
								{
									CSObject * pObject = (CSObject *) this->m_clcLocations.GetItemData(i);
									if ( pObject == pSelection )
									{
										this->m_clcLocations.SetItemState( i, LVIS_SELECTED, LVIS_SELECTED );
										this->m_clcLocations.EnsureVisible( i, FALSE );
										return;
									}
								}
								return;
							}
						}
					}
				}
				if ( !bPrevious )
				{
					hSub = this->m_ctcCategoryTree.GetNextItem( hSub, TVGN_NEXT );
					csSubsection = this->m_ctcCategoryTree.GetItemText(hSub);
					pSubsection = FindSubsection(pCategory, csSubsection);
					pos = pSubsection->m_ItemList.GetHeadPosition();
				}
				else
				{
					hSub = this->m_ctcCategoryTree.GetNextItem( hSub, TVGN_PREVIOUS );
					csSubsection = this->m_ctcCategoryTree.GetItemText(hSub);
					pSubsection = FindSubsection(pCategory, csSubsection);
					pos = pSubsection->m_ItemList.GetTailPosition();
				}
			}
		}
		if ( !bPrevious )
		{
			if (!this->m_ctcCategoryTree.GetNextItem( hCat, TVGN_NEXT ))
			{
				AfxMessageBox("Reached Bottom of list", MB_OK | MB_ICONINFORMATION);
				return;
			}
			hCat = this->m_ctcCategoryTree.GetNextItem( hCat, TVGN_NEXT );
			hSub = this->m_ctcCategoryTree.GetChildItem( hCat );
			csCategory = this->m_ctcCategoryTree.GetItemText(hCat);
			pCategory = FindCategory(&Main->m_pScripts->m_olAreas, csCategory);
			csSubsection = this->m_ctcCategoryTree.GetItemText(hSub);
			pSubsection = FindSubsection(pCategory, csSubsection);
			pos = pSubsection->m_ItemList.GetHeadPosition();
		}
		else
		{
			if (!this->m_ctcCategoryTree.GetNextItem( hCat, TVGN_PREVIOUS ))
			{
				AfxMessageBox("Reached top of list", MB_OK | MB_ICONINFORMATION);
				return;
			}
			hCat = this->m_ctcCategoryTree.GetNextItem( hCat, TVGN_PREVIOUS );
			hSub = this->m_ctcCategoryTree.GetChildItem( hCat );
			while (this->m_ctcCategoryTree.GetNextItem( hSub, TVGN_NEXT ) != NULL)
			{
				hSub = this->m_ctcCategoryTree.GetNextItem( hSub, TVGN_NEXT );
			}
			csCategory = this->m_ctcCategoryTree.GetItemText(hCat);
			pCategory = FindCategory(&Main->m_pScripts->m_olAreas, csCategory);
			csSubsection = this->m_ctcCategoryTree.GetItemText(hSub);
			pSubsection = FindSubsection(pCategory, csSubsection);
			pos = pSubsection->m_ItemList.GetTailPosition();
		}
	}
	AfxMessageBox("No matching item was found", MB_OK | MB_ICONINFORMATION);
}