Пример #1
0
SGridLocation* CPartitionGrid::Rellocate( SGridLocation* obj,const Vec3 &newPos,CEntity* pEntity )
{
	FUNCTION_PROFILER(GetISystem(),PROFILE_ENTITY);

	if (m_bResetting)
	{
		return 0;
	}

	if (obj)
	{
		LocationInfo from,to;
		GetSector(obj->nSectorIndex,from);
		GetSector(newPos,to);
		if (from.sector != to.sector)
		{
			// Relink object between sectors.
			SectorUnlink( obj,from );
			if (to.sector)
			{
				SectorLink( obj,to );
				if (from.group && from.group->nLocationCount <= 0)
					FreeGroup(from);
			}
			else
			{
				FreeLocation(obj);
				obj = 0;
			}
		}
	}
	else if (fabs(newPos.x) > 0.1f || fabs(newPos.y) > 0.1f)
	{
		// Allocate a new sector location.
		LocationInfo to;
		GetSector(newPos,to);
		if (to.sector)
		{
			obj          = AllocateLocation();
			obj->pEntity = pEntity;
			if (pEntity)
			{
				obj->pEntityClass = pEntity->GetClass();
				obj->nEntityFlags = pEntity->GetFlags();
			}
			SectorLink( obj,to );
		}
	}
	return obj;
}
Пример #2
0
void FreeGroup(struct ClcGroup *group)
{
	int i;
	if (group==NULL||IsBadCodePtr((FARPROC)group)) return;

	for(i=0;i<group->contactCount;i++) {
		if(group->contact && group->contact[i].type==CLCIT_GROUP) {
			FreeGroup(group->contact[i].group);
			mir_free(group->contact[i].group);      //**//
		}
	}
	if(group->allocedCount)
	{	
		if (group->contact->SubAllocated)
		{
			if (group->contact->subcontacts && !group->contact->isSubcontact) 
			{
				int i;
				for ( i = 0 ; i < group->contact->SubAllocated ; i++ )
				{
					Cache_DestroySmileyList(group->contact->subcontacts[i].plText);
					Cache_DestroySmileyList(group->contact->subcontacts[i].plSecondLineText);
					Cache_DestroySmileyList(group->contact->subcontacts[i].plThirdLineText);
          if (group->contact->subcontacts[i].szText) mir_free(group->contact->subcontacts[i].szText);
          if (group->contact->subcontacts[i].szSecondLineText) mir_free(group->contact->subcontacts[i].szSecondLineText);
          if (group->contact->subcontacts[i].szThirdLineText) mir_free(group->contact->subcontacts[i].szThirdLineText);
				}

				mir_free(group->contact->subcontacts);
			}
		}

		if(group->contact) 
		{
			Cache_DestroySmileyList(group->contact->plText);
			Cache_DestroySmileyList(group->contact->plSecondLineText);
			Cache_DestroySmileyList(group->contact->plThirdLineText);
      if (group->contact->szText) mir_free(group->contact->szText);
      if (group->contact->szSecondLineText) mir_free(group->contact->szSecondLineText);
      if (group->contact->szThirdLineText) mir_free(group->contact->szThirdLineText);
			mir_free(group->contact);
		}
	}
	group->allocedCount=0;
    //mir_free(group->contact);
	group->contact=NULL;
	group->contactCount=0;   
	ClearRowByIndexCache();
}
Пример #3
0
void CPartitionGrid::FreeLocation( SGridLocation* obj )
{
	if (obj && !m_bResetting)
	{
		LocationInfo locInfo;
		GetSector(obj->nSectorIndex,locInfo);
		if (locInfo.sector)
		{
			SectorUnlink( obj,locInfo );
			if (locInfo.group->nLocationCount <= 0)
				FreeGroup(locInfo);
		}
		delete obj;
	}
}
Пример #4
0
struct ClcGroup *RemoveItemFromGroup(HWND hwnd,struct ClcGroup *group,struct ClcContact *contact,int updateTotalCount)
{
	int iContact;
	struct ClcData* dat=(struct ClcData*)GetWindowLong(hwnd,0);

	
	ClearRowByIndexCache();
	if(contact->type==CLCIT_CONTACT) ClearClcContactCache(dat,contact->hContact);

	iContact=((unsigned)contact-(unsigned)group->contact)/sizeof(struct ClcContact);
	if(iContact>=group->contactCount) return group;
	if(contact->type==CLCIT_GROUP) {
		FreeGroup(contact->group);
		mir_free(contact->group);
	}
	group->contactCount--;
	if(updateTotalCount && contact->type==CLCIT_CONTACT) group->totalMembers--;
	// free on contact deletion)
	if (contact->szText) mir_free(contact->szText);
	if (contact->szSecondLineText) mir_free(contact->szSecondLineText);
	if (contact->szThirdLineText) mir_free(contact->szThirdLineText);
	memmove(group->contact+iContact,group->contact+iContact+1,sizeof(struct ClcContact)*(group->contactCount-iContact));
	if((GetWindowLong(hwnd,GWL_STYLE)&CLS_HIDEEMPTYGROUPS) && group->contactCount==0) {
		int i;
		if(group->parent==NULL) return group;
		for(i=0;i<group->parent->contactCount;i++)
			if(group->parent->contact[i].type==CLCIT_GROUP 
				&& group->parent->contact[i].groupId==group->groupId) break;
		if(i==group->parent->contactCount) return group;  //never happens
		return RemoveItemFromGroup(hwnd,group->parent,&group->parent->contact[i],0);
	}

	
	ClearRowByIndexCache();
	return group;
}
Пример #5
0
void SaveStateAndRebuildList(HWND hwnd,struct ClcData *dat)
{
	NMCLISTCONTROL nm;
	int i,j;
	struct SavedGroupState_t *savedGroup=NULL;
	int savedGroupCount=0,savedGroupAlloced=0;
	struct SavedContactState_t *savedContact=NULL;
	int savedContactCount=0,savedContactAlloced=0;
	struct SavedInfoState_t *savedInfo=NULL;
	int savedInfoCount=0,savedInfoAlloced=0;
	struct ClcGroup *group;
	struct ClcContact *contact;

	int tick=GetTickCount();
	int allocstep=1024;

  TRACE("SaveStateAndRebuildList\n");

	HideInfoTip(hwnd,dat);
	KillTimer(hwnd,TIMERID_INFOTIP);
  KillTimer(hwnd,TIMERID_REBUILDAFTER);
	KillTimer(hwnd,TIMERID_RENAME);
	EndRename(hwnd,dat,1);

	group=&dat->list;
	group->scanIndex=0;
	for(;;) {
		if(group->scanIndex==group->contactCount) {
			group=group->parent;
			if(group==NULL) break;
		}
		else if(group->contact[group->scanIndex].type==CLCIT_GROUP) {
			group=group->contact[group->scanIndex].group;
			group->scanIndex=0;
			if(++savedGroupCount>savedGroupAlloced) {
				savedGroupAlloced+=allocstep;
				savedGroup=(struct SavedGroupState_t*)mir_realloc(savedGroup,sizeof(struct SavedGroupState_t)*savedGroupAlloced);
			}
			savedGroup[savedGroupCount-1].groupId=group->groupId;
			savedGroup[savedGroupCount-1].expanded=group->expanded;
			continue;
		}
		else if(group->contact[group->scanIndex].type==CLCIT_CONTACT) {			
			if(++savedContactCount>savedContactAlloced) {
				savedContactAlloced+=allocstep;
				savedContact=(struct SavedContactState_t*)mir_realloc(savedContact,sizeof(struct SavedContactState_t)*savedContactAlloced);
			}
			savedContact[savedContactCount-1].hContact=group->contact[group->scanIndex].hContact;
			CopyMemory(savedContact[savedContactCount-1].iExtraImage,group->contact[group->scanIndex].iExtraImage,sizeof(group->contact[group->scanIndex].iExtraImage));
			savedContact[savedContactCount-1].checked=group->contact[group->scanIndex].flags&CONTACTF_CHECKED;
			if (group->contact[group->scanIndex].SubAllocated>0)
			{
				int l;
				for (l=0; l<group->contact[group->scanIndex].SubAllocated; l++)
				{
					if(++savedContactCount>savedContactAlloced) {
						savedContactAlloced+=allocstep;
						savedContact=(struct SavedContactState_t*)mir_realloc(savedContact,sizeof(struct SavedContactState_t)*savedContactAlloced);
					}
					savedContact[savedContactCount-1].hContact=group->contact[group->scanIndex].subcontacts[l].hContact;
					CopyMemory(savedContact[savedContactCount-1].iExtraImage ,group->contact[group->scanIndex].subcontacts[l].iExtraImage,sizeof(group->contact[group->scanIndex].iExtraImage));
					savedContact[savedContactCount-1].checked=group->contact[group->scanIndex].subcontacts[l].flags&CONTACTF_CHECKED;
                    

				}
			}

		}
		else if(group->contact[group->scanIndex].type==CLCIT_INFO) {
			if(++savedInfoCount>savedInfoAlloced) {
				savedInfoAlloced+=allocstep;
				savedInfo=(struct SavedInfoState_t*)mir_realloc(savedInfo,sizeof(struct SavedInfoState_t)*savedInfoAlloced);
			}
			if(group->parent==NULL) savedInfo[savedInfoCount-1].parentId=-1;
			else savedInfo[savedInfoCount-1].parentId=group->groupId;
			savedInfo[savedInfoCount-1].contact=group->contact[group->scanIndex];
			{
				TCHAR * name=NULL;
				if(savedInfo[savedInfoCount-1].contact.szText)
				{
					name=mir_strdupT(savedInfo[savedInfoCount-1].contact.szText);
					mir_free(savedInfo[savedInfoCount-1].contact.szText);
					savedInfo[savedInfoCount-1].contact.szText=name;
					group->contact[group->scanIndex].szText=NULL;
				}
			}
		}
		group->scanIndex++;
	}

	FreeGroup(&dat->list);
	RebuildEntireList(hwnd,dat);

	group=&dat->list;
	group->scanIndex=0;
	for(;;) {
		if(group->scanIndex==group->contactCount) {
			group=group->parent;
			if(group==NULL) break;
		}
		else if(group->contact[group->scanIndex].type==CLCIT_GROUP) {
			group=group->contact[group->scanIndex].group;
			group->scanIndex=0;
			for(i=0;i<savedGroupCount;i++)
				if(savedGroup[i].groupId==group->groupId) {
					group->expanded=savedGroup[i].expanded;
					break;
				}
			continue;
		}
		else if(group->contact[group->scanIndex].type==CLCIT_CONTACT) {
			for(i=0;i<savedContactCount;i++)
				if(savedContact[i].hContact==group->contact[group->scanIndex].hContact) {
					CopyMemory(group->contact[group->scanIndex].iExtraImage,savedContact[i].iExtraImage,sizeof(group->contact[group->scanIndex].iExtraImage));
					if(savedContact[i].checked) group->contact[group->scanIndex].flags|=CONTACTF_CHECKED;
					break;	
				}
			if (group->contact[group->scanIndex].SubAllocated>0)
			{
				int l;
				for (l=0; l<group->contact[group->scanIndex].SubAllocated; l++)
					for(i=0;i<savedContactCount;i++)
						if(savedContact[i].hContact==group->contact[group->scanIndex].subcontacts[l].hContact) {

							CopyMemory(group->contact[group->scanIndex].subcontacts[l].iExtraImage,savedContact[i].iExtraImage,sizeof(group->contact[group->scanIndex].iExtraImage));
							if(savedContact[i].checked) group->contact[group->scanIndex].subcontacts[l].flags|=CONTACTF_CHECKED;
                            group->contact[group->scanIndex].subcontacts[l].subcontacts=&(group->contact[group->scanIndex]);
							break;	
						}	
			}
		}
		group->scanIndex++;
	}
	if(savedGroup) mir_free(savedGroup);
	if(savedContact) mir_free(savedContact);
	for(i=0;i<savedInfoCount;i++) {
		if(savedInfo[i].parentId==-1) group=&dat->list;
		else {
			if(!FindItem(hwnd,dat,(HANDLE)(savedInfo[i].parentId|HCONTACT_ISGROUP),&contact,NULL,NULL,TRUE)) continue;
			group=contact->group;
		}
		j=AddInfoItemToGroup(group,savedInfo[i].contact.flags,NULL);
		group->contact[j]=savedInfo[i].contact;
	}
	if(savedInfo) mir_free(savedInfo);
	RecalculateGroupCheckboxes(hwnd,dat);

	RecalcScrollBar(hwnd,dat);
	nm.hdr.code=CLN_LISTREBUILT;
	nm.hdr.hwndFrom=hwnd;
	nm.hdr.idFrom=GetDlgCtrlID(hwnd);


	//srand(GetTickCount());
	
	tick=GetTickCount()-tick;
#ifdef _DEBUG
	{
	char buf[255];
	sprintf(buf,"SaveStateAndRebuildList %d \r\n",tick);
	TRACE(buf);
	}	
#endif

	ClearRowByIndexCache();
       // SetAllExtraIcons(hwnd,0);
	SendMessage(GetParent(hwnd),WM_NOTIFY,0,(LPARAM)&nm);
}